Title: [179131] trunk/Source/WebCore
Revision
179131
Author
cdu...@apple.com
Date
2015-01-26 12:04:38 -0800 (Mon, 26 Jan 2015)

Log Message

Use std::forward() instead of WTF::move() in CSSPrimitiveValue::create(T&& value)
https://bugs.webkit.org/show_bug.cgi?id=140891

Reviewed by Anders Carlsson.

Use std::forward() instead of WTF::move() in CSSPrimitiveValue::create(T&& value)
to make sure the argument is not unexpectedly moved when it shouldn't (like I
experienced yesterday in Bug 140577):
<http://trac.webkit.org/changeset/179105>

* css/CSSPrimitiveValue.h:
(WebCore::CSSPrimitiveValue::create):
* css/CSSValuePool.h:
(WebCore::CSSValuePool::createValue):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (179130 => 179131)


--- trunk/Source/WebCore/ChangeLog	2015-01-26 19:45:48 UTC (rev 179130)
+++ trunk/Source/WebCore/ChangeLog	2015-01-26 20:04:38 UTC (rev 179131)
@@ -1,3 +1,20 @@
+2015-01-26  Chris Dumez  <cdu...@apple.com>
+
+        Use std::forward() instead of WTF::move() in CSSPrimitiveValue::create(T&& value)
+        https://bugs.webkit.org/show_bug.cgi?id=140891
+
+        Reviewed by Anders Carlsson.
+
+        Use std::forward() instead of WTF::move() in CSSPrimitiveValue::create(T&& value)
+        to make sure the argument is not unexpectedly moved when it shouldn't (like I
+        experienced yesterday in Bug 140577):
+        <http://trac.webkit.org/changeset/179105>
+
+        * css/CSSPrimitiveValue.h:
+        (WebCore::CSSPrimitiveValue::create):
+        * css/CSSValuePool.h:
+        (WebCore::CSSValuePool::createValue):
+
 2015-01-26  Beth Dakin  <bda...@apple.com>
 
         Blacklist iBooks for WebKit's default immediate actions

Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.h (179130 => 179131)


--- trunk/Source/WebCore/css/CSSPrimitiveValue.h	2015-01-26 19:45:48 UTC (rev 179130)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.h	2015-01-26 20:04:38 UTC (rev 179131)
@@ -27,6 +27,7 @@
 #include "CSSValueKeywords.h"
 #include "Color.h"
 #include "LayoutUnit.h"
+#include <utility>
 #include <wtf/Forward.h>
 #include <wtf/MathExtras.h>
 #include <wtf/PassRefPtr.h>
@@ -236,14 +237,9 @@
     static Ref<CSSPrimitiveValue> create(const Length& value, const RenderStyle* style) { return adoptRef(*new CSSPrimitiveValue(value, style)); }
     static Ref<CSSPrimitiveValue> create(const LengthSize& value, const RenderStyle* style) { return adoptRef(*new CSSPrimitiveValue(value, style)); }
 
-    template<typename T> static Ref<CSSPrimitiveValue> create(const T& value)
-    {
-        return adoptRef(*new CSSPrimitiveValue(value));
-    }
-
     template<typename T> static Ref<CSSPrimitiveValue> create(T&& value)
     {
-        return adoptRef(*new CSSPrimitiveValue(WTF::move(value)));
+        return adoptRef(*new CSSPrimitiveValue(std::forward<T>(value)));
     }
 
     // This value is used to handle quirky margins in reflow roots (body, td, and th) like WinIE.

Modified: trunk/Source/WebCore/css/CSSValuePool.h (179130 => 179131)


--- trunk/Source/WebCore/css/CSSValuePool.h	2015-01-26 19:45:48 UTC (rev 179130)
+++ trunk/Source/WebCore/css/CSSValuePool.h	2015-01-26 20:04:38 UTC (rev 179131)
@@ -32,6 +32,7 @@
 #include "CSSPrimitiveValue.h"
 #include "CSSPropertyNames.h"
 #include "CSSValueKeywords.h"
+#include <utility>
 #include <wtf/HashMap.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/RefPtr.h>
@@ -56,7 +57,7 @@
     Ref<CSSPrimitiveValue> createValue(const String& value, CSSPrimitiveValue::UnitTypes type) { return CSSPrimitiveValue::create(value, type); }
     Ref<CSSPrimitiveValue> createValue(const Length& value, const RenderStyle* style) { return CSSPrimitiveValue::create(value, style); }
     Ref<CSSPrimitiveValue> createValue(const LengthSize& value, const RenderStyle* style) { return CSSPrimitiveValue::create(value, style); }
-    template<typename T> static Ref<CSSPrimitiveValue> createValue(T value) { return CSSPrimitiveValue::create(value); }
+    template<typename T> static Ref<CSSPrimitiveValue> createValue(T&& value) { return CSSPrimitiveValue::create(std::forward<T>(value)); }
 
     void drain();
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to