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

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

Issue 237743007: Handle the DOMString case of CRC2D.fillStyle/strokeStyle correctly (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add tests for objects without (explicit) toString. Created 6 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 | « LayoutTests/fast/canvas/canvas-fillStyle-strokeStyle-stringification.html ('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/V8CanvasRenderingContext2DCustom.cpp
diff --git a/Source/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp b/Source/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp
index 0351c804e0e38a038d51031b5a277d4a0d1a5185..2e22d7e958bedd9bcd8dcf4eef6473b31f4e4da5 100644
--- a/Source/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp
+++ b/Source/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp
@@ -74,10 +74,12 @@ void V8CanvasRenderingContext2D::strokeStyleAttributeGetterCustom(const v8::Prop
void V8CanvasRenderingContext2D::strokeStyleAttributeSetterCustom(v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
{
CanvasRenderingContext2D* impl = V8CanvasRenderingContext2D::toNative(info.Holder());
- if (value->IsString())
- impl->setStrokeColor(toCoreString(value.As<v8::String>()));
- else
- impl->setStrokeStyle(toCanvasStyle(value, info.GetIsolate()));
+ if (RefPtr<CanvasStyle> canvasStyle = toCanvasStyle(value, info.GetIsolate())) {
+ impl->setStrokeStyle(canvasStyle);
+ } else {
+ TOSTRING_VOID(V8StringResource<>, colorString, value);
+ impl->setStrokeColor(colorString);
+ }
}
void V8CanvasRenderingContext2D::fillStyleAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
@@ -89,10 +91,12 @@ void V8CanvasRenderingContext2D::fillStyleAttributeGetterCustom(const v8::Proper
void V8CanvasRenderingContext2D::fillStyleAttributeSetterCustom(v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
{
CanvasRenderingContext2D* impl = V8CanvasRenderingContext2D::toNative(info.Holder());
- if (value->IsString())
- impl->setFillColor(toCoreString(value.As<v8::String>()));
- else
- impl->setFillStyle(toCanvasStyle(value, info.GetIsolate()));
+ if (RefPtr<CanvasStyle> canvasStyle = toCanvasStyle(value, info.GetIsolate())) {
+ impl->setFillStyle(canvasStyle);
+ } else {
+ TOSTRING_VOID(V8StringResource<>, colorString, value);
+ impl->setFillColor(colorString);
+ }
}
} // namespace WebCore
« no previous file with comments | « LayoutTests/fast/canvas/canvas-fillStyle-strokeStyle-stringification.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698