Skip to content

Commit 74ff58d

Browse files
committed
More line breaking properties
1 parent db9ac06 commit 74ff58d

File tree

4 files changed

+129
-0
lines changed

4 files changed

+129
-0
lines changed

src/lib.rs

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4007,4 +4007,100 @@ mod tests {
40074007
}
40084008
);
40094009
}
4010+
4011+
#[test]
4012+
fn test_word_break() {
4013+
minify_test(".foo { word-break: normal }", ".foo{word-break:normal}");
4014+
minify_test(".foo { word-break: keep-all }", ".foo{word-break:keep-all}");
4015+
minify_test(".foo { word-break: break-all }", ".foo{word-break:break-all}");
4016+
minify_test(".foo { word-break: break-word }", ".foo{word-break:break-word}");
4017+
}
4018+
4019+
#[test]
4020+
fn test_line_break() {
4021+
minify_test(".foo { line-break: auto }", ".foo{line-break:auto}");
4022+
minify_test(".foo { line-break: Loose }", ".foo{line-break:loose}");
4023+
minify_test(".foo { line-break: anywhere }", ".foo{line-break:anywhere}");
4024+
}
4025+
4026+
#[test]
4027+
fn test_wrap() {
4028+
minify_test(".foo { overflow-wrap: nOrmal }", ".foo{overflow-wrap:normal}");
4029+
minify_test(".foo { overflow-wrap: break-Word }", ".foo{overflow-wrap:break-word}");
4030+
minify_test(".foo { overflow-wrap: Anywhere }", ".foo{overflow-wrap:anywhere}");
4031+
minify_test(".foo { word-wrap: Normal }", ".foo{word-wrap:normal}");
4032+
minify_test(".foo { word-wrap: Break-wOrd }", ".foo{word-wrap:break-word}");
4033+
minify_test(".foo { word-wrap: Anywhere }", ".foo{word-wrap:anywhere}");
4034+
}
4035+
4036+
#[test]
4037+
fn test_hyphens() {
4038+
minify_test(".foo { hyphens: manual }", ".foo{hyphens:manual}");
4039+
minify_test(".foo { hyphens: auto }", ".foo{hyphens:auto}");
4040+
minify_test(".foo { hyphens: none }", ".foo{hyphens:none}");
4041+
minify_test(".foo { -webkit-hyphens: manual }", ".foo{-webkit-hyphens:manual}");
4042+
minify_test(".foo { -moz-hyphens: manual }", ".foo{-moz-hyphens:manual}");
4043+
minify_test(".foo { -ms-hyphens: manual }", ".foo{-ms-hyphens:manual}");
4044+
prefix_test(
4045+
".foo{ hyphens: manual }",
4046+
indoc! {r#"
4047+
.foo {
4048+
-webkit-hyphens: manual;
4049+
-moz-hyphens: manual;
4050+
-ms-hyphens: manual;
4051+
hyphens: manual;
4052+
}
4053+
"#},
4054+
Browsers {
4055+
safari: Some(14 << 16),
4056+
firefox: Some(40 << 16),
4057+
ie: Some(10 << 16),
4058+
..Browsers::default()
4059+
}
4060+
);
4061+
prefix_test(
4062+
r#"
4063+
.foo {
4064+
-webkit-hyphens: manual;
4065+
-moz-hyphens: manual;
4066+
-ms-hyphens: manual;
4067+
hyphens: manual;
4068+
}
4069+
"#,
4070+
indoc! {r#"
4071+
.foo {
4072+
-webkit-hyphens: manual;
4073+
hyphens: manual;
4074+
}
4075+
"#},
4076+
Browsers {
4077+
safari: Some(14 << 16),
4078+
chrome: Some(88 << 16),
4079+
firefox: Some(88 << 16),
4080+
edge: Some(79 << 16),
4081+
..Browsers::default()
4082+
}
4083+
);
4084+
prefix_test(
4085+
r#"
4086+
.foo {
4087+
-webkit-hyphens: manual;
4088+
-moz-hyphens: manual;
4089+
-ms-hyphens: manual;
4090+
hyphens: manual;
4091+
}
4092+
"#,
4093+
indoc! {r#"
4094+
.foo {
4095+
hyphens: manual;
4096+
}
4097+
"#},
4098+
Browsers {
4099+
chrome: Some(88 << 16),
4100+
firefox: Some(88 << 16),
4101+
edge: Some(79 << 16),
4102+
..Browsers::default()
4103+
}
4104+
);
4105+
}
40104106
}

src/properties/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,11 @@ define_properties! {
442442
"text-transform": TextTransform(TextTransform),
443443
"white-space": WhiteSpace(WhiteSpace),
444444
"tab-size": TabSize(LengthOrNumber, VendorPrefix) / "moz" / "o",
445+
"word-break": WordBreak(WordBreak),
446+
"line-break": LineBreak(LineBreak),
447+
"hyphens": Hyphens(Hyphens, VendorPrefix) / "webkit" / "moz" / "ms",
448+
"overflow-wrap": OverflowWrap(OverflowWrap),
449+
"word-wrap": WordWrap(OverflowWrap),
445450
}
446451

447452
impl<T: smallvec::Array<Item = V>, V: Parse> Parse for SmallVec<T> {

src/properties/prefix_handler.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,5 @@ define_prefixes! {
9595
BoxShadow,
9696
BoxSizing,
9797
TabSize,
98+
Hyphens,
9899
}

src/properties/text.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,30 @@ enum_property!(WhiteSpace,
123123
("break-spaces", BreakSpaces),
124124
("pre-line", PreLine)
125125
);
126+
127+
enum_property!(WordBreak,
128+
("normal", Normal),
129+
("keep-all", KeepAll),
130+
("break-all", BreakAll),
131+
("break-word", BreakWord)
132+
);
133+
134+
enum_property!(LineBreak,
135+
Auto,
136+
Loose,
137+
Normal,
138+
Strict,
139+
Anywhere
140+
);
141+
142+
enum_property!(Hyphens,
143+
None,
144+
Manual,
145+
Auto
146+
);
147+
148+
enum_property!(OverflowWrap,
149+
("normal", Normal),
150+
("break-word", BreakWord),
151+
("anywhere", Anywhere)
152+
);

0 commit comments

Comments
 (0)