Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(580)

Unified Diff: third_party/WebKit/Source/core/css/StyleRule.cpp

Issue 2315923002: Lazy Parse CSS (Closed)
Patch Set: CL for src perf tryjob to run page_cycler_v2.typical_25 benchmark on all-android platform(s) Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..c00747492f0799f84f56093f1e44caaa83daf0d2 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<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)();
+ 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();
Timothy Loh 2016/09/27 05:15:45 The style guide (blink.style/guide) says to avoid
Charlie Harrison 2016/09/27 13:22:00 Done.
+ 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
Timothy Loh 2016/09/27 05:15:45 Is this supposed to be called somewhere? It's not
Charlie Harrison 2016/09/27 13:22:00 My mistake, this is supposed to be called in Eleme
+{
+ // 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);

Powered by Google App Engine
This is Rietveld 408576698