OLD | NEW |
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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 case InputEvent::InputType::InsertText: | 194 case InputEvent::InputType::InsertText: |
195 case InputEvent::InputType::InsertLineBreak: | 195 case InputEvent::InputType::InsertLineBreak: |
196 case InputEvent::InputType::InsertParagraph: | 196 case InputEvent::InputType::InsertParagraph: |
197 case InputEvent::InputType::InsertFromPaste: | 197 case InputEvent::InputType::InsertFromPaste: |
198 case InputEvent::InputType::InsertFromDrop: | 198 case InputEvent::InputType::InsertFromDrop: |
199 case InputEvent::InputType::InsertReplacementText: | 199 case InputEvent::InputType::InsertReplacementText: |
200 case InputEvent::InputType::DeleteComposedCharacterForward: | 200 case InputEvent::InputType::DeleteComposedCharacterForward: |
201 case InputEvent::InputType::DeleteComposedCharacterBackward: | 201 case InputEvent::InputType::DeleteComposedCharacterBackward: |
202 case InputEvent::InputType::DeleteWordBackward: | 202 case InputEvent::InputType::DeleteWordBackward: |
203 case InputEvent::InputType::DeleteWordForward: | 203 case InputEvent::InputType::DeleteWordForward: |
204 case InputEvent::InputType::DeleteLineBackward: | 204 case InputEvent::InputType::DeleteSoftLineBackward: |
205 case InputEvent::InputType::DeleteLineForward: | 205 case InputEvent::InputType::DeleteSoftLineForward: |
| 206 case InputEvent::InputType::DeleteContent: |
206 case InputEvent::InputType::DeleteContentBackward: | 207 case InputEvent::InputType::DeleteContentBackward: |
207 case InputEvent::InputType::DeleteContentForward: | 208 case InputEvent::InputType::DeleteContentForward: |
208 case InputEvent::InputType::DeleteByCut: | 209 case InputEvent::InputType::DeleteByCut: |
209 case InputEvent::InputType::DeleteByDrag: | 210 case InputEvent::InputType::DeleteByDrag: |
210 case InputEvent::InputType::None: | 211 case InputEvent::InputType::None: |
211 break; | 212 break; |
212 default: | 213 default: |
213 NOTREACHED(); | 214 NOTREACHED(); |
214 return false; | 215 return false; |
215 } | 216 } |
216 } | 217 } |
217 ensureComposition(); | 218 ensureComposition(); |
218 | 219 |
219 // Changes to the document may have been made since the last editing operation | 220 // Changes to the document may have been made since the last editing operation |
220 // that require a layout, as in <rdar://problem/5658603>. Low level | 221 // that require a layout, as in <rdar://problem/5658603>. Low level |
221 // operations, like RemoveNodeCommand, don't require a layout because the high | 222 // operations, like RemoveNodeCommand, don't require a layout because the high |
222 // level operations that use them perform one if one is necessary (like for | 223 // level operations that use them perform one if one is necessary (like for |
223 // the creation of VisiblePositions). | 224 // the creation of VisiblePositions). |
224 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 225 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
225 | 226 |
| 227 // Covers the initial TypingCommand and other top-level commands. |
| 228 // See TypingCommand::willAddTypingToOpenCommand(). |
| 229 if (!willApply()) |
| 230 return false; |
| 231 |
226 LocalFrame* frame = document().frame(); | 232 LocalFrame* frame = document().frame(); |
227 DCHECK(frame); | 233 DCHECK(frame); |
228 EditingState editingState; | 234 EditingState editingState; |
229 { | 235 { |
230 EventQueueScope eventQueueScope; | 236 EventQueueScope eventQueueScope; |
231 doApply(&editingState); | 237 doApply(&editingState); |
232 } | 238 } |
233 | 239 |
234 // Only need to call appliedEditing for top-level commands, and TypingCommands | 240 // Only need to call appliedEditing for top-level commands, and TypingCommands |
235 // do it on their own (see TypingCommand::typingAddedToOpenCommand). | 241 // do it on their own (see TypingCommand::typingAddedToOpenCommand). |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 // Mutation events (bug 22634) from the text node insertion may have removed | 429 // Mutation events (bug 22634) from the text node insertion may have removed |
424 // the refChild | 430 // the refChild |
425 if (!refChild->isConnected()) | 431 if (!refChild->isConnected()) |
426 return; | 432 return; |
427 insertNodeBefore(insertChild, refChild, editingState); | 433 insertNodeBefore(insertChild, refChild, editingState); |
428 } else { | 434 } else { |
429 insertNodeAfter(insertChild, refChild, editingState); | 435 insertNodeAfter(insertChild, refChild, editingState); |
430 } | 436 } |
431 } | 437 } |
432 | 438 |
| 439 bool CompositeEditCommand::willApply() { |
| 440 return document().frame()->editor().willApplyEditing(this); |
| 441 } |
| 442 |
433 void CompositeEditCommand::appendNode(Node* node, | 443 void CompositeEditCommand::appendNode(Node* node, |
434 ContainerNode* parent, | 444 ContainerNode* parent, |
435 EditingState* editingState) { | 445 EditingState* editingState) { |
436 // When cloneParagraphUnderNewElement() clones the fallback content | 446 // When cloneParagraphUnderNewElement() clones the fallback content |
437 // of an OBJECT element, the ASSERT below may fire since the return | 447 // of an OBJECT element, the ASSERT below may fire since the return |
438 // value of canHaveChildrenForEditing is not reliable until the layout | 448 // value of canHaveChildrenForEditing is not reliable until the layout |
439 // object of the OBJECT is created. Hence we ignore this check for OBJECTs. | 449 // object of the OBJECT is created. Hence we ignore this check for OBJECTs. |
440 // TODO(yosin): We should move following |ABORT_EDITING_COMMAND_IF|s to | 450 // TODO(yosin): We should move following |ABORT_EDITING_COMMAND_IF|s to |
441 // |AppendNodeCommand|. | 451 // |AppendNodeCommand|. |
442 // TODO(yosin): We should get rid of |canHaveChildrenForEditing()|, since | 452 // TODO(yosin): We should get rid of |canHaveChildrenForEditing()|, since |
(...skipping 1586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2029 return node; | 2039 return node; |
2030 } | 2040 } |
2031 | 2041 |
2032 DEFINE_TRACE(CompositeEditCommand) { | 2042 DEFINE_TRACE(CompositeEditCommand) { |
2033 visitor->trace(m_commands); | 2043 visitor->trace(m_commands); |
2034 visitor->trace(m_composition); | 2044 visitor->trace(m_composition); |
2035 EditCommand::trace(visitor); | 2045 EditCommand::trace(visitor); |
2036 } | 2046 } |
2037 | 2047 |
2038 } // namespace blink | 2048 } // namespace blink |
OLD | NEW |