diff --git a/components/style/gecko/generated/bindings.rs b/components/style/gecko/generated/bindings.rs index 59c97a0658e7..debc395a3911 100644 --- a/components/style/gecko/generated/bindings.rs +++ b/components/style/gecko/generated/bindings.rs @@ -17,7 +17,6 @@ use gecko_bindings::structs::mozilla::css::URLValueData; use gecko_bindings::structs::mozilla::AnonymousCounterStyle; use gecko_bindings::structs::mozilla::MallocSizeOf; use gecko_bindings::structs::mozilla::OriginFlags; -use gecko_bindings::structs::mozilla::Side; use gecko_bindings::structs::mozilla::UniquePtr; use gecko_bindings::structs::ServoRawOffsetArc; use gecko_bindings::structs::nsIContent; @@ -71,7 +70,6 @@ use gecko_bindings::structs::StyleBasicShapeType; use gecko_bindings::structs::StyleShapeSource; use gecko_bindings::structs::StyleTransition; use gecko_bindings::structs::gfxFontFeatureValueSet; -use gecko_bindings::structs::nsBorderColors; use gecko_bindings::structs::nsCSSCounterStyleRule; use gecko_bindings::structs::nsCSSFontFaceRule; use gecko_bindings::structs::nsCSSKeyword; @@ -876,22 +874,6 @@ extern "C" { extern "C" { pub fn Gecko_EnsureMozBorderColors(aBorder: *mut nsStyleBorder); } -extern "C" { - pub fn Gecko_ClearMozBorderColors(aBorder: *mut nsStyleBorder, - aSide: Side); -} -extern "C" { - pub fn Gecko_AppendMozBorderColors(aBorder: *mut nsStyleBorder, - aSide: Side, aColor: nscolor); -} -extern "C" { - pub fn Gecko_CopyMozBorderColors(aDest: *mut nsStyleBorder, - aSrc: *const nsStyleBorder, aSide: Side); -} -extern "C" { - pub fn Gecko_GetMozBorderColors(aBorder: *const nsStyleBorder, - aSide: Side) -> *const nsBorderColors; -} extern "C" { pub fn Gecko_FontFamilyList_Clear(aList: *mut FontFamilyList); } diff --git a/components/style/gecko/generated/structs_debug.rs b/components/style/gecko/generated/structs_debug.rs index 59807d919ebd..5f4e696f5eae 100644 --- a/components/style/gecko/generated/structs_debug.rs +++ b/components/style/gecko/generated/structs_debug.rs @@ -14284,7 +14284,7 @@ pub mod root { #[repr(C)] #[derive(Debug)] pub struct nsStyleBorder { - pub mBorderColors: *mut *mut root::nsBorderColors, + pub mBorderColors: root::mozilla::UniquePtr, pub mBorderRadius: root::nsStyleCorners, pub mBorderImageSource: root::nsStyleImage, pub mBorderImageSlice: root::nsStyleSides, @@ -30544,29 +30544,6 @@ pub mod root { } #[repr(C)] #[derive(Debug)] - pub struct nsBorderColors { - pub mNext: *mut root::nsBorderColors, - pub mColor: root::nscolor, - } - #[test] - fn bindgen_test_layout_nsBorderColors() { - assert_eq!(::std::mem::size_of::() , 16usize , concat - ! ( "Size of: " , stringify ! ( nsBorderColors ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat - ! ( "Alignment of " , stringify ! ( nsBorderColors ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const nsBorderColors ) ) . mNext as * const - _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( nsBorderColors ) , - "::" , stringify ! ( mNext ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const nsBorderColors ) ) . mColor as * - const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( nsBorderColors ) , - "::" , stringify ! ( mColor ) )); - } - #[repr(C)] - #[derive(Debug)] pub struct nsCSSShadowItem { pub mXOffset: root::nscoord, pub mYOffset: root::nscoord, @@ -30651,6 +30628,23 @@ pub mod root { "Alignment of field: " , stringify ! ( nsCSSShadowArray ) , "::" , stringify ! ( mArray ) )); } + #[repr(C)] + #[derive(Debug)] + pub struct nsBorderColors { + pub mColors: [root::nsTArray<::std::os::raw::c_uint>; 4usize], + } + #[test] + fn bindgen_test_layout_nsBorderColors() { + assert_eq!(::std::mem::size_of::() , 32usize , concat + ! ( "Size of: " , stringify ! ( nsBorderColors ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat + ! ( "Alignment of " , stringify ! ( nsBorderColors ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const nsBorderColors ) ) . mColors as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( nsBorderColors ) , + "::" , stringify ! ( mColors ) )); + } /// An object that allows sharing of arrays that store 'quotes' property /// values. This is particularly important for inheritance, where we want /// to share the same 'quotes' value with a parent style context. @@ -33519,6 +33513,28 @@ pub mod root { root::RefPtr ) )); } #[test] + fn __bindgen_test_layout_UniquePtr_open0_nsBorderColors_DefaultDelete_open1_nsBorderColors_close1_close0_instantiation() { + assert_eq!(::std::mem::size_of::>() + , 8usize , concat ! ( + "Size of template specialization: " , stringify ! ( + root::mozilla::UniquePtr ) )); + assert_eq!(::std::mem::align_of::>() + , 8usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( + root::mozilla::UniquePtr ) )); + } + #[test] + fn __bindgen_test_layout_DefaultDelete_open0_nsBorderColors_close0_instantiation() { + assert_eq!(::std::mem::size_of::() , + 1usize , concat ! ( + "Size of template specialization: " , stringify ! ( + root::mozilla::DefaultDelete ) )); + assert_eq!(::std::mem::align_of::() , + 1usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( + root::mozilla::DefaultDelete ) )); + } + #[test] fn __bindgen_test_layout_nsTArray_open0_nsStyleFilter_close0_instantiation() { assert_eq!(::std::mem::size_of::>() , 8usize , concat ! ( @@ -33574,6 +33590,17 @@ pub mod root { root::nsTArray<::nsstring::nsStringRepr> ) )); } #[test] + fn __bindgen_test_layout_nsTString_open0_char16_t_close0_instantiation_2() { + assert_eq!(::std::mem::size_of::<::nsstring::nsStringRepr>() , 16usize , + concat ! ( + "Size of template specialization: " , stringify ! ( + ::nsstring::nsStringRepr ) )); + assert_eq!(::std::mem::align_of::<::nsstring::nsStringRepr>() , 8usize , + concat ! ( + "Alignment of template specialization: " , stringify ! ( + ::nsstring::nsStringRepr ) )); + } + #[test] fn __bindgen_test_layout_nsTArray_open0__bindgen_ty_id_202536_close0_instantiation() { assert_eq!(::std::mem::size_of::>() , 8usize , concat ! ( @@ -34806,6 +34833,17 @@ pub mod root { root::nsTArray<::nsstring::nsStringRepr> ) )); } #[test] + fn __bindgen_test_layout_nsTString_open0_char16_t_close0_instantiation_3() { + assert_eq!(::std::mem::size_of::<::nsstring::nsStringRepr>() , 16usize , + concat ! ( + "Size of template specialization: " , stringify ! ( + ::nsstring::nsStringRepr ) )); + assert_eq!(::std::mem::align_of::<::nsstring::nsStringRepr>() , 8usize , + concat ! ( + "Alignment of template specialization: " , stringify ! ( + ::nsstring::nsStringRepr ) )); + } + #[test] fn __bindgen_test_layout_nsTArray_open0__bindgen_ty_id_213307_close0_instantiation() { assert_eq!(::std::mem::size_of::>() , 8usize , concat ! ( @@ -36704,6 +36742,17 @@ pub mod root { )); } #[test] + fn __bindgen_test_layout_nsTArray_open0_unsigned_int_close0_instantiation_5() { + assert_eq!(::std::mem::size_of::>() + , 8usize , concat ! ( + "Size of template specialization: " , stringify ! ( + root::nsTArray<::std::os::raw::c_uint> ) )); + assert_eq!(::std::mem::align_of::>() + , 8usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( + root::nsTArray<::std::os::raw::c_uint> ) )); + } + #[test] fn __bindgen_test_layout_nsTArray_open0_pair_open1_nsString_nsString_close1_close0_instantiation() { assert_eq!(::std::mem::size_of::>>() diff --git a/components/style/gecko/generated/structs_release.rs b/components/style/gecko/generated/structs_release.rs index dd1e0f487bd3..faf3924a299e 100644 --- a/components/style/gecko/generated/structs_release.rs +++ b/components/style/gecko/generated/structs_release.rs @@ -14131,7 +14131,7 @@ pub mod root { #[repr(C)] #[derive(Debug)] pub struct nsStyleBorder { - pub mBorderColors: *mut *mut root::nsBorderColors, + pub mBorderColors: root::mozilla::UniquePtr, pub mBorderRadius: root::nsStyleCorners, pub mBorderImageSource: root::nsStyleImage, pub mBorderImageSlice: root::nsStyleSides, @@ -30130,29 +30130,6 @@ pub mod root { } #[repr(C)] #[derive(Debug)] - pub struct nsBorderColors { - pub mNext: *mut root::nsBorderColors, - pub mColor: root::nscolor, - } - #[test] - fn bindgen_test_layout_nsBorderColors() { - assert_eq!(::std::mem::size_of::() , 16usize , concat - ! ( "Size of: " , stringify ! ( nsBorderColors ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat - ! ( "Alignment of " , stringify ! ( nsBorderColors ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const nsBorderColors ) ) . mNext as * const - _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( nsBorderColors ) , - "::" , stringify ! ( mNext ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const nsBorderColors ) ) . mColor as * - const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( nsBorderColors ) , - "::" , stringify ! ( mColor ) )); - } - #[repr(C)] - #[derive(Debug)] pub struct nsCSSShadowItem { pub mXOffset: root::nscoord, pub mYOffset: root::nscoord, @@ -30237,6 +30214,23 @@ pub mod root { "Alignment of field: " , stringify ! ( nsCSSShadowArray ) , "::" , stringify ! ( mArray ) )); } + #[repr(C)] + #[derive(Debug)] + pub struct nsBorderColors { + pub mColors: [root::nsTArray<::std::os::raw::c_uint>; 4usize], + } + #[test] + fn bindgen_test_layout_nsBorderColors() { + assert_eq!(::std::mem::size_of::() , 32usize , concat + ! ( "Size of: " , stringify ! ( nsBorderColors ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat + ! ( "Alignment of " , stringify ! ( nsBorderColors ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const nsBorderColors ) ) . mColors as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( nsBorderColors ) , + "::" , stringify ! ( mColors ) )); + } /// An object that allows sharing of arrays that store 'quotes' property /// values. This is particularly important for inheritance, where we want /// to share the same 'quotes' value with a parent style context. @@ -33105,6 +33099,28 @@ pub mod root { root::RefPtr ) )); } #[test] + fn __bindgen_test_layout_UniquePtr_open0_nsBorderColors_DefaultDelete_open1_nsBorderColors_close1_close0_instantiation() { + assert_eq!(::std::mem::size_of::>() + , 8usize , concat ! ( + "Size of template specialization: " , stringify ! ( + root::mozilla::UniquePtr ) )); + assert_eq!(::std::mem::align_of::>() + , 8usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( + root::mozilla::UniquePtr ) )); + } + #[test] + fn __bindgen_test_layout_DefaultDelete_open0_nsBorderColors_close0_instantiation() { + assert_eq!(::std::mem::size_of::() , + 1usize , concat ! ( + "Size of template specialization: " , stringify ! ( + root::mozilla::DefaultDelete ) )); + assert_eq!(::std::mem::align_of::() , + 1usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( + root::mozilla::DefaultDelete ) )); + } + #[test] fn __bindgen_test_layout_nsTArray_open0_nsStyleFilter_close0_instantiation() { assert_eq!(::std::mem::size_of::>() , 8usize , concat ! ( @@ -33160,6 +33176,17 @@ pub mod root { root::nsTArray<::nsstring::nsStringRepr> ) )); } #[test] + fn __bindgen_test_layout_nsTString_open0_char16_t_close0_instantiation_2() { + assert_eq!(::std::mem::size_of::<::nsstring::nsStringRepr>() , 16usize , + concat ! ( + "Size of template specialization: " , stringify ! ( + ::nsstring::nsStringRepr ) )); + assert_eq!(::std::mem::align_of::<::nsstring::nsStringRepr>() , 8usize , + concat ! ( + "Alignment of template specialization: " , stringify ! ( + ::nsstring::nsStringRepr ) )); + } + #[test] fn __bindgen_test_layout_nsTArray_open0__bindgen_ty_id_200130_close0_instantiation() { assert_eq!(::std::mem::size_of::>() , 8usize , concat ! ( @@ -34392,6 +34419,17 @@ pub mod root { root::nsTArray<::nsstring::nsStringRepr> ) )); } #[test] + fn __bindgen_test_layout_nsTString_open0_char16_t_close0_instantiation_3() { + assert_eq!(::std::mem::size_of::<::nsstring::nsStringRepr>() , 16usize , + concat ! ( + "Size of template specialization: " , stringify ! ( + ::nsstring::nsStringRepr ) )); + assert_eq!(::std::mem::align_of::<::nsstring::nsStringRepr>() , 8usize , + concat ! ( + "Alignment of template specialization: " , stringify ! ( + ::nsstring::nsStringRepr ) )); + } + #[test] fn __bindgen_test_layout_nsTArray_open0__bindgen_ty_id_210857_close0_instantiation() { assert_eq!(::std::mem::size_of::>() , 8usize , concat ! ( @@ -36277,6 +36315,17 @@ pub mod root { )); } #[test] + fn __bindgen_test_layout_nsTArray_open0_unsigned_int_close0_instantiation_5() { + assert_eq!(::std::mem::size_of::>() + , 8usize , concat ! ( + "Size of template specialization: " , stringify ! ( + root::nsTArray<::std::os::raw::c_uint> ) )); + assert_eq!(::std::mem::align_of::>() + , 8usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( + root::nsTArray<::std::os::raw::c_uint> ) )); + } + #[test] fn __bindgen_test_layout_nsTArray_open0_pair_open1_nsString_nsString_close1_close0_instantiation() { assert_eq!(::std::mem::size_of::>>() diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 1d8ff1bf08d6..a05a4f7ed7e0 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -1272,6 +1272,50 @@ fn static_assert() { border-image-repeat border-image-width border-image-slice ${skip_moz_border_color_longhands}"> + fn set_moz_border_colors(&mut self, side: structs::Side, v: Option>) { + match v { + None => { + let ptr = self.gecko.mBorderColors.mPtr; + if let Some(colors) = unsafe { ptr.as_mut() } { + unsafe { colors.mColors[side as usize].clear() }; + } + } + Some(ref colors) => { + unsafe { bindings::Gecko_EnsureMozBorderColors(&mut self.gecko) }; + let border_colors = unsafe { self.gecko.mBorderColors.mPtr.as_mut().unwrap() }; + let dest_colors = &mut border_colors.mColors[side as usize]; + unsafe { dest_colors.set_len_pod(colors.len() as u32) }; + for (dst, src) in dest_colors.iter_mut().zip(colors.into_iter()) { + *dst = convert_rgba_to_nscolor(src); + } + } + } + } + + fn copy_moz_border_colors_from(&mut self, other: &Self, side: structs::Side) { + if let Some(dest) = unsafe { self.gecko.mBorderColors.mPtr.as_mut() } { + dest.mColors[side as usize].clear_pod(); + } + if let Some(src) = unsafe { other.gecko.mBorderColors.mPtr.as_ref() } { + let src = &src.mColors[side as usize]; + if !src.is_empty() { + unsafe { bindings::Gecko_EnsureMozBorderColors(&mut self.gecko) }; + let dest = unsafe { self.gecko.mBorderColors.mPtr.as_mut().unwrap() }; + let dest = &mut dest.mColors[side as usize]; + unsafe { dest.set_len_pod(src.len() as u32) }; + dest.copy_from_slice(&src); + } + } + } + + fn clone_moz_border_colors(&self, side: structs::Side) -> Option> { + unsafe { self.gecko.mBorderColors.mPtr.as_ref() }.map(|colors| { + colors.mColors[side as usize].iter() + .map(|color| convert_nscolor_to_rgba(*color)) + .collect() + }) + } + % for side in SIDES: <% impl_keyword("border_%s_style" % side.ident, "mBorderStyle[%s]" % side.index, @@ -1322,37 +1366,12 @@ fn static_assert() { #[allow(non_snake_case)] pub fn set__moz_border_${side.ident}_colors(&mut self, v: longhands::_moz_border_${side.ident}_colors::computed_value::T) { - match v.0 { - None => { - unsafe { - bindings::Gecko_ClearMozBorderColors(&mut self.gecko, - structs::Side::eSide${to_camel_case(side.ident)}); - } - }, - Some(ref colors) => { - unsafe { - bindings::Gecko_EnsureMozBorderColors(&mut self.gecko); - bindings::Gecko_ClearMozBorderColors(&mut self.gecko, - structs::Side::eSide${to_camel_case(side.ident)}); - } - for color in colors { - let c = convert_rgba_to_nscolor(color); - unsafe { - bindings::Gecko_AppendMozBorderColors(&mut self.gecko, - structs::Side::eSide${to_camel_case(side.ident)}, - c); - } - } - } - } + self.set_moz_border_colors(structs::Side::eSide${to_camel_case(side.ident)}, v.0); } #[allow(non_snake_case)] pub fn copy__moz_border_${side.ident}_colors_from(&mut self, other: &Self) { - unsafe { - bindings::Gecko_CopyMozBorderColors(&mut self.gecko, &other.gecko, - structs::Side::eSide${to_camel_case(side.ident)}); - } + self.copy_moz_border_colors_from(other, structs::Side::eSide${to_camel_case(side.ident)}); } #[allow(non_snake_case)] @@ -1364,24 +1383,7 @@ fn static_assert() { 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)) + T(self.clone_moz_border_colors(structs::Side::eSide${to_camel_case(side.ident)})) } % endfor