Bug 1554755 - Don't set nsIFrame::mMayHaveRoundedCorners to false when there are non-zero percent borders, as we don't track all sizes that are passed to this function. r=mattwoodrow

I _think_ most of the sizes that get here are going to be equivalent to
mRect.Size(), but that seems really hard to prove.

Differential Revision: https://phabricator.services.mozilla.com/D32754

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2019-05-30 00:10:55 +00:00
parent 41399e03a6
commit 3116f4a8c3
4 changed files with 77 additions and 6 deletions

View file

@ -1836,6 +1836,15 @@ void nsIFrame::OutsetBorderRadii(nscoord aRadii[8], const nsMargin& aOffsets) {
}
}
static inline bool RadiiAreDefinitelyZero(const BorderRadius& aBorderRadius) {
NS_FOR_CSS_HALF_CORNERS(corner) {
if (!aBorderRadius.Get(corner).IsDefinitelyZero()) {
return false;
}
}
return true;
}
/* virtual */
bool nsIFrame::GetBorderRadii(const nsSize& aFrameSize,
const nsSize& aBorderArea, Sides aSkipSides,
@ -1857,10 +1866,18 @@ bool nsIFrame::GetBorderRadii(const nsSize& aFrameSize,
return false;
}
const_cast<nsIFrame*>(this)->mMayHaveRoundedCorners =
ComputeBorderRadii(StyleBorder()->mBorderRadius, aFrameSize, aBorderArea,
aSkipSides, aRadii);
return mMayHaveRoundedCorners;
const auto& radii = StyleBorder()->mBorderRadius;
const bool hasRadii =
ComputeBorderRadii(radii, aFrameSize, aBorderArea, aSkipSides, aRadii);
if (!hasRadii) {
// TODO(emilio): Maybe we can just remove this bit and do the
// IsDefinitelyZero check unconditionally. That should still avoid most of
// the work, though maybe not the cache miss of going through the style and
// the border struct.
const_cast<nsIFrame*>(this)->mMayHaveRoundedCorners =
!RadiiAreDefinitelyZero(radii);
}
return hasRadii;
}
bool nsIFrame::GetBorderRadii(nscoord aRadii[8]) const {

View file

@ -833,8 +833,6 @@ void nsImageFrame::NotifyNewCurrentRequest(imgIRequest* aRequest,
}
// Update border+content to account for image change
InvalidateFrame();
// FIXME(emilio): This just workarounds bug 1554755.
mMayHaveRoundedCorners = true;
}
}

View file

@ -0,0 +1,20 @@
<!doctype html>
<title>CSS Test Reference</title>
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
<link rel="author" title="Mozilla" href="https://mozilla.org">
<style>
#outer {
width: 100px;
height: 100px;
}
#inner {
width: 100%;
height: 100%;
background: green;
border-radius: 50px;
}
</style>
<p>Should be a green circle below</p>
<div id="outer">
<div id="inner"></div>
</div>

View file

@ -0,0 +1,36 @@
<!doctype html>
<html class="reftest-wait">
<title>CSS Test: Relative dynamic border-radius change</title>
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
<link rel="author" title="Mozilla" href="https://mozilla.org">
<link rel="help" href="https://drafts.csswg.org/css-backgrounds/#border-radius">
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1554755">
<link rel="match" href="border-radius-dynamic-from-no-radius-ref.html">
<style>
#outer {
width: 100px;
height: 100px;
}
#inner {
width: 100%;
height: 100%;
background: green;
/* The key is that this starts off computing to zero */
border-radius: calc(100% - 1px);
}
</style>
<p>Should be a green circle below</p>
<div id="outer" style="width: 1px; height: 1px;">
<div id="inner"></div>
</div>
<script>
onload = function() {
requestAnimationFrame(function() {
requestAnimationFrame(function() {
outer.style.height = "";
outer.style.width = "";
document.documentElement.className = "";
});
});
}
</script>