Bug 532721: less conservative detection of gradients with size dependence. r=dbaron

This commit is contained in:
Zack Weinberg 2009-12-15 12:34:19 -08:00
parent a0cc483d31
commit 09a37c1c23
4 changed files with 114 additions and 7 deletions

View File

@ -0,0 +1,44 @@
<!doctype html>
<html><head>
<style>
html {
background-image: -moz-linear-gradient(black, white 20%);
background-repeat: repeat-x;
-moz-background-size: 1px 80%;
}
body {
font-size: 1em;
padding: 2em;
margin: 50px auto;
width: 14em;
border: 1px solid black;
background-color: white;
}
</style>
</head><body>
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
</body>
</html>

View File

@ -0,0 +1,54 @@
<!doctype html>
<html class="reftest-wait"><head>
<style>
html {
background-image: -moz-linear-gradient(black, white 20%);
background-repeat: repeat-x;
-moz-background-size: 1px 80%;
}
body {
font-size: 1em;
padding: 2em;
margin: 50px auto;
width: 28em;
border: 1px solid black;
background-color: white;
}
</style>
<script>
window.onload = function() {
setTimeout(function() {
document.body.style.width = "14em";
setTimeout(function() {
document.documentElement.removeAttribute("class");
}, 100);
}, 100);
}
</script>
</head><body>
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
pad pad pad pad pad pad pad pad
</body>
</html>

View File

@ -87,3 +87,4 @@ fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == aja-linear-6a.html aja-linear-6-ref.htm
fails == aja-linear-6b.html aja-linear-6-ref.html # bug 522607
== height-dependence-1.html height-dependence-1-ref.html
== height-dependence-2.html height-dependence-2-ref.html
== height-dependence-3.html height-dependence-3-ref.html

View File

@ -413,10 +413,19 @@ struct nsStyleBackground {
};
PRUint8 mWidthType, mHeightType;
// True if the effective image size described by this depends on the size
// of the corresponding frame.
PRBool DependsOnFrameSize() const {
return mWidthType <= ePercentage || mHeightType <= ePercentage;
// True if the effective image size described by this depends on
// the size of the corresponding frame. Gradients depend on the
// frame size when their dimensions are 'auto', images don't; both
// types depend on the frame size when their dimensions are
// 'contain', 'cover', or a percentage.
PRBool DependsOnFrameSize(nsStyleImageType aType) const {
if (aType == eStyleImageType_Image) {
return mWidthType <= ePercentage || mHeightType <= ePercentage;
} else if (aType == eStyleImageType_Gradient) {
return mWidthType <= eAuto || mHeightType <= eAuto;
} else {
NS_NOTREACHED("unrecognized image type");
}
}
// Initialize nothing
@ -456,9 +465,8 @@ struct nsStyleBackground {
// trying to identify gradients that don't depend on the frame size.
PRBool RenderingMightDependOnFrameSize() const {
return (!mImage.IsEmpty() &&
(mImage.GetType() == eStyleImageType_Gradient ||
mPosition.DependsOnFrameSize() ||
mSize.DependsOnFrameSize()));
(mPosition.DependsOnFrameSize() ||
mSize.DependsOnFrameSize(mImage.GetType())));
}
// An equality operator that compares the images using URL-equality