Chromium Code Reviews| 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 rule->setParentRule(parentRule); | 201 rule->setParentRule(parentRule); |
| 202 return rule; | 202 return rule; |
| 203 } | 203 } |
| 204 | 204 |
| 205 unsigned StyleRule::averageSizeInBytes() { | 205 unsigned StyleRule::averageSizeInBytes() { |
| 206 return sizeof(StyleRule) + sizeof(CSSSelector) + | 206 return sizeof(StyleRule) + sizeof(CSSSelector) + |
| 207 StylePropertySet::averageSizeInBytes(); | 207 StylePropertySet::averageSizeInBytes(); |
| 208 } | 208 } |
| 209 | 209 |
| 210 StyleRule::StyleRule(CSSSelectorList selectorList, StylePropertySet* properties) | 210 StyleRule::StyleRule(CSSSelectorList selectorList, StylePropertySet* properties) |
| 211 : StyleRuleBase(Style), m_properties(properties) { | 211 : StyleRuleBase(Style), |
| 212 m_selectorList = std::move(selectorList); | 212 m_selectorList(std::move(selectorList)), |
| 213 m_properties(properties) {} | |
| 214 | |
| 215 StyleRule::StyleRule(CSSSelectorList selectorList, | |
| 216 CSSLazyPropertyParser* lazyPropertyParser) | |
| 217 : StyleRuleBase(Style), | |
| 218 m_selectorList(std::move(selectorList)), | |
| 219 m_lazyPropertyParser(lazyPropertyParser) {} | |
| 220 | |
| 221 const StylePropertySet& StyleRule::properties() const { | |
| 222 if (!m_properties) { | |
| 223 m_properties = m_lazyPropertyParser->parseProperties(); | |
| 224 m_lazyPropertyParser.clear(); | |
| 225 } | |
| 226 return *m_properties; | |
| 213 } | 227 } |
| 214 | 228 |
| 215 StyleRule::StyleRule(const StyleRule& o) | 229 StyleRule::StyleRule(const StyleRule& o) |
| 216 : StyleRuleBase(o), | 230 : StyleRuleBase(o), |
| 217 m_properties(o.m_properties->mutableCopy()), | 231 m_selectorList(o.m_selectorList.copy()), |
| 218 m_selectorList(o.m_selectorList.copy()) {} | 232 m_properties(o.properties().mutableCopy()) {} |
| 219 | 233 |
| 220 StyleRule::~StyleRule() {} | 234 StyleRule::~StyleRule() {} |
| 221 | 235 |
| 222 MutableStylePropertySet& StyleRule::mutableProperties() { | 236 MutableStylePropertySet& StyleRule::mutableProperties() { |
| 223 if (!m_properties->isMutable()) | 237 // Ensure m_properties is initialized. |
| 238 if (!properties().isMutable()) | |
| 224 m_properties = m_properties->mutableCopy(); | 239 m_properties = m_properties->mutableCopy(); |
| 225 return *toMutableStylePropertySet(m_properties.get()); | 240 return *toMutableStylePropertySet(m_properties.get()); |
| 226 } | 241 } |
| 227 | 242 |
| 243 bool StyleRule::propertiesHaveFailedOrCanceledSubresources() const { | |
| 244 return m_properties && m_properties->hasFailedOrCanceledSubresources(); | |
| 245 } | |
| 246 | |
| 247 bool StyleRule::shouldConsiderForMatchingRules(bool includeEmptyRules) const { | |
| 248 // Consider all non-empty property sets if parsing has not been deferred. | |
| 249 // Otherwise, consider all StyleRules with non-null deferred closures. | |
| 250 return includeEmptyRules || !(m_properties && m_properties->isEmpty()); | |
|
esprehn
2016/10/24 21:20:20
run demorgans
includeEmptyRules || !m_properties
Charlie Harrison
2016/10/25 15:56:55
Done.
| |
| 251 } | |
| 252 | |
| 228 DEFINE_TRACE_AFTER_DISPATCH(StyleRule) { | 253 DEFINE_TRACE_AFTER_DISPATCH(StyleRule) { |
| 229 visitor->trace(m_properties); | 254 visitor->trace(m_properties); |
| 255 visitor->trace(m_lazyPropertyParser); | |
| 230 StyleRuleBase::traceAfterDispatch(visitor); | 256 StyleRuleBase::traceAfterDispatch(visitor); |
| 231 } | 257 } |
| 232 | 258 |
| 233 StyleRulePage::StyleRulePage(CSSSelectorList selectorList, | 259 StyleRulePage::StyleRulePage(CSSSelectorList selectorList, |
| 234 StylePropertySet* properties) | 260 StylePropertySet* properties) |
| 235 : StyleRuleBase(Page), | 261 : StyleRuleBase(Page), |
| 236 m_properties(properties), | 262 m_properties(properties), |
| 237 m_selectorList(std::move(selectorList)) {} | 263 m_selectorList(std::move(selectorList)) {} |
| 238 | 264 |
| 239 StyleRulePage::StyleRulePage(const StyleRulePage& o) | 265 StyleRulePage::StyleRulePage(const StyleRulePage& o) |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 m_properties = m_properties->mutableCopy(); | 364 m_properties = m_properties->mutableCopy(); |
| 339 return *toMutableStylePropertySet(m_properties); | 365 return *toMutableStylePropertySet(m_properties); |
| 340 } | 366 } |
| 341 | 367 |
| 342 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleViewport) { | 368 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleViewport) { |
| 343 visitor->trace(m_properties); | 369 visitor->trace(m_properties); |
| 344 StyleRuleBase::traceAfterDispatch(visitor); | 370 StyleRuleBase::traceAfterDispatch(visitor); |
| 345 } | 371 } |
| 346 | 372 |
| 347 } // namespace blink | 373 } // namespace blink |
| OLD | NEW |