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

Unified Diff: LayoutTests/fast/css/invalidation/selection-pseudo.html

Issue 669873003: Avoid sub-tree style recalc for ::selection. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/css/invalidation/selection-pseudo-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/css/invalidation/selection-pseudo.html
diff --git a/LayoutTests/fast/css/invalidation/selection-pseudo.html b/LayoutTests/fast/css/invalidation/selection-pseudo.html
new file mode 100644
index 0000000000000000000000000000000000000000..1fcb40ce5839d6087af8930788573260901b53cb
--- /dev/null
+++ b/LayoutTests/fast/css/invalidation/selection-pseudo.html
@@ -0,0 +1,68 @@
+<!DOCTYPE html>
+<script src="../../../resources/js-test.js"></script>
+<style>
+.select::selection {
+ background-color: red;
+}
+
+.t1 .select::selection,
+.t2 .select::selection:window-inactive {
+ background-color: green;
+}
+</style>
+<div id="t1">
+ <div>
+ <div class="select">
+ 1
+ <span></span>
+ <span></span>
+ </div>
+ <div></div>
+ </div>
+</div>
+<div id="t2">
+ <div>
+ <div class="select">
+ 2
+ <span></span>
+ <span></span>
+ </div>
+ <div></div>
+ </div>
+</div>
+<script>
+description("Style invalidation for ::selection");
+
+var red = "rgb(255, 0, 0)";
+var green = "rgb(0, 128, 0)";
+
+function setSelection(textNode) {
+ var range = document.createRange();
+ range.setStart(textNode, 0);
+ range.setEnd(textNode, 1);
+ window.getSelection().addRange(range);
+}
+
+var select = document.querySelectorAll(".select");
+
+setSelection(select[0].firstChild);
+shouldBe("getComputedStyle(select[0], '::selection').backgroundColor", "red");
+
+document.body.offsetTop; // Force recalc.
+t1.className = "t1";
+if (window.internals)
+ shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "2");
+shouldBe("getComputedStyle(select[0], '::selection').backgroundColor", "green");
+
+shouldBeDefined(window.testRunner);
+testRunner.setWindowIsKey(false);
+
+setSelection(select[1].firstChild);
+shouldBe("getComputedStyle(select[1], '::selection').backgroundColor", "red");
+
+document.body.offsetTop; // Force recalc.
+t2.className = "t2";
+if (window.internals)
+ shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "2");
+shouldBe("getComputedStyle(select[1], '::selection').backgroundColor", "green");
+</script>
« no previous file with comments | « no previous file | LayoutTests/fast/css/invalidation/selection-pseudo-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698