mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
style: Implement basic column spans.
This patch provides some of the groundwork for column spans greater than 1. It implements the column-span CSS property (prefixed so as not to be exposed to content) as well as the corresponding colspan attribute; although the former is not well-specified outside of CSS multi-column layout, INTRINSIC refers to it. Although width is distributed to spanning columns, they do not yet contribute minimum and preferred widths; this will be implemented in a follow-up. Additionally, this patch cleans up some miscellaneous formatting issues and improves the handling of table rowgroups.
This commit is contained in:
parent
14bafb11be
commit
56b78de5bc
13 changed files with 269 additions and 129 deletions
|
@ -8,7 +8,8 @@
|
|||
use node::{TElement, TElementAttributes, TNode};
|
||||
use properties::{BackgroundColorDeclaration, BorderBottomWidthDeclaration};
|
||||
use properties::{BorderLeftWidthDeclaration, BorderRightWidthDeclaration};
|
||||
use properties::{BorderTopWidthDeclaration, SpecifiedValue, WidthDeclaration, specified};
|
||||
use properties::{BorderTopWidthDeclaration, ServoColumnSpanDeclaration, SpecifiedValue};
|
||||
use properties::{WidthDeclaration, specified};
|
||||
use selector_matching::{DeclarationBlock, Stylist};
|
||||
|
||||
use cssparser::{RGBA, RGBAColor};
|
||||
|
@ -32,6 +33,8 @@ pub enum IntegerAttribute {
|
|||
pub enum UnsignedIntegerAttribute {
|
||||
/// `<td border>`
|
||||
BorderUnsignedIntegerAttribute,
|
||||
/// `<td colspan>`
|
||||
ColSpanUnsignedIntegerAttribute,
|
||||
}
|
||||
|
||||
/// Legacy presentational attributes that take a simple color as defined in HTML5 § 2.4.6.
|
||||
|
@ -111,6 +114,14 @@ impl PresentationalHintSynthesis for Stylist {
|
|||
*shareable = false
|
||||
}
|
||||
}
|
||||
match element.get_unsigned_integer_attribute(ColSpanUnsignedIntegerAttribute) {
|
||||
None => {}
|
||||
Some(value) => {
|
||||
matching_rules_list.vec_push(DeclarationBlock::from_declaration(
|
||||
ServoColumnSpanDeclaration(SpecifiedValue(value))));
|
||||
*shareable = false
|
||||
}
|
||||
}
|
||||
self.synthesize_presentational_hint_for_legacy_background_color_attribute(
|
||||
element,
|
||||
matching_rules_list,
|
||||
|
|
|
@ -54,9 +54,10 @@ pub use selectors::{PseudoElement, Before, After, SelectorList, parse_selector_l
|
|||
pub use selectors::{AttrSelector, NamespaceConstraint, SpecificNamespace, AnyNamespace};
|
||||
pub use selectors::{SimpleSelector, LocalNameSelector};
|
||||
pub use cssparser::{Color, RGBA};
|
||||
pub use legacy::{BgColorSimpleColorAttribute, BorderUnsignedIntegerAttribute, IntegerAttribute};
|
||||
pub use legacy::{LengthAttribute, SimpleColorAttribute, SizeIntegerAttribute};
|
||||
pub use legacy::{UnsignedIntegerAttribute, WidthLengthAttribute};
|
||||
pub use legacy::{BgColorSimpleColorAttribute, BorderUnsignedIntegerAttribute};
|
||||
pub use legacy::{ColSpanUnsignedIntegerAttribute, IntegerAttribute, LengthAttribute};
|
||||
pub use legacy::{SimpleColorAttribute, SizeIntegerAttribute, UnsignedIntegerAttribute};
|
||||
pub use legacy::{WidthLengthAttribute};
|
||||
pub use font_face::{Source, LocalSource, UrlSource_};
|
||||
|
||||
mod stylesheets;
|
||||
|
|
|
@ -1316,6 +1316,34 @@ pub mod longhands {
|
|||
|
||||
${single_keyword("table-layout", "auto fixed")}
|
||||
|
||||
<%self:single_component_value name="-servo-column-span">
|
||||
// The handling of this property is not well-specified by INTRINSIC, but its presence is
|
||||
// assumed. HTML5 14.3.9 specifies that the `colspan` attribute is to be a nonnegative
|
||||
// integer.
|
||||
pub use super::computed_as_specified as to_computed_value;
|
||||
pub mod computed_value {
|
||||
pub type T = u32;
|
||||
}
|
||||
pub type SpecifiedValue = computed_value::T;
|
||||
|
||||
#[inline]
|
||||
pub fn get_initial_value() -> computed_value::T {
|
||||
1
|
||||
}
|
||||
|
||||
pub fn from_component_value(input: &ComponentValue, _: &Url) -> Result<SpecifiedValue,()> {
|
||||
match input {
|
||||
&Number(ref value) => {
|
||||
match value.int_value {
|
||||
None => Err(()),
|
||||
Some(n) => Ok(n as SpecifiedValue),
|
||||
}
|
||||
}
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
</%self:single_component_value>
|
||||
|
||||
// CSS 2.1, Section 18 - User interface
|
||||
|
||||
|
||||
|
|
|
@ -802,8 +802,8 @@ pub fn common_style_affecting_attributes() -> [CommonStyleAffectingAttributeInfo
|
|||
/// Attributes that, if present, disable style sharing. All legacy HTML attributes must be in
|
||||
/// either this list or `common_style_affecting_attributes`. See the comment in
|
||||
/// `synthesize_presentational_hints_for_legacy_attributes`.
|
||||
pub fn rare_style_affecting_attributes() -> [Atom, ..2] {
|
||||
[ atom!("bgcolor"), atom!("border") ]
|
||||
pub fn rare_style_affecting_attributes() -> [Atom, ..3] {
|
||||
[ atom!("bgcolor"), atom!("border"), atom!("colspan") ]
|
||||
}
|
||||
|
||||
/// Determines whether the given element matches the given single selector.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue