mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Make all keywords CamelCase for consistency.
This prevents confusion and paves the ground for derive(Parse) of them.
This commit is contained in:
parent
37cd870a9e
commit
af879523ea
60 changed files with 921 additions and 836 deletions
|
@ -103,11 +103,11 @@ impl KeyframesAnimationState {
|
|||
|
||||
// Update the next iteration direction if applicable.
|
||||
match self.direction {
|
||||
AnimationDirection::alternate |
|
||||
AnimationDirection::alternate_reverse => {
|
||||
AnimationDirection::Alternate |
|
||||
AnimationDirection::AlternateReverse => {
|
||||
self.current_direction = match self.current_direction {
|
||||
AnimationDirection::normal => AnimationDirection::reverse,
|
||||
AnimationDirection::reverse => AnimationDirection::normal,
|
||||
AnimationDirection::Normal => AnimationDirection::Reverse,
|
||||
AnimationDirection::Reverse => AnimationDirection::Normal,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
}
|
||||
|
@ -551,15 +551,15 @@ pub fn maybe_start_animations(context: &SharedStyleContext,
|
|||
let animation_direction = box_style.animation_direction_mod(i);
|
||||
|
||||
let initial_direction = match animation_direction {
|
||||
AnimationDirection::normal |
|
||||
AnimationDirection::alternate => AnimationDirection::normal,
|
||||
AnimationDirection::reverse |
|
||||
AnimationDirection::alternate_reverse => AnimationDirection::reverse,
|
||||
AnimationDirection::Normal |
|
||||
AnimationDirection::Alternate => AnimationDirection::Normal,
|
||||
AnimationDirection::Reverse |
|
||||
AnimationDirection::AlternateReverse => AnimationDirection::Reverse,
|
||||
};
|
||||
|
||||
let running_state = match box_style.animation_play_state_mod(i) {
|
||||
AnimationPlayState::paused => KeyframesRunningState::Paused(0.),
|
||||
AnimationPlayState::running => KeyframesRunningState::Running,
|
||||
AnimationPlayState::Paused => KeyframesRunningState::Paused(0.),
|
||||
AnimationPlayState::Running => KeyframesRunningState::Running,
|
||||
};
|
||||
|
||||
|
||||
|
@ -677,7 +677,7 @@ pub fn update_style_for_animation(context: &SharedStyleContext,
|
|||
let last_keyframe_position;
|
||||
let target_keyframe_position;
|
||||
match state.current_direction {
|
||||
AnimationDirection::normal => {
|
||||
AnimationDirection::Normal => {
|
||||
target_keyframe_position =
|
||||
animation.steps.iter().position(|step| {
|
||||
total_progress as f32 <= step.start_percentage.0
|
||||
|
@ -687,7 +687,7 @@ pub fn update_style_for_animation(context: &SharedStyleContext,
|
|||
if pos != 0 { Some(pos - 1) } else { None }
|
||||
}).unwrap_or(0);
|
||||
}
|
||||
AnimationDirection::reverse => {
|
||||
AnimationDirection::Reverse => {
|
||||
target_keyframe_position =
|
||||
animation.steps.iter().rev().position(|step| {
|
||||
total_progress as f32 <= 1. - step.start_percentage.0
|
||||
|
@ -717,10 +717,10 @@ pub fn update_style_for_animation(context: &SharedStyleContext,
|
|||
let relative_timespan = (target_keyframe.start_percentage.0 - last_keyframe.start_percentage.0).abs();
|
||||
let relative_duration = relative_timespan as f64 * duration;
|
||||
let last_keyframe_ended_at = match state.current_direction {
|
||||
AnimationDirection::normal => {
|
||||
AnimationDirection::Normal => {
|
||||
state.started_at + (total_duration * last_keyframe.start_percentage.0 as f64)
|
||||
}
|
||||
AnimationDirection::reverse => {
|
||||
AnimationDirection::Reverse => {
|
||||
state.started_at + (total_duration * (1. - last_keyframe.start_percentage.0 as f64))
|
||||
}
|
||||
_ => unreachable!(),
|
||||
|
|
|
@ -11,7 +11,7 @@ use invalidation::element::restyle_hints::RestyleHint;
|
|||
#[cfg(feature = "gecko")]
|
||||
use malloc_size_of::MallocSizeOfOps;
|
||||
use properties::ComputedValues;
|
||||
use properties::longhands::display::computed_value as display;
|
||||
use properties::longhands::display::computed_value::T as Display;
|
||||
use rule_tree::StrongRuleNode;
|
||||
use selector_parser::{EAGER_PSEUDO_COUNT, PseudoElement, RestyleDamage};
|
||||
use selectors::NthIndexCache;
|
||||
|
@ -169,7 +169,7 @@ impl ElementStyles {
|
|||
|
||||
/// Whether this element `display` value is `none`.
|
||||
pub fn is_display_none(&self) -> bool {
|
||||
self.primary().get_box().clone_display() == display::T::none
|
||||
self.primary().get_box().clone_display() == Display::None
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
use cssparser::{ToCss, serialize_identifier};
|
||||
use gecko_bindings::structs::{self, CSSPseudoElementType};
|
||||
use properties::{ComputedValues, PropertyFlags};
|
||||
use properties::longhands::display::computed_value as display;
|
||||
use properties::longhands::display::computed_value::T as Display;
|
||||
use selector_parser::{NonTSPseudoClass, PseudoElementCascadeType, SelectorImpl};
|
||||
use std::fmt;
|
||||
use string_cache::Atom;
|
||||
|
@ -161,7 +161,7 @@ impl PseudoElement {
|
|||
/// Whether this pseudo-element should actually exist if it has
|
||||
/// the given styles.
|
||||
pub fn should_exist(&self, style: &ComputedValues) -> bool {
|
||||
if style.get_box().clone_display() == display::T::none {
|
||||
if style.get_box().clone_display() == Display::None {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -102,21 +102,21 @@ macro_rules! map_enum {
|
|||
|
||||
map_enum! {
|
||||
font_style {
|
||||
normal => NS_FONT_STYLE_NORMAL,
|
||||
italic => NS_FONT_STYLE_ITALIC,
|
||||
oblique => NS_FONT_STYLE_OBLIQUE,
|
||||
Normal => NS_FONT_STYLE_NORMAL,
|
||||
Italic => NS_FONT_STYLE_ITALIC,
|
||||
Oblique => NS_FONT_STYLE_OBLIQUE,
|
||||
}
|
||||
|
||||
font_stretch {
|
||||
normal => NS_FONT_STRETCH_NORMAL,
|
||||
ultra_condensed => NS_FONT_STRETCH_ULTRA_CONDENSED,
|
||||
extra_condensed => NS_FONT_STRETCH_EXTRA_CONDENSED,
|
||||
condensed => NS_FONT_STRETCH_CONDENSED,
|
||||
semi_condensed => NS_FONT_STRETCH_SEMI_CONDENSED,
|
||||
semi_expanded => NS_FONT_STRETCH_SEMI_EXPANDED,
|
||||
expanded => NS_FONT_STRETCH_EXPANDED,
|
||||
extra_expanded => NS_FONT_STRETCH_EXTRA_EXPANDED,
|
||||
ultra_expanded => NS_FONT_STRETCH_ULTRA_EXPANDED,
|
||||
Normal => NS_FONT_STRETCH_NORMAL,
|
||||
UltraCondensed => NS_FONT_STRETCH_ULTRA_CONDENSED,
|
||||
ExtraCondensed => NS_FONT_STRETCH_EXTRA_CONDENSED,
|
||||
Condensed => NS_FONT_STRETCH_CONDENSED,
|
||||
SemiCondensed => NS_FONT_STRETCH_SEMI_CONDENSED,
|
||||
SemiExpanded => NS_FONT_STRETCH_SEMI_EXPANDED,
|
||||
Expanded => NS_FONT_STRETCH_EXPANDED,
|
||||
ExtraExpanded => NS_FONT_STRETCH_EXTRA_EXPANDED,
|
||||
UltraExpanded => NS_FONT_STRETCH_ULTRA_EXPANDED,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1446,7 +1446,7 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
old_values: Option<&ComputedValues>,
|
||||
new_values: &ComputedValues,
|
||||
) -> bool {
|
||||
use properties::longhands::display::computed_value as display;
|
||||
use properties::longhands::display::computed_value::T as Display;
|
||||
|
||||
let old_values = match old_values {
|
||||
Some(v) => v,
|
||||
|
@ -1462,8 +1462,8 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
|
||||
new_box_style.transition_property_count() > 0 &&
|
||||
!transition_not_running &&
|
||||
(new_display_style != display::T::none &&
|
||||
old_display_style != display::T::none)
|
||||
(new_display_style != Display::None &&
|
||||
old_display_style != Display::None)
|
||||
}
|
||||
|
||||
// Detect if there are any changes that require us to update transitions.
|
||||
|
|
|
@ -42,34 +42,34 @@ bitflags!(
|
|||
impl WritingMode {
|
||||
/// Return a WritingMode bitflags from the relevant CSS properties.
|
||||
pub fn new(inheritedbox_style: &style_structs::InheritedBox) -> Self {
|
||||
use properties::longhands::direction::computed_value::T as direction;
|
||||
use properties::longhands::writing_mode::computed_value::T as writing_mode;
|
||||
use properties::longhands::direction::computed_value::T as Direction;
|
||||
use properties::longhands::writing_mode::computed_value::T as SpecifiedWritingMode;
|
||||
|
||||
let mut flags = WritingMode::empty();
|
||||
|
||||
match inheritedbox_style.clone_direction() {
|
||||
direction::ltr => {},
|
||||
direction::rtl => {
|
||||
Direction::Ltr => {},
|
||||
Direction::Rtl => {
|
||||
flags.insert(WritingMode::RTL);
|
||||
},
|
||||
}
|
||||
|
||||
match inheritedbox_style.clone_writing_mode() {
|
||||
writing_mode::horizontal_tb => {},
|
||||
writing_mode::vertical_rl => {
|
||||
SpecifiedWritingMode::HorizontalTb => {},
|
||||
SpecifiedWritingMode::VerticalRl => {
|
||||
flags.insert(WritingMode::VERTICAL);
|
||||
},
|
||||
writing_mode::vertical_lr => {
|
||||
SpecifiedWritingMode::VerticalLr => {
|
||||
flags.insert(WritingMode::VERTICAL);
|
||||
flags.insert(WritingMode::VERTICAL_LR);
|
||||
},
|
||||
#[cfg(feature = "gecko")]
|
||||
writing_mode::sideways_rl => {
|
||||
SpecifiedWritingMode::SidewaysRl => {
|
||||
flags.insert(WritingMode::VERTICAL);
|
||||
flags.insert(WritingMode::SIDEWAYS);
|
||||
},
|
||||
#[cfg(feature = "gecko")]
|
||||
writing_mode::sideways_lr => {
|
||||
SpecifiedWritingMode::SidewaysLr => {
|
||||
flags.insert(WritingMode::VERTICAL);
|
||||
flags.insert(WritingMode::VERTICAL_LR);
|
||||
flags.insert(WritingMode::LINE_INVERTED);
|
||||
|
@ -79,18 +79,18 @@ impl WritingMode {
|
|||
|
||||
#[cfg(feature = "gecko")]
|
||||
{
|
||||
use properties::longhands::text_orientation::computed_value::T as text_orientation;
|
||||
use properties::longhands::text_orientation::computed_value::T as TextOrientation;
|
||||
|
||||
// If FLAG_SIDEWAYS is already set, this means writing-mode is
|
||||
// either sideways-rl or sideways-lr, and for both of these values,
|
||||
// text-orientation has no effect.
|
||||
if !flags.intersects(WritingMode::SIDEWAYS) {
|
||||
match inheritedbox_style.clone_text_orientation() {
|
||||
text_orientation::mixed => {},
|
||||
text_orientation::upright => {
|
||||
TextOrientation::Mixed => {},
|
||||
TextOrientation::Upright => {
|
||||
flags.insert(WritingMode::UPRIGHT);
|
||||
},
|
||||
text_orientation::sideways => {
|
||||
TextOrientation::Sideways => {
|
||||
flags.insert(WritingMode::SIDEWAYS);
|
||||
},
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ use data::ElementData;
|
|||
use dom::TElement;
|
||||
use invalidation::element::restyle_hints::RestyleHint;
|
||||
use properties::ComputedValues;
|
||||
use properties::longhands::display::computed_value as display;
|
||||
use properties::longhands::display::computed_value::T as Display;
|
||||
use rule_tree::{CascadeLevel, StrongRuleNode};
|
||||
use selector_parser::{PseudoElement, RestyleDamage};
|
||||
use selectors::matching::ElementSelectorFlags;
|
||||
|
@ -151,11 +151,11 @@ trait PrivateMatchMethods: TElement {
|
|||
(context.shared.traversal_flags.contains(TraversalFlags::ForCSSRuleChanges) &&
|
||||
(has_new_animation_style || has_animations)) ||
|
||||
!old_box_style.animations_equals(new_box_style) ||
|
||||
(old_display_style == display::T::none &&
|
||||
new_display_style != display::T::none &&
|
||||
(old_display_style == Display::None &&
|
||||
new_display_style != Display::None &&
|
||||
has_new_animation_style) ||
|
||||
(old_display_style != display::T::none &&
|
||||
new_display_style == display::T::none &&
|
||||
(old_display_style != Display::None &&
|
||||
new_display_style == Display::None &&
|
||||
has_animations)
|
||||
})
|
||||
}
|
||||
|
@ -179,8 +179,8 @@ trait PrivateMatchMethods: TElement {
|
|||
let display_changed_from_none = old_values.map_or(false, |old| {
|
||||
let old_display_style = old.get_box().clone_display();
|
||||
let new_display_style = new_values.get_box().clone_display();
|
||||
old_display_style == display::T::none &&
|
||||
new_display_style != display::T::none
|
||||
old_display_style == Display::None &&
|
||||
new_display_style != Display::None
|
||||
});
|
||||
|
||||
if display_changed_from_none {
|
||||
|
@ -363,7 +363,7 @@ trait PrivateMatchMethods: TElement {
|
|||
// NOTE(emilio): Gecko has the special-case of -moz-binding, but
|
||||
// that gets handled on the frame constructor when processing
|
||||
// the reframe, so no need to handle that here.
|
||||
if old_display == display::T::none && old_display != new_display {
|
||||
if old_display == Display::None && old_display != new_display {
|
||||
return ChildCascadeRequirement::MustCascadeChildren
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// `data` comes from components/style/properties.mako.rs; see build.rs for more details.
|
||||
|
||||
<%!
|
||||
from data import to_rust_ident, to_camel_case, to_camel_case_lower
|
||||
from data import to_camel_case, to_camel_case_lower
|
||||
from data import Keyword
|
||||
%>
|
||||
<%namespace name="helpers" file="/helpers.mako.rs" />
|
||||
|
@ -258,7 +258,7 @@ impl ComputedValuesInner {
|
|||
|
||||
#[inline]
|
||||
pub fn is_display_contents(&self) -> bool {
|
||||
self.get_box().clone_display() == longhands::display::computed_value::T::contents
|
||||
self.get_box().clone_display() == longhands::display::computed_value::T::Contents
|
||||
}
|
||||
|
||||
/// Returns true if the value of the `content` property would make a
|
||||
|
@ -404,7 +404,7 @@ def set_gecko_property(ffi_name, expr):
|
|||
// FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts
|
||||
let result = match v {
|
||||
% for value in keyword.values_for('gecko'):
|
||||
Keyword::${to_rust_ident(value)} =>
|
||||
Keyword::${to_camel_case(value)} =>
|
||||
structs::${keyword.gecko_constant(value)} ${keyword.maybe_cast(cast_type)},
|
||||
% endfor
|
||||
};
|
||||
|
@ -437,7 +437,7 @@ def set_gecko_property(ffi_name, expr):
|
|||
|
||||
match ${get_gecko_property(gecko_ffi_name)} as ${cast_type} {
|
||||
% for value in keyword.values_for('gecko'):
|
||||
${keyword.casted_constant_name(value, cast_type)} => Keyword::${to_rust_ident(value)},
|
||||
${keyword.casted_constant_name(value, cast_type)} => Keyword::${to_camel_case(value)},
|
||||
% endfor
|
||||
% if keyword.gecko_inexhaustive:
|
||||
x => panic!("Found unexpected value in style struct for ${ident} property: {:?}", x),
|
||||
|
@ -446,7 +446,7 @@ def set_gecko_property(ffi_name, expr):
|
|||
% else:
|
||||
match ${get_gecko_property(gecko_ffi_name)} {
|
||||
% for value in keyword.values_for('gecko'):
|
||||
structs::${keyword.gecko_constant(value)} => Keyword::${to_rust_ident(value)},
|
||||
structs::${keyword.gecko_constant(value)} => Keyword::${to_camel_case(value)},
|
||||
% endfor
|
||||
% if keyword.gecko_inexhaustive:
|
||||
x => panic!("Found unexpected value in style struct for ${ident} property: {:?}", x),
|
||||
|
@ -2348,7 +2348,7 @@ fn static_assert() {
|
|||
// cast + static_asserts
|
||||
let result = match v {
|
||||
% for value in border_style_keyword.values_for('gecko'):
|
||||
Either::Second(border_style::T::${to_rust_ident(value)}) =>
|
||||
Either::Second(border_style::T::${to_camel_case(value)}) =>
|
||||
structs::${border_style_keyword.gecko_constant(value)} ${border_style_keyword.maybe_cast("u8")},
|
||||
% endfor
|
||||
Either::First(Auto) =>
|
||||
|
@ -2377,7 +2377,9 @@ fn static_assert() {
|
|||
// FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts
|
||||
match ${get_gecko_property("mOutlineStyle")} ${border_style_keyword.maybe_cast("u32")} {
|
||||
% for value in border_style_keyword.values_for('gecko'):
|
||||
structs::${border_style_keyword.gecko_constant(value)} => Either::Second(border_style::T::${value}),
|
||||
structs::${border_style_keyword.gecko_constant(value)} => {
|
||||
Either::Second(border_style::T::${to_camel_case(value)})
|
||||
},
|
||||
% endfor
|
||||
structs::${border_style_keyword.gecko_constant('auto')} => Either::First(Auto),
|
||||
% if border_style_keyword.gecko_inexhaustive:
|
||||
|
@ -3065,7 +3067,7 @@ fn static_assert() {
|
|||
for (gecko, servo) in self.gecko.mAnimations.iter_mut().zip(v.cycle()) {
|
||||
let result = match servo {
|
||||
% for value in keyword.gecko_values():
|
||||
Keyword::${to_rust_ident(value)} =>
|
||||
Keyword::${to_camel_case(value)} =>
|
||||
structs::${keyword.gecko_constant(value)} ${keyword.maybe_cast(cast_type)},
|
||||
% endfor
|
||||
};
|
||||
|
@ -3078,7 +3080,7 @@ fn static_assert() {
|
|||
use properties::longhands::animation_${ident}::single_value::computed_value::T as Keyword;
|
||||
match self.gecko.mAnimations[index].m${gecko_ffi_name} ${keyword.maybe_cast("u32")} {
|
||||
% for value in keyword.gecko_values():
|
||||
structs::${keyword.gecko_constant(value)} => Keyword::${to_rust_ident(value)},
|
||||
structs::${keyword.gecko_constant(value)} => Keyword::${to_camel_case(value)},
|
||||
% endfor
|
||||
x => panic!("Found unexpected value for animation-${ident}: {:?}", x),
|
||||
}
|
||||
|
@ -3121,7 +3123,7 @@ fn static_assert() {
|
|||
// FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts
|
||||
let result = match v {
|
||||
% for value in display_keyword.values_for('gecko'):
|
||||
Keyword::${to_rust_ident(value)} =>
|
||||
Keyword::${to_camel_case(value)} =>
|
||||
structs::${display_keyword.gecko_constant(value)},
|
||||
% endfor
|
||||
};
|
||||
|
@ -3138,7 +3140,7 @@ fn static_assert() {
|
|||
use properties::longhands::display::computed_value::T as Keyword;
|
||||
let result = match v {
|
||||
% for value in display_keyword.values_for('gecko'):
|
||||
Keyword::${to_rust_ident(value)} =>
|
||||
Keyword::${to_camel_case(value)} =>
|
||||
structs::${display_keyword.gecko_constant(value)},
|
||||
% endfor
|
||||
};
|
||||
|
@ -3162,7 +3164,7 @@ fn static_assert() {
|
|||
// FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts
|
||||
self.gecko.mOverflowY = match v {
|
||||
% for value in overflow_x.keyword.values_for('gecko'):
|
||||
BaseType::${to_rust_ident(value)} => structs::${overflow_x.keyword.gecko_constant(value)} as u8,
|
||||
BaseType::${to_camel_case(value)} => structs::${overflow_x.keyword.gecko_constant(value)} as u8,
|
||||
% endfor
|
||||
};
|
||||
}
|
||||
|
@ -3172,7 +3174,7 @@ fn static_assert() {
|
|||
// FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts
|
||||
match self.gecko.mOverflowY as u32 {
|
||||
% for value in overflow_x.keyword.values_for('gecko'):
|
||||
structs::${overflow_x.keyword.gecko_constant(value)} => BaseType::${to_rust_ident(value)},
|
||||
structs::${overflow_x.keyword.gecko_constant(value)} => BaseType::${to_camel_case(value)},
|
||||
% endfor
|
||||
x => panic!("Found unexpected value in style struct for overflow_y property: {}", x),
|
||||
}
|
||||
|
@ -3228,11 +3230,11 @@ fn static_assert() {
|
|||
use computed_values::page_break_${kind}::T;
|
||||
|
||||
let result = match v {
|
||||
T::auto => false,
|
||||
T::always => true,
|
||||
T::avoid => false,
|
||||
T::left => true,
|
||||
T::right => true
|
||||
T::Auto => false,
|
||||
T::Always => true,
|
||||
T::Avoid => false,
|
||||
T::Left => true,
|
||||
T::Right => true
|
||||
};
|
||||
self.gecko.mBreak${kind.title()} = result;
|
||||
}
|
||||
|
@ -3244,10 +3246,7 @@ fn static_assert() {
|
|||
pub fn clone_page_break_${kind}(&self) -> longhands::page_break_${kind}::computed_value::T {
|
||||
use computed_values::page_break_${kind}::T;
|
||||
|
||||
match self.gecko.mBreak${kind.title()} {
|
||||
true => T::always,
|
||||
false => T::auto,
|
||||
}
|
||||
if self.gecko.mBreak${kind.title()} { T::Always } else { T::Auto }
|
||||
}
|
||||
% endfor
|
||||
|
||||
|
@ -3776,7 +3775,7 @@ fn static_assert() {
|
|||
geckolayer.${field_name} = {
|
||||
match servo {
|
||||
% for value in keyword.values_for("gecko"):
|
||||
Keyword::${to_rust_ident(value)} =>
|
||||
Keyword::${to_camel_case(value)} =>
|
||||
structs::${keyword.gecko_constant(value)} ${keyword.maybe_cast('u8')},
|
||||
% endfor
|
||||
}
|
||||
|
@ -3805,7 +3804,7 @@ fn static_assert() {
|
|||
% else:
|
||||
structs::${keyword.gecko_constant(value)}
|
||||
% endif
|
||||
=> Keyword::${to_rust_ident(value)},
|
||||
=> Keyword::${to_camel_case(value)},
|
||||
% endfor
|
||||
x => panic!("Found unexpected value in style struct for ${ident} property: {:?}", x),
|
||||
}
|
||||
|
|
|
@ -441,7 +441,7 @@
|
|||
use style_traits::ParseError;
|
||||
define_css_keyword_enum! { T:
|
||||
% for value in keyword.values_for(product):
|
||||
"${value}" => ${to_rust_ident(value)},
|
||||
"${value}" => ${to_camel_case(value)},
|
||||
% endfor
|
||||
}
|
||||
|
||||
|
@ -486,11 +486,11 @@
|
|||
|
||||
#[inline]
|
||||
pub fn get_initial_value() -> computed_value::T {
|
||||
computed_value::T::${to_rust_ident(values.split()[0])}
|
||||
computed_value::T::${to_camel_case(values.split()[0])}
|
||||
}
|
||||
#[inline]
|
||||
pub fn get_initial_specified_value() -> SpecifiedValue {
|
||||
SpecifiedValue::Keyword(computed_value::T::${to_rust_ident(values.split()[0])})
|
||||
SpecifiedValue::Keyword(computed_value::T::${to_camel_case(values.split()[0])})
|
||||
}
|
||||
|
||||
impl SpecifiedValue {
|
||||
|
@ -510,6 +510,8 @@
|
|||
|
||||
<%def name="single_keyword(name, values, vector=False, **kwargs)">
|
||||
<%call expr="single_keyword_computed(name, values, vector, **kwargs)">
|
||||
// FIXME(emilio): WTF is this even trying to do? Those are no-ops,
|
||||
// should be derived instead!
|
||||
impl ToComputedValue for SpecifiedValue {
|
||||
type ComputedValue = computed_value::T;
|
||||
|
||||
|
@ -517,7 +519,7 @@
|
|||
fn to_computed_value(&self, _context: &Context) -> computed_value::T {
|
||||
match *self {
|
||||
% for value in data.longhands_by_name[name].keyword.values_for(product):
|
||||
SpecifiedValue::${to_rust_ident(value)} => computed_value::T::${to_rust_ident(value)},
|
||||
SpecifiedValue::${to_camel_case(value)} => computed_value::T::${to_camel_case(value)},
|
||||
% endfor
|
||||
}
|
||||
}
|
||||
|
@ -525,7 +527,7 @@
|
|||
fn from_computed_value(computed: &computed_value::T) -> Self {
|
||||
match *computed {
|
||||
% for value in data.longhands_by_name[name].keyword.values_for(product):
|
||||
computed_value::T::${to_rust_ident(value)} => SpecifiedValue::${to_rust_ident(value)},
|
||||
computed_value::T::${to_camel_case(value)} => SpecifiedValue::${to_camel_case(value)},
|
||||
% endfor
|
||||
}
|
||||
}
|
||||
|
@ -554,7 +556,7 @@
|
|||
% endfor
|
||||
match kw ${maybe_cast} {
|
||||
% for value in values:
|
||||
${to_rust_ident(value).upper()} => ${type}::${to_rust_ident(value)},
|
||||
${to_rust_ident(value).upper()} => ${type}::${to_camel_case(value)},
|
||||
% endfor
|
||||
x => panic!("Found unexpected value in style struct for ${keyword.name} property: {:?}", x),
|
||||
}
|
||||
|
@ -616,12 +618,12 @@
|
|||
define_css_keyword_enum! { SpecifiedValue:
|
||||
values {
|
||||
% for value in keyword.values_for(product) + (extra_specified or "").split():
|
||||
"${value}" => ${to_rust_ident(value)},
|
||||
"${value}" => ${to_camel_case(value)},
|
||||
% endfor
|
||||
}
|
||||
aliases {
|
||||
% for alias, value in keyword.aliases_for(product).iteritems():
|
||||
"${alias}" => ${to_rust_ident(value)},
|
||||
"${alias}" => ${to_camel_case(value)},
|
||||
% endfor
|
||||
}
|
||||
}
|
||||
|
@ -631,17 +633,17 @@
|
|||
pub mod computed_value {
|
||||
define_css_keyword_enum! { T:
|
||||
% for value in data.longhands_by_name[name].keyword.values_for(product):
|
||||
"${value}" => ${to_rust_ident(value)},
|
||||
"${value}" => ${to_camel_case(value)},
|
||||
% endfor
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn get_initial_value() -> computed_value::T {
|
||||
computed_value::T::${to_rust_ident(values.split()[0])}
|
||||
computed_value::T::${to_camel_case(values.split()[0])}
|
||||
}
|
||||
#[inline]
|
||||
pub fn get_initial_specified_value() -> SpecifiedValue {
|
||||
SpecifiedValue::${to_rust_ident(values.split()[0])}
|
||||
SpecifiedValue::${to_camel_case(values.split()[0])}
|
||||
}
|
||||
#[inline]
|
||||
pub fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
|
|
|
@ -658,10 +658,10 @@ impl Animate for Visibility {
|
|||
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
|
||||
let (this_weight, other_weight) = procedure.weights();
|
||||
match (*self, *other) {
|
||||
(Visibility::visible, _) => {
|
||||
(Visibility::Visible, _) => {
|
||||
Ok(if this_weight > 0.0 { *self } else { *other })
|
||||
},
|
||||
(_, Visibility::visible) => {
|
||||
(_, Visibility::Visible) => {
|
||||
Ok(if other_weight > 0.0 { *other } else { *self })
|
||||
},
|
||||
_ => Err(()),
|
||||
|
@ -763,7 +763,7 @@ impl Animate for FontStretch {
|
|||
{
|
||||
let from = f64::from(*self);
|
||||
let to = f64::from(*other);
|
||||
let normal = f64::from(FontStretch::normal);
|
||||
let normal = f64::from(FontStretch::Normal);
|
||||
let (this_weight, other_weight) = procedure.weights();
|
||||
let result = (from - normal) * this_weight + (to - normal) * other_weight + normal;
|
||||
Ok(result.into())
|
||||
|
@ -788,15 +788,15 @@ impl From<FontStretch> for f64 {
|
|||
fn from(stretch: FontStretch) -> f64 {
|
||||
use self::FontStretch::*;
|
||||
match stretch {
|
||||
ultra_condensed => 1.0,
|
||||
extra_condensed => 2.0,
|
||||
condensed => 3.0,
|
||||
semi_condensed => 4.0,
|
||||
normal => 5.0,
|
||||
semi_expanded => 6.0,
|
||||
expanded => 7.0,
|
||||
extra_expanded => 8.0,
|
||||
ultra_expanded => 9.0,
|
||||
UltraCondensed => 1.0,
|
||||
ExtraCondensed => 2.0,
|
||||
Condensed => 3.0,
|
||||
SemiCondensed => 4.0,
|
||||
Normal => 5.0,
|
||||
SemiExpanded => 6.0,
|
||||
Expanded => 7.0,
|
||||
ExtraExpanded => 8.0,
|
||||
UltraExpanded => 9.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -806,8 +806,8 @@ impl Into<FontStretch> for f64 {
|
|||
use properties::longhands::font_stretch::computed_value::T::*;
|
||||
let index = (self + 0.5).floor().min(9.0).max(1.0);
|
||||
static FONT_STRETCH_ENUM_MAP: [FontStretch; 9] =
|
||||
[ ultra_condensed, extra_condensed, condensed, semi_condensed, normal,
|
||||
semi_expanded, expanded, extra_expanded, ultra_expanded ];
|
||||
[ UltraCondensed, ExtraCondensed, Condensed, SemiCondensed, Normal,
|
||||
SemiExpanded, Expanded, ExtraExpanded, UltraExpanded ];
|
||||
FONT_STRETCH_ENUM_MAP[(index - 1.0) as usize]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
)}
|
||||
|
||||
${helpers.predefined_type("border-%s-style" % side_name, "BorderStyle",
|
||||
"specified::BorderStyle::none",
|
||||
"specified::BorderStyle::None",
|
||||
alias=maybe_moz_logical_alias(product, side, "-moz-border-%s-style"),
|
||||
spec=maybe_logical_spec(side, "style"),
|
||||
flags="APPLIES_TO_FIRST_LETTER",
|
||||
|
|
|
@ -37,19 +37,20 @@
|
|||
|
||||
pub mod computed_value {
|
||||
pub use super::SpecifiedValue as T;
|
||||
use super::SpecifiedValue as Display;
|
||||
|
||||
impl T {
|
||||
impl Display {
|
||||
/// Returns whether this "display" value is the display of a flex or
|
||||
/// grid container.
|
||||
///
|
||||
/// This is used to implement various style fixups.
|
||||
pub fn is_item_container(&self) -> bool {
|
||||
matches!(*self,
|
||||
T::flex
|
||||
| T::inline_flex
|
||||
Display::Flex
|
||||
| Display::InlineFlex
|
||||
% if product == "gecko":
|
||||
| T::grid
|
||||
| T::inline_grid
|
||||
| Display::Grid
|
||||
| Display::InlineGrid
|
||||
% endif
|
||||
)
|
||||
}
|
||||
|
@ -59,11 +60,11 @@
|
|||
/// line as itself.
|
||||
pub fn is_line_participant(&self) -> bool {
|
||||
matches!(*self,
|
||||
T::inline
|
||||
Display::Inline
|
||||
% if product == "gecko":
|
||||
| T::contents
|
||||
| T::ruby
|
||||
| T::ruby_base_container
|
||||
| Display::Contents
|
||||
| Display::Ruby
|
||||
| Display::RubyBaseContainer
|
||||
% endif
|
||||
)
|
||||
}
|
||||
|
@ -84,8 +85,8 @@
|
|||
#[cfg(feature = "gecko")]
|
||||
{
|
||||
match (_old_display, _new_display) {
|
||||
(T::_webkit_box, T::_moz_box) |
|
||||
(T::_webkit_inline_box, T::_moz_inline_box) => {
|
||||
(Display::WebkitBox, Display::MozBox) |
|
||||
(Display::WebkitInlineBox, Display::MozInlineBox) => {
|
||||
return true;
|
||||
}
|
||||
_ => {},
|
||||
|
@ -99,14 +100,20 @@
|
|||
/// ruby.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub fn is_ruby_type(&self) -> bool {
|
||||
matches!(*self, T::ruby | T::ruby_base | T::ruby_text |
|
||||
T::ruby_base_container | T::ruby_text_container)
|
||||
matches!(*self,
|
||||
Display::Ruby |
|
||||
Display::RubyBase |
|
||||
Display::RubyText |
|
||||
Display::RubyBaseContainer |
|
||||
Display::RubyTextContainer)
|
||||
}
|
||||
|
||||
/// Returns whether this "display" value is a ruby level container.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub fn is_ruby_level_container(&self) -> bool {
|
||||
matches!(*self, T::ruby_base_container | T::ruby_text_container)
|
||||
matches!(*self,
|
||||
Display::RubyBaseContainer |
|
||||
Display::RubyTextContainer)
|
||||
}
|
||||
|
||||
/// Convert this display into an equivalent block display.
|
||||
|
@ -115,28 +122,36 @@
|
|||
pub fn equivalent_block_display(&self, _is_root_element: bool) -> Self {
|
||||
match *self {
|
||||
// Values that have a corresponding block-outside version.
|
||||
T::inline_table => T::table,
|
||||
T::inline_flex => T::flex,
|
||||
Display::InlineTable => Display::Table,
|
||||
Display::InlineFlex => Display::Flex,
|
||||
|
||||
% if product == "gecko":
|
||||
T::inline_grid => T::grid,
|
||||
T::_webkit_inline_box => T::_webkit_box,
|
||||
Display::InlineGrid => Display::Grid,
|
||||
Display::WebkitInlineBox => Display::WebkitBox,
|
||||
% endif
|
||||
|
||||
// Special handling for contents and list-item on the root
|
||||
// element for Gecko.
|
||||
% if product == "gecko":
|
||||
T::contents | T::list_item if _is_root_element => T::block,
|
||||
Display::Contents | Display::ListItem if _is_root_element => Display::Block,
|
||||
% endif
|
||||
|
||||
// These are not changed by blockification.
|
||||
T::none | T::block | T::flex | T::list_item | T::table => *self,
|
||||
Display::None |
|
||||
Display::Block |
|
||||
Display::Flex |
|
||||
Display::ListItem |
|
||||
Display::Table => *self,
|
||||
|
||||
% if product == "gecko":
|
||||
T::contents | T::flow_root | T::grid | T::_webkit_box => *self,
|
||||
Display::Contents |
|
||||
Display::FlowRoot |
|
||||
Display::Grid |
|
||||
Display::WebkitBox => *self,
|
||||
% endif
|
||||
|
||||
// Everything else becomes block.
|
||||
_ => T::block,
|
||||
_ => Display::Block,
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -148,35 +163,38 @@
|
|||
#[cfg(feature = "gecko")]
|
||||
pub fn inlinify(&self) -> Self {
|
||||
match *self {
|
||||
T::block | T::flow_root => T::inline_block,
|
||||
T::table => T::inline_table,
|
||||
T::flex => T::inline_flex,
|
||||
T::grid => T::inline_grid,
|
||||
T::_moz_box => T::_moz_inline_box,
|
||||
T::_moz_stack => T::_moz_inline_stack,
|
||||
T::_webkit_box => T::_webkit_inline_box,
|
||||
Display::Block |
|
||||
Display::FlowRoot => Display::InlineBlock,
|
||||
Display::Table => Display::InlineTable,
|
||||
Display::Flex => Display::InlineFlex,
|
||||
Display::Grid => Display::InlineGrid,
|
||||
Display::MozBox => Display::MozInlineBox,
|
||||
Display::MozStack => Display::MozInlineStack,
|
||||
Display::WebkitBox => Display::WebkitInlineBox,
|
||||
other => other,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME(emilio): Why does this reinvent the wheel, again?
|
||||
#[allow(non_camel_case_types)]
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue)]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
pub enum SpecifiedValue {
|
||||
% for value in values:
|
||||
${to_rust_ident(value)},
|
||||
${to_camel_case(value)},
|
||||
% endfor
|
||||
}
|
||||
|
||||
// TODO(emilio): derive.
|
||||
impl ToCss for SpecifiedValue {
|
||||
fn to_css<W>(&self, dest: &mut W) -> ::std::fmt::Result
|
||||
where W: ::std::fmt::Write,
|
||||
{
|
||||
match *self {
|
||||
% for value in values:
|
||||
SpecifiedValue::${to_rust_ident(value)} => dest.write_str("${value}"),
|
||||
SpecifiedValue::${to_camel_case(value)} => dest.write_str("${value}"),
|
||||
% endfor
|
||||
}
|
||||
}
|
||||
|
@ -185,7 +203,7 @@
|
|||
/// The initial display value.
|
||||
#[inline]
|
||||
pub fn get_initial_value() -> computed_value::T {
|
||||
computed_value::T::${to_rust_ident(values[0])}
|
||||
computed_value::T::${to_camel_case(values[0])}
|
||||
}
|
||||
|
||||
/// Parse a display value.
|
||||
|
@ -194,12 +212,12 @@
|
|||
try_match_ident_ignore_ascii_case! { input,
|
||||
% for value in values:
|
||||
"${value}" => {
|
||||
Ok(computed_value::T::${to_rust_ident(value)})
|
||||
Ok(computed_value::T::${to_camel_case(value)})
|
||||
},
|
||||
% endfor
|
||||
% for value in webkit_prefixed_values:
|
||||
"-webkit-${value}" => {
|
||||
Ok(computed_value::T::${to_rust_ident(value)})
|
||||
Ok(computed_value::T::${to_camel_case(value)})
|
||||
},
|
||||
% endfor
|
||||
}
|
||||
|
@ -250,25 +268,25 @@ ${helpers.single_keyword("position", "static absolute relative fixed sticky",
|
|||
let ltr = context.style().writing_mode.is_bidi_ltr();
|
||||
// https://drafts.csswg.org/css-logical-props/#float-clear
|
||||
match *self {
|
||||
SpecifiedValue::inline_start => {
|
||||
SpecifiedValue::InlineStart => {
|
||||
context.rule_cache_conditions.borrow_mut()
|
||||
.set_writing_mode_dependency(context.builder.writing_mode);
|
||||
if ltr {
|
||||
computed_value::T::left
|
||||
computed_value::T::Left
|
||||
} else {
|
||||
computed_value::T::right
|
||||
computed_value::T::Right
|
||||
}
|
||||
}
|
||||
SpecifiedValue::inline_end => {
|
||||
SpecifiedValue::InlineEnd => {
|
||||
context.rule_cache_conditions.borrow_mut()
|
||||
.set_writing_mode_dependency(context.builder.writing_mode);
|
||||
if ltr {
|
||||
computed_value::T::right
|
||||
computed_value::T::Right
|
||||
} else {
|
||||
computed_value::T::left
|
||||
computed_value::T::Left
|
||||
}
|
||||
}
|
||||
% for value in "none left right".split():
|
||||
% for value in "None Left Right".split():
|
||||
SpecifiedValue::${value} => computed_value::T::${value},
|
||||
% endfor
|
||||
}
|
||||
|
@ -276,7 +294,7 @@ ${helpers.single_keyword("position", "static absolute relative fixed sticky",
|
|||
#[inline]
|
||||
fn from_computed_value(computed: &computed_value::T) -> SpecifiedValue {
|
||||
match *computed {
|
||||
% for value in "none left right".split():
|
||||
% for value in "None Left Right".split():
|
||||
computed_value::T::${value} => SpecifiedValue::${value},
|
||||
% endfor
|
||||
}
|
||||
|
@ -302,25 +320,25 @@ ${helpers.single_keyword("position", "static absolute relative fixed sticky",
|
|||
let ltr = context.style().writing_mode.is_bidi_ltr();
|
||||
// https://drafts.csswg.org/css-logical-props/#float-clear
|
||||
match *self {
|
||||
SpecifiedValue::inline_start => {
|
||||
SpecifiedValue::InlineStart => {
|
||||
context.rule_cache_conditions.borrow_mut()
|
||||
.set_writing_mode_dependency(context.builder.writing_mode);
|
||||
if ltr {
|
||||
computed_value::T::left
|
||||
computed_value::T::Left
|
||||
} else {
|
||||
computed_value::T::right
|
||||
computed_value::T::Right
|
||||
}
|
||||
}
|
||||
SpecifiedValue::inline_end => {
|
||||
SpecifiedValue::InlineEnd => {
|
||||
context.rule_cache_conditions.borrow_mut()
|
||||
.set_writing_mode_dependency(context.builder.writing_mode);
|
||||
if ltr {
|
||||
computed_value::T::right
|
||||
computed_value::T::Right
|
||||
} else {
|
||||
computed_value::T::left
|
||||
computed_value::T::Left
|
||||
}
|
||||
}
|
||||
% for value in "none left right both".split():
|
||||
% for value in "None Left Right Both".split():
|
||||
SpecifiedValue::${value} => computed_value::T::${value},
|
||||
% endfor
|
||||
}
|
||||
|
@ -328,7 +346,7 @@ ${helpers.single_keyword("position", "static absolute relative fixed sticky",
|
|||
#[inline]
|
||||
fn from_computed_value(computed: &computed_value::T) -> SpecifiedValue {
|
||||
match *computed {
|
||||
% for value in "none left right both".split():
|
||||
% for value in "None Left Right Both".split():
|
||||
computed_value::T::${value} => SpecifiedValue::${value},
|
||||
% endfor
|
||||
}
|
||||
|
@ -377,7 +395,7 @@ ${helpers.single_keyword("-servo-overflow-clip-box", "padding-box content-box",
|
|||
${helpers.predefined_type(
|
||||
"overflow-clip-box-" + direction,
|
||||
"OverflowClipBox",
|
||||
"computed::OverflowClipBox::padding_box",
|
||||
"computed::OverflowClipBox::PaddingBox",
|
||||
products="gecko",
|
||||
enabled_in="ua",
|
||||
needs_context=False,
|
||||
|
|
|
@ -136,7 +136,7 @@
|
|||
input.try(|input| {
|
||||
input.expect_comma()?;
|
||||
list_style_type::parse(context, input)
|
||||
}).unwrap_or(list_style_type::computed_value::T::decimal)
|
||||
}).unwrap_or(list_style_type::computed_value::T::Decimal)
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
|
|
|
@ -76,13 +76,13 @@ ${helpers.single_keyword("word-break",
|
|||
#[inline]
|
||||
fn to_computed_value(&self, _: &Context) -> computed_value::T {
|
||||
match *self {
|
||||
% for value in "auto none inter_word".split():
|
||||
% for value in "Auto None InterWord".split():
|
||||
SpecifiedValue::${value} => computed_value::T::${value},
|
||||
% endfor
|
||||
% if product == "gecko":
|
||||
SpecifiedValue::inter_character => computed_value::T::inter_character,
|
||||
SpecifiedValue::InterCharacter => computed_value::T::InterCharacter,
|
||||
// https://drafts.csswg.org/css-text-3/#valdef-text-justify-distribute
|
||||
SpecifiedValue::distribute => computed_value::T::inter_character,
|
||||
SpecifiedValue::Distribute => computed_value::T::InterCharacter,
|
||||
% endif
|
||||
}
|
||||
}
|
||||
|
@ -90,11 +90,11 @@ ${helpers.single_keyword("word-break",
|
|||
#[inline]
|
||||
fn from_computed_value(computed: &computed_value::T) -> SpecifiedValue {
|
||||
match *computed {
|
||||
% for value in "auto none inter_word".split():
|
||||
% for value in "Auto None InterWord".split():
|
||||
computed_value::T::${value} => SpecifiedValue::${value},
|
||||
% endfor
|
||||
% if product == "gecko":
|
||||
computed_value::T::inter_character => SpecifiedValue::inter_character,
|
||||
computed_value::T::InterCharacter => SpecifiedValue::InterCharacter,
|
||||
% endif
|
||||
}
|
||||
}
|
||||
|
@ -109,18 +109,25 @@ ${helpers.single_keyword("text-align-last",
|
|||
spec="https://drafts.csswg.org/css-text/#propdef-text-align-last")}
|
||||
|
||||
// TODO make this a shorthand and implement text-align-last/text-align-all
|
||||
//
|
||||
// FIXME(emilio): This can't really be that complicated.
|
||||
<%helpers:longhand name="text-align" animation_value_type="discrete"
|
||||
flags="APPLIES_TO_PLACEHOLDER"
|
||||
spec="https://drafts.csswg.org/css-text/#propdef-text-align">
|
||||
pub use self::computed_value::TextAlign;
|
||||
|
||||
pub mod computed_value {
|
||||
pub use self::TextAlign as T;
|
||||
|
||||
macro_rules! define_text_align {
|
||||
( $( $name: ident ( $string: expr ) => $discriminant: expr, )+ ) => {
|
||||
define_css_keyword_enum! { T:
|
||||
define_css_keyword_enum! { TextAlign:
|
||||
$(
|
||||
$string => $name,
|
||||
)+
|
||||
}
|
||||
impl T {
|
||||
|
||||
impl TextAlign {
|
||||
pub fn to_u32(self) -> u32 {
|
||||
match self {
|
||||
$(
|
||||
|
@ -139,22 +146,23 @@ ${helpers.single_keyword("text-align-last",
|
|||
}
|
||||
}
|
||||
}
|
||||
// FIXME(emilio): Why reinventing the world?
|
||||
define_text_align! {
|
||||
start("start") => 0,
|
||||
end("end") => 1,
|
||||
left("left") => 2,
|
||||
right("right") => 3,
|
||||
center("center") => 4,
|
||||
justify("justify") => 5,
|
||||
Start("start") => 0,
|
||||
End("end") => 1,
|
||||
Left("left") => 2,
|
||||
Right("right") => 3,
|
||||
Center("center") => 4,
|
||||
Justify("justify") => 5,
|
||||
% if product == "servo":
|
||||
servo_center("-servo-center") => 6,
|
||||
servo_left("-servo-left") => 7,
|
||||
servo_right("-servo-right") => 8,
|
||||
ServoCenter("-servo-center") => 6,
|
||||
ServoLeft("-servo-left") => 7,
|
||||
ServoRight("-servo-right") => 8,
|
||||
% else:
|
||||
_moz_center("-moz-center") => 6,
|
||||
_moz_left("-moz-left") => 7,
|
||||
_moz_right("-moz-right") => 8,
|
||||
char("char") => 10,
|
||||
MozCenter("-moz-center") => 6,
|
||||
MozLeft("-moz-left") => 7,
|
||||
MozRight("-moz-right") => 8,
|
||||
Char("char") => 10,
|
||||
% endif
|
||||
}
|
||||
|
||||
|
@ -164,8 +172,8 @@ ${helpers.single_keyword("text-align-last",
|
|||
gecko_strip_moz_prefix=False), type="T")}
|
||||
}
|
||||
|
||||
#[inline] pub fn get_initial_value() -> computed_value::T {
|
||||
computed_value::T::start
|
||||
#[inline] pub fn get_initial_value() -> TextAlign {
|
||||
TextAlign::Start
|
||||
}
|
||||
|
||||
|
||||
|
@ -176,14 +184,14 @@ ${helpers.single_keyword("text-align-last",
|
|||
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
|
||||
pub enum SpecifiedValue {
|
||||
Keyword(computed_value::T),
|
||||
Keyword(TextAlign),
|
||||
MatchParent,
|
||||
MozCenterOrInherit,
|
||||
}
|
||||
pub fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<SpecifiedValue, ParseError<'i>> {
|
||||
// MozCenterOrInherit cannot be parsed, only set directly on th elements
|
||||
if let Ok(key) = input.try(computed_value::T::parse) {
|
||||
if let Ok(key) = input.try(TextAlign::parse) {
|
||||
Ok(SpecifiedValue::Keyword(key))
|
||||
} else {
|
||||
input.expect_ident_matching("match-parent")?;
|
||||
|
@ -211,10 +219,10 @@ ${helpers.single_keyword("text-align-last",
|
|||
}
|
||||
}
|
||||
impl ToComputedValue for SpecifiedValue {
|
||||
type ComputedValue = computed_value::T;
|
||||
type ComputedValue = TextAlign;
|
||||
|
||||
#[inline]
|
||||
fn to_computed_value(&self, context: &Context) -> computed_value::T {
|
||||
fn to_computed_value(&self, context: &Context) -> TextAlign {
|
||||
match *self {
|
||||
SpecifiedValue::Keyword(key) => key,
|
||||
SpecifiedValue::MatchParent => {
|
||||
|
@ -230,17 +238,17 @@ ${helpers.single_keyword("text-align-last",
|
|||
let parent = context.builder.get_parent_inheritedtext().clone_text_align();
|
||||
let ltr = context.builder.inherited_writing_mode().is_bidi_ltr();
|
||||
match (parent, ltr) {
|
||||
(computed_value::T::start, true) => computed_value::T::left,
|
||||
(computed_value::T::start, false) => computed_value::T::right,
|
||||
(computed_value::T::end, true) => computed_value::T::right,
|
||||
(computed_value::T::end, false) => computed_value::T::left,
|
||||
(TextAlign::Start, true) => TextAlign::Left,
|
||||
(TextAlign::Start, false) => TextAlign::Right,
|
||||
(TextAlign::End, true) => TextAlign::Right,
|
||||
(TextAlign::End, false) => TextAlign::Left,
|
||||
_ => parent
|
||||
}
|
||||
}
|
||||
SpecifiedValue::MozCenterOrInherit => {
|
||||
let parent = context.builder.get_parent_inheritedtext().clone_text_align();
|
||||
if parent == computed_value::T::start {
|
||||
computed_value::T::center
|
||||
if parent == TextAlign::Start {
|
||||
TextAlign::Center
|
||||
} else {
|
||||
parent
|
||||
}
|
||||
|
@ -314,8 +322,8 @@ ${helpers.predefined_type("word-spacing",
|
|||
// Start with no declarations if this is an atomic inline-level box; otherwise, start with the
|
||||
// declarations in effect and add in the text decorations that this block specifies.
|
||||
let mut result = match context.style().get_box().clone_display() {
|
||||
super::display::computed_value::T::inline_block |
|
||||
super::display::computed_value::T::inline_table => get_initial_value(),
|
||||
super::display::computed_value::T::InlineBlock |
|
||||
super::display::computed_value::T::InlineTable => get_initial_value(),
|
||||
_ => context.builder.get_parent_inheritedtext().clone__servo_text_decorations_in_effect()
|
||||
};
|
||||
|
||||
|
@ -354,31 +362,31 @@ ${helpers.predefined_type("word-spacing",
|
|||
impl SpecifiedValue {
|
||||
pub fn allow_wrap(&self) -> bool {
|
||||
match *self {
|
||||
SpecifiedValue::nowrap |
|
||||
SpecifiedValue::pre => false,
|
||||
SpecifiedValue::normal |
|
||||
SpecifiedValue::pre_wrap |
|
||||
SpecifiedValue::pre_line => true,
|
||||
SpecifiedValue::Nowrap |
|
||||
SpecifiedValue::Pre => false,
|
||||
SpecifiedValue::Normal |
|
||||
SpecifiedValue::PreWrap |
|
||||
SpecifiedValue::PreLine => true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn preserve_newlines(&self) -> bool {
|
||||
match *self {
|
||||
SpecifiedValue::normal |
|
||||
SpecifiedValue::nowrap => false,
|
||||
SpecifiedValue::pre |
|
||||
SpecifiedValue::pre_wrap |
|
||||
SpecifiedValue::pre_line => true,
|
||||
SpecifiedValue::Normal |
|
||||
SpecifiedValue::Nowrap => false,
|
||||
SpecifiedValue::Pre |
|
||||
SpecifiedValue::PreWrap |
|
||||
SpecifiedValue::PreLine => true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn preserve_spaces(&self) -> bool {
|
||||
match *self {
|
||||
SpecifiedValue::normal |
|
||||
SpecifiedValue::nowrap |
|
||||
SpecifiedValue::pre_line => false,
|
||||
SpecifiedValue::pre |
|
||||
SpecifiedValue::pre_wrap => true,
|
||||
SpecifiedValue::Normal |
|
||||
SpecifiedValue::Nowrap |
|
||||
SpecifiedValue::PreLine => false,
|
||||
SpecifiedValue::Pre |
|
||||
SpecifiedValue::PreWrap => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -399,7 +407,7 @@ ${helpers.predefined_type(
|
|||
<%helpers:longhand name="text-emphasis-style" products="gecko" boxed="True"
|
||||
animation_value_type="discrete"
|
||||
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-emphasis-style">
|
||||
use computed_values::writing_mode::T as writing_mode;
|
||||
use computed_values::writing_mode::T as WritingMode;
|
||||
use std::fmt;
|
||||
use style_traits::ToCss;
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
@ -519,7 +527,7 @@ ${helpers.predefined_type(
|
|||
match *self {
|
||||
SpecifiedValue::Keyword(ref keyword) => {
|
||||
let default_shape = if context.style().get_inheritedbox()
|
||||
.clone_writing_mode() == writing_mode::horizontal_tb {
|
||||
.clone_writing_mode() == WritingMode::HorizontalTb {
|
||||
ShapeKeyword::Circle
|
||||
} else {
|
||||
ShapeKeyword::Sesame
|
||||
|
|
|
@ -38,12 +38,12 @@ ${helpers.predefined_type(
|
|||
|
||||
#[inline]
|
||||
pub fn get_initial_value() -> computed_value::T {
|
||||
Either::Second(BorderStyle::none)
|
||||
Either::Second(BorderStyle::None)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_initial_specified_value() -> SpecifiedValue {
|
||||
Either::Second(BorderStyle::none)
|
||||
Either::Second(BorderStyle::None)
|
||||
}
|
||||
|
||||
pub mod computed_value {
|
||||
|
@ -54,7 +54,7 @@ ${helpers.predefined_type(
|
|||
-> Result<SpecifiedValue, ParseError<'i>> {
|
||||
SpecifiedValue::parse(context, input)
|
||||
.and_then(|result| {
|
||||
if let Either::Second(BorderStyle::hidden) = result {
|
||||
if let Either::Second(BorderStyle::Hidden) = result {
|
||||
// The outline-style property accepts the same values as
|
||||
// border-style, except that 'hidden' is not a legal outline
|
||||
// style.
|
||||
|
|
|
@ -2396,24 +2396,24 @@ impl ComputedValuesInner {
|
|||
|
||||
/// Return true if the effects force the transform style to be Flat
|
||||
pub fn overrides_transform_style(&self) -> bool {
|
||||
use computed_values::mix_blend_mode;
|
||||
use computed_values::mix_blend_mode::T as MixBlendMode;
|
||||
|
||||
let effects = self.get_effects();
|
||||
// TODO(gw): Add clip-path, isolation, mask-image, mask-border-source when supported.
|
||||
effects.opacity < 1.0 ||
|
||||
!effects.filter.0.is_empty() ||
|
||||
!effects.clip.is_auto() ||
|
||||
effects.mix_blend_mode != mix_blend_mode::T::normal
|
||||
effects.mix_blend_mode != MixBlendMode::Normal
|
||||
}
|
||||
|
||||
/// <https://drafts.csswg.org/css-transforms/#grouping-property-values>
|
||||
pub fn get_used_transform_style(&self) -> computed_values::transform_style::T {
|
||||
use computed_values::transform_style;
|
||||
use computed_values::transform_style::T as TransformStyle;
|
||||
|
||||
let box_ = self.get_box();
|
||||
|
||||
if self.overrides_transform_style() {
|
||||
transform_style::T::flat
|
||||
TransformStyle::Flat
|
||||
} else {
|
||||
// Return the computed value if not overridden by the above exceptions
|
||||
box_.transform_style
|
||||
|
@ -2913,15 +2913,15 @@ impl<'a> StyleBuilder<'a> {
|
|||
|
||||
/// Returns whether this computed style represents a floated object.
|
||||
pub fn floated(&self) -> bool {
|
||||
self.get_box().clone_float() != longhands::float::computed_value::T::none
|
||||
self.get_box().clone_float() != longhands::float::computed_value::T::None
|
||||
}
|
||||
|
||||
/// Returns whether this computed style represents an out of flow-positioned
|
||||
/// object.
|
||||
pub fn out_of_flow_positioned(&self) -> bool {
|
||||
use properties::longhands::position::computed_value::T as position;
|
||||
use properties::longhands::position::computed_value::T as Position;
|
||||
matches!(self.get_box().clone_position(),
|
||||
position::absolute | position::fixed)
|
||||
Position::Absolute | Position::Fixed)
|
||||
}
|
||||
|
||||
/// Whether this style has a top-layer style. That's implemented in Gecko
|
||||
|
@ -2934,7 +2934,7 @@ impl<'a> StyleBuilder<'a> {
|
|||
#[cfg(feature = "gecko")]
|
||||
pub fn in_top_layer(&self) -> bool {
|
||||
matches!(self.get_box().clone__moz_top_layer(),
|
||||
longhands::_moz_top_layer::computed_value::T::top)
|
||||
longhands::_moz_top_layer::computed_value::T::Top)
|
||||
}
|
||||
|
||||
/// Clears the "have any reset structs been modified" flag.
|
||||
|
|
|
@ -18,16 +18,17 @@
|
|||
use values::specified::{Color, Position, PositionComponent};
|
||||
use parser::Parse;
|
||||
|
||||
// FIXME(emilio): Should be the same type!
|
||||
impl From<background_origin::single_value::SpecifiedValue> for background_clip::single_value::SpecifiedValue {
|
||||
fn from(origin: background_origin::single_value::SpecifiedValue) ->
|
||||
background_clip::single_value::SpecifiedValue {
|
||||
match origin {
|
||||
background_origin::single_value::SpecifiedValue::content_box =>
|
||||
background_clip::single_value::SpecifiedValue::content_box,
|
||||
background_origin::single_value::SpecifiedValue::padding_box =>
|
||||
background_clip::single_value::SpecifiedValue::padding_box,
|
||||
background_origin::single_value::SpecifiedValue::border_box =>
|
||||
background_clip::single_value::SpecifiedValue::border_box,
|
||||
background_origin::single_value::SpecifiedValue::ContentBox =>
|
||||
background_clip::single_value::SpecifiedValue::ContentBox,
|
||||
background_origin::single_value::SpecifiedValue::PaddingBox =>
|
||||
background_clip::single_value::SpecifiedValue::PaddingBox,
|
||||
background_origin::single_value::SpecifiedValue::BorderBox =>
|
||||
background_clip::single_value::SpecifiedValue::BorderBox,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -177,7 +178,7 @@
|
|||
size.to_css(dest)?;
|
||||
}
|
||||
|
||||
if *origin != Origin::padding_box || *clip != Clip::border_box {
|
||||
if *origin != Origin::PaddingBox || *clip != Clip::BorderBox {
|
||||
dest.write_str(" ")?;
|
||||
origin.to_css(dest)?;
|
||||
if *clip != From::from(*origin) {
|
||||
|
|
|
@ -80,7 +80,7 @@ pub fn parse_border<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
|||
}
|
||||
if any {
|
||||
Ok((color.unwrap_or_else(|| Color::currentcolor()),
|
||||
style.unwrap_or(BorderStyle::none),
|
||||
style.unwrap_or(BorderStyle::None),
|
||||
width.unwrap_or(BorderSideWidth::Medium)))
|
||||
} else {
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
|
|
|
@ -18,20 +18,20 @@
|
|||
try_match_ident_ignore_ascii_case! { input,
|
||||
"-moz-scrollbars-horizontal" => {
|
||||
Ok(expanded! {
|
||||
overflow_x: SpecifiedValue::scroll,
|
||||
overflow_y: SpecifiedValue::hidden,
|
||||
overflow_x: SpecifiedValue::Scroll,
|
||||
overflow_y: SpecifiedValue::Hidden,
|
||||
})
|
||||
}
|
||||
"-moz-scrollbars-vertical" => {
|
||||
Ok(expanded! {
|
||||
overflow_x: SpecifiedValue::hidden,
|
||||
overflow_y: SpecifiedValue::scroll,
|
||||
overflow_x: SpecifiedValue::Hidden,
|
||||
overflow_y: SpecifiedValue::Scroll,
|
||||
})
|
||||
}
|
||||
"-moz-scrollbars-none" => {
|
||||
Ok(expanded! {
|
||||
overflow_x: SpecifiedValue::hidden,
|
||||
overflow_y: SpecifiedValue::hidden,
|
||||
overflow_x: SpecifiedValue::Hidden,
|
||||
overflow_y: SpecifiedValue::Hidden,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
|
||||
fn list_style_type_none() -> list_style_type::SpecifiedValue {
|
||||
% if product == "servo":
|
||||
list_style_type::SpecifiedValue::none
|
||||
list_style_type::SpecifiedValue::None
|
||||
% else:
|
||||
use values::generics::CounterStyleOrNone;
|
||||
list_style_type::SpecifiedValue::CounterStyle(CounterStyleOrNone::None)
|
||||
|
|
|
@ -14,22 +14,23 @@
|
|||
use values::specified::{Position, PositionComponent};
|
||||
use parser::Parse;
|
||||
|
||||
// FIXME(emilio): These two mask types should be the same!
|
||||
impl From<mask_origin::single_value::SpecifiedValue> for mask_clip::single_value::SpecifiedValue {
|
||||
fn from(origin: mask_origin::single_value::SpecifiedValue) -> mask_clip::single_value::SpecifiedValue {
|
||||
match origin {
|
||||
mask_origin::single_value::SpecifiedValue::content_box =>
|
||||
mask_clip::single_value::SpecifiedValue::content_box,
|
||||
mask_origin::single_value::SpecifiedValue::padding_box =>
|
||||
mask_clip::single_value::SpecifiedValue::padding_box,
|
||||
mask_origin::single_value::SpecifiedValue::border_box =>
|
||||
mask_clip::single_value::SpecifiedValue::border_box,
|
||||
mask_origin::single_value::SpecifiedValue::ContentBox =>
|
||||
mask_clip::single_value::SpecifiedValue::ContentBox,
|
||||
mask_origin::single_value::SpecifiedValue::PaddingBox =>
|
||||
mask_clip::single_value::SpecifiedValue::PaddingBox ,
|
||||
mask_origin::single_value::SpecifiedValue::BorderBox =>
|
||||
mask_clip::single_value::SpecifiedValue::BorderBox,
|
||||
% if product == "gecko":
|
||||
mask_origin::single_value::SpecifiedValue::fill_box =>
|
||||
mask_clip::single_value::SpecifiedValue::fill_box,
|
||||
mask_origin::single_value::SpecifiedValue::stroke_box =>
|
||||
mask_clip::single_value::SpecifiedValue::stroke_box,
|
||||
mask_origin::single_value::SpecifiedValue::view_box =>
|
||||
mask_clip::single_value::SpecifiedValue::view_box,
|
||||
mask_origin::single_value::SpecifiedValue::FillBox =>
|
||||
mask_clip::single_value::SpecifiedValue::FillBox ,
|
||||
mask_origin::single_value::SpecifiedValue::StrokeBox =>
|
||||
mask_clip::single_value::SpecifiedValue::StrokeBox,
|
||||
mask_origin::single_value::SpecifiedValue::ViewBox=>
|
||||
mask_clip::single_value::SpecifiedValue::ViewBox,
|
||||
% endif
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +161,7 @@
|
|||
dest.write_str(" ")?;
|
||||
repeat.to_css(dest)?;
|
||||
|
||||
if *origin != Origin::border_box || *clip != Clip::border_box {
|
||||
if *origin != Origin::BorderBox || *clip != Clip::BorderBox {
|
||||
dest.write_str(" ")?;
|
||||
origin.to_css(dest)?;
|
||||
if *clip != From::from(*origin) {
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
self.text_decoration_line.to_css(dest)?;
|
||||
|
||||
% if product == "gecko":
|
||||
if self.text_decoration_style != &text_decoration_style::SpecifiedValue::solid {
|
||||
if *self.text_decoration_style != text_decoration_style::SpecifiedValue::Solid {
|
||||
dest.write_str(" ")?;
|
||||
self.text_decoration_style.to_css(dest)?;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
//! The restyle damage is a hint that tells layout which kind of operations may
|
||||
//! be needed in presence of incremental style changes.
|
||||
|
||||
use computed_values::display;
|
||||
use computed_values::display::T as Display;
|
||||
use matching::{StyleChange, StyleDifference};
|
||||
use properties::ComputedValues;
|
||||
use std::fmt;
|
||||
|
@ -219,7 +219,7 @@ fn compute_damage(old: &ComputedValues, new: &ComputedValues) -> ServoRestyleDam
|
|||
get_text.text_decoration_line, get_text.unicode_bidi,
|
||||
get_inheritedtable.empty_cells, get_inheritedtable.caption_side,
|
||||
get_column.column_width, get_column.column_count
|
||||
]) || (new.get_box().display == display::T::inline &&
|
||||
]) || (new.get_box().display == Display::Inline &&
|
||||
add_if_not_equal!(old, new, damage,
|
||||
[ServoRestyleDamage::REPAINT, ServoRestyleDamage::REPOSITION,
|
||||
ServoRestyleDamage::STORE_OVERFLOW, ServoRestyleDamage::BUBBLE_ISIZES,
|
||||
|
|
|
@ -15,7 +15,7 @@ use fnv::FnvHashMap;
|
|||
use invalidation::element::element_wrapper::ElementSnapshot;
|
||||
use properties::ComputedValues;
|
||||
use properties::PropertyFlags;
|
||||
use properties::longhands::display::computed_value as display;
|
||||
use properties::longhands::display::computed_value::T as Display;
|
||||
use selector_parser::{AttrValue as SelectorAttrValue, PseudoElementCascadeType, SelectorParser};
|
||||
use selectors::attr::{AttrSelectorOperation, NamespaceConstraint, CaseSensitivity};
|
||||
use selectors::parser::{SelectorMethods, SelectorParseErrorKind};
|
||||
|
@ -229,10 +229,9 @@ impl PseudoElement {
|
|||
|
||||
/// Whether this pseudo-element should actually exist if it has
|
||||
/// the given styles.
|
||||
pub fn should_exist(&self, style: &ComputedValues) -> bool
|
||||
{
|
||||
pub fn should_exist(&self, style: &ComputedValues) -> bool {
|
||||
let display = style.get_box().clone_display();
|
||||
if display == display::T::none {
|
||||
if display == Display::None {
|
||||
return false;
|
||||
}
|
||||
if self.is_before_or_after() && style.ineffective_content_property() {
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
|
||||
use app_units::Au;
|
||||
use properties::{self, CascadeFlags, ComputedValues, StyleBuilder};
|
||||
use properties::longhands::display::computed_value::T as display;
|
||||
use properties::longhands::float::computed_value::T as float;
|
||||
use properties::longhands::overflow_x::computed_value::T as overflow;
|
||||
use properties::longhands::position::computed_value::T as position;
|
||||
use properties::longhands::display::computed_value::T as Display;
|
||||
use properties::longhands::float::computed_value::T as Float;
|
||||
use properties::longhands::overflow_x::computed_value::T as Overflow;
|
||||
use properties::longhands::position::computed_value::T as Position;
|
||||
|
||||
/// A struct that implements all the adjustment methods.
|
||||
///
|
||||
|
@ -23,10 +23,9 @@ pub struct StyleAdjuster<'a, 'b: 'a> {
|
|||
|
||||
impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||
/// Trivially constructs a new StyleAdjuster.
|
||||
#[inline]
|
||||
pub fn new(style: &'a mut StyleBuilder<'b>) -> Self {
|
||||
StyleAdjuster {
|
||||
style: style,
|
||||
}
|
||||
StyleAdjuster { style }
|
||||
}
|
||||
|
||||
/// <https://fullscreen.spec.whatwg.org/#new-stacking-layer>
|
||||
|
@ -36,7 +35,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
///
|
||||
fn adjust_for_top_layer(&mut self) {
|
||||
if !self.style.out_of_flow_positioned() && self.style.in_top_layer() {
|
||||
self.style.mutate_box().set_position(position::absolute);
|
||||
self.style.mutate_box().set_position(Position::Absolute);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +46,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
///
|
||||
fn adjust_for_position(&mut self) {
|
||||
if self.style.out_of_flow_positioned() && self.style.floated() {
|
||||
self.style.mutate_box().set_float(float::none);
|
||||
self.style.mutate_box().set_float(Float::None);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,7 +96,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
use properties::computed_value_flags::ComputedValueFlags;
|
||||
|
||||
if self.style.inherited_flags().contains(ComputedValueFlags::IS_IN_DISPLAY_NONE_SUBTREE) ||
|
||||
self.style.get_box().clone_display() == display::none {
|
||||
self.style.get_box().clone_display() == Display::None {
|
||||
self.style.flags.insert(ComputedValueFlags::IS_IN_DISPLAY_NONE_SUBTREE);
|
||||
}
|
||||
|
||||
|
@ -127,10 +126,13 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
///
|
||||
/// TODO(emilio): we should (Gecko too) revise these adjustments in presence
|
||||
/// of display: contents.
|
||||
///
|
||||
/// FIXME(emilio): How does this play with logical properties? Doesn't
|
||||
/// mutating writing-mode change the potential physical sides chosen?
|
||||
#[cfg(feature = "gecko")]
|
||||
fn adjust_for_text_combine_upright(&mut self) {
|
||||
use computed_values::text_combine_upright::T as text_combine_upright;
|
||||
use computed_values::writing_mode::T as writing_mode;
|
||||
use computed_values::text_combine_upright::T as TextCombineUpright;
|
||||
use computed_values::writing_mode::T as WritingMode;
|
||||
use properties::computed_value_flags::ComputedValueFlags;
|
||||
|
||||
let writing_mode =
|
||||
|
@ -138,10 +140,10 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
let text_combine_upright =
|
||||
self.style.get_inheritedtext().clone_text_combine_upright();
|
||||
|
||||
if writing_mode != writing_mode::horizontal_tb &&
|
||||
text_combine_upright == text_combine_upright::all {
|
||||
if writing_mode != WritingMode::HorizontalTb &&
|
||||
text_combine_upright == TextCombineUpright::All {
|
||||
self.style.flags.insert(ComputedValueFlags::IS_TEXT_COMBINED);
|
||||
self.style.mutate_inheritedbox().set_writing_mode(writing_mode::horizontal_tb);
|
||||
self.style.mutate_inheritedbox().set_writing_mode(WritingMode::HorizontalTb);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,8 +183,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
layout_parent_style.get_inheritedbox().clone_writing_mode();
|
||||
|
||||
if our_writing_mode != parent_writing_mode &&
|
||||
self.style.get_box().clone_display() == display::inline {
|
||||
self.style.mutate_box().set_display(display::inline_block);
|
||||
self.style.get_box().clone_display() == Display::Inline {
|
||||
self.style.mutate_box().set_display(Display::InlineBlock);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,18 +201,18 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
return;
|
||||
}
|
||||
|
||||
if self.style.get_box().clone_display() == display::inline {
|
||||
self.style.mutate_box().set_adjusted_display(display::inline_block,
|
||||
if self.style.get_box().clone_display() == Display::Inline {
|
||||
self.style.mutate_box().set_adjusted_display(Display::InlineBlock,
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
// When 'contain: paint', update overflow from 'visible' to 'clip'.
|
||||
if self.style.get_box().clone_contain().contains(SpecifiedValue::PAINT) {
|
||||
if self.style.get_box().clone_overflow_x() == overflow::visible {
|
||||
if self.style.get_box().clone_overflow_x() == Overflow::Visible {
|
||||
let box_style = self.style.mutate_box();
|
||||
box_style.set_overflow_x(overflow::_moz_hidden_unscrollable);
|
||||
box_style.set_overflow_y(overflow::_moz_hidden_unscrollable);
|
||||
box_style.set_overflow_x(Overflow::MozHiddenUnscrollable);
|
||||
box_style.set_overflow_y(Overflow::MozHiddenUnscrollable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -219,15 +221,15 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
/// both forced to "normal".
|
||||
#[cfg(feature = "gecko")]
|
||||
fn adjust_for_mathvariant(&mut self) {
|
||||
use properties::longhands::_moz_math_variant::computed_value::T as moz_math_variant;
|
||||
use properties::longhands::font_style::computed_value::T as font_style;
|
||||
use properties::longhands::font_weight::computed_value::T as font_weight;
|
||||
if self.style.get_font().clone__moz_math_variant() != moz_math_variant::none {
|
||||
use properties::longhands::_moz_math_variant::computed_value::T as MozMathVariant;
|
||||
use properties::longhands::font_style::computed_value::T as FontStyle;
|
||||
use properties::longhands::font_weight::computed_value::T as FontWeight;
|
||||
if self.style.get_font().clone__moz_math_variant() != MozMathVariant::None {
|
||||
let font_style = self.style.mutate_font();
|
||||
// Sadly we don't have a nice name for the computed value
|
||||
// of "font-weight: normal".
|
||||
font_style.set_font_weight(font_weight::normal());
|
||||
font_style.set_font_style(font_style::normal);
|
||||
font_style.set_font_weight(FontWeight::normal());
|
||||
font_style.set_font_style(FontStyle::Normal);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -237,18 +239,18 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
/// See https://github.com/servo/servo/issues/15229
|
||||
#[cfg(feature = "servo")]
|
||||
fn adjust_for_alignment(&mut self, layout_parent_style: &ComputedValues) {
|
||||
use computed_values::align_items::T as align_items;
|
||||
use computed_values::align_self::T as align_self;
|
||||
use computed_values::align_items::T as AlignItems;
|
||||
use computed_values::align_self::T as AlignSelf;
|
||||
|
||||
if self.style.get_position().clone_align_self() == align_self::auto &&
|
||||
if self.style.get_position().clone_align_self() == AlignSelf::Auto &&
|
||||
!self.style.out_of_flow_positioned() {
|
||||
let self_align =
|
||||
match layout_parent_style.get_position().clone_align_items() {
|
||||
align_items::stretch => align_self::stretch,
|
||||
align_items::baseline => align_self::baseline,
|
||||
align_items::flex_start => align_self::flex_start,
|
||||
align_items::flex_end => align_self::flex_end,
|
||||
align_items::center => align_self::center,
|
||||
AlignItems::Stretch => AlignSelf::Stretch,
|
||||
AlignItems::Baseline => AlignSelf::Baseline,
|
||||
AlignItems::FlexStart => AlignSelf::FlexStart,
|
||||
AlignItems::FlexEnd => AlignSelf::FlexEnd,
|
||||
AlignItems::Center => AlignSelf::Center,
|
||||
};
|
||||
self.style.mutate_position().set_align_self(self_align);
|
||||
}
|
||||
|
@ -288,23 +290,23 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
|
||||
// If 'visible' is specified but doesn't match the other dimension,
|
||||
// it turns into 'auto'.
|
||||
if overflow_x == overflow::visible {
|
||||
overflow_x = overflow::auto;
|
||||
if overflow_x == Overflow::Visible {
|
||||
overflow_x = Overflow::Auto;
|
||||
}
|
||||
|
||||
if overflow_y == overflow::visible {
|
||||
overflow_y = overflow::auto;
|
||||
if overflow_y == Overflow::Visible {
|
||||
overflow_y = Overflow::Auto;
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
{
|
||||
// overflow: clip is deprecated, so convert to hidden if it's
|
||||
// specified in only one dimension.
|
||||
if overflow_x == overflow::_moz_hidden_unscrollable {
|
||||
overflow_x = overflow::hidden;
|
||||
if overflow_x == Overflow::MozHiddenUnscrollable {
|
||||
overflow_x = Overflow::Hidden;
|
||||
}
|
||||
if overflow_y == overflow::_moz_hidden_unscrollable {
|
||||
overflow_y = overflow::hidden;
|
||||
if overflow_y == Overflow::MozHiddenUnscrollable {
|
||||
overflow_y = Overflow::Hidden;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -324,11 +326,11 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
// TODO: We should probably convert display:contents into display:none
|
||||
// in some cases too: https://drafts.csswg.org/css-display/#unbox
|
||||
if !flags.contains(CascadeFlags::PROHIBIT_DISPLAY_CONTENTS) ||
|
||||
self.style.get_box().clone_display() != display::contents {
|
||||
self.style.get_box().clone_display() != Display::Contents {
|
||||
return;
|
||||
}
|
||||
|
||||
self.style.mutate_box().set_display(display::inline);
|
||||
self.style.mutate_box().set_display(Display::Inline);
|
||||
}
|
||||
|
||||
/// If a <fieldset> has grid/flex display type, we need to inherit
|
||||
|
@ -347,16 +349,16 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
if !flags.contains(CascadeFlags::IS_FIELDSET_CONTENT) {
|
||||
return;
|
||||
}
|
||||
debug_assert_eq!(self.style.get_box().clone_display(), display::block);
|
||||
debug_assert_eq!(self.style.get_box().clone_display(), Display::Block);
|
||||
// TODO We actually want style from parent rather than layout
|
||||
// parent, so that this fixup doesn't happen incorrectly when
|
||||
// when <fieldset> has "display: contents".
|
||||
let parent_display = layout_parent_style.get_box().clone_display();
|
||||
let new_display = match parent_display {
|
||||
display::flex |
|
||||
display::inline_flex => Some(display::flex),
|
||||
display::grid |
|
||||
display::inline_grid => Some(display::grid),
|
||||
Display::Flex |
|
||||
Display::InlineFlex => Some(Display::Flex),
|
||||
Display::Grid |
|
||||
Display::InlineGrid => Some(Display::Grid),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(new_display) = new_display {
|
||||
|
@ -372,19 +374,19 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
/// table.
|
||||
#[cfg(feature = "gecko")]
|
||||
fn adjust_for_table_text_align(&mut self) {
|
||||
use properties::longhands::text_align::computed_value::T as text_align;
|
||||
if self.style.get_box().clone_display() != display::table {
|
||||
use properties::longhands::text_align::computed_value::T as TextAlign;
|
||||
if self.style.get_box().clone_display() != Display::Table {
|
||||
return;
|
||||
}
|
||||
|
||||
match self.style.get_inheritedtext().clone_text_align() {
|
||||
text_align::_moz_left |
|
||||
text_align::_moz_center |
|
||||
text_align::_moz_right => {},
|
||||
TextAlign::MozLeft |
|
||||
TextAlign::MozCenter |
|
||||
TextAlign::MozRight => {},
|
||||
_ => return,
|
||||
}
|
||||
|
||||
self.style.mutate_inheritedtext().set_text_align(text_align::start)
|
||||
self.style.mutate_inheritedtext().set_text_align(TextAlign::Start)
|
||||
}
|
||||
|
||||
/// Set the HAS_TEXT_DECORATION_LINES flag based on parent style.
|
||||
|
@ -419,15 +421,15 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
}
|
||||
match self.style.get_box().clone_display() {
|
||||
// Ruby base and text are always non-breakable.
|
||||
display::ruby_base |
|
||||
display::ruby_text => true,
|
||||
Display::RubyBase |
|
||||
Display::RubyText => true,
|
||||
// Ruby base container and text container are breakable.
|
||||
// Note that, when certain HTML tags, e.g. form controls, have ruby
|
||||
// level container display type, they could also escape from the
|
||||
// line break suppression flag while they shouldn't. However, it is
|
||||
// generally fine since they themselves are non-breakable.
|
||||
display::ruby_base_container |
|
||||
display::ruby_text_container => false,
|
||||
Display::RubyBaseContainer |
|
||||
Display::RubyTextContainer => false,
|
||||
// Anything else is non-breakable if and only if its layout parent
|
||||
// has a ruby display type, because any of the ruby boxes can be
|
||||
// anonymous.
|
||||
|
@ -448,7 +450,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
) {
|
||||
use properties::CascadeFlags;
|
||||
use properties::computed_value_flags::ComputedValueFlags;
|
||||
use properties::longhands::unicode_bidi::computed_value::T as unicode_bidi;
|
||||
use properties::longhands::unicode_bidi::computed_value::T as UnicodeBidi;
|
||||
|
||||
let self_display = self.style.get_box().clone_display();
|
||||
// Check whether line break should be suppressed for this element.
|
||||
|
@ -475,9 +477,9 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
// per spec https://drafts.csswg.org/css-ruby-1/#bidi
|
||||
if self_display.is_ruby_type() {
|
||||
let new_value = match self.style.get_text().clone_unicode_bidi() {
|
||||
unicode_bidi::normal |
|
||||
unicode_bidi::embed => Some(unicode_bidi::isolate),
|
||||
unicode_bidi::bidi_override => Some(unicode_bidi::isolate_override),
|
||||
UnicodeBidi::Normal |
|
||||
UnicodeBidi::Embed => Some(UnicodeBidi::Isolate),
|
||||
UnicodeBidi::BidiOverride => Some(UnicodeBidi::IsolateOverride),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(new_value) = new_value {
|
||||
|
|
|
@ -12,7 +12,7 @@ use log::LogLevel::Trace;
|
|||
use matching::{CascadeVisitedMode, MatchMethods};
|
||||
use properties::{AnimationRules, CascadeFlags, ComputedValues};
|
||||
use properties::cascade;
|
||||
use properties::longhands::display::computed_value::T as display;
|
||||
use properties::longhands::display::computed_value::T as Display;
|
||||
use rule_tree::StrongRuleNode;
|
||||
use selector_parser::{PseudoElement, SelectorImpl};
|
||||
use selectors::matching::{ElementSelectorFlags, MatchingContext, MatchingMode, VisitedHandlingMode};
|
||||
|
@ -115,7 +115,7 @@ fn eager_pseudo_is_definitely_not_generated(
|
|||
}
|
||||
|
||||
if !style.flags.intersects(ComputedValueFlags::INHERITS_DISPLAY) &&
|
||||
style.get_box().clone_display() == display::none {
|
||||
style.get_box().clone_display() == Display::None {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -803,7 +803,7 @@ impl ToComputedValue for specified::MozScriptLevel {
|
|||
specified::MozScriptLevel::Auto => {
|
||||
let parent = cx.builder.get_parent_font().clone__moz_script_level() as i32;
|
||||
let display = cx.builder.get_parent_font().clone__moz_math_display();
|
||||
if display == DisplayValue::inline {
|
||||
if display == DisplayValue::Inline {
|
||||
parent + 1
|
||||
} else {
|
||||
parent
|
||||
|
|
|
@ -125,9 +125,8 @@ define_css_keyword_enum! { OverscrollBehavior:
|
|||
}
|
||||
add_impls_for_keyword_enum!(OverscrollBehavior);
|
||||
|
||||
// FIXME(emilio): Make all keywords CamelCase.
|
||||
define_css_keyword_enum! { OverflowClipBox:
|
||||
"padding-box" => padding_box,
|
||||
"content-box" => content_box,
|
||||
"padding-box" => PaddingBox,
|
||||
"content-box" => ContentBox,
|
||||
}
|
||||
add_impls_for_keyword_enum!(OverflowClipBox);
|
||||
|
|
|
@ -141,24 +141,26 @@ fn parse_number_with_clamping_mode<'i, 't>(
|
|||
|
||||
// The integer values here correspond to the border conflict resolution rules in CSS 2.1 §
|
||||
// 17.6.2.1. Higher values override lower values.
|
||||
//
|
||||
// FIXME(emilio): Should move to border.rs
|
||||
define_numbered_css_keyword_enum! { BorderStyle:
|
||||
"none" => none = -1,
|
||||
"solid" => solid = 6,
|
||||
"double" => double = 7,
|
||||
"dotted" => dotted = 4,
|
||||
"dashed" => dashed = 5,
|
||||
"hidden" => hidden = -2,
|
||||
"groove" => groove = 1,
|
||||
"ridge" => ridge = 3,
|
||||
"inset" => inset = 0,
|
||||
"outset" => outset = 2,
|
||||
"none" => None = -1,
|
||||
"solid" => Solid = 6,
|
||||
"double" => Double = 7,
|
||||
"dotted" => Dotted = 4,
|
||||
"dashed" => Dashed = 5,
|
||||
"hidden" => Hidden = -2,
|
||||
"groove" => Groove = 1,
|
||||
"ridge" => Ridge = 3,
|
||||
"inset" => Inset = 0,
|
||||
"outset" => Outset = 2,
|
||||
}
|
||||
|
||||
|
||||
impl BorderStyle {
|
||||
/// Whether this border style is either none or hidden.
|
||||
pub fn none_or_hidden(&self) -> bool {
|
||||
matches!(*self, BorderStyle::none | BorderStyle::hidden)
|
||||
matches!(*self, BorderStyle::None | BorderStyle::Hidden)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue