Bug 1302341 - Part 2: SVGTextFrame should be valid when unioning borderBoxes; r?heycam draft
authordmu@mozilla.com <dmu@mozilla.com>
Wed, 28 Sep 2016 02:21:50 +0000
changeset 479955 8e580e42c4cbd42b34f091b5ba7c66b5b11d3346
parent 479954 24cb0355279d837799e3ce0a8eac5ec8b990df77
child 544827 51b5c26a6ef0a846f8615b8197f29a9747eebe09
push id44406
push userbmo:dmu@mozilla.com
push dateTue, 07 Feb 2017 15:40:49 +0000
reviewersheycam
bugs1302341
milestone54.0a1
Bug 1302341 - Part 2: SVGTextFrame should be valid when unioning borderBoxes; r?heycam MozReview-Commit-ID: 8R9f8viFt30
layout/generic/nsFrame.cpp
layout/reftests/svg/outline-ref.html
layout/reftests/svg/outline.html
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -8553,22 +8553,23 @@ static nsRect
 UnionBorderBoxes(nsIFrame* aFrame, bool aApplyTransform,
                  bool& aOutValid,
                  const nsSize* aSizeOverride = nullptr,
                  const nsOverflowAreas* aOverflowOverride = nullptr)
 {
   const nsRect bounds(nsPoint(0, 0),
                       aSizeOverride ? *aSizeOverride : aFrame->GetSize());
 
-  // The SVG container frames do not maintain an accurate mRect.
-  // It will make the outline be larger than we expect, we need
-  // to make them narrow to their children's outline.
+  // The SVG container frames besides SVGTextFrame do not maintain
+  // an accurate mRect. It will make the outline be larger than
+  // we expect, we need to make them narrow to their children's outline.
   // aOutValid is set to false if the returned nsRect is not valid
   // and should not be included in the outline rectangle.
-  aOutValid = !aFrame->IsFrameOfType(nsIFrame::eSVGContainer);
+  aOutValid = !aFrame->IsFrameOfType(nsIFrame::eSVGContainer)
+              || aFrame->GetType() == nsGkAtoms::svgTextFrame;
 
   // Start from our border-box, transformed.  See comment below about
   // transform of children.
   nsRect u;
   bool doTransform = aApplyTransform && aFrame->IsTransformed();
   if (doTransform) {
     u = nsDisplayTransform::TransformRect(bounds, aFrame, &bounds);
   } else {
--- a/layout/reftests/svg/outline-ref.html
+++ b/layout/reftests/svg/outline-ref.html
@@ -26,46 +26,51 @@
       <circle id="ggCircle" cx="50" cy="50" r="20" style="fill: green"/>
       <g>
         <rect id="ggRect" x="15" y ="15" width="30" height="10" style="fill: blue"/>
       </g>
     </g>
     <svg x="300" y="250">
       <rect id="innerRect" x="30" y="10" height="50" width="50" style="fill: red"/>
     </svg>
+    <a xlink:href="#" id="link">
+      <text x="300" y="350" font-family="Verdana" font-size="20">
+        link
+      </text>
+    </a>
   </g>
 </svg>
 <script>
 
 function createOutline(boundingRect) {
   // Outline starts from a top-left shift pixel of the bounding rect
   var left = boundingRect.left - 1;
   var top  = boundingRect.top - 1;
   var right = boundingRect.right;
   var bottom = boundingRect.bottom;
   var width = boundingRect.width;
   var height = boundingRect.height;
 
   var lines = document.createElement("div");
-  var styles = 'border: 1px solid;'
+  var styles = 'border: 1px solid black;'
                + 'width: ' + width + 'px;'
                + 'height: ' + height + 'px;'
                + 'position: absolute;'
                + 'top: ' + top + 'px;'
                + 'left: ' + left + 'px;';
 
   lines.setAttribute('style', styles);
   document.body.appendChild(lines);
 }
 
 window.onload = function drawOutline() {
   var elements = ['rect', 'foreignObject', 'circle',
                   'ellipse', 'image', 'line', 'path',
                   'polygon', 'polyline', 'text','gCircle',
-                  'innerRect'];
+                  'innerRect', 'link'];
   elements.forEach(id => {
     var element = document.getElementById(id);
     createOutline(element.getBoundingClientRect());
   });
 
   var ggRect = document.getElementById('ggRect');
   var ggRectbbox = ggRect.getBoundingClientRect();
   createOutline(ggRectbbox);
--- a/layout/reftests/svg/outline.html
+++ b/layout/reftests/svg/outline.html
@@ -6,17 +6,17 @@ text,
 foreignObject,
 circle,
 ellipse,
 image,
 line,
 path,
 polygon,
 polyline {
-  outline: 1px solid;
+  outline: 1px solid black;
 }
 
 </style>
 <body>
 <svg xmlns="http://www.w3.org/2000/svg" overflow="visible">
   <g>
     <rect width="100" height="100" style="fill: yellow"/>
     <text x="0" y="140" font-family="Verdana" font-size="20">
@@ -41,12 +41,17 @@ polyline {
       <circle cx="50" cy="50" r="20" style="fill: green; outline: 0px"/>
       <g>
         <rect x="15" y="15" width="30" height="10" style="fill: blue"/>
       </g>
     </g>
     <svg x="300" y="250">
       <rect x="30" y="10" height="50" width="50" style="fill: red"/>
     </svg>
+    <a xlink:href="#" id="link">
+      <text x="300" y="350" font-family="Verdana" font-size="20">
+        link
+      </text>
+    </a>
   </g>
 </svg>
 </body>
 </html>
\ No newline at end of file