Get rid of some of our custom additional methods in favor of clonable keywords.

Now that I'm pretty convinced we can auto-generate these and make them fast, we can
ditch the additional complexity.
This commit is contained in:
Bobby Holley 2016-04-19 16:41:38 -07:00
parent 456b05e9cf
commit cc35d4fcce
5 changed files with 36 additions and 27 deletions

View file

@ -277,10 +277,11 @@ pub mod longhands {
internal=True)}
// FIXME(pcwalton, #2742): Implement scrolling for `scroll` and `auto`.
${helpers.single_keyword("overflow-x", "visible hidden scroll auto", gecko_constant_prefix="NS_STYLE_OVERFLOW")}
${helpers.single_keyword("overflow-x", "visible hidden scroll auto", need_clone=True,
gecko_constant_prefix="NS_STYLE_OVERFLOW")}
// FIXME(pcwalton, #2742): Implement scrolling for `scroll` and `auto`.
<%helpers:longhand name="overflow-y">
<%helpers:longhand name="overflow-y" need_clone="True">
use super::overflow_x;
use cssparser::ToCss;
@ -5719,8 +5720,10 @@ pub mod style_structs {
% endfor
% if style_struct.trait_name == "Border":
% for side in ["top", "right", "bottom", "left"]:
fn border_${side}_is_none_or_hidden_and_has_nonzero_width(&self) -> bool {
self.border_${side}_style.none_or_hidden() &&
fn clone_border_${side}_style(&self) -> longhands::border_${side}_style::computed_value::T {
self.border_${side}_style.clone()
}
fn border_${side}_has_nonzero_width(&self) -> bool {
self.border_${side}_width != ::app_units::Au(0)
}
% endfor
@ -5731,14 +5734,14 @@ pub mod style_structs {
fn clone_position(&self) -> longhands::position::computed_value::T {
self.position.clone()
}
fn is_floated(&self) -> bool {
self.float != longhands::float::SpecifiedValue::none
fn clone_float(&self) -> longhands::float::computed_value::T {
self.float.clone()
}
fn overflow_x_is_visible(&self) -> bool {
self.overflow_x == longhands::overflow_x::computed_value::T::visible
fn clone_overflow_x(&self) -> longhands::overflow_x::computed_value::T {
self.overflow_x.clone()
}
fn overflow_y_is_visible(&self) -> bool {
self.overflow_y.0 == longhands::overflow_x::computed_value::T::visible
fn clone_overflow_y(&self) -> longhands::overflow_y::computed_value::T {
self.overflow_y.clone()
}
fn transition_count(&self) -> usize {
self.transition_property.0.len()
@ -5778,8 +5781,11 @@ pub mod style_structs {
self._servo_text_decorations_in_effect.clone()
}
% elif style_struct.trait_name == "Outline":
fn outline_is_none_or_hidden_and_has_nonzero_width(&self) -> bool {
self.outline_style.none_or_hidden() && self.outline_width != ::app_units::Au(0)
fn clone_outline_style(&self) -> longhands::outline_style::computed_value::T {
self.outline_style.clone()
}
fn outline_has_nonzero_width(&self) -> bool {
self.outline_width != ::app_units::Au(0)
}
% elif style_struct.trait_name == "Text":
fn has_underline(&self) -> bool {
@ -6438,7 +6444,7 @@ pub fn cascade<C: ComputedValues>(
let positioned = matches!(style.get_box().clone_position(),
longhands::position::SpecifiedValue::absolute |
longhands::position::SpecifiedValue::fixed);
let floated = style.get_box().is_floated();
let floated = style.get_box().clone_float() != longhands::float::SpecifiedValue::none;
if positioned || floated || is_root_element {
use computed_values::display::T;
@ -6472,7 +6478,8 @@ pub fn cascade<C: ComputedValues>(
{
use computed_values::overflow_x::T as overflow;
use computed_values::overflow_y;
match (style.get_box().overflow_x_is_visible(), style.get_box().overflow_y_is_visible()) {
match (style.get_box().clone_overflow_x() == longhands::overflow_x::computed_value::T::visible,
style.get_box().clone_overflow_y().0 == longhands::overflow_x::computed_value::T::visible) {
(true, true) => {}
(true, _) => {
style.mutate_box().set_overflow_x(overflow::auto);
@ -6487,13 +6494,15 @@ pub fn cascade<C: ComputedValues>(
// The initial value of border-*-width may be changed at computed value time.
% for side in ["top", "right", "bottom", "left"]:
// Like calling to_computed_value, which wouldn't type check.
if style.get_border().border_${side}_is_none_or_hidden_and_has_nonzero_width() {
if style.get_border().clone_border_${side}_style().none_or_hidden() &&
style.get_border().border_${side}_has_nonzero_width() {
style.mutate_border().set_border_${side}_width(Au(0));
}
% endfor
// The initial value of outline width may be changed at computed value time.
if style.get_outline().outline_is_none_or_hidden_and_has_nonzero_width() {
if style.get_outline().clone_outline_style().none_or_hidden() &&
style.get_outline().outline_has_nonzero_width() {
style.mutate_outline().set_outline_width(Au(0));
}