2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #include "DOMWindow.h"
30 #include "AbstractDatabase.h"
31 #include "BackForwardController.h"
34 #include "BeforeUnloadEvent.h"
35 #include "CSSComputedStyleDeclaration.h"
36 #include "CSSRuleList.h"
37 #include "CSSStyleSelector.h"
41 #include "DOMApplicationCache.h"
42 #include "DOMSelection.h"
43 #include "DOMSettableTokenList.h"
44 #include "DOMStringList.h"
46 #include "DOMTokenList.h"
49 #include "DatabaseCallback.h"
50 #include "DeviceMotionController.h"
51 #include "DeviceOrientationController.h"
53 #include "DocumentLoader.h"
55 #include "EventException.h"
56 #include "EventListener.h"
57 #include "EventNames.h"
58 #include "ExceptionCode.h"
59 #include "FloatRect.h"
61 #include "FrameLoadRequest.h"
62 #include "FrameLoader.h"
63 #include "FrameTree.h"
64 #include "FrameView.h"
65 #include "HTMLFrameOwnerElement.h"
67 #include "IDBFactory.h"
68 #include "IDBFactoryBackendInterface.h"
69 #include "InspectorInstrumentation.h"
72 #include "MediaQueryList.h"
73 #include "MediaQueryMatcher.h"
74 #include "MessageEvent.h"
75 #include "Navigator.h"
76 #include "NotificationCenter.h"
78 #include "PageGroup.h"
79 #include "PageTransitionEvent.h"
80 #include "Performance.h"
81 #include "PlatformScreen.h"
82 #include "PlatformString.h"
84 #include "SecurityOrigin.h"
85 #include "SerializedScriptValue.h"
88 #include "StorageArea.h"
89 #include "StorageNamespace.h"
90 #include "StyleMedia.h"
91 #include "SuddenTermination.h"
92 #include "WebKitPoint.h"
93 #include "WindowFeatures.h"
95 #include <wtf/CurrentTime.h>
96 #include <wtf/MathExtras.h>
97 #include <wtf/text/StringConcatenate.h>
99 #if ENABLE(FILE_SYSTEM)
100 #include "AsyncFileSystem.h"
101 #include "DOMFileSystem.h"
102 #include "DOMFileSystemBase.h"
103 #include "EntryCallback.h"
104 #include "ErrorCallback.h"
105 #include "FileError.h"
106 #include "FileSystemCallback.h"
107 #include "FileSystemCallbacks.h"
108 #include "LocalFileSystem.h"
111 #if ENABLE(REQUEST_ANIMATION_FRAME)
112 #include "RequestAnimationFrameCallback.h"
120 class PostMessageTimer : public TimerBase {
122 PostMessageTimer(DOMWindow* window, PassRefPtr<SerializedScriptValue> message, const String& sourceOrigin, PassRefPtr<DOMWindow> source, PassOwnPtr<MessagePortChannelArray> channels, SecurityOrigin* targetOrigin)
125 , m_origin(sourceOrigin)
127 , m_channels(channels)
128 , m_targetOrigin(targetOrigin)
132 PassRefPtr<MessageEvent> event(ScriptExecutionContext* context)
134 OwnPtr<MessagePortArray> messagePorts = MessagePort::entanglePorts(*context, m_channels.release());
135 return MessageEvent::create(messagePorts.release(), m_message, m_origin, "", m_source);
137 SecurityOrigin* targetOrigin() const { return m_targetOrigin.get(); }
142 m_window->postMessageTimerFired(this);
145 RefPtr<DOMWindow> m_window;
146 RefPtr<SerializedScriptValue> m_message;
148 RefPtr<DOMWindow> m_source;
149 OwnPtr<MessagePortChannelArray> m_channels;
150 RefPtr<SecurityOrigin> m_targetOrigin;
153 typedef HashCountedSet<DOMWindow*> DOMWindowSet;
155 static DOMWindowSet& windowsWithUnloadEventListeners()
157 DEFINE_STATIC_LOCAL(DOMWindowSet, windowsWithUnloadEventListeners, ());
158 return windowsWithUnloadEventListeners;
161 static DOMWindowSet& windowsWithBeforeUnloadEventListeners()
163 DEFINE_STATIC_LOCAL(DOMWindowSet, windowsWithBeforeUnloadEventListeners, ());
164 return windowsWithBeforeUnloadEventListeners;
167 static void addUnloadEventListener(DOMWindow* domWindow)
169 DOMWindowSet& set = windowsWithUnloadEventListeners();
171 disableSuddenTermination();
175 static void removeUnloadEventListener(DOMWindow* domWindow)
177 DOMWindowSet& set = windowsWithUnloadEventListeners();
178 DOMWindowSet::iterator it = set.find(domWindow);
183 enableSuddenTermination();
186 static void removeAllUnloadEventListeners(DOMWindow* domWindow)
188 DOMWindowSet& set = windowsWithUnloadEventListeners();
189 DOMWindowSet::iterator it = set.find(domWindow);
194 enableSuddenTermination();
197 static void addBeforeUnloadEventListener(DOMWindow* domWindow)
199 DOMWindowSet& set = windowsWithBeforeUnloadEventListeners();
201 disableSuddenTermination();
205 static void removeBeforeUnloadEventListener(DOMWindow* domWindow)
207 DOMWindowSet& set = windowsWithBeforeUnloadEventListeners();
208 DOMWindowSet::iterator it = set.find(domWindow);
213 enableSuddenTermination();
216 static void removeAllBeforeUnloadEventListeners(DOMWindow* domWindow)
218 DOMWindowSet& set = windowsWithBeforeUnloadEventListeners();
219 DOMWindowSet::iterator it = set.find(domWindow);
224 enableSuddenTermination();
227 static bool allowsBeforeUnloadListeners(DOMWindow* window)
229 ASSERT_ARG(window, window);
230 Frame* frame = window->frame();
233 Page* page = frame->page();
236 return frame == page->mainFrame();
239 bool DOMWindow::dispatchAllPendingBeforeUnloadEvents()
241 DOMWindowSet& set = windowsWithBeforeUnloadEventListeners();
245 static bool alreadyDispatched = false;
246 ASSERT(!alreadyDispatched);
247 if (alreadyDispatched)
250 Vector<RefPtr<DOMWindow> > windows;
251 DOMWindowSet::iterator end = set.end();
252 for (DOMWindowSet::iterator it = set.begin(); it != end; ++it)
253 windows.append(it->first);
255 size_t size = windows.size();
256 for (size_t i = 0; i < size; ++i) {
257 DOMWindow* window = windows[i].get();
258 if (!set.contains(window))
261 Frame* frame = window->frame();
265 if (!frame->loader()->shouldClose())
269 enableSuddenTermination();
271 alreadyDispatched = true;
276 unsigned DOMWindow::pendingUnloadEventListeners() const
278 return windowsWithUnloadEventListeners().count(const_cast<DOMWindow*>(this));
281 void DOMWindow::dispatchAllPendingUnloadEvents()
283 DOMWindowSet& set = windowsWithUnloadEventListeners();
287 static bool alreadyDispatched = false;
288 ASSERT(!alreadyDispatched);
289 if (alreadyDispatched)
292 Vector<RefPtr<DOMWindow> > windows;
293 DOMWindowSet::iterator end = set.end();
294 for (DOMWindowSet::iterator it = set.begin(); it != end; ++it)
295 windows.append(it->first);
297 size_t size = windows.size();
298 for (size_t i = 0; i < size; ++i) {
299 DOMWindow* window = windows[i].get();
300 if (!set.contains(window))
303 window->dispatchEvent(PageTransitionEvent::create(eventNames().pagehideEvent, false), window->document());
304 window->dispatchEvent(Event::create(eventNames().unloadEvent, false, false), window->document());
307 enableSuddenTermination();
309 alreadyDispatched = true;
313 // 1) Validates the pending changes are not changing to NaN
314 // 2) Constrains the window rect to no smaller than 100 in each dimension and no
315 // bigger than the the float rect's dimensions.
316 // 3) Constrain window rect to within the top and left boundaries of the screen rect
317 // 4) Constraint the window rect to within the bottom and right boundaries of the
319 // 5) Translate the window rect coordinates to be within the coordinate space of
321 void DOMWindow::adjustWindowRect(const FloatRect& screen, FloatRect& window, const FloatRect& pendingChanges)
323 // Make sure we're in a valid state before adjusting dimensions.
324 ASSERT(isfinite(screen.x()));
325 ASSERT(isfinite(screen.y()));
326 ASSERT(isfinite(screen.width()));
327 ASSERT(isfinite(screen.height()));
328 ASSERT(isfinite(window.x()));
329 ASSERT(isfinite(window.y()));
330 ASSERT(isfinite(window.width()));
331 ASSERT(isfinite(window.height()));
333 // Update window values if new requested values are not NaN.
334 if (!isnan(pendingChanges.x()))
335 window.setX(pendingChanges.x());
336 if (!isnan(pendingChanges.y()))
337 window.setY(pendingChanges.y());
338 if (!isnan(pendingChanges.width()))
339 window.setWidth(pendingChanges.width());
340 if (!isnan(pendingChanges.height()))
341 window.setHeight(pendingChanges.height());
343 // Resize the window to between 100 and the screen width and height.
344 window.setWidth(min(max(100.0f, window.width()), screen.width()));
345 window.setHeight(min(max(100.0f, window.height()), screen.height()));
347 // Constrain the window position to the screen.
348 window.setX(max(screen.x(), min(window.x(), screen.maxX() - window.width())));
349 window.setY(max(screen.y(), min(window.y(), screen.maxY() - window.height())));
352 // FIXME: We can remove this function once V8 showModalDialog is changed to use DOMWindow.
353 void DOMWindow::parseModalDialogFeatures(const String& string, HashMap<String, String>& map)
355 WindowFeatures::parseDialogFeatures(string, map);
358 bool DOMWindow::allowPopUp(Frame* firstFrame)
362 if (ScriptController::processingUserGesture())
365 Settings* settings = firstFrame->settings();
366 return settings && settings->javaScriptCanOpenWindowsAutomatically();
369 bool DOMWindow::allowPopUp()
371 return m_frame && allowPopUp(m_frame);
374 bool DOMWindow::canShowModalDialog(const Frame* frame)
378 Page* page = frame->page();
381 return page->chrome()->canRunModal();
384 bool DOMWindow::canShowModalDialogNow(const Frame* frame)
388 Page* page = frame->page();
391 return page->chrome()->canRunModalNow();
394 DOMWindow::DOMWindow(Frame* frame)
395 : m_shouldPrintWhenFinishedLoading(false)
397 , m_printTimer(this, &DOMWindow::printTimerFired)
401 DOMWindow::~DOMWindow()
404 m_frame->clearFormerDOMWindow(this);
406 removeAllUnloadEventListeners(this);
407 removeAllBeforeUnloadEventListeners(this);
410 ScriptExecutionContext* DOMWindow::scriptExecutionContext() const
415 PassRefPtr<MediaQueryList> DOMWindow::matchMedia(const String& media)
417 return document() ? document()->mediaQueryMatcher()->matchMedia(media) : 0;
420 void DOMWindow::disconnectFrame()
426 void DOMWindow::clear()
429 m_screen->disconnectFrame();
433 m_selection->disconnectFrame();
437 m_history->disconnectFrame();
443 m_locationbar->disconnectFrame();
447 m_menubar->disconnectFrame();
451 m_personalbar->disconnectFrame();
455 m_scrollbars->disconnectFrame();
459 m_statusbar->disconnectFrame();
463 m_toolbar->disconnectFrame();
467 m_console->disconnectFrame();
471 m_navigator->disconnectFrame();
474 #if ENABLE(WEB_TIMING)
476 m_performance->disconnectFrame();
481 m_location->disconnectFrame();
485 m_media->disconnectFrame();
488 #if ENABLE(DOM_STORAGE)
489 if (m_sessionStorage)
490 m_sessionStorage->disconnectFrame();
491 m_sessionStorage = 0;
494 m_localStorage->disconnectFrame();
498 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
499 if (m_applicationCache)
500 m_applicationCache->disconnectFrame();
501 m_applicationCache = 0;
504 #if ENABLE(NOTIFICATIONS)
506 m_notifications->disconnectFrame();
510 #if ENABLE(INDEXED_DATABASE)
515 #if ENABLE(ORIENTATION_EVENTS)
516 int DOMWindow::orientation() const
521 return m_frame->orientation();
525 Screen* DOMWindow::screen() const
528 m_screen = Screen::create(m_frame);
529 return m_screen.get();
532 History* DOMWindow::history() const
535 m_history = History::create(m_frame);
536 return m_history.get();
539 Crypto* DOMWindow::crypto() const
542 m_crypto = Crypto::create();
543 return m_crypto.get();
546 BarInfo* DOMWindow::locationbar() const
549 m_locationbar = BarInfo::create(m_frame, BarInfo::Locationbar);
550 return m_locationbar.get();
553 BarInfo* DOMWindow::menubar() const
556 m_menubar = BarInfo::create(m_frame, BarInfo::Menubar);
557 return m_menubar.get();
560 BarInfo* DOMWindow::personalbar() const
563 m_personalbar = BarInfo::create(m_frame, BarInfo::Personalbar);
564 return m_personalbar.get();
567 BarInfo* DOMWindow::scrollbars() const
570 m_scrollbars = BarInfo::create(m_frame, BarInfo::Scrollbars);
571 return m_scrollbars.get();
574 BarInfo* DOMWindow::statusbar() const
577 m_statusbar = BarInfo::create(m_frame, BarInfo::Statusbar);
578 return m_statusbar.get();
581 BarInfo* DOMWindow::toolbar() const
584 m_toolbar = BarInfo::create(m_frame, BarInfo::Toolbar);
585 return m_toolbar.get();
588 Console* DOMWindow::console() const
591 m_console = Console::create(m_frame);
592 return m_console.get();
595 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
596 DOMApplicationCache* DOMWindow::applicationCache() const
598 if (!m_applicationCache)
599 m_applicationCache = DOMApplicationCache::create(m_frame);
600 return m_applicationCache.get();
604 Navigator* DOMWindow::navigator() const
607 m_navigator = Navigator::create(m_frame);
608 return m_navigator.get();
611 #if ENABLE(WEB_TIMING)
612 Performance* DOMWindow::performance() const
615 m_performance = Performance::create(m_frame);
616 return m_performance.get();
620 Location* DOMWindow::location() const
623 m_location = Location::create(m_frame);
624 return m_location.get();
627 #if ENABLE(DOM_STORAGE)
628 Storage* DOMWindow::sessionStorage(ExceptionCode& ec) const
630 if (m_sessionStorage)
631 return m_sessionStorage.get();
633 Document* document = this->document();
637 if (!document->securityOrigin()->canAccessLocalStorage()) {
642 Page* page = document->page();
646 RefPtr<StorageArea> storageArea = page->sessionStorage()->storageArea(document->securityOrigin());
647 InspectorInstrumentation::didUseDOMStorage(page, storageArea.get(), false, m_frame);
649 m_sessionStorage = Storage::create(m_frame, storageArea.release());
650 return m_sessionStorage.get();
653 Storage* DOMWindow::localStorage(ExceptionCode& ec) const
656 return m_localStorage.get();
658 Document* document = this->document();
662 if (!document->securityOrigin()->canAccessLocalStorage()) {
667 Page* page = document->page();
671 if (!page->settings()->localStorageEnabled())
674 RefPtr<StorageArea> storageArea = page->group().localStorage()->storageArea(document->securityOrigin());
675 InspectorInstrumentation::didUseDOMStorage(page, storageArea.get(), true, m_frame);
677 m_localStorage = Storage::create(m_frame, storageArea.release());
678 return m_localStorage.get();
682 #if ENABLE(NOTIFICATIONS)
683 NotificationCenter* DOMWindow::webkitNotifications() const
686 return m_notifications.get();
688 Document* document = this->document();
692 Page* page = document->page();
696 NotificationPresenter* provider = page->chrome()->notificationPresenter();
698 m_notifications = NotificationCenter::create(document, provider);
700 return m_notifications.get();
704 void DOMWindow::pageDestroyed()
706 #if ENABLE(NOTIFICATIONS)
707 // Clearing Notifications requests involves accessing the client so it must be done
708 // before the frame is detached.
710 m_notifications->disconnectFrame();
715 void DOMWindow::resetGeolocation()
717 // Geolocation should cancel activities and permission requests when the page is detached.
719 m_navigator->resetGeolocation();
722 #if ENABLE(INDEXED_DATABASE)
723 IDBFactory* DOMWindow::webkitIndexedDB() const
726 return m_idbFactory.get();
728 Document* document = this->document();
732 // FIXME: See if access is allowed.
734 Page* page = document->page();
738 // FIXME: See if indexedDatabase access is allowed.
740 m_idbFactory = IDBFactory::create(page->group().idbFactory());
741 return m_idbFactory.get();
745 #if ENABLE(FILE_SYSTEM)
746 void DOMWindow::requestFileSystem(int type, long long size, PassRefPtr<FileSystemCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
748 Document* document = this->document();
752 if (!AsyncFileSystem::isAvailable() || !document->securityOrigin()->canAccessFileSystem()) {
753 DOMFileSystem::scheduleCallback(document, errorCallback, FileError::create(FileError::SECURITY_ERR));
757 AsyncFileSystem::Type fileSystemType = static_cast<AsyncFileSystem::Type>(type);
758 if (fileSystemType != AsyncFileSystem::Temporary && fileSystemType != AsyncFileSystem::Persistent) {
759 DOMFileSystem::scheduleCallback(document, errorCallback, FileError::create(FileError::INVALID_MODIFICATION_ERR));
763 LocalFileSystem::localFileSystem().requestFileSystem(document, fileSystemType, size, FileSystemCallbacks::create(successCallback, errorCallback, document), false);
766 void DOMWindow::resolveLocalFileSystemURL(const String& url, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
768 Document* document = this->document();
772 SecurityOrigin* securityOrigin = document->securityOrigin();
773 KURL completedURL = document->completeURL(url);
774 if (!AsyncFileSystem::isAvailable() || !securityOrigin->canAccessFileSystem() || !securityOrigin->canRequest(completedURL)) {
775 DOMFileSystem::scheduleCallback(document, errorCallback, FileError::create(FileError::SECURITY_ERR));
779 AsyncFileSystem::Type type;
781 if (!completedURL.isValid() || !DOMFileSystemBase::crackFileSystemURL(completedURL, type, filePath)) {
782 DOMFileSystem::scheduleCallback(document, errorCallback, FileError::create(FileError::ENCODING_ERR));
786 LocalFileSystem::localFileSystem().readFileSystem(document, type, ResolveURICallbacks::create(successCallback, errorCallback, document, filePath));
789 COMPILE_ASSERT(static_cast<int>(DOMWindow::TEMPORARY) == static_cast<int>(AsyncFileSystem::Temporary), enum_mismatch);
790 COMPILE_ASSERT(static_cast<int>(DOMWindow::PERSISTENT) == static_cast<int>(AsyncFileSystem::Persistent), enum_mismatch);
794 void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, MessagePort* port, const String& targetOrigin, DOMWindow* source, ExceptionCode& ec)
796 MessagePortArray ports;
799 postMessage(message, &ports, targetOrigin, source, ec);
802 void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, const String& targetOrigin, DOMWindow* source, ExceptionCode& ec)
807 // Compute the target origin. We need to do this synchronously in order
808 // to generate the SYNTAX_ERR exception correctly.
809 RefPtr<SecurityOrigin> target;
810 if (targetOrigin != "*") {
811 target = SecurityOrigin::createFromString(targetOrigin);
812 if (target->isEmpty()) {
818 OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(ports, ec);
822 // Capture the source of the message. We need to do this synchronously
823 // in order to capture the source of the message correctly.
824 Document* sourceDocument = source->document();
827 String sourceOrigin = sourceDocument->securityOrigin()->toString();
829 // Schedule the message.
830 PostMessageTimer* timer = new PostMessageTimer(this, message, sourceOrigin, source, channels.release(), target.get());
831 timer->startOneShot(0);
834 void DOMWindow::postMessageTimerFired(PostMessageTimer* t)
836 OwnPtr<PostMessageTimer> timer(t);
841 if (timer->targetOrigin()) {
842 // Check target origin now since the target document may have changed since the simer was scheduled.
843 if (!timer->targetOrigin()->isSameSchemeHostPort(document()->securityOrigin())) {
844 String message = makeString("Unable to post message to ", timer->targetOrigin()->toString(),
845 ". Recipient has origin ", document()->securityOrigin()->toString(), ".\n");
846 console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message, 0, String());
851 dispatchEvent(timer->event(document()));
854 DOMSelection* DOMWindow::getSelection()
857 m_selection = DOMSelection::create(m_frame);
858 return m_selection.get();
861 Element* DOMWindow::frameElement() const
866 return m_frame->ownerElement();
869 void DOMWindow::focus()
874 Page* page = m_frame->page();
878 // If we're a top level window, bring the window to the front.
879 if (m_frame == page->mainFrame())
880 page->chrome()->focus();
885 m_frame->eventHandler()->focusDocumentView();
888 void DOMWindow::blur()
893 Page* page = m_frame->page();
897 if (m_frame != page->mainFrame())
900 page->chrome()->unfocus();
903 void DOMWindow::close(ScriptExecutionContext* context)
908 Page* page = m_frame->page();
912 if (m_frame != page->mainFrame())
916 ASSERT(WTF::isMainThread());
917 Frame* activeFrame = static_cast<Document*>(context)->frame();
921 if (!activeFrame->loader()->shouldAllowNavigation(m_frame))
925 Settings* settings = m_frame->settings();
926 bool allowScriptsToCloseWindows = settings && settings->allowScriptsToCloseWindows();
928 if (!(page->openedByDOM() || page->backForward()->count() <= 1 || allowScriptsToCloseWindows))
931 if (!m_frame->loader()->shouldClose())
934 page->chrome()->closeWindowSoon();
937 void DOMWindow::print()
942 Page* page = m_frame->page();
946 if (m_frame->loader()->activeDocumentLoader()->isLoading()) {
947 m_shouldPrintWhenFinishedLoading = true;
950 m_shouldPrintWhenFinishedLoading = false;
951 page->chrome()->print(m_frame);
954 void DOMWindow::printTimerFired(Timer<DOMWindow>* timer)
956 ASSERT_UNUSED(timer, timer == &m_printTimer);
960 void DOMWindow::stop()
965 // We must check whether the load is complete asynchronously, because we might still be parsing
966 // the document until the callstack unwinds.
967 m_frame->loader()->stopForUserCancel(true);
970 void DOMWindow::alert(const String& message)
975 m_frame->document()->updateStyleIfNeeded();
977 Page* page = m_frame->page();
981 page->chrome()->runJavaScriptAlert(m_frame, message);
984 bool DOMWindow::confirm(const String& message)
989 m_frame->document()->updateStyleIfNeeded();
991 Page* page = m_frame->page();
995 return page->chrome()->runJavaScriptConfirm(m_frame, message);
998 String DOMWindow::prompt(const String& message, const String& defaultValue)
1003 m_frame->document()->updateStyleIfNeeded();
1005 Page* page = m_frame->page();
1010 if (page->chrome()->runJavaScriptPrompt(m_frame, message, defaultValue, returnValue))
1016 String DOMWindow::btoa(const String& stringToEncode, ExceptionCode& ec)
1018 if (stringToEncode.isNull())
1021 if (!stringToEncode.containsOnlyLatin1()) {
1022 ec = INVALID_CHARACTER_ERR;
1026 return base64Encode(stringToEncode.latin1());
1029 String DOMWindow::atob(const String& encodedString, ExceptionCode& ec)
1031 if (encodedString.isNull())
1034 if (!encodedString.containsOnlyLatin1()) {
1035 ec = INVALID_CHARACTER_ERR;
1040 if (!base64Decode(encodedString, out, FailOnInvalidCharacter)) {
1041 ec = INVALID_CHARACTER_ERR;
1045 return String(out.data(), out.size());
1048 bool DOMWindow::find(const String& string, bool caseSensitive, bool backwards, bool wrap, bool /*wholeWord*/, bool /*searchInFrames*/, bool /*showDialog*/) const
1053 // FIXME (13016): Support wholeWord, searchInFrames and showDialog
1054 return m_frame->editor()->findString(string, !backwards, caseSensitive, wrap, false);
1057 bool DOMWindow::offscreenBuffering() const
1062 int DOMWindow::outerHeight() const
1067 Page* page = m_frame->page();
1071 return static_cast<int>(page->chrome()->windowRect().height());
1074 int DOMWindow::outerWidth() const
1079 Page* page = m_frame->page();
1083 return static_cast<int>(page->chrome()->windowRect().width());
1086 int DOMWindow::innerHeight() const
1091 FrameView* view = m_frame->view();
1095 #if PLATFORM(ANDROID)
1096 return static_cast<int>(view->actualHeight() / m_frame->pageZoomFactor());
1098 return static_cast<int>(view->height() / m_frame->pageZoomFactor());
1102 int DOMWindow::innerWidth() const
1107 FrameView* view = m_frame->view();
1111 #if PLATFORM(ANDROID)
1112 return static_cast<int>(view->actualWidth() / m_frame->pageZoomFactor());
1114 return static_cast<int>(view->width() / m_frame->pageZoomFactor());
1118 int DOMWindow::screenX() const
1123 Page* page = m_frame->page();
1127 return static_cast<int>(page->chrome()->windowRect().x());
1130 int DOMWindow::screenY() const
1135 Page* page = m_frame->page();
1139 return static_cast<int>(page->chrome()->windowRect().y());
1142 int DOMWindow::scrollX() const
1147 FrameView* view = m_frame->view();
1151 m_frame->document()->updateLayoutIgnorePendingStylesheets();
1153 #if PLATFORM(ANDROID)
1154 return static_cast<int>(view->actualScrollX() / m_frame->pageZoomFactor());
1156 return static_cast<int>(view->scrollX() / m_frame->pageZoomFactor());
1160 int DOMWindow::scrollY() const
1165 FrameView* view = m_frame->view();
1169 m_frame->document()->updateLayoutIgnorePendingStylesheets();
1171 #if PLATFORM(ANDROID)
1172 return static_cast<int>(view->actualScrollY() / m_frame->pageZoomFactor());
1174 return static_cast<int>(view->scrollY() / m_frame->pageZoomFactor());
1178 bool DOMWindow::closed() const
1183 unsigned DOMWindow::length() const
1188 return m_frame->tree()->childCount();
1191 String DOMWindow::name() const
1196 return m_frame->tree()->name();
1199 void DOMWindow::setName(const String& string)
1204 m_frame->tree()->setName(string);
1207 void DOMWindow::setStatus(const String& string)
1214 Page* page = m_frame->page();
1218 ASSERT(m_frame->document()); // Client calls shouldn't be made when the frame is in inconsistent state.
1219 page->chrome()->setStatusbarText(m_frame, m_status);
1222 void DOMWindow::setDefaultStatus(const String& string)
1224 m_defaultStatus = string;
1229 Page* page = m_frame->page();
1233 ASSERT(m_frame->document()); // Client calls shouldn't be made when the frame is in inconsistent state.
1234 page->chrome()->setStatusbarText(m_frame, m_defaultStatus);
1237 DOMWindow* DOMWindow::self() const
1242 return m_frame->domWindow();
1245 DOMWindow* DOMWindow::opener() const
1250 Frame* opener = m_frame->loader()->opener();
1254 return opener->domWindow();
1257 DOMWindow* DOMWindow::parent() const
1262 Frame* parent = m_frame->tree()->parent(true);
1264 return parent->domWindow();
1266 return m_frame->domWindow();
1269 DOMWindow* DOMWindow::top() const
1274 Page* page = m_frame->page();
1278 return m_frame->tree()->top(true)->domWindow();
1281 Document* DOMWindow::document() const
1283 // FIXME: This function shouldn't need a frame to work.
1287 // The m_frame pointer is not zeroed out when the window is put into b/f cache, so it can hold an unrelated document/window pair.
1288 // FIXME: We should always zero out the frame pointer on navigation to avoid accidentally accessing the new frame content.
1289 if (m_frame->domWindow() != this)
1292 ASSERT(m_frame->document());
1293 return m_frame->document();
1296 PassRefPtr<StyleMedia> DOMWindow::styleMedia() const
1299 m_media = StyleMedia::create(m_frame);
1300 return m_media.get();
1303 PassRefPtr<CSSStyleDeclaration> DOMWindow::getComputedStyle(Element* elt, const String& pseudoElt) const
1308 return computedStyle(elt, false, pseudoElt);
1311 PassRefPtr<CSSRuleList> DOMWindow::getMatchedCSSRules(Element* elt, const String&, bool authorOnly) const
1316 Settings* settings = m_frame->settings();
1317 return m_frame->document()->styleSelector()->styleRulesForElement(elt, authorOnly, false, settings && settings->crossOriginCheckInGetMatchedCSSRulesDisabled() ? AllCSSRules : SameOriginCSSRulesOnly);
1320 PassRefPtr<WebKitPoint> DOMWindow::webkitConvertPointFromNodeToPage(Node* node, const WebKitPoint* p) const
1325 m_frame->document()->updateLayoutIgnorePendingStylesheets();
1327 FloatPoint pagePoint(p->x(), p->y());
1328 pagePoint = node->convertToPage(pagePoint);
1329 return WebKitPoint::create(pagePoint.x(), pagePoint.y());
1332 PassRefPtr<WebKitPoint> DOMWindow::webkitConvertPointFromPageToNode(Node* node, const WebKitPoint* p) const
1337 m_frame->document()->updateLayoutIgnorePendingStylesheets();
1339 FloatPoint nodePoint(p->x(), p->y());
1340 nodePoint = node->convertFromPage(nodePoint);
1341 return WebKitPoint::create(nodePoint.x(), nodePoint.y());
1344 double DOMWindow::devicePixelRatio() const
1349 Page* page = m_frame->page();
1353 return page->chrome()->scaleFactor();
1356 #if ENABLE(DATABASE)
1357 PassRefPtr<Database> DOMWindow::openDatabase(const String& name, const String& version, const String& displayName, unsigned long estimatedSize, PassRefPtr<DatabaseCallback> creationCallback, ExceptionCode& ec)
1359 RefPtr<Database> database = 0;
1360 if (m_frame && AbstractDatabase::isAvailable() && m_frame->document()->securityOrigin()->canAccessDatabase())
1361 database = Database::openDatabase(m_frame->document(), name, version, displayName, estimatedSize, creationCallback, ec);
1363 if (!database && !ec)
1370 void DOMWindow::scrollBy(int x, int y) const
1375 m_frame->document()->updateLayoutIgnorePendingStylesheets();
1377 RefPtr<FrameView> view = m_frame->view();
1381 view->scrollBy(IntSize(x, y));
1384 void DOMWindow::scrollTo(int x, int y) const
1389 m_frame->document()->updateLayoutIgnorePendingStylesheets();
1391 RefPtr<FrameView> view = m_frame->view();
1395 int zoomedX = static_cast<int>(x * m_frame->pageZoomFactor());
1396 int zoomedY = static_cast<int>(y * m_frame->pageZoomFactor());
1397 view->setScrollPosition(IntPoint(zoomedX, zoomedY));
1400 void DOMWindow::moveBy(float x, float y) const
1405 Page* page = m_frame->page();
1409 if (m_frame != page->mainFrame())
1412 FloatRect fr = page->chrome()->windowRect();
1413 FloatRect update = fr;
1415 // Security check (the spec talks about UniversalBrowserWrite to disable this check...)
1416 adjustWindowRect(screenAvailableRect(page->mainFrame()->view()), fr, update);
1417 page->chrome()->setWindowRect(fr);
1420 void DOMWindow::moveTo(float x, float y) const
1425 Page* page = m_frame->page();
1429 if (m_frame != page->mainFrame())
1432 FloatRect fr = page->chrome()->windowRect();
1433 FloatRect sr = screenAvailableRect(page->mainFrame()->view());
1434 fr.setLocation(sr.location());
1435 FloatRect update = fr;
1437 // Security check (the spec talks about UniversalBrowserWrite to disable this check...)
1438 adjustWindowRect(sr, fr, update);
1439 page->chrome()->setWindowRect(fr);
1442 void DOMWindow::resizeBy(float x, float y) const
1447 Page* page = m_frame->page();
1451 if (m_frame != page->mainFrame())
1454 FloatRect fr = page->chrome()->windowRect();
1455 FloatSize dest = fr.size() + FloatSize(x, y);
1456 FloatRect update(fr.location(), dest);
1457 adjustWindowRect(screenAvailableRect(page->mainFrame()->view()), fr, update);
1458 page->chrome()->setWindowRect(fr);
1461 void DOMWindow::resizeTo(float width, float height) const
1466 Page* page = m_frame->page();
1470 if (m_frame != page->mainFrame())
1473 FloatRect fr = page->chrome()->windowRect();
1474 FloatSize dest = FloatSize(width, height);
1475 FloatRect update(fr.location(), dest);
1476 adjustWindowRect(screenAvailableRect(page->mainFrame()->view()), fr, update);
1477 page->chrome()->setWindowRect(fr);
1480 int DOMWindow::setTimeout(PassOwnPtr<ScheduledAction> action, int timeout, ExceptionCode& ec)
1482 ScriptExecutionContext* context = scriptExecutionContext();
1484 ec = INVALID_ACCESS_ERR;
1487 return DOMTimer::install(context, action, timeout, true);
1490 void DOMWindow::clearTimeout(int timeoutId)
1492 ScriptExecutionContext* context = scriptExecutionContext();
1495 DOMTimer::removeById(context, timeoutId);
1498 int DOMWindow::setInterval(PassOwnPtr<ScheduledAction> action, int timeout, ExceptionCode& ec)
1500 ScriptExecutionContext* context = scriptExecutionContext();
1502 ec = INVALID_ACCESS_ERR;
1505 return DOMTimer::install(context, action, timeout, false);
1508 void DOMWindow::clearInterval(int timeoutId)
1510 ScriptExecutionContext* context = scriptExecutionContext();
1513 DOMTimer::removeById(context, timeoutId);
1516 #if ENABLE(REQUEST_ANIMATION_FRAME)
1517 int DOMWindow::webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback> callback, Element* e)
1519 if (Document* d = document())
1520 return d->webkitRequestAnimationFrame(callback, e);
1524 void DOMWindow::webkitCancelRequestAnimationFrame(int id)
1526 if (Document* d = document())
1527 d->webkitCancelRequestAnimationFrame(id);
1531 bool DOMWindow::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture)
1533 if (!EventTarget::addEventListener(eventType, listener, useCapture))
1536 if (Document* document = this->document())
1537 document->addListenerTypeIfNeeded(eventType);
1539 if (eventType == eventNames().unloadEvent)
1540 addUnloadEventListener(this);
1541 else if (eventType == eventNames().beforeunloadEvent && allowsBeforeUnloadListeners(this))
1542 addBeforeUnloadEventListener(this);
1543 #if ENABLE(DEVICE_ORIENTATION)
1544 else if (eventType == eventNames().devicemotionEvent && frame() && frame()->page() && frame()->page()->deviceMotionController())
1545 frame()->page()->deviceMotionController()->addListener(this);
1546 else if (eventType == eventNames().deviceorientationEvent && frame() && frame()->page() && frame()->page()->deviceOrientationController())
1547 frame()->page()->deviceOrientationController()->addListener(this);
1553 bool DOMWindow::removeEventListener(const AtomicString& eventType, EventListener* listener, bool useCapture)
1555 if (!EventTarget::removeEventListener(eventType, listener, useCapture))
1558 if (eventType == eventNames().unloadEvent)
1559 removeUnloadEventListener(this);
1560 else if (eventType == eventNames().beforeunloadEvent && allowsBeforeUnloadListeners(this))
1561 removeBeforeUnloadEventListener(this);
1562 #if ENABLE(DEVICE_ORIENTATION)
1563 else if (eventType == eventNames().devicemotionEvent && frame() && frame()->page() && frame()->page()->deviceMotionController())
1564 frame()->page()->deviceMotionController()->removeListener(this);
1565 else if (eventType == eventNames().deviceorientationEvent && frame() && frame()->page() && frame()->page()->deviceOrientationController())
1566 frame()->page()->deviceOrientationController()->removeListener(this);
1572 void DOMWindow::dispatchLoadEvent()
1574 RefPtr<Event> loadEvent(Event::create(eventNames().loadEvent, false, false));
1575 if (m_frame && m_frame->loader()->documentLoader() && !m_frame->loader()->documentLoader()->timing()->loadEventStart) {
1576 // The DocumentLoader (and thus its DocumentLoadTiming) might get destroyed while dispatching
1577 // the event, so protect it to prevent writing the end time into freed memory.
1578 RefPtr<DocumentLoader> documentLoader = m_frame->loader()->documentLoader();
1579 DocumentLoadTiming* timing = documentLoader->timing();
1580 dispatchTimedEvent(loadEvent, document(), &timing->loadEventStart, &timing->loadEventEnd);
1582 dispatchEvent(loadEvent, document());
1584 // For load events, send a separate load event to the enclosing frame only.
1585 // This is a DOM extension and is independent of bubbling/capturing rules of
1587 Element* ownerElement = m_frame ? m_frame->ownerElement() : 0;
1589 ownerElement->dispatchEvent(Event::create(eventNames().loadEvent, false, false));
1591 InspectorInstrumentation::loadEventFired(frame(), url());
1594 bool DOMWindow::dispatchEvent(PassRefPtr<Event> prpEvent, PassRefPtr<EventTarget> prpTarget)
1596 RefPtr<EventTarget> protect = this;
1597 RefPtr<Event> event = prpEvent;
1599 event->setTarget(prpTarget ? prpTarget : this);
1600 event->setCurrentTarget(this);
1601 event->setEventPhase(Event::AT_TARGET);
1603 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDispatchEventOnWindow(frame(), *event, this);
1605 bool result = fireEventListeners(event.get());
1607 InspectorInstrumentation::didDispatchEventOnWindow(cookie);
1612 void DOMWindow::dispatchTimedEvent(PassRefPtr<Event> event, Document* target, double* startTime, double* endTime)
1616 *startTime = currentTime();
1617 dispatchEvent(event, target);
1618 *endTime = currentTime();
1621 void DOMWindow::removeAllEventListeners()
1623 EventTarget::removeAllEventListeners();
1625 #if ENABLE(DEVICE_ORIENTATION)
1626 if (frame() && frame()->page() && frame()->page()->deviceMotionController())
1627 frame()->page()->deviceMotionController()->removeAllListeners(this);
1628 if (frame() && frame()->page() && frame()->page()->deviceOrientationController())
1629 frame()->page()->deviceOrientationController()->removeAllListeners(this);
1632 removeAllUnloadEventListeners(this);
1633 removeAllBeforeUnloadEventListeners(this);
1636 void DOMWindow::captureEvents()
1641 void DOMWindow::releaseEvents()
1646 void DOMWindow::finishedLoading()
1648 if (m_shouldPrintWhenFinishedLoading) {
1649 m_shouldPrintWhenFinishedLoading = false;
1651 m_printTimer.stop();
1652 m_printTimer.startOneShot(0);
1656 EventTargetData* DOMWindow::eventTargetData()
1658 return &m_eventTargetData;
1661 EventTargetData* DOMWindow::ensureEventTargetData()
1663 return &m_eventTargetData;
1666 #if ENABLE(DOM_STORAGE) && defined(ANDROID)
1667 void DOMWindow::clearDOMStorage()
1669 if (m_sessionStorage)
1670 m_sessionStorage->disconnectFrame();
1671 m_sessionStorage = 0;
1674 m_localStorage->disconnectFrame();
1679 void DOMWindow::setLocation(const String& urlString, DOMWindow* activeWindow, DOMWindow* firstWindow, SetLocationLocking locking)
1684 Frame* activeFrame = activeWindow->frame();
1688 if (!activeFrame->loader()->shouldAllowNavigation(m_frame))
1691 Frame* firstFrame = firstWindow->frame();
1695 KURL completedURL = firstFrame->document()->completeURL(urlString);
1696 if (completedURL.isNull())
1699 if (isInsecureScriptAccess(activeWindow, urlString))
1702 // We want a new history item if we are processing a user gesture.
1703 m_frame->navigationScheduler()->scheduleLocationChange(activeFrame->document()->securityOrigin(),
1704 completedURL, activeFrame->loader()->outgoingReferrer(),
1705 locking != LockHistoryBasedOnGestureState || !activeFrame->script()->anyPageIsProcessingUserGesture(),
1706 locking != LockHistoryBasedOnGestureState);
1709 void DOMWindow::printErrorMessage(const String& message)
1711 if (message.isEmpty())
1714 Settings* settings = m_frame->settings();
1717 if (settings->privateBrowsingEnabled())
1720 // FIXME: Add arguments so that we can provide a correct source URL and line number.
1721 console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message, 1, String());
1724 String DOMWindow::crossDomainAccessErrorMessage(DOMWindow* activeWindow)
1726 const KURL& activeWindowURL = activeWindow->url();
1727 if (activeWindowURL.isNull())
1730 // FIXME: This error message should contain more specifics of why the same origin check has failed.
1731 // Perhaps we should involve the security origin object in composing it.
1732 // FIXME: This message, and other console messages, have extra newlines. Should remove them.
1733 return makeString("Unsafe JavaScript attempt to access frame with URL ", m_url.string(),
1734 " from frame with URL ", activeWindowURL.string(), ". Domains, protocols and ports must match.\n");
1737 bool DOMWindow::isInsecureScriptAccess(DOMWindow* activeWindow, const String& urlString)
1739 if (!protocolIsJavaScript(urlString))
1742 // FIXME: Is there some way to eliminate the need for a separate "activeWindow == this" check?
1743 if (activeWindow == this)
1746 // FIXME: The name canAccess seems to be a roundabout way to ask "can execute script".
1747 // Can we name the SecurityOrigin function better to make this more clear?
1748 if (activeWindow->securityOrigin()->canAccess(securityOrigin()))
1751 printErrorMessage(crossDomainAccessErrorMessage(activeWindow));
1755 Frame* DOMWindow::createWindow(const String& urlString, const AtomicString& frameName, const WindowFeatures& windowFeatures,
1756 DOMWindow* activeWindow, Frame* firstFrame, Frame* openerFrame, PrepareDialogFunction function, void* functionContext)
1758 Frame* activeFrame = activeWindow->frame();
1760 // For whatever reason, Firefox uses the first frame to determine the outgoingReferrer. We replicate that behavior here.
1761 String referrer = firstFrame->loader()->outgoingReferrer();
1763 KURL completedURL = urlString.isEmpty() ? KURL(ParsedURLString, "") : firstFrame->document()->completeURL(urlString);
1764 ResourceRequest request(completedURL, referrer);
1765 FrameLoader::addHTTPOriginIfNeeded(request, firstFrame->loader()->outgoingOrigin());
1766 FrameLoadRequest frameRequest(activeWindow->securityOrigin(), request, frameName);
1768 // We pass the opener frame for the lookupFrame in case the active frame is different from
1769 // the opener frame, and the name references a frame relative to the opener frame.
1771 Frame* newFrame = WebCore::createWindow(activeFrame, openerFrame, frameRequest, windowFeatures, created);
1775 newFrame->loader()->setOpener(openerFrame);
1776 newFrame->page()->setOpenedByDOM();
1778 if (newFrame->domWindow()->isInsecureScriptAccess(activeWindow, urlString))
1782 function(newFrame->domWindow(), functionContext);
1785 newFrame->loader()->changeLocation(activeWindow->securityOrigin(), completedURL, referrer, false, false);
1786 else if (!urlString.isEmpty()) {
1787 newFrame->navigationScheduler()->scheduleLocationChange(activeWindow->securityOrigin(), completedURL.string(), referrer,
1788 !activeFrame->script()->anyPageIsProcessingUserGesture(), false);
1794 PassRefPtr<DOMWindow> DOMWindow::open(const String& urlString, const AtomicString& frameName, const String& windowFeaturesString,
1795 DOMWindow* activeWindow, DOMWindow* firstWindow)
1799 Frame* activeFrame = activeWindow->frame();
1802 Frame* firstFrame = firstWindow->frame();
1806 if (!firstWindow->allowPopUp()) {
1807 // Because FrameTree::find() returns true for empty strings, we must check for empty frame names.
1808 // Otherwise, illegitimate window.open() calls with no name will pass right through the popup blocker.
1809 if (frameName.isEmpty() || !m_frame->tree()->find(frameName))
1813 // Get the target frame for the special cases of _top and _parent.
1814 // In those cases, we schedule a location change right now and return early.
1815 Frame* targetFrame = 0;
1816 if (frameName == "_top")
1817 targetFrame = m_frame->tree()->top();
1818 else if (frameName == "_parent") {
1819 if (Frame* parent = m_frame->tree()->parent())
1820 targetFrame = parent;
1822 targetFrame = m_frame;
1825 if (!activeFrame->loader()->shouldAllowNavigation(targetFrame))
1828 if (isInsecureScriptAccess(activeWindow, urlString))
1829 return targetFrame->domWindow();
1831 if (urlString.isEmpty())
1832 return targetFrame->domWindow();
1834 // For whatever reason, Firefox uses the first window rather than the active window to
1835 // determine the outgoing referrer. We replicate that behavior here.
1836 targetFrame->navigationScheduler()->scheduleLocationChange(activeFrame->document()->securityOrigin(),
1837 firstFrame->document()->completeURL(urlString).string(),
1838 firstFrame->loader()->outgoingReferrer(),
1839 !activeFrame->script()->anyPageIsProcessingUserGesture(), false);
1841 return targetFrame->domWindow();
1844 WindowFeatures windowFeatures(windowFeaturesString);
1845 FloatRect windowRect(windowFeatures.xSet ? windowFeatures.x : 0, windowFeatures.ySet ? windowFeatures.y : 0,
1846 windowFeatures.widthSet ? windowFeatures.width : 0, windowFeatures.heightSet ? windowFeatures.height : 0);
1847 Page* page = m_frame->page();
1848 DOMWindow::adjustWindowRect(screenAvailableRect(page ? page->mainFrame()->view() : 0), windowRect, windowRect);
1849 windowFeatures.x = windowRect.x();
1850 windowFeatures.y = windowRect.y();
1851 windowFeatures.height = windowRect.height();
1852 windowFeatures.width = windowRect.width();
1854 Frame* result = createWindow(urlString, frameName, windowFeatures, activeWindow, firstFrame, m_frame);
1855 return result ? result->domWindow() : 0;
1858 void DOMWindow::showModalDialog(const String& urlString, const String& dialogFeaturesString,
1859 DOMWindow* activeWindow, DOMWindow* firstWindow, PrepareDialogFunction function, void* functionContext)
1863 Frame* activeFrame = activeWindow->frame();
1866 Frame* firstFrame = firstWindow->frame();
1870 if (!canShowModalDialogNow(m_frame) || !firstWindow->allowPopUp())
1873 Frame* dialogFrame = createWindow(urlString, emptyAtom, WindowFeatures(dialogFeaturesString, screenAvailableRect(m_frame->view())),
1874 activeWindow, firstFrame, m_frame, function, functionContext);
1878 dialogFrame->page()->chrome()->runModal();
1882 DOMURL* DOMWindow::webkitURL() const
1885 m_domURL = DOMURL::create(this->scriptExecutionContext());
1886 return m_domURL.get();
1890 } // namespace WebCore