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

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

Issue 2315923002: Lazy Parse CSS (Closed)
Patch Set: s/->/. 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 , m_namespaces(o.m_namespaces) 79 , m_namespaces(o.m_namespaces)
80 , m_defaultNamespace(o.m_defaultNamespace) 80 , m_defaultNamespace(o.m_defaultNamespace)
81 , m_hasSyntacticallyValidCSSHeader(o.m_hasSyntacticallyValidCSSHeader) 81 , m_hasSyntacticallyValidCSSHeader(o.m_hasSyntacticallyValidCSSHeader)
82 , m_didLoadErrorOccur(false) 82 , m_didLoadErrorOccur(false)
83 , m_isMutable(false) 83 , m_isMutable(false)
84 , m_hasFontFaceRule(o.m_hasFontFaceRule) 84 , m_hasFontFaceRule(o.m_hasFontFaceRule)
85 , m_hasMediaQueries(o.m_hasMediaQueries) 85 , m_hasMediaQueries(o.m_hasMediaQueries)
86 , m_hasSingleOwnerDocument(true) 86 , m_hasSingleOwnerDocument(true)
87 , m_isUsedFromTextCache(false) 87 , m_isUsedFromTextCache(false)
88 , m_parserContext(o.m_parserContext) 88 , m_parserContext(o.m_parserContext)
89 , m_escapedStrings(o.m_escapedStrings ? new Vector<String>(*o.m_escapedStrin gs) : nullptr)
90 , m_sheetText(o.m_sheetText)
89 { 91 {
90 // FIXME: Copy import rules. 92 // FIXME: Copy import rules.
91 ASSERT(o.m_importRules.isEmpty()); 93 ASSERT(o.m_importRules.isEmpty());
92 94
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 {
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 // TODO(horo): When we will use the original URL as the base URL, we can rem ove this check. crbug.com/553535 328 // TODO(horo): When we will use the original URL as the base URL, we can rem ove this check. crbug.com/553535
327 if (cachedStyleSheet->response().wasFetchedViaServiceWorker()) { 329 if (cachedStyleSheet->response().wasFetchedViaServiceWorker()) {
328 const KURL originalURL(cachedStyleSheet->response().originalURLViaServic eWorker()); 330 const KURL originalURL(cachedStyleSheet->response().originalURLViaServic eWorker());
329 // |originalURL| is empty when the response is created in the SW. 331 // |originalURL| is empty when the response is created in the SW.
330 if (!originalURL.isEmpty() && !securityOrigin->canRequest(originalURL)) 332 if (!originalURL.isEmpty() && !securityOrigin->canRequest(originalURL))
331 isSameOriginRequest = false; 333 isSameOriginRequest = false;
332 } 334 }
333 335
334 CSSStyleSheetResource::MIMETypeCheck mimeTypeCheck = isQuirksModeBehavior(m_ parserContext.mode()) && isSameOriginRequest ? CSSStyleSheetResource::MIMETypeCh eck::Lax : CSSStyleSheetResource::MIMETypeCheck::Strict; 336 CSSStyleSheetResource::MIMETypeCheck mimeTypeCheck = isQuirksModeBehavior(m_ parserContext.mode()) && isSameOriginRequest ? CSSStyleSheetResource::MIMETypeCh eck::Lax : CSSStyleSheetResource::MIMETypeCheck::Strict;
335 String sheetText = cachedStyleSheet->sheetText(mimeTypeCheck); 337 String sheetText = cachedStyleSheet->sheetText(mimeTypeCheck);
338 if (RuntimeEnabledFeatures::lazyParseCSSEnabled())
339 m_sheetText = sheetText;
336 340
337 const ResourceResponse& response = cachedStyleSheet->response(); 341 const ResourceResponse& response = cachedStyleSheet->response();
338 m_sourceMapURL = response.httpHeaderField(HTTPNames::SourceMap); 342 m_sourceMapURL = response.httpHeaderField(HTTPNames::SourceMap);
339 if (m_sourceMapURL.isEmpty()) { 343 if (m_sourceMapURL.isEmpty()) {
340 // Try to get deprecated header. 344 // Try to get deprecated header.
341 m_sourceMapURL = response.httpHeaderField(HTTPNames::X_SourceMap); 345 m_sourceMapURL = response.httpHeaderField(HTTPNames::X_SourceMap);
342 } 346 }
343 347
344 CSSParserContext context(parserContext(), UseCounter::getFrom(this)); 348 CSSParserContext context(parserContext(), UseCounter::getFrom(this));
345 CSSParser::parseSheet(context, this, sheetText); 349 CSSParser::parseSheet(context, this, sheetText, RuntimeEnabledFeatures::lazy ParseCSSEnabled());
346 } 350 }
347 351
348 void StyleSheetContents::parseString(const String& sheetText) 352 void StyleSheetContents::parseString(const String& sheetText)
349 { 353 {
350 parseStringAtPosition(sheetText, TextPosition::minimumPosition()); 354 parseStringAtPosition(sheetText, TextPosition::minimumPosition());
351 } 355 }
352 356
353 void StyleSheetContents::parseStringAtPosition(const String& sheetText, const Te xtPosition& startPosition) 357 void StyleSheetContents::parseStringAtPosition(const String& sheetText, const Te xtPosition& startPosition)
354 { 358 {
355 CSSParserContext context(parserContext(), UseCounter::getFrom(this)); 359 CSSParserContext context(parserContext(), UseCounter::getFrom(this));
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 StyleSheetContents* root = rootStyleSheet(); 471 StyleSheetContents* root = rootStyleSheet();
468 return root->clientSingleOwnerDocument(); 472 return root->clientSingleOwnerDocument();
469 } 473 }
470 474
471 static bool childRulesHaveFailedOrCanceledSubresources(const HeapVector<Member<S tyleRuleBase>>& rules) 475 static bool childRulesHaveFailedOrCanceledSubresources(const HeapVector<Member<S tyleRuleBase>>& rules)
472 { 476 {
473 for (unsigned i = 0; i < rules.size(); ++i) { 477 for (unsigned i = 0; i < rules.size(); ++i) {
474 const StyleRuleBase* rule = rules[i].get(); 478 const StyleRuleBase* rule = rules[i].get();
475 switch (rule->type()) { 479 switch (rule->type()) {
476 case StyleRuleBase::Style: 480 case StyleRuleBase::Style:
477 if (toStyleRule(rule)->properties().hasFailedOrCanceledSubresources( )) 481 if (toStyleRule(rule)->propertiesHaveFailedOrCanceledSubresources())
478 return true; 482 return true;
479 break; 483 break;
480 case StyleRuleBase::FontFace: 484 case StyleRuleBase::FontFace:
481 if (toStyleRuleFontFace(rule)->properties().hasFailedOrCanceledSubre sources()) 485 if (toStyleRuleFontFace(rule)->properties().hasFailedOrCanceledSubre sources())
482 return true; 486 return true;
483 break; 487 break;
484 case StyleRuleBase::Media: 488 case StyleRuleBase::Media:
485 if (childRulesHaveFailedOrCanceledSubresources(toStyleRuleMedia(rule )->childRules())) 489 if (childRulesHaveFailedOrCanceledSubresources(toStyleRuleMedia(rule )->childRules()))
486 return true; 490 return true;
487 break; 491 break;
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 visitor->trace(m_importRules); 668 visitor->trace(m_importRules);
665 visitor->trace(m_namespaceRules); 669 visitor->trace(m_namespaceRules);
666 visitor->trace(m_childRules); 670 visitor->trace(m_childRules);
667 visitor->trace(m_loadingClients); 671 visitor->trace(m_loadingClients);
668 visitor->trace(m_completedClients); 672 visitor->trace(m_completedClients);
669 visitor->trace(m_ruleSet); 673 visitor->trace(m_ruleSet);
670 visitor->trace(m_referencedFromResource); 674 visitor->trace(m_referencedFromResource);
671 } 675 }
672 676
673 } // namespace blink 677 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698