diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/css/CSSStyleRule.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/css/CSSStyleRule.cpp')
-rw-r--r-- | Source/WebCore/css/CSSStyleRule.cpp | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/Source/WebCore/css/CSSStyleRule.cpp b/Source/WebCore/css/CSSStyleRule.cpp index 23fc473c0..e0e30d00f 100644 --- a/Source/WebCore/css/CSSStyleRule.cpp +++ b/Source/WebCore/css/CSSStyleRule.cpp @@ -30,6 +30,7 @@ #include "RuleSet.h" #include "StyleProperties.h" #include "StyleRule.h" +#include <wtf/NeverDestroyed.h> #include <wtf/text/StringBuilder.h> namespace WebCore { @@ -37,11 +38,11 @@ namespace WebCore { typedef HashMap<const CSSStyleRule*, String> SelectorTextCache; static SelectorTextCache& selectorTextCache() { - DEFINE_STATIC_LOCAL(SelectorTextCache, cache, ()); + static NeverDestroyed<SelectorTextCache> cache; return cache; } -CSSStyleRule::CSSStyleRule(StyleRule* styleRule, CSSStyleSheet* parent) +CSSStyleRule::CSSStyleRule(StyleRule& styleRule, CSSStyleSheet* parent) : CSSRule(parent) , m_styleRule(styleRule) { @@ -58,23 +59,16 @@ CSSStyleRule::~CSSStyleRule() } } -CSSStyleDeclaration* CSSStyleRule::style() +CSSStyleDeclaration& CSSStyleRule::style() { - if (!m_propertiesCSSOMWrapper) { + if (!m_propertiesCSSOMWrapper) m_propertiesCSSOMWrapper = StyleRuleCSSStyleDeclaration::create(m_styleRule->mutableProperties(), *this); - } - return m_propertiesCSSOMWrapper.get(); + return *m_propertiesCSSOMWrapper; } String CSSStyleRule::generateSelectorText() const { - StringBuilder builder; - for (const CSSSelector* selector = m_styleRule->selectorList().first(); selector; selector = CSSSelectorList::next(selector)) { - if (selector != m_styleRule->selectorList().first()) - builder.appendLiteral(", "); - builder.append(selector->selectorText()); - } - return builder.toString(); + return m_styleRule->selectorList().selectorsText(); } String CSSStyleRule::selectorText() const @@ -131,11 +125,9 @@ String CSSStyleRule::cssText() const return result.toString(); } -void CSSStyleRule::reattach(StyleRuleBase* rule) +void CSSStyleRule::reattach(StyleRuleBase& rule) { - ASSERT(rule); - ASSERT_WITH_SECURITY_IMPLICATION(rule->isStyleRule()); - m_styleRule = static_cast<StyleRule*>(rule); + m_styleRule = downcast<StyleRule>(rule); if (m_propertiesCSSOMWrapper) m_propertiesCSSOMWrapper->reattach(m_styleRule->mutableProperties()); } |