| 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 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r
ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r
ights reserved. |
| 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
| 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // Cleanup is performed eagerly when the StyleEngine is removed from the | 83 // Cleanup is performed eagerly when the StyleEngine is removed from the |
| 84 // document. The StyleEngine is unreachable after this, since only the | 84 // document. The StyleEngine is unreachable after this, since only the |
| 85 // document has a reference to it. | 85 // document has a reference to it. |
| 86 for (unsigned i = 0; i < m_injectedAuthorStyleSheets.size(); ++i) | 86 for (unsigned i = 0; i < m_injectedAuthorStyleSheets.size(); ++i) |
| 87 m_injectedAuthorStyleSheets[i]->clearOwnerNode(); | 87 m_injectedAuthorStyleSheets[i]->clearOwnerNode(); |
| 88 for (unsigned i = 0; i < m_authorStyleSheets.size(); ++i) | 88 for (unsigned i = 0; i < m_authorStyleSheets.size(); ++i) |
| 89 m_authorStyleSheets[i]->clearOwnerNode(); | 89 m_authorStyleSheets[i]->clearOwnerNode(); |
| 90 | 90 |
| 91 if (m_fontSelector) { | 91 if (m_fontSelector) { |
| 92 m_fontSelector->clearDocument(); | 92 m_fontSelector->clearDocument(); |
| 93 #if !ENABLE(OILPAN) |
| 93 if (m_resolver) | 94 if (m_resolver) |
| 94 m_fontSelector->unregisterForInvalidationCallbacks(m_resolver.get())
; | 95 m_fontSelector->unregisterForInvalidationCallbacks(m_resolver.get())
; |
| 96 #endif |
| 95 } | 97 } |
| 96 | 98 |
| 97 // Decrement reference counts for things we could be keeping alive. | 99 // Decrement reference counts for things we could be keeping alive. |
| 98 m_fontSelector.clear(); | 100 m_fontSelector.clear(); |
| 99 m_resolver.clear(); | 101 m_resolver.clear(); |
| 100 m_styleSheetCollectionMap.clear(); | 102 m_styleSheetCollectionMap.clear(); |
| 101 } | 103 } |
| 102 | 104 |
| 103 inline Document* StyleEngine::master() | 105 inline Document* StyleEngine::master() |
| 104 { | 106 { |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 | 442 |
| 441 void StyleEngine::createResolver() | 443 void StyleEngine::createResolver() |
| 442 { | 444 { |
| 443 // It is a programming error to attempt to resolve style on a Document | 445 // It is a programming error to attempt to resolve style on a Document |
| 444 // which is not in a frame. Code which hits this should have checked | 446 // which is not in a frame. Code which hits this should have checked |
| 445 // Document::isActive() before calling into code which could get here. | 447 // Document::isActive() before calling into code which could get here. |
| 446 | 448 |
| 447 ASSERT(m_document.frame()); | 449 ASSERT(m_document.frame()); |
| 448 ASSERT(m_fontSelector); | 450 ASSERT(m_fontSelector); |
| 449 | 451 |
| 450 m_resolver = adoptPtr(new StyleResolver(m_document)); | 452 m_resolver = adoptPtrWillBeNoop(new StyleResolver(m_document)); |
| 451 appendActiveAuthorStyleSheets(); | 453 appendActiveAuthorStyleSheets(); |
| 452 m_fontSelector->registerForInvalidationCallbacks(m_resolver.get()); | 454 m_fontSelector->registerForInvalidationCallbacks(m_resolver.get()); |
| 453 combineCSSFeatureFlags(m_resolver->ensureUpdatedRuleFeatureSet()); | 455 combineCSSFeatureFlags(m_resolver->ensureUpdatedRuleFeatureSet()); |
| 454 } | 456 } |
| 455 | 457 |
| 456 void StyleEngine::clearResolver() | 458 void StyleEngine::clearResolver() |
| 457 { | 459 { |
| 458 ASSERT(!m_document.inStyleRecalc()); | 460 ASSERT(!m_document.inStyleRecalc()); |
| 459 ASSERT(isMaster() || !m_resolver); | 461 ASSERT(isMaster() || !m_resolver); |
| 460 ASSERT(m_fontSelector || !m_resolver); | 462 ASSERT(m_fontSelector || !m_resolver); |
| 461 if (m_resolver) { | 463 if (m_resolver) { |
| 462 m_document.updateStyleInvalidationIfNeeded(); | 464 m_document.updateStyleInvalidationIfNeeded(); |
| 465 #if !ENABLE(OILPAN) |
| 463 m_fontSelector->unregisterForInvalidationCallbacks(m_resolver.get()); | 466 m_fontSelector->unregisterForInvalidationCallbacks(m_resolver.get()); |
| 467 #endif |
| 464 } | 468 } |
| 465 m_resolver.clear(); | 469 m_resolver.clear(); |
| 466 } | 470 } |
| 467 | 471 |
| 468 void StyleEngine::clearMasterResolver() | 472 void StyleEngine::clearMasterResolver() |
| 469 { | 473 { |
| 470 if (Document* master = this->master()) | 474 if (Document* master = this->master()) |
| 471 master->styleEngine()->clearResolver(); | 475 master->styleEngine()->clearResolver(); |
| 472 } | 476 } |
| 473 | 477 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 | 582 |
| 579 PassRefPtrWillBeRawPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const
String& text, TextPosition startPosition, bool createdByParser) | 583 PassRefPtrWillBeRawPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const
String& text, TextPosition startPosition, bool createdByParser) |
| 580 { | 584 { |
| 581 RefPtrWillBeRawPtr<CSSStyleSheet> styleSheet = nullptr; | 585 RefPtrWillBeRawPtr<CSSStyleSheet> styleSheet = nullptr; |
| 582 | 586 |
| 583 e->document().styleEngine()->addPendingSheet(); | 587 e->document().styleEngine()->addPendingSheet(); |
| 584 | 588 |
| 585 if (!e->document().inQuirksMode()) { | 589 if (!e->document().inQuirksMode()) { |
| 586 AtomicString textContent(text); | 590 AtomicString textContent(text); |
| 587 | 591 |
| 588 HashMap<AtomicString, StyleSheetContents*>::AddResult result = m_textToS
heetCache.add(textContent, 0); | 592 WillBeHeapHashMap<AtomicString, RawPtrWillBeMember<StyleSheetContents> >
::AddResult result = m_textToSheetCache.add(textContent, nullptr); |
| 589 if (result.isNewEntry || !result.storedValue->value) { | 593 if (result.isNewEntry || !result.storedValue->value) { |
| 590 styleSheet = StyleEngine::parseSheet(e, text, startPosition, created
ByParser); | 594 styleSheet = StyleEngine::parseSheet(e, text, startPosition, created
ByParser); |
| 591 if (result.isNewEntry && isCacheableForStyleElement(*styleSheet->con
tents())) { | 595 if (result.isNewEntry && isCacheableForStyleElement(*styleSheet->con
tents())) { |
| 592 result.storedValue->value = styleSheet->contents(); | 596 result.storedValue->value = styleSheet->contents(); |
| 593 m_sheetToTextCache.add(styleSheet->contents(), textContent); | 597 m_sheetToTextCache.add(styleSheet->contents(), textContent); |
| 594 } | 598 } |
| 595 } else { | 599 } else { |
| 596 StyleSheetContents* contents = result.storedValue->value; | 600 StyleSheetContents* contents = result.storedValue->value; |
| 597 ASSERT(contents); | 601 ASSERT(contents); |
| 598 ASSERT(isCacheableForStyleElement(*contents)); | 602 ASSERT(isCacheableForStyleElement(*contents)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 612 PassRefPtrWillBeRawPtr<CSSStyleSheet> StyleEngine::parseSheet(Element* e, const
String& text, TextPosition startPosition, bool createdByParser) | 616 PassRefPtrWillBeRawPtr<CSSStyleSheet> StyleEngine::parseSheet(Element* e, const
String& text, TextPosition startPosition, bool createdByParser) |
| 613 { | 617 { |
| 614 RefPtrWillBeRawPtr<CSSStyleSheet> styleSheet = nullptr; | 618 RefPtrWillBeRawPtr<CSSStyleSheet> styleSheet = nullptr; |
| 615 styleSheet = CSSStyleSheet::createInline(e, KURL(), startPosition, e->docume
nt().inputEncoding()); | 619 styleSheet = CSSStyleSheet::createInline(e, KURL(), startPosition, e->docume
nt().inputEncoding()); |
| 616 styleSheet->contents()->parseStringAtPosition(text, startPosition, createdBy
Parser); | 620 styleSheet->contents()->parseStringAtPosition(text, startPosition, createdBy
Parser); |
| 617 return styleSheet; | 621 return styleSheet; |
| 618 } | 622 } |
| 619 | 623 |
| 620 void StyleEngine::removeSheet(StyleSheetContents* contents) | 624 void StyleEngine::removeSheet(StyleSheetContents* contents) |
| 621 { | 625 { |
| 622 HashMap<StyleSheetContents*, AtomicString>::iterator it = m_sheetToTextCache
.find(contents); | 626 WillBeHeapHashMap<RawPtrWillBeMember<StyleSheetContents>, AtomicString>::ite
rator it = m_sheetToTextCache.find(contents); |
| 623 if (it == m_sheetToTextCache.end()) | 627 if (it == m_sheetToTextCache.end()) |
| 624 return; | 628 return; |
| 625 | 629 |
| 626 m_textToSheetCache.remove(it->value); | 630 m_textToSheetCache.remove(it->value); |
| 627 m_sheetToTextCache.remove(contents); | 631 m_sheetToTextCache.remove(contents); |
| 628 } | 632 } |
| 629 | 633 |
| 630 void StyleEngine::trace(Visitor* visitor) | 634 void StyleEngine::trace(Visitor* visitor) |
| 631 { | 635 { |
| 632 visitor->trace(m_injectedAuthorStyleSheets); | 636 visitor->trace(m_injectedAuthorStyleSheets); |
| 633 visitor->trace(m_authorStyleSheets); | 637 visitor->trace(m_authorStyleSheets); |
| 634 visitor->trace(m_documentStyleSheetCollection); | 638 visitor->trace(m_documentStyleSheetCollection); |
| 635 visitor->trace(m_styleSheetCollectionMap); | 639 visitor->trace(m_styleSheetCollectionMap); |
| 640 visitor->trace(m_resolver); |
| 641 visitor->trace(m_textToSheetCache); |
| 642 visitor->trace(m_sheetToTextCache); |
| 636 } | 643 } |
| 637 | 644 |
| 638 } | 645 } |
| OLD | NEW |