Changeset 120791 in webkit


Ignore:
Timestamp:
Jun 19, 2012 8:27:27 PM (12 years ago)
Author:
adamk@chromium.org
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):

Location:
trunk/Source/WebCore
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r120790 r120791  
     12012-06-19  Adam Klein  <adamk@chromium.org>
     2
     3        Pass ScriptValue by const ref where possible
     4        https://bugs.webkit.org/show_bug.cgi?id=89531
     5
     6        Reviewed by Kentaro Hara.
     7
     8        Previously ScriptValue was sometimes passed by value, sometimes by const ref.
     9
     10        For consistency and optimality, pass by const ref everywhere (except where
     11        ScriptValue is returned from non-accessor methods).
     12
     13        No new tests, no change in behavior.
     14
     15        * bindings/js/ScriptFunctionCall.h:
     16        (ScriptCallback):
     17        * bindings/js/ScriptProfiler.cpp:
     18        (WebCore::ScriptProfiler::getHeapObjectId):
     19        * bindings/js/ScriptProfiler.h:
     20        (ScriptProfiler):
     21        * bindings/js/WorkerScriptController.cpp:
     22        (WebCore::WorkerScriptController::setException):
     23        * bindings/js/WorkerScriptController.h:
     24        (WorkerScriptController):
     25        * bindings/v8/ScriptFunctionCall.cpp:
     26        (WebCore::ScriptCallback::ScriptCallback):
     27        * bindings/v8/ScriptFunctionCall.h:
     28        (ScriptCallback):
     29        * bindings/v8/ScriptProfiler.cpp:
     30        (WebCore::ScriptProfiler::getHeapObjectId):
     31        (WebCore):
     32        * bindings/v8/ScriptProfiler.h:
     33        (ScriptProfiler):
     34        * bindings/v8/ScriptValue.h:
     35        (WebCore::ScriptValue::operator==):
     36        (WebCore::ScriptValue::operator!=):
     37        * bindings/v8/WorkerScriptController.cpp:
     38        (WebCore::WorkerScriptController::setException):
     39        * bindings/v8/WorkerScriptController.h:
     40        (WorkerScriptController):
     41        * css/MediaQueryListListener.h:
     42        (WebCore::MediaQueryListListener::create):
     43        (WebCore::MediaQueryListListener::MediaQueryListListener):
     44        * dom/CustomEvent.cpp:
     45        (WebCore::CustomEvent::initCustomEvent):
     46        * dom/CustomEvent.h:
     47        (CustomEvent):
     48        (WebCore::CustomEvent::detail):
     49        * dom/MessageEvent.h:
     50        (WebCore::MessageEvent::dataAsScriptValue):
     51        * dom/PopStateEvent.h:
     52        (WebCore::PopStateEvent::state):
     53        * inspector/InjectedScript.cpp:
     54        (WebCore::InjectedScript::wrapObject):
     55        * inspector/InjectedScript.h:
     56        (InjectedScript):
     57
    1582012-06-18  Philippe Normand  <pnormand@igalia.com>
    259
  • trunk/Source/WebCore/bindings/js/ScriptFunctionCall.cpp

    r98203 r120791  
    192192}
    193193
    194 ScriptCallback::ScriptCallback(ScriptState* state, ScriptValue function)
     194ScriptCallback::ScriptCallback(ScriptState* state, const ScriptValue& function)
    195195    : ScriptCallArgumentHandler(state)
    196196    , m_function(function)
  • trunk/Source/WebCore/bindings/js/ScriptFunctionCall.h

    r95901 r120791  
    8888    class ScriptCallback : public ScriptCallArgumentHandler {
    8989    public:
    90         ScriptCallback(ScriptState*, ScriptValue);
     90        ScriptCallback(ScriptState*, const ScriptValue&);
    9191
    9292        ScriptValue call();
  • trunk/Source/WebCore/bindings/js/ScriptProfiler.cpp

    r116768 r120791  
    5252}
    5353
    54 unsigned ScriptProfiler::getHeapObjectId(ScriptValue)
     54unsigned ScriptProfiler::getHeapObjectId(const ScriptValue&)
    5555{
    5656    return 0;
  • trunk/Source/WebCore/bindings/js/ScriptProfiler.h

    r120589 r120791  
    5757    static void collectGarbage();
    5858    static ScriptObject objectByHeapObjectId(unsigned id);
    59     static unsigned getHeapObjectId(ScriptValue);
     59    static unsigned getHeapObjectId(const ScriptValue&);
    6060    static void start(ScriptState* state, const String& title);
    6161    static void startForPage(Page*, const String& title);
  • trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp

    r115579 r120791  
    156156}
    157157
    158 void WorkerScriptController::setException(ScriptValue exception)
     158void WorkerScriptController::setException(const ScriptValue& exception)
    159159{
    160160    throwError(m_workerContextWrapper->globalExec(), exception.jsValue());
  • trunk/Source/WebCore/bindings/js/WorkerScriptController.h

    r110131 r120791  
    6161        void evaluate(const ScriptSourceCode&, ScriptValue* exception);
    6262
    63         void setException(ScriptValue);
     63        void setException(const ScriptValue&);
    6464
    6565        // Async request to terminate a JS run execution. Eventually causes termination
  • trunk/Source/WebCore/bindings/v8/ScriptFunctionCall.cpp

    r120709 r120791  
    178178}
    179179
    180 ScriptCallback::ScriptCallback(ScriptState* state, ScriptValue function)
     180ScriptCallback::ScriptCallback(ScriptState* state, const ScriptValue& function)
    181181    : ScriptCallArgumentHandler(state)
    182182    , m_function(function)
  • trunk/Source/WebCore/bindings/v8/ScriptFunctionCall.h

    r95901 r120791  
    7575    class ScriptCallback : public ScriptCallArgumentHandler {
    7676    public:
    77         ScriptCallback(ScriptState*, ScriptValue);
     77        ScriptCallback(ScriptState*, const ScriptValue&);
    7878
    7979        ScriptValue call();
  • trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp

    r120589 r120791  
    122122}
    123123
    124 unsigned ScriptProfiler::getHeapObjectId(ScriptValue value)
     124unsigned ScriptProfiler::getHeapObjectId(const ScriptValue& value)
    125125{
    126126    v8::SnapshotObjectId id = v8::HeapProfiler::GetSnapshotObjectId(value.v8Value());
  • trunk/Source/WebCore/bindings/v8/ScriptProfiler.h

    r120589 r120791  
    6161    static void collectGarbage();
    6262    static ScriptObject objectByHeapObjectId(unsigned id);
    63     static unsigned getHeapObjectId(ScriptValue);
     63    static unsigned getHeapObjectId(const ScriptValue&);
    6464    static void start(ScriptState* state, const String& title);
    6565    static void startForPage(Page*, const String& title);
  • trunk/Source/WebCore/bindings/v8/ScriptValue.h

    r115381 r120791  
    100100    }
    101101
    102     bool operator==(const ScriptValue value) const
     102    bool operator==(const ScriptValue& value) const
    103103    {
    104104        return m_value == value.m_value;
     
    115115    }
    116116
    117     bool operator!=(const ScriptValue value) const
     117    bool operator!=(const ScriptValue& value) const
    118118    {
    119119        return !operator==(value);
  • trunk/Source/WebCore/bindings/v8/WorkerScriptController.cpp

    r119777 r120791  
    138138}
    139139
    140 void WorkerScriptController::setException(ScriptValue exception)
     140void WorkerScriptController::setException(const ScriptValue& exception)
    141141{
    142142    throwError(*exception.v8Value());
  • trunk/Source/WebCore/bindings/v8/WorkerScriptController.h

    r110131 r120791  
    5959        void evaluate(const ScriptSourceCode&, ScriptValue* exception);
    6060
    61         void setException(ScriptValue);
     61        void setException(const ScriptValue&);
    6262
    6363        // Async request to terminate a future JS execution. Eventually causes termination
  • trunk/Source/WebCore/css/MediaQueryListListener.h

    r95901 r120791  
    3535class MediaQueryListListener : public RefCounted<MediaQueryListListener> {
    3636public:
    37     static PassRefPtr<MediaQueryListListener> create(ScriptValue value)
     37    static PassRefPtr<MediaQueryListListener> create(const ScriptValue& value)
    3838    {
    3939        if (!value.isFunction())
     
    4646
    4747private:
    48     MediaQueryListListener(ScriptValue value) : m_value(value) { }
     48    MediaQueryListListener(const ScriptValue& value) : m_value(value) { }
    4949
    5050    ScriptValue m_value;
  • trunk/Source/WebCore/dom/CustomEvent.cpp

    r98044 r120791  
    5050}
    5151
    52 void CustomEvent::initCustomEvent(const AtomicString& type, bool canBubble, bool cancelable, ScriptValue detail)
     52void CustomEvent::initCustomEvent(const AtomicString& type, bool canBubble, bool cancelable, const ScriptValue& detail)
    5353{
    5454    if (dispatched())
  • trunk/Source/WebCore/dom/CustomEvent.h

    r98044 r120791  
    5252    }
    5353
    54     void initCustomEvent(const AtomicString& type, bool canBubble, bool cancelable, ScriptValue detail);
     54    void initCustomEvent(const AtomicString& type, bool canBubble, bool cancelable, const ScriptValue& detail);
    5555
    5656    virtual const AtomicString& interfaceName() const;
    5757
    58     ScriptValue detail() const { return m_detail; }
     58    const ScriptValue& detail() const { return m_detail; }
    5959
    6060private:
  • trunk/Source/WebCore/dom/MessageEvent.h

    r101295 r120791  
    108108    };
    109109    DataType dataType() const { return m_dataType; }
    110     ScriptValue dataAsScriptValue() const { ASSERT(m_dataType == DataTypeScriptValue); return m_dataAsScriptValue; }
     110    const ScriptValue& dataAsScriptValue() const { ASSERT(m_dataType == DataTypeScriptValue); return m_dataAsScriptValue; }
    111111    SerializedScriptValue* dataAsSerializedScriptValue() const { ASSERT(m_dataType == DataTypeSerializedScriptValue); return m_dataAsSerializedScriptValue.get(); }
    112112    String dataAsString() const { ASSERT(m_dataType == DataTypeString); return m_dataAsString; }
  • trunk/Source/WebCore/dom/PopStateEvent.h

    r108596 r120791  
    5050
    5151    SerializedScriptValue* serializedState() const { return m_serializedState.get(); }
    52     ScriptValue state() const { return m_state; }
     52    const ScriptValue& state() const { return m_state; }
    5353    History* history() const { return m_history.get(); }
    5454
  • trunk/Source/WebCore/inspector/InjectedScript.cpp

    r120769 r120791  
    179179#endif
    180180
    181 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(ScriptValue value, const String& groupName) const
     181PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(const ScriptValue& value, const String& groupName) const
    182182{
    183183    ASSERT(!hasNoValue());
  • trunk/Source/WebCore/inspector/InjectedScript.h

    r120769 r120791  
    8686#endif
    8787
    88     PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapObject(ScriptValue, const String& groupName) const;
     88    PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapObject(const ScriptValue&, const String& groupName) const;
    8989    PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapNode(Node*, const String& groupName);
    9090    PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapSerializedObject(SerializedScriptValue*, const String& groupName) const;
Note: See TracChangeset for help on using the changeset viewer.