Changeset 74971 in webkit


Ignore:
Timestamp:
Jan 4, 2011 9:21:13 AM (13 years ago)
Author:
rniwa@webkit.org
Message:

2011-01-04 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Dan Bernstein.

Clicking on the first or the last letter of LTR/RTL text in a RTL/LTR block puts caret on the opposite side.
https://bugs.webkit.org/show_bug.cgi?id=50992

Fixed the bug by interchanging the offset when the direction of inline text box and the containing block
does not match. Reused the code added by http://trac.webkit.org/changeset/73553.

Test: editing/selection/caret-bidi-first-and-last-letters.html

  • rendering/InlineTextBox.cpp: (WebCore::InlineTextBox::offsetForPosition):

2011-01-04 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Dan Bernstein.

Clicking on the first or the last letter of LTR/RTL text in a RTL/LTR block puts caret on the opposite side.
https://bugs.webkit.org/show_bug.cgi?id=50992

Added a test to ensure WebKit places the caret on the side user clicked even when text's natural direction
and the containing block's direction do not match.

  • editing/selection/caret-bidi-first-and-last-letters-expected.txt: Added.
  • editing/selection/caret-bidi-first-and-last-letters.html: Added.
  • editing/selection/resources/caret-edge-shared.js: Avoid calling verify() outside of DRT.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r74963 r74971  
     12011-01-04  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        Clicking on the first or the last letter of LTR/RTL text in a RTL/LTR block puts caret on the opposite side.
     6        https://bugs.webkit.org/show_bug.cgi?id=50992
     7
     8        Added a test to ensure WebKit places the caret on the side user clicked even when text's natural direction
     9        and the containing block's direction do not match.
     10
     11        * editing/selection/caret-bidi-first-and-last-letters-expected.txt: Added.
     12        * editing/selection/caret-bidi-first-and-last-letters.html: Added.
     13        * editing/selection/resources/caret-edge-shared.js: Avoid calling verify() outside of DRT.
     14
    1152011-01-04  Sheriff Bot  <webkit.review.bot@gmail.com>
    216
  • trunk/LayoutTests/editing/selection/resources/caret-edge-shared.js

    r73548 r74971  
    33    var div = document.getElementsByTagName('div')[0];
    44
    5     if (!window.layoutTestController) {
    6         div.addEventListener('mouseup', verify);
     5    if (!window.layoutTestController)
    76        return;
    8     }
    97
    108    if (clickOn == 'left')
  • trunk/WebCore/ChangeLog

    r74969 r74971  
     12011-01-04  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        Clicking on the first or the last letter of LTR/RTL text in a RTL/LTR block puts caret on the opposite side.
     6        https://bugs.webkit.org/show_bug.cgi?id=50992
     7
     8        Fixed the bug by interchanging the offset when the direction of inline text box and the containing block
     9        does not match. Reused the code added by http://trac.webkit.org/changeset/73553.
     10
     11        Test: editing/selection/caret-bidi-first-and-last-letters.html
     12
     13        * rendering/InlineTextBox.cpp:
     14        (WebCore::InlineTextBox::offsetForPosition):
     15
    1162010-12-29  Tony Gentilcore  <tonyg@chromium.org>
    217
  • trunk/WebCore/rendering/InlineTextBox.cpp

    r74969 r74971  
    11481148    int leftOffset = isLeftToRightDirection() ? 0 : m_len;
    11491149    int rightOffset = isLeftToRightDirection() ? m_len : 0;
    1150     if (renderer()->containingBlock()->style()->isLeftToRightDirection() != isLeftToRightDirection())
     1150    bool blockIsInOppositeDirection = renderer()->containingBlock()->style()->isLeftToRightDirection() != isLeftToRightDirection();
     1151    if (blockIsInOppositeDirection)
    11511152        swap(leftOffset, rightOffset);
    11521153
     
    11591160    RenderStyle* style = text->style(m_firstLine);
    11601161    const Font* f = &style->font();
    1161     return f->offsetForPosition(TextRun(textRenderer()->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_toAdd, !isLeftToRightDirection(), m_dirOverride || style->visuallyOrdered()),
     1162    int offset = f->offsetForPosition(TextRun(textRenderer()->text()->characters() + m_start, m_len,
     1163        textRenderer()->allowTabs(), textPos(), m_toAdd, !isLeftToRightDirection(), m_dirOverride || style->visuallyOrdered()),
    11621164        lineOffset - logicalLeft(), includePartialGlyphs);
     1165    if (blockIsInOppositeDirection && (!offset || offset == m_len))
     1166        return !offset ? m_len : 0;
     1167    return offset;
    11631168}
    11641169
Note: See TracChangeset for help on using the changeset viewer.