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