| OLD | NEW |
| 1 /* | 1 /* |
| 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2002-2003 Dirk Mueller (mueller@kde.org) | 3 * (C) 2002-2003 Dirk Mueller (mueller@kde.org) |
| 4 * Copyright (C) 2002, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved. | 4 * Copyright (C) 2002, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "core/css/CSSKeyframesRule.h" | 26 #include "core/css/CSSKeyframesRule.h" |
| 27 #include "core/css/CSSMediaRule.h" | 27 #include "core/css/CSSMediaRule.h" |
| 28 #include "core/css/CSSNamespaceRule.h" | 28 #include "core/css/CSSNamespaceRule.h" |
| 29 #include "core/css/CSSPageRule.h" | 29 #include "core/css/CSSPageRule.h" |
| 30 #include "core/css/CSSStyleRule.h" | 30 #include "core/css/CSSStyleRule.h" |
| 31 #include "core/css/CSSSupportsRule.h" | 31 #include "core/css/CSSSupportsRule.h" |
| 32 #include "core/css/CSSViewportRule.h" | 32 #include "core/css/CSSViewportRule.h" |
| 33 #include "core/css/StyleRuleImport.h" | 33 #include "core/css/StyleRuleImport.h" |
| 34 #include "core/css/StyleRuleKeyframe.h" | 34 #include "core/css/StyleRuleKeyframe.h" |
| 35 #include "core/css/StyleRuleNamespace.h" | 35 #include "core/css/StyleRuleNamespace.h" |
| 36 #include "core/css/parser/CSSParserImpl.h" |
| 36 | 37 |
| 37 namespace blink { | 38 namespace blink { |
| 38 | 39 |
| 39 struct SameSizeAsStyleRuleBase : public GarbageCollectedFinalized<SameSizeAsStyl
eRuleBase> { | 40 struct SameSizeAsStyleRuleBase : public GarbageCollectedFinalized<SameSizeAsStyl
eRuleBase> { |
| 40 unsigned bitfields; | 41 unsigned bitfields; |
| 41 }; | 42 }; |
| 42 | 43 |
| 43 static_assert(sizeof(StyleRuleBase) <= sizeof(SameSizeAsStyleRuleBase), "StyleRu
leBase should stay small"); | 44 static_assert(sizeof(StyleRuleBase) <= sizeof(SameSizeAsStyleRuleBase), "StyleRu
leBase should stay small"); |
| 44 | 45 |
| 45 CSSRule* StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet) const | 46 CSSRule* StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet) const |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 return sizeof(StyleRule) + sizeof(CSSSelector) + StylePropertySet::averageSi
zeInBytes(); | 211 return sizeof(StyleRule) + sizeof(CSSSelector) + StylePropertySet::averageSi
zeInBytes(); |
| 211 } | 212 } |
| 212 | 213 |
| 213 StyleRule::StyleRule(CSSSelectorList selectorList, StylePropertySet* properties) | 214 StyleRule::StyleRule(CSSSelectorList selectorList, StylePropertySet* properties) |
| 214 : StyleRuleBase(Style) | 215 : StyleRuleBase(Style) |
| 215 , m_properties(properties) | 216 , m_properties(properties) |
| 216 { | 217 { |
| 217 m_selectorList = std::move(selectorList); | 218 m_selectorList = std::move(selectorList); |
| 218 } | 219 } |
| 219 | 220 |
| 221 const StylePropertySet& StyleRule::properties() const |
| 222 { |
| 223 if (!m_properties) { |
| 224 m_properties = CSSParserImpl::parseDeclarationListForLazyStyle(m_lazyTok
ens, *m_context); |
| 225 m_lazyTokens.clear(); |
| 226 } |
| 227 return *m_properties; |
| 228 } |
| 229 |
| 230 StyleRule::StyleRule(CSSSelectorList selectorList, CSSParserTokenRange block, co
nst CSSParserContext* context) |
| 231 : StyleRuleBase(Style) |
| 232 , m_selectorList(std::move(selectorList)) |
| 233 , m_properties(nullptr) |
| 234 , m_context(context) |
| 235 { |
| 236 while (!block.atEnd()) { |
| 237 m_lazyTokens.append(block.consume()); |
| 238 } |
| 239 } |
| 240 |
| 220 StyleRule::StyleRule(const StyleRule& o) | 241 StyleRule::StyleRule(const StyleRule& o) |
| 221 : StyleRuleBase(o) | 242 : StyleRuleBase(o) |
| 222 , m_properties(o.m_properties->mutableCopy()) | |
| 223 , m_selectorList(o.m_selectorList.copy()) | 243 , m_selectorList(o.m_selectorList.copy()) |
| 244 , m_properties(o.properties().mutableCopy()) |
| 224 { | 245 { |
| 225 } | 246 } |
| 226 | 247 |
| 227 StyleRule::~StyleRule() | 248 StyleRule::~StyleRule() |
| 228 { | 249 { |
| 229 } | 250 } |
| 230 | 251 |
| 231 MutableStylePropertySet& StyleRule::mutableProperties() | 252 MutableStylePropertySet& StyleRule::mutableProperties() |
| 232 { | 253 { |
| 233 if (!m_properties->isMutable()) | 254 const StylePropertySet& props = properties(); |
| 234 m_properties = m_properties->mutableCopy(); | 255 if (!props.isMutable()) |
| 256 m_properties = props.mutableCopy(); |
| 235 return *toMutableStylePropertySet(m_properties.get()); | 257 return *toMutableStylePropertySet(m_properties.get()); |
| 236 } | 258 } |
| 237 | 259 |
| 238 DEFINE_TRACE_AFTER_DISPATCH(StyleRule) | 260 DEFINE_TRACE_AFTER_DISPATCH(StyleRule) |
| 239 { | 261 { |
| 240 visitor->trace(m_properties); | 262 visitor->trace(m_properties); |
| 241 StyleRuleBase::traceAfterDispatch(visitor); | 263 StyleRuleBase::traceAfterDispatch(visitor); |
| 242 } | 264 } |
| 243 | 265 |
| 244 StyleRulePage::StyleRulePage(CSSSelectorList selectorList, StylePropertySet* pro
perties) | 266 StyleRulePage::StyleRulePage(CSSSelectorList selectorList, StylePropertySet* pro
perties) |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 return *toMutableStylePropertySet(m_properties); | 409 return *toMutableStylePropertySet(m_properties); |
| 388 } | 410 } |
| 389 | 411 |
| 390 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleViewport) | 412 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleViewport) |
| 391 { | 413 { |
| 392 visitor->trace(m_properties); | 414 visitor->trace(m_properties); |
| 393 StyleRuleBase::traceAfterDispatch(visitor); | 415 StyleRuleBase::traceAfterDispatch(visitor); |
| 394 } | 416 } |
| 395 | 417 |
| 396 } // namespace blink | 418 } // namespace blink |
| OLD | NEW |