Bug 869781 - Make nsSVGOuterSVGFrame::Reflow update the overflow rects of its children if it has a viewBox. r=dholbert
authorJonathan Watt <jwatt@jwatt.org>
Wed, 08 May 2013 18:11:42 +0100
changeset 131269 7b7eea794c8effde25e56b192be64ecf36e1af54
parent 131268 0ea128318cc839d105662a3bb327bfe4a79ff08d
child 131270 c0b7f22692c325d24624d2b080e749c808ce6a42
push id24654
push userryanvm@gmail.com
push dateThu, 09 May 2013 04:17:56 +0000
treeherdermozilla-central@ea059733677c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs869781
milestone23.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 869781 - Make nsSVGOuterSVGFrame::Reflow update the overflow rects of its children if it has a viewBox. r=dholbert
layout/svg/nsSVGOuterSVGFrame.cpp
--- a/layout/svg/nsSVGOuterSVGFrame.cpp
+++ b/layout/svg/nsSVGOuterSVGFrame.cpp
@@ -418,24 +418,37 @@ nsSVGOuterSVGFrame::Reflow(nsPresContext
   svgFloatSize newViewportSize(
     nsPresContext::AppUnitsToFloatCSSPixels(aReflowState.ComputedWidth()),
     nsPresContext::AppUnitsToFloatCSSPixels(aReflowState.ComputedHeight()));
 
   svgFloatSize oldViewportSize = svgElem->GetViewportSize();
 
   uint32_t changeBits = 0;
   if (newViewportSize != oldViewportSize) {
-    if (oldViewportSize.width <= 0.0f || oldViewportSize.height <= 0.0f) {
-      // The overflow rects of our child frames will be empty if we had a
-      // [synthetic] viewBox during our last reflow, since under
-      // FinishAndStoreOverflow() the nsDisplayTransform::TransformRect call
-      // will have ended up calling SVGSVGElement::GetViewBoxTransform()
-      // which will have returned the identity matrix due to our viewport
-      // having been zero-sized. Mark all our child frames as dirty so that we
-      // reflow them below and update their overflow rects:
+    // When our viewport size changes, we may need to update the overflow rects
+    // of our child frames. This is the case if:
+    //
+    //  * We have a real/synthetic viewBox (a children-only transform), since
+    //    the viewBox transform will change as the viewport dimensions change.
+    //
+    //  * We do not have a real/synthetic viewBox, but the last time we
+    //    reflowed (or the last time UpdateOverflow() was called) we did.
+    //
+    // We only handle the former case here, in which case we mark all our child
+    // frames as dirty so that we reflow them below and update their overflow
+    // rects.
+    //
+    // In the latter case, updating of overflow rects is handled for removal of
+    // real viewBox (the viewBox attribute) in AttributeChanged. Synthetic
+    // viewBox "removal" (e.g. a document references the same SVG via both an
+    // <svg:image> and then as a CSS background image (a synthetic viewBox is
+    // used when painting the former, but not when painting the latter)) is
+    // handled in SVGSVGElement::FlushImageTransformInvalidation.
+    //
+    if (svgElem->HasViewBoxRect() || svgElem->ShouldSynthesizeViewBox()) {
       nsIFrame* anonChild = GetFirstPrincipalChild();
       anonChild->AddStateBits(NS_FRAME_IS_DIRTY);
       for (nsIFrame* child = anonChild->GetFirstPrincipalChild(); child;
            child = child->GetNextSibling()) {
         child->AddStateBits(NS_FRAME_IS_DIRTY);
       }
     }
     changeBits |= COORD_CONTEXT_CHANGED;