| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 m_maxDirectAdjacentSelectors = features.maxDirectAdjacentSelectors(); | 124 m_maxDirectAdjacentSelectors = features.maxDirectAdjacentSelectors(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void StyleEngine::injectAuthorSheet(StyleSheetContents* authorSheet) | 127 void StyleEngine::injectAuthorSheet(StyleSheetContents* authorSheet) |
| 128 { | 128 { |
| 129 m_injectedAuthorStyleSheets.append(CSSStyleSheet::create(authorSheet, m_docu
ment)); | 129 m_injectedAuthorStyleSheets.append(CSSStyleSheet::create(authorSheet, m_docu
ment)); |
| 130 markDocumentDirty(); | 130 markDocumentDirty(); |
| 131 resolverChanged(AnalyzedStyleUpdate); | 131 resolverChanged(AnalyzedStyleUpdate); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void StyleEngine::addPendingSheet() | 134 void StyleEngine::addPendingSheet(StyleEngineContext &context) |
| 135 { | 135 { |
| 136 m_pendingStylesheets++; | 136 m_pendingStylesheets++; |
| 137 |
| 138 context.addingPendingSheet(document()); |
| 139 if (context.addedPendingSheetBeforeBody()) |
| 140 m_pendingRenderBlockingStylesheets++; |
| 137 } | 141 } |
| 138 | 142 |
| 139 // This method is called whenever a top-level stylesheet has finished loading. | 143 // This method is called whenever a top-level stylesheet has finished loading. |
| 140 void StyleEngine::removePendingSheet(Node* styleSheetCandidateNode) | 144 void StyleEngine::removePendingSheet(Node* styleSheetCandidateNode, const StyleE
ngineContext &context) |
| 141 { | 145 { |
| 142 DCHECK(styleSheetCandidateNode); | 146 DCHECK(styleSheetCandidateNode); |
| 143 TreeScope* treeScope = isStyleElement(*styleSheetCandidateNode) ? &styleShee
tCandidateNode->treeScope() : m_document.get(); | 147 TreeScope* treeScope = isStyleElement(*styleSheetCandidateNode) ? &styleShee
tCandidateNode->treeScope() : m_document.get(); |
| 144 if (styleSheetCandidateNode->inShadowIncludingDocument()) | 148 if (styleSheetCandidateNode->inShadowIncludingDocument()) |
| 145 markTreeScopeDirty(*treeScope); | 149 markTreeScopeDirty(*treeScope); |
| 146 | 150 |
| 151 if (context.addedPendingSheetBeforeBody()) { |
| 152 DCHECK_GT(m_pendingRenderBlockingStylesheets, 0); |
| 153 m_pendingRenderBlockingStylesheets--; |
| 154 } |
| 155 |
| 147 // Make sure we knew this sheet was pending, and that our count isn't out of
sync. | 156 // Make sure we knew this sheet was pending, and that our count isn't out of
sync. |
| 148 DCHECK_GT(m_pendingStylesheets, 0); | 157 DCHECK_GT(m_pendingStylesheets, 0); |
| 149 | 158 |
| 150 m_pendingStylesheets--; | 159 m_pendingStylesheets--; |
| 151 if (m_pendingStylesheets) | 160 if (m_pendingStylesheets) |
| 152 return; | 161 return; |
| 153 | 162 |
| 154 document().didRemoveAllPendingStylesheet(); | 163 document().didRemoveAllPendingStylesheet(); |
| 155 } | 164 } |
| 156 | 165 |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 m_dirtyTreeScopes.add(&scope); | 495 m_dirtyTreeScopes.add(&scope); |
| 487 } | 496 } |
| 488 | 497 |
| 489 void StyleEngine::markDocumentDirty() | 498 void StyleEngine::markDocumentDirty() |
| 490 { | 499 { |
| 491 m_documentScopeDirty = true; | 500 m_documentScopeDirty = true; |
| 492 if (document().importLoader()) | 501 if (document().importLoader()) |
| 493 document().importsController()->master()->styleEngine().markDocumentDirt
y(); | 502 document().importsController()->master()->styleEngine().markDocumentDirt
y(); |
| 494 } | 503 } |
| 495 | 504 |
| 496 CSSStyleSheet* StyleEngine::createSheet(Element* e, const String& text, TextPosi
tion startPosition) | 505 CSSStyleSheet* StyleEngine::createSheet(Element* e, const String& text, TextPosi
tion startPosition, StyleEngineContext &context) |
| 497 { | 506 { |
| 498 CSSStyleSheet* styleSheet = nullptr; | 507 CSSStyleSheet* styleSheet = nullptr; |
| 499 | 508 |
| 500 e->document().styleEngine().addPendingSheet(); | 509 e->document().styleEngine().addPendingSheet(context); |
| 501 | 510 |
| 502 AtomicString textContent(text); | 511 AtomicString textContent(text); |
| 503 | 512 |
| 504 HeapHashMap<AtomicString, Member<StyleSheetContents>>::AddResult result = m_
textToSheetCache.add(textContent, nullptr); | 513 HeapHashMap<AtomicString, Member<StyleSheetContents>>::AddResult result = m_
textToSheetCache.add(textContent, nullptr); |
| 505 if (result.isNewEntry || !result.storedValue->value) { | 514 if (result.isNewEntry || !result.storedValue->value) { |
| 506 styleSheet = StyleEngine::parseSheet(e, text, startPosition); | 515 styleSheet = StyleEngine::parseSheet(e, text, startPosition); |
| 507 if (result.isNewEntry && styleSheet->contents()->isCacheableForStyleElem
ent()) { | 516 if (result.isNewEntry && styleSheet->contents()->isCacheableForStyleElem
ent()) { |
| 508 result.storedValue->value = styleSheet->contents(); | 517 result.storedValue->value = styleSheet->contents(); |
| 509 m_sheetToTextCache.add(styleSheet->contents(), textContent); | 518 m_sheetToTextCache.add(styleSheet->contents(), textContent); |
| 510 } | 519 } |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 visitor->trace(m_styleInvalidator); | 753 visitor->trace(m_styleInvalidator); |
| 745 visitor->trace(m_dirtyTreeScopes); | 754 visitor->trace(m_dirtyTreeScopes); |
| 746 visitor->trace(m_activeTreeScopes); | 755 visitor->trace(m_activeTreeScopes); |
| 747 visitor->trace(m_fontSelector); | 756 visitor->trace(m_fontSelector); |
| 748 visitor->trace(m_textToSheetCache); | 757 visitor->trace(m_textToSheetCache); |
| 749 visitor->trace(m_sheetToTextCache); | 758 visitor->trace(m_sheetToTextCache); |
| 750 CSSFontSelectorClient::trace(visitor); | 759 CSSFontSelectorClient::trace(visitor); |
| 751 } | 760 } |
| 752 | 761 |
| 753 } // namespace blink | 762 } // namespace blink |
| OLD | NEW |