OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 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 16 matching lines...) Expand all Loading... | |
27 #define Editor_h | 27 #define Editor_h |
28 | 28 |
29 #include "core/CoreExport.h" | 29 #include "core/CoreExport.h" |
30 #include "core/clipboard/DataTransferAccessPolicy.h" | 30 #include "core/clipboard/DataTransferAccessPolicy.h" |
31 #include "core/editing/EditingBehavior.h" | 31 #include "core/editing/EditingBehavior.h" |
32 #include "core/editing/EphemeralRange.h" | 32 #include "core/editing/EphemeralRange.h" |
33 #include "core/editing/FindOptions.h" | 33 #include "core/editing/FindOptions.h" |
34 #include "core/editing/FrameSelection.h" | 34 #include "core/editing/FrameSelection.h" |
35 #include "core/editing/VisibleSelection.h" | 35 #include "core/editing/VisibleSelection.h" |
36 #include "core/editing/WritingDirection.h" | 36 #include "core/editing/WritingDirection.h" |
37 #include "core/editing/commands/CompositeEditCommand.h" | |
37 #include "core/editing/iterators/TextIterator.h" | 38 #include "core/editing/iterators/TextIterator.h" |
38 #include "core/editing/markers/DocumentMarker.h" | 39 #include "core/editing/markers/DocumentMarker.h" |
39 #include "core/events/InputEvent.h" | 40 #include "core/events/InputEvent.h" |
40 #include "platform/PasteMode.h" | 41 #include "platform/PasteMode.h" |
41 #include "platform/heap/Handle.h" | 42 #include "platform/heap/Handle.h" |
42 #include <memory> | 43 #include <memory> |
43 | 44 |
44 namespace blink { | 45 namespace blink { |
45 | 46 |
46 class CompositeEditCommand; | 47 class CompositeEditCommand; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 bool canCut() const; | 92 bool canCut() const; |
92 bool canCopy() const; | 93 bool canCopy() const; |
93 bool canPaste() const; | 94 bool canPaste() const; |
94 bool canDelete() const; | 95 bool canDelete() const; |
95 bool canSmartCopyOrDelete() const; | 96 bool canSmartCopyOrDelete() const; |
96 | 97 |
97 void cut(CommandSource); | 98 void cut(CommandSource); |
98 void copy(); | 99 void copy(); |
99 void paste(CommandSource); | 100 void paste(CommandSource); |
100 void pasteAsPlainText(CommandSource); | 101 void pasteAsPlainText(CommandSource); |
101 void performDelete(); | 102 void performDelete(CommandSource); |
102 | 103 |
103 static void countEvent(ExecutionContext*, const Event*); | 104 static void countEvent(ExecutionContext*, const Event*); |
104 void copyImage(const HitTestResult&); | 105 void copyImage(const HitTestResult&); |
105 | 106 |
106 void transpose(); | 107 void transpose(CommandSource); |
107 | 108 |
108 void respondToChangedContents(const VisibleSelection& endingSelection); | 109 void respondToChangedContents(const VisibleSelection& endingSelection); |
109 | 110 |
110 bool selectionStartHasStyle(CSSPropertyID, const String& value) const; | 111 bool selectionStartHasStyle(CSSPropertyID, const String& value) const; |
111 TriState selectionHasStyle(CSSPropertyID, const String& value) const; | 112 TriState selectionHasStyle(CSSPropertyID, const String& value) const; |
112 String selectionStartCSSPropertyValue(CSSPropertyID); | 113 String selectionStartCSSPropertyValue(CSSPropertyID); |
113 | 114 |
114 void removeFormattingAndStyle(); | 115 void removeFormattingAndStyle(CommandSource); |
115 | 116 |
116 void registerCommandGroup(CompositeEditCommand* commandGroupWrapper); | 117 void registerCommandGroup(CompositeEditCommand* commandGroupWrapper); |
117 void clearLastEditCommand(); | 118 void clearLastEditCommand(); |
118 | 119 |
119 bool deleteWithDirection(DeleteDirection, | 120 bool deleteWithDirection(CommandSource, |
121 DeleteDirection, | |
120 TextGranularity, | 122 TextGranularity, |
121 bool killRing, | 123 bool killRing, |
122 bool isTypingAction); | 124 bool isTypingAction); |
123 void deleteSelectionWithSmartDelete( | 125 void deleteSelectionWithSmartDelete( |
126 CommandSource, | |
124 DeleteMode, | 127 DeleteMode, |
125 InputEvent::InputType, | 128 InputEvent::InputType, |
126 const Position& referenceMovePosition = Position()); | 129 const Position& referenceMovePosition = Position()); |
127 | 130 |
128 void applyStyle(StylePropertySet*, InputEvent::InputType); | 131 void applyStyle(CommandSource, StylePropertySet*, InputEvent::InputType); |
129 void applyParagraphStyle(StylePropertySet*, InputEvent::InputType); | 132 void applyParagraphStyle(CommandSource, |
130 void applyStyleToSelection(StylePropertySet*, InputEvent::InputType); | 133 StylePropertySet*, |
131 void applyParagraphStyleToSelection(StylePropertySet*, InputEvent::InputType); | 134 InputEvent::InputType); |
135 void applyStyleToSelection(CommandSource, | |
136 StylePropertySet*, | |
137 InputEvent::InputType); | |
138 void applyParagraphStyleToSelection(CommandSource, | |
139 StylePropertySet*, | |
140 InputEvent::InputType); | |
132 | 141 |
133 void appliedEditing(CompositeEditCommand*); | 142 void appliedEditing(CompositeEditCommand*); |
134 void unappliedEditing(EditCommandComposition*); | 143 void unappliedEditing(EditCommandComposition*); |
135 void reappliedEditing(EditCommandComposition*); | 144 void reappliedEditing(EditCommandComposition*); |
136 | 145 |
137 void setShouldStyleWithCSS(bool flag) { m_shouldStyleWithCSS = flag; } | 146 void setShouldStyleWithCSS(bool flag) { m_shouldStyleWithCSS = flag; } |
138 bool shouldStyleWithCSS() const { return m_shouldStyleWithCSS; } | 147 bool shouldStyleWithCSS() const { return m_shouldStyleWithCSS; } |
139 | 148 |
140 class CORE_EXPORT Command { | 149 class CORE_EXPORT Command { |
141 STACK_ALLOCATED(); | 150 STACK_ALLOCATED(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 Command createCommand(const String& commandName); | 186 Command createCommand(const String& commandName); |
178 // Command source is |CommandSource::Dom|. | 187 // Command source is |CommandSource::Dom|. |
179 Command createCommandFromDOM(const String& commandName); | 188 Command createCommandFromDOM(const String& commandName); |
180 | 189 |
181 // |Editor::executeCommand| is implementation of |WebFrame::executeCommand| | 190 // |Editor::executeCommand| is implementation of |WebFrame::executeCommand| |
182 // rather than |Document::execCommand|. | 191 // rather than |Document::execCommand|. |
183 bool executeCommand(const String&); | 192 bool executeCommand(const String&); |
184 bool executeCommand(const String& commandName, const String& value); | 193 bool executeCommand(const String& commandName, const String& value); |
185 | 194 |
186 bool insertText(const String&, KeyboardEvent* triggeringEvent); | 195 bool insertText(const String&, KeyboardEvent* triggeringEvent); |
187 bool insertTextWithoutSendingTextEvent(const String&, | 196 bool insertTextWithoutSendingTextEvent(CommandSource, |
197 const String&, | |
188 bool selectInsertedText, | 198 bool selectInsertedText, |
189 TextEvent* triggeringEvent); | 199 TextEvent* triggeringEvent); |
190 bool insertLineBreak(); | 200 bool insertLineBreak(); |
191 bool insertParagraphSeparator(); | 201 bool insertParagraphSeparator(); |
192 | 202 |
193 bool isOverwriteModeEnabled() const { return m_overwriteModeEnabled; } | 203 bool isOverwriteModeEnabled() const { return m_overwriteModeEnabled; } |
194 void toggleOverwriteModeEnabled(); | 204 void toggleOverwriteModeEnabled(); |
195 | 205 |
196 bool canUndo(); | 206 bool canUndo(); |
197 void undo(); | 207 void undo(CommandSource); |
198 bool canRedo(); | 208 bool canRedo(); |
199 void redo(); | 209 void redo(CommandSource); |
200 | 210 |
201 void setBaseWritingDirection(WritingDirection); | 211 void setBaseWritingDirection(WritingDirection); |
202 | 212 |
203 // smartInsertDeleteEnabled and selectTrailingWhitespaceEnabled are | 213 // smartInsertDeleteEnabled and selectTrailingWhitespaceEnabled are |
204 // mutually exclusive, meaning that enabling one will disable the other. | 214 // mutually exclusive, meaning that enabling one will disable the other. |
205 bool smartInsertDeleteEnabled() const; | 215 bool smartInsertDeleteEnabled() const; |
206 bool isSelectTrailingWhitespaceEnabled() const; | 216 bool isSelectTrailingWhitespaceEnabled() const; |
207 | 217 |
208 bool preventRevealSelection() const { return m_preventRevealSelection; } | 218 bool preventRevealSelection() const { return m_preventRevealSelection; } |
209 | 219 |
(...skipping 23 matching lines...) Expand all Loading... | |
233 Range* findRangeOfString(const String& target, | 243 Range* findRangeOfString(const String& target, |
234 const EphemeralRange& referenceRange, | 244 const EphemeralRange& referenceRange, |
235 FindOptions); | 245 FindOptions); |
236 Range* findRangeOfString(const String& target, | 246 Range* findRangeOfString(const String& target, |
237 const EphemeralRangeInFlatTree& referenceRange, | 247 const EphemeralRangeInFlatTree& referenceRange, |
238 FindOptions); | 248 FindOptions); |
239 | 249 |
240 const VisibleSelection& mark() const; // Mark, to be used as emacs uses it. | 250 const VisibleSelection& mark() const; // Mark, to be used as emacs uses it. |
241 void setMark(const VisibleSelection&); | 251 void setMark(const VisibleSelection&); |
242 | 252 |
243 void computeAndSetTypingStyle(StylePropertySet*, InputEvent::InputType); | 253 void computeAndSetTypingStyle(CommandSource, |
254 StylePropertySet*, | |
255 InputEvent::InputType); | |
244 | 256 |
245 // |firstRectForRange| requires up-to-date layout. | 257 // |firstRectForRange| requires up-to-date layout. |
246 IntRect firstRectForRange(const EphemeralRange&) const; | 258 IntRect firstRectForRange(const EphemeralRange&) const; |
247 | 259 |
248 void respondToChangedSelection(const Position& oldSelectionStart, | 260 void respondToChangedSelection(const Position& oldSelectionStart, |
249 FrameSelection::SetSelectionOptions); | 261 FrameSelection::SetSelectionOptions); |
250 | 262 |
251 bool markedTextMatchesAreHighlighted() const; | 263 bool markedTextMatchesAreHighlighted() const; |
252 void setMarkedTextMatchesAreHighlighted(bool); | 264 void setMarkedTextMatchesAreHighlighted(bool); |
253 | 265 |
254 void replaceSelectionWithFragment(DocumentFragment*, | 266 void replaceSelectionWithFragment(CommandSource, |
267 DocumentFragment*, | |
255 bool selectReplacement, | 268 bool selectReplacement, |
256 bool smartReplace, | 269 bool smartReplace, |
257 bool matchStyle, | 270 bool matchStyle, |
258 InputEvent::InputType); | 271 InputEvent::InputType); |
259 void replaceSelectionWithText(const String&, | 272 void replaceSelectionWithText( |
260 bool selectReplacement, | 273 const String&, |
261 bool smartReplace, | 274 bool selectReplacement, |
262 InputEvent::InputType); | 275 bool smartReplace, |
276 InputEvent::InputType, | |
277 CommandSource = CommandSource::MenuOrKeyBinding); | |
Xiaocheng
2016/12/15 03:27:50
I'm not a fan of this...
Since the troublemaker i
Xiaocheng
2016/12/15 05:38:21
Implementation of WebLocalFrameImpl::replaceSelect
chongz
2016/12/16 00:45:22
Rebased and removed default parameter.
| |
263 | 278 |
264 // TODO(xiaochengh): Replace |bool| parameters by |enum|. | 279 // TODO(xiaochengh): Replace |bool| parameters by |enum|. |
265 void replaceSelectionAfterDragging(DocumentFragment*, | 280 void replaceSelectionAfterDragging(DocumentFragment*, |
266 InsertMode, | 281 InsertMode, |
267 DragSourceType); | 282 DragSourceType); |
268 | 283 |
269 // Return false if frame was destroyed by event handler, should stop executing | 284 // Return false if frame was destroyed by event handler, should stop executing |
270 // remaining actions. | 285 // remaining actions. |
271 bool deleteSelectionAfterDraggingWithEvents( | 286 bool deleteSelectionAfterDraggingWithEvents( |
272 Element* dragSource, | 287 Element* dragSource, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
362 m_mark = selection; | 377 m_mark = selection; |
363 } | 378 } |
364 | 379 |
365 inline bool Editor::markedTextMatchesAreHighlighted() const { | 380 inline bool Editor::markedTextMatchesAreHighlighted() const { |
366 return m_areMarkedTextMatchesHighlighted; | 381 return m_areMarkedTextMatchesHighlighted; |
367 } | 382 } |
368 | 383 |
369 } // namespace blink | 384 } // namespace blink |
370 | 385 |
371 #endif // Editor_h | 386 #endif // Editor_h |
OLD | NEW |