Changeset 25484 in webkit
- Timestamp:
- Sep 10, 2007 6:03:00 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 8 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r25482 r25484 1 2007-09-10 David Harrison <harrison@apple.com> 2 3 Reviewed by Kevin and Tristan. 4 5 <rdar://problem/5456800> Mail crashes at WebCore::nextCandidate() after pasting back into a <table> multiple times 6 7 * editing/pasteboard/paste-into-anchor-text.html: Added. 8 * editing/pasteboard/paste-table-cells.html: Added. 9 * editing/pasteboard/quirks-mode-br-1-expected.checksum: 10 * editing/pasteboard/quirks-mode-br-1-expected.txt: 11 * editing/pasteboard/quirks-mode-br-1.html: 12 * platform/mac/editing/pasteboard/paste-into-anchor-text-expected.checksum: Added. 13 * platform/mac/editing/pasteboard/paste-into-anchor-text-expected.png: Added. 14 * platform/mac/editing/pasteboard/paste-into-anchor-text-expected.txt: Added. 15 * platform/mac/editing/pasteboard/paste-table-cells-expected.checksum: Added. 16 * platform/mac/editing/pasteboard/paste-table-cells-expected.png: Added. 17 * platform/mac/editing/pasteboard/paste-table-cells-expected.txt: Added. 18 1 19 2007-09-10 Kevin McCullough <kmccullough@apple.com> 2 20 -
trunk/LayoutTests/editing/pasteboard/quirks-mode-br-1-expected.checksum
r20274 r25484 1 25c02b740ed1e07d4119a21c57f8d992 1 dba7fc10054f5af9c815ddfc425bb74a -
trunk/LayoutTests/editing/pasteboard/quirks-mode-br-1-expected.txt
r20950 r25484 3 3 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification 4 4 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification 5 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 61 of #text > DIV > DIV > BODY > HTML > #document to 61 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE6 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification7 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification8 5 layer at (0,0) size 800x600 9 6 RenderView at (0,0) size 800x600 … … 16 13 text run at (0,18) width 184: "end of blocks are collapsed). " 17 14 text run at (184,18) width 509: "This test used to fail because of unrendered content to the left of the collapsed br." 18 RenderBlock {DIV} at (0,52) size 784x 3615 RenderBlock {DIV} at (0,52) size 784x18 19 16 RenderBlock {DIV} at (0,0) size 784x18 20 17 RenderText {#text} at (0,0) size 370x18 21 18 text run at (0,0) width 370: "The test should add a single blank line after this paragraph." 22 19 RenderInline {SPAN} at (0,0) size 0x18 23 RenderBlock (anonymous) at (0,18) size 784x18 24 RenderBR {BR} at (0,0) size 0x18 25 caret: position 0 of child 1 {BR} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document 20 RenderBR {BR} at (370,14) size 0x0 21 caret: position 61 of child 0 {#text} of child 0 {DIV} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document -
trunk/LayoutTests/editing/pasteboard/quirks-mode-br-1.html
r17562 r25484 12 12 s.setPosition(e, 0); 13 13 s.modify("move", "forward", "line"); 14 document.execCommand("InsertHTML", false, "<br>");15 14 </script> -
trunk/WebCore/ChangeLog
r25473 r25484 1 2007-09-10 David Harrison <harrison@apple.com> 2 3 Reviewed by Kevin and Tristan. 4 5 Tests added: 6 * editing/pasteboard/paste-into-anchor-text.html: Added. 7 * editing/pasteboard/paste-table-cells.html: Added. 8 9 Source changes: 10 * editing/CompositeEditCommand.cpp: 11 (WebCore::CompositeEditCommand::positionAvoidingSpecialElementBoundary): 12 Nil check enclosingAnchor. 13 14 * editing/ReplaceSelectionCommand.cpp: 15 (WebCore::ReplaceSelectionCommand::removeNodeAndPruneAncestors): 16 New. Keeps m_firstNodeInserted and m_lastLeafInserted updated. 17 18 (WebCore::ReplaceSelectionCommand::negateStyleRulesThatAffectAppearance): 19 Added a comment. 20 21 (WebCore::ReplaceSelectionCommand::removeRedundantStyles): 22 Let ReplaceSelectionCommand::removeNodeAndPruneAncestors() update the nodes. 23 24 (WebCore::ReplaceSelectionCommand::doApply): 25 Pass originalVisPosBeforeEndBR to shouldRemoveEndBR() 26 27 (WebCore::ReplaceSelectionCommand::shouldRemoveEndBR): 28 Don't remove the br if nothing was inserted. 29 30 * editing/ReplaceSelectionCommand.h: 31 Add VisiblePosition parameter to shouldRemoveEndBR() 32 33 * editing/markup.cpp: 34 (WebCore::createMarkup): 35 Wrap orphan tr element with a table element, just like we were doing 36 for tobody elements. 37 1 38 2007-09-10 David Kilzer <ddkilzer@apple.com> 2 39 -
trunk/WebCore/editing/CompositeEditCommand.cpp
r25327 r25484 856 856 pushAnchorElementDown(enclosingAnchor); 857 857 enclosingAnchor = enclosingAnchorElement(original); 858 if (!enclosingAnchor) 859 return original; 858 860 } 859 861 // Don't insert outside an anchor if doing so would skip over a line break. It would -
trunk/WebCore/editing/ReplaceSelectionCommand.cpp
r25332 r25484 324 324 } 325 325 326 // Virtual method used so that ReplaceSelectionCommand can update the node's it tracks.326 // Wrap CompositeEditCommand::removeNodePreservingChildren() so we can update the nodes we track 327 327 void ReplaceSelectionCommand::removeNodePreservingChildren(Node* node) 328 328 { … … 332 332 m_lastLeafInserted = node->lastChild() ? node->lastChild() : node->traverseNextSibling(); 333 333 CompositeEditCommand::removeNodePreservingChildren(node); 334 } 335 336 // Wrap CompositeEditCommand::removeNodeAndPruneAncestors() so we can update the nodes we track 337 void ReplaceSelectionCommand::removeNodeAndPruneAncestors(Node* node) 338 { 339 // prepare in case m_firstNodeInserted and/or m_lastLeafInserted get removed 340 // FIXME: shouldn't m_lastLeafInserted be adjusted using traversePreviousNode()? 341 Node* afterFirst = m_firstNodeInserted ? m_firstNodeInserted->traverseNextSibling() : 0; 342 Node* afterLast = m_lastLeafInserted ? m_lastLeafInserted->traverseNextSibling() : 0; 343 344 CompositeEditCommand::removeNodeAndPruneAncestors(node); 345 346 // adjust m_firstNodeInserted and m_lastLeafInserted since either or both may have been removed 347 if (m_lastLeafInserted && !m_lastLeafInserted->inDocument()) 348 m_lastLeafInserted = afterLast; 349 if (m_firstNodeInserted && !m_firstNodeInserted->inDocument()) 350 m_firstNodeInserted = m_lastLeafInserted && m_lastLeafInserted->inDocument() ? afterFirst : 0; 334 351 } 335 352 … … 362 379 // but these are the two important ones because they'll prevent 363 380 // inserted content from appearing in the right paragraph. 381 // FIXME: Hyatt is concerned that selectively using display:inline will give inconsistent 382 // results. We already know one issue because td elements ignore their display property 383 // in quirks mode (which Mail.app is always in). We should look for an alternative. 364 384 if (isBlock(e)) 365 385 e->getInlineStyleDecl()->setProperty(CSS_PROP_DISPLAY, CSS_VAL_INLINE); … … 414 434 // Remove empty style spans. 415 435 if (isStyleSpan(element) && !element->hasChildNodes()) { 416 if (m_firstNodeInserted == m_lastLeafInserted && m_firstNodeInserted == element)417 m_firstNodeInserted = 0;418 if (m_firstNodeInserted == element)419 m_firstNodeInserted = element->traverseNextSibling();420 if (m_lastLeafInserted == element)421 m_lastLeafInserted = element->traverseNextSibling();422 436 removeNodeAndPruneAncestors(element); 423 437 continue; … … 548 562 // away, there are positions after the br which map to the same visible position as [br, 0]). 549 563 Node* endBR = insertionPos.downstream().node()->hasTagName(brTag) ? insertionPos.downstream().node() : 0; 564 VisiblePosition originalVisPosBeforeEndBR; 565 if (endBR) 566 originalVisPosBeforeEndBR = VisiblePosition(endBR, 0, DOWNSTREAM).previous(); 550 567 551 568 startBlock = enclosingBlock(insertionPos.node()); … … 632 649 bool interchangeNewlineAtEnd = fragment.hasInterchangeNewlineAtEnd(); 633 650 634 if (shouldRemoveEndBR(endBR ))651 if (shouldRemoveEndBR(endBR, originalVisPosBeforeEndBR)) 635 652 removeNodeAndPruneAncestors(endBR); 636 653 637 654 if (shouldMergeStart(selectionStartWasStartOfParagraph, fragment.hasInterchangeNewlineAtStart())) { 638 655 // Bail to avoid infinite recursion. 639 656 if (m_movingParagraph) { 640 ASSERT_NOT_REACHED(); 657 // setting display:inline does not work for td elements in quirks mode 658 ASSERT(m_firstNodeInserted->hasTagName(tdTag)); 641 659 return; 642 660 } … … 750 768 } 751 769 752 bool ReplaceSelectionCommand::shouldRemoveEndBR(Node* endBR )770 bool ReplaceSelectionCommand::shouldRemoveEndBR(Node* endBR, const VisiblePosition& originalVisPosBeforeEndBR) 753 771 { 754 772 if (!endBR || !endBR->inDocument()) … … 757 775 VisiblePosition visiblePos(Position(endBR, 0)); 758 776 759 return 760 // The br is collapsed away and so is unnecessary. 761 !document()->inStrictMode() && isEndOfBlock(visiblePos) && !isStartOfParagraph(visiblePos) || 762 // A br that was originally holding a line open should be displaced by inserted content or turned into a line break. 763 // A br that was originally acting as a line break should still be acting as a line break, not as a placeholder. 764 isStartOfParagraph(visiblePos) && isEndOfParagraph(visiblePos); 777 // Don't remove the br if nothing was inserted. 778 if (visiblePos.previous() == originalVisPosBeforeEndBR) 779 return false; 780 781 // Remove the br if it is collapsed away and so is unnecessary. 782 if (!document()->inStrictMode() && isEndOfBlock(visiblePos) && !isStartOfParagraph(visiblePos)) 783 return true; 784 785 // A br that was originally holding a line open should be displaced by inserted content or turned into a line break. 786 // A br that was originally acting as a line break should still be acting as a line break, not as a placeholder. 787 return isStartOfParagraph(visiblePos) && isEndOfParagraph(visiblePos); 765 788 } 766 789 -
trunk/WebCore/editing/ReplaceSelectionCommand.h
r24792 r25484 84 84 85 85 void updateNodesInserted(Node*); 86 bool shouldRemoveEndBR(Node* );86 bool shouldRemoveEndBR(Node*, const VisiblePosition&); 87 87 88 88 bool shouldMergeStart(bool, bool); … … 96 96 97 97 virtual void removeNodePreservingChildren(Node*); 98 virtual void removeNodeAndPruneAncestors(Node*); 98 99 99 100 VisiblePosition positionAtStartOfInsertedContent(); -
trunk/WebCore/editing/markup.cpp
r25327 r25484 589 589 Node* commonAncestorBlock = commonAncestor ? enclosingBlock(commonAncestor) : 0; 590 590 if (annotate && commonAncestorBlock) { 591 if (commonAncestorBlock->hasTagName(tbodyTag) ) {591 if (commonAncestorBlock->hasTagName(tbodyTag) || commonAncestorBlock->hasTagName(trTag)) { 592 592 Node* table = commonAncestorBlock->parentNode(); 593 593 while (table && !table->hasTagName(tableTag))
Note: See TracChangeset
for help on using the changeset viewer.