Changeset 13685 in webkit
- Timestamp:
- Apr 4, 2006, 1:52:10 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 12 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r13673 r13685 1 2006-04-04 Justin Garcia <justin.garcia@apple.com> 2 3 Reviewed by darin 4 5 <http://bugzilla.opendarwin.org/show_bug.cgi?id=6608> 6 REGRESSION: Line disappears when deleting 7 8 Added: 9 * editing/deleting/merge-different-styles-expected.checksum: Added. 10 * editing/deleting/merge-different-styles-expected.png: Added. 11 * editing/deleting/merge-different-styles-expected.txt: Added. 12 * editing/deleting/merge-different-styles.html: Added. 13 * editing/deleting/merge-no-br-expected.checksum: Added. 14 * editing/deleting/merge-no-br-expected.png: Added. 15 * editing/deleting/merge-no-br-expected.txt: Added. 16 * editing/deleting/merge-no-br.html: Added. 17 * editing/deleting/merge-whitespace-pre-expected.checksum: Added. 18 * editing/deleting/merge-whitespace-pre-expected.png: Added. 19 * editing/deleting/merge-whitespace-pre-expected.txt: Added. 20 * editing/deleting/merge-whitespace-pre.html: Added. 21 22 Fixes (not enough style on nodes for the fixes to be reflected in pixel results): 23 * editing/deleting/delete-block-merge-contents-005-expected.txt: 24 * editing/deleting/delete-block-merge-contents-006-expected.txt: 25 * editing/deleting/delete-block-merge-contents-008-expected.txt: 26 27 Equivalent render trees: 28 * editing/deleting/delete-3857753-fix-expected.txt: 29 * editing/inserting/insert-div-026-expected.txt: 30 31 Forgot to checkin these new expected results after fixing the DRT bug: 32 * fast/lists/drag-into-marker-expected.checksum: 33 * fast/lists/drag-into-marker-expected.png: 34 * fast/lists/drag-into-marker-expected.txt: 35 1 36 2006-04-03 Alexey Proskuryakov <ap@nypop.com> 2 37 -
trunk/LayoutTests/editing/deleting/delete-3857753-fix-expected.txt
r12708 r13685 17 17 RenderBody {BODY} at (8,8) size 784x584 [border: (2px solid #FF0000)] 18 18 RenderBlock {DIV} at (14,14) size 756x28 19 RenderInline {B} at (0,0) size 25x2819 RenderInline {B} at (0,0) size 37x28 20 20 RenderText {TEXT} at (0,0) size 25x28 21 21 text run at (0,0) width 25: "on" 22 RenderInline {I} at (0,0) size 12x28 23 RenderText {TEXT} at (25,0) size 12x28 24 text run at (25,0) width 12: "o" 22 RenderInline {SPAN} at (0,0) size 12x28 23 RenderInline {I} at (0,0) size 12x28 24 RenderText {TEXT} at (25,0) size 12x28 25 text run at (25,0) width 12: "o" 25 26 RenderBlock {DIV} at (14,42) size 756x28 26 27 RenderInline {B} at (0,0) size 54x28 -
trunk/LayoutTests/editing/deleting/delete-block-merge-contents-005-expected.txt
r12708 r13685 22 22 text run at (40,0) width 44: "Two" 23 23 RenderBlock {DIV} at (0,28) size 756x28 24 RenderText {TEXT} at (0,0) size 57x28 25 text run at (0,0) width 57: "Three" 24 RenderBlock (anonymous) at (0,0) size 756x0 25 RenderBlock {DIV} at (0,0) size 756x28 26 RenderText {TEXT} at (0,0) size 57x28 27 text run at (0,0) width 57: "Three" 26 28 RenderBlock (anonymous) at (0,56) size 756x28 27 29 RenderText {TEXT} at (0,0) size 45x28 -
trunk/LayoutTests/editing/deleting/delete-block-merge-contents-006-expected.txt
r12708 r13685 22 22 text run at (40,0) width 44: "Two" 23 23 RenderBlock {DIV} at (0,28) size 756x28 24 RenderText {TEXT} at (0,0) size 57x28 25 text run at (0,0) width 57: "Three" 26 RenderBR {BR} at (0,0) size 0x0 24 RenderBlock (anonymous) at (0,0) size 756x0 25 RenderBlock {DIV} at (0,0) size 756x28 26 RenderText {TEXT} at (0,0) size 57x28 27 text run at (0,0) width 57: "Three" 28 RenderBR {BR} at (0,0) size 0x0 27 29 RenderBlock (anonymous) at (0,56) size 756x28 28 30 RenderText {TEXT} at (0,0) size 45x28 -
trunk/LayoutTests/editing/deleting/delete-block-merge-contents-008-expected.txt
r12708 r13685 21 21 RenderText {TEXT} at (40,0) size 44x28 22 22 text run at (40,0) width 44: "Two" 23 RenderBlock {DIV} at (0,28) size 756x28 24 RenderText {TEXT} at (0,0) size 57x28 25 text run at (0,0) width 57: "Three" 26 RenderBlock {DIV} at (0,56) size 756x28 27 RenderText {TEXT} at (0,0) size 45x28 28 text run at (0,0) width 45: "Four" 23 RenderBlock {DIV} at (0,28) size 756x56 24 RenderBlock {DIV} at (0,0) size 756x28 25 RenderBlock (anonymous) at (0,0) size 756x0 26 RenderBlock {DIV} at (0,0) size 756x28 27 RenderText {TEXT} at (0,0) size 57x28 28 text run at (0,0) width 57: "Three" 29 RenderBlock (anonymous) at (0,28) size 756x28 30 RenderText {TEXT} at (0,0) size 45x28 31 text run at (0,0) width 45: "Four" 29 32 caret: position 3 of child 0 {TEXT} of child 1 {DIV} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document -
trunk/LayoutTests/editing/inserting/insert-div-026-expected.txt
r12709 r13685 49 49 RenderBlock {DIV} at (0,236) size 784x32 50 50 RenderBlock {DIV} at (0,0) size 784x32 [border: (2px solid #FF0000)] 51 RenderInline {B} at (0,0) size 20x2851 RenderInline {B} at (0,0) size 32x28 52 52 RenderText {TEXT} at (2,2) size 20x28 53 53 text run at (2,2) width 20: "fo" 54 RenderText {TEXT} at (22,2) size 12x28 55 text run at (22,2) width 12: "x" 54 RenderInline {SPAN} at (0,0) size 12x28 55 RenderText {TEXT} at (22,2) size 12x28 56 text run at (22,2) width 12: "x" 56 57 caret: position 3 of child 0 {TEXT} of child 0 {B} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document -
trunk/LayoutTests/fast/lists/drag-into-marker-expected.checksum
r13664 r13685 1 df27ed25b1f079512d5aad0ce5771c69 1 720296de5356ea7c8b963a39d88d5ff2 -
trunk/LayoutTests/fast/lists/drag-into-marker-expected.txt
r13664 r13685 31 31 text run at (0,54) width 371: "this test drags a bit of text over the list marker and drops it. " 32 32 text run at (371,54) width 386: "It should be pasted into the list item, which is contenteditable." 33 RenderBlock {P} at (0,161) size 784x3634 RenderInline {B} at (0,0) size 771x3635 RenderText {TEXT} at (0,0) size 771x3636 text run at (0,0) width 713: "This test case demonstrates a bug in DumpRenderTree's drag and drop support, which is that the source "37 text run at (713,0) width 58: "is copied"38 text run at (0,18) width 113: "on drop, not cut."39 RenderText {TEXT} at (113,18) size 173x1840 text run at (113,18) width 4: " "41 text run at (117,18) width 169: "So you'll see 'world' twice."42 33 selection start: position 0 of child 0 {TEXT} of child 0 {SPAN} of child 0 {LI} of child 1 {UL} of child 0 {BODY} of child 0 {HTML} of document 43 34 selection end: position 6 of child 0 {TEXT} of child 0 {SPAN} of child 0 {LI} of child 1 {UL} of child 0 {BODY} of child 0 {HTML} of document -
trunk/WebCore/ChangeLog
r13682 r13685 1 2006-04-04 Justin Garcia <justin.garcia@apple.com> 2 3 Reviewed by darin 4 5 <http://bugzilla.opendarwin.org/show_bug.cgi?id=6608> 6 REGRESSION: Line disappears when deleting 7 8 Rewrote moveNodesAfterNode to address these problems: 9 It moved nodes without preserving their style. 10 It traversed over siblings looking for a br to know when 11 to stop merging. If the br was burried inside a span, it 12 wouldn't find it. If the text is whitespace:pre, it wouldn't 13 stop. 14 In theory it would crash if the "enclosingInlineElements" of the start of the 15 selection to delete and the end of the selection to delete were the 16 same. We think that this will fix these: 17 <rdar://problems/3950559&4498113> 18 CrashTracer: 2116 crashes in Mail at com.apple.WebCore: khtml::CompositeEditCommand::insertNodeAfter + 32 19 CrashTracer: 1569 crashes in Mail at com.apple.WebCore: khtml::DeleteSelectionCommand::moveNodesAfterNode + 340 20 But we haven't been able to construct a reproducible case. 21 22 * editing/CompositeEditCommand.cpp: 23 (WebCore::CompositeEditCommand::removeNodeAndPruneAncestors): Moved from ReplaceSelectionCommand. 24 (WebCore::CompositeEditCommand::prune): Ditto. 25 * editing/CompositeEditCommand.h: 26 * editing/DeleteSelectionCommand.cpp: 27 (WebCore::DeleteSelectionCommand::mergeParagraphs): 28 (WebCore::DeleteSelectionCommand::doApply): 29 * editing/DeleteSelectionCommand.h: 30 * editing/ReplaceSelectionCommand.cpp: 31 (WebCore::ReplaceSelectionCommand::doApply): 32 * editing/ReplaceSelectionCommand.h: 33 (WebCore::): 34 * editing/markup.cpp: 35 (WebCore::createMarkup): 36 Was crashing when passed a collapsed range. I early return an empty string instead. 37 1 38 2006-04-04 John Sullivan <sullivan@apple.com> 2 39 -
trunk/WebCore/editing/CompositeEditCommand.cpp
r13485 r13685 228 228 } 229 229 230 void CompositeEditCommand::removeNodeAndPruneAncestors(Node* node) 231 { 232 RefPtr<Node> parent = node->parentNode(); 233 removeNode(node); 234 prune(parent); 235 } 236 237 void CompositeEditCommand::prune(PassRefPtr<Node> node) 238 { 239 while (node) { 240 RefPtr<Node> parent = node->parentNode(); 241 // If you change this rule you may have to add an updateLayout() here. 242 if (node->renderer() && node->renderer()->firstChild()) 243 return; 244 removeNode(node.get()); 245 node = parent; 246 } 247 } 248 230 249 void CompositeEditCommand::splitTextNode(Text *text, int offset) 231 250 { -
trunk/WebCore/editing/CompositeEditCommand.h
r13477 r13685 76 76 void removeNode(WebCore::Node *removeChild); 77 77 void removeNodePreservingChildren(WebCore::Node *node); 78 void removeNodeAndPruneAncestors(Node* node); 79 void prune(PassRefPtr<Node> node); 78 80 void replaceTextInNode(WebCore::Text *node, int offset, int count, const WebCore::String &replacementText); 79 81 WebCore::Position positionOutsideTabSpan(const WebCore::Position& pos); -
trunk/WebCore/editing/DeleteSelectionCommand.cpp
r13579 r13685 36 36 #include "htmlediting.h" 37 37 #include "HTMLNames.h" 38 #include "markup.h" 38 39 #include "render_line.h" 39 40 #include "RenderObject.h" 41 #include "ReplaceSelectionCommand.h" 40 42 #include "VisiblePosition.h" 41 43 #include "TextIterator.h" … … 491 493 } 492 494 493 // This function moves nodes in the block containing startNode to dstBlock, starting 494 // from startNode and proceeding to the end of the paragraph. Nodes in the block containing 495 // startNode that appear in document order before startNode are not moved. 496 // This function is an important helper for deleting selections that cross paragraph 497 // boundaries. 498 void DeleteSelectionCommand::moveNodesAfterNode() 495 // If a selection ended in a different paragraph than it started in, we must merge 496 // the two paragraphs after deleting the selection. 497 void DeleteSelectionCommand::mergeParagraphs() 499 498 { 500 499 if (!m_mergeBlocksAfterDelete) 501 500 return; 502 501 502 // FIXME: Deletion should adjust selection endpoints as it removes nodes so that we never get into this state (4099839). 503 if (!m_downstreamEnd.node()->inDocument() || !m_upstreamStart.node()->inDocument()) 504 return; 505 506 // Do not move content between parts of a table. 507 if (isTableStructureNode(m_downstreamEnd.node()->enclosingBlockFlowElement()) || isTableStructureNode(m_upstreamStart.node()->enclosingBlockFlowElement())) 508 return; 509 510 VisiblePosition startOfParagraphToMove(m_downstreamEnd); 511 VisiblePosition mergeDestination(m_upstreamStart); 512 513 if (mergeDestination == startOfParagraphToMove) 514 return; 515 516 // FIXME: The above early return should be all we need. 503 517 if (m_endBlock == m_startBlock) 504 518 return; 505 506 Node *startNode = m_downstreamEnd.node(); 507 Node *dstNode = m_upstreamStart.node(); 508 509 if (!startNode->inDocument() || !dstNode->inDocument()) 510 return; 511 512 Node *startBlock = startNode->enclosingBlockFlowElement(); 513 514 // Do not move content between parts of a table. 515 if (isTableStructureNode(startBlock)) 516 return; 517 518 // Now that we are about to add content, check to see if a placeholder element 519 // can be removed. 520 removeBlockPlaceholder(startBlock); 521 522 // Move the subtree containing node 523 Node *node = startNode->enclosingInlineElement(); 524 525 // Insert after the subtree containing dstNode 526 Node *refNode = dstNode->enclosingInlineElement(); 527 528 // Preserve nesting when deleting to the beginning of an ancestor block 529 Node *dstBlock = refNode->enclosingBlockFlowElement(); 530 if (startBlock->isAncestor(dstBlock) && isStartOfBlock(VisiblePosition(m_upstreamStart))) 531 return; 532 533 // Do the move. 534 Node *rootNode = refNode->rootEditableElement(); 535 while (node && node->isAncestor(startBlock)) { 536 Node *moveNode = node; 537 node = node->nextSibling(); 538 removeNode(moveNode); 539 if (moveNode->hasTagName(brTag) && !moveNode->renderer()) { 540 // Just remove this node, and don't put it back. 541 // If the BR was not rendered (since it was at the end of a block, for instance), 542 // putting it back in the document might make it appear, and that is not desirable. 543 break; 544 } 545 if (refNode == rootNode) 546 insertNodeAt(moveNode, refNode, 0); 547 else 548 insertNodeAfter(moveNode, refNode); 549 refNode = moveNode; 550 if (moveNode->hasTagName(brTag)) 551 break; 552 } 553 554 // If the startBlock no longer has any kids, we may need to deal with adding a BR 555 // to make the layout come out right. Consider this document: 556 // 557 // One 558 // <div>Two</div> 559 // Three 560 // 561 // Placing the insertion before before the 'T' of 'Two' and hitting delete will 562 // move the contents of the div to the block containing 'One' and delete the div. 563 // This will have the side effect of moving 'Three' on to the same line as 'One' 564 // and 'Two'. This is undesirable. We fix this up by adding a BR before the 'Three'. 565 // This may not be ideal, but it is better than nothing. 566 updateLayout(); 567 if (!startBlock->renderer() || startBlock->renderer()->isEmpty()) { 568 removeNode(startBlock); 569 updateLayout(); 570 if (refNode->renderer() && refNode->renderer()->inlineBox() && refNode->renderer()->inlineBox()->nextOnLineExists()) { 571 insertNodeAfter(createBreakElement(document()).get(), refNode); 572 } 573 } 519 520 VisiblePosition endOfParagraphToMove = endOfParagraph(startOfParagraphToMove); 521 522 Position start = startOfParagraphToMove.deepEquivalent().upstream(); 523 // We upstream() the end so that we don't include collapsed whitespace in the move. 524 // If we must later add a br after the merged paragraph, doing so would cause the moved unrendered space to become rendered. 525 Position end = endOfParagraphToMove.deepEquivalent().upstream(); 526 RefPtr<Range> range = new Range(document(), start.node(), start.offset(), end.node(), end.offset()); 527 528 // FIXME: This is an inefficient way to preserve style on nodes in the paragraph to move. It 529 // shouldn't matter though, since moved paragraphs will usually be quite small. 530 RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(document(), range->toHTML(), ""); 531 532 setEndingSelection(Selection(startOfParagraphToMove.deepEquivalent(), endOfParagraphToMove.deepEquivalent(), DOWNSTREAM)); 533 deleteSelection(false, false); 534 535 // The above deletion leaves a placeholder (it always does when a whole paragraph is deleted). 536 // We remove it and prune it's parents since we want to remove all traces of the paragraph to move. 537 Node* placeholder = endingSelection().end().node(); 538 // FIXME: Deletion has bugs and it doesn't always add a placeholder. If it fails, still do pruning. 539 if (placeholder->hasTagName(brTag)) 540 removeNodeAndPruneAncestors(placeholder); 541 else 542 prune(placeholder); 543 544 // Add a br if pruning an empty block level element caused a collapse. For example: 545 // foo 546 // <div>bar</div> 547 // baz 548 // Placing the cursor before 'bar' and hitting delete will merge 'foo' and 'bar' and prune the empty div. 549 if (!isEndOfParagraph(mergeDestination)) 550 insertNodeAt(createBreakElement(document()).get(), m_upstreamStart.node(), m_upstreamStart.offset()); 551 552 setEndingSelection(mergeDestination); 553 EditCommandPtr cmd(new ReplaceSelectionCommand(document(), fragment.get(), false)); 554 applyCommandToComposite(cmd); 574 555 } 575 556 … … 695 676 handleGeneralDelete(); 696 677 697 // Do block merge if start and end of selection are in different blocks. 698 moveNodesAfterNode(); 678 mergeParagraphs(); 699 679 700 680 calculateEndingPosition(); -
trunk/WebCore/editing/DeleteSelectionCommand.h
r13393 r13685 50 50 void handleGeneralDelete(); 51 51 void fixupWhitespace(); 52 void m oveNodesAfterNode();52 void mergeParagraphs(); 53 53 void calculateEndingPosition(); 54 54 void calculateTypingStyleAfterDelete(WebCore::Node *insertedPlaceholder); -
trunk/WebCore/editing/ReplaceSelectionCommand.cpp
r13664 r13685 286 286 } 287 287 288 // FIXME: Move this somewhere so that the other editing operations can use it to clean up after themselves.289 void ReplaceSelectionCommand::removeNodeAndPruneAncestors(Node* node)290 {291 Node* parent = node->parentNode();292 removeNode(node);293 while (parent) {294 Node* nextParent = parent->parentNode();295 // If you change this rule you may have to add an updateLayout() here.296 if (parent->renderer() && parent->renderer()->firstChild())297 return;298 removeNode(parent);299 parent = nextParent;300 }301 }302 303 288 void ReplaceSelectionCommand::fixupNodeStyles(const NodeVector& nodes, const RenderingInfoMap& renderingInfo) 304 289 { … … 502 487 ReplacementFragment fragment(document(), m_documentFragment.get(), m_matchStyle, selection.rootEditableElement()); 503 488 489 if (fragment.type() == EmptyFragment) 490 return; 491 504 492 if (m_matchStyle) 505 493 m_insertionStyle = styleAtPosition(selection.start()); -
trunk/WebCore/editing/ReplaceSelectionCommand.h
r13664 r13685 36 36 class DocumentFragment; 37 37 38 enum EFragmentType { EmptyFragment, SingleTextNodeFragment, TreeFragment }; 39 38 40 class RenderingInfo : public Shared<RenderingInfo> { 39 41 public: … … 57 59 ReplacementFragment(Document*, DocumentFragment*, bool, Element*); 58 60 ~ReplacementFragment(); 59 60 enum EFragmentType { EmptyFragment, SingleTextNodeFragment, TreeFragment };61 61 62 62 Node *firstChild() const; … … 131 131 void fixupNodeStyles(const NodeVector&, const RenderingInfoMap&); 132 132 void removeLinePlaceholderIfNeeded(Node *); 133 void removeNodeAndPruneAncestors(Node*);134 133 135 134 RefPtr<Node> m_firstNodeInserted; -
trunk/WebCore/editing/markup.cpp
r13543 r13685 327 327 328 328 ExceptionCode ec = 0; 329 if (range->collapsed(ec)) 330 return ""; 331 ASSERT(ec == 0); 329 332 Node *commonAncestor = range->commonAncestorContainer(ec); 330 333 ASSERT(ec == 0);
Note:
See TracChangeset
for help on using the changeset viewer.