| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 15 matching lines...) Expand all Loading... |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/inspector/InjectedScriptCanvasModule.h" | 32 #include "core/inspector/InjectedScriptCanvasModule.h" |
| 33 | 33 |
| 34 #include "bindings/core/v8/ScriptFunctionCall.h" | 34 #include "bindings/core/v8/ScriptFunctionCall.h" |
| 35 #include "bindings/core/v8/ScriptValue.h" | 35 #include "bindings/core/v8/ScriptValue.h" |
| 36 #include "core/InjectedScriptCanvasModuleSource.h" | 36 #include "public/platform/Platform.h" |
| 37 #include "public/platform/WebData.h" |
| 37 | 38 |
| 38 using blink::TypeBuilder::Array; | 39 using blink::TypeBuilder::Array; |
| 39 using blink::TypeBuilder::Canvas::ResourceId; | 40 using blink::TypeBuilder::Canvas::ResourceId; |
| 40 using blink::TypeBuilder::Canvas::ResourceState; | 41 using blink::TypeBuilder::Canvas::ResourceState; |
| 41 using blink::TypeBuilder::Canvas::TraceLog; | 42 using blink::TypeBuilder::Canvas::TraceLog; |
| 42 using blink::TypeBuilder::Canvas::TraceLogId; | 43 using blink::TypeBuilder::Canvas::TraceLogId; |
| 43 using blink::TypeBuilder::Runtime::RemoteObject; | 44 using blink::TypeBuilder::Runtime::RemoteObject; |
| 44 | 45 |
| 45 namespace blink { | 46 namespace blink { |
| 46 | 47 |
| 47 InjectedScriptCanvasModule::InjectedScriptCanvasModule() | 48 InjectedScriptCanvasModule::InjectedScriptCanvasModule() |
| 48 : InjectedScriptModule("InjectedScriptCanvasModule") | 49 : InjectedScriptModule("InjectedScriptCanvasModule") |
| 49 { | 50 { |
| 50 } | 51 } |
| 51 | 52 |
| 52 InjectedScriptCanvasModule InjectedScriptCanvasModule::moduleForState(InjectedSc
riptManager* injectedScriptManager, ScriptState* scriptState) | 53 InjectedScriptCanvasModule InjectedScriptCanvasModule::moduleForState(InjectedSc
riptManager* injectedScriptManager, ScriptState* scriptState) |
| 53 { | 54 { |
| 54 InjectedScriptCanvasModule result; | 55 InjectedScriptCanvasModule result; |
| 55 result.ensureInjected(injectedScriptManager, scriptState); | 56 result.ensureInjected(injectedScriptManager, scriptState); |
| 56 return result; | 57 return result; |
| 57 } | 58 } |
| 58 | 59 |
| 59 String InjectedScriptCanvasModule::source() const | 60 String InjectedScriptCanvasModule::source() const |
| 60 { | 61 { |
| 61 return String(reinterpret_cast<const char*>(InjectedScriptCanvasModuleSource
_js), sizeof(InjectedScriptCanvasModuleSource_js)); | 62 const blink::WebData& canvasModuleSourceResource = blink::Platform::current(
)->loadResource("InjectedScriptCanvasModuleSource.js"); |
| 63 return String(canvasModuleSourceResource.data(), canvasModuleSourceResource.
size()); |
| 62 } | 64 } |
| 63 | 65 |
| 64 ScriptValue InjectedScriptCanvasModule::wrapCanvas2DContext(const ScriptValue& c
ontext) | 66 ScriptValue InjectedScriptCanvasModule::wrapCanvas2DContext(const ScriptValue& c
ontext) |
| 65 { | 67 { |
| 66 return callWrapContextFunction("wrapCanvas2DContext", context); | 68 return callWrapContextFunction("wrapCanvas2DContext", context); |
| 67 } | 69 } |
| 68 | 70 |
| 69 ScriptValue InjectedScriptCanvasModule::wrapWebGLContext(const ScriptValue& glCo
ntext) | 71 ScriptValue InjectedScriptCanvasModule::wrapWebGLContext(const ScriptValue& glCo
ntext) |
| 70 { | 72 { |
| 71 return callWrapContextFunction("wrapWebGLContext", glContext); | 73 return callWrapContextFunction("wrapWebGLContext", glContext); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 if (remoteObject) | 209 if (remoteObject) |
| 208 *result = RemoteObject::runtimeCast(remoteObject); | 210 *result = RemoteObject::runtimeCast(remoteObject); |
| 209 RefPtr<JSONObject> resourceStateObject = resultObject->getObject("resourceSt
ate"); | 211 RefPtr<JSONObject> resourceStateObject = resultObject->getObject("resourceSt
ate"); |
| 210 if (resourceStateObject) | 212 if (resourceStateObject) |
| 211 *resourceState = ResourceState::runtimeCast(resourceStateObject); | 213 *resourceState = ResourceState::runtimeCast(resourceStateObject); |
| 212 if (!remoteObject && !resourceStateObject) | 214 if (!remoteObject && !resourceStateObject) |
| 213 *errorString = "Internal error: no result and no resource state"; | 215 *errorString = "Internal error: no result and no resource state"; |
| 214 } | 216 } |
| 215 | 217 |
| 216 } // namespace blink | 218 } // namespace blink |
| OLD | NEW |