| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 } | 143 } |
| 144 | 144 |
| 145 InputEvent::InputType EditCommandComposition::inputType() const { | 145 InputEvent::InputType EditCommandComposition::inputType() const { |
| 146 return m_inputType; | 146 return m_inputType; |
| 147 } | 147 } |
| 148 | 148 |
| 149 void EditCommandComposition::append(SimpleEditCommand* command) { | 149 void EditCommandComposition::append(SimpleEditCommand* command) { |
| 150 m_commands.append(command); | 150 m_commands.append(command); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void EditCommandComposition::append(EditCommandComposition* composition) { |
| 154 m_commands.appendVector(composition->m_commands); |
| 155 } |
| 156 |
| 153 void EditCommandComposition::setStartingSelection( | 157 void EditCommandComposition::setStartingSelection( |
| 154 const VisibleSelection& selection) { | 158 const VisibleSelection& selection) { |
| 155 m_startingSelection = selection; | 159 m_startingSelection = selection; |
| 156 m_startingRootEditableElement = selection.rootEditableElement(); | 160 m_startingRootEditableElement = selection.rootEditableElement(); |
| 157 } | 161 } |
| 158 | 162 |
| 159 void EditCommandComposition::setEndingSelection( | 163 void EditCommandComposition::setEndingSelection( |
| 160 const VisibleSelection& selection) { | 164 const VisibleSelection& selection) { |
| 161 m_endingSelection = selection; | 165 m_endingSelection = selection; |
| 162 m_endingRootEditableElement = selection.rootEditableElement(); | 166 m_endingRootEditableElement = selection.rootEditableElement(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 173 } | 177 } |
| 174 | 178 |
| 175 CompositeEditCommand::CompositeEditCommand(Document& document) | 179 CompositeEditCommand::CompositeEditCommand(Document& document) |
| 176 : EditCommand(document) {} | 180 : EditCommand(document) {} |
| 177 | 181 |
| 178 CompositeEditCommand::~CompositeEditCommand() { | 182 CompositeEditCommand::~CompositeEditCommand() { |
| 179 DCHECK(isTopLevelCommand() || !m_composition); | 183 DCHECK(isTopLevelCommand() || !m_composition); |
| 180 } | 184 } |
| 181 | 185 |
| 182 bool CompositeEditCommand::apply() { | 186 bool CompositeEditCommand::apply() { |
| 187 DCHECK(!isCommandGroupWrapper()); |
| 183 if (!endingSelection().isContentRichlyEditable()) { | 188 if (!endingSelection().isContentRichlyEditable()) { |
| 184 switch (inputType()) { | 189 switch (inputType()) { |
| 185 case InputEvent::InputType::InsertText: | 190 case InputEvent::InputType::InsertText: |
| 186 case InputEvent::InputType::InsertLineBreak: | 191 case InputEvent::InputType::InsertLineBreak: |
| 187 case InputEvent::InputType::InsertParagraph: | 192 case InputEvent::InputType::InsertParagraph: |
| 188 case InputEvent::InputType::InsertFromPaste: | 193 case InputEvent::InputType::InsertFromPaste: |
| 194 case InputEvent::InputType::InsertFromDrop: |
| 189 case InputEvent::InputType::DeleteComposedCharacterForward: | 195 case InputEvent::InputType::DeleteComposedCharacterForward: |
| 190 case InputEvent::InputType::DeleteComposedCharacterBackward: | 196 case InputEvent::InputType::DeleteComposedCharacterBackward: |
| 191 case InputEvent::InputType::DeleteWordBackward: | 197 case InputEvent::InputType::DeleteWordBackward: |
| 192 case InputEvent::InputType::DeleteWordForward: | 198 case InputEvent::InputType::DeleteWordForward: |
| 193 case InputEvent::InputType::DeleteLineBackward: | 199 case InputEvent::InputType::DeleteLineBackward: |
| 194 case InputEvent::InputType::DeleteLineForward: | 200 case InputEvent::InputType::DeleteLineForward: |
| 195 case InputEvent::InputType::DeleteContentBackward: | 201 case InputEvent::InputType::DeleteContentBackward: |
| 196 case InputEvent::InputType::DeleteContentForward: | 202 case InputEvent::InputType::DeleteContentForward: |
| 197 case InputEvent::InputType::DeleteByCut: | 203 case InputEvent::InputType::DeleteByCut: |
| 198 case InputEvent::InputType::Drag: | 204 case InputEvent::InputType::DeleteByDrag: |
| 199 case InputEvent::InputType::SetWritingDirection: | 205 case InputEvent::InputType::SetWritingDirection: |
| 200 case InputEvent::InputType::None: | 206 case InputEvent::InputType::None: |
| 201 break; | 207 break; |
| 202 default: | 208 default: |
| 203 NOTREACHED(); | 209 NOTREACHED(); |
| 204 return false; | 210 return false; |
| 205 } | 211 } |
| 206 } | 212 } |
| 207 ensureComposition(); | 213 ensureComposition(); |
| 208 | 214 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 238 } | 244 } |
| 239 | 245 |
| 240 bool CompositeEditCommand::preservesTypingStyle() const { | 246 bool CompositeEditCommand::preservesTypingStyle() const { |
| 241 return false; | 247 return false; |
| 242 } | 248 } |
| 243 | 249 |
| 244 bool CompositeEditCommand::isTypingCommand() const { | 250 bool CompositeEditCommand::isTypingCommand() const { |
| 245 return false; | 251 return false; |
| 246 } | 252 } |
| 247 | 253 |
| 254 bool CompositeEditCommand::isCommandGroupWrapper() const { |
| 255 return false; |
| 256 } |
| 257 |
| 258 bool CompositeEditCommand::isDragAndDropCommand() const { |
| 259 return false; |
| 260 } |
| 261 |
| 248 bool CompositeEditCommand::isReplaceSelectionCommand() const { | 262 bool CompositeEditCommand::isReplaceSelectionCommand() const { |
| 249 return false; | 263 return false; |
| 250 } | 264 } |
| 251 | 265 |
| 252 void CompositeEditCommand::setShouldRetainAutocorrectionIndicator(bool) {} | 266 void CompositeEditCommand::setShouldRetainAutocorrectionIndicator(bool) {} |
| 253 | 267 |
| 254 // | 268 // |
| 255 // sugary-sweet convenience functions to help create and apply edit commands in
composite commands | 269 // sugary-sweet convenience functions to help create and apply edit commands in
composite commands |
| 256 // | 270 // |
| 257 void CompositeEditCommand::applyCommandToComposite(EditCommand* command, | 271 void CompositeEditCommand::applyCommandToComposite(EditCommand* command, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 276 command->setParent(this); | 290 command->setParent(this); |
| 277 if (selection != command->endingSelection()) { | 291 if (selection != command->endingSelection()) { |
| 278 command->setStartingSelection(selection); | 292 command->setStartingSelection(selection); |
| 279 command->setEndingSelection(selection); | 293 command->setEndingSelection(selection); |
| 280 } | 294 } |
| 281 command->doApply(editingState); | 295 command->doApply(editingState); |
| 282 if (!editingState->isAborted()) | 296 if (!editingState->isAborted()) |
| 283 m_commands.append(command); | 297 m_commands.append(command); |
| 284 } | 298 } |
| 285 | 299 |
| 300 void CompositeEditCommand::appendCommandToComposite( |
| 301 CompositeEditCommand* command) { |
| 302 ensureComposition()->append(command->ensureComposition()); |
| 303 command->setParent(this); |
| 304 m_commands.append(command); |
| 305 } |
| 306 |
| 286 void CompositeEditCommand::applyStyle(const EditingStyle* style, | 307 void CompositeEditCommand::applyStyle(const EditingStyle* style, |
| 287 EditingState* editingState) { | 308 EditingState* editingState) { |
| 288 applyCommandToComposite( | 309 applyCommandToComposite( |
| 289 ApplyStyleCommand::create(document(), style, | 310 ApplyStyleCommand::create(document(), style, |
| 290 InputEvent::InputType::ChangeAttributes), | 311 InputEvent::InputType::ChangeAttributes), |
| 291 editingState); | 312 editingState); |
| 292 } | 313 } |
| 293 | 314 |
| 294 void CompositeEditCommand::applyStyle(const EditingStyle* style, | 315 void CompositeEditCommand::applyStyle(const EditingStyle* style, |
| 295 const Position& start, | 316 const Position& start, |
| (...skipping 1624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1920 return node; | 1941 return node; |
| 1921 } | 1942 } |
| 1922 | 1943 |
| 1923 DEFINE_TRACE(CompositeEditCommand) { | 1944 DEFINE_TRACE(CompositeEditCommand) { |
| 1924 visitor->trace(m_commands); | 1945 visitor->trace(m_commands); |
| 1925 visitor->trace(m_composition); | 1946 visitor->trace(m_composition); |
| 1926 EditCommand::trace(visitor); | 1947 EditCommand::trace(visitor); |
| 1927 } | 1948 } |
| 1928 | 1949 |
| 1929 } // namespace blink | 1950 } // namespace blink |
| OLD | NEW |