Bug 1128238 - Ajust NPP_SetWindow and synth native event coords to account for the chrome offset of remote tabs. Prior to this the content process always assumed the tab was the window origin. r=aklotz

This commit is contained in:
Jim Mathies 2015-04-08 11:51:49 -05:00
Родитель 2319197592
Коммит 1535724754
5 изменённых файлов: 67 добавлений и 3 удалений

Просмотреть файл

@ -342,6 +342,14 @@ parent:
*/
sync SynthesizeNativeMouseMove(LayoutDeviceIntPoint aPoint);
/**
* Returns the offset of this tab from the top level window
* origin in device pixels.
*
* aPoint offset values in device pixels.
*/
sync GetTabOffset() returns (LayoutDeviceIntPoint aPoint);
/**
* Gets the DPI of the screen corresponding to this browser.
*/

Просмотреть файл

@ -1794,6 +1794,13 @@ TabParent::RecvEnableDisableCommands(const nsString& aAction,
return true;
}
bool
TabParent::RecvGetTabOffset(LayoutDeviceIntPoint* aPoint)
{
*aPoint = GetChildProcessOffset();
return true;
}
NS_IMETHODIMP
TabParent::GetChildProcessOffset(int32_t* aOutCssX, int32_t* aOutCssY)
{

Просмотреть файл

@ -209,6 +209,7 @@ public:
virtual bool RecvSynthesizeNativeMouseMove(const mozilla::LayoutDeviceIntPoint& aPoint) override;
virtual bool RecvShowTooltip(const uint32_t& aX, const uint32_t& aY, const nsString& aTooltip) override;
virtual bool RecvHideTooltip() override;
virtual bool RecvGetTabOffset(LayoutDeviceIntPoint* aPoint) override;
virtual bool RecvGetDPI(float* aValue) override;
virtual bool RecvGetDefaultScale(double* aValue) override;
virtual bool RecvGetWidgetNativeData(WindowsHandle* aValue) override;

Просмотреть файл

@ -625,6 +625,12 @@ nsPluginFrame::CallSetWindow(bool aCheckIsHidden)
nsRect bounds = GetContentRectRelativeToSelf() + GetOffsetToCrossDoc(rootFrame);
nsIntRect intBounds = bounds.ToNearestPixels(appUnitsPerDevPixel);
// In e10s, this returns the offset to the top level window, in non-e10s
// it return 0,0.
LayoutDeviceIntPoint intOffset = GetRemoteTabChromeOffset();
intBounds.x += intOffset.x;
intBounds.y += intOffset.y;
// window must be in "display pixels"
double scaleFactor = 1.0;
if (NS_FAILED(mInstanceOwner->GetContentsScaleFactor(&scaleFactor))) {
@ -753,7 +759,30 @@ nsPluginFrame::IsHidden(bool aCheckVisibilityStyle) const
return false;
}
nsIntPoint nsPluginFrame::GetWindowOriginInPixels(bool aWindowless)
mozilla::LayoutDeviceIntPoint
nsPluginFrame::GetRemoteTabChromeOffset()
{
LayoutDeviceIntPoint offset;
if (XRE_GetProcessType() == GeckoProcessType_Content) {
nsCOMPtr<nsIDOMWindow> window = do_QueryInterface(GetContent()->OwnerDoc()->GetWindow());
if (window) {
nsCOMPtr<nsIDOMWindow> topWindow;
window->GetTop(getter_AddRefs(topWindow));
if (topWindow) {
dom::TabChild* tc = dom::TabChild::GetFrom(topWindow);
if (tc) {
LayoutDeviceIntPoint chromeOffset;
tc->SendGetTabOffset(&chromeOffset);
offset -= chromeOffset;
}
}
}
}
return offset;
}
nsIntPoint
nsPluginFrame::GetWindowOriginInPixels(bool aWindowless)
{
nsView * parentWithView;
nsPoint origin(0,0);
@ -769,8 +798,19 @@ nsIntPoint nsPluginFrame::GetWindowOriginInPixels(bool aWindowless)
}
origin += GetContentRectRelativeToSelf().TopLeft();
return nsIntPoint(PresContext()->AppUnitsToDevPixels(origin.x),
PresContext()->AppUnitsToDevPixels(origin.y));
nsIntPoint pt(PresContext()->AppUnitsToDevPixels(origin.x),
PresContext()->AppUnitsToDevPixels(origin.y));
// If we're in the content process offsetToWidget is tied to the top level
// widget we can access in the child process, which is the tab. We need the
// offset all the way up to the top level native window here. (If this is
// non-e10s this routine will return 0,0.)
if (aWindowless) {
mozilla::LayoutDeviceIntPoint lpt = GetRemoteTabChromeOffset();
pt += nsIntPoint(lpt.x, lpt.y);
}
return pt;
}
void

Просмотреть файл

@ -14,6 +14,7 @@
#include "nsRegion.h"
#include "nsDisplayList.h"
#include "nsIReflowCallback.h"
#include "Units.h"
#ifdef XP_WIN
#include <windows.h> // For HWND :(
@ -220,6 +221,13 @@ protected:
bool IsPaintedByGecko() const;
nsIntPoint GetWindowOriginInPixels(bool aWindowless);
/*
* If this frame is in a remote tab, return the tab offset to
* the origin of the chrome window. In non-e10s, this return 0,0.
* This api sends a sync ipc request so be careful about use.
*/
mozilla::LayoutDeviceIntPoint GetRemoteTabChromeOffset();
static void PaintPrintPlugin(nsIFrame* aFrame,
nsRenderingContext* aRenderingContext,