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

Unified Diff: third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.cpp

Issue 2616093003: Make CSSParserContext be garbage collected. (Closed)
Patch Set: comments 1 Created 3 years, 11 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/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 b3d2ec5c849fbab7c3acbfb27b276ed83b41b87b..296d616b11f5be47b65533a0c0242c31b39a544e 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.cpp
@@ -11,7 +11,7 @@
namespace blink {
-CSSLazyParsingState::CSSLazyParsingState(const CSSParserContext& context,
+CSSLazyParsingState::CSSLazyParsingState(const CSSParserContext* context,
Vector<String> escapedStrings,
const String& sheetText,
StyleSheetContents* contents)
@@ -23,7 +23,7 @@ CSSLazyParsingState::CSSLazyParsingState(const CSSParserContext& context,
m_totalStyleRules(0),
m_styleRulesNeededForNextMilestone(0),
m_usage(UsageGe0),
- m_shouldUseCount(!!m_context.useCounter()) {
+ m_shouldUseCount(m_context->isUseCounterRecordingEnabled()) {
recordUsageMetrics();
}
@@ -33,23 +33,21 @@ CSSLazyPropertyParserImpl* CSSLazyParsingState::createLazyParser(
return new CSSLazyPropertyParserImpl(std::move(block), this);
}
-const CSSParserContext& CSSLazyParsingState::context() {
+const CSSParserContext* CSSLazyParsingState::context() {
DCHECK(m_owningContents);
if (!m_shouldUseCount) {
- DCHECK(!m_context.useCounter());
+ DCHECK(!m_context->isUseCounterRecordingEnabled());
return m_context;
}
- // Try as best as possible to grab a valid UseCounter if the underlying
- // document has gone away.
+ // Try as best as possible to grab a valid Document if the old Document has
+ // gone away so we can still use UseCounter.
if (!m_document)
m_document = m_owningContents->anyOwnerDocument();
- // Always refresh the UseCounter, as the Document can outlive its
- // underlying frame host causing a use-after-free of m_context's counter.
UseCounter* useCounter = UseCounter::getFrom(m_document);
- if (useCounter != m_context.useCounter())
- m_context = CSSParserContext(m_context, useCounter);
+ if (useCounter != m_context->useCounter())
+ m_context = new CSSParserContext(m_context, useCounter);
return m_context;
}
@@ -123,6 +121,7 @@ void CSSLazyParsingState::recordUsageMetrics() {
DEFINE_TRACE(CSSLazyParsingState) {
visitor->trace(m_owningContents);
visitor->trace(m_document);
+ visitor->trace(m_context);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698