mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #23503 - emilio:gecko-sync, r=emilio
style: sync changes from mozilla-central See each individual commit for details. This also cherry-picks #23463 with a few fixes that were needed in Gecko-only code. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23503) <!-- Reviewable:end -->
This commit is contained in:
commit
fe8aad7227
47 changed files with 897 additions and 915 deletions
|
@ -25,7 +25,6 @@ STYLE_STRUCT_LIST = [
|
|||
"background",
|
||||
"border",
|
||||
"box",
|
||||
"color",
|
||||
"column",
|
||||
"counters",
|
||||
"effects",
|
||||
|
|
|
@ -33,13 +33,11 @@ use crate::gecko_bindings::bindings::Gecko_nsStyleFont_CopyLangFrom;
|
|||
use crate::gecko_bindings::bindings::Gecko_SetListStyleImageNone;
|
||||
use crate::gecko_bindings::bindings::Gecko_SetListStyleImageImageValue;
|
||||
use crate::gecko_bindings::bindings::Gecko_SetNullImageValue;
|
||||
use crate::gecko_bindings::bindings::{Gecko_ResetFilters, Gecko_CopyFiltersFrom};
|
||||
use crate::gecko_bindings::structs;
|
||||
use crate::gecko_bindings::structs::nsCSSPropertyID;
|
||||
use crate::gecko_bindings::structs::mozilla::PseudoStyleType;
|
||||
use crate::gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordDataMut};
|
||||
use crate::gecko_bindings::sugar::ns_style_coord::CoordDataMut;
|
||||
use crate::gecko_bindings::sugar::refptr::RefPtr;
|
||||
use crate::gecko::values::GeckoStyleCoordConvertible;
|
||||
use crate::gecko::values::round_border_to_device_pixels;
|
||||
use crate::logical_geometry::WritingMode;
|
||||
use crate::media_queries::Device;
|
||||
|
@ -52,11 +50,10 @@ use std::marker::PhantomData;
|
|||
use std::mem::{forget, uninitialized, zeroed, ManuallyDrop};
|
||||
use std::{cmp, ops, ptr};
|
||||
use crate::values::{self, CustomIdent, Either, KeyframesName, None_};
|
||||
use crate::values::computed::{NonNegativeLength, Percentage, TransitionProperty};
|
||||
use crate::values::computed::{Percentage, TransitionProperty};
|
||||
use crate::values::computed::url::ComputedImageUrl;
|
||||
use crate::values::computed::BorderStyle;
|
||||
use crate::values::computed::font::FontSize;
|
||||
use crate::values::computed::effects::Filter;
|
||||
use crate::values::generics::column::ColumnCount;
|
||||
use crate::values::generics::transform::TransformStyle;
|
||||
use crate::values::generics::url::UrlOrNone;
|
||||
|
@ -278,7 +275,7 @@ impl ComputedValuesInner {
|
|||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn has_moz_binding(&self) -> bool {
|
||||
!self.get_box().gecko.mBinding.mRawPtr.is_null()
|
||||
!self.get_box().gecko.mBinding.is_none()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -550,7 +547,7 @@ def set_gecko_property(ffi_name, expr):
|
|||
unsafe {
|
||||
bindings::Gecko_nsStyleSVGPaint_SetURLValue(
|
||||
paint,
|
||||
url.url_value_ptr(),
|
||||
&url
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -591,7 +588,6 @@ def set_gecko_property(ffi_name, expr):
|
|||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
|
||||
use crate::values::computed::url::ComputedUrl;
|
||||
use crate::values::generics::svg::{SVGPaint, SVGPaintKind};
|
||||
use self::structs::nsStyleSVGPaintType;
|
||||
use self::structs::nsStyleSVGFallbackType;
|
||||
|
@ -613,8 +609,7 @@ def set_gecko_property(ffi_name, expr):
|
|||
nsStyleSVGPaintType::eStyleSVGPaintType_ContextStroke => SVGPaintKind::ContextStroke,
|
||||
nsStyleSVGPaintType::eStyleSVGPaintType_Server => {
|
||||
SVGPaintKind::PaintServer(unsafe {
|
||||
let url = RefPtr::new(*paint.mPaint.mPaintServer.as_ref());
|
||||
ComputedUrl::from_url_value(url)
|
||||
paint.mPaint.mPaintServer.as_ref().clone()
|
||||
})
|
||||
}
|
||||
nsStyleSVGPaintType::eStyleSVGPaintType_Color => {
|
||||
|
@ -735,45 +730,6 @@ def set_gecko_property(ffi_name, expr):
|
|||
}
|
||||
</%def>
|
||||
|
||||
<%def name="impl_css_url(ident, gecko_ffi_name)">
|
||||
#[allow(non_snake_case)]
|
||||
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
|
||||
match v {
|
||||
UrlOrNone::Url(ref url) => {
|
||||
self.gecko.${gecko_ffi_name}.set_move(url.clone_url_value())
|
||||
}
|
||||
UrlOrNone::None => {
|
||||
unsafe {
|
||||
self.gecko.${gecko_ffi_name}.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#[allow(non_snake_case)]
|
||||
pub fn copy_${ident}_from(&mut self, other: &Self) {
|
||||
unsafe {
|
||||
self.gecko.${gecko_ffi_name}.set(&other.gecko.${gecko_ffi_name});
|
||||
}
|
||||
}
|
||||
#[allow(non_snake_case)]
|
||||
pub fn reset_${ident}(&mut self, other: &Self) {
|
||||
self.copy_${ident}_from(other)
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
|
||||
use crate::values::computed::url::ComputedUrl;
|
||||
|
||||
if self.gecko.${gecko_ffi_name}.mRawPtr.is_null() {
|
||||
return UrlOrNone::none()
|
||||
}
|
||||
|
||||
UrlOrNone::Url(unsafe {
|
||||
ComputedUrl::from_url_value(self.gecko.${gecko_ffi_name}.to_safe())
|
||||
})
|
||||
}
|
||||
</%def>
|
||||
|
||||
<%def name="impl_logical(name, **kwargs)">
|
||||
${helpers.logical_setter(name)}
|
||||
</%def>
|
||||
|
@ -879,7 +835,6 @@ impl Clone for ${style_struct.gecko_struct_name} {
|
|||
"SVGOpacity": impl_svg_opacity,
|
||||
"SVGPaint": impl_svg_paint,
|
||||
"SVGWidth": impl_svg_length,
|
||||
"url::UrlOrNone": impl_css_url,
|
||||
}
|
||||
|
||||
def longhand_method(longhand):
|
||||
|
@ -2164,8 +2119,7 @@ fn static_assert() {
|
|||
animation-iteration-count animation-timing-function
|
||||
clear transition-duration transition-delay
|
||||
transition-timing-function transition-property
|
||||
transform-style -moz-binding shape-outside
|
||||
-webkit-line-clamp""" %>
|
||||
transform-style shape-outside -webkit-line-clamp""" %>
|
||||
<%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}">
|
||||
#[inline]
|
||||
pub fn set_display(&mut self, v: longhands::display::computed_value::T) {
|
||||
|
@ -2205,7 +2159,7 @@ fn static_assert() {
|
|||
gecko_inexhaustive=True,
|
||||
) %>
|
||||
${impl_keyword('clear', 'mBreakType', clear_keyword)}
|
||||
${impl_css_url('_moz_binding', 'mBinding')}
|
||||
|
||||
${impl_transition_time_value('delay', 'Delay')}
|
||||
${impl_transition_time_value('duration', 'Duration')}
|
||||
${impl_transition_timing_function()}
|
||||
|
@ -2834,10 +2788,7 @@ fn static_assert() {
|
|||
}
|
||||
UrlOrNone::Url(ref url) => {
|
||||
unsafe {
|
||||
Gecko_SetListStyleImageImageValue(
|
||||
&mut *self.gecko,
|
||||
url.url_value_ptr(),
|
||||
);
|
||||
Gecko_SetListStyleImageImageValue(&mut *self.gecko, url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2973,8 +2924,7 @@ fn static_assert() {
|
|||
${impl_simple_copy('_x_span', 'mSpan')}
|
||||
</%self:impl_trait>
|
||||
|
||||
<%self:impl_trait style_struct_name="Effects"
|
||||
skip_longhands="clip filter">
|
||||
<%self:impl_trait style_struct_name="Effects" skip_longhands="clip">
|
||||
pub fn set_clip(&mut self, v: longhands::clip::computed_value::T) {
|
||||
use crate::gecko_bindings::structs::NS_STYLE_CLIP_AUTO;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_CLIP_RECT;
|
||||
|
@ -3082,138 +3032,6 @@ fn static_assert() {
|
|||
|
||||
Either::First(ClipRect { top, right, bottom, left })
|
||||
}
|
||||
|
||||
<%
|
||||
# This array is several filter function which has percentage or
|
||||
# number value for function of clone / set.
|
||||
# The setting / cloning process of other function(e.g. Blur / HueRotate) is
|
||||
# different from these function. So this array don't include such function.
|
||||
FILTER_FUNCTIONS = [ 'Brightness', 'Contrast', 'Grayscale', 'Invert',
|
||||
'Opacity', 'Saturate', 'Sepia' ]
|
||||
%>
|
||||
|
||||
pub fn set_filter<I>(&mut self, v: I)
|
||||
where
|
||||
I: IntoIterator<Item = Filter>,
|
||||
I::IntoIter: ExactSizeIterator,
|
||||
{
|
||||
use crate::values::generics::effects::Filter::*;
|
||||
use crate::gecko_bindings::structs::nsStyleFilter;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_FILTER_BLUR;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_FILTER_BRIGHTNESS;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_FILTER_CONTRAST;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_FILTER_GRAYSCALE;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_FILTER_INVERT;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_FILTER_OPACITY;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_FILTER_SATURATE;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_FILTER_SEPIA;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_FILTER_HUE_ROTATE;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_FILTER_DROP_SHADOW;
|
||||
|
||||
fn fill_filter(m_type: u32, value: CoordDataValue, gecko_filter: &mut nsStyleFilter){
|
||||
gecko_filter.mType = m_type;
|
||||
gecko_filter.mFilterParameter.set_value(value);
|
||||
}
|
||||
|
||||
let v = v.into_iter();
|
||||
unsafe {
|
||||
Gecko_ResetFilters(&mut *self.gecko, v.len());
|
||||
}
|
||||
debug_assert_eq!(v.len(), self.gecko.mFilters.len());
|
||||
|
||||
for (servo, gecko_filter) in v.zip(self.gecko.mFilters.iter_mut()) {
|
||||
match servo {
|
||||
% for func in FILTER_FUNCTIONS:
|
||||
${func}(factor) => fill_filter(NS_STYLE_FILTER_${func.upper()},
|
||||
CoordDataValue::Factor(factor.0),
|
||||
gecko_filter),
|
||||
% endfor
|
||||
Blur(length) => fill_filter(NS_STYLE_FILTER_BLUR,
|
||||
CoordDataValue::Coord(length.0.to_i32_au()),
|
||||
gecko_filter),
|
||||
|
||||
HueRotate(angle) => fill_filter(NS_STYLE_FILTER_HUE_ROTATE,
|
||||
CoordDataValue::from(angle),
|
||||
gecko_filter),
|
||||
|
||||
DropShadow(shadow) => {
|
||||
gecko_filter.mType = NS_STYLE_FILTER_DROP_SHADOW;
|
||||
unsafe {
|
||||
let ref mut union = gecko_filter.__bindgen_anon_1;
|
||||
ptr::write(union.mDropShadow.as_mut(), shadow);
|
||||
}
|
||||
},
|
||||
Url(ref url) => {
|
||||
unsafe {
|
||||
bindings::Gecko_nsStyleFilter_SetURLValue(gecko_filter, url.url_value_ptr());
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn copy_filter_from(&mut self, other: &Self) {
|
||||
unsafe {
|
||||
Gecko_CopyFiltersFrom(&other.gecko as *const _ as *mut _, &mut *self.gecko);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reset_filter(&mut self, other: &Self) {
|
||||
self.copy_filter_from(other)
|
||||
}
|
||||
|
||||
pub fn clone_filter(&self) -> longhands::filter::computed_value::T {
|
||||
use crate::values::generics::effects::Filter;
|
||||
use crate::values::computed::url::ComputedUrl;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_FILTER_BLUR;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_FILTER_BRIGHTNESS;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_FILTER_CONTRAST;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_FILTER_GRAYSCALE;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_FILTER_INVERT;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_FILTER_OPACITY;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_FILTER_SATURATE;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_FILTER_SEPIA;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_FILTER_HUE_ROTATE;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_FILTER_DROP_SHADOW;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_FILTER_URL;
|
||||
|
||||
longhands::filter::computed_value::List(self.gecko.mFilters.iter().map(|filter| {
|
||||
match filter.mType {
|
||||
% for func in FILTER_FUNCTIONS:
|
||||
NS_STYLE_FILTER_${func.upper()} => {
|
||||
Filter::${func}(
|
||||
GeckoStyleCoordConvertible::from_gecko_style_coord(
|
||||
&filter.mFilterParameter
|
||||
).unwrap()
|
||||
)
|
||||
},
|
||||
% endfor
|
||||
NS_STYLE_FILTER_BLUR => {
|
||||
Filter::Blur(NonNegativeLength::from_gecko_style_coord(
|
||||
&filter.mFilterParameter
|
||||
).unwrap())
|
||||
},
|
||||
NS_STYLE_FILTER_HUE_ROTATE => {
|
||||
Filter::HueRotate(GeckoStyleCoordConvertible::from_gecko_style_coord(
|
||||
&filter.mFilterParameter,
|
||||
).unwrap())
|
||||
},
|
||||
NS_STYLE_FILTER_DROP_SHADOW => {
|
||||
Filter::DropShadow(unsafe {
|
||||
(*filter.__bindgen_anon_1.mDropShadow.as_ref()).clone()
|
||||
})
|
||||
},
|
||||
NS_STYLE_FILTER_URL => {
|
||||
Filter::Url(unsafe {
|
||||
let url = RefPtr::new(*filter.__bindgen_anon_1.mURL.as_ref());
|
||||
ComputedUrl::from_url_value(url)
|
||||
})
|
||||
}
|
||||
_ => unreachable!("Unknown filter function?"),
|
||||
}
|
||||
}).collect())
|
||||
}
|
||||
|
||||
</%self:impl_trait>
|
||||
|
||||
<%self:impl_trait style_struct_name="InheritedBox">
|
||||
|
@ -3537,9 +3355,6 @@ clip-path
|
|||
}
|
||||
</%self:impl_trait>
|
||||
|
||||
<%self:impl_trait style_struct_name="Color">
|
||||
</%self:impl_trait>
|
||||
|
||||
<%self:impl_trait style_struct_name="InheritedUI" skip_longhands="cursor">
|
||||
pub fn set_cursor(&mut self, v: longhands::cursor::computed_value::T) {
|
||||
self.gecko.mCursor = v.keyword;
|
||||
|
@ -3550,7 +3365,7 @@ clip-path
|
|||
unsafe {
|
||||
Gecko_SetCursorImageValue(
|
||||
&mut self.gecko.mCursorImages[i],
|
||||
v.images[i].url.url_value_ptr(),
|
||||
&v.images[i].url
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -3769,7 +3584,7 @@ clip-path
|
|||
unsafe {
|
||||
bindings::Gecko_SetContentDataImageValue(
|
||||
&mut self.gecko.mContents[i],
|
||||
url.url_value_ptr(),
|
||||
url,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ use std::mem::{self, ManuallyDrop};
|
|||
use crate::hash::FxHashMap;
|
||||
use super::ComputedValues;
|
||||
use crate::values::animated::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero};
|
||||
use crate::values::animated::effects::Filter as AnimatedFilter;
|
||||
use crate::values::animated::effects::AnimatedFilter;
|
||||
#[cfg(feature = "gecko")] use crate::values::computed::TransitionProperty;
|
||||
use crate::values::computed::{ClipRect, Context};
|
||||
use crate::values::computed::ToComputedValue;
|
||||
|
|
|
@ -390,7 +390,7 @@ ${helpers.predefined_type(
|
|||
"OffsetRotate",
|
||||
"computed::OffsetRotate::auto()",
|
||||
products="gecko",
|
||||
animation_value_type="none",
|
||||
animation_value_type="ComputedValue",
|
||||
gecko_pref="layout.css.motion-path.enabled",
|
||||
spec="https://drafts.fxtf.org/motion-1/#offset-rotate-property",
|
||||
servo_restyle_damage="reflow_out_of_flow"
|
||||
|
@ -644,7 +644,6 @@ ${helpers.predefined_type(
|
|||
"basic_shape::FloatAreaShape",
|
||||
"generics::basic_shape::ShapeSource::None",
|
||||
products="gecko",
|
||||
boxed=True,
|
||||
animation_value_type="basic_shape::FloatAreaShape",
|
||||
flags="APPLIES_TO_FIRST_LETTER",
|
||||
spec="https://drafts.csswg.org/css-shapes/#shape-outside-property",
|
||||
|
|
|
@ -1,130 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
<%namespace name="helpers" file="/helpers.mako.rs" />
|
||||
|
||||
<% data.new_style_struct("Color", inherited=True) %>
|
||||
|
||||
<% from data import to_rust_ident %>
|
||||
|
||||
${helpers.predefined_type(
|
||||
"color",
|
||||
"ColorPropertyValue",
|
||||
"::cssparser::RGBA::new(0, 0, 0, 255)",
|
||||
animation_value_type="AnimatedRGBA",
|
||||
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
|
||||
ignored_when_colors_disabled="True",
|
||||
spec="https://drafts.csswg.org/css-color/#color",
|
||||
)}
|
||||
|
||||
// FIXME(#15973): Add servo support for system colors
|
||||
//
|
||||
// FIXME(emilio): Move outside of mako.
|
||||
% if product == "gecko":
|
||||
pub mod system_colors {
|
||||
<%
|
||||
# These are actually parsed. See nsCSSProps::kColorKTable
|
||||
system_colors = """activeborder activecaption appworkspace background buttonface
|
||||
buttonhighlight buttonshadow buttontext captiontext graytext highlight
|
||||
highlighttext inactiveborder inactivecaption inactivecaptiontext
|
||||
infobackground infotext menu menutext scrollbar threeddarkshadow
|
||||
threedface threedhighlight threedlightshadow threedshadow window
|
||||
windowframe windowtext -moz-buttondefault -moz-buttonhoverface
|
||||
-moz-buttonhovertext -moz-cellhighlight -moz-cellhighlighttext
|
||||
-moz-eventreerow -moz-field -moz-fieldtext -moz-dialog -moz-dialogtext
|
||||
-moz-dragtargetzone -moz-gtk-info-bar-text -moz-html-cellhighlight
|
||||
-moz-html-cellhighlighttext -moz-mac-buttonactivetext
|
||||
-moz-gtk-buttonactivetext
|
||||
-moz-mac-chrome-active -moz-mac-chrome-inactive
|
||||
-moz-mac-defaultbuttontext -moz-mac-focusring -moz-mac-menuselect
|
||||
-moz-mac-menushadow -moz-mac-menutextdisable -moz-mac-menutextselect
|
||||
-moz-mac-disabledtoolbartext -moz-mac-secondaryhighlight
|
||||
-moz-mac-vibrancy-light -moz-mac-vibrancy-dark
|
||||
-moz-mac-vibrant-titlebar-light -moz-mac-vibrant-titlebar-dark
|
||||
-moz-mac-menupopup
|
||||
-moz-mac-menuitem -moz-mac-active-menuitem -moz-mac-source-list
|
||||
-moz-mac-source-list-selection -moz-mac-active-source-list-selection
|
||||
-moz-mac-tooltip
|
||||
-moz-menuhover -moz-menuhovertext -moz-menubartext -moz-menubarhovertext
|
||||
-moz-oddtreerow -moz-win-mediatext -moz-win-communicationstext
|
||||
-moz-win-accentcolor -moz-win-accentcolortext
|
||||
-moz-nativehyperlinktext -moz-comboboxtext -moz-combobox""".split()
|
||||
|
||||
# These are not parsed but must be serialized
|
||||
# They are only ever set directly by Gecko
|
||||
extra_colors = """WindowBackground WindowForeground WidgetBackground WidgetForeground
|
||||
WidgetSelectBackground WidgetSelectForeground Widget3DHighlight Widget3DShadow
|
||||
TextBackground TextForeground TextSelectBackground TextSelectForeground
|
||||
TextSelectForegroundCustom TextSelectBackgroundDisabled TextSelectBackgroundAttention
|
||||
TextHighlightBackground TextHighlightForeground IMERawInputBackground
|
||||
IMERawInputForeground IMERawInputUnderline IMESelectedRawTextBackground
|
||||
IMESelectedRawTextForeground IMESelectedRawTextUnderline
|
||||
IMEConvertedTextBackground IMEConvertedTextForeground IMEConvertedTextUnderline
|
||||
IMESelectedConvertedTextBackground IMESelectedConvertedTextForeground
|
||||
IMESelectedConvertedTextUnderline SpellCheckerUnderline""".split()
|
||||
%>
|
||||
use crate::gecko_bindings::bindings::Gecko_GetLookAndFeelSystemColor;
|
||||
use crate::gecko_bindings::structs::root::mozilla::LookAndFeel_ColorID;
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ToCss};
|
||||
use to_shmem::impl_trivial_to_shmem;
|
||||
use crate::values::computed::{Context, ToComputedValue};
|
||||
|
||||
pub type SystemColor = LookAndFeel_ColorID;
|
||||
|
||||
// It's hard to implement MallocSizeOf for LookAndFeel_ColorID because it
|
||||
// is a bindgen type. So we implement it on the typedef instead.
|
||||
malloc_size_of_is_0!(SystemColor);
|
||||
|
||||
impl_trivial_to_shmem!(SystemColor);
|
||||
|
||||
impl ToCss for SystemColor {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
let s = match *self {
|
||||
% for color in system_colors + extra_colors:
|
||||
LookAndFeel_ColorID::eColorID_${to_rust_ident(color)} => "${color}",
|
||||
% endfor
|
||||
LookAndFeel_ColorID::eColorID_LAST_COLOR => unreachable!(),
|
||||
};
|
||||
dest.write_str(s)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToComputedValue for SystemColor {
|
||||
type ComputedValue = u32; // nscolor
|
||||
|
||||
#[inline]
|
||||
fn to_computed_value(&self, cx: &Context) -> Self::ComputedValue {
|
||||
unsafe {
|
||||
Gecko_GetLookAndFeelSystemColor(
|
||||
*self as i32,
|
||||
cx.device().document(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn from_computed_value(_: &Self::ComputedValue) -> Self {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
impl SystemColor {
|
||||
pub fn from_ident<'i, 't>(ident: &str) -> Result<Self, ()> {
|
||||
ascii_case_insensitive_phf_map! {
|
||||
color_name -> SystemColor = {
|
||||
% for color in system_colors:
|
||||
"${color}" => LookAndFeel_ColorID::eColorID_${to_rust_ident(color)},
|
||||
% endfor
|
||||
}
|
||||
}
|
||||
|
||||
color_name(ident).cloned().ok_or(())
|
||||
}
|
||||
}
|
||||
}
|
||||
% endif
|
|
@ -47,6 +47,8 @@ ${helpers.predefined_type(
|
|||
"Filter",
|
||||
None,
|
||||
vector=True,
|
||||
simple_vector_bindings=True,
|
||||
gecko_ffi_name="mFilters",
|
||||
separator="Space",
|
||||
animation_value_type="AnimatedFilterList",
|
||||
vector_animation_type="with_zero",
|
||||
|
|
|
@ -6,6 +6,16 @@
|
|||
<% from data import Keyword %>
|
||||
<% data.new_style_struct("InheritedText", inherited=True, gecko_name="Text") %>
|
||||
|
||||
${helpers.predefined_type(
|
||||
"color",
|
||||
"ColorPropertyValue",
|
||||
"::cssparser::RGBA::new(0, 0, 0, 255)",
|
||||
animation_value_type="AnimatedRGBA",
|
||||
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
|
||||
ignored_when_colors_disabled="True",
|
||||
spec="https://drafts.csswg.org/css-color/#color",
|
||||
)}
|
||||
|
||||
${helpers.predefined_type(
|
||||
"line-height",
|
||||
"LineHeight",
|
||||
|
|
|
@ -2832,7 +2832,7 @@ impl ComputedValues {
|
|||
/// style.resolve_color(style.get_border().clone_border_top_color());
|
||||
#[inline]
|
||||
pub fn resolve_color(&self, color: computed::Color) -> RGBA {
|
||||
color.to_rgba(self.get_color().clone_color())
|
||||
color.to_rgba(self.get_inherited_text().clone_color())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue