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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 76 |
77 enum EAlteration { AlterationMove, AlterationExtend }; | 77 enum EAlteration { AlterationMove, AlterationExtend }; |
78 enum SetSelectionOption { | 78 enum SetSelectionOption { |
79 // 1 << 0 is reserved for EUserTriggered | 79 // 1 << 0 is reserved for EUserTriggered |
80 CloseTyping = 1 << 1, | 80 CloseTyping = 1 << 1, |
81 ClearTypingStyle = 1 << 2, | 81 ClearTypingStyle = 1 << 2, |
82 SpellCorrectionTriggered = 1 << 3, | 82 SpellCorrectionTriggered = 1 << 3, |
83 DoNotSetFocus = 1 << 4, | 83 DoNotSetFocus = 1 << 4, |
84 DoNotUpdateAppearance = 1 << 5, | 84 DoNotUpdateAppearance = 1 << 5, |
85 DoNotClearStrategy = 1 << 6, | 85 DoNotClearStrategy = 1 << 6, |
86 DoNotAdjustInComposedTree = 1 << 7, | 86 DoNotAdjustInFlatTree = 1 << 7, |
87 }; | 87 }; |
88 typedef unsigned SetSelectionOptions; // Union of values in SetSelectionOpti
on and EUserTriggered | 88 typedef unsigned SetSelectionOptions; // Union of values in SetSelectionOpti
on and EUserTriggered |
89 static inline EUserTriggered selectionOptionsToUserTriggered(SetSelectionOpt
ions options) | 89 static inline EUserTriggered selectionOptionsToUserTriggered(SetSelectionOpt
ions options) |
90 { | 90 { |
91 return static_cast<EUserTriggered>(options & UserTriggered); | 91 return static_cast<EUserTriggered>(options & UserTriggered); |
92 } | 92 } |
93 | 93 |
94 LocalFrame* frame() const { return m_frame; } | 94 LocalFrame* frame() const { return m_frame; } |
95 Element* rootEditableElement() const { return selection().rootEditableElemen
t(); } | 95 Element* rootEditableElement() const { return selection().rootEditableElemen
t(); } |
96 Element* rootEditableElementOrDocumentElement() const; | 96 Element* rootEditableElementOrDocumentElement() const; |
97 ContainerNode* rootEditableElementOrTreeScopeRootNode() const; | 97 ContainerNode* rootEditableElementOrTreeScopeRootNode() const; |
98 | 98 |
99 bool hasEditableStyle() const { return selection().hasEditableStyle(); } | 99 bool hasEditableStyle() const { return selection().hasEditableStyle(); } |
100 bool isContentEditable() const { return selection().isContentEditable(); } | 100 bool isContentEditable() const { return selection().isContentEditable(); } |
101 bool isContentRichlyEditable() const { return selection().isContentRichlyEdi
table(); } | 101 bool isContentRichlyEditable() const { return selection().isContentRichlyEdi
table(); } |
102 | 102 |
103 void moveTo(const VisiblePosition&, EUserTriggered = NotUserTriggered, Curso
rAlignOnScroll = CursorAlignOnScroll::IfNeeded); | 103 void moveTo(const VisiblePosition&, EUserTriggered = NotUserTriggered, Curso
rAlignOnScroll = CursorAlignOnScroll::IfNeeded); |
104 void moveTo(const VisiblePosition&, const VisiblePosition&, EUserTriggered =
NotUserTriggered); | 104 void moveTo(const VisiblePosition&, const VisiblePosition&, EUserTriggered =
NotUserTriggered); |
105 void moveTo(const Position&, TextAffinity, EUserTriggered = NotUserTriggered
); | 105 void moveTo(const Position&, TextAffinity, EUserTriggered = NotUserTriggered
); |
106 | 106 |
107 template <typename Strategy> | 107 template <typename Strategy> |
108 const VisibleSelectionTemplate<Strategy>& visibleSelection() const; | 108 const VisibleSelectionTemplate<Strategy>& visibleSelection() const; |
109 | 109 |
110 const VisibleSelection& selection() const; | 110 const VisibleSelection& selection() const; |
111 void setSelection(const VisibleSelection&, SetSelectionOptions = CloseTyping
| ClearTypingStyle, CursorAlignOnScroll = CursorAlignOnScroll::IfNeeded, TextGr
anularity = CharacterGranularity); | 111 void setSelection(const VisibleSelection&, SetSelectionOptions = CloseTyping
| ClearTypingStyle, CursorAlignOnScroll = CursorAlignOnScroll::IfNeeded, TextGr
anularity = CharacterGranularity); |
112 void setSelection(const VisibleSelectionInComposedTree&, SetSelectionOptions
= CloseTyping | ClearTypingStyle, CursorAlignOnScroll = CursorAlignOnScroll::If
Needed, TextGranularity = CharacterGranularity); | 112 void setSelection(const VisibleSelectionInFlatTree&, SetSelectionOptions = C
loseTyping | ClearTypingStyle, CursorAlignOnScroll = CursorAlignOnScroll::IfNeed
ed, TextGranularity = CharacterGranularity); |
113 // TODO(yosin) We should get rid of two parameters version of | 113 // TODO(yosin) We should get rid of two parameters version of |
114 // |setSelection()| to avoid conflict of four parameters version. | 114 // |setSelection()| to avoid conflict of four parameters version. |
115 void setSelection(const VisibleSelection& selection, TextGranularity granula
rity) { setSelection(selection, CloseTyping | ClearTypingStyle, CursorAlignOnScr
oll::IfNeeded, granularity); } | 115 void setSelection(const VisibleSelection& selection, TextGranularity granula
rity) { setSelection(selection, CloseTyping | ClearTypingStyle, CursorAlignOnScr
oll::IfNeeded, granularity); } |
116 void setSelection(const VisibleSelectionInComposedTree& selection, TextGranu
larity granularity) { setSelection(selection, CloseTyping | ClearTypingStyle, Cu
rsorAlignOnScroll::IfNeeded, granularity); } | 116 void setSelection(const VisibleSelectionInFlatTree& selection, TextGranulari
ty granularity) { setSelection(selection, CloseTyping | ClearTypingStyle, Cursor
AlignOnScroll::IfNeeded, granularity); } |
117 // TODO(yosin) We should get rid of |Range| version of |setSelectedRagne()| | 117 // TODO(yosin) We should get rid of |Range| version of |setSelectedRagne()| |
118 // for Oilpan. | 118 // for Oilpan. |
119 bool setSelectedRange(Range*, TextAffinity, SelectionDirectionalMode = Selec
tionDirectionalMode::NonDirectional, SetSelectionOptions = CloseTyping | ClearTy
pingStyle); | 119 bool setSelectedRange(Range*, TextAffinity, SelectionDirectionalMode = Selec
tionDirectionalMode::NonDirectional, SetSelectionOptions = CloseTyping | ClearTy
pingStyle); |
120 bool setSelectedRange(const EphemeralRange&, TextAffinity, SelectionDirectio
nalMode = SelectionDirectionalMode::NonDirectional, FrameSelection::SetSelection
Options = CloseTyping | ClearTypingStyle); | 120 bool setSelectedRange(const EphemeralRange&, TextAffinity, SelectionDirectio
nalMode = SelectionDirectionalMode::NonDirectional, FrameSelection::SetSelection
Options = CloseTyping | ClearTypingStyle); |
121 void selectAll(); | 121 void selectAll(); |
122 void clear(); | 122 void clear(); |
123 void prepareForDestruction(); | 123 void prepareForDestruction(); |
124 | 124 |
125 // Call this after doing user-triggered selections to make it easy to delete
the frame you entirely selected. | 125 // Call this after doing user-triggered selections to make it easy to delete
the frame you entirely selected. |
126 void selectFrameElementInParentIfFullySelected(); | 126 void selectFrameElementInParentIfFullySelected(); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 // Returns true if a word is selected. | 205 // Returns true if a word is selected. |
206 bool selectWordAroundPosition(const VisiblePosition&); | 206 bool selectWordAroundPosition(const VisiblePosition&); |
207 | 207 |
208 #ifndef NDEBUG | 208 #ifndef NDEBUG |
209 void formatForDebugger(char* buffer, unsigned length) const; | 209 void formatForDebugger(char* buffer, unsigned length) const; |
210 void showTreeForThis() const; | 210 void showTreeForThis() const; |
211 #endif | 211 #endif |
212 | 212 |
213 enum EndPointsAdjustmentMode { AdjustEndpointsAtBidiBoundary, DoNotAdjsutEnd
points }; | 213 enum EndPointsAdjustmentMode { AdjustEndpointsAtBidiBoundary, DoNotAdjsutEnd
points }; |
214 void setNonDirectionalSelectionIfNeeded(const VisibleSelection&, TextGranula
rity, EndPointsAdjustmentMode = DoNotAdjsutEndpoints); | 214 void setNonDirectionalSelectionIfNeeded(const VisibleSelection&, TextGranula
rity, EndPointsAdjustmentMode = DoNotAdjsutEndpoints); |
215 void setNonDirectionalSelectionIfNeeded(const VisibleSelectionInComposedTree
&, TextGranularity, EndPointsAdjustmentMode = DoNotAdjsutEndpoints); | 215 void setNonDirectionalSelectionIfNeeded(const VisibleSelectionInFlatTree&, T
extGranularity, EndPointsAdjustmentMode = DoNotAdjsutEndpoints); |
216 void setFocusedNodeIfNeeded(); | 216 void setFocusedNodeIfNeeded(); |
217 void notifyLayoutObjectOfSelectionChange(EUserTriggered); | 217 void notifyLayoutObjectOfSelectionChange(EUserTriggered); |
218 | 218 |
219 EditingStyle* typingStyle() const; | 219 EditingStyle* typingStyle() const; |
220 void setTypingStyle(PassRefPtrWillBeRawPtr<EditingStyle>); | 220 void setTypingStyle(PassRefPtrWillBeRawPtr<EditingStyle>); |
221 void clearTypingStyle(); | 221 void clearTypingStyle(); |
222 | 222 |
223 String selectedHTMLForClipboard() const; | 223 String selectedHTMLForClipboard() const; |
224 String selectedText(TextIteratorBehavior = TextIteratorDefaultBehavior) cons
t; | 224 String selectedText(TextIteratorBehavior = TextIteratorDefaultBehavior) cons
t; |
225 String selectedTextForClipboard() const; | 225 String selectedTextForClipboard() const; |
(...skipping 16 matching lines...) Expand all Loading... |
242 // to use updated selection, we should make |updateIfNeeded()| private. | 242 // to use updated selection, we should make |updateIfNeeded()| private. |
243 void updateIfNeeded(); | 243 void updateIfNeeded(); |
244 | 244 |
245 DECLARE_VIRTUAL_TRACE(); | 245 DECLARE_VIRTUAL_TRACE(); |
246 | 246 |
247 private: | 247 private: |
248 friend class FrameSelectionTest; | 248 friend class FrameSelectionTest; |
249 | 249 |
250 explicit FrameSelection(LocalFrame*); | 250 explicit FrameSelection(LocalFrame*); |
251 | 251 |
252 // Note: We have |selectionInComposedTree()| for unit tests, we should | 252 // Note: We have |selectionInFlatTree()| for unit tests, we should |
253 // use |visibleSelection<EditingInComposedTreeStrategy>()|. | 253 // use |visibleSelection<EditingInFlatTreeStrategy>()|. |
254 const VisibleSelectionInComposedTree& selectionInComposedTree() const; | 254 const VisibleSelectionInFlatTree& selectionInFlatTree() const; |
255 | 255 |
256 template <typename Strategy> | 256 template <typename Strategy> |
257 VisiblePositionTemplate<Strategy> originalBase() const; | 257 VisiblePositionTemplate<Strategy> originalBase() const; |
258 void setOriginalBase(const VisiblePosition& newBase) { m_originalBase = newB
ase; } | 258 void setOriginalBase(const VisiblePosition& newBase) { m_originalBase = newB
ase; } |
259 void setOriginalBase(const VisiblePositionInComposedTree& newBase) { m_origi
nalBaseInComposedTree = newBase; } | 259 void setOriginalBase(const VisiblePositionInFlatTree& newBase) { m_originalB
aseInFlatTree = newBase; } |
260 | 260 |
261 template <typename Strategy> | 261 template <typename Strategy> |
262 bool containsAlgorithm(const LayoutPoint&); | 262 bool containsAlgorithm(const LayoutPoint&); |
263 | 263 |
264 template <typename Strategy> | 264 template <typename Strategy> |
265 void setNonDirectionalSelectionIfNeededAlgorithm(const VisibleSelectionTempl
ate<Strategy>&, TextGranularity, EndPointsAdjustmentMode); | 265 void setNonDirectionalSelectionIfNeededAlgorithm(const VisibleSelectionTempl
ate<Strategy>&, TextGranularity, EndPointsAdjustmentMode); |
266 | 266 |
267 template <typename Strategy> | 267 template <typename Strategy> |
268 void setSelectionAlgorithm(const VisibleSelectionTemplate<Strategy>&, SetSel
ectionOptions, CursorAlignOnScroll, TextGranularity); | 268 void setSelectionAlgorithm(const VisibleSelectionTemplate<Strategy>&, SetSel
ectionOptions, CursorAlignOnScroll, TextGranularity); |
269 | 269 |
(...skipping 19 matching lines...) Expand all Loading... |
289 VisibleSelectionTemplate<Strategy> validateSelection(const VisibleSelectionT
emplate<Strategy>&); | 289 VisibleSelectionTemplate<Strategy> validateSelection(const VisibleSelectionT
emplate<Strategy>&); |
290 | 290 |
291 GranularityStrategy* granularityStrategy(); | 291 GranularityStrategy* granularityStrategy(); |
292 | 292 |
293 RawPtrWillBeMember<LocalFrame> m_frame; | 293 RawPtrWillBeMember<LocalFrame> m_frame; |
294 const OwnPtrWillBeMember<PendingSelection> m_pendingSelection; | 294 const OwnPtrWillBeMember<PendingSelection> m_pendingSelection; |
295 const OwnPtrWillBeMember<SelectionEditor> m_selectionEditor; | 295 const OwnPtrWillBeMember<SelectionEditor> m_selectionEditor; |
296 | 296 |
297 // Used to store base before the adjustment at bidi boundary | 297 // Used to store base before the adjustment at bidi boundary |
298 VisiblePosition m_originalBase; | 298 VisiblePosition m_originalBase; |
299 VisiblePositionInComposedTree m_originalBaseInComposedTree; | 299 VisiblePositionInFlatTree m_originalBaseInFlatTree; |
300 TextGranularity m_granularity; | 300 TextGranularity m_granularity; |
301 | 301 |
302 RefPtrWillBeMember<Node> m_previousCaretNode; // The last node which painted
the caret. Retained for clearing the old caret when it moves. | 302 RefPtrWillBeMember<Node> m_previousCaretNode; // The last node which painted
the caret. Retained for clearing the old caret when it moves. |
303 LayoutRect m_previousCaretRect; | 303 LayoutRect m_previousCaretRect; |
304 CaretVisibility m_previousCaretVisibility; | 304 CaretVisibility m_previousCaretVisibility; |
305 | 305 |
306 RefPtrWillBeMember<EditingStyle> m_typingStyle; | 306 RefPtrWillBeMember<EditingStyle> m_typingStyle; |
307 | 307 |
308 Timer<FrameSelection> m_caretBlinkTimer; | 308 Timer<FrameSelection> m_caretBlinkTimer; |
309 | 309 |
(...skipping 23 matching lines...) Expand all Loading... |
333 } | 333 } |
334 } // namespace blink | 334 } // namespace blink |
335 | 335 |
336 #ifndef NDEBUG | 336 #ifndef NDEBUG |
337 // Outside the WebCore namespace for ease of invocation from gdb. | 337 // Outside the WebCore namespace for ease of invocation from gdb. |
338 void showTree(const blink::FrameSelection&); | 338 void showTree(const blink::FrameSelection&); |
339 void showTree(const blink::FrameSelection*); | 339 void showTree(const blink::FrameSelection*); |
340 #endif | 340 #endif |
341 | 341 |
342 #endif // FrameSelection_h | 342 #endif // FrameSelection_h |
OLD | NEW |