| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 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 30 matching lines...) Expand all Loading... |
| 41 class HTMLElement; | 41 class HTMLElement; |
| 42 class HTMLSpanElement; | 42 class HTMLSpanElement; |
| 43 class Text; | 43 class Text; |
| 44 | 44 |
| 45 enum class EditCommandSource { kMenuOrKeyBinding, kDOM }; | 45 enum class EditCommandSource { kMenuOrKeyBinding, kDOM }; |
| 46 | 46 |
| 47 class EditCommandComposition final : public UndoStep { | 47 class EditCommandComposition final : public UndoStep { |
| 48 public: | 48 public: |
| 49 static EditCommandComposition* create(Document*, | 49 static EditCommandComposition* create(Document*, |
| 50 const VisibleSelection&, | 50 const VisibleSelection&, |
| 51 const VisibleSelection&, | 51 const VisibleSelection&); |
| 52 InputEvent::InputType); | |
| 53 | 52 |
| 54 bool belongsTo(const LocalFrame&) const override; | 53 bool belongsTo(const LocalFrame&) const override; |
| 55 void unapply(EditCommandSource) override; | 54 void unapply(EditCommandSource) override; |
| 56 void reapply(EditCommandSource) override; | 55 void reapply(EditCommandSource) override; |
| 57 InputEvent::InputType inputType() const override; | |
| 58 void append(SimpleEditCommand*); | 56 void append(SimpleEditCommand*); |
| 59 void append(EditCommandComposition*); | 57 void append(EditCommandComposition*); |
| 60 | 58 |
| 61 const VisibleSelection& startingSelection() const { | 59 const VisibleSelection& startingSelection() const { |
| 62 return m_startingSelection; | 60 return m_startingSelection; |
| 63 } | 61 } |
| 64 const VisibleSelection& endingSelection() const { return m_endingSelection; } | 62 const VisibleSelection& endingSelection() const { return m_endingSelection; } |
| 65 void setStartingSelection(const VisibleSelection&); | 63 void setStartingSelection(const VisibleSelection&); |
| 66 void setEndingSelection(const VisibleSelection&); | 64 void setEndingSelection(const VisibleSelection&); |
| 67 Element* startingRootEditableElement() const { | 65 Element* startingRootEditableElement() const { |
| 68 return m_startingRootEditableElement.get(); | 66 return m_startingRootEditableElement.get(); |
| 69 } | 67 } |
| 70 Element* endingRootEditableElement() const { | 68 Element* endingRootEditableElement() const { |
| 71 return m_endingRootEditableElement.get(); | 69 return m_endingRootEditableElement.get(); |
| 72 } | 70 } |
| 73 | 71 |
| 74 DECLARE_VIRTUAL_TRACE(); | 72 DECLARE_VIRTUAL_TRACE(); |
| 75 | 73 |
| 76 private: | 74 private: |
| 77 EditCommandComposition(Document*, | 75 EditCommandComposition(Document*, |
| 78 const VisibleSelection& startingSelection, | 76 const VisibleSelection& startingSelection, |
| 79 const VisibleSelection& endingSelection, | 77 const VisibleSelection& endingSelection); |
| 80 InputEvent::InputType); | |
| 81 | 78 |
| 82 // TODO(chongz): Implement "beforeinput" as described below: | 79 // TODO(chongz): Implement "beforeinput" as described below: |
| 83 // Fires "beforeinput" and will returns |false| to cancel unapply / reapply if | 80 // Fires "beforeinput" and will returns |false| to cancel unapply / reapply if |
| 84 // * "beforeinput" was canceled, or | 81 // * "beforeinput" was canceled, or |
| 85 // * |frame| was destroyed by event handlers. | 82 // * |frame| was destroyed by event handlers. |
| 86 // Note: Undo stack will always get popped. | 83 // Note: Undo stack will always get popped. |
| 87 bool willUnapply(EditCommandSource); | 84 bool willUnapply(EditCommandSource); |
| 88 bool willReapply(EditCommandSource); | 85 bool willReapply(EditCommandSource); |
| 89 | 86 |
| 90 Member<Document> m_document; | 87 Member<Document> m_document; |
| 91 VisibleSelection m_startingSelection; | 88 VisibleSelection m_startingSelection; |
| 92 VisibleSelection m_endingSelection; | 89 VisibleSelection m_endingSelection; |
| 93 HeapVector<Member<SimpleEditCommand>> m_commands; | 90 HeapVector<Member<SimpleEditCommand>> m_commands; |
| 94 Member<Element> m_startingRootEditableElement; | 91 Member<Element> m_startingRootEditableElement; |
| 95 Member<Element> m_endingRootEditableElement; | 92 Member<Element> m_endingRootEditableElement; |
| 96 InputEvent::InputType m_inputType; | |
| 97 }; | 93 }; |
| 98 | 94 |
| 99 class CORE_EXPORT CompositeEditCommand : public EditCommand { | 95 class CORE_EXPORT CompositeEditCommand : public EditCommand { |
| 100 public: | 96 public: |
| 101 enum ShouldPreserveSelection { PreserveSelection, DoNotPreserveSelection }; | 97 enum ShouldPreserveSelection { PreserveSelection, DoNotPreserveSelection }; |
| 102 enum ShouldPreserveStyle { PreserveStyle, DoNotPreserveStyle }; | 98 enum ShouldPreserveStyle { PreserveStyle, DoNotPreserveStyle }; |
| 103 | 99 |
| 104 ~CompositeEditCommand() override; | 100 ~CompositeEditCommand() override; |
| 105 | 101 |
| 106 // Returns |false| if the command failed. e.g. It's aborted. | 102 // Returns |false| if the command failed. e.g. It's aborted. |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 | 285 |
| 290 DEFINE_TYPE_CASTS(CompositeEditCommand, | 286 DEFINE_TYPE_CASTS(CompositeEditCommand, |
| 291 EditCommand, | 287 EditCommand, |
| 292 command, | 288 command, |
| 293 command->isCompositeEditCommand(), | 289 command->isCompositeEditCommand(), |
| 294 command.isCompositeEditCommand()); | 290 command.isCompositeEditCommand()); |
| 295 | 291 |
| 296 } // namespace blink | 292 } // namespace blink |
| 297 | 293 |
| 298 #endif // CompositeEditCommand_h | 294 #endif // CompositeEditCommand_h |
| OLD | NEW |