mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 785929 - Kill FrameMetrics.mContentRect. r=kentuckyfriedtakahe
This commit is contained in:
parent
c4d590d135
commit
1d2c4c97c5
@ -32,7 +32,6 @@ public:
|
||||
|
||||
FrameMetrics()
|
||||
: mCompositionBounds(0, 0, 0, 0)
|
||||
, mContentRect(0, 0, 0, 0)
|
||||
, mDisplayPort(0, 0, 0, 0)
|
||||
, mCriticalDisplayPort(0, 0, 0, 0)
|
||||
, mViewport(0, 0, 0, 0)
|
||||
@ -51,7 +50,6 @@ public:
|
||||
bool operator==(const FrameMetrics& aOther) const
|
||||
{
|
||||
return mCompositionBounds.IsEqualEdges(aOther.mCompositionBounds) &&
|
||||
mContentRect.IsEqualEdges(aOther.mContentRect) &&
|
||||
mDisplayPort.IsEqualEdges(aOther.mDisplayPort) &&
|
||||
mCriticalDisplayPort.IsEqualEdges(aOther.mCriticalDisplayPort) &&
|
||||
mViewport.IsEqualEdges(aOther.mViewport) &&
|
||||
@ -122,17 +120,6 @@ public:
|
||||
// metric as they do not have a displayport set. See bug 775452.
|
||||
LayerIntRect mCompositionBounds;
|
||||
|
||||
// |mScrollableRect|, stored in layer pixels. DECPRECATED, DO NOT USE.
|
||||
//
|
||||
// This is valid on any layer where |mScrollableRect| is, though it may be
|
||||
// more lazily maintained than |mScrollableRect|. That is, when
|
||||
// |mScrollableRect| is updated, this may lag. For this reason, it's better to
|
||||
// use |mScrollableRect| for any control logic.
|
||||
//
|
||||
// FIXME/bug 785929: Is this really necessary? Can it not be calculated from
|
||||
// |mScrollableRect| whenever it's needed?
|
||||
LayerIntRect mContentRect;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// The following metrics are all in CSS pixels. They are not in any uniform
|
||||
// space, so each is explained separately.
|
||||
|
@ -411,15 +411,14 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer, const gfx3DMatr
|
||||
metrics.mScrollOffset, layerPixelRatioX, layerPixelRatioY);
|
||||
|
||||
if (mIsFirstPaint) {
|
||||
mContentRect = metrics.mContentRect;
|
||||
mContentRect = metrics.mScrollableRect;
|
||||
SetFirstPaintViewport(scrollOffsetLayerPixels,
|
||||
layerPixelRatioX,
|
||||
mContentRect,
|
||||
metrics.mScrollableRect);
|
||||
mContentRect);
|
||||
mIsFirstPaint = false;
|
||||
} else if (!metrics.mContentRect.IsEqualEdges(mContentRect)) {
|
||||
mContentRect = metrics.mContentRect;
|
||||
SetPageRect(metrics.mScrollableRect);
|
||||
} else if (!metrics.mScrollableRect.IsEqualEdges(mContentRect)) {
|
||||
mContentRect = metrics.mScrollableRect;
|
||||
SetPageRect(mContentRect);
|
||||
}
|
||||
|
||||
// We synchronise the viewport information with Java after sending the above
|
||||
@ -470,26 +469,27 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer, const gfx3DMatr
|
||||
gfxPoint fixedOffset;
|
||||
gfxSize scaleDiff;
|
||||
|
||||
LayerRect content = LayerRect::FromCSSRect(mContentRect,
|
||||
1 / aRootTransform.GetXScale(),
|
||||
1 / aRootTransform.GetYScale());
|
||||
// If the contents can fit entirely within the widget area on a particular
|
||||
// dimenson, we need to translate and scale so that the fixed layers remain
|
||||
// dimension, we need to translate and scale so that the fixed layers remain
|
||||
// within the page boundaries.
|
||||
if (mContentRect.width * tempScaleDiffX < metrics.mCompositionBounds.width) {
|
||||
if (mContentRect.width * scaleX < metrics.mCompositionBounds.width) {
|
||||
fixedOffset.x = -metricsScrollOffset.x;
|
||||
scaleDiff.width = std::min(1.0f, metrics.mCompositionBounds.width / (float)mContentRect.width);
|
||||
scaleDiff.width = std::min(1.0f, metrics.mCompositionBounds.width / content.width);
|
||||
} else {
|
||||
fixedOffset.x = clamped(scrollOffset.x / tempScaleDiffX, (float)mContentRect.x,
|
||||
mContentRect.XMost() - metrics.mCompositionBounds.width / tempScaleDiffX) -
|
||||
metricsScrollOffset.x;
|
||||
fixedOffset.x = clamped(scrollOffset.x / tempScaleDiffX, content.x,
|
||||
content.XMost() - metrics.mCompositionBounds.width / tempScaleDiffX) - metricsScrollOffset.x;
|
||||
scaleDiff.width = tempScaleDiffX;
|
||||
}
|
||||
|
||||
if (mContentRect.height * tempScaleDiffY < metrics.mCompositionBounds.height) {
|
||||
if (mContentRect.height * scaleY < metrics.mCompositionBounds.height) {
|
||||
fixedOffset.y = -metricsScrollOffset.y;
|
||||
scaleDiff.height = std::min(1.0f, metrics.mCompositionBounds.height / (float)mContentRect.height);
|
||||
scaleDiff.height = std::min(1.0f, metrics.mCompositionBounds.height / content.height);
|
||||
} else {
|
||||
fixedOffset.y = clamped(scrollOffset.y / tempScaleDiffY, (float)mContentRect.y,
|
||||
mContentRect.YMost() - metrics.mCompositionBounds.height / tempScaleDiffY) -
|
||||
metricsScrollOffset.y;
|
||||
fixedOffset.y = clamped(scrollOffset.y / tempScaleDiffY, content.y,
|
||||
content.YMost() - metrics.mCompositionBounds.height / tempScaleDiffY) - metricsScrollOffset.y;
|
||||
scaleDiff.height = tempScaleDiffY;
|
||||
}
|
||||
|
||||
@ -552,11 +552,10 @@ AsyncCompositionManager::TransformShadowTree(TimeStamp aCurrentFrame)
|
||||
void
|
||||
AsyncCompositionManager::SetFirstPaintViewport(const LayerIntPoint& aOffset,
|
||||
float aZoom,
|
||||
const LayerIntRect& aPageRect,
|
||||
const CSSRect& aCssPageRect)
|
||||
{
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
AndroidBridge::Bridge()->SetFirstPaintViewport(aOffset, aZoom, aPageRect, aCssPageRect);
|
||||
AndroidBridge::Bridge()->SetFirstPaintViewport(aOffset, aZoom, aCssPageRect);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,6 @@ private:
|
||||
|
||||
void SetFirstPaintViewport(const LayerIntPoint& aOffset,
|
||||
float aZoom,
|
||||
const LayerIntRect& aPageRect,
|
||||
const CSSRect& aCssPageRect);
|
||||
void SetPageRect(const CSSRect& aCssPageRect);
|
||||
void SyncViewportInfo(const LayerIntRect& aDisplayPort,
|
||||
@ -163,7 +162,7 @@ private:
|
||||
void DetachRefLayers();
|
||||
|
||||
TargetConfig mTargetConfig;
|
||||
LayerIntRect mContentRect;
|
||||
CSSRect mContentRect;
|
||||
|
||||
nsRefPtr<LayerManagerComposite> mLayerManager;
|
||||
// When this flag is set, the next composition will be the first for a
|
||||
|
@ -251,15 +251,17 @@ ThebesLayerComposite::GetCompositionBounds()
|
||||
|
||||
// Get the content document bounds, in screen-space.
|
||||
const FrameMetrics& metrics = scrollableLayer->GetFrameMetrics();
|
||||
const LayerIntSize& contentSize = metrics.mContentRect.Size();
|
||||
const LayerIntRect content = LayerIntRect::FromCSSRectRounded(metrics.mScrollableRect,
|
||||
1 / scaleX,
|
||||
1 / scaleY);
|
||||
gfx::Point scrollOffset =
|
||||
gfx::Point((metrics.mScrollOffset.x * metrics.LayersPixelsPerCSSPixel().width) / scaleX,
|
||||
(metrics.mScrollOffset.y * metrics.LayersPixelsPerCSSPixel().height) / scaleY);
|
||||
const nsIntPoint contentOrigin(
|
||||
metrics.mContentRect.x - NS_lround(scrollOffset.x),
|
||||
metrics.mContentRect.y - NS_lround(scrollOffset.y));
|
||||
content.x - NS_lround(scrollOffset.x),
|
||||
content.y - NS_lround(scrollOffset.y));
|
||||
gfxRect contentRect = gfxRect(contentOrigin.x, contentOrigin.y,
|
||||
contentSize.width, contentSize.height);
|
||||
content.width, content.height);
|
||||
gfxRect contentBounds = scrollableLayer->GetEffectiveTransform().
|
||||
TransformBounds(contentRect);
|
||||
|
||||
|
@ -832,19 +832,6 @@ void AsyncPanZoomController::ScrollBy(const gfx::Point& aOffset) {
|
||||
mFrameMetrics = metrics;
|
||||
}
|
||||
|
||||
void AsyncPanZoomController::SetPageRect(const CSSRect& aCSSPageRect) {
|
||||
FrameMetrics metrics = mFrameMetrics;
|
||||
gfxFloat resolution = CalculateResolution(mFrameMetrics).width;
|
||||
|
||||
// The page rect is the css page rect scaled by the current zoom.
|
||||
// Round the page rect so we don't get any truncation, then get the nsIntRect
|
||||
// from this.
|
||||
metrics.mContentRect = LayerRect::FromCSSRectRoundOut(aCSSPageRect, resolution, resolution);
|
||||
metrics.mScrollableRect = aCSSPageRect;
|
||||
|
||||
mFrameMetrics = metrics;
|
||||
}
|
||||
|
||||
void AsyncPanZoomController::ScaleWithFocus(float aZoom,
|
||||
const nsIntPoint& aFocus) {
|
||||
float zoomFactor = aZoom / mFrameMetrics.mZoom.width;
|
||||
@ -852,10 +839,6 @@ void AsyncPanZoomController::ScaleWithFocus(float aZoom,
|
||||
|
||||
SetZoomAndResolution(aZoom);
|
||||
|
||||
// Force a recalculation of the page rect based on the new zoom and the
|
||||
// current CSS page rect (which is unchanged since it's not affected by zoom).
|
||||
SetPageRect(mFrameMetrics.mScrollableRect);
|
||||
|
||||
// If the new scale is very small, we risk multiplying in huge rounding
|
||||
// errors, so don't bother adjusting the scroll offset.
|
||||
if (resolution >= 0.01f) {
|
||||
@ -1272,12 +1255,9 @@ void AsyncPanZoomController::NotifyLayersUpdated(const FrameMetrics& aViewportFr
|
||||
|
||||
mFrameMetrics = aViewportFrame;
|
||||
|
||||
SetPageRect(mFrameMetrics.mScrollableRect);
|
||||
|
||||
mState = NOTHING;
|
||||
} else if (!mFrameMetrics.mScrollableRect.IsEqualEdges(aViewportFrame.mScrollableRect)) {
|
||||
mFrameMetrics.mScrollableRect = aViewportFrame.mScrollableRect;
|
||||
SetPageRect(mFrameMetrics.mScrollableRect);
|
||||
}
|
||||
|
||||
if (needContentRepaint) {
|
||||
|
@ -198,12 +198,6 @@ public:
|
||||
// These methods can be called from any thread.
|
||||
//
|
||||
|
||||
/**
|
||||
* Sets the CSS page rect, and calculates a new page rect based on the zoom
|
||||
* level of the current metrics and the passed in CSS page rect.
|
||||
*/
|
||||
void SetPageRect(const CSSRect& aCSSPageRect);
|
||||
|
||||
/**
|
||||
* Sets the DPI of the device for use within panning and zooming logic. It is
|
||||
* a platform responsibility to set this on initialization of this class and
|
||||
|
@ -1074,7 +1074,6 @@ struct ParamTraits<mozilla::layers::FrameMetrics>
|
||||
{
|
||||
WriteParam(aMsg, aParam.mScrollableRect);
|
||||
WriteParam(aMsg, aParam.mViewport);
|
||||
WriteParam(aMsg, aParam.mContentRect);
|
||||
WriteParam(aMsg, aParam.mScrollOffset);
|
||||
WriteParam(aMsg, aParam.mDisplayPort);
|
||||
WriteParam(aMsg, aParam.mCriticalDisplayPort);
|
||||
@ -1091,7 +1090,6 @@ struct ParamTraits<mozilla::layers::FrameMetrics>
|
||||
{
|
||||
return (ReadParam(aMsg, aIter, &aResult->mScrollableRect) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mViewport) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mContentRect) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mScrollOffset) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mDisplayPort) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mCriticalDisplayPort) &&
|
||||
|
@ -83,12 +83,6 @@ struct LayerPixel {
|
||||
return RoundToInt(FromCSSRect(aRect, aResolutionX, aResolutionY));
|
||||
}
|
||||
|
||||
static gfx::IntRectTyped<LayerPixel> FromCSSRectRoundOut(const CSSRect& aRect, float aResolutionX, float aResolutionY) {
|
||||
gfx::RectTyped<LayerPixel> scaled(aRect.x, aRect.y, aRect.width, aRect.height);
|
||||
scaled.ScaleInverseRoundOut(aResolutionX, aResolutionY);
|
||||
return gfx::IntRectTyped<LayerPixel>(scaled.x, scaled.y, scaled.width, scaled.height);
|
||||
}
|
||||
|
||||
static CSSIntRect ToCSSIntRectRoundIn(const gfx::IntRectTyped<LayerPixel>& aRect, float aResolutionX, float aResolutionY) {
|
||||
gfx::IntRectTyped<CSSPixel> ret(aRect.x, aRect.y, aRect.width, aRect.height);
|
||||
ret.ScaleInverseRoundIn(aResolutionX, aResolutionY);
|
||||
|
@ -652,22 +652,12 @@ static void RecordFrameMetrics(nsIFrame* aForFrame,
|
||||
contentBounds.width += scrollableFrame->GetScrollPortRect().width;
|
||||
contentBounds.height += scrollableFrame->GetScrollPortRect().height;
|
||||
metrics.mScrollableRect = CSSRect::FromAppUnits(contentBounds);
|
||||
nsIntRect contentRect = contentBounds.ScaleToNearestPixels(
|
||||
aContainerParameters.mXScale, aContainerParameters.mYScale, auPerDevPixel);
|
||||
// I'm not sure what units contentRect is really in, hence FromUnknownRect
|
||||
metrics.mContentRect = LayerIntRect::FromUnknownRect(mozilla::gfx::IntRect(
|
||||
contentRect.x, contentRect.y, contentRect.width, contentRect.height));
|
||||
nsPoint scrollPosition = scrollableFrame->GetScrollPosition();
|
||||
metrics.mScrollOffset = CSSPoint::FromAppUnits(scrollPosition);
|
||||
}
|
||||
else {
|
||||
nsRect contentBounds = aForFrame->GetRect();
|
||||
metrics.mScrollableRect = CSSRect::FromAppUnits(contentBounds);
|
||||
nsIntRect contentRect = contentBounds.ScaleToNearestPixels(
|
||||
aContainerParameters.mXScale, aContainerParameters.mYScale, auPerDevPixel);
|
||||
// I'm not sure what units contentRect is really in, hence FromUnknownRect
|
||||
metrics.mContentRect = LayerIntRect::FromUnknownRect(mozilla::gfx::IntRect(
|
||||
contentRect.x, contentRect.y, contentRect.width, contentRect.height));
|
||||
}
|
||||
|
||||
metrics.mScrollId = aScrollId;
|
||||
|
@ -416,8 +416,8 @@ BuildViewMap(ViewMap& oldContentViews, ViewMap& newContentViews,
|
||||
NSIntPixelsToAppUnits(viewport.width, auPerDevPixel) * aXScale,
|
||||
NSIntPixelsToAppUnits(viewport.height, auPerDevPixel) * aYScale);
|
||||
view->mContentSize = nsSize(
|
||||
NSIntPixelsToAppUnits(metrics.mContentRect.width, auPerDevPixel) * aXScale,
|
||||
NSIntPixelsToAppUnits(metrics.mContentRect.height, auPerDevPixel) * aYScale);
|
||||
NSFloatPixelsToAppUnits(metrics.mScrollableRect.width, auPerCSSPixel) * aXScale,
|
||||
NSFloatPixelsToAppUnits(metrics.mScrollableRect.height, auPerCSSPixel) * aYScale);
|
||||
|
||||
newContentViews[scrollId] = view;
|
||||
}
|
||||
|
@ -553,18 +553,17 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
|
||||
* this function is invoked on; and this function will always be called prior to syncViewportInfo.
|
||||
*/
|
||||
public void setFirstPaintViewport(float offsetX, float offsetY, float zoom,
|
||||
float pageLeft, float pageTop, float pageRight, float pageBottom,
|
||||
float cssPageLeft, float cssPageTop, float cssPageRight, float cssPageBottom) {
|
||||
synchronized (getLock()) {
|
||||
ImmutableViewportMetrics currentMetrics = getViewportMetrics();
|
||||
|
||||
Tab tab = Tabs.getInstance().getSelectedTab();
|
||||
|
||||
RectF cssPageRect = new RectF(cssPageLeft, cssPageTop, cssPageRight, cssPageBottom);
|
||||
final ImmutableViewportMetrics newMetrics = currentMetrics
|
||||
.setViewportOrigin(offsetX, offsetY)
|
||||
.setZoomFactor(zoom)
|
||||
.setPageRect(new RectF(pageLeft, pageTop, pageRight, pageBottom),
|
||||
new RectF(cssPageLeft, cssPageTop, cssPageRight, cssPageBottom))
|
||||
.setPageRect(RectUtils.scale(cssPageRect, zoom), cssPageRect)
|
||||
.setIsRTL(tab.getIsRTL());
|
||||
// Since we have switched to displaying a different document, we need to update any
|
||||
// viewport-related state we have lying around. This includes mGeckoViewport and
|
||||
@ -690,9 +689,8 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
|
||||
boolean isFirstPaint)
|
||||
{
|
||||
if (isFirstPaint) {
|
||||
RectF pageRect = RectUtils.scale(new RectF(cssPageLeft, cssPageTop, cssPageRight, cssPageBottom), zoom);
|
||||
setFirstPaintViewport(offsetX, offsetY, zoom, pageRect.left, pageRect.top, pageRect.right,
|
||||
pageRect.bottom, cssPageLeft, cssPageTop, cssPageRight, cssPageBottom);
|
||||
setFirstPaintViewport(offsetX, offsetY, zoom,
|
||||
cssPageLeft, cssPageTop, cssPageRight, cssPageBottom);
|
||||
}
|
||||
|
||||
return syncViewportInfo(x, y, width, height, resolution, layersUpdated);
|
||||
|
@ -2114,13 +2114,13 @@ AndroidBridge::IsTablet()
|
||||
}
|
||||
|
||||
void
|
||||
AndroidBridge::SetFirstPaintViewport(const LayerIntPoint& aOffset, float aZoom, const LayerIntRect& aPageRect, const CSSRect& aCssPageRect)
|
||||
AndroidBridge::SetFirstPaintViewport(const LayerIntPoint& aOffset, float aZoom, const CSSRect& aCssPageRect)
|
||||
{
|
||||
AndroidGeckoLayerClient *client = mLayerClient;
|
||||
if (!client)
|
||||
return;
|
||||
|
||||
client->SetFirstPaintViewport(aOffset, aZoom, aPageRect, aCssPageRect);
|
||||
client->SetFirstPaintViewport(aOffset, aZoom, aCssPageRect);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -371,7 +371,7 @@ public:
|
||||
void EnableNetworkNotifications();
|
||||
void DisableNetworkNotifications();
|
||||
|
||||
void SetFirstPaintViewport(const LayerIntPoint& aOffset, float aZoom, const LayerIntRect& aPageRect, const CSSRect& aCssPageRect);
|
||||
void SetFirstPaintViewport(const LayerIntPoint& aOffset, float aZoom, const CSSRect& aCssPageRect);
|
||||
void SetPageRect(const CSSRect& aCssPageRect);
|
||||
void SyncViewportInfo(const LayerIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated,
|
||||
ScreenPoint& aScrollOffset, float& aScaleX, float& aScaleY,
|
||||
|
@ -351,7 +351,7 @@ AndroidGeckoLayerClient::InitGeckoLayerClientClass(JNIEnv *jEnv)
|
||||
|
||||
jGeckoLayerClientClass = getClassGlobalRef("org/mozilla/gecko/gfx/GeckoLayerClient");
|
||||
|
||||
jSetFirstPaintViewport = getMethod("setFirstPaintViewport", "(FFFFFFFFFFF)V");
|
||||
jSetFirstPaintViewport = getMethod("setFirstPaintViewport", "(FFFFFFF)V");
|
||||
jSetPageRect = getMethod("setPageRect", "(FFFF)V");
|
||||
jSyncViewportInfoMethod = getMethod("syncViewportInfo",
|
||||
"(IIIIFZ)Lorg/mozilla/gecko/gfx/ViewTransform;");
|
||||
@ -863,7 +863,7 @@ AndroidProgressiveUpdateData::Init(jobject jobj)
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoLayerClient::SetFirstPaintViewport(const LayerIntPoint& aOffset, float aZoom, const LayerIntRect& aPageRect, 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
|
||||
@ -872,7 +872,6 @@ AndroidGeckoLayerClient::SetFirstPaintViewport(const LayerIntPoint& aOffset, flo
|
||||
|
||||
AutoLocalJNIFrame jniFrame(env, 0);
|
||||
return env->CallVoidMethod(wrapped_obj, jSetFirstPaintViewport, (float)aOffset.x, (float)aOffset.y, aZoom,
|
||||
(float)aPageRect.x, (float)aPageRect.y, (float)aPageRect.XMost(), (float)aPageRect.YMost(),
|
||||
aCssPageRect.x, aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost());
|
||||
}
|
||||
|
||||
|
@ -269,7 +269,7 @@ public:
|
||||
AndroidGeckoLayerClient() {}
|
||||
AndroidGeckoLayerClient(jobject jobj) { Init(jobj); }
|
||||
|
||||
void SetFirstPaintViewport(const LayerIntPoint& aOffset, float aZoom, const LayerIntRect& aPageRect, const CSSRect& aCssPageRect);
|
||||
void SetFirstPaintViewport(const LayerIntPoint& aOffset, float aZoom, const CSSRect& aCssPageRect);
|
||||
void SetPageRect(const CSSRect& aCssPageRect);
|
||||
void SyncViewportInfo(const LayerIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated,
|
||||
ScreenPoint& aScrollOffset, float& aScaleX, float& aScaleY,
|
||||
|
Loading…
Reference in New Issue
Block a user