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

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

Issue 290143007: canvas.getContext with alpha:undefined should behave like alpha:true (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: test expectations Created 6 years, 7 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 | « LayoutTests/fast/canvas/webgl/context-attributes-alpha-depth-stencil-antialias-expected.txt ('k') | no next file » | 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 ae2010e3aeb3b76635d2e0bd02c4e8d8f775c8dd..b4d169b46ea9f2300edbed6777d4ecb1baeef88f 100644
--- a/Source/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp
+++ b/Source/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp
@@ -47,6 +47,16 @@
namespace WebCore {
+static bool determineAlpha(v8::Handle<v8::Value> alphaValue)
Justin Novosad 2014/05/20 19:28:39 We are going to need a more generic version of thi
+{
+ // WebIDL dictionary spec says that setting a dictionary value to undefined
+ // should result in the attribute retaining its default value.
+ if (isUndefinedOrNull(alphaValue))
+ return true;
+
+ return alphaValue->BooleanValue();
+}
+
void V8HTMLCanvasElement::getContextMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Handle<v8::Object> holder = info.Holder();
@@ -61,7 +71,7 @@ void V8HTMLCanvasElement::getContextMethodCustom(const v8::FunctionCallbackInfo<
v8::Handle<v8::Object> jsAttributes = info[1]->ToObject();
v8::Handle<v8::String> alpha = v8AtomicString(isolate, "alpha");
if (jsAttributes->Has(alpha))
- webGLAttributes->setAlpha(jsAttributes->Get(alpha)->BooleanValue());
+ webGLAttributes->setAlpha(determineAlpha(jsAttributes->Get(alpha)));
Justin Novosad 2014/05/20 19:28:39 Theroriginal bug was primarily about 2D canvas. If
v8::Handle<v8::String> depth = v8AtomicString(isolate, "depth");
if (jsAttributes->Has(depth))
webGLAttributes->setDepth(jsAttributes->Get(depth)->BooleanValue());
@@ -88,7 +98,7 @@ void V8HTMLCanvasElement::getContextMethodCustom(const v8::FunctionCallbackInfo<
v8::Handle<v8::Object> jsAttributes = info[1]->ToObject();
v8::Handle<v8::String> alpha = v8AtomicString(isolate, "alpha");
if (jsAttributes->Has(alpha))
- canvas2DAttributes->setAlpha(jsAttributes->Get(alpha)->BooleanValue());
+ canvas2DAttributes->setAlpha(determineAlpha(jsAttributes->Get(alpha)));
}
attributes = canvas2DAttributes;
}
« no previous file with comments | « LayoutTests/fast/canvas/webgl/context-attributes-alpha-depth-stencil-antialias-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698