| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 PassRefPtr<HTMLLinkElement> HTMLLinkElement::create(const QualifiedName& tagName
, Document* document, bool createdByParser) | 73 PassRefPtr<HTMLLinkElement> HTMLLinkElement::create(const QualifiedName& tagName
, Document* document, bool createdByParser) |
| 74 { | 74 { |
| 75 return adoptRef(new HTMLLinkElement(tagName, document, createdByParser)); | 75 return adoptRef(new HTMLLinkElement(tagName, document, createdByParser)); |
| 76 } | 76 } |
| 77 | 77 |
| 78 HTMLLinkElement::~HTMLLinkElement() | 78 HTMLLinkElement::~HTMLLinkElement() |
| 79 { | 79 { |
| 80 m_link.clear(); | 80 m_link.clear(); |
| 81 | 81 |
| 82 if (inDocument()) | 82 if (inDocument()) |
| 83 document()->styleSheetCollections()->removeStyleSheetCandidateNode(this)
; | 83 document().styleSheetCollections()->removeStyleSheetCandidateNode(this); |
| 84 | 84 |
| 85 linkLoadEventSender().cancelEvent(this); | 85 linkLoadEventSender().cancelEvent(this); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void HTMLLinkElement::parseAttribute(const QualifiedName& name, const AtomicStri
ng& value) | 88 void HTMLLinkElement::parseAttribute(const QualifiedName& name, const AtomicStri
ng& value) |
| 89 { | 89 { |
| 90 if (name == relAttr) { | 90 if (name == relAttr) { |
| 91 m_relAttribute = LinkRelAttribute(value); | 91 m_relAttribute = LinkRelAttribute(value); |
| 92 process(); | 92 process(); |
| 93 } else if (name == hrefAttr) { | 93 } else if (name == hrefAttr) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 112 link->setSheetTitle(value); | 112 link->setSheetTitle(value); |
| 113 } | 113 } |
| 114 | 114 |
| 115 HTMLElement::parseAttribute(name, value); | 115 HTMLElement::parseAttribute(name, value); |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 | 118 |
| 119 bool HTMLLinkElement::shouldLoadLink() | 119 bool HTMLLinkElement::shouldLoadLink() |
| 120 { | 120 { |
| 121 bool continueLoad = true; | 121 bool continueLoad = true; |
| 122 RefPtr<Document> originalDocument = document(); | 122 RefPtr<Document> originalDocument = &document(); |
| 123 int recursionRank = ++m_beforeLoadRecurseCount; | 123 int recursionRank = ++m_beforeLoadRecurseCount; |
| 124 if (!dispatchBeforeLoadEvent(getNonEmptyURLAttribute(hrefAttr))) | 124 if (!dispatchBeforeLoadEvent(getNonEmptyURLAttribute(hrefAttr))) |
| 125 continueLoad = false; | 125 continueLoad = false; |
| 126 | 126 |
| 127 // A beforeload handler might have removed us from the document or changed t
he document. | 127 // A beforeload handler might have removed us from the document or changed t
he document. |
| 128 if (continueLoad && (!inDocument() || document() != originalDocument)) | 128 if (continueLoad && (!inDocument() || &document() != originalDocument)) |
| 129 continueLoad = false; | 129 continueLoad = false; |
| 130 | 130 |
| 131 // If the beforeload handler recurses into the link element by mutating it,
we should only | 131 // If the beforeload handler recurses into the link element by mutating it,
we should only |
| 132 // let the latest (innermost) mutation occur. | 132 // let the latest (innermost) mutation occur. |
| 133 if (recursionRank != m_beforeLoadRecurseCount) | 133 if (recursionRank != m_beforeLoadRecurseCount) |
| 134 continueLoad = false; | 134 continueLoad = false; |
| 135 | 135 |
| 136 if (recursionRank == 1) | 136 if (recursionRank == 1) |
| 137 m_beforeLoadRecurseCount = 0; | 137 m_beforeLoadRecurseCount = 0; |
| 138 | 138 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 Node::InsertionNotificationRequest HTMLLinkElement::insertedInto(ContainerNode*
insertionPoint) | 191 Node::InsertionNotificationRequest HTMLLinkElement::insertedInto(ContainerNode*
insertionPoint) |
| 192 { | 192 { |
| 193 HTMLElement::insertedInto(insertionPoint); | 193 HTMLElement::insertedInto(insertionPoint); |
| 194 if (!insertionPoint->inDocument()) | 194 if (!insertionPoint->inDocument()) |
| 195 return InsertionDone; | 195 return InsertionDone; |
| 196 | 196 |
| 197 m_isInShadowTree = isInShadowTree(); | 197 m_isInShadowTree = isInShadowTree(); |
| 198 if (m_isInShadowTree) | 198 if (m_isInShadowTree) |
| 199 return InsertionDone; | 199 return InsertionDone; |
| 200 | 200 |
| 201 document()->styleSheetCollections()->addStyleSheetCandidateNode(this, m_crea
tedByParser); | 201 document().styleSheetCollections()->addStyleSheetCandidateNode(this, m_creat
edByParser); |
| 202 | 202 |
| 203 process(); | 203 process(); |
| 204 return InsertionDone; | 204 return InsertionDone; |
| 205 } | 205 } |
| 206 | 206 |
| 207 void HTMLLinkElement::removedFrom(ContainerNode* insertionPoint) | 207 void HTMLLinkElement::removedFrom(ContainerNode* insertionPoint) |
| 208 { | 208 { |
| 209 HTMLElement::removedFrom(insertionPoint); | 209 HTMLElement::removedFrom(insertionPoint); |
| 210 if (!insertionPoint->inDocument()) | 210 if (!insertionPoint->inDocument()) |
| 211 return; | 211 return; |
| 212 | 212 |
| 213 m_linkLoader.released(); | 213 m_linkLoader.released(); |
| 214 | 214 |
| 215 if (m_isInShadowTree) { | 215 if (m_isInShadowTree) { |
| 216 ASSERT(!linkStyle() || !linkStyle()->hasSheet()); | 216 ASSERT(!linkStyle() || !linkStyle()->hasSheet()); |
| 217 return; | 217 return; |
| 218 } | 218 } |
| 219 document()->styleSheetCollections()->removeStyleSheetCandidateNode(this); | 219 document().styleSheetCollections()->removeStyleSheetCandidateNode(this); |
| 220 | 220 |
| 221 RefPtr<StyleSheet> removedSheet = sheet(); | 221 RefPtr<StyleSheet> removedSheet = sheet(); |
| 222 | 222 |
| 223 if (m_link) | 223 if (m_link) |
| 224 m_link->ownerRemoved(); | 224 m_link->ownerRemoved(); |
| 225 | 225 |
| 226 if (document()->renderer()) | 226 if (document().renderer()) |
| 227 document()->removedStyleSheet(removedSheet.get()); | 227 document().removedStyleSheet(removedSheet.get()); |
| 228 } | 228 } |
| 229 | 229 |
| 230 void HTMLLinkElement::finishParsingChildren() | 230 void HTMLLinkElement::finishParsingChildren() |
| 231 { | 231 { |
| 232 m_createdByParser = false; | 232 m_createdByParser = false; |
| 233 HTMLElement::finishParsingChildren(); | 233 HTMLElement::finishParsingChildren(); |
| 234 } | 234 } |
| 235 | 235 |
| 236 bool HTMLLinkElement::styleSheetIsLoading() const | 236 bool HTMLLinkElement::styleSheetIsLoading() const |
| 237 { | 237 { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 linkStyle()->startLoadingDynamicSheet(); | 306 linkStyle()->startLoadingDynamicSheet(); |
| 307 } | 307 } |
| 308 | 308 |
| 309 bool HTMLLinkElement::isURLAttribute(const Attribute& attribute) const | 309 bool HTMLLinkElement::isURLAttribute(const Attribute& attribute) const |
| 310 { | 310 { |
| 311 return attribute.name().localName() == hrefAttr || HTMLElement::isURLAttribu
te(attribute); | 311 return attribute.name().localName() == hrefAttr || HTMLElement::isURLAttribu
te(attribute); |
| 312 } | 312 } |
| 313 | 313 |
| 314 KURL HTMLLinkElement::href() const | 314 KURL HTMLLinkElement::href() const |
| 315 { | 315 { |
| 316 return document()->completeURL(getAttribute(hrefAttr)); | 316 return document().completeURL(getAttribute(hrefAttr)); |
| 317 } | 317 } |
| 318 | 318 |
| 319 String HTMLLinkElement::rel() const | 319 String HTMLLinkElement::rel() const |
| 320 { | 320 { |
| 321 return getAttribute(relAttr); | 321 return getAttribute(relAttr); |
| 322 } | 322 } |
| 323 | 323 |
| 324 String HTMLLinkElement::target() const | 324 String HTMLLinkElement::target() const |
| 325 { | 325 { |
| 326 return getAttribute(targetAttr); | 326 return getAttribute(targetAttr); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 | 388 |
| 389 LinkStyle::~LinkStyle() | 389 LinkStyle::~LinkStyle() |
| 390 { | 390 { |
| 391 if (m_sheet) | 391 if (m_sheet) |
| 392 m_sheet->clearOwnerNode(); | 392 m_sheet->clearOwnerNode(); |
| 393 | 393 |
| 394 if (m_resource) | 394 if (m_resource) |
| 395 m_resource->removeClient(this); | 395 m_resource->removeClient(this); |
| 396 } | 396 } |
| 397 | 397 |
| 398 Document* LinkStyle::document() | 398 Document& LinkStyle::document() |
| 399 { | 399 { |
| 400 return m_owner->document(); | 400 return m_owner->document(); |
| 401 } | 401 } |
| 402 | 402 |
| 403 void LinkStyle::setCSSStyleSheet(const String& href, const KURL& baseURL, const
String& charset, const CSSStyleSheetResource* cachedStyleSheet) | 403 void LinkStyle::setCSSStyleSheet(const String& href, const KURL& baseURL, const
String& charset, const CSSStyleSheetResource* cachedStyleSheet) |
| 404 { | 404 { |
| 405 if (!m_owner->inDocument()) { | 405 if (!m_owner->inDocument()) { |
| 406 ASSERT(!m_sheet); | 406 ASSERT(!m_sheet); |
| 407 return; | 407 return; |
| 408 | 408 |
| 409 } | 409 } |
| 410 // Completing the sheet load may cause scripts to execute. | 410 // Completing the sheet load may cause scripts to execute. |
| 411 RefPtr<Node> protector(m_owner); | 411 RefPtr<Node> protector(m_owner); |
| 412 | 412 |
| 413 CSSParserContext parserContext(m_owner->document(), baseURL, charset); | 413 CSSParserContext parserContext(&m_owner->document(), baseURL, charset); |
| 414 | 414 |
| 415 if (RefPtr<StyleSheetContents> restoredSheet = const_cast<CSSStyleSheetResou
rce*>(cachedStyleSheet)->restoreParsedStyleSheet(parserContext)) { | 415 if (RefPtr<StyleSheetContents> restoredSheet = const_cast<CSSStyleSheetResou
rce*>(cachedStyleSheet)->restoreParsedStyleSheet(parserContext)) { |
| 416 ASSERT(restoredSheet->isCacheable()); | 416 ASSERT(restoredSheet->isCacheable()); |
| 417 ASSERT(!restoredSheet->isLoading()); | 417 ASSERT(!restoredSheet->isLoading()); |
| 418 | 418 |
| 419 if (m_sheet) | 419 if (m_sheet) |
| 420 clearSheet(); | 420 clearSheet(); |
| 421 m_sheet = CSSStyleSheet::create(restoredSheet, m_owner); | 421 m_sheet = CSSStyleSheet::create(restoredSheet, m_owner); |
| 422 m_sheet->setMediaQueries(MediaQuerySet::create(m_owner->media())); | 422 m_sheet->setMediaQueries(MediaQuerySet::create(m_owner->media())); |
| 423 m_sheet->setTitle(m_owner->title()); | 423 m_sheet->setTitle(m_owner->title()); |
| 424 | 424 |
| 425 m_loading = false; | 425 m_loading = false; |
| 426 sheetLoaded(); | 426 sheetLoaded(); |
| 427 notifyLoadedSheetAndAllCriticalSubresources(false); | 427 notifyLoadedSheetAndAllCriticalSubresources(false); |
| 428 return; | 428 return; |
| 429 } | 429 } |
| 430 | 430 |
| 431 RefPtr<StyleSheetContents> styleSheet = StyleSheetContents::create(href, par
serContext); | 431 RefPtr<StyleSheetContents> styleSheet = StyleSheetContents::create(href, par
serContext); |
| 432 | 432 |
| 433 if (m_sheet) | 433 if (m_sheet) |
| 434 clearSheet(); | 434 clearSheet(); |
| 435 m_sheet = CSSStyleSheet::create(styleSheet, m_owner); | 435 m_sheet = CSSStyleSheet::create(styleSheet, m_owner); |
| 436 m_sheet->setMediaQueries(MediaQuerySet::create(m_owner->media())); | 436 m_sheet->setMediaQueries(MediaQuerySet::create(m_owner->media())); |
| 437 m_sheet->setTitle(m_owner->title()); | 437 m_sheet->setTitle(m_owner->title()); |
| 438 | 438 |
| 439 styleSheet->parseAuthorStyleSheet(cachedStyleSheet, m_owner->document()->sec
urityOrigin()); | 439 styleSheet->parseAuthorStyleSheet(cachedStyleSheet, m_owner->document().secu
rityOrigin()); |
| 440 | 440 |
| 441 m_loading = false; | 441 m_loading = false; |
| 442 styleSheet->notifyLoadedSheet(cachedStyleSheet); | 442 styleSheet->notifyLoadedSheet(cachedStyleSheet); |
| 443 styleSheet->checkLoaded(); | 443 styleSheet->checkLoaded(); |
| 444 | 444 |
| 445 if (styleSheet->isCacheable()) | 445 if (styleSheet->isCacheable()) |
| 446 const_cast<CSSStyleSheetResource*>(cachedStyleSheet)->saveParsedStyleShe
et(styleSheet); | 446 const_cast<CSSStyleSheetResource*>(cachedStyleSheet)->saveParsedStyleShe
et(styleSheet); |
| 447 } | 447 } |
| 448 | 448 |
| 449 bool LinkStyle::sheetLoaded() | 449 bool LinkStyle::sheetLoaded() |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 } | 489 } |
| 490 | 490 |
| 491 void LinkStyle::addPendingSheet(PendingSheetType type) | 491 void LinkStyle::addPendingSheet(PendingSheetType type) |
| 492 { | 492 { |
| 493 if (type <= m_pendingSheetType) | 493 if (type <= m_pendingSheetType) |
| 494 return; | 494 return; |
| 495 m_pendingSheetType = type; | 495 m_pendingSheetType = type; |
| 496 | 496 |
| 497 if (m_pendingSheetType == NonBlocking) | 497 if (m_pendingSheetType == NonBlocking) |
| 498 return; | 498 return; |
| 499 m_owner->document()->styleSheetCollections()->addPendingSheet(); | 499 m_owner->document().styleSheetCollections()->addPendingSheet(); |
| 500 } | 500 } |
| 501 | 501 |
| 502 void LinkStyle::removePendingSheet(RemovePendingSheetNotificationType notificati
on) | 502 void LinkStyle::removePendingSheet(RemovePendingSheetNotificationType notificati
on) |
| 503 { | 503 { |
| 504 PendingSheetType type = m_pendingSheetType; | 504 PendingSheetType type = m_pendingSheetType; |
| 505 m_pendingSheetType = None; | 505 m_pendingSheetType = None; |
| 506 | 506 |
| 507 if (type == None) | 507 if (type == None) |
| 508 return; | 508 return; |
| 509 if (type == NonBlocking) { | 509 if (type == NonBlocking) { |
| 510 // Tell StyleSheetCollections to re-compute styleSheets of this m_owner'
s treescope. | 510 // Tell StyleSheetCollections to re-compute styleSheets of this m_owner'
s treescope. |
| 511 m_owner->document()->styleSheetCollections()->modifiedStyleSheetCandidat
eNode(m_owner); | 511 m_owner->document().styleSheetCollections()->modifiedStyleSheetCandidate
Node(m_owner); |
| 512 // Document::removePendingSheet() triggers the style selector recalc for
blocking sheets. | 512 // Document::removePendingSheet() triggers the style selector recalc for
blocking sheets. |
| 513 // FIXME: We don't have enough knowledge at this point to know if we're
adding or removing a sheet | 513 // FIXME: We don't have enough knowledge at this point to know if we're
adding or removing a sheet |
| 514 // so we can't call addedStyleSheet() or removedStyleSheet(). | 514 // so we can't call addedStyleSheet() or removedStyleSheet(). |
| 515 m_owner->document()->styleResolverChanged(RecalcStyleImmediately); | 515 m_owner->document().styleResolverChanged(RecalcStyleImmediately); |
| 516 return; | 516 return; |
| 517 } | 517 } |
| 518 | 518 |
| 519 m_owner->document()->styleSheetCollections()->removePendingSheet(m_owner, | 519 m_owner->document().styleSheetCollections()->removePendingSheet(m_owner, |
| 520 notification == RemovePendingSheetNotifyImmediately | 520 notification == RemovePendingSheetNotifyImmediately |
| 521 ? StyleSheetCollections::RemovePendingSheetNotifyImmediately | 521 ? StyleSheetCollections::RemovePendingSheetNotifyImmediately |
| 522 : StyleSheetCollections::RemovePendingSheetNotifyLater); | 522 : StyleSheetCollections::RemovePendingSheetNotifyLater); |
| 523 } | 523 } |
| 524 | 524 |
| 525 void LinkStyle::setDisabledState(bool disabled) | 525 void LinkStyle::setDisabledState(bool disabled) |
| 526 { | 526 { |
| 527 LinkStyle::DisabledState oldDisabledState = m_disabledState; | 527 LinkStyle::DisabledState oldDisabledState = m_disabledState; |
| 528 m_disabledState = disabled ? Disabled : EnabledViaScript; | 528 m_disabledState = disabled ? Disabled : EnabledViaScript; |
| 529 if (oldDisabledState != m_disabledState) { | 529 if (oldDisabledState != m_disabledState) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 552 | 552 |
| 553 if (m_sheet) | 553 if (m_sheet) |
| 554 m_sheet->setDisabled(disabled); | 554 m_sheet->setDisabled(disabled); |
| 555 | 555 |
| 556 // Load the sheet, since it's never been loaded before. | 556 // Load the sheet, since it's never been loaded before. |
| 557 if (!m_sheet && m_disabledState == EnabledViaScript) { | 557 if (!m_sheet && m_disabledState == EnabledViaScript) { |
| 558 if (m_owner->shouldProcessStyle()) | 558 if (m_owner->shouldProcessStyle()) |
| 559 process(); | 559 process(); |
| 560 } else { | 560 } else { |
| 561 // FIXME: We don't have enough knowledge here to know if we should c
all addedStyleSheet() or removedStyleSheet(). | 561 // FIXME: We don't have enough knowledge here to know if we should c
all addedStyleSheet() or removedStyleSheet(). |
| 562 m_owner->document()->styleResolverChanged(RecalcStyleDeferred); | 562 m_owner->document().styleResolverChanged(RecalcStyleDeferred); |
| 563 } | 563 } |
| 564 } | 564 } |
| 565 } | 565 } |
| 566 | 566 |
| 567 void LinkStyle::process() | 567 void LinkStyle::process() |
| 568 { | 568 { |
| 569 ASSERT(m_owner->shouldProcessStyle()); | 569 ASSERT(m_owner->shouldProcessStyle()); |
| 570 String type = m_owner->typeValue().lower(); | 570 String type = m_owner->typeValue().lower(); |
| 571 LinkRequestBuilder builder(m_owner); | 571 LinkRequestBuilder builder(m_owner); |
| 572 | 572 |
| 573 if (m_owner->relAttribute().iconType() != InvalidIcon && builder.url().isVal
id() && !builder.url().isEmpty()) { | 573 if (m_owner->relAttribute().iconType() != InvalidIcon && builder.url().isVal
id() && !builder.url().isEmpty()) { |
| 574 if (!m_owner->shouldLoadLink()) | 574 if (!m_owner->shouldLoadLink()) |
| 575 return; | 575 return; |
| 576 if (!document()->securityOrigin()->canDisplay(builder.url())) | 576 if (!document().securityOrigin()->canDisplay(builder.url())) |
| 577 return; | 577 return; |
| 578 if (!document()->contentSecurityPolicy()->allowImageFromSource(builder.u
rl())) | 578 if (!document().contentSecurityPolicy()->allowImageFromSource(builder.ur
l())) |
| 579 return; | 579 return; |
| 580 if (document()->frame()) | 580 if (document().frame()) |
| 581 document()->frame()->loader()->client()->dispatchDidChangeIcons(m_ow
ner->relAttribute().iconType()); | 581 document().frame()->loader()->client()->dispatchDidChangeIcons(m_own
er->relAttribute().iconType()); |
| 582 } | 582 } |
| 583 | 583 |
| 584 if (!m_owner->loadLink(type, builder.url())) | 584 if (!m_owner->loadLink(type, builder.url())) |
| 585 return; | 585 return; |
| 586 | 586 |
| 587 if ((m_disabledState != Disabled) && m_owner->relAttribute().isStyleSheet() | 587 if ((m_disabledState != Disabled) && m_owner->relAttribute().isStyleSheet() |
| 588 && document()->frame() && builder.url().isValid()) { | 588 && document().frame() && builder.url().isValid()) { |
| 589 | 589 |
| 590 if (m_resource) { | 590 if (m_resource) { |
| 591 removePendingSheet(); | 591 removePendingSheet(); |
| 592 m_resource->removeClient(this); | 592 m_resource->removeClient(this); |
| 593 m_resource = 0; | 593 m_resource = 0; |
| 594 } | 594 } |
| 595 | 595 |
| 596 if (!m_owner->shouldLoadLink()) | 596 if (!m_owner->shouldLoadLink()) |
| 597 return; | 597 return; |
| 598 | 598 |
| 599 m_loading = true; | 599 m_loading = true; |
| 600 | 600 |
| 601 bool mediaQueryMatches = true; | 601 bool mediaQueryMatches = true; |
| 602 if (!m_owner->media().isEmpty()) { | 602 if (!m_owner->media().isEmpty()) { |
| 603 RefPtr<RenderStyle> documentStyle = StyleResolver::styleForDocument(
document()); | 603 RefPtr<RenderStyle> documentStyle = StyleResolver::styleForDocument(
&document()); |
| 604 RefPtr<MediaQuerySet> media = MediaQuerySet::create(m_owner->media()
); | 604 RefPtr<MediaQuerySet> media = MediaQuerySet::create(m_owner->media()
); |
| 605 MediaQueryEvaluator evaluator(document()->frame()->view()->mediaType
(), document()->frame(), documentStyle.get()); | 605 MediaQueryEvaluator evaluator(document().frame()->view()->mediaType(
), document().frame(), documentStyle.get()); |
| 606 mediaQueryMatches = evaluator.eval(media.get()); | 606 mediaQueryMatches = evaluator.eval(media.get()); |
| 607 } | 607 } |
| 608 | 608 |
| 609 // Don't hold up render tree construction and script execution on styles
heets | 609 // Don't hold up render tree construction and script execution on styles
heets |
| 610 // that are not needed for the rendering at the moment. | 610 // that are not needed for the rendering at the moment. |
| 611 bool blocking = mediaQueryMatches && !m_owner->isAlternate(); | 611 bool blocking = mediaQueryMatches && !m_owner->isAlternate(); |
| 612 addPendingSheet(blocking ? Blocking : NonBlocking); | 612 addPendingSheet(blocking ? Blocking : NonBlocking); |
| 613 | 613 |
| 614 // Load stylesheets that are not needed for the rendering immediately wi
th low priority. | 614 // Load stylesheets that are not needed for the rendering immediately wi
th low priority. |
| 615 FetchRequest request = builder.build(blocking); | 615 FetchRequest request = builder.build(blocking); |
| 616 m_resource = document()->fetcher()->fetchCSSStyleSheet(request); | 616 m_resource = document().fetcher()->fetchCSSStyleSheet(request); |
| 617 | 617 |
| 618 if (m_resource) | 618 if (m_resource) |
| 619 m_resource->addClient(this); | 619 m_resource->addClient(this); |
| 620 else { | 620 else { |
| 621 // The request may have been denied if (for example) the stylesheet
is local and the document is remote. | 621 // The request may have been denied if (for example) the stylesheet
is local and the document is remote. |
| 622 m_loading = false; | 622 m_loading = false; |
| 623 removePendingSheet(); | 623 removePendingSheet(); |
| 624 } | 624 } |
| 625 } else if (m_sheet) { | 625 } else if (m_sheet) { |
| 626 // we no longer contain a stylesheet, e.g. perhaps rel or type was chang
ed | 626 // we no longer contain a stylesheet, e.g. perhaps rel or type was chang
ed |
| 627 RefPtr<StyleSheet> removedSheet = m_sheet; | 627 RefPtr<StyleSheet> removedSheet = m_sheet; |
| 628 clearSheet(); | 628 clearSheet(); |
| 629 document()->removedStyleSheet(removedSheet.get()); | 629 document().removedStyleSheet(removedSheet.get()); |
| 630 } | 630 } |
| 631 } | 631 } |
| 632 | 632 |
| 633 void LinkStyle::setSheetTitle(const String& title) | 633 void LinkStyle::setSheetTitle(const String& title) |
| 634 { | 634 { |
| 635 if (m_sheet) | 635 if (m_sheet) |
| 636 m_sheet->setTitle(title); | 636 m_sheet->setTitle(title); |
| 637 } | 637 } |
| 638 | 638 |
| 639 void LinkStyle::ownerRemoved() | 639 void LinkStyle::ownerRemoved() |
| 640 { | 640 { |
| 641 if (m_sheet) | 641 if (m_sheet) |
| 642 clearSheet(); | 642 clearSheet(); |
| 643 | 643 |
| 644 if (styleSheetIsLoading()) | 644 if (styleSheetIsLoading()) |
| 645 removePendingSheet(RemovePendingSheetNotifyLater); | 645 removePendingSheet(RemovePendingSheetNotifyLater); |
| 646 } | 646 } |
| 647 | 647 |
| 648 } // namespace WebCore | 648 } // namespace WebCore |
| OLD | NEW |