mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +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,21 +121,20 @@
|
|||
|
||||
impl SystemColor {
|
||||
pub fn parse<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
#[cfg(feature = "gecko")]
|
||||
use std::ascii::AsciiExt;
|
||||
static PARSE_ARRAY: &'static [(&'static str, SystemColor); ${len(system_colors)}] = &[
|
||||
% for color in system_colors:
|
||||
("${color}", LookAndFeel_ColorID::eColorID_${to_rust_ident(color)}),
|
||||
% endfor
|
||||
];
|
||||
|
||||
let ident = input.expect_ident()?;
|
||||
for &(name, color) in PARSE_ARRAY.iter() {
|
||||
if name.eq_ignore_ascii_case(&ident) {
|
||||
return Ok(color)
|
||||
ascii_case_insensitive_phf_map! {
|
||||
color_name -> SystemColor = {
|
||||
% for color in system_colors:
|
||||
"${color}" => LookAndFeel_ColorID::eColorID_${to_rust_ident(color)},
|
||||
% endfor
|
||||
}
|
||||
}
|
||||
Err(SelectorParseError::UnexpectedIdent(ident).into())
|
||||
|
||||
let ident = input.expect_ident()?;
|
||||
if let Some(color) = color_name(&ident) {
|
||||
Ok(*color)
|
||||
} else {
|
||||
Err(SelectorParseError::UnexpectedIdent(ident).into())
|
||||
}
|
||||
}
|
||||
}
|
||||
% endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue