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

Unified Diff: third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.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/parser/CSSLazyParsingState.cpp
diff --git a/third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.cpp b/third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.cpp
index 8370f0a0dbd447696b93fc7dd2c55b6cb6698e6b..601ac6003830e83ac39a9bdcac43d01da8027924 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.cpp
@@ -4,6 +4,7 @@
#include "core/css/parser/CSSLazyParsingState.h"
#include "core/css/parser/CSSParserTokenRange.h"
+#include "core/dom/Document.h"
#include "core/frame/UseCounter.h"
namespace blink {
@@ -19,9 +20,14 @@ CSSLazyParsingState::CSSLazyParsingState(const CSSParserContext& context,
const CSSParserContext& CSSLazyParsingState::context() {
DCHECK(m_owningContents);
- UseCounter* sheetCounter = UseCounter::getFrom(m_owningContents);
- if (sheetCounter != m_context.useCounter())
- m_context = CSSParserContext(m_context, sheetCounter);
+ Document* document = m_owningContents->anyOwnerDocument();
+ if (document != m_document) {
rune 2016/12/02 22:18:09 Couldn't you check if m_document is nullptr before
Charlie Harrison 2016/12/02 22:38:46 Yes I think we can do this. My reason for doing it
+ // Since all StyleSheetContents are parsed with a single owner document, try
+ // as best as possible to grab a valid UseCounter if the underlying document
+ // has gone away.
+ m_document = document;
+ m_context = CSSParserContext(m_context, UseCounter::getFrom(m_document));
+ }
return m_context;
}
@@ -53,4 +59,9 @@ bool CSSLazyParsingState::shouldLazilyParseProperties(
return true;
}
+DEFINE_TRACE(CSSLazyParsingState) {
+ visitor->trace(m_owningContents);
+ visitor->trace(m_document);
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698