Bug 1817723 - Allow HTMLEditor can receive events when the focus is switched between elements in the same shadow tree. r=masayuki

The EditorEventListener for HTMLEditor is registered on document,
which is problematic because it can't receive events when the focus is
switched between elements in the same shadow tree due to shadow dom
encapsulation.

We fix this by moving the EditorEventListener to nsWindowRoot so the
events can always be received.

Differential Revision: https://phabricator.services.mozilla.com/D178215
This commit is contained in:
Sean Feng
2023-05-23 22:57:16 +00:00
parent 8288075a62
commit 3e889ec933
11 changed files with 215 additions and 43 deletions

View File

@@ -924,6 +924,10 @@ nsDocShellTreeOwner::HandleEvent(Event* aEvent) {
handler->CanDropLink(dragEvent, false, &canDropLink);
if (canDropLink) {
aEvent->PreventDefault();
WidgetDragEvent* asWidgetDropEvent =
dragEvent->WidgetEventPtr()->AsDragEvent();
asWidgetDropEvent->UpdateDefaultPreventedOnContent(
asWidgetDropEvent->mCurrentTarget);
}
} else if (eventType.EqualsLiteral("drop")) {
nsIWebNavigation* webnav = static_cast<nsIWebNavigation*>(mWebBrowser);
@@ -974,6 +978,10 @@ nsDocShellTreeOwner::HandleEvent(Event* aEvent) {
} else {
aEvent->StopPropagation();
aEvent->PreventDefault();
WidgetDragEvent* asWidgetDropEvent =
dragEvent->WidgetEventPtr()->AsDragEvent();
asWidgetDropEvent->UpdateDefaultPreventedOnContent(
asWidgetDropEvent->mCurrentTarget);
}
}