| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 Google Inc. All rights reserved. | 2 * Copyright (c) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/inspector/ScriptArguments.h" | 32 #include "core/inspector/ScriptArguments.h" |
| 33 | 33 |
| 34 #include "bindings/v8/ScriptValue.h" | 34 #include "bindings/v8/ScriptValue.h" |
| 35 #include "bindings/v8/V8Binding.h" | 35 #include "bindings/v8/V8Binding.h" |
| 36 #include <v8.h> | 36 #include <v8.h> |
| 37 | 37 |
| 38 namespace WebCore { | 38 namespace WebCore { |
| 39 | 39 |
| 40 PassRefPtr<ScriptArguments> ScriptArguments::create(ScriptState* scriptState, Ve
ctor<ScriptValue>& arguments) | 40 PassRefPtrWillBeRawPtr<ScriptArguments> ScriptArguments::create(ScriptState* scr
iptState, Vector<ScriptValue>& arguments) |
| 41 { | 41 { |
| 42 return adoptRef(new ScriptArguments(scriptState, arguments)); | 42 return adoptRefWillBeNoop(new ScriptArguments(scriptState, arguments)); |
| 43 } | 43 } |
| 44 | 44 |
| 45 ScriptArguments::ScriptArguments(ScriptState* scriptState, Vector<ScriptValue>&
arguments) | 45 ScriptArguments::ScriptArguments(ScriptState* scriptState, Vector<ScriptValue>&
arguments) |
| 46 : m_scriptState(scriptState) | 46 : m_scriptState(scriptState) |
| 47 { | 47 { |
| 48 m_arguments.swap(arguments); | 48 m_arguments.swap(arguments); |
| 49 } | 49 } |
| 50 | 50 |
| 51 ScriptArguments::~ScriptArguments() | |
| 52 { | |
| 53 } | |
| 54 | |
| 55 const ScriptValue &ScriptArguments::argumentAt(size_t index) const | 51 const ScriptValue &ScriptArguments::argumentAt(size_t index) const |
| 56 { | 52 { |
| 57 ASSERT(m_arguments.size() > index); | 53 ASSERT(m_arguments.size() > index); |
| 58 return m_arguments[index]; | 54 return m_arguments[index]; |
| 59 } | 55 } |
| 60 | 56 |
| 61 bool ScriptArguments::getFirstArgumentAsString(String& result, bool checkForNull
OrUndefined) | 57 bool ScriptArguments::getFirstArgumentAsString(String& result, bool checkForNull
OrUndefined) |
| 62 { | 58 { |
| 63 if (!argumentCount()) | 59 if (!argumentCount()) |
| 64 return false; | 60 return false; |
| 65 | 61 |
| 66 const ScriptValue& value = argumentAt(0); | 62 const ScriptValue& value = argumentAt(0); |
| 67 ScriptState::Scope scope(m_scriptState.get()); | 63 ScriptState::Scope scope(m_scriptState.get()); |
| 68 if (checkForNullOrUndefined && (value.isNull() || value.isUndefined())) | 64 if (checkForNullOrUndefined && (value.isNull() || value.isUndefined())) |
| 69 return false; | 65 return false; |
| 70 | 66 |
| 71 // We intentionally ignore an exception that can be thrown in ToString(). | 67 // We intentionally ignore an exception that can be thrown in ToString(). |
| 72 v8::TryCatch block; | 68 v8::TryCatch block; |
| 73 v8::Handle<v8::String> string = value.v8Value()->ToString(); | 69 v8::Handle<v8::String> string = value.v8Value()->ToString(); |
| 74 result = string.IsEmpty() ? String() : toCoreString(string); | 70 result = string.IsEmpty() ? String() : toCoreString(string); |
| 75 return true; | 71 return true; |
| 76 } | 72 } |
| 77 | 73 |
| 78 } // namespace WebCore | 74 } // namespace WebCore |
| OLD | NEW |