Bug 614732 - Stop recalculating the contribution of markers on every GetCoveredRegion() call. r=roc.
authorJonathan Watt <jwatt@jwatt.org>
Thu, 08 Sep 2011 12:15:00 +0100
changeset 76723 e082a424c7fb5afe5ca83c63ce800efb36580f7e
parent 76722 24ba516de8f32db9f882076784cf95933465052f
child 76724 e3d8ac2e6385511f3f63b7adf1874172da306d21
push id21136
push usereakhgari@mozilla.com
push dateThu, 08 Sep 2011 20:54:46 +0000
treeherdermozilla-central@817c2b9dc11d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs614732
milestone9.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 614732 - Stop recalculating the contribution of markers on every GetCoveredRegion() call. r=roc.
layout/svg/base/src/nsSVGPathGeometryFrame.cpp
--- a/layout/svg/base/src/nsSVGPathGeometryFrame.cpp
+++ b/layout/svg/base/src/nsSVGPathGeometryFrame.cpp
@@ -191,60 +191,16 @@ nsSVGPathGeometryFrame::GetFrameForPoint
     return this;
 
   return nsnull;
 }
 
 NS_IMETHODIMP_(nsRect)
 nsSVGPathGeometryFrame::GetCoveredRegion()
 {
-  // XXX why are we adding in markers here each time someone gets the covered
-  // region? Isn't UpdateCoveredRegion called whenever markers change?
-  // And why are the answers to these questions not documented here??!!
-
-  if (static_cast<nsSVGPathGeometryElement*>(mContent)->IsMarkable()) {
-    MarkerProperties properties = GetMarkerProperties(this);
-
-    if (!properties.MarkersExist())
-      return mRect;
-
-    nsRect rect(mRect);
-
-    float strokeWidth = GetStrokeWidth();
-
-    nsTArray<nsSVGMark> marks;
-    static_cast<nsSVGPathGeometryElement*>(mContent)->GetMarkPoints(&marks);
-
-    PRUint32 num = marks.Length();
-
-    if (num) {
-      nsSVGMarkerFrame *frame = properties.GetMarkerStartFrame();
-      if (frame) {
-        nsRect mark = frame->RegionMark(this, &marks[0], strokeWidth);
-        rect.UnionRect(rect, mark);
-      }
-
-      frame = properties.GetMarkerMidFrame();
-      if (frame) {
-        for (PRUint32 i = 1; i < num - 1; i++) {
-          nsRect mark = frame->RegionMark(this, &marks[i], strokeWidth);
-          rect.UnionRect(rect, mark);
-        }
-      }
-
-      frame = properties.GetMarkerEndFrame();
-      if (frame) {
-        nsRect mark = frame->RegionMark(this, &marks[num-1], strokeWidth);
-        rect.UnionRect(rect, mark);
-      }
-    }
-
-    return rect;
-  }
-
   return mRect;
 }
 
 NS_IMETHODIMP
 nsSVGPathGeometryFrame::UpdateCoveredRegion()
 {
   mRect.SetEmpty();
 
@@ -283,17 +239,49 @@ nsSVGPathGeometryFrame::UpdateCoveredReg
     extent = gfxRect(0, 0, 0, 0);
   }
 
   if (!extent.IsEmpty()) {
     mRect = nsSVGUtils::ToAppPixelRect(PresContext(), extent);
   }
 
   // Add in markers
-  mRect = GetCoveredRegion();
+  if (static_cast<nsSVGPathGeometryElement*>(mContent)->IsMarkable()) {
+
+    float strokeWidth = GetStrokeWidth();
+    MarkerProperties properties = GetMarkerProperties(this);
+
+    if (properties.MarkersExist()) {
+      nsTArray<nsSVGMark> marks;
+      static_cast<nsSVGPathGeometryElement*>(mContent)->GetMarkPoints(&marks);
+      PRUint32 num = marks.Length();
+
+      if (num) {
+        nsSVGMarkerFrame *frame = properties.GetMarkerStartFrame();
+        if (frame) {
+          nsRect rect = frame->RegionMark(this, &marks[0], strokeWidth);
+          mRect.UnionRect(mRect, rect);
+        }
+
+        frame = properties.GetMarkerMidFrame();
+        if (frame) {
+          for (PRUint32 i = 1; i < num - 1; i++) {
+            nsRect rect = frame->RegionMark(this, &marks[i], strokeWidth);
+            mRect.UnionRect(mRect, rect);
+          }
+        }
+
+        frame = properties.GetMarkerEndFrame();
+        if (frame) {
+          nsRect rect = frame->RegionMark(this, &marks[num-1], strokeWidth);
+          mRect.UnionRect(mRect, rect);
+        }
+      }
+    }
+  }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSVGPathGeometryFrame::InitialUpdate()
 {
   NS_ASSERTION(GetStateBits() & NS_FRAME_FIRST_REFLOW,