Source file layout_output.ml
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
type t = {
size : float Geometry.size;
content_size : float Geometry.size;
first_baselines : float option Geometry.point;
top_margin : Collapsible_margin_set.t;
bottom_margin : Collapsible_margin_set.t;
margins_can_collapse_through : bool;
}
let make ~size ~content_size ~first_baselines ~top_margin ~bottom_margin
~margins_can_collapse_through =
{
size;
content_size;
first_baselines;
top_margin;
bottom_margin;
margins_can_collapse_through;
}
let size t = t.size
let content_size t = t.content_size
let first_baselines t = t.first_baselines
let top_margin t = t.top_margin
let bottom_margin t = t.bottom_margin
let margins_can_collapse_through t = t.margins_can_collapse_through
let hidden =
{
size = Geometry.Size.zero;
content_size = Geometry.Size.zero;
first_baselines = Geometry.(Point.none);
top_margin = Collapsible_margin_set.zero;
bottom_margin = Collapsible_margin_set.zero;
margins_can_collapse_through = false;
}
let default =
{
size = Geometry.Size.zero;
content_size = Geometry.Size.zero;
first_baselines = Geometry.(Point.none);
top_margin = Collapsible_margin_set.zero;
bottom_margin = Collapsible_margin_set.zero;
margins_can_collapse_through = false;
}
let from_outer_size size =
{
size;
content_size = Geometry.Size.zero;
first_baselines = Geometry.(Point.none);
top_margin = Collapsible_margin_set.zero;
bottom_margin = Collapsible_margin_set.zero;
margins_can_collapse_through = false;
}
let from_sizes_and_baselines size content_size first_baselines =
{
size;
content_size;
first_baselines;
top_margin = Collapsible_margin_set.zero;
bottom_margin = Collapsible_margin_set.zero;
margins_can_collapse_through = false;
}
let to_string t =
Printf.sprintf
"LayoutOutput { size: %s; content_size: %s; margins_can_collapse_through: \
%b }"
(Geometry.Size.to_string Float.to_string t.size)
(Geometry.Size.to_string Float.to_string t.content_size)
t.margins_can_collapse_through
let compare a b =
let cmp = Geometry.Size.compare Float.compare a.size b.size in
if cmp <> 0 then cmp
else
let cmp =
Geometry.Size.compare Float.compare a.content_size b.content_size
in
if cmp <> 0 then cmp
else
let cmp =
Geometry.Point.compare
(Option.compare Float.compare)
a.first_baselines b.first_baselines
in
if cmp <> 0 then cmp
else
let cmp = Collapsible_margin_set.compare a.top_margin b.top_margin in
if cmp <> 0 then cmp
else
let cmp =
Collapsible_margin_set.compare a.bottom_margin b.bottom_margin
in
if cmp <> 0 then cmp
else
Bool.compare a.margins_can_collapse_through
b.margins_can_collapse_through
let equal a b = compare a b = 0
let pp fmt t = Format.pp_print_string fmt (to_string t)