Bug 856932 - Fix async scrolling of auto-positioned fixed position elements. r=nrc

Layers representing auto-positioned fixed position elements should not be
offset by the fixed layer margins.
This commit is contained in:
Chris Lord 2013-04-15 09:31:48 +01:00
parent 54272cbda0
commit 1f8698bb32
3 changed files with 31 additions and 8 deletions

View File

@ -859,6 +859,9 @@ public:
* will be mirrored here. This allows for asynchronous animation of the
* margins by reconciling the difference between this value and a value that
* is updated more frequently.
* If the left or top margins are negative, it means that the elements this
* layer represents are auto-positioned, and so fixed position margins should
* not have an effect on the corresponding axis.
*/
void SetFixedPositionMargins(const gfx::Margin& aMargins)
{

View File

@ -642,17 +642,24 @@ CompositorParent::TransformFixedLayers(Layer* aLayer,
// aFixedLayerMargins are the margins we expect to be at at the current
// time, obtained via SyncViewportInfo, and fixedMargins are the margins
// that were used during layout.
// If top/left of fixedMargins are negative, that indicates that this layer
// represents auto-positioned elements, and should not be affected by
// fixed margins at all.
const gfx::Margin& fixedMargins = aLayer->GetFixedPositionMargins();
if (anchor.x > 0) {
translation.x -= aFixedLayerMargins.right - fixedMargins.right;
} else {
translation.x += aFixedLayerMargins.left - fixedMargins.left;
if (fixedMargins.left >= 0) {
if (anchor.x > 0) {
translation.x -= aFixedLayerMargins.right - fixedMargins.right;
} else {
translation.x += aFixedLayerMargins.left - fixedMargins.left;
}
}
if (anchor.y > 0) {
translation.y -= aFixedLayerMargins.bottom - fixedMargins.bottom;
} else {
translation.y += aFixedLayerMargins.top - fixedMargins.top;
if (fixedMargins.top >= 0) {
if (anchor.y > 0) {
translation.y -= aFixedLayerMargins.bottom - fixedMargins.bottom;
} else {
translation.y += aFixedLayerMargins.top - fixedMargins.top;
}
}
// The transform already takes the resolution scale into account. Since we

View File

@ -2961,6 +2961,19 @@ nsDisplayFixedPosition::BuildLayer(nsDisplayListBuilder* aBuilder,
aContainerParameters.mYScale,
NSAppUnitsToFloatPixels(fixedMargins.left, factor) *
aContainerParameters.mXScale);
// If the frame is auto-positioned on either axis, set the top/left layer
// margins to -1, to indicate to the compositor that this layer is
// unaffected by fixed margins.
if (position->mOffset.GetLeftUnit() == eStyleUnit_Auto &&
position->mOffset.GetRightUnit() == eStyleUnit_Auto) {
fixedLayerMargins.left = -1;
}
if (position->mOffset.GetTopUnit() == eStyleUnit_Auto &&
position->mOffset.GetBottomUnit() == eStyleUnit_Auto) {
fixedLayerMargins.top = -1;
}
layer->SetFixedPositionMargins(fixedLayerMargins);
return layer.forget();