Changeset 101561 in webkit


Ignore:
Timestamp:
Nov 30, 2011 3:27:07 PM (12 years ago)
Author:
rniwa@webkit.org
Message:

Cannot select RTL text inside LTR text from right to left by a mouse drag
https://bugs.webkit.org/show_bug.cgi?id=73056

Reviewed by Eric Seidel.

Source/WebCore:

The bug was caused by positionAtRightBoundaryOfBiDiRun using current inline box's offset
even when creating a position with previous inline box. Fixed the bug by using the correct offset.

  • editing/RenderedPosition.cpp:

(WebCore::RenderedPosition::positionAtLeftBoundaryOfBiDiRun):
(WebCore::RenderedPosition::positionAtRightBoundaryOfBiDiRun):

LayoutTests:

Added a test case to ensure WebKit can select "A" in "aCBAb" when selecting text by a mouse drag
from the position between "A" and "b" to the position between "B" and "A".

  • editing/selection/select-bidi-run-expected.txt:
  • editing/selection/select-bidi-run.html:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r101560 r101561  
     12011-11-30  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Cannot select RTL text inside LTR text from right to left by a mouse drag
     4        https://bugs.webkit.org/show_bug.cgi?id=73056
     5
     6        Reviewed by Eric Seidel.
     7
     8        Added a test case to ensure WebKit can select "A" in "aCBAb" when selecting text by a mouse drag
     9        from the position between "A" and "b" to the position between "B" and "A".
     10
     11        * editing/selection/select-bidi-run-expected.txt:
     12        * editing/selection/select-bidi-run.html:
     13
    1142011-11-30  Chris Fleizach  <cfleizach@apple.com>
    215
  • trunk/LayoutTests/editing/selection/select-bidi-run-expected.txt

    r95964 r101561  
    113113FAIL selected "123" but expected "ABC 123"
    114114
     115Test "ABC" in "aABCb":
     116Selecting from left to right
     117PASS selected "C"
     118PASS selected "BC"
     119PASS selected "ABC"
     120Selecting from right to left
     121PASS selected "A"
     122PASS selected "AB"
     123PASS selected "ABC"
     124
    115125PASS successfullyParsed is true
    116126
  • trunk/LayoutTests/editing/selection/select-bidi-run.html

    r99258 r101561  
    99dd { font-size: 0.6em; margin: 0px; padding: 0px 10px; }
    1010.target { background-color: #bbeeff; }
     11.targetContainer { position: absolute; left: 10px; top: 0px; z-index: -5; }
    1112</style>
    1213</head>
     
    4546<dd>1,12, 123,C 123,BC 123,ABC 123|A,AB,ABC,ABC ,ABC 12,ABC 1,ABC 123</dd>
    4647
     48<dt contenteditable style="position: relative;">aאבגb<div class="targetContainer">a<span class="target">אבג</span>b</div></dt>
     49<dd>C,BC,ABC|A,AB,ABC</dd>
     50
    4751<!--<dt contenteditable><span class="target">אבג 123 - 456</span></dt>
    4852<dd>1,12, 123,C 123,BC 123,ABC 123|A,AB,ABC,ABC ,ABC 12,ABC 1,ABC 123</dd>-->
     
    7175    var y = target.offsetTop + target.offsetHeight / 2;
    7276    var left = target.offsetLeft;
     77
     78    offsetParent = target.offsetParent;
     79    while (offsetParent) {
     80        y += offsetParent.offsetTop;
     81        left += offsetParent.offsetLeft;
     82        offsetParent = offsetParent.offsetParent;
     83    }
    7384
    7485    var startX = left + (leftToRight ? 0 : target.offsetWidth);
     
    115126
    116127        var target = tests[i].getElementsByClassName('target')[0];
     128        var relativeTargets = tests[i].getElementsByClassName('relativeTarget');
    117129        var testExpectation = testExpectations[i].textContent;
    118130
  • trunk/Source/WebCore/ChangeLog

    r101560 r101561  
     12011-11-30  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Cannot select RTL text inside LTR text from right to left by a mouse drag
     4        https://bugs.webkit.org/show_bug.cgi?id=73056
     5
     6        Reviewed by Eric Seidel.
     7
     8        The bug was caused by positionAtRightBoundaryOfBiDiRun using current inline box's offset
     9        even when creating a position with previous inline box. Fixed the bug by using the correct offset.
     10
     11        * editing/RenderedPosition.cpp:
     12        (WebCore::RenderedPosition::positionAtLeftBoundaryOfBiDiRun):
     13        (WebCore::RenderedPosition::positionAtRightBoundaryOfBiDiRun):
     14
    1152011-11-30 Chris Fleizach  <cfleizach@apple.com>
    216
  • trunk/Source/WebCore/editing/RenderedPosition.cpp

    r95964 r101561  
    212212        return createLegacyEditingPosition(m_renderer->node(), m_offset);
    213213
    214     return createLegacyEditingPosition(nextLeafChild()->renderer()->node(), m_offset);
     214    return createLegacyEditingPosition(nextLeafChild()->renderer()->node(), nextLeafChild()->caretLeftmostOffset());
    215215}
    216216
     
    222222        return createLegacyEditingPosition(m_renderer->node(), m_offset);
    223223
    224     return createLegacyEditingPosition(prevLeafChild()->renderer()->node(), m_offset);
     224    return createLegacyEditingPosition(prevLeafChild()->renderer()->node(), prevLeafChild()->caretRightmostOffset());
    225225}
    226226
Note: See TracChangeset for help on using the changeset viewer.