Changeset 54117 in webkit


Ignore:
Timestamp:
Jan 31, 2010 4:54:49 PM (14 years ago)
Author:
ojan@chromium.org
Message:

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):
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r54113 r54117  
     12010-01-28  Ojan Vafai  <ojan@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Implement CSSOM Range.getClientRects for collapsed selections
     6        https://bugs.webkit.org/show_bug.cgi?id=34239
     7
     8        Adds two cases to getClientRects test.
     9
     10        * fast/dom/Range/getClientRects-expected.txt:
     11        * fast/dom/Range/getClientRects.html:
     12
    1132010-01-31  Oliver Hunt  <oliver@apple.com>
    214
  • trunk/LayoutTests/fast/dom/Range/getClientRects-expected.txt

    r48806 r54117  
    187187PASS rects[3].width is 212
    188188PASS rects[3].height is 247
     189Test 9
     190FAIL rects.length should be 1. Was 0.
     191FAIL rects[0].left should be 8. Threw exception TypeError: Result of expression 'rects[0]' [undefined] is not an object.
     192FAIL rects[0].top should be 1903. Threw exception TypeError: Result of expression 'rects[0]' [undefined] is not an object.
     193FAIL rects[0].width should be 0. Threw exception TypeError: Result of expression 'rects[0]' [undefined] is not an object.
     194FAIL rects[0].height should be 18. Threw exception TypeError: Result of expression 'rects[0]' [undefined] is not an object.
     195Test 9b
     196PASS rects.length is 1
     197PASS rects[0].left is 8
     198PASS rects[0].top is 1903
     199PASS rects[0].width is 0
     200PASS rects[0].height is 18
    189201PASS successfullyParsed is true
    190202
  • trunk/LayoutTests/fast/dom/Range/getClientRects.html

    r48806 r54117  
    6969
    7070<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>
     71
     72<br><br>
     73
     74<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>
    7175
    7276</div>
     
    340344    shouldBe("rects[3].height", "247");
    341345
     346    debug("Test 9");
     347    var range9 = document.createRange();
     348    // This case should match test 9b's results. Currently though getClientRects returns an empty list.
     349    range9.setStart(document.getElementById('test9'), 0);
     350    show(range9);
     351    rects = range9.getClientRects();
     352    shouldBe("rects.length", "1");
     353    shouldBe("rects[0].left", "8");
     354    shouldBe("rects[0].top", "1903");
     355    shouldBe("rects[0].width", "0");
     356    shouldBe("rects[0].height", "18");
     357
     358    debug("Test 9b");
     359    var range9 = document.createRange();
     360    range9.setStart(document.getElementById('test9').firstChild, 0);
     361    show(range9);
     362    rects = range9.getClientRects();
     363    shouldBe("rects.length", "1");
     364    shouldBe("rects[0].left", "8");
     365    shouldBe("rects[0].top", "1903");
     366    shouldBe("rects[0].width", "0");
     367    shouldBe("rects[0].height", "18");
     368
    342369    if (window.layoutTestController) {
    343370        var area = document.getElementById('testArea');
  • trunk/WebCore/ChangeLog

    r54115 r54117  
     12010-01-28  Ojan Vafai  <ojan@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Implement CSSOM Range.getClientRects for collapsed selections
     6        https://bugs.webkit.org/show_bug.cgi?id=34239
     7
     8        When getting the quads for a range on a text node, allow returning
     9        zero width quads. This leaves the case of collapsed selections inside
     10        elements still not fixed, but no worse.
     11
     12        * rendering/InlineTextBox.cpp:
     13        (WebCore::InlineTextBox::selectionRect):
     14        * rendering/RenderText.cpp:
     15        (WebCore::RenderText::absoluteQuadsForRange):
     16
    1172010-01-31  Oliver Hunt  <oliver@apple.com>
    218
  • trunk/WebCore/rendering/InlineTextBox.cpp

    r52548 r54117  
    109109    int ePos = min(endPos - m_start, (int)m_len);
    110110   
    111     if (sPos >= ePos)
     111    if (sPos > ePos)
    112112        return IntRect();
    113113
  • trunk/WebCore/rendering/RenderText.cpp

    r52786 r54117  
    289289            unsigned realEnd = min(box->end() + 1, end);
    290290            IntRect r = box->selectionRect(0, 0, start, realEnd);
    291             if (!r.isEmpty()) {
     291            if (r.height()) {
    292292                if (!useSelectionHeight) {
    293293                    // change the height and y position because selectionRect uses selection-specific values
Note: See TracChangeset for help on using the changeset viewer.