mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #17544 - dadaa:bug1371115, r=<try>
Support discrete animations for more Gecko things <!-- Please describe your changes on the following line: --> This PR fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1371115 --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors <!-- Either: --> - [X] There are tests for these changes. Add some tests into dom/animation/test/ of m-c in patch 14. Also, remove test fail annotation from meta in wpt as patch 15. <!-- 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/17544) <!-- Reviewable:end -->
This commit is contained in:
commit
42e551f606
19 changed files with 2798 additions and 2522 deletions
|
@ -14,12 +14,15 @@ use gecko_bindings::bindings::{Gecko_CreateGradient, Gecko_SetGradientImageValue
|
||||||
use gecko_bindings::bindings::{Gecko_InitializeImageCropRect, Gecko_SetImageElement};
|
use gecko_bindings::bindings::{Gecko_InitializeImageCropRect, Gecko_SetImageElement};
|
||||||
use gecko_bindings::structs::{nsCSSUnit, nsStyleCoord_CalcValue, nsStyleImage};
|
use gecko_bindings::structs::{nsCSSUnit, nsStyleCoord_CalcValue, nsStyleImage};
|
||||||
use gecko_bindings::structs::{nsresult, SheetType};
|
use gecko_bindings::structs::{nsresult, SheetType};
|
||||||
use gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordDataMut};
|
use gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordData, CoordDataMut};
|
||||||
use stylesheets::{Origin, RulesMutateError};
|
use stylesheets::{Origin, RulesMutateError};
|
||||||
use values::computed::{Angle, CalcLengthOrPercentage, Gradient, Image};
|
use values::computed::{Angle, CalcLengthOrPercentage, Gradient, Image};
|
||||||
use values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
|
use values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||||
|
use values::generics::grid::TrackSize;
|
||||||
use values::generics::image::{CompatMode, Image as GenericImage, GradientItem};
|
use values::generics::image::{CompatMode, Image as GenericImage, GradientItem};
|
||||||
|
use values::generics::rect::Rect;
|
||||||
use values::specified::length::Percentage;
|
use values::specified::length::Percentage;
|
||||||
|
use values::specified::url::SpecifiedUrl;
|
||||||
|
|
||||||
impl From<CalcLengthOrPercentage> for nsStyleCoord_CalcValue {
|
impl From<CalcLengthOrPercentage> for nsStyleCoord_CalcValue {
|
||||||
fn from(other: CalcLengthOrPercentage) -> nsStyleCoord_CalcValue {
|
fn from(other: CalcLengthOrPercentage) -> nsStyleCoord_CalcValue {
|
||||||
|
@ -362,6 +365,212 @@ impl nsStyleImage {
|
||||||
Gecko_SetGradientImageValue(self, gecko_gradient);
|
Gecko_SetGradientImageValue(self, gecko_gradient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Converts into Image.
|
||||||
|
pub unsafe fn into_image(self: &nsStyleImage) -> Option<Image> {
|
||||||
|
use gecko_bindings::bindings::Gecko_GetImageElement;
|
||||||
|
use gecko_bindings::structs::nsStyleImageType;
|
||||||
|
use values::computed::{NumberOrPercentage, ImageRect};
|
||||||
|
|
||||||
|
match self.mType {
|
||||||
|
nsStyleImageType::eStyleImageType_Null => {
|
||||||
|
None
|
||||||
|
},
|
||||||
|
nsStyleImageType::eStyleImageType_Image => {
|
||||||
|
let url = self.get_image_url();
|
||||||
|
if self.mCropRect.mPtr.is_null() {
|
||||||
|
Some(GenericImage::Url(url))
|
||||||
|
} else {
|
||||||
|
let ref rect = *self.mCropRect.mPtr;
|
||||||
|
match (NumberOrPercentage::from_gecko_style_coord(&rect.data_at(0)),
|
||||||
|
NumberOrPercentage::from_gecko_style_coord(&rect.data_at(1)),
|
||||||
|
NumberOrPercentage::from_gecko_style_coord(&rect.data_at(2)),
|
||||||
|
NumberOrPercentage::from_gecko_style_coord(&rect.data_at(3))) {
|
||||||
|
(Some(top), Some(right), Some(bottom), Some(left)) =>
|
||||||
|
Some(GenericImage::Rect(ImageRect { url, top, right, bottom, left } )),
|
||||||
|
_ => {
|
||||||
|
debug_assert!(false, "mCropRect could not convert to NumberOrPercentage");
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
nsStyleImageType::eStyleImageType_Gradient => {
|
||||||
|
Some(GenericImage::Gradient(self.get_gradient()))
|
||||||
|
},
|
||||||
|
nsStyleImageType::eStyleImageType_Element => {
|
||||||
|
use gecko_string_cache::Atom;
|
||||||
|
let atom = Gecko_GetImageElement(self);
|
||||||
|
Some(GenericImage::Element(Atom::from(atom)))
|
||||||
|
},
|
||||||
|
x => panic!("Unexpected image type {:?}", x)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn get_image_url(self: &nsStyleImage) -> SpecifiedUrl {
|
||||||
|
use gecko_bindings::bindings::Gecko_GetURLValue;
|
||||||
|
let url_value = Gecko_GetURLValue(self);
|
||||||
|
let mut url = SpecifiedUrl::from_url_value_data(url_value.as_ref().unwrap())
|
||||||
|
.expect("Could not convert to SpecifiedUrl");
|
||||||
|
url.build_image_value();
|
||||||
|
url
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn get_gradient(self: &nsStyleImage) -> Gradient {
|
||||||
|
use gecko::values::convert_nscolor_to_rgba;
|
||||||
|
use gecko_bindings::bindings::Gecko_GetGradientImageValue;
|
||||||
|
use gecko_bindings::structs::{NS_STYLE_GRADIENT_SHAPE_CIRCULAR, NS_STYLE_GRADIENT_SHAPE_ELLIPTICAL};
|
||||||
|
use gecko_bindings::structs::{NS_STYLE_GRADIENT_SHAPE_LINEAR, NS_STYLE_GRADIENT_SIZE_CLOSEST_CORNER};
|
||||||
|
use gecko_bindings::structs::{NS_STYLE_GRADIENT_SIZE_CLOSEST_SIDE, NS_STYLE_GRADIENT_SIZE_EXPLICIT_SIZE};
|
||||||
|
use gecko_bindings::structs::{NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER, NS_STYLE_GRADIENT_SIZE_FARTHEST_SIDE};
|
||||||
|
use values::computed::{Length, LengthOrPercentage};
|
||||||
|
use values::computed::image::LineDirection;
|
||||||
|
use values::computed::position::Position;
|
||||||
|
use values::generics::image::{ColorStop, CompatMode, Circle, Ellipse, EndingShape, GradientKind, ShapeExtent};
|
||||||
|
use values::specified::position::{X, Y};
|
||||||
|
|
||||||
|
let gecko_gradient = Gecko_GetGradientImageValue(self).as_ref().unwrap();
|
||||||
|
let angle = Angle::from_gecko_style_coord(&gecko_gradient.mAngle);
|
||||||
|
let horizontal_style = LengthOrPercentage::from_gecko_style_coord(&gecko_gradient.mBgPosX);
|
||||||
|
let vertical_style = LengthOrPercentage::from_gecko_style_coord(&gecko_gradient.mBgPosY);
|
||||||
|
|
||||||
|
let kind = match gecko_gradient.mShape as u32 {
|
||||||
|
NS_STYLE_GRADIENT_SHAPE_LINEAR => {
|
||||||
|
let line_direction = match (angle, horizontal_style, vertical_style) {
|
||||||
|
(Some(a), None, None) => LineDirection::Angle(a),
|
||||||
|
(None, Some(horizontal), Some(vertical)) => {
|
||||||
|
let horizontal_as_corner = match horizontal {
|
||||||
|
LengthOrPercentage::Percentage(percentage) => {
|
||||||
|
if percentage.0 == 0.0 {
|
||||||
|
Some(X::Left)
|
||||||
|
} else if percentage.0 == 1.0 {
|
||||||
|
Some(X::Right)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_ => None
|
||||||
|
};
|
||||||
|
let vertical_as_corner = match vertical {
|
||||||
|
LengthOrPercentage::Percentage(percentage) => {
|
||||||
|
if percentage.0 == 0.0 {
|
||||||
|
Some(Y::Top)
|
||||||
|
} else if percentage.0 == 1.0 {
|
||||||
|
Some(Y::Bottom)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_ => None
|
||||||
|
};
|
||||||
|
|
||||||
|
match (horizontal_as_corner, vertical_as_corner) {
|
||||||
|
(Some(hc), Some(vc)) => LineDirection::Corner(hc, vc),
|
||||||
|
_ => LineDirection::MozPosition(
|
||||||
|
Some(Position { horizontal, vertical }), None)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
(Some(_), Some(horizontal), Some(vertical)) =>
|
||||||
|
LineDirection::MozPosition(
|
||||||
|
Some(Position { horizontal, vertical }), angle),
|
||||||
|
_ => {
|
||||||
|
debug_assert!(horizontal_style.is_none() && vertical_style.is_none(),
|
||||||
|
"Unexpected linear gradient direction");
|
||||||
|
LineDirection::MozPosition(None, None)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
GradientKind::Linear(line_direction)
|
||||||
|
},
|
||||||
|
_ => {
|
||||||
|
let gecko_size_to_keyword = |gecko_size| {
|
||||||
|
match gecko_size {
|
||||||
|
NS_STYLE_GRADIENT_SIZE_CLOSEST_SIDE => ShapeExtent::ClosestSide,
|
||||||
|
NS_STYLE_GRADIENT_SIZE_FARTHEST_SIDE => ShapeExtent::FarthestSide,
|
||||||
|
NS_STYLE_GRADIENT_SIZE_CLOSEST_CORNER => ShapeExtent::ClosestCorner,
|
||||||
|
NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER => ShapeExtent::FarthestCorner,
|
||||||
|
// FIXME: We should support ShapeExtent::Contain and ShapeExtent::Cover.
|
||||||
|
// But we can't choose those yet since Gecko does not support both values.
|
||||||
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1217664
|
||||||
|
x => panic!("Found unexpected gecko_size: {:?}", x),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let shape = match gecko_gradient.mShape as u32 {
|
||||||
|
NS_STYLE_GRADIENT_SHAPE_CIRCULAR => {
|
||||||
|
let circle = match gecko_gradient.mSize as u32 {
|
||||||
|
NS_STYLE_GRADIENT_SIZE_EXPLICIT_SIZE => {
|
||||||
|
let radius = Length::from_gecko_style_coord(&gecko_gradient.mRadiusX)
|
||||||
|
.expect("mRadiusX could not convert to Length");
|
||||||
|
debug_assert_eq!(radius,
|
||||||
|
Length::from_gecko_style_coord(&gecko_gradient.mRadiusY).unwrap());
|
||||||
|
Circle::Radius(radius)
|
||||||
|
},
|
||||||
|
size => Circle::Extent(gecko_size_to_keyword(size))
|
||||||
|
};
|
||||||
|
EndingShape::Circle(circle)
|
||||||
|
},
|
||||||
|
NS_STYLE_GRADIENT_SHAPE_ELLIPTICAL => {
|
||||||
|
let length_percentage_keyword = match gecko_gradient.mSize as u32 {
|
||||||
|
NS_STYLE_GRADIENT_SIZE_EXPLICIT_SIZE => {
|
||||||
|
match (LengthOrPercentage::from_gecko_style_coord(&gecko_gradient.mRadiusX),
|
||||||
|
LengthOrPercentage::from_gecko_style_coord(&gecko_gradient.mRadiusY)) {
|
||||||
|
(Some(x), Some(y)) => Ellipse::Radii(x, y),
|
||||||
|
_ => {
|
||||||
|
debug_assert!(false,
|
||||||
|
"mRadiusX, mRadiusY could not convert to LengthOrPercentage");
|
||||||
|
Ellipse::Radii(LengthOrPercentage::zero(),
|
||||||
|
LengthOrPercentage::zero())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
size => Ellipse::Extent(gecko_size_to_keyword(size))
|
||||||
|
};
|
||||||
|
EndingShape::Ellipse(length_percentage_keyword)
|
||||||
|
},
|
||||||
|
x => panic!("Found unexpected mShape: {:?}", x),
|
||||||
|
};
|
||||||
|
|
||||||
|
let position = match (horizontal_style, vertical_style) {
|
||||||
|
(Some(horizontal), Some(vertical)) => Position { horizontal, vertical },
|
||||||
|
_ => {
|
||||||
|
debug_assert!(false,
|
||||||
|
"mRadiusX, mRadiusY could not convert to LengthOrPercentage");
|
||||||
|
Position {
|
||||||
|
horizontal: LengthOrPercentage::zero(),
|
||||||
|
vertical: LengthOrPercentage::zero()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GradientKind::Radial(shape, position, angle)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let items = gecko_gradient.mStops.iter().map(|ref stop| {
|
||||||
|
if stop.mIsInterpolationHint {
|
||||||
|
GradientItem::InterpolationHint(
|
||||||
|
LengthOrPercentage::from_gecko_style_coord(&stop.mLocation)
|
||||||
|
.expect("mLocation could not convert to LengthOrPercentage")
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
GradientItem::ColorStop(ColorStop {
|
||||||
|
color: convert_nscolor_to_rgba(stop.mColor),
|
||||||
|
position: LengthOrPercentage::from_gecko_style_coord(&stop.mLocation)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}).collect();
|
||||||
|
|
||||||
|
let compat_mode =
|
||||||
|
if gecko_gradient.mMozLegacySyntax {
|
||||||
|
CompatMode::Moz
|
||||||
|
} else if gecko_gradient.mLegacySyntax {
|
||||||
|
CompatMode::WebKit
|
||||||
|
} else {
|
||||||
|
CompatMode::Modern
|
||||||
|
};
|
||||||
|
|
||||||
|
Gradient { items, repeating: gecko_gradient.mRepeating, kind, compat_mode }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod basic_shape {
|
pub mod basic_shape {
|
||||||
|
@ -584,3 +793,78 @@ impl From<Origin> for SheetType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl TrackSize<LengthOrPercentage> {
|
||||||
|
/// Return TrackSize from given two nsStyleCoord
|
||||||
|
pub fn from_gecko_style_coords<T: CoordData>(gecko_min: &T, gecko_max: &T) -> Self {
|
||||||
|
use gecko_bindings::structs::root::nsStyleUnit;
|
||||||
|
use values::computed::length::LengthOrPercentage;
|
||||||
|
use values::generics::grid::{TrackBreadth, TrackSize};
|
||||||
|
|
||||||
|
if gecko_min.unit() == nsStyleUnit::eStyleUnit_None {
|
||||||
|
debug_assert!(gecko_max.unit() == nsStyleUnit::eStyleUnit_Coord ||
|
||||||
|
gecko_max.unit() == nsStyleUnit::eStyleUnit_Percent);
|
||||||
|
return TrackSize::FitContent(LengthOrPercentage::from_gecko_style_coord(gecko_max)
|
||||||
|
.expect("gecko_max could not convert to LengthOrPercentage"));
|
||||||
|
}
|
||||||
|
|
||||||
|
let min = TrackBreadth::from_gecko_style_coord(gecko_min)
|
||||||
|
.expect("gecko_min could not convert to TrackBreadth");
|
||||||
|
let max = TrackBreadth::from_gecko_style_coord(gecko_max)
|
||||||
|
.expect("gecko_max could not convert to TrackBreadth");
|
||||||
|
if min == max {
|
||||||
|
TrackSize::Breadth(max)
|
||||||
|
} else {
|
||||||
|
TrackSize::MinMax(min, max)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Save TrackSize to given gecko fields.
|
||||||
|
pub fn to_gecko_style_coords<T: CoordDataMut>(&self, gecko_min: &mut T, gecko_max: &mut T) {
|
||||||
|
use values::generics::grid::TrackSize;
|
||||||
|
|
||||||
|
match *self {
|
||||||
|
TrackSize::FitContent(ref lop) => {
|
||||||
|
// Gecko sets min value to None and max value to the actual value in fit-content
|
||||||
|
// https://dxr.mozilla.org/mozilla-central/rev/0eef1d5/layout/style/nsRuleNode.cpp#8221
|
||||||
|
gecko_min.set_value(CoordDataValue::None);
|
||||||
|
lop.to_gecko_style_coord(gecko_max);
|
||||||
|
},
|
||||||
|
TrackSize::Breadth(ref breadth) => {
|
||||||
|
// Set the value to both fields if there's one breadth value
|
||||||
|
// https://dxr.mozilla.org/mozilla-central/rev/0eef1d5/layout/style/nsRuleNode.cpp#8230
|
||||||
|
breadth.to_gecko_style_coord(gecko_min);
|
||||||
|
breadth.to_gecko_style_coord(gecko_max);
|
||||||
|
},
|
||||||
|
TrackSize::MinMax(ref min, ref max) => {
|
||||||
|
min.to_gecko_style_coord(gecko_min);
|
||||||
|
max.to_gecko_style_coord(gecko_max);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Rect<T> where T: GeckoStyleCoordConvertible {
|
||||||
|
/// Convert this generic Rect to given Gecko fields.
|
||||||
|
pub fn to_gecko_rect(&self, sides: &mut ::gecko_bindings::structs::nsStyleSides) {
|
||||||
|
self.0.to_gecko_style_coord(&mut sides.data_at_mut(0));
|
||||||
|
self.1.to_gecko_style_coord(&mut sides.data_at_mut(1));
|
||||||
|
self.2.to_gecko_style_coord(&mut sides.data_at_mut(2));
|
||||||
|
self.3.to_gecko_style_coord(&mut sides.data_at_mut(3));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Convert from given Gecko data to generic Rect.
|
||||||
|
pub fn from_gecko_rect(sides: &::gecko_bindings::structs::nsStyleSides)
|
||||||
|
-> Option<::values::generics::rect::Rect<T>> {
|
||||||
|
use values::generics::rect::Rect;
|
||||||
|
|
||||||
|
Some(
|
||||||
|
Rect::new(
|
||||||
|
T::from_gecko_style_coord(&sides.data_at(0)).expect("coord[0] cound not convert"),
|
||||||
|
T::from_gecko_style_coord(&sides.data_at(1)).expect("coord[1] cound not convert"),
|
||||||
|
T::from_gecko_style_coord(&sides.data_at(2)).expect("coord[2] cound not convert"),
|
||||||
|
T::from_gecko_style_coord(&sides.data_at(3)).expect("coord[3] cound not convert")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ type nsAString_internal = nsAString;
|
||||||
use gecko_bindings::structs::mozilla::css::GridTemplateAreasValue;
|
use gecko_bindings::structs::mozilla::css::GridTemplateAreasValue;
|
||||||
use gecko_bindings::structs::mozilla::css::ImageValue;
|
use gecko_bindings::structs::mozilla::css::ImageValue;
|
||||||
use gecko_bindings::structs::mozilla::css::URLValue;
|
use gecko_bindings::structs::mozilla::css::URLValue;
|
||||||
|
use gecko_bindings::structs::mozilla::css::URLValueData;
|
||||||
use gecko_bindings::structs::mozilla::MallocSizeOf;
|
use gecko_bindings::structs::mozilla::MallocSizeOf;
|
||||||
use gecko_bindings::structs::mozilla::Side;
|
use gecko_bindings::structs::mozilla::Side;
|
||||||
use gecko_bindings::structs::nsIContent;
|
use gecko_bindings::structs::nsIContent;
|
||||||
|
@ -56,6 +57,7 @@ use gecko_bindings::structs::StyleBasicShape;
|
||||||
use gecko_bindings::structs::StyleBasicShapeType;
|
use gecko_bindings::structs::StyleBasicShapeType;
|
||||||
use gecko_bindings::structs::StyleShapeSource;
|
use gecko_bindings::structs::StyleShapeSource;
|
||||||
use gecko_bindings::structs::StyleTransition;
|
use gecko_bindings::structs::StyleTransition;
|
||||||
|
use gecko_bindings::structs::nsBorderColors;
|
||||||
use gecko_bindings::structs::nsCSSCounterStyleRule;
|
use gecko_bindings::structs::nsCSSCounterStyleRule;
|
||||||
use gecko_bindings::structs::nsCSSFontFaceRule;
|
use gecko_bindings::structs::nsCSSFontFaceRule;
|
||||||
use gecko_bindings::structs::nsCSSKeyword;
|
use gecko_bindings::structs::nsCSSKeyword;
|
||||||
|
@ -853,6 +855,10 @@ extern "C" {
|
||||||
pub fn Gecko_CopyMozBorderColors(aDest: *mut nsStyleBorder,
|
pub fn Gecko_CopyMozBorderColors(aDest: *mut nsStyleBorder,
|
||||||
aSrc: *const nsStyleBorder, aSide: Side);
|
aSrc: *const nsStyleBorder, aSide: Side);
|
||||||
}
|
}
|
||||||
|
extern "C" {
|
||||||
|
pub fn Gecko_GetMozBorderColors(aBorder: *const nsStyleBorder,
|
||||||
|
aSide: Side) -> *const nsBorderColors;
|
||||||
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_FontFamilyList_Clear(aList: *mut FontFamilyList);
|
pub fn Gecko_FontFamilyList_Clear(aList: *mut FontFamilyList);
|
||||||
}
|
}
|
||||||
|
@ -955,6 +961,17 @@ extern "C" {
|
||||||
legacy_syntax: bool, moz_legacy_syntax: bool,
|
legacy_syntax: bool, moz_legacy_syntax: bool,
|
||||||
stops: u32) -> *mut nsStyleGradient;
|
stops: u32) -> *mut nsStyleGradient;
|
||||||
}
|
}
|
||||||
|
extern "C" {
|
||||||
|
pub fn Gecko_GetURLValue(image: *const nsStyleImage)
|
||||||
|
-> *const URLValueData;
|
||||||
|
}
|
||||||
|
extern "C" {
|
||||||
|
pub fn Gecko_GetImageElement(image: *const nsStyleImage) -> *mut nsIAtom;
|
||||||
|
}
|
||||||
|
extern "C" {
|
||||||
|
pub fn Gecko_GetGradientImageValue(image: *const nsStyleImage)
|
||||||
|
-> *const nsStyleGradient;
|
||||||
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_SetListStyleImageNone(style_struct: *mut nsStyleList);
|
pub fn Gecko_SetListStyleImageNone(style_struct: *mut nsStyleList);
|
||||||
}
|
}
|
||||||
|
@ -2144,16 +2161,6 @@ extern "C" {
|
||||||
pub fn Servo_StyleRule_GetSelectorCount(rule: RawServoStyleRuleBorrowed,
|
pub fn Servo_StyleRule_GetSelectorCount(rule: RawServoStyleRuleBorrowed,
|
||||||
count: *mut u32);
|
count: *mut u32);
|
||||||
}
|
}
|
||||||
extern "C" {
|
|
||||||
pub fn Servo_StyleRule_SelectorMatchesElement(arg1:
|
|
||||||
RawServoStyleRuleBorrowed,
|
|
||||||
arg2:
|
|
||||||
RawGeckoElementBorrowed,
|
|
||||||
index: u32,
|
|
||||||
pseudo_type:
|
|
||||||
CSSPseudoElementType)
|
|
||||||
-> bool;
|
|
||||||
}
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_ImportRule_GetHref(rule: RawServoImportRuleBorrowed,
|
pub fn Servo_ImportRule_GetHref(rule: RawServoImportRuleBorrowed,
|
||||||
result: *mut nsAString);
|
result: *mut nsAString);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -7,6 +7,7 @@
|
||||||
use gecko_bindings::structs::{ServoBundledURI, URLExtraData};
|
use gecko_bindings::structs::{ServoBundledURI, URLExtraData};
|
||||||
use gecko_bindings::structs::mozilla::css::URLValueData;
|
use gecko_bindings::structs::mozilla::css::URLValueData;
|
||||||
use gecko_bindings::structs::root::mozilla::css::ImageValue;
|
use gecko_bindings::structs::root::mozilla::css::ImageValue;
|
||||||
|
use gecko_bindings::structs::root::nsStyleImageRequest;
|
||||||
use gecko_bindings::sugar::refptr::RefPtr;
|
use gecko_bindings::sugar::refptr::RefPtr;
|
||||||
use parser::ParserContext;
|
use parser::ParserContext;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
@ -62,6 +63,19 @@ impl SpecifiedUrl {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Convert from nsStyleImageRequest to SpecifiedUrl.
|
||||||
|
pub unsafe fn from_image_request(image_request: &nsStyleImageRequest) -> Result<SpecifiedUrl, ()> {
|
||||||
|
if image_request.mImageValue.mRawPtr.is_null() {
|
||||||
|
return Err(());
|
||||||
|
}
|
||||||
|
|
||||||
|
let image_value = image_request.mImageValue.mRawPtr.as_ref().unwrap();
|
||||||
|
let ref url_value_data = image_value._base;
|
||||||
|
let mut result = try!(Self::from_url_value_data(url_value_data));
|
||||||
|
result.build_image_value();
|
||||||
|
Ok(result)
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns true if this URL looks like a fragment.
|
/// Returns true if this URL looks like a fragment.
|
||||||
/// See https://drafts.csswg.org/css-values/#local-urls
|
/// See https://drafts.csswg.org/css-values/#local-urls
|
||||||
pub fn is_fragment(&self) -> bool {
|
pub fn is_fragment(&self) -> bool {
|
||||||
|
|
|
@ -22,6 +22,7 @@ use values::computed::{MaxLength, MozLength};
|
||||||
use values::computed::basic_shape::ShapeRadius as ComputedShapeRadius;
|
use values::computed::basic_shape::ShapeRadius as ComputedShapeRadius;
|
||||||
use values::generics::CounterStyleOrNone;
|
use values::generics::CounterStyleOrNone;
|
||||||
use values::generics::basic_shape::ShapeRadius;
|
use values::generics::basic_shape::ShapeRadius;
|
||||||
|
use values::generics::gecko::ScrollSnapPoint;
|
||||||
use values::generics::grid::{TrackBreadth, TrackKeyword};
|
use values::generics::grid::{TrackBreadth, TrackKeyword};
|
||||||
use values::specified::Percentage;
|
use values::specified::Percentage;
|
||||||
|
|
||||||
|
@ -368,6 +369,30 @@ impl GeckoStyleCoordConvertible for MaxLength {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl GeckoStyleCoordConvertible for ScrollSnapPoint<LengthOrPercentage> {
|
||||||
|
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
|
||||||
|
match self.repeated() {
|
||||||
|
None => coord.set_value(CoordDataValue::None),
|
||||||
|
Some(l) => l.to_gecko_style_coord(coord),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
|
||||||
|
use gecko_bindings::structs::root::nsStyleUnit;
|
||||||
|
use values::generics::gecko::ScrollSnapPoint;
|
||||||
|
|
||||||
|
Some(
|
||||||
|
match coord.unit() {
|
||||||
|
nsStyleUnit::eStyleUnit_None => ScrollSnapPoint::None,
|
||||||
|
nsStyleUnit::eStyleUnit_Coord | nsStyleUnit::eStyleUnit_Percent =>
|
||||||
|
ScrollSnapPoint::Repeat(LengthOrPercentage::from_gecko_style_coord(coord)
|
||||||
|
.expect("coord could not convert to LengthOrPercentage")),
|
||||||
|
x => panic!("Unexpected unit {:?}", x)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Convert a given RGBA value to `nscolor`.
|
/// Convert a given RGBA value to `nscolor`.
|
||||||
pub fn convert_rgba_to_nscolor(rgba: &RGBA) -> u32 {
|
pub fn convert_rgba_to_nscolor(rgba: &RGBA) -> u32 {
|
||||||
((rgba.alpha as u32) << 24) |
|
((rgba.alpha as u32) << 24) |
|
||||||
|
|
|
@ -581,6 +581,35 @@ def set_gecko_property(ffi_name, expr):
|
||||||
% endif
|
% endif
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
|
<%def name="impl_style_sides(ident)">
|
||||||
|
<% gecko_ffi_name = "m" + to_camel_case(ident) %>
|
||||||
|
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
|
||||||
|
v.to_gecko_rect(&mut self.gecko.${gecko_ffi_name});
|
||||||
|
}
|
||||||
|
|
||||||
|
<%self:copy_sides_style_coord ident="${ident}"></%self:copy_sides_style_coord>
|
||||||
|
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
|
||||||
|
longhands::${ident}::computed_value::T::from_gecko_rect(&self.gecko.${gecko_ffi_name})
|
||||||
|
.expect("clone for ${ident} failed")
|
||||||
|
}
|
||||||
|
</%def>
|
||||||
|
|
||||||
|
<%def name="copy_sides_style_coord(ident)">
|
||||||
|
<% gecko_ffi_name = "m" + to_camel_case(ident) %>
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
pub fn copy_${ident}_from(&mut self, other: &Self) {
|
||||||
|
% for side in SIDES:
|
||||||
|
self.gecko.${gecko_ffi_name}.data_at_mut(${side.index})
|
||||||
|
.copy_from(&other.gecko.${gecko_ffi_name}.data_at(${side.index}));
|
||||||
|
% endfor
|
||||||
|
${ caller.body() }
|
||||||
|
}
|
||||||
|
</%def>
|
||||||
|
|
||||||
<%def name="impl_corner_style_coord(ident, gecko_ffi_name, x_index, y_index, need_clone)">
|
<%def name="impl_corner_style_coord(ident, gecko_ffi_name, x_index, y_index, need_clone)">
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
|
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
|
||||||
|
@ -639,7 +668,20 @@ def set_gecko_property(ffi_name, expr):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
% if need_clone:
|
% if need_clone:
|
||||||
<% raise Exception("Do not know how to handle clone ") %>
|
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
|
||||||
|
use values::specified::url::SpecifiedUrl;
|
||||||
|
use values::None_;
|
||||||
|
|
||||||
|
if self.gecko.${gecko_ffi_name}.mRawPtr.is_null() {
|
||||||
|
Either::Second(None_)
|
||||||
|
} else {
|
||||||
|
unsafe {
|
||||||
|
let ref gecko_url_value = *self.gecko.${gecko_ffi_name}.mRawPtr;
|
||||||
|
Either::First(SpecifiedUrl::from_url_value_data(&gecko_url_value._base)
|
||||||
|
.expect("${gecko_ffi_name} could not convert to SpecifiedUrl"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
% endif
|
% endif
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
|
@ -991,6 +1033,30 @@ fn static_assert() {
|
||||||
structs::Side::eSide${to_camel_case(side.ident)});
|
structs::Side::eSide${to_camel_case(side.ident)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
pub fn clone__moz_border_${side.ident}_colors(&self)
|
||||||
|
-> longhands::_moz_border_${side.ident}_colors::computed_value::T {
|
||||||
|
use self::longhands::_moz_border_${side.ident}_colors::computed_value::T;
|
||||||
|
|
||||||
|
let mut gecko_colors =
|
||||||
|
unsafe { bindings::Gecko_GetMozBorderColors(&self.gecko,
|
||||||
|
structs::Side::eSide${to_camel_case(side.ident)}) };
|
||||||
|
|
||||||
|
if gecko_colors.is_null() {
|
||||||
|
return T(None);
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut colors = Vec::new();
|
||||||
|
loop {
|
||||||
|
unsafe {
|
||||||
|
colors.push(convert_nscolor_to_rgba((*gecko_colors).mColor));
|
||||||
|
if (*gecko_colors).mNext.is_null() { break; }
|
||||||
|
gecko_colors = (*gecko_colors).mNext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
T(Some(colors))
|
||||||
|
}
|
||||||
% endfor
|
% endfor
|
||||||
|
|
||||||
% for corner in CORNERS:
|
% for corner in CORNERS:
|
||||||
|
@ -1019,18 +1085,16 @@ fn static_assert() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_border_image_outset(&mut self, v: longhands::border_image_outset::computed_value::T) {
|
pub fn clone_border_image_source(&self) -> longhands::border_image_source::computed_value::T {
|
||||||
% for side in SIDES:
|
use values::None_;
|
||||||
v.${side.index}.to_gecko_style_coord(&mut self.gecko.mBorderImageOutset.data_at_mut(${side.index}));
|
|
||||||
% endfor
|
match unsafe { self.gecko.mBorderImageSource.into_image() } {
|
||||||
|
Some(image) => Either::Second(image),
|
||||||
|
None => Either::First(None_),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn copy_border_image_outset_from(&mut self, other: &Self) {
|
<% impl_style_sides("border_image_outset") %>
|
||||||
% for side in SIDES:
|
|
||||||
self.gecko.mBorderImageOutset.data_at_mut(${side.index})
|
|
||||||
.copy_from(&other.gecko.mBorderImageOutset.data_at(${side.index}));
|
|
||||||
% endfor
|
|
||||||
}
|
|
||||||
|
|
||||||
<%
|
<%
|
||||||
border_image_repeat_keywords = ["Stretch", "Repeat", "Round", "Space"]
|
border_image_repeat_keywords = ["Stretch", "Repeat", "Round", "Space"]
|
||||||
|
@ -1071,37 +1135,12 @@ fn static_assert() {
|
||||||
longhands::border_image_repeat::computed_value::T(servo_h, servo_v)
|
longhands::border_image_repeat::computed_value::T(servo_h, servo_v)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_border_image_width(&mut self, v: longhands::border_image_width::computed_value::T) {
|
<% impl_style_sides("border_image_width") %>
|
||||||
use values::generics::border::BorderImageSideWidth;
|
|
||||||
|
|
||||||
% for side in SIDES:
|
|
||||||
match v.${side.index} {
|
|
||||||
BorderImageSideWidth::Auto => {
|
|
||||||
self.gecko.mBorderImageWidth.data_at_mut(${side.index}).set_value(CoordDataValue::Auto)
|
|
||||||
},
|
|
||||||
BorderImageSideWidth::Length(l) => {
|
|
||||||
l.to_gecko_style_coord(&mut self.gecko.mBorderImageWidth.data_at_mut(${side.index}))
|
|
||||||
},
|
|
||||||
BorderImageSideWidth::Number(n) => {
|
|
||||||
self.gecko.mBorderImageWidth.data_at_mut(${side.index}).set_value(CoordDataValue::Factor(n))
|
|
||||||
},
|
|
||||||
}
|
|
||||||
% endfor
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn copy_border_image_width_from(&mut self, other: &Self) {
|
|
||||||
% for side in SIDES:
|
|
||||||
self.gecko.mBorderImageWidth.data_at_mut(${side.index})
|
|
||||||
.copy_from(&other.gecko.mBorderImageWidth.data_at(${side.index}));
|
|
||||||
% endfor
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_border_image_slice(&mut self, v: longhands::border_image_slice::computed_value::T) {
|
pub fn set_border_image_slice(&mut self, v: longhands::border_image_slice::computed_value::T) {
|
||||||
use gecko_bindings::structs::{NS_STYLE_BORDER_IMAGE_SLICE_NOFILL, NS_STYLE_BORDER_IMAGE_SLICE_FILL};
|
use gecko_bindings::structs::{NS_STYLE_BORDER_IMAGE_SLICE_NOFILL, NS_STYLE_BORDER_IMAGE_SLICE_FILL};
|
||||||
|
|
||||||
% for side in SIDES:
|
v.offsets.to_gecko_rect(&mut self.gecko.mBorderImageSlice);
|
||||||
v.offsets.${side.index}.to_gecko_style_coord(&mut self.gecko.mBorderImageSlice.data_at_mut(${side.index}));
|
|
||||||
% endfor
|
|
||||||
|
|
||||||
let fill = if v.fill {
|
let fill = if v.fill {
|
||||||
NS_STYLE_BORDER_IMAGE_SLICE_FILL
|
NS_STYLE_BORDER_IMAGE_SLICE_FILL
|
||||||
|
@ -1111,12 +1150,21 @@ fn static_assert() {
|
||||||
self.gecko.mBorderImageFill = fill as u8;
|
self.gecko.mBorderImageFill = fill as u8;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn copy_border_image_slice_from(&mut self, other: &Self) {
|
<%self:copy_sides_style_coord ident="border_image_slice">
|
||||||
for i in 0..4 {
|
|
||||||
self.gecko.mBorderImageSlice.data_at_mut(i)
|
|
||||||
.copy_from(&other.gecko.mBorderImageSlice.data_at(i));
|
|
||||||
}
|
|
||||||
self.gecko.mBorderImageFill = other.gecko.mBorderImageFill;
|
self.gecko.mBorderImageFill = other.gecko.mBorderImageFill;
|
||||||
|
</%self:copy_sides_style_coord>
|
||||||
|
|
||||||
|
pub fn clone_border_image_slice(&self) -> longhands::border_image_slice::computed_value::T {
|
||||||
|
use gecko_bindings::structs::NS_STYLE_BORDER_IMAGE_SLICE_FILL;
|
||||||
|
use values::computed::{BorderImageSlice, NumberOrPercentage};
|
||||||
|
type NumberOrPercentageRect = ::values::generics::rect::Rect<NumberOrPercentage>;
|
||||||
|
|
||||||
|
BorderImageSlice {
|
||||||
|
offsets:
|
||||||
|
NumberOrPercentageRect::from_gecko_rect(&self.gecko.mBorderImageSlice)
|
||||||
|
.expect("mBorderImageSlice[${side.index}] could not convert to NumberOrPercentageRect"),
|
||||||
|
fill: self.gecko.mBorderImageFill as u32 == NS_STYLE_BORDER_IMAGE_SLICE_FILL
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</%self:impl_trait>
|
</%self:impl_trait>
|
||||||
|
|
||||||
|
@ -1219,30 +1267,38 @@ fn static_assert() {
|
||||||
self.gecko.${value.gecko}.mInteger = other.gecko.${value.gecko}.mInteger;
|
self.gecko.${value.gecko}.mInteger = other.gecko.${value.gecko}.mInteger;
|
||||||
self.gecko.${value.gecko}.mLineName.assign(&*other.gecko.${value.gecko}.mLineName);
|
self.gecko.${value.gecko}.mLineName.assign(&*other.gecko.${value.gecko}.mLineName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clone_${value.name}(&self) -> longhands::${value.name}::computed_value::T {
|
||||||
|
use gecko_bindings::structs::{nsStyleGridLine_kMinLine, nsStyleGridLine_kMaxLine};
|
||||||
|
use string_cache::Atom;
|
||||||
|
use values::specified::Integer;
|
||||||
|
|
||||||
|
longhands::${value.name}::computed_value::T {
|
||||||
|
is_span: self.gecko.${value.gecko}.mHasSpan,
|
||||||
|
ident: {
|
||||||
|
let name = self.gecko.${value.gecko}.mLineName.to_string();
|
||||||
|
if name.len() == 0 {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(CustomIdent(Atom::from(name)))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
line_num:
|
||||||
|
if self.gecko.${value.gecko}.mInteger == 0 {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
debug_assert!(nsStyleGridLine_kMinLine <= self.gecko.${value.gecko}.mInteger);
|
||||||
|
debug_assert!(self.gecko.${value.gecko}.mInteger <= nsStyleGridLine_kMaxLine);
|
||||||
|
Some(Integer::new(self.gecko.${value.gecko}.mInteger))
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
% endfor
|
% endfor
|
||||||
|
|
||||||
% for kind in ["rows", "columns"]:
|
% for kind in ["rows", "columns"]:
|
||||||
pub fn set_grid_auto_${kind}(&mut self, v: longhands::grid_auto_${kind}::computed_value::T) {
|
pub fn set_grid_auto_${kind}(&mut self, v: longhands::grid_auto_${kind}::computed_value::T) {
|
||||||
use values::generics::grid::TrackSize;
|
v.to_gecko_style_coords(&mut self.gecko.mGridAuto${kind.title()}Min,
|
||||||
|
&mut self.gecko.mGridAuto${kind.title()}Max)
|
||||||
match v {
|
|
||||||
TrackSize::FitContent(lop) => {
|
|
||||||
// Gecko sets min value to None and max value to the actual value in fit-content
|
|
||||||
// https://dxr.mozilla.org/mozilla-central/rev/0eef1d5/layout/style/nsRuleNode.cpp#8221
|
|
||||||
self.gecko.mGridAuto${kind.title()}Min.set_value(CoordDataValue::None);
|
|
||||||
lop.to_gecko_style_coord(&mut self.gecko.mGridAuto${kind.title()}Max);
|
|
||||||
},
|
|
||||||
TrackSize::Breadth(breadth) => {
|
|
||||||
// Set the value to both fields if there's one breadth value
|
|
||||||
// https://dxr.mozilla.org/mozilla-central/rev/0eef1d5/layout/style/nsRuleNode.cpp#8230
|
|
||||||
breadth.to_gecko_style_coord(&mut self.gecko.mGridAuto${kind.title()}Min);
|
|
||||||
breadth.to_gecko_style_coord(&mut self.gecko.mGridAuto${kind.title()}Max);
|
|
||||||
},
|
|
||||||
TrackSize::MinMax(min, max) => {
|
|
||||||
min.to_gecko_style_coord(&mut self.gecko.mGridAuto${kind.title()}Min);
|
|
||||||
max.to_gecko_style_coord(&mut self.gecko.mGridAuto${kind.title()}Max);
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn copy_grid_auto_${kind}_from(&mut self, other: &Self) {
|
pub fn copy_grid_auto_${kind}_from(&mut self, other: &Self) {
|
||||||
|
@ -1250,15 +1306,19 @@ fn static_assert() {
|
||||||
self.gecko.mGridAuto${kind.title()}Max.copy_from(&other.gecko.mGridAuto${kind.title()}Max);
|
self.gecko.mGridAuto${kind.title()}Max.copy_from(&other.gecko.mGridAuto${kind.title()}Max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clone_grid_auto_${kind}(&self) -> longhands::grid_auto_${kind}::computed_value::T {
|
||||||
|
::values::generics::grid::TrackSize::from_gecko_style_coords(&self.gecko.mGridAuto${kind.title()}Min,
|
||||||
|
&self.gecko.mGridAuto${kind.title()}Max)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_grid_template_${kind}(&mut self, v: longhands::grid_template_${kind}::computed_value::T) {
|
pub fn set_grid_template_${kind}(&mut self, v: longhands::grid_template_${kind}::computed_value::T) {
|
||||||
<% self_grid = "self.gecko.mGridTemplate%s" % kind.title() %>
|
<% self_grid = "self.gecko.mGridTemplate%s" % kind.title() %>
|
||||||
use gecko::values::GeckoStyleCoordConvertible;
|
|
||||||
use gecko_bindings::structs::{nsTArray, nsStyleGridLine_kMaxLine};
|
use gecko_bindings::structs::{nsTArray, nsStyleGridLine_kMaxLine};
|
||||||
use nsstring::nsStringRepr;
|
use nsstring::nsStringRepr;
|
||||||
use std::usize;
|
use std::usize;
|
||||||
use values::CustomIdent;
|
use values::CustomIdent;
|
||||||
use values::generics::grid::TrackListType::Auto;
|
use values::generics::grid::TrackListType::Auto;
|
||||||
use values::generics::grid::{GridTemplateComponent, RepeatCount, TrackSize};
|
use values::generics::grid::{GridTemplateComponent, RepeatCount};
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn set_line_names(servo_names: &[CustomIdent], gecko_names: &mut nsTArray<nsStringRepr>) {
|
fn set_line_names(servo_names: &[CustomIdent], gecko_names: &mut nsTArray<nsStringRepr>) {
|
||||||
|
@ -1271,25 +1331,6 @@ fn static_assert() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_track_size<G, T>(value: TrackSize<T>, gecko_min: &mut G, gecko_max: &mut G)
|
|
||||||
where G: CoordDataMut, T: GeckoStyleCoordConvertible
|
|
||||||
{
|
|
||||||
match value {
|
|
||||||
TrackSize::FitContent(lop) => {
|
|
||||||
gecko_min.set_value(CoordDataValue::None);
|
|
||||||
lop.to_gecko_style_coord(gecko_max);
|
|
||||||
},
|
|
||||||
TrackSize::Breadth(breadth) => {
|
|
||||||
breadth.to_gecko_style_coord(gecko_min);
|
|
||||||
breadth.to_gecko_style_coord(gecko_max);
|
|
||||||
},
|
|
||||||
TrackSize::MinMax(min, max) => {
|
|
||||||
min.to_gecko_style_coord(gecko_min);
|
|
||||||
max.to_gecko_style_coord(gecko_max);
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set defaults
|
// Set defaults
|
||||||
${self_grid}.mRepeatAutoIndex = -1;
|
${self_grid}.mRepeatAutoIndex = -1;
|
||||||
${self_grid}.set_mIsAutoFill(false);
|
${self_grid}.set_mIsAutoFill(false);
|
||||||
|
@ -1343,13 +1384,13 @@ fn static_assert() {
|
||||||
let name_list = line_names.next().expect("expected line-names");
|
let name_list = line_names.next().expect("expected line-names");
|
||||||
set_line_names(&name_list, &mut ${self_grid}.mLineNameLists[i]);
|
set_line_names(&name_list, &mut ${self_grid}.mLineNameLists[i]);
|
||||||
if i == auto_idx {
|
if i == auto_idx {
|
||||||
set_track_size(auto_track_size.take().expect("expected <track-size> for <auto-track-repeat>"),
|
let track_size = auto_track_size.take().expect("expected <track-size> for <auto-track-repeat>");
|
||||||
gecko_min, gecko_max);
|
track_size.to_gecko_style_coords(gecko_min, gecko_max);
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
let track_size = values_iter.next().expect("expected <track-size> value");
|
let track_size = values_iter.next().expect("expected <track-size> value");
|
||||||
set_track_size(track_size, gecko_min, gecko_max);
|
track_size.to_gecko_style_coords(gecko_min, gecko_max);
|
||||||
}
|
}
|
||||||
|
|
||||||
let final_names = line_names.next().unwrap();
|
let final_names = line_names.next().unwrap();
|
||||||
|
@ -1544,6 +1585,23 @@ fn static_assert() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clone_font_feature_settings(&self) -> longhands::font_feature_settings::computed_value::T {
|
||||||
|
use values::generics::{FontSettings, FontSettingTag, FontSettingTagInt} ;
|
||||||
|
|
||||||
|
if self.gecko.mFont.fontFeatureSettings.len() == 0 {
|
||||||
|
FontSettings::Normal
|
||||||
|
} else {
|
||||||
|
FontSettings::Tag(
|
||||||
|
self.gecko.mFont.fontFeatureSettings.iter().map(|gecko_font_feature_setting| {
|
||||||
|
FontSettingTag {
|
||||||
|
tag: gecko_font_feature_setting.mTag,
|
||||||
|
value: FontSettingTagInt(gecko_font_feature_setting.mValue),
|
||||||
|
}
|
||||||
|
}).collect()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_font_variation_settings(&mut self, v: longhands::font_variation_settings::computed_value::T) {
|
pub fn set_font_variation_settings(&mut self, v: longhands::font_variation_settings::computed_value::T) {
|
||||||
use values::generics::FontSettings;
|
use values::generics::FontSettings;
|
||||||
|
|
||||||
|
@ -1621,6 +1679,34 @@ fn static_assert() {
|
||||||
self.gecko.mGenericID = other.gecko.mGenericID;
|
self.gecko.mGenericID = other.gecko.mGenericID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clone_font_family(&self) -> longhands::font_family::computed_value::T {
|
||||||
|
use properties::longhands::font_family::computed_value::{FontFamily, FamilyName};
|
||||||
|
use gecko_bindings::structs::FontFamilyType;
|
||||||
|
use gecko_string_cache::Atom;
|
||||||
|
|
||||||
|
::properties::longhands::font_family::computed_value::T(
|
||||||
|
self.gecko.mFont.fontlist.mFontlist.iter().map(|gecko_font_family_name| {
|
||||||
|
match gecko_font_family_name.mType {
|
||||||
|
FontFamilyType::eFamily_serif => FontFamily::Generic(atom!("serif")),
|
||||||
|
FontFamilyType::eFamily_sans_serif => FontFamily::Generic(atom!("sans-serif")),
|
||||||
|
FontFamilyType::eFamily_monospace => FontFamily::Generic(atom!("monospace")),
|
||||||
|
FontFamilyType::eFamily_cursive => FontFamily::Generic(atom!("cursive")),
|
||||||
|
FontFamilyType::eFamily_fantasy => FontFamily::Generic(atom!("fantasy")),
|
||||||
|
FontFamilyType::eFamily_moz_fixed => FontFamily::Generic(Atom::from("-moz-fixed")),
|
||||||
|
FontFamilyType::eFamily_named => FontFamily::FamilyName(FamilyName {
|
||||||
|
name: (&*gecko_font_family_name.mName).into(),
|
||||||
|
quoted: false
|
||||||
|
}),
|
||||||
|
FontFamilyType::eFamily_named_quoted => FontFamily::FamilyName(FamilyName {
|
||||||
|
name: (&*gecko_font_family_name.mName).into(),
|
||||||
|
quoted: true
|
||||||
|
}),
|
||||||
|
x => panic!("Found unexpected font FontFamilyType: {:?}", x),
|
||||||
|
}
|
||||||
|
}).collect()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME(bholley): Gecko has two different sizes, one of which (mSize) is the
|
// FIXME(bholley): Gecko has two different sizes, one of which (mSize) is the
|
||||||
// actual computed size, and the other of which (mFont.size) is the 'display
|
// actual computed size, and the other of which (mFont.size) is the 'display
|
||||||
// size' which takes font zooming into account. We don't handle font zooming yet.
|
// size' which takes font zooming into account. We don't handle font zooming yet.
|
||||||
|
@ -2223,16 +2309,8 @@ fn static_assert() {
|
||||||
}
|
}
|
||||||
% endfor
|
% endfor
|
||||||
|
|
||||||
% for axis in ["x", "y"]:
|
${impl_style_coord("scroll_snap_points_x", "mScrollSnapPointsX", True)}
|
||||||
pub fn set_scroll_snap_points_${axis}(&mut self, v: longhands::scroll_snap_points_${axis}::computed_value::T) {
|
${impl_style_coord("scroll_snap_points_y", "mScrollSnapPointsY", True)}
|
||||||
match v.repeated() {
|
|
||||||
None => self.gecko.mScrollSnapPoints${axis.upper()}.set_value(CoordDataValue::None),
|
|
||||||
Some(l) => l.to_gecko_style_coord(&mut self.gecko.mScrollSnapPoints${axis.upper()}),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
${impl_coord_copy('scroll_snap_points_' + axis, 'mScrollSnapPoints' + axis.upper())}
|
|
||||||
% endfor
|
|
||||||
|
|
||||||
pub fn set_scroll_snap_coordinate<I>(&mut self, v: I)
|
pub fn set_scroll_snap_coordinate<I>(&mut self, v: I)
|
||||||
where I: IntoIterator<Item = longhands::scroll_snap_coordinate::computed_value::single_value::T>,
|
where I: IntoIterator<Item = longhands::scroll_snap_coordinate::computed_value::single_value::T>,
|
||||||
|
@ -2806,6 +2884,25 @@ fn static_assert() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clone_will_change(&self) -> longhands::will_change::computed_value::T {
|
||||||
|
use properties::longhands::will_change::computed_value::T;
|
||||||
|
use gecko_bindings::structs::nsIAtom;
|
||||||
|
use gecko_string_cache::Atom;
|
||||||
|
use values::CustomIdent;
|
||||||
|
|
||||||
|
if self.gecko.mWillChange.mBuffer.len() == 0 {
|
||||||
|
T::Auto
|
||||||
|
} else {
|
||||||
|
T::AnimateableFeatures(
|
||||||
|
self.gecko.mWillChange.mBuffer.iter().map(|gecko_atom| {
|
||||||
|
CustomIdent(
|
||||||
|
unsafe { Atom::from_addrefed(*gecko_atom as *mut nsIAtom) }
|
||||||
|
)
|
||||||
|
}).collect()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
<% impl_shape_source("shape_outside", "mShapeOutside") %>
|
<% impl_shape_source("shape_outside", "mShapeOutside") %>
|
||||||
|
|
||||||
pub fn set_contain(&mut self, v: longhands::contain::computed_value::T) {
|
pub fn set_contain(&mut self, v: longhands::contain::computed_value::T) {
|
||||||
|
@ -3022,6 +3119,30 @@ fn static_assert() {
|
||||||
}
|
}
|
||||||
</%self:simple_image_array_property>
|
</%self:simple_image_array_property>
|
||||||
|
|
||||||
|
pub fn clone_${shorthand}_repeat(&self) -> longhands::${shorthand}_repeat::computed_value::T {
|
||||||
|
use properties::longhands::${shorthand}_repeat::single_value::computed_value::T;
|
||||||
|
use properties::longhands::${shorthand}_repeat::single_value::computed_value::RepeatKeyword;
|
||||||
|
use gecko_bindings::structs::StyleImageLayerRepeat;
|
||||||
|
|
||||||
|
fn to_servo(repeat: StyleImageLayerRepeat) -> RepeatKeyword {
|
||||||
|
match repeat {
|
||||||
|
StyleImageLayerRepeat::Repeat => RepeatKeyword::Repeat,
|
||||||
|
StyleImageLayerRepeat::Space => RepeatKeyword::Space,
|
||||||
|
StyleImageLayerRepeat::Round => RepeatKeyword::Round,
|
||||||
|
StyleImageLayerRepeat::NoRepeat => RepeatKeyword::NoRepeat,
|
||||||
|
x => panic!("Found unexpected value in style struct for ${shorthand}_repeat property: {:?}", x),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
longhands::${shorthand}_repeat::computed_value::T (
|
||||||
|
self.gecko.${image_layers_field}.mLayers.iter()
|
||||||
|
.take(self.gecko.${image_layers_field}.mRepeatCount as usize)
|
||||||
|
.map(|ref layer| {
|
||||||
|
T(to_servo(layer.mRepeat.mXRepeat), to_servo(layer.mRepeat.mYRepeat))
|
||||||
|
}).collect()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
<% impl_simple_image_array_property("clip", shorthand, image_layers_field, "mClip", struct_name) %>
|
<% impl_simple_image_array_property("clip", shorthand, image_layers_field, "mClip", struct_name) %>
|
||||||
<% impl_simple_image_array_property("origin", shorthand, image_layers_field, "mOrigin", struct_name) %>
|
<% impl_simple_image_array_property("origin", shorthand, image_layers_field, "mOrigin", struct_name) %>
|
||||||
|
|
||||||
|
@ -3206,6 +3327,21 @@ fn static_assert() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clone_${shorthand}_image(&self) -> longhands::${shorthand}_image::computed_value::T {
|
||||||
|
use values::None_;
|
||||||
|
|
||||||
|
longhands::${shorthand}_image::computed_value::T(
|
||||||
|
self.gecko.${image_layers_field}.mLayers.iter()
|
||||||
|
.take(self.gecko.${image_layers_field}.mImageCount as usize)
|
||||||
|
.map(|ref layer| {
|
||||||
|
match unsafe { layer.mImage.into_image() } {
|
||||||
|
Some(image) => Either::Second(image),
|
||||||
|
None => Either::First(None_),
|
||||||
|
}
|
||||||
|
}).collect()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
<%
|
<%
|
||||||
fill_fields = "mRepeat mClip mOrigin mPositionX mPositionY mImage mSize"
|
fill_fields = "mRepeat mClip mOrigin mPositionX mPositionY mImage mSize"
|
||||||
if shorthand == "background":
|
if shorthand == "background":
|
||||||
|
@ -3277,6 +3413,24 @@ fn static_assert() {
|
||||||
unsafe { Gecko_CopyListStyleImageFrom(&mut self.gecko, &other.gecko); }
|
unsafe { Gecko_CopyListStyleImageFrom(&mut self.gecko, &other.gecko); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clone_list_style_image(&self) -> longhands::list_style_image::computed_value::T {
|
||||||
|
use values::specified::url::SpecifiedUrl;
|
||||||
|
use values::{Either, None_};
|
||||||
|
|
||||||
|
longhands::list_style_image::computed_value::T(
|
||||||
|
match self.gecko.mListStyleImage.mRawPtr.is_null() {
|
||||||
|
true => Either::Second(None_),
|
||||||
|
false => {
|
||||||
|
unsafe {
|
||||||
|
let ref gecko_image_request = *self.gecko.mListStyleImage.mRawPtr;
|
||||||
|
Either::First(SpecifiedUrl::from_image_request(gecko_image_request)
|
||||||
|
.expect("mListStyleImage could not convert to SpecifiedUrl"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_list_style_type(&mut self, v: longhands::list_style_type::computed_value::T, device: &Device) {
|
pub fn set_list_style_type(&mut self, v: longhands::list_style_type::computed_value::T, device: &Device) {
|
||||||
use gecko_bindings::bindings::Gecko_SetCounterStyleToString;
|
use gecko_bindings::bindings::Gecko_SetCounterStyleToString;
|
||||||
use nsstring::{nsACString, nsCString};
|
use nsstring::{nsACString, nsCString};
|
||||||
|
@ -3316,6 +3470,17 @@ fn static_assert() {
|
||||||
unsafe { self.gecko.mQuotes.set(&other.gecko.mQuotes); }
|
unsafe { self.gecko.mQuotes.set(&other.gecko.mQuotes); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clone_quotes(&self) -> longhands::quotes::computed_value::T {
|
||||||
|
unsafe {
|
||||||
|
let ref gecko_quote_values = *self.gecko.mQuotes.mRawPtr;
|
||||||
|
longhands::quotes::computed_value::T(
|
||||||
|
gecko_quote_values.mQuotePairs.iter().map(|gecko_pair| {
|
||||||
|
(gecko_pair.first.to_string(), gecko_pair.second.to_string())
|
||||||
|
}).collect()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn set__moz_image_region(&mut self, v: longhands::_moz_image_region::computed_value::T) {
|
pub fn set__moz_image_region(&mut self, v: longhands::_moz_image_region::computed_value::T) {
|
||||||
use values::Either;
|
use values::Either;
|
||||||
|
@ -3851,6 +4016,33 @@ fn static_assert() {
|
||||||
self.gecko.mTextEmphasisStyle = other.gecko.mTextEmphasisStyle;
|
self.gecko.mTextEmphasisStyle = other.gecko.mTextEmphasisStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clone_text_emphasis_style(&self) -> longhands::text_emphasis_style::computed_value::T {
|
||||||
|
use properties::longhands::text_emphasis_style::computed_value::{T, KeywordValue};
|
||||||
|
use properties::longhands::text_emphasis_style::ShapeKeyword;
|
||||||
|
|
||||||
|
if self.gecko.mTextEmphasisStyle == structs::NS_STYLE_TEXT_EMPHASIS_STYLE_NONE as u8 {
|
||||||
|
return T::None;
|
||||||
|
} else if self.gecko.mTextEmphasisStyle == structs::NS_STYLE_TEXT_EMPHASIS_STYLE_STRING as u8 {
|
||||||
|
return T::String(self.gecko.mTextEmphasisStyleString.to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
let fill = self.gecko.mTextEmphasisStyle & structs::NS_STYLE_TEXT_EMPHASIS_STYLE_OPEN as u8 == 0;
|
||||||
|
let shape =
|
||||||
|
match self.gecko.mTextEmphasisStyle as u32 & !structs::NS_STYLE_TEXT_EMPHASIS_STYLE_OPEN {
|
||||||
|
structs::NS_STYLE_TEXT_EMPHASIS_STYLE_DOT => ShapeKeyword::Dot,
|
||||||
|
structs::NS_STYLE_TEXT_EMPHASIS_STYLE_CIRCLE => ShapeKeyword::Circle,
|
||||||
|
structs::NS_STYLE_TEXT_EMPHASIS_STYLE_DOUBLE_CIRCLE => ShapeKeyword::DoubleCircle,
|
||||||
|
structs::NS_STYLE_TEXT_EMPHASIS_STYLE_TRIANGLE => ShapeKeyword::Triangle,
|
||||||
|
structs::NS_STYLE_TEXT_EMPHASIS_STYLE_SESAME => ShapeKeyword::Sesame,
|
||||||
|
x => panic!("Unexpected value in style struct for text-emphasis-style property: {:?}", x)
|
||||||
|
};
|
||||||
|
|
||||||
|
T::Keyword(KeywordValue {
|
||||||
|
fill: fill,
|
||||||
|
shape: shape
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
<%call expr="impl_app_units('_webkit_text_stroke_width', 'mWebkitTextStrokeWidth', need_clone=True)"></%call>
|
<%call expr="impl_app_units('_webkit_text_stroke_width', 'mWebkitTextStrokeWidth', need_clone=True)"></%call>
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
@ -3936,6 +4128,26 @@ fn static_assert() {
|
||||||
self.gecko.mTextOverflow.mLogicalDirections = other.gecko.mTextOverflow.mLogicalDirections;
|
self.gecko.mTextOverflow.mLogicalDirections = other.gecko.mTextOverflow.mLogicalDirections;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clone_text_overflow(&self) -> longhands::text_overflow::computed_value::T {
|
||||||
|
use gecko_bindings::structs::nsStyleTextOverflowSide;
|
||||||
|
use properties::longhands::text_overflow::Side;
|
||||||
|
|
||||||
|
fn to_servo(side: &nsStyleTextOverflowSide) -> Side {
|
||||||
|
match side.mType as u32 {
|
||||||
|
structs::NS_STYLE_TEXT_OVERFLOW_CLIP => Side::Clip,
|
||||||
|
structs::NS_STYLE_TEXT_OVERFLOW_ELLIPSIS => Side::Ellipsis,
|
||||||
|
structs::NS_STYLE_TEXT_OVERFLOW_STRING => Side::String(side.mString.to_string().into_boxed_str()),
|
||||||
|
x => panic!("Found unexpected value in style struct for text_overflow property: {:?}", x),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
longhands::text_overflow::computed_value::T {
|
||||||
|
first: to_servo(&self.gecko.mTextOverflow.mLeft),
|
||||||
|
second: to_servo(&self.gecko.mTextOverflow.mRight),
|
||||||
|
sides_are_logical: self.gecko.mTextOverflow.mLogicalDirections
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_initial_letter(&mut self, v: longhands::initial_letter::computed_value::T) {
|
pub fn set_initial_letter(&mut self, v: longhands::initial_letter::computed_value::T) {
|
||||||
use values::generics::text::InitialLetter;
|
use values::generics::text::InitialLetter;
|
||||||
match v {
|
match v {
|
||||||
|
@ -4524,6 +4736,17 @@ clip-path
|
||||||
bindings::Gecko_CopyCounter${counter_property}sFrom(&mut self.gecko, &other.gecko)
|
bindings::Gecko_CopyCounter${counter_property}sFrom(&mut self.gecko, &other.gecko)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clone_counter_${counter_property.lower()}(&self) -> longhands::counter_increment::computed_value::T {
|
||||||
|
use values::CustomIdent;
|
||||||
|
use gecko_string_cache::Atom;
|
||||||
|
|
||||||
|
longhands::counter_increment::computed_value::T(
|
||||||
|
self.gecko.m${counter_property}s.iter().map(|ref gecko_counter| {
|
||||||
|
(CustomIdent(Atom::from(gecko_counter.mCounter.to_string())), gecko_counter.mValue)
|
||||||
|
}).collect()
|
||||||
|
)
|
||||||
|
}
|
||||||
% endfor
|
% endfor
|
||||||
</%self:impl_trait>
|
</%self:impl_trait>
|
||||||
|
|
||||||
|
|
|
@ -414,7 +414,12 @@ impl AnimatedProperty {
|
||||||
let value: longhands::${prop.ident}::computed_value::T =
|
let value: longhands::${prop.ident}::computed_value::T =
|
||||||
ToAnimatedValue::from_animated_value(value);
|
ToAnimatedValue::from_animated_value(value);
|
||||||
% endif
|
% endif
|
||||||
style.mutate_${prop.style_struct.ident.strip("_")}().set_${prop.ident}(value);
|
<% method = "style.mutate_" + prop.style_struct.ident.strip("_") + "().set_" + prop.ident %>
|
||||||
|
% if prop.has_uncacheable_values is "True":
|
||||||
|
${method}(value, &mut false);
|
||||||
|
% else:
|
||||||
|
${method}(value);
|
||||||
|
% endif
|
||||||
}
|
}
|
||||||
% endif
|
% endif
|
||||||
% endfor
|
% endfor
|
||||||
|
|
|
@ -19,7 +19,7 @@ ${helpers.predefined_type("background-image", "ImageLayer",
|
||||||
initial_specified_value="Either::First(None_)",
|
initial_specified_value="Either::First(None_)",
|
||||||
spec="https://drafts.csswg.org/css-backgrounds/#the-background-image",
|
spec="https://drafts.csswg.org/css-backgrounds/#the-background-image",
|
||||||
vector="True",
|
vector="True",
|
||||||
animation_value_type="none",
|
animation_value_type="discrete",
|
||||||
has_uncacheable_values="True" if product == "gecko" else "False",
|
has_uncacheable_values="True" if product == "gecko" else "False",
|
||||||
ignored_when_colors_disabled="True")}
|
ignored_when_colors_disabled="True")}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ ${helpers.predefined_type("background-image", "ImageLayer",
|
||||||
animation_value_type="ComputedValue", vector=True, delegate_animate=True)}
|
animation_value_type="ComputedValue", vector=True, delegate_animate=True)}
|
||||||
% endfor
|
% endfor
|
||||||
|
|
||||||
<%helpers:vector_longhand name="background-repeat" animation_value_type="none"
|
<%helpers:vector_longhand name="background-repeat" animation_value_type="discrete"
|
||||||
spec="https://drafts.csswg.org/css-backgrounds/#the-background-repeat">
|
spec="https://drafts.csswg.org/css-backgrounds/#the-background-repeat">
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
|
|
@ -60,7 +60,7 @@ ${helpers.gecko_keyword_conversion(Keyword('border-style',
|
||||||
/// -moz-border-*-colors: color, string, enum, none, inherit/initial
|
/// -moz-border-*-colors: color, string, enum, none, inherit/initial
|
||||||
/// These non-spec properties are just for Gecko (Stylo) internal use.
|
/// These non-spec properties are just for Gecko (Stylo) internal use.
|
||||||
% for side in PHYSICAL_SIDES:
|
% for side in PHYSICAL_SIDES:
|
||||||
<%helpers:longhand name="-moz-border-${side}-colors" animation_value_type="none"
|
<%helpers:longhand name="-moz-border-${side}-colors" animation_value_type="discrete"
|
||||||
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-border-*-colors)"
|
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-border-*-colors)"
|
||||||
products="gecko"
|
products="gecko"
|
||||||
ignored_when_colors_disabled="True">
|
ignored_when_colors_disabled="True">
|
||||||
|
@ -200,7 +200,7 @@ ${helpers.predefined_type("border-image-source", "ImageLayer",
|
||||||
initial_specified_value="Either::First(None_)",
|
initial_specified_value="Either::First(None_)",
|
||||||
spec="https://drafts.csswg.org/css-backgrounds/#the-background-image",
|
spec="https://drafts.csswg.org/css-backgrounds/#the-background-image",
|
||||||
vector=False,
|
vector=False,
|
||||||
animation_value_type="none",
|
animation_value_type="discrete",
|
||||||
has_uncacheable_values=False,
|
has_uncacheable_values=False,
|
||||||
boxed="True")}
|
boxed="True")}
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ ${helpers.predefined_type("border-image-outset", "LengthOrNumberRect",
|
||||||
initial_value="computed::LengthOrNumber::zero().into()",
|
initial_value="computed::LengthOrNumber::zero().into()",
|
||||||
initial_specified_value="specified::LengthOrNumber::zero().into()",
|
initial_specified_value="specified::LengthOrNumber::zero().into()",
|
||||||
spec="https://drafts.csswg.org/css-backgrounds/#border-image-outset",
|
spec="https://drafts.csswg.org/css-backgrounds/#border-image-outset",
|
||||||
animation_value_type="none",
|
animation_value_type="discrete",
|
||||||
boxed=True)}
|
boxed=True)}
|
||||||
|
|
||||||
<%helpers:longhand name="border-image-repeat" animation_value_type="discrete"
|
<%helpers:longhand name="border-image-repeat" animation_value_type="discrete"
|
||||||
|
@ -273,12 +273,66 @@ ${helpers.predefined_type("border-image-width", "BorderImageWidth",
|
||||||
initial_value="computed::BorderImageSideWidth::one().into()",
|
initial_value="computed::BorderImageSideWidth::one().into()",
|
||||||
initial_specified_value="specified::BorderImageSideWidth::one().into()",
|
initial_specified_value="specified::BorderImageSideWidth::one().into()",
|
||||||
spec="https://drafts.csswg.org/css-backgrounds/#border-image-width",
|
spec="https://drafts.csswg.org/css-backgrounds/#border-image-width",
|
||||||
animation_value_type="none",
|
animation_value_type="discrete",
|
||||||
boxed=True)}
|
boxed=True)}
|
||||||
|
|
||||||
${helpers.predefined_type("border-image-slice", "BorderImageSlice",
|
${helpers.predefined_type("border-image-slice", "BorderImageSlice",
|
||||||
initial_value="computed::NumberOrPercentage::Percentage(computed::Percentage(1.)).into()",
|
initial_value="computed::NumberOrPercentage::Percentage(computed::Percentage(1.)).into()",
|
||||||
initial_specified_value="specified::NumberOrPercentage::Percentage(specified::Percentage(1.)).into()",
|
initial_specified_value="specified::NumberOrPercentage::Percentage(specified::Percentage(1.)).into()",
|
||||||
spec="https://drafts.csswg.org/css-backgrounds/#border-image-slice",
|
spec="https://drafts.csswg.org/css-backgrounds/#border-image-slice",
|
||||||
animation_value_type="none",
|
animation_value_type="discrete",
|
||||||
boxed=True)}
|
boxed=True)}
|
||||||
|
|
||||||
|
#[cfg(feature = "gecko")]
|
||||||
|
impl ::values::computed::BorderImageWidth {
|
||||||
|
pub fn to_gecko_rect(&self, sides: &mut ::gecko_bindings::structs::nsStyleSides) {
|
||||||
|
use gecko_bindings::sugar::ns_style_coord::{CoordDataMut, CoordDataValue};
|
||||||
|
use gecko::values::GeckoStyleCoordConvertible;
|
||||||
|
use values::generics::border::BorderImageSideWidth;
|
||||||
|
|
||||||
|
% for i in range(0, 4):
|
||||||
|
match self.${i} {
|
||||||
|
BorderImageSideWidth::Auto => {
|
||||||
|
sides.data_at_mut(${i}).set_value(CoordDataValue::Auto)
|
||||||
|
},
|
||||||
|
BorderImageSideWidth::Length(l) => {
|
||||||
|
l.to_gecko_style_coord(&mut sides.data_at_mut(${i}))
|
||||||
|
},
|
||||||
|
BorderImageSideWidth::Number(n) => {
|
||||||
|
sides.data_at_mut(${i}).set_value(CoordDataValue::Factor(n))
|
||||||
|
},
|
||||||
|
}
|
||||||
|
% endfor
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn from_gecko_rect(sides: &::gecko_bindings::structs::nsStyleSides)
|
||||||
|
-> Option<::values::computed::BorderImageWidth> {
|
||||||
|
use gecko_bindings::structs::nsStyleUnit::{eStyleUnit_Factor, eStyleUnit_Auto};
|
||||||
|
use gecko_bindings::sugar::ns_style_coord::CoordData;
|
||||||
|
use gecko::values::GeckoStyleCoordConvertible;
|
||||||
|
use values::computed::{LengthOrPercentage, Number};
|
||||||
|
use values::generics::border::BorderImageSideWidth;
|
||||||
|
|
||||||
|
Some(
|
||||||
|
::values::computed::BorderImageWidth::new(
|
||||||
|
% for i in range(0, 4):
|
||||||
|
match sides.data_at(${i}).unit() {
|
||||||
|
eStyleUnit_Auto => {
|
||||||
|
BorderImageSideWidth::Auto
|
||||||
|
},
|
||||||
|
eStyleUnit_Factor => {
|
||||||
|
BorderImageSideWidth::Number(
|
||||||
|
Number::from_gecko_style_coord(&sides.data_at(${i}))
|
||||||
|
.expect("sides[${i}] could not convert to Number"))
|
||||||
|
},
|
||||||
|
_ => {
|
||||||
|
BorderImageSideWidth::Length(
|
||||||
|
LengthOrPercentage::from_gecko_style_coord(&sides.data_at(${i}))
|
||||||
|
.expect("sides[${i}] could not convert to LengthOrPercentager"))
|
||||||
|
},
|
||||||
|
},
|
||||||
|
% endfor
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -656,7 +656,7 @@ ${helpers.predefined_type("animation-delay",
|
||||||
"scroll-snap-points-" + axis,
|
"scroll-snap-points-" + axis,
|
||||||
"ScrollSnapPoint",
|
"ScrollSnapPoint",
|
||||||
"computed::ScrollSnapPoint::none()",
|
"computed::ScrollSnapPoint::none()",
|
||||||
animation_value_type="none",
|
animation_value_type="discrete",
|
||||||
products="gecko",
|
products="gecko",
|
||||||
disable_when_testing=True,
|
disable_when_testing=True,
|
||||||
spec="Nonstandard (https://www.w3.org/TR/2015/WD-css-snappoints-1-20150326/#scroll-snap-points)",
|
spec="Nonstandard (https://www.w3.org/TR/2015/WD-css-snappoints-1-20150326/#scroll-snap-points)",
|
||||||
|
@ -1874,7 +1874,7 @@ ${helpers.single_keyword("-moz-orient",
|
||||||
gecko_inexhaustive="True",
|
gecko_inexhaustive="True",
|
||||||
animation_value_type="discrete")}
|
animation_value_type="discrete")}
|
||||||
|
|
||||||
<%helpers:longhand name="will-change" products="gecko" animation_value_type="none"
|
<%helpers:longhand name="will-change" products="gecko" animation_value_type="discrete"
|
||||||
spec="https://drafts.csswg.org/css-will-change/#will-change">
|
spec="https://drafts.csswg.org/css-will-change/#will-change">
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
|
|
@ -233,7 +233,7 @@
|
||||||
}
|
}
|
||||||
</%helpers:longhand>
|
</%helpers:longhand>
|
||||||
|
|
||||||
<%helpers:longhand name="counter-increment" animation_value_type="none"
|
<%helpers:longhand name="counter-increment" animation_value_type="discrete"
|
||||||
spec="https://drafts.csswg.org/css-lists/#propdef-counter-increment">
|
spec="https://drafts.csswg.org/css-lists/#propdef-counter-increment">
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
@ -350,7 +350,7 @@
|
||||||
}
|
}
|
||||||
</%helpers:longhand>
|
</%helpers:longhand>
|
||||||
|
|
||||||
<%helpers:longhand name="counter-reset" animation_value_type="none"
|
<%helpers:longhand name="counter-reset" animation_value_type="discrete"
|
||||||
spec="https://drafts.csswg.org/css-lists-3/#propdef-counter-reset">
|
spec="https://drafts.csswg.org/css-lists-3/#propdef-counter-reset">
|
||||||
pub use super::counter_increment::{SpecifiedValue, computed_value, get_initial_value};
|
pub use super::counter_increment::{SpecifiedValue, computed_value, get_initial_value};
|
||||||
use super::counter_increment::parse_common;
|
use super::counter_increment::parse_common;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
macro_rules! impl_gecko_keyword_from_trait {
|
macro_rules! impl_gecko_keyword_conversions {
|
||||||
($name: ident, $utype: ty) => {
|
($name: ident, $utype: ty) => {
|
||||||
impl From<$utype> for $name {
|
impl From<$utype> for $name {
|
||||||
fn from(bits: $utype) -> $name {
|
fn from(bits: $utype) -> $name {
|
||||||
|
@ -78,7 +78,7 @@ macro_rules! impl_gecko_keyword_from_trait {
|
||||||
}
|
}
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%helpers:longhand name="font-family" animation_value_type="none" need_index="True" boxed="${product == 'gecko'}"
|
<%helpers:longhand name="font-family" animation_value_type="discrete" need_index="True" boxed="${product == 'gecko'}"
|
||||||
spec="https://drafts.csswg.org/css-fonts/#propdef-font-family">
|
spec="https://drafts.csswg.org/css-fonts/#propdef-font-family">
|
||||||
use properties::longhands::system_font::SystemFont;
|
use properties::longhands::system_font::SystemFont;
|
||||||
use self::computed_value::{FontFamily, FamilyName};
|
use self::computed_value::{FontFamily, FamilyName};
|
||||||
|
@ -1623,7 +1623,7 @@ macro_rules! exclusive_value {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
impl_gecko_keyword_from_trait!(VariantEastAsian, u16);
|
impl_gecko_keyword_conversions!(VariantEastAsian, u16);
|
||||||
</%helpers:longhand>
|
</%helpers:longhand>
|
||||||
|
|
||||||
<%helpers:longhand name="font-variant-ligatures" products="gecko" animation_value_type="discrete"
|
<%helpers:longhand name="font-variant-ligatures" products="gecko" animation_value_type="discrete"
|
||||||
|
@ -1782,7 +1782,7 @@ macro_rules! exclusive_value {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
impl_gecko_keyword_from_trait!(VariantLigatures, u16);
|
impl_gecko_keyword_conversions!(VariantLigatures, u16);
|
||||||
</%helpers:longhand>
|
</%helpers:longhand>
|
||||||
|
|
||||||
<%helpers:longhand name="font-variant-numeric" products="gecko" animation_value_type="discrete"
|
<%helpers:longhand name="font-variant-numeric" products="gecko" animation_value_type="discrete"
|
||||||
|
@ -1930,7 +1930,7 @@ macro_rules! exclusive_value {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
impl_gecko_keyword_from_trait!(VariantNumeric, u8);
|
impl_gecko_keyword_conversions!(VariantNumeric, u8);
|
||||||
</%helpers:longhand>
|
</%helpers:longhand>
|
||||||
|
|
||||||
${helpers.single_keyword_system("font-variant-position",
|
${helpers.single_keyword_system("font-variant-position",
|
||||||
|
@ -1941,7 +1941,7 @@ ${helpers.single_keyword_system("font-variant-position",
|
||||||
spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-position",
|
spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-position",
|
||||||
animation_value_type="discrete")}
|
animation_value_type="discrete")}
|
||||||
|
|
||||||
<%helpers:longhand name="font-feature-settings" products="gecko" animation_value_type="none"
|
<%helpers:longhand name="font-feature-settings" products="gecko" animation_value_type="discrete"
|
||||||
extra_prefixes="moz" boxed="True"
|
extra_prefixes="moz" boxed="True"
|
||||||
spec="https://drafts.csswg.org/css-fonts/#propdef-font-feature-settings">
|
spec="https://drafts.csswg.org/css-fonts/#propdef-font-feature-settings">
|
||||||
use properties::longhands::system_font::SystemFont;
|
use properties::longhands::system_font::SystemFont;
|
||||||
|
|
|
@ -119,19 +119,19 @@ ${helpers.single_keyword("clip-rule", "nonzero evenodd",
|
||||||
${helpers.predefined_type("marker-start", "UrlOrNone", "Either::Second(None_)",
|
${helpers.predefined_type("marker-start", "UrlOrNone", "Either::Second(None_)",
|
||||||
products="gecko",
|
products="gecko",
|
||||||
boxed="True" if product == "gecko" else "False",
|
boxed="True" if product == "gecko" else "False",
|
||||||
animation_value_type="none",
|
animation_value_type="discrete",
|
||||||
spec="https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties")}
|
spec="https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties")}
|
||||||
|
|
||||||
${helpers.predefined_type("marker-mid", "UrlOrNone", "Either::Second(None_)",
|
${helpers.predefined_type("marker-mid", "UrlOrNone", "Either::Second(None_)",
|
||||||
products="gecko",
|
products="gecko",
|
||||||
boxed="True" if product == "gecko" else "False",
|
boxed="True" if product == "gecko" else "False",
|
||||||
animation_value_type="none",
|
animation_value_type="discrete",
|
||||||
spec="https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties")}
|
spec="https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties")}
|
||||||
|
|
||||||
${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)",
|
${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)",
|
||||||
products="gecko",
|
products="gecko",
|
||||||
boxed="True" if product == "gecko" else "False",
|
boxed="True" if product == "gecko" else "False",
|
||||||
animation_value_type="none",
|
animation_value_type="discrete",
|
||||||
spec="https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties")}
|
spec="https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties")}
|
||||||
|
|
||||||
<%helpers:longhand name="paint-order"
|
<%helpers:longhand name="paint-order"
|
||||||
|
|
|
@ -417,8 +417,8 @@ ${helpers.predefined_type(
|
||||||
spec="https://drafts.csswg.org/css-text-decor-3/#text-shadow-property",
|
spec="https://drafts.csswg.org/css-text-decor-3/#text-shadow-property",
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<%helpers:longhand name="text-emphasis-style" products="gecko" need_clone="True" boxed="True"
|
<%helpers:longhand name="text-emphasis-style" products="gecko" boxed="True"
|
||||||
animation_value_type="none"
|
animation_value_type="discrete"
|
||||||
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-emphasis-style">
|
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-emphasis-style">
|
||||||
use computed_values::writing_mode::T as writing_mode;
|
use computed_values::writing_mode::T as writing_mode;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
|
@ -100,7 +100,7 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu
|
||||||
</%helpers:longhand>
|
</%helpers:longhand>
|
||||||
% endif
|
% endif
|
||||||
|
|
||||||
<%helpers:longhand name="list-style-image" animation_value_type="none"
|
<%helpers:longhand name="list-style-image" animation_value_type="discrete"
|
||||||
boxed="${product == 'gecko'}"
|
boxed="${product == 'gecko'}"
|
||||||
spec="https://drafts.csswg.org/css-lists/#propdef-list-style-image">
|
spec="https://drafts.csswg.org/css-lists/#propdef-list-style-image">
|
||||||
use values::computed::ComputedValueAsSpecified;
|
use values::computed::ComputedValueAsSpecified;
|
||||||
|
@ -142,7 +142,7 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu
|
||||||
}
|
}
|
||||||
</%helpers:longhand>
|
</%helpers:longhand>
|
||||||
|
|
||||||
<%helpers:longhand name="quotes" animation_value_type="none"
|
<%helpers:longhand name="quotes" animation_value_type="discrete"
|
||||||
spec="https://drafts.csswg.org/css-content/#propdef-quotes">
|
spec="https://drafts.csswg.org/css-content/#propdef-quotes">
|
||||||
use cssparser::serialize_string;
|
use cssparser::serialize_string;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
|
@ -260,7 +260,7 @@ ${helpers.predefined_type("object-position",
|
||||||
${helpers.predefined_type("grid-%s-%s" % (kind, range),
|
${helpers.predefined_type("grid-%s-%s" % (kind, range),
|
||||||
"GridLine",
|
"GridLine",
|
||||||
"Default::default()",
|
"Default::default()",
|
||||||
animation_value_type="none",
|
animation_value_type="discrete",
|
||||||
spec="https://drafts.csswg.org/css-grid/#propdef-grid-%s-%s" % (kind, range),
|
spec="https://drafts.csswg.org/css-grid/#propdef-grid-%s-%s" % (kind, range),
|
||||||
products="gecko",
|
products="gecko",
|
||||||
boxed=True)}
|
boxed=True)}
|
||||||
|
@ -271,7 +271,7 @@ ${helpers.predefined_type("object-position",
|
||||||
${helpers.predefined_type("grid-auto-%ss" % kind,
|
${helpers.predefined_type("grid-auto-%ss" % kind,
|
||||||
"TrackSize",
|
"TrackSize",
|
||||||
"Default::default()",
|
"Default::default()",
|
||||||
animation_value_type="none",
|
animation_value_type="discrete",
|
||||||
spec="https://drafts.csswg.org/css-grid/#propdef-grid-auto-%ss" % kind,
|
spec="https://drafts.csswg.org/css-grid/#propdef-grid-auto-%ss" % kind,
|
||||||
products="gecko",
|
products="gecko",
|
||||||
boxed=True)}
|
boxed=True)}
|
||||||
|
|
|
@ -70,7 +70,7 @@ ${helpers.single_keyword("mask-mode",
|
||||||
animation_value_type="discrete",
|
animation_value_type="discrete",
|
||||||
spec="https://drafts.fxtf.org/css-masking/#propdef-mask-mode")}
|
spec="https://drafts.fxtf.org/css-masking/#propdef-mask-mode")}
|
||||||
|
|
||||||
<%helpers:vector_longhand name="mask-repeat" products="gecko" animation_value_type="none" extra_prefixes="webkit"
|
<%helpers:vector_longhand name="mask-repeat" products="gecko" animation_value_type="discrete" extra_prefixes="webkit"
|
||||||
spec="https://drafts.fxtf.org/css-masking/#propdef-mask-repeat">
|
spec="https://drafts.fxtf.org/css-masking/#propdef-mask-repeat">
|
||||||
pub use properties::longhands::background_repeat::single_value::parse;
|
pub use properties::longhands::background_repeat::single_value::parse;
|
||||||
pub use properties::longhands::background_repeat::single_value::SpecifiedValue;
|
pub use properties::longhands::background_repeat::single_value::SpecifiedValue;
|
||||||
|
@ -150,6 +150,6 @@ ${helpers.predefined_type("mask-image", "ImageLayer",
|
||||||
vector=True,
|
vector=True,
|
||||||
products="gecko",
|
products="gecko",
|
||||||
extra_prefixes="webkit",
|
extra_prefixes="webkit",
|
||||||
animation_value_type="none",
|
animation_value_type="discrete",
|
||||||
flags="CREATES_STACKING_CONTEXT",
|
flags="CREATES_STACKING_CONTEXT",
|
||||||
has_uncacheable_values="True" if product == "gecko" else "False")}
|
has_uncacheable_values="True" if product == "gecko" else "False")}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
Method("has_overline", "bool"),
|
Method("has_overline", "bool"),
|
||||||
Method("has_line_through", "bool")]) %>
|
Method("has_line_through", "bool")]) %>
|
||||||
|
|
||||||
<%helpers:longhand name="text-overflow" animation_value_type="none" boxed="True"
|
<%helpers:longhand name="text-overflow" animation_value_type="discrete" boxed="True"
|
||||||
spec="https://drafts.csswg.org/css-ui/#propdef-text-overflow">
|
spec="https://drafts.csswg.org/css-ui/#propdef-text-overflow">
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue