| 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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 return rule; | 205 return rule; |
| 206 } | 206 } |
| 207 | 207 |
| 208 unsigned StyleRule::averageSizeInBytes() | 208 unsigned StyleRule::averageSizeInBytes() |
| 209 { | 209 { |
| 210 return sizeof(StyleRule) + sizeof(CSSSelector) + StylePropertySet::averageSi
zeInBytes(); | 210 return sizeof(StyleRule) + sizeof(CSSSelector) + StylePropertySet::averageSi
zeInBytes(); |
| 211 } | 211 } |
| 212 | 212 |
| 213 StyleRule::StyleRule(CSSSelectorList selectorList, StylePropertySet* properties) | 213 StyleRule::StyleRule(CSSSelectorList selectorList, StylePropertySet* properties) |
| 214 : StyleRuleBase(Style) | 214 : StyleRuleBase(Style) |
| 215 , m_selectorList(std::move(selectorList)) |
| 215 , m_properties(properties) | 216 , m_properties(properties) |
| 216 { | 217 { |
| 217 m_selectorList = std::move(selectorList); | 218 } |
| 219 |
| 220 StyleRule::StyleRule(CSSSelectorList selectorList, std::unique_ptr<DeferredPrope
rtiesClosure> deferredProperties) |
| 221 : StyleRuleBase(Style) |
| 222 , m_selectorList(std::move(selectorList)) |
| 223 , m_deferred(std::move(deferredProperties)) |
| 224 { |
| 225 } |
| 226 |
| 227 const StylePropertySet& StyleRule::properties() const |
| 228 { |
| 229 if (!m_properties) { |
| 230 m_properties = (*m_deferred)(); |
| 231 m_deferred.reset(); |
| 232 } |
| 233 return *m_properties; |
| 218 } | 234 } |
| 219 | 235 |
| 220 StyleRule::StyleRule(const StyleRule& o) | 236 StyleRule::StyleRule(const StyleRule& o) |
| 221 : StyleRuleBase(o) | 237 : StyleRuleBase(o) |
| 222 , m_properties(o.m_properties->mutableCopy()) | |
| 223 , m_selectorList(o.m_selectorList.copy()) | 238 , m_selectorList(o.m_selectorList.copy()) |
| 239 , m_properties(o.properties().mutableCopy()) |
| 224 { | 240 { |
| 225 } | 241 } |
| 226 | 242 |
| 227 StyleRule::~StyleRule() | 243 StyleRule::~StyleRule() |
| 228 { | 244 { |
| 229 } | 245 } |
| 230 | 246 |
| 231 MutableStylePropertySet& StyleRule::mutableProperties() | 247 MutableStylePropertySet& StyleRule::mutableProperties() |
| 232 { | 248 { |
| 233 if (!m_properties->isMutable()) | 249 // Ensure m_properties is initialized. |
| 250 if (!properties().isMutable()) |
| 234 m_properties = m_properties->mutableCopy(); | 251 m_properties = m_properties->mutableCopy(); |
| 235 return *toMutableStylePropertySet(m_properties.get()); | 252 return *toMutableStylePropertySet(m_properties.get()); |
| 236 } | 253 } |
| 237 | 254 |
| 255 bool StyleRule::propertiesHaveFailedOrCanceledSubresources() const |
| 256 { |
| 257 return m_properties && m_properties->hasFailedOrCanceledSubresources(); |
| 258 } |
| 259 |
| 260 bool StyleRule::shouldConsiderForMatchingRules(bool includeEmptyRules) const |
| 261 { |
| 262 // Consider all non-empty property sets if parsing has not been deferred. |
| 263 // Otherwise, consider all StyleRules with non-null deferred closures. |
| 264 return includeEmptyRules || !(m_properties && m_properties->isEmpty()); |
| 265 } |
| 266 |
| 238 DEFINE_TRACE_AFTER_DISPATCH(StyleRule) | 267 DEFINE_TRACE_AFTER_DISPATCH(StyleRule) |
| 239 { | 268 { |
| 240 visitor->trace(m_properties); | 269 visitor->trace(m_properties); |
| 241 StyleRuleBase::traceAfterDispatch(visitor); | 270 StyleRuleBase::traceAfterDispatch(visitor); |
| 242 } | 271 } |
| 243 | 272 |
| 244 StyleRulePage::StyleRulePage(CSSSelectorList selectorList, StylePropertySet* pro
perties) | 273 StyleRulePage::StyleRulePage(CSSSelectorList selectorList, StylePropertySet* pro
perties) |
| 245 : StyleRuleBase(Page) | 274 : StyleRuleBase(Page) |
| 246 , m_properties(properties) | 275 , m_properties(properties) |
| 247 , m_selectorList(std::move(selectorList)) | 276 , m_selectorList(std::move(selectorList)) |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 return *toMutableStylePropertySet(m_properties); | 416 return *toMutableStylePropertySet(m_properties); |
| 388 } | 417 } |
| 389 | 418 |
| 390 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleViewport) | 419 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleViewport) |
| 391 { | 420 { |
| 392 visitor->trace(m_properties); | 421 visitor->trace(m_properties); |
| 393 StyleRuleBase::traceAfterDispatch(visitor); | 422 StyleRuleBase::traceAfterDispatch(visitor); |
| 394 } | 423 } |
| 395 | 424 |
| 396 } // namespace blink | 425 } // namespace blink |
| OLD | NEW |