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

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

Issue 2638423005: Make FrameSelection to utilize SynchronousMutationObserver (Closed)
Patch Set: 2017-01-20T19:16:11 Rebase Created 3 years, 11 months 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 11 matching lines...) Expand all
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #ifndef FrameSelection_h 27 #ifndef FrameSelection_h
28 #define FrameSelection_h 28 #define FrameSelection_h
29 29
30 #include "core/CoreExport.h" 30 #include "core/CoreExport.h"
31 #include "core/dom/Range.h" 31 #include "core/dom/Range.h"
32 #include "core/dom/SynchronousMutationObserver.h"
32 #include "core/editing/EditingStyle.h" 33 #include "core/editing/EditingStyle.h"
33 #include "core/editing/EphemeralRange.h" 34 #include "core/editing/EphemeralRange.h"
34 #include "core/editing/VisiblePosition.h" 35 #include "core/editing/VisiblePosition.h"
35 #include "core/editing/VisibleSelection.h" 36 #include "core/editing/VisibleSelection.h"
36 #include "core/editing/iterators/TextIteratorFlags.h" 37 #include "core/editing/iterators/TextIteratorFlags.h"
37 #include "core/layout/ScrollAlignment.h" 38 #include "core/layout/ScrollAlignment.h"
38 #include "platform/Timer.h" 39 #include "platform/Timer.h"
39 #include "platform/geometry/IntRect.h" 40 #include "platform/geometry/IntRect.h"
40 #include "platform/geometry/LayoutRect.h" 41 #include "platform/geometry/LayoutRect.h"
41 #include "platform/heap/Handle.h" 42 #include "platform/heap/Handle.h"
(...skipping 20 matching lines...) Expand all
62 63
63 enum RevealExtentOption { RevealExtent, DoNotRevealExtent }; 64 enum RevealExtentOption { RevealExtent, DoNotRevealExtent };
64 65
65 enum class SelectionDirectionalMode { NonDirectional, Directional }; 66 enum class SelectionDirectionalMode { NonDirectional, Directional };
66 67
67 enum class CaretVisibility; 68 enum class CaretVisibility;
68 69
69 enum class HandleVisibility { NotVisible, Visible }; 70 enum class HandleVisibility { NotVisible, Visible };
70 71
71 class CORE_EXPORT FrameSelection final 72 class CORE_EXPORT FrameSelection final
72 : public GarbageCollectedFinalized<FrameSelection> { 73 : public GarbageCollectedFinalized<FrameSelection>,
74 public SynchronousMutationObserver {
73 WTF_MAKE_NONCOPYABLE(FrameSelection); 75 WTF_MAKE_NONCOPYABLE(FrameSelection);
76 USING_GARBAGE_COLLECTED_MIXIN(FrameSelection);
74 77
75 public: 78 public:
76 static FrameSelection* create(LocalFrame& frame) { 79 static FrameSelection* create(LocalFrame& frame) {
77 return new FrameSelection(frame); 80 return new FrameSelection(frame);
78 } 81 }
79 ~FrameSelection(); 82 ~FrameSelection();
80 83
81 enum EAlteration { AlterationMove, AlterationExtend }; 84 enum EAlteration { AlterationMove, AlterationExtend };
82 enum SetSelectionOption { 85 enum SetSelectionOption {
83 // 1 << 0 is reserved for EUserTriggered 86 // 1 << 0 is reserved for EUserTriggered
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 bool isRange() const { return selection().isRange(); } 203 bool isRange() const { return selection().isRange(); }
201 bool isInPasswordField() const; 204 bool isInPasswordField() const;
202 bool isDirectional() const { return selection().isDirectional(); } 205 bool isDirectional() const { return selection().isDirectional(); }
203 206
204 // If this FrameSelection has a logical range which is still valid, this 207 // If this FrameSelection has a logical range which is still valid, this
205 // function return its clone. Otherwise, the return value from underlying 208 // function return its clone. Otherwise, the return value from underlying
206 // VisibleSelection's firstRange() is returned. 209 // VisibleSelection's firstRange() is returned.
207 Range* firstRange() const; 210 Range* firstRange() const;
208 211
209 void documentAttached(Document*); 212 void documentAttached(Document*);
210 void documentDetached(const Document&);
211 void nodeChildrenWillBeRemoved(ContainerNode&);
212 void nodeWillBeRemoved(Node&);
213 void dataWillChange(const CharacterData& node); 213 void dataWillChange(const CharacterData& node);
214 void didUpdateCharacterData(CharacterData*,
215 unsigned offset,
216 unsigned oldLength,
217 unsigned newLength);
218 void didMergeTextNodes(const Text& oldNode, unsigned offset);
219 void didSplitTextNode(const Text& oldNode);
220 214
221 void didLayout(); 215 void didLayout();
222 bool isAppearanceDirty() const; 216 bool isAppearanceDirty() const;
223 void commitAppearanceIfNeeded(LayoutView&); 217 void commitAppearanceIfNeeded(LayoutView&);
224 void setCaretVisible(bool caretIsVisible); 218 void setCaretVisible(bool caretIsVisible);
225 void setCaretRectNeedsUpdate(); 219 void setCaretRectNeedsUpdate();
226 void scheduleVisualUpdate() const; 220 void scheduleVisualUpdate() const;
227 void invalidateCaretRect(bool forceInvalidation = false); 221 void invalidateCaretRect(bool forceInvalidation = false);
228 void paintCaret(GraphicsContext&, const LayoutPoint&); 222 void paintCaret(GraphicsContext&, const LayoutPoint&);
229 223
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 318
325 void setUseSecureKeyboardEntry(bool); 319 void setUseSecureKeyboardEntry(bool);
326 320
327 void updateSelectionIfNeeded(const Position& base, 321 void updateSelectionIfNeeded(const Position& base,
328 const Position& extent, 322 const Position& extent,
329 const Position& start, 323 const Position& start,
330 const Position& end); 324 const Position& end);
331 325
332 GranularityStrategy* granularityStrategy(); 326 GranularityStrategy* granularityStrategy();
333 327
328 // Implementation of |SynchronousMutationObserver| member functions.
329 void contextDestroyed(Document*) final;
330 void nodeChildrenWillBeRemoved(ContainerNode&) final;
331 void nodeWillBeRemoved(Node&) final;
332 void didUpdateCharacterData(CharacterData*,
333 unsigned offset,
334 unsigned oldLength,
335 unsigned newLength) final;
336 void didMergeTextNodes(const Text& mergedNode,
337 const NodeWithIndex& nodeToBeRemovedWithIndex,
338 unsigned oldLength) final;
339 void didSplitTextNode(const Text& oldNode) final;
340
334 // For unittests 341 // For unittests
335 bool shouldPaintCaretForTesting() const; 342 bool shouldPaintCaretForTesting() const;
336 bool isPreviousCaretDirtyForTesting() const; 343 bool isPreviousCaretDirtyForTesting() const;
337 344
338 Member<Document> m_document; 345 Member<Document> m_document;
339 Member<LocalFrame> m_frame; 346 Member<LocalFrame> m_frame;
340 const Member<PendingSelection> m_pendingSelection; 347 const Member<PendingSelection> m_pendingSelection;
341 const Member<SelectionEditor> m_selectionEditor; 348 const Member<SelectionEditor> m_selectionEditor;
342 349
343 TextGranularity m_granularity; 350 TextGranularity m_granularity;
(...skipping 26 matching lines...) Expand all
370 } 377 }
371 } // namespace blink 378 } // namespace blink
372 379
373 #ifndef NDEBUG 380 #ifndef NDEBUG
374 // Outside the WebCore namespace for ease of invocation from gdb. 381 // Outside the WebCore namespace for ease of invocation from gdb.
375 void showTree(const blink::FrameSelection&); 382 void showTree(const blink::FrameSelection&);
376 void showTree(const blink::FrameSelection*); 383 void showTree(const blink::FrameSelection*);
377 #endif 384 #endif
378 385
379 #endif // FrameSelection_h 386 #endif // FrameSelection_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | third_party/WebKit/Source/core/editing/FrameSelection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698