diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index f076c9a5905..0676df08c57 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -1178,6 +1178,24 @@ fn static_assert() { } } + + pub fn fill_arrays(&mut self) { + use gecko_bindings::bindings::Gecko_FillAllBackgroundLists; + use std::cmp; + let mut max_len = 1; + % for member in "mRepeat mClip mOrigin mAttachment mPositionX mPositionY mImage".split(): + max_len = cmp::max(max_len, self.gecko.mImage.${member}Count); + % endfor + + // XXXManishearth Gecko does an optimization here where it only + // fills things in if any of the properties have been set + + unsafe { + // While we could do this manually, we'd need to also manually + // run all the copy constructors, so we just delegate to gecko + Gecko_FillAllBackgroundLists(&mut self.gecko.mImage, max_len); + } + } <%self:impl_trait style_struct_name="List" skip_longhands="list-style-type" skip_additionals="*"> diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index a61f69483ac..1c3c87501e3 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -2034,6 +2034,10 @@ pub fn cascade(viewport_size: Size2D, } % endfor + % if product == "gecko": + style.mutate_background().fill_arrays(); + % endif + // The initial value of outline width may be changed at computed value time. if style.get_outline().clone_outline_style().none_or_hidden() && style.get_outline().outline_has_nonzero_width() { diff --git a/ports/geckolib/gecko_bindings/bindings.rs b/ports/geckolib/gecko_bindings/bindings.rs index 82732911007..56c794be08a 100644 --- a/ports/geckolib/gecko_bindings/bindings.rs +++ b/ports/geckolib/gecko_bindings/bindings.rs @@ -333,6 +333,8 @@ extern "C" { pub fn Gecko_DestroyClipPath(clip: *mut StyleClipPath); pub fn Gecko_NewBasicShape(type_: StyleBasicShapeType) -> *mut StyleBasicShape; + pub fn Gecko_FillAllBackgroundLists(layers: *mut nsStyleImageLayers, + maxLen: u32); pub fn Gecko_AddRefCalcArbitraryThread(aPtr: *mut Calc); pub fn Gecko_ReleaseCalcArbitraryThread(aPtr: *mut Calc); pub fn Gecko_Construct_nsStyleFont(ptr: *mut nsStyleFont);