Bug 1067088 - Use aBorderArea when not skipping any sides (e.g. ::first-letter), not the joined border area. r=roc

This commit is contained in:
Mats Palmgren 2014-09-17 00:36:57 +00:00
parent 2a76b50bf9
commit a68692d3b5
4 changed files with 170 additions and 20 deletions

View File

@ -518,24 +518,30 @@ IsBoxDecorationSlice(const nsStyleBorder& aStyleBorder)
static nsRect
BoxDecorationRectForBorder(nsIFrame* aFrame, const nsRect& aBorderArea,
Sides aSkipSides,
const nsStyleBorder* aStyleBorder = nullptr)
{
if (!aStyleBorder) {
aStyleBorder = aFrame->StyleBorder();
}
return ::IsBoxDecorationSlice(*aStyleBorder)
// If aSkipSides.IsEmpty() then there are no continuations, or it's
// a ::first-letter that wants all border sides on the first continuation.
return ::IsBoxDecorationSlice(*aStyleBorder) && !aSkipSides.IsEmpty()
? ::JoinBoxesForSlice(aFrame, aBorderArea, eForBorder)
: aBorderArea;
}
static nsRect
BoxDecorationRectForBackground(nsIFrame* aFrame, const nsRect& aBorderArea,
Sides aSkipSides,
const nsStyleBorder* aStyleBorder = nullptr)
{
if (!aStyleBorder) {
aStyleBorder = aFrame->StyleBorder();
}
return ::IsBoxDecorationSlice(*aStyleBorder)
// If aSkipSides.IsEmpty() then there are no continuations, or it's
// a ::first-letter that wants all border sides on the first continuation.
return ::IsBoxDecorationSlice(*aStyleBorder) && !aSkipSides.IsEmpty()
? ::JoinBoxesForSlice(aFrame, aBorderArea, eForBackground)
: aBorderArea;
}
@ -659,11 +665,10 @@ nsCSSRendering::PaintBorderWithStyleBorder(nsPresContext* aPresContext,
// Compute the outermost boundary of the area that might be painted.
// Same coordinate space as aBorderArea & aBGClipRect.
nsRect joinedBorderArea =
::BoxDecorationRectForBorder(aForFrame, aBorderArea, &aStyleBorder);
::BoxDecorationRectForBorder(aForFrame, aBorderArea, aSkipSides, &aStyleBorder);
gfxCornerSizes bgRadii;
::GetRadii(aForFrame, aStyleBorder, aBorderArea, joinedBorderArea, &bgRadii);
PrintAsFormatString(" joinedBorderArea: %d %d %d %d\n", joinedBorderArea.x, joinedBorderArea.y,
joinedBorderArea.width, joinedBorderArea.height);
@ -672,11 +677,7 @@ nsCSSRendering::PaintBorderWithStyleBorder(nsPresContext* aPresContext,
ctx->Save();
if (::IsBoxDecorationSlice(aStyleBorder)) {
if (aSkipSides.IsEmpty()) {
// No continuations most likely, or ::first-letter that wants all border-
// sides on the first continuation.
joinedBorderArea = aBorderArea;
} else if (joinedBorderArea.IsEqualEdges(aBorderArea)) {
if (joinedBorderArea.IsEqualEdges(aBorderArea)) {
// No need for a clip, just skip the sides we don't want.
border.ApplySkipSides(aSkipSides);
} else {
@ -1202,7 +1203,8 @@ nsCSSRendering::PaintBoxShadowOuter(nsPresContext* aPresContext,
nsRect frameRect = nativeTheme ?
aForFrame->GetVisualOverflowRectRelativeToSelf() + aFrameArea.TopLeft() :
aFrameArea;
frameRect = ::BoxDecorationRectForBorder(aForFrame, frameRect);
Sides skipSides = aForFrame->GetSkipSides();
frameRect = ::BoxDecorationRectForBorder(aForFrame, frameRect, skipSides);
// Get any border radius, since box-shadow must also have rounded corners if
// the frame does.
@ -1242,7 +1244,6 @@ nsCSSRendering::PaintBoxShadowOuter(nsPresContext* aPresContext,
std::max(borderRadii[C_BL].height, borderRadii[C_BR].height), 0));
}
Sides skipSides = aForFrame->GetSkipSides();
for (uint32_t i = shadows->Length(); i > 0; --i) {
nsCSSShadowItem* shadowItem = shadows->ShadowAt(i - 1);
if (shadowItem->mInset)
@ -1421,7 +1422,9 @@ nsCSSRendering::PaintBoxShadowInner(nsPresContext* aPresContext,
NS_ASSERTION(aForFrame->GetType() == nsGkAtoms::fieldSetFrame ||
aFrameArea.Size() == aForFrame->GetSize(), "unexpected size");
nsRect frameRect = ::BoxDecorationRectForBorder(aForFrame, aFrameArea);
Sides skipSides = aForFrame->GetSkipSides();
nsRect frameRect =
::BoxDecorationRectForBorder(aForFrame, aFrameArea, skipSides);
nsRect paddingRect = frameRect;
nsMargin border = aForFrame->GetUsedBorder();
paddingRect.Deflate(border);
@ -1681,8 +1684,9 @@ nsCSSRendering::GetBackgroundClip(const nsStyleBackground::Layer& aLayer,
{
// Compute the outermost boundary of the area that might be painted.
// Same coordinate space as aBorderArea.
Sides skipSides = aForFrame->GetSkipSides();
nsRect clipBorderArea =
::BoxDecorationRectForBorder(aForFrame, aBorderArea, &aBorder);
::BoxDecorationRectForBorder(aForFrame, aBorderArea, skipSides, &aBorder);
bool haveRoundedCorners = GetRadii(aForFrame, aBorder, aBorderArea,
clipBorderArea, aClipState->mRadii);
@ -1726,7 +1730,7 @@ nsCSSRendering::GetBackgroundClip(const nsStyleBackground::Layer& aLayer,
// padding-bottom is ignored on scrollable frames:
// https://bugzilla.mozilla.org/show_bug.cgi?id=748518
padding.bottom = 0;
padding.ApplySkipSides(aForFrame->GetSkipSides());
padding.ApplySkipSides(skipSides);
aClipState->mAdditionalBGClipArea.Deflate(padding);
}
@ -1750,7 +1754,7 @@ nsCSSRendering::GetBackgroundClip(const nsStyleBackground::Layer& aLayer,
"unexpected background-clip");
border += aForFrame->GetUsedPadding();
}
border.ApplySkipSides(aForFrame->GetSkipSides());
border.ApplySkipSides(skipSides);
aClipState->mBGClipArea.Deflate(border);
if (haveRoundedCorners) {
@ -2673,10 +2677,11 @@ nsCSSRendering::PaintBackgroundWithSC(nsPresContext* aPresContext,
// Compute the outermost boundary of the area that might be painted.
// Same coordinate space as aBorderArea & aBGClipRect.
Sides skipSides = aForFrame->GetSkipSides();
nsRect paintBorderArea =
::BoxDecorationRectForBackground(aForFrame, aBorderArea, &aBorder);
::BoxDecorationRectForBackground(aForFrame, aBorderArea, skipSides, &aBorder);
nsRect clipBorderArea =
::BoxDecorationRectForBorder(aForFrame, aBorderArea, &aBorder);
::BoxDecorationRectForBorder(aForFrame, aBorderArea, skipSides, &aBorder);
// The 'bgClipArea' (used only by the image tiling logic, far below)
// is the caller-provided aBGClipRect if any, or else the area
@ -3109,7 +3114,9 @@ nsCSSRendering::GetBackgroundLayerRect(nsPresContext* aPresContext,
const nsStyleBackground::Layer& aLayer,
uint32_t aFlags)
{
nsRect borderArea = ::BoxDecorationRectForBackground(aForFrame, aBorderArea);
Sides skipSides = aForFrame->GetSkipSides();
nsRect borderArea =
::BoxDecorationRectForBackground(aForFrame, aBorderArea, skipSides);
nsBackgroundLayerState state =
PrepareBackgroundLayer(aPresContext, aForFrame, aFlags, borderArea,
aClipRect, aLayer);
@ -3185,8 +3192,8 @@ DrawBorderImage(nsPresContext* aPresContext,
nsMargin borderWidths(aStyleBorder.GetComputedBorder());
nsMargin imageOutset(aStyleBorder.GetImageOutset());
if (::IsBoxDecorationSlice(aStyleBorder) && !aSkipSides.IsEmpty()) {
borderImgArea =
::BoxDecorationRectForBorder(aForFrame, aBorderArea, &aStyleBorder);
borderImgArea = ::BoxDecorationRectForBorder(aForFrame, aBorderArea,
aSkipSides, &aStyleBorder);
if (borderImgArea.IsEqualEdges(aBorderArea)) {
// No need for a clip, just skip the sides we don't want.
borderWidths.ApplySkipSides(aSkipSides);

View File

@ -0,0 +1,70 @@
<!DOCTYPE html>
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html>
<head>
<title>::first-letter with border-radius</title>
<link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1067088">
<style>
html,body { color:black; background-color:white; font-size:24px; }
div { line-height:36px; }
.b { background: blue; }
.r100p { border-radius: 100%; }
.r10p { border-radius: 10%; }
.s1 { border:1px solid black; }
.i { background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAIAAACRXR%2FmAAAAAXNSR0IArs4c6QAAADpJREFUWMPtzgENAAAIA6Br%2F85aQzdIQGVyUCdaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpan1oLQKsBY3S7VU8AAAAASUVORK5CYII%3D); }
.shadowi { box-shadow: inset 15px 9px 7px 0px #00F; }
.shadowo { box-shadow: 0px 0px 7px 0px #00F;}
.shadowio { box-shadow: inset 15px 9px 7px 0px #00F, 0px 0px 7px 0px #00F;}
.bi {
border: 5px solid red;
border-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD%2FgAIDAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAoUlEQVR42u3bwQ0AIAgEwcOmtXttgScmsxWQCTyp3EysJo61IliwYMGCBUuwYMGCBQuWYMGCBQsWLMGCBQsWLFiCBQsWLFiwBAsWLFiwYAkWLFiwYMESLFiwYMGCpXaVka%2BsO8dmOUNYggULFixYsAQLFixYsGAJFixYsGDBEixYsGDBgiVYsGDBggVLsGDBggULlmDBggULFizBggUL1t89N%2FYEtBGStpoAAAAASUVORK5CYII%3D) 10 10 repeat;
background: pink;
border-image-outset: 7px 3px 5px 9px;
}
</style>
</head>
<body>
<table cellpadding="10"><tr><td>
<div><span class="b r100p">F</span>irst-letter</div>
<div><span class="b r10p">F</span>irst-letter</div>
<div><span class="b s1 r100p">F</span>irst-letter</div>
<div><span class="b s1 r10p">F</span>irst-letter</div>
<div><span class="shadowo r100p">F</span>irst-letter</div>
<div><span class="shadowo s1 r10p">F</span>irst-letter</div>
<div><span class="shadowi s1 r100p">F</span>irst-letter</div>
<div><span class="shadowi r10p">F</span>irst-letter</div>
<div><span class="shadowio r100p">F</span>irst-letter</div>
<div><span class="shadowio s1 r10p">F</span>irst-letter</div>
<div><span class="s1 r100p">F</span>irst-letter</div>
<div><span class="s1 r10p">F</span>irst-letter</div>
<div><span class="i r100p">F</span>irst-letter</div>
<div><span class="i r10p">F</span>irst-letter</div>
<div><span class="i s1 r100p">F</span>irst-letter</div>
<div><span class="i s1 r10p">F</span>irst-letter</div>
<div><span class="bi">F</span>irst-letter</div>
</td>
<td>
<div><span class="b r100p">F</span>irst-letter</div>
<div><span class="b r10p">F</span>irst-letter</div>
<div><span class="b s1 r100p">F</span>irst-letter</div>
<div><span class="b s1 r10p">F</span>irst-letter</div>
<div><span class="shadowo r100p">F</span>irst-letter</div>
<div><span class="shadowo s1 r10p">F</span>irst-letter</div>
<div><span class="shadowi s1 r100p">F</span>irst-letter</div>
<div><span class="shadowi r10p">F</span>irst-letter</div>
<div><span class="shadowio r100p">F</span>irst-letter</div>
<div><span class="shadowio s1 r10p">F</span>irst-letter</div>
<div><span class="s1 r100p">F</span>irst-letter</div>
<div><span class="s1 r10p">F</span>irst-letter</div>
<div><span class="i r100p">F</span>irst-letter</div>
<div><span class="i r10p">F</span>irst-letter</div>
<div><span class="i s1 r100p">F</span>irst-letter</div>
<div><span class="i s1 r10p">F</span>irst-letter</div>
<div><span class="bi">F</span>irst-letter</div>
</td>
</tr></table>
</body>
</html>

View File

@ -0,0 +1,72 @@
<!DOCTYPE html>
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html>
<head>
<title>::first-letter with border-radius</title>
<link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1067088">
<style>
html,body { color:black; background-color:white; font-size:24px; }
div { line-height:36px; }
.b::first-letter { background: blue; }
.c::first-letter { box-decoration-break:clone; }
.r100p::first-letter { border-radius: 100%; }
.r10p::first-letter { border-radius: 10%; }
.s1::first-letter { border:1px solid black; }
.i::first-letter { background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAIAAACRXR%2FmAAAAAXNSR0IArs4c6QAAADpJREFUWMPtzgENAAAIA6Br%2F85aQzdIQGVyUCdaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpan1oLQKsBY3S7VU8AAAAASUVORK5CYII%3D); }
.shadowi::first-letter { box-shadow: inset 15px 9px 7px 0px #00F; }
.shadowo::first-letter { box-shadow: 0px 0px 7px 0px #00F;}
.shadowio::first-letter { box-shadow: inset 15px 9px 7px 0px #00F, 0px 0px 7px 0px #00F;}
.bi::first-letter {
border: 5px solid red;
border-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD%2FgAIDAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAoUlEQVR42u3bwQ0AIAgEwcOmtXttgScmsxWQCTyp3EysJo61IliwYMGCBUuwYMGCBQuWYMGCBQsWLMGCBQsWLFiCBQsWLFiwBAsWLFiwYAkWLFiwYMESLFiwYMGCpXaVka%2BsO8dmOUNYggULFixYsAQLFixYsGAJFixYsGDBEixYsGDBgiVYsGDBggVLsGDBggULlmDBggULFizBggUL1t89N%2FYEtBGStpoAAAAASUVORK5CYII%3D) 10 10 repeat;
background: pink;
border-image-outset: 7px 3px 5px 9px;
}
</style>
</head>
<body>
<table cellpadding="10"><tr><td>
<div class="b r100p">First-letter</div>
<div class="b r10p">First-letter</div>
<div class="b s1 r100p">First-letter</div>
<div class="b s1 r10p">First-letter</div>
<div class="shadowo r100p">First-letter</div>
<div class="shadowo s1 r10p">First-letter</div>
<div class="shadowi s1 r100p">First-letter</div>
<div class="shadowi r10p">First-letter</div>
<div class="shadowio r100p">First-letter</div>
<div class="shadowio s1 r10p">First-letter</div>
<div class="s1 r100p">First-letter</div>
<div class="s1 r10p">First-letter</div>
<div class="i r100p">First-letter</div>
<div class="i r10p">First-letter</div>
<div class="i s1 r100p">First-letter</div>
<div class="i s1 r10p">First-letter</div>
<div class="bi">First-letter</div>
</td>
<td>
<!-- box-decoration-break:clone should render the same for ::first-letter -->
<div class="c b r100p">First-letter</div>
<div class="c b r10p">First-letter</div>
<div class="c b s1 r100p">First-letter</div>
<div class="c b s1 r10p">First-letter</div>
<div class="c shadowo r100p">First-letter</div>
<div class="c shadowo s1 r10p">First-letter</div>
<div class="c shadowi s1 r100p">First-letter</div>
<div class="c shadowi r10p">First-letter</div>
<div class="c shadowio r100p">First-letter</div>
<div class="c shadowio s1 r10p">First-letter</div>
<div class="c s1 r100p">First-letter</div>
<div class="c s1 r10p">First-letter</div>
<div class="c i r100p">First-letter</div>
<div class="c i r10p">First-letter</div>
<div class="c i s1 r100p">First-letter</div>
<div class="c i s1 r10p">First-letter</div>
<div class="c bi">First-letter</div>
</td>
</tr></table>
</body>
</html>

View File

@ -6,3 +6,4 @@ fuzzy(16,460) == box-decoration-break-with-outset-box-shadow-1.html box-decorati
random-if(!gtk2Widget) HTTP(..) == box-decoration-break-border-image.html box-decoration-break-border-image-ref.html
== box-decoration-break-block-border-padding.html box-decoration-break-block-border-padding-ref.html
== box-decoration-break-block-margin.html box-decoration-break-block-margin-ref.html
== box-decoration-break-first-letter.html box-decoration-break-first-letter-ref.html