Skip to content

Commit

Permalink
Backed out changeset cbf5ea1b17d2 (bug 1811129) for causing failures …
Browse files Browse the repository at this point in the history
…on modal-dialog-backdrop-opacity.html CLOSED TREE
  • Loading branch information
Norisz Fay committed Jul 6, 2023
1 parent 988d294 commit 9de8b59
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 28 deletions.
27 changes: 6 additions & 21 deletions dom/base/FragmentOrElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
6 changes: 1 addition & 5 deletions dom/html/HTMLDialogElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,7 @@ void HTMLDialogElement::FocusDialog() {
doc->FlushPendingNotifications(FlushType::Frames);
}

RefPtr<Element> control = HasAttr(nsGkAtoms::autofocus)
? this
: GetFocusDelegate(false /* aWithMouse */);
RefPtr<Element> control = GetFocusDelegate(false /* aWithMouse */);

// If there isn't one of those either, then let control be subject.
if (!control) {
Expand All @@ -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()
Expand Down
2 changes: 0 additions & 2 deletions dom/html/HTMLDialogElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ class HTMLDialogElement final : public nsGenericHTMLElement {

MOZ_CAN_RUN_SCRIPT_BOUNDARY void FocusDialog();

int32_t TabIndexDefault() override;

nsString mReturnValue;

protected:
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[dialog-showModal.html]
expected:
if (os == "android") and fission: [OK, TIMEOUT]
[opening dialog without focusable children]
expected: FAIL
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9de8b59

Please sign in to comment.