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

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: IDL 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
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..e19af3a7633895adbe99289dd6df8425bf125e3b 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"
@@ -76,6 +76,15 @@ v8::Handle<v8::Value> V8HTMLCanvasElement::getContextMethodCustom(const v8::Argu
if (jsAttrs->Has(preserveDrawingBuffer))
webGLAttrs->setPreserveDrawingBuffer(jsAttrs->Get(preserveDrawingBuffer)->BooleanValue());
}
+ } else {
+ attrs = Canvas2DContextAttributes::create();
+ Canvas2DContextAttributes* canvas2DAttrs = static_cast<Canvas2DContextAttributes*>(attrs.get());
jamesr 2013/04/26 00:41:31 do you have to downcast? can you just keep a more
Stephen White 2013/04/26 15:51:03 Good point. I was blindly following the pattern of
+ 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());
jamesr 2013/04/26 00:41:31 this seems to imply that the default value for 'al
Stephen White 2013/04/26 15:51:03 I think this should work: Canvas2DContextAttribute
+ }
}
CanvasRenderingContext* result = imp->getContext(contextId, attrs.get());
if (!result)

Powered by Google App Engine
This is Rietveld 408576698