File: start-edge-in-block-layout-direction.html

package info (click to toggle)
thunderbird 1%3A140.3.1esr-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,608,628 kB
  • sloc: cpp: 7,671,698; javascript: 5,901,131; ansic: 3,898,955; python: 1,413,270; xml: 653,997; asm: 462,284; java: 180,948; sh: 113,489; makefile: 20,460; perl: 14,288; objc: 13,059; yacc: 4,583; pascal: 3,352; lex: 1,720; ruby: 1,222; exp: 762; sql: 715; awk: 580; php: 436; lisp: 430; sed: 70; csh: 10
file content (167 lines) | stat: -rw-r--r-- 4,095 bytes parent folder | download | duplicates (8)
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<!DOCTYPE html>
<meta name="viewport" content="user-scalable=no"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>

body { margin: 0; }
html {
  line-height: 0;
  width: 200vw;
  height: 200vh;
}

html.ltr { direction: ltr; }
html.rtl { direction: rtl; }

html.horz { writing-mode: horizontal-tb; }
html.vlr { writing-mode: vertical-lr; }
html.vrl { writing-mode: vertical-rl; }
html.slr { writing-mode: sideways-lr; }
html.srl { writing-mode: sideways-rl; }

.horz.ltr .cx2, .vlr .cx2 { left: 100vw; }
.horz.rtl .cx2, .vrl .cx2 { right: 100vw; }
.horz .cy2, .ltr .cy2 { top: 100vh; }
.vlr.rtl .cy2, .vrl.rtl .cy2 { bottom: 100vh; }

#block_pusher, #inline_pusher {
  display: inline-block;
  width: 100px;
  height: 100px;
}
#block_pusher { background-color: #e88; }
#inline_pusher { background-color: #88e; }
.vpush { height: 80px !important; }
.hpush { width: 70px !important; }

#anchor-container {
  display: inline-block;
}
#anchor {
  position: relative;
  background-color: #8e8;
  min-width: 100px;
  min-height: 100px;
}

#grower { width: 0; height: 0; }
.grow {
  width: 180px !important;
  height: 160px !important;
}

</style>
<div id="container">
  <div id="block_pusher"></div><br>
  <div id="inline_pusher"></div><div id="anchor-container">
    <div id="anchor">
      <div id="grower"></div>
    </div>
  </div>
</div>
<script>

// Tests that anchoring adjustments are only on the block layout axis and that
// their magnitude is based on the movement of the block start edge of the
// anchor node, for all 6 combinations of text direction and writing mode,
// regardless of which corner of the viewport the anchor node overlaps.

var CORNERS = ["cx1 cy1", "cx2 cy1", "cx1 cy2", "cx2 cy2"];
var docEl = document.documentElement;
var scroller = document.scrollingElement;
var blockPusher = document.querySelector("#block_pusher");
var inlinePusher = document.querySelector("#inline_pusher");
var grower = document.querySelector("#grower");
var anchor = document.querySelector("#anchor");

function reset() {
  scroller.scrollLeft = 0;
  scroller.scrollTop = 0;
  blockPusher.className = "";
  inlinePusher.className = "";
  grower.className = "";
}

function runCase(docClass, xDir, yDir, vert, expectXAdj, expectYAdj, corner) {
  docEl.className = docClass;
  anchor.className = corner;

  var initX = 150 * xDir;
  var initY = 150 * yDir;

  scroller.scrollLeft = initX;
  scroller.scrollTop = initY;

  // Each corner moves a different distance.
  block_pusher.className = vert ? "hpush" : "vpush";
  inline_pusher.className = vert ? "vpush" : "hpush";
  grower.className = "grow";

  assert_equals(scroller.scrollLeft, initX + expectXAdj);
  assert_equals(scroller.scrollTop, initY + expectYAdj);

  reset();
}

test(() => {
  CORNERS.forEach((corner) => {
    runCase("horz ltr", 1, 1, false, 0, -20, corner);
  });
}, "Horizontal LTR.");

test(() => {
  CORNERS.forEach((corner) => {
    runCase("horz rtl", -1, 1, false, 0, -20, corner);
  });
}, "Horizontal RTL.");

test(() => {
  CORNERS.forEach((corner) => {
    runCase("vlr ltr", 1, 1, true, -30, 0, corner);
  });
}, "Vertical-LR LTR.");

test(() => {
  CORNERS.forEach((corner) => {
    runCase("vlr rtl", 1, -1, true, -30, 0, corner);
  });
}, "Vertical-LR RTL.");

test(() => {
  CORNERS.forEach((corner) => {
    runCase("vrl ltr", -1, 1, true, 30, 0, corner);
  });
}, "Vertical-RL LTR.");

test(() => {
  CORNERS.forEach((corner) => {
    runCase("vrl rtl", -1, -1, true, 30, 0, corner);
  });
}, "Vertical-RL RTL.");

test(() => {
  CORNERS.forEach((corner) => {
    runCase("slr ltr", 1, -1, true, -30, 0, corner);
  });
}, "Sideways-LR LTR.");

test(() => {
  CORNERS.forEach((corner) => {
    runCase("slr rtl", 1, 1, true, -30, 0, corner);
  });
}, "Sideways-LR RTL.");

test(() => {
  CORNERS.forEach((corner) => {
    runCase("srl ltr", -1, 1, true, 30, 0, corner);
  });
}, "Sideways-RL LTR.");

test(() => {
  CORNERS.forEach((corner) => {
    runCase("srl rtl", -1, -1, true, 30, 0, corner);
  });
}, "Sideways-RL RTL.");

</script>