Changeset 17386 in webkit


Ignore:
Timestamp:
Oct 27, 2006 1:42:17 PM (17 years ago)
Author:
justing
Message:

LayoutTests:

Reviewed by harrison


<http://bugs.webkit.org/show_bug.cgi?id=11423>
REGRESSION: First newline missing from textarea's value

Changes reflect the removal of more brs that were about
to collapse:

  • editing/deleting/delete-4038408-fix-expected.txt:
  • editing/inserting/insert-3654864-fix-expected.txt:
  • editing/inserting/insert-3659587-fix-expected.txt:
  • editing/inserting/insert-3775316-fix-expected.txt:
  • editing/inserting/insert-at-end-01-expected.txt:
  • editing/inserting/insert-at-end-02-expected.txt:
  • editing/inserting/insert-br-001-expected.txt:
  • editing/inserting/insert-br-005-expected.txt:

Added to demonstrate fix:

  • fast/forms/11423-expected.txt: Added.
  • fast/forms/11423.html: Added.

WebCore:

Reviewed by harrison


<http://bugs.webkit.org/show_bug.cgi?id=11423>
REGRESSION: First newline missing from textarea's value


The regression is that foo, return, bar in a textarea serializes as 'foobar'.


Before my change in r11423, return (an InsertLineBreak) would insert a '\n'
(the line break) then a br to prevent the '\n' from collapsing, since the
insertion is being done at the end of a block (the textarea's shadow div). Then,
inserting "bar" would displace the br, and "foo\nbar" would serialize as "foo\nbar".
After my change in r11423, InsertLineBreak would insert a br then a '\n' (reversed
the order). Then inserting "bar" would displace the '\n' and "foo"<br>"bar" would
serialize as "foobar" because when serializing RenderTextControl intentionally asks
textContent to not convert brs to newlines. It seems to think that the only brs in
the shadow div will be placeholders or collapsed.


We could remove this assumption, but, for consistancy's sake, I changed InsertLineBreak
to insert two '\n's when at the end of a block in white-space:pre text. This alone
would have fixed the bug, but introduced a new one, because foo, return, bar would
produce "foo\nbar\n" which would serialize as "foo\nbar\n" (even though the second
'\n' is collapsed, because of 9661). So, then I changed placeholder displacement to
displace a '\n' if it's acting as a placeholder. A "placeholder" is now defined as
a br or '\n' that will collapse (become superfluous) when content is inserted just
before it.


  • editing/CompositeEditCommand.cpp: (WebCore::CompositeEditCommand::removePlaceholderAt): Renamed. Remove a br or '\n' if content inserted just before it will cause it to collapse.
  • editing/CompositeEditCommand.h:
  • editing/InsertLineBreakCommand.cpp: (WebCore::InsertLineBreakCommand::doApply): Insert the same type of node to prevent a collapse as was used for the line break. Fixed comments.
  • editing/InsertTextCommand.cpp: (WebCore::InsertTextCommand::input): Call the renamed function.
Location:
trunk
Files:
2 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r17368 r17386  
     12006-10-26  Justin Garcia  <justin.garcia@apple.com>
     2
     3        Reviewed by harrison
     4       
     5        <http://bugs.webkit.org/show_bug.cgi?id=11423>
     6        REGRESSION: First newline missing from textarea's value
     7
     8        Changes reflect the removal of more brs that were about
     9        to collapse:
     10        * editing/deleting/delete-4038408-fix-expected.txt:
     11        * editing/inserting/insert-3654864-fix-expected.txt:
     12        * editing/inserting/insert-3659587-fix-expected.txt:
     13        * editing/inserting/insert-3775316-fix-expected.txt:
     14        * editing/inserting/insert-at-end-01-expected.txt:
     15        * editing/inserting/insert-at-end-02-expected.txt:
     16        * editing/inserting/insert-br-001-expected.txt:
     17        * editing/inserting/insert-br-005-expected.txt:
     18
     19        Added to demonstrate fix:
     20        * fast/forms/11423-expected.txt: Added.
     21        * fast/forms/11423.html: Added.
     22       
    1232006-10-27  Darin Adler  <darin@apple.com>
    224
  • trunk/LayoutTests/editing/deleting/delete-4038408-fix-expected.txt

    r16237 r17386  
    2828EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    2929EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
    30 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 31 of #text > DIV > DIV > BODY > HTML > #document to 31 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 31 of #text > DIV > DIV > BODY > HTML > #document to 31 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     30EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
     31EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 31 of #text > DIV > DIV > BODY > HTML > #document to 31 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    3132EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    3233EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     
    6465            RenderText {#text} at (0,0) size 195x18
    6566              text run at (0,0) width 195: "This text should not be quoted."
    66             RenderBR {BR} at (195,14) size 0x0
    6767caret: position 31 of child 2 {#text} of child 11 {DIV} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document
  • trunk/LayoutTests/editing/inserting/insert-3654864-fix-expected.txt

    r16237 r17386  
    88EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    99EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
    10 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > BODY > HTML > #document to 1 of #text > BODY > HTML > #document toDOMRange:range from 1 of #text > BODY > HTML > #document to 1 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     10EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
     11EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > BODY > HTML > #document to 1 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    1112EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1213EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     
    2526      RenderText {#text} at (14,42) size 36x28
    2627        text run at (14,42) width 36: "xxx"
    27       RenderBR {BR} at (50,64) size 0x0
     28      RenderText {#text} at (0,0) size 0x0
     29      RenderText {#text} at (0,0) size 0x0
     30      RenderText {#text} at (0,0) size 0x0
    2831caret: position 3 of child 1 {#text} of child 1 {BODY} of child 0 {HTML} of document
  • trunk/LayoutTests/editing/inserting/insert-3659587-fix-expected.txt

    r16237 r17386  
    3030EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    3131EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
    32 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > B > SPAN > DIV > BODY > HTML > #document to 1 of #text > B > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > B > SPAN > DIV > BODY > HTML > #document to 1 of #text > B > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     32EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
     33EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > B > SPAN > DIV > BODY > HTML > #document to 1 of #text > B > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    3334EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    3435EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     
    5253            RenderText {#text} at (14,42) size 36x28
    5354              text run at (14,42) width 36: "xxx"
    54             RenderBR {BR} at (50,64) size 0x0
    5555caret: position 3 of child 2 {#text} of child 0 {B} of child 1 {SPAN} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document
  • trunk/LayoutTests/editing/inserting/insert-3775316-fix-expected.txt

    r16237 r17386  
    66EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    77EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
    8 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     8EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
     9EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    910EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1011EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     
    1718EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
    1819EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    19 EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     20EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 1 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    2021EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    2122EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
    22 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 2 of SPAN > DIV > BODY > HTML > #document to 2 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     23EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 1 of #text > DIV > BODY > HTML > #document toDOMRange:range from 2 of DIV > BODY > HTML > #document to 2 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    2324EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    2425EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
    25 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     26EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
     27EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 1 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    2628EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    2729EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     
    3234    RenderBody {BODY} at (8,8) size 784x584
    3335      RenderBlock {DIV} at (0,0) size 784x84 [border: (2px solid #FF0000)]
    34         RenderInline {SPAN} at (0,0) size 12x56
    35           RenderText {#text} at (14,14) size 12x28
    36             text run at (14,14) width 12: "x"
    37           RenderBR {BR} at (26,36) size 0x0
    38           RenderText {#text} at (14,42) size 12x28
    39             text run at (14,42) width 12: "x"
    40           RenderBR {BR} at (26,64) size 0x0
    41         RenderText {#text} at (0,0) size 0x0
    42 caret: position 1 of child 2 {#text} of child 0 {SPAN} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document
     36        RenderText {#text} at (14,14) size 12x28
     37          text run at (14,14) width 12: "x"
     38        RenderBR {BR} at (26,36) size 0x0
     39        RenderText {#text} at (14,42) size 12x28
     40          text run at (14,42) width 12: "x"
     41caret: position 1 of child 2 {#text} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document
  • trunk/LayoutTests/editing/inserting/insert-at-end-01-expected.txt

    r14768 r17386  
    44EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    55EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    6 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 1 of #text > 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
     6EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
     7EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 1 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    78EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    89EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     
    3031          RenderText {#text} at (0,0) size 8x18
    3132            text run at (0,0) width 8: "x"
    32           RenderBR {BR} at (8,14) size 0x0
    3333caret: position 1 of child 5 {#text} of child 5 {DIV} of child 1 {BODY} of child 0 {HTML} of document
  • trunk/LayoutTests/editing/inserting/insert-at-end-02-expected.txt

    r14768 r17386  
    44EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    55EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    6 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 1 of #text > 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
     6EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
     7EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 1 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    78EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    89EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     
    3031          RenderText {#text} at (0,0) size 8x18
    3132            text run at (0,0) width 8: "x"
    32           RenderBR {BR} at (8,14) size 0x0
    3333caret: position 1 of child 5 {#text} of child 5 {DIV} of child 1 {BODY} of child 0 {HTML} of document
  • trunk/LayoutTests/editing/inserting/insert-br-001-expected.txt

    r14768 r17386  
    88EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    99EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
    10 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     10EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
     11EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    1112EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1213EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     
    2324          RenderText {#text} at (14,42) size 12x28
    2425            text run at (14,42) width 12: "x"
    25           RenderBR {BR} at (26,64) size 0x0
    2626        RenderText {#text} at (0,0) size 0x0
    2727caret: position 1 of child 2 {#text} of child 1 {SPAN} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document
  • trunk/LayoutTests/editing/inserting/insert-br-005-expected.txt

    r14768 r17386  
    1010EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document toDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    1111EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
    12 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     12EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
     13EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    1314EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1415EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     
    2627          RenderText {#text} at (14,70) size 12x28
    2728            text run at (14,70) width 12: "x"
    28           RenderBR {BR} at (26,92) size 0x0
    2929        RenderText {#text} at (0,0) size 0x0
    3030caret: position 1 of child 3 {#text} of child 1 {SPAN} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document
  • trunk/WebCore/ChangeLog

    r17378 r17386  
     12006-10-26  Justin Garcia  <justin.garcia@apple.com>
     2
     3        Reviewed by harrison
     4       
     5        <http://bugs.webkit.org/show_bug.cgi?id=11423>
     6        REGRESSION: First newline missing from textarea's value
     7       
     8        The regression is that foo, return, bar in a textarea serializes as 'foobar'.
     9       
     10        Before my change in r11423, return (an InsertLineBreak) would insert a '\n'
     11        (the line break) then a br to prevent the '\n' from collapsing, since the
     12        insertion is being done at the end of a block (the textarea's shadow div).  Then,
     13        inserting "bar" would displace the br, and "foo\nbar" would serialize as "foo\nbar". 
     14        After my change in r11423, InsertLineBreak would insert a br then a '\n' (reversed
     15        the order).  Then inserting "bar" would displace the '\n' and "foo"<br>"bar" would
     16        serialize as "foobar" because when serializing RenderTextControl intentionally asks
     17        textContent to not convert brs to newlines.  It seems to think that the only brs in
     18        the shadow div will be placeholders or collapsed.
     19       
     20        We could remove this assumption, but, for consistancy's sake, I changed InsertLineBreak
     21        to insert two '\n's when at the end of a block in white-space:pre text.  This alone
     22        would have fixed the bug, but introduced a new one, because foo, return, bar would
     23        produce "foo\nbar\n" which would serialize as "foo\nbar\n" (even though the second
     24        '\n' is collapsed, because of 9661).  So, then I changed placeholder displacement to
     25        displace a '\n' if it's acting as a placeholder.  A "placeholder" is now defined as
     26        a br or '\n' that will collapse (become superfluous) when content is inserted just
     27        before it.
     28       
     29        * editing/CompositeEditCommand.cpp:
     30        (WebCore::CompositeEditCommand::removePlaceholderAt): Renamed.  Remove
     31        a br or '\n' if content inserted just before it will cause it to collapse.
     32        * editing/CompositeEditCommand.h:
     33        * editing/InsertLineBreakCommand.cpp:
     34        (WebCore::InsertLineBreakCommand::doApply): Insert the same type of node
     35        to prevent a collapse as was used for the line break.  Fixed comments.
     36        * editing/InsertTextCommand.cpp:
     37        (WebCore::InsertTextCommand::input): Call the renamed function.
     38       
    1392006-10-27  Geoffrey Garen  <ggaren@apple.com>
    240
  • trunk/WebCore/editing/CompositeEditCommand.cpp

    r17114 r17386  
    485485}
    486486
    487 void CompositeEditCommand::removeBlockPlaceholder(const VisiblePosition& visiblePosition)
     487// Removes '\n's and brs that will collapse when content is inserted just before them.
     488// FIXME: We shouldn't really have to remove placeholders, but removing them is a workaround for 9661.
     489void CompositeEditCommand::removePlaceholderAt(const VisiblePosition& visiblePosition)
    488490{
    489491    if (visiblePosition.isNull())
     
    491493       
    492494    Position p = visiblePosition.deepEquivalent().downstream();
    493     if (p.node()->hasTagName(brTag) && p.offset() == 0 && isEndOfBlock(visiblePosition) && isStartOfBlock(visiblePosition))
    494         removeNode(p.node());
     495    // If a br or '\n' is at the end of a block and not at the start of a paragraph,
     496    // then it is superfluous, so adding content before a br or '\n' that is at
     497    // the start of a paragraph will render it superfluous.
     498    // FIXME: This doesn't remove placeholders at the end of anonymous blocks.
     499    if (isEndOfBlock(visiblePosition) && isStartOfParagraph(visiblePosition)) {
     500        if (p.node()->hasTagName(brTag) && p.offset() == 0)
     501            removeNode(p.node());
     502        else if (p.node()->renderer()->style()->preserveNewline() && visiblePosition.characterAfter() == '\n')
     503            deleteTextFromNode(static_cast<Text*>(p.node()), p.offset(), 1);
     504    }
    495505}
    496506
  • trunk/WebCore/editing/CompositeEditCommand.h

    r16026 r17386  
    8888    Node *insertBlockPlaceholder(const Position&);
    8989    Node *addBlockPlaceholderIfNeeded(Node*);
    90     void removeBlockPlaceholder(const VisiblePosition&);
     90    void removePlaceholderAt(const VisiblePosition&);
    9191
    9292    void moveParagraphContentsToNewBlockIfNecessary(const Position&);
  • trunk/WebCore/editing/InsertLineBreakCommand.cpp

    r17223 r17386  
    111111        if (canonicalPos.offset() == 0) {
    112112            insertNodeBefore(nodeToInsert.get(), canonicalPos.node());
    113             // Insert an extra br if the just inserted one collapsed.
     113            // Insert an extra br or '\n' if the just inserted one collapsed.
    114114            if (!isStartOfParagraph(VisiblePosition(Position(nodeToInsert.get(), 0))))
    115                 insertNodeBefore(createBreakElement(document()).get(), nodeToInsert.get());
     115                insertNodeBefore(nodeToInsert->cloneNode(false).get(), nodeToInsert.get());
    116116            // Leave the selection where it was, just before the table/horizontal rule.
    117117        } else if (canonicalPos.offset() == maxDeepOffset(canonicalPos.node())) {
     
    127127        VisiblePosition endingPosition(endOfBlock(VisiblePosition(pos)));
    128128       
    129         // Insert an extra br if the inserted one collapsed.
     129        // Insert an extra br or '\n' if the inserted one collapsed.
    130130        if (!isStartOfParagraph(endingPosition))
    131             insertNodeBefore(createBreakElement(document()).get(), nodeToInsert.get());
     131            insertNodeBefore(nodeToInsert->cloneNode(false).get(), nodeToInsert.get());
    132132       
    133133        setEndingSelection(Selection(endingPosition));
  • trunk/WebCore/editing/InsertTextCommand.cpp

    r16026 r17386  
    107107        endPosition = insertTab(startPosition);
    108108        startPosition = endPosition.previous();
    109         removeBlockPlaceholder(VisiblePosition(startPosition));
     109        removePlaceholderAt(VisiblePosition(startPosition));
    110110        m_charactersAdded += 1;
    111111    } else {
    112112        // Make sure the document is set up to receive text
    113113        startPosition = prepareForTextInsertion(startPosition);
    114         removeBlockPlaceholder(VisiblePosition(startPosition));
     114        removePlaceholderAt(VisiblePosition(startPosition));
    115115        Text *textNode = static_cast<Text *>(startPosition.node());
    116116        int offset = startPosition.offset();
Note: See TracChangeset for help on using the changeset viewer.