зеркало из 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();
|
||||
}
|
||||
|
||||
CSSPoint APZCCallbackHelper::ApplyCallbackTransform(
|
||||
const CSSPoint& aInput, const ScrollableLayerGuid& aGuid) {
|
||||
CSSPoint input = aInput;
|
||||
mozilla::CSSToCSSMatrix4x4 APZCCallbackHelper::GetCallbackTransform(
|
||||
const ScrollableLayerGuid& aGuid) {
|
||||
if (aGuid.mScrollId == ScrollableLayerGuid::NULL_SCROLL_ID) {
|
||||
return input;
|
||||
return {};
|
||||
}
|
||||
nsCOMPtr<nsIContent> content = nsLayoutUtils::FindContentFor(aGuid.mScrollId);
|
||||
if (!content) {
|
||||
return input;
|
||||
return {};
|
||||
}
|
||||
|
||||
// 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
|
||||
// testing against content that's conceptually outside the resolution,
|
||||
// such as scrollbars.
|
||||
float resolution = 1.0f;
|
||||
if (PresShell* presShell =
|
||||
GetRootContentDocumentPresShellForContent(content)) {
|
||||
input = input / presShell->GetResolution();
|
||||
resolution = presShell->GetResolution();
|
||||
}
|
||||
|
||||
// Now apply the callback-transform. This is only approximately correct,
|
||||
// see the comment on GetCumulativeApzCallbackTransform for details.
|
||||
CSSPoint transform = nsLayoutUtils::GetCumulativeApzCallbackTransform(
|
||||
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(
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "InputData.h"
|
||||
#include "LayersTypes.h"
|
||||
#include "Units.h"
|
||||
#include "mozilla/EventForwards.h"
|
||||
#include "mozilla/layers/APZUtils.h"
|
||||
#include "mozilla/layers/MatrixMessage.h"
|
||||
|
@ -97,10 +98,9 @@ class APZCCallbackHelper {
|
|||
static PresShell* GetRootContentDocumentPresShellForContent(
|
||||
nsIContent* aContent);
|
||||
|
||||
/* Apply a "callback transform" to |aInput|, which represents the coordinates
|
||||
of an input event targeting content inside the scroll frame identified by
|
||||
|aGuid|.
|
||||
The callback transform has two components:
|
||||
/* Return a "callback transform" to be applied to the coordinates of input
|
||||
events targeting content inside the scroll frame identified by |aGuid|.
|
||||
The callback transform has two components:
|
||||
1. The pres shell resolution, representing the pinch-zoom scale
|
||||
(if the scroll frame |aScrollId| is inside the resolution, which
|
||||
is most of the time).
|
||||
|
@ -112,6 +112,10 @@ class APZCCallbackHelper {
|
|||
The translation is accumulated for all scroll frames form |aGuid| up to
|
||||
the root, using values populated in UpdateCallbackTransform. See that
|
||||
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,
|
||||
const ScrollableLayerGuid& aGuid);
|
||||
|
||||
|
|
|
@ -224,6 +224,7 @@ typedef gfx::ScaleFactors2D<ParentLayerPixel, ScreenPixel>
|
|||
typedef gfx::ScaleFactors2D<ParentLayerPixel, ParentLayerPixel>
|
||||
ParentLayerToParentLayerScale2D;
|
||||
|
||||
typedef gfx::Matrix4x4Typed<CSSPixel, CSSPixel> CSSToCSSMatrix4x4;
|
||||
typedef gfx::Matrix4x4Typed<LayoutDevicePixel, LayoutDevicePixel>
|
||||
LayoutDeviceToLayoutDeviceMatrix4x4;
|
||||
typedef gfx::Matrix4x4Typed<LayoutDevicePixel, ParentLayerPixel>
|
||||
|
|
Загрузка…
Ссылка в новой задаче