Bug 1302341 - Part 2: SVGTextFrame should be valid when unioning borderBoxes; r=heycam
authordmu@mozilla.com <dmu@mozilla.com>
Wed, 28 Sep 2016 02:21:50 +0000
changeset 341133 8f2925fcd9fffa039b37e7c31178aa9198ea2974
parent 341132 8e1741d22ce076186fe43bbc277c377f2eeef6be
child 341134 cf0424523e69c5ca6691478d6a74d27e944a949c
push id31326
push userkwierso@gmail.com
push dateTue, 07 Feb 2017 23:57:02 +0000
treeherdermozilla-central@c80c2c7bc043 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1302341
milestone54.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 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