Bug 1022612. Part 15: Add nsDisplayItem::GetVisibleRectForChildren(). r=mattwoodrow
This commit is contained in:
@@ -1044,6 +1044,15 @@ nsDisplayList::GetBounds(nsDisplayListBuilder* aBuilder) const {
|
|||||||
return bounds;
|
return bounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsRect
|
||||||
|
nsDisplayList::GetVisibleRect() const {
|
||||||
|
nsRect result;
|
||||||
|
for (nsDisplayItem* i = GetBottom(); i != nullptr; i = i->GetAbove()) {
|
||||||
|
result.UnionRect(result, i->GetVisibleRect());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
nsDisplayList::ComputeVisibilityForRoot(nsDisplayListBuilder* aBuilder,
|
nsDisplayList::ComputeVisibilityForRoot(nsDisplayListBuilder* aBuilder,
|
||||||
nsRegion* aVisibleRegion,
|
nsRegion* aVisibleRegion,
|
||||||
@@ -4315,12 +4324,15 @@ nsDisplayTransform::GetFrameBoundsForTransform(const nsIFrame* aFrame)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nsDisplayTransform::nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsIFrame *aFrame,
|
nsDisplayTransform::nsDisplayTransform(nsDisplayListBuilder* aBuilder,
|
||||||
nsDisplayList *aList, ComputeTransformFunction aTransformGetter,
|
nsIFrame *aFrame, nsDisplayList *aList,
|
||||||
|
const nsRect& aChildrenVisibleRect,
|
||||||
|
ComputeTransformFunction aTransformGetter,
|
||||||
uint32_t aIndex)
|
uint32_t aIndex)
|
||||||
: nsDisplayItem(aBuilder, aFrame)
|
: nsDisplayItem(aBuilder, aFrame)
|
||||||
, mStoredList(aBuilder, aFrame, aList)
|
, mStoredList(aBuilder, aFrame, aList)
|
||||||
, mTransformGetter(aTransformGetter)
|
, mTransformGetter(aTransformGetter)
|
||||||
|
, mChildrenVisibleRect(aChildrenVisibleRect)
|
||||||
, mIndex(aIndex)
|
, mIndex(aIndex)
|
||||||
{
|
{
|
||||||
MOZ_COUNT_CTOR(nsDisplayTransform);
|
MOZ_COUNT_CTOR(nsDisplayTransform);
|
||||||
@@ -4338,11 +4350,14 @@ nsDisplayTransform::SetReferenceFrameToAncestor(nsDisplayListBuilder* aBuilder)
|
|||||||
mVisibleRect = aBuilder->GetDirtyRect() + mToReferenceFrame;
|
mVisibleRect = aBuilder->GetDirtyRect() + mToReferenceFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsDisplayTransform::nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsIFrame *aFrame,
|
nsDisplayTransform::nsDisplayTransform(nsDisplayListBuilder* aBuilder,
|
||||||
nsDisplayList *aList, uint32_t aIndex)
|
nsIFrame *aFrame, nsDisplayList *aList,
|
||||||
|
const nsRect& aChildrenVisibleRect,
|
||||||
|
uint32_t aIndex)
|
||||||
: nsDisplayItem(aBuilder, aFrame)
|
: nsDisplayItem(aBuilder, aFrame)
|
||||||
, mStoredList(aBuilder, aFrame, aList)
|
, mStoredList(aBuilder, aFrame, aList)
|
||||||
, mTransformGetter(nullptr)
|
, mTransformGetter(nullptr)
|
||||||
|
, mChildrenVisibleRect(aChildrenVisibleRect)
|
||||||
, mIndex(aIndex)
|
, mIndex(aIndex)
|
||||||
{
|
{
|
||||||
MOZ_COUNT_CTOR(nsDisplayTransform);
|
MOZ_COUNT_CTOR(nsDisplayTransform);
|
||||||
@@ -4351,11 +4366,14 @@ nsDisplayTransform::nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsIFrame
|
|||||||
mStoredList.SetClip(aBuilder, DisplayItemClip::NoClip());
|
mStoredList.SetClip(aBuilder, DisplayItemClip::NoClip());
|
||||||
}
|
}
|
||||||
|
|
||||||
nsDisplayTransform::nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsIFrame *aFrame,
|
nsDisplayTransform::nsDisplayTransform(nsDisplayListBuilder* aBuilder,
|
||||||
nsDisplayItem *aItem, uint32_t aIndex)
|
nsIFrame *aFrame, nsDisplayItem *aItem,
|
||||||
|
const nsRect& aChildrenVisibleRect,
|
||||||
|
uint32_t aIndex)
|
||||||
: nsDisplayItem(aBuilder, aFrame)
|
: nsDisplayItem(aBuilder, aFrame)
|
||||||
, mStoredList(aBuilder, aFrame, aItem)
|
, mStoredList(aBuilder, aFrame, aItem)
|
||||||
, mTransformGetter(nullptr)
|
, mTransformGetter(nullptr)
|
||||||
|
, mChildrenVisibleRect(aChildrenVisibleRect)
|
||||||
, mIndex(aIndex)
|
, mIndex(aIndex)
|
||||||
{
|
{
|
||||||
MOZ_COUNT_CTOR(nsDisplayTransform);
|
MOZ_COUNT_CTOR(nsDisplayTransform);
|
||||||
|
|||||||
@@ -1083,7 +1083,7 @@ public:
|
|||||||
* @param aSnap set to true if the edges of the rectangles of the opaque
|
* @param aSnap set to true if the edges of the rectangles of the opaque
|
||||||
* region would be snapped to device pixels when drawing
|
* region would be snapped to device pixels when drawing
|
||||||
* @return a region of the item that is opaque --- that is, every pixel
|
* @return a region of the item that is opaque --- that is, every pixel
|
||||||
* that is visible (according to ComputeVisibility) is painted with an opaque
|
* that is visible is painted with an opaque
|
||||||
* color. This is useful for determining when one piece
|
* color. This is useful for determining when one piece
|
||||||
* of content completely obscures another so that we can do occlusion
|
* of content completely obscures another so that we can do occlusion
|
||||||
* culling.
|
* culling.
|
||||||
@@ -1270,10 +1270,17 @@ public:
|
|||||||
virtual nsDisplayList* GetChildren() { return nullptr; }
|
virtual nsDisplayList* GetChildren() { return nullptr; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the visible rect. Should only be called after ComputeVisibility
|
* Returns the visible rect.
|
||||||
* has happened.
|
|
||||||
*/
|
*/
|
||||||
const nsRect& GetVisibleRect() { return mVisibleRect; }
|
const nsRect& GetVisibleRect() const { return mVisibleRect; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the visible rect for the children, relative to their
|
||||||
|
* reference frame. Can be different from mVisibleRect for nsDisplayTransform,
|
||||||
|
* since the reference frame for the children is different from the reference
|
||||||
|
* frame for the item itself.
|
||||||
|
*/
|
||||||
|
virtual const nsRect& GetVisibleRectForChildren() const { return mVisibleRect; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the given opacity value to be applied when drawing. Returns
|
* Stores the given opacity value to be applied when drawing. Returns
|
||||||
@@ -1685,6 +1692,11 @@ public:
|
|||||||
void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
||||||
nsDisplayItem::HitTestState* aState,
|
nsDisplayItem::HitTestState* aState,
|
||||||
nsTArray<nsIFrame*> *aOutFrames) const;
|
nsTArray<nsIFrame*> *aOutFrames) const;
|
||||||
|
/**
|
||||||
|
* Compute the union of the visible rects of the items in the list. The
|
||||||
|
* result is not cached.
|
||||||
|
*/
|
||||||
|
nsRect GetVisibleRect() const;
|
||||||
|
|
||||||
#if defined(DEBUG) || defined(MOZ_DUMP_PAINTING)
|
#if defined(DEBUG) || defined(MOZ_DUMP_PAINTING)
|
||||||
bool DidComputeVisibility() const { return mDidComputeVisibility; }
|
bool DidComputeVisibility() const { return mDidComputeVisibility; }
|
||||||
@@ -1705,8 +1717,6 @@ public:
|
|||||||
mForceTransparentSurface = true;
|
mForceTransparentSurface = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsRect GetVisibleRect() const { return mVisibleRect; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// This class is only used on stack, so we don't have to worry about leaking
|
// This class is only used on stack, so we don't have to worry about leaking
|
||||||
// it. Don't let us be heap-allocated!
|
// it. Don't let us be heap-allocated!
|
||||||
@@ -2985,7 +2995,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* This potentially creates a layer for the given list of items, whose
|
* This potentially creates a layer for the given list of items, whose
|
||||||
* visibility is determined by the displayport for the given frame instead of
|
* visibility is determined by the displayport for the given frame instead of
|
||||||
* what is passed in to ComputeVisibility.
|
* normal visibility computation.
|
||||||
*
|
*
|
||||||
* Here in content, we can use this to render more content than is actually
|
* Here in content, we can use this to render more content than is actually
|
||||||
* visible. Then, the compositing process can manipulate the generated layer
|
* visible. Then, the compositing process can manipulate the generated layer
|
||||||
@@ -3245,11 +3255,14 @@ public:
|
|||||||
* ferries the underlying frame to the nsDisplayItem constructor.
|
* ferries the underlying frame to the nsDisplayItem constructor.
|
||||||
*/
|
*/
|
||||||
nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsIFrame *aFrame,
|
nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsIFrame *aFrame,
|
||||||
nsDisplayList *aList, uint32_t aIndex = 0);
|
nsDisplayList *aList, const nsRect& aChildrenVisibleRect,
|
||||||
|
uint32_t aIndex = 0);
|
||||||
nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsIFrame *aFrame,
|
nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsIFrame *aFrame,
|
||||||
nsDisplayItem *aItem, uint32_t aIndex = 0);
|
nsDisplayItem *aItem, const nsRect& aChildrenVisibleRect,
|
||||||
|
uint32_t aIndex = 0);
|
||||||
nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsIFrame *aFrame,
|
nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsIFrame *aFrame,
|
||||||
nsDisplayList *aList, ComputeTransformFunction aTransformGetter, uint32_t aIndex = 0);
|
nsDisplayList *aList, const nsRect& aChildrenVisibleRect,
|
||||||
|
ComputeTransformFunction aTransformGetter, uint32_t aIndex = 0);
|
||||||
|
|
||||||
#ifdef NS_BUILD_REFCNT_LOGGING
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
||||||
virtual ~nsDisplayTransform()
|
virtual ~nsDisplayTransform()
|
||||||
@@ -3307,6 +3320,11 @@ public:
|
|||||||
return nsDisplayItem::ReferenceFrameForChildren();
|
return nsDisplayItem::ReferenceFrameForChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual const nsRect& GetVisibleRectForChildren() const MOZ_OVERRIDE
|
||||||
|
{
|
||||||
|
return mChildrenVisibleRect;
|
||||||
|
}
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
INDEX_MAX = UINT32_MAX >> nsDisplayItem::TYPE_BITS
|
INDEX_MAX = UINT32_MAX >> nsDisplayItem::TYPE_BITS
|
||||||
};
|
};
|
||||||
@@ -3454,6 +3472,7 @@ private:
|
|||||||
nsDisplayWrapList mStoredList;
|
nsDisplayWrapList mStoredList;
|
||||||
gfx3DMatrix mTransform;
|
gfx3DMatrix mTransform;
|
||||||
ComputeTransformFunction mTransformGetter;
|
ComputeTransformFunction mTransformGetter;
|
||||||
|
nsRect mChildrenVisibleRect;
|
||||||
uint32_t mIndex;
|
uint32_t mIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -2323,7 +2323,7 @@ nsLayoutUtils::GetLayerTransformForFrame(nsIFrame* aFrame,
|
|||||||
false/*don't build caret*/);
|
false/*don't build caret*/);
|
||||||
nsDisplayList list;
|
nsDisplayList list;
|
||||||
nsDisplayTransform* item =
|
nsDisplayTransform* item =
|
||||||
new (&builder) nsDisplayTransform(&builder, aFrame, &list);
|
new (&builder) nsDisplayTransform(&builder, aFrame, &list, nsRect());
|
||||||
|
|
||||||
*aTransform =
|
*aTransform =
|
||||||
item->GetTransform();
|
item->GetTransform();
|
||||||
|
|||||||
@@ -1737,7 +1737,9 @@ DisplayDebugBorders(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static nsresult
|
static nsresult
|
||||||
WrapPreserve3DListInternal(nsIFrame* aFrame, nsDisplayListBuilder *aBuilder, nsDisplayList *aList, nsDisplayList *aOutput, uint32_t& aIndex, nsDisplayList* aTemp)
|
WrapPreserve3DListInternal(nsIFrame* aFrame, nsDisplayListBuilder *aBuilder,
|
||||||
|
nsDisplayList *aList, nsDisplayList *aOutput,
|
||||||
|
uint32_t& aIndex, nsDisplayList* aTemp)
|
||||||
{
|
{
|
||||||
if (aIndex > nsDisplayTransform::INDEX_MAX) {
|
if (aIndex > nsDisplayTransform::INDEX_MAX) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@@ -1756,7 +1758,8 @@ WrapPreserve3DListInternal(nsIFrame* aFrame, nsDisplayListBuilder *aBuilder, nsD
|
|||||||
switch (item->GetType()) {
|
switch (item->GetType()) {
|
||||||
case nsDisplayItem::TYPE_TRANSFORM: {
|
case nsDisplayItem::TYPE_TRANSFORM: {
|
||||||
if (!aTemp->IsEmpty()) {
|
if (!aTemp->IsEmpty()) {
|
||||||
aOutput->AppendToTop(new (aBuilder) nsDisplayTransform(aBuilder, aFrame, aTemp, aIndex++));
|
aOutput->AppendToTop(new (aBuilder) nsDisplayTransform(aBuilder,
|
||||||
|
aFrame, aTemp, aTemp->GetVisibleRect(), aIndex++));
|
||||||
}
|
}
|
||||||
// Override item's clipping with our current clip state (if any). Since we're
|
// Override item's clipping with our current clip state (if any). Since we're
|
||||||
// bubbling up a preserve-3d transformed child to a preserve-3d parent,
|
// bubbling up a preserve-3d transformed child to a preserve-3d parent,
|
||||||
@@ -1778,7 +1781,8 @@ WrapPreserve3DListInternal(nsIFrame* aFrame, nsDisplayListBuilder *aBuilder, nsD
|
|||||||
}
|
}
|
||||||
case nsDisplayItem::TYPE_OPACITY: {
|
case nsDisplayItem::TYPE_OPACITY: {
|
||||||
if (!aTemp->IsEmpty()) {
|
if (!aTemp->IsEmpty()) {
|
||||||
aOutput->AppendToTop(new (aBuilder) nsDisplayTransform(aBuilder, aFrame, aTemp, aIndex++));
|
aOutput->AppendToTop(new (aBuilder) nsDisplayTransform(aBuilder,
|
||||||
|
aFrame, aTemp, aTemp->GetVisibleRect(), aIndex++));
|
||||||
}
|
}
|
||||||
nsDisplayOpacity *opacity = static_cast<nsDisplayOpacity*>(item);
|
nsDisplayOpacity *opacity = static_cast<nsDisplayOpacity*>(item);
|
||||||
nsDisplayList output;
|
nsDisplayList output;
|
||||||
@@ -1788,7 +1792,8 @@ WrapPreserve3DListInternal(nsIFrame* aFrame, nsDisplayListBuilder *aBuilder, nsD
|
|||||||
rv = WrapPreserve3DListInternal(aFrame, aBuilder,
|
rv = WrapPreserve3DListInternal(aFrame, aBuilder,
|
||||||
opacity->GetChildren(), &output, aIndex, aTemp);
|
opacity->GetChildren(), &output, aIndex, aTemp);
|
||||||
if (!aTemp->IsEmpty()) {
|
if (!aTemp->IsEmpty()) {
|
||||||
output.AppendToTop(new (aBuilder) nsDisplayTransform(aBuilder, aFrame, aTemp, aIndex++));
|
output.AppendToTop(new (aBuilder) nsDisplayTransform(aBuilder,
|
||||||
|
aFrame, aTemp, aTemp->GetVisibleRect(), aIndex++));
|
||||||
}
|
}
|
||||||
opacity->GetChildren()->AppendToTop(&output);
|
opacity->GetChildren()->AppendToTop(&output);
|
||||||
opacity->UpdateBounds(aBuilder);
|
opacity->UpdateBounds(aBuilder);
|
||||||
@@ -1798,10 +1803,12 @@ WrapPreserve3DListInternal(nsIFrame* aFrame, nsDisplayListBuilder *aBuilder, nsD
|
|||||||
default: {
|
default: {
|
||||||
if (childFrame->StyleDisplay()->BackfaceIsHidden()) {
|
if (childFrame->StyleDisplay()->BackfaceIsHidden()) {
|
||||||
if (!aTemp->IsEmpty()) {
|
if (!aTemp->IsEmpty()) {
|
||||||
aOutput->AppendToTop(new (aBuilder) nsDisplayTransform(aBuilder, aFrame, aTemp, aIndex++));
|
aOutput->AppendToTop(new (aBuilder) nsDisplayTransform(aBuilder,
|
||||||
|
aFrame, aTemp, aTemp->GetVisibleRect(), aIndex++));
|
||||||
}
|
}
|
||||||
|
|
||||||
aOutput->AppendToTop(new (aBuilder) nsDisplayTransform(aBuilder, childFrame, item, aIndex++));
|
aOutput->AppendToTop(new (aBuilder) nsDisplayTransform(aBuilder,
|
||||||
|
childFrame, item, item->GetVisibleRect(), aIndex++));
|
||||||
} else {
|
} else {
|
||||||
aTemp->AppendToTop(item);
|
aTemp->AppendToTop(item);
|
||||||
}
|
}
|
||||||
@@ -1826,15 +1833,18 @@ IsScrollFrameActive(nsIScrollableFrame* aScrollableFrame)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static nsresult
|
static nsresult
|
||||||
WrapPreserve3DList(nsIFrame* aFrame, nsDisplayListBuilder* aBuilder, nsDisplayList *aList)
|
WrapPreserve3DList(nsIFrame* aFrame, nsDisplayListBuilder* aBuilder,
|
||||||
|
nsDisplayList *aList)
|
||||||
{
|
{
|
||||||
uint32_t index = 0;
|
uint32_t index = 0;
|
||||||
nsDisplayList temp;
|
nsDisplayList temp;
|
||||||
nsDisplayList output;
|
nsDisplayList output;
|
||||||
nsresult rv = WrapPreserve3DListInternal(aFrame, aBuilder, aList, &output, index, &temp);
|
nsresult rv = WrapPreserve3DListInternal(aFrame, aBuilder, aList, &output,
|
||||||
|
index, &temp);
|
||||||
|
|
||||||
if (!temp.IsEmpty()) {
|
if (!temp.IsEmpty()) {
|
||||||
output.AppendToTop(new (aBuilder) nsDisplayTransform(aBuilder, aFrame, &temp, index++));
|
output.AppendToTop(new (aBuilder) nsDisplayTransform(aBuilder, aFrame,
|
||||||
|
&temp, temp.GetVisibleRect(), index++));
|
||||||
}
|
}
|
||||||
|
|
||||||
aList->AppendToTop(&output);
|
aList->AppendToTop(&output);
|
||||||
@@ -2096,7 +2106,7 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder,
|
|||||||
WrapPreserve3DList(this, aBuilder, &resultList);
|
WrapPreserve3DList(this, aBuilder, &resultList);
|
||||||
} else {
|
} else {
|
||||||
resultList.AppendNewToTop(
|
resultList.AppendNewToTop(
|
||||||
new (aBuilder) nsDisplayTransform(aBuilder, this, &resultList));
|
new (aBuilder) nsDisplayTransform(aBuilder, this, &resultList, dirtyRect));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -531,7 +531,8 @@ nsPageFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|||||||
*aBuilder, content, child, backgroundRect, NS_RGBA(0,0,0,0));
|
*aBuilder, content, child, backgroundRect, NS_RGBA(0,0,0,0));
|
||||||
}
|
}
|
||||||
|
|
||||||
content.AppendNewToTop(new (aBuilder) nsDisplayTransform(aBuilder, child, &content, ::ComputePageTransform));
|
content.AppendNewToTop(new (aBuilder) nsDisplayTransform(aBuilder, child,
|
||||||
|
&content, content.GetVisibleRect(), ::ComputePageTransform));
|
||||||
|
|
||||||
set.Content()->AppendToTop(&content);
|
set.Content()->AppendToTop(&content);
|
||||||
|
|
||||||
|
|||||||
@@ -797,7 +797,8 @@ nsSimplePageSequenceFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|||||||
}
|
}
|
||||||
|
|
||||||
content.AppendNewToTop(new (aBuilder)
|
content.AppendNewToTop(new (aBuilder)
|
||||||
nsDisplayTransform(aBuilder, this, &content, ::ComputePageSequenceTransform));
|
nsDisplayTransform(aBuilder, this, &content, content.GetVisibleRect(),
|
||||||
|
::ComputePageSequenceTransform));
|
||||||
|
|
||||||
aLists.Content()->AppendToTop(&content);
|
aLists.Content()->AppendToTop(&content);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user