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

Side by Side Diff: webkit/port/bindings/v8/v8_custom.cpp

Issue 3195: Use static type information from IDL to streamline the wrapping and unwrappin... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 3 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 /* 1 /*
2 * This file is part of the KDE libraries 2 * This file is part of the KDE libraries
3 * Copyright (C) 2000 Harri Porten (porten@kde.org) 3 * Copyright (C) 2000 Harri Porten (porten@kde.org)
4 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 4 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
5 * Copyright (C) 2004-2006 Apple Computer, Inc. 5 * Copyright (C) 2004-2006 Apple Computer, Inc.
6 * Copyright (C) 2006 James G. Speth (speth@end.com) 6 * Copyright (C) 2006 James G. Speth (speth@end.com)
7 * Copyright (C) 2006 Samuel Weinig (sam@webkit.org) 7 * Copyright (C) 2006 Samuel Weinig (sam@webkit.org)
8 * Copyright 2007 Google Inc. All Rights Reserved. 8 * Copyright 2007 Google Inc. All Rights Reserved.
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 XSLTProcessor>(args); 312 XSLTProcessor>(args);
313 } 313 }
314 314
315 315
316 CALLBACK_FUNC_DECL(XSLTProcessorImportStylesheet) { 316 CALLBACK_FUNC_DECL(XSLTProcessorImportStylesheet) {
317 INC_STATS(L"DOM.XSLTProcessor.importStylesheet"); 317 INC_STATS(L"DOM.XSLTProcessor.importStylesheet");
318 // Return undefined if argument does not have the correct type. 318 // Return undefined if argument does not have the correct type.
319 if (!V8Node::HasInstance(args[0])) 319 if (!V8Node::HasInstance(args[0]))
320 return v8::Undefined(); 320 return v8::Undefined();
321 321
322 XSLTProcessor* imp = V8Proxy::FastToNativeObject<XSLTProcessor>( 322 XSLTProcessor* imp = V8Proxy::ToNativeObject<XSLTProcessor>(
323 V8ClassIndex::XSLTPROCESSOR, args.Holder()); 323 V8ClassIndex::XSLTPROCESSOR, args.Holder());
324 324
325 Node* node = V8Proxy::FastToNativeObject<Node>(V8ClassIndex::NODE, args[0]); 325 Node* node = V8Proxy::DOMWrapperToNode<Node>(args[0]);
326 imp->importStylesheet(node); 326 imp->importStylesheet(node);
327 return v8::Undefined(); 327 return v8::Undefined();
328 } 328 }
329 329
330 330
331 CALLBACK_FUNC_DECL(XSLTProcessorTransformToFragment) { 331 CALLBACK_FUNC_DECL(XSLTProcessorTransformToFragment) {
332 INC_STATS(L"DOM.XSLTProcessor.transformToFragment"); 332 INC_STATS(L"DOM.XSLTProcessor.transformToFragment");
333 // Return undefined if arguments do not have correct types. 333 // Return undefined if arguments do not have correct types.
334 if (!V8Node::HasInstance(args[0]) || !V8Document::HasInstance(args[1])) 334 if (!V8Node::HasInstance(args[0]) || !V8Document::HasInstance(args[1]))
335 return v8::Undefined(); 335 return v8::Undefined();
336 336
337 XSLTProcessor* imp = V8Proxy::FastToNativeObject<XSLTProcessor>( 337 XSLTProcessor* imp = V8Proxy::ToNativeObject<XSLTProcessor>(
338 V8ClassIndex::XSLTPROCESSOR, args.Holder()); 338 V8ClassIndex::XSLTPROCESSOR, args.Holder());
339 339
340 Node* source = V8Proxy::FastToNativeObject<Node>(V8ClassIndex::NODE, args[0]); 340 Node* source = V8Proxy::DOMWrapperToNode<Node>(args[0]);
341 Document* owner = 341 Document* owner =
342 V8Proxy::FastToNativeObject<Document>(V8ClassIndex::NODE, args[1]); 342 V8Proxy::DOMWrapperToNode<Document>(args[1]);
343 RefPtr<DocumentFragment> result = imp->transformToFragment(source, owner); 343 RefPtr<DocumentFragment> result = imp->transformToFragment(source, owner);
344 return V8Proxy::ToV8Object(V8ClassIndex::NODE, result.get()); 344 return V8Proxy::NodeToV8Object(result.get());
345 } 345 }
346 346
347 347
348 CALLBACK_FUNC_DECL(XSLTProcessorTransformToDocument) { 348 CALLBACK_FUNC_DECL(XSLTProcessorTransformToDocument) {
349 INC_STATS(L"DOM.XSLTProcessor.transformToDocument"); 349 INC_STATS(L"DOM.XSLTProcessor.transformToDocument");
350 // Return undefined if argument does not have the correct type. 350 // Return undefined if argument does not have the correct type.
351 if (!V8Node::HasInstance(args[0])) 351 if (!V8Node::HasInstance(args[0]))
352 return v8::Undefined(); 352 return v8::Undefined();
353 353
354 XSLTProcessor* imp = V8Proxy::FastToNativeObject<XSLTProcessor>( 354 XSLTProcessor* imp = V8Proxy::ToNativeObject<XSLTProcessor>(
355 V8ClassIndex::XSLTPROCESSOR, args.Holder()); 355 V8ClassIndex::XSLTPROCESSOR, args.Holder());
356 356
357 Node* source = V8Proxy::FastToNativeObject<Node>(V8ClassIndex::NODE, args[0]); 357 Node* source = V8Proxy::DOMWrapperToNode<Node>(args[0]);
358 if (!source) return v8::Undefined(); 358 if (!source) return v8::Undefined();
359 RefPtr<Document> result = imp->transformToDocument(source); 359 RefPtr<Document> result = imp->transformToDocument(source);
360 // Return undefined if no result was found. 360 // Return undefined if no result was found.
361 if (!result) return v8::Undefined(); 361 if (!result) return v8::Undefined();
362 return V8Proxy::ToV8Object(V8ClassIndex::NODE, result.get()); 362 return V8Proxy::NodeToV8Object(result.get());
363 } 363 }
364 364
365 365
366 CALLBACK_FUNC_DECL(XSLTProcessorSetParameter) { 366 CALLBACK_FUNC_DECL(XSLTProcessorSetParameter) {
367 INC_STATS(L"DOM.XSLTProcessor.setParameter"); 367 INC_STATS(L"DOM.XSLTProcessor.setParameter");
368 // Bail out if localName or value is null or undefined. 368 // Bail out if localName or value is null or undefined.
369 if (args[1]->IsNull() || args[1]->IsUndefined() || 369 if (args[1]->IsNull() || args[1]->IsUndefined() ||
370 args[2]->IsNull() || args[2]->IsUndefined()) { 370 args[2]->IsNull() || args[2]->IsUndefined()) {
371 return v8::Undefined(); 371 return v8::Undefined();
372 } 372 }
373 373
374 XSLTProcessor* imp = V8Proxy::FastToNativeObject<XSLTProcessor>( 374 XSLTProcessor* imp = V8Proxy::ToNativeObject<XSLTProcessor>(
375 V8ClassIndex::XSLTPROCESSOR, args.Holder()); 375 V8ClassIndex::XSLTPROCESSOR, args.Holder());
376 376
377 String namespaceURI = ToWebCoreString(args[0]); 377 String namespaceURI = ToWebCoreString(args[0]);
378 String localName = ToWebCoreString(args[1]); 378 String localName = ToWebCoreString(args[1]);
379 String value = ToWebCoreString(args[2]); 379 String value = ToWebCoreString(args[2]);
380 imp->setParameter(namespaceURI, localName, value); 380 imp->setParameter(namespaceURI, localName, value);
381 return v8::Undefined(); 381 return v8::Undefined();
382 } 382 }
383 383
384 384
385 CALLBACK_FUNC_DECL(XSLTProcessorGetParameter) { 385 CALLBACK_FUNC_DECL(XSLTProcessorGetParameter) {
386 INC_STATS(L"DOM.XSLTProcessor.getParameter"); 386 INC_STATS(L"DOM.XSLTProcessor.getParameter");
387 // Bail out if localName is null or undefined. 387 // Bail out if localName is null or undefined.
388 if (args[1]->IsNull() || args[1]->IsUndefined()) { 388 if (args[1]->IsNull() || args[1]->IsUndefined()) {
389 return v8::Undefined(); 389 return v8::Undefined();
390 } 390 }
391 391
392 XSLTProcessor* imp = V8Proxy::FastToNativeObject<XSLTProcessor>( 392 XSLTProcessor* imp = V8Proxy::ToNativeObject<XSLTProcessor>(
393 V8ClassIndex::XSLTPROCESSOR, args.Holder()); 393 V8ClassIndex::XSLTPROCESSOR, args.Holder());
394 394
395 String namespaceURI = ToWebCoreString(args[0]); 395 String namespaceURI = ToWebCoreString(args[0]);
396 String localName = ToWebCoreString(args[1]); 396 String localName = ToWebCoreString(args[1]);
397 String result = imp->getParameter(namespaceURI, localName); 397 String result = imp->getParameter(namespaceURI, localName);
398 // Return undefined if the string is null. 398 // Return undefined if the string is null.
399 if (result.isNull()) return v8::Undefined(); 399 if (result.isNull()) return v8::Undefined();
400 return v8String(result); 400 return v8String(result);
401 } 401 }
402 402
403 403
404 CALLBACK_FUNC_DECL(XSLTProcessorRemoveParameter) { 404 CALLBACK_FUNC_DECL(XSLTProcessorRemoveParameter) {
405 INC_STATS(L"DOM.XSLTProcessor.removeParameter"); 405 INC_STATS(L"DOM.XSLTProcessor.removeParameter");
406 // Bail out if localName is null or undefined. 406 // Bail out if localName is null or undefined.
407 if (args[1]->IsNull() || args[1]->IsUndefined()) { 407 if (args[1]->IsNull() || args[1]->IsUndefined()) {
408 return v8::Undefined(); 408 return v8::Undefined();
409 } 409 }
410 410
411 XSLTProcessor* imp = V8Proxy::FastToNativeObject<XSLTProcessor>( 411 XSLTProcessor* imp = V8Proxy::ToNativeObject<XSLTProcessor>(
412 V8ClassIndex::XSLTPROCESSOR, args.Holder()); 412 V8ClassIndex::XSLTPROCESSOR, args.Holder());
413 413
414 String namespaceURI = ToWebCoreString(args[0]); 414 String namespaceURI = ToWebCoreString(args[0]);
415 String localName = ToWebCoreString(args[1]); 415 String localName = ToWebCoreString(args[1]);
416 imp->removeParameter(namespaceURI, localName); 416 imp->removeParameter(namespaceURI, localName);
417 return v8::Undefined(); 417 return v8::Undefined();
418 } 418 }
419 419
420 420
421 // ---- Canvas support ---- 421 // ---- Canvas support ----
422 static v8::Handle<v8::Value> CanvasStyleToV8Object(CanvasStyle* style) { 422 static v8::Handle<v8::Value> CanvasStyleToV8Object(CanvasStyle* style) {
423 if (style->gradient()) { 423 if (style->gradient()) {
424 return V8Proxy::ToV8Object(V8ClassIndex::CANVASGRADIENT, 424 return V8Proxy::ToV8Object(V8ClassIndex::CANVASGRADIENT,
425 static_cast<Peerable*>(style->gradient())); 425 static_cast<Peerable*>(style->gradient()));
426 } 426 }
427 if (style->pattern()) { 427 if (style->pattern()) {
428 return V8Proxy::ToV8Object(V8ClassIndex::CANVASPATTERN, 428 return V8Proxy::ToV8Object(V8ClassIndex::CANVASPATTERN,
429 static_cast<Peerable*>(style->pattern())); 429 static_cast<Peerable*>(style->pattern()));
430 } 430 }
431 return v8String(style->color()); 431 return v8String(style->color());
432 } 432 }
433 433
434 434
435 static PassRefPtr<CanvasStyle> V8ObjectToCanvasStyle( 435 static PassRefPtr<CanvasStyle> V8ObjectToCanvasStyle(
436 v8::Handle<v8::Value> value) { 436 v8::Handle<v8::Value> value) {
437 if (value->IsString()) return new CanvasStyle(ToWebCoreString(value)); 437 if (value->IsString()) return new CanvasStyle(ToWebCoreString(value));
438 438
439 if (V8CanvasGradient::HasInstance(value)) { 439 if (V8CanvasGradient::HasInstance(value)) {
440 CanvasGradient* gradient = 440 CanvasGradient* gradient =
441 V8Proxy::FastDOMWrapperToNative<CanvasGradient>(value); 441 V8Proxy::DOMWrapperToNative<CanvasGradient>(value);
442 return new CanvasStyle(gradient); 442 return new CanvasStyle(gradient);
443 } 443 }
444 444
445 if (V8CanvasPattern::HasInstance(value)) { 445 if (V8CanvasPattern::HasInstance(value)) {
446 CanvasPattern* pattern = 446 CanvasPattern* pattern =
447 V8Proxy::FastDOMWrapperToNative<CanvasPattern>(value); 447 V8Proxy::DOMWrapperToNative<CanvasPattern>(value);
448 return new CanvasStyle(pattern); 448 return new CanvasStyle(pattern);
449 } 449 }
450 450
451 return 0; 451 return 0;
452 } 452 }
453 453
454 454
455 ACCESSOR_GETTER(CanvasRenderingContext2DStrokeStyle) { 455 ACCESSOR_GETTER(CanvasRenderingContext2DStrokeStyle) {
456 CanvasRenderingContext2D* impl = 456 CanvasRenderingContext2D* impl =
457 V8Proxy::FastDOMWrapperToNative<CanvasRenderingContext2D>(info.Holder()); 457 V8Proxy::DOMWrapperToNative<CanvasRenderingContext2D>(info.Holder());
458 CanvasStyle* strokeStyle = impl->strokeStyle(); 458 CanvasStyle* strokeStyle = impl->strokeStyle();
459 return CanvasStyleToV8Object(strokeStyle); 459 return CanvasStyleToV8Object(strokeStyle);
460 } 460 }
461 461
462 462
463 ACCESSOR_SETTER(CanvasRenderingContext2DStrokeStyle) { 463 ACCESSOR_SETTER(CanvasRenderingContext2DStrokeStyle) {
464 CanvasRenderingContext2D* impl = 464 CanvasRenderingContext2D* impl =
465 V8Proxy::FastDOMWrapperToNative<CanvasRenderingContext2D>(info.Holder()); 465 V8Proxy::DOMWrapperToNative<CanvasRenderingContext2D>(info.Holder());
466 impl->setStrokeStyle(V8ObjectToCanvasStyle(value)); 466 impl->setStrokeStyle(V8ObjectToCanvasStyle(value));
467 } 467 }
468 468
469 ACCESSOR_GETTER(CanvasRenderingContext2DFillStyle) { 469 ACCESSOR_GETTER(CanvasRenderingContext2DFillStyle) {
470 CanvasRenderingContext2D* impl = 470 CanvasRenderingContext2D* impl =
471 V8Proxy::FastDOMWrapperToNative<CanvasRenderingContext2D>(info.Holder()); 471 V8Proxy::DOMWrapperToNative<CanvasRenderingContext2D>(info.Holder());
472 CanvasStyle* fillStyle = impl->fillStyle(); 472 CanvasStyle* fillStyle = impl->fillStyle();
473 return CanvasStyleToV8Object(fillStyle); 473 return CanvasStyleToV8Object(fillStyle);
474 } 474 }
475 475
476 476
477 ACCESSOR_SETTER(CanvasRenderingContext2DFillStyle) { 477 ACCESSOR_SETTER(CanvasRenderingContext2DFillStyle) {
478 CanvasRenderingContext2D* impl = 478 CanvasRenderingContext2D* impl =
479 V8Proxy::FastDOMWrapperToNative<CanvasRenderingContext2D>(info.Holder()); 479 V8Proxy::DOMWrapperToNative<CanvasRenderingContext2D>(info.Holder());
480 impl->setFillStyle(V8ObjectToCanvasStyle(value)); 480 impl->setFillStyle(V8ObjectToCanvasStyle(value));
481 } 481 }
482 482
483 483
484 // DOMImplementation is a singleton in WebCore. If we use our normal 484 // DOMImplementation is a singleton in WebCore. If we use our normal
485 // mapping from DOM objects to V8 wrappers, the same wrapper will be 485 // mapping from DOM objects to V8 wrappers, the same wrapper will be
486 // shared for all frames in the same process. This is a major 486 // shared for all frames in the same process. This is a major
487 // security problem. Therefore, we generate a DOMImplementation 487 // security problem. Therefore, we generate a DOMImplementation
488 // wrapper per document and store it in an internal field of the 488 // wrapper per document and store it in an internal field of the
489 // document. Since the DOMImplementation object is a singleton, we do 489 // document. Since the DOMImplementation object is a singleton, we do
490 // not have to do anything to keep the DOMImplementation object alive 490 // not have to do anything to keep the DOMImplementation object alive
491 // for the lifetime of the wrapper. 491 // for the lifetime of the wrapper.
492 ACCESSOR_GETTER(DocumentImplementation) { 492 ACCESSOR_GETTER(DocumentImplementation) {
493 ASSERT(info.Holder()->InternalFieldCount() >= 493 ASSERT(info.Holder()->InternalFieldCount() >=
494 kDocumentMinimumInternalFieldCount); 494 kDocumentMinimumInternalFieldCount);
495 // Check if the internal field already contains a wrapper. 495 // Check if the internal field already contains a wrapper.
496 v8::Local<v8::Value> implementation = 496 v8::Local<v8::Value> implementation =
497 info.Holder()->GetInternalField(kDocumentImplementationIndex); 497 info.Holder()->GetInternalField(kDocumentImplementationIndex);
498 if (!implementation->IsUndefined()) { 498 if (!implementation->IsUndefined()) {
499 return implementation; 499 return implementation;
500 } 500 }
501 // Generate a wrapper. 501 // Generate a wrapper.
502 Document* doc = V8Proxy::FastDOMWrapperToNative<Document>(info.Holder()); 502 Document* doc = V8Proxy::DOMWrapperToNative<Document>(info.Holder());
503 v8::Handle<v8::Value> wrapper = 503 v8::Handle<v8::Value> wrapper =
504 V8Proxy::DOMImplementationToV8Object(doc->implementation()); 504 V8Proxy::DOMImplementationToV8Object(doc->implementation());
505 // Store the wrapper in the internal field. 505 // Store the wrapper in the internal field.
506 info.Holder()->SetInternalField(kDocumentImplementationIndex, wrapper); 506 info.Holder()->SetInternalField(kDocumentImplementationIndex, wrapper);
507 507
508 return wrapper; 508 return wrapper;
509 } 509 }
510 510
511 511
512 ACCESSOR_GETTER(DocumentLocation) { 512 ACCESSOR_GETTER(DocumentLocation) {
513 Document* imp = V8Proxy::FastDOMWrapperToNative<Document>(info.Holder()); 513 Document* imp = V8Proxy::DOMWrapperToNative<Document>(info.Holder());
514 if (!imp->frame()) 514 if (!imp->frame())
515 return v8::Null(); 515 return v8::Null();
516 516
517 DOMWindow* window = imp->frame()->domWindow(); 517 DOMWindow* window = imp->frame()->domWindow();
518 return V8Proxy::ToV8Object(V8ClassIndex::LOCATION, 518 return V8Proxy::ToV8Object(V8ClassIndex::LOCATION,
519 static_cast<Peerable*>(window->location())); 519 static_cast<Peerable*>(window->location()));
520 } 520 }
521 521
522 522
523 ACCESSOR_SETTER(DocumentLocation) { 523 ACCESSOR_SETTER(DocumentLocation) {
524 Document* imp = V8Proxy::FastDOMWrapperToNative<Document>(info.Holder()); 524 Document* imp = V8Proxy::DOMWrapperToNative<Document>(info.Holder());
525 if (!imp->frame()) 525 if (!imp->frame())
526 return; 526 return;
527 527
528 DOMWindow* window = imp->frame()->domWindow(); 528 DOMWindow* window = imp->frame()->domWindow();
529 // DOMWindow::setLocation does security checks. 529 // DOMWindow::setLocation does security checks.
530 window->setLocation(ToWebCoreString(value)); 530 window->setLocation(ToWebCoreString(value));
531 } 531 }
532 532
533 533
534 ACCESSOR_SETTER(DOMWindowLocation) { 534 ACCESSOR_SETTER(DOMWindowLocation) {
535 v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper( 535 v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper(
536 V8ClassIndex::DOMWINDOW, info.This()); 536 V8ClassIndex::DOMWINDOW, info.This());
537 if (holder.IsEmpty()) 537 if (holder.IsEmpty())
538 return; 538 return;
539 539
540 DOMWindow* imp = V8Proxy::FastToNativeObject<DOMWindow>( 540 DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>(
541 V8ClassIndex::DOMWINDOW, holder); 541 V8ClassIndex::DOMWINDOW, holder);
542 imp->setLocation(ToWebCoreString(value)); 542 imp->setLocation(ToWebCoreString(value));
543 } 543 }
544 544
545 545
546 ACCESSOR_SETTER(DOMWindowOpener) { 546 ACCESSOR_SETTER(DOMWindowOpener) {
547 DOMWindow* imp = V8Proxy::FastToNativeObject<DOMWindow>( 547 DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>(
548 V8ClassIndex::DOMWINDOW, info.Holder()); 548 V8ClassIndex::DOMWINDOW, info.Holder());
549 549
550 if (!V8Proxy::IsFromSameOrigin(imp->frame(), true)) 550 if (!V8Proxy::IsFromSameOrigin(imp->frame(), true))
551 return; 551 return;
552 552
553 // Opener can be shadowed if it is in the same domain. 553 // Opener can be shadowed if it is in the same domain.
554 // Have a special handling of null value to behave 554 // Have a special handling of null value to behave
555 // like Firefox. See bug 1224887 & 791706. 555 // like Firefox. See bug 1224887 & 791706.
556 if (value->IsNull()) { 556 if (value->IsNull()) {
557 // imp->frame() cannot be null, 557 // imp->frame() cannot be null,
558 // otherwise, SameOrigin check would have failed. 558 // otherwise, SameOrigin check would have failed.
559 ASSERT(imp->frame()); 559 ASSERT(imp->frame());
560 imp->frame()->loader()->setOpener(0); 560 imp->frame()->loader()->setOpener(0);
561 } 561 }
562 562
563 // Delete the accessor from this object. 563 // Delete the accessor from this object.
564 info.Holder()->Delete(name); 564 info.Holder()->Delete(name);
565 565
566 // Put property on the front (this) object. 566 // Put property on the front (this) object.
567 info.This()->Set(name, value); 567 info.This()->Set(name, value);
568 } 568 }
569 569
570 570
571 ACCESSOR_GETTER(EventSrcElement) { 571 ACCESSOR_GETTER(EventSrcElement) {
572 Event* event = V8Proxy::FastDOMWrapperToNative<Event>(info.Holder()); 572 Event* event = V8Proxy::DOMWrapperToNative<Event>(info.Holder());
573 EventTarget* target = event->target(); 573 EventTarget* target = event->target();
574 return V8Proxy::EventTargetToV8Object(target); 574 return V8Proxy::EventTargetToV8Object(target);
575 } 575 }
576 576
577 577
578 ACCESSOR_GETTER(EventReturnValue) { 578 ACCESSOR_GETTER(EventReturnValue) {
579 Event* event = V8Proxy::FastDOMWrapperToNative<Event>(info.Holder()); 579 Event* event = V8Proxy::DOMWrapperToNative<Event>(info.Holder());
580 return event->defaultPrevented() ? v8::False() : v8::True(); 580 return event->defaultPrevented() ? v8::False() : v8::True();
581 } 581 }
582 582
583 583
584 ACCESSOR_SETTER(EventReturnValue) { 584 ACCESSOR_SETTER(EventReturnValue) {
585 Event* event = V8Proxy::FastDOMWrapperToNative<Event>(info.Holder()); 585 Event* event = V8Proxy::DOMWrapperToNative<Event>(info.Holder());
586 bool v = value->BooleanValue(); 586 bool v = value->BooleanValue();
587 event->setDefaultPrevented(!v); 587 event->setDefaultPrevented(!v);
588 } 588 }
589 589
590 590
591 ACCESSOR_GETTER(EventDataTransfer) { 591 ACCESSOR_GETTER(EventDataTransfer) {
592 Event* event = V8Proxy::FastDOMWrapperToNative<Event>(info.Holder()); 592 Event* event = V8Proxy::DOMWrapperToNative<Event>(info.Holder());
593 593
594 if (event->isDragEvent()) { 594 if (event->isDragEvent()) {
595 MouseEvent* impl = static_cast<MouseEvent*>(event); 595 MouseEvent* impl = static_cast<MouseEvent*>(event);
596 Clipboard* clipboard = impl->clipboard(); 596 Clipboard* clipboard = impl->clipboard();
597 return V8Proxy::ToV8Object(V8ClassIndex::CLIPBOARD, clipboard); 597 return V8Proxy::ToV8Object(V8ClassIndex::CLIPBOARD, clipboard);
598 } 598 }
599 599
600 return v8::Undefined(); 600 return v8::Undefined();
601 } 601 }
602 602
603 603
604 ACCESSOR_GETTER(EventClipboardData) { 604 ACCESSOR_GETTER(EventClipboardData) {
605 Event* event = V8Proxy::FastDOMWrapperToNative<Event>(info.Holder()); 605 Event* event = V8Proxy::DOMWrapperToNative<Event>(info.Holder());
606 606
607 if (event->isClipboardEvent()) { 607 if (event->isClipboardEvent()) {
608 ClipboardEvent* impl = static_cast<ClipboardEvent*>(event); 608 ClipboardEvent* impl = static_cast<ClipboardEvent*>(event);
609 Clipboard* clipboard = impl->clipboard(); 609 Clipboard* clipboard = impl->clipboard();
610 return V8Proxy::ToV8Object(V8ClassIndex::CLIPBOARD, clipboard); 610 return V8Proxy::ToV8Object(V8ClassIndex::CLIPBOARD, clipboard);
611 } 611 }
612 612
613 return v8::Undefined(); 613 return v8::Undefined();
614 } 614 }
615 615
616 616
617 static v8::Handle<v8::Value> HTMLCollectionGetNamedItems( 617 static v8::Handle<v8::Value> HTMLCollectionGetNamedItems(
618 HTMLCollection* collection, String name) { 618 HTMLCollection* collection, String name) {
619 Vector<RefPtr<Node> > namedItems; 619 Vector<RefPtr<Node> > namedItems;
620 collection->namedItems(name, namedItems); 620 collection->namedItems(name, namedItems);
621 switch (namedItems.size()) { 621 switch (namedItems.size()) {
622 case 0: 622 case 0:
623 return v8::Handle<v8::Value>(); 623 return v8::Handle<v8::Value>();
624 case 1: 624 case 1:
625 return V8Proxy::ToV8Object(V8ClassIndex::NODE, namedItems.at(0).get()); 625 return V8Proxy::NodeToV8Object(namedItems.at(0).get());
626 default: 626 default:
627 NodeList* list = new V8VectorNodeList(namedItems); 627 NodeList* list = new V8VectorNodeList(namedItems);
628 return V8Proxy::ToV8Object(V8ClassIndex::NODELIST, 628 return V8Proxy::ToV8Object(V8ClassIndex::NODELIST,
629 static_cast<Peerable*>(list)); 629 static_cast<Peerable*>(list));
630 } 630 }
631 } 631 }
632 632
633 633
634 static v8::Handle<v8::Value> HTMLCollectionGetItem( 634 static v8::Handle<v8::Value> HTMLCollectionGetItem(
635 HTMLCollection* collection, v8::Handle<v8::Value> argument) { 635 HTMLCollection* collection, v8::Handle<v8::Value> argument) {
636 v8::Local<v8::Uint32> index = argument->ToArrayIndex(); 636 v8::Local<v8::Uint32> index = argument->ToArrayIndex();
637 if (index.IsEmpty()) { 637 if (index.IsEmpty()) {
638 v8::Handle<v8::String> str = argument->ToString(); 638 v8::Handle<v8::String> str = argument->ToString();
639 v8::Handle<v8::Value> result = 639 v8::Handle<v8::Value> result =
640 HTMLCollectionGetNamedItems(collection, ToWebCoreString(str)); 640 HTMLCollectionGetNamedItems(collection, ToWebCoreString(str));
641 if (result.IsEmpty()) 641 if (result.IsEmpty())
642 return v8::Undefined(); 642 return v8::Undefined();
643 else 643 else
644 return result; 644 return result;
645 } 645 }
646 unsigned i = index->Uint32Value(); 646 unsigned i = index->Uint32Value();
647 RefPtr<Node> result = collection->item(i); 647 RefPtr<Node> result = collection->item(i);
648 return V8Proxy::ToV8Object(V8ClassIndex::NODE, result.get()); 648 return V8Proxy::NodeToV8Object(result.get());
649 } 649 }
650 650
651 651
652 NAMED_PROPERTY_GETTER(HTMLCollection) { 652 NAMED_PROPERTY_GETTER(HTMLCollection) {
653 INC_STATS(L"DOM.HTMLCollection.NamedPropertyGetter"); 653 INC_STATS(L"DOM.HTMLCollection.NamedPropertyGetter");
654 // Search the prototype chain first. 654 // Search the prototype chain first.
655 v8::Handle<v8::Value> value = 655 v8::Handle<v8::Value> value =
656 info.Holder()->GetRealNamedPropertyInPrototypeChain(name); 656 info.Holder()->GetRealNamedPropertyInPrototypeChain(name);
657 657
658 if (!value.IsEmpty()) { 658 if (!value.IsEmpty()) {
659 return value; 659 return value;
660 } 660 }
661 661
662 // Search local callback properties next to find IDL defined 662 // Search local callback properties next to find IDL defined
663 // properties. 663 // properties.
664 if (info.Holder()->HasRealNamedCallbackProperty(name)) { 664 if (info.Holder()->HasRealNamedCallbackProperty(name)) {
665 return v8::Handle<v8::Value>(); 665 return v8::Handle<v8::Value>();
666 } 666 }
667 667
668 // Finally, search the DOM structure. 668 // Finally, search the DOM structure.
669 HTMLCollection* imp = V8Proxy::FastToNativeObject<HTMLCollection>( 669 HTMLCollection* imp = V8Proxy::ToNativeObject<HTMLCollection>(
670 V8ClassIndex::HTMLCOLLECTION, info.Holder()); 670 V8ClassIndex::HTMLCOLLECTION, info.Holder());
671 String key = ToWebCoreString(name); 671 String key = ToWebCoreString(name);
672 return HTMLCollectionGetNamedItems(imp, key); 672 return HTMLCollectionGetNamedItems(imp, key);
673 } 673 }
674 674
675 675
676 CALLBACK_FUNC_DECL(HTMLCollectionItem) { 676 CALLBACK_FUNC_DECL(HTMLCollectionItem) {
677 INC_STATS(L"DOM.HTMLCollection.item()"); 677 INC_STATS(L"DOM.HTMLCollection.item()");
678 HTMLCollection* imp = V8Proxy::FastToNativeObject<HTMLCollection>( 678 HTMLCollection* imp = V8Proxy::ToNativeObject<HTMLCollection>(
679 V8ClassIndex::HTMLCOLLECTION, args.Holder()); 679 V8ClassIndex::HTMLCOLLECTION, args.Holder());
680 return HTMLCollectionGetItem(imp, args[0]); 680 return HTMLCollectionGetItem(imp, args[0]);
681 } 681 }
682 682
683 683
684 CALLBACK_FUNC_DECL(HTMLCollectionNamedItem) { 684 CALLBACK_FUNC_DECL(HTMLCollectionNamedItem) {
685 INC_STATS(L"DOM.HTMLCollection.namedItem()"); 685 INC_STATS(L"DOM.HTMLCollection.namedItem()");
686 HTMLCollection* imp = V8Proxy::FastToNativeObject<HTMLCollection>( 686 HTMLCollection* imp = V8Proxy::ToNativeObject<HTMLCollection>(
687 V8ClassIndex::HTMLCOLLECTION, args.Holder()); 687 V8ClassIndex::HTMLCOLLECTION, args.Holder());
688 String name = ToWebCoreString(args[0]); 688 String name = ToWebCoreString(args[0]);
689 v8::Handle<v8::Value> result = 689 v8::Handle<v8::Value> result =
690 HTMLCollectionGetNamedItems(imp, name); 690 HTMLCollectionGetNamedItems(imp, name);
691 if (result.IsEmpty()) 691 if (result.IsEmpty())
692 return v8::Undefined(); 692 return v8::Undefined();
693 else 693 else
694 return result; 694 return result;
695 } 695 }
696 696
697 697
698 CALLBACK_FUNC_DECL(HTMLCollectionCallAsFunction) { 698 CALLBACK_FUNC_DECL(HTMLCollectionCallAsFunction) {
699 INC_STATS(L"DOM.HTMLCollection.callAsFunction()"); 699 INC_STATS(L"DOM.HTMLCollection.callAsFunction()");
700 if (args.Length() < 1) return v8::Undefined(); 700 if (args.Length() < 1) return v8::Undefined();
701 701
702 HTMLCollection* imp = V8Proxy::FastToNativeObject<HTMLCollection>( 702 HTMLCollection* imp = V8Proxy::ToNativeObject<HTMLCollection>(
703 V8ClassIndex::HTMLCOLLECTION, args.Holder()); 703 V8ClassIndex::HTMLCOLLECTION, args.Holder());
704 704
705 if (args.Length() == 1) { 705 if (args.Length() == 1) {
706 return HTMLCollectionGetItem(imp, args[0]); 706 return HTMLCollectionGetItem(imp, args[0]);
707 } 707 }
708 708
709 // If there is a second argument it is the index of the item we 709 // If there is a second argument it is the index of the item we
710 // want. 710 // want.
711 String name = ToWebCoreString(args[0]); 711 String name = ToWebCoreString(args[0]);
712 v8::Local<v8::Uint32> index = args[1]->ToArrayIndex(); 712 v8::Local<v8::Uint32> index = args[1]->ToArrayIndex();
713 if (index.IsEmpty()) return v8::Undefined(); 713 if (index.IsEmpty()) return v8::Undefined();
714 unsigned i = index->Uint32Value(); 714 unsigned i = index->Uint32Value();
715 Node* node = imp->namedItem(name); 715 Node* node = imp->namedItem(name);
716 while (node) { 716 while (node) {
717 if (i == 0) return V8Proxy::ToV8Object(V8ClassIndex::NODE, node); 717 if (i == 0) return V8Proxy::NodeToV8Object(node);
718 node = imp->nextNamedItem(name); 718 node = imp->nextNamedItem(name);
719 i--; 719 i--;
720 } 720 }
721 721
722 return v8::Undefined(); 722 return v8::Undefined();
723 } 723 }
724 724
725 725
726 static v8::Handle<v8::Value> V8HTMLSelectElementRemoveHelper( 726 static v8::Handle<v8::Value> V8HTMLSelectElementRemoveHelper(
727 HTMLSelectElement* imp, const v8::Arguments& args) { 727 HTMLSelectElement* imp, const v8::Arguments& args) {
728 if (V8HTMLOptionElement::HasInstance(args[0])) { 728 if (V8HTMLOptionElement::HasInstance(args[0])) {
729 HTMLOptionElement* element = V8Proxy::ToNativeObject<HTMLOptionElement>( 729 HTMLOptionElement* element =
730 V8ClassIndex::HTMLOPTIONELEMENT, args[0]); 730 V8Proxy::DOMWrapperToNode<HTMLOptionElement>(args[0]);
731 imp->remove(element->index()); 731 imp->remove(element->index());
732 return v8::Undefined(); 732 return v8::Undefined();
733 } 733 }
734 734
735 imp->remove(ToInt32(args[0])); 735 imp->remove(ToInt32(args[0]));
736 return v8::Undefined(); 736 return v8::Undefined();
737 } 737 }
738 738
739 CALLBACK_FUNC_DECL(HTMLSelectElementRemove) { 739 CALLBACK_FUNC_DECL(HTMLSelectElementRemove) {
740 INC_STATS(L"DOM.HTMLSelectElement.remove"); 740 INC_STATS(L"DOM.HTMLSelectElement.remove");
741 HTMLSelectElement* imp = V8Proxy::FastToNativeObject<HTMLSelectElement>( 741 HTMLSelectElement* imp =
742 V8ClassIndex::HTMLSELECTELEMENT, args.Holder()); 742 V8Proxy::DOMWrapperToNode<HTMLSelectElement>(args.Holder());
743 return V8HTMLSelectElementRemoveHelper(imp, args); 743 return V8HTMLSelectElementRemoveHelper(imp, args);
744 } 744 }
745 745
746 CALLBACK_FUNC_DECL(HTMLOptionsCollectionRemove) { 746 CALLBACK_FUNC_DECL(HTMLOptionsCollectionRemove) {
747 INC_STATS(L"DOM.HTMLOptionsCollection.remove()"); 747 INC_STATS(L"DOM.HTMLOptionsCollection.remove()");
748 HTMLOptionsCollection* imp = 748 HTMLOptionsCollection* imp =
749 V8Proxy::FastToNativeObject<HTMLOptionsCollection>( 749 V8Proxy::ToNativeObject<HTMLOptionsCollection>(
750 V8ClassIndex::HTMLOPTIONSCOLLECTION, args.Holder()); 750 V8ClassIndex::HTMLOPTIONSCOLLECTION, args.Holder());
751 HTMLSelectElement* base = static_cast<HTMLSelectElement*>(imp->base()); 751 HTMLSelectElement* base = static_cast<HTMLSelectElement*>(imp->base());
752 return V8HTMLSelectElementRemoveHelper(base, args); 752 return V8HTMLSelectElementRemoveHelper(base, args);
753 } 753 }
754 754
755 755
756 CALLBACK_FUNC_DECL(HTMLOptionsCollectionAdd) { 756 CALLBACK_FUNC_DECL(HTMLOptionsCollectionAdd) {
757 INC_STATS(L"DOM.HTMLOptionsCollection.add()"); 757 INC_STATS(L"DOM.HTMLOptionsCollection.add()");
758 if (!V8HTMLOptionElement::HasInstance(args[0])) { 758 if (!V8HTMLOptionElement::HasInstance(args[0])) {
759 V8Proxy::SetDOMException(TYPE_MISMATCH_ERR); 759 V8Proxy::SetDOMException(TYPE_MISMATCH_ERR);
760 return v8::Undefined(); 760 return v8::Undefined();
761 } 761 }
762 HTMLOptionsCollection* imp = 762 HTMLOptionsCollection* imp =
763 V8Proxy::FastToNativeObject<HTMLOptionsCollection>( 763 V8Proxy::ToNativeObject<HTMLOptionsCollection>(
764 V8ClassIndex::HTMLOPTIONSCOLLECTION, args.Holder()); 764 V8ClassIndex::HTMLOPTIONSCOLLECTION, args.Holder());
765 HTMLOptionElement* option = V8Proxy::ToNativeObject<HTMLOptionElement>( 765 HTMLOptionElement* option =
766 V8ClassIndex::NODE, args[0]); 766 V8Proxy::DOMWrapperToNode<HTMLOptionElement>(args[0]);
767 767
768 ExceptionCode ec = 0; 768 ExceptionCode ec = 0;
769 if (args.Length() < 2) { 769 if (args.Length() < 2) {
770 imp->add(option, ec); 770 imp->add(option, ec);
771 } else { 771 } else {
772 bool ok; 772 bool ok;
773 v8::TryCatch try_catch; 773 v8::TryCatch try_catch;
774 int index = ToInt32(args[1], ok); 774 int index = ToInt32(args[1], ok);
775 if (try_catch.HasCaught()) { 775 if (try_catch.HasCaught()) {
776 return v8::Undefined(); 776 return v8::Undefined();
777 } 777 }
778 if (!ok) { 778 if (!ok) {
779 ec = TYPE_MISMATCH_ERR; 779 ec = TYPE_MISMATCH_ERR;
780 } else { 780 } else {
781 imp->add(option, index, ec); 781 imp->add(option, index, ec);
782 } 782 }
783 } 783 }
784 if (ec != 0) { 784 if (ec != 0) {
785 V8Proxy::SetDOMException(ec); 785 V8Proxy::SetDOMException(ec);
786 } 786 }
787 return v8::Undefined(); 787 return v8::Undefined();
788 } 788 }
789 789
790 790
791 CALLBACK_FUNC_DECL(DOMWindowAddEventListener) { 791 CALLBACK_FUNC_DECL(DOMWindowAddEventListener) {
792 INC_STATS(L"DOM.DOMWindow.addEventListener()"); 792 INC_STATS(L"DOM.DOMWindow.addEventListener()");
793 DOMWindow* imp = V8Proxy::FastToNativeObject<DOMWindow>( 793 DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>(
794 V8ClassIndex::DOMWINDOW, args.Holder()); 794 V8ClassIndex::DOMWINDOW, args.Holder());
795 795
796 // Fast check This argument with the global object of security context. 796 // Fast check This argument with the global object of security context.
797 if ((args.This() != v8::Context::GetCurrentSecurityContext()->Global()) && 797 if ((args.This() != v8::Context::GetCurrentSecurityContext()->Global()) &&
798 !V8Proxy::IsFromSameOrigin(imp->frame(), true)) { 798 !V8Proxy::IsFromSameOrigin(imp->frame(), true)) {
799 return v8::Undefined(); 799 return v8::Undefined();
800 } 800 }
801 801
802 if (!imp->frame()) 802 if (!imp->frame())
803 return v8::Undefined(); // DOMWindow could be disconnected from the frame 803 return v8::Undefined(); // DOMWindow could be disconnected from the frame
(...skipping 15 matching lines...) Expand all
819 bool useCapture = args[2]->BooleanValue(); 819 bool useCapture = args[2]->BooleanValue();
820 doc->addWindowEventListener(event_type, listener, useCapture); 820 doc->addWindowEventListener(event_type, listener, useCapture);
821 } 821 }
822 822
823 return v8::Undefined(); 823 return v8::Undefined();
824 } 824 }
825 825
826 826
827 CALLBACK_FUNC_DECL(DOMWindowRemoveEventListener) { 827 CALLBACK_FUNC_DECL(DOMWindowRemoveEventListener) {
828 INC_STATS(L"DOM.DOMWindow.removeEventListener()"); 828 INC_STATS(L"DOM.DOMWindow.removeEventListener()");
829 DOMWindow* imp = V8Proxy::FastToNativeObject<DOMWindow>( 829 DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>(
830 V8ClassIndex::DOMWINDOW, args.Holder()); 830 V8ClassIndex::DOMWINDOW, args.Holder());
831 831
832 // Fast check This argument with the global object of security context. 832 // Fast check This argument with the global object of security context.
833 if ((args.This() != v8::Context::GetCurrentSecurityContext()->Global()) && 833 if ((args.This() != v8::Context::GetCurrentSecurityContext()->Global()) &&
834 !V8Proxy::IsFromSameOrigin(imp->frame(), true)) { 834 !V8Proxy::IsFromSameOrigin(imp->frame(), true)) {
835 return v8::Undefined(); 835 return v8::Undefined();
836 } 836 }
837 837
838 if (!imp->frame()) 838 if (!imp->frame())
839 return v8::Undefined(); 839 return v8::Undefined();
(...skipping 13 matching lines...) Expand all
853 String event_type = ToWebCoreString(args[0]); 853 String event_type = ToWebCoreString(args[0]);
854 bool useCapture = args[2]->BooleanValue(); 854 bool useCapture = args[2]->BooleanValue();
855 doc->removeWindowEventListener(event_type, listener, useCapture); 855 doc->removeWindowEventListener(event_type, listener, useCapture);
856 } 856 }
857 857
858 return v8::Undefined(); 858 return v8::Undefined();
859 } 859 }
860 860
861 CALLBACK_FUNC_DECL(DOMWindowPostMessage) { 861 CALLBACK_FUNC_DECL(DOMWindowPostMessage) {
862 INC_STATS(L"DOM.DOMWindow.postMessage()"); 862 INC_STATS(L"DOM.DOMWindow.postMessage()");
863 DOMWindow* window = V8Proxy::FastToNativeObject<DOMWindow>( 863 DOMWindow* window = V8Proxy::ToNativeObject<DOMWindow>(
864 V8ClassIndex::DOMWINDOW, args.Holder()); 864 V8ClassIndex::DOMWINDOW, args.Holder());
865 865
866 DOMWindow* source = V8Proxy::retrieveActiveFrame()->domWindow(); 866 DOMWindow* source = V8Proxy::retrieveActiveFrame()->domWindow();
867 ASSERT(source->frame()); 867 ASSERT(source->frame());
868 868
869 String domain = source->frame()->loader()->url().host(); 869 String domain = source->frame()->loader()->url().host();
870 String uri = source->frame()->loader()->url().string(); 870 String uri = source->frame()->loader()->url().string();
871 871
872 v8::TryCatch try_catch; 872 v8::TryCatch try_catch;
873 873
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 user_gesture); 995 user_gesture);
996 } 996 }
997 } 997 }
998 998
999 return new_frame; 999 return new_frame;
1000 } 1000 }
1001 1001
1002 1002
1003 CALLBACK_FUNC_DECL(DOMWindowShowModalDialog) { 1003 CALLBACK_FUNC_DECL(DOMWindowShowModalDialog) {
1004 INC_STATS(L"DOM.DOMWindow.showModalDialog()"); 1004 INC_STATS(L"DOM.DOMWindow.showModalDialog()");
1005 DOMWindow* window = V8Proxy::FastToNativeObject<DOMWindow>( 1005 DOMWindow* window = V8Proxy::ToNativeObject<DOMWindow>(
1006 V8ClassIndex::DOMWINDOW, args.Holder()); 1006 V8ClassIndex::DOMWINDOW, args.Holder());
1007 Frame* frame = window->frame(); 1007 Frame* frame = window->frame();
1008 1008
1009 if (!frame) 1009 if (!frame)
1010 return v8::Undefined(); 1010 return v8::Undefined();
1011 1011
1012 if (!canShowModalDialogNow(frame) || !allowPopUp()) 1012 if (!canShowModalDialogNow(frame) || !allowPopUp())
1013 return v8::Undefined(); 1013 return v8::Undefined();
1014 1014
1015 String url = valueToStringWithNullOrUndefinedCheck(args[0]); 1015 String url = valueToStringWithNullOrUndefinedCheck(args[0]);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 if (!return_value.IsEmpty()) { 1085 if (!return_value.IsEmpty()) {
1086 return return_value; 1086 return return_value;
1087 } 1087 }
1088 1088
1089 return v8::Undefined(); 1089 return v8::Undefined();
1090 } 1090 }
1091 1091
1092 1092
1093 CALLBACK_FUNC_DECL(DOMWindowOpen) { 1093 CALLBACK_FUNC_DECL(DOMWindowOpen) {
1094 INC_STATS(L"DOM.DOMWindow.open()"); 1094 INC_STATS(L"DOM.DOMWindow.open()");
1095 DOMWindow* parent = V8Proxy::FastToNativeObject<DOMWindow>( 1095 DOMWindow* parent = V8Proxy::ToNativeObject<DOMWindow>(
1096 V8ClassIndex::DOMWINDOW, args.Holder()); 1096 V8ClassIndex::DOMWINDOW, args.Holder());
1097 Frame* frame = parent->frame(); 1097 Frame* frame = parent->frame();
1098 if (!frame) 1098 if (!frame)
1099 return v8::Undefined(); 1099 return v8::Undefined();
1100 1100
1101 // Fast check This argument with the global object of security context. 1101 // Fast check This argument with the global object of security context.
1102 if ((args.This() != v8::Context::GetCurrentSecurityContext()->Global()) && 1102 if ((args.This() != v8::Context::GetCurrentSecurityContext()->Global()) &&
1103 !V8Proxy::IsFromSameOrigin(frame, true)) { 1103 !V8Proxy::IsFromSameOrigin(frame, true)) {
1104 return v8::Undefined(); 1104 return v8::Undefined();
1105 } 1105 }
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 v8::Local<v8::Value> result = proxy->Evaluate(prop_name, 0, code, 0); 1337 v8::Local<v8::Value> result = proxy->Evaluate(prop_name, 0, code, 0);
1338 return result; 1338 return result;
1339 } 1339 }
1340 1340
1341 // Search named items in the document. 1341 // Search named items in the document.
1342 Document* doc = frame->document(); 1342 Document* doc = frame->document();
1343 if (doc) { 1343 if (doc) {
1344 RefPtr<HTMLCollection> items = doc->windowNamedItems(prop_name); 1344 RefPtr<HTMLCollection> items = doc->windowNamedItems(prop_name);
1345 if (items->length() >= 1) { 1345 if (items->length() >= 1) {
1346 if (items->length() == 1) { 1346 if (items->length() == 1) {
1347 return V8Proxy::ToV8Object(V8ClassIndex::NODE, items->firstItem()); 1347 return V8Proxy::NodeToV8Object(items->firstItem());
1348 } else { 1348 } else {
1349 return V8Proxy::ToV8Object(V8ClassIndex::HTMLCOLLECTION, 1349 return V8Proxy::ToV8Object(V8ClassIndex::HTMLCOLLECTION,
1350 static_cast<Peerable*>(items.get())); 1350 static_cast<Peerable*>(items.get()));
1351 } 1351 }
1352 } 1352 }
1353 } 1353 }
1354 1354
1355 return v8::Handle<v8::Value>(); 1355 return v8::Handle<v8::Value>();
1356 } 1356 }
1357 1357
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 kHTMLDocumentInternalFieldCount); 1399 kHTMLDocumentInternalFieldCount);
1400 v8::Local<v8::Value> marker = 1400 v8::Local<v8::Value> marker =
1401 info.Holder()->GetInternalField(kHTMLDocumentMarkerIndex); 1401 info.Holder()->GetInternalField(kHTMLDocumentMarkerIndex);
1402 v8::Local<v8::Value> value = 1402 v8::Local<v8::Value> value =
1403 info.Holder()->GetInternalField(kHTMLDocumentShadowIndex); 1403 info.Holder()->GetInternalField(kHTMLDocumentShadowIndex);
1404 if (marker != value) { 1404 if (marker != value) {
1405 return value; 1405 return value;
1406 } 1406 }
1407 } 1407 }
1408 1408
1409 HTMLDocument* imp = V8Proxy::FastToNativeObject<HTMLDocument>( 1409 HTMLDocument* imp = V8Proxy::DOMWrapperToNode<HTMLDocument>(info.Holder());
1410 V8ClassIndex::HTMLDOCUMENT, info.Holder());
1411 1410
1412 // Fast case for named elements that are not there. 1411 // Fast case for named elements that are not there.
1413 if (!imp->hasNamedItem(key) && !imp->hasDocExtraNamedItem(key)) { 1412 if (!imp->hasNamedItem(key) && !imp->hasDocExtraNamedItem(key)) {
1414 return v8::Handle<v8::Value>(); 1413 return v8::Handle<v8::Value>();
1415 } 1414 }
1416 1415
1417 1416
1418 RefPtr<HTMLCollection> items = imp->documentNamedItems(key); 1417 RefPtr<HTMLCollection> items = imp->documentNamedItems(key);
1419 if (items->length() == 0) return v8::Handle<v8::Value>(); 1418 if (items->length() == 0) return v8::Handle<v8::Value>();
1420 if (items->length() == 1) { 1419 if (items->length() == 1) {
1421 Node* node = items->firstItem(); 1420 Node* node = items->firstItem();
1422 Frame* frame = 0; 1421 Frame* frame = 0;
1423 if (node->hasTagName(HTMLNames::iframeTag) && 1422 if (node->hasTagName(HTMLNames::iframeTag) &&
1424 (frame = static_cast<HTMLIFrameElement*>(node)->contentFrame())) { 1423 (frame = static_cast<HTMLIFrameElement*>(node)->contentFrame())) {
1425 return V8Proxy::ToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow()); 1424 return V8Proxy::ToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow());
1426 } 1425 }
1427 return V8Proxy::ToV8Object(V8ClassIndex::NODE, node); 1426 return V8Proxy::NodeToV8Object(node);
1428 } 1427 }
1429 return V8Proxy::ToV8Object(V8ClassIndex::HTMLCOLLECTION, 1428 return V8Proxy::ToV8Object(V8ClassIndex::HTMLCOLLECTION,
1430 static_cast<Peerable*>(items.get())); 1429 static_cast<Peerable*>(items.get()));
1431 } 1430 }
1432 1431
1433 1432
1434 NAMED_PROPERTY_GETTER(HTMLFrameSetElement) { 1433 NAMED_PROPERTY_GETTER(HTMLFrameSetElement) {
1435 INC_STATS(L"DOM.HTMLFrameSetElement.NamedPropertyGetter"); 1434 INC_STATS(L"DOM.HTMLFrameSetElement.NamedPropertyGetter");
1436 HTMLFrameSetElement* imp = V8Proxy::FastToNativeObject<HTMLFrameSetElement>( 1435 HTMLFrameSetElement* imp =
1437 V8ClassIndex::HTMLFRAMESETELEMENT, info.Holder()); 1436 V8Proxy::DOMWrapperToNode<HTMLFrameSetElement>(info.Holder());
1438 String key = ToWebCoreString(name); 1437 String key = ToWebCoreString(name);
1439 Node* frame = imp->children()->namedItem(key); 1438 Node* frame = imp->children()->namedItem(key);
1440 if (frame && frame->hasTagName(HTMLNames::frameTag)) { 1439 if (frame && frame->hasTagName(HTMLNames::frameTag)) {
1441 Document* doc = static_cast<HTMLFrameElement*>(frame)->contentDocument(); 1440 Document* doc = static_cast<HTMLFrameElement*>(frame)->contentDocument();
1442 if (doc) { 1441 if (doc) {
1443 Frame* content_frame = doc->frame(); 1442 Frame* content_frame = doc->frame();
1444 if (content_frame) { 1443 if (content_frame) {
1445 return V8Proxy::ToV8Object(V8ClassIndex::DOMWINDOW, 1444 return V8Proxy::ToV8Object(V8ClassIndex::DOMWINDOW,
1446 content_frame->domWindow()); 1445 content_frame->domWindow());
1447 } 1446 }
1448 } 1447 }
1449 return v8::Undefined(); 1448 return v8::Undefined();
1450 } 1449 }
1451 return v8::Handle<v8::Value>(); 1450 return v8::Handle<v8::Value>();
1452 } 1451 }
1453 1452
1454 1453
1455 NAMED_PROPERTY_GETTER(HTMLFormElement) { 1454 NAMED_PROPERTY_GETTER(HTMLFormElement) {
1456 INC_STATS(L"DOM.HTMLFormElement.NamedPropertyGetter"); 1455 INC_STATS(L"DOM.HTMLFormElement.NamedPropertyGetter");
1457 HTMLFormElement* imp = V8Proxy::FastToNativeObject<HTMLFormElement>( 1456 HTMLFormElement* imp =
1458 V8ClassIndex::HTMLFORMELEMENT, info.Holder()); 1457 V8Proxy::DOMWrapperToNode<HTMLFormElement>(info.Holder());
1459 String v = ToWebCoreString(name); 1458 String v = ToWebCoreString(name);
1460 1459
1461 // Call getNamedElements twice, first time check if it has a value 1460 // Call getNamedElements twice, first time check if it has a value
1462 // and let HTMLFormElement update its cache. 1461 // and let HTMLFormElement update its cache.
1463 // See issue: 867404 1462 // See issue: 867404
1464 { 1463 {
1465 Vector<RefPtr<Node> > elements; 1464 Vector<RefPtr<Node> > elements;
1466 imp->getNamedElements(v, elements); 1465 imp->getNamedElements(v, elements);
1467 if (elements.size() == 0) 1466 if (elements.size() == 0)
1468 return v8::Handle<v8::Value>(); 1467 return v8::Handle<v8::Value>();
1469 } 1468 }
1470 // Second call may return different results from the first call, 1469 // Second call may return different results from the first call,
1471 // but if the first the size cannot be zero. 1470 // but if the first the size cannot be zero.
1472 Vector<RefPtr<Node> > elements; 1471 Vector<RefPtr<Node> > elements;
1473 imp->getNamedElements(v, elements); 1472 imp->getNamedElements(v, elements);
1474 ASSERT(elements.size() != 0); 1473 ASSERT(elements.size() != 0);
1475 if (elements.size() == 1) { 1474 if (elements.size() == 1) {
1476 return V8Proxy::ToV8Object(V8ClassIndex::NODE, elements.at(0).get()); 1475 return V8Proxy::NodeToV8Object(elements.at(0).get());
1477 } else { 1476 } else {
1478 NodeList* collection = new V8VectorNodeList(elements); 1477 NodeList* collection = new V8VectorNodeList(elements);
1479 return V8Proxy::ToV8Object(V8ClassIndex::NODELIST, 1478 return V8Proxy::ToV8Object(V8ClassIndex::NODELIST,
1480 static_cast<Peerable*>(collection)); 1479 static_cast<Peerable*>(collection));
1481 } 1480 }
1482 } 1481 }
1483 1482
1484 1483
1485 INDEXED_PROPERTY_GETTER(NamedNodeMap) { 1484 INDEXED_PROPERTY_GETTER(NamedNodeMap) {
1486 INC_STATS(L"DOM.NamedNodeMap.IndexedPropertyGetter"); 1485 INC_STATS(L"DOM.NamedNodeMap.IndexedPropertyGetter");
1487 NamedNodeMap* imp = V8Proxy::FastToNativeObject<NamedNodeMap>( 1486 NamedNodeMap* imp = V8Proxy::ToNativeObject<NamedNodeMap>(
1488 V8ClassIndex::NAMEDNODEMAP, info.Holder()); 1487 V8ClassIndex::NAMEDNODEMAP, info.Holder());
1489 RefPtr<Node> result = imp->item(index); 1488 RefPtr<Node> result = imp->item(index);
1490 if (!result) return v8::Handle<v8::Value>(); 1489 if (!result) return v8::Handle<v8::Value>();
1491 1490
1492 return V8Proxy::ToV8Object(V8ClassIndex::NODE, result.get()); 1491 return V8Proxy::NodeToV8Object(result.get());
1493 } 1492 }
1494 1493
1495 NAMED_PROPERTY_GETTER(NamedNodeMap) { 1494 NAMED_PROPERTY_GETTER(NamedNodeMap) {
1496 INC_STATS(L"DOM.NamedNodeMap.NamedPropertyGetter"); 1495 INC_STATS(L"DOM.NamedNodeMap.NamedPropertyGetter");
1497 // Search the prototype chain first. 1496 // Search the prototype chain first.
1498 v8::Handle<v8::Value> value = 1497 v8::Handle<v8::Value> value =
1499 info.Holder()->GetRealNamedPropertyInPrototypeChain(name); 1498 info.Holder()->GetRealNamedPropertyInPrototypeChain(name);
1500 if (!value.IsEmpty()) 1499 if (!value.IsEmpty())
1501 return value; 1500 return value;
1502 1501
1503 // Then look for IDL defined properties on the object itself. 1502 // Then look for IDL defined properties on the object itself.
1504 if (info.Holder()->HasRealNamedCallbackProperty(name)) 1503 if (info.Holder()->HasRealNamedCallbackProperty(name))
1505 return v8::Handle<v8::Value>(); 1504 return v8::Handle<v8::Value>();
1506 1505
1507 // Finally, search the DOM. 1506 // Finally, search the DOM.
1508 NamedNodeMap* imp = V8Proxy::FastToNativeObject<NamedNodeMap>( 1507 NamedNodeMap* imp = V8Proxy::ToNativeObject<NamedNodeMap>(
1509 V8ClassIndex::NAMEDNODEMAP, info.Holder()); 1508 V8ClassIndex::NAMEDNODEMAP, info.Holder());
1510 String prop_name = ToWebCoreString(name); 1509 String prop_name = ToWebCoreString(name);
1511 RefPtr<Node> result = imp->getNamedItem(prop_name); 1510 RefPtr<Node> result = imp->getNamedItem(prop_name);
1512 if (!result) return v8::Handle<v8::Value>(); 1511 if (!result) return v8::Handle<v8::Value>();
1513 1512
1514 return V8Proxy::ToV8Object(V8ClassIndex::NODE, result.get()); 1513 return V8Proxy::NodeToV8Object(result.get());
1515 } 1514 }
1516 1515
1517 1516
1518 NAMED_PROPERTY_GETTER(NodeList) { 1517 NAMED_PROPERTY_GETTER(NodeList) {
1519 INC_STATS(L"DOM.NodeList.NamedPropertyGetter"); 1518 INC_STATS(L"DOM.NodeList.NamedPropertyGetter");
1520 NodeList* list = V8Proxy::FastToNativeObject<NodeList>( 1519 NodeList* list = V8Proxy::ToNativeObject<NodeList>(
1521 V8ClassIndex::NODELIST, info.Holder()); 1520 V8ClassIndex::NODELIST, info.Holder());
1522 String prop_name = ToWebCoreString(name); 1521 String prop_name = ToWebCoreString(name);
1523 1522
1524 // Length property cannot be overridden. 1523 // Length property cannot be overridden.
1525 if (prop_name == "length") 1524 if (prop_name == "length")
1526 return v8::Number::New(list->length()); 1525 return v8::Number::New(list->length());
1527 1526
1528 RefPtr<Node> result = list->itemWithName(prop_name); 1527 RefPtr<Node> result = list->itemWithName(prop_name);
1529 if (result) 1528 if (result)
1530 return V8Proxy::ToV8Object(V8ClassIndex::NODE, result.get()); 1529 return V8Proxy::NodeToV8Object(result.get());
1531 1530
1532 return v8::Handle<v8::Value>(); 1531 return v8::Handle<v8::Value>();
1533 } 1532 }
1534 1533
1535 1534
1536 INDEXED_PROPERTY_GETTER(HTMLFormElement) { 1535 INDEXED_PROPERTY_GETTER(HTMLFormElement) {
1537 INC_STATS(L"DOM.HTMLFormElement.IndexedPropertyGetter"); 1536 INC_STATS(L"DOM.HTMLFormElement.IndexedPropertyGetter");
1538 HTMLFormElement* form = V8Proxy::FastToNativeObject<HTMLFormElement>( 1537 HTMLFormElement* form =
1539 V8ClassIndex::HTMLFORMELEMENT, info.Holder()); 1538 V8Proxy::DOMWrapperToNode<HTMLFormElement>(info.Holder());
1540 1539
1541 RefPtr<Node> result = form->elements()->item(index); 1540 RefPtr<Node> result = form->elements()->item(index);
1542 if (!result) return v8::Handle<v8::Value>(); 1541 if (!result) return v8::Handle<v8::Value>();
1543 return V8Proxy::ToV8Object(V8ClassIndex::NODE, result.get()); 1542 return V8Proxy::NodeToV8Object(result.get());
1544 } 1543 }
1545 1544
1546 1545
1547 INDEXED_PROPERTY_GETTER(HTMLOptionsCollection) { 1546 INDEXED_PROPERTY_GETTER(HTMLOptionsCollection) {
1548 INC_STATS(L"DOM.HTMLOptionsCollection.IndexedPropertyGetter"); 1547 INC_STATS(L"DOM.HTMLOptionsCollection.IndexedPropertyGetter");
1549 HTMLOptionsCollection* collection = 1548 HTMLOptionsCollection* collection =
1550 V8Proxy::FastToNativeObject<HTMLOptionsCollection>( 1549 V8Proxy::ToNativeObject<HTMLOptionsCollection>(
1551 V8ClassIndex::HTMLOPTIONSCOLLECTION, info.Holder()); 1550 V8ClassIndex::HTMLOPTIONSCOLLECTION, info.Holder());
1552 1551
1553 RefPtr<Node> result = collection->item(index); 1552 RefPtr<Node> result = collection->item(index);
1554 if (!result) return v8::Handle<v8::Value>(); 1553 if (!result) return v8::Handle<v8::Value>();
1555 1554
1556 return V8Proxy::ToV8Object(V8ClassIndex::NODE, result.get()); 1555 return V8Proxy::NodeToV8Object(result.get());
1557 } 1556 }
1558 1557
1559 static v8::Handle<v8::Value> OptionsCollectionSetter(uint32_t index, 1558 static v8::Handle<v8::Value> OptionsCollectionSetter(uint32_t index,
1560 v8::Handle<v8::Value> value, HTMLSelectElement* base) { 1559 v8::Handle<v8::Value> value, HTMLSelectElement* base) {
1561 if (value->IsNull() || value->IsUndefined()) { 1560 if (value->IsNull() || value->IsUndefined()) {
1562 base->remove(index); 1561 base->remove(index);
1563 return value; 1562 return value;
1564 } 1563 }
1565 1564
1566 ExceptionCode ec = 0; 1565 ExceptionCode ec = 0;
1567 1566
1568 // Check that the value is an HTMLOptionElement. If not, throw a 1567 // Check that the value is an HTMLOptionElement. If not, throw a
1569 // TYPE_MISMATCH_ERR DOMException. 1568 // TYPE_MISMATCH_ERR DOMException.
1570 if (!V8HTMLOptionElement::HasInstance(value)) { 1569 if (!V8HTMLOptionElement::HasInstance(value)) {
1571 V8Proxy::SetDOMException(TYPE_MISMATCH_ERR); 1570 V8Proxy::SetDOMException(TYPE_MISMATCH_ERR);
1572 return value; 1571 return value;
1573 } 1572 }
1574 1573
1575 HTMLOptionElement* element = V8Proxy::FastToNativeObject<HTMLOptionElement>( 1574 HTMLOptionElement* element =
1576 V8ClassIndex::HTMLOPTIONELEMENT, v8::Handle<v8::Object>::Cast(value)); 1575 V8Proxy::DOMWrapperToNode<HTMLOptionElement>(
1576 v8::Handle<v8::Object>::Cast(value));
1577 base->setOption(index, element, ec); 1577 base->setOption(index, element, ec);
1578 1578
1579 V8Proxy::SetDOMException(ec); 1579 V8Proxy::SetDOMException(ec);
1580 return value; 1580 return value;
1581 } 1581 }
1582 1582
1583 1583
1584 INDEXED_PROPERTY_SETTER(HTMLOptionsCollection) { 1584 INDEXED_PROPERTY_SETTER(HTMLOptionsCollection) {
1585 INC_STATS(L"DOM.HTMLOptionsCollection.IndexedPropertySetter"); 1585 INC_STATS(L"DOM.HTMLOptionsCollection.IndexedPropertySetter");
1586 HTMLOptionsCollection* collection = 1586 HTMLOptionsCollection* collection =
1587 V8Proxy::FastToNativeObject<HTMLOptionsCollection>( 1587 V8Proxy::ToNativeObject<HTMLOptionsCollection>(
1588 V8ClassIndex::HTMLOPTIONSCOLLECTION, info.Holder()); 1588 V8ClassIndex::HTMLOPTIONSCOLLECTION, info.Holder());
1589 HTMLSelectElement* base = static_cast<HTMLSelectElement*>(collection->base()); 1589 HTMLSelectElement* base = static_cast<HTMLSelectElement*>(collection->base());
1590 return OptionsCollectionSetter(index, value, base); 1590 return OptionsCollectionSetter(index, value, base);
1591 } 1591 }
1592 1592
1593 1593
1594 INDEXED_PROPERTY_SETTER(HTMLSelectElementCollection) { 1594 INDEXED_PROPERTY_SETTER(HTMLSelectElementCollection) {
1595 INC_STATS(L"DOM.HTMLSelectElementCollection.IndexedPropertySetter"); 1595 INC_STATS(L"DOM.HTMLSelectElementCollection.IndexedPropertySetter");
1596 HTMLSelectElement* select = 1596 HTMLSelectElement* select =
1597 V8Proxy::FastToNativeObject<HTMLSelectElement>( 1597 V8Proxy::DOMWrapperToNode<HTMLSelectElement>(info.Holder());
1598 V8ClassIndex::HTMLSELECTELEMENT, info.Holder());
1599 return OptionsCollectionSetter(index, value, select); 1598 return OptionsCollectionSetter(index, value, select);
1600 } 1599 }
1601 1600
1602 1601
1603 // When getting properties on CSSStyleDeclarations, the name used from 1602 // When getting properties on CSSStyleDeclarations, the name used from
1604 // Javascript and the actual name of the property are not the same, so 1603 // Javascript and the actual name of the property are not the same, so
1605 // we have to do the following translation. The translation turns upper 1604 // we have to do the following translation. The translation turns upper
1606 // case characters into lower case characters and inserts dashes to 1605 // case characters into lower case characters and inserts dashes to
1607 // separate words. 1606 // separate words.
1608 // 1607 //
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1648 1647
1649 NAMED_PROPERTY_GETTER(CSSStyleDeclaration) { 1648 NAMED_PROPERTY_GETTER(CSSStyleDeclaration) {
1650 INC_STATS(L"DOM.CSSStyleDeclaration.NamedPropertyGetter"); 1649 INC_STATS(L"DOM.CSSStyleDeclaration.NamedPropertyGetter");
1651 // First look for API defined attributes on the style declaration 1650 // First look for API defined attributes on the style declaration
1652 // object. 1651 // object.
1653 if (info.Holder()->HasRealNamedCallbackProperty(name)) { 1652 if (info.Holder()->HasRealNamedCallbackProperty(name)) {
1654 return v8::Handle<v8::Value>(); 1653 return v8::Handle<v8::Value>();
1655 } 1654 }
1656 1655
1657 // Search the style declaration. 1656 // Search the style declaration.
1658 CSSStyleDeclaration* imp = V8Proxy::FastToNativeObject<CSSStyleDeclaration>( 1657 CSSStyleDeclaration* imp = V8Proxy::ToNativeObject<CSSStyleDeclaration>(
1659 V8ClassIndex::CSSSTYLEDECLARATION, info.Holder()); 1658 V8ClassIndex::CSSSTYLEDECLARATION, info.Holder());
1660 1659
1661 bool pixel_or_pos; 1660 bool pixel_or_pos;
1662 String p = ToWebCoreString(name); 1661 String p = ToWebCoreString(name);
1663 String prop = CSSPropertyName(p, &pixel_or_pos); 1662 String prop = CSSPropertyName(p, &pixel_or_pos);
1664 1663
1665 // Do not handle non-property names. 1664 // Do not handle non-property names.
1666 if (!CSSStyleDeclaration::isPropertyName(prop)) { 1665 if (!CSSStyleDeclaration::isPropertyName(prop)) {
1667 return v8::Handle<v8::Value>(); 1666 return v8::Handle<v8::Value>();
1668 } 1667 }
(...skipping 17 matching lines...) Expand all
1686 // to avoid confusion with IE's filter extension. 1685 // to avoid confusion with IE's filter extension.
1687 if (prop == "filter") { 1686 if (prop == "filter") {
1688 return v8UndetectableString(result); 1687 return v8UndetectableString(result);
1689 } 1688 }
1690 return v8String(result); 1689 return v8String(result);
1691 } 1690 }
1692 1691
1693 1692
1694 NAMED_PROPERTY_SETTER(CSSStyleDeclaration) { 1693 NAMED_PROPERTY_SETTER(CSSStyleDeclaration) {
1695 INC_STATS(L"DOM.CSSStyleDeclaration.NamedPropertySetter"); 1694 INC_STATS(L"DOM.CSSStyleDeclaration.NamedPropertySetter");
1696 CSSStyleDeclaration* imp = V8Proxy::FastToNativeObject<CSSStyleDeclaration>( 1695 CSSStyleDeclaration* imp = V8Proxy::ToNativeObject<CSSStyleDeclaration>(
1697 V8ClassIndex::CSSSTYLEDECLARATION, info.Holder()); 1696 V8ClassIndex::CSSSTYLEDECLARATION, info.Holder());
1698 String property_name = ToWebCoreString(name); 1697 String property_name = ToWebCoreString(name);
1699 int ec = 0; 1698 int ec = 0;
1700 1699
1701 bool pixel_or_pos; 1700 bool pixel_or_pos;
1702 String prop = CSSPropertyName(property_name, &pixel_or_pos); 1701 String prop = CSSPropertyName(property_name, &pixel_or_pos);
1703 if (!CSSStyleDeclaration::isPropertyName(prop)) { 1702 if (!CSSStyleDeclaration::isPropertyName(prop)) {
1704 return v8::Handle<v8::Value>(); // do not block the call 1703 return v8::Handle<v8::Value>(); // do not block the call
1705 } 1704 }
1706 1705
1707 String prop_value = valueToStringWithNullCheck(value); 1706 String prop_value = valueToStringWithNullCheck(value);
1708 if (pixel_or_pos) prop_value += "px"; 1707 if (pixel_or_pos) prop_value += "px";
1709 imp->setProperty(prop, prop_value, ec); 1708 imp->setProperty(prop, prop_value, ec);
1710 1709
1711 V8Proxy::SetDOMException(ec); 1710 V8Proxy::SetDOMException(ec);
1712 return value; 1711 return value;
1713 } 1712 }
1714 1713
1715 1714
1716 NAMED_PROPERTY_GETTER(HTMLPlugInElement) { 1715 NAMED_PROPERTY_GETTER(HTMLPlugInElement) {
1717 INC_STATS(L"DOM.HTMLPlugInElement.NamedPropertyGetter"); 1716 INC_STATS(L"DOM.HTMLPlugInElement.NamedPropertyGetter");
1718 HTMLPlugInElement* imp = V8Proxy::FastToNativeObject<HTMLPlugInElement>( 1717 HTMLPlugInElement* imp =
1719 V8ClassIndex::NODE, info.Holder()); 1718 V8Proxy::DOMWrapperToNode<HTMLPlugInElement>(info.Holder());
1720 v8::Local<v8::Object> instance = 1719 v8::Local<v8::Object> instance =
1721 v8::Local<v8::Object>::New(imp->getInstance()); 1720 v8::Local<v8::Object>::New(imp->getInstance());
1722 if (instance.IsEmpty()) return v8::Handle<v8::Object>(); 1721 if (instance.IsEmpty()) return v8::Handle<v8::Object>();
1723 return NPObjectGetNamedProperty(instance, name); 1722 return NPObjectGetNamedProperty(instance, name);
1724 } 1723 }
1725 1724
1726 1725
1727 NAMED_PROPERTY_SETTER(HTMLPlugInElement) { 1726 NAMED_PROPERTY_SETTER(HTMLPlugInElement) {
1728 INC_STATS(L"DOM.HTMLPlugInElement.NamedPropertySetter"); 1727 INC_STATS(L"DOM.HTMLPlugInElement.NamedPropertySetter");
1729 HTMLPlugInElement* imp = V8Proxy::FastToNativeObject<HTMLPlugInElement>( 1728 HTMLPlugInElement* imp =
1730 V8ClassIndex::NODE, info.Holder()); 1729 V8Proxy::DOMWrapperToNode<HTMLPlugInElement>(info.Holder());
1731 v8::Local<v8::Object> instance = 1730 v8::Local<v8::Object> instance =
1732 v8::Local<v8::Object>::New(imp->getInstance()); 1731 v8::Local<v8::Object>::New(imp->getInstance());
1733 if (instance.IsEmpty()) { 1732 if (instance.IsEmpty()) {
1734 return v8::Handle<v8::Value>(); // do not block the call 1733 return v8::Handle<v8::Value>(); // do not block the call
1735 } 1734 }
1736 1735
1737 return NPObjectSetNamedProperty(instance, name, value); 1736 return NPObjectSetNamedProperty(instance, name, value);
1738 } 1737 }
1739 1738
1740 1739
1741 CALLBACK_FUNC_DECL(HTMLPlugInElement) { 1740 CALLBACK_FUNC_DECL(HTMLPlugInElement) {
1742 INC_STATS(L"DOM.HTMLPluginElement()"); 1741 INC_STATS(L"DOM.HTMLPluginElement()");
1743 return NPObjectInvokeDefaultHandler(args); 1742 return NPObjectInvokeDefaultHandler(args);
1744 } 1743 }
1745 1744
1746 1745
1747 INDEXED_PROPERTY_GETTER(HTMLPlugInElement) { 1746 INDEXED_PROPERTY_GETTER(HTMLPlugInElement) {
1748 INC_STATS(L"DOM.HTMLPlugInElement.IndexedPropertyGetter"); 1747 INC_STATS(L"DOM.HTMLPlugInElement.IndexedPropertyGetter");
1749 HTMLPlugInElement* imp = V8Proxy::FastToNativeObject<HTMLPlugInElement>( 1748 HTMLPlugInElement* imp =
1750 V8ClassIndex::NODE, info.Holder()); 1749 V8Proxy::DOMWrapperToNode<HTMLPlugInElement>(info.Holder());
1751 v8::Local<v8::Object> instance = 1750 v8::Local<v8::Object> instance =
1752 v8::Local<v8::Object>::New(imp->getInstance()); 1751 v8::Local<v8::Object>::New(imp->getInstance());
1753 if (instance.IsEmpty()) return v8::Handle<v8::Object>(); 1752 if (instance.IsEmpty()) return v8::Handle<v8::Object>();
1754 return NPObjectGetIndexedProperty(instance, index); 1753 return NPObjectGetIndexedProperty(instance, index);
1755 } 1754 }
1756 1755
1757 1756
1758 INDEXED_PROPERTY_SETTER(HTMLPlugInElement) { 1757 INDEXED_PROPERTY_SETTER(HTMLPlugInElement) {
1759 INC_STATS(L"DOM.HTMLPlugInElement.IndexedPropertySetter"); 1758 INC_STATS(L"DOM.HTMLPlugInElement.IndexedPropertySetter");
1760 HTMLPlugInElement* imp = V8Proxy::FastToNativeObject<HTMLPlugInElement>( 1759 HTMLPlugInElement* imp =
1761 V8ClassIndex::NODE, info.Holder()); 1760 V8Proxy::DOMWrapperToNode<HTMLPlugInElement>(info.Holder());
1762 v8::Local<v8::Object> instance = 1761 v8::Local<v8::Object> instance =
1763 v8::Local<v8::Object>::New(imp->getInstance()); 1762 v8::Local<v8::Object>::New(imp->getInstance());
1764 if (instance.IsEmpty()) { 1763 if (instance.IsEmpty()) {
1765 return v8::Handle<v8::Value>(); // do not block the call 1764 return v8::Handle<v8::Value>(); // do not block the call
1766 } 1765 }
1767 1766
1768 return NPObjectSetIndexedProperty(instance, index, value); 1767 return NPObjectSetIndexedProperty(instance, index, value);
1769 } 1768 }
1770 1769
1771 NAMED_PROPERTY_GETTER(StyleSheetList) { 1770 NAMED_PROPERTY_GETTER(StyleSheetList) {
1772 INC_STATS(L"DOM.StyleSheetList.NamedPropertyGetter"); 1771 INC_STATS(L"DOM.StyleSheetList.NamedPropertyGetter");
1773 // Look for local properties first. 1772 // Look for local properties first.
1774 if (info.Holder()->HasRealNamedProperty(name)) { 1773 if (info.Holder()->HasRealNamedProperty(name)) {
1775 return v8::Handle<v8::Value>(); 1774 return v8::Handle<v8::Value>();
1776 } 1775 }
1777 1776
1778 // Search style sheet. 1777 // Search style sheet.
1779 StyleSheetList* imp = V8Proxy::FastToNativeObject<StyleSheetList>( 1778 StyleSheetList* imp = V8Proxy::ToNativeObject<StyleSheetList>(
1780 V8ClassIndex::STYLESHEETLIST, info.Holder()); 1779 V8ClassIndex::STYLESHEETLIST, info.Holder());
1781 String key = ToWebCoreString(name); 1780 String key = ToWebCoreString(name);
1782 HTMLStyleElement* item = imp->getNamedItem(key); 1781 HTMLStyleElement* item = imp->getNamedItem(key);
1783 if (item) { 1782 if (item) {
1784 return V8Proxy::ToV8Object(V8ClassIndex::HTMLSTYLEELEMENT, item); 1783 return V8Proxy::ToV8Object(V8ClassIndex::HTMLSTYLEELEMENT, item);
1785 } 1784 }
1786 return v8::Handle<v8::Value>(); 1785 return v8::Handle<v8::Value>();
1787 } 1786 }
1788 1787
1789 1788
1790 CALLBACK_FUNC_DECL(CSSPrimitiveValueGetRGBColorValue) { 1789 CALLBACK_FUNC_DECL(CSSPrimitiveValueGetRGBColorValue) {
1791 INC_STATS(L"DOM.CSSPrimitiveValue.getRGBColorValue()"); 1790 INC_STATS(L"DOM.CSSPrimitiveValue.getRGBColorValue()");
1792 CSSPrimitiveValue* value = V8Proxy::FastToNativeObject<CSSPrimitiveValue>( 1791 CSSPrimitiveValue* value = V8Proxy::ToNativeObject<CSSPrimitiveValue>(
1793 V8ClassIndex::CSSPRIMITIVEVALUE, args.Holder()); 1792 V8ClassIndex::CSSPRIMITIVEVALUE, args.Holder());
1794 ExceptionCode ec = 0; 1793 ExceptionCode ec = 0;
1795 unsigned int rgbcolor = value->getRGBColorValue(ec); 1794 unsigned int rgbcolor = value->getRGBColorValue(ec);
1796 if (ec != 0) { 1795 if (ec != 0) {
1797 V8Proxy::SetDOMException(ec); 1796 V8Proxy::SetDOMException(ec);
1798 return v8::Handle<v8::Value>(); 1797 return v8::Handle<v8::Value>();
1799 } 1798 }
1800 return V8Proxy::ToV8Object(V8ClassIndex::RGBCOLOR, 1799 return V8Proxy::ToV8Object(V8ClassIndex::RGBCOLOR,
1801 static_cast<Peerable*>(new RGBColor(rgbcolor))); 1800 static_cast<Peerable*>(new RGBColor(rgbcolor)));
1802 } 1801 }
1803 1802
1804 // Helper macro for converting v8 values into floats (expected by many of the 1803 // Helper macro for converting v8 values into floats (expected by many of the
1805 // canvas functions). 1804 // canvas functions).
1806 #define TO_FLOAT(a) static_cast<float>((a)->NumberValue()) 1805 #define TO_FLOAT(a) static_cast<float>((a)->NumberValue())
1807 1806
1808 // TODO: SetStrokeColor and SetFillColor are similar except function names, 1807 // TODO: SetStrokeColor and SetFillColor are similar except function names,
1809 // consolidate them into one. 1808 // consolidate them into one.
1810 CALLBACK_FUNC_DECL(CanvasRenderingContext2DSetStrokeColor) { 1809 CALLBACK_FUNC_DECL(CanvasRenderingContext2DSetStrokeColor) {
1811 INC_STATS(L"DOM.CanvasRenderingContext2D.setStrokeColor()"); 1810 INC_STATS(L"DOM.CanvasRenderingContext2D.setStrokeColor()");
1812 CanvasRenderingContext2D* context = 1811 CanvasRenderingContext2D* context =
1813 V8Proxy::FastToNativeObject<CanvasRenderingContext2D>( 1812 V8Proxy::ToNativeObject<CanvasRenderingContext2D>(
1814 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); 1813 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder());
1815 switch (args.Length()) { 1814 switch (args.Length()) {
1816 case 1: 1815 case 1:
1817 if (args[0]->IsString()) { 1816 if (args[0]->IsString()) {
1818 context->setStrokeColor(ToWebCoreString(args[0])); 1817 context->setStrokeColor(ToWebCoreString(args[0]));
1819 } else { 1818 } else {
1820 context->setStrokeColor(TO_FLOAT(args[0])); 1819 context->setStrokeColor(TO_FLOAT(args[0]));
1821 } 1820 }
1822 break; 1821 break;
1823 case 2: 1822 case 2:
(...skipping 23 matching lines...) Expand all
1847 "setStrokeColor: Invalid number of arguments"); 1846 "setStrokeColor: Invalid number of arguments");
1848 break; 1847 break;
1849 } 1848 }
1850 return v8::Undefined(); 1849 return v8::Undefined();
1851 } 1850 }
1852 1851
1853 1852
1854 CALLBACK_FUNC_DECL(CanvasRenderingContext2DSetFillColor) { 1853 CALLBACK_FUNC_DECL(CanvasRenderingContext2DSetFillColor) {
1855 INC_STATS(L"DOM.CanvasRenderingContext2D.steFillColor()"); 1854 INC_STATS(L"DOM.CanvasRenderingContext2D.steFillColor()");
1856 CanvasRenderingContext2D* context = 1855 CanvasRenderingContext2D* context =
1857 V8Proxy::FastToNativeObject<CanvasRenderingContext2D>( 1856 V8Proxy::ToNativeObject<CanvasRenderingContext2D>(
1858 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); 1857 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder());
1859 switch (args.Length()) { 1858 switch (args.Length()) {
1860 case 1: 1859 case 1:
1861 if (args[0]->IsString()) { 1860 if (args[0]->IsString()) {
1862 context->setFillColor(ToWebCoreString(args[0])); 1861 context->setFillColor(ToWebCoreString(args[0]));
1863 } else { 1862 } else {
1864 context->setFillColor(TO_FLOAT(args[0])); 1863 context->setFillColor(TO_FLOAT(args[0]));
1865 } 1864 }
1866 break; 1865 break;
1867 case 2: 1866 case 2:
(...skipping 21 matching lines...) Expand all
1889 "setFillColor: Invalid number of arguments"); 1888 "setFillColor: Invalid number of arguments");
1890 break; 1889 break;
1891 } 1890 }
1892 return v8::Undefined(); 1891 return v8::Undefined();
1893 } 1892 }
1894 1893
1895 1894
1896 CALLBACK_FUNC_DECL(CanvasRenderingContext2DStrokeRect) { 1895 CALLBACK_FUNC_DECL(CanvasRenderingContext2DStrokeRect) {
1897 INC_STATS(L"DOM.CanvasRenderingContext2D.strokeRect()"); 1896 INC_STATS(L"DOM.CanvasRenderingContext2D.strokeRect()");
1898 CanvasRenderingContext2D* context = 1897 CanvasRenderingContext2D* context =
1899 V8Proxy::FastToNativeObject<CanvasRenderingContext2D>( 1898 V8Proxy::ToNativeObject<CanvasRenderingContext2D>(
1900 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); 1899 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder());
1901 ExceptionCode ec = 0; 1900 ExceptionCode ec = 0;
1902 double x = 0, y = 0, width = 0, height = 0, line_width = 0; 1901 double x = 0, y = 0, width = 0, height = 0, line_width = 0;
1903 if (args.Length() == 5) { 1902 if (args.Length() == 5) {
1904 context->strokeRect(TO_FLOAT(args[0]), 1903 context->strokeRect(TO_FLOAT(args[0]),
1905 TO_FLOAT(args[1]), 1904 TO_FLOAT(args[1]),
1906 TO_FLOAT(args[2]), 1905 TO_FLOAT(args[2]),
1907 TO_FLOAT(args[3]), 1906 TO_FLOAT(args[3]),
1908 TO_FLOAT(args[4]), 1907 TO_FLOAT(args[4]),
1909 ec); 1908 ec);
(...skipping 11 matching lines...) Expand all
1921 V8Proxy::SetDOMException(ec); 1920 V8Proxy::SetDOMException(ec);
1922 return v8::Handle<v8::Value>(); 1921 return v8::Handle<v8::Value>();
1923 } 1922 }
1924 return v8::Undefined(); 1923 return v8::Undefined();
1925 } 1924 }
1926 1925
1927 1926
1928 CALLBACK_FUNC_DECL(CanvasRenderingContext2DSetShadow) { 1927 CALLBACK_FUNC_DECL(CanvasRenderingContext2DSetShadow) {
1929 INC_STATS(L"DOM.CanvasRenderingContext2D.setShadow()"); 1928 INC_STATS(L"DOM.CanvasRenderingContext2D.setShadow()");
1930 CanvasRenderingContext2D* context = 1929 CanvasRenderingContext2D* context =
1931 V8Proxy::FastToNativeObject<CanvasRenderingContext2D>( 1930 V8Proxy::ToNativeObject<CanvasRenderingContext2D>(
1932 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); 1931 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder());
1933 1932
1934 switch (args.Length()) { 1933 switch (args.Length()) {
1935 case 3: 1934 case 3:
1936 context->setShadow(TO_FLOAT(args[0]), TO_FLOAT(args[1]), 1935 context->setShadow(TO_FLOAT(args[0]), TO_FLOAT(args[1]),
1937 TO_FLOAT(args[2])); 1936 TO_FLOAT(args[2]));
1938 break; 1937 break;
1939 case 4: 1938 case 4:
1940 if (args[3]->IsString()) 1939 if (args[3]->IsString())
1941 context->setShadow(TO_FLOAT(args[0]), TO_FLOAT(args[1]), 1940 context->setShadow(TO_FLOAT(args[0]), TO_FLOAT(args[1]),
(...skipping 30 matching lines...) Expand all
1972 break; 1971 break;
1973 } 1972 }
1974 1973
1975 return v8::Undefined(); 1974 return v8::Undefined();
1976 } 1975 }
1977 1976
1978 1977
1979 CALLBACK_FUNC_DECL(CanvasRenderingContext2DDrawImage) { 1978 CALLBACK_FUNC_DECL(CanvasRenderingContext2DDrawImage) {
1980 INC_STATS(L"DOM.CanvasRenderingContext2D.drawImage()"); 1979 INC_STATS(L"DOM.CanvasRenderingContext2D.drawImage()");
1981 CanvasRenderingContext2D* context = 1980 CanvasRenderingContext2D* context =
1982 V8Proxy::FastToNativeObject<CanvasRenderingContext2D>( 1981 V8Proxy::ToNativeObject<CanvasRenderingContext2D>(
1983 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); 1982 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder());
1984 1983
1985 v8::Handle<v8::Value> arg = args[0]; 1984 v8::Handle<v8::Value> arg = args[0];
1986 1985
1987 if (V8HTMLImageElement::HasInstance(arg)) { 1986 if (V8HTMLImageElement::HasInstance(arg)) {
1988 ExceptionCode ec = 0; 1987 ExceptionCode ec = 0;
1989 HTMLImageElement* image_element = 1988 HTMLImageElement* image_element =
1990 V8Proxy::FastToNativeObject<HTMLImageElement>( 1989 V8Proxy::DOMWrapperToNode<HTMLImageElement>(arg);
1991 V8ClassIndex::HTMLIMAGEELEMENT, arg);
1992 switch (args.Length()) { 1990 switch (args.Length()) {
1993 case 3: 1991 case 3:
1994 context->drawImage(image_element, TO_FLOAT(args[1]), TO_FLOAT(args[2])); 1992 context->drawImage(image_element, TO_FLOAT(args[1]), TO_FLOAT(args[2]));
1995 break; 1993 break;
1996 case 5: 1994 case 5:
1997 context->drawImage(image_element, TO_FLOAT(args[1]), TO_FLOAT(args[2]), 1995 context->drawImage(image_element, TO_FLOAT(args[1]), TO_FLOAT(args[2]),
1998 TO_FLOAT(args[3]), TO_FLOAT(args[4]), ec); 1996 TO_FLOAT(args[3]), TO_FLOAT(args[4]), ec);
1999 if (ec != 0) { 1997 if (ec != 0) {
2000 V8Proxy::SetDOMException(ec); 1998 V8Proxy::SetDOMException(ec);
2001 return v8::Handle<v8::Value>(); 1999 return v8::Handle<v8::Value>();
(...skipping 16 matching lines...) Expand all
2018 "drawImage: Invalid number of arguments"); 2016 "drawImage: Invalid number of arguments");
2019 return v8::Undefined(); 2017 return v8::Undefined();
2020 } 2018 }
2021 return v8::Undefined(); 2019 return v8::Undefined();
2022 } 2020 }
2023 2021
2024 // HTMLCanvasElement 2022 // HTMLCanvasElement
2025 if (V8HTMLCanvasElement::HasInstance(arg)) { 2023 if (V8HTMLCanvasElement::HasInstance(arg)) {
2026 ExceptionCode ec = 0; 2024 ExceptionCode ec = 0;
2027 HTMLCanvasElement* canvas_element = 2025 HTMLCanvasElement* canvas_element =
2028 V8Proxy::FastToNativeObject<HTMLCanvasElement>( 2026 V8Proxy::DOMWrapperToNode<HTMLCanvasElement>(arg);
2029 V8ClassIndex::HTMLCANVASELEMENT, arg);
2030 switch (args.Length()) { 2027 switch (args.Length()) {
2031 case 3: 2028 case 3:
2032 context->drawImage(canvas_element, TO_FLOAT(args[1]), TO_FLOAT(args[2])); 2029 context->drawImage(canvas_element, TO_FLOAT(args[1]), TO_FLOAT(args[2]));
2033 break; 2030 break;
2034 case 5: 2031 case 5:
2035 context->drawImage(canvas_element, TO_FLOAT(args[1]), TO_FLOAT(args[2]), 2032 context->drawImage(canvas_element, TO_FLOAT(args[1]), TO_FLOAT(args[2]),
2036 TO_FLOAT(args[3]), TO_FLOAT(args[4]), ec); 2033 TO_FLOAT(args[3]), TO_FLOAT(args[4]), ec);
2037 if (ec != 0) { 2034 if (ec != 0) {
2038 V8Proxy::SetDOMException(ec); 2035 V8Proxy::SetDOMException(ec);
2039 return v8::Handle<v8::Value>(); 2036 return v8::Handle<v8::Value>();
(...skipping 20 matching lines...) Expand all
2060 } 2057 }
2061 2058
2062 V8Proxy::SetDOMException(TYPE_MISMATCH_ERR); 2059 V8Proxy::SetDOMException(TYPE_MISMATCH_ERR);
2063 return v8::Handle<v8::Value>(); 2060 return v8::Handle<v8::Value>();
2064 } 2061 }
2065 2062
2066 2063
2067 CALLBACK_FUNC_DECL(CanvasRenderingContext2DDrawImageFromRect) { 2064 CALLBACK_FUNC_DECL(CanvasRenderingContext2DDrawImageFromRect) {
2068 INC_STATS(L"DOM.CanvasRenderingContext2D.drawImageFromRect()"); 2065 INC_STATS(L"DOM.CanvasRenderingContext2D.drawImageFromRect()");
2069 CanvasRenderingContext2D* context = 2066 CanvasRenderingContext2D* context =
2070 V8Proxy::FastToNativeObject<CanvasRenderingContext2D>( 2067 V8Proxy::ToNativeObject<CanvasRenderingContext2D>(
2071 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); 2068 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder());
2072 2069
2073 v8::Handle<v8::Value> arg = args[0]; 2070 v8::Handle<v8::Value> arg = args[0];
2074 2071
2075 if (!V8Proxy::MaybeDOMWrapper(arg)) {
2076 V8Proxy::ThrowError(V8Proxy::TYPE_ERROR,
2077 "drawImageFromRect: Invalid type of arguments");
2078 return v8::Undefined();
2079 }
2080
2081 if (V8HTMLImageElement::HasInstance(arg)) { 2072 if (V8HTMLImageElement::HasInstance(arg)) {
2082 HTMLImageElement* image_element = 2073 HTMLImageElement* image_element =
2083 V8Proxy::FastToNativeObject<HTMLImageElement>( 2074 V8Proxy::DOMWrapperToNode<HTMLImageElement>(arg);
2084 V8ClassIndex::HTMLIMAGEELEMENT, arg);
2085 context->drawImageFromRect(image_element, 2075 context->drawImageFromRect(image_element,
2086 TO_FLOAT(args[1]), TO_FLOAT(args[2]), 2076 TO_FLOAT(args[1]), TO_FLOAT(args[2]),
2087 TO_FLOAT(args[3]), TO_FLOAT(args[4]), 2077 TO_FLOAT(args[3]), TO_FLOAT(args[4]),
2088 TO_FLOAT(args[5]), TO_FLOAT(args[6]), 2078 TO_FLOAT(args[5]), TO_FLOAT(args[6]),
2089 TO_FLOAT(args[7]), TO_FLOAT(args[8]), 2079 TO_FLOAT(args[7]), TO_FLOAT(args[8]),
2090 ToWebCoreString(args[9])); 2080 ToWebCoreString(args[9]));
2091 } else { 2081 } else {
2092 V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, 2082 V8Proxy::ThrowError(V8Proxy::TYPE_ERROR,
2093 "drawImageFromRect: Invalid type of arguments"); 2083 "drawImageFromRect: Invalid type of arguments");
2094 } 2084 }
2095 2085
2096 return v8::Undefined(); 2086 return v8::Undefined();
2097 } 2087 }
2098 2088
2099 // Remove the macro since we don't need it anymore. 2089 // Remove the macro since we don't need it anymore.
2100 #undef TO_FLOAT 2090 #undef TO_FLOAT
2101 2091
2102 CALLBACK_FUNC_DECL(CanvasRenderingContext2DCreatePattern) { 2092 CALLBACK_FUNC_DECL(CanvasRenderingContext2DCreatePattern) {
2103 INC_STATS(L"DOM.CanvasRenderingContext2D.createPattern()"); 2093 INC_STATS(L"DOM.CanvasRenderingContext2D.createPattern()");
2104 CanvasRenderingContext2D* context = 2094 CanvasRenderingContext2D* context =
2105 V8Proxy::FastToNativeObject<CanvasRenderingContext2D>( 2095 V8Proxy::ToNativeObject<CanvasRenderingContext2D>(
2106 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); 2096 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder());
2107 2097
2108 v8::Handle<v8::Value> arg = args[0]; 2098 v8::Handle<v8::Value> arg = args[0];
2109 2099
2110 if (V8HTMLImageElement::HasInstance(arg)) { 2100 if (V8HTMLImageElement::HasInstance(arg)) {
2111 HTMLImageElement* image_element = 2101 HTMLImageElement* image_element =
2112 V8Proxy::FastToNativeObject<HTMLImageElement>( 2102 V8Proxy::DOMWrapperToNode<HTMLImageElement>(arg);
2113 V8ClassIndex::HTMLIMAGEELEMENT, arg);
2114 ExceptionCode ec = 0; 2103 ExceptionCode ec = 0;
2115 RefPtr<CanvasPattern> pattern = 2104 RefPtr<CanvasPattern> pattern =
2116 context->createPattern(image_element, ToWebCoreString(args[1]), ec); 2105 context->createPattern(image_element, ToWebCoreString(args[1]), ec);
2117 if (ec != 0) { 2106 if (ec != 0) {
2118 V8Proxy::SetDOMException(ec); 2107 V8Proxy::SetDOMException(ec);
2119 return v8::Handle<v8::Value>(); 2108 return v8::Handle<v8::Value>();
2120 } 2109 }
2121 return V8Proxy::ToV8Object(V8ClassIndex::CANVASPATTERN, 2110 return V8Proxy::ToV8Object(V8ClassIndex::CANVASPATTERN,
2122 static_cast<Peerable*>(pattern.get())); 2111 static_cast<Peerable*>(pattern.get()));
2123 } 2112 }
2124 2113
2125 if (V8HTMLCanvasElement::HasInstance(arg)) { 2114 if (V8HTMLCanvasElement::HasInstance(arg)) {
2126 HTMLCanvasElement* canvas_element = 2115 HTMLCanvasElement* canvas_element =
2127 V8Proxy::FastToNativeObject<HTMLCanvasElement>( 2116 V8Proxy::DOMWrapperToNode<HTMLCanvasElement>(arg);
2128 V8ClassIndex::HTMLCANVASELEMENT, arg);
2129 ExceptionCode ec = 0; 2117 ExceptionCode ec = 0;
2130 RefPtr<CanvasPattern> pattern = 2118 RefPtr<CanvasPattern> pattern =
2131 context->createPattern(canvas_element, ToWebCoreString(args[1]), ec); 2119 context->createPattern(canvas_element, ToWebCoreString(args[1]), ec);
2132 if (ec != 0) { 2120 if (ec != 0) {
2133 V8Proxy::SetDOMException(ec); 2121 V8Proxy::SetDOMException(ec);
2134 return v8::Handle<v8::Value>(); 2122 return v8::Handle<v8::Value>();
2135 } 2123 }
2136 return V8Proxy::ToV8Object(V8ClassIndex::CANVASPATTERN, 2124 return V8Proxy::ToV8Object(V8ClassIndex::CANVASPATTERN,
2137 static_cast<Peerable*>(pattern.get())); 2125 static_cast<Peerable*>(pattern.get()));
2138 } 2126 }
2139 2127
2140 V8Proxy::SetDOMException(TYPE_MISMATCH_ERR); 2128 V8Proxy::SetDOMException(TYPE_MISMATCH_ERR);
2141 return v8::Handle<v8::Value>(); 2129 return v8::Handle<v8::Value>();
2142 } 2130 }
2143 2131
2144 2132
2145 CALLBACK_FUNC_DECL(ClipboardClearData) { 2133 CALLBACK_FUNC_DECL(ClipboardClearData) {
2146 INC_STATS(L"DOM.Clipboard.clearData()"); 2134 INC_STATS(L"DOM.Clipboard.clearData()");
2147 Clipboard* imp = V8Proxy::FastToNativeObject<Clipboard>( 2135 Clipboard* imp = V8Proxy::ToNativeObject<Clipboard>(
2148 V8ClassIndex::CLIPBOARD, args.Holder()); 2136 V8ClassIndex::CLIPBOARD, args.Holder());
2149 if (args.Length() == 0) { 2137 if (args.Length() == 0) {
2150 imp->clearAllData(); 2138 imp->clearAllData();
2151 } else { 2139 } else {
2152 String v = ToWebCoreString(args[0]); 2140 String v = ToWebCoreString(args[0]);
2153 imp->clearData(v); 2141 imp->clearData(v);
2154 } 2142 }
2155 return v8::Undefined(); 2143 return v8::Undefined();
2156 } 2144 }
2157 2145
2158 2146
2159 CALLBACK_FUNC_DECL(ClipboardGetData) { 2147 CALLBACK_FUNC_DECL(ClipboardGetData) {
2160 INC_STATS(L"DOM.Clipboard.getData()"); 2148 INC_STATS(L"DOM.Clipboard.getData()");
2161 Clipboard* imp = V8Proxy::FastToNativeObject<Clipboard>( 2149 Clipboard* imp = V8Proxy::ToNativeObject<Clipboard>(
2162 V8ClassIndex::CLIPBOARD, args.Holder()); 2150 V8ClassIndex::CLIPBOARD, args.Holder());
2163 if (args.Length() == 1) { 2151 if (args.Length() == 1) {
2164 bool success; 2152 bool success;
2165 String v = ToWebCoreString(args[0]); 2153 String v = ToWebCoreString(args[0]);
2166 String result = imp->getData(v, success); 2154 String result = imp->getData(v, success);
2167 if (success) return v8String(result); 2155 if (success) return v8String(result);
2168 return v8::Undefined(); 2156 return v8::Undefined();
2169 } 2157 }
2170 2158
2171 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, 2159 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR,
2172 "getData: Invalid number of arguments"); 2160 "getData: Invalid number of arguments");
2173 2161
2174 return v8::Undefined(); 2162 return v8::Undefined();
2175 } 2163 }
2176 2164
2177 CALLBACK_FUNC_DECL(ClipboardSetData) { 2165 CALLBACK_FUNC_DECL(ClipboardSetData) {
2178 INC_STATS(L"DOM.Clipboard.setData()"); 2166 INC_STATS(L"DOM.Clipboard.setData()");
2179 Clipboard* imp = V8Proxy::FastToNativeObject<Clipboard>( 2167 Clipboard* imp = V8Proxy::ToNativeObject<Clipboard>(
2180 V8ClassIndex::CLIPBOARD, args.Holder()); 2168 V8ClassIndex::CLIPBOARD, args.Holder());
2181 if (args.Length() == 2) { 2169 if (args.Length() == 2) {
2182 String type = ToWebCoreString(args[0]); 2170 String type = ToWebCoreString(args[0]);
2183 String data = ToWebCoreString(args[1]); 2171 String data = ToWebCoreString(args[1]);
2184 bool result = imp->setData(type, data); 2172 bool result = imp->setData(type, data);
2185 return result?v8::True():v8::False(); 2173 return result?v8::True():v8::False();
2186 } 2174 }
2187 2175
2188 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, 2176 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR,
2189 "setData: Invalid number of arguments"); 2177 "setData: Invalid number of arguments");
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2222 Node* contentDoc = frame->contentDocument(); 2210 Node* contentDoc = frame->contentDocument();
2223 if (contentDoc && !V8Proxy::CheckNodeSecurity(contentDoc)) 2211 if (contentDoc && !V8Proxy::CheckNodeSecurity(contentDoc))
2224 return false; 2212 return false;
2225 } 2213 }
2226 return true; 2214 return true;
2227 } 2215 }
2228 2216
2229 2217
2230 CALLBACK_FUNC_DECL(ElementSetAttribute) { 2218 CALLBACK_FUNC_DECL(ElementSetAttribute) {
2231 INC_STATS(L"DOM.Element.setAttribute()"); 2219 INC_STATS(L"DOM.Element.setAttribute()");
2232 Element* imp = V8Proxy::FastToNativeObject<Element>( 2220 Element* imp = V8Proxy::DOMWrapperToNode<Element>(args.Holder());
2233 V8ClassIndex::ELEMENT, args.Holder());
2234 ExceptionCode ec = 0; 2221 ExceptionCode ec = 0;
2235 String name = ToWebCoreString(args[0]); 2222 String name = ToWebCoreString(args[0]);
2236 String value = ToWebCoreString(args[1]); 2223 String value = ToWebCoreString(args[1]);
2237 2224
2238 if (!AllowSettingSrcToJavascriptURL(imp, name, value)) { 2225 if (!AllowSettingSrcToJavascriptURL(imp, name, value)) {
2239 return v8::Undefined(); 2226 return v8::Undefined();
2240 } 2227 }
2241 2228
2242 imp->setAttribute(name, value, ec); 2229 imp->setAttribute(name, value, ec);
2243 if (ec != 0) { 2230 if (ec != 0) {
2244 V8Proxy::SetDOMException(ec); 2231 V8Proxy::SetDOMException(ec);
2245 return v8::Handle<v8::Value>(); 2232 return v8::Handle<v8::Value>();
2246 } 2233 }
2247 return v8::Undefined(); 2234 return v8::Undefined();
2248 } 2235 }
2249 2236
2250 2237
2251 CALLBACK_FUNC_DECL(ElementSetAttributeNode) { 2238 CALLBACK_FUNC_DECL(ElementSetAttributeNode) {
2252 INC_STATS(L"DOM.Element.setAttributeNode()"); 2239 INC_STATS(L"DOM.Element.setAttributeNode()");
2253 if (!V8Attr::HasInstance(args[0])) { 2240 if (!V8Attr::HasInstance(args[0])) {
2254 V8Proxy::SetDOMException(TYPE_MISMATCH_ERR); 2241 V8Proxy::SetDOMException(TYPE_MISMATCH_ERR);
2255 return v8::Handle<v8::Value>(); 2242 return v8::Handle<v8::Value>();
2256 } 2243 }
2257 2244
2258 Attr* newAttr = 2245 Attr* newAttr = V8Proxy::DOMWrapperToNode<Attr>(args[0]);
2259 V8Proxy::FastToNativeObject<Attr>(V8ClassIndex::ATTR, args[0]); 2246 Element* imp = V8Proxy::DOMWrapperToNode<Element>(args.Holder());
2260
2261 ExceptionCode ec = 0; 2247 ExceptionCode ec = 0;
2262 Element* imp = V8Proxy::FastToNativeObject<Element>(
2263 V8ClassIndex::ELEMENT, args.Holder());
2264 2248
2265 if (!AllowSettingSrcToJavascriptURL(imp, newAttr->name(), newAttr->value())) { 2249 if (!AllowSettingSrcToJavascriptURL(imp, newAttr->name(), newAttr->value())) {
2266 return v8::Undefined(); 2250 return v8::Undefined();
2267 } 2251 }
2268 2252
2269 RefPtr<Attr> result = imp->setAttributeNode(newAttr, ec); 2253 RefPtr<Attr> result = imp->setAttributeNode(newAttr, ec);
2270 if (ec != 0) { 2254 if (ec != 0) {
2271 V8Proxy::SetDOMException(ec); 2255 V8Proxy::SetDOMException(ec);
2272 return v8::Handle<v8::Value>(); 2256 return v8::Handle<v8::Value>();
2273 } 2257 }
2274 return V8Proxy::ToV8Object(V8ClassIndex::NODE, result.get()); 2258 return V8Proxy::NodeToV8Object(result.get());
2275 } 2259 }
2276 2260
2277 2261
2278 CALLBACK_FUNC_DECL(ElementSetAttributeNS) { 2262 CALLBACK_FUNC_DECL(ElementSetAttributeNS) {
2279 INC_STATS(L"DOM.Element.setAttributeNS()"); 2263 INC_STATS(L"DOM.Element.setAttributeNS()");
2280 Element* imp = V8Proxy::FastToNativeObject<Element>( 2264 Element* imp = V8Proxy::DOMWrapperToNode<Element>(args.Holder());
2281 V8ClassIndex::ELEMENT, args.Holder());
2282 ExceptionCode ec = 0; 2265 ExceptionCode ec = 0;
2283 String namespaceURI = valueToStringWithNullCheck(args[0]); 2266 String namespaceURI = valueToStringWithNullCheck(args[0]);
2284 String qualifiedName = ToWebCoreString(args[1]); 2267 String qualifiedName = ToWebCoreString(args[1]);
2285 String value = ToWebCoreString(args[2]); 2268 String value = ToWebCoreString(args[2]);
2286 2269
2287 if (!AllowSettingSrcToJavascriptURL(imp, qualifiedName, value)) { 2270 if (!AllowSettingSrcToJavascriptURL(imp, qualifiedName, value)) {
2288 return v8::Undefined(); 2271 return v8::Undefined();
2289 } 2272 }
2290 2273
2291 imp->setAttributeNS(namespaceURI, qualifiedName, value, ec); 2274 imp->setAttributeNS(namespaceURI, qualifiedName, value, ec);
2292 if (ec != 0) { 2275 if (ec != 0) {
2293 V8Proxy::SetDOMException(ec); 2276 V8Proxy::SetDOMException(ec);
2294 return v8::Handle<v8::Value>(); 2277 return v8::Handle<v8::Value>();
2295 } 2278 }
2296 return v8::Undefined(); 2279 return v8::Undefined();
2297 } 2280 }
2298 2281
2299 2282
2300 CALLBACK_FUNC_DECL(ElementSetAttributeNodeNS) { 2283 CALLBACK_FUNC_DECL(ElementSetAttributeNodeNS) {
2301 INC_STATS(L"DOM.Element.setAttributeNodeNS()"); 2284 INC_STATS(L"DOM.Element.setAttributeNodeNS()");
2302 if (!V8Attr::HasInstance(args[0])) { 2285 if (!V8Attr::HasInstance(args[0])) {
2303 V8Proxy::SetDOMException(TYPE_MISMATCH_ERR); 2286 V8Proxy::SetDOMException(TYPE_MISMATCH_ERR);
2304 return v8::Handle<v8::Value>(); 2287 return v8::Handle<v8::Value>();
2305 } 2288 }
2306 2289
2307 Attr* newAttr = 2290 Attr* newAttr = V8Proxy::DOMWrapperToNode<Attr>(args[0]);
2308 V8Proxy::FastToNativeObject<Attr>(V8ClassIndex::ATTR, args[0]); 2291 Element* imp = V8Proxy::DOMWrapperToNode<Element>(args.Holder());
2309
2310 Element* imp = V8Proxy::FastToNativeObject<Element>(
2311 V8ClassIndex::ELEMENT, args.Holder());
2312 ExceptionCode ec = 0; 2292 ExceptionCode ec = 0;
2313 2293
2314 if (!AllowSettingSrcToJavascriptURL(imp, newAttr->name(), newAttr->value())) { 2294 if (!AllowSettingSrcToJavascriptURL(imp, newAttr->name(), newAttr->value())) {
2315 return v8::Undefined(); 2295 return v8::Undefined();
2316 } 2296 }
2317 2297
2318 RefPtr<Attr> result = imp->setAttributeNodeNS(newAttr, ec); 2298 RefPtr<Attr> result = imp->setAttributeNodeNS(newAttr, ec);
2319 if (ec != 0) { 2299 if (ec != 0) {
2320 V8Proxy::SetDOMException(ec); 2300 V8Proxy::SetDOMException(ec);
2321 return v8::Handle<v8::Value>(); 2301 return v8::Handle<v8::Value>();
2322 } 2302 }
2323 return V8Proxy::ToV8Object(V8ClassIndex::NODE, result.get()); 2303 return V8Proxy::NodeToV8Object(result.get());
2324 } 2304 }
2325 2305
2326 2306
2327 ACCESSOR_SETTER(AttrValue) { 2307 ACCESSOR_SETTER(AttrValue) {
2328 Attr* imp = 2308 Attr* imp =
2329 V8Proxy::FastToNativeObject<Attr>(V8ClassIndex::ATTR, info.Holder()); 2309 V8Proxy::DOMWrapperToNode<Attr>(info.Holder());
2330 String v = valueToStringWithNullCheck(value); 2310 String v = valueToStringWithNullCheck(value);
2331 Element* ownerElement = imp->ownerElement(); 2311 Element* ownerElement = imp->ownerElement();
2332 2312
2333 if (ownerElement && 2313 if (ownerElement &&
2334 !AllowSettingSrcToJavascriptURL(ownerElement, imp->name(), v)) 2314 !AllowSettingSrcToJavascriptURL(ownerElement, imp->name(), v))
2335 return; 2315 return;
2336 2316
2337 ExceptionCode ec = 0; 2317 ExceptionCode ec = 0;
2338 imp->setValue(v, ec); 2318 imp->setValue(v, ec);
2339 V8Proxy::SetDOMException(ec); 2319 V8Proxy::SetDOMException(ec);
2340 } 2320 }
2341 2321
2342 2322
2343 ACCESSOR_SETTER(HTMLFrameElementSrc) { 2323 ACCESSOR_SETTER(HTMLFrameElementSrc) {
2344 HTMLFrameElement* imp = V8Proxy::FastToNativeObject<HTMLFrameElement>( 2324 HTMLFrameElement* imp =
2345 V8ClassIndex::HTMLFRAMEELEMENT, info.Holder()); 2325 V8Proxy::DOMWrapperToNode<HTMLFrameElement>(info.Holder());
2346 String v = valueToStringWithNullCheck(value); 2326 String v = valueToStringWithNullCheck(value);
2347 2327
2348 if (!AllowSettingFrameSrcToJavascriptUrl(imp, v)) return; 2328 if (!AllowSettingFrameSrcToJavascriptUrl(imp, v)) return;
2349 2329
2350 imp->setSrc(v); 2330 imp->setSrc(v);
2351 } 2331 }
2352 2332
2353 2333
2354 ACCESSOR_SETTER(HTMLFrameElementLocation) { 2334 ACCESSOR_SETTER(HTMLFrameElementLocation) {
2355 HTMLFrameElement* imp = V8Proxy::FastToNativeObject<HTMLFrameElement>( 2335 HTMLFrameElement* imp =
2356 V8ClassIndex::HTMLFRAMEELEMENT, info.Holder()); 2336 V8Proxy::DOMWrapperToNode<HTMLFrameElement>(info.Holder());
2357 String v = valueToStringWithNullCheck(value); 2337 String v = valueToStringWithNullCheck(value);
2358 2338
2359 if (!AllowSettingFrameSrcToJavascriptUrl(imp, v)) return; 2339 if (!AllowSettingFrameSrcToJavascriptUrl(imp, v)) return;
2360 2340
2361 imp->setLocation(v); 2341 imp->setLocation(v);
2362 } 2342 }
2363 2343
2364 2344
2365 ACCESSOR_SETTER(HTMLIFrameElementSrc) { 2345 ACCESSOR_SETTER(HTMLIFrameElementSrc) {
2366 HTMLIFrameElement* imp = V8Proxy::FastToNativeObject<HTMLIFrameElement>( 2346 HTMLIFrameElement* imp =
2367 V8ClassIndex::HTMLIFRAMEELEMENT, info.Holder()); 2347 V8Proxy::DOMWrapperToNode<HTMLIFrameElement>(info.Holder());
2368 String v = valueToStringWithNullCheck(value); 2348 String v = valueToStringWithNullCheck(value);
2369 2349
2370 if (!AllowSettingFrameSrcToJavascriptUrl(imp, v)) return; 2350 if (!AllowSettingFrameSrcToJavascriptUrl(imp, v)) return;
2371 2351
2372 imp->setSrc(v); 2352 imp->setSrc(v);
2373 } 2353 }
2374 2354
2375 2355
2376 v8::Handle<v8::Value> V8Custom::WindowSetTimeoutImpl(const v8::Arguments& args, 2356 v8::Handle<v8::Value> V8Custom::WindowSetTimeoutImpl(const v8::Arguments& args,
2377 bool single_shot) { 2357 bool single_shot) {
2378 int num_arguments = args.Length(); 2358 int num_arguments = args.Length();
2379 2359
2380 if (num_arguments < 1) return v8::Undefined(); 2360 if (num_arguments < 1) return v8::Undefined();
2381 2361
2382 DOMWindow* imp = V8Proxy::FastToNativeObject<DOMWindow>( 2362 DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>(
2383 V8ClassIndex::DOMWINDOW, args.Holder()); 2363 V8ClassIndex::DOMWINDOW, args.Holder());
2384 2364
2385 // Fast check This argument with the global object of security context. 2365 // Fast check This argument with the global object of security context.
2386 if ((args.This() != v8::Context::GetCurrentSecurityContext()->Global()) && 2366 if ((args.This() != v8::Context::GetCurrentSecurityContext()->Global()) &&
2387 !V8Proxy::IsFromSameOrigin(imp->frame(), true)) { 2367 !V8Proxy::IsFromSameOrigin(imp->frame(), true)) {
2388 return v8::Undefined(); 2368 return v8::Undefined();
2389 } 2369 }
2390 2370
2391 v8::Handle<v8::Value> function = args[0]; 2371 v8::Handle<v8::Value> function = args[0];
2392 2372
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2447 String str = ""; 2427 String str = "";
2448 for (int i = 0; i < args.Length(); ++i) { 2428 for (int i = 0; i < args.Length(); ++i) {
2449 str += ToWebCoreString(args[i]); 2429 str += ToWebCoreString(args[i]);
2450 } 2430 }
2451 return str; 2431 return str;
2452 } 2432 }
2453 2433
2454 2434
2455 CALLBACK_FUNC_DECL(HTMLDocumentWrite) { 2435 CALLBACK_FUNC_DECL(HTMLDocumentWrite) {
2456 INC_STATS(L"DOM.HTMLDocument.write()"); 2436 INC_STATS(L"DOM.HTMLDocument.write()");
2457 HTMLDocument* imp = V8Proxy::FastToNativeObject<HTMLDocument>( 2437 HTMLDocument* imp = V8Proxy::DOMWrapperToNode<HTMLDocument>(args.Holder());
2458 V8ClassIndex::HTMLDOCUMENT, args.Holder());
2459 imp->write(WriteHelper_GetString(args)); 2438 imp->write(WriteHelper_GetString(args));
2460 return v8::Undefined(); 2439 return v8::Undefined();
2461 } 2440 }
2462 2441
2463 2442
2464 CALLBACK_FUNC_DECL(HTMLDocumentWriteln) { 2443 CALLBACK_FUNC_DECL(HTMLDocumentWriteln) {
2465 INC_STATS(L"DOM.HTMLDocument.writeln()"); 2444 INC_STATS(L"DOM.HTMLDocument.writeln()");
2466 HTMLDocument* imp = V8Proxy::FastToNativeObject<HTMLDocument>( 2445 HTMLDocument* imp = V8Proxy::DOMWrapperToNode<HTMLDocument>(args.Holder());
2467 V8ClassIndex::HTMLDOCUMENT, args.Holder());
2468 imp->writeln(WriteHelper_GetString(args)); 2446 imp->writeln(WriteHelper_GetString(args));
2469 return v8::Undefined(); 2447 return v8::Undefined();
2470 } 2448 }
2471 2449
2472 2450
2473 CALLBACK_FUNC_DECL(HTMLDocumentOpen) { 2451 CALLBACK_FUNC_DECL(HTMLDocumentOpen) {
2474 INC_STATS(L"DOM.HTMLDocument.open()"); 2452 INC_STATS(L"DOM.HTMLDocument.open()");
2475 HTMLDocument* imp = V8Proxy::FastToNativeObject<HTMLDocument>( 2453 HTMLDocument* imp = V8Proxy::DOMWrapperToNode<HTMLDocument>(args.Holder());
2476 V8ClassIndex::HTMLDOCUMENT, args.Holder());
2477 2454
2478 if (args.Length() > 2) { 2455 if (args.Length() > 2) {
2479 if (Frame* frame = imp->frame()) { 2456 if (Frame* frame = imp->frame()) {
2480 // Fetch the global object for the frame. 2457 // Fetch the global object for the frame.
2481 v8::Local<v8::Context> context = V8Proxy::GetContext(frame); 2458 v8::Local<v8::Context> context = V8Proxy::GetContext(frame);
2482 // Bail out if we cannot get the context. 2459 // Bail out if we cannot get the context.
2483 if (context.IsEmpty()) return v8::Undefined(); 2460 if (context.IsEmpty()) return v8::Undefined();
2484 v8::Local<v8::Object> global = context->Global(); 2461 v8::Local<v8::Object> global = context->Global();
2485 // Get the open property of the global object. 2462 // Get the open property of the global object.
2486 v8::Local<v8::Value> function = global->Get(v8::String::New("open")); 2463 v8::Local<v8::Value> function = global->Get(v8::String::New("open"));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2519 // Invoking HTMLDocument::clear() can cause a crash, since it 2496 // Invoking HTMLDocument::clear() can cause a crash, since it
2520 // deletes the document's tokenizer while it may still be in use. 2497 // deletes the document's tokenizer while it may still be in use.
2521 // See b:1055485 for details. 2498 // See b:1055485 for details.
2522 return v8::Undefined(); 2499 return v8::Undefined();
2523 } 2500 }
2524 2501
2525 2502
2526 CALLBACK_FUNC_DECL(DocumentEvaluate) { 2503 CALLBACK_FUNC_DECL(DocumentEvaluate) {
2527 INC_STATS(L"DOM.Document.evaluate()"); 2504 INC_STATS(L"DOM.Document.evaluate()");
2528 2505
2529 Document* imp = V8Proxy::FastToNativeObject<Document>( 2506 Document* imp = V8Proxy::DOMWrapperToNode<Document>(args.Holder());
2530 V8ClassIndex::DOCUMENT, args.Holder());
2531 ExceptionCode ec = 0; 2507 ExceptionCode ec = 0;
2532 String expression = ToWebCoreString(args[0]); 2508 String expression = ToWebCoreString(args[0]);
2533 Node* contextNode = NULL; 2509 Node* contextNode = NULL;
2534 if (V8Node::HasInstance(args[1])) { 2510 if (V8Node::HasInstance(args[1])) {
2535 contextNode = 2511 contextNode = V8Proxy::DOMWrapperToNode<Node>(args[1]);
2536 V8Proxy::FastToNativeObject<Node>(V8ClassIndex::NODE, args[1]);
2537 } 2512 }
2538 // Find the XPath 2513 // Find the XPath
2539 XPathNSResolver* resolver = NULL; 2514 XPathNSResolver* resolver = NULL;
2540 if (V8XPathNSResolver::HasInstance(args[2])) { 2515 if (V8XPathNSResolver::HasInstance(args[2])) {
2541 resolver = V8Proxy::FastToNativeObject<XPathNSResolver>( 2516 resolver = V8Proxy::ToNativeObject<XPathNSResolver>(
2542 V8ClassIndex::XPATHNSRESOLVER, args[2]); 2517 V8ClassIndex::XPATHNSRESOLVER, args[2]);
2543 } else if (args[2]->IsObject()) { 2518 } else if (args[2]->IsObject()) {
2544 v8::Handle<v8::Object> obj = args[2]->ToObject(); 2519 v8::Handle<v8::Object> obj = args[2]->ToObject();
2545 resolver = new JSXPathNSResolver(obj); 2520 resolver = new JSXPathNSResolver(obj);
2546 } else if (!args[2]->IsNull() && !args[2]->IsUndefined()) { 2521 } else if (!args[2]->IsNull() && !args[2]->IsUndefined()) {
2547 V8Proxy::SetDOMException(TYPE_MISMATCH_ERR); 2522 V8Proxy::SetDOMException(TYPE_MISMATCH_ERR);
2548 return v8::Handle<v8::Value>(); 2523 return v8::Handle<v8::Value>();
2549 } 2524 }
2550 int type = ToInt32(args[3]); 2525 int type = ToInt32(args[3]);
2551 XPathResult* inResult = NULL; 2526 XPathResult* inResult = NULL;
2552 if (V8XPathResult::HasInstance(args[4])) { 2527 if (V8XPathResult::HasInstance(args[4])) {
2553 inResult = V8Proxy::FastToNativeObject<XPathResult>( 2528 inResult = V8Proxy::ToNativeObject<XPathResult>(
2554 V8ClassIndex::XPATHRESULT, args[4]); 2529 V8ClassIndex::XPATHRESULT, args[4]);
2555 } 2530 }
2556 RefPtr<XPathResult> result = 2531 RefPtr<XPathResult> result =
2557 imp->evaluate(expression, contextNode, resolver, type, inResult, ec); 2532 imp->evaluate(expression, contextNode, resolver, type, inResult, ec);
2558 if (ec != 0) { 2533 if (ec != 0) {
2559 V8Proxy::SetDOMException(ec); 2534 V8Proxy::SetDOMException(ec);
2560 return v8::Handle<v8::Value>(); 2535 return v8::Handle<v8::Value>();
2561 } 2536 }
2562 return V8Proxy::ToV8Object(V8ClassIndex::XPATHRESULT, 2537 return V8Proxy::ToV8Object(V8ClassIndex::XPATHRESULT,
2563 static_cast<Peerable*>(result.get())); 2538 static_cast<Peerable*>(result.get()));
(...skipping 29 matching lines...) Expand all
2593 return v8::Undefined(); 2568 return v8::Undefined();
2594 } 2569 }
2595 } 2570 }
2596 2571
2597 return v8String(String(out.data(), out.size())); 2572 return v8String(String(out.data(), out.size()));
2598 } 2573 }
2599 2574
2600 2575
2601 CALLBACK_FUNC_DECL(DOMWindowAtob) { 2576 CALLBACK_FUNC_DECL(DOMWindowAtob) {
2602 INC_STATS(L"DOM.DOMWindow.atob()"); 2577 INC_STATS(L"DOM.DOMWindow.atob()");
2603 DOMWindow* imp = V8Proxy::FastToNativeObject<DOMWindow>( 2578 DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>(
2604 V8ClassIndex::DOMWINDOW, args.Holder()); 2579 V8ClassIndex::DOMWINDOW, args.Holder());
2605 2580
2606 // Fast check This argument with the global object of security context. 2581 // Fast check This argument with the global object of security context.
2607 if ((args.This() != v8::Context::GetCurrentSecurityContext()->Global()) && 2582 if ((args.This() != v8::Context::GetCurrentSecurityContext()->Global()) &&
2608 !V8Proxy::IsFromSameOrigin(imp->frame(), true)) { 2583 !V8Proxy::IsFromSameOrigin(imp->frame(), true)) {
2609 return v8::Undefined(); 2584 return v8::Undefined();
2610 } 2585 }
2611 2586
2612 if (args.Length() < 1) { 2587 if (args.Length() < 1) {
2613 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments"); 2588 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments");
2614 return v8::Undefined(); 2589 return v8::Undefined();
2615 } 2590 }
2616 2591
2617 if (args[0]->IsNull()) return v8String(""); 2592 if (args[0]->IsNull()) return v8String("");
2618 2593
2619 String str = ToWebCoreString(args[0]); 2594 String str = ToWebCoreString(args[0]);
2620 return Base64Convert(str, false); 2595 return Base64Convert(str, false);
2621 } 2596 }
2622 2597
2623 2598
2624 CALLBACK_FUNC_DECL(DOMWindowBtoa) { 2599 CALLBACK_FUNC_DECL(DOMWindowBtoa) {
2625 INC_STATS(L"DOM.DOMWindow.btoa()"); 2600 INC_STATS(L"DOM.DOMWindow.btoa()");
2626 DOMWindow* imp = V8Proxy::FastToNativeObject<DOMWindow>( 2601 DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>(
2627 V8ClassIndex::DOMWINDOW, args.Holder()); 2602 V8ClassIndex::DOMWINDOW, args.Holder());
2628 2603
2629 // Fast check This argument with the global object of security context. 2604 // Fast check This argument with the global object of security context.
2630 if ((args.This() != v8::Context::GetCurrentSecurityContext()->Global()) && 2605 if ((args.This() != v8::Context::GetCurrentSecurityContext()->Global()) &&
2631 !V8Proxy::IsFromSameOrigin(imp->frame(), true)) { 2606 !V8Proxy::IsFromSameOrigin(imp->frame(), true)) {
2632 return v8::Undefined(); 2607 return v8::Undefined();
2633 } 2608 }
2634 2609
2635 if (args.Length() < 1) { 2610 if (args.Length() < 1) {
2636 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments"); 2611 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments");
(...skipping 18 matching lines...) Expand all
2655 2630
2656 2631
2657 CALLBACK_FUNC_DECL(DOMWindowNOP) { 2632 CALLBACK_FUNC_DECL(DOMWindowNOP) {
2658 INC_STATS(L"DOM.DOMWindow.nop()"); 2633 INC_STATS(L"DOM.DOMWindow.nop()");
2659 return v8::Undefined(); 2634 return v8::Undefined();
2660 } 2635 }
2661 2636
2662 2637
2663 CALLBACK_FUNC_DECL(EventTargetNodeAddEventListener) { 2638 CALLBACK_FUNC_DECL(EventTargetNodeAddEventListener) {
2664 INC_STATS(L"DOM.EventTargetNode.addEventListener()"); 2639 INC_STATS(L"DOM.EventTargetNode.addEventListener()");
2665 EventTargetNode* node = V8Proxy::FastToNativeObject<EventTargetNode>( 2640 EventTargetNode* node =
2666 V8ClassIndex::EVENTTARGETNODE, args.Holder()); 2641 V8Proxy::DOMWrapperToNode<EventTargetNode>(args.Holder());
2667 2642
2668 V8Proxy* proxy = V8Proxy::retrieve(node->document()->frame()); 2643 V8Proxy* proxy = V8Proxy::retrieve(node->document()->frame());
2669 if (!proxy) 2644 if (!proxy)
2670 return v8::Undefined(); 2645 return v8::Undefined();
2671 2646
2672 EventListener* listener = 2647 EventListener* listener =
2673 proxy->FindOrCreateV8EventListener(args[1], false); 2648 proxy->FindOrCreateV8EventListener(args[1], false);
2674 if (listener) { 2649 if (listener) {
2675 String type = ToWebCoreString(args[0]); 2650 String type = ToWebCoreString(args[0]);
2676 bool useCapture = args[2]->BooleanValue(); 2651 bool useCapture = args[2]->BooleanValue();
2677 node->addEventListener(type, listener, useCapture); 2652 node->addEventListener(type, listener, useCapture);
2678 } 2653 }
2679 return v8::Undefined(); 2654 return v8::Undefined();
2680 } 2655 }
2681 2656
2682 2657
2683 CALLBACK_FUNC_DECL(EventTargetNodeRemoveEventListener) { 2658 CALLBACK_FUNC_DECL(EventTargetNodeRemoveEventListener) {
2684 INC_STATS(L"DOM.EventTargetNode.removeEventListener()"); 2659 INC_STATS(L"DOM.EventTargetNode.removeEventListener()");
2685 EventTargetNode* node = V8Proxy::FastToNativeObject<EventTargetNode>( 2660 EventTargetNode* node =
2686 V8ClassIndex::EVENTTARGETNODE, args.Holder()); 2661 V8Proxy::DOMWrapperToNode<EventTargetNode>(args.Holder());
2687 2662
2688 V8Proxy* proxy = V8Proxy::retrieve(node->document()->frame()); 2663 V8Proxy* proxy = V8Proxy::retrieve(node->document()->frame());
2689 // It is possbile that the owner document of the node is detached 2664 // It is possbile that the owner document of the node is detached
2690 // from the frame, return immediately in this case. 2665 // from the frame, return immediately in this case.
2691 // See issue 878909 2666 // See issue 878909
2692 if (!proxy) 2667 if (!proxy)
2693 return v8::Undefined(); 2668 return v8::Undefined();
2694 2669
2695 EventListener* listener = 2670 EventListener* listener =
2696 proxy->FindV8EventListener(args[1], false); 2671 proxy->FindV8EventListener(args[1], false);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2738 return; 2713 return;
2739 } 2714 }
2740 } 2715 }
2741 2716
2742 // Should not reach here. 2717 // Should not reach here.
2743 ASSERT(false); 2718 ASSERT(false);
2744 } 2719 }
2745 2720
2746 2721
2747 ACCESSOR_SETTER(XMLHttpRequestOnreadystatechange) { 2722 ACCESSOR_SETTER(XMLHttpRequestOnreadystatechange) {
2748 XMLHttpRequest* imp = V8Proxy::FastToNativeObject<XMLHttpRequest>( 2723 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
2749 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); 2724 V8ClassIndex::XMLHTTPREQUEST, info.Holder());
2750 if (value->IsNull()) { 2725 if (value->IsNull()) {
2751 if (imp->onreadystatechange()) { 2726 if (imp->onreadystatechange()) {
2752 V8XHREventListener* listener = 2727 V8XHREventListener* listener =
2753 static_cast<V8XHREventListener*>(imp->onreadystatechange()); 2728 static_cast<V8XHREventListener*>(imp->onreadystatechange());
2754 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); 2729 v8::Local<v8::Object> v8_listener = listener->GetListenerObject();
2755 RemoveHiddenXHRDependency(info.Holder(), v8_listener); 2730 RemoveHiddenXHRDependency(info.Holder(), v8_listener);
2756 } 2731 }
2757 2732
2758 // Clear the listener 2733 // Clear the listener
2759 imp->setOnreadystatechange(0); 2734 imp->setOnreadystatechange(0);
2760 2735
2761 } else { 2736 } else {
2762 V8Proxy* proxy = V8Proxy::retrieve(imp->document()->frame()); 2737 V8Proxy* proxy = V8Proxy::retrieve(imp->document()->frame());
2763 if (!proxy) 2738 if (!proxy)
2764 return; 2739 return;
2765 2740
2766 EventListener* listener = 2741 EventListener* listener =
2767 proxy->FindOrCreateXHREventListener(value, false); 2742 proxy->FindOrCreateXHREventListener(value, false);
2768 if (listener) { 2743 if (listener) {
2769 imp->setOnreadystatechange(listener); 2744 imp->setOnreadystatechange(listener);
2770 CreateHiddenXHRDependency(info.Holder(), value); 2745 CreateHiddenXHRDependency(info.Holder(), value);
2771 } 2746 }
2772 } 2747 }
2773 } 2748 }
2774 2749
2775 2750
2776 ACCESSOR_SETTER(XMLHttpRequestOnload) { 2751 ACCESSOR_SETTER(XMLHttpRequestOnload) {
2777 XMLHttpRequest* imp = V8Proxy::FastToNativeObject<XMLHttpRequest>( 2752 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
2778 V8ClassIndex::XMLHTTPREQUEST, info.Holder()); 2753 V8ClassIndex::XMLHTTPREQUEST, info.Holder());
2779 if (value->IsNull()) { 2754 if (value->IsNull()) {
2780 if (imp->onload()) { 2755 if (imp->onload()) {
2781 V8XHREventListener* listener = 2756 V8XHREventListener* listener =
2782 static_cast<V8XHREventListener*>(imp->onload()); 2757 static_cast<V8XHREventListener*>(imp->onload());
2783 v8::Local<v8::Object> v8_listener = listener->GetListenerObject(); 2758 v8::Local<v8::Object> v8_listener = listener->GetListenerObject();
2784 RemoveHiddenXHRDependency(info.Holder(), v8_listener); 2759 RemoveHiddenXHRDependency(info.Holder(), v8_listener);
2785 } 2760 }
2786 2761
2787 imp->setOnload(0); 2762 imp->setOnload(0);
2788 2763
2789 } else { 2764 } else {
2790 V8Proxy* proxy = V8Proxy::retrieve(imp->document()->frame()); 2765 V8Proxy* proxy = V8Proxy::retrieve(imp->document()->frame());
2791 if (!proxy) 2766 if (!proxy)
2792 return; 2767 return;
2793 2768
2794 EventListener* listener = 2769 EventListener* listener =
2795 proxy->FindOrCreateXHREventListener(value, false); 2770 proxy->FindOrCreateXHREventListener(value, false);
2796 if (listener) { 2771 if (listener) {
2797 imp->setOnload(listener); 2772 imp->setOnload(listener);
2798 CreateHiddenXHRDependency(info.Holder(), value); 2773 CreateHiddenXHRDependency(info.Holder(), value);
2799 } 2774 }
2800 } 2775 }
2801 } 2776 }
2802 2777
2803 2778
2804 CALLBACK_FUNC_DECL(XMLHttpRequestAddEventListener) { 2779 CALLBACK_FUNC_DECL(XMLHttpRequestAddEventListener) {
2805 INC_STATS(L"DOM.XMLHttpRequest.addEventListener()"); 2780 INC_STATS(L"DOM.XMLHttpRequest.addEventListener()");
2806 XMLHttpRequest* imp = V8Proxy::FastToNativeObject<XMLHttpRequest>( 2781 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
2807 V8ClassIndex::XMLHTTPREQUEST, args.Holder()); 2782 V8ClassIndex::XMLHTTPREQUEST, args.Holder());
2808 2783
2809 V8Proxy* proxy = V8Proxy::retrieve(imp->document()->frame()); 2784 V8Proxy* proxy = V8Proxy::retrieve(imp->document()->frame());
2810 if (!proxy) 2785 if (!proxy)
2811 return v8::Undefined(); 2786 return v8::Undefined();
2812 2787
2813 EventListener* listener = 2788 EventListener* listener =
2814 proxy->FindOrCreateXHREventListener(args[1], false); 2789 proxy->FindOrCreateXHREventListener(args[1], false);
2815 if (listener) { 2790 if (listener) {
2816 String type = ToWebCoreString(args[0]); 2791 String type = ToWebCoreString(args[0]);
2817 bool useCapture = args[2]->BooleanValue(); 2792 bool useCapture = args[2]->BooleanValue();
2818 imp->addEventListener(type, listener, useCapture); 2793 imp->addEventListener(type, listener, useCapture);
2819 2794
2820 CreateHiddenXHRDependency(args.Holder(), args[1]); 2795 CreateHiddenXHRDependency(args.Holder(), args[1]);
2821 } 2796 }
2822 return v8::Undefined(); 2797 return v8::Undefined();
2823 } 2798 }
2824 2799
2825 2800
2826 CALLBACK_FUNC_DECL(XMLHttpRequestRemoveEventListener) { 2801 CALLBACK_FUNC_DECL(XMLHttpRequestRemoveEventListener) {
2827 INC_STATS(L"DOM.XMLHttpRequest.removeEventListener()"); 2802 INC_STATS(L"DOM.XMLHttpRequest.removeEventListener()");
2828 XMLHttpRequest* imp = V8Proxy::FastToNativeObject<XMLHttpRequest>( 2803 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
2829 V8ClassIndex::XMLHTTPREQUEST, args.Holder()); 2804 V8ClassIndex::XMLHTTPREQUEST, args.Holder());
2830 2805
2831 V8Proxy* proxy = V8Proxy::retrieve(imp->document()->frame()); 2806 V8Proxy* proxy = V8Proxy::retrieve(imp->document()->frame());
2832 if (!proxy) 2807 if (!proxy)
2833 return v8::Undefined(); // probably leaked 2808 return v8::Undefined(); // probably leaked
2834 2809
2835 EventListener* listener = 2810 EventListener* listener =
2836 proxy->FindXHREventListener(args[1], false); 2811 proxy->FindXHREventListener(args[1], false);
2837 2812
2838 if (listener) { 2813 if (listener) {
(...skipping 15 matching lines...) Expand all
2854 // open(method, url, async) 2829 // open(method, url, async)
2855 // open(method, url, async, user) 2830 // open(method, url, async, user)
2856 // open(method, url, async, user, passwd) 2831 // open(method, url, async, user, passwd)
2857 2832
2858 if (args.Length() < 2) { 2833 if (args.Length() < 2) {
2859 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments"); 2834 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments");
2860 return v8::Undefined(); 2835 return v8::Undefined();
2861 } 2836 }
2862 2837
2863 // get the implementation 2838 // get the implementation
2864 XMLHttpRequest* xhr = V8Proxy::FastToNativeObject<XMLHttpRequest>( 2839 XMLHttpRequest* xhr = V8Proxy::ToNativeObject<XMLHttpRequest>(
2865 V8ClassIndex::XMLHTTPREQUEST, args.Holder()); 2840 V8ClassIndex::XMLHTTPREQUEST, args.Holder());
2866 2841
2867 // retrieve parameters 2842 // retrieve parameters
2868 String method = ToWebCoreString(args[0]); 2843 String method = ToWebCoreString(args[0]);
2869 String urlstring = ToWebCoreString(args[1]); 2844 String urlstring = ToWebCoreString(args[1]);
2870 V8Proxy* proxy = V8Proxy::retrieve(); 2845 V8Proxy* proxy = V8Proxy::retrieve();
2871 KURL url = 2846 KURL url =
2872 proxy->frame()->document()->completeURL(urlstring).deprecatedString(); 2847 proxy->frame()->document()->completeURL(urlstring).deprecatedString();
2873 2848
2874 bool async = (args.Length() < 3) ? true : args[2]->BooleanValue(); 2849 bool async = (args.Length() < 3) ? true : args[2]->BooleanValue();
(...skipping 28 matching lines...) Expand all
2903 } 2878 }
2904 2879
2905 2880
2906 CALLBACK_FUNC_DECL(XMLHttpRequestSend) { 2881 CALLBACK_FUNC_DECL(XMLHttpRequestSend) {
2907 INC_STATS(L"DOM.XMLHttpRequest.send()"); 2882 INC_STATS(L"DOM.XMLHttpRequest.send()");
2908 // Two cases: 2883 // Two cases:
2909 // send(document) 2884 // send(document)
2910 // send(string) 2885 // send(string)
2911 2886
2912 // get implementation 2887 // get implementation
2913 XMLHttpRequest* xhr = V8Proxy::FastToNativeObject<XMLHttpRequest>( 2888 XMLHttpRequest* xhr = V8Proxy::ToNativeObject<XMLHttpRequest>(
2914 V8ClassIndex::XMLHTTPREQUEST, args.Holder()); 2889 V8ClassIndex::XMLHTTPREQUEST, args.Holder());
2915 2890
2916 String body; 2891 String body;
2917 if (args.Length() >= 1) { 2892 if (args.Length() >= 1) {
2918 v8::Handle<v8::Value> arg = args[0]; 2893 v8::Handle<v8::Value> arg = args[0];
2919 if (IsDocumentType(arg)) { 2894 if (IsDocumentType(arg)) {
2920 v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(arg); 2895 v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(arg);
2921 Document* doc = 2896 Document* doc = V8Proxy::DOMWrapperToNode<Document>(obj);
2922 V8Proxy::ToNativeObject<Document>(V8ClassIndex::DOCUMENT, obj);
2923 ASSERT(doc); 2897 ASSERT(doc);
2924 body = doc->toString(); 2898 body = doc->toString();
2925 } else { 2899 } else {
2926 body = valueToStringWithNullCheck(arg); 2900 body = valueToStringWithNullCheck(arg);
2927 } 2901 }
2928 } 2902 }
2929 2903
2930 ExceptionCode ec = 0; 2904 ExceptionCode ec = 0;
2931 xhr->send(body, ec); 2905 xhr->send(body, ec);
2932 if (ec != 0) { 2906 if (ec != 0) {
2933 V8Proxy::SetDOMException(ec); 2907 V8Proxy::SetDOMException(ec);
2934 return v8::Handle<v8::Value>(); 2908 return v8::Handle<v8::Value>();
2935 } 2909 }
2936 2910
2937 return v8::Undefined(); 2911 return v8::Undefined();
2938 } 2912 }
2939 2913
2940 2914
2941 CALLBACK_FUNC_DECL(XMLHttpRequestSetRequestHeader) { 2915 CALLBACK_FUNC_DECL(XMLHttpRequestSetRequestHeader) {
2942 INC_STATS(L"DOM.XMLHttpRequest.setRequestHeader()"); 2916 INC_STATS(L"DOM.XMLHttpRequest.setRequestHeader()");
2943 if (args.Length() < 2) { 2917 if (args.Length() < 2) {
2944 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments"); 2918 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments");
2945 return v8::Undefined(); 2919 return v8::Undefined();
2946 } 2920 }
2947 2921
2948 XMLHttpRequest* imp = V8Proxy::FastToNativeObject<XMLHttpRequest>( 2922 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
2949 V8ClassIndex::XMLHTTPREQUEST, args.Holder()); 2923 V8ClassIndex::XMLHTTPREQUEST, args.Holder());
2950 ExceptionCode ec = 0; 2924 ExceptionCode ec = 0;
2951 String header = ToWebCoreString(args[0]); 2925 String header = ToWebCoreString(args[0]);
2952 String value = ToWebCoreString(args[1]); 2926 String value = ToWebCoreString(args[1]);
2953 imp->setRequestHeader(header, value, ec); 2927 imp->setRequestHeader(header, value, ec);
2954 if (ec != 0) { 2928 if (ec != 0) {
2955 V8Proxy::SetDOMException(ec); 2929 V8Proxy::SetDOMException(ec);
2956 return v8::Handle<v8::Value>(); 2930 return v8::Handle<v8::Value>();
2957 } 2931 }
2958 return v8::Undefined(); 2932 return v8::Undefined();
2959 } 2933 }
2960 2934
2961 2935
2962 CALLBACK_FUNC_DECL(XMLHttpRequestGetResponseHeader) { 2936 CALLBACK_FUNC_DECL(XMLHttpRequestGetResponseHeader) {
2963 INC_STATS(L"DOM.XMLHttpRequest.getResponseHeader()"); 2937 INC_STATS(L"DOM.XMLHttpRequest.getResponseHeader()");
2964 if (args.Length() < 1) { 2938 if (args.Length() < 1) {
2965 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments"); 2939 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments");
2966 return v8::Undefined(); 2940 return v8::Undefined();
2967 } 2941 }
2968 2942
2969 XMLHttpRequest* imp = V8Proxy::FastToNativeObject<XMLHttpRequest>( 2943 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
2970 V8ClassIndex::XMLHTTPREQUEST, args.Holder()); 2944 V8ClassIndex::XMLHTTPREQUEST, args.Holder());
2971 ExceptionCode ec = 0; 2945 ExceptionCode ec = 0;
2972 String header = ToWebCoreString(args[0]); 2946 String header = ToWebCoreString(args[0]);
2973 String result = imp->getResponseHeader(header, ec); 2947 String result = imp->getResponseHeader(header, ec);
2974 if (ec != 0) { 2948 if (ec != 0) {
2975 V8Proxy::SetDOMException(ec); 2949 V8Proxy::SetDOMException(ec);
2976 return v8::Handle<v8::Value>(); 2950 return v8::Handle<v8::Value>();
2977 } 2951 }
2978 return v8StringOrNull(result); 2952 return v8StringOrNull(result);
2979 } 2953 }
2980 2954
2981 2955
2982 CALLBACK_FUNC_DECL(XMLHttpRequestOverrideMimeType) { 2956 CALLBACK_FUNC_DECL(XMLHttpRequestOverrideMimeType) {
2983 INC_STATS(L"DOM.XMLHttpRequest.overrideMimeType()"); 2957 INC_STATS(L"DOM.XMLHttpRequest.overrideMimeType()");
2984 if (args.Length() < 1) { 2958 if (args.Length() < 1) {
2985 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments"); 2959 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments");
2986 return v8::Undefined(); 2960 return v8::Undefined();
2987 } 2961 }
2988 2962
2989 XMLHttpRequest* imp = V8Proxy::FastToNativeObject<XMLHttpRequest>( 2963 XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
2990 V8ClassIndex::XMLHTTPREQUEST, args.Holder()); 2964 V8ClassIndex::XMLHTTPREQUEST, args.Holder());
2991 String value = ToWebCoreString(args[0]); 2965 String value = ToWebCoreString(args[0]);
2992 imp->overrideMIMEType(value); 2966 imp->overrideMIMEType(value);
2993 return v8::Undefined(); 2967 return v8::Undefined();
2994 } 2968 }
2995 2969
2996 CALLBACK_FUNC_DECL(TreeWalkerParentNode) { 2970 CALLBACK_FUNC_DECL(TreeWalkerParentNode) {
2997 INC_STATS(L"DOM.TreeWalker.parentNode()"); 2971 INC_STATS(L"DOM.TreeWalker.parentNode()");
2998 TreeWalker* imp = V8Proxy::FastToNativeObject<TreeWalker>( 2972 TreeWalker* imp = V8Proxy::ToNativeObject<TreeWalker>(
2999 V8ClassIndex::TREEWALKER, args.Holder()); 2973 V8ClassIndex::TREEWALKER, args.Holder());
3000 return V8Proxy::ToV8Object(V8ClassIndex::NODE, imp->parentNode()); 2974 return V8Proxy::NodeToV8Object(imp->parentNode());
3001 } 2975 }
3002 2976
3003 CALLBACK_FUNC_DECL(TreeWalkerFirstChild) { 2977 CALLBACK_FUNC_DECL(TreeWalkerFirstChild) {
3004 INC_STATS(L"DOM.TreeWalker.firstChild()"); 2978 INC_STATS(L"DOM.TreeWalker.firstChild()");
3005 TreeWalker* imp = V8Proxy::FastToNativeObject<TreeWalker>( 2979 TreeWalker* imp = V8Proxy::ToNativeObject<TreeWalker>(
3006 V8ClassIndex::TREEWALKER, args.Holder()); 2980 V8ClassIndex::TREEWALKER, args.Holder());
3007 return V8Proxy::ToV8Object(V8ClassIndex::NODE, imp->firstChild()); 2981 return V8Proxy::NodeToV8Object(imp->firstChild());
3008 } 2982 }
3009 2983
3010 CALLBACK_FUNC_DECL(TreeWalkerLastChild) { 2984 CALLBACK_FUNC_DECL(TreeWalkerLastChild) {
3011 INC_STATS(L"DOM.TreeWalker.lastChild()"); 2985 INC_STATS(L"DOM.TreeWalker.lastChild()");
3012 TreeWalker* imp = V8Proxy::FastToNativeObject<TreeWalker>( 2986 TreeWalker* imp = V8Proxy::ToNativeObject<TreeWalker>(
3013 V8ClassIndex::TREEWALKER, args.Holder()); 2987 V8ClassIndex::TREEWALKER, args.Holder());
3014 return V8Proxy::ToV8Object(V8ClassIndex::NODE, imp->lastChild()); 2988 return V8Proxy::NodeToV8Object(imp->lastChild());
3015 } 2989 }
3016 2990
3017 CALLBACK_FUNC_DECL(TreeWalkerNextNode) { 2991 CALLBACK_FUNC_DECL(TreeWalkerNextNode) {
3018 INC_STATS(L"DOM.TreeWalker.nextNode()"); 2992 INC_STATS(L"DOM.TreeWalker.nextNode()");
3019 TreeWalker* imp = V8Proxy::FastToNativeObject<TreeWalker>( 2993 TreeWalker* imp = V8Proxy::ToNativeObject<TreeWalker>(
3020 V8ClassIndex::TREEWALKER, args.Holder()); 2994 V8ClassIndex::TREEWALKER, args.Holder());
3021 return V8Proxy::ToV8Object(V8ClassIndex::NODE, imp->nextNode()); 2995 return V8Proxy::NodeToV8Object(imp->nextNode());
3022 } 2996 }
3023 2997
3024 CALLBACK_FUNC_DECL(TreeWalkerPreviousNode) { 2998 CALLBACK_FUNC_DECL(TreeWalkerPreviousNode) {
3025 INC_STATS(L"DOM.TreeWalker.previousNode()"); 2999 INC_STATS(L"DOM.TreeWalker.previousNode()");
3026 TreeWalker* imp = V8Proxy::FastToNativeObject<TreeWalker>( 3000 TreeWalker* imp = V8Proxy::ToNativeObject<TreeWalker>(
3027 V8ClassIndex::TREEWALKER, args.Holder()); 3001 V8ClassIndex::TREEWALKER, args.Holder());
3028 return V8Proxy::ToV8Object(V8ClassIndex::NODE, imp->previousNode()); 3002 return V8Proxy::NodeToV8Object(imp->previousNode());
3029 } 3003 }
3030 3004
3031 CALLBACK_FUNC_DECL(TreeWalkerNextSibling) { 3005 CALLBACK_FUNC_DECL(TreeWalkerNextSibling) {
3032 INC_STATS(L"DOM.TreeWalker.nextSibling()"); 3006 INC_STATS(L"DOM.TreeWalker.nextSibling()");
3033 TreeWalker* imp = V8Proxy::FastToNativeObject<TreeWalker>( 3007 TreeWalker* imp = V8Proxy::ToNativeObject<TreeWalker>(
3034 V8ClassIndex::TREEWALKER, args.Holder()); 3008 V8ClassIndex::TREEWALKER, args.Holder());
3035 return V8Proxy::ToV8Object(V8ClassIndex::NODE, imp->nextSibling()); 3009 return V8Proxy::NodeToV8Object(imp->nextSibling());
3036 } 3010 }
3037 3011
3038 CALLBACK_FUNC_DECL(TreeWalkerPreviousSibling) { 3012 CALLBACK_FUNC_DECL(TreeWalkerPreviousSibling) {
3039 INC_STATS(L"DOM.TreeWalker.previousSibling()"); 3013 INC_STATS(L"DOM.TreeWalker.previousSibling()");
3040 TreeWalker* imp = V8Proxy::FastToNativeObject<TreeWalker>( 3014 TreeWalker* imp = V8Proxy::ToNativeObject<TreeWalker>(
3041 V8ClassIndex::TREEWALKER, args.Holder()); 3015 V8ClassIndex::TREEWALKER, args.Holder());
3042 return V8Proxy::ToV8Object(V8ClassIndex::NODE, imp->previousSibling()); 3016 return V8Proxy::NodeToV8Object(imp->previousSibling());
3043 } 3017 }
3044 3018
3045 CALLBACK_FUNC_DECL(NodeIteratorNextNode) { 3019 CALLBACK_FUNC_DECL(NodeIteratorNextNode) {
3046 INC_STATS(L"DOM.NodeIterator.nextNode()"); 3020 INC_STATS(L"DOM.NodeIterator.nextNode()");
3047 NodeIterator* imp = V8Proxy::FastToNativeObject<NodeIterator>( 3021 NodeIterator* imp = V8Proxy::ToNativeObject<NodeIterator>(
3048 V8ClassIndex::NODEITERATOR, args.Holder()); 3022 V8ClassIndex::NODEITERATOR, args.Holder());
3049 ExceptionCode ec = 0; 3023 ExceptionCode ec = 0;
3050 return V8Proxy::ToV8Object(V8ClassIndex::NODE, imp->nextNode(ec)); 3024 return V8Proxy::NodeToV8Object(imp->nextNode(ec));
3051 } 3025 }
3052 3026
3053 CALLBACK_FUNC_DECL(NodeIteratorPreviousNode) { 3027 CALLBACK_FUNC_DECL(NodeIteratorPreviousNode) {
3054 INC_STATS(L"DOM.NodeIterator.previousNode()"); 3028 INC_STATS(L"DOM.NodeIterator.previousNode()");
3055 NodeIterator* imp = V8Proxy::FastToNativeObject<NodeIterator>( 3029 NodeIterator* imp = V8Proxy::ToNativeObject<NodeIterator>(
3056 V8ClassIndex::NODEITERATOR, args.Holder()); 3030 V8ClassIndex::NODEITERATOR, args.Holder());
3057 ExceptionCode ec = 0; 3031 ExceptionCode ec = 0;
3058 return V8Proxy::ToV8Object(V8ClassIndex::NODE, imp->previousNode(ec)); 3032 return V8Proxy::NodeToV8Object(imp->previousNode(ec));
3059 } 3033 }
3060 3034
3061 CALLBACK_FUNC_DECL(NodeFilterAcceptNode) { 3035 CALLBACK_FUNC_DECL(NodeFilterAcceptNode) {
3062 INC_STATS(L"DOM.NodeFilter.acceptNode()"); 3036 INC_STATS(L"DOM.NodeFilter.acceptNode()");
3063 NodeFilter* imp = V8Proxy::FastToNativeObject<NodeFilter>( 3037 NodeFilter* imp = V8Proxy::ToNativeObject<NodeFilter>(
3064 V8ClassIndex::NODEFILTER, args.Holder()); 3038 V8ClassIndex::NODEFILTER, args.Holder());
3065 Node* node = V8Proxy::FastToNativeObject<Node>(V8ClassIndex::NODE, args[0]); 3039 Node* node = V8Proxy::DOMWrapperToNode<Node>(args[0]);
3066 return v8::Local<v8::Integer>(v8::Integer::New(imp->acceptNode(node))); 3040 return v8::Local<v8::Integer>(v8::Integer::New(imp->acceptNode(node)));
3067 } 3041 }
3068 3042
3069 ACCESSOR_SETTER(DOMWindowEventHandler) { 3043 ACCESSOR_SETTER(DOMWindowEventHandler) {
3070 v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper( 3044 v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper(
3071 V8ClassIndex::DOMWINDOW, info.This()); 3045 V8ClassIndex::DOMWINDOW, info.This());
3072 if (holder.IsEmpty()) 3046 if (holder.IsEmpty())
3073 return; 3047 return;
3074 3048
3075 DOMWindow* imp = V8Proxy::FastToNativeObject<DOMWindow>( 3049 DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>(
3076 V8ClassIndex::DOMWINDOW, holder); 3050 V8ClassIndex::DOMWINDOW, holder);
3077 if (!imp->frame()) 3051 if (!imp->frame())
3078 return; 3052 return;
3079 3053
3080 Document* doc = imp->frame()->document(); 3054 Document* doc = imp->frame()->document();
3081 if (!doc) 3055 if (!doc)
3082 return; 3056 return;
3083 3057
3084 // Name starts with 'on', remove them. 3058 // Name starts with 'on', remove them.
3085 String key = ToWebCoreString(name); 3059 String key = ToWebCoreString(name);
(...skipping 16 matching lines...) Expand all
3102 } 3076 }
3103 } 3077 }
3104 3078
3105 3079
3106 ACCESSOR_GETTER(DOMWindowEventHandler) { 3080 ACCESSOR_GETTER(DOMWindowEventHandler) {
3107 v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper( 3081 v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper(
3108 V8ClassIndex::DOMWINDOW, info.This()); 3082 V8ClassIndex::DOMWINDOW, info.This());
3109 if (holder.IsEmpty()) 3083 if (holder.IsEmpty())
3110 return v8::Undefined(); 3084 return v8::Undefined();
3111 3085
3112 DOMWindow* imp = V8Proxy::FastToNativeObject<DOMWindow>( 3086 DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>(
3113 V8ClassIndex::DOMWINDOW, holder); 3087 V8ClassIndex::DOMWINDOW, holder);
3114 if (!imp->frame()) 3088 if (!imp->frame())
3115 return v8::Undefined(); 3089 return v8::Undefined();
3116 3090
3117 Document* doc = imp->frame()->document(); 3091 Document* doc = imp->frame()->document();
3118 if (!doc) 3092 if (!doc)
3119 return v8::Undefined(); 3093 return v8::Undefined();
3120 3094
3121 // Name starts with 'on', remove them. 3095 // Name starts with 'on', remove them.
3122 String key = ToWebCoreString(name); 3096 String key = ToWebCoreString(name);
3123 ASSERT(key.startsWith("on")); 3097 ASSERT(key.startsWith("on"));
3124 String event_type = key.substring(2); 3098 String event_type = key.substring(2);
3125 3099
3126 EventListener* listener = doc->getHTMLWindowEventListener(event_type); 3100 EventListener* listener = doc->getHTMLWindowEventListener(event_type);
3127 return V8Proxy::EventListenerToV8Object(listener); 3101 return V8Proxy::EventListenerToV8Object(listener);
3128 } 3102 }
3129 3103
3130 3104
3131 ACCESSOR_SETTER(ElementEventHandler) { 3105 ACCESSOR_SETTER(ElementEventHandler) {
3132 EventTargetNode* node = V8Proxy::FastToNativeObject<EventTargetNode>( 3106 EventTargetNode* node =
3133 V8ClassIndex::EVENTTARGETNODE, info.Holder()); 3107 V8Proxy::DOMWrapperToNode<EventTargetNode>(info.Holder());
3134 3108
3135 // Name starts with 'on', remove them. 3109 // Name starts with 'on', remove them.
3136 String key = ToWebCoreString(name); 3110 String key = ToWebCoreString(name);
3137 ASSERT(key.startsWith("on")); 3111 ASSERT(key.startsWith("on"));
3138 String event_type = key.substring(2); 3112 String event_type = key.substring(2);
3139 3113
3140 // Set handler if the value is a function. Otherwise, clear the 3114 // Set handler if the value is a function. Otherwise, clear the
3141 // event handler. 3115 // event handler.
3142 if (value->IsFunction()) { 3116 if (value->IsFunction()) {
3143 V8Proxy* proxy = V8Proxy::retrieve(node->document()->frame()); 3117 V8Proxy* proxy = V8Proxy::retrieve(node->document()->frame());
3144 // the document might be created using createDocument, 3118 // the document might be created using createDocument,
3145 // which does not have a frame, use the active frame 3119 // which does not have a frame, use the active frame
3146 if (!proxy) 3120 if (!proxy)
3147 proxy = V8Proxy::retrieve(V8Proxy::retrieveActiveFrame()); 3121 proxy = V8Proxy::retrieve(V8Proxy::retrieveActiveFrame());
3148 if (!proxy) 3122 if (!proxy)
3149 return; 3123 return;
3150 3124
3151 EventListener* listener = 3125 EventListener* listener =
3152 proxy->FindOrCreateV8EventListener(value, true); 3126 proxy->FindOrCreateV8EventListener(value, true);
3153 if (listener) { 3127 if (listener) {
3154 node->setHTMLEventListener(event_type, listener); 3128 node->setHTMLEventListener(event_type, listener);
3155 } 3129 }
3156 } else { 3130 } else {
3157 node->removeHTMLEventListener(event_type); 3131 node->removeHTMLEventListener(event_type);
3158 } 3132 }
3159 } 3133 }
3160 3134
3161 3135
3162 ACCESSOR_GETTER(ElementEventHandler) { 3136 ACCESSOR_GETTER(ElementEventHandler) {
3163 EventTargetNode* node = V8Proxy::FastToNativeObject<EventTargetNode>( 3137 EventTargetNode* node =
3164 V8ClassIndex::EVENTTARGETNODE, info.Holder()); 3138 V8Proxy::DOMWrapperToNode<EventTargetNode>(info.Holder());
3165 3139
3166 // Name starts with 'on', remove them. 3140 // Name starts with 'on', remove them.
3167 String key = ToWebCoreString(name); 3141 String key = ToWebCoreString(name);
3168 ASSERT(key.startsWith("on")); 3142 ASSERT(key.startsWith("on"));
3169 String event_type = key.substring(2); 3143 String event_type = key.substring(2);
3170 3144
3171 EventListener* listener = node->getHTMLEventListener(event_type); 3145 EventListener* listener = node->getHTMLEventListener(event_type);
3172 return V8Proxy::EventListenerToV8Object(listener); 3146 return V8Proxy::EventListenerToV8Object(listener);
3173 } 3147 }
3174 3148
3175 3149
3176 ACCESSOR_SETTER(HTMLOptionsCollectionLength) { 3150 ACCESSOR_SETTER(HTMLOptionsCollectionLength) {
3177 HTMLOptionsCollection* imp = 3151 HTMLOptionsCollection* imp =
3178 V8Proxy::FastToNativeObject<HTMLOptionsCollection>( 3152 V8Proxy::ToNativeObject<HTMLOptionsCollection>(
3179 V8ClassIndex::HTMLOPTIONSCOLLECTION, info.Holder()); 3153 V8ClassIndex::HTMLOPTIONSCOLLECTION, info.Holder());
3180 double v = value->NumberValue(); 3154 double v = value->NumberValue();
3181 unsigned newLength = 0; 3155 unsigned newLength = 0;
3182 ExceptionCode ec = 0; 3156 ExceptionCode ec = 0;
3183 if (!isnan(v) && !isinf(v)) { 3157 if (!isnan(v) && !isinf(v)) {
3184 if (v < 0.0) { 3158 if (v < 0.0) {
3185 ec = INDEX_SIZE_ERR; 3159 ec = INDEX_SIZE_ERR;
3186 } else if (v > static_cast<double>(UINT_MAX)) { 3160 } else if (v > static_cast<double>(UINT_MAX)) {
3187 newLength = UINT_MAX; 3161 newLength = UINT_MAX;
3188 } else { 3162 } else {
3189 newLength = static_cast<unsigned>(v); 3163 newLength = static_cast<unsigned>(v);
3190 } 3164 }
3191 } 3165 }
3192 if (!ec) imp->setLength(value->Uint32Value(), ec); 3166 if (!ec) imp->setLength(value->Uint32Value(), ec);
3193 V8Proxy::SetDOMException(ec); 3167 V8Proxy::SetDOMException(ec);
3194 } 3168 }
3195 3169
3196 #if ENABLE(SVG) 3170 #if ENABLE(SVG)
3197 CALLBACK_FUNC_DECL(SVGMatrixInverse) { 3171 CALLBACK_FUNC_DECL(SVGMatrixInverse) {
3198 INC_STATS(L"DOM.SVGMatrix.inverse()"); 3172 INC_STATS(L"DOM.SVGMatrix.inverse()");
3199 AffineTransform imp = 3173 AffineTransform imp =
3200 *V8Proxy::FastToNativeObject<V8SVGPODTypeWrapper<AffineTransform> >( 3174 *V8Proxy::ToNativeObject<V8SVGPODTypeWrapper<AffineTransform> >(
3201 V8ClassIndex::SVGMATRIX, args.Holder()); 3175 V8ClassIndex::SVGMATRIX, args.Holder());
3202 ExceptionCode ec = 0; 3176 ExceptionCode ec = 0;
3203 AffineTransform result = imp.inverse(); 3177 AffineTransform result = imp.inverse();
3204 if (!imp.isInvertible()) { 3178 if (!imp.isInvertible()) {
3205 ec = SVGException::SVG_MATRIX_NOT_INVERTABLE; 3179 ec = SVGException::SVG_MATRIX_NOT_INVERTABLE;
3206 } 3180 }
3207 if (ec != 0) { 3181 if (ec != 0) {
3208 V8Proxy::SetDOMException(ec); 3182 V8Proxy::SetDOMException(ec);
3209 return v8::Handle<v8::Value>(); 3183 return v8::Handle<v8::Value>();
3210 } 3184 }
3211 3185
3212 Peerable* peer = static_cast<Peerable*>( 3186 Peerable* peer = static_cast<Peerable*>(
3213 new V8SVGPODTypeWrapperCreatorReadOnly<AffineTransform>(result)); 3187 new V8SVGPODTypeWrapperCreatorReadOnly<AffineTransform>(result));
3214 return V8Proxy::ToV8Object(V8ClassIndex::SVGMATRIX, peer); 3188 return V8Proxy::ToV8Object(V8ClassIndex::SVGMATRIX, peer);
3215 } 3189 }
3216 3190
3217 CALLBACK_FUNC_DECL(SVGMatrixRotateFromVector) { 3191 CALLBACK_FUNC_DECL(SVGMatrixRotateFromVector) {
3218 INC_STATS(L"DOM.SVGMatrix.rotateFromVector()"); 3192 INC_STATS(L"DOM.SVGMatrix.rotateFromVector()");
3219 AffineTransform imp = 3193 AffineTransform imp =
3220 *V8Proxy::FastToNativeObject<V8SVGPODTypeWrapper<AffineTransform> >( 3194 *V8Proxy::ToNativeObject<V8SVGPODTypeWrapper<AffineTransform> >(
3221 V8ClassIndex::SVGMATRIX, args.Holder()); 3195 V8ClassIndex::SVGMATRIX, args.Holder());
3222 ExceptionCode ec = 0; 3196 ExceptionCode ec = 0;
3223 float x = static_cast<float>(args[0]->NumberValue()); 3197 float x = static_cast<float>(args[0]->NumberValue());
3224 float y = static_cast<float>(args[1]->NumberValue()); 3198 float y = static_cast<float>(args[1]->NumberValue());
3225 AffineTransform result = imp; 3199 AffineTransform result = imp;
3226 result.rotateFromVector(x, y); 3200 result.rotateFromVector(x, y);
3227 if (x == 0.0 || y == 0.0) { 3201 if (x == 0.0 || y == 0.0) {
3228 ec = SVGException::SVG_INVALID_VALUE_ERR; 3202 ec = SVGException::SVG_INVALID_VALUE_ERR;
3229 } 3203 }
3230 if (ec != 0) { 3204 if (ec != 0) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
3285 } 3259 }
3286 3260
3287 return V8Proxy::CanAccess(target); 3261 return V8Proxy::CanAccess(target);
3288 } 3262 }
3289 3263
3290 3264
3291 INDEXED_ACCESS_CHECK(History) { 3265 INDEXED_ACCESS_CHECK(History) {
3292 ASSERT(V8ClassIndex::ToWrapperType(data) == V8ClassIndex::HISTORY); 3266 ASSERT(V8ClassIndex::ToWrapperType(data) == V8ClassIndex::HISTORY);
3293 // Only allow same origin access 3267 // Only allow same origin access
3294 History* imp = 3268 History* imp =
3295 V8Proxy::FastToNativeObject<History>(V8ClassIndex::HISTORY, host); 3269 V8Proxy::ToNativeObject<History>(V8ClassIndex::HISTORY, host);
3296 return V8Proxy::IsFromSameOrigin(imp->frame(), false); 3270 return V8Proxy::IsFromSameOrigin(imp->frame(), false);
3297 } 3271 }
3298 3272
3299 3273
3300 NAMED_ACCESS_CHECK(History) { 3274 NAMED_ACCESS_CHECK(History) {
3301 ASSERT(V8ClassIndex::ToWrapperType(data) == V8ClassIndex::HISTORY); 3275 ASSERT(V8ClassIndex::ToWrapperType(data) == V8ClassIndex::HISTORY);
3302 // Only allow same origin access 3276 // Only allow same origin access
3303 History* imp = 3277 History* imp =
3304 V8Proxy::FastToNativeObject<History>(V8ClassIndex::HISTORY, host); 3278 V8Proxy::ToNativeObject<History>(V8ClassIndex::HISTORY, host);
3305 return V8Proxy::IsFromSameOrigin(imp->frame(), false); 3279 return V8Proxy::IsFromSameOrigin(imp->frame(), false);
3306 } 3280 }
3307 3281
3308 3282
3309 INDEXED_ACCESS_CHECK(Location) { 3283 INDEXED_ACCESS_CHECK(Location) {
3310 ASSERT(V8ClassIndex::ToWrapperType(data) == V8ClassIndex::LOCATION); 3284 ASSERT(V8ClassIndex::ToWrapperType(data) == V8ClassIndex::LOCATION);
3311 // Only allow same origin access 3285 // Only allow same origin access
3312 Location* imp = 3286 Location* imp =
3313 V8Proxy::FastToNativeObject<Location>(V8ClassIndex::LOCATION, host); 3287 V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, host);
3314 return V8Proxy::IsFromSameOrigin(imp->frame(), false); 3288 return V8Proxy::IsFromSameOrigin(imp->frame(), false);
3315 } 3289 }
3316 3290
3317 3291
3318 NAMED_ACCESS_CHECK(Location) { 3292 NAMED_ACCESS_CHECK(Location) {
3319 ASSERT(V8ClassIndex::ToWrapperType(data) == V8ClassIndex::LOCATION); 3293 ASSERT(V8ClassIndex::ToWrapperType(data) == V8ClassIndex::LOCATION);
3320 // Only allow same origin access 3294 // Only allow same origin access
3321 Location* imp = 3295 Location* imp =
3322 V8Proxy::FastToNativeObject<Location>(V8ClassIndex::LOCATION, host); 3296 V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, host);
3323 return V8Proxy::IsFromSameOrigin(imp->frame(), false); 3297 return V8Proxy::IsFromSameOrigin(imp->frame(), false);
3324 } 3298 }
3325 3299
3326 3300
3327 #undef INDEXED_ACCESS_CHECK 3301 #undef INDEXED_ACCESS_CHECK
3328 #undef NAMED_ACCESS_CHECK 3302 #undef NAMED_ACCESS_CHECK
3329 #undef ACCESSOR_GETTER 3303 #undef ACCESSOR_GETTER
3330 #undef ACCESSOR_SETTER 3304 #undef ACCESSOR_SETTER
3331 #undef CALLBACK_FUNC_DECL 3305 #undef CALLBACK_FUNC_DECL
3332 #undef NAMED_PROPERTY_GETTER 3306 #undef NAMED_PROPERTY_GETTER
3333 #undef NAMED_PROPERTY_SETTER 3307 #undef NAMED_PROPERTY_SETTER
3334 #undef INDEXED_PROPERTY_GETTER 3308 #undef INDEXED_PROPERTY_GETTER
3335 #undef INDEXED_PROPERTY_SETTER 3309 #undef INDEXED_PROPERTY_SETTER
3336 3310
3337 3311
3338 // static 3312 // static
3339 Frame* V8Custom::GetTargetFrame(v8::Local<v8::Object> host, 3313 Frame* V8Custom::GetTargetFrame(v8::Local<v8::Object> host,
3340 v8::Local<v8::Value> data) { 3314 v8::Local<v8::Value> data) {
3341 Frame* target = 0; 3315 Frame* target = 0;
3342 switch (V8ClassIndex::ToWrapperType(data)) { 3316 switch (V8ClassIndex::ToWrapperType(data)) {
3343 case V8ClassIndex::DOMWINDOW: { 3317 case V8ClassIndex::DOMWINDOW: {
3344 v8::Handle<v8::Value> window = host->GetPrototype(); 3318 v8::Handle<v8::Value> window = host->GetPrototype();
3345 DOMWindow* target_win = 3319 DOMWindow* target_win =
3346 V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, window); 3320 V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, window);
3347 target = target_win->frame(); 3321 target = target_win->frame();
3348 break; 3322 break;
3349 } 3323 }
3350 case V8ClassIndex::LOCATION: { 3324 case V8ClassIndex::LOCATION: {
3351 History* imp = 3325 History* imp =
3352 V8Proxy::FastToNativeObject<History>(V8ClassIndex::HISTORY, host); 3326 V8Proxy::ToNativeObject<History>(V8ClassIndex::HISTORY, host);
3353 target = imp->frame(); 3327 target = imp->frame();
3354 break; 3328 break;
3355 } 3329 }
3356 case V8ClassIndex::HISTORY: { 3330 case V8ClassIndex::HISTORY: {
3357 Location* imp = 3331 Location* imp =
3358 V8Proxy::FastToNativeObject<Location>(V8ClassIndex::LOCATION, host); 3332 V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, host);
3359 target = imp->frame(); 3333 target = imp->frame();
3360 break; 3334 break;
3361 } 3335 }
3362 } 3336 }
3363 return target; 3337 return target;
3364 } 3338 }
3365 3339
3366 #if ENABLE(SVG) 3340 #if ENABLE(SVG)
3367 V8ClassIndex::V8WrapperType V8Custom::DowncastSVGPathSeg(void* path_seg) { 3341 V8ClassIndex::V8WrapperType V8Custom::DowncastSVGPathSeg(void* path_seg) {
3368 WebCore::SVGPathSeg *real_path_seg = 3342 WebCore::SVGPathSeg *real_path_seg =
(...skipping 29 matching lines...) Expand all
3398 #undef MAKE_CASE 3372 #undef MAKE_CASE
3399 3373
3400 default: 3374 default:
3401 return V8ClassIndex::INVALID_CLASS_INDEX; 3375 return V8ClassIndex::INVALID_CLASS_INDEX;
3402 } 3376 }
3403 } 3377 }
3404 3378
3405 #endif // ENABLE(SVG) 3379 #endif // ENABLE(SVG)
3406 3380
3407 } // namespace WebCore 3381 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698