Bug 919144. Part 8: Delete lots of code that's no longer needed. r=mattwoodrow

I never liked nsDisplayListBuilder::IsFixedItem anyway, its behavior and
naming was confusing. Also, it assumed there's only one viewport displayport,
on the rootmost document, and that's a bad assumption in general.
We're able to remove calls to ForceVisiblityForFixedItem because FrameLayerBuilder
is now responsible for inflating the visible region of the fixed-pos layers.

--HG--
extra : rebase_source : e93d8e25d2f5c7f3e167e47203d961e6b4293b81
This commit is contained in:
Robert O'Callahan 2013-09-27 18:01:16 +12:00
Родитель 145e514bf9
Коммит 94d3e5ce37
5 изменённых файлов: 7 добавлений и 163 удалений

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

@ -492,9 +492,6 @@ nsDisplayListBuilder::nsDisplayListBuilder(nsIFrame* aReferenceFrame,
mInTransform(false),
mSyncDecodeImages(false),
mIsPaintingToWindow(false),
mHasDisplayPort(false),
mHasFixedItems(false),
mIsInFixedPosition(false),
mIsCompositingCheap(false),
mContainsPluginItem(false),
mContainsBlendMode(false)
@ -513,13 +510,6 @@ nsDisplayListBuilder::nsDisplayListBuilder(nsIFrame* aReferenceFrame,
}
}
if(mReferenceFrame->GetType() == nsGkAtoms::viewportFrame) {
ViewportFrame* viewportFrame = static_cast<ViewportFrame*>(mReferenceFrame);
if (!viewportFrame->GetChildList(nsIFrame::kFixedList).IsEmpty()) {
mHasFixedItems = true;
}
}
nsCSSRendering::BeginFrameTreesLocked();
PR_STATIC_ASSERT(nsDisplayItem::TYPE_MAX < (1 << nsDisplayItem::TYPE_BITS));
}
@ -537,50 +527,6 @@ static void MarkFrameForDisplay(nsIFrame* aFrame, nsIFrame* aStopAtFrame) {
}
}
static bool IsFixedFrame(nsIFrame* aFrame)
{
return aFrame && aFrame->GetParent() && !aFrame->GetParent()->GetParent();
}
bool
nsDisplayListBuilder::IsFixedItem(nsDisplayItem *aItem,
const nsIFrame** aAnimatedGeometryRoot,
const nsIFrame* aOverrideAnimatedGeometryRoot)
{
const nsIFrame* animatedGeometryRoot = aOverrideAnimatedGeometryRoot;
if (!animatedGeometryRoot) {
if (aItem->GetType() == nsDisplayItem::TYPE_SCROLL_LAYER) {
nsDisplayScrollLayer* scrollLayerItem =
static_cast<nsDisplayScrollLayer*>(aItem);
animatedGeometryRoot =
nsLayoutUtils::GetAnimatedGeometryRootFor(scrollLayerItem->GetScrolledFrame(),
FindReferenceFrameFor(scrollLayerItem->GetScrolledFrame()));
} else {
animatedGeometryRoot = nsLayoutUtils::GetAnimatedGeometryRootFor(aItem, this);
}
}
if (aAnimatedGeometryRoot) {
*aAnimatedGeometryRoot = animatedGeometryRoot;
}
return animatedGeometryRoot &&
!nsLayoutUtils::IsScrolledByRootContentDocumentDisplayportScrolling(animatedGeometryRoot, this);
}
static bool ForceVisiblityForFixedItem(nsDisplayListBuilder* aBuilder,
nsDisplayItem* aItem)
{
return aBuilder->GetDisplayPort() && aBuilder->GetHasFixedItems() &&
aBuilder->IsFixedItem(aItem);
}
void nsDisplayListBuilder::SetDisplayPort(const nsRect& aDisplayPort)
{
mHasDisplayPort = true;
mDisplayPort = aDisplayPort;
}
void nsDisplayListBuilder::MarkOutOfFlowFrameForDisplay(nsIFrame* aDirtyFrame,
nsIFrame* aFrame,
const nsRect& aDirtyRect)
@ -1027,28 +973,6 @@ TreatAsOpaque(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder)
return opaqueClipped;
}
static nsRect
GetDisplayPortBounds(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem)
{
// GetDisplayPortBounds() rectangle is used in order to restrict fixed aItem's
// visible bounds. nsDisplayTransform bounds already take item's
// transform into account, so there is no need to apply it here one more time.
// Start TransformRectToBoundsInAncestor() calculations from aItem's frame
// parent in this case.
nsIFrame* frame = aItem->Frame();
if (aItem->GetType() == nsDisplayItem::TYPE_TRANSFORM) {
frame = nsLayoutUtils::GetCrossDocParentFrame(frame);
}
const nsRect* displayport = aBuilder->GetDisplayPort();
nsRect result = nsLayoutUtils::TransformAncestorRectToFrame(
frame,
nsRect(0, 0, displayport->width, displayport->height),
aBuilder->FindReferenceFrameFor(frame));
result.MoveBy(aBuilder->ToReferenceFrame(frame));
return result;
}
bool
nsDisplayList::ComputeVisibilityForSublist(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
@ -1094,11 +1018,7 @@ nsDisplayList::ComputeVisibilityForSublist(nsDisplayListBuilder* aBuilder,
nsRect bounds = item->GetClippedBounds(aBuilder);
nsRegion itemVisible;
if (ForceVisiblityForFixedItem(aBuilder, item)) {
itemVisible.And(GetDisplayPortBounds(aBuilder, item), bounds);
} else {
itemVisible.And(*aVisibleRegion, bounds);
}
item->mVisibleRect = itemVisible.GetBounds();
if (item->ComputeVisibility(aBuilder, aVisibleRegion,
@ -1601,11 +1521,7 @@ nsDisplayItem::RecomputeVisibility(nsDisplayListBuilder* aBuilder,
nsRect bounds = GetClippedBounds(aBuilder);
nsRegion itemVisible;
if (ForceVisiblityForFixedItem(aBuilder, this)) {
itemVisible.And(GetDisplayPortBounds(aBuilder, this), bounds);
} else {
itemVisible.And(*aVisibleRegion, bounds);
}
mVisibleRect = itemVisible.GetBounds();
// When we recompute visibility within layers we don't need to
@ -1668,22 +1584,9 @@ nsDisplayBackgroundImage::nsDisplayBackgroundImage(nsDisplayListBuilder* aBuilde
: nsDisplayImageContainer(aBuilder, aFrame)
, mBackgroundStyle(aBackgroundStyle)
, mLayer(aLayer)
, mIsBottommostLayer(true)
{
MOZ_COUNT_CTOR(nsDisplayBackgroundImage);
if (mBackgroundStyle) {
// Set HasFixedItems if we construct a background-attachment:fixed item
if (mLayer != mBackgroundStyle->mImageCount - 1) {
mIsBottommostLayer = false;
}
// Check if this background layer is attachment-fixed
if (mBackgroundStyle->mLayers[mLayer].mAttachment == NS_STYLE_BG_ATTACHMENT_FIXED) {
aBuilder->SetHasFixedItems();
}
}
mBounds = GetBoundsInternal(aBuilder);
}

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

@ -291,12 +291,6 @@ public:
bool AllowMergingAndFlattening() { return mAllowMergingAndFlattening; }
void SetAllowMergingAndFlattening(bool aAllow) { mAllowMergingAndFlattening = aAllow; }
/**
* @return Returns if the builder is currently building an
* nsDisplayFixedPosition sub-tree.
*/
bool IsInFixedPosition() const { return mIsInFixedPosition; }
bool SetIsCompositingCheap(bool aCompositingCheap) {
bool temp = mIsCompositingCheap;
mIsCompositingCheap = aCompositingCheap;
@ -354,20 +348,6 @@ public:
*/
void SetInTransform(bool aInTransform) { mInTransform = aInTransform; }
/**
* Call this if using display port for scrolling.
*/
void SetDisplayPort(const nsRect& aDisplayPort);
const nsRect* GetDisplayPort() { return mHasDisplayPort ? &mDisplayPort : nullptr; }
/**
* Call this if ReferenceFrame() is a viewport frame with fixed-position
* children, or when we construct an item which will return true from
* ShouldFixToViewport()
*/
void SetHasFixedItems() { mHasFixedItems = true; }
bool GetHasFixedItems() { return mHasFixedItems; }
/**
* Determines if this item is scrolled by content-document display-port
* scrolling. aAnimatedGeometryRoot will be set to the animated geometry root
@ -491,7 +471,7 @@ public:
/**
* A helper class to temporarily set the value of
* mIsAtRootOfPseudoStackingContext and mIsInFixedPosition, and temporarily
* mIsAtRootOfPseudoStackingContext, and temporarily
* update mCachedOffsetFrame/mCachedOffset from a frame to its child.
* Also saves and restores mClipState.
*/
@ -508,14 +488,13 @@ public:
aBuilder->mIsAtRootOfPseudoStackingContext = aIsRoot;
}
AutoBuildingDisplayList(nsDisplayListBuilder* aBuilder,
nsIFrame* aForChild, bool aIsRoot,
bool aIsInFixedPosition)
nsIFrame* aForChild, bool aIsRoot)
: mBuilder(aBuilder),
mPrevCachedOffsetFrame(aBuilder->mCachedOffsetFrame),
mPrevCachedReferenceFrame(aBuilder->mCachedReferenceFrame),
mPrevCachedOffset(aBuilder->mCachedOffset),
mPrevIsAtRootOfPseudoStackingContext(aBuilder->mIsAtRootOfPseudoStackingContext),
mPrevIsInFixedPosition(aBuilder->mIsInFixedPosition) {
mPrevIsAtRootOfPseudoStackingContext(aBuilder->mIsAtRootOfPseudoStackingContext)
{
if (aForChild->IsTransformed()) {
aBuilder->mCachedOffset = nsPoint();
aBuilder->mCachedReferenceFrame = aForChild;
@ -526,16 +505,12 @@ public:
}
aBuilder->mCachedOffsetFrame = aForChild;
aBuilder->mIsAtRootOfPseudoStackingContext = aIsRoot;
if (aIsInFixedPosition) {
aBuilder->mIsInFixedPosition = aIsInFixedPosition;
}
}
~AutoBuildingDisplayList() {
mBuilder->mCachedOffsetFrame = mPrevCachedOffsetFrame;
mBuilder->mCachedReferenceFrame = mPrevCachedReferenceFrame;
mBuilder->mCachedOffset = mPrevCachedOffset;
mBuilder->mIsAtRootOfPseudoStackingContext = mPrevIsAtRootOfPseudoStackingContext;
mBuilder->mIsInFixedPosition = mPrevIsInFixedPosition;
}
private:
nsDisplayListBuilder* mBuilder;
@ -543,7 +518,6 @@ public:
const nsIFrame* mPrevCachedReferenceFrame;
nsPoint mPrevCachedOffset;
bool mPrevIsAtRootOfPseudoStackingContext;
bool mPrevIsInFixedPosition;
};
/**
@ -663,7 +637,6 @@ private:
const nsIFrame* mCachedOffsetFrame;
const nsIFrame* mCachedReferenceFrame;
nsPoint mCachedOffset;
nsRect mDisplayPort;
nsRegion mExcludedGlassRegion;
// The display item for the Windows window glass background, if any
nsDisplayItem* mGlassDisplayItem;
@ -683,9 +656,6 @@ private:
bool mInTransform;
bool mSyncDecodeImages;
bool mIsPaintingToWindow;
bool mHasDisplayPort;
bool mHasFixedItems;
bool mIsInFixedPosition;
bool mIsCompositingCheap;
bool mContainsPluginItem;
bool mContainsBlendMode;
@ -2079,9 +2049,6 @@ protected:
/* Bounds of this display item */
nsRect mBounds;
uint32_t mLayer;
/* true if this item represents the bottom-most background layer */
bool mIsBottommostLayer;
};

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

@ -1293,21 +1293,6 @@ nsLayoutUtils::GetAnimatedGeometryRootFor(nsDisplayItem* aItem,
return nsLayoutUtils::GetAnimatedGeometryRootFor(f, aItem->ReferenceFrame());
}
bool
nsLayoutUtils::IsScrolledByRootContentDocumentDisplayportScrolling(const nsIFrame* aAnimatedGeometryRoot,
nsDisplayListBuilder* aBuilder)
{
nsPresContext* presContext = aAnimatedGeometryRoot->PresContext()->
GetToplevelContentDocumentPresContext();
if (!presContext)
return false;
nsIFrame* rootScrollFrame = presContext->GetPresShell()->GetRootScrollFrame();
if (!rootScrollFrame || !nsLayoutUtils::GetDisplayPort(rootScrollFrame->GetContent(), nullptr))
return false;
return nsLayoutUtils::IsAncestorFrameCrossDoc(rootScrollFrame, aAnimatedGeometryRoot);
}
// static
nsIScrollableFrame*
nsLayoutUtils::GetNearestScrollableFrameForDirection(nsIFrame* aFrame,
@ -2105,9 +2090,6 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
nsDisplayListBuilder builder(aFrame, nsDisplayListBuilder::PAINTING,
!(aFlags & PAINT_HIDE_CARET));
if (usingDisplayPort) {
builder.SetDisplayPort(displayport);
}
nsDisplayList list;
if (aFlags & PAINT_IN_TRANSFORM) {

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

@ -393,14 +393,6 @@ public:
nsDisplayListBuilder* aBuilder);
/**
* 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* aAnimatedGeometryRoot,
nsDisplayListBuilder* aBuilder);
/**
* GetScrollableFrameFor returns the scrollable frame for a scrolled frame
*/

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

@ -2172,7 +2172,7 @@ nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder,
"Stacking contexts must also be pseudo-stacking-contexts");
nsDisplayListBuilder::AutoBuildingDisplayList
buildingForChild(aBuilder, child, pseudoStackingContext, false);
buildingForChild(aBuilder, child, pseudoStackingContext);
DisplayListClipState::AutoClipMultiple clipState(aBuilder);
if (savedOutOfFlowData) {