Chromium Code Reviews| Index: third_party/WebKit/Source/core/editing/markers/SpellCheckMarkerListImpl.h |
| diff --git a/third_party/WebKit/Source/core/editing/markers/GenericDocumentMarkerListImpl.h b/third_party/WebKit/Source/core/editing/markers/SpellCheckMarkerListImpl.h |
| similarity index 52% |
| copy from third_party/WebKit/Source/core/editing/markers/GenericDocumentMarkerListImpl.h |
| copy to third_party/WebKit/Source/core/editing/markers/SpellCheckMarkerListImpl.h |
| index bd148c554746c436bdbb5c4e0cfd33f491b23bba..34545dc3b52afd161d507c30fed5ba9580eb7afd 100644 |
| --- a/third_party/WebKit/Source/core/editing/markers/GenericDocumentMarkerListImpl.h |
| +++ b/third_party/WebKit/Source/core/editing/markers/SpellCheckMarkerListImpl.h |
| @@ -2,21 +2,19 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef GenericDocumentMarkerListImpl_h |
| -#define GenericDocumentMarkerListImpl_h |
| +#ifndef SpellCheckMarkerListImpl_h |
| +#define SpellCheckMarkerListImpl_h |
| #include "core/editing/markers/DocumentMarkerList.h" |
| namespace blink { |
| -class RenderedDocumentMarker; |
| - |
| -// Temporary implementation of DocumentMarkerList that can handle |
| -// DocumentMarkers of all MarkerTypes. This will be removed once we have |
| -// specialized implementations for every MarkerType. |
| -class GenericDocumentMarkerListImpl final : public DocumentMarkerList { |
| +// Implementation of DocumentMarkerList for Spelling/Grammar markers. |
| +// Markers with touching endpoints are merged on insert. Markers are kept sorted |
| +// by start offset in order to be able to do this efficiently. |
| +class CORE_EXPORT SpellCheckMarkerListImpl : public DocumentMarkerList { |
| public: |
| - GenericDocumentMarkerListImpl() = default; |
| + SpellCheckMarkerListImpl() = default; |
| // DocumentMarkerList implementations |
| bool IsEmpty() const final; |
| @@ -28,20 +26,28 @@ class GenericDocumentMarkerListImpl final : public DocumentMarkerList { |
| bool MoveMarkers(int length, DocumentMarkerList* dst_list) final; |
| bool RemoveMarkers(unsigned start_offset, int length) final; |
| - bool RemoveMarkersUnderWords(const String& node_text, |
| - const Vector<String>& words) final; |
| bool ShiftMarkers(unsigned offset, |
| unsigned old_length, |
| unsigned new_length) final; |
| - |
| DECLARE_TRACE(); |
|
Xiaocheng
2017/04/27 19:04:01
Should it be DECLARE_VIRTUAL_TRACE?
Should we fix
rlanday
2017/04/27 20:30:13
I think it only really matters in the base class;
|
| + // SpellCheckMarkerListImpl-specific |
| + // Returns true if a marker was removed, false otherwise. |
| + bool RemoveMarkersUnderWords(const String& node_text, |
| + const Vector<String>& words); |
| + |
| private: |
| HeapVector<Member<RenderedDocumentMarker>> markers_; |
| - DISALLOW_COPY_AND_ASSIGN(GenericDocumentMarkerListImpl); |
| + DISALLOW_COPY_AND_ASSIGN(SpellCheckMarkerListImpl); |
| }; |
| +DEFINE_TYPE_CASTS(SpellCheckMarkerListImpl, |
|
Xiaocheng
2017/04/27 19:04:01
I prefer using static_cast at the (only) call site
|
| + DocumentMarkerList, |
| + list, |
| + true, |
| + true); |
| + |
| } // namespace blink |
| -#endif // GenericDocumentMarkerListImpl_h |
| +#endif // SpellCheckMarkerListImpl_h |