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

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

Issue 2282303002: [test] lazily parse css style rules
Patch Set: use string pool Created 4 years, 4 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..9e954b738e9d18ecc9443fbfc7f6a172412e31de 100644
--- a/third_party/WebKit/Source/core/css/StyleRule.cpp
+++ b/third_party/WebKit/Source/core/css/StyleRule.cpp
@@ -33,6 +33,7 @@
#include "core/css/StyleRuleImport.h"
#include "core/css/StyleRuleKeyframe.h"
#include "core/css/StyleRuleNamespace.h"
+#include "core/css/parser/CSSParserImpl.h"
namespace blink {
@@ -217,10 +218,30 @@ StyleRule::StyleRule(CSSSelectorList selectorList, StylePropertySet* properties)
m_selectorList = std::move(selectorList);
}
+const StylePropertySet& StyleRule::properties() const
+{
+ if (!m_properties) {
+ m_properties = CSSParserImpl::parseDeclarationListForLazyStyle(m_lazyTokens, *m_context);
+ m_lazyTokens.clear();
+ }
+ return *m_properties;
+}
+
+StyleRule::StyleRule(CSSSelectorList selectorList, CSSParserTokenRange block, const CSSParserContext* context)
+ : StyleRuleBase(Style)
+ , m_selectorList(std::move(selectorList))
+ , m_properties(nullptr)
+ , m_context(context)
+{
+ while (!block.atEnd()) {
+ m_lazyTokens.append(block.consume());
+ }
+}
+
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,8 +251,9 @@ StyleRule::~StyleRule()
MutableStylePropertySet& StyleRule::mutableProperties()
{
- if (!m_properties->isMutable())
- m_properties = m_properties->mutableCopy();
+ const StylePropertySet& props = properties();
+ if (!props.isMutable())
+ m_properties = props.mutableCopy();
return *toMutableStylePropertySet(m_properties.get());
}
« no previous file with comments | « third_party/WebKit/Source/core/css/StyleRule.h ('k') | third_party/WebKit/Source/core/css/StyleSheetContents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698