mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
#15842 Add gecko glue for caret-color.
Implement from(StyleComplexColor) for ColorOrAuto. Thanks @emilio. (+4 squashed commits) Squashed commits: [baf7cc0
] Add clone to caret-color [9cb82ca
] Correctly call methods to copy a color in a SympleComplexColor and getting its auto [c483f07
] Add set and copy functions for caret_color [0aa20be
] Move caret-color and set its product property to gecko
This commit is contained in:
parent
e34aac03ff
commit
f195b247c0
4 changed files with 50 additions and 13 deletions
|
@ -4,9 +4,10 @@
|
||||||
|
|
||||||
//! Rust helpers to interact with Gecko's StyleComplexColor.
|
//! Rust helpers to interact with Gecko's StyleComplexColor.
|
||||||
|
|
||||||
use cssparser::Color;
|
use cssparser;
|
||||||
use gecko::values::{convert_nscolor_to_rgba, convert_rgba_to_nscolor};
|
use gecko::values::{convert_nscolor_to_rgba, convert_rgba_to_nscolor};
|
||||||
use gecko_bindings::structs::{nscolor, StyleComplexColor};
|
use gecko_bindings::structs::{nscolor, StyleComplexColor};
|
||||||
|
use values;
|
||||||
|
|
||||||
impl From<nscolor> for StyleComplexColor {
|
impl From<nscolor> for StyleComplexColor {
|
||||||
fn from(other: nscolor) -> Self {
|
fn from(other: nscolor) -> Self {
|
||||||
|
@ -38,8 +39,10 @@ impl StyleComplexColor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Color> for StyleComplexColor {
|
impl From<cssparser::Color> for StyleComplexColor {
|
||||||
fn from(other: Color) -> Self {
|
fn from(other: cssparser::Color) -> Self {
|
||||||
|
use cssparser::Color;
|
||||||
|
|
||||||
match other {
|
match other {
|
||||||
Color::RGBA(rgba) => convert_rgba_to_nscolor(&rgba).into(),
|
Color::RGBA(rgba) => convert_rgba_to_nscolor(&rgba).into(),
|
||||||
Color::CurrentColor => StyleComplexColor::current_color(),
|
Color::CurrentColor => StyleComplexColor::current_color(),
|
||||||
|
@ -47,8 +50,22 @@ impl From<Color> for StyleComplexColor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<StyleComplexColor> for Color {
|
impl From<StyleComplexColor> for values::computed::ColorOrAuto {
|
||||||
|
fn from(color: StyleComplexColor) -> Self {
|
||||||
|
use values::{Auto, Either};
|
||||||
|
|
||||||
|
if color.mIsAuto {
|
||||||
|
return Either::Second(Auto);
|
||||||
|
}
|
||||||
|
|
||||||
|
Either::First(color.into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<StyleComplexColor> for cssparser::Color {
|
||||||
fn from(other: StyleComplexColor) -> Self {
|
fn from(other: StyleComplexColor) -> Self {
|
||||||
|
use cssparser::Color;
|
||||||
|
|
||||||
if other.mForegroundRatio == 0 {
|
if other.mForegroundRatio == 0 {
|
||||||
Color::RGBA(convert_nscolor_to_rgba(other.mColor))
|
Color::RGBA(convert_nscolor_to_rgba(other.mColor))
|
||||||
} else if other.mForegroundRatio == 255 {
|
} else if other.mForegroundRatio == 255 {
|
||||||
|
|
|
@ -43,7 +43,7 @@ use gecko_bindings::bindings::Gecko_SetNullImageValue;
|
||||||
use gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull;
|
use gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull;
|
||||||
use gecko_bindings::bindings::{Gecko_ResetFilters, Gecko_CopyFiltersFrom};
|
use gecko_bindings::bindings::{Gecko_ResetFilters, Gecko_CopyFiltersFrom};
|
||||||
use gecko_bindings::bindings::RawGeckoPresContextBorrowed;
|
use gecko_bindings::bindings::RawGeckoPresContextBorrowed;
|
||||||
use gecko_bindings::structs;
|
use gecko_bindings::structs::{self, StyleComplexColor};
|
||||||
use gecko_bindings::structs::nsStyleVariables;
|
use gecko_bindings::structs::nsStyleVariables;
|
||||||
use gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordData, CoordDataMut};
|
use gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordData, CoordDataMut};
|
||||||
use gecko_bindings::sugar::ownership::HasArcFFI;
|
use gecko_bindings::sugar::ownership::HasArcFFI;
|
||||||
|
@ -3095,7 +3095,7 @@ clip-path
|
||||||
</%self:impl_trait>
|
</%self:impl_trait>
|
||||||
|
|
||||||
<%self:impl_trait style_struct_name="Pointing"
|
<%self:impl_trait style_struct_name="Pointing"
|
||||||
skip_longhands="cursor">
|
skip_longhands="cursor caret-color">
|
||||||
pub fn set_cursor(&mut self, v: longhands::cursor::computed_value::T) {
|
pub fn set_cursor(&mut self, v: longhands::cursor::computed_value::T) {
|
||||||
use properties::longhands::cursor::computed_value::Keyword;
|
use properties::longhands::cursor::computed_value::Keyword;
|
||||||
use style_traits::cursor::Cursor;
|
use style_traits::cursor::Cursor;
|
||||||
|
@ -3162,6 +3162,26 @@ clip-path
|
||||||
Gecko_CopyCursorArrayFrom(&mut self.gecko, &other.gecko);
|
Gecko_CopyCursorArrayFrom(&mut self.gecko, &other.gecko);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_caret_color(&mut self, v: longhands::caret_color::computed_value::T){
|
||||||
|
use values::Either;
|
||||||
|
|
||||||
|
match v {
|
||||||
|
Either::First(color) => {
|
||||||
|
self.gecko.mCaretColor = StyleComplexColor::from(color);
|
||||||
|
}
|
||||||
|
Either::Second(_auto) => {
|
||||||
|
self.gecko.mCaretColor = StyleComplexColor::auto();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn copy_caret_color_from(&mut self, other: &Self){
|
||||||
|
self.gecko.mCaretColor = other.gecko.mCaretColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
<%call expr="impl_color_clone('caret_color', 'mCaretColor')"></%call>
|
||||||
|
|
||||||
</%self:impl_trait>
|
</%self:impl_trait>
|
||||||
|
|
||||||
<%self:impl_trait style_struct_name="Column"
|
<%self:impl_trait style_struct_name="Column"
|
||||||
|
|
|
@ -170,3 +170,10 @@ ${helpers.single_keyword("-moz-user-focus",
|
||||||
gecko_inexhaustive=True,
|
gecko_inexhaustive=True,
|
||||||
animatable=False,
|
animatable=False,
|
||||||
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-user-focus)")}
|
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-user-focus)")}
|
||||||
|
|
||||||
|
${helpers.predefined_type("caret-color",
|
||||||
|
"ColorOrAuto",
|
||||||
|
"Either::Second(Auto)",
|
||||||
|
spec="https://drafts.csswg.org/css-ui/#caret-color",
|
||||||
|
animatable="True",
|
||||||
|
products="gecko")}
|
||||||
|
|
|
@ -30,10 +30,3 @@ ${helpers.single_keyword("-moz-window-dragging", "default drag no-drag", product
|
||||||
gecko_enum_prefix="StyleWindowDragging",
|
gecko_enum_prefix="StyleWindowDragging",
|
||||||
animatable=False,
|
animatable=False,
|
||||||
spec="None (Nonstandard Firefox-only property)")}
|
spec="None (Nonstandard Firefox-only property)")}
|
||||||
|
|
||||||
${helpers.predefined_type("caret-color",
|
|
||||||
"ColorOrAuto",
|
|
||||||
"Either::Second(Auto)",
|
|
||||||
spec="https://drafts.csswg.org/css-ui/#caret-color",
|
|
||||||
animatable="True",
|
|
||||||
products="none")}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue