OLD | NEW |
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 enum class CursorAlignOnScroll { IfNeeded, Always }; | 58 enum class CursorAlignOnScroll { IfNeeded, Always }; |
59 | 59 |
60 enum EUserTriggered { NotUserTriggered = 0, UserTriggered = 1 }; | 60 enum EUserTriggered { NotUserTriggered = 0, UserTriggered = 1 }; |
61 | 61 |
62 enum RevealExtentOption { RevealExtent, DoNotRevealExtent }; | 62 enum RevealExtentOption { RevealExtent, DoNotRevealExtent }; |
63 | 63 |
64 enum class SelectionDirectionalMode { NonDirectional, Directional }; | 64 enum class SelectionDirectionalMode { NonDirectional, Directional }; |
65 | 65 |
66 enum class CaretVisibility; | 66 enum class CaretVisibility; |
67 | 67 |
| 68 enum class HandleVisibility { NotVisible, Visible }; |
| 69 |
68 class CORE_EXPORT FrameSelection final | 70 class CORE_EXPORT FrameSelection final |
69 : public GarbageCollectedFinalized<FrameSelection> { | 71 : public GarbageCollectedFinalized<FrameSelection> { |
70 WTF_MAKE_NONCOPYABLE(FrameSelection); | 72 WTF_MAKE_NONCOPYABLE(FrameSelection); |
71 | 73 |
72 public: | 74 public: |
73 static FrameSelection* create(LocalFrame* frame) { | 75 static FrameSelection* create(LocalFrame* frame) { |
74 return new FrameSelection(frame); | 76 return new FrameSelection(frame); |
75 } | 77 } |
76 ~FrameSelection(); | 78 ~FrameSelection(); |
77 | 79 |
78 enum EAlteration { AlterationMove, AlterationExtend }; | 80 enum EAlteration { AlterationMove, AlterationExtend }; |
79 enum SetSelectionOption { | 81 enum SetSelectionOption { |
80 // 1 << 0 is reserved for EUserTriggered | 82 // 1 << 0 is reserved for EUserTriggered |
81 CloseTyping = 1 << 1, | 83 CloseTyping = 1 << 1, |
82 ClearTypingStyle = 1 << 2, | 84 ClearTypingStyle = 1 << 2, |
83 DoNotSetFocus = 1 << 3, | 85 DoNotSetFocus = 1 << 3, |
84 DoNotUpdateAppearance = 1 << 4, | 86 DoNotUpdateAppearance = 1 << 4, |
85 DoNotClearStrategy = 1 << 5, | 87 DoNotClearStrategy = 1 << 5, |
86 DoNotAdjustInFlatTree = 1 << 6, | 88 DoNotAdjustInFlatTree = 1 << 6, |
| 89 HandleVisible = 1 << 7, |
87 }; | 90 }; |
88 // Union of values in SetSelectionOption and EUserTriggered | 91 // Union of values in SetSelectionOption and EUserTriggered |
89 typedef unsigned SetSelectionOptions; | 92 typedef unsigned SetSelectionOptions; |
90 static inline EUserTriggered selectionOptionsToUserTriggered( | 93 static inline EUserTriggered selectionOptionsToUserTriggered( |
91 SetSelectionOptions options) { | 94 SetSelectionOptions options) { |
92 return static_cast<EUserTriggered>(options & UserTriggered); | 95 return static_cast<EUserTriggered>(options & UserTriggered); |
93 } | 96 } |
94 | 97 |
95 bool isAvailable() const { return m_document; } | 98 bool isAvailable() const { return m_document; } |
96 // You should not call |document()| when |!isAvailable()|. | 99 // You should not call |document()| when |!isAvailable()|. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 TextAffinity, | 147 TextAffinity, |
145 SelectionDirectionalMode = SelectionDirectionalMode::NonDirectional, | 148 SelectionDirectionalMode = SelectionDirectionalMode::NonDirectional, |
146 FrameSelection::SetSelectionOptions = CloseTyping | ClearTypingStyle); | 149 FrameSelection::SetSelectionOptions = CloseTyping | ClearTypingStyle); |
147 void selectAll(); | 150 void selectAll(); |
148 void clear(); | 151 void clear(); |
149 | 152 |
150 // Call this after doing user-triggered selections to make it easy to delete | 153 // Call this after doing user-triggered selections to make it easy to delete |
151 // the frame you entirely selected. | 154 // the frame you entirely selected. |
152 void selectFrameElementInParentIfFullySelected(); | 155 void selectFrameElementInParentIfFullySelected(); |
153 | 156 |
| 157 bool contains(const HitTestResult&); |
154 bool contains(const LayoutPoint&); | 158 bool contains(const LayoutPoint&); |
155 | 159 |
156 SelectionType getSelectionType() const { | 160 SelectionType getSelectionType() const { |
157 return selection().getSelectionType(); | 161 return selection().getSelectionType(); |
158 } | 162 } |
159 | 163 |
160 TextAffinity affinity() const { return selection().affinity(); } | 164 TextAffinity affinity() const { return selection().affinity(); } |
161 | 165 |
162 bool modify(EAlteration, | 166 bool modify(EAlteration, |
163 SelectionDirection, | 167 SelectionDirection, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 void setCaretBlinkingSuspended(bool); | 232 void setCaretBlinkingSuspended(bool); |
229 bool isCaretBlinkingSuspended() const; | 233 bool isCaretBlinkingSuspended() const; |
230 | 234 |
231 // Focus | 235 // Focus |
232 void setFocused(bool); | 236 void setFocused(bool); |
233 bool isFocused() const { return m_focused; } | 237 bool isFocused() const { return m_focused; } |
234 bool isFocusedAndActive() const; | 238 bool isFocusedAndActive() const; |
235 void pageActivationChanged(); | 239 void pageActivationChanged(); |
236 | 240 |
237 void setUseSecureKeyboardEntryWhenActive(bool); | 241 void setUseSecureKeyboardEntryWhenActive(bool); |
| 242 |
| 243 bool isHandleVisible() const { |
| 244 return m_handleVisibility == HandleVisibility::Visible; |
| 245 } |
| 246 |
238 void updateSecureKeyboardEntryIfActive(); | 247 void updateSecureKeyboardEntryIfActive(); |
239 | 248 |
240 // Returns true if a word is selected. | 249 // Returns true if a word is selected. |
241 bool selectWordAroundPosition(const VisiblePosition&); | 250 bool selectWordAroundPosition(const VisiblePosition&); |
242 | 251 |
243 #ifndef NDEBUG | 252 #ifndef NDEBUG |
244 void showTreeForThis() const; | 253 void showTreeForThis() const; |
245 #endif | 254 #endif |
246 | 255 |
247 void setFocusedNodeIfNeeded(); | 256 void setFocusedNodeIfNeeded(); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 const Member<PendingSelection> m_pendingSelection; | 337 const Member<PendingSelection> m_pendingSelection; |
329 const Member<SelectionEditor> m_selectionEditor; | 338 const Member<SelectionEditor> m_selectionEditor; |
330 | 339 |
331 TextGranularity m_granularity; | 340 TextGranularity m_granularity; |
332 LayoutUnit m_xPosForVerticalArrowNavigation; | 341 LayoutUnit m_xPosForVerticalArrowNavigation; |
333 | 342 |
334 Member<EditingStyle> m_typingStyle; | 343 Member<EditingStyle> m_typingStyle; |
335 | 344 |
336 bool m_focused : 1; | 345 bool m_focused : 1; |
337 | 346 |
| 347 HandleVisibility m_handleVisibility = HandleVisibility::NotVisible; |
| 348 |
338 // Controls text granularity used to adjust the selection's extent in | 349 // Controls text granularity used to adjust the selection's extent in |
339 // moveRangeSelectionExtent. | 350 // moveRangeSelectionExtent. |
340 std::unique_ptr<GranularityStrategy> m_granularityStrategy; | 351 std::unique_ptr<GranularityStrategy> m_granularityStrategy; |
341 | 352 |
342 const Member<FrameCaret> m_frameCaret; | 353 const Member<FrameCaret> m_frameCaret; |
343 bool m_useSecureKeyboardEntryWhenActive = false; | 354 bool m_useSecureKeyboardEntryWhenActive = false; |
344 }; | 355 }; |
345 | 356 |
346 inline EditingStyle* FrameSelection::typingStyle() const { | 357 inline EditingStyle* FrameSelection::typingStyle() const { |
347 return m_typingStyle.get(); | 358 return m_typingStyle.get(); |
348 } | 359 } |
349 | 360 |
350 inline void FrameSelection::clearTypingStyle() { | 361 inline void FrameSelection::clearTypingStyle() { |
351 m_typingStyle.clear(); | 362 m_typingStyle.clear(); |
352 } | 363 } |
353 | 364 |
354 inline void FrameSelection::setTypingStyle(EditingStyle* style) { | 365 inline void FrameSelection::setTypingStyle(EditingStyle* style) { |
355 m_typingStyle = style; | 366 m_typingStyle = style; |
356 } | 367 } |
357 } // namespace blink | 368 } // namespace blink |
358 | 369 |
359 #ifndef NDEBUG | 370 #ifndef NDEBUG |
360 // Outside the WebCore namespace for ease of invocation from gdb. | 371 // Outside the WebCore namespace for ease of invocation from gdb. |
361 void showTree(const blink::FrameSelection&); | 372 void showTree(const blink::FrameSelection&); |
362 void showTree(const blink::FrameSelection*); | 373 void showTree(const blink::FrameSelection*); |
363 #endif | 374 #endif |
364 | 375 |
365 #endif // FrameSelection_h | 376 #endif // FrameSelection_h |
OLD | NEW |