mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out 7 changesets (bug 883646) for reftest-ipc failures.
Backed out changeset 2272804a8e71 (bug 883646) Backed out changeset e39d3bdf847a (bug 883646) Backed out changeset bf46fc332efe (bug 883646) Backed out changeset 6bb558c3136f (bug 883646) Backed out changeset d7d5d16e27e0 (bug 883646) Backed out changeset 14c73096a132 (bug 883646) Backed out changeset 89f6185a271b (bug 883646)
This commit is contained in:
parent
9e2717d794
commit
5ee79e7c80
@ -346,19 +346,15 @@ TabChild::Observe(nsISupports *aSubject,
|
||||
// Calculate a really simple resolution that we probably won't
|
||||
// be keeping, as well as putting the scroll offset back to
|
||||
// the top-left of the page.
|
||||
mLastMetrics.mZoom = ScreenToScreenScale(1.0);
|
||||
mLastMetrics.mZoom = gfxSize(1.0, 1.0);
|
||||
mLastMetrics.mViewport = CSSRect(CSSPoint(), kDefaultViewportSize);
|
||||
mLastMetrics.mCompositionBounds = ScreenIntRect(ScreenIntPoint(), mInnerSize);
|
||||
CSSToScreenScale resolution =
|
||||
AsyncPanZoomController::CalculateResolution(mLastMetrics);
|
||||
// We use ScreenToLayerScale(1) below in order to ask gecko to render
|
||||
// what's currently visible on the screen. This is effectively turning
|
||||
// the async zoom amount into the gecko zoom amount.
|
||||
mLastMetrics.mResolution =
|
||||
resolution / mLastMetrics.mDevPixelsPerCSSPixel * ScreenToLayerScale(1);
|
||||
mLastMetrics.mResolution = gfxSize(resolution.scale, resolution.scale);
|
||||
mLastMetrics.mScrollOffset = CSSPoint(0, 0);
|
||||
utils->SetResolution(mLastMetrics.mResolution.scale,
|
||||
mLastMetrics.mResolution.scale);
|
||||
utils->SetResolution(mLastMetrics.mResolution.width,
|
||||
mLastMetrics.mResolution.height);
|
||||
|
||||
HandlePossibleViewportChange();
|
||||
}
|
||||
@ -601,13 +597,13 @@ TabChild::HandlePossibleViewportChange()
|
||||
nsresult rv = utils->GetIsFirstPaint(&isFirstPaint);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
if (NS_FAILED(rv) || isFirstPaint) {
|
||||
CSSToScreenScale intrinsicScale =
|
||||
gfxSize intrinsicScale =
|
||||
AsyncPanZoomController::CalculateIntrinsicScale(metrics);
|
||||
// FIXME/bug 799585(?): GetViewportInfo() returns a defaultZoom of
|
||||
// 0.0 to mean "did not calculate a zoom". In that case, we default
|
||||
// it to the intrinsic scale.
|
||||
if (viewportInfo.GetDefaultZoom() < 0.01f) {
|
||||
viewportInfo.SetDefaultZoom(intrinsicScale.scale);
|
||||
viewportInfo.SetDefaultZoom(intrinsicScale.width);
|
||||
}
|
||||
|
||||
double defaultZoom = viewportInfo.GetDefaultZoom();
|
||||
@ -615,7 +611,8 @@ TabChild::HandlePossibleViewportChange()
|
||||
defaultZoom <= viewportInfo.GetMaxZoom());
|
||||
// GetViewportInfo() returns a resolution-dependent scale factor.
|
||||
// Convert that to a resolution-indepedent zoom.
|
||||
metrics.mZoom = ScreenToScreenScale(defaultZoom / intrinsicScale.scale);
|
||||
metrics.mZoom = gfxSize(defaultZoom / intrinsicScale.width,
|
||||
defaultZoom / intrinsicScale.height);
|
||||
}
|
||||
|
||||
metrics.mDisplayPort = AsyncPanZoomController::CalculatePendingDisplayPort(
|
||||
@ -624,8 +621,13 @@ 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);
|
||||
metrics.mResolution = resolution / metrics.mDevPixelsPerCSSPixel * ScreenToLayerScale(1);
|
||||
utils->SetResolution(metrics.mResolution.scale, metrics.mResolution.scale);
|
||||
// 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);
|
||||
utils->SetResolution(metrics.mResolution.width, metrics.mResolution.height);
|
||||
|
||||
// Force a repaint with these metrics. This, among other things, sets the
|
||||
// displayport, so we start with async painting.
|
||||
|
@ -290,7 +290,7 @@ public:
|
||||
void GetDPI(float* aDPI);
|
||||
void GetDefaultScale(double *aScale);
|
||||
|
||||
ScreenToScreenScale GetZoom() { return mLastMetrics.mZoom; }
|
||||
gfxSize GetZoom() { return mLastMetrics.mZoom; }
|
||||
|
||||
ScreenOrientation GetOrientation() { return mOrientation; }
|
||||
|
||||
|
@ -55,20 +55,10 @@ struct ScaleFactor {
|
||||
return ScaleFactor<other, dst>(scale / aOther.scale);
|
||||
}
|
||||
|
||||
template<class other>
|
||||
ScaleFactor<src, other> operator/(const ScaleFactor<other, dst>& aOther) const {
|
||||
return ScaleFactor<src, other>(scale / aOther.scale);
|
||||
}
|
||||
|
||||
template<class other>
|
||||
ScaleFactor<src, other> operator*(const ScaleFactor<dst, other>& aOther) const {
|
||||
return ScaleFactor<src, other>(scale * aOther.scale);
|
||||
}
|
||||
|
||||
template<class other>
|
||||
ScaleFactor<other, dst> operator*(const ScaleFactor<other, src>& aOther) const {
|
||||
return ScaleFactor<other, dst>(scale * aOther.scale);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -38,8 +38,8 @@ public:
|
||||
, mScrollOffset(0, 0)
|
||||
, mScrollId(NULL_SCROLL_ID)
|
||||
, mScrollableRect(0, 0, 0, 0)
|
||||
, mResolution(1)
|
||||
, mZoom(1)
|
||||
, mResolution(1, 1)
|
||||
, mZoom(1, 1)
|
||||
, mDevPixelsPerCSSPixel(1)
|
||||
, mMayHaveTouchListeners(false)
|
||||
, mPresShellId(-1)
|
||||
@ -84,14 +84,18 @@ public:
|
||||
return mScrollId != NULL_SCROLL_ID;
|
||||
}
|
||||
|
||||
CSSToLayerScale LayersPixelsPerCSSPixel() const
|
||||
gfxSize LayersPixelsPerCSSPixel() const
|
||||
{
|
||||
return mResolution * mDevPixelsPerCSSPixel;
|
||||
}
|
||||
|
||||
LayerPoint GetScrollOffsetInLayerPixels() const
|
||||
gfx::Point GetScrollOffsetInLayerPixels() const
|
||||
{
|
||||
return mScrollOffset * LayersPixelsPerCSSPixel();
|
||||
return gfx::Point(
|
||||
static_cast<gfx::Float>(
|
||||
mScrollOffset.x * LayersPixelsPerCSSPixel().width),
|
||||
static_cast<gfx::Float>(
|
||||
mScrollOffset.y * LayersPixelsPerCSSPixel().height));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -168,8 +172,8 @@ public:
|
||||
//
|
||||
// It is required that the rect:
|
||||
// { x = mScrollOffset.x, y = mScrollOffset.y,
|
||||
// width = mCompositionBounds.x / mResolution.scale,
|
||||
// height = mCompositionBounds.y / mResolution.scale }
|
||||
// width = mCompositionBounds.x / mResolution.width,
|
||||
// height = mCompositionBounds.y / mResolution.height }
|
||||
// Be within |mScrollableRect|.
|
||||
//
|
||||
// This is valid for any layer, but is always relative to this frame and
|
||||
@ -205,7 +209,7 @@ public:
|
||||
// post-multiplied into the parent's transform. Since this only happens when
|
||||
// we walk the layer tree, the resulting transform isn't stored here. Thus the
|
||||
// resolution of parent layers is opaque to this metric.
|
||||
LayoutDeviceToLayerScale mResolution;
|
||||
gfxSize mResolution;
|
||||
|
||||
// The resolution-independent "user zoom". For example, if a page
|
||||
// configures the viewport to a zoom value of 2x, then this member
|
||||
@ -220,13 +224,13 @@ public:
|
||||
//
|
||||
// When this is not true, we're probably asynchronously sampling a
|
||||
// zoom animation for content.
|
||||
ScreenToScreenScale mZoom;
|
||||
gfxSize mZoom;
|
||||
|
||||
// The conversion factor between CSS pixels and device pixels for this frame.
|
||||
// This can vary based on a variety of things, such as reflowing-zoom. The
|
||||
// conversion factor for device pixels to layers pixels is just the
|
||||
// resolution.
|
||||
CSSToLayoutDeviceScale mDevPixelsPerCSSPixel;
|
||||
float mDevPixelsPerCSSPixel;
|
||||
|
||||
// Whether or not this frame may have touch listeners.
|
||||
bool mMayHaveTouchListeners;
|
||||
|
@ -408,8 +408,8 @@ ClientLayerManager::ProgressiveUpdateCallback(bool aHasPendingNewThebesContent,
|
||||
// This is derived from the code in
|
||||
// gfx/layers/ipc/CompositorParent.cpp::TransformShadowTree.
|
||||
const gfx3DMatrix& rootTransform = GetRoot()->GetTransform();
|
||||
CSSToLayerScale paintScale = metrics.mDevPixelsPerCSSPixel
|
||||
/ LayerToLayoutDeviceScale(rootTransform.GetXScale(), rootTransform.GetYScale());
|
||||
CSSToLayerScale paintScale = LayerToCSSScale(rootTransform.GetXScale(),
|
||||
rootTransform.GetYScale()).Inverse();
|
||||
const CSSRect& metricsDisplayPort =
|
||||
(aDrawingCritical && !metrics.mCriticalDisplayPort.IsEmpty()) ?
|
||||
metrics.mCriticalDisplayPort : metrics.mDisplayPort;
|
||||
|
@ -57,9 +57,8 @@ ClientTiledThebesLayer::BeginPaint()
|
||||
|
||||
// Compute the critical display port in layer space.
|
||||
mPaintData.mLayerCriticalDisplayPort.SetEmpty();
|
||||
const FrameMetrics& metrics = GetParent()->GetFrameMetrics();
|
||||
const gfx::Rect& criticalDisplayPort =
|
||||
(metrics.mCriticalDisplayPort * metrics.mDevPixelsPerCSSPixel).ToUnknownRect();
|
||||
GetParent()->GetFrameMetrics().mCriticalDisplayPort.ToUnknownRect();
|
||||
if (!criticalDisplayPort.IsEmpty()) {
|
||||
gfxRect transformedCriticalDisplayPort =
|
||||
mPaintData.mTransformScreenToLayer.TransformBounds(
|
||||
@ -76,8 +75,8 @@ ClientTiledThebesLayer::BeginPaint()
|
||||
mPaintData.mResolution.SizeTo(1, 1);
|
||||
for (ContainerLayer* parent = GetParent(); parent; parent = parent->GetParent()) {
|
||||
const FrameMetrics& metrics = parent->GetFrameMetrics();
|
||||
mPaintData.mResolution.width *= metrics.mResolution.scale;
|
||||
mPaintData.mResolution.height *= metrics.mResolution.scale;
|
||||
mPaintData.mResolution.width *= metrics.mResolution.width;
|
||||
mPaintData.mResolution.height *= metrics.mResolution.height;
|
||||
}
|
||||
|
||||
// Calculate the scroll offset since the last transaction, and the
|
||||
|
@ -351,14 +351,12 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(TimeStamp aCurrentFram
|
||||
|
||||
const gfx3DMatrix& rootTransform = mLayerManager->GetRoot()->GetTransform();
|
||||
const FrameMetrics& metrics = container->GetFrameMetrics();
|
||||
CSSToLayerScale paintScale = metrics.mDevPixelsPerCSSPixel
|
||||
/ LayerToLayoutDeviceScale(rootTransform.GetXScale(), rootTransform.GetYScale());
|
||||
CSSRect displayPort(metrics.mCriticalDisplayPort.IsEmpty() ?
|
||||
metrics.mDisplayPort : metrics.mCriticalDisplayPort);
|
||||
gfx::Margin fixedLayerMargins(0, 0, 0, 0);
|
||||
ScreenPoint offset(0, 0);
|
||||
SyncFrameMetrics(scrollOffset, treeTransform.mScale.scale, metrics.mScrollableRect,
|
||||
mLayersUpdated, displayPort, paintScale,
|
||||
mLayersUpdated, displayPort, 1 / rootTransform.GetXScale(),
|
||||
mIsFirstPaint, fixedLayerMargins, offset);
|
||||
|
||||
mIsFirstPaint = false;
|
||||
@ -406,15 +404,15 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer, const gfx3DMatr
|
||||
|
||||
gfx3DMatrix treeTransform;
|
||||
|
||||
CSSToLayerScale geckoZoom = metrics.mDevPixelsPerCSSPixel /
|
||||
LayerToLayoutDeviceScale(aRootTransform.GetXScale(), aRootTransform.GetYScale());
|
||||
CSSToLayerScale geckoZoom = LayerToCSSScale(aRootTransform.GetXScale(),
|
||||
aRootTransform.GetYScale()).Inverse();
|
||||
|
||||
LayerIntPoint scrollOffsetLayerPixels = RoundedToInt(metrics.mScrollOffset * geckoZoom);
|
||||
|
||||
if (mIsFirstPaint) {
|
||||
mContentRect = metrics.mScrollableRect;
|
||||
SetFirstPaintViewport(scrollOffsetLayerPixels,
|
||||
geckoZoom,
|
||||
geckoZoom.scale,
|
||||
mContentRect);
|
||||
mIsFirstPaint = false;
|
||||
} else if (!metrics.mScrollableRect.IsEqualEdges(mContentRect)) {
|
||||
@ -436,8 +434,8 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer, const gfx3DMatr
|
||||
ScreenPoint offset(0, 0);
|
||||
ScreenPoint userScroll(0, 0);
|
||||
CSSToScreenScale userZoom;
|
||||
SyncViewportInfo(displayPort, geckoZoom, mLayersUpdated,
|
||||
userScroll, userZoom, fixedLayerMargins,
|
||||
SyncViewportInfo(displayPort, geckoZoom.scale, mLayersUpdated,
|
||||
userScroll, userZoom.scale, userZoom.scale, fixedLayerMargins,
|
||||
offset);
|
||||
mLayersUpdated = false;
|
||||
|
||||
@ -458,7 +456,7 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer, const gfx3DMatr
|
||||
}
|
||||
|
||||
LayerPoint translation = (userScroll / zoomAdjust) - geckoScroll;
|
||||
treeTransform = gfx3DMatrix(ViewTransform(-translation, userZoom / metrics.mDevPixelsPerCSSPixel));
|
||||
treeTransform = gfx3DMatrix(ViewTransform(-translation, userZoom));
|
||||
|
||||
// Translate fixed position layers so that they stay in the correct position
|
||||
// when userScroll and geckoScroll differ.
|
||||
@ -545,7 +543,7 @@ AsyncCompositionManager::TransformShadowTree(TimeStamp aCurrentFrame)
|
||||
|
||||
void
|
||||
AsyncCompositionManager::SetFirstPaintViewport(const LayerIntPoint& aOffset,
|
||||
const CSSToLayerScale& aZoom,
|
||||
float aZoom,
|
||||
const CSSRect& aCssPageRect)
|
||||
{
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
@ -563,10 +561,10 @@ AsyncCompositionManager::SetPageRect(const CSSRect& aCssPageRect)
|
||||
|
||||
void
|
||||
AsyncCompositionManager::SyncViewportInfo(const LayerIntRect& aDisplayPort,
|
||||
const CSSToLayerScale& aDisplayResolution,
|
||||
float aDisplayResolution,
|
||||
bool aLayersUpdated,
|
||||
ScreenPoint& aScrollOffset,
|
||||
CSSToScreenScale& aScale,
|
||||
float& aScaleX, float& aScaleY,
|
||||
gfx::Margin& aFixedLayerMargins,
|
||||
ScreenPoint& aOffset)
|
||||
{
|
||||
@ -575,7 +573,7 @@ AsyncCompositionManager::SyncViewportInfo(const LayerIntRect& aDisplayPort,
|
||||
aDisplayResolution,
|
||||
aLayersUpdated,
|
||||
aScrollOffset,
|
||||
aScale,
|
||||
aScaleX, aScaleY,
|
||||
aFixedLayerMargins,
|
||||
aOffset);
|
||||
#endif
|
||||
@ -587,7 +585,7 @@ AsyncCompositionManager::SyncFrameMetrics(const ScreenPoint& aScrollOffset,
|
||||
const CSSRect& aCssPageRect,
|
||||
bool aLayersUpdated,
|
||||
const CSSRect& aDisplayPort,
|
||||
const CSSToLayerScale& aDisplayResolution,
|
||||
float aDisplayResolution,
|
||||
bool aIsFirstPaint,
|
||||
gfx::Margin& aFixedLayerMargins,
|
||||
ScreenPoint& aOffset)
|
||||
|
@ -28,7 +28,7 @@ class AutoResolveRefLayers;
|
||||
// Represents (affine) transforms that are calculated from a content view.
|
||||
struct ViewTransform {
|
||||
ViewTransform(LayerPoint aTranslation = LayerPoint(),
|
||||
LayoutDeviceToScreenScale aScale = LayoutDeviceToScreenScale())
|
||||
CSSToScreenScale aScale = CSSToScreenScale())
|
||||
: mTranslation(aTranslation)
|
||||
, mScale(aScale)
|
||||
{}
|
||||
@ -41,7 +41,7 @@ struct ViewTransform {
|
||||
}
|
||||
|
||||
LayerPoint mTranslation;
|
||||
LayoutDeviceToScreenScale mScale;
|
||||
CSSToScreenScale mScale;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -115,14 +115,14 @@ private:
|
||||
bool* aWantNextFrame);
|
||||
|
||||
void SetFirstPaintViewport(const LayerIntPoint& aOffset,
|
||||
const CSSToLayerScale& aZoom,
|
||||
float aZoom,
|
||||
const CSSRect& aCssPageRect);
|
||||
void SetPageRect(const CSSRect& aCssPageRect);
|
||||
void SyncViewportInfo(const LayerIntRect& aDisplayPort,
|
||||
const CSSToLayerScale& aDisplayResolution,
|
||||
float aDisplayResolution,
|
||||
bool aLayersUpdated,
|
||||
ScreenPoint& aScrollOffset,
|
||||
CSSToScreenScale& aScale,
|
||||
float& aScaleX, float& aScaleY,
|
||||
gfx::Margin& aFixedLayerMargins,
|
||||
ScreenPoint& aOffset);
|
||||
void SyncFrameMetrics(const ScreenPoint& aScrollOffset,
|
||||
@ -130,7 +130,7 @@ private:
|
||||
const CSSRect& aCssPageRect,
|
||||
bool aLayersUpdated,
|
||||
const CSSRect& aDisplayPort,
|
||||
const CSSToLayerScale& aDisplayResolution,
|
||||
float aDisplayResolution,
|
||||
bool aIsFirstPaint,
|
||||
gfx::Margin& aFixedLayerMargins,
|
||||
ScreenPoint& aOffset);
|
||||
|
@ -165,8 +165,8 @@ ThebesLayerComposite::GetEffectiveResolution()
|
||||
gfxSize resolution(1, 1);
|
||||
for (ContainerLayer* parent = GetParent(); parent; parent = parent->GetParent()) {
|
||||
const FrameMetrics& metrics = parent->GetFrameMetrics();
|
||||
resolution.width *= metrics.mResolution.scale;
|
||||
resolution.height *= metrics.mResolution.scale;
|
||||
resolution.width *= metrics.mResolution.width;
|
||||
resolution.height *= metrics.mResolution.height;
|
||||
}
|
||||
|
||||
return resolution;
|
||||
@ -199,8 +199,8 @@ ThebesLayerComposite::GetDisplayPort()
|
||||
metrics.mDisplayPort.height);
|
||||
displayPort.ScaleRoundOut(parentResolution.width, parentResolution.height);
|
||||
}
|
||||
parentResolution.width /= metrics.mResolution.scale;
|
||||
parentResolution.height /= metrics.mResolution.scale;
|
||||
parentResolution.width /= metrics.mResolution.width;
|
||||
parentResolution.height /= metrics.mResolution.height;
|
||||
}
|
||||
if (parent->UseIntermediateSurface()) {
|
||||
transform.PreMultiply(parent->GetTransform());
|
||||
@ -252,10 +252,9 @@ ThebesLayerComposite::GetCompositionBounds()
|
||||
// Get the content document bounds, in screen-space.
|
||||
const FrameMetrics& metrics = scrollableLayer->GetFrameMetrics();
|
||||
const LayerIntRect content = RoundedToInt(metrics.mScrollableRect / scale);
|
||||
// !!! WTF. this code is just wrong. See bug 881451.
|
||||
gfx::Point scrollOffset =
|
||||
gfx::Point((metrics.mScrollOffset.x * metrics.LayersPixelsPerCSSPixel().scale) / scale.scale,
|
||||
(metrics.mScrollOffset.y * metrics.LayersPixelsPerCSSPixel().scale) / scale.scale);
|
||||
gfx::Point((metrics.mScrollOffset.x * metrics.LayersPixelsPerCSSPixel().width) / scale.scale,
|
||||
(metrics.mScrollOffset.y * metrics.LayersPixelsPerCSSPixel().height) / scale.scale);
|
||||
const nsIntPoint contentOrigin(
|
||||
content.x - NS_lround(scrollOffset.x),
|
||||
content.y - NS_lround(scrollOffset.y));
|
||||
|
@ -68,12 +68,12 @@ StaticAutoPtr<ComputedTimingFunction> gComputedTimingFunction;
|
||||
/**
|
||||
* Maximum zoom amount, always used, even if a page asks for higher.
|
||||
*/
|
||||
static const float MAX_ZOOM = 8.0f;
|
||||
static const double MAX_ZOOM = 8.0;
|
||||
|
||||
/**
|
||||
* Minimum zoom amount, always used, even if a page asks for lower.
|
||||
*/
|
||||
static const float MIN_ZOOM = 0.125f;
|
||||
static const double MIN_ZOOM = 0.125;
|
||||
|
||||
/**
|
||||
* Amount of time before we timeout touch event listeners. For example, if
|
||||
@ -391,7 +391,7 @@ nsEventStatus AsyncPanZoomController::OnTouchStart(const MultiTouchInput& aEvent
|
||||
{
|
||||
MonitorAutoLock monitor(mMonitor);
|
||||
// Bring the resolution back in sync with the zoom.
|
||||
SetZoomAndResolution(mFrameMetrics.mZoom);
|
||||
SetZoomAndResolution(mFrameMetrics.mZoom.width);
|
||||
RequestContentRepaint();
|
||||
ScheduleComposite();
|
||||
}
|
||||
@ -545,7 +545,7 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) {
|
||||
MonitorAutoLock monitor(mMonitor);
|
||||
|
||||
CSSToScreenScale resolution = CalculateResolution(mFrameMetrics);
|
||||
gfxFloat userZoom = mFrameMetrics.mZoom.scale;
|
||||
gfxFloat userZoom = mFrameMetrics.mZoom.width;
|
||||
ScreenPoint focusPoint = aEvent.mFocusPoint;
|
||||
|
||||
CSSPoint focusChange = (mLastZoomFocus - focusPoint) / resolution;
|
||||
@ -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;
|
||||
|
||||
float maxZoom = mMaxZoom / CalculateIntrinsicScale(mFrameMetrics).scale;
|
||||
float minZoom = mMinZoom / CalculateIntrinsicScale(mFrameMetrics).scale;
|
||||
// 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);
|
||||
|
||||
bool doScale = (spanRatio > 1.0 && userZoom < maxZoom) ||
|
||||
(spanRatio < 1.0 && userZoom > minZoom);
|
||||
// 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;
|
||||
}
|
||||
|
||||
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:
|
||||
@ -785,7 +785,7 @@ bool AsyncPanZoomController::DoFling(const TimeDuration& aDelta) {
|
||||
if (!shouldContinueFlingX && !shouldContinueFlingY) {
|
||||
// Bring the resolution back in sync with the zoom, in case we scaled down
|
||||
// the zoom while accelerating.
|
||||
SetZoomAndResolution(mFrameMetrics.mZoom);
|
||||
SetZoomAndResolution(mFrameMetrics.mZoom.width);
|
||||
SendAsyncScrollEvent();
|
||||
RequestContentRepaint();
|
||||
mState = NOTHING;
|
||||
@ -825,10 +825,10 @@ void AsyncPanZoomController::ScrollBy(const CSSPoint& aOffset) {
|
||||
|
||||
void AsyncPanZoomController::ScaleWithFocus(float aZoom,
|
||||
const ScreenPoint& aFocus) {
|
||||
float zoomFactor = aZoom / mFrameMetrics.mZoom.scale;
|
||||
float zoomFactor = aZoom / mFrameMetrics.mZoom.width;
|
||||
CSSToScreenScale resolution = CalculateResolution(mFrameMetrics);
|
||||
|
||||
SetZoomAndResolution(ScreenToScreenScale(aZoom));
|
||||
SetZoomAndResolution(aZoom);
|
||||
|
||||
// If the new scale is very small, we risk multiplying in huge rounding
|
||||
// errors, so don't bother adjusting the scroll offset.
|
||||
@ -958,17 +958,21 @@ const CSSRect AsyncPanZoomController::CalculatePendingDisplayPort(
|
||||
return scrollableRect.ClampRect(shiftedDisplayPort) - scrollOffset;
|
||||
}
|
||||
|
||||
/*static*/ CSSToScreenScale
|
||||
/*static*/ gfxSize
|
||||
AsyncPanZoomController::CalculateIntrinsicScale(const FrameMetrics& aMetrics)
|
||||
{
|
||||
return CSSToScreenScale(gfxFloat(aMetrics.mCompositionBounds.width) /
|
||||
gfxFloat(aMetrics.mViewport.width));
|
||||
gfxFloat intrinsicScale = (gfxFloat(aMetrics.mCompositionBounds.width) /
|
||||
gfxFloat(aMetrics.mViewport.width));
|
||||
return gfxSize(intrinsicScale, intrinsicScale);
|
||||
}
|
||||
|
||||
/*static*/ CSSToScreenScale
|
||||
AsyncPanZoomController::CalculateResolution(const FrameMetrics& aMetrics)
|
||||
{
|
||||
return CalculateIntrinsicScale(aMetrics) * aMetrics.mZoom;
|
||||
gfxSize intrinsicScale = CalculateIntrinsicScale(aMetrics);
|
||||
gfxSize userZoom = aMetrics.mZoom;
|
||||
return CSSToScreenScale(intrinsicScale.width * userZoom.width,
|
||||
intrinsicScale.height * userZoom.height);
|
||||
}
|
||||
|
||||
/*static*/ CSSRect
|
||||
@ -1027,7 +1031,7 @@ void AsyncPanZoomController::RequestContentRepaint() {
|
||||
mFrameMetrics.mScrollOffset.x) < EPSILON &&
|
||||
fabsf(mLastPaintRequestMetrics.mScrollOffset.y -
|
||||
mFrameMetrics.mScrollOffset.y) < EPSILON &&
|
||||
mFrameMetrics.mResolution == mLastPaintRequestMetrics.mResolution) {
|
||||
mFrameMetrics.mResolution.width == mLastPaintRequestMetrics.mResolution.width) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1035,13 +1039,14 @@ void AsyncPanZoomController::RequestContentRepaint() {
|
||||
|
||||
// Cache the zoom since we're temporarily changing it for
|
||||
// acceleration-scaled painting.
|
||||
ScreenToScreenScale actualZoom = mFrameMetrics.mZoom;
|
||||
gfxFloat actualZoom = mFrameMetrics.mZoom.width;
|
||||
// Calculate the factor of acceleration based on the faster of the two axes.
|
||||
float accelerationFactor =
|
||||
clamped(std::max(mX.GetAccelerationFactor(), mY.GetAccelerationFactor()),
|
||||
MIN_ZOOM / 2.0f, MAX_ZOOM);
|
||||
float(MIN_ZOOM) / 2.0f, float(MAX_ZOOM));
|
||||
// Scale down the resolution a bit based on acceleration.
|
||||
mFrameMetrics.mZoom.scale /= accelerationFactor;
|
||||
mFrameMetrics.mZoom.width = mFrameMetrics.mZoom.height =
|
||||
actualZoom / accelerationFactor;
|
||||
|
||||
// This message is compressed, so fire whether or not we already have a paint
|
||||
// queued up. We need to know whether or not a paint was requested anyways,
|
||||
@ -1056,7 +1061,7 @@ void AsyncPanZoomController::RequestContentRepaint() {
|
||||
mWaitingForContentToPaint = true;
|
||||
|
||||
// Set the zoom back to what it was for the purpose of logic control.
|
||||
mFrameMetrics.mZoom = actualZoom;
|
||||
mFrameMetrics.mZoom = gfxSize(actualZoom, actualZoom);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1080,6 +1085,12 @@ bool AsyncPanZoomController::SampleContentTransformForFrame(const TimeStamp& aSa
|
||||
// responsibility to schedule a composite.
|
||||
bool requestAnimationFrame = false;
|
||||
|
||||
const gfx3DMatrix& currentTransform = aLayer->GetTransform();
|
||||
|
||||
// Scales on the root layer, on what's currently painted.
|
||||
LayerToCSSScale rootScale(currentTransform.GetXScale(),
|
||||
currentTransform.GetYScale());
|
||||
|
||||
LayerPoint metricsScrollOffset;
|
||||
CSSPoint scrollOffset;
|
||||
CSSToScreenScale localScale;
|
||||
@ -1102,10 +1113,11 @@ bool AsyncPanZoomController::SampleContentTransformForFrame(const TimeStamp& aSa
|
||||
// will affect the final computed resolution.
|
||||
double sampledPosition = gComputedTimingFunction->GetValue(animPosition);
|
||||
|
||||
ScreenToScreenScale startZoom = mStartZoomToMetrics.mZoom;
|
||||
ScreenToScreenScale endZoom = mEndZoomToMetrics.mZoom;
|
||||
mFrameMetrics.mZoom = ScreenToScreenScale(endZoom.scale * sampledPosition +
|
||||
startZoom.scale * (1 - sampledPosition));
|
||||
gfxFloat startZoom = mStartZoomToMetrics.mZoom.width;
|
||||
gfxFloat endZoom = mEndZoomToMetrics.mZoom.width;
|
||||
gfxFloat sampledZoom = (endZoom * sampledPosition +
|
||||
startZoom * (1 - sampledPosition));
|
||||
mFrameMetrics.mZoom = gfxSize(sampledZoom, sampledZoom);
|
||||
|
||||
mFrameMetrics.mScrollOffset = CSSPoint::FromUnknownPoint(gfx::Point(
|
||||
mEndZoomToMetrics.mScrollOffset.x * sampledPosition +
|
||||
@ -1118,7 +1130,7 @@ bool AsyncPanZoomController::SampleContentTransformForFrame(const TimeStamp& aSa
|
||||
|
||||
if (aSampleTime - mAnimationStartTime >= ZOOM_TO_DURATION) {
|
||||
// Bring the resolution in sync with the zoom.
|
||||
SetZoomAndResolution(mFrameMetrics.mZoom);
|
||||
SetZoomAndResolution(mFrameMetrics.mZoom.width);
|
||||
mState = NOTHING;
|
||||
SendAsyncScrollEvent();
|
||||
RequestContentRepaint();
|
||||
@ -1137,7 +1149,8 @@ bool AsyncPanZoomController::SampleContentTransformForFrame(const TimeStamp& aSa
|
||||
localScale = CalculateResolution(mFrameMetrics);
|
||||
|
||||
if (frame.IsScrollable()) {
|
||||
metricsScrollOffset = frame.GetScrollOffsetInLayerPixels();
|
||||
metricsScrollOffset = LayerPoint::FromUnknownPoint(
|
||||
frame.GetScrollOffsetInLayerPixels());
|
||||
}
|
||||
|
||||
scrollOffset = mFrameMetrics.mScrollOffset;
|
||||
@ -1171,13 +1184,8 @@ bool AsyncPanZoomController::SampleContentTransformForFrame(const TimeStamp& aSa
|
||||
mAsyncScrollTimeout);
|
||||
}
|
||||
|
||||
// Scales on the root layer, on what's currently painted.
|
||||
const gfx3DMatrix& currentTransform = aLayer->GetTransform();
|
||||
CSSToLayerScale rootScale = frame.mDevPixelsPerCSSPixel
|
||||
/ LayerToLayoutDeviceScale(currentTransform.GetXScale(), currentTransform.GetYScale());
|
||||
|
||||
LayerPoint translation = (scrollOffset * rootScale) - metricsScrollOffset;
|
||||
*aNewTransform = ViewTransform(-translation, localScale / frame.mDevPixelsPerCSSPixel);
|
||||
LayerPoint translation = (scrollOffset / rootScale) - metricsScrollOffset;
|
||||
*aNewTransform = ViewTransform(-translation, localScale);
|
||||
aScrollOffset = scrollOffset * localScale;
|
||||
|
||||
mLastSampleTime = aSampleTime;
|
||||
@ -1267,7 +1275,7 @@ void AsyncPanZoomController::UpdateCompositionBounds(const ScreenIntRect& aCompo
|
||||
// has gone out of view, the buffer will be cleared elsewhere anyways.
|
||||
if (aCompositionBounds.width && aCompositionBounds.height &&
|
||||
oldCompositionBounds.width && oldCompositionBounds.height) {
|
||||
SetZoomAndResolution(mFrameMetrics.mZoom);
|
||||
SetZoomAndResolution(mFrameMetrics.mZoom.width);
|
||||
|
||||
// Repaint on a rotation so that our new resolution gets properly updated.
|
||||
RequestContentRepaint();
|
||||
@ -1296,55 +1304,58 @@ void AsyncPanZoomController::ZoomToRect(const gfxRect& aRect) {
|
||||
ScreenIntRect compositionBounds = mFrameMetrics.mCompositionBounds;
|
||||
CSSRect cssPageRect = mFrameMetrics.mScrollableRect;
|
||||
CSSPoint scrollOffset = mFrameMetrics.mScrollOffset;
|
||||
float currentZoom = mFrameMetrics.mZoom.scale;
|
||||
CSSToScreenScale resolution = CalculateResolution(mFrameMetrics);
|
||||
gfxSize currentZoom = mFrameMetrics.mZoom;
|
||||
float targetZoom;
|
||||
float intrinsicScale = CalculateIntrinsicScale(mFrameMetrics).scale;
|
||||
gfxFloat targetResolution;
|
||||
|
||||
// The minimum zoom to prevent over-zoom-out.
|
||||
// If the zoom factor is lower than this (i.e. we are zoomed more into the page),
|
||||
// then the CSS content rect, in layers pixels, will be smaller than the
|
||||
// composition bounds. If this happens, we can't fill the target composited
|
||||
// area with this frame.
|
||||
float localMinZoom = std::max(mMinZoom,
|
||||
std::max(compositionBounds.width / cssPageRect.width,
|
||||
compositionBounds.height / cssPageRect.height))
|
||||
/ intrinsicScale;
|
||||
float localMaxZoom = mMaxZoom / intrinsicScale;
|
||||
float localMinZoom;
|
||||
CSSRect compositedRect = CalculateCompositedRectInCssPixels(mFrameMetrics);
|
||||
localMinZoom =
|
||||
std::max(currentZoom.width / (cssPageRect.width / compositedRect.width),
|
||||
currentZoom.height / (cssPageRect.height / compositedRect.height));
|
||||
localMinZoom = std::max(localMinZoom, mMinZoom);
|
||||
|
||||
if (!zoomToRect.IsEmpty()) {
|
||||
// Intersect the zoom-to-rect to the CSS rect to make sure it fits.
|
||||
zoomToRect = zoomToRect.Intersect(cssPageRect);
|
||||
float targetResolution =
|
||||
targetResolution =
|
||||
std::min(compositionBounds.width / zoomToRect.width,
|
||||
compositionBounds.height / zoomToRect.height);
|
||||
targetZoom = targetResolution / intrinsicScale;
|
||||
targetZoom = float(targetResolution / resolution.scale) * currentZoom.width;
|
||||
}
|
||||
// 1. If the rect is empty, request received from browserElementScrolling.js
|
||||
// 2. currentZoom is equal to mMaxZoom and user still double-tapping it
|
||||
// 3. currentZoom is equal to localMinZoom and user still double-tapping it
|
||||
// Treat these three cases as a request to zoom out as much as possible.
|
||||
if (zoomToRect.IsEmpty() ||
|
||||
(currentZoom == localMaxZoom && targetZoom >= localMaxZoom) ||
|
||||
(currentZoom == localMinZoom && targetZoom <= localMinZoom)) {
|
||||
CSSRect compositedRect = CalculateCompositedRectInCssPixels(mFrameMetrics);
|
||||
(currentZoom.width == mMaxZoom && targetZoom >= mMaxZoom) ||
|
||||
(currentZoom.width == localMinZoom && targetZoom <= localMinZoom)) {
|
||||
CSSIntRect cssCompositionBounds = gfx::RoundedIn(compositionBounds / resolution);
|
||||
|
||||
float y = scrollOffset.y;
|
||||
float newHeight =
|
||||
cssPageRect.width * (compositedRect.height / compositedRect.width);
|
||||
float dh = compositedRect.height - newHeight;
|
||||
cssCompositionBounds.height * cssPageRect.width / cssCompositionBounds.width;
|
||||
float dh = cssCompositionBounds.height - newHeight;
|
||||
|
||||
zoomToRect = CSSRect(0.0f,
|
||||
y + dh/2,
|
||||
cssPageRect.width,
|
||||
newHeight);
|
||||
zoomToRect = zoomToRect.Intersect(cssPageRect);
|
||||
float targetResolution =
|
||||
targetResolution =
|
||||
std::min(compositionBounds.width / zoomToRect.width,
|
||||
compositionBounds.height / zoomToRect.height);
|
||||
targetZoom = targetResolution / intrinsicScale;
|
||||
targetZoom = float(targetResolution / resolution.scale) * currentZoom.width;
|
||||
}
|
||||
|
||||
targetZoom = clamped(targetZoom, localMinZoom, localMaxZoom);
|
||||
mEndZoomToMetrics.mZoom = ScreenToScreenScale(targetZoom);
|
||||
targetZoom = clamped(targetZoom, localMinZoom, mMaxZoom);
|
||||
mEndZoomToMetrics.mZoom = gfxSize(targetZoom, targetZoom);
|
||||
|
||||
// Adjust the zoomToRect to a sensible position to prevent overscrolling.
|
||||
FrameMetrics metricsAfterZoom = mFrameMetrics;
|
||||
@ -1427,22 +1438,19 @@ void AsyncPanZoomController::TimeoutTouchListeners() {
|
||||
ContentReceivedTouch(false);
|
||||
}
|
||||
|
||||
void AsyncPanZoomController::SetZoomAndResolution(const ScreenToScreenScale& aZoom) {
|
||||
void AsyncPanZoomController::SetZoomAndResolution(float aZoom) {
|
||||
mMonitor.AssertCurrentThreadOwns();
|
||||
mFrameMetrics.mZoom = aZoom;
|
||||
mFrameMetrics.mZoom = gfxSize(aZoom, aZoom);
|
||||
CSSToScreenScale resolution = CalculateResolution(mFrameMetrics);
|
||||
// We use ScreenToLayerScale(1) below in order to ask gecko to render
|
||||
// what's currently visible on the screen. This is effectively turning
|
||||
// the async zoom amount into the gecko zoom amount.
|
||||
mFrameMetrics.mResolution = resolution / mFrameMetrics.mDevPixelsPerCSSPixel * ScreenToLayerScale(1);
|
||||
mFrameMetrics.mResolution = gfxSize(resolution.scale, resolution.scale);
|
||||
}
|
||||
|
||||
void AsyncPanZoomController::UpdateZoomConstraints(bool aAllowZoom,
|
||||
float aMinZoom,
|
||||
float aMaxZoom) {
|
||||
mAllowZoom = aAllowZoom;
|
||||
mMinZoom = std::max(MIN_ZOOM, aMinZoom);
|
||||
mMaxZoom = std::min(MAX_ZOOM, aMaxZoom);
|
||||
mMinZoom = aMinZoom;
|
||||
mMaxZoom = aMaxZoom;
|
||||
}
|
||||
|
||||
void AsyncPanZoomController::PostDelayedTask(Task* aTask, int aDelayMs) {
|
||||
|
@ -227,7 +227,7 @@ public:
|
||||
* Return the scale factor needed to fit the viewport in |aMetrics|
|
||||
* into its composition bounds.
|
||||
*/
|
||||
static CSSToScreenScale CalculateIntrinsicScale(const FrameMetrics& aMetrics);
|
||||
static gfxSize CalculateIntrinsicScale(const FrameMetrics& aMetrics);
|
||||
|
||||
/**
|
||||
* Return the resolution that content should be rendered at given
|
||||
@ -456,7 +456,7 @@ protected:
|
||||
*
|
||||
* *** The monitor must be held while calling this.
|
||||
*/
|
||||
void SetZoomAndResolution(const ScreenToScreenScale& aZoom);
|
||||
void SetZoomAndResolution(float aScale);
|
||||
|
||||
/**
|
||||
* Timeout function for mozbrowserasyncscroll event. Because we throttle
|
||||
|
@ -318,7 +318,7 @@ bool Axis::ScaleWillOverscrollBothSides(float aScale) {
|
||||
|
||||
CSSRect cssContentRect = metrics.mScrollableRect;
|
||||
|
||||
CSSToScreenScale scale(metrics.mZoom.scale * aScale);
|
||||
CSSToScreenScale scale(metrics.mZoom.width * aScale);
|
||||
CSSIntRect cssCompositionBounds = RoundedIn(metrics.mCompositionBounds / scale);
|
||||
|
||||
return GetRectLength(cssContentRect) < GetRectLength(CSSRect(cssCompositionBounds));
|
||||
|
@ -788,22 +788,6 @@ struct ParamTraits<nsIntSize>
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
struct ParamTraits< mozilla::gfx::ScaleFactor<T, U> >
|
||||
{
|
||||
typedef mozilla::gfx::ScaleFactor<T, U> paramType;
|
||||
|
||||
static void Write(Message* msg, const paramType& param)
|
||||
{
|
||||
WriteParam(msg, param.scale);
|
||||
}
|
||||
|
||||
static bool Read(const Message* msg, void** iter, paramType* result)
|
||||
{
|
||||
return (ReadParam(msg, iter, &result->scale));
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct ParamTraits< mozilla::gfx::PointTyped<T> >
|
||||
{
|
||||
|
@ -15,7 +15,6 @@
|
||||
namespace mozilla {
|
||||
|
||||
struct CSSPixel;
|
||||
struct LayoutDevicePixel;
|
||||
struct LayerPixel;
|
||||
struct ScreenPixel;
|
||||
|
||||
@ -26,13 +25,6 @@ typedef gfx::IntSizeTyped<CSSPixel> CSSIntSize;
|
||||
typedef gfx::RectTyped<CSSPixel> CSSRect;
|
||||
typedef gfx::IntRectTyped<CSSPixel> CSSIntRect;
|
||||
|
||||
typedef gfx::PointTyped<LayoutDevicePixel> LayoutDevicePoint;
|
||||
typedef gfx::IntPointTyped<LayoutDevicePixel> LayoutDeviceIntPoint;
|
||||
typedef gfx::SizeTyped<LayoutDevicePixel> LayoutDeviceSize;
|
||||
typedef gfx::IntSizeTyped<LayoutDevicePixel> LayoutDeviceIntSize;
|
||||
typedef gfx::RectTyped<LayoutDevicePixel> LayoutDeviceRect;
|
||||
typedef gfx::IntRectTyped<LayoutDevicePixel> LayoutDeviceIntRect;
|
||||
|
||||
typedef gfx::PointTyped<LayerPixel> LayerPoint;
|
||||
typedef gfx::IntPointTyped<LayerPixel> LayerIntPoint;
|
||||
typedef gfx::SizeTyped<LayerPixel> LayerSize;
|
||||
@ -47,19 +39,12 @@ typedef gfx::IntSizeTyped<ScreenPixel> ScreenIntSize;
|
||||
typedef gfx::RectTyped<ScreenPixel> ScreenRect;
|
||||
typedef gfx::IntRectTyped<ScreenPixel> ScreenIntRect;
|
||||
|
||||
typedef gfx::ScaleFactor<CSSPixel, LayoutDevicePixel> CSSToLayoutDeviceScale;
|
||||
typedef gfx::ScaleFactor<LayoutDevicePixel, CSSPixel> LayoutDeviceToCSSScale;
|
||||
typedef gfx::ScaleFactor<CSSPixel, LayerPixel> CSSToLayerScale;
|
||||
typedef gfx::ScaleFactor<LayerPixel, CSSPixel> LayerToCSSScale;
|
||||
typedef gfx::ScaleFactor<CSSPixel, ScreenPixel> CSSToScreenScale;
|
||||
typedef gfx::ScaleFactor<ScreenPixel, CSSPixel> ScreenToCSSScale;
|
||||
typedef gfx::ScaleFactor<LayoutDevicePixel, LayerPixel> LayoutDeviceToLayerScale;
|
||||
typedef gfx::ScaleFactor<LayerPixel, LayoutDevicePixel> LayerToLayoutDeviceScale;
|
||||
typedef gfx::ScaleFactor<LayoutDevicePixel, ScreenPixel> LayoutDeviceToScreenScale;
|
||||
typedef gfx::ScaleFactor<ScreenPixel, LayoutDevicePixel> ScreenToLayoutDeviceScale;
|
||||
typedef gfx::ScaleFactor<LayerPixel, ScreenPixel> LayerToScreenScale;
|
||||
typedef gfx::ScaleFactor<ScreenPixel, LayerPixel> ScreenToLayerScale;
|
||||
typedef gfx::ScaleFactor<ScreenPixel, ScreenPixel> ScreenToScreenScale;
|
||||
|
||||
/*
|
||||
* The pixels that content authors use to specify sizes in.
|
||||
@ -112,24 +97,13 @@ struct CSSPixel {
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* The pixels that are referred to as "device pixels" in layout code. In
|
||||
* general this is obtained by converting a value in app units value by the
|
||||
* nsDeviceContext::AppUnitsPerDevPixel() value. The size of these pixels
|
||||
* are affected by:
|
||||
* 1) the "full zoom" (see nsPresContext::SetFullZoom)
|
||||
* 2) the "widget scale" (see nsIWidget::GetDefaultScale)
|
||||
*/
|
||||
struct LayoutDevicePixel {
|
||||
};
|
||||
|
||||
/*
|
||||
* The pixels that layout rasterizes and delivers to the graphics code.
|
||||
* These are generally referred to as "device pixels" in layout code. Layer
|
||||
* pixels are affected by:
|
||||
* 1) the "display resolution" (see nsIPresShell::SetResolution)
|
||||
* 2) the "full zoom" (see nsPresContext::SetFullZoom)
|
||||
* 3) the "widget scale" (see nsIWidget::GetDefaultScale)
|
||||
* 3) the "widget scale" (nsIWidget::GetDefaultScale)
|
||||
*/
|
||||
struct LayerPixel {
|
||||
};
|
||||
|
@ -631,10 +631,9 @@ static void RecordFrameMetrics(nsIFrame* aForFrame,
|
||||
bool aMayHaveTouchListeners) {
|
||||
nsPresContext* presContext = aForFrame->PresContext();
|
||||
int32_t auPerDevPixel = presContext->AppUnitsPerDevPixel();
|
||||
LayoutDeviceToLayerScale resolution(aContainerParameters.mXScale, aContainerParameters.mYScale);
|
||||
|
||||
nsIntRect visible = aVisibleRect.ScaleToNearestPixels(
|
||||
resolution.scale, resolution.scale, auPerDevPixel);
|
||||
aContainerParameters.mXScale, aContainerParameters.mYScale, auPerDevPixel);
|
||||
aRoot->SetVisibleRegion(nsIntRegion(visible));
|
||||
|
||||
FrameMetrics metrics;
|
||||
@ -669,10 +668,10 @@ static void RecordFrameMetrics(nsIFrame* aForFrame,
|
||||
if (TabChild *tc = GetTabChildFrom(presShell)) {
|
||||
metrics.mZoom = tc->GetZoom();
|
||||
}
|
||||
metrics.mResolution = resolution;
|
||||
metrics.mResolution = gfxSize(presShell->GetXResolution(), presShell->GetYResolution());
|
||||
|
||||
metrics.mDevPixelsPerCSSPixel = CSSToLayoutDeviceScale(
|
||||
(float)nsPresContext::AppUnitsPerCSSPixel() / auPerDevPixel);
|
||||
metrics.mDevPixelsPerCSSPixel =
|
||||
(float)nsPresContext::AppUnitsPerCSSPixel() / auPerDevPixel;
|
||||
|
||||
metrics.mMayHaveTouchListeners = aMayHaveTouchListeners;
|
||||
|
||||
|
@ -167,7 +167,10 @@ ComputeShadowTreeTransform(nsIFrame* aContainerFrame,
|
||||
nscoord auPerDevPixel = aContainerFrame->PresContext()->AppUnitsPerDevPixel();
|
||||
nsIntPoint scrollOffset =
|
||||
aConfig.mScrollOffset.ToNearestPixels(auPerDevPixel);
|
||||
LayerIntPoint metricsScrollOffset = RoundedToInt(aMetrics->GetScrollOffsetInLayerPixels());
|
||||
// metricsScrollOffset is in layer coordinates.
|
||||
gfx::Point metricsScrollOffset = aMetrics->GetScrollOffsetInLayerPixels();
|
||||
nsIntPoint roundedMetricsScrollOffset =
|
||||
nsIntPoint(NS_lround(metricsScrollOffset.x), NS_lround(metricsScrollOffset.y));
|
||||
|
||||
if (aRootFrameLoader->AsyncScrollEnabled() && !aMetrics->mDisplayPort.IsEmpty()) {
|
||||
// Only use asynchronous scrolling if it is enabled and there is a
|
||||
@ -175,8 +178,8 @@ ComputeShadowTreeTransform(nsIFrame* aContainerFrame,
|
||||
// synchronously scrolled for identifying a scroll area before it is
|
||||
// being actively scrolled.
|
||||
nsIntPoint scrollCompensation(
|
||||
(scrollOffset.x / aTempScaleX - metricsScrollOffset.x),
|
||||
(scrollOffset.y / aTempScaleY - metricsScrollOffset.y));
|
||||
(scrollOffset.x / aTempScaleX - roundedMetricsScrollOffset.x),
|
||||
(scrollOffset.y / aTempScaleY - roundedMetricsScrollOffset.y));
|
||||
|
||||
return ViewTransform(-scrollCompensation, aConfig.mXScale, aConfig.mYScale);
|
||||
} else {
|
||||
@ -368,7 +371,7 @@ BuildViewMap(ViewMap& oldContentViews, ViewMap& newContentViews,
|
||||
if (metrics.IsScrollable()) {
|
||||
nscoord auPerDevPixel = aFrameLoader->GetPrimaryFrameOfOwningContent()
|
||||
->PresContext()->AppUnitsPerDevPixel();
|
||||
nscoord auPerCSSPixel = auPerDevPixel * metrics.mDevPixelsPerCSSPixel.scale;
|
||||
nscoord auPerCSSPixel = auPerDevPixel * metrics.mDevPixelsPerCSSPixel;
|
||||
nsContentView* view = FindViewForId(oldContentViews, scrollId);
|
||||
if (view) {
|
||||
// View already exists. Be sure to propagate scales for any values
|
||||
|
@ -2114,7 +2114,7 @@ AndroidBridge::IsTablet()
|
||||
}
|
||||
|
||||
void
|
||||
AndroidBridge::SetFirstPaintViewport(const LayerIntPoint& aOffset, const CSSToLayerScale& aZoom, const CSSRect& aCssPageRect)
|
||||
AndroidBridge::SetFirstPaintViewport(const LayerIntPoint& aOffset, float aZoom, const CSSRect& aCssPageRect)
|
||||
{
|
||||
AndroidGeckoLayerClient *client = mLayerClient;
|
||||
if (!client)
|
||||
@ -2134,8 +2134,8 @@ AndroidBridge::SetPageRect(const CSSRect& aCssPageRect)
|
||||
}
|
||||
|
||||
void
|
||||
AndroidBridge::SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
||||
bool aLayersUpdated, ScreenPoint& aScrollOffset, CSSToScreenScale& aScale,
|
||||
AndroidBridge::SyncViewportInfo(const LayerIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated,
|
||||
ScreenPoint& aScrollOffset, float& aScaleX, float& aScaleY,
|
||||
gfx::Margin& aFixedLayerMargins, ScreenPoint& aOffset)
|
||||
{
|
||||
AndroidGeckoLayerClient *client = mLayerClient;
|
||||
@ -2143,12 +2143,12 @@ AndroidBridge::SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLay
|
||||
return;
|
||||
|
||||
client->SyncViewportInfo(aDisplayPort, aDisplayResolution, aLayersUpdated,
|
||||
aScrollOffset, aScale, aFixedLayerMargins,
|
||||
aScrollOffset, aScaleX, aScaleY, aFixedLayerMargins,
|
||||
aOffset);
|
||||
}
|
||||
|
||||
void AndroidBridge::SyncFrameMetrics(const ScreenPoint& aScrollOffset, float aZoom, const CSSRect& aCssPageRect,
|
||||
bool aLayersUpdated, const CSSRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
||||
bool aLayersUpdated, const CSSRect& aDisplayPort, float aDisplayResolution,
|
||||
bool aIsFirstPaint, gfx::Margin& aFixedLayerMargins, ScreenPoint& aOffset)
|
||||
{
|
||||
AndroidGeckoLayerClient *client = mLayerClient;
|
||||
|
@ -371,13 +371,13 @@ public:
|
||||
void EnableNetworkNotifications();
|
||||
void DisableNetworkNotifications();
|
||||
|
||||
void SetFirstPaintViewport(const LayerIntPoint& aOffset, const CSSToLayerScale& aZoom, const CSSRect& aCssPageRect);
|
||||
void SetFirstPaintViewport(const LayerIntPoint& aOffset, float aZoom, const CSSRect& aCssPageRect);
|
||||
void SetPageRect(const CSSRect& aCssPageRect);
|
||||
void SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
||||
bool aLayersUpdated, ScreenPoint& aScrollOffset, CSSToScreenScale& aScale,
|
||||
void SyncViewportInfo(const LayerIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated,
|
||||
ScreenPoint& aScrollOffset, float& aScaleX, float& aScaleY,
|
||||
gfx::Margin& aFixedLayerMargins, ScreenPoint& aOffset);
|
||||
void SyncFrameMetrics(const ScreenPoint& aScrollOffset, float aZoom, const CSSRect& aCssPageRect,
|
||||
bool aLayersUpdated, const CSSRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
||||
bool aLayersUpdated, const CSSRect& aDisplayPort, float aDisplayResolution,
|
||||
bool aIsFirstPaint, gfx::Margin& aFixedLayerMargins, ScreenPoint& aOffset);
|
||||
|
||||
void AddPluginView(jobject view, const gfxRect& rect, bool isFullScreen);
|
||||
|
@ -905,7 +905,7 @@ AndroidProgressiveUpdateData::Init(jobject jobj)
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoLayerClient::SetFirstPaintViewport(const LayerIntPoint& aOffset, const CSSToLayerScale& aZoom, const CSSRect& aCssPageRect)
|
||||
AndroidGeckoLayerClient::SetFirstPaintViewport(const LayerIntPoint& aOffset, float aZoom, const CSSRect& aCssPageRect)
|
||||
{
|
||||
NS_ASSERTION(!isNull(), "SetFirstPaintViewport called on null layer client!");
|
||||
JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread
|
||||
@ -913,7 +913,7 @@ AndroidGeckoLayerClient::SetFirstPaintViewport(const LayerIntPoint& aOffset, con
|
||||
return;
|
||||
|
||||
AutoLocalJNIFrame jniFrame(env, 0);
|
||||
return env->CallVoidMethod(wrapped_obj, jSetFirstPaintViewport, (float)aOffset.x, (float)aOffset.y, aZoom.scale,
|
||||
return env->CallVoidMethod(wrapped_obj, jSetFirstPaintViewport, (float)aOffset.x, (float)aOffset.y, aZoom,
|
||||
aCssPageRect.x, aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost());
|
||||
}
|
||||
|
||||
@ -931,8 +931,8 @@ AndroidGeckoLayerClient::SetPageRect(const CSSRect& aCssPageRect)
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoLayerClient::SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
||||
bool aLayersUpdated, ScreenPoint& aScrollOffset, CSSToScreenScale& aScale,
|
||||
AndroidGeckoLayerClient::SyncViewportInfo(const LayerIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated,
|
||||
ScreenPoint& aScrollOffset, float& aScaleX, float& aScaleY,
|
||||
gfx::Margin& aFixedLayerMargins, ScreenPoint& aOffset)
|
||||
{
|
||||
NS_ASSERTION(!isNull(), "SyncViewportInfo called on null layer client!");
|
||||
@ -945,7 +945,7 @@ AndroidGeckoLayerClient::SyncViewportInfo(const LayerIntRect& aDisplayPort, cons
|
||||
jobject viewTransformJObj = env->CallObjectMethod(wrapped_obj, jSyncViewportInfoMethod,
|
||||
aDisplayPort.x, aDisplayPort.y,
|
||||
aDisplayPort.width, aDisplayPort.height,
|
||||
aDisplayResolution.scale, aLayersUpdated);
|
||||
aDisplayResolution, aLayersUpdated);
|
||||
if (jniFrame.CheckForException())
|
||||
return;
|
||||
|
||||
@ -955,7 +955,7 @@ AndroidGeckoLayerClient::SyncViewportInfo(const LayerIntRect& aDisplayPort, cons
|
||||
viewTransform.Init(viewTransformJObj);
|
||||
|
||||
aScrollOffset = ScreenPoint(viewTransform.GetX(env), viewTransform.GetY(env));
|
||||
aScale.scale = viewTransform.GetScale(env);
|
||||
aScaleX = aScaleY = viewTransform.GetScale(env);
|
||||
viewTransform.GetFixedLayerMargins(env, aFixedLayerMargins);
|
||||
|
||||
aOffset.x = viewTransform.GetOffsetX(env);
|
||||
@ -964,7 +964,7 @@ AndroidGeckoLayerClient::SyncViewportInfo(const LayerIntRect& aDisplayPort, cons
|
||||
|
||||
void
|
||||
AndroidGeckoLayerClient::SyncFrameMetrics(const ScreenPoint& aScrollOffset, float aZoom, const CSSRect& aCssPageRect,
|
||||
bool aLayersUpdated, const CSSRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
||||
bool aLayersUpdated, const CSSRect& aDisplayPort, float aDisplayResolution,
|
||||
bool aIsFirstPaint, gfx::Margin& aFixedLayerMargins, ScreenPoint& aOffset)
|
||||
{
|
||||
NS_ASSERTION(!isNull(), "SyncFrameMetrics called on null layer client!");
|
||||
@ -975,14 +975,14 @@ AndroidGeckoLayerClient::SyncFrameMetrics(const ScreenPoint& aScrollOffset, floa
|
||||
AutoLocalJNIFrame jniFrame(env);
|
||||
|
||||
// convert the displayport rect from scroll-relative CSS pixels to document-relative device pixels
|
||||
LayerRect dpUnrounded = aDisplayPort * aDisplayResolution;
|
||||
LayerRect dpUnrounded = aDisplayPort * CSSToLayerScale(aDisplayResolution);
|
||||
dpUnrounded += LayerPoint::FromUnknownPoint(aScrollOffset.ToUnknownPoint());
|
||||
LayerIntRect dp = gfx::RoundedToInt(dpUnrounded);
|
||||
|
||||
jobject viewTransformJObj = env->CallObjectMethod(wrapped_obj, jSyncFrameMetricsMethod,
|
||||
aScrollOffset.x, aScrollOffset.y, aZoom,
|
||||
aCssPageRect.x, aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost(),
|
||||
aLayersUpdated, dp.x, dp.y, dp.width, dp.height, aDisplayResolution.scale,
|
||||
aLayersUpdated, dp.x, dp.y, dp.width, dp.height, aDisplayResolution,
|
||||
aIsFirstPaint);
|
||||
|
||||
if (jniFrame.CheckForException())
|
||||
|
@ -269,13 +269,13 @@ public:
|
||||
AndroidGeckoLayerClient() {}
|
||||
AndroidGeckoLayerClient(jobject jobj) { Init(jobj); }
|
||||
|
||||
void SetFirstPaintViewport(const LayerIntPoint& aOffset, const CSSToLayerScale& aZoom, const CSSRect& aCssPageRect);
|
||||
void SetFirstPaintViewport(const LayerIntPoint& aOffset, float aZoom, const CSSRect& aCssPageRect);
|
||||
void SetPageRect(const CSSRect& aCssPageRect);
|
||||
void SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
||||
bool aLayersUpdated, ScreenPoint& aScrollOffset, CSSToScreenScale& aScale,
|
||||
void SyncViewportInfo(const LayerIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated,
|
||||
ScreenPoint& aScrollOffset, float& aScaleX, float& aScaleY,
|
||||
gfx::Margin& aFixedLayerMargins, ScreenPoint& aOffset);
|
||||
void SyncFrameMetrics(const ScreenPoint& aScrollOffset, float aZoom, const CSSRect& aCssPageRect,
|
||||
bool aLayersUpdated, const CSSRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
||||
bool aLayersUpdated, const CSSRect& aDisplayPort, float aDisplayResolution,
|
||||
bool aIsFirstPaint, gfx::Margin& aFixedLayerMargins, ScreenPoint& aOffset);
|
||||
bool ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, const LayerRect& aDisplayPort, float aDisplayResolution, bool aDrawingCritical, gfx::Rect& aViewport, float& aScaleX, float& aScaleY);
|
||||
bool CreateFrame(AutoLocalJNIFrame *jniFrame, AndroidLayerRendererFrame& aFrame);
|
||||
|
Loading…
Reference in New Issue
Block a user