diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-07 11:21:11 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-07 11:21:11 +0200 |
commit | 2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47 (patch) | |
tree | 988e8c5b116dd0466244ae2fe5af8ee9be926d76 /Source/WebCore/css/CSSStyleRule.cpp | |
parent | dd91e772430dc294e3bf478c119ef8d43c0a3358 (diff) | |
download | qtwebkit-2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47.tar.gz |
Imported WebKit commit 7e538425aa020340619e927792f3d895061fb54b (http://svn.webkit.org/repository/webkit/trunk@116286)
Diffstat (limited to 'Source/WebCore/css/CSSStyleRule.cpp')
-rw-r--r-- | Source/WebCore/css/CSSStyleRule.cpp | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/Source/WebCore/css/CSSStyleRule.cpp b/Source/WebCore/css/CSSStyleRule.cpp index 65da867c5..7357fcf22 100644 --- a/Source/WebCore/css/CSSStyleRule.cpp +++ b/Source/WebCore/css/CSSStyleRule.cpp @@ -26,30 +26,13 @@ #include "CSSSelector.h" #include "CSSStyleSheet.h" #include "Document.h" +#include "PropertySetCSSStyleDeclaration.h" #include "StylePropertySet.h" #include "StyleRule.h" #include <wtf/text/StringBuilder.h> namespace WebCore { -CSSStyleRule::CSSStyleRule(CSSStyleSheet* parent, int line) - : CSSRule(parent, CSSRule::STYLE_RULE) - , m_styleRule(adoptPtr(new StyleRule(line, this))) -{ -} - -CSSStyleRule::~CSSStyleRule() -{ - if (m_styleRule->properties()) - m_styleRule->properties()->clearParentRule(this); - cleanup(); -} - -CSSStyleDeclaration* CSSStyleRule::style() const -{ - return m_styleRule->properties()->ensureRuleCSSStyleDeclaration(this); -} - typedef HashMap<const CSSStyleRule*, String> SelectorTextCache; static SelectorTextCache& selectorTextCache() { @@ -57,14 +40,30 @@ static SelectorTextCache& selectorTextCache() return cache; } -inline void CSSStyleRule::cleanup() +CSSStyleRule::CSSStyleRule(StyleRule* styleRule, CSSStyleSheet* parent) + : CSSRule(parent, CSSRule::STYLE_RULE) + , m_styleRule(styleRule) +{ +} + +CSSStyleRule::~CSSStyleRule() { + if (m_propertiesCSSOMWrapper) + m_propertiesCSSOMWrapper->clearParentRule(); + if (hasCachedSelectorText()) { selectorTextCache().remove(this); setHasCachedSelectorText(false); } } +CSSStyleDeclaration* CSSStyleRule::style() const +{ + if (!m_propertiesCSSOMWrapper) + m_propertiesCSSOMWrapper = StyleRuleCSSStyleDeclaration::create(m_styleRule->properties(), const_cast<CSSStyleRule*>(this)); + return m_propertiesCSSOMWrapper.get(); +} + String CSSStyleRule::generateSelectorText() const { StringBuilder builder; @@ -94,28 +93,25 @@ void CSSStyleRule::setSelectorText(const String& selectorText) { Document* doc = 0; if (CSSStyleSheet* styleSheet = parentStyleSheet()) - doc = styleSheet->findDocument(); + doc = styleSheet->ownerDocument(); if (!doc) return; - CSSParser p; + CSSParser p(parserContext()); CSSSelectorList selectorList; - p.parseSelector(selectorText, doc, selectorList); + p.parseSelector(selectorText, selectorList); if (!selectorList.first()) return; String oldSelectorText = this->selectorText(); - m_styleRule->adoptSelectorList(selectorList); + m_styleRule->wrapperAdoptSelectorList(selectorList); if (hasCachedSelectorText()) { ASSERT(selectorTextCache().contains(this)); selectorTextCache().set(this, generateSelectorText()); } - if (this->selectorText() == oldSelectorText) - return; - - doc->styleSelectorChanged(DeferRecalcStyle); + doc->styleResolverChanged(DeferRecalcStyle); } String CSSStyleRule::cssText() const |