Commit 8b260b86 authored by rune@opera.com's avatar rune@opera.com

Avoid sub-tree style recalc for ::selection.

The presence of the ::selection pseudo element should not trigger a
sub-tree style recalc from style invalidation. The same goes for the
:window-inactive pseudo class.

R=chrishtr@chromium.org,esprehn@chromium.org
BUG=425494

Review URL: https://codereview.chromium.org/669873003

git-svn-id: svn://svn.chromium.org/blink/trunk@184367 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 49856547
CONSOLE ERROR: Discontiguous selection is not supported.
Style invalidation for ::selection
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS getComputedStyle(select[0], '::selection').backgroundColor is red
PASS internals.updateStyleAndReturnAffectedElementCount() is 2
PASS getComputedStyle(select[0], '::selection').backgroundColor is green
PASS [object Object] is defined.
PASS getComputedStyle(select[1], '::selection').backgroundColor is red
PASS internals.updateStyleAndReturnAffectedElementCount() is 2
PASS getComputedStyle(select[1], '::selection').backgroundColor is green
PASS successfullyParsed is true
TEST COMPLETE
1
2
<!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>
...@@ -118,6 +118,8 @@ static bool supportsInvalidation(CSSSelector::PseudoType type) ...@@ -118,6 +118,8 @@ static bool supportsInvalidation(CSSSelector::PseudoType type)
case CSSSelector::PseudoScrollbarThumb: case CSSSelector::PseudoScrollbarThumb:
case CSSSelector::PseudoScrollbarTrack: case CSSSelector::PseudoScrollbarTrack:
case CSSSelector::PseudoScrollbarTrackPiece: case CSSSelector::PseudoScrollbarTrackPiece:
case CSSSelector::PseudoWindowInactive:
case CSSSelector::PseudoSelection:
case CSSSelector::PseudoInRange: case CSSSelector::PseudoInRange:
case CSSSelector::PseudoOutOfRange: case CSSSelector::PseudoOutOfRange:
case CSSSelector::PseudoUnresolved: case CSSSelector::PseudoUnresolved:
...@@ -155,7 +157,6 @@ static bool requiresSubtreeInvalidation(const CSSSelector& selector) ...@@ -155,7 +157,6 @@ static bool requiresSubtreeInvalidation(const CSSSelector& selector)
case CSSSelector::PseudoFirstLetter: case CSSSelector::PseudoFirstLetter:
case CSSSelector::PseudoFullPageMedia: case CSSSelector::PseudoFullPageMedia:
case CSSSelector::PseudoResizer: case CSSSelector::PseudoResizer:
case CSSSelector::PseudoWindowInactive:
case CSSSelector::PseudoCornerPresent: case CSSSelector::PseudoCornerPresent:
case CSSSelector::PseudoDecrement: case CSSSelector::PseudoDecrement:
case CSSSelector::PseudoIncrement: case CSSSelector::PseudoIncrement:
...@@ -166,7 +167,6 @@ static bool requiresSubtreeInvalidation(const CSSSelector& selector) ...@@ -166,7 +167,6 @@ static bool requiresSubtreeInvalidation(const CSSSelector& selector)
case CSSSelector::PseudoDoubleButton: case CSSSelector::PseudoDoubleButton:
case CSSSelector::PseudoSingleButton: case CSSSelector::PseudoSingleButton:
case CSSSelector::PseudoNoButton: case CSSSelector::PseudoNoButton:
case CSSSelector::PseudoSelection:
case CSSSelector::PseudoFullScreen: case CSSSelector::PseudoFullScreen:
case CSSSelector::PseudoFullScreenDocument: case CSSSelector::PseudoFullScreenDocument:
case CSSSelector::PseudoFullScreenAncestor: case CSSSelector::PseudoFullScreenAncestor:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment