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 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<CSSParser::De ferredPropertiesClosure> 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)(); | |
|
Timothy Loh
2016/09/26 05:18:00
Should we clear the escaped string store since it
Charlie Harrison
2016/09/26 22:14:45
Unfortunately the escaped string pool has *all* th
Timothy Loh
2016/09/27 05:15:45
Oh right, it's fine as is then :)
| |
| 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. |
| 234 m_properties = m_properties->mutableCopy(); | 250 const StylePropertySet& props = properties(); |
| 251 if (!props.isMutable()) | |
| 252 m_properties = props.mutableCopy(); | |
| 235 return *toMutableStylePropertySet(m_properties.get()); | 253 return *toMutableStylePropertySet(m_properties.get()); |
| 236 } | 254 } |
| 237 | 255 |
| 256 bool StyleRule::propertiesHaveFailedOrCanceledSubresources() const | |
| 257 { | |
| 258 return m_properties && m_properties->hasFailedOrCanceledSubresources(); | |
| 259 } | |
| 260 | |
| 261 bool StyleRule::hasEmptyProperties() const | |
| 262 { | |
| 263 // We only lazily parse if the property block has a nonzero amount of | |
| 264 // tokens. Thus, consider all lazily initialized properties to be non-empty. | |
| 265 return m_properties && m_properties->isEmpty(); | |
| 266 } | |
| 267 | |
| 238 DEFINE_TRACE_AFTER_DISPATCH(StyleRule) | 268 DEFINE_TRACE_AFTER_DISPATCH(StyleRule) |
| 239 { | 269 { |
| 240 visitor->trace(m_properties); | 270 visitor->trace(m_properties); |
| 241 StyleRuleBase::traceAfterDispatch(visitor); | 271 StyleRuleBase::traceAfterDispatch(visitor); |
| 242 } | 272 } |
| 243 | 273 |
| 244 StyleRulePage::StyleRulePage(CSSSelectorList selectorList, StylePropertySet* pro perties) | 274 StyleRulePage::StyleRulePage(CSSSelectorList selectorList, StylePropertySet* pro perties) |
| 245 : StyleRuleBase(Page) | 275 : StyleRuleBase(Page) |
| 246 , m_properties(properties) | 276 , m_properties(properties) |
| 247 , m_selectorList(std::move(selectorList)) | 277 , m_selectorList(std::move(selectorList)) |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 387 return *toMutableStylePropertySet(m_properties); | 417 return *toMutableStylePropertySet(m_properties); |
| 388 } | 418 } |
| 389 | 419 |
| 390 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleViewport) | 420 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleViewport) |
| 391 { | 421 { |
| 392 visitor->trace(m_properties); | 422 visitor->trace(m_properties); |
| 393 StyleRuleBase::traceAfterDispatch(visitor); | 423 StyleRuleBase::traceAfterDispatch(visitor); |
| 394 } | 424 } |
| 395 | 425 |
| 396 } // namespace blink | 426 } // namespace blink |
| OLD | NEW |