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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 m_dirtyTreeScopes.add(&scope); | 486 m_dirtyTreeScopes.add(&scope); |
487 } | 487 } |
488 | 488 |
489 void StyleEngine::markDocumentDirty() | 489 void StyleEngine::markDocumentDirty() |
490 { | 490 { |
491 m_documentScopeDirty = true; | 491 m_documentScopeDirty = true; |
492 if (document().importLoader()) | 492 if (document().importLoader()) |
493 document().importsController()->master()->styleEngine().markDocumentDirt
y(); | 493 document().importsController()->master()->styleEngine().markDocumentDirt
y(); |
494 } | 494 } |
495 | 495 |
496 static bool isCacheableForStyleElement(const StyleSheetContents& contents) | |
497 { | |
498 // FIXME: Support copying import rules. | |
499 if (!contents.importRules().isEmpty()) | |
500 return false; | |
501 // Until import rules are supported in cached sheets it's not possible for l
oading to fail. | |
502 DCHECK(!contents.didLoadErrorOccur()); | |
503 // It is not the original sheet anymore. | |
504 if (contents.isMutable()) | |
505 return false; | |
506 if (!contents.hasSyntacticallyValidCSSHeader()) | |
507 return false; | |
508 return true; | |
509 } | |
510 | |
511 CSSStyleSheet* StyleEngine::createSheet(Element* e, const String& text, TextPosi
tion startPosition) | 496 CSSStyleSheet* StyleEngine::createSheet(Element* e, const String& text, TextPosi
tion startPosition) |
512 { | 497 { |
513 CSSStyleSheet* styleSheet = nullptr; | 498 CSSStyleSheet* styleSheet = nullptr; |
514 | 499 |
515 e->document().styleEngine().addPendingSheet(); | 500 e->document().styleEngine().addPendingSheet(); |
516 | 501 |
517 AtomicString textContent(text); | 502 AtomicString textContent(text); |
518 | 503 |
519 HeapHashMap<AtomicString, Member<StyleSheetContents>>::AddResult result = m_
textToSheetCache.add(textContent, nullptr); | 504 HeapHashMap<AtomicString, Member<StyleSheetContents>>::AddResult result = m_
textToSheetCache.add(textContent, nullptr); |
520 if (result.isNewEntry || !result.storedValue->value) { | 505 if (result.isNewEntry || !result.storedValue->value) { |
521 styleSheet = StyleEngine::parseSheet(e, text, startPosition); | 506 styleSheet = StyleEngine::parseSheet(e, text, startPosition); |
522 if (result.isNewEntry && isCacheableForStyleElement(*styleSheet->content
s())) { | 507 if (result.isNewEntry && styleSheet->contents()->isCacheableForStyleElem
ent()) { |
523 result.storedValue->value = styleSheet->contents(); | 508 result.storedValue->value = styleSheet->contents(); |
524 m_sheetToTextCache.add(styleSheet->contents(), textContent); | 509 m_sheetToTextCache.add(styleSheet->contents(), textContent); |
525 } | 510 } |
526 } else { | 511 } else { |
527 StyleSheetContents* contents = result.storedValue->value; | 512 StyleSheetContents* contents = result.storedValue->value; |
528 DCHECK(contents); | 513 DCHECK(contents); |
529 DCHECK(isCacheableForStyleElement(*contents)); | 514 DCHECK(contents->isCacheableForStyleElement()); |
530 DCHECK_EQ(contents->singleOwnerDocument(), e->document()); | 515 DCHECK_EQ(contents->singleOwnerDocument(), e->document()); |
531 styleSheet = CSSStyleSheet::createInline(contents, e, startPosition); | 516 styleSheet = CSSStyleSheet::createInline(contents, e, startPosition); |
532 } | 517 } |
533 | 518 |
534 DCHECK(styleSheet); | 519 DCHECK(styleSheet); |
535 styleSheet->setTitle(e->title()); | 520 styleSheet->setTitle(e->title()); |
536 return styleSheet; | 521 return styleSheet; |
537 } | 522 } |
538 | 523 |
539 CSSStyleSheet* StyleEngine::parseSheet(Element* e, const String& text, TextPosit
ion startPosition) | 524 CSSStyleSheet* StyleEngine::parseSheet(Element* e, const String& text, TextPosit
ion startPosition) |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 visitor->trace(m_styleInvalidator); | 744 visitor->trace(m_styleInvalidator); |
760 visitor->trace(m_dirtyTreeScopes); | 745 visitor->trace(m_dirtyTreeScopes); |
761 visitor->trace(m_activeTreeScopes); | 746 visitor->trace(m_activeTreeScopes); |
762 visitor->trace(m_fontSelector); | 747 visitor->trace(m_fontSelector); |
763 visitor->trace(m_textToSheetCache); | 748 visitor->trace(m_textToSheetCache); |
764 visitor->trace(m_sheetToTextCache); | 749 visitor->trace(m_sheetToTextCache); |
765 CSSFontSelectorClient::trace(visitor); | 750 CSSFontSelectorClient::trace(visitor); |
766 } | 751 } |
767 | 752 |
768 } // namespace blink | 753 } // namespace blink |
OLD | NEW |