diff options
Diffstat (limited to 'components')
-rw-r--r-- | components/selectors/parser.rs | 27 | ||||
-rw-r--r-- | components/style/gecko/generated/bindings.rs | 10 |
2 files changed, 28 insertions, 9 deletions
diff --git a/components/selectors/parser.rs b/components/selectors/parser.rs index c613d741eb6..92ba8c17601 100644 --- a/components/selectors/parser.rs +++ b/components/selectors/parser.rs @@ -167,6 +167,23 @@ impl<Impl: SelectorImpl> SelectorList<Impl> { pub fn from_vec(v: Vec<Selector<Impl>>) -> Self { SelectorList(v.into_iter().map(SelectorAndHashes::new).collect()) } + + pub fn to_css_from_index<W>(&self, from_index: usize, dest: &mut W) + -> fmt::Result where W: fmt::Write { + let mut iter = self.0.iter().skip(from_index); + + let first = match iter.next() { + Some(f) => f, + None => return Ok(()), + }; + + first.selector.to_css(dest)?; + for selector_and_hashes in iter { + dest.write_str(", ")?; + selector_and_hashes.selector.to_css(dest)?; + } + Ok(()) + } } /// Copied from Gecko, who copied it from WebKit. Note that increasing the @@ -638,15 +655,7 @@ impl<Impl: SelectorImpl> Debug for LocalName<Impl> { impl<Impl: SelectorImpl> ToCss for SelectorList<Impl> { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { - let mut iter = self.0.iter(); - let first = iter.next() - .expect("Empty SelectorList, should contain at least one selector"); - first.selector.to_css(dest)?; - for selector_and_hashes in iter { - dest.write_str(", ")?; - selector_and_hashes.selector.to_css(dest)?; - } - Ok(()) + self.to_css_from_index(/* from_index = */ 0, dest) } } diff --git a/components/style/gecko/generated/bindings.rs b/components/style/gecko/generated/bindings.rs index 7054148ba70..3eed899e538 100644 --- a/components/style/gecko/generated/bindings.rs +++ b/components/style/gecko/generated/bindings.rs @@ -2051,6 +2051,16 @@ extern "C" { result: *mut nsAString); } extern "C" { + pub fn Servo_StyleRule_GetSelectorTextFromIndex(rule: + RawServoStyleRuleBorrowed, + index: u32, + result: *mut nsAString); +} +extern "C" { + pub fn Servo_StyleRule_GetSelectorCount(rule: RawServoStyleRuleBorrowed, + count: *mut u32); +} +extern "C" { pub fn Servo_ImportRule_GetHref(rule: RawServoImportRuleBorrowed, result: *mut nsAString); } |