Bug 1109860 - getBBox incorrect with bidirectional text character. r=heycam
authorRobert Longson <longsonr@gmail.com>
Fri, 02 Jan 2015 16:47:47 +0000
changeset 247714 35141bed8113e219d5e166f3c1288a2e93a3ffd1
parent 247713 4f05661ca1162c4fbb56e67c8ebf99b693c7d58c
child 247715 827fa9b5f9b48cea237ded7903fd569d63c1fdc7
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1109860
milestone37.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 1109860 - getBBox incorrect with bidirectional text character. r=heycam
dom/svg/test/bbox-helper.svg
dom/svg/test/test_bbox.xhtml
layout/svg/SVGTextFrame.cpp
--- a/dom/svg/test/bbox-helper.svg
+++ b/dom/svg/test/bbox-helper.svg
@@ -5,16 +5,19 @@
     <image id="i" x="10" y="10" width="100" height="100"/>
   </g>
   <text id="b" x="20" y="20">b</text>
   <text id="a" x="20" y="30">a</text>
   <text id="y" x="20" y="40">y</text>
   <text id="tspan">
     <tspan x="20" y="20">b</tspan>
   </text>
+  <text id="text" x="20" y="60">text</text>
+  <!-- &#8206; is the same as the HTML &lrm; -->
+  <text id="lrmText" x="20" y="60">&#8206;text</text>
   <g id="v">
     <circle cx="100" cy="50" r="5"/>
     <path d="M 100,100 L 100,200"/>
   </g>
   <g id="h">
     <circle cx="200" cy="50" r="5"/>
     <path d="M 200,100 L 300,100"/>
   </g>
--- a/dom/svg/test/test_bbox.xhtml
+++ b/dom/svg/test/test_bbox.xhtml
@@ -53,16 +53,17 @@ function run()
     is(bbox1.height, bbox2.height, id1 + ".getBBox().height");
   }
 
   checkBBox("fO", 10, 10, 100, 100, 0.0);
   checkBBox("i", 10, 10, 100, 100, 0.0);
   compareBBoxHeight("a", "b");
   compareBBoxHeight("a", "y");
   compareBBox("b", "tspan");
+  compareBBoxHeight("text", "lrmText");
   checkBBox("v", 95, 45, 10, 155, 0.001);
   checkBBox("h", 195, 45, 105, 55, 0.001);
   checkBBox("e", 95, 95, 10, 10, 0.001);
   
   SimpleTest.finish();
 }
 
 window.addEventListener("load", run, false);
--- a/layout/svg/SVGTextFrame.cpp
+++ b/layout/svg/SVGTextFrame.cpp
@@ -895,16 +895,19 @@ TextRenderedRun::GetRunUserSpaceRect(nsP
 
   gfxSkipCharsIterator it = mFrame->EnsureTextRun(nsTextFrame::eInflated);
   gfxTextRun* textRun = mFrame->GetTextRun(nsTextFrame::eInflated);
 
   // Get the content range for this rendered run.
   uint32_t offset, length;
   ConvertOriginalToSkipped(it, mTextFrameContentOffset, mTextFrameContentLength,
                            offset, length);
+  if (length == 0) {
+    return r;
+  }
 
   // Measure that range.
   gfxTextRun::Metrics metrics =
     textRun->MeasureText(offset, length, gfxFont::LOOSE_INK_EXTENTS,
                          nullptr, nullptr);
 
   // Determine the rectangle that covers the rendered run's fill,
   // taking into account the measured vertical overflow due to
@@ -942,16 +945,17 @@ TextRenderedRun::GetRunUserSpaceRect(nsP
 
   // Include the fill if requested.
   if (aFlags & eIncludeFill) {
     r = fill;
   }
 
   // Include the stroke if requested.
   if ((aFlags & eIncludeStroke) &&
+      !fill.IsEmpty() &&
       nsSVGUtils::GetStrokeWidth(mFrame) > 0) {
     r.UnionEdges(nsSVGUtils::PathExtentsToMaxStrokeExtents(fill, mFrame,
                                                            gfxMatrix()));
   }
 
   return r;
 }