Bug 1668913 - Audit usages of ScaleFactors2D::ToScaleFactor(). r=botond

Differential Revision: https://phabricator.services.mozilla.com/D106576
This commit is contained in:
tanweerali 2021-02-27 21:17:55 +00:00
Родитель 6a023272d5
Коммит 6a27002564
4 изменённых файлов: 20 добавлений и 1 удалений

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

@ -1543,6 +1543,7 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) {
MOZ_ASSERT(Metrics().IsRootContent());
MOZ_ASSERT(Metrics().GetZoom().AreScalesSame());
// TODO: Need to handle different x-and y-scales.
CSSToParentLayerScale userZoom = Metrics().GetZoom().ToScaleFactor();
ParentLayerPoint focusPoint =
aEvent.mLocalFocusPoint - Metrics().GetCompositionBounds().TopLeft();
@ -5224,6 +5225,7 @@ void AsyncPanZoomController::ZoomToRect(CSSRect aRect, const uint32_t aFlags) {
ParentLayerRect compositionBounds = Metrics().GetCompositionBounds();
CSSRect cssPageRect = Metrics().GetScrollableRect();
CSSPoint scrollOffset = Metrics().GetVisualScrollOffset();
// TODO: Need to handle different x-and y-scales.
CSSToParentLayerScale currentZoom = Metrics().GetZoom().ToScaleFactor();
CSSToParentLayerScale targetZoom;

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

@ -318,7 +318,7 @@ ParentLayerCoord Axis::DisplacementWillOverscrollAmount(
CSSCoord Axis::ScaleWillOverscrollAmount(float aScale, CSSCoord aFocus) const {
// Internally, do computations in ParentLayer coordinates *before* the scale
// is applied.
CSSToParentLayerScale zoom = GetFrameMetrics().GetZoom().ToScaleFactor();
CSSToParentLayerScale zoom = GetAxisScale(GetFrameMetrics().GetZoom());
ParentLayerCoord focus = aFocus * zoom;
ParentLayerCoord originAfterScale = (GetOrigin() + focus) - (focus / aScale);
@ -433,6 +433,11 @@ ParentLayerCoord AxisX::GetPointOffset(const ParentLayerPoint& aPoint) const {
return aPoint.x;
}
CSSToParentLayerScale AxisX::GetAxisScale(
const CSSToParentLayerScale2D& aScale) const {
return CSSToParentLayerScale(aScale.xScale);
}
ParentLayerCoord AxisX::GetRectLength(const ParentLayerRect& aRect) const {
return aRect.Width();
}
@ -475,6 +480,11 @@ ParentLayerCoord AxisY::GetPointOffset(const ParentLayerPoint& aPoint) const {
return aPoint.y;
}
CSSToParentLayerScale AxisY::GetAxisScale(
const CSSToParentLayerScale2D& aScale) const {
return CSSToParentLayerScale(aScale.yScale);
}
ParentLayerCoord AxisY::GetRectLength(const ParentLayerRect& aRect) const {
return aRect.Height();
}

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

@ -273,6 +273,8 @@ class Axis {
bool OverscrollBehaviorAllowsHandoff() const;
bool OverscrollBehaviorAllowsOverscrollEffect() const;
virtual CSSToParentLayerScale GetAxisScale(
const CSSToParentLayerScale2D& aScale) const = 0;
virtual ParentLayerCoord GetPointOffset(
const ParentLayerPoint& aPoint) const = 0;
virtual ParentLayerCoord GetRectLength(
@ -340,6 +342,8 @@ class Axis {
class AxisX : public Axis {
public:
explicit AxisX(AsyncPanZoomController* mAsyncPanZoomController);
CSSToParentLayerScale GetAxisScale(
const CSSToParentLayerScale2D& aScale) const override;
ParentLayerCoord GetPointOffset(
const ParentLayerPoint& aPoint) const override;
ParentLayerCoord GetRectLength(const ParentLayerRect& aRect) const override;
@ -359,6 +363,8 @@ class AxisY : public Axis {
explicit AxisY(AsyncPanZoomController* mAsyncPanZoomController);
ParentLayerCoord GetPointOffset(
const ParentLayerPoint& aPoint) const override;
CSSToParentLayerScale GetAxisScale(
const CSSToParentLayerScale2D& aScale) const override;
ParentLayerCoord GetRectLength(const ParentLayerRect& aRect) const override;
ParentLayerCoord GetRectOffset(const ParentLayerRect& aRect) const override;
CSSToParentLayerScale GetScaleForAxis(

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

@ -217,6 +217,7 @@ void UiCompositorControllerParent::NotifyFirstPaint() {
void UiCompositorControllerParent::NotifyUpdateScreenMetrics(
const GeckoViewMetrics& aMetrics) {
#if defined(MOZ_WIDGET_ANDROID)
// TODO: Need to handle different x-and y-scales.
CSSToScreenScale scale = ViewTargetAs<ScreenPixel>(
aMetrics.mZoom.ToScaleFactor(),
PixelCastJustification::ScreenIsParentLayerForRoot);