[Webkit-unassigned] [Bug 70117] Expose HTMLCanvasElement supportsContext

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Jun 2 13:29:41 PDT 2013


https://bugs.webkit.org/show_bug.cgi?id=70117





--- Comment #25 from Sam Weinig <sam at webkit.org>  2013-06-02 13:28:11 PST ---
(In reply to comment #23)
> I tried wrapping one of the toBoolean statements in a try-catch and got an error in Xcode saying that exceptions are disabled; not sure where this is set/what's it's scope.

I should have given you some sample code, so, here you go:

+JSValue JSHTMLCanvasElement::supportsContext(ExecState* exec)
+{
+    HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(impl());
+    if (!exec->argumentCount())
+        return jsBoolean(false);
+
+    const String& contextId = exec->argument(0).toString(exec)->value(exec);
+    if (exec->hadException())
+        return jsUndefined();
+
+    RefPtr<CanvasContextAttributes> attrs;
+#if ENABLE(WEBGL)
+    if (contextId == "experimental-webgl" || contextId == "webkit-3d") {
+        JSValue initializerValue = exec->argument(1);
+        if (!initializerValue.isUndefinedOrNull()) {
+            // Given the above test, this will always yield an object.
+            JSObject* initializerObject = initializerValue.toObject(exec);
+
+            // Create the dictionary wrapper from the initializer object.
+            JSDictionary dictionary(exec, initializerObject);
+
+            GraphicsContext3D::Attributes attrs;
+            if (!dictionary.tryGetProperty("alpha", attrs.alpha))
+                return jsUndefined();
+            if (!dictionary.tryGetProperty("depth", attrs.depth))
+                return jsUndefined();
+            if (!dictionary.tryGetProperty("stencil", attrs.stencil))
+                return jsUndefined();
+            if (!dictionary.tryGetProperty("antialias", attrs.antialias))
+                return jsUndefined();
+            if (!dictionary.tryGetProperty("premultipliedAlpha", attrs.premultipliedAlpha))
+                return jsUndefined();
+            if (!dictionary.tryGetProperty("preserveDrawingBuffer", attrs.preserveDrawingBuffer))
+                return jsUndefined();
+
+            attrs = WebGLContextAttributes::create(attrs);
+        }
+    }
+#endif
+
+    return jsBoolean(canvas->supportsContext(contextId, attrs.get()));
+}

Not sure if this compiles.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list