Bug 991046 - Combine the display item clips when we flatten an nsDisplayOpacity. r=roc

This commit is contained in:
Matt Woodrow 2014-04-09 14:28:38 +12:00
parent 7cad134034
commit 761f4b0fbe
5 changed files with 83 additions and 3 deletions

View File

@ -3389,7 +3389,7 @@ nsDisplayOpacity::ShouldFlattenAway(nsDisplayListBuilder* aBuilder)
return false;
}
return child->ApplyOpacity(mFrame->StyleDisplay()->mOpacity);
return child->ApplyOpacity(aBuilder, mFrame->StyleDisplay()->mOpacity, mClip);
}
nsDisplayItem::LayerState

View File

@ -1206,7 +1206,11 @@ public:
* Stores the given opacity value to be applied when drawing. Returns
* false if this isn't supported for this display item.
*/
virtual bool ApplyOpacity(float aOpacity) { return false; }
virtual bool ApplyOpacity(nsDisplayListBuilder* aBuilder,
float aOpacity,
const DisplayItemClip* aClip) {
return false;
}
#ifdef MOZ_DUMP_PAINTING
/**
@ -1282,6 +1286,17 @@ public:
mClip = aBuilder->AllocateDisplayItemClip(aClip);
}
void IntersectClip(nsDisplayListBuilder* aBuilder, const DisplayItemClip& aClip)
{
if (mClip) {
DisplayItemClip temp = *mClip;
temp.IntersectWith(aClip);
SetClip(aBuilder, temp);
} else {
SetClip(aBuilder, aClip);
}
}
// If we return false here it means that if this item creates a layer then
// ProcessDisplayItems will not set the visible region on the layer. The item
// should set the visible region, usually in BuildContainerLayer.
@ -2296,9 +2311,14 @@ public:
const nsDisplayItemGeometry* aGeometry,
nsRegion* aInvalidRegion) MOZ_OVERRIDE;
virtual bool ApplyOpacity(float aOpacity) MOZ_OVERRIDE
virtual bool ApplyOpacity(nsDisplayListBuilder* aBuilder,
float aOpacity,
const DisplayItemClip* aClip) MOZ_OVERRIDE
{
mOpacity = aOpacity;
if (aClip) {
IntersectClip(aBuilder, *aClip);
}
return true;
}

View File

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252"><title>box-shadow + transparent background + opacity =&gt; overflow hidden does not work</title></head>
<body>
<style>
#parent {
width: 200px;
height: 200px;
background-color: #BADA55;
overflow: hidden;
position: relative;
}
#child {
width: 200px;
height: 200px;
position: absolute;
left: 50px;
top: 50px;
box-shadow: 0 0 5px rgba(0,0,0,0.5);
}
</style>
<div id="parent">
<div id="child"></div>
</div>
</body></html>

View File

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252"><title>box-shadow + transparent background + opacity =&gt; overflow hidden does not work</title></head>
<body>
<style>
#parent {
width: 200px;
height: 200px;
background-color: #BADA55;
overflow: hidden;
position: relative;
}
#child {
width: 200px;
height: 200px;
position: absolute;
left: 50px;
top: 50px;
box-shadow: 0 0 5px rgb(0,0,0);
opacity: 0.5;
}
</style>
<div id="parent">
<div id="child"></div>
</div>
</body></html>

View File

@ -1804,4 +1804,5 @@ skip-if(Android) == 966510-2.html 966510-2-ref.html # same as above
== 983084-2.html 983084-2-ref.html
== 983084-3.html 983084-1-ref.html
== 983691-1.html 983691-ref.html
== 991046-1.html 991046-1-ref.html
pref(layout.css.overflow-clip-box.enabled,true) == 992447.html 992447-ref.html