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

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

Issue 299353004: Oilpan: move editing objects to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Make test wrapper class finalized Created 6 years, 6 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
« no previous file with comments | « Source/core/editing/FormatBlockCommand.cpp ('k') | Source/core/editing/FrameSelection.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) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 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 FrameSelection_h 27 #define FrameSelection_h
28 28
29 #include "core/dom/Range.h" 29 #include "core/dom/Range.h"
30 #include "core/editing/Caret.h" 30 #include "core/editing/Caret.h"
31 #include "core/editing/EditingStyle.h" 31 #include "core/editing/EditingStyle.h"
32 #include "core/editing/VisibleSelection.h" 32 #include "core/editing/VisibleSelection.h"
33 #include "core/rendering/ScrollAlignment.h" 33 #include "core/rendering/ScrollAlignment.h"
34 #include "platform/Timer.h" 34 #include "platform/Timer.h"
35 #include "platform/geometry/IntRect.h" 35 #include "platform/geometry/IntRect.h"
36 #include "platform/geometry/LayoutRect.h" 36 #include "platform/geometry/LayoutRect.h"
37 #include "platform/heap/Handle.h"
37 #include "wtf/Noncopyable.h" 38 #include "wtf/Noncopyable.h"
38 39
39 namespace WebCore { 40 namespace WebCore {
40 41
41 class CharacterData; 42 class CharacterData;
42 class LocalFrame; 43 class LocalFrame;
43 class GraphicsContext; 44 class GraphicsContext;
44 class HTMLFormElement; 45 class HTMLFormElement;
45 class MutableStylePropertySet; 46 class MutableStylePropertySet;
46 class RenderObject; 47 class RenderObject;
47 class RenderView; 48 class RenderView;
48 class Settings; 49 class Settings;
49 class Text; 50 class Text;
50 class VisiblePosition; 51 class VisiblePosition;
51 52
52 enum EUserTriggered { NotUserTriggered = 0, UserTriggered = 1 }; 53 enum EUserTriggered { NotUserTriggered = 0, UserTriggered = 1 };
53 54
54 enum RevealExtentOption { 55 enum RevealExtentOption {
55 RevealExtent, 56 RevealExtent,
56 DoNotRevealExtent 57 DoNotRevealExtent
57 }; 58 };
58 59
59 class FrameSelection FINAL : public VisibleSelection::ChangeObserver, private Ca retBase { 60 class FrameSelection FINAL : public NoBaseWillBeGarbageCollectedFinalized<FrameS election>, public VisibleSelection::ChangeObserver, private CaretBase {
60 WTF_MAKE_NONCOPYABLE(FrameSelection); 61 WTF_MAKE_NONCOPYABLE(FrameSelection);
61 WTF_MAKE_FAST_ALLOCATED; 62 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
63 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(FrameSelection);
62 public: 64 public:
65 static PassOwnPtrWillBeRawPtr<FrameSelection> create(LocalFrame* frame = 0)
66 {
67 return adoptPtrWillBeNoop(new FrameSelection(frame));
68 }
69 virtual ~FrameSelection();
70
63 enum EAlteration { AlterationMove, AlterationExtend }; 71 enum EAlteration { AlterationMove, AlterationExtend };
64 enum CursorAlignOnScroll { AlignCursorOnScrollIfNeeded, 72 enum CursorAlignOnScroll { AlignCursorOnScrollIfNeeded,
65 AlignCursorOnScrollAlways }; 73 AlignCursorOnScrollAlways };
66 enum SetSelectionOption { 74 enum SetSelectionOption {
67 // 1 << 0 is reserved for EUserTriggered 75 // 1 << 0 is reserved for EUserTriggered
68 CloseTyping = 1 << 1, 76 CloseTyping = 1 << 1,
69 ClearTypingStyle = 1 << 2, 77 ClearTypingStyle = 1 << 2,
70 SpellCorrectionTriggered = 1 << 3, 78 SpellCorrectionTriggered = 1 << 3,
71 DoNotSetFocus = 1 << 4, 79 DoNotSetFocus = 1 << 4,
72 DoNotUpdateAppearance = 1 << 5, 80 DoNotUpdateAppearance = 1 << 5,
73 }; 81 };
74 typedef unsigned SetSelectionOptions; // Union of values in SetSelectionOpti on and EUserTriggered 82 typedef unsigned SetSelectionOptions; // Union of values in SetSelectionOpti on and EUserTriggered
75 static inline EUserTriggered selectionOptionsToUserTriggered(SetSelectionOpt ions options) 83 static inline EUserTriggered selectionOptionsToUserTriggered(SetSelectionOpt ions options)
76 { 84 {
77 return static_cast<EUserTriggered>(options & UserTriggered); 85 return static_cast<EUserTriggered>(options & UserTriggered);
78 } 86 }
79 87
80 explicit FrameSelection(LocalFrame* = 0);
81 virtual ~FrameSelection();
82
83 Element* rootEditableElement() const { return m_selection.rootEditableElemen t(); } 88 Element* rootEditableElement() const { return m_selection.rootEditableElemen t(); }
84 Element* rootEditableElementOrDocumentElement() const; 89 Element* rootEditableElementOrDocumentElement() const;
85 Node* rootEditableElementOrTreeScopeRootNode() const; 90 Node* rootEditableElementOrTreeScopeRootNode() const;
86 91
87 bool rendererIsEditable() const { return m_selection.rendererIsEditable(); } 92 bool rendererIsEditable() const { return m_selection.rendererIsEditable(); }
88 bool isContentEditable() const { return m_selection.isContentEditable(); } 93 bool isContentEditable() const { return m_selection.isContentEditable(); }
89 bool isContentRichlyEditable() const { return m_selection.isContentRichlyEdi table(); } 94 bool isContentRichlyEditable() const { return m_selection.isContentRichlyEdi table(); }
90 95
91 void moveTo(const VisiblePosition&, EUserTriggered = NotUserTriggered, Curso rAlignOnScroll = AlignCursorOnScrollIfNeeded); 96 void moveTo(const VisiblePosition&, EUserTriggered = NotUserTriggered, Curso rAlignOnScroll = AlignCursorOnScrollIfNeeded);
92 void moveTo(const VisiblePosition&, const VisiblePosition&, EUserTriggered = NotUserTriggered); 97 void moveTo(const VisiblePosition&, const VisiblePosition&, EUserTriggered = NotUserTriggered);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 void formatForDebugger(char* buffer, unsigned length) const; 185 void formatForDebugger(char* buffer, unsigned length) const;
181 void showTreeForThis() const; 186 void showTreeForThis() const;
182 #endif 187 #endif
183 188
184 enum EndPointsAdjustmentMode { AdjustEndpointsAtBidiBoundary, DoNotAdjsutEnd points }; 189 enum EndPointsAdjustmentMode { AdjustEndpointsAtBidiBoundary, DoNotAdjsutEnd points };
185 void setNonDirectionalSelectionIfNeeded(const VisibleSelection&, TextGranula rity, EndPointsAdjustmentMode = DoNotAdjsutEndpoints); 190 void setNonDirectionalSelectionIfNeeded(const VisibleSelection&, TextGranula rity, EndPointsAdjustmentMode = DoNotAdjsutEndpoints);
186 void setFocusedNodeIfNeeded(); 191 void setFocusedNodeIfNeeded();
187 void notifyRendererOfSelectionChange(EUserTriggered); 192 void notifyRendererOfSelectionChange(EUserTriggered);
188 193
189 EditingStyle* typingStyle() const; 194 EditingStyle* typingStyle() const;
190 void setTypingStyle(PassRefPtr<EditingStyle>); 195 void setTypingStyle(PassRefPtrWillBeRawPtr<EditingStyle>);
191 void clearTypingStyle(); 196 void clearTypingStyle();
192 197
193 String selectedText() const; 198 String selectedText() const;
194 String selectedTextForClipboard() const; 199 String selectedTextForClipboard() const;
195 200
196 FloatRect bounds(bool clipToVisibleContent = true) const; 201 FloatRect bounds(bool clipToVisibleContent = true) const;
197 202
198 HTMLFormElement* currentForm() const; 203 HTMLFormElement* currentForm() const;
199 204
200 void revealSelection(const ScrollAlignment& = ScrollAlignment::alignCenterIf Needed, RevealExtentOption = DoNotRevealExtent); 205 void revealSelection(const ScrollAlignment& = ScrollAlignment::alignCenterIf Needed, RevealExtentOption = DoNotRevealExtent);
201 void setSelectionFromNone(); 206 void setSelectionFromNone();
202 207
203 void setShouldShowBlockCursor(bool); 208 void setShouldShowBlockCursor(bool);
204 209
205 // VisibleSelection::ChangeObserver interface. 210 // VisibleSelection::ChangeObserver interface.
206 virtual void didChangeVisibleSelection() OVERRIDE; 211 virtual void didChangeVisibleSelection() OVERRIDE;
207 212
213 virtual void trace(Visitor*) OVERRIDE;
214
208 private: 215 private:
216 explicit FrameSelection(LocalFrame*);
217
209 enum EPositionType { START, END, BASE, EXTENT }; 218 enum EPositionType { START, END, BASE, EXTENT };
210 219
211 void respondToNodeModification(Node&, bool baseRemoved, bool extentRemoved, bool startRemoved, bool endRemoved); 220 void respondToNodeModification(Node&, bool baseRemoved, bool extentRemoved, bool startRemoved, bool endRemoved);
212 TextDirection directionOfEnclosingBlock(); 221 TextDirection directionOfEnclosingBlock();
213 TextDirection directionOfSelection(); 222 TextDirection directionOfSelection();
214 223
215 VisiblePosition positionForPlatform(bool isGetStart) const; 224 VisiblePosition positionForPlatform(bool isGetStart) const;
216 VisiblePosition startForPlatform() const; 225 VisiblePosition startForPlatform() const;
217 VisiblePosition endForPlatform() const; 226 VisiblePosition endForPlatform() const;
218 VisiblePosition nextWordPositionForPlatform(const VisiblePosition&); 227 VisiblePosition nextWordPositionForPlatform(const VisiblePosition&);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 LayoutUnit m_xPosForVerticalArrowNavigation; 260 LayoutUnit m_xPosForVerticalArrowNavigation;
252 261
253 VisibleSelection m_selection; 262 VisibleSelection m_selection;
254 bool m_observingVisibleSelection; 263 bool m_observingVisibleSelection;
255 VisiblePosition m_originalBase; // Used to store base before the adjustment at bidi boundary 264 VisiblePosition m_originalBase; // Used to store base before the adjustment at bidi boundary
256 TextGranularity m_granularity; 265 TextGranularity m_granularity;
257 266
258 // The range specified by the user, which may not be visually canonicalized (hence "logical"). 267 // The range specified by the user, which may not be visually canonicalized (hence "logical").
259 // This will be invalidated if the underlying VisibleSelection changes. If t hat happens, this variable will 268 // This will be invalidated if the underlying VisibleSelection changes. If t hat happens, this variable will
260 // become null, in which case logical positions == visible positions. 269 // become null, in which case logical positions == visible positions.
261 RefPtrWillBePersistent<Range> m_logicalRange; 270 RefPtrWillBeMember<Range> m_logicalRange;
262 271
263 RefPtr<Node> m_previousCaretNode; // The last node which painted the caret. Retained for clearing the old caret when it moves. 272 RefPtrWillBeMember<Node> m_previousCaretNode; // The last node which painted the caret. Retained for clearing the old caret when it moves.
264 273
265 RefPtr<EditingStyle> m_typingStyle; 274 RefPtrWillBeMember<EditingStyle> m_typingStyle;
266 275
267 Timer<FrameSelection> m_caretBlinkTimer; 276 Timer<FrameSelection> m_caretBlinkTimer;
268 // The painted bounds of the caret in absolute coordinates 277 // The painted bounds of the caret in absolute coordinates
269 IntRect m_absCaretBounds; 278 IntRect m_absCaretBounds;
270 bool m_absCaretBoundsDirty : 1; 279 bool m_absCaretBoundsDirty : 1;
271 bool m_caretPaint : 1; 280 bool m_caretPaint : 1;
272 bool m_isCaretBlinkingSuspended : 1; 281 bool m_isCaretBlinkingSuspended : 1;
273 bool m_focused : 1; 282 bool m_focused : 1;
274 bool m_shouldShowBlockCursor : 1; 283 bool m_shouldShowBlockCursor : 1;
275 }; 284 };
276 285
277 inline EditingStyle* FrameSelection::typingStyle() const 286 inline EditingStyle* FrameSelection::typingStyle() const
278 { 287 {
279 return m_typingStyle.get(); 288 return m_typingStyle.get();
280 } 289 }
281 290
282 inline void FrameSelection::clearTypingStyle() 291 inline void FrameSelection::clearTypingStyle()
283 { 292 {
284 m_typingStyle.clear(); 293 m_typingStyle.clear();
285 } 294 }
286 295
287 inline void FrameSelection::setTypingStyle(PassRefPtr<EditingStyle> style) 296 inline void FrameSelection::setTypingStyle(PassRefPtrWillBeRawPtr<EditingStyle> style)
288 { 297 {
289 m_typingStyle = style; 298 m_typingStyle = style;
290 } 299 }
291 } // namespace WebCore 300 } // namespace WebCore
292 301
293 #ifndef NDEBUG 302 #ifndef NDEBUG
294 // Outside the WebCore namespace for ease of invocation from gdb. 303 // Outside the WebCore namespace for ease of invocation from gdb.
295 void showTree(const WebCore::FrameSelection&); 304 void showTree(const WebCore::FrameSelection&);
296 void showTree(const WebCore::FrameSelection*); 305 void showTree(const WebCore::FrameSelection*);
297 #endif 306 #endif
298 307
299 #endif // FrameSelection_h 308 #endif // FrameSelection_h
OLDNEW
« no previous file with comments | « Source/core/editing/FormatBlockCommand.cpp ('k') | Source/core/editing/FrameSelection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698