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

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

Issue 2201853002: Blink handle selection handle visibility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixing nits and context menu Created 4 years, 1 month 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 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
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 TextAffinity, 149 TextAffinity,
147 SelectionDirectionalMode = SelectionDirectionalMode::NonDirectional, 150 SelectionDirectionalMode = SelectionDirectionalMode::NonDirectional,
148 FrameSelection::SetSelectionOptions = CloseTyping | ClearTypingStyle); 151 FrameSelection::SetSelectionOptions = CloseTyping | ClearTypingStyle);
149 void selectAll(); 152 void selectAll();
150 void clear(); 153 void clear();
151 154
152 // Call this after doing user-triggered selections to make it easy to delete 155 // Call this after doing user-triggered selections to make it easy to delete
153 // the frame you entirely selected. 156 // the frame you entirely selected.
154 void selectFrameElementInParentIfFullySelected(); 157 void selectFrameElementInParentIfFullySelected();
155 158
159 bool contains(const HitTestResult&);
156 bool contains(const LayoutPoint&); 160 bool contains(const LayoutPoint&);
157 161
158 SelectionType getSelectionType() const { 162 SelectionType getSelectionType() const {
159 return selection().getSelectionType(); 163 return selection().getSelectionType();
160 } 164 }
161 165
162 TextAffinity affinity() const { return selection().affinity(); } 166 TextAffinity affinity() const { return selection().affinity(); }
163 167
164 bool modify(EAlteration, 168 bool modify(EAlteration,
165 SelectionDirection, 169 SelectionDirection,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // Used to suspend caret blinking while the mouse is down. 237 // Used to suspend caret blinking while the mouse is down.
234 void setCaretBlinkingSuspended(bool); 238 void setCaretBlinkingSuspended(bool);
235 bool isCaretBlinkingSuspended() const; 239 bool isCaretBlinkingSuspended() const;
236 240
237 // Focus 241 // Focus
238 void setFocused(bool); 242 void setFocused(bool);
239 bool isFocused() const { return m_focused; } 243 bool isFocused() const { return m_focused; }
240 bool isFocusedAndActive() const; 244 bool isFocusedAndActive() const;
241 void pageActivationChanged(); 245 void pageActivationChanged();
242 246
247 bool isHandleVisible() const {
248 return m_handleVisibility == HandleVisibility::Visible;
249 }
250
243 void updateSecureKeyboardEntryIfActive(); 251 void updateSecureKeyboardEntryIfActive();
244 252
245 // Returns true if a word is selected. 253 // Returns true if a word is selected.
246 bool selectWordAroundPosition(const VisiblePosition&); 254 bool selectWordAroundPosition(const VisiblePosition&);
247 255
248 #ifndef NDEBUG 256 #ifndef NDEBUG
249 void showTreeForThis() const; 257 void showTreeForThis() const;
250 #endif 258 #endif
251 259
252 enum EndPointsAdjustmentMode { 260 enum EndPointsAdjustmentMode {
253 AdjustEndpointsAtBidiBoundary, 261 AdjustEndpointsAtBidiBoundary,
254 DoNotAdjustEndpoints 262 DoNotAdjustEndpoints
255 }; 263 };
256 void setNonDirectionalSelectionIfNeeded( 264 void setNonDirectionalSelectionIfNeeded(
257 const VisibleSelectionInFlatTree&, 265 const VisibleSelectionInFlatTree&,
258 TextGranularity, 266 TextGranularity,
259 EndPointsAdjustmentMode = DoNotAdjustEndpoints); 267 EndPointsAdjustmentMode = DoNotAdjustEndpoints,
268 HandleVisibility = HandleVisibility::NotVisible);
260 void setFocusedNodeIfNeeded(); 269 void setFocusedNodeIfNeeded();
261 void notifyLayoutObjectOfSelectionChange(EUserTriggered); 270 void notifyLayoutObjectOfSelectionChange(EUserTriggered);
262 271
263 EditingStyle* typingStyle() const; 272 EditingStyle* typingStyle() const;
264 void setTypingStyle(EditingStyle*); 273 void setTypingStyle(EditingStyle*);
265 void clearTypingStyle(); 274 void clearTypingStyle();
266 275
267 String selectedHTMLForClipboard() const; 276 String selectedHTMLForClipboard() const;
268 String selectedText(TextIteratorBehavior = TextIteratorDefaultBehavior) const; 277 String selectedText(TextIteratorBehavior = TextIteratorDefaultBehavior) const;
269 String selectedTextForClipboard() const; 278 String selectedTextForClipboard() const;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 356
348 // Used to store base before the adjustment at bidi boundary 357 // Used to store base before the adjustment at bidi boundary
349 VisiblePositionInFlatTree m_originalBaseInFlatTree; 358 VisiblePositionInFlatTree m_originalBaseInFlatTree;
350 TextGranularity m_granularity; 359 TextGranularity m_granularity;
351 LayoutUnit m_xPosForVerticalArrowNavigation; 360 LayoutUnit m_xPosForVerticalArrowNavigation;
352 361
353 Member<EditingStyle> m_typingStyle; 362 Member<EditingStyle> m_typingStyle;
354 363
355 bool m_focused : 1; 364 bool m_focused : 1;
356 365
366 HandleVisibility m_handleVisibility = HandleVisibility::NotVisible;
367
357 // Controls text granularity used to adjust the selection's extent in 368 // Controls text granularity used to adjust the selection's extent in
358 // moveRangeSelectionExtent. 369 // moveRangeSelectionExtent.
359 std::unique_ptr<GranularityStrategy> m_granularityStrategy; 370 std::unique_ptr<GranularityStrategy> m_granularityStrategy;
360 371
361 const Member<FrameCaret> m_frameCaret; 372 const Member<FrameCaret> m_frameCaret;
362 }; 373 };
363 374
364 inline EditingStyle* FrameSelection::typingStyle() const { 375 inline EditingStyle* FrameSelection::typingStyle() const {
365 return m_typingStyle.get(); 376 return m_typingStyle.get();
366 } 377 }
367 378
368 inline void FrameSelection::clearTypingStyle() { 379 inline void FrameSelection::clearTypingStyle() {
369 m_typingStyle.clear(); 380 m_typingStyle.clear();
370 } 381 }
371 382
372 inline void FrameSelection::setTypingStyle(EditingStyle* style) { 383 inline void FrameSelection::setTypingStyle(EditingStyle* style) {
373 m_typingStyle = style; 384 m_typingStyle = style;
374 } 385 }
375 } // namespace blink 386 } // namespace blink
376 387
377 #ifndef NDEBUG 388 #ifndef NDEBUG
378 // Outside the WebCore namespace for ease of invocation from gdb. 389 // Outside the WebCore namespace for ease of invocation from gdb.
379 void showTree(const blink::FrameSelection&); 390 void showTree(const blink::FrameSelection&);
380 void showTree(const blink::FrameSelection*); 391 void showTree(const blink::FrameSelection*);
381 #endif 392 #endif
382 393
383 #endif // FrameSelection_h 394 #endif // FrameSelection_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698