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 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 OwnPtr<PostMessageTimer> timer(t); | 781 OwnPtr<PostMessageTimer> timer(t); |
782 | 782 |
783 if (!document() || !isCurrentlyDisplayedInFrame()) | 783 if (!document() || !isCurrentlyDisplayedInFrame()) |
784 return; | 784 return; |
785 | 785 |
786 RefPtr<MessageEvent> event = timer->event(); | 786 RefPtr<MessageEvent> event = timer->event(); |
787 | 787 |
788 // Give the embedder a chance to intercept this postMessage because this | 788 // Give the embedder a chance to intercept this postMessage because this |
789 // DOMWindow might be a proxy for another in browsers that support | 789 // DOMWindow might be a proxy for another in browsers that support |
790 // postMessage calls across WebKit instances. | 790 // postMessage calls across WebKit instances. |
791 if (m_frame->loader()->client()->willCheckAndDispatchMessageEvent(timer->tar
getOrigin(), event.get())) | 791 if (m_frame->loader().client()->willCheckAndDispatchMessageEvent(timer->targ
etOrigin(), event.get())) |
792 return; | 792 return; |
793 | 793 |
794 event->entangleMessagePorts(document()); | 794 event->entangleMessagePorts(document()); |
795 dispatchMessageEventWithOriginCheck(timer->targetOrigin(), event, timer->sta
ckTrace()); | 795 dispatchMessageEventWithOriginCheck(timer->targetOrigin(), event, timer->sta
ckTrace()); |
796 } | 796 } |
797 | 797 |
798 void DOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTarg
etOrigin, PassRefPtr<Event> event, PassRefPtr<ScriptCallStack> stackTrace) | 798 void DOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTarg
etOrigin, PassRefPtr<Event> event, PassRefPtr<ScriptCallStack> stackTrace) |
799 { | 799 { |
800 if (intendedTargetOrigin) { | 800 if (intendedTargetOrigin) { |
801 // Check target origin now since the target document may have changed si
nce the timer was scheduled. | 801 // Check target origin now since the target document may have changed si
nce the timer was scheduled. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 if (!activeDocument->canNavigate(m_frame)) | 878 if (!activeDocument->canNavigate(m_frame)) |
879 return; | 879 return; |
880 } | 880 } |
881 | 881 |
882 Settings* settings = m_frame->settings(); | 882 Settings* settings = m_frame->settings(); |
883 bool allowScriptsToCloseWindows = settings && settings->allowScriptsToCloseW
indows(); | 883 bool allowScriptsToCloseWindows = settings && settings->allowScriptsToCloseW
indows(); |
884 | 884 |
885 if (!(page->openedByDOM() || page->backForward().backForwardListCount() <= 1
|| allowScriptsToCloseWindows)) | 885 if (!(page->openedByDOM() || page->backForward().backForwardListCount() <= 1
|| allowScriptsToCloseWindows)) |
886 return; | 886 return; |
887 | 887 |
888 if (!m_frame->loader()->shouldClose()) | 888 if (!m_frame->loader().shouldClose()) |
889 return; | 889 return; |
890 | 890 |
891 page->chrome().closeWindowSoon(); | 891 page->chrome().closeWindowSoon(); |
892 } | 892 } |
893 | 893 |
894 void DOMWindow::print() | 894 void DOMWindow::print() |
895 { | 895 { |
896 if (!m_frame) | 896 if (!m_frame) |
897 return; | 897 return; |
898 | 898 |
899 Page* page = m_frame->page(); | 899 Page* page = m_frame->page(); |
900 if (!page) | 900 if (!page) |
901 return; | 901 return; |
902 | 902 |
903 if (m_frame->loader()->activeDocumentLoader()->isLoading()) { | 903 if (m_frame->loader().activeDocumentLoader()->isLoading()) { |
904 m_shouldPrintWhenFinishedLoading = true; | 904 m_shouldPrintWhenFinishedLoading = true; |
905 return; | 905 return; |
906 } | 906 } |
907 m_shouldPrintWhenFinishedLoading = false; | 907 m_shouldPrintWhenFinishedLoading = false; |
908 page->chrome().print(m_frame); | 908 page->chrome().print(m_frame); |
909 } | 909 } |
910 | 910 |
911 void DOMWindow::stop() | 911 void DOMWindow::stop() |
912 { | 912 { |
913 if (!m_frame) | 913 if (!m_frame) |
914 return; | 914 return; |
915 m_frame->loader()->stopAllLoaders(); | 915 m_frame->loader().stopAllLoaders(); |
916 } | 916 } |
917 | 917 |
918 void DOMWindow::alert(const String& message) | 918 void DOMWindow::alert(const String& message) |
919 { | 919 { |
920 if (!m_frame) | 920 if (!m_frame) |
921 return; | 921 return; |
922 | 922 |
923 m_frame->document()->updateStyleIfNeeded(); | 923 m_frame->document()->updateStyleIfNeeded(); |
924 | 924 |
925 Page* page = m_frame->page(); | 925 Page* page = m_frame->page(); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 | 1111 |
1112 return m_frame->tree().name(); | 1112 return m_frame->tree().name(); |
1113 } | 1113 } |
1114 | 1114 |
1115 void DOMWindow::setName(const String& string) | 1115 void DOMWindow::setName(const String& string) |
1116 { | 1116 { |
1117 if (!m_frame) | 1117 if (!m_frame) |
1118 return; | 1118 return; |
1119 | 1119 |
1120 m_frame->tree().setName(string); | 1120 m_frame->tree().setName(string); |
1121 m_frame->loader()->client()->didChangeName(string); | 1121 m_frame->loader().client()->didChangeName(string); |
1122 } | 1122 } |
1123 | 1123 |
1124 void DOMWindow::setStatus(const String& string) | 1124 void DOMWindow::setStatus(const String& string) |
1125 { | 1125 { |
1126 m_status = string; | 1126 m_status = string; |
1127 | 1127 |
1128 if (!m_frame) | 1128 if (!m_frame) |
1129 return; | 1129 return; |
1130 | 1130 |
1131 Page* page = m_frame->page(); | 1131 Page* page = m_frame->page(); |
(...skipping 25 matching lines...) Expand all Loading... |
1157 return 0; | 1157 return 0; |
1158 | 1158 |
1159 return m_frame->domWindow(); | 1159 return m_frame->domWindow(); |
1160 } | 1160 } |
1161 | 1161 |
1162 DOMWindow* DOMWindow::opener() const | 1162 DOMWindow* DOMWindow::opener() const |
1163 { | 1163 { |
1164 if (!m_frame) | 1164 if (!m_frame) |
1165 return 0; | 1165 return 0; |
1166 | 1166 |
1167 Frame* opener = m_frame->loader()->opener(); | 1167 Frame* opener = m_frame->loader().opener(); |
1168 if (!opener) | 1168 if (!opener) |
1169 return 0; | 1169 return 0; |
1170 | 1170 |
1171 return opener->domWindow(); | 1171 return opener->domWindow(); |
1172 } | 1172 } |
1173 | 1173 |
1174 DOMWindow* DOMWindow::parent() const | 1174 DOMWindow* DOMWindow::parent() const |
1175 { | 1175 { |
1176 if (!m_frame) | 1176 if (!m_frame) |
1177 return 0; | 1177 return 0; |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1475 if (NewDeviceOrientationController* controller = NewDeviceOrientationCon
troller::from(document())) | 1475 if (NewDeviceOrientationController* controller = NewDeviceOrientationCon
troller::from(document())) |
1476 controller->stopUpdating(); | 1476 controller->stopUpdating(); |
1477 } | 1477 } |
1478 | 1478 |
1479 return true; | 1479 return true; |
1480 } | 1480 } |
1481 | 1481 |
1482 void DOMWindow::dispatchLoadEvent() | 1482 void DOMWindow::dispatchLoadEvent() |
1483 { | 1483 { |
1484 RefPtr<Event> loadEvent(Event::create(EventTypeNames::load)); | 1484 RefPtr<Event> loadEvent(Event::create(EventTypeNames::load)); |
1485 if (m_frame && m_frame->loader()->documentLoader() && !m_frame->loader()->do
cumentLoader()->timing()->loadEventStart()) { | 1485 if (m_frame && m_frame->loader().documentLoader() && !m_frame->loader().docu
mentLoader()->timing()->loadEventStart()) { |
1486 // The DocumentLoader (and thus its DocumentLoadTiming) might get destro
yed while dispatching | 1486 // The DocumentLoader (and thus its DocumentLoadTiming) might get destro
yed while dispatching |
1487 // the event, so protect it to prevent writing the end time into freed m
emory. | 1487 // the event, so protect it to prevent writing the end time into freed m
emory. |
1488 RefPtr<DocumentLoader> documentLoader = m_frame->loader()->documentLoade
r(); | 1488 RefPtr<DocumentLoader> documentLoader = m_frame->loader().documentLoader
(); |
1489 DocumentLoadTiming* timing = documentLoader->timing(); | 1489 DocumentLoadTiming* timing = documentLoader->timing(); |
1490 timing->markLoadEventStart(); | 1490 timing->markLoadEventStart(); |
1491 dispatchEvent(loadEvent, document()); | 1491 dispatchEvent(loadEvent, document()); |
1492 timing->markLoadEventEnd(); | 1492 timing->markLoadEventEnd(); |
1493 } else | 1493 } else |
1494 dispatchEvent(loadEvent, document()); | 1494 dispatchEvent(loadEvent, document()); |
1495 | 1495 |
1496 // For load events, send a separate load event to the enclosing frame only. | 1496 // For load events, send a separate load event to the enclosing frame only. |
1497 // This is a DOM extension and is independent of bubbling/capturing rules of | 1497 // This is a DOM extension and is independent of bubbling/capturing rules of |
1498 // the DOM. | 1498 // the DOM. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1563 KURL completedURL = firstFrame->document()->completeURL(urlString); | 1563 KURL completedURL = firstFrame->document()->completeURL(urlString); |
1564 if (completedURL.isNull()) | 1564 if (completedURL.isNull()) |
1565 return; | 1565 return; |
1566 | 1566 |
1567 if (isInsecureScriptAccess(activeWindow, completedURL)) | 1567 if (isInsecureScriptAccess(activeWindow, completedURL)) |
1568 return; | 1568 return; |
1569 | 1569 |
1570 // We want a new history item if we are processing a user gesture. | 1570 // We want a new history item if we are processing a user gesture. |
1571 m_frame->navigationScheduler().scheduleLocationChange(activeDocument->securi
tyOrigin(), | 1571 m_frame->navigationScheduler().scheduleLocationChange(activeDocument->securi
tyOrigin(), |
1572 // FIXME: What if activeDocument()->frame() is 0? | 1572 // FIXME: What if activeDocument()->frame() is 0? |
1573 completedURL, activeDocument->frame()->loader()->outgoingReferrer(), | 1573 completedURL, activeDocument->frame()->loader().outgoingReferrer(), |
1574 locking != LockHistoryBasedOnGestureState); | 1574 locking != LockHistoryBasedOnGestureState); |
1575 } | 1575 } |
1576 | 1576 |
1577 void DOMWindow::printErrorMessage(const String& message) | 1577 void DOMWindow::printErrorMessage(const String& message) |
1578 { | 1578 { |
1579 if (message.isEmpty()) | 1579 if (message.isEmpty()) |
1580 return; | 1580 return; |
1581 | 1581 |
1582 pageConsole()->addMessage(JSMessageSource, ErrorMessageLevel, message); | 1582 pageConsole()->addMessage(JSMessageSource, ErrorMessageLevel, message); |
1583 } | 1583 } |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1708 return targetFrame->domWindow(); | 1708 return targetFrame->domWindow(); |
1709 | 1709 |
1710 if (urlString.isEmpty()) | 1710 if (urlString.isEmpty()) |
1711 return targetFrame->domWindow(); | 1711 return targetFrame->domWindow(); |
1712 | 1712 |
1713 // For whatever reason, Firefox uses the first window rather than the ac
tive window to | 1713 // For whatever reason, Firefox uses the first window rather than the ac
tive window to |
1714 // determine the outgoing referrer. We replicate that behavior here. | 1714 // determine the outgoing referrer. We replicate that behavior here. |
1715 targetFrame->navigationScheduler().scheduleLocationChange( | 1715 targetFrame->navigationScheduler().scheduleLocationChange( |
1716 activeDocument->securityOrigin(), | 1716 activeDocument->securityOrigin(), |
1717 completedURL, | 1717 completedURL, |
1718 firstFrame->loader()->outgoingReferrer(), | 1718 firstFrame->loader().outgoingReferrer(), |
1719 false); | 1719 false); |
1720 return targetFrame->domWindow(); | 1720 return targetFrame->domWindow(); |
1721 } | 1721 } |
1722 | 1722 |
1723 WindowFeatures windowFeatures(windowFeaturesString); | 1723 WindowFeatures windowFeatures(windowFeaturesString); |
1724 Frame* result = createWindow(urlString, frameName, windowFeatures, activeWin
dow, firstFrame, m_frame); | 1724 Frame* result = createWindow(urlString, frameName, windowFeatures, activeWin
dow, firstFrame, m_frame); |
1725 return result ? result->domWindow() : 0; | 1725 return result ? result->domWindow() : 0; |
1726 } | 1726 } |
1727 | 1727 |
1728 void DOMWindow::showModalDialog(const String& urlString, const String& dialogFea
turesString, | 1728 void DOMWindow::showModalDialog(const String& urlString, const String& dialogFea
turesString, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1767 return static_cast<DOMWindowLifecycleNotifier*>(LifecycleContext::lifecycleN
otifier()); | 1767 return static_cast<DOMWindowLifecycleNotifier*>(LifecycleContext::lifecycleN
otifier()); |
1768 } | 1768 } |
1769 | 1769 |
1770 PassOwnPtr<LifecycleNotifier> DOMWindow::createLifecycleNotifier() | 1770 PassOwnPtr<LifecycleNotifier> DOMWindow::createLifecycleNotifier() |
1771 { | 1771 { |
1772 return DOMWindowLifecycleNotifier::create(this); | 1772 return DOMWindowLifecycleNotifier::create(this); |
1773 } | 1773 } |
1774 | 1774 |
1775 | 1775 |
1776 } // namespace WebCore | 1776 } // namespace WebCore |
OLD | NEW |