зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1849689 - Initial steps on handling Esc key for popover. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D186643
This commit is contained in:
Родитель
7de3a1e7db
Коммит
9dac459535
|
@ -14433,14 +14433,23 @@ void Document::SetFullscreenRoot(Document* aRoot) {
|
|||
mFullscreenRoot = do_GetWeakReference(aRoot);
|
||||
}
|
||||
|
||||
void Document::TryCancelDialog() {
|
||||
// Check if the document is blocked by modal dialog
|
||||
// https://github.com/whatwg/html/issues/9143
|
||||
// We need to consider the precedence between active modal dialog, topmost auto
|
||||
// popover and fullscreen element once it's specified.
|
||||
void Document::HandleEscKey() {
|
||||
for (const nsWeakPtr& weakPtr : Reversed(mTopLayer)) {
|
||||
nsCOMPtr<Element> element(do_QueryReferent(weakPtr));
|
||||
if (auto* dialog = HTMLDialogElement::FromNodeOrNull(element)) {
|
||||
dialog->QueueCancelDialog();
|
||||
break;
|
||||
}
|
||||
if (RefPtr<nsGenericHTMLElement> popoverHTMLEl =
|
||||
nsGenericHTMLElement::FromNodeOrNull(element)) {
|
||||
if (element->IsAutoPopover() && element->IsPopoverOpen()) {
|
||||
popoverHTMLEl->HidePopover(IgnoreErrors());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1878,8 +1878,11 @@ class Document : public nsINode,
|
|||
// Whether we has pending fullscreen request.
|
||||
bool HasPendingFullscreenRequests();
|
||||
|
||||
// Cancel the dialog element if the document is blocked by the dialog
|
||||
void TryCancelDialog();
|
||||
/**
|
||||
* When Esc key is pressed, cancel the dialog element if the document is
|
||||
* blocked by the dialog or hide popover if popover is shown.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT void HandleEscKey();
|
||||
|
||||
void AddModalDialog(HTMLDialogElement&);
|
||||
void RemoveModalDialog(HTMLDialogElement&);
|
||||
|
|
|
@ -3447,13 +3447,10 @@ void nsGenericHTMLElement::FocusPreviousElementAfterHidingPopover() {
|
|||
return;
|
||||
}
|
||||
|
||||
// Run the focusing steps for previouslyFocusedElement if focus is within the
|
||||
// popover hierarchy.
|
||||
if (IsShadowIncludingInclusiveDescendantOf(control)) {
|
||||
FocusOptions options;
|
||||
options.mPreventScroll = true;
|
||||
control->Focus(options, CallerType::NonSystem, IgnoreErrors());
|
||||
}
|
||||
// Run the focusing steps for previouslyFocusedElement.
|
||||
FocusOptions options;
|
||||
options.mPreventScroll = true;
|
||||
control->Focus(options, CallerType::NonSystem, IgnoreErrors());
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/popover.html#dom-togglepopover
|
||||
|
|
|
@ -8371,8 +8371,8 @@ void PresShell::EventHandler::FinalizeHandlingEvent(WidgetEvent* aEvent) {
|
|||
}
|
||||
if (aEvent->mMessage == eKeyDown &&
|
||||
!aEvent->mFlags.mDefaultPrevented) {
|
||||
if (Document* doc = GetDocument()) {
|
||||
doc->TryCancelDialog();
|
||||
if (RefPtr<Document> doc = GetDocument()) {
|
||||
doc->HandleEscKey();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2762,7 +2762,7 @@ class PresShell final : public nsStubDocumentObserver,
|
|||
*
|
||||
* @param aEvent The handled event.
|
||||
*/
|
||||
void FinalizeHandlingEvent(WidgetEvent* aEvent);
|
||||
MOZ_CAN_RUN_SCRIPT void FinalizeHandlingEvent(WidgetEvent* aEvent);
|
||||
|
||||
/**
|
||||
* AutoCurrentEventInfoSetter() pushes and pops current event info of
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
[popover-change-type.html]
|
||||
[Changing the popover attribute should always update the auto/manual behavior.]
|
||||
expected: FAIL
|
|
@ -1,60 +1,42 @@
|
|||
[popover-focus.html]
|
||||
[Popover focus test: default behavior - popover is not focused]
|
||||
expected: FAIL
|
||||
|
||||
[Popover button click focus test: default behavior - popover is not focused]
|
||||
expected: FAIL
|
||||
|
||||
[Popover focus test: autofocus popover]
|
||||
expected: FAIL
|
||||
|
||||
[Popover button click focus test: autofocus popover]
|
||||
expected: FAIL
|
||||
|
||||
[Popover focus test: autofocus empty popover]
|
||||
expected: FAIL
|
||||
|
||||
[Popover button click focus test: autofocus empty popover]
|
||||
expected: FAIL
|
||||
|
||||
[Popover focus test: autofocus popover with button]
|
||||
expected: FAIL
|
||||
|
||||
[Popover button click focus test: autofocus popover with button]
|
||||
expected: FAIL
|
||||
|
||||
[Popover focus test: autofocus child]
|
||||
expected: FAIL
|
||||
|
||||
[Popover button click focus test: autofocus child]
|
||||
expected: FAIL
|
||||
|
||||
[Popover focus test: autofocus on tabindex=0 element]
|
||||
expected: FAIL
|
||||
|
||||
[Popover button click focus test: autofocus on tabindex=0 element]
|
||||
expected: FAIL
|
||||
|
||||
[Popover focus test: autofocus multiple children]
|
||||
expected: FAIL
|
||||
|
||||
[Popover button click focus test: autofocus multiple children]
|
||||
expected: FAIL
|
||||
|
||||
[Popover focus test: autofocus popover and multiple autofocus children]
|
||||
expected: FAIL
|
||||
|
||||
[Popover button click focus test: autofocus popover and multiple autofocus children]
|
||||
expected: FAIL
|
||||
|
||||
[Popover button click focus test: Opening dialogs as popovers should use dialog initial focus algorithm.]
|
||||
expected: FAIL
|
||||
|
||||
[Popover button click focus test: Opening dialogs as popovers which have autofocus should focus the dialog.]
|
||||
expected: FAIL
|
||||
|
||||
[Popover focus test: Opening dialogs as popovers should use dialog initial focus algorithm.]
|
||||
expected: FAIL
|
||||
|
||||
[Popover button click focus test: Opening dialogs as popovers should use dialog initial focus algorithm.]
|
||||
[Popover corner cases test: Opening dialogs as popovers should use dialog initial focus algorithm.]
|
||||
expected: FAIL
|
||||
|
||||
[Popover focus test: Opening dialogs as popovers which have autofocus should focus the dialog.]
|
||||
expected: FAIL
|
||||
|
||||
[Popover button click focus test: Opening dialogs as popovers which have autofocus should focus the dialog.]
|
||||
[Popover corner cases test: Opening dialogs as popovers which have autofocus should focus the dialog.]
|
||||
expected: FAIL
|
||||
|
|
Загрузка…
Ссылка в новой задаче