| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 : m_shouldPrintWhenFinishedLoading(false) | 398 : m_shouldPrintWhenFinishedLoading(false) |
| 399 , m_frame(frame) | 399 , m_frame(frame) |
| 400 { | 400 { |
| 401 } | 401 } |
| 402 | 402 |
| 403 DOMWindow::~DOMWindow() | 403 DOMWindow::~DOMWindow() |
| 404 { | 404 { |
| 405 if (m_frame) | 405 if (m_frame) |
| 406 m_frame->clearFormerDOMWindow(this); | 406 m_frame->clearFormerDOMWindow(this); |
| 407 | 407 |
| 408 ASSERT(!m_screen); |
| 409 ASSERT(!m_selection); |
| 410 ASSERT(!m_history); |
| 411 ASSERT(!m_crypto); |
| 412 ASSERT(!m_locationbar); |
| 413 ASSERT(!m_menubar); |
| 414 ASSERT(!m_personalbar); |
| 415 ASSERT(!m_scrollbars); |
| 416 ASSERT(!m_statusbar); |
| 417 ASSERT(!m_toolbar); |
| 418 ASSERT(!m_console); |
| 419 ASSERT(!m_navigator); |
| 420 #if ENABLE(WEB_TIMING) |
| 421 ASSERT(!m_performance); |
| 422 #endif |
| 423 ASSERT(!m_location); |
| 424 ASSERT(!m_media); |
| 425 #if ENABLE(DOM_STORAGE) |
| 426 ASSERT(!m_sessionStorage); |
| 427 ASSERT(!m_localStorage); |
| 428 #endif |
| 429 ASSERT(!m_applicationCache); |
| 430 #if ENABLE(NOTIFICATIONS) |
| 431 ASSERT(!m_notifications); |
| 432 #endif |
| 433 #if ENABLE(INDEXED_DATABASE) |
| 434 ASSERT(!m_idbFactory); |
| 435 #endif |
| 436 #if ENABLE(BLOB) |
| 437 ASSERT(!m_domURL); |
| 438 #endif |
| 439 #if ENABLE(QUOTA) |
| 440 ASSERT(!m_storageInfo); |
| 441 #endif |
| 442 |
| 443 // This clear should be unnessary given the ASSERTs above, but we don't |
| 444 // want any of these objects to hang around after we've been destroyed. |
| 445 clear(); |
| 446 |
| 408 removeAllUnloadEventListeners(this); | 447 removeAllUnloadEventListeners(this); |
| 409 removeAllBeforeUnloadEventListeners(this); | 448 removeAllBeforeUnloadEventListeners(this); |
| 410 } | 449 } |
| 411 | 450 |
| 412 ScriptExecutionContext* DOMWindow::scriptExecutionContext() const | 451 ScriptExecutionContext* DOMWindow::scriptExecutionContext() const |
| 413 { | 452 { |
| 414 return document(); | 453 return document(); |
| 415 } | 454 } |
| 416 | 455 |
| 417 PassRefPtr<MediaQueryList> DOMWindow::matchMedia(const String& media) | 456 PassRefPtr<MediaQueryList> DOMWindow::matchMedia(const String& media) |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 | 549 |
| 511 #if ENABLE(NOTIFICATIONS) | 550 #if ENABLE(NOTIFICATIONS) |
| 512 if (m_notifications) | 551 if (m_notifications) |
| 513 m_notifications->disconnectFrame(); | 552 m_notifications->disconnectFrame(); |
| 514 m_notifications = 0; | 553 m_notifications = 0; |
| 515 #endif | 554 #endif |
| 516 | 555 |
| 517 #if ENABLE(INDEXED_DATABASE) | 556 #if ENABLE(INDEXED_DATABASE) |
| 518 m_idbFactory = 0; | 557 m_idbFactory = 0; |
| 519 #endif | 558 #endif |
| 559 |
| 560 #if ENABLE(BLOB) |
| 561 m_domURL = 0; |
| 562 #endif |
| 563 |
| 564 #if ENABLE(QUOTA) |
| 565 m_storageInfo = 0; |
| 566 #endif |
| 567 } |
| 568 |
| 569 bool DOMWindow::isCurrentlyDisplayedInFrame() const |
| 570 { |
| 571 return m_frame && m_frame->domWindow() == this; |
| 520 } | 572 } |
| 521 | 573 |
| 522 #if ENABLE(ORIENTATION_EVENTS) | 574 #if ENABLE(ORIENTATION_EVENTS) |
| 523 int DOMWindow::orientation() const | 575 int DOMWindow::orientation() const |
| 524 { | 576 { |
| 525 if (!m_frame) | 577 if (!m_frame) |
| 526 return 0; | 578 return 0; |
| 527 | 579 |
| 528 return m_frame->orientation(); | 580 return m_frame->orientation(); |
| 529 } | 581 } |
| 530 #endif | 582 #endif |
| 531 | 583 |
| 532 Screen* DOMWindow::screen() const | 584 Screen* DOMWindow::screen() const |
| 533 { | 585 { |
| 534 if (!m_screen) | 586 if (!m_screen && isCurrentlyDisplayedInFrame()) |
| 535 m_screen = Screen::create(m_frame); | 587 m_screen = Screen::create(m_frame); |
| 536 return m_screen.get(); | 588 return m_screen.get(); |
| 537 } | 589 } |
| 538 | 590 |
| 539 History* DOMWindow::history() const | 591 History* DOMWindow::history() const |
| 540 { | 592 { |
| 541 if (!m_history) | 593 if (!m_history && isCurrentlyDisplayedInFrame()) |
| 542 m_history = History::create(m_frame); | 594 m_history = History::create(m_frame); |
| 543 return m_history.get(); | 595 return m_history.get(); |
| 544 } | 596 } |
| 545 | 597 |
| 546 Crypto* DOMWindow::crypto() const | 598 Crypto* DOMWindow::crypto() const |
| 547 { | 599 { |
| 548 if (!m_crypto) | 600 if (!m_crypto && isCurrentlyDisplayedInFrame()) |
| 549 m_crypto = Crypto::create(); | 601 m_crypto = Crypto::create(); |
| 550 return m_crypto.get(); | 602 return m_crypto.get(); |
| 551 } | 603 } |
| 552 | 604 |
| 553 BarInfo* DOMWindow::locationbar() const | 605 BarInfo* DOMWindow::locationbar() const |
| 554 { | 606 { |
| 555 if (!m_locationbar) | 607 if (!m_locationbar && isCurrentlyDisplayedInFrame()) |
| 556 m_locationbar = BarInfo::create(m_frame, BarInfo::Locationbar); | 608 m_locationbar = BarInfo::create(m_frame, BarInfo::Locationbar); |
| 557 return m_locationbar.get(); | 609 return m_locationbar.get(); |
| 558 } | 610 } |
| 559 | 611 |
| 560 BarInfo* DOMWindow::menubar() const | 612 BarInfo* DOMWindow::menubar() const |
| 561 { | 613 { |
| 562 if (!m_menubar) | 614 if (!m_menubar && isCurrentlyDisplayedInFrame()) |
| 563 m_menubar = BarInfo::create(m_frame, BarInfo::Menubar); | 615 m_menubar = BarInfo::create(m_frame, BarInfo::Menubar); |
| 564 return m_menubar.get(); | 616 return m_menubar.get(); |
| 565 } | 617 } |
| 566 | 618 |
| 567 BarInfo* DOMWindow::personalbar() const | 619 BarInfo* DOMWindow::personalbar() const |
| 568 { | 620 { |
| 569 if (!m_personalbar) | 621 if (!m_personalbar && isCurrentlyDisplayedInFrame()) |
| 570 m_personalbar = BarInfo::create(m_frame, BarInfo::Personalbar); | 622 m_personalbar = BarInfo::create(m_frame, BarInfo::Personalbar); |
| 571 return m_personalbar.get(); | 623 return m_personalbar.get(); |
| 572 } | 624 } |
| 573 | 625 |
| 574 BarInfo* DOMWindow::scrollbars() const | 626 BarInfo* DOMWindow::scrollbars() const |
| 575 { | 627 { |
| 576 if (!m_scrollbars) | 628 if (!m_scrollbars && isCurrentlyDisplayedInFrame()) |
| 577 m_scrollbars = BarInfo::create(m_frame, BarInfo::Scrollbars); | 629 m_scrollbars = BarInfo::create(m_frame, BarInfo::Scrollbars); |
| 578 return m_scrollbars.get(); | 630 return m_scrollbars.get(); |
| 579 } | 631 } |
| 580 | 632 |
| 581 BarInfo* DOMWindow::statusbar() const | 633 BarInfo* DOMWindow::statusbar() const |
| 582 { | 634 { |
| 583 if (!m_statusbar) | 635 if (!m_statusbar && isCurrentlyDisplayedInFrame()) |
| 584 m_statusbar = BarInfo::create(m_frame, BarInfo::Statusbar); | 636 m_statusbar = BarInfo::create(m_frame, BarInfo::Statusbar); |
| 585 return m_statusbar.get(); | 637 return m_statusbar.get(); |
| 586 } | 638 } |
| 587 | 639 |
| 588 BarInfo* DOMWindow::toolbar() const | 640 BarInfo* DOMWindow::toolbar() const |
| 589 { | 641 { |
| 590 if (!m_toolbar) | 642 if (!m_toolbar && isCurrentlyDisplayedInFrame()) |
| 591 m_toolbar = BarInfo::create(m_frame, BarInfo::Toolbar); | 643 m_toolbar = BarInfo::create(m_frame, BarInfo::Toolbar); |
| 592 return m_toolbar.get(); | 644 return m_toolbar.get(); |
| 593 } | 645 } |
| 594 | 646 |
| 595 Console* DOMWindow::console() const | 647 Console* DOMWindow::console() const |
| 596 { | 648 { |
| 597 if (!m_console) | 649 if (!m_console && isCurrentlyDisplayedInFrame()) |
| 598 m_console = Console::create(m_frame); | 650 m_console = Console::create(m_frame); |
| 599 return m_console.get(); | 651 return m_console.get(); |
| 600 } | 652 } |
| 601 | 653 |
| 602 #if ENABLE(OFFLINE_WEB_APPLICATIONS) | 654 #if ENABLE(OFFLINE_WEB_APPLICATIONS) |
| 603 DOMApplicationCache* DOMWindow::applicationCache() const | 655 DOMApplicationCache* DOMWindow::applicationCache() const |
| 604 { | 656 { |
| 605 if (!m_applicationCache) | 657 if (!m_applicationCache && isCurrentlyDisplayedInFrame()) |
| 606 m_applicationCache = DOMApplicationCache::create(m_frame); | 658 m_applicationCache = DOMApplicationCache::create(m_frame); |
| 607 return m_applicationCache.get(); | 659 return m_applicationCache.get(); |
| 608 } | 660 } |
| 609 #endif | 661 #endif |
| 610 | 662 |
| 611 Navigator* DOMWindow::navigator() const | 663 Navigator* DOMWindow::navigator() const |
| 612 { | 664 { |
| 613 if (!m_navigator) | 665 if (!m_navigator && isCurrentlyDisplayedInFrame()) |
| 614 m_navigator = Navigator::create(m_frame); | 666 m_navigator = Navigator::create(m_frame); |
| 615 return m_navigator.get(); | 667 return m_navigator.get(); |
| 616 } | 668 } |
| 617 | 669 |
| 618 #if ENABLE(WEB_TIMING) | 670 #if ENABLE(WEB_TIMING) |
| 619 Performance* DOMWindow::performance() const | 671 Performance* DOMWindow::performance() const |
| 620 { | 672 { |
| 621 if (!m_performance) | 673 if (!m_performance && isCurrentlyDisplayedInFrame()) |
| 622 m_performance = Performance::create(m_frame); | 674 m_performance = Performance::create(m_frame); |
| 623 return m_performance.get(); | 675 return m_performance.get(); |
| 624 } | 676 } |
| 625 #endif | 677 #endif |
| 626 | 678 |
| 627 Location* DOMWindow::location() const | 679 Location* DOMWindow::location() const |
| 628 { | 680 { |
| 629 if (!m_location) | 681 if (!m_location && isCurrentlyDisplayedInFrame()) |
| 630 m_location = Location::create(m_frame); | 682 m_location = Location::create(m_frame); |
| 631 return m_location.get(); | 683 return m_location.get(); |
| 632 } | 684 } |
| 633 | 685 |
| 634 #if ENABLE(DOM_STORAGE) | 686 #if ENABLE(DOM_STORAGE) |
| 635 Storage* DOMWindow::sessionStorage(ExceptionCode& ec) const | 687 Storage* DOMWindow::sessionStorage(ExceptionCode& ec) const |
| 636 { | 688 { |
| 637 if (m_sessionStorage) | 689 if (m_sessionStorage || !isCurrentlyDisplayedInFrame()) |
| 638 return m_sessionStorage.get(); | 690 return m_sessionStorage.get(); |
| 639 | 691 |
| 640 Document* document = this->document(); | 692 Document* document = this->document(); |
| 641 if (!document) | 693 if (!document) |
| 642 return 0; | 694 return 0; |
| 643 | 695 |
| 644 if (!document->securityOrigin()->canAccessLocalStorage()) { | 696 if (!document->securityOrigin()->canAccessLocalStorage()) { |
| 645 ec = SECURITY_ERR; | 697 ec = SECURITY_ERR; |
| 646 return 0; | 698 return 0; |
| 647 } | 699 } |
| 648 | 700 |
| 649 Page* page = document->page(); | 701 Page* page = document->page(); |
| 650 if (!page) | 702 if (!page) |
| 651 return 0; | 703 return 0; |
| 652 | 704 |
| 653 RefPtr<StorageArea> storageArea = page->sessionStorage()->storageArea(docume
nt->securityOrigin()); | 705 RefPtr<StorageArea> storageArea = page->sessionStorage()->storageArea(docume
nt->securityOrigin()); |
| 654 InspectorInstrumentation::didUseDOMStorage(page, storageArea.get(), false, m
_frame); | 706 InspectorInstrumentation::didUseDOMStorage(page, storageArea.get(), false, m
_frame); |
| 655 | 707 |
| 656 m_sessionStorage = Storage::create(m_frame, storageArea.release()); | 708 m_sessionStorage = Storage::create(m_frame, storageArea.release()); |
| 657 return m_sessionStorage.get(); | 709 return m_sessionStorage.get(); |
| 658 } | 710 } |
| 659 | 711 |
| 660 Storage* DOMWindow::localStorage(ExceptionCode& ec) const | 712 Storage* DOMWindow::localStorage(ExceptionCode& ec) const |
| 661 { | 713 { |
| 662 if (m_localStorage) | 714 if (m_localStorage || !isCurrentlyDisplayedInFrame()) |
| 663 return m_localStorage.get(); | 715 return m_localStorage.get(); |
| 664 | 716 |
| 665 Document* document = this->document(); | 717 Document* document = this->document(); |
| 666 if (!document) | 718 if (!document) |
| 667 return 0; | 719 return 0; |
| 668 | 720 |
| 669 if (!document->securityOrigin()->canAccessLocalStorage()) { | 721 if (!document->securityOrigin()->canAccessLocalStorage()) { |
| 670 ec = SECURITY_ERR; | 722 ec = SECURITY_ERR; |
| 671 return 0; | 723 return 0; |
| 672 } | 724 } |
| 673 | 725 |
| 674 Page* page = document->page(); | 726 Page* page = document->page(); |
| 675 if (!page) | 727 if (!page) |
| 676 return 0; | 728 return 0; |
| 677 | 729 |
| 678 if (!page->settings()->localStorageEnabled()) | 730 if (!page->settings()->localStorageEnabled()) |
| 679 return 0; | 731 return 0; |
| 680 | 732 |
| 681 RefPtr<StorageArea> storageArea = page->group().localStorage()->storageArea(
document->securityOrigin()); | 733 RefPtr<StorageArea> storageArea = page->group().localStorage()->storageArea(
document->securityOrigin()); |
| 682 InspectorInstrumentation::didUseDOMStorage(page, storageArea.get(), true, m_
frame); | 734 InspectorInstrumentation::didUseDOMStorage(page, storageArea.get(), true, m_
frame); |
| 683 | 735 |
| 684 m_localStorage = Storage::create(m_frame, storageArea.release()); | 736 m_localStorage = Storage::create(m_frame, storageArea.release()); |
| 685 return m_localStorage.get(); | 737 return m_localStorage.get(); |
| 686 } | 738 } |
| 687 #endif | 739 #endif |
| 688 | 740 |
| 689 #if ENABLE(NOTIFICATIONS) | 741 #if ENABLE(NOTIFICATIONS) |
| 690 NotificationCenter* DOMWindow::webkitNotifications() const | 742 NotificationCenter* DOMWindow::webkitNotifications() const |
| 691 { | 743 { |
| 692 if (m_notifications) | 744 if (m_notifications || !isCurrentlyDisplayedInFrame()) |
| 693 return m_notifications.get(); | 745 return m_notifications.get(); |
| 694 | 746 |
| 695 Document* document = this->document(); | 747 Document* document = this->document(); |
| 696 if (!document) | 748 if (!document) |
| 697 return 0; | 749 return 0; |
| 698 | 750 |
| 699 Page* page = document->page(); | 751 Page* page = document->page(); |
| 700 if (!page) | 752 if (!page) |
| 701 return 0; | 753 return 0; |
| 702 | 754 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 if (!document) | 786 if (!document) |
| 735 return 0; | 787 return 0; |
| 736 | 788 |
| 737 Page* page = document->page(); | 789 Page* page = document->page(); |
| 738 if (!page) | 790 if (!page) |
| 739 return 0; | 791 return 0; |
| 740 | 792 |
| 741 if (!document->securityOrigin()->canAccessDatabase()) | 793 if (!document->securityOrigin()->canAccessDatabase()) |
| 742 return 0; | 794 return 0; |
| 743 | 795 |
| 744 if (!m_idbFactory) | 796 if (!m_idbFactory && isCurrentlyDisplayedInFrame()) |
| 745 m_idbFactory = IDBFactory::create(page->group().idbFactory()); | 797 m_idbFactory = IDBFactory::create(page->group().idbFactory()); |
| 746 return m_idbFactory.get(); | 798 return m_idbFactory.get(); |
| 747 } | 799 } |
| 748 #endif | 800 #endif |
| 749 | 801 |
| 750 #if ENABLE(FILE_SYSTEM) | 802 #if ENABLE(FILE_SYSTEM) |
| 751 void DOMWindow::webkitRequestFileSystem(int type, long long size, PassRefPtr<Fil
eSystemCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) | 803 void DOMWindow::webkitRequestFileSystem(int type, long long size, PassRefPtr<Fil
eSystemCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) |
| 752 { | 804 { |
| 805 if (!isCurrentlyDisplayedInFrame()) |
| 806 return; |
| 807 |
| 753 Document* document = this->document(); | 808 Document* document = this->document(); |
| 754 if (!document) | 809 if (!document) |
| 755 return; | 810 return; |
| 756 | 811 |
| 757 if (!AsyncFileSystem::isAvailable() || !document->securityOrigin()->canAcces
sFileSystem()) { | 812 if (!AsyncFileSystem::isAvailable() || !document->securityOrigin()->canAcces
sFileSystem()) { |
| 758 DOMFileSystem::scheduleCallback(document, errorCallback, FileError::crea
te(FileError::SECURITY_ERR)); | 813 DOMFileSystem::scheduleCallback(document, errorCallback, FileError::crea
te(FileError::SECURITY_ERR)); |
| 759 return; | 814 return; |
| 760 } | 815 } |
| 761 | 816 |
| 762 AsyncFileSystem::Type fileSystemType = static_cast<AsyncFileSystem::Type>(ty
pe); | 817 AsyncFileSystem::Type fileSystemType = static_cast<AsyncFileSystem::Type>(ty
pe); |
| 763 if (fileSystemType != AsyncFileSystem::Temporary && fileSystemType != AsyncF
ileSystem::Persistent && fileSystemType != AsyncFileSystem::External) { | 818 if (fileSystemType != AsyncFileSystem::Temporary && fileSystemType != AsyncF
ileSystem::Persistent && fileSystemType != AsyncFileSystem::External) { |
| 764 DOMFileSystem::scheduleCallback(document, errorCallback, FileError::crea
te(FileError::INVALID_MODIFICATION_ERR)); | 819 DOMFileSystem::scheduleCallback(document, errorCallback, FileError::crea
te(FileError::INVALID_MODIFICATION_ERR)); |
| 765 return; | 820 return; |
| 766 } | 821 } |
| 767 | 822 |
| 768 LocalFileSystem::localFileSystem().requestFileSystem(document, fileSystemTyp
e, size, FileSystemCallbacks::create(successCallback, errorCallback, document),
false); | 823 LocalFileSystem::localFileSystem().requestFileSystem(document, fileSystemTyp
e, size, FileSystemCallbacks::create(successCallback, errorCallback, document),
false); |
| 769 } | 824 } |
| 770 | 825 |
| 771 void DOMWindow::webkitResolveLocalFileSystemURL(const String& url, PassRefPtr<En
tryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) | 826 void DOMWindow::webkitResolveLocalFileSystemURL(const String& url, PassRefPtr<En
tryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) |
| 772 { | 827 { |
| 828 if (!isCurrentlyDisplayedInFrame()) |
| 829 return; |
| 830 |
| 773 Document* document = this->document(); | 831 Document* document = this->document(); |
| 774 if (!document) | 832 if (!document) |
| 775 return; | 833 return; |
| 776 | 834 |
| 777 SecurityOrigin* securityOrigin = document->securityOrigin(); | 835 SecurityOrigin* securityOrigin = document->securityOrigin(); |
| 778 KURL completedURL = document->completeURL(url); | 836 KURL completedURL = document->completeURL(url); |
| 779 if (!AsyncFileSystem::isAvailable() || !securityOrigin->canAccessFileSystem(
) || !securityOrigin->canRequest(completedURL)) { | 837 if (!AsyncFileSystem::isAvailable() || !securityOrigin->canAccessFileSystem(
) || !securityOrigin->canRequest(completedURL)) { |
| 780 DOMFileSystem::scheduleCallback(document, errorCallback, FileError::crea
te(FileError::SECURITY_ERR)); | 838 DOMFileSystem::scheduleCallback(document, errorCallback, FileError::crea
te(FileError::SECURITY_ERR)); |
| 781 return; | 839 return; |
| 782 } | 840 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 801 void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, MessagePo
rt* port, const String& targetOrigin, DOMWindow* source, ExceptionCode& ec) | 859 void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, MessagePo
rt* port, const String& targetOrigin, DOMWindow* source, ExceptionCode& ec) |
| 802 { | 860 { |
| 803 MessagePortArray ports; | 861 MessagePortArray ports; |
| 804 if (port) | 862 if (port) |
| 805 ports.append(port); | 863 ports.append(port); |
| 806 postMessage(message, &ports, targetOrigin, source, ec); | 864 postMessage(message, &ports, targetOrigin, source, ec); |
| 807 } | 865 } |
| 808 | 866 |
| 809 void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, const Mes
sagePortArray* ports, const String& targetOrigin, DOMWindow* source, ExceptionCo
de& ec) | 867 void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, const Mes
sagePortArray* ports, const String& targetOrigin, DOMWindow* source, ExceptionCo
de& ec) |
| 810 { | 868 { |
| 811 if (!m_frame) | 869 if (!isCurrentlyDisplayedInFrame()) |
| 812 return; | 870 return; |
| 813 | 871 |
| 814 // Compute the target origin. We need to do this synchronously in order | 872 // Compute the target origin. We need to do this synchronously in order |
| 815 // to generate the SYNTAX_ERR exception correctly. | 873 // to generate the SYNTAX_ERR exception correctly. |
| 816 RefPtr<SecurityOrigin> target; | 874 RefPtr<SecurityOrigin> target; |
| 817 if (targetOrigin != "*") { | 875 if (targetOrigin != "*") { |
| 818 target = SecurityOrigin::createFromString(targetOrigin); | 876 target = SecurityOrigin::createFromString(targetOrigin); |
| 819 if (target->isEmpty()) { | 877 if (target->isEmpty()) { |
| 820 ec = SYNTAX_ERR; | 878 ec = SYNTAX_ERR; |
| 821 return; | 879 return; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageL
evel, message, 0, String()); | 911 console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageL
evel, message, 0, String()); |
| 854 return; | 912 return; |
| 855 } | 913 } |
| 856 } | 914 } |
| 857 | 915 |
| 858 dispatchEvent(timer->event(document())); | 916 dispatchEvent(timer->event(document())); |
| 859 } | 917 } |
| 860 | 918 |
| 861 DOMSelection* DOMWindow::getSelection() | 919 DOMSelection* DOMWindow::getSelection() |
| 862 { | 920 { |
| 863 if (!m_selection) | 921 if (!m_selection && isCurrentlyDisplayedInFrame()) |
| 864 m_selection = DOMSelection::create(m_frame); | 922 m_selection = DOMSelection::create(m_frame); |
| 865 return m_selection.get(); | 923 return m_selection.get(); |
| 866 } | 924 } |
| 867 | 925 |
| 868 Element* DOMWindow::frameElement() const | 926 Element* DOMWindow::frameElement() const |
| 869 { | 927 { |
| 870 if (!m_frame) | 928 if (!m_frame) |
| 871 return 0; | 929 return 0; |
| 872 | 930 |
| 873 return m_frame->ownerElement(); | 931 return m_frame->ownerElement(); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 if (!base64Decode(encodedString, out, FailOnInvalidCharacter)) { | 1099 if (!base64Decode(encodedString, out, FailOnInvalidCharacter)) { |
| 1042 ec = INVALID_CHARACTER_ERR; | 1100 ec = INVALID_CHARACTER_ERR; |
| 1043 return String(); | 1101 return String(); |
| 1044 } | 1102 } |
| 1045 | 1103 |
| 1046 return String(out.data(), out.size()); | 1104 return String(out.data(), out.size()); |
| 1047 } | 1105 } |
| 1048 | 1106 |
| 1049 bool DOMWindow::find(const String& string, bool caseSensitive, bool backwards, b
ool wrap, bool /*wholeWord*/, bool /*searchInFrames*/, bool /*showDialog*/) cons
t | 1107 bool DOMWindow::find(const String& string, bool caseSensitive, bool backwards, b
ool wrap, bool /*wholeWord*/, bool /*searchInFrames*/, bool /*showDialog*/) cons
t |
| 1050 { | 1108 { |
| 1051 if (!m_frame) | 1109 if (!isCurrentlyDisplayedInFrame()) |
| 1052 return false; | 1110 return false; |
| 1053 | 1111 |
| 1054 // FIXME (13016): Support wholeWord, searchInFrames and showDialog | 1112 // FIXME (13016): Support wholeWord, searchInFrames and showDialog |
| 1055 return m_frame->editor()->findString(string, !backwards, caseSensitive, wrap
, false); | 1113 return m_frame->editor()->findString(string, !backwards, caseSensitive, wrap
, false); |
| 1056 } | 1114 } |
| 1057 | 1115 |
| 1058 bool DOMWindow::offscreenBuffering() const | 1116 bool DOMWindow::offscreenBuffering() const |
| 1059 { | 1117 { |
| 1060 return true; | 1118 return true; |
| 1061 } | 1119 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1160 return static_cast<int>(view->scrollY() / m_frame->pageZoomFactor()); | 1218 return static_cast<int>(view->scrollY() / m_frame->pageZoomFactor()); |
| 1161 } | 1219 } |
| 1162 | 1220 |
| 1163 bool DOMWindow::closed() const | 1221 bool DOMWindow::closed() const |
| 1164 { | 1222 { |
| 1165 return !m_frame; | 1223 return !m_frame; |
| 1166 } | 1224 } |
| 1167 | 1225 |
| 1168 unsigned DOMWindow::length() const | 1226 unsigned DOMWindow::length() const |
| 1169 { | 1227 { |
| 1170 if (!m_frame) | 1228 if (!isCurrentlyDisplayedInFrame()) |
| 1171 return 0; | 1229 return 0; |
| 1172 | 1230 |
| 1173 return m_frame->tree()->childCount(); | 1231 return m_frame->tree()->childCount(); |
| 1174 } | 1232 } |
| 1175 | 1233 |
| 1176 String DOMWindow::name() const | 1234 String DOMWindow::name() const |
| 1177 { | 1235 { |
| 1178 if (!m_frame) | 1236 if (!m_frame) |
| 1179 return String(); | 1237 return String(); |
| 1180 | 1238 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1258 | 1316 |
| 1259 Page* page = m_frame->page(); | 1317 Page* page = m_frame->page(); |
| 1260 if (!page) | 1318 if (!page) |
| 1261 return 0; | 1319 return 0; |
| 1262 | 1320 |
| 1263 return m_frame->tree()->top(true)->domWindow(); | 1321 return m_frame->tree()->top(true)->domWindow(); |
| 1264 } | 1322 } |
| 1265 | 1323 |
| 1266 Document* DOMWindow::document() const | 1324 Document* DOMWindow::document() const |
| 1267 { | 1325 { |
| 1268 // FIXME: This function shouldn't need a frame to work. | 1326 if (!isCurrentlyDisplayedInFrame()) |
| 1269 if (!m_frame) | |
| 1270 return 0; | 1327 return 0; |
| 1271 | 1328 |
| 1272 // The m_frame pointer is not zeroed out when the window is put into b/f cac
he, so it can hold an unrelated document/window pair. | 1329 // FIXME: This function shouldn't need a frame to work. |
| 1273 // FIXME: We should always zero out the frame pointer on navigation to avoid
accidentally accessing the new frame content. | |
| 1274 if (m_frame->domWindow() != this) | |
| 1275 return 0; | |
| 1276 | |
| 1277 ASSERT(m_frame->document()); | 1330 ASSERT(m_frame->document()); |
| 1278 return m_frame->document(); | 1331 return m_frame->document(); |
| 1279 } | 1332 } |
| 1280 | 1333 |
| 1281 PassRefPtr<StyleMedia> DOMWindow::styleMedia() const | 1334 PassRefPtr<StyleMedia> DOMWindow::styleMedia() const |
| 1282 { | 1335 { |
| 1283 if (!m_media) | 1336 if (!m_media && isCurrentlyDisplayedInFrame()) |
| 1284 m_media = StyleMedia::create(m_frame); | 1337 m_media = StyleMedia::create(m_frame); |
| 1285 return m_media.get(); | 1338 return m_media.get(); |
| 1286 } | 1339 } |
| 1287 | 1340 |
| 1288 PassRefPtr<CSSStyleDeclaration> DOMWindow::getComputedStyle(Element* elt, const
String& pseudoElt) const | 1341 PassRefPtr<CSSStyleDeclaration> DOMWindow::getComputedStyle(Element* elt, const
String& pseudoElt) const |
| 1289 { | 1342 { |
| 1290 if (!elt) | 1343 if (!elt) |
| 1291 return 0; | 1344 return 0; |
| 1292 | 1345 |
| 1293 return computedStyle(elt, false, pseudoElt); | 1346 return computedStyle(elt, false, pseudoElt); |
| 1294 } | 1347 } |
| 1295 | 1348 |
| 1296 PassRefPtr<CSSRuleList> DOMWindow::getMatchedCSSRules(Element* element, const St
ring&, bool authorOnly) const | 1349 PassRefPtr<CSSRuleList> DOMWindow::getMatchedCSSRules(Element* element, const St
ring&, bool authorOnly) const |
| 1297 { | 1350 { |
| 1298 if (!m_frame) | 1351 if (!isCurrentlyDisplayedInFrame()) |
| 1299 return 0; | 1352 return 0; |
| 1300 | 1353 |
| 1301 unsigned rulesToInclude = CSSStyleSelector::AuthorCSSRules; | 1354 unsigned rulesToInclude = CSSStyleSelector::AuthorCSSRules; |
| 1302 if (!authorOnly) | 1355 if (!authorOnly) |
| 1303 rulesToInclude |= CSSStyleSelector::UAAndUserCSSRules; | 1356 rulesToInclude |= CSSStyleSelector::UAAndUserCSSRules; |
| 1304 if (Settings* settings = m_frame->settings()) { | 1357 if (Settings* settings = m_frame->settings()) { |
| 1305 if (settings->crossOriginCheckInGetMatchedCSSRulesDisabled()) | 1358 if (settings->crossOriginCheckInGetMatchedCSSRulesDisabled()) |
| 1306 rulesToInclude |= CSSStyleSelector::CrossOriginCSSRules; | 1359 rulesToInclude |= CSSStyleSelector::CrossOriginCSSRules; |
| 1307 } | 1360 } |
| 1308 | 1361 |
| 1309 return m_frame->document()->styleSelector()->styleRulesForElement(element, r
ulesToInclude); | 1362 return m_frame->document()->styleSelector()->styleRulesForElement(element, r
ulesToInclude); |
| 1310 } | 1363 } |
| 1311 | 1364 |
| 1312 PassRefPtr<WebKitPoint> DOMWindow::webkitConvertPointFromNodeToPage(Node* node,
const WebKitPoint* p) const | 1365 PassRefPtr<WebKitPoint> DOMWindow::webkitConvertPointFromNodeToPage(Node* node,
const WebKitPoint* p) const |
| 1313 { | 1366 { |
| 1314 if (!node || !p) | 1367 if (!node || !p) |
| 1315 return 0; | 1368 return 0; |
| 1316 | 1369 |
| 1317 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 1370 if (!document()) |
| 1371 return 0; |
| 1372 |
| 1373 document()->updateLayoutIgnorePendingStylesheets(); |
| 1318 | 1374 |
| 1319 FloatPoint pagePoint(p->x(), p->y()); | 1375 FloatPoint pagePoint(p->x(), p->y()); |
| 1320 pagePoint = node->convertToPage(pagePoint); | 1376 pagePoint = node->convertToPage(pagePoint); |
| 1321 return WebKitPoint::create(pagePoint.x(), pagePoint.y()); | 1377 return WebKitPoint::create(pagePoint.x(), pagePoint.y()); |
| 1322 } | 1378 } |
| 1323 | 1379 |
| 1324 PassRefPtr<WebKitPoint> DOMWindow::webkitConvertPointFromPageToNode(Node* node,
const WebKitPoint* p) const | 1380 PassRefPtr<WebKitPoint> DOMWindow::webkitConvertPointFromPageToNode(Node* node,
const WebKitPoint* p) const |
| 1325 { | 1381 { |
| 1326 if (!node || !p) | 1382 if (!node || !p) |
| 1327 return 0; | 1383 return 0; |
| 1328 | 1384 |
| 1329 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 1385 if (!document()) |
| 1386 return 0; |
| 1387 |
| 1388 document()->updateLayoutIgnorePendingStylesheets(); |
| 1330 | 1389 |
| 1331 FloatPoint nodePoint(p->x(), p->y()); | 1390 FloatPoint nodePoint(p->x(), p->y()); |
| 1332 nodePoint = node->convertFromPage(nodePoint); | 1391 nodePoint = node->convertFromPage(nodePoint); |
| 1333 return WebKitPoint::create(nodePoint.x(), nodePoint.y()); | 1392 return WebKitPoint::create(nodePoint.x(), nodePoint.y()); |
| 1334 } | 1393 } |
| 1335 | 1394 |
| 1336 double DOMWindow::devicePixelRatio() const | 1395 double DOMWindow::devicePixelRatio() const |
| 1337 { | 1396 { |
| 1338 if (!m_frame) | 1397 if (!m_frame) |
| 1339 return 0.0; | 1398 return 0.0; |
| 1340 | 1399 |
| 1341 Page* page = m_frame->page(); | 1400 Page* page = m_frame->page(); |
| 1342 if (!page) | 1401 if (!page) |
| 1343 return 0.0; | 1402 return 0.0; |
| 1344 | 1403 |
| 1345 return page->deviceScaleFactor(); | 1404 return page->deviceScaleFactor(); |
| 1346 } | 1405 } |
| 1347 | 1406 |
| 1348 #if ENABLE(DATABASE) | 1407 #if ENABLE(DATABASE) |
| 1349 PassRefPtr<Database> DOMWindow::openDatabase(const String& name, const String& v
ersion, const String& displayName, unsigned long estimatedSize, PassRefPtr<Datab
aseCallback> creationCallback, ExceptionCode& ec) | 1408 PassRefPtr<Database> DOMWindow::openDatabase(const String& name, const String& v
ersion, const String& displayName, unsigned long estimatedSize, PassRefPtr<Datab
aseCallback> creationCallback, ExceptionCode& ec) |
| 1350 { | 1409 { |
| 1410 if (!isCurrentlyDisplayedInFrame()) |
| 1411 return 0; |
| 1412 |
| 1351 RefPtr<Database> database = 0; | 1413 RefPtr<Database> database = 0; |
| 1352 if (m_frame && AbstractDatabase::isAvailable() && m_frame->document()->secur
ityOrigin()->canAccessDatabase()) | 1414 if (m_frame && AbstractDatabase::isAvailable() && m_frame->document()->secur
ityOrigin()->canAccessDatabase()) |
| 1353 database = Database::openDatabase(m_frame->document(), name, version, di
splayName, estimatedSize, creationCallback, ec); | 1415 database = Database::openDatabase(m_frame->document(), name, version, di
splayName, estimatedSize, creationCallback, ec); |
| 1354 | 1416 |
| 1355 if (!database && !ec) | 1417 if (!database && !ec) |
| 1356 ec = SECURITY_ERR; | 1418 ec = SECURITY_ERR; |
| 1357 | 1419 |
| 1358 return database; | 1420 return database; |
| 1359 } | 1421 } |
| 1360 #endif | 1422 #endif |
| 1361 | 1423 |
| 1362 void DOMWindow::scrollBy(int x, int y) const | 1424 void DOMWindow::scrollBy(int x, int y) const |
| 1363 { | 1425 { |
| 1364 if (!m_frame) | 1426 if (!isCurrentlyDisplayedInFrame()) |
| 1365 return; | 1427 return; |
| 1366 | 1428 |
| 1367 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 1429 document()->updateLayoutIgnorePendingStylesheets(); |
| 1368 | 1430 |
| 1369 FrameView* view = m_frame->view(); | 1431 FrameView* view = m_frame->view(); |
| 1370 if (!view) | 1432 if (!view) |
| 1371 return; | 1433 return; |
| 1372 | 1434 |
| 1373 view->scrollBy(IntSize(x, y)); | 1435 view->scrollBy(IntSize(x, y)); |
| 1374 } | 1436 } |
| 1375 | 1437 |
| 1376 void DOMWindow::scrollTo(int x, int y) const | 1438 void DOMWindow::scrollTo(int x, int y) const |
| 1377 { | 1439 { |
| 1378 if (!m_frame) | 1440 if (!isCurrentlyDisplayedInFrame()) |
| 1379 return; | 1441 return; |
| 1380 | 1442 |
| 1381 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 1443 document()->updateLayoutIgnorePendingStylesheets(); |
| 1382 | 1444 |
| 1383 RefPtr<FrameView> view = m_frame->view(); | 1445 RefPtr<FrameView> view = m_frame->view(); |
| 1384 if (!view) | 1446 if (!view) |
| 1385 return; | 1447 return; |
| 1386 | 1448 |
| 1387 int zoomedX = static_cast<int>(x * m_frame->pageZoomFactor()); | 1449 int zoomedX = static_cast<int>(x * m_frame->pageZoomFactor()); |
| 1388 int zoomedY = static_cast<int>(y * m_frame->pageZoomFactor()); | 1450 int zoomedY = static_cast<int>(y * m_frame->pageZoomFactor()); |
| 1389 view->setScrollPosition(IntPoint(zoomedX, zoomedY)); | 1451 view->setScrollPosition(IntPoint(zoomedX, zoomedY)); |
| 1390 } | 1452 } |
| 1391 | 1453 |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1648 return &m_eventTargetData; | 1710 return &m_eventTargetData; |
| 1649 } | 1711 } |
| 1650 | 1712 |
| 1651 EventTargetData* DOMWindow::ensureEventTargetData() | 1713 EventTargetData* DOMWindow::ensureEventTargetData() |
| 1652 { | 1714 { |
| 1653 return &m_eventTargetData; | 1715 return &m_eventTargetData; |
| 1654 } | 1716 } |
| 1655 | 1717 |
| 1656 void DOMWindow::setLocation(const String& urlString, DOMWindow* activeWindow, DO
MWindow* firstWindow, SetLocationLocking locking) | 1718 void DOMWindow::setLocation(const String& urlString, DOMWindow* activeWindow, DO
MWindow* firstWindow, SetLocationLocking locking) |
| 1657 { | 1719 { |
| 1658 if (!m_frame) | 1720 if (!isCurrentlyDisplayedInFrame()) |
| 1659 return; | 1721 return; |
| 1660 | 1722 |
| 1661 Frame* activeFrame = activeWindow->frame(); | 1723 Frame* activeFrame = activeWindow->frame(); |
| 1662 if (!activeFrame) | 1724 if (!activeFrame) |
| 1663 return; | 1725 return; |
| 1664 | 1726 |
| 1665 if (!activeFrame->loader()->shouldAllowNavigation(m_frame)) | 1727 if (!activeFrame->loader()->shouldAllowNavigation(m_frame)) |
| 1666 return; | 1728 return; |
| 1667 | 1729 |
| 1668 Frame* firstFrame = firstWindow->frame(); | 1730 Frame* firstFrame = firstWindow->frame(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1708 // Perhaps we should involve the security origin object in composing it. | 1770 // Perhaps we should involve the security origin object in composing it. |
| 1709 // FIXME: This message, and other console messages, have extra newlines. Sho
uld remove them. | 1771 // FIXME: This message, and other console messages, have extra newlines. Sho
uld remove them. |
| 1710 return "Unsafe JavaScript attempt to access frame with URL " + m_url.string(
) + " from frame with URL " + activeWindowURL.string() + ". Domains, protocols a
nd ports must match.\n"; | 1772 return "Unsafe JavaScript attempt to access frame with URL " + m_url.string(
) + " from frame with URL " + activeWindowURL.string() + ". Domains, protocols a
nd ports must match.\n"; |
| 1711 } | 1773 } |
| 1712 | 1774 |
| 1713 bool DOMWindow::isInsecureScriptAccess(DOMWindow* activeWindow, const String& ur
lString) | 1775 bool DOMWindow::isInsecureScriptAccess(DOMWindow* activeWindow, const String& ur
lString) |
| 1714 { | 1776 { |
| 1715 if (!protocolIsJavaScript(urlString)) | 1777 if (!protocolIsJavaScript(urlString)) |
| 1716 return false; | 1778 return false; |
| 1717 | 1779 |
| 1718 // If m_frame->domWindow() != this, then |this| isn't the DOMWindow that's | 1780 // If this DOMWindow isn't currently active in the Frame, then there's no |
| 1719 // currently active in the frame and there's no way we should allow the | 1781 // way we should allow the access. |
| 1720 // access. | |
| 1721 // FIXME: Remove this check if we're able to disconnect DOMWindow from | 1782 // FIXME: Remove this check if we're able to disconnect DOMWindow from |
| 1722 // Frame on navigation: https://bugs.webkit.org/show_bug.cgi?id=62054 | 1783 // Frame on navigation: https://bugs.webkit.org/show_bug.cgi?id=62054 |
| 1723 if (m_frame->domWindow() == this) { | 1784 if (isCurrentlyDisplayedInFrame()) { |
| 1724 // FIXME: Is there some way to eliminate the need for a separate "active
Window == this" check? | 1785 // FIXME: Is there some way to eliminate the need for a separate "active
Window == this" check? |
| 1725 if (activeWindow == this) | 1786 if (activeWindow == this) |
| 1726 return false; | 1787 return false; |
| 1727 | 1788 |
| 1728 // FIXME: The name canAccess seems to be a roundabout way to ask "can ex
ecute script". | 1789 // FIXME: The name canAccess seems to be a roundabout way to ask "can ex
ecute script". |
| 1729 // Can we name the SecurityOrigin function better to make this more clea
r? | 1790 // Can we name the SecurityOrigin function better to make this more clea
r? |
| 1730 if (activeWindow->securityOrigin()->canAccess(securityOrigin())) | 1791 if (activeWindow->securityOrigin()->canAccess(securityOrigin())) |
| 1731 return false; | 1792 return false; |
| 1732 } | 1793 } |
| 1733 | 1794 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1770 bool lockHistory = !ScriptController::processingUserGesture(); | 1831 bool lockHistory = !ScriptController::processingUserGesture(); |
| 1771 newFrame->navigationScheduler()->scheduleLocationChange(activeWindow->se
curityOrigin(), completedURL.string(), referrer, lockHistory, false); | 1832 newFrame->navigationScheduler()->scheduleLocationChange(activeWindow->se
curityOrigin(), completedURL.string(), referrer, lockHistory, false); |
| 1772 } | 1833 } |
| 1773 | 1834 |
| 1774 return newFrame; | 1835 return newFrame; |
| 1775 } | 1836 } |
| 1776 | 1837 |
| 1777 PassRefPtr<DOMWindow> DOMWindow::open(const String& urlString, const AtomicStrin
g& frameName, const String& windowFeaturesString, | 1838 PassRefPtr<DOMWindow> DOMWindow::open(const String& urlString, const AtomicStrin
g& frameName, const String& windowFeaturesString, |
| 1778 DOMWindow* activeWindow, DOMWindow* firstWindow) | 1839 DOMWindow* activeWindow, DOMWindow* firstWindow) |
| 1779 { | 1840 { |
| 1780 if (!m_frame) | 1841 if (!isCurrentlyDisplayedInFrame()) |
| 1781 return 0; | 1842 return 0; |
| 1782 Frame* activeFrame = activeWindow->frame(); | 1843 Frame* activeFrame = activeWindow->frame(); |
| 1783 if (!activeFrame) | 1844 if (!activeFrame) |
| 1784 return 0; | 1845 return 0; |
| 1785 Frame* firstFrame = firstWindow->frame(); | 1846 Frame* firstFrame = firstWindow->frame(); |
| 1786 if (!firstFrame) | 1847 if (!firstFrame) |
| 1787 return 0; | 1848 return 0; |
| 1788 | 1849 |
| 1789 if (!firstWindow->allowPopUp()) { | 1850 if (!firstWindow->allowPopUp()) { |
| 1790 // Because FrameTree::find() returns true for empty strings, we must che
ck for empty frame names. | 1851 // Because FrameTree::find() returns true for empty strings, we must che
ck for empty frame names. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1838 windowFeatures.height = windowRect.height(); | 1899 windowFeatures.height = windowRect.height(); |
| 1839 windowFeatures.width = windowRect.width(); | 1900 windowFeatures.width = windowRect.width(); |
| 1840 | 1901 |
| 1841 Frame* result = createWindow(urlString, frameName, windowFeatures, activeWin
dow, firstFrame, m_frame); | 1902 Frame* result = createWindow(urlString, frameName, windowFeatures, activeWin
dow, firstFrame, m_frame); |
| 1842 return result ? result->domWindow() : 0; | 1903 return result ? result->domWindow() : 0; |
| 1843 } | 1904 } |
| 1844 | 1905 |
| 1845 void DOMWindow::showModalDialog(const String& urlString, const String& dialogFea
turesString, | 1906 void DOMWindow::showModalDialog(const String& urlString, const String& dialogFea
turesString, |
| 1846 DOMWindow* activeWindow, DOMWindow* firstWindow, PrepareDialogFunction funct
ion, void* functionContext) | 1907 DOMWindow* activeWindow, DOMWindow* firstWindow, PrepareDialogFunction funct
ion, void* functionContext) |
| 1847 { | 1908 { |
| 1848 if (!m_frame) | 1909 if (!isCurrentlyDisplayedInFrame()) |
| 1849 return; | 1910 return; |
| 1850 Frame* activeFrame = activeWindow->frame(); | 1911 Frame* activeFrame = activeWindow->frame(); |
| 1851 if (!activeFrame) | 1912 if (!activeFrame) |
| 1852 return; | 1913 return; |
| 1853 Frame* firstFrame = firstWindow->frame(); | 1914 Frame* firstFrame = firstWindow->frame(); |
| 1854 if (!firstFrame) | 1915 if (!firstFrame) |
| 1855 return; | 1916 return; |
| 1856 | 1917 |
| 1857 if (!canShowModalDialogNow(m_frame) || !firstWindow->allowPopUp()) | 1918 if (!canShowModalDialogNow(m_frame) || !firstWindow->allowPopUp()) |
| 1858 return; | 1919 return; |
| 1859 | 1920 |
| 1860 Frame* dialogFrame = createWindow(urlString, emptyAtom, WindowFeatures(dialo
gFeaturesString, screenAvailableRect(m_frame->view())), | 1921 Frame* dialogFrame = createWindow(urlString, emptyAtom, WindowFeatures(dialo
gFeaturesString, screenAvailableRect(m_frame->view())), |
| 1861 activeWindow, firstFrame, m_frame, function, functionContext); | 1922 activeWindow, firstFrame, m_frame, function, functionContext); |
| 1862 if (!dialogFrame) | 1923 if (!dialogFrame) |
| 1863 return; | 1924 return; |
| 1864 | 1925 |
| 1865 dialogFrame->page()->chrome()->runModal(); | 1926 dialogFrame->page()->chrome()->runModal(); |
| 1866 } | 1927 } |
| 1867 | 1928 |
| 1868 #if ENABLE(BLOB) | 1929 #if ENABLE(BLOB) |
| 1869 DOMURL* DOMWindow::webkitURL() const | 1930 DOMURL* DOMWindow::webkitURL() const |
| 1870 { | 1931 { |
| 1871 if (!m_domURL) | 1932 if (!m_domURL && isCurrentlyDisplayedInFrame()) |
| 1872 m_domURL = DOMURL::create(this->scriptExecutionContext()); | 1933 m_domURL = DOMURL::create(this->scriptExecutionContext()); |
| 1873 return m_domURL.get(); | 1934 return m_domURL.get(); |
| 1874 } | 1935 } |
| 1875 #endif | 1936 #endif |
| 1876 | 1937 |
| 1877 #if ENABLE(QUOTA) | 1938 #if ENABLE(QUOTA) |
| 1878 StorageInfo* DOMWindow::webkitStorageInfo() const | 1939 StorageInfo* DOMWindow::webkitStorageInfo() const |
| 1879 { | 1940 { |
| 1880 if (!m_storageInfo) | 1941 if (!m_storageInfo && isCurrentlyDisplayedInFrame()) |
| 1881 m_storageInfo = StorageInfo::create(); | 1942 m_storageInfo = StorageInfo::create(); |
| 1882 return m_storageInfo.get(); | 1943 return m_storageInfo.get(); |
| 1883 } | 1944 } |
| 1884 #endif | 1945 #endif |
| 1885 | 1946 |
| 1886 } // namespace WebCore | 1947 } // namespace WebCore |
| OLD | NEW |