Bug 1519144 - Apply context scale when inflating mRect of SVG text. r=longsonr
authorAlex Henrie <alexhenrie24@gmail.com>
Wed, 16 Jan 2019 19:55:24 -0700
changeset 514575 193394b152f20e41a339fe145cbb4bdba0f64780
parent 514574 62545dd149d1aa7b064f32e827ea97d31521a280
child 514576 bd64d6e1a11b985615399215422e536be229890d
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslongsonr
bugs1519144
milestone66.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 1519144 - Apply context scale when inflating mRect of SVG text. r=longsonr
layout/svg/SVGTextFrame.cpp
layout/svg/tests/mochitest.ini
layout/svg/tests/test_hover_near_text.html
--- a/layout/svg/SVGTextFrame.cpp
+++ b/layout/svg/SVGTextFrame.cpp
@@ -3515,17 +3515,17 @@ void SVGTextFrame::ReflowSVG() {
     mRect.SetEmpty();
   } else {
     mRect = nsLayoutUtils::RoundGfxRectToAppRect(r.ToThebesRect(),
                                                  AppUnitsPerCSSPixel());
 
     // Due to rounding issues when we have a transform applied, we sometimes
     // don't include an additional row of pixels.  For now, just inflate our
     // covered region.
-    mRect.Inflate(presContext->AppUnitsPerDevPixel());
+    mRect.Inflate(presContext->AppUnitsPerDevPixel() / mLastContextScale);
   }
 
   if (mState & NS_FRAME_FIRST_REFLOW) {
     // Make sure we have our filter property (if any) before calling
     // FinishAndStoreOverflow (subsequent filter changes are handled off
     // nsChangeHint_UpdateEffects):
     SVGObserverUtils::UpdateEffects(this);
   }
--- a/layout/svg/tests/mochitest.ini
+++ b/layout/svg/tests/mochitest.ini
@@ -4,8 +4,10 @@ support-files =
 
 [test_disabled.html]
 [test_filter_crossorigin.html]
 support-files =
   filters.svg
   file_filter_crossorigin.svg
   file_black_yellow.svg
   file_yellow_black.svg
+
+[test_hover_near_text.html]
new file mode 100644
--- /dev/null
+++ b/layout/svg/tests/test_hover_near_text.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8"/>
+        <title>Test mouse hover near text element inside svg element with viewBox attribute</title>
+        <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+    </head>
+    <body style="margin:0">
+        <div>
+            <svg viewBox="-1 -1 2 2" width="300" height="300">
+                <text style="font-size:0.1px" onmouseover="this.setAttribute('fill', 'red')">Hi</text>
+            </svg>
+        </div>
+        <p>
+            <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1519144">Mozilla Bug 1519144</a>
+        </p>
+        <script type="application/javascript">
+            let utils = SpecialPowers.getDOMWindowUtils(window);
+            utils.sendMouseEvent('mousemove', 155, 125, 0, 0, 0); //hover above the text
+            utils.sendMouseEvent('mousemove', 125, 155, 0, 0, 0); //hover to the left of the text
+            requestIdleCallback(() => {
+                ok(!document.getElementsByTagName('text')[0].hasAttribute('fill'),
+                   'Text element should not receive an event');
+                SimpleTest.finish();
+            });
+            SimpleTest.waitForExplicitFinish()
+        </script>
+    </body>
+</html>