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