OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "core/editing/markers/DocumentMarkerList.h" |
| 6 |
| 7 #include "core/editing/markers/DocumentMarkerController.h" |
| 8 |
| 9 namespace blink { |
| 10 |
| 11 DocumentMarkerList::DocumentMarkerList( |
| 12 DocumentMarkerController* documentMarkerController) |
| 13 : m_documentMarkerController(documentMarkerController) {} |
| 14 |
| 15 bool DocumentMarkerList::startsAfter(const Member<DocumentMarker>& marker, |
| 16 size_t startOffset) { |
| 17 return marker->startOffset() < startOffset; |
| 18 } |
| 19 |
| 20 bool DocumentMarkerList::endsBefore(size_t startOffset, |
| 21 const Member<DocumentMarker>& rhv) { |
| 22 return startOffset < rhv->endOffset(); |
| 23 } |
| 24 |
| 25 bool DocumentMarkerList::compareByStart(const Member<DocumentMarker>& lhv, |
| 26 const Member<DocumentMarker>& rhv) { |
| 27 return lhv->startOffset() < rhv->startOffset(); |
| 28 } |
| 29 |
| 30 DocumentMarkerList::ShiftMarkerResult |
| 31 DocumentMarkerList::getShiftedMarkerPosition(const DocumentMarker& marker, |
| 32 unsigned startOffset, |
| 33 int delta) { |
| 34 ShiftMarkerResult result; |
| 35 result.newStartOffset = marker.startOffset(); |
| 36 result.newEndOffset = marker.endOffset(); |
| 37 |
| 38 if (marker.startOffset() < startOffset) |
| 39 return result; |
| 40 |
| 41 DCHECK_GE(static_cast<int>(marker.startOffset()) + delta, 0); |
| 42 |
| 43 result.newStartOffset += delta; |
| 44 result.newEndOffset += delta; |
| 45 |
| 46 return result; |
| 47 } |
| 48 |
| 49 DEFINE_TRACE(DocumentMarkerList) { |
| 50 visitor->trace(m_documentMarkerController); |
| 51 } |
| 52 |
| 53 } // namespace blink |
OLD | NEW |