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 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
583 m_performance = nullptr; | 583 m_performance = nullptr; |
584 m_location = nullptr; | 584 m_location = nullptr; |
585 m_media = nullptr; | 585 m_media = nullptr; |
586 m_sessionStorage = nullptr; | 586 m_sessionStorage = nullptr; |
587 m_localStorage = nullptr; | 587 m_localStorage = nullptr; |
588 m_applicationCache = nullptr; | 588 m_applicationCache = nullptr; |
589 } | 589 } |
590 | 590 |
591 bool DOMWindow::isCurrentlyDisplayedInFrame() const | 591 bool DOMWindow::isCurrentlyDisplayedInFrame() const |
592 { | 592 { |
593 return m_frame && m_frame->domWindow() == this; | 593 return m_frame && m_frame->domWindow() == this && m_frame->host(); |
594 } | 594 } |
595 | 595 |
596 int DOMWindow::orientation() const | 596 int DOMWindow::orientation() const |
597 { | 597 { |
598 ASSERT(RuntimeEnabledFeatures::orientationEventEnabled()); | 598 ASSERT(RuntimeEnabledFeatures::orientationEventEnabled()); |
599 | 599 |
600 if (!m_frame) | 600 if (!m_frame) |
601 return 0; | 601 return 0; |
602 | 602 |
603 return m_frame->orientation(); | 603 return m_frame->orientation(); |
604 } | 604 } |
605 | 605 |
606 Screen* DOMWindow::screen() const | 606 Screen* DOMWindow::screen() const |
607 { | 607 { |
608 if (!isCurrentlyDisplayedInFrame()) | |
609 return 0; | |
abarth-chromium
2014/03/01 07:00:32
Why doesn't this change web-visible behavior? Pre
dcheng
2014/03/01 09:41:53
It doesn't change web visible behavior because the
| |
610 if (!m_screen) | 608 if (!m_screen) |
611 m_screen = Screen::create(m_frame); | 609 m_screen = Screen::create(m_frame); |
612 return m_screen.get(); | 610 return m_screen.get(); |
613 } | 611 } |
614 | 612 |
615 History* DOMWindow::history() const | 613 History* DOMWindow::history() const |
616 { | 614 { |
617 if (!isCurrentlyDisplayedInFrame()) | |
618 return 0; | |
619 if (!m_history) | 615 if (!m_history) |
620 m_history = History::create(m_frame); | 616 m_history = History::create(m_frame); |
621 return m_history.get(); | 617 return m_history.get(); |
622 } | 618 } |
623 | 619 |
624 BarProp* DOMWindow::locationbar() const | 620 BarProp* DOMWindow::locationbar() const |
625 { | 621 { |
626 UseCounter::count(document(), UseCounter::BarPropLocationbar); | 622 UseCounter::count(document(), UseCounter::BarPropLocationbar); |
627 if (!isCurrentlyDisplayedInFrame()) | |
628 return 0; | |
629 if (!m_locationbar) | 623 if (!m_locationbar) |
630 m_locationbar = BarProp::create(m_frame, BarProp::Locationbar); | 624 m_locationbar = BarProp::create(m_frame, BarProp::Locationbar); |
631 return m_locationbar.get(); | 625 return m_locationbar.get(); |
632 } | 626 } |
633 | 627 |
634 BarProp* DOMWindow::menubar() const | 628 BarProp* DOMWindow::menubar() const |
635 { | 629 { |
636 UseCounter::count(document(), UseCounter::BarPropMenubar); | 630 UseCounter::count(document(), UseCounter::BarPropMenubar); |
637 if (!isCurrentlyDisplayedInFrame()) | |
638 return 0; | |
639 if (!m_menubar) | 631 if (!m_menubar) |
640 m_menubar = BarProp::create(m_frame, BarProp::Menubar); | 632 m_menubar = BarProp::create(m_frame, BarProp::Menubar); |
641 return m_menubar.get(); | 633 return m_menubar.get(); |
642 } | 634 } |
643 | 635 |
644 BarProp* DOMWindow::personalbar() const | 636 BarProp* DOMWindow::personalbar() const |
645 { | 637 { |
646 UseCounter::count(document(), UseCounter::BarPropPersonalbar); | 638 UseCounter::count(document(), UseCounter::BarPropPersonalbar); |
647 if (!isCurrentlyDisplayedInFrame()) | |
648 return 0; | |
649 if (!m_personalbar) | 639 if (!m_personalbar) |
650 m_personalbar = BarProp::create(m_frame, BarProp::Personalbar); | 640 m_personalbar = BarProp::create(m_frame, BarProp::Personalbar); |
651 return m_personalbar.get(); | 641 return m_personalbar.get(); |
652 } | 642 } |
653 | 643 |
654 BarProp* DOMWindow::scrollbars() const | 644 BarProp* DOMWindow::scrollbars() const |
655 { | 645 { |
656 UseCounter::count(document(), UseCounter::BarPropScrollbars); | 646 UseCounter::count(document(), UseCounter::BarPropScrollbars); |
657 if (!isCurrentlyDisplayedInFrame()) | |
658 return 0; | |
659 if (!m_scrollbars) | 647 if (!m_scrollbars) |
660 m_scrollbars = BarProp::create(m_frame, BarProp::Scrollbars); | 648 m_scrollbars = BarProp::create(m_frame, BarProp::Scrollbars); |
661 return m_scrollbars.get(); | 649 return m_scrollbars.get(); |
662 } | 650 } |
663 | 651 |
664 BarProp* DOMWindow::statusbar() const | 652 BarProp* DOMWindow::statusbar() const |
665 { | 653 { |
666 UseCounter::count(document(), UseCounter::BarPropStatusbar); | 654 UseCounter::count(document(), UseCounter::BarPropStatusbar); |
667 if (!isCurrentlyDisplayedInFrame()) | |
668 return 0; | |
669 if (!m_statusbar) | 655 if (!m_statusbar) |
670 m_statusbar = BarProp::create(m_frame, BarProp::Statusbar); | 656 m_statusbar = BarProp::create(m_frame, BarProp::Statusbar); |
671 return m_statusbar.get(); | 657 return m_statusbar.get(); |
672 } | 658 } |
673 | 659 |
674 BarProp* DOMWindow::toolbar() const | 660 BarProp* DOMWindow::toolbar() const |
675 { | 661 { |
676 UseCounter::count(document(), UseCounter::BarPropToolbar); | 662 UseCounter::count(document(), UseCounter::BarPropToolbar); |
677 if (!isCurrentlyDisplayedInFrame()) | |
678 return 0; | |
679 if (!m_toolbar) | 663 if (!m_toolbar) |
680 m_toolbar = BarProp::create(m_frame, BarProp::Toolbar); | 664 m_toolbar = BarProp::create(m_frame, BarProp::Toolbar); |
681 return m_toolbar.get(); | 665 return m_toolbar.get(); |
682 } | 666 } |
683 | 667 |
684 Console* DOMWindow::console() const | 668 Console* DOMWindow::console() const |
685 { | 669 { |
686 if (!isCurrentlyDisplayedInFrame()) | |
687 return 0; | |
688 if (!m_console) | 670 if (!m_console) |
689 m_console = Console::create(m_frame); | 671 m_console = Console::create(m_frame); |
690 return m_console.get(); | 672 return m_console.get(); |
691 } | 673 } |
692 | 674 |
693 PageConsole* DOMWindow::pageConsole() const | 675 PageConsole* DOMWindow::pageConsole() const |
694 { | 676 { |
695 if (!isCurrentlyDisplayedInFrame()) | 677 if (!isCurrentlyDisplayedInFrame()) |
696 return 0; | 678 return 0; |
697 return m_frame->host() ? &m_frame->host()->console() : 0; | 679 return m_frame->host() ? &m_frame->host()->console() : 0; |
698 } | 680 } |
699 | 681 |
700 ApplicationCache* DOMWindow::applicationCache() const | 682 ApplicationCache* DOMWindow::applicationCache() const |
701 { | 683 { |
702 if (!isCurrentlyDisplayedInFrame()) | 684 if (!isCurrentlyDisplayedInFrame()) |
703 return 0; | 685 return 0; |
704 if (!m_applicationCache) | 686 if (!m_applicationCache) |
705 m_applicationCache = ApplicationCache::create(m_frame); | 687 m_applicationCache = ApplicationCache::create(m_frame); |
706 return m_applicationCache.get(); | 688 return m_applicationCache.get(); |
707 } | 689 } |
708 | 690 |
709 Navigator* DOMWindow::navigator() const | 691 Navigator* DOMWindow::navigator() const |
710 { | 692 { |
711 if (!isCurrentlyDisplayedInFrame()) | |
712 return 0; | |
713 if (!m_navigator) | 693 if (!m_navigator) |
714 m_navigator = Navigator::create(m_frame); | 694 m_navigator = Navigator::create(m_frame); |
715 return m_navigator.get(); | 695 return m_navigator.get(); |
716 } | 696 } |
717 | 697 |
718 Performance* DOMWindow::performance() const | 698 Performance* DOMWindow::performance() const |
719 { | 699 { |
720 if (!isCurrentlyDisplayedInFrame()) | |
721 return 0; | |
722 if (!m_performance) | 700 if (!m_performance) |
723 m_performance = Performance::create(m_frame); | 701 m_performance = Performance::create(m_frame); |
724 return m_performance.get(); | 702 return m_performance.get(); |
725 } | 703 } |
726 | 704 |
727 Location* DOMWindow::location() const | 705 Location* DOMWindow::location() const |
728 { | 706 { |
729 if (!isCurrentlyDisplayedInFrame()) | |
730 return 0; | |
731 if (!m_location) | 707 if (!m_location) |
732 m_location = Location::create(m_frame); | 708 m_location = Location::create(m_frame); |
733 return m_location.get(); | 709 return m_location.get(); |
734 } | 710 } |
735 | 711 |
736 Storage* DOMWindow::sessionStorage(ExceptionState& exceptionState) const | 712 Storage* DOMWindow::sessionStorage(ExceptionState& exceptionState) const |
737 { | 713 { |
738 if (!isCurrentlyDisplayedInFrame()) | 714 if (!isCurrentlyDisplayedInFrame()) |
739 return 0; | 715 return 0; |
740 | 716 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
860 // Schedule the message. | 836 // Schedule the message. |
861 PostMessageTimer* timer = new PostMessageTimer(this, message, sourceOrigin, source, channels.release(), target.get(), stackTrace.release()); | 837 PostMessageTimer* timer = new PostMessageTimer(this, message, sourceOrigin, source, channels.release(), target.get(), stackTrace.release()); |
862 timer->startOneShot(0); | 838 timer->startOneShot(0); |
863 timer->suspendIfNeeded(); | 839 timer->suspendIfNeeded(); |
864 } | 840 } |
865 | 841 |
866 void DOMWindow::postMessageTimerFired(PassOwnPtr<PostMessageTimer> t) | 842 void DOMWindow::postMessageTimerFired(PassOwnPtr<PostMessageTimer> t) |
867 { | 843 { |
868 OwnPtr<PostMessageTimer> timer(t); | 844 OwnPtr<PostMessageTimer> timer(t); |
869 | 845 |
870 // FIXME: The frame()->host() check really does not belong here. We should | 846 if (!isCurrentlyDisplayedInFrame()) |
871 // move it up into isCurrentlyDisplayedInFrame(); however, doing so breaks a | |
872 // number of window properties like window.toolbar. | |
873 if (!isCurrentlyDisplayedInFrame() || !frame()->host()) | |
874 return; | 847 return; |
875 | 848 |
876 RefPtr<MessageEvent> event = timer->event(); | 849 RefPtr<MessageEvent> event = timer->event(); |
877 | 850 |
878 // Give the embedder a chance to intercept this postMessage because this | 851 // Give the embedder a chance to intercept this postMessage because this |
879 // DOMWindow might be a proxy for another in browsers that support | 852 // DOMWindow might be a proxy for another in browsers that support |
880 // postMessage calls across WebKit instances. | 853 // postMessage calls across WebKit instances. |
881 if (m_frame->loader().client()->willCheckAndDispatchMessageEvent(timer->targ etOrigin(), event.get())) | 854 if (m_frame->loader().client()->willCheckAndDispatchMessageEvent(timer->targ etOrigin(), event.get())) |
882 return; | 855 return; |
883 | 856 |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1287 return m_frame->tree().top()->domWindow(); | 1260 return m_frame->tree().top()->domWindow(); |
1288 } | 1261 } |
1289 | 1262 |
1290 Document* DOMWindow::document() const | 1263 Document* DOMWindow::document() const |
1291 { | 1264 { |
1292 return m_document.get(); | 1265 return m_document.get(); |
1293 } | 1266 } |
1294 | 1267 |
1295 PassRefPtr<StyleMedia> DOMWindow::styleMedia() const | 1268 PassRefPtr<StyleMedia> DOMWindow::styleMedia() const |
1296 { | 1269 { |
1297 if (!isCurrentlyDisplayedInFrame()) | |
1298 return nullptr; | |
1299 if (!m_media) | 1270 if (!m_media) |
1300 m_media = StyleMedia::create(m_frame); | 1271 m_media = StyleMedia::create(m_frame); |
1301 return m_media.get(); | 1272 return m_media.get(); |
1302 } | 1273 } |
1303 | 1274 |
1304 PassRefPtr<CSSStyleDeclaration> DOMWindow::getComputedStyle(Element* elt, const String& pseudoElt) const | 1275 PassRefPtr<CSSStyleDeclaration> DOMWindow::getComputedStyle(Element* elt, const String& pseudoElt) const |
1305 { | 1276 { |
1306 if (!elt) | 1277 if (!elt) |
1307 return nullptr; | 1278 return nullptr; |
1308 | 1279 |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1845 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<DOMWindow>: :lifecycleNotifier()); | 1816 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<DOMWindow>: :lifecycleNotifier()); |
1846 } | 1817 } |
1847 | 1818 |
1848 PassOwnPtr<LifecycleNotifier<DOMWindow> > DOMWindow::createLifecycleNotifier() | 1819 PassOwnPtr<LifecycleNotifier<DOMWindow> > DOMWindow::createLifecycleNotifier() |
1849 { | 1820 { |
1850 return DOMWindowLifecycleNotifier::create(this); | 1821 return DOMWindowLifecycleNotifier::create(this); |
1851 } | 1822 } |
1852 | 1823 |
1853 | 1824 |
1854 } // namespace WebCore | 1825 } // namespace WebCore |
OLD | NEW |