Title: [154766] trunk/Source/WebCore
Revision
154766
Author
[email protected]
Date
2013-08-28 12:24:50 -0700 (Wed, 28 Aug 2013)

Log Message

Document::elementSheet() should return a reference
https://bugs.webkit.org/show_bug.cgi?id=120433

Reviewed by Andreas Kling.

Since elementSheet() always retruns a valid pointer, we can simply return a reference
instead. Also rename m_elemSheet to m_elementSheet.

* css/CSSParser.cpp:
(WebCore::CSSParser::parseInlineStyleDeclaration):
* css/PropertySetCSSStyleDeclaration.cpp:
(WebCore::InlineCSSStyleDeclaration::parentStyleSheet):
* dom/Document.cpp:
(WebCore::Document::~Document):
(WebCore::Document::recalcStyle):
(WebCore::Document::updateBaseURL):
(WebCore::Document::elementSheet):
* dom/Document.h:
* dom/StyledElement.cpp:
(WebCore::StyledElement::setInlineStyleFromString):
(WebCore::StyledElement::setInlineStyleProperty):
(WebCore::StyledElement::addSubresourceAttributeURLs):
(WebCore::StyledElement::addPropertyToPresentationAttributeStyle):
* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyleSheetForInlineStyle::getStyleAttributeRanges):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (154765 => 154766)


--- trunk/Source/WebCore/ChangeLog	2013-08-28 19:00:01 UTC (rev 154765)
+++ trunk/Source/WebCore/ChangeLog	2013-08-28 19:24:50 UTC (rev 154766)
@@ -1,3 +1,31 @@
+2013-08-28  Pratik Solanki  <[email protected]>
+
+        Document::elementSheet() should return a reference
+        https://bugs.webkit.org/show_bug.cgi?id=120433
+
+        Reviewed by Andreas Kling.
+
+        Since elementSheet() always retruns a valid pointer, we can simply return a reference
+        instead. Also rename m_elemSheet to m_elementSheet.
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseInlineStyleDeclaration):
+        * css/PropertySetCSSStyleDeclaration.cpp:
+        (WebCore::InlineCSSStyleDeclaration::parentStyleSheet):
+        * dom/Document.cpp:
+        (WebCore::Document::~Document):
+        (WebCore::Document::recalcStyle):
+        (WebCore::Document::updateBaseURL):
+        (WebCore::Document::elementSheet):
+        * dom/Document.h:
+        * dom/StyledElement.cpp:
+        (WebCore::StyledElement::setInlineStyleFromString):
+        (WebCore::StyledElement::setInlineStyleProperty):
+        (WebCore::StyledElement::addSubresourceAttributeURLs):
+        (WebCore::StyledElement::addPropertyToPresentationAttributeStyle):
+        * inspector/InspectorStyleSheet.cpp:
+        (WebCore::InspectorStyleSheetForInlineStyle::getStyleAttributeRanges):
+
 2013-08-28  Ryosuke Niwa  <[email protected]>
 
         REGRESSION(r154586): Past names map should only be used when named item is empty

Modified: trunk/Source/WebCore/css/CSSParser.cpp (154765 => 154766)


--- trunk/Source/WebCore/css/CSSParser.cpp	2013-08-28 19:00:01 UTC (rev 154765)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2013-08-28 19:24:50 UTC (rev 154766)
@@ -1423,9 +1423,9 @@
 
 PassRefPtr<ImmutableStylePropertySet> CSSParser::parseInlineStyleDeclaration(const String& string, Element* element)
 {
-    CSSParserContext context = element->document()->elementSheet()->contents()->parserContext();
+    CSSParserContext context = element->document()->elementSheet().contents()->parserContext();
     context.mode = strictToCSSParserMode(element->isHTMLElement() && !element->document()->inQuirksMode());
-    return CSSParser(context).parseDeclaration(string, element->document()->elementSheet()->contents());
+    return CSSParser(context).parseDeclaration(string, element->document()->elementSheet().contents());
 }
 
 PassRefPtr<ImmutableStylePropertySet> CSSParser::parseDeclaration(const String& string, StyleSheetContents* contextStyleSheet)

Modified: trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp (154765 => 154766)


--- trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp	2013-08-28 19:00:01 UTC (rev 154765)
+++ trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp	2013-08-28 19:24:50 UTC (rev 154766)
@@ -366,7 +366,7 @@
 
 CSSStyleSheet* InlineCSSStyleDeclaration::parentStyleSheet() const
 {
-    return m_parentElement ? m_parentElement->document()->elementSheet() : 0;
+    return m_parentElement ? &m_parentElement->document()->elementSheet() : 0;
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/dom/Document.cpp (154765 => 154766)


--- trunk/Source/WebCore/dom/Document.cpp	2013-08-28 19:00:01 UTC (rev 154765)
+++ trunk/Source/WebCore/dom/Document.cpp	2013-08-28 19:24:50 UTC (rev 154766)
@@ -593,8 +593,8 @@
 
     m_styleSheetCollection.clear();
 
-    if (m_elemSheet)
-        m_elemSheet->clearOwnerNode();
+    if (m_elementSheet)
+        m_elementSheet->clearOwnerNode();
 
     clearStyleResolver(); // We need to destroy CSSFontSelector before destroying m_cachedResourceLoader.
 
@@ -1753,7 +1753,7 @@
 
     InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalculateStyle(this);
 
-    if (m_elemSheet && m_elemSheet->contents()->usesRemUnits())
+    if (m_elementSheet && m_elementSheet->contents()->usesRemUnits())
         m_styleSheetCollection->setUsesRemUnit(true);
 
     m_inStyleRecalc = true;
@@ -2647,13 +2647,13 @@
     if (!m_baseURL.isValid())
         m_baseURL = KURL();
 
-    if (m_elemSheet) {
+    if (m_elementSheet) {
         // Element sheet is silly. It never contains anything.
-        ASSERT(!m_elemSheet->contents()->ruleCount());
-        bool usesRemUnits = m_elemSheet->contents()->usesRemUnits();
-        m_elemSheet = CSSStyleSheet::createInline(this, m_baseURL);
+        ASSERT(!m_elementSheet->contents()->ruleCount());
+        bool usesRemUnits = m_elementSheet->contents()->usesRemUnits();
+        m_elementSheet = CSSStyleSheet::createInline(this, m_baseURL);
         // FIXME: So we are not really the parser. The right fix is to eliminate the element sheet completely.
-        m_elemSheet->contents()->parserSetUsesRemUnits(usesRemUnits);
+        m_elementSheet->contents()->parserSetUsesRemUnits(usesRemUnits);
     }
 
     if (!equalIgnoringFragmentIdentifier(oldBaseURL, m_baseURL)) {
@@ -2814,11 +2814,11 @@
         view()->scrollToFragment(m_url);
 }
 
-CSSStyleSheet* Document::elementSheet()
+CSSStyleSheet& Document::elementSheet()
 {
-    if (!m_elemSheet)
-        m_elemSheet = CSSStyleSheet::createInline(this, m_baseURL);
-    return m_elemSheet.get();
+    if (!m_elementSheet)
+        m_elementSheet = CSSStyleSheet::createInline(this, m_baseURL);
+    return *m_elementSheet;
 }
 
 void Document::processHttpEquiv(const String& equiv, const String& content)

Modified: trunk/Source/WebCore/dom/Document.h (154765 => 154766)


--- trunk/Source/WebCore/dom/Document.h	2013-08-28 19:00:01 UTC (rev 154765)
+++ trunk/Source/WebCore/dom/Document.h	2013-08-28 19:24:50 UTC (rev 154766)
@@ -597,7 +597,7 @@
     bool canNavigate(Frame* targetFrame);
     Frame* findUnsafeParentScrollPropagationBoundary();
 
-    CSSStyleSheet* elementSheet();
+    CSSStyleSheet& elementSheet();
     
     virtual PassRefPtr<DocumentParser> createParser();
     DocumentParser* parser() const { return m_parser.get(); }
@@ -1316,7 +1316,7 @@
     RefPtr<DocumentType> m_docType;
     OwnPtr<DOMImplementation> m_implementation;
 
-    RefPtr<CSSStyleSheet> m_elemSheet;
+    RefPtr<CSSStyleSheet> m_elementSheet;
 
     bool m_printing;
     bool m_paginatedForScreen;

Modified: trunk/Source/WebCore/dom/StyledElement.cpp (154765 => 154766)


--- trunk/Source/WebCore/dom/StyledElement.cpp	2013-08-28 19:00:01 UTC (rev 154765)
+++ trunk/Source/WebCore/dom/StyledElement.cpp	2013-08-28 19:24:50 UTC (rev 154766)
@@ -195,7 +195,7 @@
         inlineStyle = CSSParser::parseInlineStyleDeclaration(newStyleString, this);
     else {
         ASSERT(inlineStyle->isMutable());
-        static_pointer_cast<MutableStylePropertySet>(inlineStyle)->parseDeclaration(newStyleString, document()->elementSheet()->contents());
+        static_pointer_cast<MutableStylePropertySet>(inlineStyle)->parseDeclaration(newStyleString, document()->elementSheet().contents());
     }
 }
 
@@ -249,7 +249,7 @@
 
 bool StyledElement::setInlineStyleProperty(CSSPropertyID propertyID, const String& value, bool important)
 {
-    bool changes = ensureMutableInlineStyle().setProperty(propertyID, value, important, document()->elementSheet()->contents());
+    bool changes = ensureMutableInlineStyle().setProperty(propertyID, value, important, document()->elementSheet().contents());
     if (changes)
         inlineStyleChanged();
     return changes;
@@ -276,7 +276,7 @@
 void StyledElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
 {
     if (const StylePropertySet* inlineStyle = elementData() ? elementData()->inlineStyle() : 0)
-        inlineStyle->addSubresourceStyleURLs(urls, document()->elementSheet()->contents());
+        inlineStyle->addSubresourceStyleURLs(urls, document()->elementSheet().contents());
 }
 
 static inline bool attributeNameSort(const pair<AtomicStringImpl*, AtomicString>& p1, const pair<AtomicStringImpl*, AtomicString>& p2)
@@ -384,7 +384,7 @@
     
 void StyledElement::addPropertyToPresentationAttributeStyle(MutableStylePropertySet* style, CSSPropertyID propertyID, const String& value)
 {
-    style->setProperty(propertyID, value, false, document()->elementSheet()->contents());
+    style->setProperty(propertyID, value, false, document()->elementSheet().contents());
 }
 
 }

Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp (154765 => 154766)


--- trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp	2013-08-28 19:00:01 UTC (rev 154765)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp	2013-08-28 19:24:50 UTC (rev 154766)
@@ -1548,7 +1548,7 @@
     }
 
     RefPtr<MutableStylePropertySet> tempDeclaration = MutableStylePropertySet::create();
-    createCSSParser(m_element->document())->parseDeclaration(tempDeclaration.get(), m_styleText, result, m_element->document()->elementSheet()->contents());
+    createCSSParser(m_element->document())->parseDeclaration(tempDeclaration.get(), m_styleText, result, m_element->document()->elementSheet().contents());
     return true;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to