mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
style: Respect transparent and system color border colors in forced-colors mode
Differential Revision: https://phabricator.services.mozilla.com/D123111
This commit is contained in:
parent
f31f541125
commit
26c5db6a6e
2 changed files with 47 additions and 3 deletions
|
@ -464,7 +464,22 @@ fn tweak_when_ignoring_colors(
|
|||
}
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
_ => {
|
||||
// We honor transparent and system colors more generally for all
|
||||
// colors.
|
||||
//
|
||||
// NOTE(emilio): This doesn't handle caret-color and
|
||||
// accent-color because those use a slightly different syntax
|
||||
// (<color> | auto for example). That's probably fine though, as
|
||||
// using a system color for caret-color doesn't make sense (using
|
||||
// currentColor is fine), and we ignore accent-color in
|
||||
// high-contrast-mode anyways.
|
||||
if let Some(color) = declaration.color_value() {
|
||||
if color.is_system() || alpha_channel(color, context) == 0 {
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
*declaration.to_mut() =
|
||||
|
|
|
@ -232,7 +232,7 @@ pub mod shorthands {
|
|||
// which don't exist in `LonghandId`.
|
||||
|
||||
<%
|
||||
extra = [
|
||||
extra_variants = [
|
||||
{
|
||||
"name": "CSSWideKeyword",
|
||||
"type": "WideKeywordDeclaration",
|
||||
|
@ -252,7 +252,7 @@ pub mod shorthands {
|
|||
"copy": False,
|
||||
},
|
||||
]
|
||||
for v in extra:
|
||||
for v in extra_variants:
|
||||
variants.append(v)
|
||||
groups[v["type"]] = [v]
|
||||
%>
|
||||
|
@ -394,6 +394,17 @@ impl MallocSizeOf for PropertyDeclaration {
|
|||
|
||||
|
||||
impl PropertyDeclaration {
|
||||
/// Returns whether this is a variant of the Longhand(Value) type, rather
|
||||
/// than one of the special variants in extra_variants.
|
||||
fn is_longhand_value(&self) -> bool {
|
||||
match *self {
|
||||
% for v in extra_variants:
|
||||
PropertyDeclaration::${v["name"]}(..) => false,
|
||||
% endfor
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
|
||||
/// Like the method on ToCss, but without the type parameter to avoid
|
||||
/// accidentally monomorphizing this large function multiple times for
|
||||
/// different writers.
|
||||
|
@ -409,6 +420,24 @@ impl PropertyDeclaration {
|
|||
% endfor
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the color value of a given property, for high-contrast-mode
|
||||
/// tweaks.
|
||||
pub(crate) fn color_value(&self) -> Option<<&crate::values::specified::Color> {
|
||||
${static_longhand_id_set("COLOR_PROPERTIES", lambda p: p.predefined_type == "Color")}
|
||||
<%
|
||||
# sanity check
|
||||
assert data.longhands_by_name["background-color"].predefined_type == "Color"
|
||||
|
||||
color_specified_type = data.longhands_by_name["background-color"].specified_type()
|
||||
%>
|
||||
let id = self.id().as_longhand()?;
|
||||
if !COLOR_PROPERTIES.contains(id) || !self.is_longhand_value() {
|
||||
return None;
|
||||
}
|
||||
let repr = self as *const _ as *const PropertyDeclarationVariantRepr<${color_specified_type}>;
|
||||
Some(unsafe { &(*repr).value })
|
||||
}
|
||||
}
|
||||
|
||||
/// A module with all the code related to animated properties.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue