summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-flexbox/scrollbars-ref.html
blob: 552d9fc6da4768424a4e0f01b7017fd321059131 (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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<!DOCTYPE html>
<head>

<script src="support/scrollbars.js"></script>

<style>
.horizontal-header {
  width: 120px;
}
.vertical-header {
  width: 60px;
}
.container-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: flex-start;
}
.container {
  flex: none;
  margin: 5px;
}
.ltr {
  direction: ltr;
}
.rtl {
  direction: rtl;
}
.horizontal {
  writing-mode: horizontal-tb;
}
.flipped-blocks {
  writing-mode: vertical-rl;
}
.flipped-lines {
  writing-mode: vertical-lr;
}
.flex {
  border: 2px solid red;
  overflow: scroll;
  max-width: 100px;
  max-height: 100px;
  white-space: nowrap;
}
.row > div, .row-reverse > div {
  display: inline-flex;
  margin: 3px;
}
.column > div, .column-reverse > div {
  display: flex;
  margin: 3px;
}

/* Adjust margins to account for collapsing. */
.horizontal > .column > .leaf1, .horizontal > .column > .leaf2 {
  margin: 3px 3px 6px 3px;
}
.flipped-blocks > .column > .leaf1, .flipped-blocks > .column > .leaf2 {
  margin: 3px 3px 3px 6px;
}
.flipped-lines > .column > .leaf1, .flipped-lines > .column > .leaf2 {
  margin: 3px 6px 3px 3px;
}

.horizontal > .column-reverse > .leaf1, .horizontal > .column-reverse > .leaf2 {
  margin: 6px 3px 3px 3px;
}
.flipped-blocks > .column-reverse > .leaf1, .flipped-blocks > .column-reverse > .leaf2 {
  margin: 3px 6px 3px 3px;
}
.flipped-lines > .column-reverse > .leaf1, .flipped-lines > .column-reverse > .leaf2 {
  margin: 3px 3px 3px 6px;
}

.flex > div {
  width: 30px;
  height: 30px;
  border: 2px solid blue;
  flex-direction: column;
  justify-content: center;
}
.flex > div > div {
  font-size: 20px;
  text-align: center;
  flex: none;
}
</style>

</head>

<div class="container-row">
  <div class="vertical-header ltr horizontal"></div>
  <div class="horizontal-header ltr horizontal">ltr<br>horizontal-tb</div>
  <div class="vertical-header ltr flipped-blocks">ltr<br>vertical-rl</div>
  <div class="vertical-header ltr flipped-blocks">ltr<br>vertical-lr</div>
  <div class="horizontal-header rtl horizontal">rtl<br>horizontal-tb</div>
  <div class="vertical-header rtl flipped-blocks">rtl<br>vertical-rl</div>
  <div class="vertical-header rtl flipped-blocks">rtl<br>vertical-lr</div>
</div>

<script>
// Override createContentNode to emulate reverse flow direction.
createContentNode = (flexDirection, textDirection, writingMode) => {
  var flexNode = document.createElement("div");
  flexNode.className = "flex " + flexDirection;
  flexNode.title = "flex-direction: " + flexDirection + "; direction: " + textDirection + "; writing-mode: " + writingMode;
  for (var i = 1; i < 4; i++)
    flexNode.appendChild(createLeafNode(flexDirection.endsWith("reverse") ? 4 - i : i));
  return flexNode;
}

flexDirections.forEach((flexDirection) => {
  var containerRow = createContainerRow(flexDirection);
  document.body.appendChild(containerRow);
});

// Scroll all flex containers to the emulated beginning of flow.
var nodes = document.querySelectorAll(".ltr > .row-reverse");
for (var i = 0; i < nodes.length; i++) {
  nodes[i].scrollLeft = 10000;
  nodes[i].scrollTop = 10000;
}
nodes = document.querySelectorAll(".rtl > .row-reverse");
for (var i = 0; i < nodes.length; i++) {
  nodes[i].scrollLeft = -10000;
  nodes[i].scrollTop = -10000;
}
nodes = document.querySelectorAll(".column-reverse");
for (var i = 0; i < nodes.length; i++) {
  nodes[i].scrollLeft = 10000;
  nodes[i].scrollTop = 10000;
}
nodes = document.querySelectorAll(".flipped-blocks > .column-reverse");
for (var i = 0; i < nodes.length; i++) {
  nodes[i].scrollLeft = -10000;
  nodes[i].scrollTop = 0;
}
</script>