| 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 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 namespace DartLocationInternal { | 40 namespace DartLocationInternal { |
| 41 | 41 |
| 42 void hrefSetter(Dart_NativeArguments args) | 42 void hrefSetter(Dart_NativeArguments args) |
| 43 { | 43 { |
| 44 DartApiScope dartApiScope; | 44 DartApiScope dartApiScope; |
| 45 Dart_Handle exception = 0; | 45 Dart_Handle exception = 0; |
| 46 { | 46 { |
| 47 Location* receiver = DartDOMWrapper::receiver<Location>(args); | 47 Location* receiver = DartDOMWrapper::receiver<Location>(args); |
| 48 | 48 |
| 49 const ParameterAdapter<String> href(Dart_GetNativeArgument(args, 1)); | 49 DartStringAdapter href = DartUtilities::dartToString(Dart_GetNativeArgum
ent(args, 1), exception); |
| 50 if (!href.conversionSuccessful()) { | 50 if (exception) |
| 51 exception = href.exception(); | |
| 52 goto fail; | 51 goto fail; |
| 53 } | |
| 54 | 52 |
| 55 receiver->setHref(href, DartUtilities::domWindowForCurrentIsolate(), rec
eiver->frame()->existingDOMWindow()); | 53 receiver->setHref(href, DartUtilities::domWindowForCurrentIsolate(), rec
eiver->frame()->existingDOMWindow()); |
| 56 return; | 54 return; |
| 57 } | 55 } |
| 58 | 56 |
| 59 fail: | 57 fail: |
| 60 Dart_ThrowException(exception); | 58 Dart_ThrowException(exception); |
| 61 ASSERT_NOT_REACHED(); | 59 ASSERT_NOT_REACHED(); |
| 62 } | 60 } |
| 63 | 61 |
| 64 void protocolSetter(Dart_NativeArguments args) | 62 void protocolSetter(Dart_NativeArguments args) |
| 65 { | 63 { |
| 66 DartApiScope dartApiScope; | 64 DartApiScope dartApiScope; |
| 67 Dart_Handle exception = 0; | 65 Dart_Handle exception = 0; |
| 68 { | 66 { |
| 69 Location* receiver = DartDOMWrapper::receiver<Location>(args); | 67 Location* receiver = DartDOMWrapper::receiver<Location>(args); |
| 70 | 68 |
| 71 const ParameterAdapter<String> protocol(Dart_GetNativeArgument(args, 1))
; | 69 DartStringAdapter protocol = DartUtilities::dartToString(Dart_GetNativeA
rgument(args, 1), exception); |
| 72 if (!protocol.conversionSuccessful()) { | 70 if (exception) |
| 73 exception = protocol.exception(); | |
| 74 goto fail; | 71 goto fail; |
| 75 } | |
| 76 | 72 |
| 77 DOMWindow* window = receiver->frame()->existingDOMWindow(); | 73 DOMWindow* window = receiver->frame()->existingDOMWindow(); |
| 78 ASSERT(window == DartUtilities::domWindowForCurrentIsolate()); | 74 ASSERT(window == DartUtilities::domWindowForCurrentIsolate()); |
| 79 ExceptionCode ec = 0; | 75 ExceptionCode ec = 0; |
| 80 receiver->setProtocol(protocol, window, window, ec); | 76 receiver->setProtocol(protocol, window, window, ec); |
| 81 if (UNLIKELY(ec)) { | 77 if (UNLIKELY(ec)) { |
| 82 exception = DartDOMWrapper::exceptionCodeToDartException(ec); | 78 exception = DartDOMWrapper::exceptionCodeToDartException(ec); |
| 83 goto fail; | 79 goto fail; |
| 84 } | 80 } |
| 85 return; | 81 return; |
| 86 } | 82 } |
| 87 | 83 |
| 88 fail: | 84 fail: |
| 89 Dart_ThrowException(exception); | 85 Dart_ThrowException(exception); |
| 90 ASSERT_NOT_REACHED(); | 86 ASSERT_NOT_REACHED(); |
| 91 } | 87 } |
| 92 | 88 |
| 93 void hostSetter(Dart_NativeArguments args) | 89 void hostSetter(Dart_NativeArguments args) |
| 94 { | 90 { |
| 95 DartApiScope dartApiScope; | 91 DartApiScope dartApiScope; |
| 96 Dart_Handle exception = 0; | 92 Dart_Handle exception = 0; |
| 97 { | 93 { |
| 98 Location* receiver = DartDOMWrapper::receiver<Location>(args); | 94 Location* receiver = DartDOMWrapper::receiver<Location>(args); |
| 99 | 95 |
| 100 const ParameterAdapter<String> host(Dart_GetNativeArgument(args, 1)); | 96 DartStringAdapter host = DartUtilities::dartToString(Dart_GetNativeArgum
ent(args, 1), exception); |
| 101 if (!host.conversionSuccessful()) { | 97 if (exception) |
| 102 exception = host.exception(); | |
| 103 goto fail; | 98 goto fail; |
| 104 } | |
| 105 | 99 |
| 106 DOMWindow* window = receiver->frame()->existingDOMWindow(); | 100 DOMWindow* window = receiver->frame()->existingDOMWindow(); |
| 107 ASSERT(window == DartUtilities::domWindowForCurrentIsolate()); | 101 ASSERT(window == DartUtilities::domWindowForCurrentIsolate()); |
| 108 receiver->setHost(host, window, window); | 102 receiver->setHost(host, window, window); |
| 109 return; | 103 return; |
| 110 } | 104 } |
| 111 | 105 |
| 112 fail: | 106 fail: |
| 113 Dart_ThrowException(exception); | 107 Dart_ThrowException(exception); |
| 114 ASSERT_NOT_REACHED(); | 108 ASSERT_NOT_REACHED(); |
| 115 } | 109 } |
| 116 | 110 |
| 117 void hostnameSetter(Dart_NativeArguments args) | 111 void hostnameSetter(Dart_NativeArguments args) |
| 118 { | 112 { |
| 119 DartApiScope dartApiScope; | 113 DartApiScope dartApiScope; |
| 120 Dart_Handle exception = 0; | 114 Dart_Handle exception = 0; |
| 121 { | 115 { |
| 122 Location* receiver = DartDOMWrapper::receiver<Location>(args); | 116 Location* receiver = DartDOMWrapper::receiver<Location>(args); |
| 123 | 117 |
| 124 const ParameterAdapter<String> hostname(Dart_GetNativeArgument(args, 1))
; | 118 DartStringAdapter hostname = DartUtilities::dartToString(Dart_GetNativeA
rgument(args, 1), exception); |
| 125 if (!hostname.conversionSuccessful()) { | 119 if (exception) |
| 126 exception = hostname.exception(); | |
| 127 goto fail; | 120 goto fail; |
| 128 } | |
| 129 | 121 |
| 130 DOMWindow* window = receiver->frame()->existingDOMWindow(); | 122 DOMWindow* window = receiver->frame()->existingDOMWindow(); |
| 131 ASSERT(window == DartUtilities::domWindowForCurrentIsolate()); | 123 ASSERT(window == DartUtilities::domWindowForCurrentIsolate()); |
| 132 receiver->setHostname(hostname, window, window); | 124 receiver->setHostname(hostname, window, window); |
| 133 return; | 125 return; |
| 134 } | 126 } |
| 135 | 127 |
| 136 fail: | 128 fail: |
| 137 Dart_ThrowException(exception); | 129 Dart_ThrowException(exception); |
| 138 ASSERT_NOT_REACHED(); | 130 ASSERT_NOT_REACHED(); |
| 139 } | 131 } |
| 140 | 132 |
| 141 void portSetter(Dart_NativeArguments args) | 133 void portSetter(Dart_NativeArguments args) |
| 142 { | 134 { |
| 143 DartApiScope dartApiScope; | 135 DartApiScope dartApiScope; |
| 144 Dart_Handle exception = 0; | 136 Dart_Handle exception = 0; |
| 145 { | 137 { |
| 146 Location* receiver = DartDOMWrapper::receiver<Location>(args); | 138 Location* receiver = DartDOMWrapper::receiver<Location>(args); |
| 147 | 139 |
| 148 const ParameterAdapter<String> port(Dart_GetNativeArgument(args, 1)); | 140 DartStringAdapter port = DartUtilities::dartToString(Dart_GetNativeArgum
ent(args, 1), exception); |
| 149 if (!port.conversionSuccessful()) { | 141 if (exception) |
| 150 exception = port.exception(); | |
| 151 goto fail; | 142 goto fail; |
| 152 } | |
| 153 | 143 |
| 154 DOMWindow* window = receiver->frame()->existingDOMWindow(); | 144 DOMWindow* window = receiver->frame()->existingDOMWindow(); |
| 155 ASSERT(window == DartUtilities::domWindowForCurrentIsolate()); | 145 ASSERT(window == DartUtilities::domWindowForCurrentIsolate()); |
| 156 receiver->setPort(port, window, window); | 146 receiver->setPort(port, window, window); |
| 157 return; | 147 return; |
| 158 } | 148 } |
| 159 | 149 |
| 160 fail: | 150 fail: |
| 161 Dart_ThrowException(exception); | 151 Dart_ThrowException(exception); |
| 162 ASSERT_NOT_REACHED(); | 152 ASSERT_NOT_REACHED(); |
| 163 } | 153 } |
| 164 | 154 |
| 165 void pathnameSetter(Dart_NativeArguments args) | 155 void pathnameSetter(Dart_NativeArguments args) |
| 166 { | 156 { |
| 167 DartApiScope dartApiScope; | 157 DartApiScope dartApiScope; |
| 168 Dart_Handle exception = 0; | 158 Dart_Handle exception = 0; |
| 169 { | 159 { |
| 170 Location* receiver = DartDOMWrapper::receiver<Location>(args); | 160 Location* receiver = DartDOMWrapper::receiver<Location>(args); |
| 171 | 161 |
| 172 const ParameterAdapter<String> pathname(Dart_GetNativeArgument(args, 1))
; | 162 DartStringAdapter pathname = DartUtilities::dartToString(Dart_GetNativeA
rgument(args, 1), exception); |
| 173 if (!pathname.conversionSuccessful()) { | 163 if (exception) |
| 174 exception = pathname.exception(); | |
| 175 goto fail; | 164 goto fail; |
| 176 } | |
| 177 | 165 |
| 178 DOMWindow* window = receiver->frame()->existingDOMWindow(); | 166 DOMWindow* window = receiver->frame()->existingDOMWindow(); |
| 179 ASSERT(window == DartUtilities::domWindowForCurrentIsolate()); | 167 ASSERT(window == DartUtilities::domWindowForCurrentIsolate()); |
| 180 receiver->setPathname(pathname, window, window); | 168 receiver->setPathname(pathname, window, window); |
| 181 return; | 169 return; |
| 182 } | 170 } |
| 183 | 171 |
| 184 fail: | 172 fail: |
| 185 Dart_ThrowException(exception); | 173 Dart_ThrowException(exception); |
| 186 ASSERT_NOT_REACHED(); | 174 ASSERT_NOT_REACHED(); |
| 187 } | 175 } |
| 188 | 176 |
| 189 void searchSetter(Dart_NativeArguments args) | 177 void searchSetter(Dart_NativeArguments args) |
| 190 { | 178 { |
| 191 DartApiScope dartApiScope; | 179 DartApiScope dartApiScope; |
| 192 Dart_Handle exception = 0; | 180 Dart_Handle exception = 0; |
| 193 { | 181 { |
| 194 Location* receiver = DartDOMWrapper::receiver<Location>(args); | 182 Location* receiver = DartDOMWrapper::receiver<Location>(args); |
| 195 | 183 |
| 196 const ParameterAdapter<String> search(Dart_GetNativeArgument(args, 1)); | 184 DartStringAdapter search = DartUtilities::dartToString(Dart_GetNativeArg
ument(args, 1), exception); |
| 197 if (!search.conversionSuccessful()) { | 185 if (exception) |
| 198 exception = search.exception(); | |
| 199 goto fail; | 186 goto fail; |
| 200 } | |
| 201 | 187 |
| 202 DOMWindow* window = receiver->frame()->existingDOMWindow(); | 188 DOMWindow* window = receiver->frame()->existingDOMWindow(); |
| 203 ASSERT(window == DartUtilities::domWindowForCurrentIsolate()); | 189 ASSERT(window == DartUtilities::domWindowForCurrentIsolate()); |
| 204 receiver->setSearch(search, window, window); | 190 receiver->setSearch(search, window, window); |
| 205 return; | 191 return; |
| 206 } | 192 } |
| 207 | 193 |
| 208 fail: | 194 fail: |
| 209 Dart_ThrowException(exception); | 195 Dart_ThrowException(exception); |
| 210 ASSERT_NOT_REACHED(); | 196 ASSERT_NOT_REACHED(); |
| 211 } | 197 } |
| 212 | 198 |
| 213 void hashSetter(Dart_NativeArguments args) | 199 void hashSetter(Dart_NativeArguments args) |
| 214 { | 200 { |
| 215 DartApiScope dartApiScope; | 201 DartApiScope dartApiScope; |
| 216 Dart_Handle exception = 0; | 202 Dart_Handle exception = 0; |
| 217 { | 203 { |
| 218 Location* receiver = DartDOMWrapper::receiver<Location>(args); | 204 Location* receiver = DartDOMWrapper::receiver<Location>(args); |
| 219 const ParameterAdapter<String> hash(Dart_GetNativeArgument(args, 1)); | 205 DartStringAdapter hash = DartUtilities::dartToString(Dart_GetNativeArgum
ent(args, 1), exception); |
| 220 if (!hash.conversionSuccessful()) { | 206 if (exception) |
| 221 exception = hash.exception(); | |
| 222 goto fail; | 207 goto fail; |
| 223 } | |
| 224 | 208 |
| 225 DOMWindow* window = receiver->frame()->existingDOMWindow(); | 209 DOMWindow* window = receiver->frame()->existingDOMWindow(); |
| 226 ASSERT(window == DartUtilities::domWindowForCurrentIsolate()); | 210 ASSERT(window == DartUtilities::domWindowForCurrentIsolate()); |
| 227 receiver->setHash(hash, window, window); | 211 receiver->setHash(hash, window, window); |
| 228 return; | 212 return; |
| 229 } | 213 } |
| 230 | 214 |
| 231 fail: | 215 fail: |
| 232 Dart_ThrowException(exception); | 216 Dart_ThrowException(exception); |
| 233 ASSERT_NOT_REACHED(); | 217 ASSERT_NOT_REACHED(); |
| 234 } | 218 } |
| 235 | 219 |
| 236 void assignCallback(Dart_NativeArguments args) | 220 void assignCallback(Dart_NativeArguments args) |
| 237 { | 221 { |
| 238 DartApiScope dartApiScope; | 222 DartApiScope dartApiScope; |
| 239 Dart_Handle exception = 0; | 223 Dart_Handle exception = 0; |
| 240 { | 224 { |
| 241 Location* receiver = DartDOMWrapper::receiver<Location>(args); | 225 Location* receiver = DartDOMWrapper::receiver<Location>(args); |
| 242 const ParameterAdapter<String> url(Dart_GetNativeArgument(args, 1)); | 226 DartStringAdapter url = DartUtilities::dartToString(Dart_GetNativeArgume
nt(args, 1), exception); |
| 243 if (!url.conversionSuccessful()) { | 227 if (exception) |
| 244 exception = url.exception(); | |
| 245 goto fail; | 228 goto fail; |
| 246 } | |
| 247 | 229 |
| 248 DOMWindow* window = receiver->frame()->existingDOMWindow(); | 230 DOMWindow* window = receiver->frame()->existingDOMWindow(); |
| 249 ASSERT(window == DartUtilities::domWindowForCurrentIsolate()); | 231 ASSERT(window == DartUtilities::domWindowForCurrentIsolate()); |
| 250 receiver->assign(url, window, window); | 232 receiver->assign(url, window, window); |
| 251 return; | 233 return; |
| 252 } | 234 } |
| 253 | 235 |
| 254 fail: | 236 fail: |
| 255 Dart_ThrowException(exception); | 237 Dart_ThrowException(exception); |
| 256 ASSERT_NOT_REACHED(); | 238 ASSERT_NOT_REACHED(); |
| 257 } | 239 } |
| 258 | 240 |
| 259 void replaceCallback(Dart_NativeArguments args) | 241 void replaceCallback(Dart_NativeArguments args) |
| 260 { | 242 { |
| 261 DartApiScope dartApiScope; | 243 DartApiScope dartApiScope; |
| 262 Dart_Handle exception = 0; | 244 Dart_Handle exception = 0; |
| 263 { | 245 { |
| 264 Location* receiver = DartDOMWrapper::receiver<Location>(args); | 246 Location* receiver = DartDOMWrapper::receiver<Location>(args); |
| 265 const ParameterAdapter<String> url(Dart_GetNativeArgument(args, 1)); | 247 DartStringAdapter url = DartUtilities::dartToString(Dart_GetNativeArgume
nt(args, 1), exception); |
| 266 if (!url.conversionSuccessful()) { | 248 if (exception) |
| 267 exception = url.exception(); | |
| 268 goto fail; | 249 goto fail; |
| 269 } | |
| 270 | 250 |
| 271 DOMWindow* window = receiver->frame()->existingDOMWindow(); | 251 DOMWindow* window = receiver->frame()->existingDOMWindow(); |
| 272 ASSERT(window == DartUtilities::domWindowForCurrentIsolate()); | 252 ASSERT(window == DartUtilities::domWindowForCurrentIsolate()); |
| 273 receiver->replace(url, window, window); | 253 receiver->replace(url, window, window); |
| 274 return; | 254 return; |
| 275 } | 255 } |
| 276 | 256 |
| 277 fail: | 257 fail: |
| 278 Dart_ThrowException(exception); | 258 Dart_ThrowException(exception); |
| 279 ASSERT_NOT_REACHED(); | 259 ASSERT_NOT_REACHED(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 298 | 278 |
| 299 void valueOfCallback(Dart_NativeArguments args) | 279 void valueOfCallback(Dart_NativeArguments args) |
| 300 { | 280 { |
| 301 // FIXME: proper implementation. | 281 // FIXME: proper implementation. |
| 302 DART_UNIMPLEMENTED(); | 282 DART_UNIMPLEMENTED(); |
| 303 } | 283 } |
| 304 | 284 |
| 305 } | 285 } |
| 306 | 286 |
| 307 } | 287 } |
| OLD | NEW |