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

Side by Side Diff: third_party/WebKit/Source/core/css/parser/CSSLazyParsingTest.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/CSSStyleSheet.h" 5 #include "core/css/CSSStyleSheet.h"
6 #include "core/css/StyleRule.h" 6 #include "core/css/StyleRule.h"
7 #include "core/css/StyleSheetContents.h" 7 #include "core/css/StyleSheetContents.h"
8 #include "core/css/parser/CSSLazyParsingState.h" 8 #include "core/css/parser/CSSLazyParsingState.h"
9 #include "core/css/parser/CSSParser.h" 9 #include "core/css/parser/CSSParser.h"
10 #include "core/css/parser/CSSParserContext.h" 10 #include "core/css/parser/CSSParserContext.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 113 }
114 114
115 // Regression test for crbug.com/660290 where we change the underlying owning 115 // Regression test for crbug.com/660290 where we change the underlying owning
116 // document from the StyleSheetContents without changing the UseCounter. This 116 // document from the StyleSheetContents without changing the UseCounter. This
117 // test ensures that the new UseCounter is used when doing new parsing work. 117 // test ensures that the new UseCounter is used when doing new parsing work.
118 TEST_F(CSSLazyParsingTest, ChangeDocuments) { 118 TEST_F(CSSLazyParsingTest, ChangeDocuments) {
119 std::unique_ptr<DummyPageHolder> dummyHolder = 119 std::unique_ptr<DummyPageHolder> dummyHolder =
120 DummyPageHolder::create(IntSize(500, 500)); 120 DummyPageHolder::create(IntSize(500, 500));
121 CSSParserContext* context = CSSParserContext::create( 121 CSSParserContext* context = CSSParserContext::create(
122 HTMLStandardMode, CSSParserContext::DynamicProfile, 122 HTMLStandardMode, CSSParserContext::DynamicProfile,
123 UseCounter::getFrom(&dummyHolder->document())); 123 &dummyHolder->document());
124 m_cachedContents = StyleSheetContents::create(context); 124 m_cachedContents = StyleSheetContents::create(context);
125 { 125 {
126 CSSStyleSheet* sheet = 126 CSSStyleSheet* sheet =
127 CSSStyleSheet::create(m_cachedContents, dummyHolder->document()); 127 CSSStyleSheet::create(m_cachedContents, dummyHolder->document());
128 DCHECK(sheet); 128 DCHECK(sheet);
129 129
130 String sheetText = "body { background-color: red; } p { color: orange; }"; 130 String sheetText = "body { background-color: red; } p { color: orange; }";
131 CSSParser::parseSheet(context, m_cachedContents, sheetText, 131 CSSParser::parseSheet(context, m_cachedContents, sheetText,
132 true /* lazy parse */); 132 true /* lazy parse */);
133 133
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 // Parsing the last rule bumps both Gt90 and All buckets. 211 // Parsing the last rule bumps both Gt90 and All buckets.
212 ruleAt(styleSheet, 4)->properties(); 212 ruleAt(styleSheet, 4)->properties();
213 m_histogramTester.expectTotalCount(metricName, 7); 213 m_histogramTester.expectTotalCount(metricName, 7);
214 m_histogramTester.expectBucketCount(metricName, 214 m_histogramTester.expectBucketCount(metricName,
215 CSSLazyParsingState::UsageGt90, 1); 215 CSSLazyParsingState::UsageGt90, 1);
216 m_histogramTester.expectBucketCount(metricName, CSSLazyParsingState::UsageAll, 216 m_histogramTester.expectBucketCount(metricName, CSSLazyParsingState::UsageAll,
217 1); 217 1);
218 } 218 }
219 219
220 } // namespace blink 220 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698