| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 } else if (name == scopeAttr) { | 112 } else if (name == scopeAttr) { |
| 113 m_scope = value; | 113 m_scope = value; |
| 114 process(); | 114 process(); |
| 115 } else if (name == disabledAttr) { | 115 } else if (name == disabledAttr) { |
| 116 UseCounter::count(document(), UseCounter::HTMLLinkElementDisabled); | 116 UseCounter::count(document(), UseCounter::HTMLLinkElementDisabled); |
| 117 if (LinkStyle* link = linkStyle()) | 117 if (LinkStyle* link = linkStyle()) |
| 118 link->setDisabledState(!value.isNull()); | 118 link->setDisabledState(!value.isNull()); |
| 119 } else { | 119 } else { |
| 120 if (name == titleAttr) { | 120 if (name == titleAttr) { |
| 121 if (LinkStyle* link = linkStyle()) | 121 if (LinkStyle* link = linkStyle()) |
| 122 link->setSheetTitle(value); | 122 link->setSheetTitle(value, StyleEngine::UpdateActiveSheets); |
| 123 } | 123 } |
| 124 | 124 |
| 125 HTMLElement::parseAttribute(name, oldValue, value); | 125 HTMLElement::parseAttribute(name, oldValue, value); |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 | 128 |
| 129 bool HTMLLinkElement::shouldLoadLink() | 129 bool HTMLLinkElement::shouldLoadLink() |
| 130 { | 130 { |
| 131 return isInDocumentTree() || (isConnected() && m_relAttribute.isStyleSheet()
); | 131 return isInDocumentTree() || (isConnected() && m_relAttribute.isStyleSheet()
); |
| 132 } | 132 } |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 | 455 |
| 456 if (StyleSheetContents* restoredSheet = const_cast<CSSStyleSheetResource*>(c
achedStyleSheet)->restoreParsedStyleSheet(parserContext)) { | 456 if (StyleSheetContents* restoredSheet = const_cast<CSSStyleSheetResource*>(c
achedStyleSheet)->restoreParsedStyleSheet(parserContext)) { |
| 457 DCHECK(restoredSheet->isCacheableForResource()); | 457 DCHECK(restoredSheet->isCacheableForResource()); |
| 458 DCHECK(!restoredSheet->isLoading()); | 458 DCHECK(!restoredSheet->isLoading()); |
| 459 | 459 |
| 460 if (m_sheet) | 460 if (m_sheet) |
| 461 clearSheet(); | 461 clearSheet(); |
| 462 m_sheet = CSSStyleSheet::create(restoredSheet, m_owner); | 462 m_sheet = CSSStyleSheet::create(restoredSheet, m_owner); |
| 463 m_sheet->setMediaQueries(MediaQuerySet::create(m_owner->media())); | 463 m_sheet->setMediaQueries(MediaQuerySet::create(m_owner->media())); |
| 464 if (m_owner->isInDocumentTree()) | 464 if (m_owner->isInDocumentTree()) |
| 465 m_sheet->setTitle(m_owner->title()); | 465 setSheetTitle(m_owner->title()); |
| 466 setCrossOriginStylesheetStatus(m_sheet.get()); | 466 setCrossOriginStylesheetStatus(m_sheet.get()); |
| 467 | 467 |
| 468 m_loading = false; | 468 m_loading = false; |
| 469 restoredSheet->checkLoaded(); | 469 restoredSheet->checkLoaded(); |
| 470 | 470 |
| 471 restoredCachedStyleSheetHistogram.count(true); | 471 restoredCachedStyleSheetHistogram.count(true); |
| 472 restoredCachedStyleSheet2Histogram.count(StyleSheetInMemoryCache); | 472 restoredCachedStyleSheet2Histogram.count(StyleSheetInMemoryCache); |
| 473 return; | 473 return; |
| 474 } | 474 } |
| 475 restoredCachedStyleSheetHistogram.count(false); | 475 restoredCachedStyleSheetHistogram.count(false); |
| 476 StyleSheetCacheStatus cacheStatus = cachedStyleSheet->response().wasCached()
? StyleSheetInDiskCache : StyleSheetNewEntry; | 476 StyleSheetCacheStatus cacheStatus = cachedStyleSheet->response().wasCached()
? StyleSheetInDiskCache : StyleSheetNewEntry; |
| 477 restoredCachedStyleSheet2Histogram.count(cacheStatus); | 477 restoredCachedStyleSheet2Histogram.count(cacheStatus); |
| 478 | 478 |
| 479 StyleSheetContents* styleSheet = StyleSheetContents::create(href, parserCont
ext); | 479 StyleSheetContents* styleSheet = StyleSheetContents::create(href, parserCont
ext); |
| 480 | 480 |
| 481 if (m_sheet) | 481 if (m_sheet) |
| 482 clearSheet(); | 482 clearSheet(); |
| 483 | 483 |
| 484 m_sheet = CSSStyleSheet::create(styleSheet, m_owner); | 484 m_sheet = CSSStyleSheet::create(styleSheet, m_owner); |
| 485 m_sheet->setMediaQueries(MediaQuerySet::create(m_owner->media())); | 485 m_sheet->setMediaQueries(MediaQuerySet::create(m_owner->media())); |
| 486 if (m_owner->isInDocumentTree()) | 486 if (m_owner->isInDocumentTree()) |
| 487 m_sheet->setTitle(m_owner->title()); | 487 setSheetTitle(m_owner->title()); |
| 488 setCrossOriginStylesheetStatus(m_sheet.get()); | 488 setCrossOriginStylesheetStatus(m_sheet.get()); |
| 489 | 489 |
| 490 styleSheet->parseAuthorStyleSheet(cachedStyleSheet, m_owner->document().getS
ecurityOrigin()); | 490 styleSheet->parseAuthorStyleSheet(cachedStyleSheet, m_owner->document().getS
ecurityOrigin()); |
| 491 | 491 |
| 492 m_loading = false; | 492 m_loading = false; |
| 493 styleSheet->notifyLoadedSheet(cachedStyleSheet); | 493 styleSheet->notifyLoadedSheet(cachedStyleSheet); |
| 494 styleSheet->checkLoaded(); | 494 styleSheet->checkLoaded(); |
| 495 | 495 |
| 496 if (styleSheet->isCacheableForResource()) | 496 if (styleSheet->isCacheableForResource()) |
| 497 const_cast<CSSStyleSheetResource*>(cachedStyleSheet)->saveParsedStyleShe
et(styleSheet); | 497 const_cast<CSSStyleSheetResource*>(cachedStyleSheet)->saveParsedStyleShe
et(styleSheet); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 clearFetchFollowingCORS(); | 643 clearFetchFollowingCORS(); |
| 644 } | 644 } |
| 645 | 645 |
| 646 if (!m_owner->shouldLoadLink()) | 646 if (!m_owner->shouldLoadLink()) |
| 647 return; | 647 return; |
| 648 | 648 |
| 649 m_loading = true; | 649 m_loading = true; |
| 650 | 650 |
| 651 String title = m_owner->title(); | 651 String title = m_owner->title(); |
| 652 if (!title.isEmpty() && !m_owner->isAlternate() && m_disabledState != En
abledViaScript && m_owner->isInDocumentTree()) | 652 if (!title.isEmpty() && !m_owner->isAlternate() && m_disabledState != En
abledViaScript && m_owner->isInDocumentTree()) |
| 653 document().styleEngine().setPreferredStylesheetSetNameIfNotSet(title
); | 653 document().styleEngine().setPreferredStylesheetSetNameIfNotSet(title
, StyleEngine::DontUpdateActiveSheets); |
| 654 | 654 |
| 655 bool mediaQueryMatches = true; | 655 bool mediaQueryMatches = true; |
| 656 LocalFrame* frame = loadingFrame(); | 656 LocalFrame* frame = loadingFrame(); |
| 657 if (!m_owner->media().isEmpty() && frame) { | 657 if (!m_owner->media().isEmpty() && frame) { |
| 658 MediaQuerySet* media = MediaQuerySet::create(m_owner->media()); | 658 MediaQuerySet* media = MediaQuerySet::create(m_owner->media()); |
| 659 MediaQueryEvaluator evaluator(frame); | 659 MediaQueryEvaluator evaluator(frame); |
| 660 mediaQueryMatches = evaluator.eval(media); | 660 mediaQueryMatches = evaluator.eval(media); |
| 661 } | 661 } |
| 662 | 662 |
| 663 // Don't hold up layout tree construction and script execution on styles
heets | 663 // Don't hold up layout tree construction and script execution on styles
heets |
| (...skipping 27 matching lines...) Expand all Loading... |
| 691 notifyLoadedSheetAndAllCriticalSubresources(Node::ErrorOccurredLoadi
ngSubresource); | 691 notifyLoadedSheetAndAllCriticalSubresources(Node::ErrorOccurredLoadi
ngSubresource); |
| 692 } | 692 } |
| 693 } else if (m_sheet) { | 693 } else if (m_sheet) { |
| 694 // we no longer contain a stylesheet, e.g. perhaps rel or type was chang
ed | 694 // we no longer contain a stylesheet, e.g. perhaps rel or type was chang
ed |
| 695 StyleSheet* removedSheet = m_sheet.get(); | 695 StyleSheet* removedSheet = m_sheet.get(); |
| 696 clearSheet(); | 696 clearSheet(); |
| 697 document().styleEngine().setNeedsActiveStyleUpdate(removedSheet, FullSty
leUpdate); | 697 document().styleEngine().setNeedsActiveStyleUpdate(removedSheet, FullSty
leUpdate); |
| 698 } | 698 } |
| 699 } | 699 } |
| 700 | 700 |
| 701 void LinkStyle::setSheetTitle(const String& title) | 701 void LinkStyle::setSheetTitle(const String& title, StyleEngine::ActiveSheetsUpda
te updateActiveSheets) |
| 702 { | 702 { |
| 703 if (m_sheet && m_owner->isInDocumentTree()) | 703 if (!m_owner->isInDocumentTree() || !m_owner->relAttribute().isStyleSheet()) |
| 704 return; |
| 705 |
| 706 if (m_sheet) |
| 704 m_sheet->setTitle(title); | 707 m_sheet->setTitle(title); |
| 708 |
| 709 if (title.isEmpty() || !isUnset() || m_owner->isAlternate()) |
| 710 return; |
| 711 |
| 712 KURL href = m_owner->getNonEmptyURLAttribute(hrefAttr); |
| 713 if (href.isValid() && !href.isEmpty()) |
| 714 document().styleEngine().setPreferredStylesheetSetNameIfNotSet(title, up
dateActiveSheets); |
| 705 } | 715 } |
| 706 | 716 |
| 707 void LinkStyle::ownerRemoved() | 717 void LinkStyle::ownerRemoved() |
| 708 { | 718 { |
| 709 if (m_sheet) | 719 if (m_sheet) |
| 710 clearSheet(); | 720 clearSheet(); |
| 711 | 721 |
| 712 if (styleSheetIsLoading()) | 722 if (styleSheetIsLoading()) |
| 713 removePendingSheet(); | 723 removePendingSheet(); |
| 714 } | 724 } |
| 715 | 725 |
| 716 DEFINE_TRACE(LinkStyle) | 726 DEFINE_TRACE(LinkStyle) |
| 717 { | 727 { |
| 718 visitor->trace(m_sheet); | 728 visitor->trace(m_sheet); |
| 719 LinkResource::trace(visitor); | 729 LinkResource::trace(visitor); |
| 720 ResourceOwner<StyleSheetResource>::trace(visitor); | 730 ResourceOwner<StyleSheetResource>::trace(visitor); |
| 721 } | 731 } |
| 722 | 732 |
| 723 } // namespace blink | 733 } // namespace blink |
| OLD | NEW |