Skip to content

Commit 703e9b9

Browse files
committed
Teach the float and clear properties to the test generator
Signed-off-by: Nico Burns <[email protected]>
1 parent e9eac43 commit 703e9b9

File tree

6 files changed

+280
-0
lines changed

6 files changed

+280
-0
lines changed

scripts/gentest/src/main.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,25 @@ fn generate_node(ident: &str, node: &Value) -> TokenStream {
420420
_ => quote!(),
421421
};
422422

423+
let float = match style["cssFloat"] {
424+
Value::String(ref value) => match value.as_ref() {
425+
"left" => quote!(float: taffy::style::Float::Left,),
426+
"right" => quote!(float: taffy::style::Float::Right,),
427+
_ => quote!(),
428+
},
429+
_ => quote!(),
430+
};
431+
432+
let clear = match style["clear"] {
433+
Value::String(ref value) => match value.as_ref() {
434+
"left" => quote!(clear: taffy::style::Clear::Left,),
435+
"right" => quote!(clear: taffy::style::Clear::Right,),
436+
"both" => quote!(clear: taffy::style::Clear::Right,),
437+
_ => quote!(),
438+
},
439+
_ => quote!(),
440+
};
441+
423442
let flex_direction = match style["flexDirection"] {
424443
Value::String(ref value) => match value.as_ref() {
425444
"row-reverse" => quote!(flex_direction: taffy::style::FlexDirection::RowReverse,),
@@ -646,6 +665,8 @@ fn generate_node(ident: &str, node: &Value) -> TokenStream {
646665
#box_sizing
647666
#direction
648667
#position
668+
#float
669+
#clear
649670
#text_align
650671
#flex_direction
651672
#flex_wrap

scripts/gentest/test_helper.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ function describeElement(e) {
212212

213213
writingMode: parseEnum(e.style.writingMode),
214214

215+
cssFloat: parseEnum(e.style.cssFloat),
216+
clear: parseEnum(e.style.clear),
217+
215218
textAlign: parseEnum(e.style.textAlign),
216219

217220
flexDirection: parseEnum(e.style.flexDirection),
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<script src="../../scripts/gentest/test_helper.js"></script>
5+
<link rel="stylesheet" type="text/css" href="../../scripts/gentest/test_base_style.css">
6+
<title>
7+
Test description
8+
</title>
9+
</head>
10+
<body>
11+
12+
<div id="test-root" style="display: block; height: 300px; border: 2px solid red;">
13+
<div style="float: right; width: 50px; height: 50px; background: black;"></div>
14+
<div style="float: right; width: 50px; height: 50px; background: blue;"></div>
15+
<div style="float: right; width: 50px; height: 50px; background: green;"></div>
16+
<div style="float: right; width: 50px; height: 50px; background: pink;"></div>
17+
<div style="float: right; width: 50px; height: 50px; background: orange;"></div>
18+
</div>
19+
20+
</body>
21+
</html>

tests/generated/float/float_simple.rs

Lines changed: 233 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/generated/float/mod.rs

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/generated/mod.rs

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)