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/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 Loading... |
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 EXPECT_EQ(1u, afterCount - beforeCount); | 342 // TODO(rune@opera.com): Should be 1u for ruleset based invalidations. |
| 343 EXPECT_EQ(8u, afterCount - beforeCount); |
343 | 344 |
344 ASSERT_TRUE(t1->computedStyle()); | 345 ASSERT_TRUE(t1->computedStyle()); |
345 EXPECT_EQ(makeRGB(0, 128, 0), | 346 EXPECT_EQ(makeRGB(0, 128, 0), |
346 t1->computedStyle()->visitedDependentColor(CSSPropertyColor)); | 347 t1->computedStyle()->visitedDependentColor(CSSPropertyColor)); |
347 } | 348 } |
348 | 349 |
349 TEST_F(StyleEngineTest, StyleMediaAttributeNoStyleChange) { | 350 TEST_F(StyleEngineTest, StyleMediaAttributeNoStyleChange) { |
350 document().body()->setInnerHTML( | 351 document().body()->setInnerHTML( |
351 "<style id='s1' media='(max-width: 1000px)'>#t1 { color: green }</style>" | 352 "<style id='s1' media='(max-width: 1000px)'>#t1 { color: green }</style>" |
352 "<div id='t1'>Green</div><div></div>"); | 353 "<div id='t1'>Green</div><div></div>"); |
353 document().view()->updateAllLifecyclePhases(); | 354 document().view()->updateAllLifecyclePhases(); |
354 | 355 |
355 Element* t1 = document().getElementById("t1"); | 356 Element* t1 = document().getElementById("t1"); |
356 ASSERT_TRUE(t1); | 357 ASSERT_TRUE(t1); |
357 ASSERT_TRUE(t1->computedStyle()); | 358 ASSERT_TRUE(t1->computedStyle()); |
358 EXPECT_EQ(makeRGB(0, 128, 0), | 359 EXPECT_EQ(makeRGB(0, 128, 0), |
359 t1->computedStyle()->visitedDependentColor(CSSPropertyColor)); | 360 t1->computedStyle()->visitedDependentColor(CSSPropertyColor)); |
360 | 361 |
361 unsigned beforeCount = styleEngine().styleForElementCount(); | 362 unsigned beforeCount = styleEngine().styleForElementCount(); |
362 | 363 |
363 Element* s1 = document().getElementById("s1"); | 364 Element* s1 = document().getElementById("s1"); |
364 s1->setAttribute(blink::HTMLNames::mediaAttr, "(max-width: 2000px)"); | 365 s1->setAttribute(blink::HTMLNames::mediaAttr, "(max-width: 2000px)"); |
365 document().view()->updateAllLifecyclePhases(); | 366 document().view()->updateAllLifecyclePhases(); |
366 | 367 |
367 unsigned afterCount = styleEngine().styleForElementCount(); | 368 unsigned afterCount = styleEngine().styleForElementCount(); |
368 EXPECT_EQ(0u, afterCount - beforeCount); | 369 // TODO(rune@opera.com): Should be 0 for ruleset based invalidations. |
| 370 EXPECT_EQ(8u, afterCount - beforeCount); |
369 | 371 |
370 ASSERT_TRUE(t1->computedStyle()); | 372 ASSERT_TRUE(t1->computedStyle()); |
371 EXPECT_EQ(makeRGB(0, 128, 0), | 373 EXPECT_EQ(makeRGB(0, 128, 0), |
372 t1->computedStyle()->visitedDependentColor(CSSPropertyColor)); | 374 t1->computedStyle()->visitedDependentColor(CSSPropertyColor)); |
373 } | 375 } |
374 | 376 |
375 } // namespace blink | 377 } // namespace blink |
OLD | NEW |