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

Unified Diff: third_party/WebKit/Source/core/css/parser/CSSParserImpl.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/parser/CSSParserImpl.cpp
diff --git a/third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp b/third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp
index 59c96a646cdd6bc98f2765b1a43d5e7d62918f6a..030f2578bd32f309b4f859cb1bd053177f8a055f 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp
@@ -172,12 +172,14 @@ void CSSParserImpl::parseStyleSheet(const String& string, const CSSParserContext
TRACE_EVENT_BEGIN0("blink,blink_style", "CSSParserImpl::parseStyleSheet.parse");
CSSParserImpl parser(context, styleSheet);
+ parser.enableLazyParsing();
bool firstRuleValid = parser.consumeRuleList(scope.tokenRange(), TopLevelRuleList, [&styleSheet](StyleRuleBase* rule) {
if (rule->isCharsetRule())
return;
styleSheet->parserAppendRule(rule);
});
styleSheet->setHasSyntacticallyValidCSSHeader(firstRuleValid);
+ styleSheet->populateStringPool(scope.stringPool());
TRACE_EVENT_END0("blink,blink_style", "CSSParserImpl::parseStyleSheet.parse");
TRACE_EVENT_END2(
@@ -276,6 +278,13 @@ void CSSParserImpl::parseDeclarationListForInspector(const String& declaration,
parser.consumeDeclarationList(scope.tokenRange(), StyleRule::Style);
}
+ImmutableStylePropertySet* CSSParserImpl::parseDeclarationListForLazyStyle(CSSParserTokenRange block, const CSSParserContext& context)
+{
+ CSSParserImpl parser(context);
+ parser.consumeDeclarationList(block, StyleRule::Style);
+ return createStylePropertySet(parser.m_parsedProperties, context.mode());
+}
+
void CSSParserImpl::parseStyleSheetForInspector(const String& string, const CSSParserContext& context, StyleSheetContents* styleSheet, CSSParserObserver& observer)
{
CSSParserImpl parser(context, styleSheet);
@@ -684,8 +693,11 @@ StyleRule* CSSParserImpl::consumeStyleRule(CSSParserTokenRange prelude, CSSParse
if (m_observerWrapper)
observeSelectors(*m_observerWrapper, prelude);
+ // TODO(csharrison): How should we lazily parse css that needs the observer?
+ if (m_shouldUseLazyParsing && !m_observerWrapper) {
+ return StyleRule::createLazy(std::move(selectorList), block, &m_context);
+ }
consumeDeclarationList(block, StyleRule::Style);
-
return StyleRule::create(std::move(selectorList), createStylePropertySet(m_parsedProperties, m_context.mode()));
}
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSParserImpl.h ('k') | third_party/WebKit/Source/core/css/parser/CSSTokenizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698