| 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(bool isBeforeBody) |
| 135 { | 135 { |
| 136 m_pendingStylesheets++; | 136 m_pendingStylesheets++; |
| 137 if (isBeforeBody) |
| 138 m_pendingRenderBlockingStylesheets++; |
| 137 } | 139 } |
| 138 | 140 |
| 139 // This method is called whenever a top-level stylesheet has finished loading. | 141 // This method is called whenever a top-level stylesheet has finished loading. |
| 140 void StyleEngine::removePendingSheet(Node* styleSheetCandidateNode) | 142 void StyleEngine::removePendingSheet(Node* styleSheetCandidateNode, bool isBefor
eBody) |
| 141 { | 143 { |
| 142 DCHECK(styleSheetCandidateNode); | 144 DCHECK(styleSheetCandidateNode); |
| 143 TreeScope* treeScope = isStyleElement(*styleSheetCandidateNode) ? &styleShee
tCandidateNode->treeScope() : m_document.get(); | 145 TreeScope* treeScope = isStyleElement(*styleSheetCandidateNode) ? &styleShee
tCandidateNode->treeScope() : m_document.get(); |
| 144 if (styleSheetCandidateNode->inShadowIncludingDocument()) | 146 if (styleSheetCandidateNode->inShadowIncludingDocument()) |
| 145 markTreeScopeDirty(*treeScope); | 147 markTreeScopeDirty(*treeScope); |
| 146 | 148 |
| 149 if (isBeforeBody) { |
| 150 DCHECK_GT(m_pendingRenderBlockingStylesheets, 0); |
| 151 m_pendingRenderBlockingStylesheets--; |
| 152 } |
| 153 |
| 147 // Make sure we knew this sheet was pending, and that our count isn't out of
sync. | 154 // Make sure we knew this sheet was pending, and that our count isn't out of
sync. |
| 148 DCHECK_GT(m_pendingStylesheets, 0); | 155 DCHECK_GT(m_pendingStylesheets, 0); |
| 149 | 156 |
| 150 m_pendingStylesheets--; | 157 m_pendingStylesheets--; |
| 151 if (m_pendingStylesheets) | 158 if (m_pendingStylesheets) |
| 152 return; | 159 return; |
| 153 | 160 |
| 154 document().didRemoveAllPendingStylesheet(); | 161 document().didRemoveAllPendingStylesheet(); |
| 155 } | 162 } |
| 156 | 163 |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 // Until import rules are supported in cached sheets it's not possible for l
oading to fail. | 508 // Until import rules are supported in cached sheets it's not possible for l
oading to fail. |
| 502 DCHECK(!contents.didLoadErrorOccur()); | 509 DCHECK(!contents.didLoadErrorOccur()); |
| 503 // It is not the original sheet anymore. | 510 // It is not the original sheet anymore. |
| 504 if (contents.isMutable()) | 511 if (contents.isMutable()) |
| 505 return false; | 512 return false; |
| 506 if (!contents.hasSyntacticallyValidCSSHeader()) | 513 if (!contents.hasSyntacticallyValidCSSHeader()) |
| 507 return false; | 514 return false; |
| 508 return true; | 515 return true; |
| 509 } | 516 } |
| 510 | 517 |
| 511 CSSStyleSheet* StyleEngine::createSheet(Element* e, const String& text, TextPosi
tion startPosition) | 518 CSSStyleSheet* StyleEngine::createSheet(Element* e, const String& text, TextPosi
tion startPosition, bool isBeforeBody) |
| 512 { | 519 { |
| 513 CSSStyleSheet* styleSheet = nullptr; | 520 CSSStyleSheet* styleSheet = nullptr; |
| 514 | 521 |
| 515 e->document().styleEngine().addPendingSheet(); | 522 e->document().styleEngine().addPendingSheet(isBeforeBody); |
| 516 | 523 |
| 517 AtomicString textContent(text); | 524 AtomicString textContent(text); |
| 518 | 525 |
| 519 HeapHashMap<AtomicString, Member<StyleSheetContents>>::AddResult result = m_
textToSheetCache.add(textContent, nullptr); | 526 HeapHashMap<AtomicString, Member<StyleSheetContents>>::AddResult result = m_
textToSheetCache.add(textContent, nullptr); |
| 520 if (result.isNewEntry || !result.storedValue->value) { | 527 if (result.isNewEntry || !result.storedValue->value) { |
| 521 styleSheet = StyleEngine::parseSheet(e, text, startPosition); | 528 styleSheet = StyleEngine::parseSheet(e, text, startPosition); |
| 522 if (result.isNewEntry && isCacheableForStyleElement(*styleSheet->content
s())) { | 529 if (result.isNewEntry && isCacheableForStyleElement(*styleSheet->content
s())) { |
| 523 result.storedValue->value = styleSheet->contents(); | 530 result.storedValue->value = styleSheet->contents(); |
| 524 m_sheetToTextCache.add(styleSheet->contents(), textContent); | 531 m_sheetToTextCache.add(styleSheet->contents(), textContent); |
| 525 } | 532 } |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 visitor->trace(m_styleInvalidator); | 766 visitor->trace(m_styleInvalidator); |
| 760 visitor->trace(m_dirtyTreeScopes); | 767 visitor->trace(m_dirtyTreeScopes); |
| 761 visitor->trace(m_activeTreeScopes); | 768 visitor->trace(m_activeTreeScopes); |
| 762 visitor->trace(m_fontSelector); | 769 visitor->trace(m_fontSelector); |
| 763 visitor->trace(m_textToSheetCache); | 770 visitor->trace(m_textToSheetCache); |
| 764 visitor->trace(m_sheetToTextCache); | 771 visitor->trace(m_sheetToTextCache); |
| 765 CSSFontSelectorClient::trace(visitor); | 772 CSSFontSelectorClient::trace(visitor); |
| 766 } | 773 } |
| 767 | 774 |
| 768 } // namespace blink | 775 } // namespace blink |
| OLD | NEW |