Changeset 19811 in webkit


Ignore:
Timestamp:
Feb 22, 2007 3:51:47 PM (17 years ago)
Author:
justing
Message:

LayoutTests:

Reviewed by darin


<rdar://problem/5007143>
REGRESSION: WebKit doesn't remember horizontal position of caret when moving forward by line

Added, tests the removal of the use of the
recalc bool from xPosForVerticalArrowNavigation(...):

  • editing/selection/5007143-2-expected.checksum: Added.
  • editing/selection/5007143-2-expected.png: Added.
  • editing/selection/5007143-2-expected.txt: Added.
  • editing/selection/5007143-2.html: Added. Added, demonstrate the changes to modify:
  • editing/selection/5007143-expected.checksum: Added.
  • editing/selection/5007143-expected.png: Added.
  • editing/selection/5007143-expected.txt: Added.
  • editing/selection/5007143.html: Added. Demonstrates a bug (filed 5017312):
  • editing/style/block-style-004-expected.txt:
  • editing/style/block-style-005-expected.txt:
  • editing/style/block-style-006-expected.txt: Fixed:
  • editing/selection/3690703-2-expected.checksum:
  • editing/selection/3690703-2-expected.png:
  • editing/selection/3690703-2-expected.txt:
  • editing/style/create-block-for-style-009-expected.checksum:
  • editing/style/create-block-for-style-009-expected.png:
  • editing/style/create-block-for-style-009-expected.txt:
  • editing/style/create-block-for-style-011-expected.checksum:
  • editing/style/create-block-for-style-011-expected.png:
  • editing/style/create-block-for-style-011-expected.txt:

WebCore:

Reviewed by darin


<rdar://problem/5007143>
REGRESSION: WebKit doesn't remember horizontal position of caret when moving forward by line

  • editing/SelectionController.cpp: (WebCore::SelectionController::SelectionController): Initialize m_xPosForVerticalArrowNavigation. (WebCore::SelectionController::setSelection): Call the new setter. (WebCore::SelectionController::modifyMovingRightForward): For line and paragraph granularities, use the saved xPosForVerticalArrowNavigation even if the old selection was a range. Use the x position of the *start*, not the end of the selection if there is no saved xPosForVerticalArrowNavigation. This matches TextEdit's behavior. (WebCore::SelectionController::modifyMovingLeftBackward): For line and paragraph granularities, use the saved xPosForVerticalArrowNavigation even if the old selection was a range. (WebCore::SelectionController::modify): Preserve the xPosForVerticalArrowNavigation for line and paragraph granularities. (WebCore::SelectionController::xPosForVerticalArrowNavigation): Removed the recalc bool because it is now always false. (WebCore::SelectionController::setXPosForVerticalArrowNavigation): Added.
  • editing/SelectionController.h: Moved m_xPosForVerticalArrowNavigation from Frame.
  • page/Frame.cpp: Moved m_xPosForVerticalArrowNavigation to SelectionController.
  • page/Frame.h: Ditto.
  • page/FramePrivate.h: Ditto.
Location:
trunk
Files:
8 added
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r19806 r19811  
     12007-02-22  Justin Garcia  <justin.garcia@apple.com>
     2
     3        Reviewed by darin
     4       
     5        <rdar://problem/5007143>
     6        REGRESSION: WebKit doesn't remember horizontal position of caret when moving forward by line
     7
     8        Added, tests the removal of the use of the
     9        recalc bool from xPosForVerticalArrowNavigation(...):
     10        * editing/selection/5007143-2-expected.checksum: Added.
     11        * editing/selection/5007143-2-expected.png: Added.
     12        * editing/selection/5007143-2-expected.txt: Added.
     13        * editing/selection/5007143-2.html: Added.
     14        Added, demonstrate the changes to modify:
     15        * editing/selection/5007143-expected.checksum: Added.
     16        * editing/selection/5007143-expected.png: Added.
     17        * editing/selection/5007143-expected.txt: Added.
     18        * editing/selection/5007143.html: Added.
     19        Demonstrates a bug (filed 5017312):
     20        * editing/style/block-style-004-expected.txt:
     21        * editing/style/block-style-005-expected.txt:
     22        * editing/style/block-style-006-expected.txt:
     23        Fixed:
     24        * editing/selection/3690703-2-expected.checksum:
     25        * editing/selection/3690703-2-expected.png:
     26        * editing/selection/3690703-2-expected.txt:
     27        * editing/style/create-block-for-style-009-expected.checksum:
     28        * editing/style/create-block-for-style-009-expected.png:
     29        * editing/style/create-block-for-style-009-expected.txt:
     30        * editing/style/create-block-for-style-011-expected.checksum:
     31        * editing/style/create-block-for-style-011-expected.png:
     32        * editing/style/create-block-for-style-011-expected.txt:
     33
    1342007-02-22  Adele Peterson  <adele@apple.com>
    235
  • trunk/LayoutTests/editing/selection/3690703-2-expected.checksum

    r14777 r19811  
    1 452b613a30dd16c4dc466d6a7c26d8e6
     12670a8da12f9a73062439bd90375c24d
  • trunk/LayoutTests/editing/selection/3690703-2-expected.txt

    r19605 r19811  
    148148layer at (206,88) size 385x13
    149149  RenderBlock {DIV} at (3,3) size 385x13
    150 selection start: position 0 of child 4 {INPUT} of child 1 {TD} of child 0 {TR} of child 0 {TBODY} of child 2 {TABLE} of child 4 {DIV} of child 0 {CENTER} of child 1 {BODY} of child 0 {HTML} of document
     150selection start: position 0 of child 3 {INPUT} of child 1 {TD} of child 0 {TR} of child 0 {TBODY} of child 2 {TABLE} of child 4 {DIV} of child 0 {CENTER} of child 1 {BODY} of child 0 {HTML} of document
    151151selection end:   position 1 of child 2 {BR} of child 0 {FONT} of child 2 {TD} of child 0 {TR} of child 0 {TBODY} of child 2 {TABLE} of child 4 {DIV} of child 0 {CENTER} of child 1 {BODY} of child 0 {HTML} of document
  • trunk/LayoutTests/editing/style/block-style-004-expected.txt

    r19605 r19811  
    1212EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1313EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     14EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1415EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1516EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
  • trunk/LayoutTests/editing/style/block-style-005-expected.txt

    r19605 r19811  
    1212EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1313EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     14EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1415EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1516EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
  • trunk/LayoutTests/editing/style/block-style-006-expected.txt

    r19605 r19811  
    1212EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1313EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     14EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1415EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1516EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
  • trunk/LayoutTests/editing/style/create-block-for-style-009-expected.checksum

    r12711 r19811  
    1 e7b924dbdde9acccf847881eafab9aed
     19f6f3cef5f3215cca9f6557f89cacf1a
  • trunk/LayoutTests/editing/style/create-block-for-style-009-expected.txt

    r19605 r19811  
    44EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    55EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    6 EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 2 of #text > DIV > DIV > DIV > BODY > HTML > #document to 2 of #text > DIV > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     6EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    77EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    88EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     
    2828              text run at (361,0) width 34: "baz"
    2929          RenderBlock (anonymous) at (14,126) size 756x0
    30 caret: position 2 of child 0 {#text} of child 2 {DIV} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
     30caret: position 1 of child 0 {#text} of child 2 {DIV} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
  • trunk/LayoutTests/editing/style/create-block-for-style-011-expected.checksum

    r12711 r19811  
    1 13699ca76620e54ff95b441919cea70d
     13c9f840fe96eb5903f08fdced33ac2e0
  • trunk/LayoutTests/editing/style/create-block-for-style-011-expected.txt

    r19605 r19811  
    55EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    66EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    7 EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > DIV > DIV > DIV > BODY > HTML > #document to 3 of #text > DIV > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     7EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > DIV > DIV > DIV > BODY > HTML > #document to 2 of #text > DIV > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    88EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    99EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     
    3030          RenderBlock (anonymous) at (14,126) size 756x0
    3131selection start: position 1 of child 0 {#text} of child 1 {DIV} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
    32 selection end:   position 3 of child 0 {#text} of child 2 {DIV} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
     32selection end:   position 2 of child 0 {#text} of child 2 {DIV} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
  • trunk/WebCore/ChangeLog

    r19810 r19811  
     12007-02-22  Justin Garcia  <justin.garcia@apple.com>
     2
     3        Reviewed by darin
     4       
     5        <rdar://problem/5007143>
     6        REGRESSION: WebKit doesn't remember horizontal position of caret when moving forward by line
     7
     8        * editing/SelectionController.cpp:
     9        (WebCore::SelectionController::SelectionController): Initialize
     10        m_xPosForVerticalArrowNavigation.
     11        (WebCore::SelectionController::setSelection): Call the new setter.
     12        (WebCore::SelectionController::modifyMovingRightForward): For line
     13        and paragraph granularities, use the saved xPosForVerticalArrowNavigation
     14        even if the old selection was a range. Use the x position of the
     15        *start*, not the end of the selection if there is no saved
     16        xPosForVerticalArrowNavigation.  This matches TextEdit's behavior.
     17        (WebCore::SelectionController::modifyMovingLeftBackward): For line
     18        and paragraph granularities, use the saved xPosForVerticalArrowNavigation
     19        even if the old selection was a range.
     20        (WebCore::SelectionController::modify): Preserve the xPosForVerticalArrowNavigation
     21        for line and paragraph granularities.
     22        (WebCore::SelectionController::xPosForVerticalArrowNavigation): Removed
     23        the recalc bool because it is now always false.
     24        (WebCore::SelectionController::setXPosForVerticalArrowNavigation): Added.
     25        * editing/SelectionController.h: Moved m_xPosForVerticalArrowNavigation
     26        from Frame.
     27        * page/Frame.cpp: Moved m_xPosForVerticalArrowNavigation to SelectionController.
     28        * page/Frame.h: Ditto.
     29        * page/FramePrivate.h: Ditto.
     30
    1312007-02-22  Beth Dakin  <bdakin@apple.com>
    232
  • trunk/WebCore/editing/SelectionController.cpp

    r19785 r19811  
    6464    , m_isDragCaretController(isDragCaretController)
    6565    , m_isCaretBlinkingSuspended(false)
     66    , m_xPosForVerticalArrowNavigation(NoXPosForVerticalArrowNavigation)
    6667{
    6768}
     
    134135    // Always clear the x position used for vertical arrow navigation.
    135136    // It will be restored by the vertical arrow navigation code if necessary.
    136     m_frame->setXPosForVerticalArrowNavigation(NoXPosForVerticalArrowNavigation);
     137    m_xPosForVerticalArrowNavigation = NoXPosForVerticalArrowNavigation;
    137138    selectFrameElementInParentIfFullySelected();
    138139    m_frame->notifyRendererOfSelectionChange(userTriggered);
     
    289290            pos = VisiblePosition(m_sel.end(), m_sel.affinity());
    290291            if (!isRange() || !isStartOfLine(pos))
    291                 pos = nextLinePosition(pos, xPosForVerticalArrowNavigation(END, isRange()));
     292                pos = nextLinePosition(pos, xPosForVerticalArrowNavigation(START));
    292293            break;
    293294        }
    294295        case ParagraphGranularity:
    295             pos = nextParagraphPosition(VisiblePosition(m_sel.end(), m_sel.affinity()), xPosForVerticalArrowNavigation(END, isRange()));
     296            pos = nextParagraphPosition(VisiblePosition(m_sel.end(), m_sel.affinity()), xPosForVerticalArrowNavigation(START));
    296297            break;
    297298        case SentenceBoundary:
     
    384385            break;
    385386        case LineGranularity:
    386             pos = previousLinePosition(VisiblePosition(m_sel.start(), m_sel.affinity()), xPosForVerticalArrowNavigation(START, isRange()));
     387            pos = previousLinePosition(VisiblePosition(m_sel.start(), m_sel.affinity()), xPosForVerticalArrowNavigation(START));
    387388            break;
    388389        case ParagraphGranularity:
    389             pos = previousParagraphPosition(VisiblePosition(m_sel.start(), m_sel.affinity()), xPosForVerticalArrowNavigation(START, isRange()));
     390            pos = previousParagraphPosition(VisiblePosition(m_sel.start(), m_sel.affinity()), xPosForVerticalArrowNavigation(START));
    390391            break;
    391392        case SentenceBoundary:
     
    495496    if (pos.isNull())
    496497        return false;
     498   
     499    // Some of the above operations set an xPosForVerticalArrowNavigation.
     500    // Setting a selection will clear it, so save it to possibly restore later.
     501    // Note: the START position type is arbitrary because it is unused, it would be
     502    // the requested position type if there were no xPosForVerticalArrowNavigation set.
     503    int x = xPosForVerticalArrowNavigation(START);
    497504
    498505    switch (alter) {
     
    504511            break;
    505512    }
     513   
     514    if (granularity == LineGranularity || granularity == ParagraphGranularity)
     515        m_xPosForVerticalArrowNavigation = x;
    506516
    507517    if (userTriggered) {
     
    562572        case MOVE:
    563573            pos = VisiblePosition(up ? m_sel.start() : m_sel.end(), m_sel.affinity());
    564             xPos = xPosForVerticalArrowNavigation(up ? START : END, isRange());
     574            xPos = xPosForVerticalArrowNavigation(up ? START : END);
    565575            m_sel.setAffinity(up ? UPSTREAM : DOWNSTREAM);
    566576            break;
     
    626636}
    627637
    628 int SelectionController::xPosForVerticalArrowNavigation(EPositionType type, bool recalc) const
     638int SelectionController::xPosForVerticalArrowNavigation(EPositionType type)
    629639{
    630640    int x = 0;
     
    653663        return x;
    654664       
    655     if (recalc || frame->xPosForVerticalArrowNavigation() == NoXPosForVerticalArrowNavigation) {
     665    if (m_xPosForVerticalArrowNavigation == NoXPosForVerticalArrowNavigation) {
    656666        pos = VisiblePosition(pos, m_sel.affinity()).deepEquivalent();
    657667        // VisiblePosition creation can fail here if a node containing the selection becomes visibility:hidden
    658668        // after the selection is created and before this function is called.
    659669        x = pos.isNotNull() ? pos.node()->renderer()->caretRect(pos.offset(), m_sel.affinity()).x() : 0;
    660         frame->setXPosForVerticalArrowNavigation(x);
    661     }
    662     else {
    663         x = frame->xPosForVerticalArrowNavigation();
    664     }
     670        m_xPosForVerticalArrowNavigation = x;
     671    }
     672    else
     673        x = m_xPosForVerticalArrowNavigation;
     674       
    665675    return x;
    666676}
  • trunk/WebCore/editing/SelectionController.h

    r19785 r19811  
    167167    IntRect caretRepaintRect() const;
    168168
    169     int xPosForVerticalArrowNavigation(EPositionType, bool recalc = false) const;
     169    int xPosForVerticalArrowNavigation(EPositionType);
    170170
    171171    Selection m_sel;
     
    185185
    186186    bool m_isCaretBlinkingSuspended;
     187   
     188    int m_xPosForVerticalArrowNavigation;
    187189};
    188190
  • trunk/WebCore/page/Frame.cpp

    r19702 r19811  
    641641}
    642642
    643 void Frame::setXPosForVerticalArrowNavigation(int x)
    644 {
    645     d->m_xPosForVerticalArrowNavigation = x;
    646 }
    647 
    648 int Frame::xPosForVerticalArrowNavigation() const
    649 {
    650     return d->m_xPosForVerticalArrowNavigation;
    651 }
    652 
    653643void Frame::caretBlinkTimerFired(Timer<Frame>*)
    654644{
  • trunk/WebCore/page/Frame.h

    r19702 r19811  
    320320    void paintDragCaret(GraphicsContext*, const IntRect&) const;
    321321
    322     void setXPosForVerticalArrowNavigation(int);
    323     int xPosForVerticalArrowNavigation() const;
    324 
    325322    bool isContentEditable() const; // if true, everything in frame is editable
    326323
  • trunk/WebCore/page/FramePrivate.h

    r19702 r19811  
    9999        bool m_isActive : 1;
    100100
    101         int m_xPosForVerticalArrowNavigation;
    102101        RefPtr<CSSMutableStyleDeclaration> m_typingStyle;
    103102
Note: See TracChangeset for help on using the changeset viewer.