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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLLinkElement.cpp

Issue 2171293002: Fix the condition to call removePandingSheet() in LinkStyle::setCSSStyleSheet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
6 * Copyright (C) 2009 Rob Buis (rwlbuis@gmail.com) 6 * Copyright (C) 2009 Rob Buis (rwlbuis@gmail.com)
7 * Copyright (C) 2011 Google Inc. All rights reserved. 7 * Copyright (C) 2011 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 433
434 enum StyleSheetCacheStatus { 434 enum StyleSheetCacheStatus {
435 StyleSheetNewEntry, 435 StyleSheetNewEntry,
436 StyleSheetInDiskCache, 436 StyleSheetInDiskCache,
437 StyleSheetInMemoryCache, 437 StyleSheetInMemoryCache,
438 StyleSheetCacheStatusCount, 438 StyleSheetCacheStatusCount,
439 }; 439 };
440 440
441 void LinkStyle::setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CSSStyleSheetResource* cachedStyleSheet) 441 void LinkStyle::setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CSSStyleSheetResource* cachedStyleSheet)
442 { 442 {
443 if (!m_owner->isConnected()) { 443 if (!m_owner->isInDocumentTree()) {
444 ASSERT(!m_sheet); 444 // While the stylesheet is asynchronously loading, the owner can be move d out of a document tree.
445 // In that case, cancel any processing on the loaded content.
446 m_loading = false;
447 removePendingSheet();
448 if (m_sheet)
449 clearSheet();
445 return; 450 return;
446 } 451 }
447 452
448 // See the comment in PendingScript.cpp about why this check is necessary 453 // See the comment in PendingScript.cpp about why this check is necessary
449 // here, instead of in the resource fetcher. https://crbug.com/500701. 454 // here, instead of in the resource fetcher. https://crbug.com/500701.
450 if (!cachedStyleSheet->errorOccurred() && m_owner->fastHasAttribute(HTMLName s::integrityAttr) && cachedStyleSheet->resourceBuffer() && !SubresourceIntegrity ::CheckSubresourceIntegrity(*m_owner, cachedStyleSheet->resourceBuffer()->data() , cachedStyleSheet->resourceBuffer()->size(), KURL(baseURL, href), *cachedStyleS heet)) { 455 if (!cachedStyleSheet->errorOccurred() && m_owner->fastHasAttribute(HTMLName s::integrityAttr) && cachedStyleSheet->resourceBuffer() && !SubresourceIntegrity ::CheckSubresourceIntegrity(*m_owner, cachedStyleSheet->resourceBuffer()->data() , cachedStyleSheet->resourceBuffer()->size(), KURL(baseURL, href), *cachedStyleS heet)) {
451 m_loading = false; 456 m_loading = false;
452 removePendingSheet(); 457 removePendingSheet();
453 notifyLoadedSheetAndAllCriticalSubresources(Node::ErrorOccurredLoadingSu bresource); 458 notifyLoadedSheetAndAllCriticalSubresources(Node::ErrorOccurredLoadingSu bresource);
454 return; 459 return;
455 } 460 }
456 // While the stylesheet is asynchronously loading, the owner can be moved un der
457 // shadow tree. In that case, cancel any processing on the loaded content.
458 if (m_owner->isInShadowTree()) {
459 m_loading = false;
460 removePendingSheet();
461 if (m_sheet)
462 clearSheet();
463 return;
464 }
465 461
466 CSSParserContext parserContext(m_owner->document(), nullptr, baseURL, charse t); 462 CSSParserContext parserContext(m_owner->document(), nullptr, baseURL, charse t);
467 463
468 DEFINE_STATIC_LOCAL(EnumerationHistogram, restoredCachedStyleSheetHistogram, ("Blink.RestoredCachedStyleSheet", 2)); 464 DEFINE_STATIC_LOCAL(EnumerationHistogram, restoredCachedStyleSheetHistogram, ("Blink.RestoredCachedStyleSheet", 2));
469 DEFINE_STATIC_LOCAL(EnumerationHistogram, restoredCachedStyleSheet2Histogram , ("Blink.RestoredCachedStyleSheet2", StyleSheetCacheStatusCount)); 465 DEFINE_STATIC_LOCAL(EnumerationHistogram, restoredCachedStyleSheet2Histogram , ("Blink.RestoredCachedStyleSheet2", StyleSheetCacheStatusCount));
470 466
471 if (StyleSheetContents* restoredSheet = const_cast<CSSStyleSheetResource*>(c achedStyleSheet)->restoreParsedStyleSheet(parserContext)) { 467 if (StyleSheetContents* restoredSheet = const_cast<CSSStyleSheetResource*>(c achedStyleSheet)->restoreParsedStyleSheet(parserContext)) {
472 ASSERT(restoredSheet->isCacheableForResource()); 468 ASSERT(restoredSheet->isCacheableForResource());
473 ASSERT(!restoredSheet->isLoading()); 469 ASSERT(!restoredSheet->isLoading());
474 470
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 } 724 }
729 725
730 DEFINE_TRACE(LinkStyle) 726 DEFINE_TRACE(LinkStyle)
731 { 727 {
732 visitor->trace(m_sheet); 728 visitor->trace(m_sheet);
733 LinkResource::trace(visitor); 729 LinkResource::trace(visitor);
734 ResourceOwner<StyleSheetResource>::trace(visitor); 730 ResourceOwner<StyleSheetResource>::trace(visitor);
735 } 731 }
736 732
737 } // namespace blink 733 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698