Commit 16e0fd82 authored by ojan@chromium.org's avatar ojan@chromium.org

2010-01-28 Ojan Vafai <ojan@chromium.org>

        Reviewed by Darin Adler.

        Implement CSSOM Range.getClientRects for collapsed selections
        https://bugs.webkit.org/show_bug.cgi?id=34239

        Adds two cases to getClientRects test.

        * fast/dom/Range/getClientRects-expected.txt:
        * fast/dom/Range/getClientRects.html:
2010-01-28  Ojan Vafai  <ojan@chromium.org>

        Reviewed by Darin Adler.

        Implement CSSOM Range.getClientRects for collapsed selections
        https://bugs.webkit.org/show_bug.cgi?id=34239

        When getting the quads for a range on a text node, allow returning
        zero width quads. This leaves the case of collapsed selections inside
        elements still not fixed, but no worse.

        * rendering/InlineTextBox.cpp:
        (WebCore::InlineTextBox::selectionRect):
        * rendering/RenderText.cpp:
        (WebCore::RenderText::absoluteQuadsForRange):

git-svn-id: svn://svn.chromium.org/blink/trunk@54117 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent f9fa5fb0
2010-01-28 Ojan Vafai <ojan@chromium.org>
Reviewed by Darin Adler.
Implement CSSOM Range.getClientRects for collapsed selections
https://bugs.webkit.org/show_bug.cgi?id=34239
Adds two cases to getClientRects test.
* fast/dom/Range/getClientRects-expected.txt:
* fast/dom/Range/getClientRects.html:
2010-01-31 Oliver Hunt <oliver@apple.com> 2010-01-31 Oliver Hunt <oliver@apple.com>
Reviewed by Simon Fraser. Reviewed by Simon Fraser.
......
...@@ -186,6 +186,18 @@ PASS rects[3].left is 76 ...@@ -186,6 +186,18 @@ PASS rects[3].left is 76
PASS rects[3].top is 1755 PASS rects[3].top is 1755
PASS rects[3].width is 212 PASS rects[3].width is 212
PASS rects[3].height is 247 PASS rects[3].height is 247
Test 9
FAIL rects.length should be 1. Was 0.
FAIL rects[0].left should be 8. Threw exception TypeError: Result of expression 'rects[0]' [undefined] is not an object.
FAIL rects[0].top should be 1903. Threw exception TypeError: Result of expression 'rects[0]' [undefined] is not an object.
FAIL rects[0].width should be 0. Threw exception TypeError: Result of expression 'rects[0]' [undefined] is not an object.
FAIL rects[0].height should be 18. Threw exception TypeError: Result of expression 'rects[0]' [undefined] is not an object.
Test 9b
PASS rects.length is 1
PASS rects[0].left is 8
PASS rects[0].top is 1903
PASS rects[0].width is 0
PASS rects[0].height is 18
PASS successfullyParsed is true PASS successfullyParsed is true
TEST COMPLETE TEST COMPLETE
......
...@@ -69,6 +69,10 @@ ...@@ -69,6 +69,10 @@
<div class="box" id="test8">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 class="box" id="test8">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="test9">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> </div>
<script> <script>
...@@ -339,6 +343,29 @@ ...@@ -339,6 +343,29 @@
shouldBe("rects[3].width", "212"); shouldBe("rects[3].width", "212");
shouldBe("rects[3].height", "247"); shouldBe("rects[3].height", "247");
debug("Test 9");
var range9 = document.createRange();
// This case should match test 9b's results. Currently though getClientRects returns an empty list.
range9.setStart(document.getElementById('test9'), 0);
show(range9);
rects = range9.getClientRects();
shouldBe("rects.length", "1");
shouldBe("rects[0].left", "8");
shouldBe("rects[0].top", "1903");
shouldBe("rects[0].width", "0");
shouldBe("rects[0].height", "18");
debug("Test 9b");
var range9 = document.createRange();
range9.setStart(document.getElementById('test9').firstChild, 0);
show(range9);
rects = range9.getClientRects();
shouldBe("rects.length", "1");
shouldBe("rects[0].left", "8");
shouldBe("rects[0].top", "1903");
shouldBe("rects[0].width", "0");
shouldBe("rects[0].height", "18");
if (window.layoutTestController) { if (window.layoutTestController) {
var area = document.getElementById('testArea'); var area = document.getElementById('testArea');
area.parentNode.removeChild(area); area.parentNode.removeChild(area);
......
2010-01-28 Ojan Vafai <ojan@chromium.org>
Reviewed by Darin Adler.
Implement CSSOM Range.getClientRects for collapsed selections
https://bugs.webkit.org/show_bug.cgi?id=34239
When getting the quads for a range on a text node, allow returning
zero width quads. This leaves the case of collapsed selections inside
elements still not fixed, but no worse.
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::selectionRect):
* rendering/RenderText.cpp:
(WebCore::RenderText::absoluteQuadsForRange):
2010-01-31 Oliver Hunt <oliver@apple.com> 2010-01-31 Oliver Hunt <oliver@apple.com>
Reviewed by Simon Fraser. Reviewed by Simon Fraser.
......
...@@ -108,7 +108,7 @@ IntRect InlineTextBox::selectionRect(int tx, int ty, int startPos, int endPos) ...@@ -108,7 +108,7 @@ IntRect InlineTextBox::selectionRect(int tx, int ty, int startPos, int endPos)
int sPos = max(startPos - m_start, 0); int sPos = max(startPos - m_start, 0);
int ePos = min(endPos - m_start, (int)m_len); int ePos = min(endPos - m_start, (int)m_len);
if (sPos >= ePos) if (sPos > ePos)
return IntRect(); return IntRect();
RenderText* textObj = textRenderer(); RenderText* textObj = textRenderer();
......
...@@ -288,7 +288,7 @@ void RenderText::absoluteQuadsForRange(Vector<FloatQuad>& quads, unsigned start, ...@@ -288,7 +288,7 @@ void RenderText::absoluteQuadsForRange(Vector<FloatQuad>& quads, unsigned start,
} else { } else {
unsigned realEnd = min(box->end() + 1, end); unsigned realEnd = min(box->end() + 1, end);
IntRect r = box->selectionRect(0, 0, start, realEnd); IntRect r = box->selectionRect(0, 0, start, realEnd);
if (!r.isEmpty()) { if (r.height()) {
if (!useSelectionHeight) { if (!useSelectionHeight) {
// change the height and y position because selectionRect uses selection-specific values // change the height and y position because selectionRect uses selection-specific values
r.setHeight(box->height()); r.setHeight(box->height());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment