Bug 614265 - Make paint server references to elements within an unknown SVG element subtree work again. r=longsonr a=b
authorCameron McCormack <cam@mcc.id.au>
Fri, 26 Nov 2010 16:49:08 +1300
changeset 58309 bb43b6a9b62114137cfc6461baff7f619e378708
parent 58308 9537e23f97081f3df45d0e4356035e8662b2dc2a
child 58310 22344f2229cc604b67aa75990a2e7d5eb652eeba
push id17236
push userdgottwald@mozilla.com
push dateSun, 28 Nov 2010 09:46:08 +0000
treeherdermozilla-central@bb43b6a9b621 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslongsonr, b
bugs614265
milestone2.0b8pre
first release with
nightly win64
bb43b6a9b621 / 4.0b8pre / 20101128044846 / files
nightly linux32
nightly linux64
nightly mac
nightly win32
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly win64
Bug 614265 - Make paint server references to elements within an unknown SVG element subtree work again. r=longsonr a=b
layout/base/nsCSSFrameConstructor.cpp
layout/reftests/svg/conditions-02.svg
layout/reftests/svg/conditions-03.svg
layout/reftests/svg/conditions-04.svg
layout/reftests/svg/moz-only/reftest.list
layout/reftests/svg/moz-only/xbl-basic-03.svg
layout/reftests/svg/reftest.list
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -4743,18 +4743,18 @@ nsCSSFrameConstructor::FindSVGData(nsICo
                                    nsIFrame* aParentFrame,
                                    nsStyleContext* aStyleContext)
 {
   if (aNameSpaceID != kNameSpaceID_SVG || !NS_SVGEnabled()) {
     return nsnull;
   }
 
   static const FrameConstructionData sSuppressData = SUPPRESS_FCDATA();
-  static const FrameConstructionData sGenericContainerData =
-    SIMPLE_SVG_FCDATA(NS_NewSVGGenericContainerFrame);
+  static const FrameConstructionData sContainerData =
+    SIMPLE_SVG_FCDATA(NS_NewSVGContainerFrame);
 
   PRBool parentIsSVG = PR_FALSE;
   nsIContent* parentContent =
     aParentFrame ? aParentFrame->GetContent() : nsnull;
   // XXXbz should this really be based on the XBL-resolved tag of the parent
   // frame's content?  Should it not be based on the type of the parent frame
   // (e.g. whether it's an SVG frame)?
   if (parentContent) {
@@ -4787,27 +4787,21 @@ nsCSSFrameConstructor::FindSVGData(nsICo
     return &sSuppressData;
   }
 
   // We don't need frames for animation elements
   if (aContent->IsNodeOfType(nsINode::eANIMATION)) {
     return &sSuppressData;
   }
 
-  // Reduce the number of frames we create unnecessarily. Note that this is not
-  // where we select which frame in a <switch> to render! That happens in
-  // nsSVGSwitchFrame::PaintSVG.
+  // Elements with failing conditional processing attributes never get
+  // rendered.  Note that this is not where we select which frame in a
+  // <switch> to render!  That happens in nsSVGSwitchFrame::PaintSVG.
   if (!nsSVGFeatures::PassesConditionalProcessingTests(aContent)) {
-    // Note that just returning is probably not right.  According
-    // to the spec, <use> is allowed to use an element that fails its
-    // conditional, but because we never actually create the frame when
-    // a conditional fails and when we use GetReferencedFrame to find the
-    // references, things don't work right.
-    // XXX FIXME XXX
-    return &sSuppressData;
+    return &sContainerData;
   }
 
   // Special case for aTag == nsGkAtoms::svg because we don't want to
   // have to recompute parentIsSVG for it.
   if (aTag == nsGkAtoms::svg) {
     if (parentIsSVG) {
       static const FrameConstructionData sInnerSVGData =
         SIMPLE_SVG_FCDATA(NS_NewSVGInnerSVGFrame);
@@ -4855,16 +4849,17 @@ nsCSSFrameConstructor::FindSVGData(nsICo
     SIMPLE_SVG_CREATE(polygon, NS_NewSVGPathGeometryFrame),
     SIMPLE_SVG_CREATE(polyline, NS_NewSVGPathGeometryFrame),
     SIMPLE_SVG_CREATE(circle, NS_NewSVGPathGeometryFrame),
     SIMPLE_SVG_CREATE(ellipse, NS_NewSVGPathGeometryFrame),
     SIMPLE_SVG_CREATE(line, NS_NewSVGPathGeometryFrame),
     SIMPLE_SVG_CREATE(rect, NS_NewSVGPathGeometryFrame),
     SIMPLE_SVG_CREATE(path, NS_NewSVGPathGeometryFrame),
     SIMPLE_SVG_CREATE(defs, NS_NewSVGContainerFrame),
+    SIMPLE_SVG_CREATE(generic, NS_NewSVGGenericContainerFrame),
     { &nsGkAtoms::foreignObject,
       FULL_CTOR_FCDATA(FCDATA_DISALLOW_OUT_OF_FLOW,
                        &nsCSSFrameConstructor::ConstructSVGForeignObjectFrame) },
     SIMPLE_SVG_CREATE(a, NS_NewSVGAFrame),
     SIMPLE_SVG_CREATE(altGlyph, NS_NewSVGTSpanFrame),
     SIMPLE_SVG_CREATE(text, NS_NewSVGTextFrame),
     SIMPLE_SVG_CREATE(tspan, NS_NewSVGTSpanFrame),
     SIMPLE_SVG_CREATE(linearGradient, NS_NewSVGLinearGradientFrame),
@@ -4903,17 +4898,17 @@ nsCSSFrameConstructor::FindSVGData(nsICo
     SIMPLE_SVG_CREATE(feTurbulence, NS_NewSVGLeafFrame) 
   };
 
   const FrameConstructionData* data =
     FindDataByTag(aTag, aContent, aStyleContext, sSVGData,
                   NS_ARRAY_LENGTH(sSVGData));
 
   if (!data) {
-    data = &sSuppressData;
+    data = &sContainerData;
   }
 
   return data;
 }
 
 nsresult
 nsCSSFrameConstructor::ConstructSVGForeignObjectFrame(nsFrameConstructorState& aState,
                                                       FrameConstructionItem&   aItem,
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/conditions-02.svg
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/licenses/publicdomain/
+-->
+<svg xmlns="http://www.w3.org/2000/svg">
+  <title>Test that paint servers inside a failing conditional attribute subtree work</title>
+  <!-- https://bugzilla.mozilla.org/show_bug.cgi?id=614265 -->
+
+  <g requiredExtensions="http://example.org/hypothetical">
+    <linearGradient id="g">
+      <stop stop-color="lime" offset="0"/>
+      <stop stop-color="lime" offset="1"/>
+    </linearGradient>
+  </g>
+  <rect width="100%" height="100%" fill="url(#g) red"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/conditions-03.svg
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/licenses/publicdomain/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     xmlns:xlink="http://www.w3.org/1999/xlink">
+  <title>Test that 'use'ing elements inside a failing conditional attribute subtree works</title>
+  <!-- https://bugzilla.mozilla.org/show_bug.cgi?id=614265 -->
+
+  <g requiredExtensions="http://example.org/hypothetical">
+    <rect id="r" width="100%" height="100%" fill="lime"/>
+  </g>
+  <rect width="100%" height="100%" fill="red"/>
+  <use xlink:href="#r"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/conditions-04.svg
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/licenses/publicdomain/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     xmlns:xlink="http://www.w3.org/1999/xlink">
+  <title>Test that 'use'ing an element with a failing conditional fails</title>
+  <!-- https://bugzilla.mozilla.org/show_bug.cgi?id=614265 -->
+
+  <rect id="r1" width="100%" height="100%" fill="lime"/>
+  <rect requiredExtensions="http://example.org/hypothetical" id="r2" width="100%" height="100%" fill="red"/>
+  <use xlink:href="#r1"/>
+  <use xlink:href="#r2"/>
+</svg>
--- a/layout/reftests/svg/moz-only/reftest.list
+++ b/layout/reftests/svg/moz-only/reftest.list
@@ -1,12 +1,13 @@
 
 # XBL tests
 == xbl-basic-01.svg                             pass.svg
 == xbl-basic-02.svg                             pass.svg
+== xbl-basic-03.svg                             pass.svg
 == xbl-grad-ref--grad-in-binding-01.svg         pass.svg
 == xbl-grad-ref--grad-in-binding-02.svg         pass.svg
 == xbl-grad-ref--grad-in-bound-01.svg           pass.svg
 fails == xbl-grad-ref--grad-in-bound-02.svg     pass-black.svg
 fails == xbl-grad-ref--grad-in-resources-01.svg pass.svg
 fails == xbl-grad-ref--grad-in-resources-02.svg pass.svg
 == xbl-grad-ref--grad-in-binding-03.svg         pass.svg
 == xbl-grad-ref--grad-in-bound-03.svg           pass.svg
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/moz-only/xbl-basic-03.svg
@@ -0,0 +1,19 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/licenses/publicdomain/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     xmlns:svg="http://www.w3.org/2000/svg"
+     xmlns:ex="http://example.org/">
+
+  <bindings xmlns="http://www.mozilla.org/xbl">
+    <binding id="b" extends="svg:generic">
+      <content>
+        <svg:rect width="100%" height="100%" fill="lime"/>
+      </content>
+    </binding>
+  </bindings>
+
+  <rect width="100%" height="100%" fill="red"/>
+  <g style="-moz-binding: url(#b)"/>
+</svg>
--- a/layout/reftests/svg/reftest.list
+++ b/layout/reftests/svg/reftest.list
@@ -27,16 +27,19 @@ include svg-integration/reftest.list
 == clipPath-and-shape-rendering-01.svg clipPath-and-shape-rendering-01-ref.svg
 == clipPath-basic-01.svg pass.svg
 == clipPath-basic-02.svg pass.svg
 == clipPath-basic-03.svg pass.svg
 == clipPath-basic-04.svg pass.svg
 == clipPath-winding-01.svg pass.svg
 == clip-surface-clone-01.svg clip-surface-clone-01-ref.svg
 == conditions-01.svg pass.svg
+== conditions-02.svg pass.svg
+== conditions-03.svg pass.svg
+== conditions-04.svg pass.svg
 == currentColor-01.svg pass.svg
 == currentColor-02.svg pass.svg
 == currentColor-03.svg pass.svg
 == dynamic-attr-removal-1.svg pass.svg
 == dynamic-attr-removal-2.svg pass.svg
 == dynamic-attr-change-1.svg pass.svg
 == dynamic-conditions-01.svg pass.svg
 == dynamic-clipPath-01.svg pass.svg