Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Unified Diff: third_party/WebKit/Source/core/dom/StyleEngine.cpp

Issue 1903803002: Do not block painting for in-body CSS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed premature script execution Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/StyleEngine.cpp
diff --git a/third_party/WebKit/Source/core/dom/StyleEngine.cpp b/third_party/WebKit/Source/core/dom/StyleEngine.cpp
index bf0ea0dc6fa95c8863be8c13b3be1fc163ad84f6..4efede4c161a5a90df485266a957449614b0f8af 100644
--- a/third_party/WebKit/Source/core/dom/StyleEngine.cpp
+++ b/third_party/WebKit/Source/core/dom/StyleEngine.cpp
@@ -131,19 +131,26 @@ void StyleEngine::injectAuthorSheet(StyleSheetContents* authorSheet)
resolverChanged(AnalyzedStyleUpdate);
}
-void StyleEngine::addPendingSheet()
+void StyleEngine::addPendingSheet(bool isBeforeBody)
{
m_pendingStylesheets++;
+ if (isBeforeBody)
+ m_pendingRenderBlockingStylesheets++;
}
// This method is called whenever a top-level stylesheet has finished loading.
-void StyleEngine::removePendingSheet(Node* styleSheetCandidateNode)
+void StyleEngine::removePendingSheet(Node* styleSheetCandidateNode, bool isBeforeBody)
{
DCHECK(styleSheetCandidateNode);
TreeScope* treeScope = isStyleElement(*styleSheetCandidateNode) ? &styleSheetCandidateNode->treeScope() : m_document.get();
if (styleSheetCandidateNode->inShadowIncludingDocument())
markTreeScopeDirty(*treeScope);
+ if (isBeforeBody) {
+ DCHECK_GT(m_pendingRenderBlockingStylesheets, 0);
+ m_pendingRenderBlockingStylesheets--;
+ }
+
// Make sure we knew this sheet was pending, and that our count isn't out of sync.
DCHECK_GT(m_pendingStylesheets, 0);
@@ -508,11 +515,11 @@ static bool isCacheableForStyleElement(const StyleSheetContents& contents)
return true;
}
-CSSStyleSheet* StyleEngine::createSheet(Element* e, const String& text, TextPosition startPosition)
+CSSStyleSheet* StyleEngine::createSheet(Element* e, const String& text, TextPosition startPosition, bool isBeforeBody)
{
CSSStyleSheet* styleSheet = nullptr;
- e->document().styleEngine().addPendingSheet();
+ e->document().styleEngine().addPendingSheet(isBeforeBody);
AtomicString textContent(text);

Powered by Google App Engine
This is Rietveld 408576698