| OLD | NEW |
| 1 // Copyright (c) 2008, Google Inc. | 1 // Copyright (c) 2008, 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 27 matching lines...) Expand all Loading... |
| 38 #include "V8HTMLDocument.h" | 38 #include "V8HTMLDocument.h" |
| 39 | 39 |
| 40 #include "ExceptionCode.h" | 40 #include "ExceptionCode.h" |
| 41 #include "Frame.h" | 41 #include "Frame.h" |
| 42 #include "XMLHttpRequest.h" | 42 #include "XMLHttpRequest.h" |
| 43 #include "XMLHttpRequestUpload.h" | 43 #include "XMLHttpRequestUpload.h" |
| 44 | 44 |
| 45 namespace WebCore { | 45 namespace WebCore { |
| 46 | 46 |
| 47 CALLBACK_FUNC_DECL(XMLHttpRequestConstructor) { | 47 CALLBACK_FUNC_DECL(XMLHttpRequestConstructor) { |
| 48 INC_STATS(L"DOM.XMLHttpRequest.Constructor"); | 48 INC_STATS("DOM.XMLHttpRequest.Constructor"); |
| 49 | 49 |
| 50 if (!args.IsConstructCall()) { | 50 if (!args.IsConstructCall()) { |
| 51 V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, | 51 V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, |
| 52 "DOM object constructor cannot be called as a function."); | 52 "DOM object constructor cannot be called as a function."); |
| 53 return v8::Undefined(); | 53 return v8::Undefined(); |
| 54 } | 54 } |
| 55 // Expect no parameters. | 55 // Expect no parameters. |
| 56 // Allocate a XMLHttpRequest object as its internal field. | 56 // Allocate a XMLHttpRequest object as its internal field. |
| 57 Document* doc = V8Proxy::retrieveFrame()->document(); | 57 Document* doc = V8Proxy::retrieveFrame()->document(); |
| 58 RefPtr<XMLHttpRequest> xhr = XMLHttpRequest::create(doc); | 58 RefPtr<XMLHttpRequest> xhr = XMLHttpRequest::create(doc); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 cache_array->Delete(i); | 97 cache_array->Delete(i); |
| 98 return; | 98 return; |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 | 101 |
| 102 // We should only get here if we try to remove an event listener that was | 102 // We should only get here if we try to remove an event listener that was |
| 103 // never added. | 103 // never added. |
| 104 } | 104 } |
| 105 | 105 |
| 106 ACCESSOR_GETTER(XMLHttpRequestOnabort) { | 106 ACCESSOR_GETTER(XMLHttpRequestOnabort) { |
| 107 INC_STATS(L"DOM.XMLHttpRequest.onabort._get"); | 107 INC_STATS("DOM.XMLHttpRequest.onabort._get"); |
| 108 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( | 108 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( |
| 109 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); | 109 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); |
| 110 if (imp->onabort()) { | 110 if (imp->onabort()) { |
| 111 V8ObjectEventListener* listener = | 111 V8ObjectEventListener* listener = |
| 112 static_cast<V8ObjectEventListener*>(imp->onabort()); | 112 static_cast<V8ObjectEventListener*>(imp->onabort()); |
| 113 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); | 113 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); |
| 114 return v8_listener; | 114 return v8_listener; |
| 115 } | 115 } |
| 116 return v8::Undefined(); | 116 return v8::Undefined(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 ACCESSOR_SETTER(XMLHttpRequestOnabort) { | 119 ACCESSOR_SETTER(XMLHttpRequestOnabort) { |
| 120 INC_STATS(L"DOM.XMLHttpRequest.onabort._set"); | 120 INC_STATS("DOM.XMLHttpRequest.onabort._set"); |
| 121 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( | 121 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( |
| 122 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); | 122 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); |
| 123 if (value->IsNull()) { | 123 if (value->IsNull()) { |
| 124 if (imp->onabort()) { | 124 if (imp->onabort()) { |
| 125 V8ObjectEventListener* listener = | 125 V8ObjectEventListener* listener = |
| 126 static_cast<V8ObjectEventListener*>(imp->onabort()); | 126 static_cast<V8ObjectEventListener*>(imp->onabort()); |
| 127 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); | 127 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); |
| 128 RemoveHiddenXHRDependency(info.Holder(), v8_listener); | 128 RemoveHiddenXHRDependency(info.Holder(), v8_listener); |
| 129 } | 129 } |
| 130 | 130 |
| 131 // Clear the listener | 131 // Clear the listener |
| 132 imp->setOnabort(0); | 132 imp->setOnabort(0); |
| 133 } else { | 133 } else { |
| 134 V8Proxy* proxy = V8Proxy::retrieve(imp->scriptExecutionContext()); | 134 V8Proxy* proxy = V8Proxy::retrieve(imp->scriptExecutionContext()); |
| 135 if (!proxy) | 135 if (!proxy) |
| 136 return; | 136 return; |
| 137 | 137 |
| 138 RefPtr<EventListener> listener = | 138 RefPtr<EventListener> listener = |
| 139 proxy->FindOrCreateObjectEventListener(value, false); | 139 proxy->FindOrCreateObjectEventListener(value, false); |
| 140 if (listener) { | 140 if (listener) { |
| 141 imp->setOnabort(listener); | 141 imp->setOnabort(listener); |
| 142 CreateHiddenXHRDependency(info.Holder(), value); | 142 CreateHiddenXHRDependency(info.Holder(), value); |
| 143 } | 143 } |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| 147 ACCESSOR_GETTER(XMLHttpRequestOnerror) { | 147 ACCESSOR_GETTER(XMLHttpRequestOnerror) { |
| 148 INC_STATS(L"DOM.XMLHttpRequest.onerror._get"); | 148 INC_STATS("DOM.XMLHttpRequest.onerror._get"); |
| 149 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( | 149 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( |
| 150 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); | 150 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); |
| 151 if (imp->onerror()) { | 151 if (imp->onerror()) { |
| 152 RefPtr<V8ObjectEventListener> listener = | 152 RefPtr<V8ObjectEventListener> listener = |
| 153 static_cast<V8ObjectEventListener*>(imp->onerror()); | 153 static_cast<V8ObjectEventListener*>(imp->onerror()); |
| 154 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); | 154 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); |
| 155 return v8_listener; | 155 return v8_listener; |
| 156 } | 156 } |
| 157 return v8::Undefined(); | 157 return v8::Undefined(); |
| 158 } | 158 } |
| 159 | 159 |
| 160 ACCESSOR_SETTER(XMLHttpRequestOnerror) { | 160 ACCESSOR_SETTER(XMLHttpRequestOnerror) { |
| 161 INC_STATS(L"DOM.XMLHttpRequest.onerror._set"); | 161 INC_STATS("DOM.XMLHttpRequest.onerror._set"); |
| 162 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( | 162 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( |
| 163 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); | 163 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); |
| 164 if (value->IsNull()) { | 164 if (value->IsNull()) { |
| 165 if (imp->onerror()) { | 165 if (imp->onerror()) { |
| 166 V8ObjectEventListener* listener = | 166 V8ObjectEventListener* listener = |
| 167 static_cast<V8ObjectEventListener*>(imp->onerror()); | 167 static_cast<V8ObjectEventListener*>(imp->onerror()); |
| 168 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); | 168 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); |
| 169 RemoveHiddenXHRDependency(info.Holder(), v8_listener); | 169 RemoveHiddenXHRDependency(info.Holder(), v8_listener); |
| 170 } | 170 } |
| 171 | 171 |
| 172 // Clear the listener | 172 // Clear the listener |
| 173 imp->setOnerror(0); | 173 imp->setOnerror(0); |
| 174 } else { | 174 } else { |
| 175 V8Proxy* proxy = V8Proxy::retrieve(imp->scriptExecutionContext()); | 175 V8Proxy* proxy = V8Proxy::retrieve(imp->scriptExecutionContext()); |
| 176 if (!proxy) | 176 if (!proxy) |
| 177 return; | 177 return; |
| 178 | 178 |
| 179 RefPtr<EventListener> listener = | 179 RefPtr<EventListener> listener = |
| 180 proxy->FindOrCreateObjectEventListener(value, false); | 180 proxy->FindOrCreateObjectEventListener(value, false); |
| 181 if (listener) { | 181 if (listener) { |
| 182 imp->setOnerror(listener); | 182 imp->setOnerror(listener); |
| 183 CreateHiddenXHRDependency(info.Holder(), value); | 183 CreateHiddenXHRDependency(info.Holder(), value); |
| 184 } | 184 } |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 | 187 |
| 188 ACCESSOR_GETTER(XMLHttpRequestOnload) { | 188 ACCESSOR_GETTER(XMLHttpRequestOnload) { |
| 189 INC_STATS(L"DOM.XMLHttpRequest.onload._get"); | 189 INC_STATS("DOM.XMLHttpRequest.onload._get"); |
| 190 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( | 190 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( |
| 191 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); | 191 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); |
| 192 if (imp->onload()) { | 192 if (imp->onload()) { |
| 193 V8ObjectEventListener* listener = | 193 V8ObjectEventListener* listener = |
| 194 static_cast<V8ObjectEventListener*>(imp->onload()); | 194 static_cast<V8ObjectEventListener*>(imp->onload()); |
| 195 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); | 195 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); |
| 196 return v8_listener; | 196 return v8_listener; |
| 197 } | 197 } |
| 198 return v8::Undefined(); | 198 return v8::Undefined(); |
| 199 } | 199 } |
| 200 | 200 |
| 201 ACCESSOR_SETTER(XMLHttpRequestOnload) | 201 ACCESSOR_SETTER(XMLHttpRequestOnload) |
| 202 { | 202 { |
| 203 INC_STATS(L"DOM.XMLHttpRequest.onload._set"); | 203 INC_STATS("DOM.XMLHttpRequest.onload._set"); |
| 204 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( | 204 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( |
| 205 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); | 205 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); |
| 206 if (value->IsNull()) { | 206 if (value->IsNull()) { |
| 207 if (imp->onload()) { | 207 if (imp->onload()) { |
| 208 V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(imp-
>onload()); | 208 V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(imp-
>onload()); |
| 209 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); | 209 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); |
| 210 RemoveHiddenXHRDependency(info.Holder(), v8_listener); | 210 RemoveHiddenXHRDependency(info.Holder(), v8_listener); |
| 211 } | 211 } |
| 212 | 212 |
| 213 imp->setOnload(0); | 213 imp->setOnload(0); |
| 214 | 214 |
| 215 } else { | 215 } else { |
| 216 V8Proxy* proxy = V8Proxy::retrieve(imp->scriptExecutionContext()); | 216 V8Proxy* proxy = V8Proxy::retrieve(imp->scriptExecutionContext()); |
| 217 if (!proxy) | 217 if (!proxy) |
| 218 return; | 218 return; |
| 219 | 219 |
| 220 RefPtr<EventListener> listener = | 220 RefPtr<EventListener> listener = |
| 221 proxy->FindOrCreateObjectEventListener(value, false); | 221 proxy->FindOrCreateObjectEventListener(value, false); |
| 222 if (listener) { | 222 if (listener) { |
| 223 imp->setOnload(listener.get()); | 223 imp->setOnload(listener.get()); |
| 224 CreateHiddenXHRDependency(info.Holder(), value); | 224 CreateHiddenXHRDependency(info.Holder(), value); |
| 225 } | 225 } |
| 226 } | 226 } |
| 227 } | 227 } |
| 228 | 228 |
| 229 ACCESSOR_GETTER(XMLHttpRequestOnloadstart) { | 229 ACCESSOR_GETTER(XMLHttpRequestOnloadstart) { |
| 230 INC_STATS(L"DOM.XMLHttpRequest.onloadstart._get"); | 230 INC_STATS("DOM.XMLHttpRequest.onloadstart._get"); |
| 231 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( | 231 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( |
| 232 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); | 232 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); |
| 233 if (imp->onloadstart()) { | 233 if (imp->onloadstart()) { |
| 234 V8ObjectEventListener* listener = | 234 V8ObjectEventListener* listener = |
| 235 static_cast<V8ObjectEventListener*>(imp->onloadstart()); | 235 static_cast<V8ObjectEventListener*>(imp->onloadstart()); |
| 236 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); | 236 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); |
| 237 return v8_listener; | 237 return v8_listener; |
| 238 } | 238 } |
| 239 return v8::Undefined(); | 239 return v8::Undefined(); |
| 240 } | 240 } |
| 241 | 241 |
| 242 ACCESSOR_SETTER(XMLHttpRequestOnloadstart) { | 242 ACCESSOR_SETTER(XMLHttpRequestOnloadstart) { |
| 243 INC_STATS(L"DOM.XMLHttpRequest.onloadstart._set"); | 243 INC_STATS("DOM.XMLHttpRequest.onloadstart._set"); |
| 244 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( | 244 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( |
| 245 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); | 245 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); |
| 246 if (value->IsNull()) { | 246 if (value->IsNull()) { |
| 247 if (imp->onloadstart()) { | 247 if (imp->onloadstart()) { |
| 248 V8ObjectEventListener* listener = | 248 V8ObjectEventListener* listener = |
| 249 static_cast<V8ObjectEventListener*>(imp->onloadstart()); | 249 static_cast<V8ObjectEventListener*>(imp->onloadstart()); |
| 250 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); | 250 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); |
| 251 RemoveHiddenXHRDependency(info.Holder(), v8_listener); | 251 RemoveHiddenXHRDependency(info.Holder(), v8_listener); |
| 252 } | 252 } |
| 253 | 253 |
| 254 // Clear the listener | 254 // Clear the listener |
| 255 imp->setOnloadstart(0); | 255 imp->setOnloadstart(0); |
| 256 } else { | 256 } else { |
| 257 V8Proxy* proxy = V8Proxy::retrieve(imp->scriptExecutionContext()); | 257 V8Proxy* proxy = V8Proxy::retrieve(imp->scriptExecutionContext()); |
| 258 if (!proxy) | 258 if (!proxy) |
| 259 return; | 259 return; |
| 260 | 260 |
| 261 RefPtr<EventListener> listener = | 261 RefPtr<EventListener> listener = |
| 262 proxy->FindOrCreateObjectEventListener(value, false); | 262 proxy->FindOrCreateObjectEventListener(value, false); |
| 263 if (listener) { | 263 if (listener) { |
| 264 imp->setOnloadstart(listener); | 264 imp->setOnloadstart(listener); |
| 265 CreateHiddenXHRDependency(info.Holder(), value); | 265 CreateHiddenXHRDependency(info.Holder(), value); |
| 266 } | 266 } |
| 267 } | 267 } |
| 268 } | 268 } |
| 269 | 269 |
| 270 ACCESSOR_GETTER(XMLHttpRequestOnprogress) { | 270 ACCESSOR_GETTER(XMLHttpRequestOnprogress) { |
| 271 INC_STATS(L"DOM.XMLHttpRequest.onprogress._get"); | 271 INC_STATS("DOM.XMLHttpRequest.onprogress._get"); |
| 272 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( | 272 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( |
| 273 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); | 273 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); |
| 274 if (imp->onprogress()) { | 274 if (imp->onprogress()) { |
| 275 V8ObjectEventListener* listener = | 275 V8ObjectEventListener* listener = |
| 276 static_cast<V8ObjectEventListener*>(imp->onprogress()); | 276 static_cast<V8ObjectEventListener*>(imp->onprogress()); |
| 277 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); | 277 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); |
| 278 return v8_listener; | 278 return v8_listener; |
| 279 } | 279 } |
| 280 return v8::Undefined(); | 280 return v8::Undefined(); |
| 281 } | 281 } |
| 282 | 282 |
| 283 ACCESSOR_SETTER(XMLHttpRequestOnprogress) { | 283 ACCESSOR_SETTER(XMLHttpRequestOnprogress) { |
| 284 INC_STATS(L"DOM.XMLHttpRequest.onprogress._set"); | 284 INC_STATS("DOM.XMLHttpRequest.onprogress._set"); |
| 285 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( | 285 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( |
| 286 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); | 286 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); |
| 287 if (value->IsNull()) { | 287 if (value->IsNull()) { |
| 288 if (imp->onprogress()) { | 288 if (imp->onprogress()) { |
| 289 V8ObjectEventListener* listener = | 289 V8ObjectEventListener* listener = |
| 290 static_cast<V8ObjectEventListener*>(imp->onprogress()); | 290 static_cast<V8ObjectEventListener*>(imp->onprogress()); |
| 291 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); | 291 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); |
| 292 RemoveHiddenXHRDependency(info.Holder(), v8_listener); | 292 RemoveHiddenXHRDependency(info.Holder(), v8_listener); |
| 293 } | 293 } |
| 294 | 294 |
| 295 // Clear the listener | 295 // Clear the listener |
| 296 imp->setOnprogress(0); | 296 imp->setOnprogress(0); |
| 297 } else { | 297 } else { |
| 298 V8Proxy* proxy = V8Proxy::retrieve(imp->scriptExecutionContext()); | 298 V8Proxy* proxy = V8Proxy::retrieve(imp->scriptExecutionContext()); |
| 299 if (!proxy) | 299 if (!proxy) |
| 300 return; | 300 return; |
| 301 | 301 |
| 302 RefPtr<EventListener> listener = | 302 RefPtr<EventListener> listener = |
| 303 proxy->FindOrCreateObjectEventListener(value, false); | 303 proxy->FindOrCreateObjectEventListener(value, false); |
| 304 if (listener) { | 304 if (listener) { |
| 305 imp->setOnprogress(listener); | 305 imp->setOnprogress(listener); |
| 306 CreateHiddenXHRDependency(info.Holder(), value); | 306 CreateHiddenXHRDependency(info.Holder(), value); |
| 307 } | 307 } |
| 308 } | 308 } |
| 309 } | 309 } |
| 310 | 310 |
| 311 ACCESSOR_GETTER(XMLHttpRequestOnreadystatechange) { | 311 ACCESSOR_GETTER(XMLHttpRequestOnreadystatechange) { |
| 312 INC_STATS(L"DOM.XMLHttpRequest.onreadystatechange._get"); | 312 INC_STATS("DOM.XMLHttpRequest.onreadystatechange._get"); |
| 313 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( | 313 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( |
| 314 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); | 314 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); |
| 315 if (imp->onreadystatechange()) { | 315 if (imp->onreadystatechange()) { |
| 316 V8ObjectEventListener* listener = | 316 V8ObjectEventListener* listener = |
| 317 static_cast<V8ObjectEventListener*>(imp->onreadystatechange()); | 317 static_cast<V8ObjectEventListener*>(imp->onreadystatechange()); |
| 318 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); | 318 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); |
| 319 return v8_listener; | 319 return v8_listener; |
| 320 } | 320 } |
| 321 return v8::Undefined(); | 321 return v8::Undefined(); |
| 322 } | 322 } |
| 323 | 323 |
| 324 ACCESSOR_SETTER(XMLHttpRequestOnreadystatechange) | 324 ACCESSOR_SETTER(XMLHttpRequestOnreadystatechange) |
| 325 { | 325 { |
| 326 INC_STATS(L"DOM.XMLHttpRequest.onreadystatechange._set"); | 326 INC_STATS("DOM.XMLHttpRequest.onreadystatechange._set"); |
| 327 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( | 327 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( |
| 328 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); | 328 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); |
| 329 if (value->IsNull()) { | 329 if (value->IsNull()) { |
| 330 if (imp->onreadystatechange()) { | 330 if (imp->onreadystatechange()) { |
| 331 V8ObjectEventListener* listener = | 331 V8ObjectEventListener* listener = |
| 332 static_cast<V8ObjectEventListener*>(imp->onreadystatechange()); | 332 static_cast<V8ObjectEventListener*>(imp->onreadystatechange()); |
| 333 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); | 333 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); |
| 334 RemoveHiddenXHRDependency(info.Holder(), v8_listener); | 334 RemoveHiddenXHRDependency(info.Holder(), v8_listener); |
| 335 } | 335 } |
| 336 | 336 |
| 337 // Clear the listener | 337 // Clear the listener |
| 338 imp->setOnreadystatechange(0); | 338 imp->setOnreadystatechange(0); |
| 339 } else { | 339 } else { |
| 340 V8Proxy* proxy = V8Proxy::retrieve(imp->scriptExecutionContext()); | 340 V8Proxy* proxy = V8Proxy::retrieve(imp->scriptExecutionContext()); |
| 341 if (!proxy) | 341 if (!proxy) |
| 342 return; | 342 return; |
| 343 | 343 |
| 344 RefPtr<EventListener> listener = | 344 RefPtr<EventListener> listener = |
| 345 proxy->FindOrCreateObjectEventListener(value, false); | 345 proxy->FindOrCreateObjectEventListener(value, false); |
| 346 if (listener) { | 346 if (listener) { |
| 347 imp->setOnreadystatechange(listener.get()); | 347 imp->setOnreadystatechange(listener.get()); |
| 348 CreateHiddenXHRDependency(info.Holder(), value); | 348 CreateHiddenXHRDependency(info.Holder(), value); |
| 349 } | 349 } |
| 350 } | 350 } |
| 351 } | 351 } |
| 352 | 352 |
| 353 CALLBACK_FUNC_DECL(XMLHttpRequestAddEventListener) | 353 CALLBACK_FUNC_DECL(XMLHttpRequestAddEventListener) |
| 354 { | 354 { |
| 355 INC_STATS(L"DOM.XMLHttpRequest.addEventListener()"); | 355 INC_STATS("DOM.XMLHttpRequest.addEventListener()"); |
| 356 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( | 356 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( |
| 357 V8ClassIndex::XMLHTTPREQUEST, args.Holder()); | 357 V8ClassIndex::XMLHTTPREQUEST, args.Holder()); |
| 358 | 358 |
| 359 V8Proxy* proxy = V8Proxy::retrieve(imp->scriptExecutionContext()); | 359 V8Proxy* proxy = V8Proxy::retrieve(imp->scriptExecutionContext()); |
| 360 if (!proxy) | 360 if (!proxy) |
| 361 return v8::Undefined(); | 361 return v8::Undefined(); |
| 362 | 362 |
| 363 RefPtr<EventListener> listener = | 363 RefPtr<EventListener> listener = |
| 364 proxy->FindOrCreateObjectEventListener(args[1], false); | 364 proxy->FindOrCreateObjectEventListener(args[1], false); |
| 365 if (listener) { | 365 if (listener) { |
| 366 String type = ToWebCoreString(args[0]); | 366 String type = ToWebCoreString(args[0]); |
| 367 bool useCapture = args[2]->BooleanValue(); | 367 bool useCapture = args[2]->BooleanValue(); |
| 368 imp->addEventListener(type, listener, useCapture); | 368 imp->addEventListener(type, listener, useCapture); |
| 369 | 369 |
| 370 CreateHiddenXHRDependency(args.Holder(), args[1]); | 370 CreateHiddenXHRDependency(args.Holder(), args[1]); |
| 371 } | 371 } |
| 372 return v8::Undefined(); | 372 return v8::Undefined(); |
| 373 } | 373 } |
| 374 | 374 |
| 375 CALLBACK_FUNC_DECL(XMLHttpRequestRemoveEventListener) { | 375 CALLBACK_FUNC_DECL(XMLHttpRequestRemoveEventListener) { |
| 376 INC_STATS(L"DOM.XMLHttpRequest.removeEventListener()"); | 376 INC_STATS("DOM.XMLHttpRequest.removeEventListener()"); |
| 377 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( | 377 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( |
| 378 V8ClassIndex::XMLHTTPREQUEST, args.Holder()); | 378 V8ClassIndex::XMLHTTPREQUEST, args.Holder()); |
| 379 | 379 |
| 380 V8Proxy* proxy = V8Proxy::retrieve(imp->scriptExecutionContext()); | 380 V8Proxy* proxy = V8Proxy::retrieve(imp->scriptExecutionContext()); |
| 381 if (!proxy) | 381 if (!proxy) |
| 382 return v8::Undefined(); // probably leaked | 382 return v8::Undefined(); // probably leaked |
| 383 | 383 |
| 384 RefPtr<EventListener> listener = | 384 RefPtr<EventListener> listener = |
| 385 proxy->FindObjectEventListener(args[1], false); | 385 proxy->FindObjectEventListener(args[1], false); |
| 386 | 386 |
| 387 if (listener) { | 387 if (listener) { |
| 388 String type = ToWebCoreString(args[0]); | 388 String type = ToWebCoreString(args[0]); |
| 389 bool useCapture = args[2]->BooleanValue(); | 389 bool useCapture = args[2]->BooleanValue(); |
| 390 imp->removeEventListener(type, listener.get(), useCapture); | 390 imp->removeEventListener(type, listener.get(), useCapture); |
| 391 | 391 |
| 392 RemoveHiddenXHRDependency(args.Holder(), args[1]); | 392 RemoveHiddenXHRDependency(args.Holder(), args[1]); |
| 393 } | 393 } |
| 394 | 394 |
| 395 return v8::Undefined(); | 395 return v8::Undefined(); |
| 396 } | 396 } |
| 397 | 397 |
| 398 CALLBACK_FUNC_DECL(XMLHttpRequestOpen) | 398 CALLBACK_FUNC_DECL(XMLHttpRequestOpen) |
| 399 { | 399 { |
| 400 INC_STATS(L"DOM.XMLHttpRequest.open()"); | 400 INC_STATS("DOM.XMLHttpRequest.open()"); |
| 401 // Four cases: | 401 // Four cases: |
| 402 // open(method, url) | 402 // open(method, url) |
| 403 // open(method, url, async) | 403 // open(method, url, async) |
| 404 // open(method, url, async, user) | 404 // open(method, url, async, user) |
| 405 // open(method, url, async, user, passwd) | 405 // open(method, url, async, user, passwd) |
| 406 | 406 |
| 407 if (args.Length() < 2) { | 407 if (args.Length() < 2) { |
| 408 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments"); | 408 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments"); |
| 409 return v8::Undefined(); | 409 return v8::Undefined(); |
| 410 } | 410 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 } | 443 } |
| 444 | 444 |
| 445 static bool IsDocumentType(v8::Handle<v8::Value> value) | 445 static bool IsDocumentType(v8::Handle<v8::Value> value) |
| 446 { | 446 { |
| 447 // TODO(fqian): add other document types. | 447 // TODO(fqian): add other document types. |
| 448 return V8Document::HasInstance(value) || V8HTMLDocument::HasInstance(value); | 448 return V8Document::HasInstance(value) || V8HTMLDocument::HasInstance(value); |
| 449 } | 449 } |
| 450 | 450 |
| 451 CALLBACK_FUNC_DECL(XMLHttpRequestSend) | 451 CALLBACK_FUNC_DECL(XMLHttpRequestSend) |
| 452 { | 452 { |
| 453 INC_STATS(L"DOM.XMLHttpRequest.send()"); | 453 INC_STATS("DOM.XMLHttpRequest.send()"); |
| 454 XMLHttpRequest* xhr = V8Proxy::ToNativeObject<XMLHttpRequest>( | 454 XMLHttpRequest* xhr = V8Proxy::ToNativeObject<XMLHttpRequest>( |
| 455 V8ClassIndex::XMLHTTPREQUEST, args.Holder()); | 455 V8ClassIndex::XMLHTTPREQUEST, args.Holder()); |
| 456 | 456 |
| 457 ExceptionCode ec = 0; | 457 ExceptionCode ec = 0; |
| 458 if (args.Length() < 1) | 458 if (args.Length() < 1) |
| 459 xhr->send(ec); | 459 xhr->send(ec); |
| 460 else { | 460 else { |
| 461 v8::Handle<v8::Value> arg = args[0]; | 461 v8::Handle<v8::Value> arg = args[0]; |
| 462 // TODO(eseidel): upstream handles "File" objects too | 462 // TODO(eseidel): upstream handles "File" objects too |
| 463 if (IsDocumentType(arg)) { | 463 if (IsDocumentType(arg)) { |
| 464 v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(arg); | 464 v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(arg); |
| 465 Document* doc = V8Proxy::DOMWrapperToNode<Document>(obj); | 465 Document* doc = V8Proxy::DOMWrapperToNode<Document>(obj); |
| 466 ASSERT(doc); | 466 ASSERT(doc); |
| 467 xhr->send(doc, ec); | 467 xhr->send(doc, ec); |
| 468 } else | 468 } else |
| 469 xhr->send(valueToStringWithNullCheck(arg), ec); | 469 xhr->send(valueToStringWithNullCheck(arg), ec); |
| 470 } | 470 } |
| 471 | 471 |
| 472 if (ec) { | 472 if (ec) { |
| 473 V8Proxy::SetDOMException(ec); | 473 V8Proxy::SetDOMException(ec); |
| 474 return v8::Handle<v8::Value>(); | 474 return v8::Handle<v8::Value>(); |
| 475 } | 475 } |
| 476 | 476 |
| 477 return v8::Undefined(); | 477 return v8::Undefined(); |
| 478 } | 478 } |
| 479 | 479 |
| 480 CALLBACK_FUNC_DECL(XMLHttpRequestSetRequestHeader) { | 480 CALLBACK_FUNC_DECL(XMLHttpRequestSetRequestHeader) { |
| 481 INC_STATS(L"DOM.XMLHttpRequest.setRequestHeader()"); | 481 INC_STATS("DOM.XMLHttpRequest.setRequestHeader()"); |
| 482 if (args.Length() < 2) { | 482 if (args.Length() < 2) { |
| 483 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments"); | 483 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments"); |
| 484 return v8::Undefined(); | 484 return v8::Undefined(); |
| 485 } | 485 } |
| 486 | 486 |
| 487 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( | 487 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( |
| 488 V8ClassIndex::XMLHTTPREQUEST, args.Holder()); | 488 V8ClassIndex::XMLHTTPREQUEST, args.Holder()); |
| 489 ExceptionCode ec = 0; | 489 ExceptionCode ec = 0; |
| 490 String header = ToWebCoreString(args[0]); | 490 String header = ToWebCoreString(args[0]); |
| 491 String value = ToWebCoreString(args[1]); | 491 String value = ToWebCoreString(args[1]); |
| 492 imp->setRequestHeader(header, value, ec); | 492 imp->setRequestHeader(header, value, ec); |
| 493 if (ec != 0) { | 493 if (ec != 0) { |
| 494 V8Proxy::SetDOMException(ec); | 494 V8Proxy::SetDOMException(ec); |
| 495 return v8::Handle<v8::Value>(); | 495 return v8::Handle<v8::Value>(); |
| 496 } | 496 } |
| 497 return v8::Undefined(); | 497 return v8::Undefined(); |
| 498 } | 498 } |
| 499 | 499 |
| 500 CALLBACK_FUNC_DECL(XMLHttpRequestGetResponseHeader) { | 500 CALLBACK_FUNC_DECL(XMLHttpRequestGetResponseHeader) { |
| 501 INC_STATS(L"DOM.XMLHttpRequest.getResponseHeader()"); | 501 INC_STATS("DOM.XMLHttpRequest.getResponseHeader()"); |
| 502 if (args.Length() < 1) { | 502 if (args.Length() < 1) { |
| 503 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments"); | 503 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments"); |
| 504 return v8::Undefined(); | 504 return v8::Undefined(); |
| 505 } | 505 } |
| 506 | 506 |
| 507 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( | 507 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( |
| 508 V8ClassIndex::XMLHTTPREQUEST, args.Holder()); | 508 V8ClassIndex::XMLHTTPREQUEST, args.Holder()); |
| 509 ExceptionCode ec = 0; | 509 ExceptionCode ec = 0; |
| 510 String header = ToWebCoreString(args[0]); | 510 String header = ToWebCoreString(args[0]); |
| 511 String result = imp->getResponseHeader(header, ec); | 511 String result = imp->getResponseHeader(header, ec); |
| 512 if (ec != 0) { | 512 if (ec != 0) { |
| 513 V8Proxy::SetDOMException(ec); | 513 V8Proxy::SetDOMException(ec); |
| 514 return v8::Handle<v8::Value>(); | 514 return v8::Handle<v8::Value>(); |
| 515 } | 515 } |
| 516 return v8StringOrNull(result); | 516 return v8StringOrNull(result); |
| 517 } | 517 } |
| 518 | 518 |
| 519 CALLBACK_FUNC_DECL(XMLHttpRequestOverrideMimeType) | 519 CALLBACK_FUNC_DECL(XMLHttpRequestOverrideMimeType) |
| 520 { | 520 { |
| 521 INC_STATS(L"DOM.XMLHttpRequest.overrideMimeType()"); | 521 INC_STATS("DOM.XMLHttpRequest.overrideMimeType()"); |
| 522 if (args.Length() < 1) { | 522 if (args.Length() < 1) { |
| 523 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments"); | 523 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments"); |
| 524 return v8::Undefined(); | 524 return v8::Undefined(); |
| 525 } | 525 } |
| 526 | 526 |
| 527 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( | 527 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>( |
| 528 V8ClassIndex::XMLHTTPREQUEST, args.Holder()); | 528 V8ClassIndex::XMLHTTPREQUEST, args.Holder()); |
| 529 String value = ToWebCoreString(args[0]); | 529 String value = ToWebCoreString(args[0]); |
| 530 imp->overrideMimeType(value); | 530 imp->overrideMimeType(value); |
| 531 return v8::Undefined(); | 531 return v8::Undefined(); |
| 532 } | 532 } |
| 533 | 533 |
| 534 CALLBACK_FUNC_DECL(XMLHttpRequestDispatchEvent) | 534 CALLBACK_FUNC_DECL(XMLHttpRequestDispatchEvent) |
| 535 { | 535 { |
| 536 INC_STATS(L"DOM.XMLHttpRequest.dispatchEvent()"); | 536 INC_STATS("DOM.XMLHttpRequest.dispatchEvent()"); |
| 537 return v8::Undefined(); | 537 return v8::Undefined(); |
| 538 } | 538 } |
| 539 | 539 |
| 540 | 540 |
| 541 // XMLHttpRequestUpload -------------------------------------------------------- | 541 // XMLHttpRequestUpload -------------------------------------------------------- |
| 542 | 542 |
| 543 ACCESSOR_GETTER(XMLHttpRequestUploadOnabort) { | 543 ACCESSOR_GETTER(XMLHttpRequestUploadOnabort) { |
| 544 INC_STATS(L"DOM.XMLHttpRequestUpload.onabort._get"); | 544 INC_STATS("DOM.XMLHttpRequestUpload.onabort._get"); |
| 545 XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>( | 545 XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>( |
| 546 V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); | 546 V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); |
| 547 if (imp->onabort()) { | 547 if (imp->onabort()) { |
| 548 V8ObjectEventListener* listener = | 548 V8ObjectEventListener* listener = |
| 549 static_cast<V8ObjectEventListener*>(imp->onabort()); | 549 static_cast<V8ObjectEventListener*>(imp->onabort()); |
| 550 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); | 550 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); |
| 551 return v8_listener; | 551 return v8_listener; |
| 552 } | 552 } |
| 553 return v8::Undefined(); | 553 return v8::Undefined(); |
| 554 } | 554 } |
| 555 | 555 |
| 556 ACCESSOR_SETTER(XMLHttpRequestUploadOnabort) { | 556 ACCESSOR_SETTER(XMLHttpRequestUploadOnabort) { |
| 557 INC_STATS(L"DOM.XMLHttpRequestUpload.onabort._set"); | 557 INC_STATS("DOM.XMLHttpRequestUpload.onabort._set"); |
| 558 XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>( | 558 XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>( |
| 559 V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); | 559 V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); |
| 560 if (value->IsNull()) { | 560 if (value->IsNull()) { |
| 561 if (imp->onabort()) { | 561 if (imp->onabort()) { |
| 562 V8ObjectEventListener* listener = | 562 V8ObjectEventListener* listener = |
| 563 static_cast<V8ObjectEventListener*>(imp->onabort()); | 563 static_cast<V8ObjectEventListener*>(imp->onabort()); |
| 564 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); | 564 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); |
| 565 RemoveHiddenXHRDependency(info.Holder(), v8_listener); | 565 RemoveHiddenXHRDependency(info.Holder(), v8_listener); |
| 566 } | 566 } |
| 567 | 567 |
| 568 // Clear the listener | 568 // Clear the listener |
| 569 imp->setOnabort(0); | 569 imp->setOnabort(0); |
| 570 } else { | 570 } else { |
| 571 XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest(); | 571 XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest(); |
| 572 V8Proxy* proxy = | 572 V8Proxy* proxy = |
| 573 V8Proxy::retrieve(xmlhttprequest->scriptExecutionContext()); | 573 V8Proxy::retrieve(xmlhttprequest->scriptExecutionContext()); |
| 574 if (!proxy) | 574 if (!proxy) |
| 575 return; | 575 return; |
| 576 | 576 |
| 577 RefPtr<EventListener> listener = | 577 RefPtr<EventListener> listener = |
| 578 proxy->FindOrCreateObjectEventListener(value, false); | 578 proxy->FindOrCreateObjectEventListener(value, false); |
| 579 if (listener) { | 579 if (listener) { |
| 580 imp->setOnabort(listener); | 580 imp->setOnabort(listener); |
| 581 CreateHiddenXHRDependency(info.Holder(), value); | 581 CreateHiddenXHRDependency(info.Holder(), value); |
| 582 } | 582 } |
| 583 } | 583 } |
| 584 } | 584 } |
| 585 | 585 |
| 586 ACCESSOR_GETTER(XMLHttpRequestUploadOnerror) { | 586 ACCESSOR_GETTER(XMLHttpRequestUploadOnerror) { |
| 587 INC_STATS(L"DOM.XMLHttpRequestUpload.onerror._get"); | 587 INC_STATS("DOM.XMLHttpRequestUpload.onerror._get"); |
| 588 XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>( | 588 XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>( |
| 589 V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); | 589 V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); |
| 590 if (imp->onerror()) { | 590 if (imp->onerror()) { |
| 591 V8ObjectEventListener* listener = | 591 V8ObjectEventListener* listener = |
| 592 static_cast<V8ObjectEventListener*>(imp->onerror()); | 592 static_cast<V8ObjectEventListener*>(imp->onerror()); |
| 593 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); | 593 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); |
| 594 return v8_listener; | 594 return v8_listener; |
| 595 } | 595 } |
| 596 return v8::Undefined(); | 596 return v8::Undefined(); |
| 597 } | 597 } |
| 598 | 598 |
| 599 ACCESSOR_SETTER(XMLHttpRequestUploadOnerror) { | 599 ACCESSOR_SETTER(XMLHttpRequestUploadOnerror) { |
| 600 INC_STATS(L"DOM.XMLHttpRequestUpload.onerror._set"); | 600 INC_STATS("DOM.XMLHttpRequestUpload.onerror._set"); |
| 601 XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>( | 601 XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>( |
| 602 V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); | 602 V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); |
| 603 if (value->IsNull()) { | 603 if (value->IsNull()) { |
| 604 if (imp->onerror()) { | 604 if (imp->onerror()) { |
| 605 V8ObjectEventListener* listener = | 605 V8ObjectEventListener* listener = |
| 606 static_cast<V8ObjectEventListener*>(imp->onerror()); | 606 static_cast<V8ObjectEventListener*>(imp->onerror()); |
| 607 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); | 607 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); |
| 608 RemoveHiddenXHRDependency(info.Holder(), v8_listener); | 608 RemoveHiddenXHRDependency(info.Holder(), v8_listener); |
| 609 } | 609 } |
| 610 | 610 |
| 611 // Clear the listener | 611 // Clear the listener |
| 612 imp->setOnerror(0); | 612 imp->setOnerror(0); |
| 613 } else { | 613 } else { |
| 614 XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest(); | 614 XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest(); |
| 615 V8Proxy* proxy = V8Proxy::retrieve(xmlhttprequest->scriptExecutionContext())
; | 615 V8Proxy* proxy = V8Proxy::retrieve(xmlhttprequest->scriptExecutionContext())
; |
| 616 if (!proxy) | 616 if (!proxy) |
| 617 return; | 617 return; |
| 618 | 618 |
| 619 RefPtr<EventListener> listener = | 619 RefPtr<EventListener> listener = |
| 620 proxy->FindOrCreateObjectEventListener(value, false); | 620 proxy->FindOrCreateObjectEventListener(value, false); |
| 621 if (listener) { | 621 if (listener) { |
| 622 imp->setOnerror(listener); | 622 imp->setOnerror(listener); |
| 623 CreateHiddenXHRDependency(info.Holder(), value); | 623 CreateHiddenXHRDependency(info.Holder(), value); |
| 624 } | 624 } |
| 625 } | 625 } |
| 626 } | 626 } |
| 627 | 627 |
| 628 ACCESSOR_GETTER(XMLHttpRequestUploadOnload) { | 628 ACCESSOR_GETTER(XMLHttpRequestUploadOnload) { |
| 629 INC_STATS(L"DOM.XMLHttpRequestUpload.onload._get"); | 629 INC_STATS("DOM.XMLHttpRequestUpload.onload._get"); |
| 630 XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>( | 630 XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>( |
| 631 V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); | 631 V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); |
| 632 if (imp->onload()) { | 632 if (imp->onload()) { |
| 633 V8ObjectEventListener* listener = | 633 V8ObjectEventListener* listener = |
| 634 static_cast<V8ObjectEventListener*>(imp->onload()); | 634 static_cast<V8ObjectEventListener*>(imp->onload()); |
| 635 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); | 635 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); |
| 636 return v8_listener; | 636 return v8_listener; |
| 637 } | 637 } |
| 638 return v8::Undefined(); | 638 return v8::Undefined(); |
| 639 } | 639 } |
| 640 | 640 |
| 641 ACCESSOR_SETTER(XMLHttpRequestUploadOnload) { | 641 ACCESSOR_SETTER(XMLHttpRequestUploadOnload) { |
| 642 INC_STATS(L"DOM.XMLHttpRequestUpload.onload._set"); | 642 INC_STATS("DOM.XMLHttpRequestUpload.onload._set"); |
| 643 XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>( | 643 XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>( |
| 644 V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); | 644 V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); |
| 645 if (value->IsNull()) { | 645 if (value->IsNull()) { |
| 646 if (imp->onload()) { | 646 if (imp->onload()) { |
| 647 V8ObjectEventListener* listener = | 647 V8ObjectEventListener* listener = |
| 648 static_cast<V8ObjectEventListener*>(imp->onload()); | 648 static_cast<V8ObjectEventListener*>(imp->onload()); |
| 649 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); | 649 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); |
| 650 RemoveHiddenXHRDependency(info.Holder(), v8_listener); | 650 RemoveHiddenXHRDependency(info.Holder(), v8_listener); |
| 651 } | 651 } |
| 652 | 652 |
| 653 // Clear the listener | 653 // Clear the listener |
| 654 imp->setOnload(0); | 654 imp->setOnload(0); |
| 655 } else { | 655 } else { |
| 656 XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest(); | 656 XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest(); |
| 657 V8Proxy* proxy = V8Proxy::retrieve(xmlhttprequest->scriptExecutionContext())
; | 657 V8Proxy* proxy = V8Proxy::retrieve(xmlhttprequest->scriptExecutionContext())
; |
| 658 if (!proxy) | 658 if (!proxy) |
| 659 return; | 659 return; |
| 660 | 660 |
| 661 RefPtr<EventListener> listener = | 661 RefPtr<EventListener> listener = |
| 662 proxy->FindOrCreateObjectEventListener(value, false); | 662 proxy->FindOrCreateObjectEventListener(value, false); |
| 663 if (listener) { | 663 if (listener) { |
| 664 imp->setOnload(listener); | 664 imp->setOnload(listener); |
| 665 CreateHiddenXHRDependency(info.Holder(), value); | 665 CreateHiddenXHRDependency(info.Holder(), value); |
| 666 } | 666 } |
| 667 } | 667 } |
| 668 } | 668 } |
| 669 | 669 |
| 670 ACCESSOR_GETTER(XMLHttpRequestUploadOnloadstart) { | 670 ACCESSOR_GETTER(XMLHttpRequestUploadOnloadstart) { |
| 671 INC_STATS(L"DOM.XMLHttpRequestUpload.onloadstart._get"); | 671 INC_STATS("DOM.XMLHttpRequestUpload.onloadstart._get"); |
| 672 XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>( | 672 XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>( |
| 673 V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); | 673 V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); |
| 674 if (imp->onloadstart()) { | 674 if (imp->onloadstart()) { |
| 675 V8ObjectEventListener* listener = | 675 V8ObjectEventListener* listener = |
| 676 static_cast<V8ObjectEventListener*>(imp->onloadstart()); | 676 static_cast<V8ObjectEventListener*>(imp->onloadstart()); |
| 677 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); | 677 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); |
| 678 return v8_listener; | 678 return v8_listener; |
| 679 } | 679 } |
| 680 return v8::Undefined(); | 680 return v8::Undefined(); |
| 681 } | 681 } |
| 682 | 682 |
| 683 ACCESSOR_SETTER(XMLHttpRequestUploadOnloadstart) { | 683 ACCESSOR_SETTER(XMLHttpRequestUploadOnloadstart) { |
| 684 INC_STATS(L"DOM.XMLHttpRequestUpload.onloadstart._set"); | 684 INC_STATS("DOM.XMLHttpRequestUpload.onloadstart._set"); |
| 685 XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>( | 685 XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>( |
| 686 V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); | 686 V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); |
| 687 if (value->IsNull()) { | 687 if (value->IsNull()) { |
| 688 if (imp->onloadstart()) { | 688 if (imp->onloadstart()) { |
| 689 V8ObjectEventListener* listener = | 689 V8ObjectEventListener* listener = |
| 690 static_cast<V8ObjectEventListener*>(imp->onloadstart()); | 690 static_cast<V8ObjectEventListener*>(imp->onloadstart()); |
| 691 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); | 691 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); |
| 692 RemoveHiddenXHRDependency(info.Holder(), v8_listener); | 692 RemoveHiddenXHRDependency(info.Holder(), v8_listener); |
| 693 } | 693 } |
| 694 | 694 |
| 695 // Clear the listener | 695 // Clear the listener |
| 696 imp->setOnloadstart(0); | 696 imp->setOnloadstart(0); |
| 697 } else { | 697 } else { |
| 698 XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest(); | 698 XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest(); |
| 699 V8Proxy* proxy = V8Proxy::retrieve(xmlhttprequest->scriptExecutionContext())
; | 699 V8Proxy* proxy = V8Proxy::retrieve(xmlhttprequest->scriptExecutionContext())
; |
| 700 if (!proxy) | 700 if (!proxy) |
| 701 return; | 701 return; |
| 702 | 702 |
| 703 RefPtr<EventListener> listener = | 703 RefPtr<EventListener> listener = |
| 704 proxy->FindOrCreateObjectEventListener(value, false); | 704 proxy->FindOrCreateObjectEventListener(value, false); |
| 705 if (listener) { | 705 if (listener) { |
| 706 imp->setOnloadstart(listener); | 706 imp->setOnloadstart(listener); |
| 707 CreateHiddenXHRDependency(info.Holder(), value); | 707 CreateHiddenXHRDependency(info.Holder(), value); |
| 708 } | 708 } |
| 709 } | 709 } |
| 710 } | 710 } |
| 711 | 711 |
| 712 ACCESSOR_GETTER(XMLHttpRequestUploadOnprogress) { | 712 ACCESSOR_GETTER(XMLHttpRequestUploadOnprogress) { |
| 713 INC_STATS(L"DOM.XMLHttpRequestUpload.onprogress._get"); | 713 INC_STATS("DOM.XMLHttpRequestUpload.onprogress._get"); |
| 714 XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>( | 714 XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>( |
| 715 V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); | 715 V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); |
| 716 if (imp->onprogress()) { | 716 if (imp->onprogress()) { |
| 717 V8ObjectEventListener* listener = | 717 V8ObjectEventListener* listener = |
| 718 static_cast<V8ObjectEventListener*>(imp->onprogress()); | 718 static_cast<V8ObjectEventListener*>(imp->onprogress()); |
| 719 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); | 719 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); |
| 720 return v8_listener; | 720 return v8_listener; |
| 721 } | 721 } |
| 722 return v8::Undefined(); | 722 return v8::Undefined(); |
| 723 } | 723 } |
| 724 | 724 |
| 725 ACCESSOR_SETTER(XMLHttpRequestUploadOnprogress) { | 725 ACCESSOR_SETTER(XMLHttpRequestUploadOnprogress) { |
| 726 INC_STATS(L"DOM.XMLHttpRequestUpload.onprogress._set"); | 726 INC_STATS("DOM.XMLHttpRequestUpload.onprogress._set"); |
| 727 XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>( | 727 XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>( |
| 728 V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); | 728 V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); |
| 729 if (value->IsNull()) { | 729 if (value->IsNull()) { |
| 730 if (imp->onprogress()) { | 730 if (imp->onprogress()) { |
| 731 V8ObjectEventListener* listener = | 731 V8ObjectEventListener* listener = |
| 732 static_cast<V8ObjectEventListener*>(imp->onprogress()); | 732 static_cast<V8ObjectEventListener*>(imp->onprogress()); |
| 733 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); | 733 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); |
| 734 RemoveHiddenXHRDependency(info.Holder(), v8_listener); | 734 RemoveHiddenXHRDependency(info.Holder(), v8_listener); |
| 735 } | 735 } |
| 736 | 736 |
| 737 // Clear the listener | 737 // Clear the listener |
| 738 imp->setOnprogress(0); | 738 imp->setOnprogress(0); |
| 739 } else { | 739 } else { |
| 740 XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest(); | 740 XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest(); |
| 741 V8Proxy* proxy = V8Proxy::retrieve(xmlhttprequest->scriptExecutionContext())
; | 741 V8Proxy* proxy = V8Proxy::retrieve(xmlhttprequest->scriptExecutionContext())
; |
| 742 if (!proxy) | 742 if (!proxy) |
| 743 return; | 743 return; |
| 744 | 744 |
| 745 RefPtr<EventListener> listener = | 745 RefPtr<EventListener> listener = |
| 746 proxy->FindOrCreateObjectEventListener(value, false); | 746 proxy->FindOrCreateObjectEventListener(value, false); |
| 747 if (listener) { | 747 if (listener) { |
| 748 imp->setOnprogress(listener); | 748 imp->setOnprogress(listener); |
| 749 CreateHiddenXHRDependency(info.Holder(), value); | 749 CreateHiddenXHRDependency(info.Holder(), value); |
| 750 } | 750 } |
| 751 } | 751 } |
| 752 } | 752 } |
| 753 | 753 |
| 754 CALLBACK_FUNC_DECL(XMLHttpRequestUploadAddEventListener) { | 754 CALLBACK_FUNC_DECL(XMLHttpRequestUploadAddEventListener) { |
| 755 INC_STATS(L"DOM.XMLHttpRequestUpload.addEventListener()"); | 755 INC_STATS("DOM.XMLHttpRequestUpload.addEventListener()"); |
| 756 XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>( | 756 XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>( |
| 757 V8ClassIndex::XMLHTTPREQUESTUPLOAD, args.Holder()); | 757 V8ClassIndex::XMLHTTPREQUESTUPLOAD, args.Holder()); |
| 758 | 758 |
| 759 XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest(); | 759 XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest(); |
| 760 V8Proxy* proxy = V8Proxy::retrieve(xmlhttprequest->scriptExecutionContext()); | 760 V8Proxy* proxy = V8Proxy::retrieve(xmlhttprequest->scriptExecutionContext()); |
| 761 if (!proxy) | 761 if (!proxy) |
| 762 return v8::Undefined(); | 762 return v8::Undefined(); |
| 763 | 763 |
| 764 RefPtr<EventListener> listener = | 764 RefPtr<EventListener> listener = |
| 765 proxy->FindOrCreateObjectEventListener(args[1], false); | 765 proxy->FindOrCreateObjectEventListener(args[1], false); |
| 766 if (listener) { | 766 if (listener) { |
| 767 String type = ToWebCoreString(args[0]); | 767 String type = ToWebCoreString(args[0]); |
| 768 bool useCapture = args[2]->BooleanValue(); | 768 bool useCapture = args[2]->BooleanValue(); |
| 769 imp->addEventListener(type, listener, useCapture); | 769 imp->addEventListener(type, listener, useCapture); |
| 770 | 770 |
| 771 CreateHiddenXHRDependency(args.Holder(), args[1]); | 771 CreateHiddenXHRDependency(args.Holder(), args[1]); |
| 772 } | 772 } |
| 773 return v8::Undefined(); | 773 return v8::Undefined(); |
| 774 } | 774 } |
| 775 | 775 |
| 776 CALLBACK_FUNC_DECL(XMLHttpRequestUploadRemoveEventListener) { | 776 CALLBACK_FUNC_DECL(XMLHttpRequestUploadRemoveEventListener) { |
| 777 INC_STATS(L"DOM.XMLHttpRequestUpload.removeEventListener()"); | 777 INC_STATS("DOM.XMLHttpRequestUpload.removeEventListener()"); |
| 778 XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>( | 778 XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>( |
| 779 V8ClassIndex::XMLHTTPREQUESTUPLOAD, args.Holder()); | 779 V8ClassIndex::XMLHTTPREQUESTUPLOAD, args.Holder()); |
| 780 | 780 |
| 781 XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest(); | 781 XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest(); |
| 782 V8Proxy* proxy = V8Proxy::retrieve(xmlhttprequest->scriptExecutionContext()); | 782 V8Proxy* proxy = V8Proxy::retrieve(xmlhttprequest->scriptExecutionContext()); |
| 783 if (!proxy) | 783 if (!proxy) |
| 784 return v8::Undefined(); // probably leaked | 784 return v8::Undefined(); // probably leaked |
| 785 | 785 |
| 786 RefPtr<EventListener> listener = | 786 RefPtr<EventListener> listener = |
| 787 proxy->FindObjectEventListener(args[1], false); | 787 proxy->FindObjectEventListener(args[1], false); |
| 788 | 788 |
| 789 if (listener) { | 789 if (listener) { |
| 790 String type = ToWebCoreString(args[0]); | 790 String type = ToWebCoreString(args[0]); |
| 791 bool useCapture = args[2]->BooleanValue(); | 791 bool useCapture = args[2]->BooleanValue(); |
| 792 imp->removeEventListener(type, listener.get(), useCapture); | 792 imp->removeEventListener(type, listener.get(), useCapture); |
| 793 | 793 |
| 794 RemoveHiddenXHRDependency(args.Holder(), args[1]); | 794 RemoveHiddenXHRDependency(args.Holder(), args[1]); |
| 795 } | 795 } |
| 796 | 796 |
| 797 return v8::Undefined(); | 797 return v8::Undefined(); |
| 798 } | 798 } |
| 799 | 799 |
| 800 CALLBACK_FUNC_DECL(XMLHttpRequestUploadDispatchEvent) { | 800 CALLBACK_FUNC_DECL(XMLHttpRequestUploadDispatchEvent) { |
| 801 INC_STATS(L"DOM.XMLHttpRequestUpload.dispatchEvent()"); | 801 INC_STATS("DOM.XMLHttpRequestUpload.dispatchEvent()"); |
| 802 V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); | 802 V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); |
| 803 return v8::Undefined(); | 803 return v8::Undefined(); |
| 804 } | 804 } |
| 805 | 805 |
| 806 } // namespace WebCore | 806 } // namespace WebCore |
| OLD | NEW |