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

Unified Diff: LayoutTests/fast/css/getComputedStyle/computed-style-recalc.html

Issue 768533004: Make getComputedStyle optimization work for adjacent combinators. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Redistribution might change computed style. Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/css/getComputedStyle/computed-style-recalc-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/css/getComputedStyle/computed-style-recalc.html
diff --git a/LayoutTests/fast/css/getComputedStyle/computed-style-recalc.html b/LayoutTests/fast/css/getComputedStyle/computed-style-recalc.html
new file mode 100644
index 0000000000000000000000000000000000000000..1c4acf95dc85c692192b9752a251efa8ac270276
--- /dev/null
+++ b/LayoutTests/fast/css/getComputedStyle/computed-style-recalc.html
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<script src="../../../resources/js-test.js"></script>
+<style>
+.a + .b { color: green; }
+.c + .d { color: green; }
+.e { color: green; }
+</style>
+<div id="t1">
+ <div></div>
+ <div class="b"></div>
+</div>
+<div id="t2">
+ <div>
+ <div></div>
+ <div class="d"></div>
+ </div>
+ <div>
+ <div class="e"></div>
+ </div>
+</div>
+<div id="t3">
+ <div>
+ <div></div>
+ <div class="d"></div>
+ </div>
+ <div>
+ <div class="a"></div>
+ <div class="b"></div>
+ </div>
+</div>
+<script>
+description("Check that getComputedStyle causes a style recalc when necessary, and only when necessary.");
+
+var green = "rgb(0, 128, 0)";
+
+// Check that sibling recalc for .b is performed before computed style is returned.
+
+document.body.offsetTop;
+document.body.querySelector("#t1 > div").className = "a";
+shouldBe("getComputedStyle(document.body.querySelector('#t1 .b')).color", "green", true);
+if (window.internals)
+ shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "0");
+
+// No style invalidation or recalc scheduled for an ascendant of .e, and no affected-by-adjacent
+// bits set on any ascendants, hence we don't need to do a recalc even if a style invalidation
+// is scheduled for the .c change with adjacent implications.
+
+document.body.offsetTop;
+document.body.querySelector("#t2 > div > div").className = "c";
+shouldBe("getComputedStyle(document.body.querySelector('#t2 .e')).color", "green", true);
+if (window.internals)
+ shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "2");
+
+// No style invalidation or recalc scheduled for an ascendant of .b, and even if affected-by-adjacent
+// bits are set on the ascendant (because of a+b), it doesn't matter since that ascendant does
+// not have any children that needs style recalc or invalidation.
+
+document.body.offsetTop;
+document.body.querySelector("#t3 > div > div").className = "c";
+shouldBe("getComputedStyle(document.body.querySelector('#t3 .b')).color", "green", true);
+if (window.internals)
+ shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "2");
+
+</script>
« no previous file with comments | « no previous file | LayoutTests/fast/css/getComputedStyle/computed-style-recalc-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698