Auto merge of #12906 - servo:ffiless, r=emilio

Remove some use of FFI in gecko_string_cache

Now that nsIAtom’s mLength and mString can both be accessed directly on the struct, fewer operations need to call into C++ code.

These functions are not used anymore and can be removed from the Gecko side:

* `Gecko_GetAtomAsUTF16`
* `Gecko_AtomEqualsUTF8IgnoreCase`
* `Gecko_AtomEqualsUTF8` (looks like this one was already unused before this PR)

r? @emilio

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not new require tests because no behavior change

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12906)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-08-17 20:44:42 -05:00 committed by GitHub
commit 18390dbd48

View file

@ -10,15 +10,14 @@ extern crate selectors;
extern crate serde;
use gecko_bindings::bindings::Gecko_AddRefAtom;
use gecko_bindings::bindings::Gecko_AtomEqualsUTF8IgnoreCase;
use gecko_bindings::bindings::Gecko_Atomize;
use gecko_bindings::bindings::Gecko_GetAtomAsUTF16;
use gecko_bindings::bindings::Gecko_ReleaseAtom;
use gecko_bindings::structs::nsIAtom;
use heapsize::HeapSizeOf;
use selectors::bloom::BloomHash;
use selectors::parser::FromCowStr;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::ascii::AsciiExt;
use std::borrow::{Cow, Borrow};
use std::char::{self, DecodeUtf16};
use std::fmt;
@ -96,9 +95,7 @@ impl WeakAtom {
pub fn as_slice(&self) -> &[u16] {
unsafe {
let mut len = 0;
let ptr = Gecko_GetAtomAsUTF16(self.as_ptr(), &mut len);
slice::from_raw_parts(ptr, len as usize)
slice::from_raw_parts((*self.as_ptr()).mString, self.len() as usize)
}
}
@ -118,9 +115,10 @@ impl WeakAtom {
#[inline]
pub fn eq_str_ignore_ascii_case(&self, s: &str) -> bool {
unsafe {
Gecko_AtomEqualsUTF8IgnoreCase(self.as_ptr(), s.as_ptr() as *const _, s.len() as u32)
}
self.chars().map(|r| match r {
Ok(c) => c.to_ascii_lowercase() as u32,
Err(e) => e.unpaired_surrogate() as u32,
}).eq(s.chars().map(|c| c.to_ascii_lowercase() as u32))
}
#[inline]