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

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

Issue 2627103003: [EditCommandSource] Pass source through |CompositeEditCommand| ctor instead of |apply(source)| (Closed)
Patch Set: Created 3 years, 11 months 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, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 DEFINE_TRACE(EditCommandComposition) { 182 DEFINE_TRACE(EditCommandComposition) {
183 visitor->trace(m_document); 183 visitor->trace(m_document);
184 visitor->trace(m_startingSelection); 184 visitor->trace(m_startingSelection);
185 visitor->trace(m_endingSelection); 185 visitor->trace(m_endingSelection);
186 visitor->trace(m_commands); 186 visitor->trace(m_commands);
187 visitor->trace(m_startingRootEditableElement); 187 visitor->trace(m_startingRootEditableElement);
188 visitor->trace(m_endingRootEditableElement); 188 visitor->trace(m_endingRootEditableElement);
189 UndoStep::trace(visitor); 189 UndoStep::trace(visitor);
190 } 190 }
191 191
192 CompositeEditCommand::CompositeEditCommand(Document& document) 192 CompositeEditCommand::CompositeEditCommand(Document& document,
193 : EditCommand(document) {} 193 EditCommandSource source)
194 : EditCommand(document), m_source(source) {}
194 195
195 CompositeEditCommand::~CompositeEditCommand() { 196 CompositeEditCommand::~CompositeEditCommand() {
196 DCHECK(isTopLevelCommand() || !m_composition); 197 DCHECK(isTopLevelCommand() || !m_composition);
197 } 198 }
198 199
199 bool CompositeEditCommand::apply(EditCommandSource source) { 200 bool CompositeEditCommand::apply() {
200 DCHECK(!isCommandGroupWrapper()); 201 DCHECK(!isCommandGroupWrapper());
201 if (!endingSelection().isContentRichlyEditable()) { 202 if (!endingSelection().isContentRichlyEditable()) {
202 switch (inputType()) { 203 switch (inputType()) {
203 case InputEvent::InputType::InsertText: 204 case InputEvent::InputType::InsertText:
204 case InputEvent::InputType::InsertLineBreak: 205 case InputEvent::InputType::InsertLineBreak:
205 case InputEvent::InputType::InsertParagraph: 206 case InputEvent::InputType::InsertParagraph:
206 case InputEvent::InputType::InsertFromPaste: 207 case InputEvent::InputType::InsertFromPaste:
207 case InputEvent::InputType::InsertFromDrop: 208 case InputEvent::InputType::InsertFromDrop:
208 case InputEvent::InputType::InsertReplacementText: 209 case InputEvent::InputType::InsertReplacementText:
209 case InputEvent::InputType::DeleteComposedCharacterForward: 210 case InputEvent::InputType::DeleteComposedCharacterForward:
(...skipping 15 matching lines...) Expand all
225 } 226 }
226 ensureComposition(); 227 ensureComposition();
227 228
228 // Changes to the document may have been made since the last editing operation 229 // Changes to the document may have been made since the last editing operation
229 // that require a layout, as in <rdar://problem/5658603>. Low level 230 // that require a layout, as in <rdar://problem/5658603>. Low level
230 // operations, like RemoveNodeCommand, don't require a layout because the high 231 // operations, like RemoveNodeCommand, don't require a layout because the high
231 // level operations that use them perform one if one is necessary (like for 232 // level operations that use them perform one if one is necessary (like for
232 // the creation of VisiblePositions). 233 // the creation of VisiblePositions).
233 document().updateStyleAndLayoutIgnorePendingStylesheets(); 234 document().updateStyleAndLayoutIgnorePendingStylesheets();
234 235
235 if (!willApplyEditing(source)) 236 if (!willApplyEditing(m_source))
236 return false; 237 return false;
237 238
238 LocalFrame* frame = document().frame(); 239 LocalFrame* frame = document().frame();
239 DCHECK(frame); 240 DCHECK(frame);
240 EditingState editingState; 241 EditingState editingState;
241 { 242 {
242 EventQueueScope eventQueueScope; 243 EventQueueScope eventQueueScope;
243 doApply(&editingState); 244 doApply(&editingState);
244 } 245 }
245 246
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 CompositeEditCommand* command) { 327 CompositeEditCommand* command) {
327 ensureComposition()->append(command->ensureComposition()); 328 ensureComposition()->append(command->ensureComposition());
328 command->m_composition = nullptr; 329 command->m_composition = nullptr;
329 command->setParent(this); 330 command->setParent(this);
330 m_commands.append(command); 331 m_commands.append(command);
331 } 332 }
332 333
333 void CompositeEditCommand::applyStyle(const EditingStyle* style, 334 void CompositeEditCommand::applyStyle(const EditingStyle* style,
334 EditingState* editingState) { 335 EditingState* editingState) {
335 applyCommandToComposite( 336 applyCommandToComposite(
336 ApplyStyleCommand::create(document(), style, InputEvent::InputType::None), 337 ApplyStyleCommand::create(document(), EditCommandSource::kInternal, style,
338 InputEvent::InputType::None),
337 editingState); 339 editingState);
338 } 340 }
339 341
340 void CompositeEditCommand::applyStyle(const EditingStyle* style, 342 void CompositeEditCommand::applyStyle(const EditingStyle* style,
341 const Position& start, 343 const Position& start,
342 const Position& end, 344 const Position& end,
343 EditingState* editingState) { 345 EditingState* editingState) {
344 applyCommandToComposite( 346 applyCommandToComposite(
345 ApplyStyleCommand::create(document(), style, start, end), editingState); 347 ApplyStyleCommand::create(document(), style, start, end), editingState);
346 } 348 }
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 EditingState* editingState) { 752 EditingState* editingState) {
751 // insert node before, after, or at split of tab span 753 // insert node before, after, or at split of tab span
752 insertNodeAt(node, positionOutsideTabSpan(pos), editingState); 754 insertNodeAt(node, positionOutsideTabSpan(pos), editingState);
753 } 755 }
754 756
755 void CompositeEditCommand::deleteSelection(EditingState* editingState, 757 void CompositeEditCommand::deleteSelection(EditingState* editingState,
756 bool smartDelete, 758 bool smartDelete,
757 bool mergeBlocksAfterDelete, 759 bool mergeBlocksAfterDelete,
758 bool expandForSpecialElements, 760 bool expandForSpecialElements,
759 bool sanitizeMarkup) { 761 bool sanitizeMarkup) {
760 if (endingSelection().isRange()) 762 if (endingSelection().isRange()) {
761 applyCommandToComposite(DeleteSelectionCommand::create( 763 applyCommandToComposite(
762 document(), smartDelete, mergeBlocksAfterDelete, 764 DeleteSelectionCommand::create(
763 expandForSpecialElements, sanitizeMarkup), 765 document(), EditCommandSource::kInternal, smartDelete,
764 editingState); 766 mergeBlocksAfterDelete, expandForSpecialElements, sanitizeMarkup),
767 editingState);
768 }
765 } 769 }
766 770
767 void CompositeEditCommand::deleteSelection(const VisibleSelection& selection, 771 void CompositeEditCommand::deleteSelection(const VisibleSelection& selection,
768 EditingState* editingState, 772 EditingState* editingState,
769 bool smartDelete, 773 bool smartDelete,
770 bool mergeBlocksAfterDelete, 774 bool mergeBlocksAfterDelete,
771 bool expandForSpecialElements, 775 bool expandForSpecialElements,
772 bool sanitizeMarkup) { 776 bool sanitizeMarkup) {
773 if (selection.isRange()) 777 if (selection.isRange())
774 applyCommandToComposite(DeleteSelectionCommand::create( 778 applyCommandToComposite(DeleteSelectionCommand::create(
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after
1679 editingState->abort(); 1683 editingState->abort();
1680 return; 1684 return;
1681 } 1685 }
1682 setEndingSelection(destinationSelection); 1686 setEndingSelection(destinationSelection);
1683 ReplaceSelectionCommand::CommandOptions options = 1687 ReplaceSelectionCommand::CommandOptions options =
1684 ReplaceSelectionCommand::SelectReplacement | 1688 ReplaceSelectionCommand::SelectReplacement |
1685 ReplaceSelectionCommand::MovingParagraph; 1689 ReplaceSelectionCommand::MovingParagraph;
1686 if (shouldPreserveStyle == DoNotPreserveStyle) 1690 if (shouldPreserveStyle == DoNotPreserveStyle)
1687 options |= ReplaceSelectionCommand::MatchStyle; 1691 options |= ReplaceSelectionCommand::MatchStyle;
1688 applyCommandToComposite( 1692 applyCommandToComposite(
1689 ReplaceSelectionCommand::create(document(), fragment, options), 1693 ReplaceSelectionCommand::create(document(), EditCommandSource::kInternal,
1694 fragment, options),
1690 editingState); 1695 editingState);
1691 if (editingState->isAborted()) 1696 if (editingState->isAborted())
1692 return; 1697 return;
1693 1698
1694 document().updateStyleAndLayoutIgnorePendingStylesheets(); 1699 document().updateStyleAndLayoutIgnorePendingStylesheets();
1695 1700
1696 document().frame()->spellChecker().markMisspellingsForMovingParagraphs( 1701 document().frame()->spellChecker().markMisspellingsForMovingParagraphs(
1697 endingSelection()); 1702 endingSelection());
1698 1703
1699 // If the selection is in an empty paragraph, restore styles from the old 1704 // If the selection is in an empty paragraph, restore styles from the old
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
2047 return node; 2052 return node;
2048 } 2053 }
2049 2054
2050 DEFINE_TRACE(CompositeEditCommand) { 2055 DEFINE_TRACE(CompositeEditCommand) {
2051 visitor->trace(m_commands); 2056 visitor->trace(m_commands);
2052 visitor->trace(m_composition); 2057 visitor->trace(m_composition);
2053 EditCommand::trace(visitor); 2058 EditCommand::trace(visitor);
2054 } 2059 }
2055 2060
2056 } // namespace blink 2061 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698