From 70481ebbac2ff90893cc5b070995c868aef67e2c Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Mon, 9 Dec 2013 12:01:30 +1300 Subject: [PATCH] Bug 926268 - Don't include the full frame bounds in nsDisplayBorder if we're only painting one side. r=roc --- layout/base/nsDisplayList.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index aca702ca87a4..dd16513e958b 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -2548,10 +2548,30 @@ nsDisplayBorder::Paint(nsDisplayListBuilder* aBuilder, nsRect nsDisplayBorder::GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) { - nsRect borderBounds(ToReferenceFrame(), mFrame->GetSize()); - borderBounds.Inflate(mFrame->StyleBorder()->GetImageOutset()); *aSnap = true; - return borderBounds; + const nsStyleBorder *styleBorder = mFrame->StyleBorder(); + nsRect borderBounds(ToReferenceFrame(), mFrame->GetSize()); + if (styleBorder->IsBorderImageLoaded()) { + borderBounds.Inflate(mFrame->StyleBorder()->GetImageOutset()); + return borderBounds; + } else { + nsMargin border = styleBorder->GetComputedBorder(); + nsRect result; + if (border.top > 0) { + result = nsRect(borderBounds.X(), borderBounds.Y(), borderBounds.Width(), border.top); + } + if (border.right > 0) { + result.UnionRect(result, nsRect(borderBounds.XMost() - border.right, borderBounds.Y(), border.right, borderBounds.Height())); + } + if (border.bottom > 0) { + result.UnionRect(result, nsRect(borderBounds.X(), borderBounds.YMost() - border.bottom, borderBounds.Width(), border.bottom)); + } + if (border.left > 0) { + result.UnionRect(result, nsRect(borderBounds.X(), borderBounds.Y(), border.left, borderBounds.Height())); + } + + return result; + } } // Given a region, compute a conservative approximation to it as a list