Bug 1289011 - Part 1. Implement ComputeHTMLReferenceRect. draft
authorcku <cku@mozilla.com>
Sat, 27 Aug 2016 02:49:41 +0800
changeset 409564 b87c65af72ef26f638b016eb71ca03e96ef2aae9
parent 409497 d0830980ffdb36a10855d02a588b4869cad6707e
child 409565 61a9d55466d22b85c21a3c104b5b2280a83a2acf
push id28492
push userbmo:cku@mozilla.com
push dateSat, 03 Sep 2016 18:05:10 +0000
bugs1289011
milestone51.0a1
Bug 1289011 - Part 1. Implement ComputeHTMLReferenceRect. MozReview-Commit-ID: DvlSF3L8yE0
layout/svg/nsCSSClipPathInstance.cpp
layout/svg/nsCSSClipPathInstance.h
--- a/layout/svg/nsCSSClipPathInstance.cpp
+++ b/layout/svg/nsCSSClipPathInstance.cpp
@@ -57,35 +57,45 @@ nsCSSClipPathInstance::HitTestBasicShape
   RefPtr<DrawTarget> drawTarget =
     gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget();
   RefPtr<Path> path = instance.CreateClipPath(drawTarget);
   float pixelRatio = float(nsPresContext::AppUnitsPerCSSPixel()) /
                      aFrame->PresContext()->AppUnitsPerDevPixel();
   return path->ContainsPoint(ToPoint(aPoint) * pixelRatio, Matrix());
 }
 
-already_AddRefed<Path>
-nsCSSClipPathInstance::CreateClipPath(DrawTarget* aDrawTarget)
+
+nsRect
+nsCSSClipPathInstance::ComputeHTMLReferenceRect()
 {
   nsRect r;
   // XXXkrit SVG needs to use different boxes.
   switch (mClipPathStyle.GetReferenceBox()) {
     case StyleClipPathGeometryBox::Content:
       r = mTargetFrame->GetContentRectRelativeToSelf();
       break;
     case StyleClipPathGeometryBox::Padding:
       r = mTargetFrame->GetPaddingRectRelativeToSelf();
       break;
     case StyleClipPathGeometryBox::Margin:
       r = mTargetFrame->GetMarginRectRelativeToSelf();
       break;
     default: // Use the border box
       r = mTargetFrame->GetRectRelativeToSelf();
+      break;
   }
 
+  return r;
+}
+
+already_AddRefed<Path>
+nsCSSClipPathInstance::CreateClipPath(DrawTarget* aDrawTarget)
+{
+  nsRect r = ComputeHTMLReferenceRect();
+
   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 =
--- a/layout/svg/nsCSSClipPathInstance.h
+++ b/layout/svg/nsCSSClipPathInstance.h
@@ -42,16 +42,20 @@ private:
   already_AddRefed<Path> CreateClipPathEllipse(DrawTarget* aDrawTarget,
                                                const nsRect& aRefBox);
 
   already_AddRefed<Path> CreateClipPathPolygon(DrawTarget* aDrawTarget,
                                                const nsRect& aRefBox);
 
   already_AddRefed<Path> CreateClipPathInset(DrawTarget* aDrawTarget,
                                              const nsRect& aRefBox);
+
+
+  nsRect ComputeHTMLReferenceRect();
+
   /**
    * The frame for the element that is currently being clipped.
    */
   nsIFrame* mTargetFrame;
   StyleClipPath mClipPathStyle;
 };
 
 } // namespace mozilla