Bug 1366247 - Add sugar for already_AddRefed and use it for conversion between Atom and nsIAtom pointer. r?Manishearth
MozReview-Commit-ID: HeV5UsqGcWs
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -148,19 +148,19 @@ SERVO_BINDING_FUNC(Servo_Keyframe_SetKey
RawServoKeyframeBorrowed keyframe, const nsACString* text)
SERVO_BINDING_FUNC(Servo_Keyframe_GetStyle, RawServoDeclarationBlockStrong,
RawServoKeyframeBorrowed keyframe)
SERVO_BINDING_FUNC(Servo_Keyframe_SetStyle, void,
RawServoKeyframeBorrowed keyframe,
RawServoDeclarationBlockBorrowed declarations)
SERVO_BINDING_FUNC(Servo_KeyframesRule_GetName, nsIAtom*,
RawServoKeyframesRuleBorrowed rule)
-// This method takes an addrefed nsIAtom.
SERVO_BINDING_FUNC(Servo_KeyframesRule_SetName, void,
- RawServoKeyframesRuleBorrowed rule, nsIAtom* name)
+ RawServoKeyframesRuleBorrowed rule,
+ already_AddRefed<nsIAtom> name)
SERVO_BINDING_FUNC(Servo_KeyframesRule_GetCount, uint32_t,
RawServoKeyframesRuleBorrowed rule)
SERVO_BINDING_FUNC(Servo_KeyframesRule_GetKeyframe, RawServoKeyframeStrong,
RawServoKeyframesRuleBorrowed rule, uint32_t index)
// Returns the index of the rule, max value of uint32_t if nothing found.
SERVO_BINDING_FUNC(Servo_KeyframesRule_FindRule, uint32_t,
RawServoKeyframesRuleBorrowed rule, const nsACString* key)
// Returns whether it successfully appends the rule.
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -1825,19 +1825,20 @@ Gecko_CSSValue_SetString(nsCSSValueBorro
void
Gecko_CSSValue_SetStringFromAtom(nsCSSValueBorrowedMut aCSSValue,
nsIAtom* aAtom, nsCSSUnit aUnit)
{
aCSSValue->SetStringValue(nsDependentAtomString(aAtom), aUnit);
}
void
-Gecko_CSSValue_SetAtomIdent(nsCSSValueBorrowedMut aCSSValue, nsIAtom* aAtom)
+Gecko_CSSValue_SetAtomIdent(nsCSSValueBorrowedMut aCSSValue,
+ already_AddRefed<nsIAtom> aAtom)
{
- aCSSValue->SetAtomIdentValue(already_AddRefed<nsIAtom>(aAtom));
+ aCSSValue->SetAtomIdentValue(Move(aAtom));
}
void
Gecko_CSSValue_SetArray(nsCSSValueBorrowedMut aCSSValue, int32_t aLength)
{
MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Null);
RefPtr<nsCSSValue::Array> array
= nsCSSValue::Array::Create(aLength);
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -469,18 +469,17 @@ void Gecko_CSSValue_SetNumber(nsCSSValue
void Gecko_CSSValue_SetKeyword(nsCSSValueBorrowedMut css_value, nsCSSKeyword keyword);
void Gecko_CSSValue_SetPercentage(nsCSSValueBorrowedMut css_value, float percent);
void Gecko_CSSValue_SetCalc(nsCSSValueBorrowedMut css_value, nsStyleCoord::CalcValue calc);
void Gecko_CSSValue_SetFunction(nsCSSValueBorrowedMut css_value, int32_t len);
void Gecko_CSSValue_SetString(nsCSSValueBorrowedMut css_value,
const uint8_t* string, uint32_t len, nsCSSUnit unit);
void Gecko_CSSValue_SetStringFromAtom(nsCSSValueBorrowedMut css_value,
nsIAtom* atom, nsCSSUnit unit);
-// Take an addrefed nsIAtom and set it to the nsCSSValue
-void Gecko_CSSValue_SetAtomIdent(nsCSSValueBorrowedMut css_value, nsIAtom* atom);
+void Gecko_CSSValue_SetAtomIdent(nsCSSValueBorrowedMut css_value, already_AddRefed<nsIAtom> atom);
void Gecko_CSSValue_SetArray(nsCSSValueBorrowedMut css_value, int32_t len);
void Gecko_CSSValue_SetURL(nsCSSValueBorrowedMut css_value, ServoBundledURI uri);
void Gecko_CSSValue_SetInt(nsCSSValueBorrowedMut css_value, int32_t integer, nsCSSUnit unit);
void Gecko_CSSValue_SetPair(nsCSSValueBorrowedMut css_value,
nsCSSValueBorrowed xvalue, nsCSSValueBorrowed yvalue);
void Gecko_CSSValue_SetList(nsCSSValueBorrowedMut css_value, uint32_t len);
void Gecko_CSSValue_SetPairList(nsCSSValueBorrowedMut css_value, uint32_t len);
void Gecko_CSSValue_Drop(nsCSSValueBorrowedMut css_value);
--- a/layout/style/ServoBindings.toml
+++ b/layout/style/ServoBindings.toml
@@ -298,26 +298,26 @@ fixups = [
[bindings]
headers = ["mozilla/ServoBindings.h"]
hide-types = [
"nsACString_internal",
"nsAString_internal",
]
raw-lines = [
"pub use nsstring::{nsACString, nsAString, nsString, nsStringRepr};",
- "use gecko_bindings::structs::nsTArray;",
"type nsACString_internal = nsACString;",
"type nsAString_internal = nsAString;",
]
whitelist-functions = ["Servo_.*", "Gecko_.*"]
structs-types = [
"mozilla::css::GridTemplateAreasValue",
"mozilla::css::ImageValue",
"mozilla::css::URLValue",
"mozilla::Side",
+ "already_AddRefed",
"RawGeckoAnimationPropertySegment",
"RawGeckoComputedTiming",
"RawGeckoDocument",
"RawGeckoElement",
"RawGeckoKeyframeList",
"RawGeckoComputedKeyframeValuesList",
"RawGeckoFontFaceRuleList",
"RawGeckoNode",
@@ -402,16 +402,17 @@ structs-types = [
"nsStyleTextReset",
"nsStyleUIReset",
"nsStyleUnion",
"nsStyleUnit",
"nsStyleUserInterface",
"nsStyleVariables",
"nsStyleVisibility",
"nsStyleXUL",
+ "nsTArray",
"nsTimingFunction",
"nscolor",
"nscoord",
"nsresult",
"Loader",
"ServoStyleSheet",
"EffectCompositor_CascadeLevel",
"UpdateAnimationsTasks",
--- a/layout/style/ServoKeyframesRule.cpp
+++ b/layout/style/ServoKeyframesRule.cpp
@@ -256,17 +256,17 @@ ServoKeyframesRule::SetName(const nsAStr
{
nsCOMPtr<nsIAtom> name = NS_Atomize(aName);
nsIAtom* oldName = Servo_KeyframesRule_GetName(mRawRule);
if (name == oldName) {
return NS_OK;
}
UpdateRule([this, &name]() {
- Servo_KeyframesRule_SetName(mRawRule, name.forget().take());
+ Servo_KeyframesRule_SetName(mRawRule, name.forget());
});
return NS_OK;
}
NS_IMETHODIMP
ServoKeyframesRule::AppendRule(const nsAString& aRule)
{
StyleSheet* sheet = GetStyleSheet();