OLD | NEW |
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 19 matching lines...) Expand all Loading... |
30 #include "config.h" | 30 #include "config.h" |
31 #include "DartFormData.h" | 31 #include "DartFormData.h" |
32 | 32 |
33 #include "DartBlob.h" | 33 #include "DartBlob.h" |
34 #include "DartHTMLFormElement.h" | 34 #include "DartHTMLFormElement.h" |
35 | 35 |
36 namespace WebCore { | 36 namespace WebCore { |
37 | 37 |
38 namespace DartFormDataInternal { | 38 namespace DartFormDataInternal { |
39 | 39 |
40 void constructorCallback(Dart_NativeArguments args) | |
41 { | |
42 Dart_Handle exception = 0; | |
43 { | |
44 HTMLFormElement* form = 0; | |
45 if (!Dart_IsNull(Dart_GetNativeArgument(args, 0))) { | |
46 form = DartHTMLFormElement::toNative(Dart_GetNativeArgument(args, 0)
, exception); | |
47 if (exception) | |
48 goto fail; | |
49 } | |
50 | |
51 DartDOMWrapper::returnToDart<DartFormData>(args, DOMFormData::create(for
m)); | |
52 return; | |
53 } | |
54 | |
55 fail: | |
56 Dart_ThrowException(exception); | |
57 ASSERT_NOT_REACHED(); | |
58 } | |
59 | |
60 void appendCallback(Dart_NativeArguments args) | 40 void appendCallback(Dart_NativeArguments args) |
61 { | 41 { |
62 Dart_Handle exception = 0; | 42 Dart_Handle exception = 0; |
63 { | 43 { |
64 DOMFormData* receiver = DartDOMWrapper::receiver<DOMFormData>(args); | 44 DOMFormData* receiver = DartDOMWrapper::receiver<DOMFormData>(args); |
65 | 45 |
66 DartStringAdapter name = DartUtilities::dartToString(args, 1, exception)
; | 46 DartStringAdapter name = DartUtilities::dartToString(args, 1, exception)
; |
67 if (exception) | 47 if (exception) |
68 goto fail; | 48 goto fail; |
69 | 49 |
70 Dart_Handle arg2 = Dart_GetNativeArgument(args, 2); | 50 Dart_Handle arg2 = Dart_GetNativeArgument(args, 2); |
71 | 51 |
72 if (Dart_IsString(arg2)) { | 52 if (Dart_IsString(arg2)) { |
73 ASSERT(Dart_GetNativeArgumentCount(args) == 3); | 53 ASSERT(Dart_GetNativeArgumentCount(args) == 3); |
74 | 54 |
75 DartStringAdapter value = DartUtilities::dartToString(arg2, exceptio
n); | 55 DartStringAdapter value = DartUtilities::dartToString(arg2, exceptio
n); |
76 if (exception) | 56 if (exception) |
77 goto fail; | 57 goto fail; |
78 | 58 |
79 receiver->append(name, value); | 59 receiver->append(name, value); |
80 return; | 60 return; |
81 } | 61 } |
82 | 62 |
83 Blob* blob = DartBlob::toNative(arg2, exception); | 63 Blob* blob = DartBlob::toNativeWithNullCheck(arg2, exception); |
84 if (exception) | 64 if (exception) |
85 goto fail; | 65 goto fail; |
86 | 66 |
87 if (Dart_GetNativeArgumentCount(args) == 3) { | 67 if (Dart_GetNativeArgumentCount(args) == 3) { |
88 receiver->append(name, blob); | 68 receiver->append(name, blob); |
89 return; | 69 return; |
90 } | 70 } |
91 | 71 |
92 DartStringAdapter filename = DartUtilities::dartToStringWithNullCheck(ar
gs, 3, exception); | 72 DartStringAdapter filename = DartUtilities::dartToStringWithNullCheck(ar
gs, 3, exception); |
93 if (exception) | 73 if (exception) |
94 goto fail; | 74 goto fail; |
95 | 75 |
96 receiver->append(name, blob, filename); | 76 receiver->append(name, blob, filename); |
97 return; | 77 return; |
98 } | 78 } |
99 | 79 |
100 fail: | 80 fail: |
101 Dart_ThrowException(exception); | 81 Dart_ThrowException(exception); |
102 ASSERT_NOT_REACHED(); | 82 ASSERT_NOT_REACHED(); |
103 } | 83 } |
104 | 84 |
105 } | 85 } |
106 | 86 |
107 } | 87 } |
OLD | NEW |