| OLD | NEW |
| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 } | 138 } |
| 139 | 139 |
| 140 bool HTMLLinkElement::loadLink(const String& type, const String& as, const Strin
g& media, const KURL& url) | 140 bool HTMLLinkElement::loadLink(const String& type, const String& as, const Strin
g& media, const KURL& url) |
| 141 { | 141 { |
| 142 return m_linkLoader->loadLink(m_relAttribute, crossOriginAttributeValue(fast
GetAttribute(HTMLNames::crossoriginAttr)), type, as, media, url, document(), Net
workHintsInterfaceImpl()); | 142 return m_linkLoader->loadLink(m_relAttribute, crossOriginAttributeValue(fast
GetAttribute(HTMLNames::crossoriginAttr)), type, as, media, url, document(), Net
workHintsInterfaceImpl()); |
| 143 } | 143 } |
| 144 | 144 |
| 145 LinkResource* HTMLLinkElement::linkResourceToProcess() | 145 LinkResource* HTMLLinkElement::linkResourceToProcess() |
| 146 { | 146 { |
| 147 if (!shouldLoadLink()) { | 147 if (!shouldLoadLink()) { |
| 148 ASSERT(!linkStyle() || !linkStyle()->hasSheet()); | 148 DCHECK(!linkStyle() || !linkStyle()->hasSheet()); |
| 149 return nullptr; | 149 return nullptr; |
| 150 } | 150 } |
| 151 | 151 |
| 152 if (!m_link) { | 152 if (!m_link) { |
| 153 if (m_relAttribute.isImport()) { | 153 if (m_relAttribute.isImport()) { |
| 154 m_link = LinkImport::create(this); | 154 m_link = LinkImport::create(this); |
| 155 } else if (m_relAttribute.isManifest()) { | 155 } else if (m_relAttribute.isManifest()) { |
| 156 m_link = LinkManifest::create(this); | 156 m_link = LinkManifest::create(this); |
| 157 } else if (m_relAttribute.isServiceWorker() && OriginTrials::linkService
WorkerEnabled(getExecutionContext())) { | 157 } else if (m_relAttribute.isServiceWorker() && OriginTrials::linkService
WorkerEnabled(getExecutionContext())) { |
| 158 if (document().frame()) | 158 if (document().frame()) |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 { | 225 { |
| 226 // Store the result of isConnected() here before Node::removedFrom(..) clear
s the flags. | 226 // Store the result of isConnected() here before Node::removedFrom(..) clear
s the flags. |
| 227 bool wasConnected = isConnected(); | 227 bool wasConnected = isConnected(); |
| 228 HTMLElement::removedFrom(insertionPoint); | 228 HTMLElement::removedFrom(insertionPoint); |
| 229 if (!insertionPoint->isConnected()) | 229 if (!insertionPoint->isConnected()) |
| 230 return; | 230 return; |
| 231 | 231 |
| 232 m_linkLoader->released(); | 232 m_linkLoader->released(); |
| 233 | 233 |
| 234 if (!wasConnected) { | 234 if (!wasConnected) { |
| 235 ASSERT(!linkStyle() || !linkStyle()->hasSheet()); | 235 DCHECK(!linkStyle() || !linkStyle()->hasSheet()); |
| 236 return; | 236 return; |
| 237 } | 237 } |
| 238 document().styleEngine().removeStyleSheetCandidateNode(this); | 238 document().styleEngine().removeStyleSheetCandidateNode(this); |
| 239 | 239 |
| 240 StyleSheet* removedSheet = sheet(); | 240 StyleSheet* removedSheet = sheet(); |
| 241 | 241 |
| 242 if (m_link) | 242 if (m_link) |
| 243 m_link->ownerRemoved(); | 243 m_link->ownerRemoved(); |
| 244 | 244 |
| 245 document().styleEngine().setNeedsActiveStyleUpdate(removedSheet, FullStyleUp
date); | 245 document().styleEngine().setNeedsActiveStyleUpdate(removedSheet, FullStyleUp
date); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 setSynchronizedLazyAttribute(HTMLNames::sizesAttr, m_sizes->value()); | 291 setSynchronizedLazyAttribute(HTMLNames::sizesAttr, m_sizes->value()); |
| 292 WebVector<WebSize> webIconSizes = WebIconSizesParser::parseIconSizes(m_sizes
->value()); | 292 WebVector<WebSize> webIconSizes = WebIconSizesParser::parseIconSizes(m_sizes
->value()); |
| 293 m_iconSizes.resize(webIconSizes.size()); | 293 m_iconSizes.resize(webIconSizes.size()); |
| 294 for (size_t i = 0; i < webIconSizes.size(); ++i) | 294 for (size_t i = 0; i < webIconSizes.size(); ++i) |
| 295 m_iconSizes[i] = webIconSizes[i]; | 295 m_iconSizes[i] = webIconSizes[i]; |
| 296 process(); | 296 process(); |
| 297 } | 297 } |
| 298 | 298 |
| 299 bool HTMLLinkElement::sheetLoaded() | 299 bool HTMLLinkElement::sheetLoaded() |
| 300 { | 300 { |
| 301 ASSERT(linkStyle()); | 301 DCHECK(linkStyle()); |
| 302 return linkStyle()->sheetLoaded(); | 302 return linkStyle()->sheetLoaded(); |
| 303 } | 303 } |
| 304 | 304 |
| 305 void HTMLLinkElement::notifyLoadedSheetAndAllCriticalSubresources(LoadedSheetErr
orStatus errorStatus) | 305 void HTMLLinkElement::notifyLoadedSheetAndAllCriticalSubresources(LoadedSheetErr
orStatus errorStatus) |
| 306 { | 306 { |
| 307 ASSERT(linkStyle()); | 307 DCHECK(linkStyle()); |
| 308 linkStyle()->notifyLoadedSheetAndAllCriticalSubresources(errorStatus); | 308 linkStyle()->notifyLoadedSheetAndAllCriticalSubresources(errorStatus); |
| 309 } | 309 } |
| 310 | 310 |
| 311 void HTMLLinkElement::dispatchPendingLoadEvents() | 311 void HTMLLinkElement::dispatchPendingLoadEvents() |
| 312 { | 312 { |
| 313 linkLoadEventSender().dispatchPendingEvents(); | 313 linkLoadEventSender().dispatchPendingEvents(); |
| 314 } | 314 } |
| 315 | 315 |
| 316 void HTMLLinkElement::dispatchPendingEvent(LinkEventSender* eventSender) | 316 void HTMLLinkElement::dispatchPendingEvent(LinkEventSender* eventSender) |
| 317 { | 317 { |
| 318 ASSERT_UNUSED(eventSender, eventSender == &linkLoadEventSender()); | 318 DCHECK_EQ(eventSender, &linkLoadEventSender()); |
| 319 ASSERT(m_link); | 319 DCHECK(m_link); |
| 320 if (m_link->hasLoaded()) | 320 if (m_link->hasLoaded()) |
| 321 linkLoaded(); | 321 linkLoaded(); |
| 322 else | 322 else |
| 323 linkLoadingErrored(); | 323 linkLoadingErrored(); |
| 324 } | 324 } |
| 325 | 325 |
| 326 void HTMLLinkElement::scheduleEvent() | 326 void HTMLLinkElement::scheduleEvent() |
| 327 { | 327 { |
| 328 linkLoadEventSender().dispatchEventSoon(this); | 328 linkLoadEventSender().dispatchEventSoon(this); |
| 329 } | 329 } |
| 330 | 330 |
| 331 void HTMLLinkElement::startLoadingDynamicSheet() | 331 void HTMLLinkElement::startLoadingDynamicSheet() |
| 332 { | 332 { |
| 333 ASSERT(linkStyle()); | 333 DCHECK(linkStyle()); |
| 334 linkStyle()->startLoadingDynamicSheet(); | 334 linkStyle()->startLoadingDynamicSheet(); |
| 335 } | 335 } |
| 336 | 336 |
| 337 bool HTMLLinkElement::isURLAttribute(const Attribute& attribute) const | 337 bool HTMLLinkElement::isURLAttribute(const Attribute& attribute) const |
| 338 { | 338 { |
| 339 return attribute.name().localName() == hrefAttr || HTMLElement::isURLAttribu
te(attribute); | 339 return attribute.name().localName() == hrefAttr || HTMLElement::isURLAttribu
te(attribute); |
| 340 } | 340 } |
| 341 | 341 |
| 342 bool HTMLLinkElement::hasLegalLinkAttribute(const QualifiedName& name) const | 342 bool HTMLLinkElement::hasLegalLinkAttribute(const QualifiedName& name) const |
| 343 { | 343 { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 notifyLoadedSheetAndAllCriticalSubresources(Node::ErrorOccurredLoadingSu
bresource); | 459 notifyLoadedSheetAndAllCriticalSubresources(Node::ErrorOccurredLoadingSu
bresource); |
| 460 return; | 460 return; |
| 461 } | 461 } |
| 462 | 462 |
| 463 CSSParserContext parserContext(m_owner->document(), nullptr, baseURL, charse
t); | 463 CSSParserContext parserContext(m_owner->document(), nullptr, baseURL, charse
t); |
| 464 | 464 |
| 465 DEFINE_STATIC_LOCAL(EnumerationHistogram, restoredCachedStyleSheetHistogram,
("Blink.RestoredCachedStyleSheet", 2)); | 465 DEFINE_STATIC_LOCAL(EnumerationHistogram, restoredCachedStyleSheetHistogram,
("Blink.RestoredCachedStyleSheet", 2)); |
| 466 DEFINE_STATIC_LOCAL(EnumerationHistogram, restoredCachedStyleSheet2Histogram
, ("Blink.RestoredCachedStyleSheet2", StyleSheetCacheStatusCount)); | 466 DEFINE_STATIC_LOCAL(EnumerationHistogram, restoredCachedStyleSheet2Histogram
, ("Blink.RestoredCachedStyleSheet2", StyleSheetCacheStatusCount)); |
| 467 | 467 |
| 468 if (StyleSheetContents* restoredSheet = const_cast<CSSStyleSheetResource*>(c
achedStyleSheet)->restoreParsedStyleSheet(parserContext)) { | 468 if (StyleSheetContents* restoredSheet = const_cast<CSSStyleSheetResource*>(c
achedStyleSheet)->restoreParsedStyleSheet(parserContext)) { |
| 469 ASSERT(restoredSheet->isCacheableForResource()); | 469 DCHECK(restoredSheet->isCacheableForResource()); |
| 470 ASSERT(!restoredSheet->isLoading()); | 470 DCHECK(!restoredSheet->isLoading()); |
| 471 | 471 |
| 472 if (m_sheet) | 472 if (m_sheet) |
| 473 clearSheet(); | 473 clearSheet(); |
| 474 m_sheet = CSSStyleSheet::create(restoredSheet, m_owner); | 474 m_sheet = CSSStyleSheet::create(restoredSheet, m_owner); |
| 475 m_sheet->setMediaQueries(MediaQuerySet::create(m_owner->media())); | 475 m_sheet->setMediaQueries(MediaQuerySet::create(m_owner->media())); |
| 476 if (m_owner->isInDocumentTree()) | 476 if (m_owner->isInDocumentTree()) |
| 477 m_sheet->setTitle(m_owner->title()); | 477 m_sheet->setTitle(m_owner->title()); |
| 478 setCrossOriginStylesheetStatus(m_sheet.get()); | 478 setCrossOriginStylesheetStatus(m_sheet.get()); |
| 479 | 479 |
| 480 m_loading = false; | 480 m_loading = false; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 if (m_firedLoad) | 524 if (m_firedLoad) |
| 525 return; | 525 return; |
| 526 m_loadedSheet = (errorStatus == Node::NoErrorLoadingSubresource); | 526 m_loadedSheet = (errorStatus == Node::NoErrorLoadingSubresource); |
| 527 if (m_owner) | 527 if (m_owner) |
| 528 m_owner->scheduleEvent(); | 528 m_owner->scheduleEvent(); |
| 529 m_firedLoad = true; | 529 m_firedLoad = true; |
| 530 } | 530 } |
| 531 | 531 |
| 532 void LinkStyle::startLoadingDynamicSheet() | 532 void LinkStyle::startLoadingDynamicSheet() |
| 533 { | 533 { |
| 534 ASSERT(m_pendingSheetType < Blocking); | 534 DCHECK_LT(m_pendingSheetType, Blocking); |
| 535 addPendingSheet(Blocking); | 535 addPendingSheet(Blocking); |
| 536 } | 536 } |
| 537 | 537 |
| 538 void LinkStyle::clearSheet() | 538 void LinkStyle::clearSheet() |
| 539 { | 539 { |
| 540 ASSERT(m_sheet); | 540 DCHECK(m_sheet); |
| 541 ASSERT(m_sheet->ownerNode() == m_owner); | 541 DCHECK_EQ(m_sheet->ownerNode(), m_owner); |
| 542 m_sheet.release()->clearOwnerNode(); | 542 m_sheet.release()->clearOwnerNode(); |
| 543 } | 543 } |
| 544 | 544 |
| 545 bool LinkStyle::styleSheetIsLoading() const | 545 bool LinkStyle::styleSheetIsLoading() const |
| 546 { | 546 { |
| 547 if (m_loading) | 547 if (m_loading) |
| 548 return true; | 548 return true; |
| 549 if (!m_sheet) | 549 if (!m_sheet) |
| 550 return false; | 550 return false; |
| 551 return m_sheet->contents()->isLoading(); | 551 return m_sheet->contents()->isLoading(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 if (m_fetchFollowingCORS && resource() && !resource()->errorOccurred()) { | 621 if (m_fetchFollowingCORS && resource() && !resource()->errorOccurred()) { |
| 622 // Record the security origin the CORS access check succeeded at, if cro
ss origin. | 622 // Record the security origin the CORS access check succeeded at, if cro
ss origin. |
| 623 // Only origins that are script accessible to it may access the styleshe
et's rules. | 623 // Only origins that are script accessible to it may access the styleshe
et's rules. |
| 624 sheet->setAllowRuleAccessFromOrigin(m_owner->document().getSecurityOrigi
n()); | 624 sheet->setAllowRuleAccessFromOrigin(m_owner->document().getSecurityOrigi
n()); |
| 625 } | 625 } |
| 626 m_fetchFollowingCORS = false; | 626 m_fetchFollowingCORS = false; |
| 627 } | 627 } |
| 628 | 628 |
| 629 void LinkStyle::process() | 629 void LinkStyle::process() |
| 630 { | 630 { |
| 631 ASSERT(m_owner->shouldProcessStyle()); | 631 DCHECK(m_owner->shouldProcessStyle()); |
| 632 String type = m_owner->typeValue().lower(); | 632 String type = m_owner->typeValue().lower(); |
| 633 String as = m_owner->asValue().lower(); | 633 String as = m_owner->asValue().lower(); |
| 634 String media = m_owner->media().lower(); | 634 String media = m_owner->media().lower(); |
| 635 LinkRequestBuilder builder(m_owner); | 635 LinkRequestBuilder builder(m_owner); |
| 636 | 636 |
| 637 if (m_owner->relAttribute().getIconType() != InvalidIcon && builder.url().is
Valid() && !builder.url().isEmpty()) { | 637 if (m_owner->relAttribute().getIconType() != InvalidIcon && builder.url().is
Valid() && !builder.url().isEmpty()) { |
| 638 if (!m_owner->shouldLoadLink()) | 638 if (!m_owner->shouldLoadLink()) |
| 639 return; | 639 return; |
| 640 if (!document().getSecurityOrigin()->canDisplay(builder.url())) | 640 if (!document().getSecurityOrigin()->canDisplay(builder.url())) |
| 641 return; | 641 return; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 } | 726 } |
| 727 | 727 |
| 728 DEFINE_TRACE(LinkStyle) | 728 DEFINE_TRACE(LinkStyle) |
| 729 { | 729 { |
| 730 visitor->trace(m_sheet); | 730 visitor->trace(m_sheet); |
| 731 LinkResource::trace(visitor); | 731 LinkResource::trace(visitor); |
| 732 ResourceOwner<StyleSheetResource>::trace(visitor); | 732 ResourceOwner<StyleSheetResource>::trace(visitor); |
| 733 } | 733 } |
| 734 | 734 |
| 735 } // namespace blink | 735 } // namespace blink |
| OLD | NEW |