haikuwebkit/LayoutTests/fast/selectors/hover-quirks.html

30 lines
985 B
HTML
Raw Permalink Normal View History

Fix the quirks mode selector matching of the pseudo classes :hover and :active https://bugs.webkit.org/show_bug.cgi?id=133063 Reviewed by Antti Koivisto. Source/WebCore: Our implementation of the quirks mode of :active and :hover was very wrong. The only thing it was doing is verify the pseudo class is not the first selector of a fragment (which was conveniently the only thing that was tested :)). Since those pseudo class were only checking for the order of the filters, something like #target:hover would succeed because :hover is not the first simple selector, while :hover#target would fail. That behavior is also a problem for the CSS JIT as it is an implementation detail of SelectorChecker and compiling something like that with our out-of-order matching would be nonsense. This patch update the implementation to follow http://quirks.spec.whatwg.org/#the-:active-and-:hover-quirk Basically, the only cases that do not work in quirks mode are selectors composed only of "*, :hover and :active". To implement this behavior, I needed to be able to inspect a complete selector fragment, including what is before and after :hover/:active. To do that, I replaced the boolean isSubSelector by a pointer to the first selector of the fragment. When we need to match :active/:hover in quirks mode, we just go over all the selectors in the fragment to find one of the qualifying match type. Tests: fast/selectors/active-hover-quirks.html fast/selectors/active-quirks.html fast/selectors/hover-quirks.html * css/SelectorChecker.cpp: (WebCore::SelectorChecker::matchRecursively): (WebCore::canMatchHoverOrActiveInQuirksMode): (WebCore::SelectorChecker::checkOne): * css/SelectorChecker.h: (WebCore::SelectorChecker::SelectorCheckingContext::SelectorCheckingContext): LayoutTests: The test coverage of :hover and :active was extremly poor. Those new tests add coverage for the cases fixed by this patch. * fast/selectors/active-hover-quirks-expected.txt: Added. * fast/selectors/active-hover-quirks.html: Added. * fast/selectors/active-hover-strict-expected.txt: Added. * fast/selectors/active-hover-strict.html: Added. * fast/selectors/active-quirks-expected.txt: Added. * fast/selectors/active-quirks.html: Added. * fast/selectors/active-strict-expected.txt: Added. * fast/selectors/active-strict.html: Added. * fast/selectors/hover-quirks-expected.txt: Added. * fast/selectors/hover-quirks.html: Added. * fast/selectors/hover-strict-expected.txt: Added. * fast/selectors/hover-strict.html: Added. * fast/selectors/resources/hover-active-quirks-utility.js: Added. * selectors/resources/hover-active-strict-utility.js: Added. Canonical link: https://commits.webkit.org/151317@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169360 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-05-26 21:45:17 +00:00
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script src="resources/hover-active-quirks-utility.js"></script>
<style id="testStyle">
</style>
</head>
<body>
<div id="target" class="aClass otherClass" webkit="rocks" style="background-color:green; width:200px; height:200px;"></div>
<div id="console"></div>
</div>
</body>
<script>
description('Test the :hover selector when the document is in quirks mode. To test manually, move the cursor over the green rectangle and reload the page.');
if (window.eventSender) {
var target = document.getElementById('target');
var x = target.offsetLeft + target.offsetWidth / 2;
var y = target.offsetTop + target.offsetHeight / 2;
eventSender.mouseMoveTo(x, y);
test(':hover');
} else {
// To test manually, wait a bit to make sure the browers has updated its state, then run the tests.
setTimeout(test, 250, ':hover');
}
</script>
<script src="../../resources/js-test-post.js"></script>
</html>