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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 if (!insertionPoint->isConnected()) | 198 if (!insertionPoint->isConnected()) |
199 return InsertionDone; | 199 return InsertionDone; |
200 DCHECK(isConnected()); | 200 DCHECK(isConnected()); |
201 if (!shouldLoadLink()) { | 201 if (!shouldLoadLink()) { |
202 DCHECK(isInShadowTree()); | 202 DCHECK(isInShadowTree()); |
203 String message = "HTML element <link> is ignored in shadow tree."; | 203 String message = "HTML element <link> is ignored in shadow tree."; |
204 document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, War
ningMessageLevel, message)); | 204 document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, War
ningMessageLevel, message)); |
205 return InsertionDone; | 205 return InsertionDone; |
206 } | 206 } |
207 | 207 |
208 document().styleEngine().addStyleSheetCandidateNode(this); | 208 document().styleEngine().addStyleSheetCandidateNode(*this); |
209 | 209 |
210 process(); | 210 process(); |
211 | 211 |
212 if (m_link) | 212 if (m_link) |
213 m_link->ownerInserted(); | 213 m_link->ownerInserted(); |
214 | 214 |
215 return InsertionDone; | 215 return InsertionDone; |
216 } | 216 } |
217 | 217 |
218 void HTMLLinkElement::removedFrom(ContainerNode* insertionPoint) | 218 void HTMLLinkElement::removedFrom(ContainerNode* insertionPoint) |
219 { | 219 { |
220 // Store the result of isConnected() here before Node::removedFrom(..) clear
s the flags. | 220 // Store the result of isConnected() here before Node::removedFrom(..) clear
s the flags. |
221 bool wasConnected = isConnected(); | 221 bool wasConnected = isConnected(); |
222 HTMLElement::removedFrom(insertionPoint); | 222 HTMLElement::removedFrom(insertionPoint); |
223 if (!insertionPoint->isConnected()) | 223 if (!insertionPoint->isConnected()) |
224 return; | 224 return; |
225 | 225 |
226 m_linkLoader->released(); | 226 m_linkLoader->released(); |
227 | 227 |
228 if (!wasConnected) { | 228 if (!wasConnected) { |
229 DCHECK(!linkStyle() || !linkStyle()->hasSheet()); | 229 DCHECK(!linkStyle() || !linkStyle()->hasSheet()); |
230 return; | 230 return; |
231 } | 231 } |
232 document().styleEngine().removeStyleSheetCandidateNode(this); | 232 document().styleEngine().removeStyleSheetCandidateNode(*this); |
233 | 233 |
234 StyleSheet* removedSheet = sheet(); | 234 StyleSheet* removedSheet = sheet(); |
235 | 235 |
236 if (m_link) | 236 if (m_link) |
237 m_link->ownerRemoved(); | 237 m_link->ownerRemoved(); |
238 | 238 |
239 document().styleEngine().setNeedsActiveStyleUpdate(removedSheet, FullStyleUp
date); | 239 document().styleEngine().setNeedsActiveStyleUpdate(removedSheet, FullStyleUp
date); |
240 } | 240 } |
241 | 241 |
242 void HTMLLinkElement::finishParsingChildren() | 242 void HTMLLinkElement::finishParsingChildren() |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 | 452 |
453 DEFINE_STATIC_LOCAL(EnumerationHistogram, restoredCachedStyleSheetHistogram,
("Blink.RestoredCachedStyleSheet", 2)); | 453 DEFINE_STATIC_LOCAL(EnumerationHistogram, restoredCachedStyleSheetHistogram,
("Blink.RestoredCachedStyleSheet", 2)); |
454 DEFINE_STATIC_LOCAL(EnumerationHistogram, restoredCachedStyleSheet2Histogram
, ("Blink.RestoredCachedStyleSheet2", StyleSheetCacheStatusCount)); | 454 DEFINE_STATIC_LOCAL(EnumerationHistogram, restoredCachedStyleSheet2Histogram
, ("Blink.RestoredCachedStyleSheet2", StyleSheetCacheStatusCount)); |
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 setSheetTitle(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 setSheetTitle(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(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 return; | 545 return; |
546 m_pendingSheetType = type; | 546 m_pendingSheetType = type; |
547 | 547 |
548 if (m_pendingSheetType == NonBlocking) | 548 if (m_pendingSheetType == NonBlocking) |
549 return; | 549 return; |
550 m_owner->document().styleEngine().addPendingSheet(m_styleEngineContext); | 550 m_owner->document().styleEngine().addPendingSheet(m_styleEngineContext); |
551 } | 551 } |
552 | 552 |
553 void LinkStyle::removePendingSheet() | 553 void LinkStyle::removePendingSheet() |
554 { | 554 { |
| 555 DCHECK(m_owner); |
555 PendingSheetType type = m_pendingSheetType; | 556 PendingSheetType type = m_pendingSheetType; |
556 m_pendingSheetType = None; | 557 m_pendingSheetType = None; |
557 | 558 |
558 if (type == None) | 559 if (type == None) |
559 return; | 560 return; |
560 if (type == NonBlocking) { | 561 if (type == NonBlocking) { |
561 // Tell StyleEngine to re-compute styleSheets of this m_owner's treescop
e. | 562 // Tell StyleEngine to re-compute styleSheets of this m_owner's treescop
e. |
562 m_owner->document().styleEngine().modifiedStyleSheetCandidateNode(m_owne
r); | 563 m_owner->document().styleEngine().modifiedStyleSheetCandidateNode(*m_own
er); |
563 return; | 564 return; |
564 } | 565 } |
565 | 566 |
566 m_owner->document().styleEngine().removePendingSheet(m_owner, m_styleEngineC
ontext); | 567 m_owner->document().styleEngine().removePendingSheet(*m_owner, m_styleEngine
Context); |
567 } | 568 } |
568 | 569 |
569 void LinkStyle::setDisabledState(bool disabled) | 570 void LinkStyle::setDisabledState(bool disabled) |
570 { | 571 { |
571 LinkStyle::DisabledState oldDisabledState = m_disabledState; | 572 LinkStyle::DisabledState oldDisabledState = m_disabledState; |
572 m_disabledState = disabled ? Disabled : EnabledViaScript; | 573 m_disabledState = disabled ? Disabled : EnabledViaScript; |
573 if (oldDisabledState != m_disabledState) { | 574 if (oldDisabledState != m_disabledState) { |
574 // If we change the disabled state while the sheet is still loading, the
n we have to | 575 // If we change the disabled state while the sheet is still loading, the
n we have to |
575 // perform three checks: | 576 // perform three checks: |
576 if (styleSheetIsLoading()) { | 577 if (styleSheetIsLoading()) { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 } | 725 } |
725 | 726 |
726 DEFINE_TRACE(LinkStyle) | 727 DEFINE_TRACE(LinkStyle) |
727 { | 728 { |
728 visitor->trace(m_sheet); | 729 visitor->trace(m_sheet); |
729 LinkResource::trace(visitor); | 730 LinkResource::trace(visitor); |
730 ResourceOwner<StyleSheetResource>::trace(visitor); | 731 ResourceOwner<StyleSheetResource>::trace(visitor); |
731 } | 732 } |
732 | 733 |
733 } // namespace blink | 734 } // namespace blink |
OLD | NEW |