| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 enum EUserTriggered { NotUserTriggered = 0, UserTriggered = 1 }; | 58 enum EUserTriggered { NotUserTriggered = 0, UserTriggered = 1 }; |
| 59 | 59 |
| 60 enum RevealExtentOption { | 60 enum RevealExtentOption { |
| 61 RevealExtent, | 61 RevealExtent, |
| 62 DoNotRevealExtent | 62 DoNotRevealExtent |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 enum class SelectionDirectionalMode { NonDirectional, Directional }; | 65 enum class SelectionDirectionalMode { NonDirectional, Directional }; |
| 66 | 66 |
| 67 class CORE_EXPORT FrameSelection final : public NoBaseWillBeGarbageCollectedFina
lized<FrameSelection>, private CaretBase { | 67 class CORE_EXPORT FrameSelection final : public GarbageCollectedFinalized<FrameS
election>, private CaretBase { |
| 68 WTF_MAKE_NONCOPYABLE(FrameSelection); | 68 WTF_MAKE_NONCOPYABLE(FrameSelection); |
| 69 USING_FAST_MALLOC_WILL_BE_REMOVED(FrameSelection); | |
| 70 public: | 69 public: |
| 71 static PassOwnPtrWillBeRawPtr<FrameSelection> create(LocalFrame* frame = nul
lptr) | 70 static RawPtr<FrameSelection> create(LocalFrame* frame = nullptr) |
| 72 { | 71 { |
| 73 return adoptPtrWillBeNoop(new FrameSelection(frame)); | 72 return (new FrameSelection(frame)); |
| 74 } | 73 } |
| 75 ~FrameSelection(); | 74 ~FrameSelection(); |
| 76 | 75 |
| 77 enum EAlteration { AlterationMove, AlterationExtend }; | 76 enum EAlteration { AlterationMove, AlterationExtend }; |
| 78 enum SetSelectionOption { | 77 enum SetSelectionOption { |
| 79 // 1 << 0 is reserved for EUserTriggered | 78 // 1 << 0 is reserved for EUserTriggered |
| 80 CloseTyping = 1 << 1, | 79 CloseTyping = 1 << 1, |
| 81 ClearTypingStyle = 1 << 2, | 80 ClearTypingStyle = 1 << 2, |
| 82 SpellCorrectionTriggered = 1 << 3, | 81 SpellCorrectionTriggered = 1 << 3, |
| 83 DoNotSetFocus = 1 << 4, | 82 DoNotSetFocus = 1 << 4, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 164 |
| 166 bool isNone() const { return selection().isNone(); } | 165 bool isNone() const { return selection().isNone(); } |
| 167 bool isCaret() const { return selection().isCaret(); } | 166 bool isCaret() const { return selection().isCaret(); } |
| 168 bool isRange() const { return selection().isRange(); } | 167 bool isRange() const { return selection().isRange(); } |
| 169 bool isCaretOrRange() const { return selection().isCaretOrRange(); } | 168 bool isCaretOrRange() const { return selection().isCaretOrRange(); } |
| 170 bool isInPasswordField() const; | 169 bool isInPasswordField() const; |
| 171 bool isDirectional() const { return selection().isDirectional(); } | 170 bool isDirectional() const { return selection().isDirectional(); } |
| 172 | 171 |
| 173 // If this FrameSelection has a logical range which is still valid, this fun
ction return its clone. Otherwise, | 172 // If this FrameSelection has a logical range which is still valid, this fun
ction return its clone. Otherwise, |
| 174 // the return value from underlying VisibleSelection's firstRange() is retur
ned. | 173 // the return value from underlying VisibleSelection's firstRange() is retur
ned. |
| 175 PassRefPtrWillBeRawPtr<Range> firstRange() const; | 174 RawPtr<Range> firstRange() const; |
| 176 | 175 |
| 177 void nodeWillBeRemoved(Node&); | 176 void nodeWillBeRemoved(Node&); |
| 178 void didUpdateCharacterData(CharacterData*, unsigned offset, unsigned oldLen
gth, unsigned newLength); | 177 void didUpdateCharacterData(CharacterData*, unsigned offset, unsigned oldLen
gth, unsigned newLength); |
| 179 void didMergeTextNodes(const Text& oldNode, unsigned offset); | 178 void didMergeTextNodes(const Text& oldNode, unsigned offset); |
| 180 void didSplitTextNode(const Text& oldNode); | 179 void didSplitTextNode(const Text& oldNode); |
| 181 | 180 |
| 182 bool isAppearanceDirty() const; | 181 bool isAppearanceDirty() const; |
| 183 void commitAppearanceIfNeeded(LayoutView&); | 182 void commitAppearanceIfNeeded(LayoutView&); |
| 184 void updateAppearance(); | 183 void updateAppearance(); |
| 185 void setCaretVisible(bool caretIsVisible) { setCaretVisibility(caretIsVisibl
e ? Visible : Hidden); } | 184 void setCaretVisible(bool caretIsVisible) { setCaretVisibility(caretIsVisibl
e ? Visible : Hidden); } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 210 void showTreeForThis() const; | 209 void showTreeForThis() const; |
| 211 #endif | 210 #endif |
| 212 | 211 |
| 213 enum EndPointsAdjustmentMode { AdjustEndpointsAtBidiBoundary, DoNotAdjsutEnd
points }; | 212 enum EndPointsAdjustmentMode { AdjustEndpointsAtBidiBoundary, DoNotAdjsutEnd
points }; |
| 214 void setNonDirectionalSelectionIfNeeded(const VisibleSelection&, TextGranula
rity, EndPointsAdjustmentMode = DoNotAdjsutEndpoints); | 213 void setNonDirectionalSelectionIfNeeded(const VisibleSelection&, TextGranula
rity, EndPointsAdjustmentMode = DoNotAdjsutEndpoints); |
| 215 void setNonDirectionalSelectionIfNeeded(const VisibleSelectionInFlatTree&, T
extGranularity, EndPointsAdjustmentMode = DoNotAdjsutEndpoints); | 214 void setNonDirectionalSelectionIfNeeded(const VisibleSelectionInFlatTree&, T
extGranularity, EndPointsAdjustmentMode = DoNotAdjsutEndpoints); |
| 216 void setFocusedNodeIfNeeded(); | 215 void setFocusedNodeIfNeeded(); |
| 217 void notifyLayoutObjectOfSelectionChange(EUserTriggered); | 216 void notifyLayoutObjectOfSelectionChange(EUserTriggered); |
| 218 | 217 |
| 219 EditingStyle* typingStyle() const; | 218 EditingStyle* typingStyle() const; |
| 220 void setTypingStyle(PassRefPtrWillBeRawPtr<EditingStyle>); | 219 void setTypingStyle(RawPtr<EditingStyle>); |
| 221 void clearTypingStyle(); | 220 void clearTypingStyle(); |
| 222 | 221 |
| 223 String selectedHTMLForClipboard() const; | 222 String selectedHTMLForClipboard() const; |
| 224 String selectedText(TextIteratorBehavior = TextIteratorDefaultBehavior) cons
t; | 223 String selectedText(TextIteratorBehavior = TextIteratorDefaultBehavior) cons
t; |
| 225 String selectedTextForClipboard() const; | 224 String selectedTextForClipboard() const; |
| 226 | 225 |
| 227 // The bounds are clipped to the viewport as this is what callers expect. | 226 // The bounds are clipped to the viewport as this is what callers expect. |
| 228 LayoutRect bounds() const; | 227 LayoutRect bounds() const; |
| 229 LayoutRect unclippedBounds() const; | 228 LayoutRect unclippedBounds() const; |
| 230 | 229 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 void setCaretVisibility(CaretVisibility); | 282 void setCaretVisibility(CaretVisibility); |
| 284 bool shouldBlinkCaret() const; | 283 bool shouldBlinkCaret() const; |
| 285 | 284 |
| 286 void updateSelectionIfNeeded(const Position& base, const Position& extent, c
onst Position& start, const Position& end); | 285 void updateSelectionIfNeeded(const Position& base, const Position& extent, c
onst Position& start, const Position& end); |
| 287 | 286 |
| 288 template <typename Strategy> | 287 template <typename Strategy> |
| 289 VisibleSelectionTemplate<Strategy> validateSelection(const VisibleSelectionT
emplate<Strategy>&); | 288 VisibleSelectionTemplate<Strategy> validateSelection(const VisibleSelectionT
emplate<Strategy>&); |
| 290 | 289 |
| 291 GranularityStrategy* granularityStrategy(); | 290 GranularityStrategy* granularityStrategy(); |
| 292 | 291 |
| 293 RawPtrWillBeMember<LocalFrame> m_frame; | 292 Member<LocalFrame> m_frame; |
| 294 const OwnPtrWillBeMember<PendingSelection> m_pendingSelection; | 293 const Member<PendingSelection> m_pendingSelection; |
| 295 const OwnPtrWillBeMember<SelectionEditor> m_selectionEditor; | 294 const Member<SelectionEditor> m_selectionEditor; |
| 296 | 295 |
| 297 // Used to store base before the adjustment at bidi boundary | 296 // Used to store base before the adjustment at bidi boundary |
| 298 VisiblePosition m_originalBase; | 297 VisiblePosition m_originalBase; |
| 299 VisiblePositionInFlatTree m_originalBaseInFlatTree; | 298 VisiblePositionInFlatTree m_originalBaseInFlatTree; |
| 300 TextGranularity m_granularity; | 299 TextGranularity m_granularity; |
| 301 | 300 |
| 302 RefPtrWillBeMember<Node> m_previousCaretNode; // The last node which painted
the caret. Retained for clearing the old caret when it moves. | 301 Member<Node> m_previousCaretNode; // The last node which painted the caret.
Retained for clearing the old caret when it moves. |
| 303 LayoutRect m_previousCaretRect; | 302 LayoutRect m_previousCaretRect; |
| 304 CaretVisibility m_previousCaretVisibility; | 303 CaretVisibility m_previousCaretVisibility; |
| 305 | 304 |
| 306 RefPtrWillBeMember<EditingStyle> m_typingStyle; | 305 Member<EditingStyle> m_typingStyle; |
| 307 | 306 |
| 308 Timer<FrameSelection> m_caretBlinkTimer; | 307 Timer<FrameSelection> m_caretBlinkTimer; |
| 309 | 308 |
| 310 bool m_caretRectDirty : 1; | 309 bool m_caretRectDirty : 1; |
| 311 bool m_shouldPaintCaret : 1; | 310 bool m_shouldPaintCaret : 1; |
| 312 bool m_isCaretBlinkingSuspended : 1; | 311 bool m_isCaretBlinkingSuspended : 1; |
| 313 bool m_focused : 1; | 312 bool m_focused : 1; |
| 314 bool m_shouldShowBlockCursor : 1; | 313 bool m_shouldShowBlockCursor : 1; |
| 315 | 314 |
| 316 // Controls text granularity used to adjust the selection's extent in moveRa
ngeSelectionExtent. | 315 // Controls text granularity used to adjust the selection's extent in moveRa
ngeSelectionExtent. |
| 317 OwnPtr<GranularityStrategy> m_granularityStrategy; | 316 OwnPtr<GranularityStrategy> m_granularityStrategy; |
| 318 }; | 317 }; |
| 319 | 318 |
| 320 inline EditingStyle* FrameSelection::typingStyle() const | 319 inline EditingStyle* FrameSelection::typingStyle() const |
| 321 { | 320 { |
| 322 return m_typingStyle.get(); | 321 return m_typingStyle.get(); |
| 323 } | 322 } |
| 324 | 323 |
| 325 inline void FrameSelection::clearTypingStyle() | 324 inline void FrameSelection::clearTypingStyle() |
| 326 { | 325 { |
| 327 m_typingStyle.clear(); | 326 m_typingStyle.clear(); |
| 328 } | 327 } |
| 329 | 328 |
| 330 inline void FrameSelection::setTypingStyle(PassRefPtrWillBeRawPtr<EditingStyle>
style) | 329 inline void FrameSelection::setTypingStyle(RawPtr<EditingStyle> style) |
| 331 { | 330 { |
| 332 m_typingStyle = style; | 331 m_typingStyle = style; |
| 333 } | 332 } |
| 334 } // namespace blink | 333 } // namespace blink |
| 335 | 334 |
| 336 #ifndef NDEBUG | 335 #ifndef NDEBUG |
| 337 // Outside the WebCore namespace for ease of invocation from gdb. | 336 // Outside the WebCore namespace for ease of invocation from gdb. |
| 338 void showTree(const blink::FrameSelection&); | 337 void showTree(const blink::FrameSelection&); |
| 339 void showTree(const blink::FrameSelection*); | 338 void showTree(const blink::FrameSelection*); |
| 340 #endif | 339 #endif |
| 341 | 340 |
| 342 #endif // FrameSelection_h | 341 #endif // FrameSelection_h |
| OLD | NEW |