mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Auto merge of #15595 - deror1869107:use-bitflags, r=Wafflespeanut
Use bitflags for multikeyword properties <!-- Please describe your changes on the following line: --> Use bitflags for multikeyword properties --- <!-- 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 #15556 <!-- 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/15595) <!-- Reviewable:end -->
This commit is contained in:
commit
6e8d7b7d02
3 changed files with 31 additions and 31 deletions
|
@ -2567,16 +2567,16 @@ fn static_assert() {
|
||||||
|
|
||||||
pub fn set_text_decoration_line(&mut self, v: longhands::text_decoration_line::computed_value::T) {
|
pub fn set_text_decoration_line(&mut self, v: longhands::text_decoration_line::computed_value::T) {
|
||||||
let mut bits: u8 = 0;
|
let mut bits: u8 = 0;
|
||||||
if v.underline {
|
if v.contains(longhands::text_decoration_line::UNDERLINE) {
|
||||||
bits |= structs::NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE as u8;
|
bits |= structs::NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE as u8;
|
||||||
}
|
}
|
||||||
if v.overline {
|
if v.contains(longhands::text_decoration_line::OVERLINE) {
|
||||||
bits |= structs::NS_STYLE_TEXT_DECORATION_LINE_OVERLINE as u8;
|
bits |= structs::NS_STYLE_TEXT_DECORATION_LINE_OVERLINE as u8;
|
||||||
}
|
}
|
||||||
if v.line_through {
|
if v.contains(longhands::text_decoration_line::LINE_THROUGH) {
|
||||||
bits |= structs::NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH as u8;
|
bits |= structs::NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH as u8;
|
||||||
}
|
}
|
||||||
if v.blink {
|
if v.contains(longhands::text_decoration_line::BLINK) {
|
||||||
bits |= structs::NS_STYLE_TEXT_DECORATION_LINE_BLINK as u8;
|
bits |= structs::NS_STYLE_TEXT_DECORATION_LINE_BLINK as u8;
|
||||||
}
|
}
|
||||||
self.gecko.mTextDecorationLine = bits;
|
self.gecko.mTextDecorationLine = bits;
|
||||||
|
|
|
@ -114,13 +114,15 @@ ${helpers.single_keyword("unicode-bidi",
|
||||||
impl ComputedValueAsSpecified for SpecifiedValue {}
|
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||||
no_viewport_percentage!(SpecifiedValue);
|
no_viewport_percentage!(SpecifiedValue);
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
|
bitflags! {
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
pub struct SpecifiedValue {
|
pub flags SpecifiedValue: u8 {
|
||||||
pub underline: bool,
|
const NONE = 0,
|
||||||
pub overline: bool,
|
const OVERLINE = 0x01,
|
||||||
pub line_through: bool,
|
const UNDERLINE = 0x02,
|
||||||
pub blink: bool,
|
const LINE_THROUGH = 0x04,
|
||||||
|
const BLINK = 0x08,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToCss for SpecifiedValue {
|
impl ToCss for SpecifiedValue {
|
||||||
|
@ -128,7 +130,7 @@ ${helpers.single_keyword("unicode-bidi",
|
||||||
let mut has_any = false;
|
let mut has_any = false;
|
||||||
macro_rules! write_value {
|
macro_rules! write_value {
|
||||||
($line:ident => $css:expr) => {
|
($line:ident => $css:expr) => {
|
||||||
if self.$line {
|
if self.contains($line) {
|
||||||
if has_any {
|
if has_any {
|
||||||
dest.write_str(" ")?;
|
dest.write_str(" ")?;
|
||||||
}
|
}
|
||||||
|
@ -137,10 +139,10 @@ ${helpers.single_keyword("unicode-bidi",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
write_value!(underline => "underline");
|
write_value!(UNDERLINE => "underline");
|
||||||
write_value!(overline => "overline");
|
write_value!(OVERLINE => "overline");
|
||||||
write_value!(line_through => "line-through");
|
write_value!(LINE_THROUGH => "line-through");
|
||||||
write_value!(blink => "blink");
|
write_value!(BLINK => "blink");
|
||||||
if !has_any {
|
if !has_any {
|
||||||
dest.write_str("none")?;
|
dest.write_str("none")?;
|
||||||
}
|
}
|
||||||
|
@ -151,7 +153,7 @@ ${helpers.single_keyword("unicode-bidi",
|
||||||
pub type T = super::SpecifiedValue;
|
pub type T = super::SpecifiedValue;
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
pub const none: T = super::SpecifiedValue {
|
pub const none: T = super::SpecifiedValue {
|
||||||
underline: false, overline: false, line_through: false, blink: false
|
bits: 0
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#[inline] pub fn get_initial_value() -> computed_value::T {
|
#[inline] pub fn get_initial_value() -> computed_value::T {
|
||||||
|
@ -159,9 +161,7 @@ ${helpers.single_keyword("unicode-bidi",
|
||||||
}
|
}
|
||||||
/// none | [ underline || overline || line-through || blink ]
|
/// none | [ underline || overline || line-through || blink ]
|
||||||
pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||||
let mut result = SpecifiedValue {
|
let mut result = SpecifiedValue::empty();
|
||||||
underline: false, overline: false, line_through: false, blink: false
|
|
||||||
};
|
|
||||||
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
|
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
|
||||||
return Ok(result)
|
return Ok(result)
|
||||||
}
|
}
|
||||||
|
@ -170,14 +170,14 @@ ${helpers.single_keyword("unicode-bidi",
|
||||||
while input.try(|input| {
|
while input.try(|input| {
|
||||||
if let Ok(ident) = input.expect_ident() {
|
if let Ok(ident) = input.expect_ident() {
|
||||||
match_ignore_ascii_case! { ident,
|
match_ignore_ascii_case! { ident,
|
||||||
"underline" => if result.underline { return Err(()) }
|
"underline" => if result.contains(UNDERLINE) { return Err(()) }
|
||||||
else { empty = false; result.underline = true },
|
else { empty = false; result.insert(UNDERLINE) },
|
||||||
"overline" => if result.overline { return Err(()) }
|
"overline" => if result.contains(OVERLINE) { return Err(()) }
|
||||||
else { empty = false; result.overline = true },
|
else { empty = false; result.insert(OVERLINE) },
|
||||||
"line-through" => if result.line_through { return Err(()) }
|
"line-through" => if result.contains(LINE_THROUGH) { return Err(()) }
|
||||||
else { empty = false; result.line_through = true },
|
else { empty = false; result.insert(LINE_THROUGH) },
|
||||||
"blink" => if result.blink { return Err(()) }
|
"blink" => if result.contains(BLINK) { return Err(()) }
|
||||||
else { empty = false; result.blink = true },
|
else { empty = false; result.insert(BLINK) },
|
||||||
_ => return Err(())
|
_ => return Err(())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1288,19 +1288,19 @@ pub mod style_structs {
|
||||||
/// Whether the text decoration has an underline.
|
/// Whether the text decoration has an underline.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn has_underline(&self) -> bool {
|
pub fn has_underline(&self) -> bool {
|
||||||
self.${text_decoration_field}.underline
|
self.${text_decoration_field}.contains(longhands::${text_decoration_field}::UNDERLINE)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether the text decoration has an overline.
|
/// Whether the text decoration has an overline.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn has_overline(&self) -> bool {
|
pub fn has_overline(&self) -> bool {
|
||||||
self.${text_decoration_field}.overline
|
self.${text_decoration_field}.contains(longhands::${text_decoration_field}::OVERLINE)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether the text decoration has a line through.
|
/// Whether the text decoration has a line through.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn has_line_through(&self) -> bool {
|
pub fn has_line_through(&self) -> bool {
|
||||||
self.${text_decoration_field}.line_through
|
self.${text_decoration_field}.contains(longhands::${text_decoration_field}::LINE_THROUGH)
|
||||||
}
|
}
|
||||||
% endif
|
% endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue