Bug 1923546 - Fix MockDragServiceController on macOS after bug 1922956. r=handyman

Bug 1922956 made it so that nsChildView::GetTopLevelWidget() properly
returned the top level nsCocoaWindow. However that meant that
MockDragServiceController::SendEvent started sending events through the
wrong widget (because the nsChildView is the thing that has the APZ
state and such).

However the fix is trivial. Use GetWidgetForContent in order to
determine which widget to fire the event to, restoring the previous
behavior and fixing the tests.

Differential Revision: https://phabricator.services.mozilla.com/D225198
This commit is contained in:
Emilio Cobos Álvarez 2024-10-10 16:50:03 +00:00
parent 809de792a0
commit 40295335a1
2 changed files with 2 additions and 9 deletions

View File

@ -20,14 +20,8 @@ support-files = [
["browser_bug1539497.js"]
["browser_dragdrop_protected_diff_origin.js"]
skip-if = [
"os == 'mac'", # Bug 1923546 - temp disabled due to permafails until a fix in place
]
["browser_dragdrop_protected_same_origin.js"]
skip-if = [
"os == 'mac'", # Bug 1923546 - temp disabled due to permafails until a fix in place
]
["browser_dragdrop_unprotected_diff_origin.js"]

View File

@ -135,15 +135,14 @@ MockDragServiceController::SendEvent(
dom::BrowsingContext* aBC,
nsIMockDragServiceController::EventType aEventType, int32_t aScreenX,
int32_t aScreenY, uint32_t aKeyModifiers = 0) {
RefPtr<nsIWidget> widget =
aBC->Canonical()->GetParentProcessWidgetContaining();
NS_ENSURE_TRUE(widget, NS_ERROR_UNEXPECTED);
auto* embedder = aBC->Top()->GetEmbedderElement();
NS_ENSURE_TRUE(embedder, NS_ERROR_UNEXPECTED);
auto* frame = embedder->GetPrimaryFrame();
NS_ENSURE_TRUE(frame, NS_ERROR_UNEXPECTED);
auto* presCxt = frame->PresContext();
MOZ_ASSERT(presCxt);
RefPtr<nsIWidget> widget = nsContentUtils::WidgetForContent(embedder);
NS_ENSURE_TRUE(widget, NS_ERROR_UNEXPECTED);
EventMessage eventType = MockEventTypeToEventMessage(aEventType);
UniquePtr<WidgetInputEvent> widgetEvent;