Chromium Code Reviews| 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 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 21 matching lines...) Expand all Loading... | |
| 184 } | 189 } |
| 185 | 190 |
| 186 bool CompositeEditCommand::apply() | 191 bool CompositeEditCommand::apply() |
| 187 { | 192 { |
| 188 if (!endingSelection().isContentRichlyEditable()) { | 193 if (!endingSelection().isContentRichlyEditable()) { |
| 189 switch (inputType()) { | 194 switch (inputType()) { |
| 190 case InputEvent::InputType::InsertText: | 195 case InputEvent::InputType::InsertText: |
| 191 case InputEvent::InputType::InsertLineBreak: | 196 case InputEvent::InputType::InsertLineBreak: |
| 192 case InputEvent::InputType::InsertParagraph: | 197 case InputEvent::InputType::InsertParagraph: |
| 193 case InputEvent::InputType::InsertFromPaste: | 198 case InputEvent::InputType::InsertFromPaste: |
| 199 case InputEvent::InputType::InsertFromDrop: | |
| 194 case InputEvent::InputType::DeleteComposedCharacterForward: | 200 case InputEvent::InputType::DeleteComposedCharacterForward: |
| 195 case InputEvent::InputType::DeleteComposedCharacterBackward: | 201 case InputEvent::InputType::DeleteComposedCharacterBackward: |
| 196 case InputEvent::InputType::DeleteWordBackward: | 202 case InputEvent::InputType::DeleteWordBackward: |
| 197 case InputEvent::InputType::DeleteWordForward: | 203 case InputEvent::InputType::DeleteWordForward: |
| 198 case InputEvent::InputType::DeleteLineBackward: | 204 case InputEvent::InputType::DeleteLineBackward: |
| 199 case InputEvent::InputType::DeleteLineForward: | 205 case InputEvent::InputType::DeleteLineForward: |
| 200 case InputEvent::InputType::DeleteContentBackward: | 206 case InputEvent::InputType::DeleteContentBackward: |
| 201 case InputEvent::InputType::DeleteContentForward: | 207 case InputEvent::InputType::DeleteContentForward: |
| 202 case InputEvent::InputType::DeleteByCut: | 208 case InputEvent::InputType::DeleteByCut: |
| 203 case InputEvent::InputType::Drag: | 209 case InputEvent::InputType::DeleteByDrag: |
| 204 case InputEvent::InputType::SetWritingDirection: | 210 case InputEvent::InputType::SetWritingDirection: |
| 205 case InputEvent::InputType::None: | 211 case InputEvent::InputType::None: |
| 206 break; | 212 break; |
| 207 default: | 213 default: |
| 208 NOTREACHED(); | 214 NOTREACHED(); |
| 209 return false; | 215 return false; |
| 210 } | 216 } |
| 211 } | 217 } |
| 212 ensureComposition(); | 218 ensureComposition(); |
| 213 | 219 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 284 command->setParent(this); | 290 command->setParent(this); |
| 285 if (selection != command->endingSelection()) { | 291 if (selection != command->endingSelection()) { |
| 286 command->setStartingSelection(selection); | 292 command->setStartingSelection(selection); |
| 287 command->setEndingSelection(selection); | 293 command->setEndingSelection(selection); |
| 288 } | 294 } |
| 289 command->doApply(editingState); | 295 command->doApply(editingState); |
| 290 if (!editingState->isAborted()) | 296 if (!editingState->isAborted()) |
| 291 m_commands.append(command); | 297 m_commands.append(command); |
| 292 } | 298 } |
| 293 | 299 |
| 300 void CompositeEditCommand::appendCommandToComposite(CompositeEditCommand* comman d) | |
|
yosin_UTC9
2016/09/28 04:19:03
Good invention!
We can implement Undo/Redo for dra
chongz
2016/09/29 02:36:22
Thanks! :>
| |
| 301 { | |
| 302 ensureComposition()->append(command->ensureComposition()); | |
| 303 command->setParent(this); | |
| 304 m_commands.append(command); | |
| 305 } | |
| 306 | |
| 294 void CompositeEditCommand::applyStyle(const EditingStyle* style, EditingState* e ditingState) | 307 void CompositeEditCommand::applyStyle(const EditingStyle* style, EditingState* e ditingState) |
| 295 { | 308 { |
| 296 applyCommandToComposite(ApplyStyleCommand::create(document(), style, InputEv ent::InputType::ChangeAttributes), editingState); | 309 applyCommandToComposite(ApplyStyleCommand::create(document(), style, InputEv ent::InputType::ChangeAttributes), editingState); |
| 297 } | 310 } |
| 298 | 311 |
| 299 void CompositeEditCommand::applyStyle(const EditingStyle* style, const Position& start, const Position& end, EditingState* editingState) | 312 void CompositeEditCommand::applyStyle(const EditingStyle* style, const Position& start, const Position& end, EditingState* editingState) |
| 300 { | 313 { |
| 301 applyCommandToComposite(ApplyStyleCommand::create(document(), style, start, end), editingState); | 314 applyCommandToComposite(ApplyStyleCommand::create(document(), style, start, end), editingState); |
| 302 } | 315 } |
| 303 | 316 |
| (...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1657 } | 1670 } |
| 1658 | 1671 |
| 1659 DEFINE_TRACE(CompositeEditCommand) | 1672 DEFINE_TRACE(CompositeEditCommand) |
| 1660 { | 1673 { |
| 1661 visitor->trace(m_commands); | 1674 visitor->trace(m_commands); |
| 1662 visitor->trace(m_composition); | 1675 visitor->trace(m_composition); |
| 1663 EditCommand::trace(visitor); | 1676 EditCommand::trace(visitor); |
| 1664 } | 1677 } |
| 1665 | 1678 |
| 1666 } // namespace blink | 1679 } // namespace blink |
| OLD | NEW |