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

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

Issue 2557533005: Collect active stylesheets and and apply asynchronously. (Closed)
Patch Set: Rebased. Created 4 years 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/dom/StyleEngine.h" 5 #include "core/dom/StyleEngine.h"
6 6
7 #include "core/css/StyleSheetContents.h" 7 #include "core/css/StyleSheetContents.h"
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/dom/NodeComputedStyle.h" 9 #include "core/dom/NodeComputedStyle.h"
10 #include "core/dom/shadow/ShadowRootInit.h" 10 #include "core/dom/shadow/ShadowRootInit.h"
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 EXPECT_EQ(makeRGB(0, 0, 0), 332 EXPECT_EQ(makeRGB(0, 0, 0),
333 t1->computedStyle()->visitedDependentColor(CSSPropertyColor)); 333 t1->computedStyle()->visitedDependentColor(CSSPropertyColor));
334 334
335 unsigned beforeCount = styleEngine().styleForElementCount(); 335 unsigned beforeCount = styleEngine().styleForElementCount();
336 336
337 Element* s1 = document().getElementById("s1"); 337 Element* s1 = document().getElementById("s1");
338 s1->setAttribute(blink::HTMLNames::mediaAttr, "(max-width: 2000px)"); 338 s1->setAttribute(blink::HTMLNames::mediaAttr, "(max-width: 2000px)");
339 document().view()->updateAllLifecyclePhases(); 339 document().view()->updateAllLifecyclePhases();
340 340
341 unsigned afterCount = styleEngine().styleForElementCount(); 341 unsigned afterCount = styleEngine().styleForElementCount();
342 // TODO(rune@opera.com): Should be 1u for ruleset based invalidations. 342 EXPECT_EQ(1u, afterCount - beforeCount);
343 EXPECT_EQ(8u, afterCount - beforeCount);
344 343
345 ASSERT_TRUE(t1->computedStyle()); 344 ASSERT_TRUE(t1->computedStyle());
346 EXPECT_EQ(makeRGB(0, 128, 0), 345 EXPECT_EQ(makeRGB(0, 128, 0),
347 t1->computedStyle()->visitedDependentColor(CSSPropertyColor)); 346 t1->computedStyle()->visitedDependentColor(CSSPropertyColor));
348 } 347 }
349 348
350 TEST_F(StyleEngineTest, StyleMediaAttributeNoStyleChange) { 349 TEST_F(StyleEngineTest, StyleMediaAttributeNoStyleChange) {
351 document().body()->setInnerHTML( 350 document().body()->setInnerHTML(
352 "<style id='s1' media='(max-width: 1000px)'>#t1 { color: green }</style>" 351 "<style id='s1' media='(max-width: 1000px)'>#t1 { color: green }</style>"
353 "<div id='t1'>Green</div><div></div>"); 352 "<div id='t1'>Green</div><div></div>");
354 document().view()->updateAllLifecyclePhases(); 353 document().view()->updateAllLifecyclePhases();
355 354
356 Element* t1 = document().getElementById("t1"); 355 Element* t1 = document().getElementById("t1");
357 ASSERT_TRUE(t1); 356 ASSERT_TRUE(t1);
358 ASSERT_TRUE(t1->computedStyle()); 357 ASSERT_TRUE(t1->computedStyle());
359 EXPECT_EQ(makeRGB(0, 128, 0), 358 EXPECT_EQ(makeRGB(0, 128, 0),
360 t1->computedStyle()->visitedDependentColor(CSSPropertyColor)); 359 t1->computedStyle()->visitedDependentColor(CSSPropertyColor));
361 360
362 unsigned beforeCount = styleEngine().styleForElementCount(); 361 unsigned beforeCount = styleEngine().styleForElementCount();
363 362
364 Element* s1 = document().getElementById("s1"); 363 Element* s1 = document().getElementById("s1");
365 s1->setAttribute(blink::HTMLNames::mediaAttr, "(max-width: 2000px)"); 364 s1->setAttribute(blink::HTMLNames::mediaAttr, "(max-width: 2000px)");
366 document().view()->updateAllLifecyclePhases(); 365 document().view()->updateAllLifecyclePhases();
367 366
368 unsigned afterCount = styleEngine().styleForElementCount(); 367 unsigned afterCount = styleEngine().styleForElementCount();
369 // TODO(rune@opera.com): Should be 0 for ruleset based invalidations. 368 EXPECT_EQ(0u, afterCount - beforeCount);
370 EXPECT_EQ(8u, afterCount - beforeCount);
371 369
372 ASSERT_TRUE(t1->computedStyle()); 370 ASSERT_TRUE(t1->computedStyle());
373 EXPECT_EQ(makeRGB(0, 128, 0), 371 EXPECT_EQ(makeRGB(0, 128, 0),
374 t1->computedStyle()->visitedDependentColor(CSSPropertyColor)); 372 t1->computedStyle()->visitedDependentColor(CSSPropertyColor));
375 } 373 }
376 374
377 } // namespace blink 375 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleEngine.cpp ('k') | third_party/WebKit/Source/core/dom/StyleSheetCollection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698