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

Unified Diff: Source/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp

Issue 14298018: This CL implements the first draft of Canvas 2D Context Attributes, aka getContext('2d', { alpha: f… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased to ToT; test cleanup Created 7 years, 8 months 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
« no previous file with comments | « Source/WebKit/chromium/tests/Canvas2DLayerManagerTest.cpp ('k') | Source/core/core.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp
diff --git a/Source/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp b/Source/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp
index dda0c9eb235930887d1d7ee858264ddbadcf3359..2f737da2f47464ad99216f06256bef9db9f605a0 100644
--- a/Source/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp
+++ b/Source/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp
@@ -37,7 +37,7 @@
#include "V8WebGLRenderingContext.h"
#include "bindings/v8/V8Binding.h"
#include "core/html/HTMLCanvasElement.h"
-#include "core/html/canvas/CanvasContextAttributes.h"
+#include "core/html/canvas/Canvas2DContextAttributes.h"
#include "core/html/canvas/CanvasRenderingContext.h"
#include "core/html/canvas/WebGLContextAttributes.h"
#include "core/inspector/InspectorCanvasInstrumentation.h"
@@ -53,8 +53,7 @@ v8::Handle<v8::Value> V8HTMLCanvasElement::getContextMethodCustom(const v8::Argu
String contextId = toWebCoreString(args[0]);
RefPtr<CanvasContextAttributes> attrs;
if (contextId == "webgl" || contextId == "experimental-webgl" || contextId == "webkit-3d") {
- attrs = WebGLContextAttributes::create();
- WebGLContextAttributes* webGLAttrs = static_cast<WebGLContextAttributes*>(attrs.get());
+ RefPtr<WebGLContextAttributes> webGLAttrs = WebGLContextAttributes::create();
if (args.Length() > 1 && args[1]->IsObject()) {
v8::Handle<v8::Object> jsAttrs = args[1]->ToObject();
v8::Handle<v8::String> alpha = v8::String::NewSymbol("alpha");
@@ -76,6 +75,16 @@ v8::Handle<v8::Value> V8HTMLCanvasElement::getContextMethodCustom(const v8::Argu
if (jsAttrs->Has(preserveDrawingBuffer))
webGLAttrs->setPreserveDrawingBuffer(jsAttrs->Get(preserveDrawingBuffer)->BooleanValue());
}
+ attrs = webGLAttrs;
+ } else {
+ RefPtr<Canvas2DContextAttributes> canvas2DAttrs = Canvas2DContextAttributes::create();
+ if (args.Length() > 1 && args[1]->IsObject()) {
+ v8::Handle<v8::Object> jsAttrs = args[1]->ToObject();
+ v8::Handle<v8::String> alpha = v8::String::NewSymbol("alpha");
+ if (jsAttrs->Has(alpha))
+ canvas2DAttrs->setAlpha(jsAttrs->Get(alpha)->BooleanValue());
+ }
+ attrs = canvas2DAttrs;
}
CanvasRenderingContext* result = imp->getContext(contextId, attrs.get());
if (!result)
« no previous file with comments | « Source/WebKit/chromium/tests/Canvas2DLayerManagerTest.cpp ('k') | Source/core/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698