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

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

Issue 2554193002: Make sure media query results are re-collected. (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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 } 313 }
314 314
315 EXPECT_TRUE(document().styleEngine().hasViewportDependentMediaQueries()); 315 EXPECT_TRUE(document().styleEngine().hasViewportDependentMediaQueries());
316 316
317 document().body()->removeChild(styleElement); 317 document().body()->removeChild(styleElement);
318 document().view()->updateAllLifecyclePhases(); 318 document().view()->updateAllLifecyclePhases();
319 319
320 EXPECT_FALSE(document().styleEngine().hasViewportDependentMediaQueries()); 320 EXPECT_FALSE(document().styleEngine().hasViewportDependentMediaQueries());
321 } 321 }
322 322
323 TEST_F(StyleEngineTest, StyleMediaAttributeStyleChange) {
324 document().body()->setInnerHTML(
325 "<style id='s1' media='(max-width: 1px)'>#t1 { color: green }</style>"
326 "<div id='t1'>Green</div><div></div>");
327 document().view()->updateAllLifecyclePhases();
328
329 Element* t1 = document().getElementById("t1");
330 ASSERT_TRUE(t1);
331 ASSERT_TRUE(t1->computedStyle());
332 EXPECT_EQ(makeRGB(0, 0, 0),
333 t1->computedStyle()->visitedDependentColor(CSSPropertyColor));
334
335 unsigned beforeCount = styleEngine().styleForElementCount();
336
337 Element* s1 = document().getElementById("s1");
338 s1->setAttribute(blink::HTMLNames::mediaAttr, "(max-width: 2000px)");
339 document().view()->updateAllLifecyclePhases();
340
341 unsigned afterCount = styleEngine().styleForElementCount();
342 // TODO(rune@opera.com): Should be 1u for ruleset based invalidations.
343 EXPECT_EQ(8u, afterCount - beforeCount);
344
345 ASSERT_TRUE(t1->computedStyle());
346 EXPECT_EQ(makeRGB(0, 128, 0),
347 t1->computedStyle()->visitedDependentColor(CSSPropertyColor));
348 }
349
350 TEST_F(StyleEngineTest, StyleMediaAttributeNoStyleChange) {
351 document().body()->setInnerHTML(
352 "<style id='s1' media='(max-width: 1000px)'>#t1 { color: green }</style>"
353 "<div id='t1'>Green</div><div></div>");
354 document().view()->updateAllLifecyclePhases();
355
356 Element* t1 = document().getElementById("t1");
357 ASSERT_TRUE(t1);
358 ASSERT_TRUE(t1->computedStyle());
359 EXPECT_EQ(makeRGB(0, 128, 0),
360 t1->computedStyle()->visitedDependentColor(CSSPropertyColor));
361
362 unsigned beforeCount = styleEngine().styleForElementCount();
363
364 Element* s1 = document().getElementById("s1");
365 s1->setAttribute(blink::HTMLNames::mediaAttr, "(max-width: 2000px)");
366 document().view()->updateAllLifecyclePhases();
367
368 unsigned afterCount = styleEngine().styleForElementCount();
369 // TODO(rune@opera.com): Should be 0 for ruleset based invalidations.
370 EXPECT_EQ(8u, afterCount - beforeCount);
371
372 ASSERT_TRUE(t1->computedStyle());
373 EXPECT_EQ(makeRGB(0, 128, 0),
374 t1->computedStyle()->visitedDependentColor(CSSPropertyColor));
375 }
376
323 } // namespace blink 377 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleEngine.cpp ('k') | third_party/WebKit/Source/core/html/HTMLStyleElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698