mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Migrate <th>
text-align
behaviour from presentation hint to UA CSS
Differential Revision: https://phabricator.services.mozilla.com/D142494
This commit is contained in:
parent
0cf72d5e70
commit
739d6d14ab
2 changed files with 14 additions and 21 deletions
|
@ -1588,23 +1588,9 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
use crate::properties::longhands::_x_lang::SpecifiedValue as SpecifiedLang;
|
||||
use crate::properties::longhands::_x_text_zoom::SpecifiedValue as SpecifiedZoom;
|
||||
use crate::properties::longhands::color::SpecifiedValue as SpecifiedColor;
|
||||
use crate::properties::longhands::text_align::SpecifiedValue as SpecifiedTextAlign;
|
||||
use crate::stylesheets::layer_rule::LayerOrder;
|
||||
use crate::values::specified::color::Color;
|
||||
lazy_static! {
|
||||
static ref TH_RULE: ApplicableDeclarationBlock = {
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
let pdb = PropertyDeclarationBlock::with_one(
|
||||
PropertyDeclaration::TextAlign(SpecifiedTextAlign::MozCenterOrInherit),
|
||||
Importance::Normal,
|
||||
);
|
||||
let arc = Arc::new_leaked(global_style_data.shared_lock.wrap(pdb));
|
||||
ApplicableDeclarationBlock::from_declarations(
|
||||
arc,
|
||||
ServoCascadeLevel::PresHints,
|
||||
LayerOrder::root(),
|
||||
)
|
||||
};
|
||||
static ref TABLE_COLOR_RULE: ApplicableDeclarationBlock = {
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
let pdb = PropertyDeclarationBlock::with_one(
|
||||
|
@ -1649,9 +1635,7 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
let ns = self.namespace_id();
|
||||
// <th> elements get a default MozCenterOrInherit which may get overridden
|
||||
if ns == structs::kNameSpaceID_XHTML as i32 {
|
||||
if self.local_name().as_ptr() == atom!("th").as_ptr() {
|
||||
hints.push(TH_RULE.clone());
|
||||
} else if self.local_name().as_ptr() == atom!("table").as_ptr() &&
|
||||
if self.local_name().as_ptr() == atom!("table").as_ptr() &&
|
||||
self.as_node().owner_doc().quirks_mode() == QuirksMode::Quirks
|
||||
{
|
||||
hints.push(TABLE_COLOR_RULE.clone());
|
||||
|
|
|
@ -528,11 +528,20 @@ pub enum TextAlign {
|
|||
/// unlike other keywords.
|
||||
#[cfg(feature = "gecko")]
|
||||
MatchParent,
|
||||
/// `MozCenterOrInherit` value of text-align property. It cannot be parsed,
|
||||
/// only set directly on the elements and it has a different handling
|
||||
/// unlike other values.
|
||||
/// This is how we implement the following HTML behavior from
|
||||
/// https://html.spec.whatwg.org/#tables-2:
|
||||
///
|
||||
/// User agents are expected to have a rule in their user agent style sheet
|
||||
/// that matches th elements that have a parent node whose computed value
|
||||
/// for the 'text-align' property is its initial value, whose declaration
|
||||
/// block consists of just a single declaration that sets the 'text-align'
|
||||
/// property to the value 'center'.
|
||||
///
|
||||
/// Since selectors can't depend on the ancestor styles, we implement it with a
|
||||
/// magic value that computes to the right thing. Since this is an
|
||||
/// implementation detail, it shouldn't be exposed to web content.
|
||||
#[cfg(feature = "gecko")]
|
||||
#[css(skip)]
|
||||
#[parse(condition = "ParserContext::in_ua_or_chrome_sheet")]
|
||||
MozCenterOrInherit,
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue