Changeset 16122 in webkit


Ignore:
Timestamp:
Aug 30, 2006 1:00:37 PM (18 years ago)
Author:
justing
Message:

LayoutTests:

Reviewed by harrison


<rdar://problem/4700297>
REGRESSION: After replacing a misspelled word in a sentence, the selection extends to end of current line


Fixed:

  • editing/pasteboard/smart-paste-002-expected.checksum:
  • editing/pasteboard/smart-paste-002-expected.png:
  • editing/pasteboard/smart-paste-002-expected.txt: Added to demonstrate fix:
  • editing/pasteboard/4700297-expected.checksum: Added.
  • editing/pasteboard/4700297-expected.png: Added.
  • editing/pasteboard/4700297-expected.txt: Added.
  • editing/pasteboard/4700297.html: Added. Removed a superfluous style span:
  • editing/deleting/pruning-after-merge-1-expected.txt:
  • editing/pasteboard/interchange-newline-1-expected.txt:
  • editing/pasteboard/paste-text-019-expected.checksum:
  • editing/pasteboard/paste-text-019-expected.png:
  • editing/pasteboard/paste-text-019-expected.txt:
  • editing/selection/drag-to-contenteditable-iframe-expected.txt: Accidently checked in bad results yesterday:
  • editing/pasteboard/copy-paste-bidi-expected.txt: Equivalent render tree:
  • editing/pasteboard/smart-paste-001-expected.txt:

WebCore:

Reviewed by harrison


<rdar://problem/4700297>
REGRESSION: After replacing a misspelled word in a sentence, the selection extends to end of current line

  • editing/ReplaceSelectionCommand.cpp: (WebCore::ReplaceSelectionCommand::doApply): Rebalance whitespace around insertionPos before insertion because the content might cause a collapse, e.g. inserting <div>foo</div> at hello world.
  • editing/htmlediting.cpp: (WebCore::rebalanceWhitespaceInTextNode): Rebalance with all nbsps for simplicity, we can produce sequences of regular spaces and nbsps on serialization (10636).
Location:
trunk
Files:
4 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r16117 r16122  
     12006-08-29  Justin Garcia  <justin.garcia@apple.com>
     2
     3        Reviewed by harrison
     4       
     5        <rdar://problem/4700297>
     6        REGRESSION: After replacing a misspelled word in a sentence, the selection extends to end of current line
     7       
     8        Fixed:
     9        * editing/pasteboard/smart-paste-002-expected.checksum:
     10        * editing/pasteboard/smart-paste-002-expected.png:
     11        * editing/pasteboard/smart-paste-002-expected.txt:
     12        Added to demonstrate fix:
     13        * editing/pasteboard/4700297-expected.checksum: Added.
     14        * editing/pasteboard/4700297-expected.png: Added.
     15        * editing/pasteboard/4700297-expected.txt: Added.
     16        * editing/pasteboard/4700297.html: Added.
     17        Removed a superfluous style span:
     18        * editing/deleting/pruning-after-merge-1-expected.txt:
     19        * editing/pasteboard/interchange-newline-1-expected.txt:
     20        * editing/pasteboard/paste-text-019-expected.checksum:
     21        * editing/pasteboard/paste-text-019-expected.png:
     22        * editing/pasteboard/paste-text-019-expected.txt:
     23        * editing/selection/drag-to-contenteditable-iframe-expected.txt:
     24        Accidently checked in bad results yesterday:
     25        * editing/pasteboard/copy-paste-bidi-expected.txt:
     26        Equivalent render tree:
     27        * editing/pasteboard/smart-paste-001-expected.txt:
     28
    1292006-08-29  waylonis  <waylonis@google.com>
    230
  • trunk/LayoutTests/editing/deleting/pruning-after-merge-1-expected.txt

    r15975 r16122  
    3232          RenderText {#text} at (0,0) size 5x18
    3333            text run at (0,0) width 5: "f"
    34           RenderInline {SPAN} at (0,0) size 15x18
     34          RenderInline {B} at (0,0) size 15x18
    3535            RenderText {#text} at (5,0) size 15x18
    3636              text run at (5,0) width 15: "ar"
    37           RenderInline {B} at (0,0) size 0x18
    3837        RenderBlock (anonymous) at (0,18) size 784x18
    3938          RenderBlock {DIV} at (0,0) size 784x18
  • trunk/LayoutTests/editing/pasteboard/copy-paste-bidi-expected.txt

    r16088 r16122  
    4646              text run at (32,0) width 36 RTL: "\x{5E9}\x{5D3}\x{5D2}\x{5DB}"
    4747              text run at (68,0) width 4: ":"
     48          RenderBlock (anonymous) at (0,18) size 784x0
    4849          RenderBlock {DIV} at (0,18) size 784x18
    4950            RenderText {#text} at (712,0) size 72x18
  • trunk/LayoutTests/editing/pasteboard/interchange-newline-1-expected.txt

    r15918 r16122  
    2121          RenderText {#text} at (0,0) size 8x18
    2222            text run at (0,0) width 8: "x"
    23           RenderText {#text} at (8,0) size 21x18
    24             text run at (8,0) width 21: "foo"
    25           RenderInline {SPAN} at (0,0) size 0x18
     23          RenderInline {SPAN} at (0,0) size 21x18
     24            RenderText {#text} at (8,0) size 21x18
     25              text run at (8,0) width 21: "foo"
    2626        RenderBlock (anonymous) at (0,18) size 784x18
    2727          RenderBlock {DIV} at (0,0) size 784x18
     
    3232          RenderText {#text} at (0,0) size 8x18
    3333            text run at (0,0) width 8: "x"
    34 caret: position 0 of child 3 {#text} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
     34caret: position 0 of child 2 {#text} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
  • trunk/LayoutTests/editing/pasteboard/paste-text-019-expected.checksum

    r15918 r16122  
    1 60a3a69108263e9487ae750e514fbcc3
     1329f766c06e6f043242bfd9e28720822
  • trunk/LayoutTests/editing/pasteboard/paste-text-019-expected.txt

    r15918 r16122  
    1515EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1616EDITING DELEGATE: shouldInsertText:Bar replacingDOMRange:range from 4 of #text > SPAN > DIV > BODY > HTML > #document to 4 of #text > SPAN > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
    17 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 4 of #text > SPAN > DIV > BODY > HTML > #document to 4 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 1 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     17EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 4 of #text > SPAN > DIV > BODY > HTML > #document to 4 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 3 of #text > SPAN > DIV > BODY > HTML > #document to 3 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    1818EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1919EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     
    6868            RenderText {#text} at (0,0) size 35x28
    6969              text run at (0,0) width 35: "Bar"
    70           RenderText {#text} at (35,0) size 6x28
    71             text run at (35,0) width 6: " "
    72 caret: position 1 of child 2 {#text} of child 5 {DIV} of child 1 {BODY} of child 0 {HTML} of document
     70caret: position 3 of child 2 {#text} of child 1 {SPAN} of child 5 {DIV} of child 1 {BODY} of child 0 {HTML} of document
  • trunk/LayoutTests/editing/pasteboard/smart-paste-001-expected.txt

    r15918 r16122  
    55EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    66EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 5 of #text > DIV > DIV > BODY > HTML > #document to 5 of #text > DIV > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
    7 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 5 of #text > DIV > DIV > BODY > HTML > #document to 5 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 4 of #text > DIV > DIV > BODY > HTML > #document to 4 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     7EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 5 of #text > DIV > DIV > BODY > HTML > #document to 5 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 5 of #text > DIV > DIV > BODY > HTML > #document to 5 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    88EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    99EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     
    3232      RenderBlock {DIV} at (0,236) size 784x32
    3333        RenderBlock {DIV} at (0,0) size 784x32 [border: (2px solid #FF0000)]
    34           RenderText {#text} at (2,2) size 40x28
    35             text run at (2,2) width 40: "test "
    36           RenderText {#text} at (42,2) size 34x28
    37             text run at (42,2) width 34: "test"
     34          RenderText {#text} at (2,2) size 34x28
     35            text run at (2,2) width 34: "test"
     36          RenderText {#text} at (36,2) size 40x28
     37            text run at (36,2) width 40: " test"
    3838        RenderBlock (anonymous) at (0,32) size 784x0
    39 caret: position 4 of child 1 {#text} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
     39caret: position 5 of child 1 {#text} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
  • trunk/LayoutTests/editing/pasteboard/smart-paste-002-expected.checksum

    r13644 r16122  
    1 11895ba8ba4493d17ac8a12adb18aff4
     12b7e6aca0cf97c095c360a8a7abc2a4d
  • trunk/LayoutTests/editing/pasteboard/smart-paste-002-expected.txt

    r15918 r16122  
    55EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    66EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
    7 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 4 of #text > DIV > DIV > BODY > HTML > #document to 4 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     7EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 5 of #text > DIV > DIV > BODY > HTML > #document to 5 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    88EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    99EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     
    3333        RenderBlock (anonymous) at (0,0) size 784x0
    3434        RenderBlock {DIV} at (0,0) size 784x32 [border: (2px solid #FF0000)]
    35           RenderText {#text} at (2,2) size 34x28
    36             text run at (2,2) width 34: "test"
    37           RenderText {#text} at (36,2) size 40x28
    38             text run at (36,2) width 40: " test"
    39 caret: position 4 of child 0 {#text} of child 0 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
     35          RenderText {#text} at (2,2) size 40x28
     36            text run at (2,2) width 40: "test "
     37          RenderText {#text} at (42,2) size 34x28
     38            text run at (42,2) width 34: "test"
     39caret: position 5 of child 0 {#text} of child 0 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
  • trunk/LayoutTests/editing/selection/drag-to-contenteditable-iframe-expected.txt

    r15531 r16122  
    22EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 2 of BODY > HTML > #document to 2 of BODY > HTML > #document toDOMRange:range from 0 of #text > BODY > HTML > #document to 5 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    33EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
    4 EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of BODY > HTML > #document to 6 of BODY > HTML > #document
     4EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of BODY > HTML > #document to 4 of BODY > HTML > #document
    55EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
    66EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
  • trunk/WebCore/ChangeLog

    r16121 r16122  
     12006-08-29  Justin Garcia  <justin.garcia@apple.com>
     2
     3        Reviewed by harrison
     4       
     5        <rdar://problem/4700297>
     6        REGRESSION: After replacing a misspelled word in a sentence, the selection extends to end of current line
     7
     8        * editing/ReplaceSelectionCommand.cpp:
     9        (WebCore::ReplaceSelectionCommand::doApply): Rebalance whitespace
     10        around insertionPos before insertion because the content might
     11        cause a collapse, e.g. inserting <div>foo</div> at hello^ world.
     12        * editing/htmlediting.cpp:
     13        (WebCore::rebalanceWhitespaceInTextNode): Rebalance with all nbsps
     14        for simplicity, we can produce sequences of regular spaces and
     15        nbsps on serialization (10636).
     16
    1172006-08-30  Nikolas Zimmermann  <zimmermann@kde.org>
    218
  • trunk/WebCore/editing/ReplaceSelectionCommand.cpp

    r16088 r16122  
    483483    }
    484484   
     485    // Inserting content could cause whitespace to collapse, e.g. inserting <div>foo</div> into hello^ world.
     486    // We remove unrendered spaces and rebalance the rendered ones (turn them into nbsps) around insertionPos to prevent that.
     487    Position upstreamInsertionPos = insertionPos.upstream();
     488    deleteInsignificantText(insertionPos.upstream(), insertionPos.downstream());
     489    insertionPos = upstreamInsertionPos.downstream();
     490    rebalanceWhitespaceAt(insertionPos);
     491   
    485492    // NOTE: This would be an incorrect usage of downstream() if downstream() were changed to mean the last position after
    486493    // p that maps to the same visible position as p (since in the case where a br is at the end of a block and collapsed
     
    575582        m_firstNodeInserted = endingSelection().visibleStart().deepEquivalent().downstream().node();
    576583        if (!m_lastNodeInserted->inDocument())
    577             m_lastNodeInserted = endingSelection().visibleEnd().deepEquivalent().downstream().node();
     584            m_lastNodeInserted = endingSelection().visibleEnd().deepEquivalent().upstream().node();
    578585    }
    579586           
  • trunk/WebCore/editing/htmlediting.cpp

    r15563 r16122  
    348348void rebalanceWhitespaceInTextNode(Node *node, unsigned int start, unsigned int length)
    349349{
    350     static RegularExpression nonRegularWhitespace("[\xa0\n]");
    351     static DeprecatedString twoSpaces("  ");
     350    static RegularExpression whitespace("[ \t\n]");
    352351    static DeprecatedString nbsp("\xa0");
    353     static DeprecatedString space(" ");
    354352     
    355353    ASSERT(node->isTextNode());
     
    360358    DeprecatedString substring = text.substring(start, length).deprecatedString();
    361359
    362     substring.replace(nonRegularWhitespace, space);
    363    
    364     // The sequence should alternate between spaces and nbsps, always ending in a regular space.
    365     // Note: This pattern doesn't mimic TextEdit editing behavior on other clients that don't
    366     // support our -webkit-nbsp-mode: space, but it comes close.
    367     static DeprecatedString pattern("\xa0 ");
    368     int end = length - 1;
    369     int i = substring.findRev(twoSpaces, end);
    370     while (i >= 0) {
    371         substring.replace(i , 2, pattern);
    372         i = substring.findRev(twoSpaces, i);
    373     }
    374    
    375     // Rendering will collapse any regular whitespace at the start or end of a line.  To prevent this, we use
    376     // a nbsp at the start and end of a text node.  This is sometimes unnecessary,  E.G. <a>link</a> text
    377     if (start == 0 && substring[0] == ' ')
    378         substring.replace(0, 1, nbsp);
    379     if (start + length == text.length() && substring[end] == ' ')
    380         substring.replace(end, 1, nbsp);
     360    // FIXME: We rebalance with all nbsps, for simplicity (we don't need crazy sequences while editing
     361    // because all editable regions will have -webkit-nbsp-mode: space.  We should produce sequences of
     362    // regular spaces and nbsps that are better for interchange when we serialize (10636).
     363    substring.replace(whitespace, nbsp);
    381364   
    382365    ExceptionCode ec = 0;
Note: See TracChangeset for help on using the changeset viewer.