Auto merge of #11043 - heycam:attr, r=bholley

Pass in string lengths to Gecko_GetAttrAsUTF8.

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11043)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-05-05 23:51:54 -07:00
commit 0558687d71
2 changed files with 5 additions and 3 deletions

View file

@ -106,8 +106,8 @@ extern "C" {
-> *mut ServoComputedValues;
pub fn Servo_AddRefComputedValues(arg1: *mut ServoComputedValues);
pub fn Servo_ReleaseComputedValues(arg1: *mut ServoComputedValues);
pub fn Gecko_GetAttrAsUTF8(element: *mut RawGeckoElement, ns: *const u8,
name: *const u8, length: *mut u32)
pub fn Gecko_GetAttrAsUTF8(element: *mut RawGeckoElement, ns: *const u8, nslen: u32,
name: *const u8, namelen: u32, length: *mut u32)
-> *const ::std::os::raw::c_char;
pub fn Gecko_GetAtomAsUTF16(atom: *mut nsIAtom, length: *mut u32)
-> *const u16;

View file

@ -344,7 +344,9 @@ impl<'le> TElement for GeckoElement<'le> {
fn get_attr<'a>(&'a self, namespace: &Namespace, name: &Atom) -> Option<&'a str> {
unsafe {
let mut length: u32 = 0;
let ptr = Gecko_GetAttrAsUTF8(self.element, namespace.0.as_ptr(), name.as_ptr(), &mut length);
let ptr = Gecko_GetAttrAsUTF8(self.element,
namespace.0.as_ptr(), namespace.0.len() as u32,
name.as_ptr(), name.len() as u32, &mut length);
reinterpret_string(ptr, length)
}
}