| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 #include "core/layout/line/InlineTextBox.h" | 75 #include "core/layout/line/InlineTextBox.h" |
| 76 #include <algorithm> | 76 #include <algorithm> |
| 77 | 77 |
| 78 namespace blink { | 78 namespace blink { |
| 79 | 79 |
| 80 using namespace HTMLNames; | 80 using namespace HTMLNames; |
| 81 | 81 |
| 82 EditCommandComposition* EditCommandComposition::create( | 82 EditCommandComposition* EditCommandComposition::create( |
| 83 Document* document, | 83 Document* document, |
| 84 const VisibleSelection& startingSelection, | 84 const VisibleSelection& startingSelection, |
| 85 const VisibleSelection& endingSelection) { | 85 const VisibleSelection& endingSelection, |
| 86 InputEvent::InputType inputType) { |
| 86 return new EditCommandComposition(document, startingSelection, | 87 return new EditCommandComposition(document, startingSelection, |
| 87 endingSelection); | 88 endingSelection, inputType); |
| 88 } | 89 } |
| 89 | 90 |
| 90 EditCommandComposition::EditCommandComposition( | 91 EditCommandComposition::EditCommandComposition( |
| 91 Document* document, | 92 Document* document, |
| 92 const VisibleSelection& startingSelection, | 93 const VisibleSelection& startingSelection, |
| 93 const VisibleSelection& endingSelection) | 94 const VisibleSelection& endingSelection, |
| 95 InputEvent::InputType inputType) |
| 94 : m_document(document), | 96 : m_document(document), |
| 95 m_startingSelection(startingSelection), | 97 m_startingSelection(startingSelection), |
| 96 m_endingSelection(endingSelection), | 98 m_endingSelection(endingSelection), |
| 97 m_startingRootEditableElement(startingSelection.rootEditableElement()), | 99 m_startingRootEditableElement(startingSelection.rootEditableElement()), |
| 98 m_endingRootEditableElement(endingSelection.rootEditableElement()) {} | 100 m_endingRootEditableElement(endingSelection.rootEditableElement()), |
| 101 m_inputType(inputType) {} |
| 99 | 102 |
| 100 bool EditCommandComposition::belongsTo(const LocalFrame& frame) const { | 103 bool EditCommandComposition::belongsTo(const LocalFrame& frame) const { |
| 101 DCHECK(m_document); | 104 DCHECK(m_document); |
| 102 return m_document->frame() == &frame; | 105 return m_document->frame() == &frame; |
| 103 } | 106 } |
| 104 | 107 |
| 105 void EditCommandComposition::unapply(EditCommandSource source) { | 108 void EditCommandComposition::unapply(EditCommandSource source) { |
| 106 DCHECK(m_document); | 109 DCHECK(m_document); |
| 107 LocalFrame* frame = m_document->frame(); | 110 LocalFrame* frame = m_document->frame(); |
| 108 DCHECK(frame); | 111 DCHECK(frame); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 bool EditCommandComposition::willUnapply(EditCommandSource) { | 155 bool EditCommandComposition::willUnapply(EditCommandSource) { |
| 153 // TODO(chongz): Fire 'beforeinput' for 'historyUndo'. | 156 // TODO(chongz): Fire 'beforeinput' for 'historyUndo'. |
| 154 return true; | 157 return true; |
| 155 } | 158 } |
| 156 | 159 |
| 157 bool EditCommandComposition::willReapply(EditCommandSource) { | 160 bool EditCommandComposition::willReapply(EditCommandSource) { |
| 158 // TODO(chongz): Fire 'beforeinput' for 'historyRedo'. | 161 // TODO(chongz): Fire 'beforeinput' for 'historyRedo'. |
| 159 return true; | 162 return true; |
| 160 } | 163 } |
| 161 | 164 |
| 165 InputEvent::InputType EditCommandComposition::inputType() const { |
| 166 return m_inputType; |
| 167 } |
| 168 |
| 162 void EditCommandComposition::append(SimpleEditCommand* command) { | 169 void EditCommandComposition::append(SimpleEditCommand* command) { |
| 163 m_commands.push_back(command); | 170 m_commands.push_back(command); |
| 164 } | 171 } |
| 165 | 172 |
| 166 void EditCommandComposition::append(EditCommandComposition* composition) { | 173 void EditCommandComposition::append(EditCommandComposition* composition) { |
| 167 m_commands.appendVector(composition->m_commands); | 174 m_commands.appendVector(composition->m_commands); |
| 168 } | 175 } |
| 169 | 176 |
| 170 void EditCommandComposition::setStartingSelection( | 177 void EditCommandComposition::setStartingSelection( |
| 171 const VisibleSelection& selection) { | 178 const VisibleSelection& selection) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 if (!isTypingCommand()) | 255 if (!isTypingCommand()) |
| 249 frame->editor().appliedEditing(this); | 256 frame->editor().appliedEditing(this); |
| 250 setShouldRetainAutocorrectionIndicator(false); | 257 setShouldRetainAutocorrectionIndicator(false); |
| 251 return !editingState.isAborted(); | 258 return !editingState.isAborted(); |
| 252 } | 259 } |
| 253 | 260 |
| 254 EditCommandComposition* CompositeEditCommand::ensureComposition() { | 261 EditCommandComposition* CompositeEditCommand::ensureComposition() { |
| 255 CompositeEditCommand* command = this; | 262 CompositeEditCommand* command = this; |
| 256 while (command && command->parent()) | 263 while (command && command->parent()) |
| 257 command = command->parent(); | 264 command = command->parent(); |
| 258 if (!command->m_composition) { | 265 if (!command->m_composition) |
| 259 command->m_composition = EditCommandComposition::create( | 266 command->m_composition = EditCommandComposition::create( |
| 260 &document(), startingSelection(), endingSelection()); | 267 &document(), startingSelection(), endingSelection(), inputType()); |
| 261 } | |
| 262 return command->m_composition.get(); | 268 return command->m_composition.get(); |
| 263 } | 269 } |
| 264 | 270 |
| 265 bool CompositeEditCommand::willApplyEditing(EditCommandSource) { | 271 bool CompositeEditCommand::willApplyEditing(EditCommandSource) { |
| 266 // TODO(chongz): Move all the 'beforeinput' dispatching logic here. | 272 // TODO(chongz): Move all the 'beforeinput' dispatching logic here. |
| 267 return true; | 273 return true; |
| 268 } | 274 } |
| 269 | 275 |
| 270 bool CompositeEditCommand::preservesTypingStyle() const { | 276 bool CompositeEditCommand::preservesTypingStyle() const { |
| 271 return false; | 277 return false; |
| (...skipping 1775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2047 return node; | 2053 return node; |
| 2048 } | 2054 } |
| 2049 | 2055 |
| 2050 DEFINE_TRACE(CompositeEditCommand) { | 2056 DEFINE_TRACE(CompositeEditCommand) { |
| 2051 visitor->trace(m_commands); | 2057 visitor->trace(m_commands); |
| 2052 visitor->trace(m_composition); | 2058 visitor->trace(m_composition); |
| 2053 EditCommand::trace(visitor); | 2059 EditCommand::trace(visitor); |
| 2054 } | 2060 } |
| 2055 | 2061 |
| 2056 } // namespace blink | 2062 } // namespace blink |
| OLD | NEW |