⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 93221 in webkit


Ignore:
Timestamp:
Aug 17, 2011, 11:07:33 AM (15 years ago)
Author:
rniwa@webkit.org
Message:

An arrow key collapses directionless selection range in the wrong direction in BiDi
https://bugs.webkit.org/show_bug.cgi?id=64626

Reviewed by Darin Adler.

Source/WebCore:

The bug was caused by willBeModified's always using block direction to determine
the direction to which the selection is collapsed. Fixed the bug by calling directionOfSelection
in willBeModified, which will return the text direction of the surrounding context when
the start and the end have the same direction. When the text directions at the start and at the end
of selection do not match, it uses the block's text direction.

Test: editing/selection/collapse-selection-in-bidi.html

  • editing/FrameSelection.cpp:

(WebCore::FrameSelection::directionOfSelection): Added.
(WebCore::FrameSelection::willBeModified): Calls directionOfSelection.
(WebCore::FrameSelection::modifyMovingRight): Ditto.
(WebCore::FrameSelection::modifyMovingLeft): Ditto.

  • editing/FrameSelection.h:

LayoutTests:

Added a test to ensure collapsing directionless selection respects the direction of text around
the selection's end points.

  • editing/selection/collapse-selection-in-bidi-expected.txt: Added.
  • editing/selection/collapse-selection-in-bidi.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r93217 r93221  
     12011-08-17  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        An arrow key collapses directionless selection range in the wrong direction in BiDi
     4        https://bugs.webkit.org/show_bug.cgi?id=64626
     5
     6        Reviewed by Darin Adler.
     7
     8        Added a test to ensure collapsing directionless selection respects the direction of text around
     9        the selection's end points.
     10
     11        * editing/selection/collapse-selection-in-bidi-expected.txt: Added.
     12        * editing/selection/collapse-selection-in-bidi.html: Added.
     13
    1142011-08-17  Steve Block  <steveblock@google.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r93219 r93221  
     12011-08-17  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        An arrow key collapses directionless selection range in the wrong direction in BiDi
     4        https://bugs.webkit.org/show_bug.cgi?id=64626
     5
     6        Reviewed by Darin Adler.
     7
     8        The bug was caused by willBeModified's always using block direction to determine
     9        the direction to which the selection is collapsed. Fixed the bug by calling directionOfSelection
     10        in willBeModified, which will return the text direction of the surrounding context when
     11        the start and the end have the same direction. When the text directions at the start and at the end
     12        of selection do not match, it uses the block's text direction.
     13
     14        Test: editing/selection/collapse-selection-in-bidi.html
     15
     16        * editing/FrameSelection.cpp:
     17        (WebCore::FrameSelection::directionOfSelection): Added.
     18        (WebCore::FrameSelection::willBeModified): Calls directionOfSelection.
     19        (WebCore::FrameSelection::modifyMovingRight): Ditto.
     20        (WebCore::FrameSelection::modifyMovingLeft): Ditto.
     21        * editing/FrameSelection.h:
     22
    1232011-08-17  Jeff Miller  <jeffm@apple.com>
    224
  • trunk/Source/WebCore/editing/FrameSelection.cpp

    r93134 r93221  
    391391}
    392392
     393TextDirection FrameSelection::directionOfSelection()
     394{
     395    InlineBox* startBox = 0;
     396    InlineBox* endBox = 0;
     397    int unusedOffset;
     398    if (m_selection.start().isNotNull())
     399        m_selection.visibleStart().getInlineBoxAndOffset(startBox, unusedOffset);
     400    if (m_selection.end().isNotNull())
     401        m_selection.visibleEnd().getInlineBoxAndOffset(endBox, unusedOffset);
     402    if (startBox && endBox && startBox->direction() == endBox->direction())
     403        return startBox->direction();
     404
     405    return directionOfEnclosingBlock();
     406}
     407
    393408void FrameSelection::willBeModified(EAlteration alter, SelectionDirection direction)
    394409{
     
    412427        switch (direction) {
    413428        case DirectionRight:
    414             if (directionOfEnclosingBlock() == LTR)
     429            if (directionOfSelection() == LTR)
    415430                baseIsStart = true;
    416431            else
     
    421436            break;
    422437        case DirectionLeft:
    423             if (directionOfEnclosingBlock() == LTR)
     438            if (directionOfSelection() == LTR)
    424439                baseIsStart = false;
    425440            else
     
    554569    case CharacterGranularity:
    555570        if (isRange()) {
    556             if (directionOfEnclosingBlock() == LTR)
     571            if (directionOfSelection() == LTR)
    557572                pos = VisiblePosition(m_selection.end(), m_selection.affinity());
    558573            else
     
    725740    case CharacterGranularity:
    726741        if (isRange())
    727             if (directionOfEnclosingBlock() == LTR)
     742            if (directionOfSelection() == LTR)
    728743                pos = VisiblePosition(m_selection.start(), m_selection.affinity());
    729744            else
  • trunk/Source/WebCore/editing/FrameSelection.h

    r93134 r93221  
    249249    void respondToNodeModification(Node*, bool baseRemoved, bool extentRemoved, bool startRemoved, bool endRemoved);
    250250    TextDirection directionOfEnclosingBlock();
     251    TextDirection directionOfSelection();
    251252
    252253    VisiblePosition positionForPlatform(bool isGetStart) const;
Note: See TracChangeset for help on using the changeset viewer.