Diff
Modified: trunk/Source/WebCore/ChangeLog (99594 => 99595)
--- trunk/Source/WebCore/ChangeLog 2011-11-08 18:39:49 UTC (rev 99594)
+++ trunk/Source/WebCore/ChangeLog 2011-11-08 19:04:43 UTC (rev 99595)
@@ -1,3 +1,43 @@
+2011-11-08 Roland Steiner <rolandstei...@chromium.org>
+
+ Rename CSS document() -> findDocument(), to indicate tree climbing
+ https://bugs.webkit.org/show_bug.cgi?id=71764
+
+ Renamed document() to findDocument(), styleSheetOwnerNode() to findStyleSheetOwnerNode().
+
+ Reviewed by Darin Adler.
+
+ No new tests. (simple refactoring)
+
+ * css/CSSGrammar.y:
+ * css/CSSImportRule.cpp:
+ (WebCore::CSSImportRule::setCSSStyleSheet):
+ (WebCore::CSSImportRule::requestStyleSheet):
+ * css/CSSMutableStyleDeclaration.cpp:
+ (WebCore::CSSMutableStyleDeclaration::setNeedsStyleRecalc):
+ * css/CSSParser.cpp:
+ (WebCore::parseColorValue):
+ (WebCore::parseSimpleLengthValue):
+ (WebCore::CSSParser::setStyleSheet):
+ (WebCore::CSSParser::findDocument):
+ (WebCore::CSSParser::parseAttr):
+ * css/CSSParser.h:
+ * css/CSSStyleRule.cpp:
+ (WebCore::CSSStyleRule::setSelectorText):
+ * css/CSSStyleSheet.cpp:
+ (WebCore::CSSStyleSheet::cssRules):
+ (WebCore::CSSStyleSheet::findStyleSheetOwnerNode):
+ (WebCore::CSSStyleSheet::findDocument):
+ (WebCore::CSSStyleSheet::styleSheetChanged):
+ * css/CSSStyleSheet.h:
+ * inspector/InspectorCSSAgent.cpp:
+ (WebCore::InspectorCSSAgent::bindStyleSheet):
+ * inspector/InspectorStyleSheet.cpp:
+ (WebCore::InspectorStyleSheet::ownerDocument):
+ * page/PageSerializer.cpp:
+ (WebCore::PageSerializer::serializeCSSStyleSheet):
+ (WebCore::PageSerializer::retrieveResourcesForCSSDeclaration):
+
2011-11-07 Ryosuke Niwa <rn...@webkit.org>
Indent command can insert block quote in non editable content
Modified: trunk/Source/WebCore/css/CSSGrammar.y (99594 => 99595)
--- trunk/Source/WebCore/css/CSSGrammar.y 2011-11-08 18:39:49 UTC (rev 99594)
+++ trunk/Source/WebCore/css/CSSGrammar.y 2011-11-08 19:04:43 UTC (rev 99595)
@@ -985,7 +985,7 @@
IDENT {
CSSParserString& str = $1;
CSSParser* p = static_cast<CSSParser*>(parser);
- Document* doc = p->document();
+ Document* doc = p->findDocument();
if (doc && doc->isHTMLDocument())
str.lower();
$$ = str;
@@ -1053,7 +1053,7 @@
IDENT maybe_space {
CSSParserString& str = $1;
CSSParser* p = static_cast<CSSParser*>(parser);
- Document* doc = p->document();
+ Document* doc = p->findDocument();
if (doc && doc->isHTMLDocument())
str.lower();
$$ = str;
@@ -1465,7 +1465,7 @@
$$.fValue = $1;
$$.unit = CSSPrimitiveValue::CSS_REMS;
CSSParser* p = static_cast<CSSParser*>(parser);
- if (Document* doc = p->document())
+ if (Document* doc = p->findDocument())
doc->setUsesRemUnits(true);
}
;
Modified: trunk/Source/WebCore/css/CSSImportRule.cpp (99594 => 99595)
--- trunk/Source/WebCore/css/CSSImportRule.cpp 2011-11-08 18:39:49 UTC (rev 99594)
+++ trunk/Source/WebCore/css/CSSImportRule.cpp 2011-11-08 19:04:43 UTC (rev 99595)
@@ -66,7 +66,8 @@
CSSStyleSheet* parent = parentStyleSheet();
bool strict = !parent || parent->useStrictParsing();
bool enforceMIMEType = strict;
- bool needsSiteSpecificQuirks = parent && parent->document() && parent->document()->settings() && parent->document()->settings()->needsSiteSpecificQuirks();
+ Document* document = parent ? parent->findDocument() : 0;
+ bool needsSiteSpecificQuirks = document && document->settings() && document->settings()->needsSiteSpecificQuirks();
#ifdef BUILDING_ON_LEOPARD
if (enforceMIMEType && needsSiteSpecificQuirks) {
@@ -79,7 +80,7 @@
String sheetText = sheet->sheetText(enforceMIMEType, &validMIMEType);
m_styleSheet->parseString(sheetText, strict);
- if (!parent || !parent->document() || !parent->document()->securityOrigin()->canRequest(baseURL))
+ if (!document || !document->securityOrigin()->canRequest(baseURL))
crossOriginCSS = true;
if (crossOriginCSS && !validMIMEType && !m_styleSheet->hasSyntacticallyValidCSSHeader())
@@ -113,10 +114,13 @@
void CSSImportRule::requestStyleSheet()
{
CSSStyleSheet* parentSheet = parentStyleSheet();
- if (!parentSheet || !parentSheet->document())
+ if (!parentSheet)
return;
+ Document* document = parentSheet->findDocument();
+ if (!document)
+ return;
- CachedResourceLoader* cachedResourceLoader = parentSheet->document()->cachedResourceLoader();
+ CachedResourceLoader* cachedResourceLoader = document->cachedResourceLoader();
if (!cachedResourceLoader)
return;
@@ -135,7 +139,7 @@
rootSheet = sheet;
}
- ResourceRequest request(parentSheet->document()->completeURL(absHref));
+ ResourceRequest request(document->completeURL(absHref));
if (parentSheet->isUserStyleSheet())
m_cachedSheet = cachedResourceLoader->requestUserCSSStyleSheet(request, parentSheet->charset());
else
Modified: trunk/Source/WebCore/css/CSSMutableStyleDeclaration.cpp (99594 => 99595)
--- trunk/Source/WebCore/css/CSSMutableStyleDeclaration.cpp 2011-11-08 18:39:49 UTC (rev 99594)
+++ trunk/Source/WebCore/css/CSSMutableStyleDeclaration.cpp 2011-11-08 19:04:43 UTC (rev 99595)
@@ -521,7 +521,7 @@
}
if (CSSStyleSheet* styleSheet = parentStyleSheet()) {
- if (Document* document = styleSheet->document())
+ if (Document* document = styleSheet->findDocument())
document->styleSelectorChanged(DeferRecalcStyle);
}
}
Modified: trunk/Source/WebCore/css/CSSParser.cpp (99594 => 99595)
--- trunk/Source/WebCore/css/CSSParser.cpp 2011-11-08 18:39:49 UTC (rev 99594)
+++ trunk/Source/WebCore/css/CSSParser.cpp 2011-11-08 19:04:43 UTC (rev 99595)
@@ -343,17 +343,20 @@
}
CSSStyleSheet* styleSheet = declaration->parentStyleSheet();
- if (!styleSheet || !styleSheet->document())
+ if (!styleSheet)
return false;
+ Document* document = styleSheet->findDocument();
+ if (!document)
+ return false;
if (validPrimitive) {
- CSSProperty property(propertyId, styleSheet->document()->cssPrimitiveValueCache()->createIdentifierValue(valueID), important);
+ CSSProperty property(propertyId, document->cssPrimitiveValueCache()->createIdentifierValue(valueID), important);
declaration->addParsedProperty(property);
return true;
}
RGBA32 color;
if (!CSSParser::parseColor(string, color, strict && string[0] != '#'))
return false;
- CSSProperty property(propertyId, styleSheet->document()->cssPrimitiveValueCache()->createColorValue(color), important);
+ CSSProperty property(propertyId, document->cssPrimitiveValueCache()->createColorValue(color), important);
declaration->addParsedProperty(property);
return true;
}
@@ -435,9 +438,12 @@
return false;
CSSStyleSheet* styleSheet = declaration->parentStyleSheet();
- if (!styleSheet || !styleSheet->document())
+ if (!styleSheet)
return false;
- CSSProperty property(propertyId, styleSheet->document()->cssPrimitiveValueCache()->createValue(number, unit), important);
+ Document* document = styleSheet->findDocument();
+ if (!document)
+ return false;
+ CSSProperty property(propertyId, document->cssPrimitiveValueCache()->createValue(number, unit), important);
declaration->addParsedProperty(property);
return true;
}
@@ -648,14 +654,15 @@
void CSSParser::setStyleSheet(CSSStyleSheet* styleSheet)
{
m_styleSheet = styleSheet;
- m_primitiveValueCache = document() ? document()->cssPrimitiveValueCache() : CSSPrimitiveValueCache::create();
+ Document* document = findDocument();
+ m_primitiveValueCache = document ? document->cssPrimitiveValueCache() : CSSPrimitiveValueCache::create();
}
-Document* CSSParser::document() const
+Document* CSSParser::findDocument() const
{
if (!m_styleSheet)
return 0;
- return m_styleSheet->document();
+ return m_styleSheet->findDocument();
}
bool CSSParser::validUnit(CSSParserValue* value, Units unitflags, bool strict)
@@ -2794,7 +2801,8 @@
if (attrName[0] == '-')
return 0;
- if (document() && document()->isHTMLDocument())
+ Document* document = findDocument();
+ if (document && document->isHTMLDocument())
attrName = attrName.lower();
return primitiveValueCache()->createValue(attrName, CSSPrimitiveValue::CSS_ATTR);
Modified: trunk/Source/WebCore/css/CSSParser.h (99594 => 99595)
--- trunk/Source/WebCore/css/CSSParser.h 2011-11-08 18:39:49 UTC (rev 99594)
+++ trunk/Source/WebCore/css/CSSParser.h 2011-11-08 19:04:43 UTC (rev 99595)
@@ -73,7 +73,7 @@
bool parseDeclaration(CSSMutableStyleDeclaration*, const String&, RefPtr<CSSStyleSourceData>* = 0, CSSStyleSheet* contextStyleSheet = 0);
bool parseMediaQuery(MediaList*, const String&);
- Document* document() const;
+ Document* findDocument() const;
CSSPrimitiveValueCache* primitiveValueCache() const { return m_primitiveValueCache.get(); }
Modified: trunk/Source/WebCore/css/CSSStyleRule.cpp (99594 => 99595)
--- trunk/Source/WebCore/css/CSSStyleRule.cpp 2011-11-08 18:39:49 UTC (rev 99594)
+++ trunk/Source/WebCore/css/CSSStyleRule.cpp 2011-11-08 19:04:43 UTC (rev 99595)
@@ -63,7 +63,7 @@
Document* doc = 0;
if (CSSStyleSheet* styleSheet = m_style->parentStyleSheet())
- doc = styleSheet->document();
+ doc = styleSheet->findDocument();
if (!doc)
doc = m_style->node() ? m_style->node()->document() : 0;
Modified: trunk/Source/WebCore/css/CSSStyleSheet.cpp (99594 => 99595)
--- trunk/Source/WebCore/css/CSSStyleSheet.cpp 2011-11-08 18:39:49 UTC (rev 99594)
+++ trunk/Source/WebCore/css/CSSStyleSheet.cpp 2011-11-08 19:04:43 UTC (rev 99595)
@@ -158,7 +158,8 @@
PassRefPtr<CSSRuleList> CSSStyleSheet::cssRules(bool omitCharsetRules)
{
KURL url = ""
- if (!url.isEmpty() && document() && !document()->securityOrigin()->canRequest(url))
+ Document* document = findDocument();
+ if (!url.isEmpty() && document && !document->securityOrigin()->canRequest(url))
return 0;
return CSSRuleList::create(this, omitCharsetRules);
}
@@ -245,7 +246,7 @@
owner->startLoadingDynamicSheet();
}
-Node* CSSStyleSheet::styleSheetOwnerNode() const
+Node* CSSStyleSheet::findStyleSheetOwnerNode() const
{
for (const CSSStyleSheet* sheet = this; sheet; sheet = sheet->parentStyleSheet()) {
if (Node* ownerNode = sheet->ownerNode())
@@ -254,14 +255,13 @@
return 0;
}
-Document* CSSStyleSheet::document()
+Document* CSSStyleSheet::findDocument()
{
- Node* ownerNode = styleSheetOwnerNode();
+ Node* ownerNode = findStyleSheetOwnerNode();
return ownerNode ? ownerNode->document() : 0;
}
-
void CSSStyleSheet::styleSheetChanged()
{
CSSStyleSheet* rootSheet = this;
@@ -272,7 +272,7 @@
* basically we just need to recreate the document's selector with the
* already existing style sheets.
*/
- if (Document* documentToUpdate = rootSheet->document())
+ if (Document* documentToUpdate = rootSheet->findDocument())
documentToUpdate->styleSelectorChanged(DeferRecalcStyle);
}
Modified: trunk/Source/WebCore/css/CSSStyleSheet.h (99594 => 99595)
--- trunk/Source/WebCore/css/CSSStyleSheet.h 2011-11-08 18:39:49 UTC (rev 99594)
+++ trunk/Source/WebCore/css/CSSStyleSheet.h 2011-11-08 19:04:43 UTC (rev 99595)
@@ -95,8 +95,8 @@
virtual void checkLoaded();
void startLoadingDynamicSheet();
- Node* styleSheetOwnerNode() const;
- Document* document();
+ Node* findStyleSheetOwnerNode() const;
+ Document* findDocument();
const String& charset() const { return m_charset; }
Modified: trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp (99594 => 99595)
--- trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp 2011-11-08 18:39:49 UTC (rev 99594)
+++ trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp 2011-11-08 19:04:43 UTC (rev 99595)
@@ -497,7 +497,8 @@
RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleSheetToInspectorStyleSheet.get(styleSheet);
if (!inspectorStyleSheet) {
String id = String::number(m_lastStyleSheetId++);
- inspectorStyleSheet = InspectorStyleSheet::create(id, styleSheet, detectOrigin(styleSheet, styleSheet->document()), m_domAgent->documentURLString(styleSheet->document()));
+ Document* document = styleSheet->findDocument();
+ inspectorStyleSheet = InspectorStyleSheet::create(id, styleSheet, detectOrigin(styleSheet, document), m_domAgent->documentURLString(document));
m_idToInspectorStyleSheet.set(id, inspectorStyleSheet);
m_cssStyleSheetToInspectorStyleSheet.set(styleSheet, inspectorStyleSheet);
}
Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp (99594 => 99595)
--- trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp 2011-11-08 18:39:49 UTC (rev 99594)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp 2011-11-08 19:04:43 UTC (rev 99595)
@@ -829,7 +829,7 @@
Document* InspectorStyleSheet::ownerDocument() const
{
- return m_pageStyleSheet->document();
+ return m_pageStyleSheet->findDocument();
}
RefPtr<CSSRuleSourceData> InspectorStyleSheet::ruleSourceDataFor(CSSStyleDeclaration* style) const
Modified: trunk/Source/WebCore/page/PageSerializer.cpp (99594 => 99595)
--- trunk/Source/WebCore/page/PageSerializer.cpp 2011-11-08 18:39:49 UTC (rev 99594)
+++ trunk/Source/WebCore/page/PageSerializer.cpp 2011-11-08 19:04:43 UTC (rev 99595)
@@ -264,7 +264,8 @@
// Some rules have resources associated with them that we need to retrieve.
if (rule->isImportRule()) {
CSSImportRule* importRule = static_cast<CSSImportRule*>(rule);
- KURL importURL = styleSheet->document()->completeURL(importRule->href());
+ Document* document = styleSheet->findDocument();
+ KURL importURL = document->completeURL(importRule->href());
if (m_resourceURLs.contains(importURL))
continue;
serializeCSSStyleSheet(importRule->styleSheet(), importURL);
@@ -332,7 +333,8 @@
CachedImage* image = static_cast<StyleCachedImage*>(styleImage)->cachedImage();
- KURL url = ""
+ Document* document = cssStyleSheet->findDocument();
+ KURL url = ""
addImageToResources(image, 0, url);
}
}