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

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

Issue 2374743002: [InputEvent] Support |deleteByDrag|, |insertFromDrop| and fire in sequential order (Closed)
Patch Set: Yosin's review Created 4 years, 2 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 InputEvent::InputType EditCommandComposition::inputType() const 143 InputEvent::InputType EditCommandComposition::inputType() const
144 { 144 {
145 return m_inputType; 145 return m_inputType;
146 } 146 }
147 147
148 void EditCommandComposition::append(SimpleEditCommand* command) 148 void EditCommandComposition::append(SimpleEditCommand* command)
149 { 149 {
150 m_commands.append(command); 150 m_commands.append(command);
151 } 151 }
152 152
153 void EditCommandComposition::append(EditCommandComposition* composition)
154 {
155 m_commands.appendVector(composition->m_commands);
156 }
157
153 void EditCommandComposition::setStartingSelection(const VisibleSelection& select ion) 158 void EditCommandComposition::setStartingSelection(const VisibleSelection& select ion)
154 { 159 {
155 m_startingSelection = selection; 160 m_startingSelection = selection;
156 m_startingRootEditableElement = selection.rootEditableElement(); 161 m_startingRootEditableElement = selection.rootEditableElement();
157 } 162 }
158 163
159 void EditCommandComposition::setEndingSelection(const VisibleSelection& selectio n) 164 void EditCommandComposition::setEndingSelection(const VisibleSelection& selectio n)
160 { 165 {
161 m_endingSelection = selection; 166 m_endingSelection = selection;
162 m_endingRootEditableElement = selection.rootEditableElement(); 167 m_endingRootEditableElement = selection.rootEditableElement();
(...skipping 15 matching lines...) Expand all
178 { 183 {
179 } 184 }
180 185
181 CompositeEditCommand::~CompositeEditCommand() 186 CompositeEditCommand::~CompositeEditCommand()
182 { 187 {
183 DCHECK(isTopLevelCommand() || !m_composition); 188 DCHECK(isTopLevelCommand() || !m_composition);
184 } 189 }
185 190
186 bool CompositeEditCommand::apply() 191 bool CompositeEditCommand::apply()
187 { 192 {
193 DCHECK(!isCommandGroupWrapper());
188 if (!endingSelection().isContentRichlyEditable()) { 194 if (!endingSelection().isContentRichlyEditable()) {
189 switch (inputType()) { 195 switch (inputType()) {
190 case InputEvent::InputType::InsertText: 196 case InputEvent::InputType::InsertText:
191 case InputEvent::InputType::InsertLineBreak: 197 case InputEvent::InputType::InsertLineBreak:
192 case InputEvent::InputType::InsertParagraph: 198 case InputEvent::InputType::InsertParagraph:
193 case InputEvent::InputType::InsertFromPaste: 199 case InputEvent::InputType::InsertFromPaste:
200 case InputEvent::InputType::InsertFromDrop:
194 case InputEvent::InputType::DeleteComposedCharacterForward: 201 case InputEvent::InputType::DeleteComposedCharacterForward:
195 case InputEvent::InputType::DeleteComposedCharacterBackward: 202 case InputEvent::InputType::DeleteComposedCharacterBackward:
196 case InputEvent::InputType::DeleteWordBackward: 203 case InputEvent::InputType::DeleteWordBackward:
197 case InputEvent::InputType::DeleteWordForward: 204 case InputEvent::InputType::DeleteWordForward:
198 case InputEvent::InputType::DeleteLineBackward: 205 case InputEvent::InputType::DeleteLineBackward:
199 case InputEvent::InputType::DeleteLineForward: 206 case InputEvent::InputType::DeleteLineForward:
200 case InputEvent::InputType::DeleteContentBackward: 207 case InputEvent::InputType::DeleteContentBackward:
201 case InputEvent::InputType::DeleteContentForward: 208 case InputEvent::InputType::DeleteContentForward:
202 case InputEvent::InputType::DeleteByCut: 209 case InputEvent::InputType::DeleteByCut:
203 case InputEvent::InputType::Drag: 210 case InputEvent::InputType::DeleteByDrag:
204 case InputEvent::InputType::SetWritingDirection: 211 case InputEvent::InputType::SetWritingDirection:
205 case InputEvent::InputType::None: 212 case InputEvent::InputType::None:
206 break; 213 break;
207 default: 214 default:
208 NOTREACHED(); 215 NOTREACHED();
209 return false; 216 return false;
210 } 217 }
211 } 218 }
212 ensureComposition(); 219 ensureComposition();
213 220
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 bool CompositeEditCommand::preservesTypingStyle() const 252 bool CompositeEditCommand::preservesTypingStyle() const
246 { 253 {
247 return false; 254 return false;
248 } 255 }
249 256
250 bool CompositeEditCommand::isTypingCommand() const 257 bool CompositeEditCommand::isTypingCommand() const
251 { 258 {
252 return false; 259 return false;
253 } 260 }
254 261
262 bool CompositeEditCommand::isCommandGroupWrapper() const
263 {
264 return false;
265 }
266
267 bool CompositeEditCommand::isDragAndDropCommand() const
268 {
269 return false;
270 }
271
255 bool CompositeEditCommand::isReplaceSelectionCommand() const 272 bool CompositeEditCommand::isReplaceSelectionCommand() const
256 { 273 {
257 return false; 274 return false;
258 } 275 }
259 276
260 void CompositeEditCommand::setShouldRetainAutocorrectionIndicator(bool) 277 void CompositeEditCommand::setShouldRetainAutocorrectionIndicator(bool)
261 { 278 {
262 } 279 }
263 280
264 // 281 //
(...skipping 19 matching lines...) Expand all
284 command->setParent(this); 301 command->setParent(this);
285 if (selection != command->endingSelection()) { 302 if (selection != command->endingSelection()) {
286 command->setStartingSelection(selection); 303 command->setStartingSelection(selection);
287 command->setEndingSelection(selection); 304 command->setEndingSelection(selection);
288 } 305 }
289 command->doApply(editingState); 306 command->doApply(editingState);
290 if (!editingState->isAborted()) 307 if (!editingState->isAborted())
291 m_commands.append(command); 308 m_commands.append(command);
292 } 309 }
293 310
311 void CompositeEditCommand::appendCommandToComposite(CompositeEditCommand* comman d)
312 {
313 ensureComposition()->append(command->ensureComposition());
314 command->setParent(this);
315 m_commands.append(command);
316 }
317
294 void CompositeEditCommand::applyStyle(const EditingStyle* style, EditingState* e ditingState) 318 void CompositeEditCommand::applyStyle(const EditingStyle* style, EditingState* e ditingState)
295 { 319 {
296 applyCommandToComposite(ApplyStyleCommand::create(document(), style, InputEv ent::InputType::ChangeAttributes), editingState); 320 applyCommandToComposite(ApplyStyleCommand::create(document(), style, InputEv ent::InputType::ChangeAttributes), editingState);
297 } 321 }
298 322
299 void CompositeEditCommand::applyStyle(const EditingStyle* style, const Position& start, const Position& end, EditingState* editingState) 323 void CompositeEditCommand::applyStyle(const EditingStyle* style, const Position& start, const Position& end, EditingState* editingState)
300 { 324 {
301 applyCommandToComposite(ApplyStyleCommand::create(document(), style, start, end), editingState); 325 applyCommandToComposite(ApplyStyleCommand::create(document(), style, start, end), editingState);
302 } 326 }
303 327
(...skipping 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 } 1684 }
1661 1685
1662 DEFINE_TRACE(CompositeEditCommand) 1686 DEFINE_TRACE(CompositeEditCommand)
1663 { 1687 {
1664 visitor->trace(m_commands); 1688 visitor->trace(m_commands);
1665 visitor->trace(m_composition); 1689 visitor->trace(m_composition);
1666 EditCommand::trace(visitor); 1690 EditCommand::trace(visitor);
1667 } 1691 }
1668 1692
1669 } // namespace blink 1693 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698