Chromium Code Reviews| Index: third_party/WebKit/Source/core/editing/SelectionEditor.h |
| diff --git a/third_party/WebKit/Source/core/editing/SelectionEditor.h b/third_party/WebKit/Source/core/editing/SelectionEditor.h |
| index eb4a2019db6f8b41196f83fd80f0fbad3a1de3eb..a6e75de5f2b13013b0477a87459c53553e4cafb6 100644 |
| --- a/third_party/WebKit/Source/core/editing/SelectionEditor.h |
| +++ b/third_party/WebKit/Source/core/editing/SelectionEditor.h |
| @@ -27,7 +27,9 @@ |
| #ifndef SelectionEditor_h |
| #define SelectionEditor_h |
| +#include "core/dom/SynchronousMutationObserver.h" |
| #include "core/editing/FrameSelection.h" |
| +#include "core/editing/SelectionTemplate.h" |
| #include "core/events/EventDispatchResult.h" |
| namespace blink { |
| @@ -35,39 +37,32 @@ namespace blink { |
| // TODO(yosin): We will rename |SelectionEditor| to appropriate name since |
| // it is no longer have a changing selection functionality, it was moved to |
| // |SelectionModifier| class. |
| -class SelectionEditor final |
| - : public GarbageCollectedFinalized<SelectionEditor> { |
| +class SelectionEditor final : public GarbageCollectedFinalized<SelectionEditor>, |
| + public SynchronousMutationObserver { |
| WTF_MAKE_NONCOPYABLE(SelectionEditor); |
| + USING_GARBAGE_COLLECTED_MIXIN(SelectionEditor); |
| public: |
| static SelectionEditor* create(LocalFrame& frame) { |
| return new SelectionEditor(frame); |
| } |
| + |
| virtual ~SelectionEditor(); |
| void dispose(); |
| - bool hasEditableStyle() const { return m_selection.hasEditableStyle(); } |
| - bool isContentEditable() const { return m_selection.isContentEditable(); } |
| - bool isContentRichlyEditable() const { |
| - return m_selection.isContentRichlyEditable(); |
| - } |
| - |
| - bool setSelectedRange(const EphemeralRange&, |
| - TextAffinity, |
| - SelectionDirectionalMode, |
| - FrameSelection::SetSelectionOptions); |
| - |
| template <typename Strategy> |
| const VisibleSelectionTemplate<Strategy>& visibleSelection() const; |
| - void setVisibleSelection(const VisibleSelection&, |
| - FrameSelection::SetSelectionOptions); |
| - void setVisibleSelection(const VisibleSelectionInFlatTree&, |
| - FrameSelection::SetSelectionOptions); |
| + const SelectionInDOMTree& selectionInDOMTree() const; |
| - void setWithoutValidation(const Position& base, const Position& extent); |
| + bool hasEditableStyle() const; |
| + bool isContentEditable() const; |
| + bool isContentRichlyEditable() const; |
| + |
| + const VisibleSelection& computeVisibleSelectionInDOMTree() const; |
| + const VisibleSelectionInFlatTree& computeVisibleSelectionInFlatTree() const; |
| + void setSelection(const SelectionInDOMTree&); |
| void documentAttached(Document*); |
| - void documentDetached(const Document&); |
| // If this FrameSelection has a logical range which is still valid, this |
| // function return its clone. Otherwise, the return value from underlying |
| @@ -92,17 +87,38 @@ class SelectionEditor final |
| explicit SelectionEditor(LocalFrame&); |
| const Document& document() const; |
| + Document& document(); |
| LocalFrame* frame() const { return m_frame.get(); } |
| + void assertSelectionValid() const; |
| void clearVisibleSelection(); |
| + void markCacheDirty(); |
| bool shouldAlwaysUseDirectionalSelection() const; |
| - Member<Document> m_document; |
| + // VisibleSelection cache related |
| + bool needsUpdateVisibleSelection() const; |
| + void updateCachedVisibleSelectionIfNeeded(); |
| + |
| + void didFinishTextChange(const Position& base, const Position& extent); |
| + void didFinishDOMMutation(); |
| + |
| + // Implementation of |SynchronousMutationObsderver| member functions. |
| + void contextDestroyed(Document*) final; |
| + void didChangeChildren(const ContainerNode&) final; |
| + void didMergeTextNodes(const Text& mergedNode, |
| + const NodeWithIndex& nodeToBeRemovedWithIndex, |
| + unsigned oldLength) final; |
| + void didSplitTextNode(const Text&) final; |
| + void didUpdateCharacterData(CharacterData*, |
| + unsigned offset, |
| + unsigned oldLength, |
| + unsigned newLength) final; |
| + void nodeChildrenWillBeRemoved(ContainerNode&) final; |
| + void nodeWillBeRemoved(Node&) final; |
| + |
| Member<LocalFrame> m_frame; |
| - VisibleSelection m_selection; |
| - VisibleSelectionInFlatTree m_selectionInFlatTree; |
| - bool m_observingVisibleSelection; |
| + SelectionInDOMTree m_selection; |
| // TODO(editing-dev): Removing |m_logicalRange| |
| // The range specified by the user, which may not be visually canonicalized |
| @@ -110,9 +126,15 @@ class SelectionEditor final |
| // |VisibleSelection| changes. If that happens, this variable will |
| // become |nullptr|, in which case logical positions == visible positions. |
| Member<Range> m_logicalRange; |
| + |
| // If document is root, document.getSelection().addRange(range) is cached on |
| // this. |
| Member<Range> m_cachedRange; |
| + |
| + mutable VisibleSelection m_cachedVisibleSelectionInDOMTree; |
| + mutable VisibleSelectionInFlatTree m_cachedVisibleSelectionInFlatTree; |
| + mutable uint64_t m_styleVersion = static_cast<uint64_t>(-1); |
|
tkent
2017/02/10 08:47:41
Why don't you make it int64_t?
yosin_UTC9
2017/02/10 10:13:20
As same as Document::m_styleVersion
|
| + mutable bool m_cacheIsDirty = false; |
| }; |
| } // namespace blink |