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

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

Issue 2671173002: Change CSSParserContext to have a Document handle (vs UseCounter). (Closed)
Patch Set: fix todo style Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/css/parser/CSSLazyParsingState.h" 5 #include "core/css/parser/CSSLazyParsingState.h"
6 #include "core/css/parser/CSSLazyPropertyParserImpl.h" 6 #include "core/css/parser/CSSLazyPropertyParserImpl.h"
7 #include "core/css/parser/CSSParserTokenRange.h" 7 #include "core/css/parser/CSSParserTokenRange.h"
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/frame/UseCounter.h" 9 #include "core/frame/UseCounter.h"
10 #include "platform/Histogram.h" 10 #include "platform/Histogram.h"
(...skipping 27 matching lines...) Expand all
38 if (!m_shouldUseCount) { 38 if (!m_shouldUseCount) {
39 DCHECK(!m_context->isUseCounterRecordingEnabled()); 39 DCHECK(!m_context->isUseCounterRecordingEnabled());
40 return m_context; 40 return m_context;
41 } 41 }
42 42
43 // Try as best as possible to grab a valid Document if the old Document has 43 // Try as best as possible to grab a valid Document if the old Document has
44 // gone away so we can still use UseCounter. 44 // gone away so we can still use UseCounter.
45 if (!m_document) 45 if (!m_document)
46 m_document = m_owningContents->anyOwnerDocument(); 46 m_document = m_owningContents->anyOwnerDocument();
47 47
48 UseCounter* useCounter = UseCounter::getFrom(m_document); 48 if (!m_context->isDocumentHandleEqual(m_document))
49 if (useCounter != m_context->useCounter()) 49 m_context = CSSParserContext::create(m_context, m_document);
50 m_context = CSSParserContext::create(m_context, useCounter);
51 return m_context; 50 return m_context;
52 } 51 }
53 52
54 void CSSLazyParsingState::countRuleParsed() { 53 void CSSLazyParsingState::countRuleParsed() {
55 ++m_parsedStyleRules; 54 ++m_parsedStyleRules;
56 while (m_parsedStyleRules > m_styleRulesNeededForNextMilestone) { 55 while (m_parsedStyleRules > m_styleRulesNeededForNextMilestone) {
57 DCHECK_NE(UsageAll, m_usage); 56 DCHECK_NE(UsageAll, m_usage);
58 ++m_usage; 57 ++m_usage;
59 recordUsageMetrics(); 58 recordUsageMetrics();
60 } 59 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 usageHistogram.count(m_usage); 117 usageHistogram.count(m_usage);
119 } 118 }
120 119
121 DEFINE_TRACE(CSSLazyParsingState) { 120 DEFINE_TRACE(CSSLazyParsingState) {
122 visitor->trace(m_owningContents); 121 visitor->trace(m_owningContents);
123 visitor->trace(m_document); 122 visitor->trace(m_document);
124 visitor->trace(m_context); 123 visitor->trace(m_context);
125 } 124 }
126 125
127 } // namespace blink 126 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698