summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/editing/serializers/create_markup_options.h
blob: 63fae1e29577bad698454e10855423f9640f3dc9 (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
53
54
55
56
57
58
59
60
61
62
63
// 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_EDITING_SERIALIZERS_CREATE_MARKUP_OPTIONS_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_SERIALIZERS_CREATE_MARKUP_OPTIONS_H_

#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"

namespace blink {

class Node;

enum AbsoluteURLs { kDoNotResolveURLs, kResolveAllURLs, kResolveNonLocalURLs };

class CORE_EXPORT CreateMarkupOptions final {
  STACK_ALLOCATED();

 public:
  class CORE_EXPORT Builder;

  CreateMarkupOptions() = default;

  const Node* ConstrainingAncestor() const { return constraining_ancestor_; }
  AbsoluteURLs ShouldResolveURLs() const { return should_resolve_urls_; }
  bool ShouldAnnotateForInterchange() const {
    return should_annotate_for_interchange_;
  }
  bool ShouldConvertBlocksToInlines() const {
    return should_convert_blocks_to_inlines_;
  }

 private:
  Member<const Node> constraining_ancestor_;
  AbsoluteURLs should_resolve_urls_ = kDoNotResolveURLs;
  bool should_annotate_for_interchange_ = false;
  bool should_convert_blocks_to_inlines_ = false;
};

class CORE_EXPORT CreateMarkupOptions::Builder final {
  STACK_ALLOCATED();

 public:
  Builder() = default;
  explicit Builder(const CreateMarkupOptions& options) : data_(options) {}

  CreateMarkupOptions Build() const { return data_; }

  Builder& SetConstrainingAncestor(const Node* node);
  Builder& SetShouldResolveURLs(AbsoluteURLs absolute_urls);
  Builder& SetShouldAnnotateForInterchange(bool annotate_for_interchange);
  Builder& SetShouldConvertBlocksToInlines(bool convert_blocks_for_inlines);

 private:
  CreateMarkupOptions data_;
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_SERIALIZERS_CREATE_MARKUP_OPTIONS_H_