Changeset 24792 in webkit
- Timestamp:
- Jul 30, 2007 8:54:56 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r24781 r24792 1 2007-07-30 Justin Garcia <justin.garcia@apple.com> 2 3 Reviewed by Darin. 4 5 <rdar://problem/5369009> 6 Crash due to infinite recursion in moveParagraphs deleting line from a Mail message 7 8 * editing/deleting/5369009-expected.checksum: Added. 9 * editing/deleting/5369009-expected.png: Added. 10 * editing/deleting/5369009-expected.txt: Added. 11 * editing/deleting/5369009.html: Added. 12 1 13 2007-07-30 Sam Weinig <sam@webkit.org> 2 14 -
trunk/WebCore/ChangeLog
r24789 r24792 1 2007-07-30 Justin Garcia <justin.garcia@apple.com> 2 3 Reviewed by Darin. 4 5 <rdar://problem/5369009> Crash due to infinite recursion in moveParagraphs on delete 6 7 After the delete, we moved content into the previous block, and a style 8 rule turned a style span in the moved content into a block, throwing 9 moveParagraphs into infinite recursion, as it continually tried and failed 10 to get the style span into the same paragraph as the content just before it. 11 12 Added a method to ReplaceSelectionCommand to keep inserted style spans 13 from turning into blocks because of style rules. Will add code to prevent 14 other kinds of content from changing appearance because of style rules, 15 post-Leopard (5371536). Also added a bool to ReplaceSelectionCommand's 16 constructor to guard against infinite recursion. 17 18 * editing/CompositeEditCommand.cpp: 19 (WebCore::CompositeEditCommand::moveParagraphs): 20 * editing/JSEditor.cpp: 21 * editing/ReplaceSelectionCommand.cpp: 22 (WebCore::ReplaceSelectionCommand::ReplaceSelectionCommand): 23 (WebCore::ReplaceSelectionCommand::negateStyleRulesThatEffectAppearance): 24 (WebCore::ReplaceSelectionCommand::doApply): 25 * editing/ReplaceSelectionCommand.h: 26 1 27 2007-07-30 Anders Carlsson <andersca@apple.com> 2 28 -
trunk/WebCore/editing/CompositeEditCommand.cpp
r21078 r24792 784 784 785 785 setEndingSelection(destination); 786 applyCommandToComposite(new ReplaceSelectionCommand(document(), fragment.get(), true, false, !preserveStyle, false ));786 applyCommandToComposite(new ReplaceSelectionCommand(document(), fragment.get(), true, false, !preserveStyle, false, true)); 787 787 788 788 if (preserveSelection && startIndex != -1) { -
trunk/WebCore/editing/JSEditor.cpp
r24330 r24792 295 295 296 296 applyCommand(new ReplaceSelectionCommand(frame->document(), fragment.release(), 297 false, false, false, true, EditActionUnspecified));297 false, false, false, true, false, EditActionUnspecified)); 298 298 return true; 299 299 } -
trunk/WebCore/editing/ReplaceSelectionCommand.cpp
r23986 r24792 31 31 #include "CSSComputedStyleDeclaration.h" 32 32 #include "CSSPropertyNames.h" 33 #include "CSSValueKeywords.h" 33 34 #include "Document.h" 34 35 #include "DocumentFragment.h" … … 275 276 276 277 ReplaceSelectionCommand::ReplaceSelectionCommand(Document* document, PassRefPtr<DocumentFragment> fragment, 277 bool selectReplacement, bool smartReplace, bool matchStyle, bool preventNesting, 278 bool selectReplacement, bool smartReplace, bool matchStyle, bool preventNesting, bool movingParagraph, 278 279 EditAction editAction) 279 280 : CompositeEditCommand(document), … … 283 284 m_documentFragment(fragment), 284 285 m_preventNesting(preventNesting), 286 m_movingParagraph(movingParagraph), 285 287 m_editAction(editAction) 286 288 { … … 344 346 // be a no-op and cause infinite recursion. 345 347 !isBlock(fromNode) && !isBlock(toNode); 348 } 349 350 // Style rules that match just inserted elements could change their appearance, like 351 // a div inserted into a document with div { display:inline; }. 352 void ReplaceSelectionCommand::negateStyleRulesThatAffectAppearance() 353 { 354 for (RefPtr<Node> node = m_firstNodeInserted.get(); node; node = node->traverseNextNode()) { 355 // FIXME: <rdar://problem/5371536> Style rules that match pasted content can change it's appearance 356 if (isStyleSpan(node.get())) { 357 HTMLElement* e = static_cast<HTMLElement*>(node.get()); 358 // There are other styles that style rules can give to style spans, 359 // but these are the two important ones because they'll prevent 360 // inserted content from appearing in the right paragraph. 361 if (isBlock(e)) 362 e->getInlineStyleDecl()->setProperty(CSS_PROP_DISPLAY, CSS_VAL_INLINE); 363 if (e->renderer() && e->renderer()->style()->floating() != FNONE) 364 e->getInlineStyleDecl()->setProperty(CSS_PROP_FLOAT, CSS_VAL_NONE); 365 } 366 if (node == m_lastLeafInserted) 367 break; 368 } 346 369 } 347 370 … … 585 608 } 586 609 610 negateStyleRulesThatAffectAppearance(); 611 587 612 removeRedundantStyles(mailBlockquoteEnclosingSelectionStart); 588 613 … … 603 628 604 629 if (shouldMergeStart(selectionStartWasStartOfParagraph, fragment.hasInterchangeNewlineAtStart())) { 630 // Bail to avoid infinite recursion. 631 if (m_movingParagraph) { 632 ASSERT_NOT_REACHED(); 633 return; 634 } 605 635 VisiblePosition destination = startOfInsertedContent.previous(); 606 636 VisiblePosition startOfParagraphToMove = startOfInsertedContent; … … 643 673 644 674 } else if (shouldMergeEnd(selectionEndWasEndOfParagraph)) { 645 675 // Bail to avoid infinite recursion. 676 if (m_movingParagraph) { 677 ASSERT_NOT_REACHED(); 678 return; 679 } 646 680 // Merging two paragraphs will destroy the moved one's block styles. Always move forward to preserve 647 681 // the block style of the paragraph already in the document, unless the paragraph to move would include the -
trunk/WebCore/editing/ReplaceSelectionCommand.h
r20960 r24792 70 70 public: 71 71 ReplaceSelectionCommand(Document*, PassRefPtr<DocumentFragment>, 72 bool selectReplacement = true, bool smartReplace = false, bool matchStyle = false, bool preventNesting = true, 72 bool selectReplacement = true, bool smartReplace = false, bool matchStyle = false, bool preventNesting = true, bool movingParagraph = false, 73 73 EditAction = EditActionPaste); 74 74 … … 90 90 bool shouldMerge(const VisiblePosition&, const VisiblePosition&); 91 91 92 void negateStyleRulesThatAffectAppearance(); 92 93 void removeRedundantStyles(Node*); 93 94 … … 107 108 RefPtr<DocumentFragment> m_documentFragment; 108 109 bool m_preventNesting; 110 bool m_movingParagraph; 109 111 EditAction m_editAction; 110 112 };
Note: See TracChangeset
for help on using the changeset viewer.