mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Auto merge of #17754 - SergeevPavel:system-colors-refactor, r=SimonSapin
replace vector iteration by ascii_case_insensitive_phf_map <!-- Please describe your changes on the following line: --> --- <!-- 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 #15994 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- 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/17754) <!-- Reviewable:end -->
This commit is contained in:
commit
e7b195b060
1 changed files with 12 additions and 13 deletions
|
@ -121,22 +121,21 @@
|
||||||
|
|
||||||
impl SystemColor {
|
impl SystemColor {
|
||||||
pub fn parse<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
pub fn parse<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||||
#[cfg(feature = "gecko")]
|
ascii_case_insensitive_phf_map! {
|
||||||
use std::ascii::AsciiExt;
|
color_name -> SystemColor = {
|
||||||
static PARSE_ARRAY: &'static [(&'static str, SystemColor); ${len(system_colors)}] = &[
|
|
||||||
% for color in system_colors:
|
% for color in system_colors:
|
||||||
("${color}", LookAndFeel_ColorID::eColorID_${to_rust_ident(color)}),
|
"${color}" => LookAndFeel_ColorID::eColorID_${to_rust_ident(color)},
|
||||||
% endfor
|
% endfor
|
||||||
];
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let ident = input.expect_ident()?;
|
let ident = input.expect_ident()?;
|
||||||
for &(name, color) in PARSE_ARRAY.iter() {
|
if let Some(color) = color_name(&ident) {
|
||||||
if name.eq_ignore_ascii_case(&ident) {
|
Ok(*color)
|
||||||
return Ok(color)
|
} else {
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(SelectorParseError::UnexpectedIdent(ident).into())
|
Err(SelectorParseError::UnexpectedIdent(ident).into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
% endif
|
% endif
|
||||||
</%helpers:longhand>
|
</%helpers:longhand>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue