Changeset 25634 in webkit


Ignore:
Timestamp:
Sep 18, 2007 6:39:59 PM (17 years ago)
Author:
thatcher
Message:

WebCore:

Reviewed by Darin.

<rdar://problem/5478250> REGRESSION: After pasting text copied from Mail subject and typing return, the cursor disappears because of negative left margin

When pasting text from the Mail subject line, the RTF pasteboard contains text that has a first line negative indent along with a
paragraph indent that has a counteracting positive indent. This results in the first line being flush left justified, and the remaining
wrapped lines being indented. When this is converted to a DOM fragment, AppKit makes a block element with a margin-left and a negative
text-indent that matches the RTF. So far this is all correct behavior.

When this content is pasted on the line of an existing paragraph that has content, ReplaceSelectionCommand will decided to merge the paragraphs.
This will convert the block element to a style span that has all inherited style properties. These inherited properties will still contain block
properties that have no affect on inline elements. These block properties will hang around on the style span and will get cloned to new block
elements if the user hit return on that line. The new block elements would then have the text-indent but not the margin-left, so the text would be
hidden off the left edge of the page.

In the end, we should never hang on to block-only properties in our style spans. This cuts out meaningless properties and prevents properties
from magically affecting blocks later if the style is cloned for a new block element during a future editing operation.

  • editing/ReplaceSelectionCommand.cpp: (WebCore::ReplaceSelectionCommand::removeRedundantStyles): Remove any inherited block properties that are now in the span's style.
  • editing/markup.cpp: (WebCore::createMarkup): Ditto.

LayoutTests:

Reviewed by Darin.

Test for <rdar://problem/5478250> REGRESSION: After pasting text copied from Mail subject and typing return, the cursor disappears because of negative left margin

  • editing/pasteboard/5478250.html: Added.
  • platform/mac/editing/pasteboard/5478250-expected.txt: Added.

Updated results that are affected by the style span being removed or added with different style properties.

  • editing/execCommand/5144139-1-expected.txt:
  • editing/execCommand/create-list-with-hr-expected.txt:
  • editing/pasteboard/merge-end-blockquote-expected.txt:
  • editing/pasteboard/styled-element-markup-expected.txt:
Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r25623 r25634  
     12007-09-18  Timothy Hatcher  <timothy@apple.com>
     2
     3        Reviewed by Darin.
     4
     5        Test for <rdar://problem/5478250> REGRESSION: After pasting text copied from Mail subject and typing return, the cursor disappears because of negative left margin
     6
     7        * editing/pasteboard/5478250.html: Added.
     8        * platform/mac/editing/pasteboard/5478250-expected.txt: Added.
     9
     10        Updated results that are affected by the style span being removed or added with different style properties.
     11
     12        * editing/execCommand/5144139-1-expected.txt:
     13        * editing/execCommand/create-list-with-hr-expected.txt:
     14        * editing/pasteboard/merge-end-blockquote-expected.txt:
     15        * editing/pasteboard/styled-element-markup-expected.txt:
     16
    1172007-09-18  Sam Weinig  <sam@webkit.org>
    218
  • trunk/LayoutTests/editing/execCommand/5144139-1-expected.txt

    r25533 r25634  
    1111        RenderBlock {UL} at (0,0) size 784x46
    1212          RenderListItem {LI} at (40,0) size 744x46
    13             RenderBlock (anonymous) at (0,0) size 744x18
    14               RenderListMarker at (-17,0) size 7x18: bullet
    15             RenderTable {TABLE} at (0,18) size 31x28 [border: (1px outset #808080)]
     13            RenderTable {TABLE} at (0,0) size 31x28 [border: (1px outset #808080)]
    1614              RenderTableSection {TBODY} at (1,1) size 29x26
    1715                RenderTableRow {TR} at (0,2) size 29x22
     
    1917                    RenderText {#text} at (2,2) size 21x18
    2018                      text run at (2,2) width 21: "foo"
    21             RenderBlock (anonymous) at (0,46) size 744x0
     19            RenderBlock (anonymous) at (0,28) size 744x18
     20              RenderListMarker at (-17,0) size 7x18: bullet
    2221        RenderBlock (anonymous) at (0,62) size 784x0
    2322selection start: position 0 of child 0 {TABLE} of child 0 {LI} of child 0 {UL} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
  • trunk/LayoutTests/editing/execCommand/create-list-with-hr-expected.txt

    r20950 r25634  
    2323        RenderBlock {UL} at (0,0) size 784x28
    2424          RenderListItem {LI} at (40,0) size 744x28
    25             RenderBlock (anonymous) at (0,0) size 744x0
    2625            RenderBlock {HR} at (0,0) size 744x2 [border: (1px inset #000000)]
    2726            RenderBlock (anonymous) at (0,10) size 744x18
  • trunk/LayoutTests/editing/pasteboard/merge-end-blockquote-expected.txt

    r20950 r25634  
    1212EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1313EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    14 EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 3 of #text > DIV > BLOCKQUOTE > DIV > BODY > HTML > #document to 3 of #text > DIV > BLOCKQUOTE > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     14EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 3 of #text > SPAN > DIV > BLOCKQUOTE > DIV > BODY > HTML > #document to 3 of #text > SPAN > DIV > BLOCKQUOTE > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    1515EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1616EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     
    3939            RenderText {#text} at (0,0) size 81x18
    4040              text run at (0,0) width 81: "Blockquoted"
    41             RenderText {#text} at (81,0) size 21x18
    42               text run at (81,0) width 21: "foo"
     41            RenderInline {SPAN} at (0,0) size 21x18
     42              RenderText {#text} at (81,0) size 21x18
     43                text run at (81,0) width 21: "foo"
    4344          RenderBlock {DIV} at (0,18) size 704x18
    44             RenderText {#text} at (0,0) size 20x18
    45               text run at (0,0) width 20: "bar"
     45            RenderInline {SPAN} at (0,0) size 20x18
     46              RenderText {#text} at (0,0) size 20x18
     47                text run at (0,0) width 20: "bar"
    4648            RenderText {#text} at (20,0) size 33x18
    4749              text run at (20,0) width 33: " Text"
    48 caret: position 3 of child 0 {#text} of child 1 {DIV} of child 0 {BLOCKQUOTE} of child 10 {DIV} of child 1 {BODY} of child 0 {HTML} of document
     50caret: position 3 of child 0 {#text} of child 0 {SPAN} of child 1 {DIV} of child 0 {BLOCKQUOTE} of child 10 {DIV} of child 1 {BODY} of child 0 {HTML} of document
  • trunk/LayoutTests/editing/pasteboard/styled-element-markup-expected.txt

    r20950 r25634  
    1010EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1111EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
    12 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 1 of SPAN > DIV > BODY > HTML > #document to 1 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     12EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 1 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    1313EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1414EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     
    3232          RenderImage {IMG} at (354,0) size 76x103
    3333      RenderBlock {DIV} at (0,207) size 784x103
    34         RenderInline {SPAN} at (0,0) size 76x14
    35           RenderImage {IMG} at (0,0) size 76x103
    36 caret: position 1 of child 0 {IMG} of child 0 {SPAN} of child 6 {DIV} of child 1 {BODY} of child 0 {HTML} of document
     34        RenderImage {IMG} at (0,0) size 76x103
     35caret: position 1 of child 0 {IMG} of child 6 {DIV} of child 1 {BODY} of child 0 {HTML} of document
  • trunk/WebCore/ChangeLog

    r25632 r25634  
     12007-09-18  Timothy Hatcher  <timothy@apple.com>
     2
     3        Reviewed by Darin.
     4
     5        <rdar://problem/5478250> REGRESSION: After pasting text copied from Mail subject and typing return, the cursor disappears because of negative left margin
     6
     7        When pasting text from the Mail subject line, the RTF pasteboard contains text that has a first line negative indent along with a
     8        paragraph indent that has a counteracting positive indent. This results in the first line being flush left justified, and the remaining
     9        wrapped lines being indented. When this is converted to a DOM fragment, AppKit makes a block element with a margin-left and a negative
     10        text-indent that matches the RTF. So far this is all correct behavior.
     11
     12        When this content is pasted on the line of an existing paragraph that has content, ReplaceSelectionCommand will decided to merge the paragraphs.
     13        This will convert the block element to a style span that has all inherited style properties. These inherited properties will still contain block
     14        properties that have no affect on inline elements. These block properties will hang around on the style span and will get cloned to new block
     15        elements if the user hit return on that line. The new block elements would then have the text-indent but not the margin-left, so the text would be
     16        hidden off the left edge of the page.
     17
     18        In the end, we should never hang on to block-only properties in our style spans. This cuts out meaningless properties and prevents properties
     19        from magically affecting blocks later if the style is cloned for a new block element during a future editing operation.
     20
     21        * editing/ReplaceSelectionCommand.cpp:
     22        (WebCore::ReplaceSelectionCommand::removeRedundantStyles): Remove any inherited block properties that are now in the span's style.
     23        * editing/markup.cpp:
     24        (WebCore::createMarkup): Ditto.
     25
    1262007-09-18  Dave Hyatt  <hyatt@apple.com>
    227
  • trunk/WebCore/editing/ReplaceSelectionCommand.cpp

    r25484 r25634  
    414414            RefPtr<CSSMutableStyleDeclaration> style = computedStyle(node)->copyInheritableProperties();
    415415            parentStyle->diff(style.get());
    416            
     416
     417            // Remove any inherited block properties that are now in the span's style. This cuts out meaningless properties
     418            // and prevents properties from magically affecting blocks later if the style is cloned for a new block element
     419            // during a future editing operation.
     420            style->removeBlockProperties();
     421
    417422            styles.append(style.release());
    418423        }
  • trunk/WebCore/editing/markup.cpp

    r25484 r25634  
    655655    if (parentOfLastClosed && parentOfLastClosed->renderer()) {
    656656        RefPtr<CSSMutableStyleDeclaration> style = computedStyle(parentOfLastClosed)->copyInheritableProperties();
     657
    657658        // Styles that Mail blockquotes contribute should only be placed on the Mail blockquote, to help
    658659        // us differentiate those styles from ones that the user has applied.  This helps us
     
    660661        removeEnclosingMailBlockquoteStyle(style.get(), parentOfLastClosed);
    661662       
     663        // Since we are converting blocks to inlines, remove any inherited block properties that are in the style.
     664        // This cuts out meaningless properties and prevents properties from magically affecting blocks later
     665        // if the style is cloned for a new block element during a future editing operation.
     666        if (convertBlocksToInlines)
     667            style->removeBlockProperties();
     668
    662669        if (style->length() > 0) {
    663670            DeprecatedString openTag = DeprecatedString("<span class=\"") + AppleStyleSpanClass + "\" style=\"" + escapeTextForMarkup(style->cssText(), true) + "\">";
Note: See TracChangeset for help on using the changeset viewer.