Bug 1557245 - Support overflow:visible for foreignObject r=longsonr
authorviolet <violet.bugreport@gmail.com>
Tue, 25 Jun 2019 18:03:47 +0000
changeset 480119 09b3d826af112c35179e87ea0ac804d787cbc2ba
parent 480103 a3cad1d7836c6f84e33a895841ba0315460115bc
child 480120 95654f223f59b98cfecfea1744f2e0c255366b51
push id36203
push usershindli@mozilla.com
push dateWed, 26 Jun 2019 09:36:33 +0000
treeherdermozilla-central@b20b355373b4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslongsonr
bugs1557245
milestone69.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 1557245 - Support overflow:visible for foreignObject r=longsonr Differential Revision: https://phabricator.services.mozilla.com/D35760
layout/svg/nsSVGForeignObjectFrame.cpp
testing/web-platform/tests/svg/painting/foreignObject-overflow-ref.html
testing/web-platform/tests/svg/painting/foreignObject-overflow.html
--- a/layout/svg/nsSVGForeignObjectFrame.cpp
+++ b/layout/svg/nsSVGForeignObjectFrame.cpp
@@ -352,19 +352,19 @@ void nsSVGForeignObjectFrame::ReflowSVG(
   }
 
   // If we have a filter, we need to invalidate ourselves because filter
   // output can change even if none of our descendants need repainting.
   if (StyleEffects()->HasFilters()) {
     InvalidateFrame();
   }
 
-  // TODO: once we support |overflow:visible| on foreignObject, then we will
-  // need to take account of our descendants here.
-  nsRect overflow = nsRect(nsPoint(0, 0), mRect.Size());
+  auto* anonKid = PrincipalChildList().FirstChild();
+  nsRect overflow = anonKid->GetVisualOverflowRect();
+
   nsOverflowAreas overflowAreas(overflow, overflow);
   FinishAndStoreOverflow(overflowAreas, mRect.Size());
 
   // Now unset the various reflow bits:
   RemoveStateBits(NS_FRAME_FIRST_REFLOW | NS_FRAME_IS_DIRTY |
                   NS_FRAME_HAS_DIRTY_CHILDREN);
 }
 
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/svg/painting/foreignObject-overflow-ref.html
@@ -0,0 +1,11 @@
+<!doctype html>
+<html>
+<title>foreignObject overflow</title>
+<svg width="400" height="400">
+  <foreignObject x="100" y="100" style="overflow: visible" width="250" height="250" font-size="16px">
+    <div style="width:100px;height:100px;background:yellow;border:1px solid red">
+      <div style="position:absolute;top:20px;left:30px;width:20px;height:20px;background:navy"></div>
+      Should show all the text
+    </div>
+  </foreignObject>
+</svg>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/svg/painting/foreignObject-overflow.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<html>
+<title>foreignObject overflow</title>
+<link rel="match" href="foreignObject-overflow-ref.html">
+<svg width="400" height="400">
+  <foreignObject x="100" y="100" style="overflow: visible" width="2" height="2" font-size="16px">
+    <div style="width:100px;height:100px;background:yellow;border:1px solid red">
+      <div style="position:absolute;top:20px;left:30px;width:20px;height:20px;background:navy"></div>
+      Should show all the text
+    </div>
+  </foreignObject>
+</svg>