mirror of
https://github.com/servo/servo.git
synced 2025-06-14 03:14:29 +00:00
style: Remove -servo-display-for-hypothetical-box from longhand
This commit is contained in:
parent
e81193c5c9
commit
0291a75b3c
5 changed files with 64 additions and 56 deletions
|
@ -1485,7 +1485,7 @@ impl<'a, ConcreteThreadSafeLayoutNode> PostorderNodeMutTraversal<ConcreteThreadS
|
||||||
}
|
}
|
||||||
Some(LayoutNodeType::Element(_)) => {
|
Some(LayoutNodeType::Element(_)) => {
|
||||||
let style = node.style(self.style_context());
|
let style = node.style(self.style_context());
|
||||||
let original_display = style.get_box()._servo_display_for_hypothetical_box;
|
let original_display = style.get_box().original_display;
|
||||||
let munged_display = match original_display {
|
let munged_display = match original_display {
|
||||||
Display::Inline | Display::InlineBlock => original_display,
|
Display::Inline | Display::InlineBlock => original_display,
|
||||||
_ => style.get_box().display,
|
_ => style.get_box().display,
|
||||||
|
|
|
@ -3114,33 +3114,23 @@ fn static_assert() {
|
||||||
gecko_enum_prefix="StyleDisplay",
|
gecko_enum_prefix="StyleDisplay",
|
||||||
gecko_strip_moz_prefix=False) %>
|
gecko_strip_moz_prefix=False) %>
|
||||||
|
|
||||||
pub fn set_display(&mut self, v: longhands::display::computed_value::T) {
|
fn match_display_keyword(
|
||||||
|
v: longhands::display::computed_value::T
|
||||||
|
) -> structs::root::mozilla::StyleDisplay {
|
||||||
use properties::longhands::display::computed_value::T as Keyword;
|
use properties::longhands::display::computed_value::T as Keyword;
|
||||||
// FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts
|
// FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts
|
||||||
let result = match v {
|
match v {
|
||||||
% for value in display_keyword.values_for('gecko'):
|
% for value in display_keyword.values_for('gecko'):
|
||||||
Keyword::${to_camel_case(value)} =>
|
Keyword::${to_camel_case(value)} =>
|
||||||
structs::${display_keyword.gecko_constant(value)},
|
structs::${display_keyword.gecko_constant(value)},
|
||||||
% endfor
|
% endfor
|
||||||
};
|
}
|
||||||
self.gecko.mDisplay = result;
|
|
||||||
self.gecko.mOriginalDisplay = result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the display value from the style adjustment code. This is pretty
|
pub fn set_display(&mut self, v: longhands::display::computed_value::T) {
|
||||||
/// much like set_display, but without touching the mOriginalDisplay field,
|
let result = Self::match_display_keyword(v);
|
||||||
/// which we want to keep.
|
|
||||||
pub fn set_adjusted_display(&mut self,
|
|
||||||
v: longhands::display::computed_value::T,
|
|
||||||
_is_item_or_root: bool) {
|
|
||||||
use properties::longhands::display::computed_value::T as Keyword;
|
|
||||||
let result = match v {
|
|
||||||
% for value in display_keyword.values_for('gecko'):
|
|
||||||
Keyword::${to_camel_case(value)} =>
|
|
||||||
structs::${display_keyword.gecko_constant(value)},
|
|
||||||
% endfor
|
|
||||||
};
|
|
||||||
self.gecko.mDisplay = result;
|
self.gecko.mDisplay = result;
|
||||||
|
self.gecko.mOriginalDisplay = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn copy_display_from(&mut self, other: &Self) {
|
pub fn copy_display_from(&mut self, other: &Self) {
|
||||||
|
@ -3152,6 +3142,14 @@ fn static_assert() {
|
||||||
self.copy_display_from(other)
|
self.copy_display_from(other)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_adjusted_display(
|
||||||
|
&mut self,
|
||||||
|
v: longhands::display::computed_value::T,
|
||||||
|
_is_item_or_root: bool
|
||||||
|
) {
|
||||||
|
self.gecko.mDisplay = Self::match_display_keyword(v);
|
||||||
|
}
|
||||||
|
|
||||||
<%call expr="impl_keyword_clone('display', 'mDisplay', display_keyword)"></%call>
|
<%call expr="impl_keyword_clone('display', 'mDisplay', display_keyword)"></%call>
|
||||||
|
|
||||||
<% overflow_x = data.longhands_by_name["overflow-x"] %>
|
<% overflow_x = data.longhands_by_name["overflow-x"] %>
|
||||||
|
|
|
@ -161,27 +161,6 @@ ${helpers.single_keyword("position", "static absolute relative fixed sticky",
|
||||||
}
|
}
|
||||||
</%helpers:single_keyword_computed>
|
</%helpers:single_keyword_computed>
|
||||||
|
|
||||||
<%helpers:longhand name="-servo-display-for-hypothetical-box"
|
|
||||||
animation_value_type="none"
|
|
||||||
derived_from="display"
|
|
||||||
products="servo"
|
|
||||||
spec="Internal (not web-exposed)">
|
|
||||||
pub use super::display::{SpecifiedValue, get_initial_value};
|
|
||||||
pub use super::display::{parse};
|
|
||||||
|
|
||||||
pub mod computed_value {
|
|
||||||
pub type T = super::SpecifiedValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn derive_from_display(context: &mut Context) {
|
|
||||||
let d = context.style().get_box().clone_display();
|
|
||||||
context.builder.set__servo_display_for_hypothetical_box(d);
|
|
||||||
}
|
|
||||||
|
|
||||||
</%helpers:longhand>
|
|
||||||
|
|
||||||
|
|
||||||
${helpers.predefined_type(
|
${helpers.predefined_type(
|
||||||
"vertical-align",
|
"vertical-align",
|
||||||
"VerticalAlign",
|
"VerticalAlign",
|
||||||
|
|
|
@ -1863,6 +1863,11 @@ pub mod style_structs {
|
||||||
/// The font hash, used for font caching.
|
/// The font hash, used for font caching.
|
||||||
pub hash: u64,
|
pub hash: u64,
|
||||||
% endif
|
% endif
|
||||||
|
% if style_struct.name == "Box":
|
||||||
|
/// The display value specified by the CSS stylesheets (without any style adjustments),
|
||||||
|
/// which is needed for hypothetical layout boxes.
|
||||||
|
pub original_display: longhands::display::computed_value::T,
|
||||||
|
% endif
|
||||||
}
|
}
|
||||||
% if style_struct.name == "Font":
|
% if style_struct.name == "Font":
|
||||||
|
|
||||||
|
@ -1893,6 +1898,17 @@ pub mod style_structs {
|
||||||
self.${longhand.ident} = longhands::${longhand.ident}::computed_value
|
self.${longhand.ident} = longhands::${longhand.ident}::computed_value
|
||||||
::T(v.into_iter().collect());
|
::T(v.into_iter().collect());
|
||||||
}
|
}
|
||||||
|
% elif longhand.ident == "display":
|
||||||
|
/// Set `display`.
|
||||||
|
///
|
||||||
|
/// We need to keep track of the original display for hypothetical boxes,
|
||||||
|
/// so we need to special-case this.
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
#[inline]
|
||||||
|
pub fn set_display(&mut self, v: longhands::display::computed_value::T) {
|
||||||
|
self.display = v;
|
||||||
|
self.original_display = v;
|
||||||
|
}
|
||||||
% else:
|
% else:
|
||||||
/// Set ${longhand.name}.
|
/// Set ${longhand.name}.
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
@ -1901,13 +1917,25 @@ pub mod style_structs {
|
||||||
self.${longhand.ident} = v;
|
self.${longhand.ident} = v;
|
||||||
}
|
}
|
||||||
% endif
|
% endif
|
||||||
/// Set ${longhand.name} from other struct.
|
% if longhand.ident == "display":
|
||||||
#[allow(non_snake_case)]
|
/// Set `display` from other struct.
|
||||||
#[inline]
|
///
|
||||||
pub fn copy_${longhand.ident}_from(&mut self, other: &Self) {
|
/// Same as `set_display` above.
|
||||||
self.${longhand.ident} = other.${longhand.ident}.clone();
|
/// Thus, we need to special-case this.
|
||||||
}
|
#[allow(non_snake_case)]
|
||||||
|
#[inline]
|
||||||
|
pub fn copy_display_from(&mut self, other: &Self) {
|
||||||
|
self.display = other.display.clone();
|
||||||
|
self.original_display = other.display.clone();
|
||||||
|
}
|
||||||
|
% else:
|
||||||
|
/// Set ${longhand.name} from other struct.
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
#[inline]
|
||||||
|
pub fn copy_${longhand.ident}_from(&mut self, other: &Self) {
|
||||||
|
self.${longhand.ident} = other.${longhand.ident}.clone();
|
||||||
|
}
|
||||||
|
% endif
|
||||||
/// Reset ${longhand.name} from the initial struct.
|
/// Reset ${longhand.name} from the initial struct.
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -2002,15 +2030,16 @@ pub mod style_structs {
|
||||||
self.text_decoration_line.contains(longhands::text_decoration_line::SpecifiedValue::LINE_THROUGH)
|
self.text_decoration_line.contains(longhands::text_decoration_line::SpecifiedValue::LINE_THROUGH)
|
||||||
}
|
}
|
||||||
% elif style_struct.name == "Box":
|
% elif style_struct.name == "Box":
|
||||||
/// Sets the display property, but without touching
|
/// Sets the display property, but without touching original_display,
|
||||||
/// __servo_display_for_hypothetical_box, except when the
|
/// except when the adjustment comes from root or item display fixups.
|
||||||
/// adjustment comes from root or item display fixups.
|
pub fn set_adjusted_display(
|
||||||
pub fn set_adjusted_display(&mut self,
|
&mut self,
|
||||||
dpy: longhands::display::computed_value::T,
|
dpy: longhands::display::computed_value::T,
|
||||||
is_item_or_root: bool) {
|
is_item_or_root: bool
|
||||||
self.set_display(dpy);
|
) {
|
||||||
|
self.display = dpy;
|
||||||
if is_item_or_root {
|
if is_item_or_root {
|
||||||
self.set__servo_display_for_hypothetical_box(dpy);
|
self.original_display = dpy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
% endif
|
% endif
|
||||||
|
@ -3048,6 +3077,9 @@ mod lazy_static_module {
|
||||||
% if style_struct.name == "Font":
|
% if style_struct.name == "Font":
|
||||||
hash: 0,
|
hash: 0,
|
||||||
% endif
|
% endif
|
||||||
|
% if style_struct.name == "Box":
|
||||||
|
original_display: longhands::display::get_initial_value(),
|
||||||
|
% endif
|
||||||
}),
|
}),
|
||||||
% endfor
|
% endfor
|
||||||
custom_properties: None,
|
custom_properties: None,
|
||||||
|
|
|
@ -228,7 +228,6 @@ impl Display {
|
||||||
_declaration: &PropertyDeclaration,
|
_declaration: &PropertyDeclaration,
|
||||||
context: &mut Context
|
context: &mut Context
|
||||||
) {
|
) {
|
||||||
longhands::_servo_display_for_hypothetical_box::derive_from_display(context);
|
|
||||||
longhands::_servo_text_decorations_in_effect::derive_from_display(context);
|
longhands::_servo_text_decorations_in_effect::derive_from_display(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue