| 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 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 return false; | 596 return false; |
| 597 return true; | 597 return true; |
| 598 } | 598 } |
| 599 | 599 |
| 600 PassRefPtrWillBeRawPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const
String& text, TextPosition startPosition, bool createdByParser) | 600 PassRefPtrWillBeRawPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const
String& text, TextPosition startPosition, bool createdByParser) |
| 601 { | 601 { |
| 602 RefPtrWillBeRawPtr<CSSStyleSheet> styleSheet = nullptr; | 602 RefPtrWillBeRawPtr<CSSStyleSheet> styleSheet = nullptr; |
| 603 | 603 |
| 604 e->document().styleEngine().addPendingSheet(); | 604 e->document().styleEngine().addPendingSheet(); |
| 605 | 605 |
| 606 if (!e->document().inQuirksMode()) { | 606 AtomicString textContent(text); |
| 607 AtomicString textContent(text); | |
| 608 | 607 |
| 609 WillBeHeapHashMap<AtomicString, RawPtrWillBeMember<StyleSheetContents>>:
:AddResult result = m_textToSheetCache.add(textContent, nullptr); | 608 WillBeHeapHashMap<AtomicString, RawPtrWillBeMember<StyleSheetContents>>::Add
Result result = m_textToSheetCache.add(textContent, nullptr); |
| 610 if (result.isNewEntry || !result.storedValue->value) { | 609 if (result.isNewEntry || !result.storedValue->value) { |
| 611 styleSheet = StyleEngine::parseSheet(e, text, startPosition, created
ByParser); | 610 styleSheet = StyleEngine::parseSheet(e, text, startPosition, createdByPa
rser); |
| 612 if (result.isNewEntry && isCacheableForStyleElement(*styleSheet->con
tents())) { | 611 if (result.isNewEntry && isCacheableForStyleElement(*styleSheet->content
s())) { |
| 613 result.storedValue->value = styleSheet->contents(); | 612 result.storedValue->value = styleSheet->contents(); |
| 614 m_sheetToTextCache.add(styleSheet->contents(), textContent); | 613 m_sheetToTextCache.add(styleSheet->contents(), textContent); |
| 615 } | |
| 616 } else { | |
| 617 StyleSheetContents* contents = result.storedValue->value; | |
| 618 ASSERT(contents); | |
| 619 ASSERT(isCacheableForStyleElement(*contents)); | |
| 620 ASSERT(contents->singleOwnerDocument() == e->document()); | |
| 621 styleSheet = CSSStyleSheet::createInline(contents, e, startPosition)
; | |
| 622 } | 614 } |
| 623 } else { | 615 } else { |
| 624 // FIXME: currently we don't cache StyleSheetContents inQuirksMode. | 616 StyleSheetContents* contents = result.storedValue->value; |
| 625 styleSheet = StyleEngine::parseSheet(e, text, startPosition, createdByPa
rser); | 617 ASSERT(contents); |
| 618 ASSERT(isCacheableForStyleElement(*contents)); |
| 619 ASSERT(contents->singleOwnerDocument() == e->document()); |
| 620 styleSheet = CSSStyleSheet::createInline(contents, e, startPosition); |
| 626 } | 621 } |
| 627 | 622 |
| 628 ASSERT(styleSheet); | 623 ASSERT(styleSheet); |
| 629 styleSheet->setTitle(e->title()); | 624 styleSheet->setTitle(e->title()); |
| 630 return styleSheet; | 625 return styleSheet; |
| 631 } | 626 } |
| 632 | 627 |
| 633 // TODO(timloh): Remove createdByParser | 628 // TODO(timloh): Remove createdByParser |
| 634 PassRefPtrWillBeRawPtr<CSSStyleSheet> StyleEngine::parseSheet(Element* e, const
String& text, TextPosition startPosition, bool createdByParser) | 629 PassRefPtrWillBeRawPtr<CSSStyleSheet> StyleEngine::parseSheet(Element* e, const
String& text, TextPosition startPosition, bool createdByParser) |
| 635 { | 630 { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 visitor->trace(m_dirtyTreeScopes); | 781 visitor->trace(m_dirtyTreeScopes); |
| 787 visitor->trace(m_activeTreeScopes); | 782 visitor->trace(m_activeTreeScopes); |
| 788 visitor->trace(m_fontSelector); | 783 visitor->trace(m_fontSelector); |
| 789 visitor->trace(m_textToSheetCache); | 784 visitor->trace(m_textToSheetCache); |
| 790 visitor->trace(m_sheetToTextCache); | 785 visitor->trace(m_sheetToTextCache); |
| 791 #endif | 786 #endif |
| 792 CSSFontSelectorClient::trace(visitor); | 787 CSSFontSelectorClient::trace(visitor); |
| 793 } | 788 } |
| 794 | 789 |
| 795 } | 790 } |
| OLD | NEW |