mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1836057 - Popover: Use dialog initial focus for dialog popovers, r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D179580
This commit is contained in:
parent
f06667d996
commit
fa7b94707d
@ -87,6 +87,7 @@ void HTMLDialogElement::Show(ErrorResult& aError) {
|
||||
|
||||
StorePreviouslyFocusedElement();
|
||||
|
||||
OwnerDoc()->HideAllPopoversWithoutRunningScript();
|
||||
FocusDialog();
|
||||
}
|
||||
|
||||
@ -148,6 +149,7 @@ void HTMLDialogElement::ShowModal(ErrorResult& aError) {
|
||||
|
||||
StorePreviouslyFocusedElement();
|
||||
|
||||
OwnerDoc()->HideAllPopoversWithoutRunningScript();
|
||||
FocusDialog();
|
||||
|
||||
aError.SuppressException();
|
||||
@ -162,8 +164,6 @@ void HTMLDialogElement::FocusDialog() {
|
||||
doc->FlushPendingNotifications(FlushType::Frames);
|
||||
}
|
||||
|
||||
doc->HideAllPopoversWithoutRunningScript();
|
||||
|
||||
RefPtr<Element> control = GetFocusDelegate(false /* aWithMouse */);
|
||||
|
||||
// If there isn't one of those either, then let control be subject.
|
||||
|
@ -47,11 +47,12 @@ class HTMLDialogElement final : public nsGenericHTMLElement {
|
||||
void QueueCancelDialog();
|
||||
void RunCancelDialogSteps();
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY void FocusDialog();
|
||||
|
||||
nsString mReturnValue;
|
||||
|
||||
protected:
|
||||
virtual ~HTMLDialogElement();
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY void FocusDialog();
|
||||
JSObject* WrapNode(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
|
@ -100,6 +100,7 @@
|
||||
#include "mozilla/dom/HTMLBodyElement.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "nsComputedDOMStyle.h"
|
||||
#include "mozilla/dom/HTMLDialogElement.h"
|
||||
#include "mozilla/dom/HTMLLabelElement.h"
|
||||
#include "mozilla/dom/HTMLInputElement.h"
|
||||
#include "mozilla/dom/CustomElementRegistry.h"
|
||||
@ -3460,6 +3461,10 @@ void nsGenericHTMLElement::TogglePopover(const Optional<bool>& aForce,
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/popover.html#popover-focusing-steps
|
||||
void nsGenericHTMLElement::FocusPopover() {
|
||||
if (auto* dialog = HTMLDialogElement::FromNode(this)) {
|
||||
return MOZ_KnownLive(dialog)->FocusDialog();
|
||||
}
|
||||
|
||||
if (RefPtr<Document> doc = GetComposedDoc()) {
|
||||
doc->FlushPendingNotifications(FlushType::Frames);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user