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

Unified Diff: third_party/WebKit/Source/core/css/StyleSheetContents.cpp

Issue 2474483002: [LazyParseCSS] Ensure UseCounting has parity with strict parsing (Closed)
Patch Set: Add StyleSheetContents::anyOwnerDocument() Created 4 years 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/css/StyleSheetContents.cpp
diff --git a/third_party/WebKit/Source/core/css/StyleSheetContents.cpp b/third_party/WebKit/Source/core/css/StyleSheetContents.cpp
index be7d917df767513bc75e55fef728e24855593542..be199485ccd790933f278c6bae8578cab046fac3 100644
--- a/third_party/WebKit/Source/core/css/StyleSheetContents.cpp
+++ b/third_party/WebKit/Source/core/css/StyleSheetContents.cpp
@@ -326,6 +326,12 @@ const AtomicString& StyleSheetContents::namespaceURIFromPrefix(
void StyleSheetContents::parseAuthorStyleSheet(
const CSSStyleSheetResource* cachedStyleSheet,
const SecurityOrigin* securityOrigin) {
+ // All StyleSheetContents are first parsed with a single owner document and
+ // node. This guarantees us that we will always have a valid document for use
+ // counting.
+ DCHECK(hasSingleOwnerDocument());
+ DCHECK(hasSingleOwnerNode());
+
TRACE_EVENT1("blink,devtools.timeline", "ParseAuthorStyleSheet", "data",
InspectorParseAuthorStyleSheetEvent::data(cachedStyleSheet));
double startTimeMS = monotonicallyIncreasingTimeMS();
@@ -491,6 +497,10 @@ Document* StyleSheetContents::singleOwnerDocument() const {
return root->clientSingleOwnerDocument();
}
+Document* StyleSheetContents::anyOwnerDocument() const {
+ return rootStyleSheet()->clientAnyOwnerDocument();
+}
+
static bool childRulesHaveFailedOrCanceledSubresources(
const HeapVector<Member<StyleRuleBase>>& rules) {
for (unsigned i = 0; i < rules.size(); ++i) {
@@ -531,13 +541,16 @@ bool StyleSheetContents::hasFailedOrCanceledSubresources() const {
return childRulesHaveFailedOrCanceledSubresources(m_childRules);
}
-Document* StyleSheetContents::clientSingleOwnerDocument() const {
- if (!m_hasSingleOwnerDocument || clientSize() <= 0)
+Document* StyleSheetContents::clientAnyOwnerDocument() const {
+ if (clientSize() <= 0)
return nullptr;
+ return m_loadingClients.size()
+ ? (*m_loadingClients.begin())->ownerDocument()
+ : (*m_completedClients.begin())->ownerDocument();
rune 2016/12/02 22:18:08 Nit: is the return rewrite due to the chromium cod
Charlie Harrison 2016/12/02 22:38:46 I can change it back, I was mostly just trying to
Charlie Harrison 2016/12/05 19:30:09 Done.
+}
- if (m_loadingClients.size())
- return (*m_loadingClients.begin())->ownerDocument();
- return (*m_completedClients.begin())->ownerDocument();
+Document* StyleSheetContents::clientSingleOwnerDocument() const {
+ return m_hasSingleOwnerDocument ? clientAnyOwnerDocument() : nullptr;
}
StyleSheetContents* StyleSheetContents::parentStyleSheet() const {

Powered by Google App Engine
This is Rietveld 408576698