blob: cac653f2f5e4f672bbcf938e943c24f5ba83b0ea [file] [log] [blame]
// Copyright 2016 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 "third_party/blink/renderer/core/editing/iterators/backwards_text_buffer.h"
namespace blink {
const UChar* BackwardsTextBuffer::Data() const {
return BufferEnd() - Size();
}
UChar* BackwardsTextBuffer::CalcDestination(wtf_size_t length) {
DCHECK_LE(Size() + length, Capacity());
return BufferEnd() - Size() - length;
}
void BackwardsTextBuffer::ShiftData(wtf_size_t old_capacity) {
DCHECK_LE(old_capacity, Capacity());
DCHECK_LE(Size(), old_capacity);
std::copy_backward(BufferBegin() + old_capacity - Size(),
BufferBegin() + old_capacity, BufferEnd());
}
} // namespace blink