mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #15174 - DexterHaslem:15165-webkit-text-stroke-sh-ord, r=SimonSapin
make -webkit-text-stroke color and width shorthand no longer sensitive to ordering <!-- Please describe your changes on the following line: --> this makes `-webkit-text-stroke` shorthand work with line-width and color in either order. I added a shorthand parser test to the existing inherited_text test, which wasn't very similar to any of the other tests in there, hope sticking shorthand below the longhand stuff is ok. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #15165 (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15174) <!-- Reviewable:end -->
This commit is contained in:
commit
2da1977108
2 changed files with 47 additions and 14 deletions
|
@ -76,25 +76,34 @@
|
|||
use values::specified::{BorderWidth, Length};
|
||||
use app_units::Au;
|
||||
|
||||
let (mut color, mut width, mut any) = (None, None, false);
|
||||
% for value in "color width".split():
|
||||
if ${value}.is_none() {
|
||||
if let Ok(value) = input.try(|input| _webkit_text_stroke_${value}::parse(context, input)) {
|
||||
${value} = Some(value);
|
||||
any = true;
|
||||
let mut color = None;
|
||||
let mut width = None;
|
||||
loop {
|
||||
if color.is_none() {
|
||||
if let Ok(value) = input.try(|input| _webkit_text_stroke_color::parse(context, input)) {
|
||||
color = Some(value);
|
||||
continue
|
||||
}
|
||||
}
|
||||
% endfor
|
||||
|
||||
if !any {
|
||||
return Err(());
|
||||
if width.is_none() {
|
||||
if let Ok(value) = input.try(|input| _webkit_text_stroke_width::parse(context, input)) {
|
||||
width = Some(value);
|
||||
continue
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
Ok(Longhands {
|
||||
_webkit_text_stroke_color: color.or(Some(CSSColor { parsed: CSSParserColor::CurrentColor,
|
||||
authored: None })),
|
||||
_webkit_text_stroke_width: width.or(Some(BorderWidth::from_length(Length::Absolute(Au::from_px(0))))),
|
||||
})
|
||||
if color.is_some() || width.is_some() {
|
||||
Ok(Longhands {
|
||||
_webkit_text_stroke_color: color.or(Some(CSSColor { parsed: CSSParserColor::CurrentColor,
|
||||
authored: None })),
|
||||
_webkit_text_stroke_width: width.or(Some(BorderWidth::from_length(Length::Absolute(Au::from_px(0))))),
|
||||
})
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue