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

Side by Side Diff: Source/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp

Issue 171533006: V8 Binding: Introduce toNativeWithTypeCheck (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 return toV8(style->canvasGradient(), creationContext, isolate); 52 return toV8(style->canvasGradient(), creationContext, isolate);
53 53
54 if (style->canvasPattern()) 54 if (style->canvasPattern())
55 return toV8(style->canvasPattern(), creationContext, isolate); 55 return toV8(style->canvasPattern(), creationContext, isolate);
56 56
57 return v8String(isolate, style->color()); 57 return v8String(isolate, style->color());
58 } 58 }
59 59
60 static PassRefPtr<CanvasStyle> toCanvasStyle(v8::Handle<v8::Value> value, v8::Is olate* isolate) 60 static PassRefPtr<CanvasStyle> toCanvasStyle(v8::Handle<v8::Value> value, v8::Is olate* isolate)
61 { 61 {
62 if (V8CanvasGradient::hasInstance(value, isolate)) 62 RefPtr<CanvasStyle> canvasStyle = CanvasStyle::createFromGradient(V8CanvasGr adient::toNativeWithTypeCheck(isolate, value));
63 return CanvasStyle::createFromGradient(V8CanvasGradient::toNative(v8::Ha ndle<v8::Object>::Cast(value))); 63 if (canvasStyle)
64 64 return canvasStyle;
65 if (V8CanvasPattern::hasInstance(value, isolate)) 65 return CanvasStyle::createFromPattern(V8CanvasPattern::toNativeWithTypeCheck (isolate, value));
66 return CanvasStyle::createFromPattern(V8CanvasPattern::toNative(v8::Hand le<v8::Object>::Cast(value)));
67
68 return 0;
69 } 66 }
70 67
71 void V8CanvasRenderingContext2D::strokeStyleAttributeGetterCustom(const v8::Prop ertyCallbackInfo<v8::Value>& info) 68 void V8CanvasRenderingContext2D::strokeStyleAttributeGetterCustom(const v8::Prop ertyCallbackInfo<v8::Value>& info)
72 { 69 {
73 CanvasRenderingContext2D* impl = V8CanvasRenderingContext2D::toNative(info.H older()); 70 CanvasRenderingContext2D* impl = V8CanvasRenderingContext2D::toNative(info.H older());
74 v8SetReturnValue(info, toV8Object(impl->strokeStyle(), info.Holder(), info.G etIsolate())); 71 v8SetReturnValue(info, toV8Object(impl->strokeStyle(), info.Holder(), info.G etIsolate()));
75 } 72 }
76 73
77 void V8CanvasRenderingContext2D::strokeStyleAttributeSetterCustom(v8::Local<v8:: Value> value, const v8::PropertyCallbackInfo<void>& info) 74 void V8CanvasRenderingContext2D::strokeStyleAttributeSetterCustom(v8::Local<v8:: Value> value, const v8::PropertyCallbackInfo<void>& info)
78 { 75 {
(...skipping 13 matching lines...) Expand all
92 void V8CanvasRenderingContext2D::fillStyleAttributeSetterCustom(v8::Local<v8::Va lue> value, const v8::PropertyCallbackInfo<void>& info) 89 void V8CanvasRenderingContext2D::fillStyleAttributeSetterCustom(v8::Local<v8::Va lue> value, const v8::PropertyCallbackInfo<void>& info)
93 { 90 {
94 CanvasRenderingContext2D* impl = V8CanvasRenderingContext2D::toNative(info.H older()); 91 CanvasRenderingContext2D* impl = V8CanvasRenderingContext2D::toNative(info.H older());
95 if (value->IsString()) 92 if (value->IsString())
96 impl->setFillColor(toCoreString(value.As<v8::String>())); 93 impl->setFillColor(toCoreString(value.As<v8::String>()));
97 else 94 else
98 impl->setFillStyle(toCanvasStyle(value, info.GetIsolate())); 95 impl->setFillStyle(toCanvasStyle(value, info.GetIsolate()));
99 } 96 }
100 97
101 } // namespace WebCore 98 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/custom/V8ArrayBufferViewCustom.cpp ('k') | Source/bindings/v8/custom/V8DocumentCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698