| 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 12 matching lines...) Expand all Loading... |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef SelectionEditor_h | 26 #ifndef SelectionEditor_h |
| 27 #define SelectionEditor_h | 27 #define SelectionEditor_h |
| 28 | 28 |
| 29 #include "core/editing/FrameSelection.h" | 29 #include "core/editing/FrameSelection.h" |
| 30 | 30 |
| 31 namespace blink { | 31 namespace blink { |
| 32 | 32 |
| 33 class SelectionEditor final : public NoBaseWillBeGarbageCollectedFinalized<Selec
tionEditor>, public VisibleSelectionChangeObserver { | 33 class SelectionEditor final : public GarbageCollectedFinalized<SelectionEditor>,
public VisibleSelectionChangeObserver { |
| 34 WTF_MAKE_NONCOPYABLE(SelectionEditor); | 34 WTF_MAKE_NONCOPYABLE(SelectionEditor); |
| 35 USING_FAST_MALLOC_WILL_BE_REMOVED(SelectionEditor); | 35 USING_GARBAGE_COLLECTED_MIXIN(SelectionEditor); |
| 36 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(SelectionEditor); | |
| 37 public: | 36 public: |
| 38 // TODO(yosin) We should move |EAlteration| and |VerticalDirection| out | 37 // TODO(yosin) We should move |EAlteration| and |VerticalDirection| out |
| 39 // from |FrameSelection| class like |EUserTriggered|. | 38 // from |FrameSelection| class like |EUserTriggered|. |
| 40 typedef FrameSelection::EAlteration EAlteration; | 39 typedef FrameSelection::EAlteration EAlteration; |
| 41 typedef FrameSelection::VerticalDirection VerticalDirection; | 40 typedef FrameSelection::VerticalDirection VerticalDirection; |
| 42 | 41 |
| 43 static PassOwnPtrWillBeRawPtr<SelectionEditor> create(FrameSelection& frameS
election) | 42 static RawPtr<SelectionEditor> create(FrameSelection& frameSelection) |
| 44 { | 43 { |
| 45 return adoptPtrWillBeNoop(new SelectionEditor(frameSelection)); | 44 return (new SelectionEditor(frameSelection)); |
| 46 } | 45 } |
| 47 virtual ~SelectionEditor(); | 46 virtual ~SelectionEditor(); |
| 48 void dispose(); | 47 void dispose(); |
| 49 | 48 |
| 50 bool hasEditableStyle() const { return m_selection.hasEditableStyle(); } | 49 bool hasEditableStyle() const { return m_selection.hasEditableStyle(); } |
| 51 bool isContentEditable() const { return m_selection.isContentEditable(); } | 50 bool isContentEditable() const { return m_selection.isContentEditable(); } |
| 52 bool isContentRichlyEditable() const { return m_selection.isContentRichlyEdi
table(); } | 51 bool isContentRichlyEditable() const { return m_selection.isContentRichlyEdi
table(); } |
| 53 | 52 |
| 54 bool setSelectedRange(const EphemeralRange&, TextAffinity, SelectionDirectio
nalMode, FrameSelection::SetSelectionOptions); | 53 bool setSelectedRange(const EphemeralRange&, TextAffinity, SelectionDirectio
nalMode, FrameSelection::SetSelectionOptions); |
| 55 | 54 |
| 56 bool modify(EAlteration, SelectionDirection, TextGranularity, EUserTriggered
); | 55 bool modify(EAlteration, SelectionDirection, TextGranularity, EUserTriggered
); |
| 57 bool modify(EAlteration, unsigned verticalDistance, VerticalDirection, EUser
Triggered, CursorAlignOnScroll); | 56 bool modify(EAlteration, unsigned verticalDistance, VerticalDirection, EUser
Triggered, CursorAlignOnScroll); |
| 58 | 57 |
| 59 template <typename Strategy> | 58 template <typename Strategy> |
| 60 const VisibleSelectionTemplate<Strategy>& visibleSelection() const; | 59 const VisibleSelectionTemplate<Strategy>& visibleSelection() const; |
| 61 void setVisibleSelection(const VisibleSelection&, FrameSelection::SetSelecti
onOptions); | 60 void setVisibleSelection(const VisibleSelection&, FrameSelection::SetSelecti
onOptions); |
| 62 void setVisibleSelection(const VisibleSelectionInFlatTree&, FrameSelection::
SetSelectionOptions); | 61 void setVisibleSelection(const VisibleSelectionInFlatTree&, FrameSelection::
SetSelectionOptions); |
| 63 | 62 |
| 64 void setIsDirectional(bool); | 63 void setIsDirectional(bool); |
| 65 void setWithoutValidation(const Position& base, const Position& extent); | 64 void setWithoutValidation(const Position& base, const Position& extent); |
| 66 | 65 |
| 67 void resetXPosForVerticalArrowNavigation(); | 66 void resetXPosForVerticalArrowNavigation(); |
| 68 | 67 |
| 69 void willBeModified(EAlteration, SelectionDirection); | 68 void willBeModified(EAlteration, SelectionDirection); |
| 70 | 69 |
| 71 // If this FrameSelection has a logical range which is still valid, this | 70 // If this FrameSelection has a logical range which is still valid, this |
| 72 // function return its clone. Otherwise, the return value from underlying | 71 // function return its clone. Otherwise, the return value from underlying |
| 73 // |VisibleSelection|'s |firstRange()| is returned. | 72 // |VisibleSelection|'s |firstRange()| is returned. |
| 74 PassRefPtrWillBeRawPtr<Range> firstRange() const; | 73 RawPtr<Range> firstRange() const; |
| 75 | 74 |
| 76 // VisibleSelectionChangeObserver interface. | 75 // VisibleSelectionChangeObserver interface. |
| 77 void didChangeVisibleSelection() override; | 76 void didChangeVisibleSelection() override; |
| 78 | 77 |
| 79 // Updates |m_selection| and |m_selectionInFlatTree| with up-to-date | 78 // Updates |m_selection| and |m_selectionInFlatTree| with up-to-date |
| 80 // layout if needed. | 79 // layout if needed. |
| 81 void updateIfNeeded(); | 80 void updateIfNeeded(); |
| 82 | 81 |
| 83 DECLARE_VIRTUAL_TRACE(); | 82 DECLARE_VIRTUAL_TRACE(); |
| 84 | 83 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 109 VisiblePosition modifyExtendingBackward(TextGranularity); | 108 VisiblePosition modifyExtendingBackward(TextGranularity); |
| 110 VisiblePosition modifyMovingLeft(TextGranularity); | 109 VisiblePosition modifyMovingLeft(TextGranularity); |
| 111 VisiblePosition modifyMovingBackward(TextGranularity); | 110 VisiblePosition modifyMovingBackward(TextGranularity); |
| 112 | 111 |
| 113 void startObservingVisibleSelectionChange(); | 112 void startObservingVisibleSelectionChange(); |
| 114 void stopObservingVisibleSelectionChangeIfNecessary(); | 113 void stopObservingVisibleSelectionChangeIfNecessary(); |
| 115 | 114 |
| 116 LayoutUnit lineDirectionPointForBlockDirectionNavigation(EPositionType); | 115 LayoutUnit lineDirectionPointForBlockDirectionNavigation(EPositionType); |
| 117 bool dispatchSelectStart(); | 116 bool dispatchSelectStart(); |
| 118 | 117 |
| 119 RawPtrWillBeMember<FrameSelection> m_frameSelection; | 118 Member<FrameSelection> m_frameSelection; |
| 120 | 119 |
| 121 LayoutUnit m_xPosForVerticalArrowNavigation; | 120 LayoutUnit m_xPosForVerticalArrowNavigation; |
| 122 VisibleSelection m_selection; | 121 VisibleSelection m_selection; |
| 123 VisibleSelectionInFlatTree m_selectionInFlatTree; | 122 VisibleSelectionInFlatTree m_selectionInFlatTree; |
| 124 bool m_observingVisibleSelection; | 123 bool m_observingVisibleSelection; |
| 125 | 124 |
| 126 // The range specified by the user, which may not be visually canonicalized | 125 // The range specified by the user, which may not be visually canonicalized |
| 127 // (hence "logical"). This will be invalidated if the underlying | 126 // (hence "logical"). This will be invalidated if the underlying |
| 128 // |VisibleSelection| changes. If that happens, this variable will | 127 // |VisibleSelection| changes. If that happens, this variable will |
| 129 // become |nullptr|, in which case logical positions == visible positions. | 128 // become |nullptr|, in which case logical positions == visible positions. |
| 130 RefPtrWillBeMember<Range> m_logicalRange; | 129 Member<Range> m_logicalRange; |
| 131 }; | 130 }; |
| 132 | 131 |
| 133 } // namespace blink | 132 } // namespace blink |
| 134 | 133 |
| 135 #endif // SelectionEditor_h | 134 #endif // SelectionEditor_h |
| OLD | NEW |