| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2004 Apple Computer, 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 26 matching lines...) Expand all Loading... |
| 37 #include "wtf/Allocator.h" | 37 #include "wtf/Allocator.h" |
| 38 | 38 |
| 39 namespace blink { | 39 namespace blink { |
| 40 | 40 |
| 41 class LayoutPoint; | 41 class LayoutPoint; |
| 42 | 42 |
| 43 // TODO(yosin) We should use capitalized name instead of |SEL_DEFAULT_AFFINITY|. | 43 // TODO(yosin) We should use capitalized name instead of |SEL_DEFAULT_AFFINITY|. |
| 44 const TextAffinity SEL_DEFAULT_AFFINITY = TextAffinity::Downstream; // NOLINT | 44 const TextAffinity SEL_DEFAULT_AFFINITY = TextAffinity::Downstream; // NOLINT |
| 45 enum SelectionDirection { DirectionForward, DirectionBackward, DirectionRight, D
irectionLeft }; | 45 enum SelectionDirection { DirectionForward, DirectionBackward, DirectionRight, D
irectionLeft }; |
| 46 | 46 |
| 47 // Listener of |VisibleSelection| modification. |didChangeVisibleSelection()| |
| 48 // will be invoked when base, extent, start or end is moved to a different |
| 49 // position. |
| 50 // |
| 51 // Objects implementing |VisibleSelectionChangeObserver| interface must outlive |
| 52 // the |VisibleSelection| object. |
| 53 class CORE_EXPORT VisibleSelectionChangeObserver : public WillBeGarbageCollected
Mixin { |
| 54 WTF_MAKE_NONCOPYABLE(VisibleSelectionChangeObserver); |
| 55 public: |
| 56 VisibleSelectionChangeObserver(); |
| 57 virtual ~VisibleSelectionChangeObserver(); |
| 58 virtual void didChangeVisibleSelection() = 0; |
| 59 DEFINE_INLINE_VIRTUAL_TRACE() { } |
| 60 }; |
| 61 |
| 47 class CORE_EXPORT VisibleSelection { | 62 class CORE_EXPORT VisibleSelection { |
| 48 DISALLOW_ALLOCATION(); | 63 DISALLOW_ALLOCATION(); |
| 49 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(VisibleSelection); | 64 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(VisibleSelection); |
| 50 public: | 65 public: |
| 51 class InDOMTree { | 66 class InDOMTree { |
| 52 STATIC_ONLY(InDOMTree); | 67 STATIC_ONLY(InDOMTree); |
| 53 public: | 68 public: |
| 54 using PositionType = Position; | 69 using PositionType = Position; |
| 55 using Strategy = EditingStrategy; | 70 using Strategy = EditingStrategy; |
| 56 | 71 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // ShadowRoot node for new shadow trees, or 0 for non-shadow trees. | 182 // ShadowRoot node for new shadow trees, or 0 for non-shadow trees. |
| 168 Node* nonBoundaryShadowTreeRootNode() const; | 183 Node* nonBoundaryShadowTreeRootNode() const; |
| 169 | 184 |
| 170 VisiblePosition visiblePositionRespectingEditingBoundary(const LayoutPoint&
localPoint, Node* targetNode) const; | 185 VisiblePosition visiblePositionRespectingEditingBoundary(const LayoutPoint&
localPoint, Node* targetNode) const; |
| 171 PositionWithAffinity positionRespectingEditingBoundary(const LayoutPoint& lo
calPoint, Node* targetNode) const; | 186 PositionWithAffinity positionRespectingEditingBoundary(const LayoutPoint& lo
calPoint, Node* targetNode) const; |
| 172 | 187 |
| 173 bool isValidFor(const Document&) const; | 188 bool isValidFor(const Document&) const; |
| 174 void setWithoutValidation(const Position&, const Position&); | 189 void setWithoutValidation(const Position&, const Position&); |
| 175 void setWithoutValidation(const PositionInComposedTree&, const PositionInCom
posedTree&); | 190 void setWithoutValidation(const PositionInComposedTree&, const PositionInCom
posedTree&); |
| 176 | 191 |
| 177 // Listener of VisibleSelection modification. didChangeVisibleSelection() wi
ll be invoked when base, extent, start | 192 void setChangeObserver(VisibleSelectionChangeObserver&); |
| 178 // or end is moved to a different position. | |
| 179 // | |
| 180 // Objects implementing |ChangeObserver| interface must outlive the VisibleS
election object. | |
| 181 class CORE_EXPORT ChangeObserver : public WillBeGarbageCollectedMixin { | |
| 182 WTF_MAKE_NONCOPYABLE(ChangeObserver); | |
| 183 public: | |
| 184 ChangeObserver(); | |
| 185 virtual ~ChangeObserver(); | |
| 186 virtual void didChangeVisibleSelection() = 0; | |
| 187 DEFINE_INLINE_VIRTUAL_TRACE() { } | |
| 188 }; | |
| 189 | |
| 190 void setChangeObserver(ChangeObserver&); | |
| 191 void clearChangeObserver(); | 193 void clearChangeObserver(); |
| 192 void didChange(); // Fire the change observer, if any. | 194 void didChange(); // Fire the change observer, if any. |
| 193 | 195 |
| 194 DECLARE_TRACE(); | 196 DECLARE_TRACE(); |
| 195 | 197 |
| 196 void validatePositionsIfNeeded(); | 198 void validatePositionsIfNeeded(); |
| 197 | 199 |
| 198 #ifndef NDEBUG | 200 #ifndef NDEBUG |
| 199 void debugPosition(const char* message) const; | 201 void debugPosition(const char* message) const; |
| 200 void formatForDebugger(char* buffer, unsigned length) const; | 202 void formatForDebugger(char* buffer, unsigned length) const; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 // VisibleUnit.cpp, and VisiblePosition.cpp). We'll do that in the future. | 237 // VisibleUnit.cpp, and VisiblePosition.cpp). We'll do that in the future. |
| 236 PositionInComposedTree m_baseInComposedTree; | 238 PositionInComposedTree m_baseInComposedTree; |
| 237 PositionInComposedTree m_extentInComposedTree; | 239 PositionInComposedTree m_extentInComposedTree; |
| 238 PositionInComposedTree m_startInComposedTree; | 240 PositionInComposedTree m_startInComposedTree; |
| 239 PositionInComposedTree m_endInComposedTree; | 241 PositionInComposedTree m_endInComposedTree; |
| 240 | 242 |
| 241 TextAffinity m_affinity; // the upstream/downstream affinity of the caret | 243 TextAffinity m_affinity; // the upstream/downstream affinity of the caret |
| 242 | 244 |
| 243 // Oilpan: this reference has a lifetime that is at least as long | 245 // Oilpan: this reference has a lifetime that is at least as long |
| 244 // as this object. | 246 // as this object. |
| 245 RawPtrWillBeMember<ChangeObserver> m_changeObserver; | 247 RawPtrWillBeMember<VisibleSelectionChangeObserver> m_changeObserver; |
| 246 | 248 |
| 247 // these are cached, can be recalculated by validate() | 249 // these are cached, can be recalculated by validate() |
| 248 SelectionType m_selectionType; // None, Caret, Range | 250 SelectionType m_selectionType; // None, Caret, Range |
| 249 bool m_baseIsFirst : 1; // True if base is before the extent | 251 bool m_baseIsFirst : 1; // True if base is before the extent |
| 250 bool m_isDirectional : 1; // Non-directional ignores m_baseIsFirst and selec
tion always extends on shift + arrow key. | 252 bool m_isDirectional : 1; // Non-directional ignores m_baseIsFirst and selec
tion always extends on shift + arrow key. |
| 251 }; | 253 }; |
| 252 | 254 |
| 253 // We don't yet support multi-range selections, so we only ever have one range | 255 // We don't yet support multi-range selections, so we only ever have one range |
| 254 // to return. | 256 // to return. |
| 255 CORE_EXPORT PassRefPtrWillBeRawPtr<Range> firstRangeOf(const VisibleSelection&); | 257 CORE_EXPORT PassRefPtrWillBeRawPtr<Range> firstRangeOf(const VisibleSelection&); |
| 256 | 258 |
| 257 } // namespace blink | 259 } // namespace blink |
| 258 | 260 |
| 259 #ifndef NDEBUG | 261 #ifndef NDEBUG |
| 260 // Outside the WebCore namespace for ease of invocation from gdb. | 262 // Outside the WebCore namespace for ease of invocation from gdb. |
| 261 void showTree(const blink::VisibleSelection&); | 263 void showTree(const blink::VisibleSelection&); |
| 262 void showTree(const blink::VisibleSelection*); | 264 void showTree(const blink::VisibleSelection*); |
| 263 #endif | 265 #endif |
| 264 | 266 |
| 265 #endif // VisibleSelection_h | 267 #endif // VisibleSelection_h |
| OLD | NEW |