diff options
Diffstat (limited to 'Source/WebCore/css/CSSStyleRule.cpp')
-rw-r--r-- | Source/WebCore/css/CSSStyleRule.cpp | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/Source/WebCore/css/CSSStyleRule.cpp b/Source/WebCore/css/CSSStyleRule.cpp index 12e37e3b5..bfabe51ed 100644 --- a/Source/WebCore/css/CSSStyleRule.cpp +++ b/Source/WebCore/css/CSSStyleRule.cpp @@ -1,7 +1,7 @@ /* * (C) 1999-2003 Lars Knoll (knoll@kde.org) * (C) 2002-2003 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2002, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved. + * Copyright (C) 2002, 2005, 2006, 2008, 2012, 2013 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -27,9 +27,9 @@ #include "CSSStyleSheet.h" #include "Document.h" #include "PropertySetCSSStyleDeclaration.h" +#include "RuleSet.h" #include "StylePropertySet.h" #include "StyleRule.h" -#include "WebCoreMemoryInstrumentation.h" #include <wtf/text/StringBuilder.h> namespace WebCore { @@ -58,10 +58,10 @@ CSSStyleRule::~CSSStyleRule() } } -CSSStyleDeclaration* CSSStyleRule::style() const +CSSStyleDeclaration* CSSStyleRule::style() { if (!m_propertiesCSSOMWrapper) { - m_propertiesCSSOMWrapper = StyleRuleCSSStyleDeclaration::create(m_styleRule->mutableProperties(), const_cast<CSSStyleRule*>(this)); + m_propertiesCSSOMWrapper = StyleRuleCSSStyleDeclaration::create(m_styleRule->mutableProperties(), this); } return m_propertiesCSSOMWrapper.get(); } @@ -69,10 +69,10 @@ CSSStyleDeclaration* CSSStyleRule::style() const String CSSStyleRule::generateSelectorText() const { StringBuilder builder; - for (CSSSelector* s = m_styleRule->selectorList().first(); s; s = CSSSelectorList::next(s)) { - if (s != m_styleRule->selectorList().first()) - builder.append(", "); - builder.append(s->selectorText()); + 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(); } @@ -96,7 +96,11 @@ void CSSStyleRule::setSelectorText(const String& selectorText) CSSParser p(parserContext()); CSSSelectorList selectorList; p.parseSelector(selectorText, selectorList); - if (!selectorList.first()) + if (!selectorList.isValid()) + return; + + // NOTE: The selector list has to fit into RuleData. <http://webkit.org/b/118369> + if (selectorList.componentCount() > RuleData::maximumSelectorComponentCount) return; CSSStyleSheet::RuleMutationScope mutationScope(this); @@ -125,18 +129,10 @@ String CSSStyleRule::cssText() const void CSSStyleRule::reattach(StyleRuleBase* rule) { ASSERT(rule); - ASSERT(rule->isStyleRule()); + ASSERT_WITH_SECURITY_IMPLICATION(rule->isStyleRule()); m_styleRule = static_cast<StyleRule*>(rule); if (m_propertiesCSSOMWrapper) m_propertiesCSSOMWrapper->reattach(m_styleRule->mutableProperties()); } -void CSSStyleRule::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const -{ - MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); - CSSRule::reportMemoryUsage(memoryObjectInfo); - info.addMember(m_styleRule); - info.addMember(m_propertiesCSSOMWrapper); -} - } // namespace WebCore |