Commit b073baab authored by Csoregi Natalia's avatar Csoregi Natalia
Browse files

Backed out 30 changesets (bug 1556556, bug 1631568) for multiple mochitest failures. CLOSED TREE

Backed out changeset edd529f7a9c5 (bug 1631568)
Backed out changeset 1cc0881e244b (bug 1631568)
Backed out changeset ed3c1e85d5e3 (bug 1556556)
Backed out changeset 38ffc6215bbf (bug 1556556)
Backed out changeset 03c2c25d8023 (bug 1556556)
Backed out changeset 9c717eb067b8 (bug 1556556)
Backed out changeset 98e26bc98b85 (bug 1556556)
Backed out changeset 05a6a581e755 (bug 1556556)
Backed out changeset 867946cf05bb (bug 1556556)
Backed out changeset 20d72a334530 (bug 1556556)
Backed out changeset 2c62e61d9054 (bug 1556556)
Backed out changeset 62a223d057d2 (bug 1556556)
Backed out changeset 2c5d55a1f0b1 (bug 1556556)
Backed out changeset 700447945b4e (bug 1556556)
Backed out changeset 93190ae4f5ff (bug 1556556)
Backed out changeset a7bd34d961bb (bug 1556556)
Backed out changeset fccd1d3c7189 (bug 1556556)
Backed out changeset 24056e47183d (bug 1556556)
Backed out changeset 204881474cc1 (bug 1556556)
Backed out changeset 387320881876 (bug 1556556)
Backed out changeset be8f5eb58460 (bug 1556556)
Backed out changeset 629c58a9166b (bug 1556556)
Backed out changeset 4312b2b5dda8 (bug 1556556)
Backed out changeset d11dbf6403a5 (bug 1556556)
Backed out changeset 95c54c023779 (bug 1556556)
Backed out changeset 80fcb7e71188 (bug 1556556)
Backed out changeset d75a4ecb0d47 (bug 1556556)
Backed out changeset 903c4de34e7a (bug 1556556)
Backed out changeset f15334a3e803 (bug 1556556)
Backed out changeset 9553e99137ea (bug 1556556)
parent 879ef8e0
......@@ -99,7 +99,7 @@ void DocAccessibleWrap::CacheViewportCallback(nsITimer* aTimer,
nsRect scrollPort = sf ? sf->GetScrollPortRect() : rootFrame->GetRect();
nsLayoutUtils::GetFramesForArea(
RelativeTo{presShell->GetRootFrame()}, scrollPort, frames,
presShell->GetRootFrame(), scrollPort, frames,
nsLayoutUtils::FrameForPointOption::OnlyVisible);
AccessibleHashtable inViewAccs;
for (size_t i = 0; i < frames.Length(); i++) {
......
......@@ -527,8 +527,26 @@ Accessible* Accessible::ChildAtPoint(int32_t aX, int32_t aY,
nsPoint offset(presContext->DevPixelsToAppUnits(aX) - screenRect.X(),
presContext->DevPixelsToAppUnits(aY) - screenRect.Y());
nsIFrame* foundFrame = nsLayoutUtils::GetFrameForPoint(
RelativeTo{startFrame, ViewportType::Visual}, offset);
// We need to take into account a non-1 resolution set on the presshell.
// This happens in mobile platforms with async pinch zooming.
offset = offset.RemoveResolution(presContext->PresShell()->GetResolution());
// We need to translate with the offset of the edge of the visual
// viewport from top edge of the layout viewport.
offset += presContext->PresShell()->GetVisualViewportOffset() -
presContext->PresShell()->GetLayoutViewportOffset();
EnumSet<nsLayoutUtils::FrameForPointOption> options = {
#ifdef MOZ_WIDGET_ANDROID
// This is needed in Android to ignore the clipping of the scroll frame
// when zoomed in. May regress something on other platforms, so
// keeping it Android-exclusive for now.
nsLayoutUtils::FrameForPointOption::IgnoreRootScrollFrame
#endif
};
nsIFrame* foundFrame =
nsLayoutUtils::GetFrameForPoint(startFrame, offset, options);
nsIContent* content = nullptr;
if (!foundFrame || !(content = foundFrame->GetContent()))
......
......@@ -12322,7 +12322,7 @@ already_AddRefed<nsDOMCaretPosition> Document::CaretPositionFromPoint(
}
 
nsIFrame* ptFrame = nsLayoutUtils::GetFrameForPoint(
RelativeTo{rootFrame}, pt,
rootFrame, pt,
{FrameForPointOption::IgnorePaintSuppression,
FrameForPointOption::IgnoreCrossDoc});
if (!ptFrame) {
......@@ -12334,8 +12334,8 @@ already_AddRefed<nsDOMCaretPosition> Document::CaretPositionFromPoint(
nsCOMPtr<nsIWidget> widget = nsContentUtils::GetWidget(presShell, &aOffset);
LayoutDeviceIntPoint refPoint = nsContentUtils::ToWidgetPoint(
CSSPoint(aX, aY), aOffset, GetPresContext());
nsPoint adjustedPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(
widget, refPoint, RelativeTo{ptFrame});
nsPoint adjustedPoint =
nsLayoutUtils::GetEventCoordinatesRelativeTo(widget, refPoint, ptFrame);
 
nsFrame::ContentOffsets offsets =
ptFrame->GetContentOffsetsFromPoint(adjustedPoint);
......
......@@ -363,7 +363,7 @@ template <typename NodeOrElement>
static void QueryNodesFromRect(DocumentOrShadowRoot& aRoot, const nsRect& aRect,
EnumSet<FrameForPointOption> aOptions,
FlushLayout aShouldFlushLayout,
Multiple aMultiple, ViewportType aViewportType,
Multiple aMultiple,
nsTArray<RefPtr<NodeOrElement>>& aNodes) {
static_assert(std::is_same<nsINode, NodeOrElement>::value ||
std::is_same<Element, NodeOrElement>::value,
......@@ -395,8 +395,7 @@ static void QueryNodesFromRect(DocumentOrShadowRoot& aRoot, const nsRect& aRect,
aOptions += FrameForPointOption::IgnoreCrossDoc;
AutoTArray<nsIFrame*, 8> frames;
nsLayoutUtils::GetFramesForArea({rootFrame, aViewportType}, aRect, frames,
aOptions);
nsLayoutUtils::GetFramesForArea(rootFrame, aRect, frames, aOptions);
for (nsIFrame* frame : frames) {
nsIContent* content = doc->GetContentInThisDocument(frame);
......@@ -440,7 +439,7 @@ template <typename NodeOrElement>
static void QueryNodesFromPoint(DocumentOrShadowRoot& aRoot, float aX, float aY,
EnumSet<FrameForPointOption> aOptions,
FlushLayout aShouldFlushLayout,
Multiple aMultiple, ViewportType aViewportType,
Multiple aMultiple,
nsTArray<RefPtr<NodeOrElement>>& aNodes) {
// As per the spec, we return null if either coord is negative.
if (!aOptions.contains(FrameForPointOption::IgnoreRootScrollFrame) &&
......@@ -452,37 +451,35 @@ static void QueryNodesFromPoint(DocumentOrShadowRoot& aRoot, float aX, float aY,
nscoord y = nsPresContext::CSSPixelsToAppUnits(aY);
nsPoint pt(x, y);
QueryNodesFromRect(aRoot, nsRect(pt, nsSize(1, 1)), aOptions,
aShouldFlushLayout, aMultiple, aViewportType, aNodes);
aShouldFlushLayout, aMultiple, aNodes);
}
} // namespace
Element* DocumentOrShadowRoot::ElementFromPoint(float aX, float aY) {
return ElementFromPointHelper(aX, aY, false, true, ViewportType::Layout);
return ElementFromPointHelper(aX, aY, false, true);
}
void DocumentOrShadowRoot::ElementsFromPoint(
float aX, float aY, nsTArray<RefPtr<Element>>& aElements) {
QueryNodesFromPoint(*this, aX, aY, {}, FlushLayout::Yes, Multiple::Yes,
ViewportType::Layout, aElements);
aElements);
}
void DocumentOrShadowRoot::NodesFromPoint(float aX, float aY,
nsTArray<RefPtr<nsINode>>& aNodes) {
QueryNodesFromPoint(*this, aX, aY, {}, FlushLayout::Yes, Multiple::Yes,
ViewportType::Layout, aNodes);
aNodes);
}
nsINode* DocumentOrShadowRoot::NodeFromPoint(float aX, float aY) {
AutoTArray<RefPtr<nsINode>, 1> nodes;
QueryNodesFromPoint(*this, aX, aY, {}, FlushLayout::Yes, Multiple::No,
ViewportType::Layout, nodes);
QueryNodesFromPoint(*this, aX, aY, {}, FlushLayout::Yes, Multiple::No, nodes);
return nodes.SafeElementAt(0);
}
Element* DocumentOrShadowRoot::ElementFromPointHelper(
float aX, float aY, bool aIgnoreRootScrollFrame, bool aFlushLayout,
ViewportType aViewportType) {
float aX, float aY, bool aIgnoreRootScrollFrame, bool aFlushLayout) {
EnumSet<FrameForPointOption> options;
if (aIgnoreRootScrollFrame) {
options += FrameForPointOption::IgnoreRootScrollFrame;
......@@ -491,8 +488,7 @@ Element* DocumentOrShadowRoot::ElementFromPointHelper(
auto flush = aFlushLayout ? FlushLayout::Yes : FlushLayout::No;
AutoTArray<RefPtr<Element>, 1> elements;
QueryNodesFromPoint(*this, aX, aY, options, flush, Multiple::No,
aViewportType, elements);
QueryNodesFromPoint(*this, aX, aY, options, flush, Multiple::No, elements);
return elements.SafeElementAt(0);
}
......@@ -524,8 +520,7 @@ void DocumentOrShadowRoot::NodesFromRect(float aX, float aY, float aTopSize,
}
auto flush = aFlushLayout ? FlushLayout::Yes : FlushLayout::No;
QueryNodesFromRect(*this, rect, options, flush, Multiple::Yes,
ViewportType::Layout, aReturn);
QueryNodesFromRect(*this, rect, options, flush, Multiple::Yes, aReturn);
}
Element* DocumentOrShadowRoot::AddIDTargetObserver(nsAtom* aID,
......
......@@ -9,7 +9,6 @@
#include "mozilla/dom/NameSpaceConstants.h"
#include "mozilla/IdentifierMapEntry.h"
#include "mozilla/RelativeTo.h"
#include "nsClassHashtable.h"
#include "nsContentListDeclarations.h"
#include "nsTArray.h"
......@@ -136,8 +135,7 @@ class DocumentOrShadowRoot {
*/
Element* ElementFromPointHelper(float aX, float aY,
bool aIgnoreRootScrollFrame,
bool aFlushLayout,
ViewportType aViewportType);
bool aFlushLayout);
void NodesFromRect(float aX, float aY, float aTopSize, float aRightSize,
float aBottomSize, float aLeftSize,
......
......@@ -3227,9 +3227,8 @@ already_AddRefed<DOMMatrixReadOnly> Element::GetTransformToAncestor(
// If aAncestor is not actually an ancestor of this (including nullptr),
// then the call to GetTransformToAncestor will return the transform
// all the way up through the parent chain.
transform = nsLayoutUtils::GetTransformToAncestor(RelativeTo{primaryFrame},
RelativeTo{ancestorFrame},
nsIFrame::IN_CSS_UNITS)
transform = nsLayoutUtils::GetTransformToAncestor(
primaryFrame, ancestorFrame, nsIFrame::IN_CSS_UNITS)
.GetMatrix();
}
......@@ -3244,8 +3243,7 @@ already_AddRefed<DOMMatrixReadOnly> Element::GetTransformToParent() {
Matrix4x4 transform;
if (primaryFrame) {
nsIFrame* parentFrame = primaryFrame->GetParent();
transform = nsLayoutUtils::GetTransformToAncestor(RelativeTo{primaryFrame},
RelativeTo{parentFrame},
transform = nsLayoutUtils::GetTransformToAncestor(primaryFrame, parentFrame,
nsIFrame::IN_CSS_UNITS)
.GetMatrix();
}
......@@ -3261,8 +3259,7 @@ already_AddRefed<DOMMatrixReadOnly> Element::GetTransformToViewport() {
if (primaryFrame) {
transform =
nsLayoutUtils::GetTransformToAncestor(
RelativeTo{primaryFrame},
RelativeTo{nsLayoutUtils::GetDisplayRootFrame(primaryFrame)},
primaryFrame, nsLayoutUtils::GetDisplayRootFrame(primaryFrame),
nsIFrame::IN_CSS_UNITS)
.GetMatrix();
}
......
......@@ -115,7 +115,6 @@
#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"
......@@ -7866,11 +7865,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(
visualRelative, aPresContext->AppUnitsPerDevPixel());
(CSSPoint::ToAppUnits(aPoint) + aOffset)
.ApplyResolution(nsLayoutUtils::GetCurrentAPZResolutionScale(
aPresContext->PresShell())),
aPresContext->AppUnitsPerDevPixel());
}
nsView* nsContentUtils::GetViewToDispatchEvent(nsPresContext* aPresContext,
......
......@@ -1155,8 +1155,8 @@ nsDOMWindowUtils::ElementFromPoint(float aX, float aY,
nsCOMPtr<Document> doc = GetDocument();
NS_ENSURE_STATE(doc);
RefPtr<Element> el = doc->ElementFromPointHelper(
aX, aY, aIgnoreRootScrollFrame, aFlushLayout, ViewportType::Layout);
RefPtr<Element> el =
doc->ElementFromPointHelper(aX, aY, aIgnoreRootScrollFrame, aFlushLayout);
el.forget(aReturn);
return NS_OK;
}
......@@ -3231,10 +3231,9 @@ nsDOMWindowUtils::SelectAtPoint(float aX, float aY, uint32_t aSelectBehavior,
nsCOMPtr<nsIWidget> widget = GetWidget(&offset);
LayoutDeviceIntPoint pt =
nsContentUtils::ToWidgetPoint(CSSPoint(aX, aY), offset, GetPresContext());
nsPoint ptInRoot = nsLayoutUtils::GetEventCoordinatesRelativeTo(
widget, pt, RelativeTo{rootFrame});
nsIFrame* targetFrame =
nsLayoutUtils::GetFrameForPoint(RelativeTo{rootFrame}, ptInRoot);
nsPoint ptInRoot =
nsLayoutUtils::GetEventCoordinatesRelativeTo(widget, pt, rootFrame);
nsIFrame* targetFrame = nsLayoutUtils::GetFrameForPoint(rootFrame, ptInRoot);
// This can happen if the page hasn't loaded yet or if the point
// is outside the frame.
if (!targetFrame) {
......@@ -3243,8 +3242,8 @@ nsDOMWindowUtils::SelectAtPoint(float aX, float aY, uint32_t aSelectBehavior,
// Convert point to coordinates relative to the target frame, which is
// what targetFrame's SelectByTypeAtPoint expects.
nsPoint relPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(
widget, pt, RelativeTo{targetFrame});
nsPoint relPoint =
nsLayoutUtils::GetEventCoordinatesRelativeTo(widget, pt, targetFrame);
nsresult rv = static_cast<nsFrame*>(targetFrame)
->SelectByTypeAtPoint(GetPresContext(), relPoint, amount,
......
......@@ -2549,11 +2549,10 @@ nsresult ContentEventHandler::OnQueryCharacterAtPoint(
eventOnRoot.mRefPoint += aEvent->mWidget->WidgetToScreenOffset() -
rootWidget->WidgetToScreenOffset();
}
nsPoint ptInRoot = nsLayoutUtils::GetEventCoordinatesRelativeTo(
&eventOnRoot, RelativeTo{rootFrame});
nsPoint ptInRoot =
nsLayoutUtils::GetEventCoordinatesRelativeTo(&eventOnRoot, rootFrame);
nsIFrame* targetFrame =
nsLayoutUtils::GetFrameForPoint(RelativeTo{rootFrame}, ptInRoot);
nsIFrame* targetFrame = nsLayoutUtils::GetFrameForPoint(rootFrame, ptInRoot);
if (!targetFrame || !targetFrame->GetContent() ||
!targetFrame->GetContent()->IsInclusiveDescendantOf(mRootContent)) {
// There is no character at the point.
......@@ -2649,7 +2648,7 @@ nsresult ContentEventHandler::OnQueryDOMWidgetHittest(
docFrameRect.y);
Element* contentUnderMouse = mDocument->ElementFromPointHelper(
eventLocCSS.x, eventLocCSS.y, false, false, ViewportType::Visual);
eventLocCSS.x, eventLocCSS.y, false, false);
if (contentUnderMouse) {
nsIWidget* targetWidget = nullptr;
nsIFrame* targetFrame = contentUnderMouse->GetPrimaryFrame();
......
......@@ -21,7 +21,6 @@
#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"
......@@ -550,8 +549,9 @@ CSSIntPoint Event::GetScreenCoords(nsPresContext* aPresContext,
rounded,
aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom());
if (PresShell* shell = aPresContext->GetPresShell()) {
pt = ViewportUtils::VisualToLayout(pt, shell);
if (PresShell* presShell = aPresContext->GetPresShell()) {
pt = pt.RemoveResolution(
nsLayoutUtils::GetCurrentAPZResolutionScale(presShell));
}
pt += LayoutDevicePixel::ToAppUnits(
......@@ -612,8 +612,8 @@ CSSIntPoint Event::GetClientCoords(nsPresContext* aPresContext,
if (!rootFrame) {
return CSSIntPoint(0, 0);
}
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(
aEvent, aPoint, RelativeTo{rootFrame});
nsPoint pt =
nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, aPoint, rootFrame);
return CSSIntPoint::FromAppUnitsRounded(pt);
}
......@@ -646,8 +646,8 @@ CSSIntPoint Event::GetOffsetCoords(nsPresContext* aPresContext,
CSSIntPoint clientCoords =
GetClientCoords(aPresContext, aEvent, aPoint, aDefaultPoint);
nsPoint pt = CSSPixel::ToAppUnits(clientCoords);
if (nsLayoutUtils::TransformPoint(RelativeTo{rootFrame}, RelativeTo{frame},
pt) == nsLayoutUtils::TRANSFORM_SUCCEEDED) {
if (nsLayoutUtils::TransformPoint(rootFrame, frame, pt) ==
nsLayoutUtils::TRANSFORM_SUCCEEDED) {
pt -= frame->GetPaddingRectRelativeToSelf().TopLeft();
return CSSPixel::FromAppUnitsRounded(pt);
}
......
......@@ -3809,7 +3809,7 @@ static bool ShouldBlockCustomCursor(nsPresContext* aPresContext,
}
nsPoint point = nsLayoutUtils::GetEventCoordinatesRelativeTo(
aEvent, RelativeTo{topLevel->PresShell()->GetRootFrame()});
aEvent, topLevel->PresShell()->GetRootFrame());
nsSize size(CSSPixel::ToAppUnits(width), CSSPixel::ToAppUnits(height));
nsPoint hotspot(CSSPixel::ToAppUnits(aCursor.mHotspot.x),
......@@ -3904,8 +3904,8 @@ void EventStateManager::UpdateCursor(nsPresContext* aPresContext,
}
// If not locked, look for correct cursor
else if (aTargetFrame) {
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(
aEvent, RelativeTo{aTargetFrame});
nsPoint pt =
nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, aTargetFrame);
Maybe<nsIFrame::Cursor> framecursor = aTargetFrame->GetCursor(pt);
// Avoid setting cursor when the mouse is over a windowless plugin.
if (!framecursor) {
......
......@@ -181,8 +181,7 @@ nsIntPoint UIEvent::GetLayerPoint() const {
nsIFrame* targetFrame = mPresContext->EventStateManager()->GetEventTarget();
if (!targetFrame) return mLayerPoint;
nsIFrame* layer = nsLayoutUtils::GetClosestLayer(targetFrame);
nsPoint pt(
nsLayoutUtils::GetEventCoordinatesRelativeTo(mEvent, RelativeTo{layer}));
nsPoint pt(nsLayoutUtils::GetEventCoordinatesRelativeTo(mEvent, layer));
return nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(pt.x),
nsPresContext::AppUnitsToIntCSSPixels(pt.y));
}
......
......@@ -563,7 +563,7 @@ void HTMLCanvasElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
return;
}
nsPoint ptInRoot =
nsLayoutUtils::GetEventCoordinatesRelativeTo(evt, RelativeTo{frame});
nsLayoutUtils::GetEventCoordinatesRelativeTo(evt, frame);
nsRect paddingRect = frame->GetContentRectRelativeToSelf();
Point hitpoint;
hitpoint.x = (ptInRoot.x - paddingRect.x) / AppUnitsPerCSSPixel();
......
......@@ -1339,13 +1339,8 @@ mozilla::ipc::IPCResult BrowserChild::RecvHandleTap(
}
CSSToLayoutDeviceScale scale(
presShell->GetPresContext()->CSSToDevPixelScale());
CSSPoint point = aPoint / scale;
// Stash the guid in InputAPZContext so that when the visual-to-layout
// transform is applied to the event's coordinates, we use the right transform
// based on the scroll frame being targeted.
// The other values don't really matter.
InputAPZContext context(aGuid, aInputBlockId, nsEventStatus_eSentinel);
CSSPoint point =
APZCCallbackHelper::ApplyCallbackTransform(aPoint / scale, aGuid);
switch (aType) {
case GeckoContentController::TapType::eSingleTap:
......@@ -1640,16 +1635,6 @@ mozilla::ipc::IPCResult BrowserChild::RecvRealMouseButtonEvent(
void BrowserChild::HandleRealMouseButtonEvent(const WidgetMouseEvent& aEvent,
const ScrollableLayerGuid& aGuid,
const uint64_t& aInputBlockId) {
WidgetMouseEvent localEvent(aEvent);
localEvent.mWidget = mPuppetWidget;
// We need one InputAPZContext here to propagate |aGuid| to places in
// SendSetTargetAPZCNotification() which apply the visual-to-layout transform,
// and another below to propagate the |postLayerization| flag (whose value
// we don't know until SendSetTargetAPZCNotification() returns) into
// the event dispatch code.
InputAPZContext context1(aGuid, aInputBlockId, nsEventStatus_eSentinel);
// Mouse events like eMouseEnterIntoWidget, that are created in the parent
// process EventStateManager code, have an input block id which they get from
// the InputAPZContext in the parent process stack. However, they did not
......@@ -1657,19 +1642,23 @@ void BrowserChild::HandleRealMouseButtonEvent(const WidgetMouseEvent& aEvent,
// Since thos events didn't go through APZ, we don't need to send
// notifications for them.
UniquePtr<DisplayportSetListener> postLayerization;
if (aInputBlockId && localEvent.mFlags.mHandledByAPZ) {
if (aInputBlockId && aEvent.mFlags.mHandledByAPZ) {
nsCOMPtr<Document> document(GetTopLevelDocument());
postLayerization = APZCCallbackHelper::SendSetTargetAPZCNotification(
mPuppetWidget, document, localEvent, aGuid.mLayersId, aInputBlockId);
mPuppetWidget, document, aEvent, aGuid.mLayersId, aInputBlockId);
}
InputAPZContext context2(aGuid, aInputBlockId, nsEventStatus_eSentinel,
postLayerization != nullptr);
InputAPZContext context(aGuid, aInputBlockId, nsEventStatus_eIgnore,
postLayerization != nullptr);
WidgetMouseEvent localEvent(aEvent);
localEvent.mWidget = mPuppetWidget;
APZCCallbackHelper::ApplyCallbackTransform(localEvent, aGuid,
mPuppetWidget->GetDefaultScale());
DispatchWidgetEventViaAPZ(localEvent);
if (aInputBlockId && localEvent.mFlags.mHandledByAPZ) {
mAPZEventState->ProcessMouseEvent(localEvent, aInputBlockId);
if (aInputBlockId && aEvent.mFlags.mHandledByAPZ) {
mAPZEventState->ProcessMouseEvent(aEvent, aInputBlockId);
}
// Do this after the DispatchWidgetEventViaAPZ call above, so that if the
......@@ -1756,13 +1745,8 @@ void BrowserChild::DispatchWheelEvent(const WidgetWheelEvent& aEvent,
}
localEvent.mWidget = mPuppetWidget;
// Stash the guid in InputAPZContext so that when the visual-to-layout
// transform is applied to the event's coordinates, we use the right transform
// based on the scroll frame being targeted.
// The other values don't really matter.
InputAPZContext context(aGuid, aInputBlockId, nsEventStatus_eSentinel);
APZCCallbackHelper::ApplyCallbackTransform(localEvent, aGuid,
mPuppetWidget->GetDefaultScale());
DispatchWidgetEventViaAPZ(localEvent);
if (localEvent.mCanTriggerSwipe) {
......@@ -1816,11 +1800,8 @@ mozilla::ipc::IPCResult BrowserChild::RecvRealTouchEvent(
WidgetTouchEvent localEvent(aEvent);
localEvent.mWidget = mPuppetWidget;
// Stash the guid in InputAPZContext so that when the visual-to-layout
// transform is applied to the event's coordinates, we use the right transform
// based on the scroll frame being targeted.
// The other values don't really matter.
InputAPZContext context(aGuid, aInputBlockId, aApzResponse);
APZCCallbackHelper::ApplyCallbackTransform(localEvent, aGuid,
mPuppetWidget->GetDefaultScale());
if (localEvent.mMessage == eTouchStart && AsyncPanZoomEnabled()) {
nsCOMPtr<Document> document = GetTopLevelDocument();
......
......@@ -2452,14 +2452,9 @@ 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,
viewportType, widget);
widget);
}
LayoutDeviceIntPoint BrowserParent::GetClientOffset() {
......
......@@ -1833,9 +1833,9 @@ static NPCocoaEvent TranslateToNPCocoaEvent(WidgetGUIEvent* anEvent,
anEvent->mMessage == eMouseUp ||
anEvent->mMessage == eLegacyMouseLineOrPageScroll ||
anEvent->mMessage == eMouseOver || anEvent->mMessage == eMouseOut) {
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(
anEvent, RelativeTo{aObjectFrame}) -
aObjectFrame->GetContentRectRelativeToSelf().TopLeft();
nsPoint pt =
nsLayoutUtils::GetEventCoordinatesRelativeTo(anEvent, aObjectFrame) -
aObjectFrame->GetContentRectRelativeToSelf().TopLeft();
nsPresContext* presContext = aObjectFrame->PresContext();
// Plugin event coordinates need to be translated from device pixels
// into "display pixels" in HiDPI modes.
......@@ -2164,9 +2164,9 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(
anEvent.mMessage == eMouseOver || anEvent.mMessage == eMouseOut ||
anEvent.mMessage == eMouseMove || anEvent.mMessage == eWheel,
"Incorrect event type for coordinate translation");
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(
&anEvent, RelativeTo{mPluginFrame}) -
mPluginFrame->GetContentRectRelativeToSelf().TopLeft();
nsPoint pt =
nsLayoutUtils::GetEventCoordinatesRelativeTo(&anEvent, mPluginFrame) -
mPluginFrame->GetContentRectRelativeToSelf().TopLeft();
nsPresContext* presContext = mPluginFrame->PresContext();
nsIntPoint ptPx(presContext->AppUnitsToDevPixels(pt.x),
presContext->AppUnitsToDevPixels(pt.y));
......@@ -2246,9 +2246,9 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(
// Get reference point relative to plugin origin.
const nsPresContext* presContext = mPluginFrame->PresContext();
nsPoint appPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(
&anEvent, RelativeTo{mPluginFrame}) -
mPluginFrame->GetContentRectRelativeToSelf().TopLeft();
nsPoint appPoint =
nsLayoutUtils::GetEventCoordinatesRelativeTo(&anEvent, mPluginFrame) -
mPluginFrame->GetContentRectRelativeToSelf().TopLeft();
nsIntPoint pluginPoint(presContext->AppUnitsToDevPixels(appPoint.x),
presContext->AppUnitsToDevPixels(appPoint.y));
const WidgetMouseEvent& mouseEvent = *anEvent.AsMouseEvent();
......
......@@ -62,6 +62,17 @@ APZEventResult APZInputBridge::ReceiveInputEvent(WidgetInputEvent& aEvent) {
UpdateWheelTransaction(mouseEvent.mRefPoint, mouseEvent.mMessage);
}
// If zooming is enabled, mark the mouse event as "ignore root
// scroll frame". This ensures that the main-thread hit test the
// mouse event undergoes (in PositionedEventTargeting.cpp) uses
// the IGNORE_ROOT_SCROLL_FRAME flag, which is needed for correct
// hit testing in a zoomed-in or zoomed-out state.
// FIXME: bug 1525793 -- this may need to handle zooming or not on a
// per-document basis.
if (StaticPrefs::apz_allow_zooming()) {
mouseEvent.mIgnoreRootScrollFrame = true;
}
if (WillHandleMouseEvent(mouseEvent)) {
MouseInput input(mouseEvent);
input.mOrigin =
......
......@@ -19,8 +19,9 @@ var subtests = [
// Test for dragging on the scrollbar of the root scrollable element works.
// This takes different codepaths with async zooming support enabled and
// disabled, and so needs to be tested separately for both.
// TODO(bug 1556556): Once we get this working with zooming enabled,
// add an entry to run this with apz.allow_zooming=true as well.
{"file": "helper_drag_root_scrollbar.html", "prefs": [["apz.allow_zooming", false]]},
{"file": "helper_drag_root_scrollbar.html", "prefs": [["apz.allow_zooming", true]]},
// Test for dragging on a fake-scrollbar element that scrolls the page
{"file": "helper_drag_scroll.html"},
// Test for dragging the scrollbar with a fixed-pos element overlaying it
......
......@@ -20,7 +20,6 @@
#include "mozilla/layers/WebRenderBridgeChild.h"
#include "mozilla/PresShell.h"
#include "mozilla/TouchEvents.h"
#include "mozilla/ViewportUtils.h"
#include "nsContainerFrame.h"
#include "nsContentUtils.h"
#include "nsIContent.h"
......@@ -452,6 +451,89 @@ PresShell* APZCCallbackHelper::GetRootContentDocumentPresShellForContent(
return context->PresShell();
}
static PresShell* GetRootDocumentPresShell(nsIContent* aContent) {
dom::Document* doc = aContent->GetComposedDoc();
if (!doc) {
return nullptr;
}
PresShell* presShell = doc->GetPresShell();
if (!presShell) {
return nullptr;
}
nsPresContext* context = presShell->GetPresContext();
if (!context) {
return nullptr;
}
context = context->GetRootPresContext();
if (!context) {
return nullptr;
}
return context->PresShell();
}
CSSPoint APZCCallbackHelper::ApplyCallbackTransform(
const CSSPoint& aInput, const ScrollableLayerGuid& aGuid) {
CSSPoint input = aInput;
if (aGuid.mScrollId == ScrollableLayerGuid::NULL_SCROLL_ID) {
return input;
}
nsCOMPtr<nsIContent> content = nsLayoutUtils::FindContentFor(aGuid.mScrollId);
if (!content) {
return input;
}
// First, scale inversely by the root content document's pres shell
// resolution to cancel the scale-to-resolution transform that the
// compositor adds to the layer with the pres shell resolution. The points
// sent to Gecko by APZ don't have this transform unapplied (unlike other