зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #17210 - Bug 1367615 - Stylo: implement inIDOMUtils.getSelectorCount and inIDO… (from ferjm:bug1367615.inDOMUtils); r=emilio
…MUtils.getSelectorTextFromIndex https://bugzilla.mozilla.org/show_bug.cgi?id=1367615 Source-Repo: https://github.com/servo/servo Source-Revision: cb281af463e2f6a30f4f65db0dd614b07570c356 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 977320d2aa7fe67bf54306e42d63d09b7f33ae91
This commit is contained in:
Родитель
963eaf95ea
Коммит
1a6d9324fd
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2050,6 +2050,16 @@ extern "C" {
|
|||
pub fn Servo_StyleRule_GetSelectorText(rule: RawServoStyleRuleBorrowed,
|
||||
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);
|
||||
|
|
|
@ -1156,6 +1156,25 @@ pub extern "C" fn Servo_StyleRule_GetSelectorText(rule: RawServoStyleRuleBorrowe
|
|||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_StyleRule_GetSelectorTextFromIndex(rule: RawServoStyleRuleBorrowed,
|
||||
aSelectorIndex: u32,
|
||||
result: *mut nsAString) {
|
||||
read_locked_arc(rule, |rule: &StyleRule| {
|
||||
rule.selectors.to_css_from_index(
|
||||
aSelectorIndex as usize,
|
||||
unsafe { result.as_mut().unwrap() }
|
||||
).unwrap();
|
||||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_StyleRule_GetSelectorCount(rule: RawServoStyleRuleBorrowed, count: *mut u32) {
|
||||
read_locked_arc(rule, |rule: &StyleRule| {
|
||||
*unsafe { count.as_mut().unwrap() } = rule.selectors.0.len() as u32;
|
||||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ImportRule_GetHref(rule: RawServoImportRuleBorrowed, result: *mut nsAString) {
|
||||
read_locked_arc(rule, |rule: &ImportRule| {
|
||||
|
|
Загрузка…
Ссылка в новой задаче