Title: [243635] trunk
- Revision
- 243635
- Author
- rn...@webkit.org
- Date
- 2019-03-28 18:56:51 -0700 (Thu, 28 Mar 2019)
Log Message
getBoundingClientRect always returns empty rect on a collapsed range
https://bugs.webkit.org/show_bug.cgi?id=196380
Reviewed by Wenson Hsieh.
Source/WebCore:
The bug was caused by Range::boundingRect merging rects via FloatRect::unite which ignores empty rects.
Use uniteIfNonZero instead to fix the bug. Note that we can't use uniteEvenIfEmpty because that would
set x, y to always 0, 0 as we would end up merging any rect with the initial empty rect.
Test: fast/dom/Range/getBoundingClientRect-on-collapsed-selection-range.html
* dom/Range.cpp:
(WebCore::Range::boundingRect const):
LayoutTests:
Added a regression test.
* fast/dom/Range/getBoundingClientRect-on-collapsed-selection-range-expected.txt: Added.
* fast/dom/Range/getBoundingClientRect-on-collapsed-selection-range.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (243634 => 243635)
--- trunk/LayoutTests/ChangeLog 2019-03-29 01:43:31 UTC (rev 243634)
+++ trunk/LayoutTests/ChangeLog 2019-03-29 01:56:51 UTC (rev 243635)
@@ -1,3 +1,15 @@
+2019-03-28 Ryosuke Niwa <rn...@webkit.org>
+
+ getBoundingClientRect always returns empty rect on a collapsed range
+ https://bugs.webkit.org/show_bug.cgi?id=196380
+
+ Reviewed by Wenson Hsieh.
+
+ Added a regression test.
+
+ * fast/dom/Range/getBoundingClientRect-on-collapsed-selection-range-expected.txt: Added.
+ * fast/dom/Range/getBoundingClientRect-on-collapsed-selection-range.html: Added.
+
2019-03-28 Chris Dumez <cdu...@apple.com>
Re-sync web-platform-tests/html/browsers/the-window-object/ from upstream
Added: trunk/LayoutTests/fast/dom/Range/getBoundingClientRect-on-collapsed-selection-range-expected.txt (0 => 243635)
--- trunk/LayoutTests/fast/dom/Range/getBoundingClientRect-on-collapsed-selection-range-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/Range/getBoundingClientRect-on-collapsed-selection-range-expected.txt 2019-03-29 01:56:51 UTC (rev 243635)
@@ -0,0 +1,15 @@
+hello
+This tests calling getBoundingClientRect on a selection range when it is collapsed.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS rect = getSelection().getRangeAt(0).getBoundingClientRect(); rect.x is 10
+PASS rect.x is 10
+PASS rect.y > 5 is true
+PASS rect.width is 0
+PASS rect.height > 15 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/dom/Range/getBoundingClientRect-on-collapsed-selection-range.html (0 => 243635)
--- trunk/LayoutTests/fast/dom/Range/getBoundingClientRect-on-collapsed-selection-range.html (rev 0)
+++ trunk/LayoutTests/fast/dom/Range/getBoundingClientRect-on-collapsed-selection-range.html 2019-03-29 01:56:51 UTC (rev 243635)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div id="target">hello</div>
+<p id="description"></p>
+<div id="console"></div>
+<style>
+html, body { margin: 0; padding: 0; }
+body { margin: 10px; }
+#target { font-size: 20px; line-height: 100%; }
+</style>
+<script src=""
+<script>
+
+description('This tests calling getBoundingClientRect on a selection range when it is collapsed.');
+
+getSelection().setBaseAndExtent(target.lastChild, 0, target.lastChild, 0);
+
+shouldBe('rect = getSelection().getRangeAt(0).getBoundingClientRect(); rect.x', '10');
+shouldBe('rect.x', '10');
+shouldBeTrue('rect.y > 5');
+shouldBe('rect.width', '0');
+shouldBeTrue('rect.height > 15');
+
+successfullyParsed = true;
+
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (243634 => 243635)
--- trunk/Source/WebCore/ChangeLog 2019-03-29 01:43:31 UTC (rev 243634)
+++ trunk/Source/WebCore/ChangeLog 2019-03-29 01:56:51 UTC (rev 243635)
@@ -1,3 +1,19 @@
+2019-03-28 Ryosuke Niwa <rn...@webkit.org>
+
+ getBoundingClientRect always returns empty rect on a collapsed range
+ https://bugs.webkit.org/show_bug.cgi?id=196380
+
+ Reviewed by Wenson Hsieh.
+
+ The bug was caused by Range::boundingRect merging rects via FloatRect::unite which ignores empty rects.
+ Use uniteIfNonZero instead to fix the bug. Note that we can't use uniteEvenIfEmpty because that would
+ set x, y to always 0, 0 as we would end up merging any rect with the initial empty rect.
+
+ Test: fast/dom/Range/getBoundingClientRect-on-collapsed-selection-range.html
+
+ * dom/Range.cpp:
+ (WebCore::Range::boundingRect const):
+
2019-03-28 Justin Fan <justin_...@apple.com>
[Web GPU] Prototype compute pipeline with MSL
Modified: trunk/Source/WebCore/dom/Range.cpp (243634 => 243635)
--- trunk/Source/WebCore/dom/Range.cpp 2019-03-29 01:43:31 UTC (rev 243634)
+++ trunk/Source/WebCore/dom/Range.cpp 2019-03-29 01:56:51 UTC (rev 243635)
@@ -1842,7 +1842,7 @@
{
FloatRect result;
for (auto& rect : borderAndTextRects(space, respectClippingForTextRects))
- result.unite(rect);
+ result.uniteIfNonZero(rect);
return result;
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes