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

Side by Side Diff: third_party/WebKit/Source/core/dom/StyleEngineTest.cpp

Issue 2703643003: Schedule a type selector invalidation set for RuleSet invalidations. (Closed)
Patch Set: Corrected expectation text. 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleEngine.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/dom/StyleEngine.h" 5 #include "core/dom/StyleEngine.h"
6 6
7 #include "core/css/CSSRuleList.h" 7 #include "core/css/CSSRuleList.h"
8 #include "core/css/CSSStyleRule.h" 8 #include "core/css/CSSStyleRule.h"
9 #include "core/css/CSSStyleSheet.h" 9 #include "core/css/CSSStyleSheet.h"
10 #include "core/css/StyleSheetContents.h" 10 #include "core/css/StyleSheetContents.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // Check that we did not use a cached StyleSheetContents after the garbage 137 // Check that we did not use a cached StyleSheetContents after the garbage
138 // collection. 138 // collection.
139 EXPECT_FALSE(sheet1->contents()->isUsedFromTextCache()); 139 EXPECT_FALSE(sheet1->contents()->isUsedFromTextCache());
140 } 140 }
141 141
142 TEST_F(StyleEngineTest, RuleSetInvalidationTypeSelectors) { 142 TEST_F(StyleEngineTest, RuleSetInvalidationTypeSelectors) {
143 document().body()->setInnerHTML( 143 document().body()->setInnerHTML(
144 "<div>" 144 "<div>"
145 " <span></span>" 145 " <span></span>"
146 " <div></div>" 146 " <div></div>"
147 "</div>"); 147 "</div>"
148 "<b></b><b></b><b></b><b></b>"
149 "<i id=i>"
150 " <i>"
151 " <b></b>"
152 " </i>"
153 "</i>");
148 154
149 document().view()->updateAllLifecyclePhases(); 155 document().view()->updateAllLifecyclePhases();
150 156
151 unsigned beforeCount = styleEngine().styleForElementCount(); 157 unsigned beforeCount = styleEngine().styleForElementCount();
152 EXPECT_EQ( 158 EXPECT_EQ(
153 scheduleInvalidationsForRules(document(), "span { background: green}"), 159 RuleSetInvalidationsScheduled,
154 RuleSetInvalidationsScheduled); 160 scheduleInvalidationsForRules(document(), "span { background: green}"));
155 document().view()->updateAllLifecyclePhases(); 161 document().view()->updateAllLifecyclePhases();
156 unsigned afterCount = styleEngine().styleForElementCount(); 162 unsigned afterCount = styleEngine().styleForElementCount();
157 EXPECT_EQ(1u, afterCount - beforeCount); 163 EXPECT_EQ(1u, afterCount - beforeCount);
158 164
159 beforeCount = afterCount; 165 beforeCount = afterCount;
160 EXPECT_EQ(scheduleInvalidationsForRules(document(), 166 EXPECT_EQ(RuleSetInvalidationsScheduled,
161 "body div { background: green}"), 167 scheduleInvalidationsForRules(document(),
162 RuleSetInvalidationsScheduled); 168 "body div { background: green}"));
163 document().view()->updateAllLifecyclePhases(); 169 document().view()->updateAllLifecyclePhases();
164 afterCount = styleEngine().styleForElementCount(); 170 afterCount = styleEngine().styleForElementCount();
165 EXPECT_EQ(2u, afterCount - beforeCount); 171 EXPECT_EQ(2u, afterCount - beforeCount);
166 172
167 EXPECT_EQ( 173 EXPECT_EQ(
168 scheduleInvalidationsForRules(document(), "div * { background: green}"), 174 RuleSetInvalidationFullRecalc,
169 RuleSetInvalidationFullRecalc); 175 scheduleInvalidationsForRules(document(), "div * { background: green}"));
176 document().view()->updateAllLifecyclePhases();
177
178 beforeCount = styleEngine().styleForElementCount();
179 EXPECT_EQ(
180 RuleSetInvalidationsScheduled,
181 scheduleInvalidationsForRules(document(), "#i b { background: green}"));
182 document().view()->updateAllLifecyclePhases();
183 afterCount = styleEngine().styleForElementCount();
184 EXPECT_EQ(1u, afterCount - beforeCount);
170 } 185 }
171 186
172 TEST_F(StyleEngineTest, RuleSetInvalidationHost) { 187 TEST_F(StyleEngineTest, RuleSetInvalidationHost) {
173 document().body()->setInnerHTML("<div id=nohost></div><div id=host></div>"); 188 document().body()->setInnerHTML("<div id=nohost></div><div id=host></div>");
174 Element* host = document().getElementById("host"); 189 Element* host = document().getElementById("host");
175 ASSERT_TRUE(host); 190 ASSERT_TRUE(host);
176 191
177 ShadowRootInit init; 192 ShadowRootInit init;
178 init.setMode("open"); 193 init.setMode("open");
179 ShadowRoot* shadowRoot = host->attachShadow( 194 ShadowRoot* shadowRoot = host->attachShadow(
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 427
413 styleRule->style()->setProperty("color", "green", "", ASSERT_NO_EXCEPTION); 428 styleRule->style()->setProperty("color", "green", "", ASSERT_NO_EXCEPTION);
414 document().view()->updateAllLifecyclePhases(); 429 document().view()->updateAllLifecyclePhases();
415 430
416 ASSERT_TRUE(t1->computedStyle()); 431 ASSERT_TRUE(t1->computedStyle());
417 EXPECT_EQ(makeRGB(0, 128, 0), 432 EXPECT_EQ(makeRGB(0, 128, 0),
418 t1->computedStyle()->visitedDependentColor(CSSPropertyColor)); 433 t1->computedStyle()->visitedDependentColor(CSSPropertyColor));
419 } 434 }
420 435
421 } // namespace blink 436 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleEngine.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698