mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
layout: Implement <table width>
and <center>
.
Improves Hacker News.
This commit is contained in:
parent
263b69cf7f
commit
4b9cd4e65d
13 changed files with 160 additions and 36 deletions
|
@ -75,6 +75,14 @@ pub trait PresentationalHintSynthesis {
|
|||
E: TElement<'a> +
|
||||
TElementAttributes<'a>,
|
||||
V: VecLike<DeclarationBlock<Vec<PropertyDeclaration>>>;
|
||||
/// Synthesizes rules for the legacy `width` attribute.
|
||||
fn synthesize_presentational_hint_for_legacy_width_attribute<'a,E,V>(
|
||||
&self,
|
||||
element: E,
|
||||
matching_rules_list: &mut V,
|
||||
shareable: &mut bool)
|
||||
where E: TElement<'a> + TElementAttributes<'a>,
|
||||
V: VecLike<DeclarationBlock<Vec<PropertyDeclaration>>>;
|
||||
}
|
||||
|
||||
impl PresentationalHintSynthesis for Stylist {
|
||||
|
@ -97,27 +105,20 @@ impl PresentationalHintSynthesis for Stylist {
|
|||
|
||||
match element.get_local_name() {
|
||||
name if *name == atom!("td") => {
|
||||
match element.get_length_attribute(LengthAttribute::Width) {
|
||||
LengthOrPercentageOrAuto::Auto => {}
|
||||
LengthOrPercentageOrAuto::Percentage(percentage) => {
|
||||
let width_value = specified::LengthOrPercentageOrAuto::Percentage(percentage);
|
||||
matching_rules_list.push(from_declaration(
|
||||
PropertyDeclaration::Width(SpecifiedValue(width_value))));
|
||||
*shareable = false
|
||||
}
|
||||
LengthOrPercentageOrAuto::Length(length) => {
|
||||
let width_value = specified::LengthOrPercentageOrAuto::Length(specified::Length::Absolute(length));
|
||||
matching_rules_list.push(from_declaration(
|
||||
PropertyDeclaration::Width(SpecifiedValue(width_value))));
|
||||
*shareable = false
|
||||
}
|
||||
}
|
||||
self.synthesize_presentational_hint_for_legacy_width_attribute(
|
||||
element,
|
||||
matching_rules_list,
|
||||
shareable);
|
||||
self.synthesize_presentational_hint_for_legacy_border_attribute(
|
||||
element,
|
||||
matching_rules_list,
|
||||
shareable);
|
||||
}
|
||||
name if *name == atom!("table") => {
|
||||
self.synthesize_presentational_hint_for_legacy_width_attribute(
|
||||
element,
|
||||
matching_rules_list,
|
||||
shareable);
|
||||
self.synthesize_presentational_hint_for_legacy_border_attribute(
|
||||
element,
|
||||
matching_rules_list,
|
||||
|
@ -221,6 +222,31 @@ impl PresentationalHintSynthesis for Stylist {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn synthesize_presentational_hint_for_legacy_width_attribute<'a,E,V>(
|
||||
&self,
|
||||
element: E,
|
||||
matching_rules_list: &mut V,
|
||||
shareable: &mut bool)
|
||||
where E: TElement<'a> + TElementAttributes<'a>,
|
||||
V: VecLike<DeclarationBlock<Vec<PropertyDeclaration>>> {
|
||||
match element.get_length_attribute(LengthAttribute::Width) {
|
||||
LengthOrPercentageOrAuto::Auto => {}
|
||||
LengthOrPercentageOrAuto::Percentage(percentage) => {
|
||||
let width_value = specified::LengthOrPercentageOrAuto::Percentage(percentage);
|
||||
matching_rules_list.push(from_declaration(
|
||||
PropertyDeclaration::Width(SpecifiedValue(width_value))));
|
||||
*shareable = false
|
||||
}
|
||||
LengthOrPercentageOrAuto::Length(length) => {
|
||||
let width_value = specified::LengthOrPercentageOrAuto::Length(
|
||||
specified::Length::Absolute(length));
|
||||
matching_rules_list.push(from_declaration(
|
||||
PropertyDeclaration::Width(SpecifiedValue(width_value))));
|
||||
*shareable = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1735,10 +1735,10 @@ pub mod longhands {
|
|||
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||
pub mod computed_value {
|
||||
macro_rules! define_text_align {
|
||||
( $( $name: ident => $discriminant: expr, )+ ) => {
|
||||
( $( $name: ident ( $string: expr ) => $discriminant: expr, )+ ) => {
|
||||
define_css_keyword_enum! { T:
|
||||
$(
|
||||
stringify!($name) => $name,
|
||||
$string => $name,
|
||||
)+
|
||||
}
|
||||
impl T {
|
||||
|
@ -1761,12 +1761,13 @@ pub mod longhands {
|
|||
}
|
||||
}
|
||||
define_text_align! {
|
||||
start => 0,
|
||||
end => 1,
|
||||
left => 2,
|
||||
right => 3,
|
||||
center => 4,
|
||||
justify => 5,
|
||||
start("start") => 0,
|
||||
end("end") => 1,
|
||||
left("left") => 2,
|
||||
right("right") => 3,
|
||||
center("center") => 4,
|
||||
justify("justify") => 5,
|
||||
servo_center("-servo-center") => 6,
|
||||
}
|
||||
}
|
||||
#[inline] pub fn get_initial_value() -> computed_value::T {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue