internal CanvasRenderingContext2D(Window window, IHTMLCanvasElement canvas) { this.window = window; this.canvas = canvas; this.savedStates = new Stack<DrawingState>(); this.state = new DrawingState(); }
internal HTMLCanvasElement(IWindow window) : base(window) { this.window = (Window)window; this.height = this.clientHeight; this.width = this.clientWidth; }
public ChakraHost() { if (Native.JsCreateRuntime(JavaScriptRuntimeAttributes.None, null, out runtime) != JavaScriptErrorCode.NoError) { throw new Exception("failed to create runtime."); } if (Native.JsCreateContext(runtime, out context) != JavaScriptErrorCode.NoError) throw new Exception("failed to create execution context."); if (Native.JsSetCurrentContext(context) != JavaScriptErrorCode.NoError) throw new Exception("failed to set current context."); // ES6 Promise callback JavaScriptPromiseContinuationCallback promiseContinuationCallback = delegate (JavaScriptValue task, IntPtr callbackState) { promiseCallback = task; }; if (Native.JsSetPromiseContinuationCallback(promiseContinuationCallback, IntPtr.Zero) != JavaScriptErrorCode.NoError) throw new Exception("failed to setup callback for ES6 Promise"); // Bind to global object // setTimeout SetTimeoutJavaScriptNativeFunction = SetTimeout.SetTimeoutJavaScriptNativeFunction; DefineHostCallback("setTimeout", SetTimeoutJavaScriptNativeFunction); SendToHostJavaScriptNativeFunction = CommunicationManager.SendToHostJavaScriptNativeFunction; DefineHostCallback("sendToHost", SendToHostJavaScriptNativeFunction); // Projections if (Native.JsProjectWinRTNamespace("ChakraBridge") != JavaScriptErrorCode.NoError) throw new Exception("failed to project ChakraBridge namespace."); this.window = new Window(); ProjectObjectToGlobal(new Console(), "console"); ProjectObjectToGlobal(this.window, "window"); ProjectObjectToGlobal(this.window.navigator, "navigator"); ProjectObjectToGlobal(this.window.document, "document"); // Add references RunScript(@"XMLHttpRequest = ChakraBridge.XMLHttpRequest; HTMLCanvasElement = ChakraBridge.HTMLCanvasElementWrapper; atob = window.atob; btoa = window.btoa;"); #if DEBUG // Debug if (Native.JsStartDebugging() != JavaScriptErrorCode.NoError) throw new Exception("failed to start debugging."); #endif }