From 9de8b59a547cfd64f314271977f9729474568367 Mon Sep 17 00:00:00 2001 From: Norisz Fay Date: Thu, 6 Jul 2023 20:28:17 +0300 Subject: [PATCH] Backed out changeset cbf5ea1b17d2 (bug 1811129) for causing failures on modal-dialog-backdrop-opacity.html CLOSED TREE --- dom/base/FragmentOrElement.cpp | 27 +++++-------------- dom/html/HTMLDialogElement.cpp | 6 +---- dom/html/HTMLDialogElement.h | 2 -- .../child-sequential-focus.html.ini | 12 +++++++++ .../dialog-focus-shadow.html.ini | 20 ++++++++++++++ .../dialog-showModal.html.ini | 5 ++++ .../show-modal-focusing-steps.html.ini | 5 ++++ 7 files changed, 49 insertions(+), 28 deletions(-) create mode 100644 testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/child-sequential-focus.html.ini create mode 100644 testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow.html.ini create mode 100644 testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-showModal.html.ini create mode 100644 testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/show-modal-focusing-steps.html.ini diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp index e5a49ad5dbec0..dc4e43064a9ba 100644 --- a/dom/base/FragmentOrElement.cpp +++ b/dom/base/FragmentOrElement.cpp @@ -1036,14 +1036,9 @@ Element* nsIContent::GetFocusDelegate(bool aWithMouse, whereToLook = root; } - auto IsFocusable = [&](Element* aElement) -> nsIFrame::Focusable { + auto IsFocusable = [&](Element* aElement) { nsIFrame* frame = aElement->GetPrimaryFrame(); - - if (!frame) { - return {}; - } - - return frame->IsFocusable(aWithMouse); + return frame && frame->IsFocusable(aWithMouse); }; Element* potentialFocus = nullptr; @@ -1064,20 +1059,10 @@ Element* nsIContent::GetFocusDelegate(bool aWithMouse, // Found an autofocus candidate. return el; } - } else if (!potentialFocus) { - if (nsIFrame::Focusable focusable = IsFocusable(el)) { - if (IsHTMLElement(nsGkAtoms::dialog)) { - if (focusable.mTabIndex >= 0) { - // If focusTarget is a dialog element and descendant is sequentially - // focusable, then set focusableArea to descendant. - potentialFocus = el; - } - } else { - // This element could be the one if we can't find an - // autofocus candidate which has the precedence. - potentialFocus = el; - } - } + } else if (!potentialFocus && IsFocusable(el)) { + // This element could be the one if we can't find an + // autofocus candidate which has the precedence. + potentialFocus = el; } if (!autofocus && potentialFocus) { diff --git a/dom/html/HTMLDialogElement.cpp b/dom/html/HTMLDialogElement.cpp index b9cb6a79b51c8..a243f3b72dda6 100644 --- a/dom/html/HTMLDialogElement.cpp +++ b/dom/html/HTMLDialogElement.cpp @@ -159,9 +159,7 @@ void HTMLDialogElement::FocusDialog() { doc->FlushPendingNotifications(FlushType::Frames); } - RefPtr control = HasAttr(nsGkAtoms::autofocus) - ? this - : GetFocusDelegate(false /* aWithMouse */); + RefPtr control = GetFocusDelegate(false /* aWithMouse */); // If there isn't one of those either, then let control be subject. if (!control) { @@ -171,8 +169,6 @@ void HTMLDialogElement::FocusDialog() { FocusCandidate(*control, IsInTopLayer()); } -int32_t HTMLDialogElement::TabIndexDefault() { return 0; } - void HTMLDialogElement::QueueCancelDialog() { // queues an element task on the user interaction task source OwnerDoc() diff --git a/dom/html/HTMLDialogElement.h b/dom/html/HTMLDialogElement.h index 82f21423879b2..4f5f0c8abaebd 100644 --- a/dom/html/HTMLDialogElement.h +++ b/dom/html/HTMLDialogElement.h @@ -49,8 +49,6 @@ class HTMLDialogElement final : public nsGenericHTMLElement { MOZ_CAN_RUN_SCRIPT_BOUNDARY void FocusDialog(); - int32_t TabIndexDefault() override; - nsString mReturnValue; protected: diff --git a/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/child-sequential-focus.html.ini b/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/child-sequential-focus.html.ini new file mode 100644 index 0000000000000..6f8c4561a74de --- /dev/null +++ b/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/child-sequential-focus.html.ini @@ -0,0 +1,12 @@ +[child-sequential-focus.html] + [dialog element with autofocus should get initial focus.] + expected: FAIL + + [Only keyboard-focusable elements should get dialog initial focus.] + expected: FAIL + + [Only keyboard-focusable elements should get dialog initial focus including in subtrees.] + expected: FAIL + + [Only keyboard-focusable elements should get dialog initial focus including in nested buttons.] + expected: FAIL diff --git a/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow.html.ini b/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow.html.ini new file mode 100644 index 0000000000000..863e564527a68 --- /dev/null +++ b/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow.html.ini @@ -0,0 +1,20 @@ +[dialog-focus-shadow.html] + expected: + if (os == "android") and fission: [OK, TIMEOUT] + [show: No autofocus, no delegatesFocus, no siblings] + expected: FAIL + + [showModal: No autofocus, no delegatesFocus, no siblings] + expected: FAIL + + [show: Autofocus on shadow host, no delegatesFocus, no siblings] + expected: FAIL + + [showModal: Autofocus on shadow host, no delegatesFocus, no siblings] + expected: FAIL + + [show: Autofocus inside shadow tree, no delegatesFocus, no siblings] + expected: FAIL + + [showModal: Autofocus inside shadow tree, no delegatesFocus, no siblings] + expected: FAIL diff --git a/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-showModal.html.ini b/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-showModal.html.ini new file mode 100644 index 0000000000000..c7357edd24989 --- /dev/null +++ b/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-showModal.html.ini @@ -0,0 +1,5 @@ +[dialog-showModal.html] + expected: + if (os == "android") and fission: [OK, TIMEOUT] + [opening dialog without focusable children] + expected: FAIL diff --git a/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/show-modal-focusing-steps.html.ini b/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/show-modal-focusing-steps.html.ini new file mode 100644 index 0000000000000..f0d673d2c2145 --- /dev/null +++ b/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/show-modal-focusing-steps.html.ini @@ -0,0 +1,5 @@ +[show-modal-focusing-steps.html] + expected: + if (os == "android") and fission: [OK, TIMEOUT] + [focus when a modal dialog is opened] + expected: FAIL