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