| 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 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 // Until import rules are supported in cached sheets it's not possible for l
oading to fail. | 527 // Until import rules are supported in cached sheets it's not possible for l
oading to fail. |
| 528 ASSERT(!contents.didLoadErrorOccur()); | 528 ASSERT(!contents.didLoadErrorOccur()); |
| 529 // It is not the original sheet anymore. | 529 // It is not the original sheet anymore. |
| 530 if (contents.isMutable()) | 530 if (contents.isMutable()) |
| 531 return false; | 531 return false; |
| 532 if (!contents.hasSyntacticallyValidCSSHeader()) | 532 if (!contents.hasSyntacticallyValidCSSHeader()) |
| 533 return false; | 533 return false; |
| 534 return true; | 534 return true; |
| 535 } | 535 } |
| 536 | 536 |
| 537 PassRefPtrWillBeRawPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const
String& text, TextPosition startPosition, bool createdByParser) | 537 PassRefPtrWillBeRawPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const
String& text, TextPosition startPosition) |
| 538 { | 538 { |
| 539 RefPtrWillBeRawPtr<CSSStyleSheet> styleSheet = nullptr; | 539 RefPtrWillBeRawPtr<CSSStyleSheet> styleSheet = nullptr; |
| 540 | 540 |
| 541 e->document().styleEngine().addPendingSheet(); | 541 e->document().styleEngine().addPendingSheet(); |
| 542 | 542 |
| 543 AtomicString textContent(text); | 543 AtomicString textContent(text); |
| 544 | 544 |
| 545 WillBeHeapHashMap<AtomicString, RawPtrWillBeMember<StyleSheetContents>>::Add
Result result = m_textToSheetCache.add(textContent, nullptr); | 545 WillBeHeapHashMap<AtomicString, RawPtrWillBeMember<StyleSheetContents>>::Add
Result result = m_textToSheetCache.add(textContent, nullptr); |
| 546 if (result.isNewEntry || !result.storedValue->value) { | 546 if (result.isNewEntry || !result.storedValue->value) { |
| 547 styleSheet = StyleEngine::parseSheet(e, text, startPosition, createdByPa
rser); | 547 styleSheet = StyleEngine::parseSheet(e, text, startPosition); |
| 548 if (result.isNewEntry && isCacheableForStyleElement(*styleSheet->content
s())) { | 548 if (result.isNewEntry && isCacheableForStyleElement(*styleSheet->content
s())) { |
| 549 result.storedValue->value = styleSheet->contents(); | 549 result.storedValue->value = styleSheet->contents(); |
| 550 m_sheetToTextCache.add(styleSheet->contents(), textContent); | 550 m_sheetToTextCache.add(styleSheet->contents(), textContent); |
| 551 } | 551 } |
| 552 } else { | 552 } else { |
| 553 StyleSheetContents* contents = result.storedValue->value; | 553 StyleSheetContents* contents = result.storedValue->value; |
| 554 ASSERT(contents); | 554 ASSERT(contents); |
| 555 ASSERT(isCacheableForStyleElement(*contents)); | 555 ASSERT(isCacheableForStyleElement(*contents)); |
| 556 ASSERT(contents->singleOwnerDocument() == e->document()); | 556 ASSERT(contents->singleOwnerDocument() == e->document()); |
| 557 styleSheet = CSSStyleSheet::createInline(contents, e, startPosition); | 557 styleSheet = CSSStyleSheet::createInline(contents, e, startPosition); |
| 558 } | 558 } |
| 559 | 559 |
| 560 ASSERT(styleSheet); | 560 ASSERT(styleSheet); |
| 561 styleSheet->setTitle(e->title()); | 561 styleSheet->setTitle(e->title()); |
| 562 return styleSheet; | 562 return styleSheet; |
| 563 } | 563 } |
| 564 | 564 |
| 565 // TODO(timloh): Remove createdByParser | 565 PassRefPtrWillBeRawPtr<CSSStyleSheet> StyleEngine::parseSheet(Element* e, const
String& text, TextPosition startPosition) |
| 566 PassRefPtrWillBeRawPtr<CSSStyleSheet> StyleEngine::parseSheet(Element* e, const
String& text, TextPosition startPosition, bool createdByParser) | |
| 567 { | 566 { |
| 568 RefPtrWillBeRawPtr<CSSStyleSheet> styleSheet = nullptr; | 567 RefPtrWillBeRawPtr<CSSStyleSheet> styleSheet = nullptr; |
| 569 styleSheet = CSSStyleSheet::createInline(e, KURL(), startPosition, e->docume
nt().characterSet()); | 568 styleSheet = CSSStyleSheet::createInline(e, KURL(), startPosition, e->docume
nt().characterSet()); |
| 570 styleSheet->contents()->parseStringAtPosition(text, startPosition); | 569 styleSheet->contents()->parseStringAtPosition(text, startPosition); |
| 571 return styleSheet; | 570 return styleSheet; |
| 572 } | 571 } |
| 573 | 572 |
| 574 void StyleEngine::removeSheet(StyleSheetContents* contents) | 573 void StyleEngine::removeSheet(StyleSheetContents* contents) |
| 575 { | 574 { |
| 576 WillBeHeapHashMap<RawPtrWillBeMember<StyleSheetContents>, AtomicString>::ite
rator it = m_sheetToTextCache.find(contents); | 575 WillBeHeapHashMap<RawPtrWillBeMember<StyleSheetContents>, AtomicString>::ite
rator it = m_sheetToTextCache.find(contents); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 visitor->trace(m_dirtyTreeScopes); | 722 visitor->trace(m_dirtyTreeScopes); |
| 724 visitor->trace(m_activeTreeScopes); | 723 visitor->trace(m_activeTreeScopes); |
| 725 visitor->trace(m_fontSelector); | 724 visitor->trace(m_fontSelector); |
| 726 visitor->trace(m_textToSheetCache); | 725 visitor->trace(m_textToSheetCache); |
| 727 visitor->trace(m_sheetToTextCache); | 726 visitor->trace(m_sheetToTextCache); |
| 728 #endif | 727 #endif |
| 729 CSSFontSelectorClient::trace(visitor); | 728 CSSFontSelectorClient::trace(visitor); |
| 730 } | 729 } |
| 731 | 730 |
| 732 } | 731 } |
| OLD | NEW |