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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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); | 52 InputEvent::InputType); |
53 | 53 |
54 bool belongsTo(const LocalFrame&) const override; | 54 bool belongsTo(const LocalFrame&) const override; |
55 void unapply(EditCommandSource) override; | 55 void unapply() override; |
56 void reapply(EditCommandSource) override; | 56 void reapply() override; |
57 InputEvent::InputType inputType() const override; | 57 InputEvent::InputType inputType() const override; |
58 void append(SimpleEditCommand*); | 58 void append(SimpleEditCommand*); |
59 void append(EditCommandComposition*); | 59 void append(EditCommandComposition*); |
60 | 60 |
61 const VisibleSelection& startingSelection() const { | 61 const VisibleSelection& startingSelection() const { |
62 return m_startingSelection; | 62 return m_startingSelection; |
63 } | 63 } |
64 const VisibleSelection& endingSelection() const { return m_endingSelection; } | 64 const VisibleSelection& endingSelection() const { return m_endingSelection; } |
65 void setStartingSelection(const VisibleSelection&); | 65 void setStartingSelection(const VisibleSelection&); |
66 void setEndingSelection(const VisibleSelection&); | 66 void setEndingSelection(const VisibleSelection&); |
67 Element* startingRootEditableElement() const { | 67 Element* startingRootEditableElement() const { |
68 return m_startingRootEditableElement.get(); | 68 return m_startingRootEditableElement.get(); |
69 } | 69 } |
70 Element* endingRootEditableElement() const { | 70 Element* endingRootEditableElement() const { |
71 return m_endingRootEditableElement.get(); | 71 return m_endingRootEditableElement.get(); |
72 } | 72 } |
73 | 73 |
74 DECLARE_VIRTUAL_TRACE(); | 74 DECLARE_VIRTUAL_TRACE(); |
75 | 75 |
76 private: | 76 private: |
77 EditCommandComposition(Document*, | 77 EditCommandComposition(Document*, |
78 const VisibleSelection& startingSelection, | 78 const VisibleSelection& startingSelection, |
79 const VisibleSelection& endingSelection, | 79 const VisibleSelection& endingSelection, |
80 InputEvent::InputType); | 80 InputEvent::InputType); |
81 | 81 |
82 // TODO(chongz): Implement "beforeinput" as described below: | |
83 // Fires "beforeinput" and will returns |false| to cancel unapply / reapply if | |
84 // * "beforeinput" was canceled, or | |
85 // * |frame| was destroyed by event handlers. | |
86 // Note: Undo stack will always get popped. | |
87 bool willUnapply(EditCommandSource); | |
88 bool willReapply(EditCommandSource); | |
89 | |
90 Member<Document> m_document; | 82 Member<Document> m_document; |
91 VisibleSelection m_startingSelection; | 83 VisibleSelection m_startingSelection; |
92 VisibleSelection m_endingSelection; | 84 VisibleSelection m_endingSelection; |
93 HeapVector<Member<SimpleEditCommand>> m_commands; | 85 HeapVector<Member<SimpleEditCommand>> m_commands; |
94 Member<Element> m_startingRootEditableElement; | 86 Member<Element> m_startingRootEditableElement; |
95 Member<Element> m_endingRootEditableElement; | 87 Member<Element> m_endingRootEditableElement; |
96 InputEvent::InputType m_inputType; | 88 InputEvent::InputType m_inputType; |
97 }; | 89 }; |
98 | 90 |
99 class CORE_EXPORT CompositeEditCommand : public EditCommand { | 91 class CORE_EXPORT CompositeEditCommand : public EditCommand { |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 | 281 |
290 DEFINE_TYPE_CASTS(CompositeEditCommand, | 282 DEFINE_TYPE_CASTS(CompositeEditCommand, |
291 EditCommand, | 283 EditCommand, |
292 command, | 284 command, |
293 command->isCompositeEditCommand(), | 285 command->isCompositeEditCommand(), |
294 command.isCompositeEditCommand()); | 286 command.isCompositeEditCommand()); |
295 | 287 |
296 } // namespace blink | 288 } // namespace blink |
297 | 289 |
298 #endif // CompositeEditCommand_h | 290 #endif // CompositeEditCommand_h |
OLD | NEW |