Bug 1166301 - Annotate fixed background layers with scroll metadata for the animated geometry root of the frame they're the background of. r=mattwoodrow

--HG--
extra : rebase_source : 0d62774bfb83070d0503ff5156bb93adc196a7de
extra : source : e90b6ffe53f1b093ca92ca39df32d873d3144704
This commit is contained in:
Botond Ballo 2015-08-26 18:16:51 -04:00
Родитель d726dc2234
Коммит 66ecf4ccdd
1 изменённых файлов: 32 добавлений и 1 удалений

Просмотреть файл

@ -500,6 +500,10 @@ public:
* active scrolled root.
*/
const nsIFrame* mAnimatedGeometryRoot;
/**
* See NewLayerEntry::mAnimatedGeometryRootForScrollMetadata.
*/
const nsIFrame* mAnimatedGeometryRootForScrollMetadata;
/**
* The offset between mAnimatedGeometryRoot and the reference frame.
*/
@ -619,6 +623,7 @@ public:
struct NewLayerEntry {
NewLayerEntry()
: mAnimatedGeometryRoot(nullptr)
, mAnimatedGeometryRootForScrollMetadata(nullptr)
, mFixedPosFrameForLayerData(nullptr)
, mLayerContentsVisibleRect(0, 0, -1, -1)
, mHideAllLayersBelow(false)
@ -630,6 +635,12 @@ struct NewLayerEntry {
// been optimized to some other form (yet).
nsRefPtr<Layer> mLayer;
const nsIFrame* mAnimatedGeometryRoot;
// For fixed background layers, mAnimatedGeometryRoot is the animated geometry
// root of the viewport frame it's fixed to, but we need to annotate it with
// scroll metadata starting from the animated geometry root of the element
// it's the background of, so that during async scrolling we can correctly
// transform the fixed layer's clip.
const nsIFrame* mAnimatedGeometryRootForScrollMetadata;
const nsIFrame* mFixedPosFrameForLayerData;
// If non-null, this FrameMetrics is set to the be the first FrameMetrics
// on the layer.
@ -1263,6 +1274,10 @@ protected:
* @param aItem The item that is going to be added.
* @param aVisibleRect The visible rect of the item.
* @param aAnimatedGeometryRoot The item's animated geometry root.
* @param aAnimatedGeometryRootForScrollMetadata
* The animated geometry root to be used as
* the starting point in SetupScrollMetadata().
* See NewLayerEntry::mAnimatedGeometryRootForScrollMetadata.
* @param aTopLeft The offset between aAnimatedGeometryRoot and
* the reference frame.
* @param aShouldFixToViewport If true, aAnimatedGeometryRoot is the
@ -1273,6 +1288,7 @@ protected:
PaintedLayerData NewPaintedLayerData(nsDisplayItem* aItem,
const nsIntRect& aVisibleRect,
const nsIFrame* aAnimatedGeometryRoot,
const nsIFrame* aAnimatedGeometryRootForScrollMetadata,
const nsPoint& aTopLeft,
bool aShouldFixToViewport);
@ -3087,6 +3103,7 @@ void ContainerState::FinishPaintedLayerData(PaintedLayerData& aData, FindOpaqueB
NS_ASSERTION(!newLayerEntry->mLayer, "Slot already occupied?");
newLayerEntry->mLayer = layer;
newLayerEntry->mAnimatedGeometryRoot = data->mAnimatedGeometryRoot;
newLayerEntry->mAnimatedGeometryRootForScrollMetadata = data->mAnimatedGeometryRootForScrollMetadata;
newLayerEntry->mFixedPosFrameForLayerData = data->mFixedPosFrameForLayerData;
newLayerEntry->mIsCaret = data->mIsCaret;
@ -3460,11 +3477,13 @@ PaintedLayerData
ContainerState::NewPaintedLayerData(nsDisplayItem* aItem,
const nsIntRect& aVisibleRect,
const nsIFrame* aAnimatedGeometryRoot,
const nsIFrame* aAnimatedGeometryRootForScrollMetadata,
const nsPoint& aTopLeft,
bool aShouldFixToViewport)
{
PaintedLayerData data;
data.mAnimatedGeometryRoot = aAnimatedGeometryRoot;
data.mAnimatedGeometryRootForScrollMetadata = aAnimatedGeometryRootForScrollMetadata;
data.mAnimatedGeometryRootOffset = aTopLeft;
data.mFixedPosFrameForLayerData =
FindFixedPosFrameForLayerData(aAnimatedGeometryRoot, aShouldFixToViewport);
@ -3475,6 +3494,7 @@ ContainerState::NewPaintedLayerData(nsDisplayItem* aItem,
data.mNewChildLayersIndex = mNewChildLayers.Length();
NewLayerEntry* newLayerEntry = mNewChildLayers.AppendElement();
newLayerEntry->mAnimatedGeometryRoot = aAnimatedGeometryRoot;
newLayerEntry->mAnimatedGeometryRootForScrollMetadata = aAnimatedGeometryRootForScrollMetadata;
newLayerEntry->mFixedPosFrameForLayerData = data.mFixedPosFrameForLayerData;
newLayerEntry->mIsCaret = data.mIsCaret;
// newLayerEntry->mOpaqueRegion is filled in later from
@ -3754,6 +3774,7 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList)
bool forceInactive;
const nsIFrame* animatedGeometryRoot;
const nsIFrame* animatedGeometryRootForScrollMetadata = nullptr;
const nsIFrame* realAnimatedGeometryRootOfItem =
nsLayoutUtils::GetAnimatedGeometryRootFor(item, mBuilder, mManager);
if (mFlattenToSingleLayer) {
@ -3763,6 +3784,11 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList)
forceInactive = false;
if (mManager->IsWidgetLayerManager()) {
animatedGeometryRoot = realAnimatedGeometryRootOfItem;
// Unlike GetAnimatedGeometryRootFor(), GetAnimatedGeometryRootForFrame() does not
// take ShouldFixToViewport() into account, so it will return something different
// for fixed background items.
animatedGeometryRootForScrollMetadata = nsLayoutUtils::GetAnimatedGeometryRootForFrame(
mBuilder, item->Frame(), item->ReferenceFrame());
} else {
// For inactive layer subtrees, splitting content into PaintedLayers
// based on animated geometry roots is pointless. It's more efficient
@ -3775,6 +3801,9 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList)
topLeft = animatedGeometryRoot->GetOffsetToCrossDoc(mContainerReferenceFrame);
}
}
if (!animatedGeometryRootForScrollMetadata) {
animatedGeometryRootForScrollMetadata = animatedGeometryRoot;
}
nsDisplayItem::Type itemType = item->GetType();
@ -3971,6 +4000,7 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList)
NewLayerEntry* newLayerEntry = mNewChildLayers.AppendElement();
newLayerEntry->mLayer = ownLayer;
newLayerEntry->mAnimatedGeometryRoot = animatedGeometryRoot;
newLayerEntry->mAnimatedGeometryRootForScrollMetadata = animatedGeometryRootForScrollMetadata;
newLayerEntry->mFixedPosFrameForLayerData = fixedPosFrame;
// Don't attempt to flatten compnent alpha layers that are within
@ -4024,6 +4054,7 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList)
mPaintedLayerDataTree.FindPaintedLayerFor(animatedGeometryRoot, itemVisibleRect,
forceOwnLayer, [&]() {
return NewPaintedLayerData(item, itemVisibleRect, animatedGeometryRoot,
animatedGeometryRootForScrollMetadata,
topLeft, shouldFixToViewport);
});
@ -4512,7 +4543,7 @@ ContainerState::SetupScrollingMetadata(NewLayerEntry* aEntry)
nsTArray<nsRefPtr<Layer>> maskLayers;
nsIFrame* fParent;
for (const nsIFrame* f = aEntry->mAnimatedGeometryRoot;
for (const nsIFrame* f = aEntry->mAnimatedGeometryRootForScrollMetadata;
f != mContainerAnimatedGeometryRoot;
f = nsLayoutUtils::GetAnimatedGeometryRootForFrame(this->mBuilder,
fParent, mContainerAnimatedGeometryRoot)) {