Chromium Code Reviews| Index: third_party/WebKit/Source/core/css/StyleRule.cpp |
| diff --git a/third_party/WebKit/Source/core/css/StyleRule.cpp b/third_party/WebKit/Source/core/css/StyleRule.cpp |
| index ffc73fe80bc83c10d6dd96c826c9646bb7d9eb7e..797dc0ce6ab6dd86292c21816a44d2923566bfdb 100644 |
| --- a/third_party/WebKit/Source/core/css/StyleRule.cpp |
| +++ b/third_party/WebKit/Source/core/css/StyleRule.cpp |
| @@ -212,15 +212,31 @@ unsigned StyleRule::averageSizeInBytes() |
| StyleRule::StyleRule(CSSSelectorList selectorList, StylePropertySet* properties) |
| : StyleRuleBase(Style) |
| + , m_selectorList(std::move(selectorList)) |
| , m_properties(properties) |
| { |
| - m_selectorList = std::move(selectorList); |
| +} |
| + |
| +StyleRule::StyleRule(CSSSelectorList selectorList, std::unique_ptr<CSSParser::DeferredPropertiesClosure> deferredProperties) |
| + : StyleRuleBase(Style) |
| + , m_selectorList(std::move(selectorList)) |
| + , m_deferred(std::move(deferredProperties)) |
| +{ |
| +} |
| + |
| +const StylePropertySet& StyleRule::properties() const |
| +{ |
| + if (!m_properties) { |
| + 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 :)
|
| + m_deferred.reset(); |
| + } |
| + return *m_properties; |
| } |
| StyleRule::StyleRule(const StyleRule& o) |
| : StyleRuleBase(o) |
| - , m_properties(o.m_properties->mutableCopy()) |
| , m_selectorList(o.m_selectorList.copy()) |
| + , m_properties(o.properties().mutableCopy()) |
| { |
| } |
| @@ -230,11 +246,25 @@ StyleRule::~StyleRule() |
| MutableStylePropertySet& StyleRule::mutableProperties() |
| { |
| - if (!m_properties->isMutable()) |
| - m_properties = m_properties->mutableCopy(); |
| + // Ensure m_properties is initialized. |
| + const StylePropertySet& props = properties(); |
| + if (!props.isMutable()) |
| + m_properties = props.mutableCopy(); |
| return *toMutableStylePropertySet(m_properties.get()); |
| } |
| +bool StyleRule::propertiesHaveFailedOrCanceledSubresources() const |
| +{ |
| + return m_properties && m_properties->hasFailedOrCanceledSubresources(); |
| +} |
| + |
| +bool StyleRule::hasEmptyProperties() const |
| +{ |
| + // We only lazily parse if the property block has a nonzero amount of |
| + // tokens. Thus, consider all lazily initialized properties to be non-empty. |
| + return m_properties && m_properties->isEmpty(); |
| +} |
| + |
| DEFINE_TRACE_AFTER_DISPATCH(StyleRule) |
| { |
| visitor->trace(m_properties); |