summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/layout/layout_object_factory.h
blob: 37428424c92aef0bcf555e14061d55d63b0b38df (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
64
65
66
67
68
69
70
71
72
73
// Copyright 2018 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_LAYOUT_OBJECT_FACTORY_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_OBJECT_FACTORY_H_

#include "base/memory/scoped_refptr.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/forward.h"

namespace blink {

class ComputedStyle;
class LayoutBlock;
class LayoutBlockFlow;
class LayoutObject;
enum class LegacyLayout;
class LayoutProgress;
class LayoutTableCaption;
class LayoutTableCell;
class LayoutText;
class LayoutTextFragment;
class Node;

// Helper class for creation of certain LayoutObject-derived objects that may
// need to be of different types, depending on whether or not LayoutNG is to be
// used in the given context.
class LayoutObjectFactory {
  STATIC_ONLY(LayoutObjectFactory);

 public:
  // The following methods will create and return some LayoutObject-derived
  // object. If |node| is of type Element, it will be associated with the new
  // LayoutObject. Otherwise it will be assumed to be a Document node, in which
  // case the LayoutObject created will be anonymous. The |style| reference
  // passed will only be used to determine which object type to create.
  static LayoutBlockFlow* CreateBlockFlow(Node&,
                                          const ComputedStyle&,
                                          LegacyLayout);
  static LayoutBlock* CreateBlockForLineClamp(Node& node,
                                              const ComputedStyle& style,
                                              LegacyLayout legacy);
  static LayoutBlock* CreateFlexibleBox(Node&,
                                        const ComputedStyle&,
                                        LegacyLayout);
  static LayoutObject* CreateListMarker(Node&,
                                        const ComputedStyle&,
                                        LegacyLayout);
  static LayoutTableCaption* CreateTableCaption(Node&,
                                                const ComputedStyle&,
                                                LegacyLayout);
  static LayoutTableCell* CreateTableCell(Node&,
                                          const ComputedStyle&,
                                          LegacyLayout);
  static LayoutBlock* CreateFieldset(Node&, const ComputedStyle&, LegacyLayout);
  static LayoutBlockFlow* CreateFileUploadControl(Node& node,
                                                  const ComputedStyle& style,
                                                  LegacyLayout legacy);
  static LayoutText* CreateText(Node*, scoped_refptr<StringImpl>, LegacyLayout);
  static LayoutTextFragment* CreateTextFragment(Node*,
                                                StringImpl*,
                                                int start_offset,
                                                int length,
                                                LegacyLayout);
  static LayoutProgress* CreateProgress(Node* node,
                                        const ComputedStyle& style,
                                        LegacyLayout legacy);
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_OBJECT_FACTORY_H_