| 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 DeleteMode { Simple, Smart }; |
| 63 enum class InsertMode { Simple, Smart }; |
| 64 enum class DragSourceType { HTMLSource, PlainTextSource }; |
| 61 | 65 |
| 62 enum EditorCommandSource { CommandFromMenuOrKeyBinding, CommandFromDOM }; | 66 enum EditorCommandSource { CommandFromMenuOrKeyBinding, CommandFromDOM }; |
| 63 enum EditorParagraphSeparator { | 67 enum EditorParagraphSeparator { |
| 64 EditorParagraphSeparatorIsDiv, | 68 EditorParagraphSeparatorIsDiv, |
| 65 EditorParagraphSeparatorIsP | 69 EditorParagraphSeparatorIsP |
| 66 }; | 70 }; |
| 67 | 71 |
| 68 class CORE_EXPORT Editor final : public GarbageCollectedFinalized<Editor> { | 72 class CORE_EXPORT Editor final : public GarbageCollectedFinalized<Editor> { |
| 69 WTF_MAKE_NONCOPYABLE(Editor); | 73 WTF_MAKE_NONCOPYABLE(Editor); |
| 70 | 74 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 void transpose(); | 107 void transpose(); |
| 104 | 108 |
| 105 void respondToChangedContents(const VisibleSelection& endingSelection); | 109 void respondToChangedContents(const VisibleSelection& endingSelection); |
| 106 | 110 |
| 107 bool selectionStartHasStyle(CSSPropertyID, const String& value) const; | 111 bool selectionStartHasStyle(CSSPropertyID, const String& value) const; |
| 108 TriState selectionHasStyle(CSSPropertyID, const String& value) const; | 112 TriState selectionHasStyle(CSSPropertyID, const String& value) const; |
| 109 String selectionStartCSSPropertyValue(CSSPropertyID); | 113 String selectionStartCSSPropertyValue(CSSPropertyID); |
| 110 | 114 |
| 111 void removeFormattingAndStyle(); | 115 void removeFormattingAndStyle(); |
| 112 | 116 |
| 117 void registerCommandGroup(CompositeEditCommand* commandGroupWrapper); |
| 113 void clearLastEditCommand(); | 118 void clearLastEditCommand(); |
| 114 | 119 |
| 115 bool deleteWithDirection(DeleteDirection, | 120 bool deleteWithDirection(DeleteDirection, |
| 116 TextGranularity, | 121 TextGranularity, |
| 117 bool killRing, | 122 bool killRing, |
| 118 bool isTypingAction); | 123 bool isTypingAction); |
| 119 void deleteSelectionWithSmartDelete(bool smartDelete, InputEvent::InputType); | 124 void deleteSelectionWithSmartDelete( |
| 125 DeleteMode, |
| 126 InputEvent::InputType, |
| 127 const Position& referenceMovePosition = Position()); |
| 120 | 128 |
| 121 void applyStyle(StylePropertySet*, InputEvent::InputType); | 129 void applyStyle(StylePropertySet*, InputEvent::InputType); |
| 122 void applyParagraphStyle(StylePropertySet*, InputEvent::InputType); | 130 void applyParagraphStyle(StylePropertySet*, InputEvent::InputType); |
| 123 void applyStyleToSelection(StylePropertySet*, InputEvent::InputType); | 131 void applyStyleToSelection(StylePropertySet*, InputEvent::InputType); |
| 124 void applyParagraphStyleToSelection(StylePropertySet*, InputEvent::InputType); | 132 void applyParagraphStyleToSelection(StylePropertySet*, InputEvent::InputType); |
| 125 | 133 |
| 126 void appliedEditing(CompositeEditCommand*); | 134 void appliedEditing(CompositeEditCommand*); |
| 127 void unappliedEditing(EditCommandComposition*); | 135 void unappliedEditing(EditCommandComposition*); |
| 128 void reappliedEditing(EditCommandComposition*); | 136 void reappliedEditing(EditCommandComposition*); |
| 129 | 137 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 EditingBehavior behavior() const; | 219 EditingBehavior behavior() const; |
| 212 | 220 |
| 213 EphemeralRange selectedRange(); | 221 EphemeralRange selectedRange(); |
| 214 | 222 |
| 215 void addToKillRing(const EphemeralRange&); | 223 void addToKillRing(const EphemeralRange&); |
| 216 | 224 |
| 217 void pasteAsFragment(DocumentFragment*, bool smartReplace, bool matchStyle); | 225 void pasteAsFragment(DocumentFragment*, bool smartReplace, bool matchStyle); |
| 218 void pasteAsPlainText(const String&, bool smartReplace); | 226 void pasteAsPlainText(const String&, bool smartReplace); |
| 219 | 227 |
| 220 Element* findEventTargetFrom(const VisibleSelection&) const; | 228 Element* findEventTargetFrom(const VisibleSelection&) const; |
| 229 Element* findEventTargetFromSelection() const; |
| 221 | 230 |
| 222 bool findString(const String&, FindOptions); | 231 bool findString(const String&, FindOptions); |
| 223 | 232 |
| 224 Range* findStringAndScrollToVisible(const String&, Range*, FindOptions); | 233 Range* findStringAndScrollToVisible(const String&, Range*, FindOptions); |
| 225 Range* findRangeOfString(const String& target, | 234 Range* findRangeOfString(const String& target, |
| 226 const EphemeralRange& referenceRange, | 235 const EphemeralRange& referenceRange, |
| 227 FindOptions); | 236 FindOptions); |
| 228 Range* findRangeOfString(const String& target, | 237 Range* findRangeOfString(const String& target, |
| 229 const EphemeralRangeInFlatTree& referenceRange, | 238 const EphemeralRangeInFlatTree& referenceRange, |
| 230 FindOptions); | 239 FindOptions); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 246 void replaceSelectionWithFragment(DocumentFragment*, | 255 void replaceSelectionWithFragment(DocumentFragment*, |
| 247 bool selectReplacement, | 256 bool selectReplacement, |
| 248 bool smartReplace, | 257 bool smartReplace, |
| 249 bool matchStyle); | 258 bool matchStyle); |
| 250 void replaceSelectionWithText(const String&, | 259 void replaceSelectionWithText(const String&, |
| 251 bool selectReplacement, | 260 bool selectReplacement, |
| 252 bool smartReplace); | 261 bool smartReplace); |
| 253 | 262 |
| 254 // TODO(xiaochengh): Replace |bool| parameters by |enum|. | 263 // TODO(xiaochengh): Replace |bool| parameters by |enum|. |
| 255 void replaceSelectionAfterDragging(DocumentFragment*, | 264 void replaceSelectionAfterDragging(DocumentFragment*, |
| 256 bool smartReplace, | 265 InsertMode, |
| 257 bool plainText); | 266 DragSourceType); |
| 258 void moveSelectionAfterDragging(DocumentFragment*, | 267 |
| 259 const Position&, | 268 // Return false if frame was destroyed by event handler, should stop executing
remaining actions. |
| 260 bool smartInsert, | 269 bool deleteSelectionAfterDraggingWithEvents( |
| 261 bool smartDelete); | 270 Element* dragSource, |
| 271 DeleteMode, |
| 272 const Position& referenceMovePosition); |
| 273 bool replaceSelectionAfterDraggingWithEvents(Element* dropTarget, |
| 274 DragData*, |
| 275 DocumentFragment*, |
| 276 Range* dropCaretRange, |
| 277 InsertMode, |
| 278 DragSourceType); |
| 262 | 279 |
| 263 EditorParagraphSeparator defaultParagraphSeparator() const { | 280 EditorParagraphSeparator defaultParagraphSeparator() const { |
| 264 return m_defaultParagraphSeparator; | 281 return m_defaultParagraphSeparator; |
| 265 } | 282 } |
| 266 void setDefaultParagraphSeparator(EditorParagraphSeparator separator) { | 283 void setDefaultParagraphSeparator(EditorParagraphSeparator separator) { |
| 267 m_defaultParagraphSeparator = separator; | 284 m_defaultParagraphSeparator = separator; |
| 268 } | 285 } |
| 269 | 286 |
| 270 static void tidyUpHTMLStructure(Document&); | 287 static void tidyUpHTMLStructure(Document&); |
| 271 | 288 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 DataTransferAccessPolicy, | 337 DataTransferAccessPolicy, |
| 321 PasteMode = AllMimeTypes); | 338 PasteMode = AllMimeTypes); |
| 322 | 339 |
| 323 void revealSelectionAfterEditingOperation( | 340 void revealSelectionAfterEditingOperation( |
| 324 const ScrollAlignment& = ScrollAlignment::alignCenterIfNeeded, | 341 const ScrollAlignment& = ScrollAlignment::alignCenterIfNeeded, |
| 325 RevealExtentOption = DoNotRevealExtent); | 342 RevealExtentOption = DoNotRevealExtent); |
| 326 void changeSelectionAfterCommand(const VisibleSelection& newSelection, | 343 void changeSelectionAfterCommand(const VisibleSelection& newSelection, |
| 327 FrameSelection::SetSelectionOptions); | 344 FrameSelection::SetSelectionOptions); |
| 328 void notifyComponentsOnChangedSelection(); | 345 void notifyComponentsOnChangedSelection(); |
| 329 | 346 |
| 330 Element* findEventTargetFromSelection() const; | |
| 331 | |
| 332 SpellChecker& spellChecker() const; | 347 SpellChecker& spellChecker() const; |
| 333 | 348 |
| 334 bool handleEditingKeyboardEvent(KeyboardEvent*); | 349 bool handleEditingKeyboardEvent(KeyboardEvent*); |
| 335 }; | 350 }; |
| 336 | 351 |
| 337 inline void Editor::setStartNewKillRingSequence(bool flag) { | 352 inline void Editor::setStartNewKillRingSequence(bool flag) { |
| 338 m_shouldStartNewKillRingSequence = flag; | 353 m_shouldStartNewKillRingSequence = flag; |
| 339 } | 354 } |
| 340 | 355 |
| 341 inline const VisibleSelection& Editor::mark() const { | 356 inline const VisibleSelection& Editor::mark() const { |
| 342 return m_mark; | 357 return m_mark; |
| 343 } | 358 } |
| 344 | 359 |
| 345 inline void Editor::setMark(const VisibleSelection& selection) { | 360 inline void Editor::setMark(const VisibleSelection& selection) { |
| 346 m_mark = selection; | 361 m_mark = selection; |
| 347 } | 362 } |
| 348 | 363 |
| 349 inline bool Editor::markedTextMatchesAreHighlighted() const { | 364 inline bool Editor::markedTextMatchesAreHighlighted() const { |
| 350 return m_areMarkedTextMatchesHighlighted; | 365 return m_areMarkedTextMatchesHighlighted; |
| 351 } | 366 } |
| 352 | 367 |
| 353 } // namespace blink | 368 } // namespace blink |
| 354 | 369 |
| 355 #endif // Editor_h | 370 #endif // Editor_h |
| OLD | NEW |