Commit 2f9fa62f authored by adamk@chromium.org's avatar adamk@chromium.org

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):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@120791 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 36de885b
2012-06-19 Adam Klein <adamk@chromium.org>
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 <pnormand@igalia.com>
[GStreamer] 0.11 video-sink
......@@ -191,7 +191,7 @@ ScriptObject ScriptFunctionCall::construct(bool& hadException, bool reportExcept
return ScriptObject(m_exec, asObject(result));
}
ScriptCallback::ScriptCallback(ScriptState* state, ScriptValue function)
ScriptCallback::ScriptCallback(ScriptState* state, const ScriptValue& function)
: ScriptCallArgumentHandler(state)
, m_function(function)
{
......
......@@ -87,7 +87,7 @@ namespace WebCore {
class ScriptCallback : public ScriptCallArgumentHandler {
public:
ScriptCallback(ScriptState*, ScriptValue);
ScriptCallback(ScriptState*, const ScriptValue&);
ScriptValue call();
ScriptValue call(bool& hadException);
......
......@@ -51,7 +51,7 @@ ScriptObject ScriptProfiler::objectByHeapObjectId(unsigned)
return ScriptObject();
}
unsigned ScriptProfiler::getHeapObjectId(ScriptValue)
unsigned ScriptProfiler::getHeapObjectId(const ScriptValue&)
{
return 0;
}
......
......@@ -56,7 +56,7 @@ public:
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)
......
......@@ -155,7 +155,7 @@ void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, Script
}
}
void WorkerScriptController::setException(ScriptValue exception)
void WorkerScriptController::setException(const ScriptValue& exception)
{
throwError(m_workerContextWrapper->globalExec(), exception.jsValue());
}
......
......@@ -60,7 +60,7 @@ namespace WebCore {
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.
......
......@@ -177,7 +177,7 @@ ScriptObject ScriptFunctionCall::construct(bool& hadException, bool reportExcept
return ScriptObject(m_scriptState, result);
}
ScriptCallback::ScriptCallback(ScriptState* state, ScriptValue function)
ScriptCallback::ScriptCallback(ScriptState* state, const ScriptValue& function)
: ScriptCallArgumentHandler(state)
, m_function(function)
{
......
......@@ -74,7 +74,7 @@ namespace WebCore {
class ScriptCallback : public ScriptCallArgumentHandler {
public:
ScriptCallback(ScriptState*, ScriptValue);
ScriptCallback(ScriptState*, const ScriptValue&);
ScriptValue call();
ScriptValue call(bool& hadException);
......
......@@ -121,7 +121,7 @@ ScriptObject ScriptProfiler::objectByHeapObjectId(unsigned id)
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;
......
......@@ -60,7 +60,7 @@ public:
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)
......
......@@ -99,7 +99,7 @@ public:
return *this;
}
bool operator==(const ScriptValue value) const
bool operator==(const ScriptValue& value) const
{
return m_value == value.m_value;
}
......@@ -114,7 +114,7 @@ public:
return m_value->IsFunction();
}
bool operator!=(const ScriptValue value) const
bool operator!=(const ScriptValue& value) const
{
return !operator==(value);
}
......
......@@ -137,7 +137,7 @@ void WorkerScriptController::disableEval()
{
}
void WorkerScriptController::setException(ScriptValue exception)
void WorkerScriptController::setException(const ScriptValue& exception)
{
throwError(*exception.v8Value());
}
......
......@@ -58,7 +58,7 @@ namespace WebCore {
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.
......
......@@ -34,7 +34,7 @@ class MediaQueryList;
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 @@ public:
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;
};
......
......@@ -49,7 +49,7 @@ CustomEvent::~CustomEvent()
{
}
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;
......
......@@ -51,11 +51,11 @@ public:
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();
......
......@@ -107,7 +107,7 @@ public:
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(); }
......
......@@ -49,7 +49,7 @@ public:
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;
......
......@@ -178,7 +178,7 @@ PassRefPtr<Array<CallFrame> > InjectedScript::wrapCallFrames(const ScriptValue&
}
#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");
......
......@@ -85,7 +85,7 @@ public:
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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment