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

Side by Side Diff: third_party/WebKit/Source/core/css/StyleSheetContents.cpp

Issue 2315923002: Lazy Parse CSS (Closed)
Patch Set: Remove the closure and refactor logic into a separate file Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2006, 2007, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2006, 2007, 2012 Apple Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 m_didLoadErrorOccur(false), 83 m_didLoadErrorOccur(false),
84 m_isMutable(false), 84 m_isMutable(false),
85 m_hasFontFaceRule(o.m_hasFontFaceRule), 85 m_hasFontFaceRule(o.m_hasFontFaceRule),
86 m_hasMediaQueries(o.m_hasMediaQueries), 86 m_hasMediaQueries(o.m_hasMediaQueries),
87 m_hasSingleOwnerDocument(true), 87 m_hasSingleOwnerDocument(true),
88 m_isUsedFromTextCache(false), 88 m_isUsedFromTextCache(false),
89 m_parserContext(o.m_parserContext) { 89 m_parserContext(o.m_parserContext) {
90 // FIXME: Copy import rules. 90 // FIXME: Copy import rules.
91 ASSERT(o.m_importRules.isEmpty()); 91 ASSERT(o.m_importRules.isEmpty());
92 92
93 // LazyParseCSS: Copying child rules is a strict point for lazy parsing, so
94 // there is no need to copy lazy parsing state here.
93 for (unsigned i = 0; i < m_childRules.size(); ++i) 95 for (unsigned i = 0; i < m_childRules.size(); ++i)
94 m_childRules[i] = o.m_childRules[i]->copy(); 96 m_childRules[i] = o.m_childRules[i]->copy();
95 } 97 }
96 98
97 StyleSheetContents::~StyleSheetContents() {} 99 StyleSheetContents::~StyleSheetContents() {}
98 100
99 void StyleSheetContents::setHasSyntacticallyValidCSSHeader(bool isValidCss) { 101 void StyleSheetContents::setHasSyntacticallyValidCSSHeader(bool isValidCss) {
100 m_hasSyntacticallyValidCSSHeader = isValidCss; 102 m_hasSyntacticallyValidCSSHeader = isValidCss;
101 } 103 }
102 104
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 String sheetText = cachedStyleSheet->sheetText(mimeTypeCheck); 344 String sheetText = cachedStyleSheet->sheetText(mimeTypeCheck);
343 345
344 const ResourceResponse& response = cachedStyleSheet->response(); 346 const ResourceResponse& response = cachedStyleSheet->response();
345 m_sourceMapURL = response.httpHeaderField(HTTPNames::SourceMap); 347 m_sourceMapURL = response.httpHeaderField(HTTPNames::SourceMap);
346 if (m_sourceMapURL.isEmpty()) { 348 if (m_sourceMapURL.isEmpty()) {
347 // Try to get deprecated header. 349 // Try to get deprecated header.
348 m_sourceMapURL = response.httpHeaderField(HTTPNames::X_SourceMap); 350 m_sourceMapURL = response.httpHeaderField(HTTPNames::X_SourceMap);
349 } 351 }
350 352
351 CSSParserContext context(parserContext(), UseCounter::getFrom(this)); 353 CSSParserContext context(parserContext(), UseCounter::getFrom(this));
352 CSSParser::parseSheet(context, this, sheetText); 354 CSSParser::parseSheet(context, this, sheetText,
355 RuntimeEnabledFeatures::lazyParseCSSEnabled());
esprehn 2016/10/24 21:20:20 Can we check this flag from inside parseSheet inst
Charlie Harrison 2016/10/25 15:56:55 It's a bit tricky and involves tradeoffs. Passing
353 } 356 }
354 357
355 void StyleSheetContents::parseString(const String& sheetText) { 358 void StyleSheetContents::parseString(const String& sheetText) {
356 parseStringAtPosition(sheetText, TextPosition::minimumPosition()); 359 parseStringAtPosition(sheetText, TextPosition::minimumPosition());
357 } 360 }
358 361
359 void StyleSheetContents::parseStringAtPosition( 362 void StyleSheetContents::parseStringAtPosition(
360 const String& sheetText, 363 const String& sheetText,
361 const TextPosition& startPosition) { 364 const TextPosition& startPosition) {
362 CSSParserContext context(parserContext(), UseCounter::getFrom(this)); 365 CSSParserContext context(parserContext(), UseCounter::getFrom(this));
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 StyleSheetContents* root = rootStyleSheet(); 472 StyleSheetContents* root = rootStyleSheet();
470 return root->clientSingleOwnerDocument(); 473 return root->clientSingleOwnerDocument();
471 } 474 }
472 475
473 static bool childRulesHaveFailedOrCanceledSubresources( 476 static bool childRulesHaveFailedOrCanceledSubresources(
474 const HeapVector<Member<StyleRuleBase>>& rules) { 477 const HeapVector<Member<StyleRuleBase>>& rules) {
475 for (unsigned i = 0; i < rules.size(); ++i) { 478 for (unsigned i = 0; i < rules.size(); ++i) {
476 const StyleRuleBase* rule = rules[i].get(); 479 const StyleRuleBase* rule = rules[i].get();
477 switch (rule->type()) { 480 switch (rule->type()) {
478 case StyleRuleBase::Style: 481 case StyleRuleBase::Style:
479 if (toStyleRule(rule)->properties().hasFailedOrCanceledSubresources()) 482 if (toStyleRule(rule)->propertiesHaveFailedOrCanceledSubresources())
480 return true; 483 return true;
481 break; 484 break;
482 case StyleRuleBase::FontFace: 485 case StyleRuleBase::FontFace:
483 if (toStyleRuleFontFace(rule) 486 if (toStyleRuleFontFace(rule)
484 ->properties() 487 ->properties()
485 .hasFailedOrCanceledSubresources()) 488 .hasFailedOrCanceledSubresources())
486 return true; 489 return true;
487 break; 490 break;
488 case StyleRuleBase::Media: 491 case StyleRuleBase::Media:
489 if (childRulesHaveFailedOrCanceledSubresources( 492 if (childRulesHaveFailedOrCanceledSubresources(
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 visitor->trace(m_importRules); 667 visitor->trace(m_importRules);
665 visitor->trace(m_namespaceRules); 668 visitor->trace(m_namespaceRules);
666 visitor->trace(m_childRules); 669 visitor->trace(m_childRules);
667 visitor->trace(m_loadingClients); 670 visitor->trace(m_loadingClients);
668 visitor->trace(m_completedClients); 671 visitor->trace(m_completedClients);
669 visitor->trace(m_ruleSet); 672 visitor->trace(m_ruleSet);
670 visitor->trace(m_referencedFromResource); 673 visitor->trace(m_referencedFromResource);
671 } 674 }
672 675
673 } // namespace blink 676 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698