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

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

Issue 988023005: Implementing directional selection strategy in Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Expanded a couple of comments. Created 5 years, 9 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 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 23 matching lines...) Expand all
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 "platform/heap/Handle.h"
38 #include "wtf/Noncopyable.h" 38 #include "wtf/Noncopyable.h"
39 39
40 namespace blink { 40 namespace blink {
41 41
42 class CharacterData; 42 class CharacterData;
43 class LocalFrame; 43 class LocalFrame;
44 class GranularityStrategy;
44 class GraphicsContext; 45 class GraphicsContext;
45 class HTMLFormElement; 46 class HTMLFormElement;
46 class Text; 47 class Text;
47 class VisiblePosition; 48 class VisiblePosition;
48 49
49 enum EUserTriggered { NotUserTriggered = 0, UserTriggered = 1 }; 50 enum EUserTriggered { NotUserTriggered = 0, UserTriggered = 1 };
50 51
51 enum RevealExtentOption { 52 enum RevealExtentOption {
52 RevealExtent, 53 RevealExtent,
53 DoNotRevealExtent 54 DoNotRevealExtent
(...skipping 13 matching lines...) Expand all
67 enum EAlteration { AlterationMove, AlterationExtend }; 68 enum EAlteration { AlterationMove, AlterationExtend };
68 enum CursorAlignOnScroll { AlignCursorOnScrollIfNeeded, 69 enum CursorAlignOnScroll { AlignCursorOnScrollIfNeeded,
69 AlignCursorOnScrollAlways }; 70 AlignCursorOnScrollAlways };
70 enum SetSelectionOption { 71 enum SetSelectionOption {
71 // 1 << 0 is reserved for EUserTriggered 72 // 1 << 0 is reserved for EUserTriggered
72 CloseTyping = 1 << 1, 73 CloseTyping = 1 << 1,
73 ClearTypingStyle = 1 << 2, 74 ClearTypingStyle = 1 << 2,
74 SpellCorrectionTriggered = 1 << 3, 75 SpellCorrectionTriggered = 1 << 3,
75 DoNotSetFocus = 1 << 4, 76 DoNotSetFocus = 1 << 4,
76 DoNotUpdateAppearance = 1 << 5, 77 DoNotUpdateAppearance = 1 << 5,
78 DoNotClearStrategy = 1 << 6,
77 }; 79 };
78 typedef unsigned SetSelectionOptions; // Union of values in SetSelectionOpti on and EUserTriggered 80 typedef unsigned SetSelectionOptions; // Union of values in SetSelectionOpti on and EUserTriggered
79 static inline EUserTriggered selectionOptionsToUserTriggered(SetSelectionOpt ions options) 81 static inline EUserTriggered selectionOptionsToUserTriggered(SetSelectionOpt ions options)
80 { 82 {
81 return static_cast<EUserTriggered>(options & UserTriggered); 83 return static_cast<EUserTriggered>(options & UserTriggered);
82 } 84 }
83 85
84 enum DirectoinalOption { 86 enum DirectoinalOption {
85 NonDirectional, 87 NonDirectional,
86 Directional 88 Directional
(...skipping 28 matching lines...) Expand all
115 117
116 bool contains(const LayoutPoint&); 118 bool contains(const LayoutPoint&);
117 119
118 SelectionType selectionType() const { return m_selection.selectionType(); } 120 SelectionType selectionType() const { return m_selection.selectionType(); }
119 121
120 EAffinity affinity() const { return m_selection.affinity(); } 122 EAffinity affinity() const { return m_selection.affinity(); }
121 123
122 bool modify(EAlteration, SelectionDirection, TextGranularity, EUserTriggered = NotUserTriggered); 124 bool modify(EAlteration, SelectionDirection, TextGranularity, EUserTriggered = NotUserTriggered);
123 enum VerticalDirection { DirectionUp, DirectionDown }; 125 enum VerticalDirection { DirectionUp, DirectionDown };
124 bool modify(EAlteration, unsigned verticalDistance, VerticalDirection, EUser Triggered = NotUserTriggered, CursorAlignOnScroll = AlignCursorOnScrollIfNeeded) ; 126 bool modify(EAlteration, unsigned verticalDistance, VerticalDirection, EUser Triggered = NotUserTriggered, CursorAlignOnScroll = AlignCursorOnScrollIfNeeded) ;
125 // Currently we support only CharaterGranularity and WordGranurarity. 127
126 void moveRangeSelectionExtent(const VisiblePosition&, TextGranularity); 128 // Moves the selection extent based on the selection granularity strategy.
129 // This function does not allow the selection to collapse. If the new extent
130 // is set to the same position as the current base, this function will do no thing.
131 void moveRangeSelectionExtent(const VisiblePosition&);
127 void moveRangeSelection(const VisiblePosition& base, const VisiblePosition& extent, TextGranularity); 132 void moveRangeSelection(const VisiblePosition& base, const VisiblePosition& extent, TextGranularity);
128 133
129 TextGranularity granularity() const { return m_granularity; } 134 TextGranularity granularity() const { return m_granularity; }
130 135
131 void setStart(const VisiblePosition &, EUserTriggered = NotUserTriggered); 136 void setStart(const VisiblePosition &, EUserTriggered = NotUserTriggered);
132 void setEnd(const VisiblePosition &, EUserTriggered = NotUserTriggered); 137 void setEnd(const VisiblePosition &, EUserTriggered = NotUserTriggered);
133 138
134 void setBase(const VisiblePosition&, EUserTriggered = NotUserTriggered); 139 void setBase(const VisiblePosition&, EUserTriggered = NotUserTriggered);
135 void setExtent(const VisiblePosition&, EUserTriggered = NotUserTriggered); 140 void setExtent(const VisiblePosition&, EUserTriggered = NotUserTriggered);
136 141
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 269
265 bool dispatchSelectStart(); 270 bool dispatchSelectStart();
266 271
267 void updateSelectionIfNeeded(const Position& base, const Position& extent, c onst Position& start, const Position& end); 272 void updateSelectionIfNeeded(const Position& base, const Position& extent, c onst Position& start, const Position& end);
268 273
269 void startObservingVisibleSelectionChange(); 274 void startObservingVisibleSelectionChange();
270 void stopObservingVisibleSelectionChangeIfNecessary(); 275 void stopObservingVisibleSelectionChangeIfNecessary();
271 276
272 VisibleSelection validateSelection(const VisibleSelection&); 277 VisibleSelection validateSelection(const VisibleSelection&);
273 278
279 GranularityStrategy& granularityStrategy();
280
274 RawPtrWillBeMember<LocalFrame> m_frame; 281 RawPtrWillBeMember<LocalFrame> m_frame;
275 282
276 LayoutUnit m_xPosForVerticalArrowNavigation; 283 LayoutUnit m_xPosForVerticalArrowNavigation;
277 284
278 VisibleSelection m_selection; 285 VisibleSelection m_selection;
279 bool m_observingVisibleSelection; 286 bool m_observingVisibleSelection;
280 VisiblePosition m_originalBase; // Used to store base before the adjustment at bidi boundary 287 VisiblePosition m_originalBase; // Used to store base before the adjustment at bidi boundary
281 TextGranularity m_granularity; 288 TextGranularity m_granularity;
282 289
283 // The range specified by the user, which may not be visually canonicalized (hence "logical"). 290 // The range specified by the user, which may not be visually canonicalized (hence "logical").
284 // This will be invalidated if the underlying VisibleSelection changes. If t hat happens, this variable will 291 // This will be invalidated if the underlying VisibleSelection changes. If t hat happens, this variable will
285 // become null, in which case logical positions == visible positions. 292 // become null, in which case logical positions == visible positions.
286 RefPtrWillBeMember<Range> m_logicalRange; 293 RefPtrWillBeMember<Range> m_logicalRange;
287 294
288 RefPtrWillBeMember<Node> m_previousCaretNode; // The last node which painted the caret. Retained for clearing the old caret when it moves. 295 RefPtrWillBeMember<Node> m_previousCaretNode; // The last node which painted the caret. Retained for clearing the old caret when it moves.
289 LayoutRect m_previousCaretRect; 296 LayoutRect m_previousCaretRect;
290 297
291 RefPtrWillBeMember<EditingStyle> m_typingStyle; 298 RefPtrWillBeMember<EditingStyle> m_typingStyle;
292 299
293 Timer<FrameSelection> m_caretBlinkTimer; 300 Timer<FrameSelection> m_caretBlinkTimer;
294 301
295 bool m_caretRectDirty : 1; 302 bool m_caretRectDirty : 1;
296 bool m_shouldPaintCaret : 1; 303 bool m_shouldPaintCaret : 1;
297 bool m_isCaretBlinkingSuspended : 1; 304 bool m_isCaretBlinkingSuspended : 1;
298 bool m_focused : 1; 305 bool m_focused : 1;
299 bool m_shouldShowBlockCursor : 1; 306 bool m_shouldShowBlockCursor : 1;
307
308 // Controls text granularity used to adjust the selection's extent in moveRa ngeSelectionExtent.
309 OwnPtr<GranularityStrategy> m_granularityStrategy;
300 }; 310 };
301 311
302 inline EditingStyle* FrameSelection::typingStyle() const 312 inline EditingStyle* FrameSelection::typingStyle() const
303 { 313 {
304 return m_typingStyle.get(); 314 return m_typingStyle.get();
305 } 315 }
306 316
307 inline void FrameSelection::clearTypingStyle() 317 inline void FrameSelection::clearTypingStyle()
308 { 318 {
309 m_typingStyle.clear(); 319 m_typingStyle.clear();
310 } 320 }
311 321
312 inline void FrameSelection::setTypingStyle(PassRefPtrWillBeRawPtr<EditingStyle> style) 322 inline void FrameSelection::setTypingStyle(PassRefPtrWillBeRawPtr<EditingStyle> style)
313 { 323 {
314 m_typingStyle = style; 324 m_typingStyle = style;
315 } 325 }
316 } // namespace blink 326 } // namespace blink
317 327
318 #ifndef NDEBUG 328 #ifndef NDEBUG
319 // Outside the WebCore namespace for ease of invocation from gdb. 329 // Outside the WebCore namespace for ease of invocation from gdb.
320 void showTree(const blink::FrameSelection&); 330 void showTree(const blink::FrameSelection&);
321 void showTree(const blink::FrameSelection*); 331 void showTree(const blink::FrameSelection*);
322 #endif 332 #endif
323 333
324 #endif // FrameSelection_h 334 #endif // FrameSelection_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/editing/FrameSelection.cpp » ('j') | Source/core/editing/FrameSelection.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698