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