mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 883646 - Fix the zoom clamping in APZC and the resolution calculation. r=kentuckyfriedtakahe
This commit is contained in:
parent
311eecb4d6
commit
d50a5eb6ca
@ -621,12 +621,8 @@ TabChild::HandlePossibleViewportChange()
|
||||
// we have no idea how long painting will take.
|
||||
metrics, gfx::Point(0.0f, 0.0f), gfx::Point(0.0f, 0.0f), 0.0);
|
||||
CSSToScreenScale resolution = AsyncPanZoomController::CalculateResolution(metrics);
|
||||
// XXX is this actually hysteresis? This calculation is not well
|
||||
// understood. It's taken from the previous JS implementation.
|
||||
gfxFloat hysteresis/*?*/ =
|
||||
gfxFloat(oldBrowserWidth) / gfxFloat(oldScreenWidth);
|
||||
metrics.mResolution = gfxSize(resolution.scale * hysteresis,
|
||||
resolution.scale * hysteresis);
|
||||
metrics.mResolution = gfxSize(resolution.scale / metrics.mDevPixelsPerCSSPixel,
|
||||
resolution.scale / metrics.mDevPixelsPerCSSPixel);
|
||||
utils->SetResolution(metrics.mResolution.width, metrics.mResolution.height);
|
||||
|
||||
// Force a repaint with these metrics. This, among other things, sets the
|
||||
|
@ -68,12 +68,12 @@ StaticAutoPtr<ComputedTimingFunction> gComputedTimingFunction;
|
||||
/**
|
||||
* Maximum zoom amount, always used, even if a page asks for higher.
|
||||
*/
|
||||
static const double MAX_ZOOM = 8.0;
|
||||
static const float MAX_ZOOM = 8.0f;
|
||||
|
||||
/**
|
||||
* Minimum zoom amount, always used, even if a page asks for lower.
|
||||
*/
|
||||
static const double MIN_ZOOM = 0.125;
|
||||
static const float MIN_ZOOM = 0.125f;
|
||||
|
||||
/**
|
||||
* Amount of time before we timeout touch event listeners. For example, if
|
||||
@ -564,19 +564,19 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) {
|
||||
// either axis such that we don't overscroll the boundaries when zooming.
|
||||
gfx::Point neededDisplacement;
|
||||
|
||||
// Only do the scaling if we won't go over 8x zoom in or out.
|
||||
bool doScale = (spanRatio > 1.0 && userZoom < mMaxZoom) ||
|
||||
(spanRatio < 1.0 && userZoom > mMinZoom);
|
||||
float maxZoom = mMaxZoom / CalculateIntrinsicScale(mFrameMetrics).width;
|
||||
float minZoom = mMinZoom / CalculateIntrinsicScale(mFrameMetrics).width;
|
||||
|
||||
// If this zoom will take it over 8x zoom in either direction, but it's not
|
||||
// already there, then normalize it.
|
||||
if (userZoom * spanRatio > mMaxZoom) {
|
||||
spanRatio = userZoom / mMaxZoom;
|
||||
} else if (userZoom * spanRatio < mMinZoom) {
|
||||
spanRatio = userZoom / mMinZoom;
|
||||
}
|
||||
bool doScale = (spanRatio > 1.0 && userZoom < maxZoom) ||
|
||||
(spanRatio < 1.0 && userZoom > minZoom);
|
||||
|
||||
if (doScale) {
|
||||
if (userZoom * spanRatio > maxZoom) {
|
||||
spanRatio = maxZoom / userZoom;
|
||||
} else if (userZoom * spanRatio < minZoom) {
|
||||
spanRatio = minZoom / userZoom;
|
||||
}
|
||||
|
||||
switch (mX.ScaleWillOverscroll(spanRatio, focusPoint.x))
|
||||
{
|
||||
case Axis::OVERSCROLL_NONE:
|
||||
@ -1043,7 +1043,7 @@ void AsyncPanZoomController::RequestContentRepaint() {
|
||||
// Calculate the factor of acceleration based on the faster of the two axes.
|
||||
float accelerationFactor =
|
||||
clamped(std::max(mX.GetAccelerationFactor(), mY.GetAccelerationFactor()),
|
||||
float(MIN_ZOOM) / 2.0f, float(MAX_ZOOM));
|
||||
MIN_ZOOM / 2.0f, MAX_ZOOM);
|
||||
// Scale down the resolution a bit based on acceleration.
|
||||
mFrameMetrics.mZoom.width = mFrameMetrics.mZoom.height =
|
||||
actualZoom / accelerationFactor;
|
||||
@ -1441,15 +1441,16 @@ void AsyncPanZoomController::SetZoomAndResolution(float aZoom) {
|
||||
mMonitor.AssertCurrentThreadOwns();
|
||||
mFrameMetrics.mZoom = gfxSize(aZoom, aZoom);
|
||||
CSSToScreenScale resolution = CalculateResolution(mFrameMetrics);
|
||||
mFrameMetrics.mResolution = gfxSize(resolution.scale, resolution.scale);
|
||||
mFrameMetrics.mResolution = gfxSize(resolution.scale / mFrameMetrics.mDevPixelsPerCSSPixel,
|
||||
resolution.scale / mFrameMetrics.mDevPixelsPerCSSPixel);
|
||||
}
|
||||
|
||||
void AsyncPanZoomController::UpdateZoomConstraints(bool aAllowZoom,
|
||||
float aMinZoom,
|
||||
float aMaxZoom) {
|
||||
mAllowZoom = aAllowZoom;
|
||||
mMinZoom = aMinZoom;
|
||||
mMaxZoom = aMaxZoom;
|
||||
mMinZoom = std::max(MIN_ZOOM, aMinZoom);
|
||||
mMaxZoom = std::min(MAX_ZOOM, aMaxZoom);
|
||||
}
|
||||
|
||||
void AsyncPanZoomController::PostDelayedTask(Task* aTask, int aDelayMs) {
|
||||
|
Loading…
Reference in New Issue
Block a user