Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1210)

Unified Diff: third_party/WebKit/Source/core/editing/markers/DocumentMarkerList.cpp

Issue 2723663002: Refactor DocumentMarkerController (Closed)
Patch Set: Remove logging Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/markers/DocumentMarkerList.cpp
diff --git a/third_party/WebKit/Source/core/editing/markers/DocumentMarkerList.cpp b/third_party/WebKit/Source/core/editing/markers/DocumentMarkerList.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f8640ee0783d55a21ffa70f5ffd803f86c0f2b7c
--- /dev/null
+++ b/third_party/WebKit/Source/core/editing/markers/DocumentMarkerList.cpp
@@ -0,0 +1,53 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/editing/markers/DocumentMarkerList.h"
+
+#include "core/editing/markers/DocumentMarkerController.h"
+
+namespace blink {
+
+DocumentMarkerList::DocumentMarkerList(
+ DocumentMarkerController* documentMarkerController)
+ : m_documentMarkerController(documentMarkerController) {}
+
+bool DocumentMarkerList::startsAfter(const Member<DocumentMarker>& marker,
+ size_t startOffset) {
+ return marker->startOffset() < startOffset;
+}
+
+bool DocumentMarkerList::endsBefore(size_t startOffset,
+ const Member<DocumentMarker>& rhv) {
+ return startOffset < rhv->endOffset();
+}
+
+bool DocumentMarkerList::compareByStart(const Member<DocumentMarker>& lhv,
+ const Member<DocumentMarker>& rhv) {
+ return lhv->startOffset() < rhv->startOffset();
+}
+
+DocumentMarkerList::ShiftMarkerResult
+DocumentMarkerList::getShiftedMarkerPosition(const DocumentMarker& marker,
+ unsigned startOffset,
+ int delta) {
+ ShiftMarkerResult result;
+ result.newStartOffset = marker.startOffset();
+ result.newEndOffset = marker.endOffset();
+
+ if (marker.startOffset() < startOffset)
+ return result;
+
+ DCHECK_GE(static_cast<int>(marker.startOffset()) + delta, 0);
+
+ result.newStartOffset += delta;
+ result.newEndOffset += delta;
+
+ return result;
+}
+
+DEFINE_TRACE(DocumentMarkerList) {
+ visitor->trace(m_documentMarkerController);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698