Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp

Issue 2574793002: [Editing] Store |CommandSource| in |CompositeEditCommand| (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 if (m_firstNodeInserted.get() == node) 431 if (m_firstNodeInserted.get() == node)
432 m_firstNodeInserted = &newNode; 432 m_firstNodeInserted = &newNode;
433 if (m_lastNodeInserted.get() == node) 433 if (m_lastNodeInserted.get() == node)
434 m_lastNodeInserted = &newNode; 434 m_lastNodeInserted = &newNode;
435 if (m_refNode.get() == node) 435 if (m_refNode.get() == node)
436 m_refNode = &newNode; 436 m_refNode = &newNode;
437 } 437 }
438 438
439 ReplaceSelectionCommand::ReplaceSelectionCommand( 439 ReplaceSelectionCommand::ReplaceSelectionCommand(
440 Document& document, 440 Document& document,
441 CommandSource source,
441 DocumentFragment* fragment, 442 DocumentFragment* fragment,
442 CommandOptions options, 443 CommandOptions options,
443 InputEvent::InputType inputType) 444 InputEvent::InputType inputType)
444 : CompositeEditCommand(document), 445 : CompositeEditCommand(document, source),
445 m_selectReplacement(options & SelectReplacement), 446 m_selectReplacement(options & SelectReplacement),
446 m_smartReplace(options & SmartReplace), 447 m_smartReplace(options & SmartReplace),
447 m_matchStyle(options & MatchStyle), 448 m_matchStyle(options & MatchStyle),
448 m_documentFragment(fragment), 449 m_documentFragment(fragment),
449 m_preventNesting(options & PreventNesting), 450 m_preventNesting(options & PreventNesting),
450 m_movingParagraph(options & MovingParagraph), 451 m_movingParagraph(options & MovingParagraph),
451 m_inputType(inputType), 452 m_inputType(inputType),
452 m_sanitizeFragment(options & SanitizeFragment), 453 m_sanitizeFragment(options & SanitizeFragment),
453 m_shouldMergeEnd(false) {} 454 m_shouldMergeEnd(false) {}
454 455
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 1273
1273 Position insertionPos = endingSelection().start(); 1274 Position insertionPos = endingSelection().start();
1274 // We don't want any of the pasted content to end up nested in a Mail 1275 // We don't want any of the pasted content to end up nested in a Mail
1275 // blockquote, so first break out of any surrounding Mail blockquotes. Unless 1276 // blockquote, so first break out of any surrounding Mail blockquotes. Unless
1276 // we're inserting in a table, in which case breaking the blockquote will 1277 // we're inserting in a table, in which case breaking the blockquote will
1277 // prevent the content from actually being inserted in the table. 1278 // prevent the content from actually being inserted in the table.
1278 if (enclosingNodeOfType(insertionPos, isMailHTMLBlockquoteElement, 1279 if (enclosingNodeOfType(insertionPos, isMailHTMLBlockquoteElement,
1279 CanCrossEditingBoundary) && 1280 CanCrossEditingBoundary) &&
1280 m_preventNesting && 1281 m_preventNesting &&
1281 !(enclosingNodeOfType(insertionPos, &isTableStructureNode))) { 1282 !(enclosingNodeOfType(insertionPos, &isTableStructureNode))) {
1282 applyCommandToComposite(BreakBlockquoteCommand::create(document()), 1283 applyCommandToComposite(
1283 editingState); 1284 BreakBlockquoteCommand::create(document(), commandSource()),
1285 editingState);
1284 if (editingState->isAborted()) 1286 if (editingState->isAborted())
1285 return; 1287 return;
1286 // This will leave a br between the split. 1288 // This will leave a br between the split.
1287 Node* br = endingSelection().start().anchorNode(); 1289 Node* br = endingSelection().start().anchorNode();
1288 DCHECK(isHTMLBRElement(br)) << br; 1290 DCHECK(isHTMLBRElement(br)) << br;
1289 // Insert content between the two blockquotes, but remove the br (since it 1291 // Insert content between the two blockquotes, but remove the br (since it
1290 // was just a placeholder). 1292 // was just a placeholder).
1291 insertionPos = Position::inParentBeforeNode(*br); 1293 insertionPos = Position::inParentBeforeNode(*br);
1292 removeNode(br, editingState); 1294 removeNode(br, editingState);
1293 if (editingState->isAborted()) 1295 if (editingState->isAborted())
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 // where refNode is dereferenced and refNode is connected. 1539 // where refNode is dereferenced and refNode is connected.
1538 bool refNodeWasConnected = insertedNodes.refNode()->isConnected(); 1540 bool refNodeWasConnected = insertedNodes.refNode()->isConnected();
1539 removeRedundantStylesAndKeepStyleSpanInline(insertedNodes, editingState); 1541 removeRedundantStylesAndKeepStyleSpanInline(insertedNodes, editingState);
1540 if (editingState->isAborted()) 1542 if (editingState->isAborted())
1541 return; 1543 return;
1542 DCHECK_EQ(insertedNodes.refNode()->isConnected(), refNodeWasConnected) 1544 DCHECK_EQ(insertedNodes.refNode()->isConnected(), refNodeWasConnected)
1543 << insertedNodes.refNode(); 1545 << insertedNodes.refNode();
1544 } 1546 }
1545 1547
1546 if (m_sanitizeFragment && insertedNodes.firstNodeInserted()) { 1548 if (m_sanitizeFragment && insertedNodes.firstNodeInserted()) {
1547 applyCommandToComposite(SimplifyMarkupCommand::create( 1549 applyCommandToComposite(
1548 document(), insertedNodes.firstNodeInserted(), 1550 SimplifyMarkupCommand::create(document(), commandSource(),
1549 insertedNodes.pastLastLeaf()), 1551 insertedNodes.firstNodeInserted(),
1550 editingState); 1552 insertedNodes.pastLastLeaf()),
1553 editingState);
1551 if (editingState->isAborted()) 1554 if (editingState->isAborted())
1552 return; 1555 return;
1553 } 1556 }
1554 1557
1555 // Setup m_startOfInsertedContent and m_endOfInsertedContent. This should be 1558 // Setup m_startOfInsertedContent and m_endOfInsertedContent. This should be
1556 // the last two lines of code that access insertedNodes. 1559 // the last two lines of code that access insertedNodes.
1557 m_startOfInsertedContent = 1560 m_startOfInsertedContent =
1558 firstPositionInOrBeforeNode(insertedNodes.firstNodeInserted()); 1561 firstPositionInOrBeforeNode(insertedNodes.firstNodeInserted());
1559 m_endOfInsertedContent = 1562 m_endOfInsertedContent =
1560 lastPositionInOrAfterNode(insertedNodes.lastLeafInserted()); 1563 lastPositionInOrAfterNode(insertedNodes.lastLeafInserted());
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
2130 visitor->trace(m_startOfInsertedContent); 2133 visitor->trace(m_startOfInsertedContent);
2131 visitor->trace(m_endOfInsertedContent); 2134 visitor->trace(m_endOfInsertedContent);
2132 visitor->trace(m_insertionStyle); 2135 visitor->trace(m_insertionStyle);
2133 visitor->trace(m_documentFragment); 2136 visitor->trace(m_documentFragment);
2134 visitor->trace(m_startOfInsertedRange); 2137 visitor->trace(m_startOfInsertedRange);
2135 visitor->trace(m_endOfInsertedRange); 2138 visitor->trace(m_endOfInsertedRange);
2136 CompositeEditCommand::trace(visitor); 2139 CompositeEditCommand::trace(visitor);
2137 } 2140 }
2138 2141
2139 } // namespace blink 2142 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698