Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 326 // TODO(horo): When we will use the original URL as the base URL, we can rem ove this check. crbug.com/553535 | 326 // 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()) { | 327 if (cachedStyleSheet->response().wasFetchedViaServiceWorker()) { |
| 328 const KURL originalURL(cachedStyleSheet->response().originalURLViaServic eWorker()); | 328 const KURL originalURL(cachedStyleSheet->response().originalURLViaServic eWorker()); |
| 329 // |originalURL| is empty when the response is created in the SW. | 329 // |originalURL| is empty when the response is created in the SW. |
| 330 if (!originalURL.isEmpty() && !securityOrigin->canRequest(originalURL)) | 330 if (!originalURL.isEmpty() && !securityOrigin->canRequest(originalURL)) |
| 331 isSameOriginRequest = false; | 331 isSameOriginRequest = false; |
| 332 } | 332 } |
| 333 | 333 |
| 334 CSSStyleSheetResource::MIMETypeCheck mimeTypeCheck = isQuirksModeBehavior(m_ parserContext.mode()) && isSameOriginRequest ? CSSStyleSheetResource::MIMETypeCh eck::Lax : CSSStyleSheetResource::MIMETypeCheck::Strict; | 334 CSSStyleSheetResource::MIMETypeCheck mimeTypeCheck = isQuirksModeBehavior(m_ parserContext.mode()) && isSameOriginRequest ? CSSStyleSheetResource::MIMETypeCh eck::Lax : CSSStyleSheetResource::MIMETypeCheck::Strict; |
| 335 String sheetText = cachedStyleSheet->sheetText(mimeTypeCheck); | 335 String sheetText = cachedStyleSheet->sheetText(mimeTypeCheck); |
| 336 if (RuntimeEnabledFeatures::lazyParseCSSEnabled()) | |
| 337 m_sheetText = sheetText; | |
| 336 | 338 |
| 337 const ResourceResponse& response = cachedStyleSheet->response(); | 339 const ResourceResponse& response = cachedStyleSheet->response(); |
| 338 m_sourceMapURL = response.httpHeaderField(HTTPNames::SourceMap); | 340 m_sourceMapURL = response.httpHeaderField(HTTPNames::SourceMap); |
| 339 if (m_sourceMapURL.isEmpty()) { | 341 if (m_sourceMapURL.isEmpty()) { |
| 340 // Try to get deprecated header. | 342 // Try to get deprecated header. |
| 341 m_sourceMapURL = response.httpHeaderField(HTTPNames::X_SourceMap); | 343 m_sourceMapURL = response.httpHeaderField(HTTPNames::X_SourceMap); |
| 342 } | 344 } |
| 343 | 345 |
| 344 CSSParserContext context(parserContext(), UseCounter::getFrom(this)); | 346 // Note: pass the member context here, as lazy parsing requires retaining a |
|
Timothy Loh
2016/09/26 05:18:00
Presumably there was some reason for this to be wr
Charlie Harrison
2016/09/26 22:14:45
After looking through the code I think you're righ
| |
| 345 CSSParser::parseSheet(context, this, sheetText); | 347 // reference to it. |
| 348 CSSParser::parseSheet(parserContext(), this, sheetText, RuntimeEnabledFeatur es::lazyParseCSSEnabled()); | |
| 346 } | 349 } |
| 347 | 350 |
| 348 void StyleSheetContents::parseString(const String& sheetText) | 351 void StyleSheetContents::parseString(const String& sheetText) |
| 349 { | 352 { |
| 350 parseStringAtPosition(sheetText, TextPosition::minimumPosition()); | 353 parseStringAtPosition(sheetText, TextPosition::minimumPosition()); |
| 351 } | 354 } |
| 352 | 355 |
| 353 void StyleSheetContents::parseStringAtPosition(const String& sheetText, const Te xtPosition& startPosition) | 356 void StyleSheetContents::parseStringAtPosition(const String& sheetText, const Te xtPosition& startPosition) |
| 354 { | 357 { |
| 355 CSSParserContext context(parserContext(), UseCounter::getFrom(this)); | 358 CSSParserContext context(parserContext(), UseCounter::getFrom(this)); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 467 StyleSheetContents* root = rootStyleSheet(); | 470 StyleSheetContents* root = rootStyleSheet(); |
| 468 return root->clientSingleOwnerDocument(); | 471 return root->clientSingleOwnerDocument(); |
| 469 } | 472 } |
| 470 | 473 |
| 471 static bool childRulesHaveFailedOrCanceledSubresources(const HeapVector<Member<S tyleRuleBase>>& rules) | 474 static bool childRulesHaveFailedOrCanceledSubresources(const HeapVector<Member<S tyleRuleBase>>& rules) |
| 472 { | 475 { |
| 473 for (unsigned i = 0; i < rules.size(); ++i) { | 476 for (unsigned i = 0; i < rules.size(); ++i) { |
| 474 const StyleRuleBase* rule = rules[i].get(); | 477 const StyleRuleBase* rule = rules[i].get(); |
| 475 switch (rule->type()) { | 478 switch (rule->type()) { |
| 476 case StyleRuleBase::Style: | 479 case StyleRuleBase::Style: |
| 477 if (toStyleRule(rule)->properties().hasFailedOrCanceledSubresources( )) | 480 if (toStyleRule(rule)->propertiesHaveFailedOrCanceledSubresources()) |
| 478 return true; | 481 return true; |
| 479 break; | 482 break; |
| 480 case StyleRuleBase::FontFace: | 483 case StyleRuleBase::FontFace: |
| 481 if (toStyleRuleFontFace(rule)->properties().hasFailedOrCanceledSubre sources()) | 484 if (toStyleRuleFontFace(rule)->properties().hasFailedOrCanceledSubre sources()) |
| 482 return true; | 485 return true; |
| 483 break; | 486 break; |
| 484 case StyleRuleBase::Media: | 487 case StyleRuleBase::Media: |
| 485 if (childRulesHaveFailedOrCanceledSubresources(toStyleRuleMedia(rule )->childRules())) | 488 if (childRulesHaveFailedOrCanceledSubresources(toStyleRuleMedia(rule )->childRules())) |
| 486 return true; | 489 return true; |
| 487 break; | 490 break; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 |
| OLD | NEW |