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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 DoNotUpdateAppearance = 1 << 4, | 86 DoNotUpdateAppearance = 1 << 4, |
87 DoNotClearStrategy = 1 << 5, | 87 DoNotClearStrategy = 1 << 5, |
88 DoNotAdjustInFlatTree = 1 << 6, | 88 DoNotAdjustInFlatTree = 1 << 6, |
89 }; | 89 }; |
90 typedef unsigned SetSelectionOptions; // Union of values in SetSelectionOpti
on and EUserTriggered | 90 typedef unsigned SetSelectionOptions; // Union of values in SetSelectionOpti
on and EUserTriggered |
91 static inline EUserTriggered selectionOptionsToUserTriggered(SetSelectionOpt
ions options) | 91 static inline EUserTriggered selectionOptionsToUserTriggered(SetSelectionOpt
ions options) |
92 { | 92 { |
93 return static_cast<EUserTriggered>(options & UserTriggered); | 93 return static_cast<EUserTriggered>(options & UserTriggered); |
94 } | 94 } |
95 | 95 |
| 96 bool isAvailable() const { return m_document; } |
| 97 // You should not call |document()| when |!isAvailable()|. |
| 98 const Document& document() const; |
| 99 Document& document(); |
96 LocalFrame* frame() const { return m_frame; } | 100 LocalFrame* frame() const { return m_frame; } |
97 Element* rootEditableElement() const { return selection().rootEditableElemen
t(); } | 101 Element* rootEditableElement() const { return selection().rootEditableElemen
t(); } |
98 Element* rootEditableElementOrDocumentElement() const; | 102 Element* rootEditableElementOrDocumentElement() const; |
99 ContainerNode* rootEditableElementOrTreeScopeRootNode() const; | 103 ContainerNode* rootEditableElementOrTreeScopeRootNode() const; |
100 | 104 |
101 bool hasEditableStyle() const { return selection().hasEditableStyle(); } | 105 bool hasEditableStyle() const { return selection().hasEditableStyle(); } |
102 bool isContentEditable() const { return selection().isContentEditable(); } | 106 bool isContentEditable() const { return selection().isContentEditable(); } |
103 bool isContentRichlyEditable() const { return selection().isContentRichlyEdi
table(); } | 107 bool isContentRichlyEditable() const { return selection().isContentRichlyEdi
table(); } |
104 | 108 |
105 void moveTo(const VisiblePosition&, EUserTriggered = NotUserTriggered, Curso
rAlignOnScroll = CursorAlignOnScroll::IfNeeded); | 109 void moveTo(const VisiblePosition&, EUserTriggered = NotUserTriggered, Curso
rAlignOnScroll = CursorAlignOnScroll::IfNeeded); |
106 void moveTo(const VisiblePosition&, const VisiblePosition&, EUserTriggered =
NotUserTriggered); | 110 void moveTo(const VisiblePosition&, const VisiblePosition&, EUserTriggered =
NotUserTriggered); |
107 void moveTo(const Position&, TextAffinity); | 111 void moveTo(const Position&, TextAffinity); |
108 | 112 |
109 template <typename Strategy> | 113 template <typename Strategy> |
110 const VisibleSelectionTemplate<Strategy>& visibleSelection() const; | 114 const VisibleSelectionTemplate<Strategy>& visibleSelection() const; |
111 | 115 |
112 const VisibleSelection& selection() const; | 116 const VisibleSelection& selection() const; |
113 void setSelection(const VisibleSelection&, SetSelectionOptions = CloseTyping
| ClearTypingStyle, CursorAlignOnScroll = CursorAlignOnScroll::IfNeeded, TextGr
anularity = CharacterGranularity); | 117 void setSelection(const VisibleSelection&, SetSelectionOptions = CloseTyping
| ClearTypingStyle, CursorAlignOnScroll = CursorAlignOnScroll::IfNeeded, TextGr
anularity = CharacterGranularity); |
114 void setSelection(const VisibleSelectionInFlatTree&, SetSelectionOptions = C
loseTyping | ClearTypingStyle, CursorAlignOnScroll = CursorAlignOnScroll::IfNeed
ed, TextGranularity = CharacterGranularity); | 118 void setSelection(const VisibleSelectionInFlatTree&, SetSelectionOptions = C
loseTyping | ClearTypingStyle, CursorAlignOnScroll = CursorAlignOnScroll::IfNeed
ed, TextGranularity = CharacterGranularity); |
115 // TODO(yosin) We should get rid of two parameters version of | 119 // TODO(yosin) We should get rid of two parameters version of |
116 // |setSelection()| to avoid conflict of four parameters version. | 120 // |setSelection()| to avoid conflict of four parameters version. |
117 void setSelection(const VisibleSelection& selection, TextGranularity granula
rity) { setSelection(selection, CloseTyping | ClearTypingStyle, CursorAlignOnScr
oll::IfNeeded, granularity); } | 121 void setSelection(const VisibleSelection& selection, TextGranularity granula
rity) { setSelection(selection, CloseTyping | ClearTypingStyle, CursorAlignOnScr
oll::IfNeeded, granularity); } |
118 // TODO(yosin) We should get rid of |Range| version of |setSelectedRagne()| | 122 // TODO(yosin) We should get rid of |Range| version of |setSelectedRagne()| |
119 // for Oilpan. | 123 // for Oilpan. |
120 bool setSelectedRange(Range*, TextAffinity, SelectionDirectionalMode = Selec
tionDirectionalMode::NonDirectional, SetSelectionOptions = CloseTyping | ClearTy
pingStyle); | 124 bool setSelectedRange(Range*, TextAffinity, SelectionDirectionalMode = Selec
tionDirectionalMode::NonDirectional, SetSelectionOptions = CloseTyping | ClearTy
pingStyle); |
121 bool setSelectedRange(const EphemeralRange&, TextAffinity, SelectionDirectio
nalMode = SelectionDirectionalMode::NonDirectional, FrameSelection::SetSelection
Options = CloseTyping | ClearTypingStyle); | 125 bool setSelectedRange(const EphemeralRange&, TextAffinity, SelectionDirectio
nalMode = SelectionDirectionalMode::NonDirectional, FrameSelection::SetSelection
Options = CloseTyping | ClearTypingStyle); |
122 void selectAll(); | 126 void selectAll(); |
123 void clear(); | 127 void clear(); |
124 void prepareForDestruction(); | |
125 | 128 |
126 // Call this after doing user-triggered selections to make it easy to delete
the frame you entirely selected. | 129 // Call this after doing user-triggered selections to make it easy to delete
the frame you entirely selected. |
127 void selectFrameElementInParentIfFullySelected(); | 130 void selectFrameElementInParentIfFullySelected(); |
128 | 131 |
129 bool contains(const LayoutPoint&); | 132 bool contains(const LayoutPoint&); |
130 | 133 |
131 SelectionType getSelectionType() const { return selection().getSelectionType
(); } | 134 SelectionType getSelectionType() const { return selection().getSelectionType
(); } |
132 | 135 |
133 TextAffinity affinity() const { return selection().affinity(); } | 136 TextAffinity affinity() const { return selection().affinity(); } |
134 | 137 |
(...skipping 26 matching lines...) Expand all Loading... |
161 bool isNone() const { return selection().isNone(); } | 164 bool isNone() const { return selection().isNone(); } |
162 bool isCaret() const { return selection().isCaret(); } | 165 bool isCaret() const { return selection().isCaret(); } |
163 bool isRange() const { return selection().isRange(); } | 166 bool isRange() const { return selection().isRange(); } |
164 bool isInPasswordField() const; | 167 bool isInPasswordField() const; |
165 bool isDirectional() const { return selection().isDirectional(); } | 168 bool isDirectional() const { return selection().isDirectional(); } |
166 | 169 |
167 // If this FrameSelection has a logical range which is still valid, this fun
ction return its clone. Otherwise, | 170 // If this FrameSelection has a logical range which is still valid, this fun
ction return its clone. Otherwise, |
168 // the return value from underlying VisibleSelection's firstRange() is retur
ned. | 171 // the return value from underlying VisibleSelection's firstRange() is retur
ned. |
169 Range* firstRange() const; | 172 Range* firstRange() const; |
170 | 173 |
| 174 void documentAttached(Document*); |
| 175 void documentDetached(const Document&); |
171 void nodeWillBeRemoved(Node&); | 176 void nodeWillBeRemoved(Node&); |
172 void dataWillChange(const CharacterData& node); | 177 void dataWillChange(const CharacterData& node); |
173 void didUpdateCharacterData(CharacterData*, unsigned offset, unsigned oldLen
gth, unsigned newLength); | 178 void didUpdateCharacterData(CharacterData*, unsigned offset, unsigned oldLen
gth, unsigned newLength); |
174 void didMergeTextNodes(const Text& oldNode, unsigned offset); | 179 void didMergeTextNodes(const Text& oldNode, unsigned offset); |
175 void didSplitTextNode(const Text& oldNode); | 180 void didSplitTextNode(const Text& oldNode); |
176 | 181 |
177 bool isAppearanceDirty() const; | 182 bool isAppearanceDirty() const; |
178 void commitAppearanceIfNeeded(LayoutView&); | 183 void commitAppearanceIfNeeded(LayoutView&); |
179 void updateAppearance(); | 184 void updateAppearance(); |
180 void setCaretVisible(bool caretIsVisible); | 185 void setCaretVisible(bool caretIsVisible); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 278 |
274 template <typename Strategy> | 279 template <typename Strategy> |
275 VisibleSelectionTemplate<Strategy> validateSelection(const VisibleSelectionT
emplate<Strategy>&); | 280 VisibleSelectionTemplate<Strategy> validateSelection(const VisibleSelectionT
emplate<Strategy>&); |
276 | 281 |
277 GranularityStrategy* granularityStrategy(); | 282 GranularityStrategy* granularityStrategy(); |
278 | 283 |
279 // For unittests | 284 // For unittests |
280 bool shouldPaintCaretForTesting() const; | 285 bool shouldPaintCaretForTesting() const; |
281 bool isPreviousCaretDirtyForTesting() const; | 286 bool isPreviousCaretDirtyForTesting() const; |
282 | 287 |
| 288 Member<Document> m_document; |
283 Member<LocalFrame> m_frame; | 289 Member<LocalFrame> m_frame; |
284 const Member<PendingSelection> m_pendingSelection; | 290 const Member<PendingSelection> m_pendingSelection; |
285 const Member<SelectionEditor> m_selectionEditor; | 291 const Member<SelectionEditor> m_selectionEditor; |
286 | 292 |
287 // Used to store base before the adjustment at bidi boundary | 293 // Used to store base before the adjustment at bidi boundary |
288 VisiblePosition m_originalBase; | 294 VisiblePosition m_originalBase; |
289 VisiblePositionInFlatTree m_originalBaseInFlatTree; | 295 VisiblePositionInFlatTree m_originalBaseInFlatTree; |
290 TextGranularity m_granularity; | 296 TextGranularity m_granularity; |
291 LayoutUnit m_xPosForVerticalArrowNavigation; | 297 LayoutUnit m_xPosForVerticalArrowNavigation; |
292 | 298 |
(...skipping 23 matching lines...) Expand all Loading... |
316 } | 322 } |
317 } // namespace blink | 323 } // namespace blink |
318 | 324 |
319 #ifndef NDEBUG | 325 #ifndef NDEBUG |
320 // Outside the WebCore namespace for ease of invocation from gdb. | 326 // Outside the WebCore namespace for ease of invocation from gdb. |
321 void showTree(const blink::FrameSelection&); | 327 void showTree(const blink::FrameSelection&); |
322 void showTree(const blink::FrameSelection*); | 328 void showTree(const blink::FrameSelection*); |
323 #endif | 329 #endif |
324 | 330 |
325 #endif // FrameSelection_h | 331 #endif // FrameSelection_h |
OLD | NEW |