From b78934da4978d2899b32aabccf02aece98f14042 Mon Sep 17 00:00:00 2001 From: "rego@igalia.com" Date: Tue, 25 Apr 2017 04:58:55 +0000 Subject: [PATCH] [selectors4] :focus-within should use the flat tree https://bugs.webkit.org/show_bug.cgi?id=170899 Reviewed by Antti Koivisto. Source/WebCore: This has been discussed in the following CSS WG issue: https://github.com/w3c/csswg-drafts/issues/1135 And the spec has been updated (https://drafts.csswg.org/selectors-4/#the-focus-within-pseudo): "An element also matches :focus-within if one of its descendants in the flat tree (including non-element nodes, such as text nodes) matches the conditions for matching :focus." Test: imported/w3c/web-platform-tests/css/selectors4/focus-within-shadow-006.html * dom/Element.cpp: (WebCore::Element::setFocus): Use "flat tree" ("composed tree" in WebKit) to set focus-within flag. LayoutTests: * TestExpectations: Remove test that is passing now. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@215719 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 9 +++++++++ LayoutTests/TestExpectations | 1 - Source/WebCore/ChangeLog | 20 ++++++++++++++++++++ Source/WebCore/dom/Element.cpp | 2 +- 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 1cd5770234d9e..16538b73e2f1f 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,12 @@ +2017-04-24 Manuel Rego Casasnovas + + [selectors4] :focus-within should use the flat tree + https://bugs.webkit.org/show_bug.cgi?id=170899 + + Reviewed by Antti Koivisto. + + * TestExpectations: Remove test that is passing now. + 2017-04-24 Nan Wang AX: Crash at WebCore::AXObjectCache::characterOffsetForIndex(int, WebCore::AccessibilityObject const*) + 703 diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations index 41ebc86d7733d..5a9b81a8997dd 100644 --- a/LayoutTests/TestExpectations +++ b/LayoutTests/TestExpectations @@ -285,7 +285,6 @@ webkit.org/b/169271 imported/w3c/web-platform-tests/css/css-grid-1/grid-items/gr # selectors4 webkit.org/b/170900 imported/w3c/web-platform-tests/css/selectors4/focus-within-006.html [ ImageOnlyFailure ] -webkit.org/b/170899 imported/w3c/web-platform-tests/css/selectors4/focus-within-shadow-006.html [ ImageOnlyFailure ] webkit.org/b/64861 imported/w3c/web-platform-tests/css/selectors4/selectors-dir-selector-ltr-001.html [ ImageOnlyFailure ] webkit.org/b/64861 imported/w3c/web-platform-tests/css/selectors4/selectors-dir-selector-rtl-001.html [ ImageOnlyFailure ] diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index bf80398dec5e7..3db082e0cd559 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,23 @@ +2017-04-24 Manuel Rego Casasnovas + + [selectors4] :focus-within should use the flat tree + https://bugs.webkit.org/show_bug.cgi?id=170899 + + Reviewed by Antti Koivisto. + + This has been discussed in the following CSS WG issue: + https://github.com/w3c/csswg-drafts/issues/1135 + + And the spec has been updated (https://drafts.csswg.org/selectors-4/#the-focus-within-pseudo): + "An element also matches :focus-within if one of its descendants in the flat tree + (including non-element nodes, such as text nodes) matches the conditions for matching :focus." + + Test: imported/w3c/web-platform-tests/css/selectors4/focus-within-shadow-006.html + + * dom/Element.cpp: + (WebCore::Element::setFocus): Use "flat tree" ("composed tree" in WebKit) + to set focus-within flag. + 2017-04-24 Wenson Hsieh Respect fidelity order when reading web content from item providers diff --git a/Source/WebCore/dom/Element.cpp b/Source/WebCore/dom/Element.cpp index 6d3626d2c9d8f..b031f5b2434a3 100644 --- a/Source/WebCore/dom/Element.cpp +++ b/Source/WebCore/dom/Element.cpp @@ -611,7 +611,7 @@ void Element::setFocus(bool flag) document().userActionElements().setFocused(this, flag); invalidateStyleForSubtree(); - for (Element* element = this; element; element = element->parentOrShadowHostElement()) + for (Element* element = this; element; element = element->parentElementInComposedTree()) element->setHasFocusWithin(flag); }