Bug 1300421 - Back out 4 csets from bug 1288760 for regressing event coordinate reporting. r=jfkthame

MozReview-Commit-ID: AJ2PkSfYCpv
This commit is contained in:
Kartikaya Gupta 2016-09-29 10:20:52 -04:00
Родитель 906dc920ad
Коммит 1d5a942431
9 изменённых файлов: 10 добавлений и 100 удалений

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

@ -28,7 +28,6 @@
#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsIPresShell.h"
#include "nsIScreen.h"
#include "nsIScrollableFrame.h"
#include "nsJSEnvironment.h"
#include "nsLayoutUtils.h"
@ -928,46 +927,17 @@ Event::GetScreenCoords(nsPresContext* aPresContext,
return CSSIntPoint(aPoint.x, aPoint.y);
}
nsPoint pt =
LayoutDevicePixel::ToAppUnits(aPoint, aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom());
int32_t appPerDevFullZoom =
aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
LayoutDevicePoint devPt = aPoint;
if (nsIPresShell* ps = aPresContext->GetPresShell()) {
// convert to appUnits in order to use RemoveResolution, then back to
// device pixels
nsPoint pt =
LayoutDevicePixel::ToAppUnits(aPoint, appPerDevFullZoom);
pt = pt.RemoveResolution(nsLayoutUtils::GetCurrentAPZResolutionScale(ps));
devPt = LayoutDevicePixel::FromAppUnits(pt, appPerDevFullZoom);
}
devPt += guiEvent->mWidget->WidgetToScreenOffset();
pt += LayoutDevicePixel::ToAppUnits(guiEvent->mWidget->WidgetToScreenOffset(),
aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom());
nsCOMPtr<nsIScreen> screen = guiEvent->mWidget->GetWidgetScreen();
if (screen) {
// subtract device-pixel origin of current screen
int32_t x, y, w, h;
screen->GetRect(&x, &y, &w, &h);
devPt.x -= x;
devPt.y -= y;
// then convert position *within the current screen* to unscaled CSS px
double cssToDevScale;
screen->GetDefaultCSSScaleFactor(&cssToDevScale);
CSSIntPoint cssPt(NSToIntRound(devPt.x / cssToDevScale),
NSToIntRound(devPt.y / cssToDevScale));
// finally, add the desktop-pixel origin of the screen, to get a global
// CSS pixel value that is compatible with window.screenX/Y positions
screen->GetRectDisplayPix(&x, &y, &w, &h);
cssPt.x += x;
cssPt.y += y;
return cssPt;
}
// this shouldn't happen, but just in case...
NS_WARNING("failed to find screen, using default CSS px conversion");
return CSSPixel::FromAppUnitsRounded(
LayoutDevicePixel::ToAppUnits(aPoint, appPerDevFullZoom));
return CSSPixel::FromAppUnitsRounded(pt);
}
// static

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

@ -23,7 +23,6 @@ struct ScreenDetails {
int32_t pixelDepth;
int32_t colorDepth;
double contentsScaleFactor;
double defaultCSSScaleFactor;
};
prio(normal upto high) sync protocol PScreenManager

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

@ -216,11 +216,6 @@ ScreenManagerParent::ExtractScreenDetails(nsIScreen* aScreen, ScreenDetails &aDe
NS_ENSURE_SUCCESS(rv, false);
aDetails.contentsScaleFactor() = contentsScaleFactor;
double defaultCSSScaleFactor = 1.0;
rv = aScreen->GetDefaultCSSScaleFactor(&defaultCSSScaleFactor);
NS_ENSURE_SUCCESS(rv, false);
aDetails.defaultCSSScaleFactor() = defaultCSSScaleFactor;
return true;
}

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

@ -802,31 +802,7 @@ nsMenuPopupFrame::InitializePopupAtScreen(nsIContent* aTriggerContent,
mPopupState = ePopupShowing;
mAnchorContent = nullptr;
mTriggerContent = aTriggerContent;
nsCOMPtr<nsIScreenManager> screenMgr =
do_GetService("@mozilla.org/gfx/screenmanager;1");
nsCOMPtr<nsIScreen> screen;
if (screenMgr) {
// aXPos and aYPos are "global desktop" coordinates in units of
// CSS pixels, but nsMenuPopupFrame wants CSS pixels that are
// directly scaled from device pixels, without being offset for
// the screen origin. So we need to undo the offset that was
// applied to the global CSS coordinate values in the mouse event.
screenMgr->ScreenForRect(aXPos, aYPos, 1, 1,
getter_AddRefs(screen));
double cssToDevScale, deskToDevScale;
screen->GetDefaultCSSScaleFactor(&cssToDevScale);
screen->GetContentsScaleFactor(&deskToDevScale);
double scale = deskToDevScale / cssToDevScale;
int32_t w, h;
DesktopIntPoint origin;
screen->GetRectDisplayPix(&origin.x, &origin.y, &w, &h);
mScreenRect.x = aXPos + (origin.x * scale) - origin.x;
mScreenRect.y = aYPos + (origin.y * scale) - origin.y;
mScreenRect.width = mScreenRect.height = 0;
} else {
mScreenRect = nsIntRect(aXPos, aYPos, 0, 0);
}
mScreenRect = nsIntRect(aXPos, aYPos, 0, 0);
mXPos = 0;
mYPos = 0;
mFlip = FlipType_Default;

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

@ -21,7 +21,6 @@ static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
ScreenProxy::ScreenProxy(nsScreenManagerProxy* aScreenManager, ScreenDetails aDetails)
: mContentsScaleFactor(0)
, mDefaultCSSScaleFactor(0)
, mScreenManager(aScreenManager)
, mId(0)
, mPixelDepth(0)
@ -129,28 +128,6 @@ ScreenProxy::GetColorDepth(int32_t *aColorDepth)
return NS_OK;
}
NS_IMETHODIMP
ScreenProxy::GetContentsScaleFactor(double* aContentsScaleFactor)
{
if (!EnsureCacheIsValid()) {
return NS_ERROR_FAILURE;
}
*aContentsScaleFactor = mContentsScaleFactor;
return NS_OK;
}
NS_IMETHODIMP
ScreenProxy::GetDefaultCSSScaleFactor(double* aScaleFactor)
{
if (!EnsureCacheIsValid()) {
return NS_ERROR_FAILURE;
}
*aScaleFactor = mDefaultCSSScaleFactor;
return NS_OK;
}
void
ScreenProxy::PopulateByDetails(ScreenDetails aDetails)
{
@ -162,7 +139,6 @@ ScreenProxy::PopulateByDetails(ScreenDetails aDetails)
mPixelDepth = aDetails.pixelDepth();
mColorDepth = aDetails.colorDepth();
mContentsScaleFactor = aDetails.contentsScaleFactor();
mDefaultCSSScaleFactor = aDetails.defaultCSSScaleFactor();
}
bool

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

@ -44,9 +44,6 @@ public:
NS_IMETHOD GetPixelDepth(int32_t* aPixelDepth) override;
NS_IMETHOD GetColorDepth(int32_t* aColorDepth) override;
NS_IMETHOD GetContentsScaleFactor(double* aContentsScaleFactor) override;
NS_IMETHOD GetDefaultCSSScaleFactor(double* aScaleFactor) override;
private:
void PopulateByDetails(mozilla::dom::ScreenDetails aDetails);
@ -55,7 +52,6 @@ private:
void InvalidateCache();
double mContentsScaleFactor;
double mDefaultCSSScaleFactor;
RefPtr<nsScreenManagerProxy> mScreenManager;
uint32_t mId;
int32_t mPixelDepth;

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

@ -1924,7 +1924,7 @@ nsBaseWidget::StartAsyncScrollbarDrag(const AsyncDragMetrics& aDragMetrics)
}
already_AddRefed<nsIScreen>
nsIWidget::GetWidgetScreen()
nsBaseWidget::GetWidgetScreen()
{
nsCOMPtr<nsIScreenManager> screenManager;
screenManager = do_GetService("@mozilla.org/gfx/screenmanager;1");

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

@ -338,6 +338,9 @@ public:
return aClientSize;
}
// return the screen the widget is in.
already_AddRefed<nsIScreen> GetWidgetScreen();
// return true if this is a popup widget with a native titlebar
bool IsPopupWithTitleBar() const
{

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

@ -1191,11 +1191,6 @@ class nsIWidget : public nsISupports
nsISupports* aData,
nsIRunnable* aCallback) = 0;
/**
* Return the screen the widget is in, or null if we don't know.
*/
already_AddRefed<nsIScreen> GetWidgetScreen();
/**
* Put the toplevel window into or out of fullscreen mode.
* If aTargetScreen is given, attempt to go fullscreen on that screen,