Add sugar for already_AddRefed and use it for conversion between Atom and nsIAtom pointer.

This commit is contained in:
Xidorn Quan 2017-05-21 13:06:31 +10:00
parent 1602edb04a
commit 2b1f7f6081
6 changed files with 75 additions and 25 deletions

View file

@ -54,6 +54,7 @@ use gecko_bindings::structs::ELEMENT_HAS_SNAPSHOT;
use gecko_bindings::structs::EffectCompositor_CascadeLevel as CascadeLevel;
use gecko_bindings::structs::NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE;
use gecko_bindings::structs::NODE_IS_NATIVE_ANONYMOUS;
use gecko_bindings::structs::already_AddRefed;
use gecko_bindings::sugar::ownership::HasArcFFI;
use logical_geometry::WritingMode;
use media_queries::Device;
@ -1074,13 +1075,13 @@ impl<'le> PresentationalHintsSynthesizer for GeckoElement<'le> {
//
// http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#language
let ptr = unsafe {
bindings::Gecko_GetXMLLangValue(self.0)
already_AddRefed::new(bindings::Gecko_GetXMLLangValue(self.0))
};
if !ptr.is_null() {
if let Some(ptr) = ptr {
let global_style_data = &*GLOBAL_STYLE_DATA;
let pdb = PropertyDeclarationBlock::with_one(
PropertyDeclaration::XLang(SpecifiedLang(unsafe { Atom::from_addrefed(ptr) })),
PropertyDeclaration::XLang(SpecifiedLang(ptr.into())),
Importance::Normal
);
let arc = Arc::new(global_style_data.shared_lock.wrap(pdb));