Bug 1289011 - Part 4. Handle stroke-box. draft
authorcku <cku@mozilla.com>
Sun, 28 Aug 2016 02:36:20 +0800
changeset 409567 b3dc077939a4e3f200b9da57603f8878305339eb
parent 409566 a8746ff8fd3131262f61f75dad7fcbd84df8c92d
child 409568 4b0df749c18120e17ae5663c1bfc1beda56a210b
push id28492
push userbmo:cku@mozilla.com
push dateSat, 03 Sep 2016 18:05:10 +0000
bugs1289011
milestone51.0a1
Bug 1289011 - Part 4. Handle stroke-box. MozReview-Commit-ID: BImaXBGds6l
layout/svg/nsCSSClipPathInstance.cpp
--- a/layout/svg/nsCSSClipPathInstance.cpp
+++ b/layout/svg/nsCSSClipPathInstance.cpp
@@ -66,16 +66,26 @@ nsRect
 nsCSSClipPathInstance::ComputeSVGReferenceRect()
 {
   MOZ_ASSERT(mTargetFrame->GetContent()->IsSVGElement());
   nsRect r;
 
   // For SVG elements without associated CSS layout box, the used value for
   // content-box, padding-box, border-box and margin-box is fill-box.
   switch (mClipPathStyle.GetReferenceBox()) {
+    case StyleClipPathGeometryBox::Stroke: {
+      // XXX Bug 1299876
+      // The size of srtoke-box is not correct if this graphic element has
+      // specific stroke-linejoin or stroke-linecap.
+      gfxRect bbox = nsSVGUtils::GetBBox(mTargetFrame,
+                nsSVGUtils::eBBoxIncludeFill | nsSVGUtils::eBBoxIncludeStroke);
+      r = nsLayoutUtils::RoundGfxRectToAppRect(bbox,
+                                         nsPresContext::AppUnitsPerCSSPixel());
+      break;
+    }
     case StyleClipPathGeometryBox::View: {
       nsIContent* content = mTargetFrame->GetContent();
       nsSVGElement* element = static_cast<nsSVGElement*>(content);
       SVGSVGElement* svgElement = element->GetCtx();
       MOZ_ASSERT(svgElement);
 
       if (svgElement && svgElement->HasViewBoxRect()) {
         // If a ‘viewBox‘ attribute is specified for the SVG viewport creating