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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 enum class CursorAlignOnScroll { IfNeeded, Always }; | 60 enum class CursorAlignOnScroll { IfNeeded, Always }; |
61 | 61 |
62 enum EUserTriggered { NotUserTriggered = 0, UserTriggered = 1 }; | 62 enum EUserTriggered { NotUserTriggered = 0, UserTriggered = 1 }; |
63 | 63 |
64 enum RevealExtentOption { RevealExtent, DoNotRevealExtent }; | 64 enum RevealExtentOption { RevealExtent, DoNotRevealExtent }; |
65 | 65 |
66 enum class SelectionDirectionalMode { NonDirectional, Directional }; | 66 enum class SelectionDirectionalMode { NonDirectional, Directional }; |
67 | 67 |
68 enum class CaretVisibility; | 68 enum class CaretVisibility; |
69 | 69 |
| 70 enum class HandleVisibility { NotVisible, Visible }; |
| 71 |
70 class CORE_EXPORT FrameSelection final | 72 class CORE_EXPORT FrameSelection final |
71 : public GarbageCollectedFinalized<FrameSelection> { | 73 : public GarbageCollectedFinalized<FrameSelection> { |
72 WTF_MAKE_NONCOPYABLE(FrameSelection); | 74 WTF_MAKE_NONCOPYABLE(FrameSelection); |
73 | 75 |
74 public: | 76 public: |
75 static FrameSelection* create(LocalFrame* frame) { | 77 static FrameSelection* create(LocalFrame* frame) { |
76 return new FrameSelection(frame); | 78 return new FrameSelection(frame); |
77 } | 79 } |
78 ~FrameSelection(); | 80 ~FrameSelection(); |
79 | 81 |
80 enum EAlteration { AlterationMove, AlterationExtend }; | 82 enum EAlteration { AlterationMove, AlterationExtend }; |
81 enum SetSelectionOption { | 83 enum SetSelectionOption { |
82 // 1 << 0 is reserved for EUserTriggered | 84 // 1 << 0 is reserved for EUserTriggered |
83 CloseTyping = 1 << 1, | 85 CloseTyping = 1 << 1, |
84 ClearTypingStyle = 1 << 2, | 86 ClearTypingStyle = 1 << 2, |
85 DoNotSetFocus = 1 << 3, | 87 DoNotSetFocus = 1 << 3, |
86 DoNotUpdateAppearance = 1 << 4, | 88 DoNotUpdateAppearance = 1 << 4, |
87 DoNotClearStrategy = 1 << 5, | 89 DoNotClearStrategy = 1 << 5, |
88 DoNotAdjustInFlatTree = 1 << 6, | 90 DoNotAdjustInFlatTree = 1 << 6, |
| 91 HandleVisible = 1 << 7, |
89 }; | 92 }; |
90 // Union of values in SetSelectionOption and EUserTriggered | 93 // Union of values in SetSelectionOption and EUserTriggered |
91 typedef unsigned SetSelectionOptions; | 94 typedef unsigned SetSelectionOptions; |
92 static inline EUserTriggered selectionOptionsToUserTriggered( | 95 static inline EUserTriggered selectionOptionsToUserTriggered( |
93 SetSelectionOptions options) { | 96 SetSelectionOptions options) { |
94 return static_cast<EUserTriggered>(options & UserTriggered); | 97 return static_cast<EUserTriggered>(options & UserTriggered); |
95 } | 98 } |
96 | 99 |
97 bool isAvailable() const { return m_document; } | 100 bool isAvailable() const { return m_document; } |
98 // You should not call |document()| when |!isAvailable()|. | 101 // You should not call |document()| when |!isAvailable()|. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 TextAffinity, | 160 TextAffinity, |
158 SelectionDirectionalMode = SelectionDirectionalMode::NonDirectional, | 161 SelectionDirectionalMode = SelectionDirectionalMode::NonDirectional, |
159 FrameSelection::SetSelectionOptions = CloseTyping | ClearTypingStyle); | 162 FrameSelection::SetSelectionOptions = CloseTyping | ClearTypingStyle); |
160 void selectAll(); | 163 void selectAll(); |
161 void clear(); | 164 void clear(); |
162 | 165 |
163 // Call this after doing user-triggered selections to make it easy to delete | 166 // Call this after doing user-triggered selections to make it easy to delete |
164 // the frame you entirely selected. | 167 // the frame you entirely selected. |
165 void selectFrameElementInParentIfFullySelected(); | 168 void selectFrameElementInParentIfFullySelected(); |
166 | 169 |
| 170 bool contains(const HitTestResult&); |
167 bool contains(const LayoutPoint&); | 171 bool contains(const LayoutPoint&); |
168 | 172 |
169 SelectionType getSelectionType() const { | 173 SelectionType getSelectionType() const { |
170 return selection().getSelectionType(); | 174 return selection().getSelectionType(); |
171 } | 175 } |
172 | 176 |
173 TextAffinity affinity() const { return selection().affinity(); } | 177 TextAffinity affinity() const { return selection().affinity(); } |
174 | 178 |
175 bool modify(EAlteration, | 179 bool modify(EAlteration, |
176 SelectionDirection, | 180 SelectionDirection, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 // Used to suspend caret blinking while the mouse is down. | 248 // Used to suspend caret blinking while the mouse is down. |
245 void setCaretBlinkingSuspended(bool); | 249 void setCaretBlinkingSuspended(bool); |
246 bool isCaretBlinkingSuspended() const; | 250 bool isCaretBlinkingSuspended() const; |
247 | 251 |
248 // Focus | 252 // Focus |
249 void setFocused(bool); | 253 void setFocused(bool); |
250 bool isFocused() const { return m_focused; } | 254 bool isFocused() const { return m_focused; } |
251 bool isFocusedAndActive() const; | 255 bool isFocusedAndActive() const; |
252 void pageActivationChanged(); | 256 void pageActivationChanged(); |
253 | 257 |
| 258 bool isHandleVisible() const { |
| 259 return m_handleVisibility == HandleVisibility::Visible; |
| 260 } |
| 261 |
254 void updateSecureKeyboardEntryIfActive(); | 262 void updateSecureKeyboardEntryIfActive(); |
255 | 263 |
256 // Returns true if a word is selected. | 264 // Returns true if a word is selected. |
257 bool selectWordAroundPosition(const VisiblePosition&); | 265 bool selectWordAroundPosition(const VisiblePosition&); |
258 | 266 |
259 #ifndef NDEBUG | 267 #ifndef NDEBUG |
260 void showTreeForThis() const; | 268 void showTreeForThis() const; |
261 #endif | 269 #endif |
262 | 270 |
263 enum EndPointsAdjustmentMode { | 271 enum EndPointsAdjustmentMode { |
264 AdjustEndpointsAtBidiBoundary, | 272 AdjustEndpointsAtBidiBoundary, |
265 DoNotAdjustEndpoints | 273 DoNotAdjustEndpoints |
266 }; | 274 }; |
267 void setNonDirectionalSelectionIfNeeded( | 275 void setNonDirectionalSelectionIfNeeded( |
268 const VisibleSelectionInFlatTree&, | 276 const VisibleSelectionInFlatTree&, |
269 TextGranularity, | 277 TextGranularity, |
270 EndPointsAdjustmentMode = DoNotAdjustEndpoints); | 278 EndPointsAdjustmentMode = DoNotAdjustEndpoints, |
| 279 const HandleVisibility& = HandleVisibility::NotVisible); |
271 void setFocusedNodeIfNeeded(); | 280 void setFocusedNodeIfNeeded(); |
272 void notifyLayoutObjectOfSelectionChange(EUserTriggered); | 281 void notifyLayoutObjectOfSelectionChange(EUserTriggered); |
273 | 282 |
274 EditingStyle* typingStyle() const; | 283 EditingStyle* typingStyle() const; |
275 void setTypingStyle(EditingStyle*); | 284 void setTypingStyle(EditingStyle*); |
276 void clearTypingStyle(); | 285 void clearTypingStyle(); |
277 | 286 |
278 String selectedHTMLForClipboard() const; | 287 String selectedHTMLForClipboard() const; |
279 String selectedText(TextIteratorBehavior = TextIteratorDefaultBehavior) const; | 288 String selectedText(TextIteratorBehavior = TextIteratorDefaultBehavior) const; |
280 String selectedTextForClipboard() const; | 289 String selectedTextForClipboard() const; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 | 371 |
363 // Used to store base before the adjustment at bidi boundary | 372 // Used to store base before the adjustment at bidi boundary |
364 VisiblePositionInFlatTree m_originalBaseInFlatTree; | 373 VisiblePositionInFlatTree m_originalBaseInFlatTree; |
365 TextGranularity m_granularity; | 374 TextGranularity m_granularity; |
366 LayoutUnit m_xPosForVerticalArrowNavigation; | 375 LayoutUnit m_xPosForVerticalArrowNavigation; |
367 | 376 |
368 Member<EditingStyle> m_typingStyle; | 377 Member<EditingStyle> m_typingStyle; |
369 | 378 |
370 bool m_focused : 1; | 379 bool m_focused : 1; |
371 | 380 |
| 381 HandleVisibility m_handleVisibility; |
| 382 |
372 // Controls text granularity used to adjust the selection's extent in | 383 // Controls text granularity used to adjust the selection's extent in |
373 // moveRangeSelectionExtent. | 384 // moveRangeSelectionExtent. |
374 std::unique_ptr<GranularityStrategy> m_granularityStrategy; | 385 std::unique_ptr<GranularityStrategy> m_granularityStrategy; |
375 | 386 |
376 const Member<FrameCaret> m_frameCaret; | 387 const Member<FrameCaret> m_frameCaret; |
377 }; | 388 }; |
378 | 389 |
379 inline EditingStyle* FrameSelection::typingStyle() const { | 390 inline EditingStyle* FrameSelection::typingStyle() const { |
380 return m_typingStyle.get(); | 391 return m_typingStyle.get(); |
381 } | 392 } |
382 | 393 |
383 inline void FrameSelection::clearTypingStyle() { | 394 inline void FrameSelection::clearTypingStyle() { |
384 m_typingStyle.clear(); | 395 m_typingStyle.clear(); |
385 } | 396 } |
386 | 397 |
387 inline void FrameSelection::setTypingStyle(EditingStyle* style) { | 398 inline void FrameSelection::setTypingStyle(EditingStyle* style) { |
388 m_typingStyle = style; | 399 m_typingStyle = style; |
389 } | 400 } |
390 } // namespace blink | 401 } // namespace blink |
391 | 402 |
392 #ifndef NDEBUG | 403 #ifndef NDEBUG |
393 // Outside the WebCore namespace for ease of invocation from gdb. | 404 // Outside the WebCore namespace for ease of invocation from gdb. |
394 void showTree(const blink::FrameSelection&); | 405 void showTree(const blink::FrameSelection&); |
395 void showTree(const blink::FrameSelection*); | 406 void showTree(const blink::FrameSelection*); |
396 #endif | 407 #endif |
397 | 408 |
398 #endif // FrameSelection_h | 409 #endif // FrameSelection_h |
OLD | NEW |