Bug 1388985 Part 1 - Compute box for clip-path: basic shape based on first frame according to the value of box-decoration-break. r?cjku
MozReview-Commit-ID: GfMnmsswksq
--- a/layout/svg/nsCSSClipPathInstance.cpp
+++ b/layout/svg/nsCSSClipPathInstance.cpp
@@ -71,16 +71,37 @@ nsCSSClipPathInstance::HitTestBasicShape
already_AddRefed<Path>
nsCSSClipPathInstance::CreateClipPath(DrawTarget* aDrawTarget)
{
nsRect r =
nsLayoutUtils::ComputeGeometryBox(mTargetFrame,
mClipPathStyle.GetReferenceBox());
+ // If mTargetFrame is a continuation frame, compute the box based on
+ // first frame according to different values of box-decoration-break.
+ nsIFrame* firstFrame =
+ nsLayoutUtils::FirstContinuationOrIBSplitSibling(mTargetFrame);
+ if (firstFrame != mTargetFrame) {
+ if (mTargetFrame->StyleBorder()->mBoxDecorationBreak ==
+ StyleBoxDecorationBreak::Clone) {
+ nsPoint offsetToFirstFrame =
+ mTargetFrame->GetRect().TopLeft() - firstFrame->GetRect().TopLeft();
+ r.MoveTo(r.TopLeft() + offsetToFirstFrame);
+ } else {
+ nsRect firstComputedRect =
+ nsLayoutUtils::ComputeGeometryBox(firstFrame,
+ mClipPathStyle.GetReferenceBox());
+ gfxRect bbox = nsSVGUtils::GetBBox(mTargetFrame);
+ firstComputedRect.SizeTo(
+ nsLayoutUtils::RoundGfxRectToAppRect(bbox, AppUnitsPerCSSPixel()).Size());
+ r = firstComputedRect;
+ }
+ }
+
if (mClipPathStyle.GetType() != StyleShapeSourceType::Shape) {
// TODO Clip to border-radius/reference box if no shape
// was specified.
RefPtr<PathBuilder> builder = aDrawTarget->CreatePathBuilder();
return builder->Finish();
}
nscoord appUnitsPerDevPixel =