Changeset 54395 in webkit
- Timestamp:
- Feb 4, 2010 6:38:21 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r54393 r54395 1 2010-02-04 Tony Chang <tony@chromium.org> 2 3 Reviewed by Eric Seidel. 4 5 https://bugs.webkit.org/show_bug.cgi?id=25002 6 When inserting a new paragraph, avoid nesting empty divs. When 7 pasting near the end of a paragraph, this prevents each paste 8 command for getting nested one level deeper. 9 10 Three paste tests have been rebaselined since this causes the pasted 11 content to be outside the last div instead of inside. E.g., 12 <div>foo<div>bar</div>[pasted content]</div> is now 13 <div>foo<div>bar</div></div><div>[pasted content]</div> 14 15 The new test verifies this behavior. 16 17 * editing/inserting/paragraph-outside-nested-divs-expected.txt: Added. 18 * editing/inserting/paragraph-outside-nested-divs.html: Added. 19 * platform/mac/editing/pasteboard/paste-text-012-expected.txt: 20 * platform/mac/editing/pasteboard/paste-text-013-expected.txt: 21 * platform/mac/editing/pasteboard/paste-text-017-expected.txt: 22 1 23 2010-02-04 Dumitru Daniliuc <dumi@chromium.org> 2 24 -
trunk/LayoutTests/platform/mac/editing/pasteboard/paste-text-012-expected.txt
r41569 r54395 8 8 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification 9 9 EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted 10 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 0 of DIV > DIV > DIV > SPAN > DIV > BODY > HTML > #document to 0 of DIV >DIV > DIV > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE10 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 0 of DIV > DIV > SPAN > DIV > BODY > HTML > #document to 0 of DIV > DIV > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE 11 11 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification 12 12 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification … … 37 37 RenderBlock (anonymous) at (14,14) size 756x132 38 38 RenderBlock {DIV} at (0,0) size 756x132 [border: (2px solid #FF0000)] 39 RenderBlock {DIV} at (14,38) size 728x 8039 RenderBlock {DIV} at (14,38) size 728x28 40 40 RenderBlock {BLOCKQUOTE} at (40,0) size 648x28 41 41 RenderText {#text} at (0,0) size 32x28 42 42 text run at (0,0) width 32: "foo" 43 RenderBlock {DIV} at (0,52) size 728x2844 43 RenderBlock {DIV} at (14,90) size 728x28 44 RenderBR {BR} at (0,0) size 0x28 45 45 RenderBlock (anonymous) at (14,146) size 756x0 46 46 RenderInline {SPAN} at (0,0) size 0x0 47 caret: position 0 of child 0 {BR} of child 1 {DIV} of child 0 {DIV} of child 0 { DIV} of child 0 {SPAN} of child 7 {DIV} of child 1 {BODY} of child 0 {HTML} of document47 caret: position 0 of child 0 {BR} of child 1 {DIV} of child 0 {DIV} of child 0 {SPAN} of child 7 {DIV} of child 1 {BODY} of child 0 {HTML} of document -
trunk/LayoutTests/platform/mac/editing/pasteboard/paste-text-013-expected.txt
r41569 r54395 11 11 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification 12 12 EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 1 of #text > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted 13 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 1 of #text > DIV > BODY > HTML > #document toDOMRange:range from 0 of DIV > DIV > DIV > BODY > HTML > #document to 0 of DIV >DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE13 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 1 of #text > DIV > BODY > HTML > #document toDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE 14 14 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification 15 15 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification … … 41 41 text run at (14,14) width 12: "x" 42 42 RenderBlock {DIV} at (0,238) size 784x132 [border: (2px solid #FF0000)] 43 RenderBlock {DIV} at (14,38) size 756x 8043 RenderBlock {DIV} at (14,38) size 756x28 44 44 RenderBlock {BLOCKQUOTE} at (40,0) size 676x28 45 45 RenderText {#text} at (0,0) size 32x28 46 46 text run at (0,0) width 32: "foo" 47 RenderBlock {DIV} at (0,52) size 756x2848 49 caret: position 0 of child 0 {BR} of child 1 {DIV} of child 0 {DIV} of child8 {DIV} of child 1 {BODY} of child 0 {HTML} of document47 RenderBlock {DIV} at (14,90) size 756x28 48 RenderBR {BR} at (0,0) size 0x28 49 caret: position 0 of child 0 {BR} of child 1 {DIV} of child 8 {DIV} of child 1 {BODY} of child 0 {HTML} of document -
trunk/LayoutTests/platform/mac/editing/pasteboard/paste-text-017-expected.txt
r25970 r54395 7 7 EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 5 of #text > DIV > DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted 8 8 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification 9 EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > DIV > DIV > DIV > BODY > HTML > #document to 0 of DIV >DIV > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE9 EDITING 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 10 10 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification 11 11 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification … … 41 41 RenderBlock {DIV} at (2,30) size 780x28 42 42 RenderBR {BR} at (0,0) size 0x28 43 RenderBlock {DIV} at (2,58) size 780x 5643 RenderBlock {DIV} at (2,58) size 780x28 44 44 RenderBlock {DIV} at (0,0) size 780x28 45 45 RenderText {#text} at (0,0) size 36x28 46 46 text run at (0,0) width 36: "two" 47 47 RenderBlock (anonymous) at (0,28) size 780x0 48 RenderBlock {DIV} at (0,28) size 780x2849 48 RenderBlock {DIV} at (2,86) size 780x28 49 RenderBR {BR} at (0,0) size 0x28 50 50 RenderBlock {DIV} at (2,114) size 780x28 51 51 RenderText {#text} at (0,0) size 49x28 52 52 text run at (0,0) width 49: "three" 53 caret: position 0 of child 0 {BR} of child 1 {DIV} of child 5{DIV} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document53 caret: position 0 of child 0 {BR} of child 6 {DIV} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document -
trunk/WebCore/ChangeLog
r54393 r54395 1 2010-02-04 Tony Chang <tony@chromium.org> 2 3 Reviewed by Eric Seidel. 4 5 https://bugs.webkit.org/show_bug.cgi?id=25002 6 When inserting a new paragraph, avoid nesting empty divs. When 7 pasting near the end of a paragraph, this prevents each paste 8 command for getting nested one level deeper. 9 10 Test: editing/inserting/paragraph-outside-nested-divs.html 11 12 * editing/InsertParagraphSeparatorCommand.cpp: 13 (WebCore::highestVisuallyEquivalentDiv): 14 (WebCore::InsertParagraphSeparatorCommand::doApply): 15 1 16 2010-02-04 Dumitru Daniliuc <dumi@chromium.org> 2 17 -
trunk/WebCore/editing/InsertParagraphSeparatorCommand.cpp
r48764 r54395 45 45 using namespace HTMLNames; 46 46 47 // When inserting a new line, we want to avoid nesting empty divs if we can. Otherwise, when 48 // pasting, it's easy to have each new line be a div deeper than the previous. E.g., in the case 49 // below, we want to insert at ^ instead of |. 50 // <div>foo<div>bar</div>|</div>^ 51 static Element* highestVisuallyEquivalentDiv(Element* startBlock) 52 { 53 Element* curBlock = startBlock; 54 while (!curBlock->nextSibling() && curBlock->parentElement()->hasTagName(divTag)) { 55 NamedNodeMap* attributes = curBlock->parentElement()->attributes(true); 56 if (attributes && !attributes->isEmpty()) 57 break; 58 curBlock = curBlock->parentElement(); 59 } 60 return curBlock; 61 } 62 47 63 InsertParagraphSeparatorCommand::InsertParagraphSeparatorCommand(Document *document, bool mustUseDefaultParagraphElement) 48 64 : CompositeEditCommand(document) … … 215 231 shouldApplyStyleAfterInsertion = false; 216 232 } 217 insertNodeAfter(blockToInsert, startBlock); 233 234 // Most of the time we want to stay at the nesting level of the startBlock (e.g., when nesting within lists). However, 235 // for div nodes, this can result in nested div tags that are hard to break out of. 236 Element* siblingNode = startBlock; 237 if (blockToInsert->hasTagName(divTag)) 238 siblingNode = highestVisuallyEquivalentDiv(startBlock); 239 insertNodeAfter(blockToInsert, siblingNode); 218 240 } 219 241
Note: See TracChangeset
for help on using the changeset viewer.