зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1556556
- Factor out an APZCCallbackHelper::GetCallbackTransform() helper. r=kats
This is to facilitate call sites that need to incorporate the transform into a larger transform matrix rather than immediately applying the callback transform to a point. Differential Revision: https://phabricator.services.mozilla.com/D68275
This commit is contained in:
Родитель
2037608c4a
Коммит
2290774510
|
@ -451,15 +451,14 @@ PresShell* APZCCallbackHelper::GetRootContentDocumentPresShellForContent(
|
||||||
return context->PresShell();
|
return context->PresShell();
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSPoint APZCCallbackHelper::ApplyCallbackTransform(
|
mozilla::CSSToCSSMatrix4x4 APZCCallbackHelper::GetCallbackTransform(
|
||||||
const CSSPoint& aInput, const ScrollableLayerGuid& aGuid) {
|
const ScrollableLayerGuid& aGuid) {
|
||||||
CSSPoint input = aInput;
|
|
||||||
if (aGuid.mScrollId == ScrollableLayerGuid::NULL_SCROLL_ID) {
|
if (aGuid.mScrollId == ScrollableLayerGuid::NULL_SCROLL_ID) {
|
||||||
return input;
|
return {};
|
||||||
}
|
}
|
||||||
nsCOMPtr<nsIContent> content = nsLayoutUtils::FindContentFor(aGuid.mScrollId);
|
nsCOMPtr<nsIContent> content = nsLayoutUtils::FindContentFor(aGuid.mScrollId);
|
||||||
if (!content) {
|
if (!content) {
|
||||||
return input;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// First, scale inversely by the root content document's pres shell
|
// First, scale inversely by the root content document's pres shell
|
||||||
|
@ -469,16 +468,24 @@ CSSPoint APZCCallbackHelper::ApplyCallbackTransform(
|
||||||
// compositor-side transforms) because Gecko needs it applied when hit
|
// compositor-side transforms) because Gecko needs it applied when hit
|
||||||
// testing against content that's conceptually outside the resolution,
|
// testing against content that's conceptually outside the resolution,
|
||||||
// such as scrollbars.
|
// such as scrollbars.
|
||||||
|
float resolution = 1.0f;
|
||||||
if (PresShell* presShell =
|
if (PresShell* presShell =
|
||||||
GetRootContentDocumentPresShellForContent(content)) {
|
GetRootContentDocumentPresShellForContent(content)) {
|
||||||
input = input / presShell->GetResolution();
|
resolution = presShell->GetResolution();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now apply the callback-transform. This is only approximately correct,
|
// Now apply the callback-transform. This is only approximately correct,
|
||||||
// see the comment on GetCumulativeApzCallbackTransform for details.
|
// see the comment on GetCumulativeApzCallbackTransform for details.
|
||||||
CSSPoint transform = nsLayoutUtils::GetCumulativeApzCallbackTransform(
|
CSSPoint transform = nsLayoutUtils::GetCumulativeApzCallbackTransform(
|
||||||
content->GetPrimaryFrame());
|
content->GetPrimaryFrame());
|
||||||
return input + transform;
|
|
||||||
|
return mozilla::CSSToCSSMatrix4x4::Scaling(1 / resolution, 1 / resolution, 1)
|
||||||
|
.PostTranslate(transform.x, transform.y, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
CSSPoint APZCCallbackHelper::ApplyCallbackTransform(
|
||||||
|
const CSSPoint& aInput, const ScrollableLayerGuid& aGuid) {
|
||||||
|
return GetCallbackTransform(aGuid).TransformPoint(aInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
LayoutDeviceIntPoint APZCCallbackHelper::ApplyCallbackTransform(
|
LayoutDeviceIntPoint APZCCallbackHelper::ApplyCallbackTransform(
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include "InputData.h"
|
#include "InputData.h"
|
||||||
#include "LayersTypes.h"
|
#include "LayersTypes.h"
|
||||||
|
#include "Units.h"
|
||||||
#include "mozilla/EventForwards.h"
|
#include "mozilla/EventForwards.h"
|
||||||
#include "mozilla/layers/APZUtils.h"
|
#include "mozilla/layers/APZUtils.h"
|
||||||
#include "mozilla/layers/MatrixMessage.h"
|
#include "mozilla/layers/MatrixMessage.h"
|
||||||
|
@ -97,9 +98,8 @@ class APZCCallbackHelper {
|
||||||
static PresShell* GetRootContentDocumentPresShellForContent(
|
static PresShell* GetRootContentDocumentPresShellForContent(
|
||||||
nsIContent* aContent);
|
nsIContent* aContent);
|
||||||
|
|
||||||
/* Apply a "callback transform" to |aInput|, which represents the coordinates
|
/* Return a "callback transform" to be applied to the coordinates of input
|
||||||
of an input event targeting content inside the scroll frame identified by
|
events targeting content inside the scroll frame identified by |aGuid|.
|
||||||
|aGuid|.
|
|
||||||
The callback transform has two components:
|
The callback transform has two components:
|
||||||
1. The pres shell resolution, representing the pinch-zoom scale
|
1. The pres shell resolution, representing the pinch-zoom scale
|
||||||
(if the scroll frame |aScrollId| is inside the resolution, which
|
(if the scroll frame |aScrollId| is inside the resolution, which
|
||||||
|
@ -112,6 +112,10 @@ class APZCCallbackHelper {
|
||||||
The translation is accumulated for all scroll frames form |aGuid| up to
|
The translation is accumulated for all scroll frames form |aGuid| up to
|
||||||
the root, using values populated in UpdateCallbackTransform. See that
|
the root, using values populated in UpdateCallbackTransform. See that
|
||||||
method's documentation for additional details. */
|
method's documentation for additional details. */
|
||||||
|
static CSSToCSSMatrix4x4 GetCallbackTransform(
|
||||||
|
const ScrollableLayerGuid& aGuid);
|
||||||
|
|
||||||
|
/* Apply |GetCallbackTransform()| to |aInput| and return the result. */
|
||||||
static CSSPoint ApplyCallbackTransform(const CSSPoint& aInput,
|
static CSSPoint ApplyCallbackTransform(const CSSPoint& aInput,
|
||||||
const ScrollableLayerGuid& aGuid);
|
const ScrollableLayerGuid& aGuid);
|
||||||
|
|
||||||
|
|
|
@ -224,6 +224,7 @@ typedef gfx::ScaleFactors2D<ParentLayerPixel, ScreenPixel>
|
||||||
typedef gfx::ScaleFactors2D<ParentLayerPixel, ParentLayerPixel>
|
typedef gfx::ScaleFactors2D<ParentLayerPixel, ParentLayerPixel>
|
||||||
ParentLayerToParentLayerScale2D;
|
ParentLayerToParentLayerScale2D;
|
||||||
|
|
||||||
|
typedef gfx::Matrix4x4Typed<CSSPixel, CSSPixel> CSSToCSSMatrix4x4;
|
||||||
typedef gfx::Matrix4x4Typed<LayoutDevicePixel, LayoutDevicePixel>
|
typedef gfx::Matrix4x4Typed<LayoutDevicePixel, LayoutDevicePixel>
|
||||||
LayoutDeviceToLayoutDeviceMatrix4x4;
|
LayoutDeviceToLayoutDeviceMatrix4x4;
|
||||||
typedef gfx::Matrix4x4Typed<LayoutDevicePixel, ParentLayerPixel>
|
typedef gfx::Matrix4x4Typed<LayoutDevicePixel, ParentLayerPixel>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче