Bug 1221823 patch 1 - Use rvalue-reference and Move rather than just comments to show behavior of nsCSSKeyframeRule constructor. r=xidorn
authorL. David Baron <dbaron@dbaron.org>
Fri, 20 Nov 2015 22:30:54 -0800
changeset 309658 2d3a04a4d334f383b0a2c2e0a4b3b1540865de7e
parent 309657 de4585e9617cb5b888ebec7296080bc4c33acaa5
child 309659 69f8ba112b5dfb79f954a4d917523a893948edbf
push id1040
push userraliiev@mozilla.com
push dateMon, 29 Feb 2016 17:11:22 +0000
treeherdermozilla-release@8c3167321162 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersxidorn
bugs1221823
milestone45.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 1221823 patch 1 - Use rvalue-reference and Move rather than just comments to show behavior of nsCSSKeyframeRule constructor. r=xidorn
layout/style/nsCSSParser.cpp
layout/style/nsCSSRules.h
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -4274,19 +4274,19 @@ CSSParserImpl::ParseKeyframeRule()
 
   // Ignore !important in keyframe rules
   uint32_t parseFlags = eParseDeclaration_InBraces;
   RefPtr<css::Declaration> declaration(ParseDeclarationBlock(parseFlags));
   if (!declaration) {
     return nullptr;
   }
 
-  // Takes ownership of declaration, and steals contents of selectorList.
+  // Takes ownership of declaration
   RefPtr<nsCSSKeyframeRule> rule =
-    new nsCSSKeyframeRule(selectorList, declaration, linenum, colnum);
+    new nsCSSKeyframeRule(Move(selectorList), declaration, linenum, colnum);
   return rule.forget();
 }
 
 bool
 CSSParserImpl::ParseKeyframeSelectorList(InfallibleTArray<float>& aSelectorList)
 {
   for (;;) {
     if (!GetToken(true)) {
--- a/layout/style/nsCSSRules.h
+++ b/layout/style/nsCSSRules.h
@@ -373,24 +373,24 @@ protected:
   // when it's about to go away.
   nsCSSKeyframeRule* MOZ_NON_OWNING_REF mRule;
 };
 
 class nsCSSKeyframeRule final : public mozilla::css::Rule,
                                 public nsIDOMMozCSSKeyframeRule
 {
 public:
-  // WARNING: Steals the contents of aKeys
-  nsCSSKeyframeRule(InfallibleTArray<float>& aKeys,
+  // Steals the contents of aKeys
+  nsCSSKeyframeRule(InfallibleTArray<float>&& aKeys,
                     mozilla::css::Declaration* aDeclaration,
                     uint32_t aLineNumber, uint32_t aColumnNumber)
     : mozilla::css::Rule(aLineNumber, aColumnNumber)
+    , mKeys(mozilla::Move(aKeys))
     , mDeclaration(aDeclaration)
   {
-    mKeys.SwapElements(aKeys);
     mDeclaration->SetOwningRule(this);
   }
 private:
   nsCSSKeyframeRule(const nsCSSKeyframeRule& aCopy);
   ~nsCSSKeyframeRule();
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsCSSKeyframeRule, mozilla::css::Rule)