Bug 919144. Part 1: Rename identifiers from 'active scroll(ed) root' to 'animated geometry root'. r=mattwoodrow

Also sneaks in a couple of other refactorings:

--HG--
extra : rebase_source : 8b0e0729f26231d98ed069b54dd4f7c1e51b10b5
This commit is contained in:
Robert O'Callahan 2013-09-26 09:07:26 +12:00
parent d34b4a705a
commit 3d6d117d48
6 changed files with 153 additions and 130 deletions

View File

@ -325,7 +325,7 @@ protected:
class ThebesLayerData {
public:
ThebesLayerData() :
mActiveScrolledRoot(nullptr), mLayer(nullptr),
mAnimatedGeometryRoot(nullptr), mLayer(nullptr),
mIsSolidColorInVisibleRegion(false),
mNeedComponentAlpha(false),
mForceTransparentSurface(false),
@ -350,7 +350,7 @@ protected:
const nsIntRect& aVisibleRect,
const nsIntRect& aDrawRect,
const DisplayItemClip& aClip);
const nsIFrame* GetActiveScrolledRoot() { return mActiveScrolledRoot; }
const nsIFrame* GetAnimatedGeometryRoot() { return mAnimatedGeometryRoot; }
/**
* If this represents only a nsDisplayImage, and the image type
@ -437,7 +437,7 @@ protected:
* be non-null; all content in a ThebesLayer must have the same
* active scrolled root.
*/
const nsIFrame* mActiveScrolledRoot;
const nsIFrame* mAnimatedGeometryRoot;
ThebesLayer* mLayer;
/**
* If mIsSolidColorInVisibleRegion is true, this is the color of the visible
@ -522,7 +522,7 @@ protected:
* a recycled ThebesLayer, and sets up the transform on the ThebesLayer
* to account for scrolling.
*/
already_AddRefed<ThebesLayer> CreateOrRecycleThebesLayer(const nsIFrame* aActiveScrolledRoot,
already_AddRefed<ThebesLayer> CreateOrRecycleThebesLayer(const nsIFrame* aAnimatedGeometryRoot,
const nsIFrame *aReferenceFrame,
const nsPoint& aTopLeft);
/**
@ -580,7 +580,7 @@ protected:
* layer is found. If we choose a ThebesLayer that's already on the
* ThebesLayerData stack, later elements on the stack will be popped off.
* @param aVisibleRect the area of the next display item that's visible
* @param aActiveScrolledRoot the active scrolled root for the next
* @param aAnimatedGeometryRoot the active scrolled root for the next
* display item
* @param aOpaqueRect if non-null, a region of the display item that is opaque
* @param aSolidColor if non-null, indicates that every pixel in aVisibleRect
@ -590,7 +590,7 @@ protected:
const nsIntRect& aVisibleRect,
const nsIntRect& aDrawRect,
const DisplayItemClip& aClip,
const nsIFrame* aActiveScrolledRoot,
const nsIFrame* aAnimatedGeometryRoot,
const nsPoint& aTopLeft);
ThebesLayerData* GetTopThebesLayerData()
{
@ -610,8 +610,8 @@ protected:
void SetupMaskLayer(Layer *aLayer, const DisplayItemClip& aClip,
uint32_t aRoundedRectClipCount = UINT32_MAX);
bool ChooseActiveScrolledRoot(const nsDisplayList& aList,
const nsIFrame **aActiveScrolledRoot);
bool ChooseAnimatedGeometryRoot(const nsDisplayList& aList,
const nsIFrame **aAnimatedGeometryRoot);
nsDisplayListBuilder* mBuilder;
LayerManager* mManager;
@ -651,7 +651,7 @@ public:
mXScale(1.f), mYScale(1.f),
mAppUnitsPerDevPixel(0),
mTranslation(0, 0),
mActiveScrolledRootPosition(0, 0) {}
mAnimatedGeometryRootPosition(0, 0) {}
/**
* Record the number of clips in the Thebes layer's mask layer.
@ -694,15 +694,15 @@ public:
* store the coordinates in ThebesLayer space of the top-left of the
* active scrolled root.
*/
gfxPoint mActiveScrolledRootPosition;
gfxPoint mAnimatedGeometryRootPosition;
nsIntRegion mRegionToInvalidate;
// The offset between the active scrolled root of this layer
// and the root of the container for the previous and current
// paints respectively.
nsPoint mLastActiveScrolledRootOrigin;
nsPoint mActiveScrolledRootOrigin;
nsPoint mLastAnimatedGeometryRootOrigin;
nsPoint mAnimatedGeometryRootOrigin;
nsRefPtr<ColorLayer> mColorLayer;
nsRefPtr<ImageLayer> mImageLayer;
@ -1321,16 +1321,16 @@ RoundToMatchResidual(double aValue, double aOldResidual)
}
static void
ResetScrollPositionForLayerPixelAlignment(const nsIFrame* aActiveScrolledRoot)
ResetScrollPositionForLayerPixelAlignment(const nsIFrame* aAnimatedGeometryRoot)
{
nsIScrollableFrame* sf = nsLayoutUtils::GetScrollableFrameFor(aActiveScrolledRoot);
nsIScrollableFrame* sf = nsLayoutUtils::GetScrollableFrameFor(aAnimatedGeometryRoot);
if (sf) {
sf->ResetScrollPositionForLayerPixelAlignment();
}
}
static void
InvalidateEntireThebesLayer(ThebesLayer* aLayer, const nsIFrame* aActiveScrolledRoot)
InvalidateEntireThebesLayer(ThebesLayer* aLayer, const nsIFrame* aAnimatedGeometryRoot)
{
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
@ -1339,11 +1339,11 @@ InvalidateEntireThebesLayer(ThebesLayer* aLayer, const nsIFrame* aActiveScrolled
#endif
nsIntRect invalidate = aLayer->GetValidRegion().GetBounds();
aLayer->InvalidateRegion(invalidate);
ResetScrollPositionForLayerPixelAlignment(aActiveScrolledRoot);
ResetScrollPositionForLayerPixelAlignment(aAnimatedGeometryRoot);
}
already_AddRefed<ThebesLayer>
ContainerState::CreateOrRecycleThebesLayer(const nsIFrame* aActiveScrolledRoot,
ContainerState::CreateOrRecycleThebesLayer(const nsIFrame* aAnimatedGeometryRoot,
const nsIFrame* aReferenceFrame,
const nsPoint& aTopLeft)
{
@ -1376,7 +1376,7 @@ ContainerState::CreateOrRecycleThebesLayer(const nsIFrame* aActiveScrolledRoot,
if (!FuzzyEqual(data->mXScale, mParameters.mXScale, 0.00001f) ||
!FuzzyEqual(data->mYScale, mParameters.mYScale, 0.00001f) ||
data->mAppUnitsPerDevPixel != mAppUnitsPerDevPixel) {
InvalidateEntireThebesLayer(layer, aActiveScrolledRoot);
InvalidateEntireThebesLayer(layer, aAnimatedGeometryRoot);
#ifndef MOZ_ANDROID_OMTC
didResetScrollPositionForLayerPixelAlignment = true;
#endif
@ -1409,31 +1409,31 @@ ContainerState::CreateOrRecycleThebesLayer(const nsIFrame* aActiveScrolledRoot,
// Mark this layer as being used for Thebes-painting display items
data = new ThebesDisplayItemLayerUserData();
layer->SetUserData(&gThebesDisplayItemLayerUserData, data);
ResetScrollPositionForLayerPixelAlignment(aActiveScrolledRoot);
ResetScrollPositionForLayerPixelAlignment(aAnimatedGeometryRoot);
#ifndef MOZ_ANDROID_OMTC
didResetScrollPositionForLayerPixelAlignment = true;
#endif
}
data->mXScale = mParameters.mXScale;
data->mYScale = mParameters.mYScale;
data->mLastActiveScrolledRootOrigin = data->mActiveScrolledRootOrigin;
data->mActiveScrolledRootOrigin = aTopLeft;
data->mLastAnimatedGeometryRootOrigin = data->mAnimatedGeometryRootOrigin;
data->mAnimatedGeometryRootOrigin = aTopLeft;
data->mAppUnitsPerDevPixel = mAppUnitsPerDevPixel;
layer->SetAllowResidualTranslation(mParameters.AllowResidualTranslation());
mLayerBuilder->SaveLastPaintOffset(layer);
// Set up transform so that 0,0 in the Thebes layer corresponds to the
// (pixel-snapped) top-left of the aActiveScrolledRoot.
nsPoint offset = aActiveScrolledRoot->GetOffsetToCrossDoc(aReferenceFrame);
nscoord appUnitsPerDevPixel = aActiveScrolledRoot->PresContext()->AppUnitsPerDevPixel();
// (pixel-snapped) top-left of the aAnimatedGeometryRoot.
nsPoint offset = aAnimatedGeometryRoot->GetOffsetToCrossDoc(aReferenceFrame);
nscoord appUnitsPerDevPixel = aAnimatedGeometryRoot->PresContext()->AppUnitsPerDevPixel();
gfxPoint scaledOffset(
NSAppUnitsToDoublePixels(offset.x, appUnitsPerDevPixel)*mParameters.mXScale,
NSAppUnitsToDoublePixels(offset.y, appUnitsPerDevPixel)*mParameters.mYScale);
// We call RoundToMatchResidual here so that the residual after rounding
// is close to data->mActiveScrolledRootPosition if possible.
nsIntPoint pixOffset(RoundToMatchResidual(scaledOffset.x, data->mActiveScrolledRootPosition.x),
RoundToMatchResidual(scaledOffset.y, data->mActiveScrolledRootPosition.y));
// is close to data->mAnimatedGeometryRootPosition if possible.
nsIntPoint pixOffset(RoundToMatchResidual(scaledOffset.x, data->mAnimatedGeometryRootPosition.x),
RoundToMatchResidual(scaledOffset.y, data->mAnimatedGeometryRootPosition.y));
data->mTranslation = pixOffset;
pixOffset += mParameters.mOffset;
gfxMatrix matrix;
@ -1444,15 +1444,15 @@ ContainerState::CreateOrRecycleThebesLayer(const nsIFrame* aActiveScrolledRoot,
#ifndef MOZ_ANDROID_OMTC
// Calculate exact position of the top-left of the active scrolled root.
// This might not be 0,0 due to the snapping in ScaleToNearestPixels.
gfxPoint activeScrolledRootTopLeft = scaledOffset - matrix.GetTranslation() + mParameters.mOffset;
gfxPoint animatedGeometryRootTopLeft = scaledOffset - matrix.GetTranslation() + mParameters.mOffset;
// If it has changed, then we need to invalidate the entire layer since the
// pixels in the layer buffer have the content at a (subpixel) offset
// from what we need.
if (!activeScrolledRootTopLeft.WithinEpsilonOf(data->mActiveScrolledRootPosition, SUBPIXEL_OFFSET_EPSILON)) {
data->mActiveScrolledRootPosition = activeScrolledRootTopLeft;
InvalidateEntireThebesLayer(layer, aActiveScrolledRoot);
if (!animatedGeometryRootTopLeft.WithinEpsilonOf(data->mAnimatedGeometryRootPosition, SUBPIXEL_OFFSET_EPSILON)) {
data->mAnimatedGeometryRootPosition = animatedGeometryRootTopLeft;
InvalidateEntireThebesLayer(layer, aAnimatedGeometryRoot);
} else if (didResetScrollPositionForLayerPixelAlignment) {
data->mActiveScrolledRootPosition = activeScrolledRootTopLeft;
data->mAnimatedGeometryRootPosition = animatedGeometryRootTopLeft;
}
#endif
@ -1907,7 +1907,7 @@ ContainerState::FindThebesLayerFor(nsDisplayItem* aItem,
++i;
break;
}
if (data->mActiveScrolledRoot == aActiveScrolledRoot) {
if (data->mAnimatedGeometryRoot == aActiveScrolledRoot) {
lowestUsableLayerWithScrolledRoot = i;
if (topmostLayerWithScrolledRoot < 0) {
topmostLayerWithScrolledRoot = i;
@ -1920,7 +1920,7 @@ ContainerState::FindThebesLayerFor(nsDisplayItem* aItem,
--i;
for (; i >= 0; --i) {
ThebesLayerData* data = mThebesLayerDataStack[i];
if (data->mActiveScrolledRoot == aActiveScrolledRoot) {
if (data->mAnimatedGeometryRoot == aActiveScrolledRoot) {
topmostLayerWithScrolledRoot = i;
break;
}
@ -1944,7 +1944,7 @@ ContainerState::FindThebesLayerFor(nsDisplayItem* aItem,
thebesLayerData = new ThebesLayerData();
mThebesLayerDataStack.AppendElement(thebesLayerData);
thebesLayerData->mLayer = layer;
thebesLayerData->mActiveScrolledRoot = aActiveScrolledRoot;
thebesLayerData->mAnimatedGeometryRoot = aActiveScrolledRoot;
} else {
thebesLayerData = mThebesLayerDataStack[lowestUsableLayerWithScrolledRoot];
layer = thebesLayerData->mLayer;
@ -2032,8 +2032,8 @@ PaintInactiveLayer(nsDisplayListBuilder* aBuilder,
* when we are flattening layers.
*/
bool
ContainerState::ChooseActiveScrolledRoot(const nsDisplayList& aList,
const nsIFrame **aActiveScrolledRoot)
ContainerState::ChooseAnimatedGeometryRoot(const nsDisplayList& aList,
const nsIFrame **aAnimatedGeometryRoot)
{
for (nsDisplayItem* item = aList.GetBottom(); item; item = item->GetAbove()) {
LayerState layerState = item->GetLayerState(mBuilder, mManager, mParameters);
@ -2045,8 +2045,8 @@ ContainerState::ChooseActiveScrolledRoot(const nsDisplayList& aList,
// Try using the actual active scrolled root of the backmost item, as that
// should result in the least invalidation when scrolling.
mBuilder->IsFixedItem(item, aActiveScrolledRoot);
if (*aActiveScrolledRoot) {
mBuilder->IsFixedItem(item, aAnimatedGeometryRoot);
if (*aAnimatedGeometryRoot) {
return true;
}
}
@ -2073,18 +2073,18 @@ ContainerState::ProcessDisplayItems(const nsDisplayList& aList,
{
PROFILER_LABEL("ContainerState", "ProcessDisplayItems");
const nsIFrame* lastActiveScrolledRoot = nullptr;
const nsIFrame* lastAnimatedGeometryRoot = nullptr;
nsPoint topLeft;
// When NO_COMPONENT_ALPHA is set, items will be flattened into a single
// layer, so we need to choose which active scrolled root to use for all
// items.
if (aFlags & NO_COMPONENT_ALPHA) {
if (!ChooseActiveScrolledRoot(aList, &lastActiveScrolledRoot)) {
lastActiveScrolledRoot = mContainerReferenceFrame;
if (!ChooseAnimatedGeometryRoot(aList, &lastAnimatedGeometryRoot)) {
lastAnimatedGeometryRoot = mContainerReferenceFrame;
}
topLeft = lastActiveScrolledRoot->GetOffsetToCrossDoc(mContainerReferenceFrame);
topLeft = lastAnimatedGeometryRoot->GetOffsetToCrossDoc(mContainerReferenceFrame);
}
int32_t maxLayers = nsDisplayItem::MaxActiveLayers();
@ -2118,17 +2118,17 @@ ContainerState::ProcessDisplayItems(const nsDisplayList& aList,
bool isFixed;
bool forceInactive;
const nsIFrame* activeScrolledRoot;
const nsIFrame* AnimatedGeometryRoot;
if (aFlags & NO_COMPONENT_ALPHA) {
forceInactive = true;
activeScrolledRoot = lastActiveScrolledRoot;
isFixed = mBuilder->IsFixedItem(item, nullptr, activeScrolledRoot);
AnimatedGeometryRoot = lastAnimatedGeometryRoot;
isFixed = mBuilder->IsFixedItem(item, nullptr, AnimatedGeometryRoot);
} else {
forceInactive = false;
isFixed = mBuilder->IsFixedItem(item, &activeScrolledRoot);
if (activeScrolledRoot != lastActiveScrolledRoot) {
lastActiveScrolledRoot = activeScrolledRoot;
topLeft = activeScrolledRoot->GetOffsetToCrossDoc(mContainerReferenceFrame);
isFixed = mBuilder->IsFixedItem(item, &AnimatedGeometryRoot);
if (AnimatedGeometryRoot != lastAnimatedGeometryRoot) {
lastAnimatedGeometryRoot = AnimatedGeometryRoot;
topLeft = AnimatedGeometryRoot->GetOffsetToCrossDoc(mContainerReferenceFrame);
}
}
@ -2264,7 +2264,7 @@ ContainerState::ProcessDisplayItems(const nsDisplayList& aList,
} else {
ThebesLayerData* data =
FindThebesLayerFor(item, itemVisibleRect, itemDrawRect, itemClip,
activeScrolledRoot, topLeft);
AnimatedGeometryRoot, topLeft);
data->mLayer->SetIsFixedPosition(isFixed);
@ -2344,7 +2344,7 @@ ContainerState::InvalidateForLayerChange(nsDisplayItem* aItem,
// If we do get an invalid rect, then we want to add this on top of the change areas.
nsRect invalid;
nsRegion combined;
nsPoint shift = aTopLeft - data->mLastActiveScrolledRootOrigin;
nsPoint shift = aTopLeft - data->mLastAnimatedGeometryRootOrigin;
if (!oldLayer) {
// This item is being added for the first time, invalidate its entire area.
//TODO: We call GetGeometry again in AddThebesDisplayItem, we should reuse this.
@ -2429,7 +2429,7 @@ FrameLayerBuilder::AddThebesDisplayItem(ThebesLayer* aLayer,
DisplayItemClip* oldClip = nullptr;
GetOldLayerFor(aItem, nullptr, &oldClip);
hasClip = aClip.ComputeRegionInClips(oldClip,
aTopLeft - thebesData->mLastActiveScrolledRootOrigin,
aTopLeft - thebesData->mLastAnimatedGeometryRootOrigin,
&clip);
if (hasClip) {

View File

@ -76,7 +76,7 @@ public:
* return it as a candidate for recycling.
*
* FrameLayerBuilder sets up ThebesLayers so that 0,0 in the Thebes layer
* corresponds to the (pixel-snapped) top-left of the aActiveScrolledRoot.
* corresponds to the (pixel-snapped) top-left of the aAnimatedGeometryRoot.
* It sets up ContainerLayers so that 0,0 in the container layer
* corresponds to the snapped top-left of the display item reference frame.
*

View File

@ -544,28 +544,28 @@ static bool IsFixedFrame(nsIFrame* aFrame)
bool
nsDisplayListBuilder::IsFixedItem(nsDisplayItem *aItem,
const nsIFrame** aActiveScrolledRoot,
const nsIFrame* aOverrideActiveScrolledRoot)
const nsIFrame** aAnimatedGeometryRoot,
const nsIFrame* aOverrideAnimatedGeometryRoot)
{
const nsIFrame* activeScrolledRoot = aOverrideActiveScrolledRoot;
if (!activeScrolledRoot) {
const nsIFrame* animatedGeometryRoot = aOverrideAnimatedGeometryRoot;
if (!animatedGeometryRoot) {
if (aItem->GetType() == nsDisplayItem::TYPE_SCROLL_LAYER) {
nsDisplayScrollLayer* scrollLayerItem =
static_cast<nsDisplayScrollLayer*>(aItem);
activeScrolledRoot =
nsLayoutUtils::GetActiveScrolledRootFor(scrollLayerItem->GetScrolledFrame(),
FindReferenceFrameFor(scrollLayerItem->GetScrolledFrame()));
animatedGeometryRoot =
nsLayoutUtils::GetAnimatedGeometryRootFor(scrollLayerItem->GetScrolledFrame(),
FindReferenceFrameFor(scrollLayerItem->GetScrolledFrame()));
} else {
activeScrolledRoot = nsLayoutUtils::GetActiveScrolledRootFor(aItem, this);
animatedGeometryRoot = nsLayoutUtils::GetAnimatedGeometryRootFor(aItem, this);
}
}
if (aActiveScrolledRoot) {
*aActiveScrolledRoot = activeScrolledRoot;
if (aAnimatedGeometryRoot) {
*aAnimatedGeometryRoot = animatedGeometryRoot;
}
return activeScrolledRoot &&
!nsLayoutUtils::IsScrolledByRootContentDocumentDisplayportScrolling(activeScrolledRoot, this);
return animatedGeometryRoot &&
!nsLayoutUtils::IsScrolledByRootContentDocumentDisplayportScrolling(animatedGeometryRoot, this);
}
static bool ForceVisiblityForFixedItem(nsDisplayListBuilder* aBuilder,
@ -2932,28 +2932,32 @@ void nsDisplayWrapList::Paint(nsDisplayListBuilder* aBuilder,
NS_ERROR("nsDisplayWrapList should have been flattened away for painting");
}
LayerState
nsDisplayWrapList::RequiredLayerStateForChildren(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
const ContainerParameters& aParameters,
const nsDisplayList& aList,
nsIFrame* aActiveScrolledRoot) {
static LayerState
RequiredLayerStateForChildrenInternal(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
const FrameLayerBuilder::ContainerParameters& aParameters,
const nsDisplayList& aList,
nsIFrame* aAnimatedGeometryRoot)
{
LayerState result = LAYER_INACTIVE;
for (nsDisplayItem* i = aList.GetBottom(); i; i = i->GetAbove()) {
nsIFrame* f = i->Frame();
nsIFrame* activeScrolledRoot =
nsLayoutUtils::GetActiveScrolledRootFor(f, nullptr);
if (activeScrolledRoot != aActiveScrolledRoot && result == LAYER_INACTIVE) {
if (result == LAYER_INACTIVE &&
nsLayoutUtils::GetAnimatedGeometryRootFor(f) != aAnimatedGeometryRoot) {
result = LAYER_ACTIVE;
}
LayerState state = i->GetLayerState(aBuilder, aManager, aParameters);
if ((state == LAYER_ACTIVE || state == LAYER_ACTIVE_FORCE) && (state > result))
if ((state == LAYER_ACTIVE || state == LAYER_ACTIVE_FORCE) &&
state > result) {
result = state;
}
if (state == LAYER_NONE) {
nsDisplayList* list = i->GetSameCoordinateSystemChildren();
if (list) {
LayerState childState = RequiredLayerStateForChildren(aBuilder, aManager, aParameters, *list, aActiveScrolledRoot);
LayerState childState =
RequiredLayerStateForChildrenInternal(aBuilder, aManager, aParameters, *list,
aAnimatedGeometryRoot);
if (childState > result) {
result = childState;
}
@ -2963,6 +2967,18 @@ nsDisplayWrapList::RequiredLayerStateForChildren(nsDisplayListBuilder* aBuilder,
return result;
}
LayerState
nsDisplayWrapList::RequiredLayerStateForChildren(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
const ContainerParameters& aParameters,
const nsDisplayList& aList,
nsIFrame* aItemFrame)
{
return RequiredLayerStateForChildrenInternal(
aBuilder, aManager, aParameters, aList,
nsLayoutUtils::GetAnimatedGeometryRootFor(aItemFrame));
}
nsRect nsDisplayWrapList::GetComponentAlphaBounds(nsDisplayListBuilder* aBuilder)
{
nsRect bounds;
@ -3112,9 +3128,7 @@ nsDisplayOpacity::GetLayerState(nsDisplayListBuilder* aBuilder,
return LAYER_ACTIVE;
}
}
nsIFrame* activeScrolledRoot =
nsLayoutUtils::GetActiveScrolledRootFor(mFrame, nullptr);
return RequiredLayerStateForChildren(aBuilder, aManager, aParameters, mList, activeScrolledRoot);
return RequiredLayerStateForChildren(aBuilder, aManager, aParameters, mList, mFrame);
}
bool
@ -3341,16 +3355,19 @@ nsDisplayFixedPosition::~nsDisplayFixedPosition() {
}
#endif
void nsDisplayFixedPosition::SetFixedPositionLayerData(Layer* const aLayer,
nsIFrame* aViewportFrame,
nsSize aViewportSize,
nsPresContext* aPresContext,
const ContainerParameters& aContainerParameters) {
/* static */ void
nsDisplayFixedPosition::SetFixedPositionLayerData(Layer* aLayer,
const nsIFrame* aViewportFrame,
nsSize aViewportSize,
const nsIFrame* aFixedPosFrame,
const nsIFrame* aReferenceFrame,
nsPresContext* aPresContext,
const ContainerParameters& aContainerParameters) {
// Find out the rect of the viewport frame relative to the reference frame.
// This, in conjunction with the container scale, will correspond to the
// coordinate-space of the built layer.
float factor = aPresContext->AppUnitsPerDevPixel();
nsPoint origin = aViewportFrame->GetOffsetToCrossDoc(ReferenceFrame());
nsPoint origin = aViewportFrame->GetOffsetToCrossDoc(aReferenceFrame);
LayerRect anchorRect(NSAppUnitsToFloatPixels(origin.x, factor) *
aContainerParameters.mXScale,
NSAppUnitsToFloatPixels(origin.y, factor) *
@ -3367,7 +3384,7 @@ void nsDisplayFixedPosition::SetFixedPositionLayerData(Layer* const aLayer,
// to the center.
LayerPoint anchor = anchorRect.TopLeft();
const nsStylePosition* position = mFixedPosFrame->StylePosition();
const nsStylePosition* position = aFixedPosFrame->StylePosition();
if (position->mOffset.GetRightUnit() != eStyleUnit_Auto) {
if (position->mOffset.GetLeftUnit() != eStyleUnit_Auto) {
anchor.x = anchorRect.x + anchorRect.width / 2.f;
@ -3430,7 +3447,8 @@ nsDisplayFixedPosition::BuildLayer(nsDisplayListBuilder* aBuilder,
GetScrollPositionClampingScrollPortSize();
}
SetFixedPositionLayerData(layer, viewportFrame, viewportSize, presContext,
SetFixedPositionLayerData(layer, viewportFrame, viewportSize, mFixedPosFrame,
ReferenceFrame(), presContext,
aContainerParameters);
return layer.forget();
@ -3488,7 +3506,9 @@ nsDisplayStickyPosition::BuildLayer(nsDisplayListBuilder* aBuilder,
GetScrollPositionClampingScrollPortSize();
}
SetFixedPositionLayerData(layer, scrollFrame, scrollFrameSize, presContext,
SetFixedPositionLayerData(layer, scrollFrame, scrollFrameSize,
mFixedPosFrame, ReferenceFrame(),
presContext,
aContainerParameters);
ViewID scrollId = nsLayoutUtils::FindOrCreateIDFor(
@ -4395,13 +4415,11 @@ nsDisplayTransform::GetLayerState(nsDisplayListBuilder* aBuilder,
return LAYER_ACTIVE;
}
}
nsIFrame* activeScrolledRoot =
nsLayoutUtils::GetActiveScrolledRootFor(mFrame, nullptr);
return mStoredList.RequiredLayerStateForChildren(aBuilder,
aManager,
aParameters,
*mStoredList.GetChildren(),
activeScrolledRoot);
mFrame);
}
bool nsDisplayTransform::ComputeVisibility(nsDisplayListBuilder *aBuilder,

View File

@ -370,15 +370,15 @@ public:
/**
* Determines if this item is scrolled by content-document display-port
* scrolling. aActiveScrolledRoot will be set to the active scrolled root
* of the item. This may not necessarily correspond to the active scrolled
* scrolling. aAnimatedGeometryRoot will be set to the animated geometry root
* of the item. This may not necessarily correspond to the animated geometry
* root of the item's underlying frame.
* If specified, aOverrideActiveScrolledRoot will be treated as the active
* If specified, aOverrideAnimatedGeometryRoot will be treated as the active
* scrolled root.
*/
bool IsFixedItem(nsDisplayItem* aItem,
const nsIFrame** aActiveScrolledRoot = nullptr,
const nsIFrame* aOverrideActiveScrolledRoot = nullptr);
const nsIFrame** aAnimatedGeometryRoot = nullptr,
const nsIFrame* aOverrideAnimatedGeometryScrolledRoot = nullptr);
/**
* @return true if images have been set to decode synchronously.
@ -2417,13 +2417,13 @@ public:
/**
* Returns true if all descendant display items can be placed in the same
* ThebesLayer --- GetLayerState returns LAYER_INACTIVE or LAYER_NONE,
* and they all have the given aActiveScrolledRoot.
* and they all have the given aAnimatedGeometryRoot.
*/
static LayerState RequiredLayerStateForChildren(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
const ContainerParameters& aParameters,
const nsDisplayList& aList,
nsIFrame* aActiveScrolledRoot);
nsIFrame* aItemFrame);
protected:
nsDisplayWrapList() {}
@ -2655,10 +2655,13 @@ public:
NS_DISPLAY_DECL_NAME("FixedPosition", TYPE_FIXED_POSITION)
static void SetFixedPositionLayerData(Layer* aLayer, const nsIFrame* aViewportFrame,
nsSize aViewportSize,
const nsIFrame* aFixedPosFrame,
const nsIFrame* aReferenceFrame,
nsPresContext* aPresContext,
const ContainerParameters& aContainerParameters);
protected:
void SetFixedPositionLayerData(Layer* const aLayer, nsIFrame* aViewportFrame,
nsSize aViewportSize, nsPresContext* aPresContext,
const ContainerParameters& aContainerParameters);
nsIFrame* mFixedPosFrame;
};

View File

@ -1199,8 +1199,8 @@ nsLayoutUtils::GetScrollableFrameFor(const nsIFrame *aScrolledFrame)
}
nsIFrame*
nsLayoutUtils::GetActiveScrolledRootFor(nsIFrame* aFrame,
const nsIFrame* aStopAtAncestor)
nsLayoutUtils::GetAnimatedGeometryRootFor(nsIFrame* aFrame,
const nsIFrame* aStopAtAncestor)
{
nsIFrame* f = aFrame;
nsIFrame* stickyFrame = nullptr;
@ -1245,18 +1245,11 @@ nsLayoutUtils::GetActiveScrolledRootFor(nsIFrame* aFrame,
}
nsIFrame*
nsLayoutUtils::GetActiveScrolledRootFor(nsDisplayItem* aItem,
nsDisplayListBuilder* aBuilder,
bool* aShouldFixToViewport)
nsLayoutUtils::GetAnimatedGeometryRootFor(nsDisplayItem* aItem,
nsDisplayListBuilder* aBuilder)
{
nsIFrame* f = aItem->Frame();
if (aShouldFixToViewport) {
*aShouldFixToViewport = false;
}
if (aItem->ShouldFixToViewport(aBuilder)) {
if (aShouldFixToViewport) {
*aShouldFixToViewport = true;
}
// Make its active scrolled root be the active scrolled root of
// the enclosing viewport, since it shouldn't be scrolled by scrolled
// frames in its document. InvalidateFixedBackgroundFramesFromList in
@ -1264,17 +1257,17 @@ nsLayoutUtils::GetActiveScrolledRootFor(nsDisplayItem* aItem,
nsIFrame* viewportFrame =
nsLayoutUtils::GetClosestFrameOfType(f, nsGkAtoms::viewportFrame);
NS_ASSERTION(viewportFrame, "no viewport???");
return nsLayoutUtils::GetActiveScrolledRootFor(viewportFrame, aBuilder->FindReferenceFrameFor(viewportFrame));
} else {
return nsLayoutUtils::GetActiveScrolledRootFor(f, aItem->ReferenceFrame());
return nsLayoutUtils::GetAnimatedGeometryRootFor(viewportFrame,
aBuilder->FindReferenceFrameFor(viewportFrame));
}
return nsLayoutUtils::GetAnimatedGeometryRootFor(f, aItem->ReferenceFrame());
}
bool
nsLayoutUtils::IsScrolledByRootContentDocumentDisplayportScrolling(const nsIFrame* aActiveScrolledRoot,
nsLayoutUtils::IsScrolledByRootContentDocumentDisplayportScrolling(const nsIFrame* aAnimatedGeometryRoot,
nsDisplayListBuilder* aBuilder)
{
nsPresContext* presContext = aActiveScrolledRoot->PresContext()->
nsPresContext* presContext = aAnimatedGeometryRoot->PresContext()->
GetToplevelContentDocumentPresContext();
if (!presContext)
return false;
@ -1282,7 +1275,7 @@ nsLayoutUtils::IsScrolledByRootContentDocumentDisplayportScrolling(const nsIFram
nsIFrame* rootScrollFrame = presContext->GetPresShell()->GetRootScrollFrame();
if (!rootScrollFrame || !nsLayoutUtils::GetDisplayPort(rootScrollFrame->GetContent(), nullptr))
return false;
return nsLayoutUtils::IsAncestorFrameCrossDoc(rootScrollFrame, aActiveScrolledRoot);
return nsLayoutUtils::IsAncestorFrameCrossDoc(rootScrollFrame, aAnimatedGeometryRoot);
}
// static

View File

@ -362,25 +362,34 @@ public:
const nsIFrame* aCommonAncestor = nullptr);
/**
* Finds the nearest ancestor frame that is the root of an "actively
* scrolled" frame subtree, or aStopAtAncestor if there is no
* such ancestor before we reach aStopAtAncestor in the ancestor chain.
* We expect frames with the same "active scrolled root" to be
* scrolled together, so we'll place them in the same ThebesLayer.
* Finds the nearest ancestor frame that is considered to have (or will have)
* "animated geometry". For example the scrolled frames of scrollframes which
* are actively being scrolled fall into this category. Frames with certain
* CSS properties that are being animated (e.g. 'left'/'top' etc) are also
* placed in this category. Frames with animated CSS transforms are not
* put in this category because they can be handled directly by
* nsDisplayTransform.
* Stop searching at aStopAtAncestor if there is no such ancestor before it
* in the ancestor chain.
* Frames with different active geometry roots are in different ThebesLayers,
* so that we can animate the geometry root by changing its transform (either
* on the main thread or in the compositor).
* This function is idempotent: a frame returned by GetAnimatedGeometryRootFor
* is always returned again if you pass it to GetAnimatedGeometryRootFor.
*/
static nsIFrame* GetActiveScrolledRootFor(nsIFrame* aFrame,
const nsIFrame* aStopAtAncestor);
static nsIFrame* GetAnimatedGeometryRootFor(nsIFrame* aFrame,
const nsIFrame* aStopAtAncestor = nullptr);
static nsIFrame* GetAnimatedGeometryRootFor(nsDisplayItem* aItem,
nsDisplayListBuilder* aBuilder);
static nsIFrame* GetActiveScrolledRootFor(nsDisplayItem* aItem,
nsDisplayListBuilder* aBuilder,
bool* aShouldFixToViewport = nullptr);
/**
* Returns true if aActiveScrolledRoot is in a content document,
* and its topmost content document ancestor has a root scroll frame with
* a displayport set, and aActiveScrolledRoot is scrolled by that scrollframe.
*/
static bool IsScrolledByRootContentDocumentDisplayportScrolling(const nsIFrame* aActiveScrolledRoot,
static bool IsScrolledByRootContentDocumentDisplayportScrolling(const nsIFrame* aAnimatedGeometryRoot,
nsDisplayListBuilder* aBuilder);
/**