Log Message
REGRESSION: getBoundingClientRect() method of Range incorrectly returns null for collapsed Range https://bugs.webkit.org/show_bug.cgi?id=65324
Reviewed by Ryosuke Niwa. Source/WebCore: Update to more closely match the spec. * dom/Range.cpp: (WebCore::Range::getClientRects): Return an empty ClientRectList instead of null when the range is empty. (WebCore::Range::getBoundingClientRect): Always return a ClientRect, even for an empty bounding rect. LayoutTests: * fast/dom/Range/getBoundingClientRect-expected.txt: * fast/dom/Range/getBoundingClientRect.html: * fast/dom/Range/getClientRects-expected.txt: * fast/dom/Range/getClientRects.html: Add test cases for empty and collapsed ranges.
Modified Paths
- trunk/LayoutTests/ChangeLog
- trunk/LayoutTests/fast/dom/Range/getBoundingClientRect-expected.txt
- trunk/LayoutTests/fast/dom/Range/getBoundingClientRect.html
- trunk/LayoutTests/fast/dom/Range/getClientRects-expected.txt
- trunk/LayoutTests/fast/dom/Range/getClientRects.html
- trunk/Source/WebCore/ChangeLog
- trunk/Source/WebCore/dom/Range.cpp
Diff
Modified: trunk/LayoutTests/ChangeLog (92088 => 92089)
--- trunk/LayoutTests/ChangeLog 2011-07-31 20:44:57 UTC (rev 92088)
+++ trunk/LayoutTests/ChangeLog 2011-07-31 21:05:26 UTC (rev 92089)
@@ -1,3 +1,16 @@
+2011-07-31 Sam Weinig <[email protected]>
+
+ REGRESSION: getBoundingClientRect() method of Range incorrectly returns null for collapsed Range
+ https://bugs.webkit.org/show_bug.cgi?id=65324
+
+ Reviewed by Ryosuke Niwa.
+
+ * fast/dom/Range/getBoundingClientRect-expected.txt:
+ * fast/dom/Range/getBoundingClientRect.html:
+ * fast/dom/Range/getClientRects-expected.txt:
+ * fast/dom/Range/getClientRects.html:
+ Add test cases for empty and collapsed ranges.
+
2011-07-29 Ryosuke Niwa <[email protected]>
[HTML5] Implement the selectionDirection property on input and textarea
Modified: trunk/LayoutTests/fast/dom/Range/getBoundingClientRect-expected.txt (92088 => 92089)
--- trunk/LayoutTests/fast/dom/Range/getBoundingClientRect-expected.txt 2011-07-31 20:44:57 UTC (rev 92088)
+++ trunk/LayoutTests/fast/dom/Range/getBoundingClientRect-expected.txt 2011-07-31 21:05:26 UTC (rev 92089)
@@ -23,13 +23,29 @@
PASS rect.bottom is rect.top + rect.height
Test 4
+PASS rect.left.toFixed(3) is "0.000"
+PASS rect.top.toFixed(3) is "0.000"
+PASS rect.width.toFixed(3) is "0.000"
+PASS rect.height.toFixed(3) is "0.000"
+PASS rect.right is rect.left + rect.width
+PASS rect.bottom is rect.top + rect.height
+
+Test 5
PASS rect.left.toFixed(3) is "-14.574"
-PASS rect.top.toFixed(3) is "1329.947"
+PASS rect.top.toFixed(3) is "1761.947"
PASS rect.width.toFixed(3) is "504.009"
PASS rect.height.toFixed(3) is "535.849"
PASS Math.abs(rect.left + rect.width - rect.right) < 0.001 is true
PASS Math.abs(rect.top + rect.height - rect.bottom) < 0.001 is true
+Test 6
+PASS rect.left.toFixed(3) is "0.000"
+PASS rect.top.toFixed(3) is "0.000"
+PASS rect.width.toFixed(3) is "0.000"
+PASS rect.height.toFixed(3) is "0.000"
+PASS rect.right is rect.left + rect.width
+PASS rect.bottom is rect.top + rect.height
+
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/dom/Range/getBoundingClientRect.html (92088 => 92089)
--- trunk/LayoutTests/fast/dom/Range/getBoundingClientRect.html 2011-07-31 20:44:57 UTC (rev 92088)
+++ trunk/LayoutTests/fast/dom/Range/getBoundingClientRect.html 2011-07-31 21:05:26 UTC (rev 92089)
@@ -27,7 +27,7 @@
outline: 2px solid blue;
}
-#test4 {
+#test5 {
-webkit-transform: translate(50px, 100px) rotate(50deg);
}
@@ -57,6 +57,10 @@
<div class="box" id="test4">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
+<br><br>
+
+<div class="box" id="test5">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
+
</div>
<script>
if (window.layoutTestController)
@@ -105,9 +109,12 @@
/*1*/ { left: 8, top: 8, width: 400, height: 400 },
/*2*/ { left: 8, top: 452, width: 400, height: 376 },
/*3*/ { left: 8, top: 1044, width: 400, height: 96 },
- /*4*/ { left: -14.574, top: 1329.947, width: 504.009, height: 535.849 },
+ /*4*/ { left: 0, top: 0, width: 0, height: 0 },
+ /*5*/ { left: -14.574, top: 1761.947, width: 504.009, height: 535.849 },
+ /*6*/ { left: 0, top: 0, width: 0, height: 0 },
];
+ // Range over entire element.
debug("Test 1")
var range1 = document.createRange();
range1.selectNode(document.getElementById('test1'));
@@ -115,6 +122,7 @@
rect = range1.getBoundingClientRect();
testClientRect(rect, expectedResults[1 - 1]);
+ // Range over entire element's contents.
debug("Test 2")
var range2 = document.createRange();
range2.selectNodeContents(document.getElementById('test2'));
@@ -122,6 +130,7 @@
rect = range2.getBoundingClientRect();
testClientRect(rect, expectedResults[2 - 1]);
+ // Range over subset of element's contents.
debug("Test 3")
var range3 = document.createRange();
range3.setStart(document.getElementById('test3').firstChild, 100);
@@ -130,13 +139,33 @@
rect = range3.getBoundingClientRect()
testClientRect(rect, expectedResults[3 - 1]);
+ // Collapsed range.
debug("Test 4")
var range4 = document.createRange();
range4.selectNodeContents(document.getElementById('test4'));
+ range4.collapse(true);
show(range4);
+
+ var blah = range4.getClientRects();
+ debug(blah);
+
rect = range4.getBoundingClientRect()
testClientRect(rect, expectedResults[4 - 1]);
+ // Range over transformed elements.
+ debug("Test 5")
+ var range5 = document.createRange();
+ range5.selectNodeContents(document.getElementById('test5'));
+ show(range5);
+ rect = range5.getBoundingClientRect()
+ testClientRect(rect, expectedResults[5 - 1]);
+
+ // Empty range.
+ debug("Test 6")
+ var range6 = document.createRange();
+ rect = range6.getBoundingClientRect()
+ testClientRect(rect, expectedResults[6 - 1]);
+
if (window.layoutTestController) {
var area = document.getElementById('testArea');
area.parentNode.removeChild(area);
Modified: trunk/LayoutTests/fast/dom/Range/getClientRects-expected.txt (92088 => 92089)
--- trunk/LayoutTests/fast/dom/Range/getClientRects-expected.txt 2011-07-31 20:44:57 UTC (rev 92088)
+++ trunk/LayoutTests/fast/dom/Range/getClientRects-expected.txt 2011-07-31 21:05:26 UTC (rev 92089)
@@ -216,6 +216,8 @@
PASS rects[3].top is 2088
PASS rects[3].width is 18
PASS rects[3].height is 360
+Test 11
+PASS rects.length is 0
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/dom/Range/getClientRects.html (92088 => 92089)
--- trunk/LayoutTests/fast/dom/Range/getClientRects.html 2011-07-31 20:44:57 UTC (rev 92088)
+++ trunk/LayoutTests/fast/dom/Range/getClientRects.html 2011-07-31 21:05:26 UTC (rev 92089)
@@ -399,6 +399,11 @@
shouldBe("rects[3].width", "18");
shouldBe("rects[3].height", "360");
+ debug("Test 11");
+ var range11 = document.createRange();
+ rects = range11.getClientRects();
+ shouldBe("rects.length", "0");
+
if (window.layoutTestController) {
var area = document.getElementById('testArea');
area.parentNode.removeChild(area);
Modified: trunk/Source/WebCore/ChangeLog (92088 => 92089)
--- trunk/Source/WebCore/ChangeLog 2011-07-31 20:44:57 UTC (rev 92088)
+++ trunk/Source/WebCore/ChangeLog 2011-07-31 21:05:26 UTC (rev 92089)
@@ -1,3 +1,19 @@
+2011-07-31 Sam Weinig <[email protected]>
+
+ REGRESSION: getBoundingClientRect() method of Range incorrectly returns null for collapsed Range
+ https://bugs.webkit.org/show_bug.cgi?id=65324
+
+ Reviewed by Ryosuke Niwa.
+
+ Update to more closely match the spec.
+
+ * dom/Range.cpp:
+ (WebCore::Range::getClientRects):
+ Return an empty ClientRectList instead of null when the range is empty.
+
+ (WebCore::Range::getBoundingClientRect):
+ Always return a ClientRect, even for an empty bounding rect.
+
2011-07-29 Ryosuke Niwa <[email protected]>
[HTML5] Implement the selectionDirection property on input and textarea
Modified: trunk/Source/WebCore/dom/Range.cpp (92088 => 92089)
--- trunk/Source/WebCore/dom/Range.cpp 2011-07-31 20:44:57 UTC (rev 92088)
+++ trunk/Source/WebCore/dom/Range.cpp 2011-07-31 21:05:26 UTC (rev 92089)
@@ -1910,7 +1910,7 @@
PassRefPtr<ClientRectList> Range::getClientRects() const
{
if (!m_start.container())
- return 0;
+ return ClientRectList::create();
m_ownerDocument->updateLayoutIgnorePendingStylesheets();
@@ -1922,8 +1922,7 @@
PassRefPtr<ClientRect> Range::getBoundingClientRect() const
{
- FloatRect rect = boundingRect();
- return rect.isEmpty() ? 0 : ClientRect::create(rect);
+ return ClientRect::create(boundingRect());
}
static void adjustFloatQuadsForScrollAndAbsoluteZoomAndPageScale(Vector<FloatQuad>& quads, Document* document, RenderObject* renderer)
_______________________________________________ webkit-changes mailing list [email protected] http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes
