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 draft
authorLouis Chang <lochang@mozilla.com>
Thu, 17 Aug 2017 00:55:12 +0800
changeset 647601 d327b085d872458b6c27328d8410ee2ea0768f71
parent 645781 cecc62945523b2ff6df76b8d3a7f8563de30fbcf
child 726568 24cb42fe595ad0b8db1721b6cc561834d47b42c5
push id74472
push userlochang@mozilla.com
push dateWed, 16 Aug 2017 16:55:44 +0000
reviewerscjku
bugs1388985
milestone57.0a1
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
layout/svg/nsCSSClipPathInstance.cpp
--- 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 =