Bug 890783 - Reflow non-display SVG text when a child text frame is restyled. r=roc
authorCameron McCormack <cam@mcc.id.au>
Fri, 12 Jul 2013 17:13:07 +1000
changeset 150572 6b8eac57d567eb152fb21b0c4434b24aad267f2f
parent 150571 8d715a147cd890a3129b9834dd1f285caa27941b
child 150573 fd31bf6cc7794a2e05e32e77268c07bd815a98f8
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs890783
milestone25.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 890783 - Reflow non-display SVG text when a child text frame is restyled. r=roc
layout/generic/nsFrame.cpp
layout/svg/crashtests/890783-1.svg
layout/svg/crashtests/crashtests.list
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -78,16 +78,17 @@
 #include "nsIObjectLoadingContent.h"
 #include "nsExpirationTracker.h"
 #include "nsSVGIntegrationUtils.h"
 #include "nsSVGEffects.h"
 #include "nsChangeHint.h"
 #include "nsDeckFrame.h"
 #include "nsTableFrame.h"
 #include "nsSubDocumentFrame.h"
+#include "nsSVGTextFrame2.h"
 
 #include "gfxContext.h"
 #include "nsRenderingContext.h"
 #include "CSSCalc.h"
 #include "nsAbsoluteContainingBlock.h"
 #include "nsFontInflationData.h"
 #include "nsAnimationManager.h"
 #include "nsTransitionManager.h"
@@ -692,16 +693,27 @@ nsFrame::GetOffsets(int32_t &aStart, int
   aEnd = 0;
   return NS_OK;
 }
 
 // Subclass hook for style post processing
 /* virtual */ void
 nsFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
 {
+  if (IsSVGText()) {
+    nsSVGTextFrame2* svgTextFrame = static_cast<nsSVGTextFrame2*>(
+        nsLayoutUtils::GetClosestFrameOfType(this, nsGkAtoms::svgTextFrame2));
+    // Just as in nsSVGTextFrame2::DidSetStyleContext, we need to ensure that
+    // any non-display nsSVGTextFrame2s get reflowed when a child text frame
+    // gets new style.
+    if (svgTextFrame->GetStateBits() & NS_FRAME_IS_NONDISPLAY) {
+      svgTextFrame->ScheduleReflowSVGNonDisplayText();
+    }
+  }
+
   ImageLoader* imageLoader = PresContext()->Document()->StyleImageLoader();
 
   // If the old context had a background image image and new context
   // does not have the same image, clear the image load notifier
   // (which keeps the image loading, if it still is) for the frame.
   // We want to do this conservatively because some frames paint their
   // backgrounds from some other frame's style data, and we don't want
   // to clear those notifiers unless we have to.  (They'll be reset
new file mode 100644
--- /dev/null
+++ b/layout/svg/crashtests/890783-1.svg
@@ -0,0 +1,19 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+
+  <mask id="m">
+    <text>
+      <tspan id="tspan" />
+    </text>
+  </mask>
+
+  <rect width="600" height="400" mask="url(#m)"/>
+
+  <script>
+
+    window.addEventListener("load", function() {
+      document.getElementById("tspan").style.dominantBaseline = "alphabetic";
+    }, false);
+
+  </script>
+
+</svg>
--- a/layout/svg/crashtests/crashtests.list
+++ b/layout/svg/crashtests/crashtests.list
@@ -165,8 +165,9 @@ load 860378-1.svg
 load 868904-1.svg
 load 873806-1.svg
 load 876831-1.svg
 load 877029-1.svg
 load 880925-1.svg
 load 881031-1.svg
 load 885608-1.svg
 load 890782-1.svg
+load 890783-1.svg