Title: [120791] trunk/Source/WebCore
Revision
120791
Author
[email protected]
Date
2012-06-19 20:27:27 -0700 (Tue, 19 Jun 2012)

Log Message

Pass ScriptValue by const ref where possible
https://bugs.webkit.org/show_bug.cgi?id=89531

Reviewed by Kentaro Hara.

Previously ScriptValue was sometimes passed by value, sometimes by const ref.

For consistency and optimality, pass by const ref everywhere (except where
ScriptValue is returned from non-accessor methods).

No new tests, no change in behavior.

* bindings/js/ScriptFunctionCall.h:
(ScriptCallback):
* bindings/js/ScriptProfiler.cpp:
(WebCore::ScriptProfiler::getHeapObjectId):
* bindings/js/ScriptProfiler.h:
(ScriptProfiler):
* bindings/js/WorkerScriptController.cpp:
(WebCore::WorkerScriptController::setException):
* bindings/js/WorkerScriptController.h:
(WorkerScriptController):
* bindings/v8/ScriptFunctionCall.cpp:
(WebCore::ScriptCallback::ScriptCallback):
* bindings/v8/ScriptFunctionCall.h:
(ScriptCallback):
* bindings/v8/ScriptProfiler.cpp:
(WebCore::ScriptProfiler::getHeapObjectId):
(WebCore):
* bindings/v8/ScriptProfiler.h:
(ScriptProfiler):
* bindings/v8/ScriptValue.h:
(WebCore::ScriptValue::operator==):
(WebCore::ScriptValue::operator!=):
* bindings/v8/WorkerScriptController.cpp:
(WebCore::WorkerScriptController::setException):
* bindings/v8/WorkerScriptController.h:
(WorkerScriptController):
* css/MediaQueryListListener.h:
(WebCore::MediaQueryListListener::create):
(WebCore::MediaQueryListListener::MediaQueryListListener):
* dom/CustomEvent.cpp:
(WebCore::CustomEvent::initCustomEvent):
* dom/CustomEvent.h:
(CustomEvent):
(WebCore::CustomEvent::detail):
* dom/MessageEvent.h:
(WebCore::MessageEvent::dataAsScriptValue):
* dom/PopStateEvent.h:
(WebCore::PopStateEvent::state):
* inspector/InjectedScript.cpp:
(WebCore::InjectedScript::wrapObject):
* inspector/InjectedScript.h:
(InjectedScript):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (120790 => 120791)


--- trunk/Source/WebCore/ChangeLog	2012-06-20 02:25:14 UTC (rev 120790)
+++ trunk/Source/WebCore/ChangeLog	2012-06-20 03:27:27 UTC (rev 120791)
@@ -1,3 +1,60 @@
+2012-06-19  Adam Klein  <[email protected]>
+
+        Pass ScriptValue by const ref where possible
+        https://bugs.webkit.org/show_bug.cgi?id=89531
+
+        Reviewed by Kentaro Hara.
+
+        Previously ScriptValue was sometimes passed by value, sometimes by const ref.
+
+        For consistency and optimality, pass by const ref everywhere (except where
+        ScriptValue is returned from non-accessor methods).
+
+        No new tests, no change in behavior.
+
+        * bindings/js/ScriptFunctionCall.h:
+        (ScriptCallback):
+        * bindings/js/ScriptProfiler.cpp:
+        (WebCore::ScriptProfiler::getHeapObjectId):
+        * bindings/js/ScriptProfiler.h:
+        (ScriptProfiler):
+        * bindings/js/WorkerScriptController.cpp:
+        (WebCore::WorkerScriptController::setException):
+        * bindings/js/WorkerScriptController.h:
+        (WorkerScriptController):
+        * bindings/v8/ScriptFunctionCall.cpp:
+        (WebCore::ScriptCallback::ScriptCallback):
+        * bindings/v8/ScriptFunctionCall.h:
+        (ScriptCallback):
+        * bindings/v8/ScriptProfiler.cpp:
+        (WebCore::ScriptProfiler::getHeapObjectId):
+        (WebCore):
+        * bindings/v8/ScriptProfiler.h:
+        (ScriptProfiler):
+        * bindings/v8/ScriptValue.h:
+        (WebCore::ScriptValue::operator==):
+        (WebCore::ScriptValue::operator!=):
+        * bindings/v8/WorkerScriptController.cpp:
+        (WebCore::WorkerScriptController::setException):
+        * bindings/v8/WorkerScriptController.h:
+        (WorkerScriptController):
+        * css/MediaQueryListListener.h:
+        (WebCore::MediaQueryListListener::create):
+        (WebCore::MediaQueryListListener::MediaQueryListListener):
+        * dom/CustomEvent.cpp:
+        (WebCore::CustomEvent::initCustomEvent):
+        * dom/CustomEvent.h:
+        (CustomEvent):
+        (WebCore::CustomEvent::detail):
+        * dom/MessageEvent.h:
+        (WebCore::MessageEvent::dataAsScriptValue):
+        * dom/PopStateEvent.h:
+        (WebCore::PopStateEvent::state):
+        * inspector/InjectedScript.cpp:
+        (WebCore::InjectedScript::wrapObject):
+        * inspector/InjectedScript.h:
+        (InjectedScript):
+
 2012-06-18  Philippe Normand  <[email protected]>
 
         [GStreamer] 0.11 video-sink

Modified: trunk/Source/WebCore/bindings/js/ScriptFunctionCall.cpp (120790 => 120791)


--- trunk/Source/WebCore/bindings/js/ScriptFunctionCall.cpp	2012-06-20 02:25:14 UTC (rev 120790)
+++ trunk/Source/WebCore/bindings/js/ScriptFunctionCall.cpp	2012-06-20 03:27:27 UTC (rev 120791)
@@ -191,7 +191,7 @@
     return ScriptObject(m_exec, asObject(result));
 }
 
-ScriptCallback::ScriptCallback(ScriptState* state, ScriptValue function)
+ScriptCallback::ScriptCallback(ScriptState* state, const ScriptValue& function)
     : ScriptCallArgumentHandler(state)
     , m_function(function)
 {

Modified: trunk/Source/WebCore/bindings/js/ScriptFunctionCall.h (120790 => 120791)


--- trunk/Source/WebCore/bindings/js/ScriptFunctionCall.h	2012-06-20 02:25:14 UTC (rev 120790)
+++ trunk/Source/WebCore/bindings/js/ScriptFunctionCall.h	2012-06-20 03:27:27 UTC (rev 120791)
@@ -87,7 +87,7 @@
 
     class ScriptCallback : public ScriptCallArgumentHandler {
     public:
-        ScriptCallback(ScriptState*, ScriptValue);
+        ScriptCallback(ScriptState*, const ScriptValue&);
 
         ScriptValue call();
         ScriptValue call(bool& hadException);

Modified: trunk/Source/WebCore/bindings/js/ScriptProfiler.cpp (120790 => 120791)


--- trunk/Source/WebCore/bindings/js/ScriptProfiler.cpp	2012-06-20 02:25:14 UTC (rev 120790)
+++ trunk/Source/WebCore/bindings/js/ScriptProfiler.cpp	2012-06-20 03:27:27 UTC (rev 120791)
@@ -51,7 +51,7 @@
     return ScriptObject();
 }
 
-unsigned ScriptProfiler::getHeapObjectId(ScriptValue)
+unsigned ScriptProfiler::getHeapObjectId(const ScriptValue&)
 {
     return 0;
 }

Modified: trunk/Source/WebCore/bindings/js/ScriptProfiler.h (120790 => 120791)


--- trunk/Source/WebCore/bindings/js/ScriptProfiler.h	2012-06-20 02:25:14 UTC (rev 120790)
+++ trunk/Source/WebCore/bindings/js/ScriptProfiler.h	2012-06-20 03:27:27 UTC (rev 120791)
@@ -56,7 +56,7 @@
 
     static void collectGarbage();
     static ScriptObject objectByHeapObjectId(unsigned id);
-    static unsigned getHeapObjectId(ScriptValue);
+    static unsigned getHeapObjectId(const ScriptValue&);
     static void start(ScriptState* state, const String& title);
     static void startForPage(Page*, const String& title);
 #if ENABLE(WORKERS)

Modified: trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp (120790 => 120791)


--- trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp	2012-06-20 02:25:14 UTC (rev 120790)
+++ trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp	2012-06-20 03:27:27 UTC (rev 120791)
@@ -155,7 +155,7 @@
     }
 }
 
-void WorkerScriptController::setException(ScriptValue exception)
+void WorkerScriptController::setException(const ScriptValue& exception)
 {
     throwError(m_workerContextWrapper->globalExec(), exception.jsValue());
 }

Modified: trunk/Source/WebCore/bindings/js/WorkerScriptController.h (120790 => 120791)


--- trunk/Source/WebCore/bindings/js/WorkerScriptController.h	2012-06-20 02:25:14 UTC (rev 120790)
+++ trunk/Source/WebCore/bindings/js/WorkerScriptController.h	2012-06-20 03:27:27 UTC (rev 120791)
@@ -60,7 +60,7 @@
         void evaluate(const ScriptSourceCode&);
         void evaluate(const ScriptSourceCode&, ScriptValue* exception);
 
-        void setException(ScriptValue);
+        void setException(const ScriptValue&);
 
         // Async request to terminate a JS run execution. Eventually causes termination
         // exception raised during JS execution, if the worker thread happens to run JS.

Modified: trunk/Source/WebCore/bindings/v8/ScriptFunctionCall.cpp (120790 => 120791)


--- trunk/Source/WebCore/bindings/v8/ScriptFunctionCall.cpp	2012-06-20 02:25:14 UTC (rev 120790)
+++ trunk/Source/WebCore/bindings/v8/ScriptFunctionCall.cpp	2012-06-20 03:27:27 UTC (rev 120791)
@@ -177,7 +177,7 @@
     return ScriptObject(m_scriptState, result);
 }
 
-ScriptCallback::ScriptCallback(ScriptState* state, ScriptValue function)
+ScriptCallback::ScriptCallback(ScriptState* state, const ScriptValue& function)
     : ScriptCallArgumentHandler(state)
     , m_function(function)
 {

Modified: trunk/Source/WebCore/bindings/v8/ScriptFunctionCall.h (120790 => 120791)


--- trunk/Source/WebCore/bindings/v8/ScriptFunctionCall.h	2012-06-20 02:25:14 UTC (rev 120790)
+++ trunk/Source/WebCore/bindings/v8/ScriptFunctionCall.h	2012-06-20 03:27:27 UTC (rev 120791)
@@ -74,7 +74,7 @@
 
     class ScriptCallback : public ScriptCallArgumentHandler {
     public:
-        ScriptCallback(ScriptState*, ScriptValue);
+        ScriptCallback(ScriptState*, const ScriptValue&);
 
         ScriptValue call();
         ScriptValue call(bool& hadException);

Modified: trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp (120790 => 120791)


--- trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp	2012-06-20 02:25:14 UTC (rev 120790)
+++ trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp	2012-06-20 03:27:27 UTC (rev 120791)
@@ -121,7 +121,7 @@
     return ScriptObject(scriptState, object);
 }
 
-unsigned ScriptProfiler::getHeapObjectId(ScriptValue value)
+unsigned ScriptProfiler::getHeapObjectId(const ScriptValue& value)
 {
     v8::SnapshotObjectId id = v8::HeapProfiler::GetSnapshotObjectId(value.v8Value());
     return id;

Modified: trunk/Source/WebCore/bindings/v8/ScriptProfiler.h (120790 => 120791)


--- trunk/Source/WebCore/bindings/v8/ScriptProfiler.h	2012-06-20 02:25:14 UTC (rev 120790)
+++ trunk/Source/WebCore/bindings/v8/ScriptProfiler.h	2012-06-20 03:27:27 UTC (rev 120791)
@@ -60,7 +60,7 @@
 
     static void collectGarbage();
     static ScriptObject objectByHeapObjectId(unsigned id);
-    static unsigned getHeapObjectId(ScriptValue);
+    static unsigned getHeapObjectId(const ScriptValue&);
     static void start(ScriptState* state, const String& title);
     static void startForPage(Page*, const String& title);
 #if ENABLE(WORKERS)

Modified: trunk/Source/WebCore/bindings/v8/ScriptValue.h (120790 => 120791)


--- trunk/Source/WebCore/bindings/v8/ScriptValue.h	2012-06-20 02:25:14 UTC (rev 120790)
+++ trunk/Source/WebCore/bindings/v8/ScriptValue.h	2012-06-20 03:27:27 UTC (rev 120791)
@@ -99,7 +99,7 @@
         return *this;
     }
 
-    bool operator==(const ScriptValue value) const
+    bool operator==(const ScriptValue& value) const
     {
         return m_value == value.m_value;
     }
@@ -114,7 +114,7 @@
         return m_value->IsFunction();
     }
 
-    bool operator!=(const ScriptValue value) const
+    bool operator!=(const ScriptValue& value) const
     {
         return !operator==(value);
     }

Modified: trunk/Source/WebCore/bindings/v8/WorkerScriptController.cpp (120790 => 120791)


--- trunk/Source/WebCore/bindings/v8/WorkerScriptController.cpp	2012-06-20 02:25:14 UTC (rev 120790)
+++ trunk/Source/WebCore/bindings/v8/WorkerScriptController.cpp	2012-06-20 03:27:27 UTC (rev 120791)
@@ -137,7 +137,7 @@
 {
 }
 
-void WorkerScriptController::setException(ScriptValue exception)
+void WorkerScriptController::setException(const ScriptValue& exception)
 {
     throwError(*exception.v8Value());
 }

Modified: trunk/Source/WebCore/bindings/v8/WorkerScriptController.h (120790 => 120791)


--- trunk/Source/WebCore/bindings/v8/WorkerScriptController.h	2012-06-20 02:25:14 UTC (rev 120790)
+++ trunk/Source/WebCore/bindings/v8/WorkerScriptController.h	2012-06-20 03:27:27 UTC (rev 120791)
@@ -58,7 +58,7 @@
         void evaluate(const ScriptSourceCode&);
         void evaluate(const ScriptSourceCode&, ScriptValue* exception);
 
-        void setException(ScriptValue);
+        void setException(const ScriptValue&);
 
         // Async request to terminate a future JS execution. Eventually causes termination
         // exception raised during JS execution, if the worker thread happens to run JS.

Modified: trunk/Source/WebCore/css/MediaQueryListListener.h (120790 => 120791)


--- trunk/Source/WebCore/css/MediaQueryListListener.h	2012-06-20 02:25:14 UTC (rev 120790)
+++ trunk/Source/WebCore/css/MediaQueryListListener.h	2012-06-20 03:27:27 UTC (rev 120791)
@@ -34,7 +34,7 @@
 
 class MediaQueryListListener : public RefCounted<MediaQueryListListener> {
 public:
-    static PassRefPtr<MediaQueryListListener> create(ScriptValue value)
+    static PassRefPtr<MediaQueryListListener> create(const ScriptValue& value)
     {
         if (!value.isFunction())
             return 0;
@@ -45,7 +45,7 @@
     bool operator==(const MediaQueryListListener& other) const { return m_value == other.m_value; }
 
 private:
-    MediaQueryListListener(ScriptValue value) : m_value(value) { }
+    MediaQueryListListener(const ScriptValue& value) : m_value(value) { }
 
     ScriptValue m_value;
 };

Modified: trunk/Source/WebCore/dom/CustomEvent.cpp (120790 => 120791)


--- trunk/Source/WebCore/dom/CustomEvent.cpp	2012-06-20 02:25:14 UTC (rev 120790)
+++ trunk/Source/WebCore/dom/CustomEvent.cpp	2012-06-20 03:27:27 UTC (rev 120791)
@@ -49,7 +49,7 @@
 {
 }
 
-void CustomEvent::initCustomEvent(const AtomicString& type, bool canBubble, bool cancelable, ScriptValue detail)
+void CustomEvent::initCustomEvent(const AtomicString& type, bool canBubble, bool cancelable, const ScriptValue& detail)
 {
     if (dispatched())
         return;

Modified: trunk/Source/WebCore/dom/CustomEvent.h (120790 => 120791)


--- trunk/Source/WebCore/dom/CustomEvent.h	2012-06-20 02:25:14 UTC (rev 120790)
+++ trunk/Source/WebCore/dom/CustomEvent.h	2012-06-20 03:27:27 UTC (rev 120791)
@@ -51,11 +51,11 @@
         return adoptRef(new CustomEvent(type, initializer));
     }
 
-    void initCustomEvent(const AtomicString& type, bool canBubble, bool cancelable, ScriptValue detail);
+    void initCustomEvent(const AtomicString& type, bool canBubble, bool cancelable, const ScriptValue& detail);
 
     virtual const AtomicString& interfaceName() const;
 
-    ScriptValue detail() const { return m_detail; }
+    const ScriptValue& detail() const { return m_detail; }
 
 private:
     CustomEvent();

Modified: trunk/Source/WebCore/dom/MessageEvent.h (120790 => 120791)


--- trunk/Source/WebCore/dom/MessageEvent.h	2012-06-20 02:25:14 UTC (rev 120790)
+++ trunk/Source/WebCore/dom/MessageEvent.h	2012-06-20 03:27:27 UTC (rev 120791)
@@ -107,7 +107,7 @@
         DataTypeArrayBuffer
     };
     DataType dataType() const { return m_dataType; }
-    ScriptValue dataAsScriptValue() const { ASSERT(m_dataType == DataTypeScriptValue); return m_dataAsScriptValue; }
+    const ScriptValue& dataAsScriptValue() const { ASSERT(m_dataType == DataTypeScriptValue); return m_dataAsScriptValue; }
     SerializedScriptValue* dataAsSerializedScriptValue() const { ASSERT(m_dataType == DataTypeSerializedScriptValue); return m_dataAsSerializedScriptValue.get(); }
     String dataAsString() const { ASSERT(m_dataType == DataTypeString); return m_dataAsString; }
     Blob* dataAsBlob() const { ASSERT(m_dataType == DataTypeBlob); return m_dataAsBlob.get(); }

Modified: trunk/Source/WebCore/dom/PopStateEvent.h (120790 => 120791)


--- trunk/Source/WebCore/dom/PopStateEvent.h	2012-06-20 02:25:14 UTC (rev 120790)
+++ trunk/Source/WebCore/dom/PopStateEvent.h	2012-06-20 03:27:27 UTC (rev 120791)
@@ -49,7 +49,7 @@
     static PassRefPtr<PopStateEvent> create(const AtomicString&, const PopStateEventInit&);
 
     SerializedScriptValue* serializedState() const { return m_serializedState.get(); }
-    ScriptValue state() const { return m_state; }
+    const ScriptValue& state() const { return m_state; }
     History* history() const { return m_history.get(); }
 
     virtual const AtomicString& interfaceName() const;

Modified: trunk/Source/WebCore/inspector/InjectedScript.cpp (120790 => 120791)


--- trunk/Source/WebCore/inspector/InjectedScript.cpp	2012-06-20 02:25:14 UTC (rev 120790)
+++ trunk/Source/WebCore/inspector/InjectedScript.cpp	2012-06-20 03:27:27 UTC (rev 120791)
@@ -178,7 +178,7 @@
 }
 #endif
 
-PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(ScriptValue value, const String& groupName) const
+PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(const ScriptValue& value, const String& groupName) const
 {
     ASSERT(!hasNoValue());
     ScriptFunctionCall wrapFunction(injectedScriptObject(), "wrapObject");

Modified: trunk/Source/WebCore/inspector/InjectedScript.h (120790 => 120791)


--- trunk/Source/WebCore/inspector/InjectedScript.h	2012-06-20 02:25:14 UTC (rev 120790)
+++ trunk/Source/WebCore/inspector/InjectedScript.h	2012-06-20 03:27:27 UTC (rev 120791)
@@ -85,7 +85,7 @@
     PassRefPtr<TypeBuilder::Array<TypeBuilder::Debugger::CallFrame> > wrapCallFrames(const ScriptValue&);
 #endif
 
-    PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapObject(ScriptValue, const String& groupName) const;
+    PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapObject(const ScriptValue&, const String& groupName) const;
     PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapNode(Node*, const String& groupName);
     PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapSerializedObject(SerializedScriptValue*, const String& groupName) const;
     ScriptValue findObjectById(const String& objectId) const;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to