Bug 626602. Part 4: Make the display items behind a plugin that needs readback be as visible as we can. r=tnikkel

This commit is contained in:
Robert O'Callahan 2011-02-08 18:44:13 -06:00
Родитель d02ac93bf2
Коммит 4c3aa706a8
5 изменённых файлов: 77 добавлений и 10 удалений

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

@ -375,7 +375,7 @@ nsDisplayList::ComputeVisibilityForRoot(nsDisplayListBuilder* aBuilder,
r.And(*aVisibleRegion, GetBounds(aBuilder));
PRBool notUsed;
return ComputeVisibilityForSublist(aBuilder, aVisibleRegion,
r.GetBounds(), notUsed);
r.GetBounds(), r.GetBounds(), notUsed);
}
static nsRegion
@ -397,6 +397,7 @@ PRBool
nsDisplayList::ComputeVisibilityForSublist(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aListVisibleBounds,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG) {
#ifdef DEBUG
nsRegion r;
@ -429,7 +430,7 @@ nsDisplayList::ComputeVisibilityForSublist(nsDisplayListBuilder* aBuilder,
item->mVisibleRect = itemVisible.GetBounds();
PRBool containsRootContentDocBG = PR_FALSE;
if (item->ComputeVisibility(aBuilder, aVisibleRegion,
if (item->ComputeVisibility(aBuilder, aVisibleRegion, aAllowVisibleRegionExpansion,
containsRootContentDocBG)) {
if (containsRootContentDocBG) {
aContainsRootContentDocBG = PR_TRUE;
@ -744,8 +745,11 @@ PRBool nsDisplayItem::RecomputeVisibility(nsDisplayListBuilder* aBuilder,
itemVisible.And(*aVisibleRegion, bounds);
mVisibleRect = itemVisible.GetBounds();
// When we recompute visibility within layers we don't need to
// expand the visible region for content behind plugins (the plugin
// is not in the layer).
PRBool notUsed;
if (!ComputeVisibility(aBuilder, aVisibleRegion, notUsed))
if (!ComputeVisibility(aBuilder, aVisibleRegion, nsRect(), notUsed))
return PR_FALSE;
PRBool forceTransparentBackground;
@ -763,9 +767,11 @@ void nsDisplaySolidColor::Paint(nsDisplayListBuilder* aBuilder,
PRBool
nsDisplaySolidColor::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG)
{
PRBool retval = nsDisplayItem::ComputeVisibility(aBuilder, aVisibleRegion,
aAllowVisibleRegionExpansion,
aContainsRootContentDocBG);
if (retval && IsRootContentDocBackground()) {
aContainsRootContentDocBG = PR_TRUE;
@ -923,9 +929,11 @@ nsDisplayBackground::HitTest(nsDisplayListBuilder* aBuilder,
PRBool
nsDisplayBackground::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG)
{
if (!nsDisplayItem::ComputeVisibility(aBuilder, aVisibleRegion,
aAllowVisibleRegionExpansion,
aContainsRootContentDocBG)) {
return PR_FALSE;
}
@ -1198,8 +1206,10 @@ nsDisplayOutline::Paint(nsDisplayListBuilder* aBuilder,
PRBool
nsDisplayOutline::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG) {
if (!nsDisplayItem::ComputeVisibility(aBuilder, aVisibleRegion,
aAllowVisibleRegionExpansion,
aContainsRootContentDocBG)) {
return PR_FALSE;
}
@ -1243,8 +1253,10 @@ nsDisplayCaret::Paint(nsDisplayListBuilder* aBuilder,
PRBool
nsDisplayBorder::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG) {
if (!nsDisplayItem::ComputeVisibility(aBuilder, aVisibleRegion,
aAllowVisibleRegionExpansion,
aContainsRootContentDocBG)) {
return PR_FALSE;
}
@ -1342,8 +1354,10 @@ nsDisplayBoxShadowOuter::GetBounds(nsDisplayListBuilder* aBuilder) {
PRBool
nsDisplayBoxShadowOuter::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG) {
if (!nsDisplayItem::ComputeVisibility(aBuilder, aVisibleRegion,
aAllowVisibleRegionExpansion,
aContainsRootContentDocBG)) {
return PR_FALSE;
}
@ -1388,8 +1402,10 @@ nsDisplayBoxShadowInner::Paint(nsDisplayListBuilder* aBuilder,
PRBool
nsDisplayBoxShadowInner::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG) {
if (!nsDisplayItem::ComputeVisibility(aBuilder, aVisibleRegion,
aAllowVisibleRegionExpansion,
aContainsRootContentDocBG)) {
return PR_FALSE;
}
@ -1429,9 +1445,11 @@ nsDisplayWrapList::GetBounds(nsDisplayListBuilder* aBuilder) {
PRBool
nsDisplayWrapList::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG) {
return mList.ComputeVisibilityForSublist(aBuilder, aVisibleRegion,
mVisibleRect,
aAllowVisibleRegionExpansion,
aContainsRootContentDocBG);
}
@ -1618,6 +1636,7 @@ nsDisplayOpacity::GetLayerState(nsDisplayListBuilder* aBuilder,
PRBool nsDisplayOpacity::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG) {
// Our children are translucent so we should not allow them to subtract
// area from aVisibleRegion. We do need to find out what is visible under
@ -1630,9 +1649,11 @@ PRBool nsDisplayOpacity::ComputeVisibility(nsDisplayListBuilder* aBuilder,
// do not pass up the aContainsRootContentDocBG value because anything under
// us is not opaque
PRBool notUsed;
nsRect allowExpansion;
allowExpansion.IntersectRect(bounds, aAllowVisibleRegionExpansion);
return
nsDisplayWrapList::ComputeVisibility(aBuilder, &visibleUnderChildren,
notUsed);
allowExpansion, notUsed);
}
PRBool nsDisplayOpacity::TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem) {
@ -1708,6 +1729,7 @@ nsDisplayScrollLayer::BuildLayer(nsDisplayListBuilder* aBuilder,
PRBool
nsDisplayScrollLayer::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG)
{
nsPresContext* presContext = mFrame->PresContext();
@ -1722,14 +1744,17 @@ nsDisplayScrollLayer::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRect boundedRect;
boundedRect.IntersectRect(childVisibleRegion.GetBounds(), mList.GetBounds(aBuilder));
nsRect allowExpansion;
allowExpansion.IntersectRect(allowExpansion, boundedRect);
PRBool visible = mList.ComputeVisibilityForSublist(
aBuilder, &childVisibleRegion, boundedRect, aContainsRootContentDocBG);
aBuilder, &childVisibleRegion, boundedRect, allowExpansion, aContainsRootContentDocBG);
mVisibleRect = boundedRect;
return visible;
} else {
return nsDisplayOwnLayer::ComputeVisibility(aBuilder, aVisibleRegion,
aAllowVisibleRegionExpansion,
aContainsRootContentDocBG);
}
}
@ -1780,13 +1805,17 @@ void nsDisplayClip::Paint(nsDisplayListBuilder* aBuilder,
PRBool nsDisplayClip::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG) {
nsRegion clipped;
clipped.And(*aVisibleRegion, mClip);
nsRegion finalClipped(clipped);
nsRect allowExpansion;
allowExpansion.IntersectRect(mClip, aAllowVisibleRegionExpansion);
PRBool anyVisible =
nsDisplayWrapList::ComputeVisibility(aBuilder, &finalClipped,
allowExpansion,
aContainsRootContentDocBG);
nsRegion removed;
@ -1880,13 +1909,14 @@ nsDisplayClipRoundedRect::WrapWithClone(nsDisplayListBuilder* aBuilder,
PRBool nsDisplayClipRoundedRect::ComputeVisibility(
nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG)
{
nsRegion clipped;
clipped.And(*aVisibleRegion, mClip);
PRBool notUsed;
return nsDisplayWrapList::ComputeVisibility(aBuilder, &clipped, notUsed);
return nsDisplayWrapList::ComputeVisibility(aBuilder, &clipped, nsRect(), notUsed);
// FIXME: Remove a *conservative* opaque region from aVisibleRegion
// (like in nsDisplayClip::ComputeVisibility).
}
@ -1949,6 +1979,7 @@ void nsDisplayZoom::Paint(nsDisplayListBuilder* aBuilder,
PRBool nsDisplayZoom::ComputeVisibility(nsDisplayListBuilder *aBuilder,
nsRegion *aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG)
{
// Convert the passed in visible region to our appunits.
@ -1958,9 +1989,12 @@ PRBool nsDisplayZoom::ComputeVisibility(nsDisplayListBuilder *aBuilder,
nsRect transformedVisibleRect =
mVisibleRect.ConvertAppUnitsRoundOut(mParentAPD, mAPD);
nsRect allowExpansion =
aAllowVisibleRegionExpansion.ConvertAppUnitsRoundIn(mParentAPD, mAPD);
PRBool retval =
mList.ComputeVisibilityForSublist(aBuilder, &visibleRegion,
transformedVisibleRect,
allowExpansion,
aContainsRootContentDocBG);
nsRegion removed;
@ -2158,6 +2192,7 @@ nsDisplayTransform::GetLayerState(nsDisplayListBuilder* aBuilder,
PRBool nsDisplayTransform::ComputeVisibility(nsDisplayListBuilder *aBuilder,
nsRegion *aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG)
{
/* As we do this, we need to be sure to
@ -2440,6 +2475,7 @@ void nsDisplaySVGEffects::Paint(nsDisplayListBuilder* aBuilder,
PRBool nsDisplaySVGEffects::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG) {
nsPoint offset = aBuilder->ToReferenceFrame(mEffectsFrame);
nsRect dirtyRect =
@ -2453,7 +2489,7 @@ PRBool nsDisplaySVGEffects::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRect r;
r.IntersectRect(dirtyRect, mList.GetBounds(aBuilder));
PRBool notUsed;
mList.ComputeVisibilityForSublist(aBuilder, &childrenVisible, r, notUsed);
mList.ComputeVisibilityForSublist(aBuilder, &childrenVisible, r, nsRect(), notUsed);
return PR_TRUE;
}

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

@ -705,13 +705,17 @@ public:
* this item to the intersection of *aVisibleRegion and this item's bounds.
* We rely on that, so this should only be called by
* nsDisplayList::ComputeVisibility or nsDisplayItem::RecomputeVisibility.
*
* aAllowVisibleRegionExpansion is a rect where we are allowed to
* expand the visible region and is only used for making sure the
* background behind a plugin is visible.
*
* @return PR_TRUE if the item is visible, PR_FALSE if no part of the item
* is visible. aContainsRootContentDocBG is set to true if this item contains
* the background for the root content document.
*/
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG)
{ return !mVisibleRect.IsEmpty(); }
@ -993,6 +997,7 @@ public:
PRBool ComputeVisibilityForSublist(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aListVisibleBounds,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
/**
@ -1399,6 +1404,7 @@ public:
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
NS_DISPLAY_DECL_NAME("Border", TYPE_BORDER)
@ -1457,6 +1463,7 @@ public:
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
PRBool IsRootContentDocBackground() {
@ -1487,6 +1494,7 @@ public:
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
virtual nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
PRBool* aForceTransparentSurface = nsnull);
@ -1526,6 +1534,7 @@ public:
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
NS_DISPLAY_DECL_NAME("BoxShadowOuter", TYPE_BOX_SHADOW_OUTER)
@ -1551,6 +1560,7 @@ public:
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
NS_DISPLAY_DECL_NAME("BoxShadowInner", TYPE_BOX_SHADOW_INNER)
@ -1577,6 +1587,7 @@ public:
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
NS_DISPLAY_DECL_NAME("Outline", TYPE_OUTLINE)
};
@ -1639,6 +1650,7 @@ public:
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
virtual PRBool TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem) {
NS_WARNING("This list should already have been flattened!!!");
@ -1724,6 +1736,7 @@ public:
LayerManager* aManager);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
virtual PRBool TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem);
NS_DISPLAY_DECL_NAME("Opacity", TYPE_OPACITY)
@ -1791,6 +1804,7 @@ public:
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
private:
@ -1822,6 +1836,7 @@ public:
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
virtual PRBool TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem);
NS_DISPLAY_DECL_NAME("Clip", TYPE_CLIP)
@ -1864,6 +1879,7 @@ public:
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
virtual PRBool TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem);
NS_DISPLAY_DECL_NAME("ClipRoundedRect", TYPE_CLIP_ROUNDED_RECT)
@ -1905,6 +1921,7 @@ public:
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
NS_DISPLAY_DECL_NAME("Zoom", TYPE_ZOOM)
@ -1940,6 +1957,7 @@ public:
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
virtual PRBool TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem);
NS_DISPLAY_DECL_NAME("SVGEffects", TYPE_SVG_EFFECTS)
@ -2004,6 +2022,7 @@ public:
LayerManager* aManager);
virtual PRBool ComputeVisibility(nsDisplayListBuilder *aBuilder,
nsRegion *aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
virtual PRBool TryMerge(nsDisplayListBuilder *aBuilder, nsDisplayItem *aItem);

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

@ -173,10 +173,12 @@ public:
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG)
{
PRBool retval = NS_GET_A(mExtraBackgroundColor) > 0 ||
nsDisplayBackground::ComputeVisibility(aBuilder, aVisibleRegion,
aAllowVisibleRegionExpansion,
aContainsRootContentDocBG);
if (retval && mFrame->PresContext()->IsRootContentDocument()) {
aContainsRootContentDocBG = PR_TRUE;

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

@ -1328,6 +1328,7 @@ public:
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
NS_DISPLAY_DECL_NAME("PluginReadback", TYPE_PLUGIN_READBACK)
@ -1375,14 +1376,20 @@ nsDisplayPluginReadback::GetBounds(nsDisplayListBuilder* aBuilder)
PRBool
nsDisplayPluginReadback::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG)
{
if (!nsDisplayItem::ComputeVisibility(aBuilder, aVisibleRegion, aContainsRootContentDocBG))
if (!nsDisplayItem::ComputeVisibility(aBuilder, aVisibleRegion,
aAllowVisibleRegionExpansion,
aContainsRootContentDocBG))
return PR_FALSE;
nsRect expand;
expand.IntersectRect(aAllowVisibleRegionExpansion, GetBounds(aBuilder));
// *Add* our bounds to the visible region so that stuff underneath us is
// likely to be made visible, so we can use it for a background! This is
// a bit crazy since we normally only subtract from the visible region.
aVisibleRegion->Or(*aVisibleRegion, GetBounds(aBuilder));
aVisibleRegion->Or(*aVisibleRegion, expand);
return PR_TRUE;
}
@ -1403,10 +1410,12 @@ nsDisplayPlugin::Paint(nsDisplayListBuilder* aBuilder,
PRBool
nsDisplayPlugin::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG)
{
mVisibleRegion.And(*aVisibleRegion, GetBounds(aBuilder));
return nsDisplayItem::ComputeVisibility(aBuilder, aVisibleRegion,
aAllowVisibleRegionExpansion,
aContainsRootContentDocBG);
}

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

@ -334,6 +334,7 @@ public:
nsIRenderingContext* aCtx);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
NS_DISPLAY_DECL_NAME("Plugin", TYPE_PLUGIN)