haikuwebkit/LayoutTests/fast/css/pseudo-active-style-sharing...

126 lines
4.6 KiB
HTML
Raw Permalink Normal View History

Fix style invalidation for :active when the activated node has no renderer https://bugs.webkit.org/show_bug.cgi?id=159125 Reviewed by Antti Koivisto. Source/WebCore: Same old bug: a style invalidation path was depending on the style. Here we really need both flags. An element can have childrenAffectedByActive() false and renderStyle->affectedByActive() true if it was subject to style sharing. The element state "childrenAffectedByActive" should be renamed "styleAffectedByActive" since it is not a parent invalidation flag. That will be done separately. Tests: fast/css/pseudo-active-on-labeled-control-without-renderer.html fast/css/pseudo-active-style-sharing-1.html fast/css/pseudo-active-style-sharing-2.html fast/css/pseudo-active-style-sharing-3.html fast/css/pseudo-active-style-sharing-4.html fast/css/pseudo-active-style-sharing-5.html fast/css/pseudo-active-style-sharing-6.html * dom/Element.cpp: (WebCore::Element::setActive): * style/StyleRelations.cpp: (WebCore::Style::commitRelationsToRenderStyle): LayoutTests: There was no bug with style sharing but I wanted that covered anyway. Style sharing depends on 2 flags which is uncommon. There was no test coverage whatsoever, breaking it did not fail any test. * fast/css/pseudo-active-on-labeled-control-without-renderer-expected.txt: Added. * fast/css/pseudo-active-on-labeled-control-without-renderer.html: Added. * fast/css/pseudo-active-style-sharing-1-expected.txt: Added. * fast/css/pseudo-active-style-sharing-1.html: Added. * fast/css/pseudo-active-style-sharing-2-expected.txt: Added. * fast/css/pseudo-active-style-sharing-2.html: Added. * fast/css/pseudo-active-style-sharing-3-expected.txt: Added. * fast/css/pseudo-active-style-sharing-3.html: Added. * fast/css/pseudo-active-style-sharing-4-expected.txt: Added. * fast/css/pseudo-active-style-sharing-4.html: Added. * fast/css/pseudo-active-style-sharing-5-expected.txt: Added. * fast/css/pseudo-active-style-sharing-5.html: Added. * fast/css/pseudo-active-style-sharing-6-expected.txt: Added. * fast/css/pseudo-active-style-sharing-6.html: Added. Canonical link: https://commits.webkit.org/177268@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202517 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-27 22:20:17 +00:00
<!DOCTYPE html>
<html id="html">
<head>
<style id="custom-style">
* {
background-color: white;
margin: 0;
padding: 0;
}
label:active, input:active {
background-color: rgb(50, 100, 150) !important;
}
#target1, #target2, #target3 {
display: block;
width: 100px;
height: 100px;
background-color: green;
border: 2px solid black;
}
</style>
</head>
<script src="../../resources/js-test-pre.js"></script>
<body id="body">
<div id="webkit-test">
<div id="labelable-ancestor">
<div id="labelable-parent">
<label for="labelable"><div id="target1">Target</div></label>
<label for="labelable"><div id="target2"></div></label>
<label for="labelable"><div id="target3"></div></label>
</div>
</div>
<div id="next-group" style="display:none">
<input id="labelable" value="Labelable Input">
<input id="labelable" value="Labelable Input">
<input id="labelable" value="Labelable Input">
</div>
</div>
<div id="console">
</div>
<script>
description("Verify that a labeled elemed gets the :active state even if it has no renderer.");
window.jsTestIsAsync = true;
function generateName(element) {
if (element.id && element.id !== "labelable")
return element.id;
let childPosition = 1;
while (element.previousElementSibling) {
element = element.previousElementSibling;
++childPosition;
}
return "#" + element.parentElement.id + " >> " + element.tagName.toLowerCase() + ":nth-child(" + childPosition + ")";
}
function elementsWithActiveStyle() {
let elements = [];
for (let element of document.querySelectorAll("*")) {
if (getComputedStyle(element).backgroundColor === "rgb(50, 100, 150)")
elements.push(generateName(element));
}
return elements;
}
function elementsMatchingActiveSelector() {
let elements = [];
for (let element of document.querySelectorAll(":active")) {
elements.push(generateName(element));
}
return elements;
}
if (window.eventSender) {
eventSender.mouseMoveTo(50, 50);
} else {
debug("");
debug("To run Manually, click-hold-release on the first green rect. All the results below should say PASS.")
debug("");
}
function sendMouseDown() {
if (window.eventSender) {
eventSender.mouseDown();
}
}
function sendMouseUp() {
if (window.eventSender) {
eventSender.mouseUp();
}
}
function mouseDownHandler(event, delayed = false) {
debug(delayed ? "After Mouse Down" : "On Mouse Down");
shouldBe('elementsWithActiveStyle()', '["#labelable-parent >> label:nth-child(1)", "#next-group >> input:nth-child(1)"]');
shouldBe('elementsMatchingActiveSelector()', '["html", "body", "webkit-test", "labelable-ancestor", "labelable-parent", "#labelable-parent >> label:nth-child(1)", "target1", "#next-group >> input:nth-child(1)"]');
if (!delayed) {
setTimeout(function() { mouseDownHandler(event, true); }, 0);
} else {
sendMouseUp();
}
}
var target = document.querySelector('label:nth-child(1)');
target.addEventListener('mousedown', mouseDownHandler);
function mouseUpHandler(event, delayed = false) {
debug(delayed ? "After Mouse Up" : "On Mouse Up");
shouldBe('elementsWithActiveStyle()', '[]');
shouldBe('elementsMatchingActiveSelector()', '[]');
document.getElementById("webkit-test").style.display = "none";
document.getElementById("custom-style").innerText = "";
finishJSTest();
}
target.addEventListener('mouseup', mouseUpHandler);
debug("Initial state");
shouldBe('elementsWithActiveStyle()', '[]');
shouldBe('elementsMatchingActiveSelector()', '[]');
sendMouseDown();
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>