From 7d66bdef48057ade68b30b85d2ebd7d6b2b8d2d6 Mon Sep 17 00:00:00 2001 From: Rakina Zata Amni Date: Wed, 13 Mar 2019 01:32:36 +0000 Subject: [PATCH] Revert "Make mouse-triggered focus use flat tree traversal" This reverts commit 169c2efa93aa145fde63d95c7f3788fe7625f9e7. Reason for revert: Causes crbug.com/939546, and fix for selection seems to be non-trivial. Original change's description: > Make mouse-triggered focus use flat tree traversal > > Previously mouse-triggered focusing on an element (e.g. clicking) uses > repeated calls of ParentOrShadowElement() instead of using flat-tree > traversal methods, causing it to go up its shadow-including ancestors > instead of flat-tree. This behavior is not specified, but other > browser vendors had implemented flat-tree traversal usage for focus > traversal. > > See: https://github.com/w3c/webcomponents/issues/773 > > Bug: 894931 > Change-Id: I5666c9e973480648e8e9a1774e5d6abe026aac5c > Reviewed-on: https://chromium-review.googlesource.com/c/1455839 > Reviewed-by: Hayato Ito > Reviewed-by: Kent Tamura > Commit-Queue: Rakina Zata Amni > Cr-Commit-Position: refs/heads/master@{#629515} TBR=hayato@chromium.org,tkent@chromium.org,rakina@chromium.org # Not skipping CQ checks because original CL landed > 1 day ago. Bug: 894931, 939546 Change-Id: I215fe3f98c6117cd2bff8bd0930f3b8e380646f9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1514433 Reviewed-by: Rakina Zata Amni Reviewed-by: Kent Tamura Commit-Queue: Rakina Zata Amni Cr-Original-Commit-Position: refs/heads/master@{#639420}(cherry picked from commit 5310256007c2d3a77fdf520d2eb2e1d06a04a8d3) Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1519508 Cr-Commit-Position: refs/branch-heads/3729@{#74} Cr-Branched-From: d4a8972e30b604f090aeda5dfff68386ae656267-refs/heads/master@{#638880} --- .../core/input/mouse_event_manager.cc | 2 +- .../web_tests/shadow-dom/focus-flat-tree.html | 35 ------------------- 2 files changed, 1 insertion(+), 36 deletions(-) delete mode 100644 third_party/blink/web_tests/shadow-dom/focus-flat-tree.html diff --git a/third_party/blink/renderer/core/input/mouse_event_manager.cc b/third_party/blink/renderer/core/input/mouse_event_manager.cc index 93ebf4d91e49..8a30aaf60444 100644 --- a/third_party/blink/renderer/core/input/mouse_event_manager.cc +++ b/third_party/blink/renderer/core/input/mouse_event_manager.cc @@ -490,7 +490,7 @@ WebInputEventResult MouseEventManager::HandleMouseFocus( frame_->GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets(); Element* element = element_under_mouse_; - for (; element; element = FlatTreeTraversal::ParentElement(*element)) { + for (; element; element = element->ParentOrShadowHostElement()) { if (element->IsFocusable() && element->IsFocusedElementInDocument()) return WebInputEventResult::kNotHandled; if (element->IsMouseFocusable()) diff --git a/third_party/blink/web_tests/shadow-dom/focus-flat-tree.html b/third_party/blink/web_tests/shadow-dom/focus-flat-tree.html deleted file mode 100644 index 41f8f706136e..000000000000 --- a/third_party/blink/web_tests/shadow-dom/focus-flat-tree.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - -
OK
-
OK
- -