Title: [204820] releases/WebKitGTK/webkit-2.12
- Revision
- 204820
- Author
- [email protected]
- Date
- 2016-08-23 05:23:59 -0700 (Tue, 23 Aug 2016)
Log Message
Merge r203976 - REGRESSION (r196383): Drop down CSS menus not working on cnet.com, apmex.com
https://bugs.webkit.org/show_bug.cgi?id=160390
Reviewed by Simon Fraser.
Source/WebCore:
The case here is that we have a rule like
.enableHover:hover .child { ... }
and the "enableHover" class is added dynamically. The class change invalidation optimization code would figure out
that nothing needs to be invalidated as the class change doesn't make the rule match (since :hover doesn't match).
However for event driven hover to actually work the hover element needs to have its childrenAffectedByHover bit set.
This bits is set when the selector match is attempted, whether it actually matches or not. Since we optimized away
the style invalidation we never set the bit either.
Fix by treating :hover as always matching (==ignored) when collecting rules for invalidation optimization purposes.
Dynamic pseudo elements are already treated this way for similar reasons.
Test: fast/selectors/hover-invalidation-descendant-dynamic.html
* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::checkOne):
Match always in CollectingRulesIgnoringVirtualPseudoElements mode (now slightly misnamed).
This mode is used for optimization purposes in StyleInvalidationAnalysis (which we care about here) and
StyleSharingResolver. The change is fine for both.
* cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsHovered):
Same change for the slow path selector checker.
LayoutTests:
* fast/selectors/hover-invalidation-descendant-dynamic-expected.txt: Added.
* fast/selectors/hover-invalidation-descendant-dynamic.html: Added.
Modified Paths
Added Paths
Diff
Modified: releases/WebKitGTK/webkit-2.12/LayoutTests/ChangeLog (204819 => 204820)
--- releases/WebKitGTK/webkit-2.12/LayoutTests/ChangeLog 2016-08-23 12:17:42 UTC (rev 204819)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/ChangeLog 2016-08-23 12:23:59 UTC (rev 204820)
@@ -1,3 +1,13 @@
+2016-08-01 Antti Koivisto <[email protected]>
+
+ REGRESSION (r196383): Drop down CSS menus not working on cnet.com, apmex.com
+ https://bugs.webkit.org/show_bug.cgi?id=160390
+
+ Reviewed by Simon Fraser.
+
+ * fast/selectors/hover-invalidation-descendant-dynamic-expected.txt: Added.
+ * fast/selectors/hover-invalidation-descendant-dynamic.html: Added.
+
2016-07-04 Fujii Hironori <[email protected]>
[GTK] Null Node dereference in FrameSelection::notifyAccessibilityForSelectionChange of FrameSelectionAtk.cpp
Added: releases/WebKitGTK/webkit-2.12/LayoutTests/fast/selectors/hover-invalidation-descendant-dynamic-expected.txt (0 => 204820)
--- releases/WebKitGTK/webkit-2.12/LayoutTests/fast/selectors/hover-invalidation-descendant-dynamic-expected.txt (rev 0)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/fast/selectors/hover-invalidation-descendant-dynamic-expected.txt 2016-08-23 12:23:59 UTC (rev 204820)
@@ -0,0 +1,5 @@
+Test that dynamically activated :hover rule affecting descendants works.
+Hover to see a green box below.
+Hover to see a green box below.
+Selector compiler: PASS
+Selector checker: PASS
Added: releases/WebKitGTK/webkit-2.12/LayoutTests/fast/selectors/hover-invalidation-descendant-dynamic.html (0 => 204820)
--- releases/WebKitGTK/webkit-2.12/LayoutTests/fast/selectors/hover-invalidation-descendant-dynamic.html (rev 0)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/fast/selectors/hover-invalidation-descendant-dynamic.html 2016-08-23 12:23:59 UTC (rev 204820)
@@ -0,0 +1,85 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+.parent {
+ position: relative;
+ padding: 10px;
+ background-color: silver;
+}
+
+.child {
+ position: absolute;
+ width: 200px;
+ height: 200px;
+ top: 0px;
+ background-color: green;
+ display: none;
+}
+
+#target.enableHover:hover .child {
+ display: block;
+}
+
+/* :matches() is here to disable the selector compiler */
+#target2:matches(:root, :nth-of-type(n), :not(#specificity-trick), :nth-last-of-type(n)).enableHover:hover .child {
+ display: block;
+}
+
+</style>
+<script>
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+}
+
+function runTest(targetSelector) {
+ var target = document.querySelector(targetSelector);
+ var child = target.querySelector('.child');
+
+ target.classList.add('enableHover');
+
+ if (window.eventSender) {
+ var x = target.offsetLeft + target.offsetWidth / 2;
+ var y = target.offsetTop + target.offsetHeight / 2;
+ eventSender.mouseMoveTo(x, y);
+ }
+
+ return child.offsetWidth != 0;
+}
+
+function log(text, pass) {
+ var log = document.querySelector("#log");
+ var line = document.createElement("div");
+ line.innerHTML = text + ": " + (pass ? "PASS" : "FAIL");
+ log.appendChild(line);
+}
+
+function runTests() {
+ var compilerPass = runTest("#target");
+ var checkerPass = runTest("#target2");
+ if (!window.testRunner)
+ return;
+ log("Selector compiler", compilerPass);
+ log("Selector checker", checkerPass);
+
+ testRunner.notifyDone();
+}
+
+</script>
+</head>
+<body _onload_="runTests()">
+<div>
+Test that dynamically activated :hover rule affecting descendants works.
+</div>
+<div id="target" class="parent">
+ Hover to see a green box below.
+ <div class="child"></div>
+</div>
+<div id="target2" class="parent">
+ Hover to see a green box below.
+ <div class="child"></div>
+</div>
+<div id=log></div>
+</body>
+</html>
Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog (204819 => 204820)
--- releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog 2016-08-23 12:17:42 UTC (rev 204819)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog 2016-08-23 12:23:59 UTC (rev 204820)
@@ -1,3 +1,39 @@
+2016-08-01 Antti Koivisto <[email protected]>
+
+ REGRESSION (r196383): Drop down CSS menus not working on cnet.com, apmex.com
+ https://bugs.webkit.org/show_bug.cgi?id=160390
+
+ Reviewed by Simon Fraser.
+
+ The case here is that we have a rule like
+
+ .enableHover:hover .child { ... }
+
+ and the "enableHover" class is added dynamically. The class change invalidation optimization code would figure out
+ that nothing needs to be invalidated as the class change doesn't make the rule match (since :hover doesn't match).
+
+ However for event driven hover to actually work the hover element needs to have its childrenAffectedByHover bit set.
+ This bits is set when the selector match is attempted, whether it actually matches or not. Since we optimized away
+ the style invalidation we never set the bit either.
+
+ Fix by treating :hover as always matching (==ignored) when collecting rules for invalidation optimization purposes.
+ Dynamic pseudo elements are already treated this way for similar reasons.
+
+ Test: fast/selectors/hover-invalidation-descendant-dynamic.html
+
+ * css/SelectorChecker.cpp:
+ (WebCore::SelectorChecker::checkOne):
+
+ Match always in CollectingRulesIgnoringVirtualPseudoElements mode (now slightly misnamed).
+
+ This mode is used for optimization purposes in StyleInvalidationAnalysis (which we care about here) and
+ StyleSharingResolver. The change is fine for both.
+
+ * cssjit/SelectorCompiler.cpp:
+ (WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsHovered):
+
+ Same change for the slow path selector checker.
+
2016-07-04 Fujii Hironori <[email protected]>
[GTK] Null Node dereference in FrameSelection::notifyAccessibilityForSelectionChange of FrameSelectionAtk.cpp
Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/css/SelectorChecker.cpp (204819 => 204820)
--- releases/WebKitGTK/webkit-2.12/Source/WebCore/css/SelectorChecker.cpp 2016-08-23 12:17:42 UTC (rev 204819)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/css/SelectorChecker.cpp 2016-08-23 12:23:59 UTC (rev 204820)
@@ -912,6 +912,10 @@
if (m_strictParsing || element.isLink() || canMatchHoverOrActiveInQuirksMode(context)) {
addStyleRelation(checkingContext, element, StyleRelation::AffectedByHover);
+ // See the comment in generateElementIsHovered() in SelectorCompiler.
+ if (checkingContext.resolvingMode == SelectorChecker::Mode::CollectingRulesIgnoringVirtualPseudoElements && !context.isMatchElement)
+ return true;
+
if (element.hovered() || InspectorInstrumentation::forcePseudoState(const_cast<Element&>(element), CSSSelector::PseudoClassHover))
return true;
}
Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/cssjit/SelectorCompiler.cpp (204819 => 204820)
--- releases/WebKitGTK/webkit-2.12/Source/WebCore/cssjit/SelectorCompiler.cpp 2016-08-23 12:17:42 UTC (rev 204819)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/cssjit/SelectorCompiler.cpp 2016-08-23 12:23:59 UTC (rev 204820)
@@ -3164,10 +3164,22 @@
generateAddStyleRelationIfResolvingStyle(elementAddressRegister, SelectorChecker::StyleRelation::AffectedByHover);
+ Assembler::JumpList successCases;
+ if (m_selectorContext != SelectorContext::QuerySelector && fragment.relationToRightFragment != FragmentRelation::Rightmost) {
+ // :hover always matches when not in rightmost position when collecting rules for descendant style invalidation optimization.
+ // Resolving style for a matching descendant will set parent childrenAffectedByHover bit even when the element is not currently hovered.
+ // This bit has to be set for the event based :hover invalidation to work.
+ // FIXME: We should just collect style relation bits and apply them as needed when computing style invalidation optimization.
+ LocalRegister checkingContext(m_registerAllocator);
+ successCases.append(branchOnResolvingMode(Assembler::Equal, SelectorChecker::Mode::CollectingRulesIgnoringVirtualPseudoElements, checkingContext));
+ }
+
FunctionCall functionCall(m_assembler, m_registerAllocator, m_stackAllocator, m_functionCalls);
functionCall.setFunctionAddress(elementIsHovered);
functionCall.setOneArgument(elementAddressRegister);
failureCases.append(functionCall.callAndBranchOnBooleanReturnValue(Assembler::Zero));
+
+ successCases.link(&m_assembler);
}
void SelectorCodeGenerator::generateElementIsInLanguage(Assembler::JumpList& failureCases, const SelectorFragment& fragment)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes