summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/layout/ng/inline/ng_text_offset.h
blob: 8e196f9850f86ad77edf1271f50c6e6d97c493f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright 2019 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.

#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_INLINE_NG_TEXT_OFFSET_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_INLINE_NG_TEXT_OFFSET_H_

#include "base/check_op.h"
#include "third_party/blink/renderer/core/core_export.h"

namespace blink {

// Represents a range of text, as a |start| and |end| offset pair.
struct CORE_EXPORT NGTextOffset {
  NGTextOffset() = default;
  NGTextOffset(unsigned start, unsigned end) : start(start), end(end) {
    AssertValid();
  }

  unsigned Length() const {
    AssertValid();
    return end - start;
  }

  void AssertValid() const { DCHECK_GE(end, start); }
  void AssertNotEmpty() const { DCHECK_GT(end, start); }

  unsigned start;
  unsigned end;
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_INLINE_NG_TEXT_OFFSET_H_