Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: third_party/WebKit/Source/core/editing/Editor.h

Issue 2576903002: [EditCommandSource] Pass source from |Editor::Command| to |Editor::apply*()/insert*()/...| (2/3) (Closed)
Patch Set: Xiaocheng's review: Add TODOs and DCHECK comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/Editor.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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(EditCommandSource); 98 void cut(EditCommandSource);
98 void copy(); 99 void copy();
99 void paste(EditCommandSource); 100 void paste(EditCommandSource);
100 void pasteAsPlainText(EditCommandSource); 101 void pasteAsPlainText(EditCommandSource);
101 void performDelete(); 102 void performDelete(EditCommandSource);
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(EditCommandSource);
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(EditCommandSource);
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(EditCommandSource,
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 EditCommandSource,
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(EditCommandSource, StylePropertySet*, InputEvent::InputType);
129 void applyParagraphStyle(StylePropertySet*, InputEvent::InputType); 132 void applyParagraphStyle(EditCommandSource,
130 void applyStyleToSelection(StylePropertySet*, InputEvent::InputType); 133 StylePropertySet*,
131 void applyParagraphStyleToSelection(StylePropertySet*, InputEvent::InputType); 134 InputEvent::InputType);
135 void applyStyleToSelection(EditCommandSource,
136 StylePropertySet*,
137 InputEvent::InputType);
138 void applyParagraphStyleToSelection(EditCommandSource,
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
177 Command createCommand(const String& commandName); 186 Command createCommand(const String& commandName);
178 // Command source is |EditCommandSource::kDOM|. 187 // Command source is |EditCommandSource::kDOM|.
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(EditCommandSource,
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(EditCommandSource);
198 bool canRedo(); 208 bool canRedo();
199 void redo(); 209 void redo(EditCommandSource);
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
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(EditCommandSource,
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(EditCommandSource,
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(EditCommandSource,
273 const String&,
260 bool selectReplacement, 274 bool selectReplacement,
261 bool smartReplace, 275 bool smartReplace,
262 InputEvent::InputType); 276 InputEvent::InputType);
263 277
264 // Implementation of WebLocalFrameImpl::replaceSelection. 278 // Implementation of WebLocalFrameImpl::replaceSelection.
265 void replaceSelection(const String&); 279 void replaceSelection(const String&);
280 // Implementation of SpellChecker::replaceMisspelledRange.
281 void replaceSelectionForSpellChecker(const String&);
chongz 2016/12/16 00:45:22 Added |replaceSelectionForSpellChecker()| similar
Xiaocheng 2016/12/16 01:30:43 I like this change. Could you update patch descrip
chongz 2016/12/16 03:18:45 Done.
266 282
267 void replaceSelectionAfterDragging(DocumentFragment*, 283 void replaceSelectionAfterDragging(DocumentFragment*,
268 InsertMode, 284 InsertMode,
269 DragSourceType); 285 DragSourceType);
270 286
271 // Return false if frame was destroyed by event handler, should stop executing 287 // Return false if frame was destroyed by event handler, should stop executing
272 // remaining actions. 288 // remaining actions.
273 bool deleteSelectionAfterDraggingWithEvents( 289 bool deleteSelectionAfterDraggingWithEvents(
274 Element* dragSource, 290 Element* dragSource,
275 DeleteMode, 291 DeleteMode,
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 m_mark = selection; 380 m_mark = selection;
365 } 381 }
366 382
367 inline bool Editor::markedTextMatchesAreHighlighted() const { 383 inline bool Editor::markedTextMatchesAreHighlighted() const {
368 return m_areMarkedTextMatchesHighlighted; 384 return m_areMarkedTextMatchesHighlighted;
369 } 385 }
370 386
371 } // namespace blink 387 } // namespace blink
372 388
373 #endif // Editor_h 389 #endif // Editor_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/Editor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698