зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1556556
- Miscellaneous fixes related to event coordinate transformations. r=tnikkel
Differential Revision: https://phabricator.services.mozilla.com/D69639
This commit is contained in:
Родитель
b6c97a5eb0
Коммит
551a4602dc
|
@ -115,6 +115,7 @@
|
|||
#include "mozilla/TextControlState.h"
|
||||
#include "mozilla/TextEditor.h"
|
||||
#include "mozilla/TextEvents.h"
|
||||
#include "mozilla/ViewportUtils.h"
|
||||
#include "nsArrayUtils.h"
|
||||
#include "nsAString.h"
|
||||
#include "nsAttrName.h"
|
||||
|
@ -7844,11 +7845,11 @@ int16_t nsContentUtils::GetButtonsFlagForButton(int32_t aButton) {
|
|||
LayoutDeviceIntPoint nsContentUtils::ToWidgetPoint(
|
||||
const CSSPoint& aPoint, const nsPoint& aOffset,
|
||||
nsPresContext* aPresContext) {
|
||||
nsPoint layoutRelative = CSSPoint::ToAppUnits(aPoint) + aOffset;
|
||||
nsPoint visualRelative =
|
||||
ViewportUtils::LayoutToVisual(layoutRelative, aPresContext->PresShell());
|
||||
return LayoutDeviceIntPoint::FromAppUnitsRounded(
|
||||
(CSSPoint::ToAppUnits(aPoint) + aOffset)
|
||||
.ApplyResolution(nsLayoutUtils::GetCurrentAPZResolutionScale(
|
||||
aPresContext->PresShell())),
|
||||
aPresContext->AppUnitsPerDevPixel());
|
||||
visualRelative, aPresContext->AppUnitsPerDevPixel());
|
||||
}
|
||||
|
||||
nsView* nsContentUtils::GetViewToDispatchEvent(nsPresContext* aPresContext,
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/TextEvents.h"
|
||||
#include "mozilla/TouchEvents.h"
|
||||
#include "mozilla/ViewportUtils.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "mozilla/dom/DocumentInlines.h"
|
||||
#include "mozilla/dom/Event.h"
|
||||
|
@ -549,9 +550,8 @@ CSSIntPoint Event::GetScreenCoords(nsPresContext* aPresContext,
|
|||
rounded,
|
||||
aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom());
|
||||
|
||||
if (PresShell* presShell = aPresContext->GetPresShell()) {
|
||||
pt = pt.RemoveResolution(
|
||||
nsLayoutUtils::GetCurrentAPZResolutionScale(presShell));
|
||||
if (PresShell* shell = aPresContext->GetPresShell()) {
|
||||
pt = ViewportUtils::VisualToLayout(pt, shell);
|
||||
}
|
||||
|
||||
pt += LayoutDevicePixel::ToAppUnits(
|
||||
|
|
|
@ -2473,9 +2473,14 @@ LayoutDeviceIntPoint BrowserParent::GetChildProcessOffset() {
|
|||
// any events we send to the child, and reverse them for any screen
|
||||
// coordinates that we retrieve from the child.
|
||||
|
||||
// TODO: Once we take into account transforms here, set viewportType
|
||||
// correctly. For now we use Visual as this means we don't apply
|
||||
// the layout-to-visual transform in TranslateViewToWidget().
|
||||
ViewportType viewportType = ViewportType::Visual;
|
||||
|
||||
nsPoint pt = targetFrame->GetOffsetTo(rootFrame);
|
||||
return -nsLayoutUtils::TranslateViewToWidget(presContext, rootView, pt,
|
||||
widget);
|
||||
viewportType, widget);
|
||||
}
|
||||
|
||||
LayoutDeviceIntPoint BrowserParent::GetClientOffset() {
|
||||
|
|
|
@ -529,7 +529,8 @@ nsIFrame* FindFrameTargetedByInputEvent(
|
|||
return target;
|
||||
}
|
||||
LayoutDeviceIntPoint widgetPoint = nsLayoutUtils::TranslateViewToWidget(
|
||||
aRootFrame.mFrame->PresContext(), view, point, aEvent->mWidget);
|
||||
aRootFrame.mFrame->PresContext(), view, point, aRootFrame.mViewportType,
|
||||
aEvent->mWidget);
|
||||
if (widgetPoint.x != NS_UNCONSTRAINEDSIZE) {
|
||||
// If that succeeded, we update the point in the event
|
||||
aEvent->mRefPoint = widgetPoint;
|
||||
|
|
|
@ -3108,16 +3108,19 @@ nsPoint nsLayoutUtils::TranslateWidgetToView(nsPresContext* aPresContext,
|
|||
|
||||
LayoutDeviceIntPoint nsLayoutUtils::TranslateViewToWidget(
|
||||
nsPresContext* aPresContext, nsView* aView, nsPoint aPt,
|
||||
nsIWidget* aWidget) {
|
||||
ViewportType aViewportType, nsIWidget* aWidget) {
|
||||
nsPoint viewOffset;
|
||||
nsIWidget* viewWidget = aView->GetNearestWidget(&viewOffset);
|
||||
if (!viewWidget) {
|
||||
return LayoutDeviceIntPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
|
||||
}
|
||||
|
||||
nsPoint pt = (aPt + viewOffset)
|
||||
.ApplyResolution(
|
||||
GetCurrentAPZResolutionScale(aPresContext->PresShell()));
|
||||
nsPoint pt = (aPt + viewOffset);
|
||||
// The target coordinates are visual, so perform a layout-to-visual
|
||||
// conversion if the incoming coordinates are layout.
|
||||
if (aViewportType == ViewportType::Layout && aPresContext->GetPresShell()) {
|
||||
pt = ViewportUtils::LayoutToVisual(pt, aPresContext->GetPresShell());
|
||||
}
|
||||
LayoutDeviceIntPoint relativeToViewWidget(
|
||||
aPresContext->AppUnitsToDevPixels(pt.x),
|
||||
aPresContext->AppUnitsToDevPixels(pt.y));
|
||||
|
|
|
@ -882,12 +882,13 @@ class nsLayoutUtils {
|
|||
* @param aPresContext the PresContext for the view
|
||||
* @param aView the view
|
||||
* @param aPt the point relative to the view
|
||||
* @param aViewportType whether the point is in visual or layout coordinates
|
||||
* @param aWidget the widget to which returned coordinates are relative
|
||||
* @return the point in the view's coordinates
|
||||
*/
|
||||
static mozilla::LayoutDeviceIntPoint TranslateViewToWidget(
|
||||
nsPresContext* aPresContext, nsView* aView, nsPoint aPt,
|
||||
nsIWidget* aWidget);
|
||||
ViewportType aViewportType, nsIWidget* aWidget);
|
||||
|
||||
static mozilla::LayoutDeviceIntPoint WidgetToWidgetOffset(
|
||||
nsIWidget* aFromWidget, nsIWidget* aToWidget);
|
||||
|
|
Загрузка…
Ссылка в новой задаче