Bug 1346124 - Pass sync decode flag down to nsSVGMarkerFrame::PaintMark. draft
authorcku <cku@mozilla.com>
Mon, 27 Mar 2017 12:33:53 +0800
changeset 552197 f5d706b834692c9655de55329084278ea8c57da6
parent 552196 e10bde89c3f9b6033975512baa672b812275aa42
child 552198 e5fa62807df912177d79af767bf033134f06e839
push id51282
push userbmo:cku@mozilla.com
push dateTue, 28 Mar 2017 05:04:54 +0000
bugs1346124
milestone55.0a1
Bug 1346124 - Pass sync decode flag down to nsSVGMarkerFrame::PaintMark. MozReview-Commit-ID: 45yNaXpLSM4
layout/svg/SVGGeometryFrame.cpp
layout/svg/SVGGeometryFrame.h
layout/svg/nsSVGMarkerFrame.cpp
layout/svg/nsSVGMarkerFrame.h
--- a/layout/svg/SVGGeometryFrame.cpp
+++ b/layout/svg/SVGGeometryFrame.cpp
@@ -299,30 +299,30 @@ SVGGeometryFrame::PaintSVG(gfxContext& a
     return DrawResult::SUCCESS;
   }
 
   uint32_t paintOrder = StyleSVG()->mPaintOrder;
   DrawResult result = DrawResult::SUCCESS;
 
   if (paintOrder == NS_STYLE_PAINT_ORDER_NORMAL) {
     result = Render(&aContext, eRenderFill | eRenderStroke, newMatrix, aFlags);
-    PaintMarkers(aContext, aTransform);
+    result &= PaintMarkers(aContext, aTransform, aFlags);
   } else {
     while (paintOrder) {
       uint32_t component =
         paintOrder & ((1 << NS_STYLE_PAINT_ORDER_BITWIDTH) - 1);
       switch (component) {
         case NS_STYLE_PAINT_ORDER_FILL:
           result &= Render(&aContext, eRenderFill, newMatrix, aFlags);
           break;
         case NS_STYLE_PAINT_ORDER_STROKE:
           result &= Render(&aContext, eRenderStroke, newMatrix, aFlags);
           break;
         case NS_STYLE_PAINT_ORDER_MARKERS:
-          PaintMarkers(aContext, aTransform);
+          result &= PaintMarkers(aContext, aTransform, aFlags);
           break;
       }
       paintOrder >>= NS_STYLE_PAINT_ORDER_BITWIDTH;
     }
   }
 
   return result;
 }
@@ -876,22 +876,23 @@ SVGGeometryFrame::Render(gfxContext* aCo
         drawTarget->Stroke(path, strokePattern, strokeOptions, drawOptions);
       }
     }
   }
 
   return result;
 }
 
-void
+DrawResult
 SVGGeometryFrame::PaintMarkers(gfxContext& aContext,
-                               const gfxMatrix& aTransform)
+                               const gfxMatrix& aTransform,
+                               uint32_t aFlags)
 {
   SVGContextPaint* contextPaint = SVGContextPaint::GetContextPaint(mContent);
-
+  DrawResult result = DrawResult::SUCCESS;
   if (static_cast<SVGGeometryElement*>(mContent)->IsMarkable()) {
     MarkerProperties properties = GetMarkerProperties(this);
 
     if (properties.MarkersExist()) {
       float strokeWidth = nsSVGUtils::GetStrokeWidth(this, contextPaint);
 
       nsTArray<nsSVGMark> marks;
       static_cast<SVGGeometryElement*>
@@ -907,22 +908,25 @@ SVGGeometryFrame::PaintMarkers(gfxContex
         };
         static_assert(MOZ_ARRAY_LENGTH(markerFrames) == nsSVGMark::eTypeCount,
                       "Number of Marker frames should be equal to eTypeCount");
 
         for (uint32_t i = 0; i < num; i++) {
           nsSVGMark& mark = marks[i];
           nsSVGMarkerFrame* frame = markerFrames[mark.type];
           if (frame) {
-            frame->PaintMark(aContext, aTransform, this, &mark, strokeWidth);
+            result &= frame->PaintMark(aContext, aTransform, this, &mark,
+                                       strokeWidth, aFlags);
           }
         }
       }
     }
   }
+
+  return result;
 }
 
 uint16_t
 SVGGeometryFrame::GetHitTestFlags()
 {
   return nsSVGUtils::GetGeometryHitTestFlags(this);
 }
 } // namespace mozilla
--- a/layout/svg/SVGGeometryFrame.h
+++ b/layout/svg/SVGGeometryFrame.h
@@ -123,17 +123,18 @@ private:
   enum { eRenderFill = 1, eRenderStroke = 2 };
   DrawResult Render(gfxContext* aContext, uint32_t aRenderComponents,
                     const gfxMatrix& aTransform, uint32_t aFlags);
 
   /**
    * @param aMatrix The transform that must be multiplied onto aContext to
    *   establish this frame's SVG user space.
    */
-  void PaintMarkers(gfxContext& aContext, const gfxMatrix& aMatrix);
+  DrawResult PaintMarkers(gfxContext& aContext, const gfxMatrix& aMatrix,
+                          uint32_t aFlags);
 
   struct MarkerProperties {
     nsSVGMarkerProperty* mMarkerStart;
     nsSVGMarkerProperty* mMarkerMid;
     nsSVGMarkerProperty* mMarkerEnd;
 
     bool MarkersExist() const {
       return mMarkerStart || mMarkerMid || mMarkerEnd;
--- a/layout/svg/nsSVGMarkerFrame.cpp
+++ b/layout/svg/nsSVGMarkerFrame.cpp
@@ -97,40 +97,42 @@ static nsIFrame*
 GetAnonymousChildFrame(nsIFrame* aFrame)
 {
   nsIFrame* kid = aFrame->PrincipalChildList().FirstChild();
   MOZ_ASSERT(kid && kid->GetType() == nsGkAtoms::svgMarkerAnonChildFrame,
              "expected to find anonymous child of marker frame");
   return kid;
 }
 
-nsresult
+DrawResult
 nsSVGMarkerFrame::PaintMark(gfxContext& aContext,
                             const gfxMatrix& aToMarkedFrameUserSpace,
                             SVGGeometryFrame *aMarkedFrame,
-                            nsSVGMark *aMark, float aStrokeWidth)
+                            nsSVGMark *aMark, float aStrokeWidth,
+                            uint32_t aFlags)
 {
   // If the flag is set when we get here, it means this marker frame
   // has already been used painting the current mark, and the document
   // has a marker reference loop.
-  if (mInUse)
-    return NS_OK;
+  if (mInUse) {
+    return DrawResult::SUCCESS;
+  }
 
   AutoMarkerReferencer markerRef(this, aMarkedFrame);
 
   SVGMarkerElement *marker = static_cast<SVGMarkerElement*>(mContent);
   if (!marker->HasValidDimensions()) {
-    return NS_OK;
+    return DrawResult::SUCCESS;
   }
 
   const nsSVGViewBoxRect viewBox = marker->GetViewBoxRect();
 
   if (viewBox.width <= 0.0f || viewBox.height <= 0.0f) {
     // We must disable rendering if the viewBox width or height are zero.
-    return NS_OK;
+    return DrawResult::SUCCESS;
   }
 
   mStrokeWidth = aStrokeWidth;
   mX = aMark->x;
   mY = aMark->y;
   mAutoAngle = aMark->angle;
   mIsStart = aMark->type == nsSVGMark::eStart;
 
@@ -150,22 +152,23 @@ nsSVGMarkerFrame::PaintMark(gfxContext& 
     nsSVGUtils::SetClipRect(&aContext, markTM, clipRect);
   }
 
 
   nsIFrame* kid = GetAnonymousChildFrame(this);
   nsSVGDisplayableFrame* SVGFrame = do_QueryFrame(kid);
   // The CTM of each frame referencing us may be different.
   SVGFrame->NotifySVGChanged(nsSVGDisplayableFrame::TRANSFORM_CHANGED);
-  DrawResult result = nsSVGUtils::PaintFrameWithEffects(kid, aContext, markTM);
+  DrawResult result = nsSVGUtils::PaintFrameWithEffects(kid, aContext, markTM,
+                                                        nullptr, aFlags);
 
   if (StyleDisplay()->IsScrollableOverflow())
     aContext.Restore();
 
-  return (result == DrawResult::SUCCESS) ? NS_OK : NS_ERROR_FAILURE;
+  return result;
 }
 
 SVGBBox
 nsSVGMarkerFrame::GetMarkBBoxContribution(const Matrix &aToBBoxUserspace,
                                           uint32_t aFlags,
                                           SVGGeometryFrame *aMarkedFrame,
                                           const nsSVGMark *aMark,
                                           float aStrokeWidth)
--- a/layout/svg/nsSVGMarkerFrame.h
+++ b/layout/svg/nsSVGMarkerFrame.h
@@ -77,21 +77,22 @@ public:
     MOZ_ASSERT(PrincipalChildList().FirstChild() &&
                PrincipalChildList().FirstChild()->GetType() ==
                  nsGkAtoms::svgMarkerAnonChildFrame,
                "Where is our anonymous child?");
     return PrincipalChildList().FirstChild()->GetContentInsertionFrame();
   }
 
   // nsSVGMarkerFrame methods:
-  nsresult PaintMark(gfxContext& aContext,
-                     const gfxMatrix& aToMarkedFrameUserSpace,
-                     mozilla::SVGGeometryFrame *aMarkedFrame,
-                     nsSVGMark *aMark,
-                     float aStrokeWidth);
+  DrawResult PaintMark(gfxContext& aContext,
+                      const gfxMatrix& aToMarkedFrameUserSpace,
+                      mozilla::SVGGeometryFrame *aMarkedFrame,
+                      nsSVGMark *aMark,
+                      float aStrokeWidth,
+                      uint32_t aFlags);
 
   SVGBBox GetMarkBBoxContribution(const Matrix &aToBBoxUserspace,
                                   uint32_t aFlags,
                                   mozilla::SVGGeometryFrame *aMarkedFrame,
                                   const nsSVGMark *aMark,
                                   float aStrokeWidth);
 
   // Update the style on our anonymous box child.