summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/page/scrolling/text_fragment_selector.h
blob: 536cdb59b895b165221c92a8477497310662b9b6 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// 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_PAGE_SCROLLING_TEXT_FRAGMENT_SELECTOR_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_PAGE_SCROLLING_TEXT_FRAGMENT_SELECTOR_H_

#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"

namespace blink {

// TextFragmentSelector represents a single text=... selector of a
// TextFragmentAnchor, parsed into its components.
class CORE_EXPORT TextFragmentSelector final {
 public:
  static TextFragmentSelector Create(String target_text);

  enum SelectorType {
    // An invalid text selector.
    kInvalid,
    // An exact selector on the string start_.
    kExact,
    // A range selector on a text range start_ to end_.
    kRange,
  };

  TextFragmentSelector(SelectorType type,
                       const String& start,
                       const String& end,
                       const String& prefix,
                       const String& suffix);
  TextFragmentSelector(SelectorType type);
  ~TextFragmentSelector() = default;

  SelectorType Type() const { return type_; }
  String Start() const { return start_; }
  String End() const { return end_; }
  String Prefix() const { return prefix_; }
  String Suffix() const { return suffix_; }

 private:
  const SelectorType type_;
  String start_;
  String end_;
  String prefix_;
  String suffix_;
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_PAGE_SCROLLING_TEXT_FRAGMENT_SELECTOR_H_