Bug 1524232 - Dispatch synthesized mousemoves to OOP iframes if that's where they land. r=tnikkel

Depends on D29731

Differential Revision: https://phabricator.services.mozilla.com/D29732

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kartikaya Gupta 2019-05-02 19:57:16 +00:00
parent a8a0dd9a5a
commit 46c4b1ff9e
2 changed files with 33 additions and 5 deletions

View File

@ -44,6 +44,7 @@
#include "nsContentList.h"
#include "nsPresContext.h"
#include "nsIContent.h"
#include "mozilla/dom/BrowserBridgeChild.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/PointerEventHandler.h"
#include "mozilla/dom/PopupBlocker.h"
@ -5373,6 +5374,22 @@ static nsView* FindViewContaining(nsView* aView, nsPoint aPt) {
return aView;
}
static BrowserBridgeChild* GetChildBrowser(nsView* aView) {
if (!aView) {
return nullptr;
}
nsIFrame* frame = aView->GetFrame();
if (!frame && aView->GetParent()) {
// If frame is null then view is an anonymous inner view, and we want
// the frame from the corresponding outer view.
frame = aView->GetParent()->GetFrame();
}
if (!frame || !frame->GetContent()) {
return nullptr;
}
return BrowserBridgeChild::GetFrom(frame->GetContent());
}
void PresShell::ProcessSynthMouseMoveEvent(bool aFromScroll) {
// If drag session has started, we shouldn't synthesize mousemove event.
nsCOMPtr<nsIDragSession> dragSession = nsContentUtils::GetDragSession();
@ -5427,9 +5444,10 @@ void PresShell::ProcessSynthMouseMoveEvent(bool aFromScroll) {
// This could be a bit slow (traverses entire view hierarchy)
// but it's OK to do it once per synthetic mouse event
view = FindFloatingViewContaining(rootView, mMouseLocation);
nsView* pointView = view;
if (!view) {
view = rootView;
nsView* pointView = FindViewContaining(rootView, mMouseLocation);
pointView = FindViewContaining(rootView, mMouseLocation);
// pointView can be null in situations related to mouse capture
pointVM = (pointView ? pointView : view)->GetViewManager();
refpoint = mMouseLocation + rootView->ViewToWidgetOffset();
@ -5452,7 +5470,17 @@ void PresShell::ProcessSynthMouseMoveEvent(bool aFromScroll) {
// XXX set event.mModifiers ?
// XXX mnakano I think that we should get the latest information from widget.
if (RefPtr<PresShell> presShell = pointVM->GetPresShell()) {
if (BrowserBridgeChild* bbc = GetChildBrowser(pointView)) {
// If we have a BrowserBridgeChild, we're going to be dispatching this
// mouse event into an OOP iframe of the current document.
event.mLayersId = bbc->GetLayersId();
bbc->SendDispatchSynthesizedMouseEvent(event);
} else if (RefPtr<PresShell> presShell = pointVM->GetPresShell()) {
// Otherwise we're targetting regular (non-OOP iframe) content in the
// current process. This field probably won't even be read, but we
// can fill it in with a sane value.
event.mLayersId = mMouseEventTargetGuid.mLayersId;
// Since this gets run in a refresh tick there isn't an InputAPZContext on
// the stack from the nsBaseWidget. We need to simulate one with at least
// the correct target guid, so that the correct callback transform gets

View File

@ -767,9 +767,9 @@ void nsView::List(FILE* out, int32_t aIndent) const {
nonclientBounds.Y(), windowBounds.Width(), windowBounds.Height());
}
nsRect brect = GetBounds();
fprintf(out, "{%d,%d,%d,%d}", brect.X(), brect.Y(), brect.Width(),
brect.Height());
fprintf(out, " z=%d vis=%d frame=%p <\n", mZIndex, mVis,
fprintf(out, "{%d,%d,%d,%d} @ %d,%d", brect.X(), brect.Y(), brect.Width(),
brect.Height(), mPosX, mPosY);
fprintf(out, " flags=%x z=%d vis=%d frame=%p <\n", mVFlags, mZIndex, mVis,
static_cast<void*>(mFrame));
for (nsView* kid = mFirstChild; kid; kid = kid->GetNextSibling()) {
NS_ASSERTION(kid->GetParent() == this, "incorrect parent");