Title: [282316] trunk
Revision
282316
Author
[email protected]
Date
2021-09-12 11:40:39 -0700 (Sun, 12 Sep 2021)

Log Message

Implement getClientRects() for SVG elements
https://bugs.webkit.org/show_bug.cgi?id=230197

Reviewed by Sam Weinig.

Source/WebCore:

For SVG elements we can just use absoluteQuads().

Test: svg/custom/getClientRects.xhtml

* dom/Element.cpp:
(WebCore::Element::getClientRects):

LayoutTests:

* svg/custom/getClientRects-expected.txt: Added.
* svg/custom/getClientRects.xhtml: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (282315 => 282316)


--- trunk/LayoutTests/ChangeLog	2021-09-12 01:41:08 UTC (rev 282315)
+++ trunk/LayoutTests/ChangeLog	2021-09-12 18:40:39 UTC (rev 282316)
@@ -1,3 +1,13 @@
+2021-09-12  Simon Fraser  <[email protected]>
+
+        Implement getClientRects() for SVG elements
+        https://bugs.webkit.org/show_bug.cgi?id=230197
+
+        Reviewed by Sam Weinig.
+
+        * svg/custom/getClientRects-expected.txt: Added.
+        * svg/custom/getClientRects.xhtml: Added.
+
 2021-09-11  Philippe Normand  <[email protected]>
 
         [GLIB] MediaSession is not enabled

Added: trunk/LayoutTests/platform/ios-wk2/svg/custom/getClientRects-expected.txt (0 => 282316)


--- trunk/LayoutTests/platform/ios-wk2/svg/custom/getClientRects-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios-wk2/svg/custom/getClientRects-expected.txt	2021-09-12 18:40:39 UTC (rev 282316)
@@ -0,0 +1,24 @@
+
+A BC
+This test checks getClientRects() on SVG elements
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+getClientRects on a rect at absolute coordinates:
+{ x 20.00 y 30.00 width 40.00 height 50.00 }
+
+getClientRects on a rotated rect:
+{ x 30.36 y 115.36 width 139.27 height 139.27 }
+
+getClientRects on a g:
+{ x 0.00 y 105.00 width 260.00 height 110.00 }
+
+getClientRects on a path:
+{ x 25.00 y 140.00 width 60.00 height 60.00 }
+
+getClientRects on text:
+{ x 25.00 y 140.00 width 60.00 height 60.00 }
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/svg/custom/getClientRects-expected.txt (0 => 282316)


--- trunk/LayoutTests/svg/custom/getClientRects-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/svg/custom/getClientRects-expected.txt	2021-09-12 18:40:39 UTC (rev 282316)
@@ -0,0 +1,24 @@
+
+A BC
+This test checks getClientRects() on SVG elements
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+getClientRects on a rect at absolute coordinates:
+{ x 20.00 y 30.00 width 40.00 height 50.00 }
+
+getClientRects on a rotated rect:
+{ x 30.36 y 114.36 width 139.27 height 139.27 }
+
+getClientRects on a g:
+{ x 0.00 y 104.00 width 260.00 height 110.00 }
+
+getClientRects on a path:
+{ x 25.00 y 139.00 width 60.00 height 60.00 }
+
+getClientRects on text:
+{ x 25.00 y 139.00 width 60.00 height 60.00 }
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/svg/custom/getClientRects.xhtml (0 => 282316)


--- trunk/LayoutTests/svg/custom/getClientRects.xhtml	                        (rev 0)
+++ trunk/LayoutTests/svg/custom/getClientRects.xhtml	2021-09-12 18:40:39 UTC (rev 282316)
@@ -0,0 +1,66 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+</head>
+<body style="margin:0; border:0; padding:0;">
+
+<div style="width:500px;height:200px;">
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100px" height="100px">
+  <rect id="r1" x="20" y="30" width="40" height="50" fill="blue" />
+</svg>
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="200px" height="100px" viewBox="0 0 50 200" preserveAspectRatio="none">
+  <rect id="r2" x="20" y="30" width="40" height="50" fill="green" />
+</svg>
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="200px" height="100px">
+  <g id="rect-group">
+    <rect x="0" y="0" width="200px" height="50px" fill="yellow" overflow="hidden" />
+    <rect x="50px" y="50px" width="210px" height="60px" fill="orange" overflow="visible" />
+  </g>
+  <rect id="r3" transform="translate(50, 30) rotate(35, 50, 50)" fill="green" width="100" height="100"/>
+  <path id="path1" fill="green" stroke="black" stroke-width="10" d="M 30 40 L 80 40 L 80 90  L 30 90 Z"/>
+  <text id="text" x="10" y="30"><tspan>A<tspan dy="-5"> B</tspan><tspan dy="10"><tspan>C</tspan></tspan></tspan></text>
+</svg>
+</div>
+
+<div id="description"></div>
+<div id="console"></div>
+
+<script src=""
+<script>
+
+function rectToString(r)
+{
+    return `{ x ${r.left.toFixed(2)} y ${r.top.toFixed(2)} width ${r.width.toFixed(2)} height ${r.height.toFixed(2)} }`;
+}
+
+function dumpRects(rectList)
+{
+    for (let rect of rectList)
+        debug(rectToString(rect));
+}
+
+description("This test checks getClientRects() on SVG elements");
+
+debug("getClientRects on a rect at absolute coordinates:");
+dumpRects(document.getElementById("r1").getClientRects());
+
+debug("");
+debug("getClientRects on a rotated rect:");
+dumpRects(document.getElementById("r3").getClientRects());
+
+debug("");
+debug("getClientRects on a g:");
+dumpRects(document.getElementById("rect-group").getClientRects());
+
+debug("");
+debug("getClientRects on a path:");
+dumpRects(document.getElementById("path1").getClientRects());
+
+debug("");
+debug("getClientRects on text:");
+dumpRects(document.getElementById("path1").getClientRects());
+
+</script>
+<script src=""
+
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (282315 => 282316)


--- trunk/Source/WebCore/ChangeLog	2021-09-12 01:41:08 UTC (rev 282315)
+++ trunk/Source/WebCore/ChangeLog	2021-09-12 18:40:39 UTC (rev 282316)
@@ -1,3 +1,17 @@
+2021-09-12  Simon Fraser  <[email protected]>
+
+        Implement getClientRects() for SVG elements
+        https://bugs.webkit.org/show_bug.cgi?id=230197
+
+        Reviewed by Sam Weinig.
+
+        For SVG elements we can just use absoluteQuads().
+
+        Test: svg/custom/getClientRects.xhtml
+
+        * dom/Element.cpp:
+        (WebCore::Element::getClientRects):
+
 2021-09-11  Simon Fraser  <[email protected]>
 
         css/css-transforms/translate-getComputedStyle.html fails

Modified: trunk/Source/WebCore/dom/Element.cpp (282315 => 282316)


--- trunk/Source/WebCore/dom/Element.cpp	2021-09-12 01:41:08 UTC (rev 282315)
+++ trunk/Source/WebCore/dom/Element.cpp	2021-09-12 18:40:39 UTC (rev 282316)
@@ -1641,8 +1641,9 @@
         quads.append(renderer->localToAbsoluteQuad(FloatQuad { pair.value().second }));
     } else if (auto* renderBoxModelObject = this->renderBoxModelObject())
         renderBoxModelObject->absoluteQuads(quads);
+    else if (isSVGElement() && renderer)
+        renderer->absoluteQuads(quads);
 
-    // FIXME: Handle SVG elements.
     // FIXME: Handle table/inline-table with a caption.
 
     if (quads.isEmpty())
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to