mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
stylo: Add support for <table> color quirk
MozReview-Commit-ID: 56IKARwfbhw
This commit is contained in:
parent
0392e58a2f
commit
1c23296d8a
6 changed files with 62 additions and 25 deletions
|
@ -624,12 +624,23 @@ impl<'le> PresentationalHintsSynthetizer for GeckoElement<'le> {
|
||||||
fn synthesize_presentational_hints_for_legacy_attributes<V>(&self, hints: &mut V)
|
fn synthesize_presentational_hints_for_legacy_attributes<V>(&self, hints: &mut V)
|
||||||
where V: Push<ApplicableDeclarationBlock>,
|
where V: Push<ApplicableDeclarationBlock>,
|
||||||
{
|
{
|
||||||
use properties::longhands::text_align::SpecifiedValue;
|
use properties::longhands::text_align::SpecifiedValue as SpecifiedTextAlign;
|
||||||
|
use properties::longhands::color::SpecifiedValue as SpecifiedColor;
|
||||||
|
use values::specified::color::Color;
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref TH_RULE: ApplicableDeclarationBlock = {
|
static ref TH_RULE: ApplicableDeclarationBlock = {
|
||||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||||
let pdb = PropertyDeclarationBlock::with_one(
|
let pdb = PropertyDeclarationBlock::with_one(
|
||||||
PropertyDeclaration::TextAlign(SpecifiedValue::MozCenterOrInherit),
|
PropertyDeclaration::TextAlign(SpecifiedTextAlign::MozCenterOrInherit),
|
||||||
|
Importance::Normal
|
||||||
|
);
|
||||||
|
let arc = Arc::new(global_style_data.shared_lock.wrap(pdb));
|
||||||
|
ApplicableDeclarationBlock::from_declarations(arc, ServoCascadeLevel::PresHints)
|
||||||
|
};
|
||||||
|
static ref TABLE_COLOR_RULE: ApplicableDeclarationBlock = {
|
||||||
|
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||||
|
let pdb = PropertyDeclarationBlock::with_one(
|
||||||
|
PropertyDeclaration::Color(SpecifiedColor(Color::InheritFromBodyQuirk.into())),
|
||||||
Importance::Normal
|
Importance::Normal
|
||||||
);
|
);
|
||||||
let arc = Arc::new(global_style_data.shared_lock.wrap(pdb));
|
let arc = Arc::new(global_style_data.shared_lock.wrap(pdb));
|
||||||
|
@ -638,9 +649,13 @@ impl<'le> PresentationalHintsSynthetizer for GeckoElement<'le> {
|
||||||
};
|
};
|
||||||
|
|
||||||
// <th> elements get a default MozCenterOrInherit which may get overridden
|
// <th> elements get a default MozCenterOrInherit which may get overridden
|
||||||
if self.get_namespace() == &*Namespace(atom!("http://www.w3.org/1999/xhtml")) &&
|
if self.get_namespace() == &*Namespace(atom!("http://www.w3.org/1999/xhtml")) {
|
||||||
self.get_local_name().as_ptr() == atom!("th").as_ptr() {
|
if self.get_local_name().as_ptr() == atom!("th").as_ptr() {
|
||||||
hints.push(TH_RULE.clone());
|
hints.push(TH_RULE.clone());
|
||||||
|
} else if self.get_local_name().as_ptr() == atom!("table").as_ptr() &&
|
||||||
|
self.as_node().owner_doc().mCompatMode == structs::nsCompatibility::eCompatibility_NavQuirks {
|
||||||
|
hints.push(TABLE_COLOR_RULE.clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let declarations = unsafe { Gecko_GetHTMLPresentationAttrDeclarationBlock(self.0) };
|
let declarations = unsafe { Gecko_GetHTMLPresentationAttrDeclarationBlock(self.0) };
|
||||||
let declarations = declarations.and_then(|s| s.as_arc_opt());
|
let declarations = declarations.and_then(|s| s.as_arc_opt());
|
||||||
|
|
|
@ -1050,6 +1050,10 @@ extern "C" {
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CSSFontFaceRule_Release(aPtr: *mut nsCSSFontFaceRule);
|
pub fn Gecko_CSSFontFaceRule_Release(aPtr: *mut nsCSSFontFaceRule);
|
||||||
}
|
}
|
||||||
|
extern "C" {
|
||||||
|
pub fn Gecko_GetBody(pres_context: RawGeckoPresContextBorrowed)
|
||||||
|
-> RawGeckoElementBorrowedOrNull;
|
||||||
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_GetLookAndFeelSystemColor(color_id: i32,
|
pub fn Gecko_GetLookAndFeelSystemColor(color_id: i32,
|
||||||
pres_context:
|
pres_context:
|
||||||
|
|
|
@ -26,10 +26,7 @@
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from_computed_value(computed: &computed_value::T) -> Self {
|
fn from_computed_value(computed: &computed_value::T) -> Self {
|
||||||
SpecifiedValue(CSSColor {
|
SpecifiedValue(Color::RGBA(*computed).into())
|
||||||
parsed: Color::RGBA(*computed),
|
|
||||||
authored: None,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -209,6 +209,24 @@ impl ToComputedValue for specified::Color {
|
||||||
specified::Color::MozHyperlinktext => to_rgba(pres_context.mLinkColor),
|
specified::Color::MozHyperlinktext => to_rgba(pres_context.mLinkColor),
|
||||||
specified::Color::MozActiveHyperlinktext => to_rgba(pres_context.mActiveLinkColor),
|
specified::Color::MozActiveHyperlinktext => to_rgba(pres_context.mActiveLinkColor),
|
||||||
specified::Color::MozVisitedHyperlinktext => to_rgba(pres_context.mVisitedLinkColor),
|
specified::Color::MozVisitedHyperlinktext => to_rgba(pres_context.mVisitedLinkColor),
|
||||||
|
specified::Color::InheritFromBodyQuirk => {
|
||||||
|
use dom::TElement;
|
||||||
|
use gecko_bindings::bindings::Gecko_GetBody;
|
||||||
|
use gecko::wrapper::GeckoElement;
|
||||||
|
let body = unsafe {
|
||||||
|
Gecko_GetBody(pres_context)
|
||||||
|
};
|
||||||
|
if let Some(body) = body {
|
||||||
|
let wrap = GeckoElement(body);
|
||||||
|
let borrow = wrap.borrow_data();
|
||||||
|
borrow.as_ref().unwrap()
|
||||||
|
.styles().primary.values()
|
||||||
|
.get_color()
|
||||||
|
.clone_color()
|
||||||
|
} else {
|
||||||
|
to_rgba(pres_context.mDefaultColor)
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,13 +257,10 @@ impl ToComputedValue for specified::CSSColor {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from_computed_value(computed: &CSSColor) -> Self {
|
fn from_computed_value(computed: &CSSColor) -> Self {
|
||||||
specified::CSSColor {
|
(match *computed {
|
||||||
parsed: match *computed {
|
CSSColor::RGBA(rgba) => specified::Color::RGBA(rgba),
|
||||||
CSSColor::RGBA(rgba) => specified::Color::RGBA(rgba),
|
CSSColor::CurrentColor => specified::Color::CurrentColor,
|
||||||
CSSColor::CurrentColor => specified::Color::CurrentColor,
|
}).into()
|
||||||
},
|
|
||||||
authored: None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,8 @@ mod gecko {
|
||||||
MozActiveHyperlinktext,
|
MozActiveHyperlinktext,
|
||||||
/// -moz-visitedhyperlinktext
|
/// -moz-visitedhyperlinktext
|
||||||
MozVisitedHyperlinktext,
|
MozVisitedHyperlinktext,
|
||||||
|
/// Quirksmode-only rule for inheriting color from the body
|
||||||
|
InheritFromBodyQuirk,
|
||||||
}
|
}
|
||||||
|
|
||||||
no_viewport_percentage!(Color);
|
no_viewport_percentage!(Color);
|
||||||
|
@ -89,6 +91,7 @@ mod gecko {
|
||||||
Color::MozHyperlinktext => dest.write_str("-moz-hyperlinktext"),
|
Color::MozHyperlinktext => dest.write_str("-moz-hyperlinktext"),
|
||||||
Color::MozActiveHyperlinktext => dest.write_str("-moz-activehyperlinktext"),
|
Color::MozActiveHyperlinktext => dest.write_str("-moz-activehyperlinktext"),
|
||||||
Color::MozVisitedHyperlinktext => dest.write_str("-moz-visitedhyperlinktext"),
|
Color::MozVisitedHyperlinktext => dest.write_str("-moz-visitedhyperlinktext"),
|
||||||
|
Color::InheritFromBodyQuirk => Ok(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,24 +107,27 @@ impl ToCss for CSSColor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<Color> for CSSColor {
|
||||||
|
fn from(color: Color) -> Self {
|
||||||
|
CSSColor {
|
||||||
|
parsed: color,
|
||||||
|
authored: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl CSSColor {
|
impl CSSColor {
|
||||||
#[inline]
|
#[inline]
|
||||||
/// Returns currentcolor value.
|
/// Returns currentcolor value.
|
||||||
pub fn currentcolor() -> CSSColor {
|
pub fn currentcolor() -> CSSColor {
|
||||||
CSSColor {
|
Color::CurrentColor.into()
|
||||||
parsed: Color::CurrentColor,
|
|
||||||
authored: None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
/// Returns transparent value.
|
/// Returns transparent value.
|
||||||
pub fn transparent() -> CSSColor {
|
pub fn transparent() -> CSSColor {
|
||||||
CSSColor {
|
// We should probably set authored to "transparent", but maybe it doesn't matter.
|
||||||
parsed: Color::RGBA(cssparser::RGBA::transparent()),
|
Color::RGBA(cssparser::RGBA::transparent()).into()
|
||||||
// This should probably be "transparent", but maybe it doesn't matter.
|
|
||||||
authored: None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue