blob: 9ee54bdbde8676a0c80be6e4f33cb7a084451907 (
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
74
75
|
// Copyright 2017 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 NG_BASE_LAYOUT_ALGORITHM_TEST_H_
#define NG_BASE_LAYOUT_ALGORITHM_TEST_H_
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/layout/ng/geometry/ng_logical_size.h"
#include "third_party/blink/renderer/core/layout/ng/ng_constraint_space.h"
#include "third_party/blink/renderer/core/layout/ng/ng_layout_test.h"
#include "third_party/blink/renderer/core/testing/core_unit_test_helper.h"
#include "third_party/blink/renderer/platform/text/text_direction.h"
#include "third_party/blink/renderer/platform/text/writing_mode.h"
#include "third_party/blink/renderer/platform/wtf/allocator.h"
namespace blink {
class Element;
class LayoutNGBlockFlow;
class NGPhysicalBoxFragment;
// Base class for all LayoutNG Algorithms unit test classes.
typedef bool TestParamLayoutNG;
class NGBaseLayoutAlgorithmTest
: public testing::WithParamInterface<TestParamLayoutNG>,
public NGLayoutTest {
protected:
void SetUp() override;
// Should be called before calling Layout(), if you're not using
// RunBlockLayoutAlgorithmForElement.
void AdvanceToLayoutPhase();
std::pair<scoped_refptr<NGPhysicalBoxFragment>,
scoped_refptr<NGConstraintSpace>>
RunBlockLayoutAlgorithmForElement(Element* element);
scoped_refptr<const NGPhysicalBoxFragment> GetBoxFragmentByElementId(
const char*);
static const NGPhysicalBoxFragment* CurrentFragmentFor(
const LayoutNGBlockFlow*);
};
class FragmentChildIterator {
STACK_ALLOCATED();
public:
explicit FragmentChildIterator(const NGPhysicalBoxFragment* parent) {
SetParent(parent);
}
void SetParent(const NGPhysicalBoxFragment* parent) {
parent_ = parent;
index_ = 0;
}
const NGPhysicalBoxFragment* NextChild();
private:
const NGPhysicalBoxFragment* parent_;
unsigned index_;
};
scoped_refptr<NGConstraintSpace> ConstructBlockLayoutTestConstraintSpace(
WritingMode writing_mode,
TextDirection direction,
NGLogicalSize size,
bool shrink_to_fit = false,
bool is_new_formatting_context = false,
LayoutUnit fragmentainer_space_available = LayoutUnit());
} // namespace blink
#endif // NG_BASE_LAYOUT_ALGORITHM_TEST_H_
|