Bug 1366247 - Add sugar for already_AddRefed and use it for conversion between Atom and nsIAtom pointer. r=manishearth
☠☠ backed out by b5d15ecde93a ☠ ☠
authorXidorn Quan <me@upsuper.org>
Fri, 19 May 2017 23:24:31 +1000
changeset 407942 dd3a293cf053608b7f8a6f5f72ae0a6eb5b66225
parent 407941 f5d0213a9d16f3b45fe51c4c1c5ed93c40a91eb2
child 407943 f76dd202aa3844bab4a42b3b7a23f80b79e64136
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmanishearth
bugs1366247
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1366247 - Add sugar for already_AddRefed and use it for conversion between Atom and nsIAtom pointer. r=manishearth MozReview-Commit-ID: HeV5UsqGcWs
layout/style/ServoBindingList.h
layout/style/ServoBindings.cpp
layout/style/ServoBindings.h
layout/style/ServoBindings.toml
layout/style/ServoKeyframesRule.cpp
--- 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
@@ -1844,19 +1844,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
@@ -471,18 +471,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
@@ -299,26 +299,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",
     "RawGeckoCSSPropertyIDList",
     "RawGeckoDocument",
     "RawGeckoElement",
     "RawGeckoKeyframeList",
     "RawGeckoComputedKeyframeValuesList",
     "RawGeckoFontFaceRuleList",
@@ -405,16 +405,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();