Chromium Code Reviews| 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 26 matching lines...) Expand all Loading... | |
| 37 #include "core/editing/iterators/TextIterator.h" | 37 #include "core/editing/iterators/TextIterator.h" |
| 38 #include "core/editing/markers/DocumentMarker.h" | 38 #include "core/editing/markers/DocumentMarker.h" |
| 39 #include "core/events/InputEvent.h" | 39 #include "core/events/InputEvent.h" |
| 40 #include "platform/PasteMode.h" | 40 #include "platform/PasteMode.h" |
| 41 #include "platform/heap/Handle.h" | 41 #include "platform/heap/Handle.h" |
| 42 #include <memory> | 42 #include <memory> |
| 43 | 43 |
| 44 namespace blink { | 44 namespace blink { |
| 45 | 45 |
| 46 class CompositeEditCommand; | 46 class CompositeEditCommand; |
| 47 class DragData; | |
| 47 class DummyPageHolder; | 48 class DummyPageHolder; |
| 48 class EditCommandComposition; | 49 class EditCommandComposition; |
| 49 class EditorClient; | 50 class EditorClient; |
| 50 class EditorInternalCommand; | 51 class EditorInternalCommand; |
| 51 class LocalFrame; | 52 class LocalFrame; |
| 52 class HitTestResult; | 53 class HitTestResult; |
| 53 class KillRing; | 54 class KillRing; |
| 54 class Pasteboard; | 55 class Pasteboard; |
| 55 class SpellChecker; | 56 class SpellChecker; |
| 56 class StylePropertySet; | 57 class StylePropertySet; |
| 57 class TextEvent; | 58 class TextEvent; |
| 58 class UndoStack; | 59 class UndoStack; |
| 59 | 60 |
| 60 enum class DeleteDirection; | 61 enum class DeleteDirection; |
| 62 enum class SmartDelete { Yes, No }; | |
|
yosin_UTC9
2016/10/03 09:19:03
How about enum class DeleteMode { Simple, Smart }?
chongz
2016/10/04 02:18:39
Done.
| |
| 63 enum class SmartInsert { Yes, No }; | |
|
yosin_UTC9
2016/10/03 09:19:03
How about enum class InsertMode { Simple, Smart }?
chongz
2016/10/04 02:18:39
Done.
| |
| 64 enum class ChosePlainText { Yes, No }; | |
|
yosin_UTC9
2016/10/03 09:19:03
How about DragSourceType { HTMLSource, PlainTextSo
chongz
2016/10/04 02:18:39
Done.
| |
| 61 | 65 |
| 62 enum EditorCommandSource { CommandFromMenuOrKeyBinding, CommandFromDOM }; | 66 enum EditorCommandSource { CommandFromMenuOrKeyBinding, CommandFromDOM }; |
| 63 enum EditorParagraphSeparator { EditorParagraphSeparatorIsDiv, EditorParagraphSe paratorIsP }; | 67 enum EditorParagraphSeparator { EditorParagraphSeparatorIsDiv, EditorParagraphSe paratorIsP }; |
| 64 | 68 |
| 65 class CORE_EXPORT Editor final : public GarbageCollectedFinalized<Editor> { | 69 class CORE_EXPORT Editor final : public GarbageCollectedFinalized<Editor> { |
| 66 WTF_MAKE_NONCOPYABLE(Editor); | 70 WTF_MAKE_NONCOPYABLE(Editor); |
| 67 public: | 71 public: |
| 68 static Editor* create(LocalFrame&); | 72 static Editor* create(LocalFrame&); |
| 69 ~Editor(); | 73 ~Editor(); |
| 70 | 74 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 99 void transpose(); | 103 void transpose(); |
| 100 | 104 |
| 101 void respondToChangedContents(const VisibleSelection& endingSelection); | 105 void respondToChangedContents(const VisibleSelection& endingSelection); |
| 102 | 106 |
| 103 bool selectionStartHasStyle(CSSPropertyID, const String& value) const; | 107 bool selectionStartHasStyle(CSSPropertyID, const String& value) const; |
| 104 TriState selectionHasStyle(CSSPropertyID, const String& value) const; | 108 TriState selectionHasStyle(CSSPropertyID, const String& value) const; |
| 105 String selectionStartCSSPropertyValue(CSSPropertyID); | 109 String selectionStartCSSPropertyValue(CSSPropertyID); |
| 106 | 110 |
| 107 void removeFormattingAndStyle(); | 111 void removeFormattingAndStyle(); |
| 108 | 112 |
| 113 void registerCommandGroup(CompositeEditCommand* commandGroupWrapper); | |
| 109 void clearLastEditCommand(); | 114 void clearLastEditCommand(); |
| 110 | 115 |
| 111 bool deleteWithDirection(DeleteDirection, TextGranularity, bool killRing, bo ol isTypingAction); | 116 bool deleteWithDirection(DeleteDirection, TextGranularity, bool killRing, bo ol isTypingAction); |
| 112 void deleteSelectionWithSmartDelete(bool smartDelete, InputEvent::InputType) ; | 117 void deleteSelectionWithSmartDelete(bool smartDelete, InputEvent::InputType, const Position& referenceMovePosition = Position()); |
|
yosin_UTC9
2016/10/03 09:19:03
Is it better to use |SmartDelete| enum class inste
chongz
2016/10/04 02:18:39
Done.
| |
| 113 | 118 |
| 114 void applyStyle(StylePropertySet*, InputEvent::InputType); | 119 void applyStyle(StylePropertySet*, InputEvent::InputType); |
| 115 void applyParagraphStyle(StylePropertySet*, InputEvent::InputType); | 120 void applyParagraphStyle(StylePropertySet*, InputEvent::InputType); |
| 116 void applyStyleToSelection(StylePropertySet*, InputEvent::InputType); | 121 void applyStyleToSelection(StylePropertySet*, InputEvent::InputType); |
| 117 void applyParagraphStyleToSelection(StylePropertySet*, InputEvent::InputType ); | 122 void applyParagraphStyleToSelection(StylePropertySet*, InputEvent::InputType ); |
| 118 | 123 |
| 119 void appliedEditing(CompositeEditCommand*); | 124 void appliedEditing(CompositeEditCommand*); |
| 120 void unappliedEditing(EditCommandComposition*); | 125 void unappliedEditing(EditCommandComposition*); |
| 121 void reappliedEditing(EditCommandComposition*); | 126 void reappliedEditing(EditCommandComposition*); |
| 122 | 127 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 EditingBehavior behavior() const; | 203 EditingBehavior behavior() const; |
| 199 | 204 |
| 200 EphemeralRange selectedRange(); | 205 EphemeralRange selectedRange(); |
| 201 | 206 |
| 202 void addToKillRing(const EphemeralRange&); | 207 void addToKillRing(const EphemeralRange&); |
| 203 | 208 |
| 204 void pasteAsFragment(DocumentFragment*, bool smartReplace, bool matchStyle); | 209 void pasteAsFragment(DocumentFragment*, bool smartReplace, bool matchStyle); |
| 205 void pasteAsPlainText(const String&, bool smartReplace); | 210 void pasteAsPlainText(const String&, bool smartReplace); |
| 206 | 211 |
| 207 Element* findEventTargetFrom(const VisibleSelection&) const; | 212 Element* findEventTargetFrom(const VisibleSelection&) const; |
| 213 Element* findEventTargetFromSelection() const; | |
| 208 | 214 |
| 209 bool findString(const String&, FindOptions); | 215 bool findString(const String&, FindOptions); |
| 210 | 216 |
| 211 Range* findStringAndScrollToVisible(const String&, Range*, FindOptions); | 217 Range* findStringAndScrollToVisible(const String&, Range*, FindOptions); |
| 212 Range* findRangeOfString(const String& target, const EphemeralRange& referen ceRange, FindOptions); | 218 Range* findRangeOfString(const String& target, const EphemeralRange& referen ceRange, FindOptions); |
| 213 Range* findRangeOfString(const String& target, const EphemeralRangeInFlatTre e& referenceRange, FindOptions); | 219 Range* findRangeOfString(const String& target, const EphemeralRangeInFlatTre e& referenceRange, FindOptions); |
| 214 | 220 |
| 215 const VisibleSelection& mark() const; // Mark, to be used as emacs uses it. | 221 const VisibleSelection& mark() const; // Mark, to be used as emacs uses it. |
| 216 void setMark(const VisibleSelection&); | 222 void setMark(const VisibleSelection&); |
| 217 | 223 |
| 218 void computeAndSetTypingStyle(StylePropertySet*, InputEvent::InputType); | 224 void computeAndSetTypingStyle(StylePropertySet*, InputEvent::InputType); |
| 219 | 225 |
| 220 // |firstRectForRange| requires up-to-date layout. | 226 // |firstRectForRange| requires up-to-date layout. |
| 221 IntRect firstRectForRange(const EphemeralRange&) const; | 227 IntRect firstRectForRange(const EphemeralRange&) const; |
| 222 | 228 |
| 223 void respondToChangedSelection(const VisibleSelection& oldSelection, FrameSe lection::SetSelectionOptions); | 229 void respondToChangedSelection(const VisibleSelection& oldSelection, FrameSe lection::SetSelectionOptions); |
| 224 | 230 |
| 225 bool markedTextMatchesAreHighlighted() const; | 231 bool markedTextMatchesAreHighlighted() const; |
| 226 void setMarkedTextMatchesAreHighlighted(bool); | 232 void setMarkedTextMatchesAreHighlighted(bool); |
| 227 | 233 |
| 228 void replaceSelectionWithFragment(DocumentFragment*, bool selectReplacement, bool smartReplace, bool matchStyle); | 234 void replaceSelectionWithFragment(DocumentFragment*, bool selectReplacement, bool smartReplace, bool matchStyle); |
| 229 void replaceSelectionWithText(const String&, bool selectReplacement, bool sm artReplace); | 235 void replaceSelectionWithText(const String&, bool selectReplacement, bool sm artReplace); |
| 230 | 236 |
| 231 // TODO(xiaochengh): Replace |bool| parameters by |enum|. | 237 // TODO(xiaochengh): Replace |bool| parameters by |enum|. |
| 232 void replaceSelectionAfterDragging(DocumentFragment*, bool smartReplace, boo l plainText); | 238 void replaceSelectionAfterDragging(DocumentFragment*, bool smartReplace, boo l plainText); |
| 233 void moveSelectionAfterDragging(DocumentFragment*, const Position&, bool sma rtInsert, bool smartDelete); | 239 |
| 240 // Return false if frame was destroyed by event handler, should stop executi ng remaining actions. | |
| 241 bool deleteSelectionAfterDraggingWithEvents(Element* dragSource, SmartDelete , const Position& referenceMovePosition); | |
| 242 bool replaceSelectionAfterDraggingWithEvents(Element* dropTarget, DragData*, DocumentFragment*, Range* dropCaretRange, SmartInsert, ChosePlainText); | |
| 234 | 243 |
| 235 EditorParagraphSeparator defaultParagraphSeparator() const { return m_defaul tParagraphSeparator; } | 244 EditorParagraphSeparator defaultParagraphSeparator() const { return m_defaul tParagraphSeparator; } |
| 236 void setDefaultParagraphSeparator(EditorParagraphSeparator separator) { m_de faultParagraphSeparator = separator; } | 245 void setDefaultParagraphSeparator(EditorParagraphSeparator separator) { m_de faultParagraphSeparator = separator; } |
| 237 | 246 |
| 238 static void tidyUpHTMLStructure(Document&); | 247 static void tidyUpHTMLStructure(Document&); |
| 239 | 248 |
| 240 class RevealSelectionScope { | 249 class RevealSelectionScope { |
| 241 WTF_MAKE_NONCOPYABLE(RevealSelectionScope); | 250 WTF_MAKE_NONCOPYABLE(RevealSelectionScope); |
| 242 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 251 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 243 public: | 252 public: |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 bool canSmartReplaceWithPasteboard(Pasteboard*); | 291 bool canSmartReplaceWithPasteboard(Pasteboard*); |
| 283 void pasteAsPlainTextWithPasteboard(Pasteboard*); | 292 void pasteAsPlainTextWithPasteboard(Pasteboard*); |
| 284 void pasteWithPasteboard(Pasteboard*); | 293 void pasteWithPasteboard(Pasteboard*); |
| 285 void writeSelectionToPasteboard(); | 294 void writeSelectionToPasteboard(); |
| 286 bool dispatchCPPEvent(const AtomicString&, DataTransferAccessPolicy, PasteMo de = AllMimeTypes); | 295 bool dispatchCPPEvent(const AtomicString&, DataTransferAccessPolicy, PasteMo de = AllMimeTypes); |
| 287 | 296 |
| 288 void revealSelectionAfterEditingOperation(const ScrollAlignment& = ScrollAli gnment::alignCenterIfNeeded, RevealExtentOption = DoNotRevealExtent); | 297 void revealSelectionAfterEditingOperation(const ScrollAlignment& = ScrollAli gnment::alignCenterIfNeeded, RevealExtentOption = DoNotRevealExtent); |
| 289 void changeSelectionAfterCommand(const VisibleSelection& newSelection, Frame Selection::SetSelectionOptions); | 298 void changeSelectionAfterCommand(const VisibleSelection& newSelection, Frame Selection::SetSelectionOptions); |
| 290 void notifyComponentsOnChangedSelection(); | 299 void notifyComponentsOnChangedSelection(); |
| 291 | 300 |
| 292 Element* findEventTargetFromSelection() const; | |
| 293 | |
| 294 SpellChecker& spellChecker() const; | 301 SpellChecker& spellChecker() const; |
| 295 | 302 |
| 296 bool handleEditingKeyboardEvent(KeyboardEvent*); | 303 bool handleEditingKeyboardEvent(KeyboardEvent*); |
| 297 }; | 304 }; |
| 298 | 305 |
| 299 inline void Editor::setStartNewKillRingSequence(bool flag) | 306 inline void Editor::setStartNewKillRingSequence(bool flag) |
| 300 { | 307 { |
| 301 m_shouldStartNewKillRingSequence = flag; | 308 m_shouldStartNewKillRingSequence = flag; |
| 302 } | 309 } |
| 303 | 310 |
| 304 inline const VisibleSelection& Editor::mark() const | 311 inline const VisibleSelection& Editor::mark() const |
| 305 { | 312 { |
| 306 return m_mark; | 313 return m_mark; |
| 307 } | 314 } |
| 308 | 315 |
| 309 inline void Editor::setMark(const VisibleSelection& selection) | 316 inline void Editor::setMark(const VisibleSelection& selection) |
| 310 { | 317 { |
| 311 m_mark = selection; | 318 m_mark = selection; |
| 312 } | 319 } |
| 313 | 320 |
| 314 inline bool Editor::markedTextMatchesAreHighlighted() const | 321 inline bool Editor::markedTextMatchesAreHighlighted() const |
| 315 { | 322 { |
| 316 return m_areMarkedTextMatchesHighlighted; | 323 return m_areMarkedTextMatchesHighlighted; |
| 317 } | 324 } |
| 318 | 325 |
| 319 | 326 |
| 320 } // namespace blink | 327 } // namespace blink |
| 321 | 328 |
| 322 #endif // Editor_h | 329 #endif // Editor_h |
| OLD | NEW |