Commit 8c60b801 authored by psolanki@apple.com's avatar psolanki@apple.com

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):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154766 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ed8925fb
2013-08-28 Pratik Solanki <psolanki@apple.com>
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 <rniwa@webkit.org>
REGRESSION(r154586): Past names map should only be used when named item is empty
......@@ -1423,9 +1423,9 @@ void CSSParser::parseSelector(const String& string, CSSSelectorList& selectorLis
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)
......
......@@ -366,7 +366,7 @@ void InlineCSSStyleDeclaration::didMutate(MutationType type)
CSSStyleSheet* InlineCSSStyleDeclaration::parentStyleSheet() const
{
return m_parentElement ? m_parentElement->document()->elementSheet() : 0;
return m_parentElement ? &m_parentElement->document()->elementSheet() : 0;
}
} // namespace WebCore
......@@ -593,8 +593,8 @@ Document::~Document()
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 @@ void Document::recalcStyle(Style::Change change)
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 @@ void Document::updateBaseURL()
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 @@ void Document::didRemoveAllPendingStylesheet()
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)
......
......@@ -597,7 +597,7 @@ public:
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 @@ private:
RefPtr<DocumentType> m_docType;
OwnPtr<DOMImplementation> m_implementation;
RefPtr<CSSStyleSheet> m_elemSheet;
RefPtr<CSSStyleSheet> m_elementSheet;
bool m_printing;
bool m_paginatedForScreen;
......
......@@ -195,7 +195,7 @@ inline void StyledElement::setInlineStyleFromString(const AtomicString& newStyle
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, double valu
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::removeAllInlineStyleProperties()
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(MutableStyleProperty
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());
}
}
......@@ -1548,7 +1548,7 @@ bool InspectorStyleSheetForInlineStyle::getStyleAttributeRanges(CSSRuleSourceDat
}
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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment