| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |