Skip to content

Commit

Permalink
Bug 856039 - Default to keeping the fixed layer margins in setViewpor…
Browse files Browse the repository at this point in the history
…tMetrics. r=Cwiiis
  • Loading branch information
staktrace committed Apr 1, 2013
1 parent 5250562 commit f572c89
Showing 2 changed files with 24 additions and 14 deletions.
31 changes: 17 additions & 14 deletions mobile/android/base/gfx/GeckoLayerClient.java
Original file line number Diff line number Diff line change
@@ -408,7 +408,7 @@ public void run() {
newMetrics.pageRectTop - oldMetrics.fixedLayerMarginTop);
}

setViewportMetrics(newMetrics, type == ViewportMessageType.UPDATE, true);
setViewportMetrics(newMetrics, type == ViewportMessageType.UPDATE);
mDisplayPort = DisplayPortCalculator.calculate(getViewportMetrics(), null);
}
return mDisplayPort;
@@ -434,7 +434,7 @@ public DisplayPortMetrics getDisplayPort(boolean pageSizeUpdate, boolean isBrows
* Sets margins on fixed-position layers, to be used when compositing.
* Must be called on the UI thread!
*/
public void setFixedLayerMargins(float left, float top, float right, float bottom) {
public synchronized void setFixedLayerMargins(float left, float top, float right, float bottom) {
ImmutableViewportMetrics oldMetrics = getViewportMetrics();
ImmutableViewportMetrics newMetrics = oldMetrics.setFixedLayerMargins(left, top, right, bottom);

@@ -473,7 +473,9 @@ public void setFixedLayerMargins(float left, float top, float right, float botto
}
}

setViewportMetrics(newMetrics, false, false);
mViewportMetrics = newMetrics;
mView.requestRender();
setShadowVisibility();
}

public void setClampOnFixedLayerMarginsChange(boolean aClamp) {
@@ -805,21 +807,22 @@ public void setAnimationTarget(ImmutableViewportMetrics metrics) {
*/
@Override
public void setViewportMetrics(ImmutableViewportMetrics metrics) {
setViewportMetrics(metrics, true, true);
setViewportMetrics(metrics, true);
}

private void setViewportMetrics(ImmutableViewportMetrics metrics, boolean notifyGecko, boolean keepFixedMargins) {
// This class owns the viewport size; don't let other pieces of code clobber our notion
// of the viewport size. The only place the viewport size should ever be updated is in
// the GeckoLayerClient.setViewportSize function, and there mViewportMetrics is updated
// directly.
/*
* You must hold the monitor while calling this.
*/
private void setViewportMetrics(ImmutableViewportMetrics metrics, boolean notifyGecko) {
// This class owns the viewport size and the fixed layer margins; don't let other pieces
// of code clobber either of them. The only place the viewport size should ever be
// updated is in GeckoLayerClient.setViewportSize, and the only place the margins should
// ever be updated is in GeckoLayerClient.setFixedLayerMargins; both of these assign to
// mViewportMetrics directly.
metrics = metrics.setViewportSize(mViewportMetrics.getWidth(), mViewportMetrics.getHeight());
metrics = metrics.setFixedLayerMarginsFrom(mViewportMetrics);
mViewportMetrics = metrics;

if (keepFixedMargins) {
mViewportMetrics = metrics.setFixedLayerMarginsFrom(mViewportMetrics);
} else {
mViewportMetrics = metrics;
}
mView.requestRender();
if (notifyGecko && mGeckoIsReady) {
geometryChanged();
7 changes: 7 additions & 0 deletions mobile/android/base/gfx/ImmutableViewportMetrics.java
Original file line number Diff line number Diff line change
@@ -209,6 +209,13 @@ public ImmutableViewportMetrics setPageRect(RectF pageRect, RectF cssPageRect) {
}

public ImmutableViewportMetrics setFixedLayerMargins(float left, float top, float right, float bottom) {
if (FloatUtils.fuzzyEquals(left, fixedLayerMarginLeft)
&& FloatUtils.fuzzyEquals(top, fixedLayerMarginTop)
&& FloatUtils.fuzzyEquals(right, fixedLayerMarginRight)
&& FloatUtils.fuzzyEquals(bottom, fixedLayerMarginBottom)) {
return this;
}

return new ImmutableViewportMetrics(
pageRectLeft, pageRectTop, pageRectRight, pageRectBottom,
cssPageRectLeft, cssPageRectTop, cssPageRectRight, cssPageRectBottom,

0 comments on commit f572c89

Please sign in to comment.