Title: [289521] trunk
- Revision
- 289521
- Author
- [email protected]
- Date
- 2022-02-10 00:10:04 -0800 (Thu, 10 Feb 2022)
Log Message
:focus-visible with click on radio/checkbox labels is broken
https://bugs.webkit.org/show_bug.cgi?id=236331
Reviewed by Antti Koivisto.
LayoutTests/imported/w3c:
Added new WPT test to cover this case.
* web-platform-tests/css/selectors/focus-visible-026-expected.txt: Added.
* web-platform-tests/css/selectors/focus-visible-026.html: Added.
Source/WebCore:
When the label is clicked we have to send the FocusTrigger information to Element::focus().
There we avoid setting FocusVisibility:Visible if it has been triggered via mouse click.
Test: imported/w3c/web-platform-tests/css/selectors/focus-visible-026.html
* dom/Element.cpp:
(WebCore::Element::focus): Add a check for FocusTrigger::Click to avoid setting FocusVisibility:Visible.
* html/HTMLLabelElement.cpp:
(WebCore::HTMLLabelElement::defaultEventHandler): Pass FocusTrigger::Click.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (289520 => 289521)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2022-02-10 07:44:22 UTC (rev 289520)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2022-02-10 08:10:04 UTC (rev 289521)
@@ -1,3 +1,15 @@
+2022-02-10 Manuel Rego Casasnovas <[email protected]>
+
+ :focus-visible with click on radio/checkbox labels is broken
+ https://bugs.webkit.org/show_bug.cgi?id=236331
+
+ Reviewed by Antti Koivisto.
+
+ Added new WPT test to cover this case.
+
+ * web-platform-tests/css/selectors/focus-visible-026-expected.txt: Added.
+ * web-platform-tests/css/selectors/focus-visible-026.html: Added.
+
2022-02-09 Chris Dumez <[email protected]>
Resync web-platform-tests/html/browsers from upstream
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-026-expected.txt (0 => 289521)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-026-expected.txt (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-026-expected.txt 2022-02-10 08:10:04 UTC (rev 289521)
@@ -0,0 +1,5 @@
+ label
+
+PASS ":focus-visible" should be a valid selector
+PASS :focus-visible does NOT match when a checkbox is focused via click on the associated label
+
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-026.html (0 => 289521)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-026.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-026.html 2022-02-10 08:10:04 UTC (rev 289521)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<meta charset="utf-8" />
+<title>CSS Test (Selectors): Checkbox doesn't match :focus-visiblel after click on label</title>
+<link rel="author" title="Manuel Rego Casasnovas" href=""
+<link rel="help" href="" />
+<meta name="assert" content="This test checks that :focus-visible does NOT match when a checkbox is focused because an associated label has been clicked.">
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<style>
+ :focus-visible {
+ outline: red solid 5px;
+ }
+</style>
+<input type="checkbox" id="checkbox">
+<label for="" id="label">label</label>
+<script>
+ // Check that :focus-visible is supported.
+ test_valid_selector(':focus-visible');
+
+ promise_test(async t => {
+ await test_driver.click(label);
+ assert_equals(getComputedStyle(checkbox).outlineStyle, "none", `outline-style for ${checkbox.tagName}#${checkbox.id} should be none`);
+ t.done();
+ }, ":focus-visible does NOT match when a checkbox is focused via click on the associated label");
+</script>
+
Modified: trunk/Source/WebCore/ChangeLog (289520 => 289521)
--- trunk/Source/WebCore/ChangeLog 2022-02-10 07:44:22 UTC (rev 289520)
+++ trunk/Source/WebCore/ChangeLog 2022-02-10 08:10:04 UTC (rev 289521)
@@ -1,3 +1,20 @@
+2022-02-10 Manuel Rego Casasnovas <[email protected]>
+
+ :focus-visible with click on radio/checkbox labels is broken
+ https://bugs.webkit.org/show_bug.cgi?id=236331
+
+ Reviewed by Antti Koivisto.
+
+ When the label is clicked we have to send the FocusTrigger information to Element::focus().
+ There we avoid setting FocusVisibility:Visible if it has been triggered via mouse click.
+
+ Test: imported/w3c/web-platform-tests/css/selectors/focus-visible-026.html
+
+ * dom/Element.cpp:
+ (WebCore::Element::focus): Add a check for FocusTrigger::Click to avoid setting FocusVisibility:Visible.
+ * html/HTMLLabelElement.cpp:
+ (WebCore::HTMLLabelElement::defaultEventHandler): Pass FocusTrigger::Click.
+
2022-02-09 Said Abou-Hallawa <[email protected]>
[GPU Process] Move ImageBuffer::createCompatibleImageBuffer() and SVGRenderingContext::createImageBuffer to GraphicsContext
Modified: trunk/Source/WebCore/dom/Element.cpp (289520 => 289521)
--- trunk/Source/WebCore/dom/Element.cpp 2022-02-10 07:44:22 UTC (rev 289520)
+++ trunk/Source/WebCore/dom/Element.cpp 2022-02-10 08:10:04 UTC (rev 289521)
@@ -3109,7 +3109,7 @@
FocusOptions optionsWithVisibility = options;
if (options.trigger == FocusTrigger::Bindings && document->wasLastFocusByClick())
optionsWithVisibility.visibility = FocusVisibility::Invisible;
- else
+ else if (options.trigger != FocusTrigger::Click)
optionsWithVisibility.visibility = FocusVisibility::Visible;
// Focus and change event handlers can cause us to lose our last ref.
Modified: trunk/Source/WebCore/html/HTMLLabelElement.cpp (289520 => 289521)
--- trunk/Source/WebCore/html/HTMLLabelElement.cpp 2022-02-10 07:44:22 UTC (rev 289520)
+++ trunk/Source/WebCore/html/HTMLLabelElement.cpp 2022-02-10 08:10:04 UTC (rev 289521)
@@ -157,7 +157,7 @@
document().updateLayoutIgnorePendingStylesheets();
if (control->isMouseFocusable())
- control->focus();
+ control->focus({ { }, { }, { }, FocusTrigger::Click, { } });
processingClick = false;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes