mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
style: Make vertical writing mode (left/right) in text-emphasis-position optional
Differential Revision: https://phabricator.services.mozilla.com/D158399
This commit is contained in:
parent
d4742aefb9
commit
4dd841a036
4 changed files with 16 additions and 12 deletions
|
@ -221,9 +221,9 @@ ${helpers.predefined_type(
|
|||
${helpers.predefined_type(
|
||||
"text-emphasis-position",
|
||||
"TextEmphasisPosition",
|
||||
"computed::TextEmphasisPosition::DEFAULT",
|
||||
"computed::TextEmphasisPosition::OVER",
|
||||
engines="gecko",
|
||||
initial_specified_value="specified::TextEmphasisPosition::DEFAULT",
|
||||
initial_specified_value="specified::TextEmphasisPosition::OVER",
|
||||
animation_value_type="discrete",
|
||||
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-emphasis-position",
|
||||
)}
|
||||
|
|
|
@ -2242,7 +2242,7 @@ bitflags! {
|
|||
|
||||
impl ScrollbarGutter {
|
||||
#[inline]
|
||||
fn has_stable(self) -> bool {
|
||||
fn has_stable(&self) -> bool {
|
||||
self.intersects(Self::STABLE)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -774,7 +774,7 @@ impl Parse for TextEmphasisStyle {
|
|||
bitflags! {
|
||||
#[derive(MallocSizeOf, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem, Parse, ToCss)]
|
||||
#[repr(C)]
|
||||
#[css(bitflags(mixed="over,under,left,right", validate_mixed="Self::is_valid"))]
|
||||
#[css(bitflags(mixed="over,under,left,right", validate_mixed="Self::validate_and_simplify"))]
|
||||
/// Values for text-emphasis-position:
|
||||
/// <https://drafts.csswg.org/css-text-decor/#text-emphasis-position-property>
|
||||
pub struct TextEmphasisPosition: u8 {
|
||||
|
@ -786,17 +786,21 @@ bitflags! {
|
|||
const LEFT = 1 << 2;
|
||||
/// Draws marks to the right of the text in vertical writing mode.
|
||||
const RIGHT = 1 << 3;
|
||||
/// Returns the initial value of `text-emphasis-position`
|
||||
const DEFAULT = Self::OVER.bits | Self::RIGHT.bits;
|
||||
/// Non-standard behavior: Intelligent default for zh locale
|
||||
const DEFAULT_ZH = Self::UNDER.bits | Self::RIGHT.bits;
|
||||
}
|
||||
}
|
||||
|
||||
impl TextEmphasisPosition {
|
||||
fn is_valid(self) -> bool {
|
||||
return self.intersects(Self::LEFT) != self.intersects(Self::RIGHT) &&
|
||||
self.intersects(Self::OVER) != self.intersects(Self::UNDER);
|
||||
fn validate_and_simplify(&mut self) -> bool {
|
||||
if self.intersects(Self::OVER) == self.intersects(Self::UNDER) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if self.intersects(Self::LEFT) {
|
||||
return !self.intersects(Self::RIGHT);
|
||||
}
|
||||
|
||||
self.remove(Self::RIGHT); // Right is the default
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ fn parse_bitflags(bitflags: &CssBitflagAttrs) -> TokenStream {
|
|||
let mut validate_condition = quote! { !result.is_empty() };
|
||||
if let Some(ref function) = bitflags.validate_mixed {
|
||||
validate_condition.append_all(quote! {
|
||||
&& #function(result)
|
||||
&& #function(&mut result)
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue