From 2ae317f5261fe90d6a5d62e5766771a1c095d848 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Sun, 12 Mar 2017 21:11:52 -0700 Subject: [PATCH] stylo: Support counter-increment and counter-reset MozReview-Commit-ID: DnSd8xAkidM --- components/style/gecko_bindings/bindings.rs | 16 ++++++++++++++ components/style/properties/gecko.mako.rs | 21 ++++++++++++++++++- .../properties/longhand/counters.mako.rs | 4 ++-- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index 897f5236708..832bd3b7ae4 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -717,10 +717,26 @@ extern "C" { pub fn Gecko_ClearAndResizeStyleContents(content: *mut nsStyleContent, how_many: u32); } +extern "C" { + pub fn Gecko_ClearAndResizeCounterIncrements(content: *mut nsStyleContent, + how_many: u32); +} +extern "C" { + pub fn Gecko_ClearAndResizeCounterResets(content: *mut nsStyleContent, + how_many: u32); +} extern "C" { pub fn Gecko_CopyStyleContentsFrom(content: *mut nsStyleContent, other: *const nsStyleContent); } +extern "C" { + pub fn Gecko_CopyCounterResetsFrom(content: *mut nsStyleContent, + other: *const nsStyleContent); +} +extern "C" { + pub fn Gecko_CopyCounterIncrementsFrom(content: *mut nsStyleContent, + other: *const nsStyleContent); +} extern "C" { pub fn Gecko_EnsureImageLayersLength(layers: *mut nsStyleImageLayers, len: usize, diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 65af844c8c0..8d6ceeeb59c 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -3186,7 +3186,7 @@ clip-path <%self:impl_trait style_struct_name="Counters" - skip_longhands="content"> + skip_longhands="content counter-increment counter-reset"> pub fn set_content(&mut self, v: longhands::content::computed_value::T) { use properties::longhands::content::computed_value::T; use properties::longhands::content::computed_value::ContentItem; @@ -3294,6 +3294,25 @@ clip-path Gecko_CopyStyleContentsFrom(&mut self.gecko, &other.gecko) } } + + % for counter_property in ["Increment", "Reset"]: + pub fn set_counter_${counter_property.lower()}(&mut self, v: longhands::counter_increment::computed_value::T) { + unsafe { + bindings::Gecko_ClearAndResizeCounter${counter_property}s(&mut self.gecko, + v.0.len() as u32); + for (i, item) in v.0.into_iter().enumerate() { + self.gecko.m${counter_property}s[i].mCounter.assign_utf8(&item.0); + self.gecko.m${counter_property}s[i].mValue = item.1; + } + } + } + + pub fn copy_counter_${counter_property.lower()}_from(&mut self, other: &Self) { + unsafe { + bindings::Gecko_CopyCounter${counter_property}sFrom(&mut self.gecko, &other.gecko) + } + } + % endfor <%self:impl_trait style_struct_name="XUL" diff --git a/components/style/properties/longhand/counters.mako.rs b/components/style/properties/longhand/counters.mako.rs index ec75f431bcc..8eec5fbb8b2 100644 --- a/components/style/properties/longhand/counters.mako.rs +++ b/components/style/properties/longhand/counters.mako.rs @@ -239,7 +239,7 @@ } -<%helpers:longhand name="counter-increment" products="servo" animatable="False" +<%helpers:longhand name="counter-increment" animatable="False" spec="https://drafts.csswg.org/css-lists/#propdef-counter-increment"> use std::fmt; use style_traits::ToCss; @@ -313,7 +313,7 @@ } -<%helpers:longhand name="counter-reset" products="servo" animatable="False" +<%helpers:longhand name="counter-reset" animatable="False" spec="https://drafts.csswg.org/css-lists-3/#propdef-counter-reset"> pub use super::counter_increment::{SpecifiedValue, computed_value, get_initial_value}; use super::counter_increment::{parse_common};