Chromium Code Reviews| 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 |