mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: Move Canvas/Link color computation to C++-land
This doesn't change behavior but will allow us to deduplicate some logic given we compute the effective color-scheme in C++. Differential Revision: https://phabricator.services.mozilla.com/D129744
This commit is contained in:
parent
6c16c019fc
commit
c3322938f2
1 changed files with 11 additions and 22 deletions
|
@ -471,28 +471,17 @@ impl SystemColor {
|
|||
fn compute(&self, cx: &Context) -> ComputedColor {
|
||||
use crate::gecko_bindings::bindings;
|
||||
|
||||
let colors = &cx.device().pref_sheet_prefs().mColors;
|
||||
let style_color_scheme = cx.style().get_inherited_ui().clone_color_scheme();
|
||||
|
||||
// TODO: At least Canvas / CanvasText should be color-scheme aware
|
||||
// (probably the link colors too).
|
||||
convert_nscolor_to_computedcolor(match *self {
|
||||
SystemColor::Canvastext => colors.mDefault,
|
||||
SystemColor::Canvas => colors.mDefaultBackground,
|
||||
SystemColor::Linktext => colors.mLink,
|
||||
SystemColor::Activetext => colors.mActiveLink,
|
||||
SystemColor::Visitedtext => colors.mVisitedLink,
|
||||
|
||||
_ => {
|
||||
// TODO: We should avoid cloning here most likely, though it's
|
||||
// cheap-ish.
|
||||
let style_color_scheme =
|
||||
cx.style().get_inherited_ui().clone_color_scheme();
|
||||
let color = unsafe {
|
||||
bindings::Gecko_GetLookAndFeelSystemColor(*self as i32, cx.device().document(), &style_color_scheme)
|
||||
bindings::Gecko_ComputeSystemColor(*self, cx.device().document(), &style_color_scheme)
|
||||
};
|
||||
if color == bindings::NS_SAME_AS_FOREGROUND_COLOR {
|
||||
return ComputedColor::currentcolor();
|
||||
}
|
||||
color
|
||||
},
|
||||
})
|
||||
convert_nscolor_to_computedcolor(color)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue