Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Unified Diff: Source/WebCore/inspector/ScriptArguments.cpp

Issue 8806015: Changes to support a second VM. (Closed) Base URL: svn://svn.chromium.org/dash/experimental/chrome/src/webkit-full
Patch Set: . Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/WebCore/inspector/ScriptArguments.cpp
diff --git a/Source/WebCore/inspector/ScriptArguments.cpp b/Source/WebCore/inspector/ScriptArguments.cpp
index b0fe554ea78e5d0a76737fad85dfb8ac1856098f..43251e6845fa7ef58976074ecfb0d80d3b744af7 100644
--- a/Source/WebCore/inspector/ScriptArguments.cpp
+++ b/Source/WebCore/inspector/ScriptArguments.cpp
@@ -31,66 +31,85 @@
#include "config.h"
#include "ScriptArguments.h"
+#include "InspectorValues.h"
+#include "InjectedScript.h"
+#include "InjectedScriptManager.h"
#include "ScriptValue.h"
namespace WebCore {
-PassRefPtr<ScriptArguments> ScriptArguments::create(ScriptState* scriptState, Vector<ScriptValue>& arguments)
+PassRefPtr<JavaScriptArguments> JavaScriptArguments::create(ScriptState* scriptState, Vector<ScriptValue>& arguments)
{
- return adoptRef(new ScriptArguments(scriptState, arguments));
+ return adoptRef(new JavaScriptArguments(scriptState, arguments));
}
-ScriptArguments::ScriptArguments(ScriptState* scriptState, Vector<ScriptValue>& arguments)
+JavaScriptArguments::JavaScriptArguments(ScriptState* scriptState, Vector<ScriptValue>& arguments)
: m_scriptState(scriptState)
{
m_arguments.swap(arguments);
}
-ScriptArguments::~ScriptArguments()
+JavaScriptArguments::~JavaScriptArguments()
{
}
-const ScriptValue &ScriptArguments::argumentAt(size_t index) const
+PassRefPtr<InspectorArray> JavaScriptArguments::wrap(InjectedScriptManager* injectedScriptManager) const
{
- ASSERT(m_arguments.size() > index);
- return m_arguments[index];
+ if (!argumentCount())
+ return 0;
+
+ InjectedScript injectedScript = injectedScriptManager->injectedScriptFor(m_scriptState.get());
+ if (injectedScript.hasNoValue())
+ return 0;
+
+ RefPtr<InspectorArray> wrappedArguments = InspectorArray::create();
+ for (unsigned i = 0; i < argumentCount(); ++i) {
+ RefPtr<InspectorValue> wrappedArgument = injectedScript.wrapObject(argumentAt(i), "console");
+ if (!wrappedArgument) {
+ ASSERT_NOT_REACHED();
+ return 0;
+ }
+ wrappedArguments->pushValue(wrappedArgument);
+ }
+ return wrappedArguments.release();
}
-ScriptState* ScriptArguments::globalState() const
+DOMWindow* JavaScriptArguments::domWindow() const
{
- return m_scriptState.get();
+ return domWindowFromScriptState(m_scriptState.get());
}
-bool ScriptArguments::getFirstArgumentAsString(String& result, bool checkForNullOrUndefined)
+bool JavaScriptArguments::argumentGetString(size_t index, String& result) const
{
- if (!argumentCount())
- return false;
-
- const ScriptValue& value = argumentAt(0);
- if (checkForNullOrUndefined && (value.isNull() || value.isUndefined()))
+ if (index >= m_arguments.size())
return false;
+ return argumentAt(index).getString(m_scriptState.get(), result);
+}
- if (!globalState()) {
- ASSERT_NOT_REACHED();
+bool JavaScriptArguments::argumentToString(size_t index, String& result) const
+{
+ if (index >= m_arguments.size())
return false;
- }
-
- result = value.toString(globalState());
+ result = argumentAt(index).toString(m_scriptState.get());
return true;
}
-bool ScriptArguments::isEqual(ScriptArguments* other) const
+ScriptValue JavaScriptArguments::argumentAt(size_t index) const
+{
+ ASSERT(m_arguments.size() > index);
+ return m_arguments[index];
+}
+
+bool JavaScriptArguments::isEqual(ScriptArguments* other) const
{
if (!other)
return false;
- if (m_arguments.size() != other->m_arguments.size())
- return false;
- if (!globalState() && m_arguments.size())
+ if (argumentCount() != other->argumentCount())
return false;
- for (size_t i = 0; i < m_arguments.size(); ++i) {
- if (!m_arguments[i].isEqual(other->globalState(), other->m_arguments[i]))
+ for (size_t i = 0; i < argumentCount(); ++i) {
+ if (!argumentAt(i).isEqual(m_scriptState.get(), other->argumentAt(i)))
return false;
}
return true;

Powered by Google App Engine
This is Rietveld 408576698