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

Side by Side Diff: Source/WebCore/bindings/dart/custom/DartHTMLCanvasElementCustom.cpp

Issue 10660025: Cleanup dart to string conversions. (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: . Created 8 years, 5 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 // Copyright 2011, Google Inc. 1 // Copyright 2011, Google Inc.
2 // All rights reserved. 2 // 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 namespace DartHTMLCanvasElementInternal { 50 namespace DartHTMLCanvasElementInternal {
51 51
52 void toDataURLCallback(Dart_NativeArguments args) 52 void toDataURLCallback(Dart_NativeArguments args)
53 { 53 {
54 DartApiScope dartApiScope; 54 DartApiScope dartApiScope;
55 Dart_Handle exception = 0; 55 Dart_Handle exception = 0;
56 { 56 {
57 HTMLCanvasElement* receiver = DartDOMWrapper::receiver<HTMLCanvasElement >(args); 57 HTMLCanvasElement* receiver = DartDOMWrapper::receiver<HTMLCanvasElement >(args);
58 58
59 const ParameterAdapter<String> type(Dart_GetNativeArgument(args, 1)); 59 DartStringAdapter type = DartUtilities::dartToString(Dart_GetNativeArgum ent(args, 1), exception);
60 if (!type.conversionSuccessful()) { 60 if (exception)
61 exception = type.exception();
62 goto fail; 61 goto fail;
63 }
64 62
65 ExceptionCode ec = 0; 63 ExceptionCode ec = 0;
66 String result = receiver->toDataURL(type, 0, ec); 64 String result = receiver->toDataURL(type, 0, ec);
67 if (UNLIKELY(ec)) { 65 if (UNLIKELY(ec)) {
68 exception = DartDOMWrapper::exceptionCodeToDartException(ec); 66 exception = DartDOMWrapper::exceptionCodeToDartException(ec);
69 goto fail; 67 goto fail;
70 } 68 }
71 69
72 Dart_SetReturnValue(args, DartUtilities::stringToDart(result, DartUtilit ies::ConvertNullToDefaultValue)); 70 Dart_SetReturnValue(args, DartUtilities::stringToDart(result, DartUtilit ies::ConvertNullToDefaultValue));
73 return; 71 return;
74 } 72 }
75 73
76 fail: 74 fail:
77 Dart_ThrowException(exception); 75 Dart_ThrowException(exception);
78 ASSERT_NOT_REACHED(); 76 ASSERT_NOT_REACHED();
79 } 77 }
80 78
81 void getContextCallback(Dart_NativeArguments args) 79 void getContextCallback(Dart_NativeArguments args)
82 { 80 {
83 DartApiScope dartApiScope; 81 DartApiScope dartApiScope;
84 Dart_Handle exception = 0; 82 Dart_Handle exception = 0;
85 { 83 {
86 HTMLCanvasElement* receiver = DartDOMWrapper::receiver<HTMLCanvasElement >(args); 84 HTMLCanvasElement* receiver = DartDOMWrapper::receiver<HTMLCanvasElement >(args);
87 85
88 const ParameterAdapter<String> contextId(Dart_GetNativeArgument(args, 1) ); 86 DartStringAdapter contextId = DartUtilities::dartToString(Dart_GetNative Argument(args, 1), exception);
89 if (!contextId.conversionSuccessful()) { 87 if (exception)
90 exception = contextId.exception();
91 goto fail; 88 goto fail;
92 }
93 89
94 RefPtr<CanvasContextAttributes> attrs; 90 RefPtr<CanvasContextAttributes> attrs;
95 #if ENABLE(WEBGL) 91 #if ENABLE(WEBGL)
96 const String& contextIdStr = contextId; 92 const String& contextIdStr = contextId;
97 if (contextIdStr == "experimental-webgl" || contextIdStr == "webkit-3d") { 93 if (contextIdStr == "experimental-webgl" || contextIdStr == "webkit-3d") {
98 attrs = WebGLContextAttributes::create(); 94 attrs = WebGLContextAttributes::create();
99 // FIXME: IDL doesn't mention second argument, but JS 95 // FIXME: IDL doesn't mention second argument, but JS
100 // passes map with parameters describing desired context 96 // passes map with parameters describing desired context
101 // features. 97 // features.
102 } 98 }
(...skipping 13 matching lines...) Expand all
116 } 112 }
117 113
118 fail: 114 fail:
119 Dart_ThrowException(exception); 115 Dart_ThrowException(exception);
120 ASSERT_NOT_REACHED(); 116 ASSERT_NOT_REACHED();
121 } 117 }
122 118
123 } // namespace DartHTMLCanvasElementInternal 119 } // namespace DartHTMLCanvasElementInternal
124 120
125 } // namespace WebCore 121 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698