Auto merge of #16976 - upsuper:bug1366247, r=nox

Add sugar for already_AddRefed

This is Servo side change of [bug 1366247](https://bugzilla.mozilla.org/show_bug.cgi?id=1366247).

<!-- 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/16976)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-05-21 05:28:58 -05:00 committed by GitHub
commit 3d40b516c8
7 changed files with 79 additions and 28 deletions

View file

@ -1,13 +1,13 @@
/* automatically generated by rust-bindgen */
pub use nsstring::{nsACString, nsAString, nsString, nsStringRepr};
use gecko_bindings::structs::nsTArray;
type nsACString_internal = nsACString;
type nsAString_internal = nsAString;
use gecko_bindings::structs::mozilla::css::GridTemplateAreasValue;
use gecko_bindings::structs::mozilla::css::ImageValue;
use gecko_bindings::structs::mozilla::css::URLValue;
use gecko_bindings::structs::mozilla::Side;
use gecko_bindings::structs::already_AddRefed;
use gecko_bindings::structs::RawGeckoAnimationPropertySegment;
use gecko_bindings::structs::RawGeckoComputedTiming;
use gecko_bindings::structs::RawGeckoCSSPropertyIDList;
@ -190,6 +190,7 @@ unsafe impl Sync for nsStyleVisibility {}
use gecko_bindings::structs::nsStyleXUL;
unsafe impl Send for nsStyleXUL {}
unsafe impl Sync for nsStyleXUL {}
use gecko_bindings::structs::nsTArray;
use gecko_bindings::structs::nsTimingFunction;
use gecko_bindings::structs::nscolor;
use gecko_bindings::structs::nscoord;
@ -1237,7 +1238,7 @@ extern "C" {
}
extern "C" {
pub fn Gecko_CSSValue_SetAtomIdent(css_value: nsCSSValueBorrowedMut,
atom: *mut nsIAtom);
atom: already_AddRefed<nsIAtom>);
}
extern "C" {
pub fn Gecko_CSSValue_SetArray(css_value: nsCSSValueBorrowedMut,
@ -1981,7 +1982,7 @@ extern "C" {
}
extern "C" {
pub fn Servo_KeyframesRule_SetName(rule: RawServoKeyframesRuleBorrowed,
name: *mut nsIAtom);
name: already_AddRefed<nsIAtom>);
}
extern "C" {
pub fn Servo_KeyframesRule_GetCount(rule: RawServoKeyframesRuleBorrowed)

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));