mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Add forced-color-adjust property
Adds the forced-color-adjust property and ForcedColorAdjust keywords. Updates tweak_when_ignoring_colors to check for `none` value of that property when determining if a color adjustment in needed. Adds a check for `none` when styling selections to make sure they can be styled in forced color modes. Differential Revision: https://phabricator.services.mozilla.com/D169000
This commit is contained in:
parent
93326b2d2b
commit
9d41dd1ad9
8 changed files with 44 additions and 3 deletions
|
@ -424,6 +424,12 @@ fn tweak_when_ignoring_colors(
|
|||
return;
|
||||
}
|
||||
|
||||
// Always honor colors if forced-color-adjust is set to none.
|
||||
let forced = context.builder.get_inherited_text().clone_forced_color_adjust();
|
||||
if forced == computed::ForcedColorAdjust::None {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't override background-color on ::-moz-color-swatch. It is set as an
|
||||
// author style (via the style attribute), but it's pretty important for it
|
||||
// to show up for obvious reasons :)
|
||||
|
|
|
@ -480,6 +480,7 @@ class Longhand(Property):
|
|||
"PageOrientation",
|
||||
"Percentage",
|
||||
"PrintColorAdjust",
|
||||
"ForcedColorAdjust",
|
||||
"Resize",
|
||||
"RubyPosition",
|
||||
"SVGOpacity",
|
||||
|
|
|
@ -388,3 +388,14 @@ ${helpers.predefined_type(
|
|||
animation_value_type="discrete",
|
||||
spec="https://www.w3.org/TR/css-text-4/#hyphenate-character",
|
||||
)}
|
||||
|
||||
${helpers.predefined_type(
|
||||
"forced-color-adjust",
|
||||
"ForcedColorAdjust",
|
||||
"computed::ForcedColorAdjust::Auto",
|
||||
engines="gecko",
|
||||
gecko_pref="layout.css.forced-color-adjust.enabled",
|
||||
has_effect_on_gecko_scrollbars=False,
|
||||
animation_value_type="discrete",
|
||||
spec="https://drafts.csswg.org/css-color-adjust-1/#forced-color-adjust-prop",
|
||||
)}
|
||||
|
|
|
@ -935,6 +935,7 @@ CASCADE_GROUPS = {
|
|||
"font-family",
|
||||
# color-scheme affects how system colors resolve.
|
||||
"color-scheme",
|
||||
"forced-color-adjust",
|
||||
],
|
||||
}
|
||||
def in_late_group(p):
|
||||
|
|
|
@ -12,7 +12,7 @@ use cssparser::{Color as CSSParserColor, RGBA};
|
|||
use std::fmt;
|
||||
use style_traits::{CssWriter, ToCss};
|
||||
|
||||
pub use crate::values::specified::color::{ColorScheme, PrintColorAdjust};
|
||||
pub use crate::values::specified::color::{ColorScheme, PrintColorAdjust, ForcedColorAdjust};
|
||||
|
||||
/// The computed value of the `color` property.
|
||||
pub type ColorPropertyValue = RGBA;
|
||||
|
|
|
@ -59,7 +59,7 @@ pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize, S
|
|||
pub use self::box_::{ScrollAxis, ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStop};
|
||||
pub use self::box_::{ScrollSnapStrictness, ScrollSnapType, ScrollTimelineName};
|
||||
pub use self::box_::{TouchAction, VerticalAlign, WillChange};
|
||||
pub use self::color::{Color, ColorOrAuto, ColorPropertyValue, ColorScheme, PrintColorAdjust};
|
||||
pub use self::color::{Color, ColorOrAuto, ColorPropertyValue, ColorScheme, PrintColorAdjust, ForcedColorAdjust};
|
||||
pub use self::column::ColumnCount;
|
||||
pub use self::counters::{Content, ContentItem, CounterIncrement, CounterReset, CounterSet};
|
||||
pub use self::easing::TimingFunction;
|
||||
|
|
|
@ -1073,3 +1073,25 @@ pub enum PrintColorAdjust {
|
|||
/// Respect specified colors.
|
||||
Exact,
|
||||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-color-adjust-1/#forced-color-adjust-prop
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
MallocSizeOf,
|
||||
Parse,
|
||||
PartialEq,
|
||||
SpecifiedValueInfo,
|
||||
ToCss,
|
||||
ToComputedValue,
|
||||
ToResolvedValue,
|
||||
ToShmem,
|
||||
)]
|
||||
#[repr(u8)]
|
||||
pub enum ForcedColorAdjust {
|
||||
/// Adjust colors if needed.
|
||||
Auto,
|
||||
/// Respect specified colors.
|
||||
None,
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize, S
|
|||
pub use self::box_::{ScrollAxis, ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStop};
|
||||
pub use self::box_::{ScrollSnapStrictness, ScrollSnapType, ScrollTimelineName};
|
||||
pub use self::box_::{TouchAction, TransitionProperty, VerticalAlign, WillChange};
|
||||
pub use self::color::{Color, ColorOrAuto, ColorPropertyValue, ColorScheme, PrintColorAdjust};
|
||||
pub use self::color::{Color, ColorOrAuto, ColorPropertyValue, ColorScheme, PrintColorAdjust, ForcedColorAdjust};
|
||||
pub use self::column::ColumnCount;
|
||||
pub use self::counters::{Content, ContentItem, CounterIncrement, CounterReset, CounterSet};
|
||||
pub use self::easing::TimingFunction;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue