mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Move table border to the new infrastructure.
This commit is contained in:
parent
52afa1dc34
commit
69f92596ca
2 changed files with 25 additions and 73 deletions
|
@ -383,6 +383,30 @@ impl RawLayoutElementHelpers for Element {
|
||||||
longhands::height::SpecifiedValue(
|
longhands::height::SpecifiedValue(
|
||||||
specified::LengthOrPercentageOrAuto::Length(value))))));
|
specified::LengthOrPercentageOrAuto::Length(value))))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let border = if self.is_htmltableelement() {
|
||||||
|
let this: &HTMLTableElement = mem::transmute(self);
|
||||||
|
this.get_border()
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(border) = border {
|
||||||
|
let width_value = specified::Length::Absolute(Au::from_px(border as i32));
|
||||||
|
hints.push(from_declaration(
|
||||||
|
PropertyDeclaration::BorderTopWidth(SpecifiedValue(
|
||||||
|
longhands::border_top_width::SpecifiedValue(width_value)))));
|
||||||
|
hints.push(from_declaration(
|
||||||
|
PropertyDeclaration::BorderLeftWidth(SpecifiedValue(
|
||||||
|
longhands::border_left_width::SpecifiedValue(width_value)))));
|
||||||
|
hints.push(from_declaration(
|
||||||
|
PropertyDeclaration::BorderBottomWidth(SpecifiedValue(
|
||||||
|
longhands::border_bottom_width::SpecifiedValue(width_value)))));
|
||||||
|
hints.push(from_declaration(
|
||||||
|
PropertyDeclaration::BorderRightWidth(SpecifiedValue(
|
||||||
|
longhands::border_right_width::SpecifiedValue(width_value)))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -412,16 +436,6 @@ impl RawLayoutElementHelpers for Element {
|
||||||
attribute: UnsignedIntegerAttribute)
|
attribute: UnsignedIntegerAttribute)
|
||||||
-> Option<u32> {
|
-> Option<u32> {
|
||||||
match attribute {
|
match attribute {
|
||||||
UnsignedIntegerAttribute::Border => {
|
|
||||||
if self.is_htmltableelement() {
|
|
||||||
let this: &HTMLTableElement = mem::transmute(self);
|
|
||||||
this.get_border()
|
|
||||||
} else {
|
|
||||||
// Don't panic since `:-servo-nonzero-border` can cause this to be called on
|
|
||||||
// arbitrary elements.
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
UnsignedIntegerAttribute::ColSpan => {
|
UnsignedIntegerAttribute::ColSpan => {
|
||||||
if self.is_htmltablecellelement() {
|
if self.is_htmltablecellelement() {
|
||||||
let this: &HTMLTableCellElement = mem::transmute(self);
|
let this: &HTMLTableCellElement = mem::transmute(self);
|
||||||
|
|
|
@ -7,23 +7,17 @@
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use selectors::tree::{TElement, TNode};
|
use selectors::tree::TNode;
|
||||||
use selectors::matching::DeclarationBlock;
|
use selectors::matching::DeclarationBlock;
|
||||||
use node::TElementAttributes;
|
use node::TElementAttributes;
|
||||||
use values::specified;
|
|
||||||
use properties::DeclaredValue::SpecifiedValue;
|
|
||||||
use properties::PropertyDeclaration;
|
use properties::PropertyDeclaration;
|
||||||
use properties::longhands;
|
|
||||||
use selector_matching::Stylist;
|
use selector_matching::Stylist;
|
||||||
|
|
||||||
use util::geometry::Au;
|
|
||||||
use util::smallvec::VecLike;
|
use util::smallvec::VecLike;
|
||||||
|
|
||||||
/// Legacy presentational attributes that take a nonnegative integer as defined in HTML5 § 2.4.4.2.
|
/// Legacy presentational attributes that take a nonnegative integer as defined in HTML5 § 2.4.4.2.
|
||||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||||
pub enum UnsignedIntegerAttribute {
|
pub enum UnsignedIntegerAttribute {
|
||||||
/// `<td border>`
|
|
||||||
Border,
|
|
||||||
/// `<td colspan>`
|
/// `<td colspan>`
|
||||||
ColSpan,
|
ColSpan,
|
||||||
}
|
}
|
||||||
|
@ -46,16 +40,6 @@ pub trait PresentationalHintSynthesis {
|
||||||
where N: TNode<'a>,
|
where N: TNode<'a>,
|
||||||
N::Element: TElementAttributes<'a>,
|
N::Element: TElementAttributes<'a>,
|
||||||
V: VecLike<DeclarationBlock<Vec<PropertyDeclaration>>>;
|
V: VecLike<DeclarationBlock<Vec<PropertyDeclaration>>>;
|
||||||
/// Synthesizes rules for the legacy `border` attribute.
|
|
||||||
fn synthesize_presentational_hint_for_legacy_border_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 {
|
impl PresentationalHintSynthesis for Stylist {
|
||||||
|
@ -75,52 +59,6 @@ impl PresentationalHintSynthesis for Stylist {
|
||||||
// Never share style for elements with preshints
|
// Never share style for elements with preshints
|
||||||
*shareable = false;
|
*shareable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
match element.get_local_name() {
|
|
||||||
name if *name == atom!("td") => {
|
|
||||||
self.synthesize_presentational_hint_for_legacy_border_attribute(
|
|
||||||
element,
|
|
||||||
matching_rules_list,
|
|
||||||
shareable);
|
|
||||||
}
|
|
||||||
name if *name == atom!("table") => {
|
|
||||||
self.synthesize_presentational_hint_for_legacy_border_attribute(
|
|
||||||
element,
|
|
||||||
matching_rules_list,
|
|
||||||
shareable);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn synthesize_presentational_hint_for_legacy_border_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_unsigned_integer_attribute(UnsignedIntegerAttribute::Border) {
|
|
||||||
None => {}
|
|
||||||
Some(length) => {
|
|
||||||
let width_value = specified::Length::Absolute(Au::from_px(length as i32));
|
|
||||||
matching_rules_list.push(from_declaration(
|
|
||||||
PropertyDeclaration::BorderTopWidth(SpecifiedValue(
|
|
||||||
longhands::border_top_width::SpecifiedValue(width_value)))));
|
|
||||||
matching_rules_list.push(from_declaration(
|
|
||||||
PropertyDeclaration::BorderLeftWidth(SpecifiedValue(
|
|
||||||
longhands::border_left_width::SpecifiedValue(width_value)))));
|
|
||||||
matching_rules_list.push(from_declaration(
|
|
||||||
PropertyDeclaration::BorderBottomWidth(SpecifiedValue(
|
|
||||||
longhands::border_bottom_width::SpecifiedValue(width_value)))));
|
|
||||||
matching_rules_list.push(from_declaration(
|
|
||||||
PropertyDeclaration::BorderRightWidth(SpecifiedValue(
|
|
||||||
longhands::border_right_width::SpecifiedValue(width_value)))));
|
|
||||||
*shareable = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue