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 "ScheduledAction.h"
84 #include "SecurityOrigin.h"
85 #include "SerializedScriptValue.h"
88 #include "StorageArea.h"
89 #include "StorageInfo.h"
90 #include "StorageNamespace.h"
91 #include "StyleMedia.h"
92 #include "SuddenTermination.h"
93 #include "WebKitPoint.h"
94 #include "WindowFeatures.h"
96 #include <wtf/CurrentTime.h>
97 #include <wtf/MainThread.h>
98 #include <wtf/MathExtras.h>
99 #include <wtf/text/WTFString.h>
101 #if ENABLE(FILE_SYSTEM)
102 #include "AsyncFileSystem.h"
103 #include "DOMFileSystem.h"
104 #include "DOMFileSystemBase.h"
105 #include "EntryCallback.h"
106 #include "ErrorCallback.h"
107 #include "FileError.h"
108 #include "FileSystemCallback.h"
109 #include "FileSystemCallbacks.h"
110 #include "LocalFileSystem.h"
113 #if ENABLE(REQUEST_ANIMATION_FRAME)
114 #include "RequestAnimationFrameCallback.h"
122 class PostMessageTimer : public TimerBase {
124 PostMessageTimer(DOMWindow* window, PassRefPtr<SerializedScriptValue> message, const String& sourceOrigin, PassRefPtr<DOMWindow> source, PassOwnPtr<MessagePortChannelArray> channels, SecurityOrigin* targetOrigin)
127 , m_origin(sourceOrigin)
129 , m_channels(channels)
130 , m_targetOrigin(targetOrigin)
134 PassRefPtr<MessageEvent> event(ScriptExecutionContext* context)
136 OwnPtr<MessagePortArray> messagePorts = MessagePort::entanglePorts(*context, m_channels.release());
137 return MessageEvent::create(messagePorts.release(), m_message, m_origin, "", m_source);
139 SecurityOrigin* targetOrigin() const { return m_targetOrigin.get(); }
144 m_window->postMessageTimerFired(adoptPtr(this));
145 // This object is deleted now.
148 RefPtr<DOMWindow> m_window;
149 RefPtr<SerializedScriptValue> m_message;
151 RefPtr<DOMWindow> m_source;
152 OwnPtr<MessagePortChannelArray> m_channels;
153 RefPtr<SecurityOrigin> m_targetOrigin;
156 typedef HashCountedSet<DOMWindow*> DOMWindowSet;
158 static DOMWindowSet& windowsWithUnloadEventListeners()
160 DEFINE_STATIC_LOCAL(DOMWindowSet, windowsWithUnloadEventListeners, ());
161 return windowsWithUnloadEventListeners;
164 static DOMWindowSet& windowsWithBeforeUnloadEventListeners()
166 DEFINE_STATIC_LOCAL(DOMWindowSet, windowsWithBeforeUnloadEventListeners, ());
167 return windowsWithBeforeUnloadEventListeners;
170 static void addUnloadEventListener(DOMWindow* domWindow)
172 DOMWindowSet& set = windowsWithUnloadEventListeners();
174 disableSuddenTermination();
178 static void removeUnloadEventListener(DOMWindow* domWindow)
180 DOMWindowSet& set = windowsWithUnloadEventListeners();
181 DOMWindowSet::iterator it = set.find(domWindow);
186 enableSuddenTermination();
189 static void removeAllUnloadEventListeners(DOMWindow* domWindow)
191 DOMWindowSet& set = windowsWithUnloadEventListeners();
192 DOMWindowSet::iterator it = set.find(domWindow);
197 enableSuddenTermination();
200 static void addBeforeUnloadEventListener(DOMWindow* domWindow)
202 DOMWindowSet& set = windowsWithBeforeUnloadEventListeners();
204 disableSuddenTermination();
208 static void removeBeforeUnloadEventListener(DOMWindow* domWindow)
210 DOMWindowSet& set = windowsWithBeforeUnloadEventListeners();
211 DOMWindowSet::iterator it = set.find(domWindow);
216 enableSuddenTermination();
219 static void removeAllBeforeUnloadEventListeners(DOMWindow* domWindow)
221 DOMWindowSet& set = windowsWithBeforeUnloadEventListeners();
222 DOMWindowSet::iterator it = set.find(domWindow);
227 enableSuddenTermination();
230 static bool allowsBeforeUnloadListeners(DOMWindow* window)
232 ASSERT_ARG(window, window);
233 Frame* frame = window->frame();
236 Page* page = frame->page();
239 return frame == page->mainFrame();
242 bool DOMWindow::dispatchAllPendingBeforeUnloadEvents()
244 DOMWindowSet& set = windowsWithBeforeUnloadEventListeners();
248 static bool alreadyDispatched = false;
249 ASSERT(!alreadyDispatched);
250 if (alreadyDispatched)
253 Vector<RefPtr<DOMWindow> > windows;
254 DOMWindowSet::iterator end = set.end();
255 for (DOMWindowSet::iterator it = set.begin(); it != end; ++it)
256 windows.append(it->first);
258 size_t size = windows.size();
259 for (size_t i = 0; i < size; ++i) {
260 DOMWindow* window = windows[i].get();
261 if (!set.contains(window))
264 Frame* frame = window->frame();
268 if (!frame->loader()->shouldClose())
272 enableSuddenTermination();
274 alreadyDispatched = true;
279 unsigned DOMWindow::pendingUnloadEventListeners() const
281 return windowsWithUnloadEventListeners().count(const_cast<DOMWindow*>(this));
284 void DOMWindow::dispatchAllPendingUnloadEvents()
286 DOMWindowSet& set = windowsWithUnloadEventListeners();
290 static bool alreadyDispatched = false;
291 ASSERT(!alreadyDispatched);
292 if (alreadyDispatched)
295 Vector<RefPtr<DOMWindow> > windows;
296 DOMWindowSet::iterator end = set.end();
297 for (DOMWindowSet::iterator it = set.begin(); it != end; ++it)
298 windows.append(it->first);
300 size_t size = windows.size();
301 for (size_t i = 0; i < size; ++i) {
302 DOMWindow* window = windows[i].get();
303 if (!set.contains(window))
306 window->dispatchEvent(PageTransitionEvent::create(eventNames().pagehideEvent, false), window->document());
307 window->dispatchEvent(Event::create(eventNames().unloadEvent, false, false), window->document());
310 enableSuddenTermination();
312 alreadyDispatched = true;
316 // 1) Validates the pending changes are not changing to NaN
317 // 2) Constrains the window rect to no smaller than 100 in each dimension and no
318 // bigger than the the float rect's dimensions.
319 // 3) Constrain window rect to within the top and left boundaries of the screen rect
320 // 4) Constraint the window rect to within the bottom and right boundaries of the
322 // 5) Translate the window rect coordinates to be within the coordinate space of
324 void DOMWindow::adjustWindowRect(const FloatRect& screen, FloatRect& window, const FloatRect& pendingChanges)
326 // Make sure we're in a valid state before adjusting dimensions.
327 ASSERT(isfinite(screen.x()));
328 ASSERT(isfinite(screen.y()));
329 ASSERT(isfinite(screen.width()));
330 ASSERT(isfinite(screen.height()));
331 ASSERT(isfinite(window.x()));
332 ASSERT(isfinite(window.y()));
333 ASSERT(isfinite(window.width()));
334 ASSERT(isfinite(window.height()));
336 // Update window values if new requested values are not NaN.
337 if (!isnan(pendingChanges.x()))
338 window.setX(pendingChanges.x());
339 if (!isnan(pendingChanges.y()))
340 window.setY(pendingChanges.y());
341 if (!isnan(pendingChanges.width()))
342 window.setWidth(pendingChanges.width());
343 if (!isnan(pendingChanges.height()))
344 window.setHeight(pendingChanges.height());
346 // Resize the window to between 100 and the screen width and height.
347 window.setWidth(min(max(100.0f, window.width()), screen.width()));
348 window.setHeight(min(max(100.0f, window.height()), screen.height()));
350 // Constrain the window position to the screen.
351 window.setX(max(screen.x(), min(window.x(), screen.maxX() - window.width())));
352 window.setY(max(screen.y(), min(window.y(), screen.maxY() - window.height())));
355 // FIXME: We can remove this function once V8 showModalDialog is changed to use DOMWindow.
356 void DOMWindow::parseModalDialogFeatures(const String& string, HashMap<String, String>& map)
358 WindowFeatures::parseDialogFeatures(string, map);
361 bool DOMWindow::allowPopUp(Frame* firstFrame)
365 if (ScriptController::processingUserGesture())
368 Settings* settings = firstFrame->settings();
369 return settings && settings->javaScriptCanOpenWindowsAutomatically();
372 bool DOMWindow::allowPopUp()
374 return m_frame && allowPopUp(m_frame);
377 bool DOMWindow::canShowModalDialog(const Frame* frame)
381 Page* page = frame->page();
384 return page->chrome()->canRunModal();
387 bool DOMWindow::canShowModalDialogNow(const Frame* frame)
391 Page* page = frame->page();
394 return page->chrome()->canRunModalNow();
397 DOMWindow::DOMWindow(Frame* frame)
398 : m_shouldPrintWhenFinishedLoading(false)
403 DOMWindow::~DOMWindow()
406 m_frame->clearFormerDOMWindow(this);
408 removeAllUnloadEventListeners(this);
409 removeAllBeforeUnloadEventListeners(this);
412 ScriptExecutionContext* DOMWindow::scriptExecutionContext() const
417 PassRefPtr<MediaQueryList> DOMWindow::matchMedia(const String& media)
419 return document() ? document()->mediaQueryMatcher()->matchMedia(media) : 0;
422 void DOMWindow::setSecurityOrigin(SecurityOrigin* securityOrigin)
424 m_securityOrigin = securityOrigin;
427 void DOMWindow::disconnectFrame()
433 void DOMWindow::clear()
436 m_screen->disconnectFrame();
440 m_selection->disconnectFrame();
444 m_history->disconnectFrame();
450 m_locationbar->disconnectFrame();
454 m_menubar->disconnectFrame();
458 m_personalbar->disconnectFrame();
462 m_scrollbars->disconnectFrame();
466 m_statusbar->disconnectFrame();
470 m_toolbar->disconnectFrame();
474 m_console->disconnectFrame();
478 m_navigator->disconnectFrame();
481 #if ENABLE(WEB_TIMING)
483 m_performance->disconnectFrame();
488 m_location->disconnectFrame();
492 m_media->disconnectFrame();
495 #if ENABLE(DOM_STORAGE)
496 if (m_sessionStorage)
497 m_sessionStorage->disconnectFrame();
498 m_sessionStorage = 0;
501 m_localStorage->disconnectFrame();
505 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
506 if (m_applicationCache)
507 m_applicationCache->disconnectFrame();
508 m_applicationCache = 0;
511 #if ENABLE(NOTIFICATIONS)
513 m_notifications->disconnectFrame();
517 #if ENABLE(INDEXED_DATABASE)
522 #if ENABLE(ORIENTATION_EVENTS)
523 int DOMWindow::orientation() const
528 return m_frame->orientation();
532 Screen* DOMWindow::screen() const
535 m_screen = Screen::create(m_frame);
536 return m_screen.get();
539 History* DOMWindow::history() const
542 m_history = History::create(m_frame);
543 return m_history.get();
546 Crypto* DOMWindow::crypto() const
549 m_crypto = Crypto::create();
550 return m_crypto.get();
553 BarInfo* DOMWindow::locationbar() const
556 m_locationbar = BarInfo::create(m_frame, BarInfo::Locationbar);
557 return m_locationbar.get();
560 BarInfo* DOMWindow::menubar() const
563 m_menubar = BarInfo::create(m_frame, BarInfo::Menubar);
564 return m_menubar.get();
567 BarInfo* DOMWindow::personalbar() const
570 m_personalbar = BarInfo::create(m_frame, BarInfo::Personalbar);
571 return m_personalbar.get();
574 BarInfo* DOMWindow::scrollbars() const
577 m_scrollbars = BarInfo::create(m_frame, BarInfo::Scrollbars);
578 return m_scrollbars.get();
581 BarInfo* DOMWindow::statusbar() const
584 m_statusbar = BarInfo::create(m_frame, BarInfo::Statusbar);
585 return m_statusbar.get();
588 BarInfo* DOMWindow::toolbar() const
591 m_toolbar = BarInfo::create(m_frame, BarInfo::Toolbar);
592 return m_toolbar.get();
595 Console* DOMWindow::console() const
598 m_console = Console::create(m_frame);
599 return m_console.get();
602 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
603 DOMApplicationCache* DOMWindow::applicationCache() const
605 if (!m_applicationCache)
606 m_applicationCache = DOMApplicationCache::create(m_frame);
607 return m_applicationCache.get();
611 Navigator* DOMWindow::navigator() const
614 m_navigator = Navigator::create(m_frame);
615 return m_navigator.get();
618 #if ENABLE(WEB_TIMING)
619 Performance* DOMWindow::performance() const
622 m_performance = Performance::create(m_frame);
623 return m_performance.get();
627 Location* DOMWindow::location() const
630 m_location = Location::create(m_frame);
631 return m_location.get();
634 #if ENABLE(DOM_STORAGE)
635 Storage* DOMWindow::sessionStorage(ExceptionCode& ec) const
637 if (m_sessionStorage)
638 return m_sessionStorage.get();
640 Document* document = this->document();
644 if (!document->securityOrigin()->canAccessLocalStorage()) {
649 Page* page = document->page();
653 RefPtr<StorageArea> storageArea = page->sessionStorage()->storageArea(document->securityOrigin());
654 InspectorInstrumentation::didUseDOMStorage(page, storageArea.get(), false, m_frame);
656 m_sessionStorage = Storage::create(m_frame, storageArea.release());
657 return m_sessionStorage.get();
660 Storage* DOMWindow::localStorage(ExceptionCode& ec) const
663 return m_localStorage.get();
665 Document* document = this->document();
669 if (!document->securityOrigin()->canAccessLocalStorage()) {
674 Page* page = document->page();
678 if (!page->settings()->localStorageEnabled())
681 RefPtr<StorageArea> storageArea = page->group().localStorage()->storageArea(document->securityOrigin());
682 InspectorInstrumentation::didUseDOMStorage(page, storageArea.get(), true, m_frame);
684 m_localStorage = Storage::create(m_frame, storageArea.release());
685 return m_localStorage.get();
689 #if ENABLE(NOTIFICATIONS)
690 NotificationCenter* DOMWindow::webkitNotifications() const
693 return m_notifications.get();
695 Document* document = this->document();
699 Page* page = document->page();
703 NotificationPresenter* provider = page->chrome()->notificationPresenter();
705 m_notifications = NotificationCenter::create(document, provider);
707 return m_notifications.get();
711 void DOMWindow::pageDestroyed()
713 InspectorInstrumentation::frameWindowDiscarded(m_frame, this);
714 #if ENABLE(NOTIFICATIONS)
715 // Clearing Notifications requests involves accessing the client so it must be done
716 // before the frame is detached.
718 m_notifications->disconnectFrame();
723 void DOMWindow::resetGeolocation()
725 // Geolocation should cancel activities and permission requests when the page is detached.
727 m_navigator->resetGeolocation();
730 #if ENABLE(INDEXED_DATABASE)
731 IDBFactory* DOMWindow::webkitIndexedDB() const
733 Document* document = this->document();
737 Page* page = document->page();
741 if (!document->securityOrigin()->canAccessDatabase())
745 m_idbFactory = IDBFactory::create(page->group().idbFactory());
746 return m_idbFactory.get();
750 #if ENABLE(FILE_SYSTEM)
751 void DOMWindow::webkitRequestFileSystem(int type, long long size, PassRefPtr<FileSystemCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
753 Document* document = this->document();
757 if (!AsyncFileSystem::isAvailable() || !document->securityOrigin()->canAccessFileSystem()) {
758 DOMFileSystem::scheduleCallback(document, errorCallback, FileError::create(FileError::SECURITY_ERR));
762 AsyncFileSystem::Type fileSystemType = static_cast<AsyncFileSystem::Type>(type);
763 if (fileSystemType != AsyncFileSystem::Temporary && fileSystemType != AsyncFileSystem::Persistent && fileSystemType != AsyncFileSystem::External) {
764 DOMFileSystem::scheduleCallback(document, errorCallback, FileError::create(FileError::INVALID_MODIFICATION_ERR));
768 LocalFileSystem::localFileSystem().requestFileSystem(document, fileSystemType, size, FileSystemCallbacks::create(successCallback, errorCallback, document), false);
771 void DOMWindow::webkitResolveLocalFileSystemURL(const String& url, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
773 Document* document = this->document();
777 SecurityOrigin* securityOrigin = document->securityOrigin();
778 KURL completedURL = document->completeURL(url);
779 if (!AsyncFileSystem::isAvailable() || !securityOrigin->canAccessFileSystem() || !securityOrigin->canRequest(completedURL)) {
780 DOMFileSystem::scheduleCallback(document, errorCallback, FileError::create(FileError::SECURITY_ERR));
784 AsyncFileSystem::Type type;
786 if (!completedURL.isValid() || !DOMFileSystemBase::crackFileSystemURL(completedURL, type, filePath)) {
787 DOMFileSystem::scheduleCallback(document, errorCallback, FileError::create(FileError::ENCODING_ERR));
791 LocalFileSystem::localFileSystem().readFileSystem(document, type, ResolveURICallbacks::create(successCallback, errorCallback, document, filePath));
794 COMPILE_ASSERT(static_cast<int>(DOMWindow::EXTERNAL) == static_cast<int>(AsyncFileSystem::External), enum_mismatch);
796 COMPILE_ASSERT(static_cast<int>(DOMWindow::TEMPORARY) == static_cast<int>(AsyncFileSystem::Temporary), enum_mismatch);
797 COMPILE_ASSERT(static_cast<int>(DOMWindow::PERSISTENT) == static_cast<int>(AsyncFileSystem::Persistent), enum_mismatch);
801 void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, MessagePort* port, const String& targetOrigin, DOMWindow* source, ExceptionCode& ec)
803 MessagePortArray ports;
806 postMessage(message, &ports, targetOrigin, source, ec);
809 void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, const String& targetOrigin, DOMWindow* source, ExceptionCode& ec)
814 // Compute the target origin. We need to do this synchronously in order
815 // to generate the SYNTAX_ERR exception correctly.
816 RefPtr<SecurityOrigin> target;
817 if (targetOrigin != "*") {
818 target = SecurityOrigin::createFromString(targetOrigin);
819 if (target->isEmpty()) {
825 OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(ports, ec);
829 // Capture the source of the message. We need to do this synchronously
830 // in order to capture the source of the message correctly.
831 Document* sourceDocument = source->document();
834 String sourceOrigin = sourceDocument->securityOrigin()->toString();
836 // Schedule the message.
837 PostMessageTimer* timer = new PostMessageTimer(this, message, sourceOrigin, source, channels.release(), target.get());
838 timer->startOneShot(0);
841 void DOMWindow::postMessageTimerFired(PassOwnPtr<PostMessageTimer> t)
843 OwnPtr<PostMessageTimer> timer(t);
848 if (timer->targetOrigin()) {
849 // Check target origin now since the target document may have changed since the simer was scheduled.
850 if (!timer->targetOrigin()->isSameSchemeHostPort(document()->securityOrigin())) {
851 String message = "Unable to post message to " + timer->targetOrigin()->toString() +
852 ". Recipient has origin " + document()->securityOrigin()->toString() + ".\n";
853 console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message, 0, String());
858 dispatchEvent(timer->event(document()));
861 DOMSelection* DOMWindow::getSelection()
864 m_selection = DOMSelection::create(m_frame);
865 return m_selection.get();
868 Element* DOMWindow::frameElement() const
873 return m_frame->ownerElement();
876 void DOMWindow::focus()
881 Page* page = m_frame->page();
885 // If we're a top level window, bring the window to the front.
886 if (m_frame == page->mainFrame())
887 page->chrome()->focus();
892 m_frame->eventHandler()->focusDocumentView();
895 void DOMWindow::blur()
900 Page* page = m_frame->page();
904 if (m_frame != page->mainFrame())
907 page->chrome()->unfocus();
910 void DOMWindow::close(ScriptExecutionContext* context)
915 Page* page = m_frame->page();
919 if (m_frame != page->mainFrame())
923 ASSERT(isMainThread());
924 Frame* activeFrame = static_cast<Document*>(context)->frame();
928 if (!activeFrame->loader()->shouldAllowNavigation(m_frame))
932 Settings* settings = m_frame->settings();
933 bool allowScriptsToCloseWindows = settings && settings->allowScriptsToCloseWindows();
935 if (!(page->openedByDOM() || page->backForward()->count() <= 1 || allowScriptsToCloseWindows))
938 if (!m_frame->loader()->shouldClose())
941 page->chrome()->closeWindowSoon();
944 void DOMWindow::print()
949 Page* page = m_frame->page();
953 if (m_frame->loader()->activeDocumentLoader()->isLoading()) {
954 m_shouldPrintWhenFinishedLoading = true;
957 m_shouldPrintWhenFinishedLoading = false;
958 page->chrome()->print(m_frame);
961 void DOMWindow::stop()
966 // We must check whether the load is complete asynchronously, because we might still be parsing
967 // the document until the callstack unwinds.
968 m_frame->loader()->stopForUserCancel(true);
971 void DOMWindow::alert(const String& message)
976 m_frame->document()->updateStyleIfNeeded();
978 Page* page = m_frame->page();
982 page->chrome()->runJavaScriptAlert(m_frame, message);
985 bool DOMWindow::confirm(const String& message)
990 m_frame->document()->updateStyleIfNeeded();
992 Page* page = m_frame->page();
996 return page->chrome()->runJavaScriptConfirm(m_frame, message);
999 String DOMWindow::prompt(const String& message, const String& defaultValue)
1004 m_frame->document()->updateStyleIfNeeded();
1006 Page* page = m_frame->page();
1011 if (page->chrome()->runJavaScriptPrompt(m_frame, message, defaultValue, returnValue))
1017 String DOMWindow::btoa(const String& stringToEncode, ExceptionCode& ec)
1019 if (stringToEncode.isNull())
1022 if (!stringToEncode.containsOnlyLatin1()) {
1023 ec = INVALID_CHARACTER_ERR;
1027 return base64Encode(stringToEncode.latin1());
1030 String DOMWindow::atob(const String& encodedString, ExceptionCode& ec)
1032 if (encodedString.isNull())
1035 if (!encodedString.containsOnlyLatin1()) {
1036 ec = INVALID_CHARACTER_ERR;
1041 if (!base64Decode(encodedString, out, FailOnInvalidCharacter)) {
1042 ec = INVALID_CHARACTER_ERR;
1046 return String(out.data(), out.size());
1049 bool DOMWindow::find(const String& string, bool caseSensitive, bool backwards, bool wrap, bool /*wholeWord*/, bool /*searchInFrames*/, bool /*showDialog*/) const
1054 // FIXME (13016): Support wholeWord, searchInFrames and showDialog
1055 return m_frame->editor()->findString(string, !backwards, caseSensitive, wrap, false);
1058 bool DOMWindow::offscreenBuffering() const
1063 int DOMWindow::outerHeight() const
1068 Page* page = m_frame->page();
1072 return static_cast<int>(page->chrome()->windowRect().height());
1075 int DOMWindow::outerWidth() const
1080 Page* page = m_frame->page();
1084 return static_cast<int>(page->chrome()->windowRect().width());
1087 int DOMWindow::innerHeight() const
1092 FrameView* view = m_frame->view();
1096 return static_cast<int>(view->height() / m_frame->pageZoomFactor());
1099 int DOMWindow::innerWidth() const
1104 FrameView* view = m_frame->view();
1108 return static_cast<int>(view->width() / m_frame->pageZoomFactor());
1111 int DOMWindow::screenX() const
1116 Page* page = m_frame->page();
1120 return static_cast<int>(page->chrome()->windowRect().x());
1123 int DOMWindow::screenY() const
1128 Page* page = m_frame->page();
1132 return static_cast<int>(page->chrome()->windowRect().y());
1135 int DOMWindow::scrollX() const
1140 FrameView* view = m_frame->view();
1144 m_frame->document()->updateLayoutIgnorePendingStylesheets();
1146 return static_cast<int>(view->scrollX() / m_frame->pageZoomFactor());
1149 int DOMWindow::scrollY() const
1154 FrameView* view = m_frame->view();
1158 m_frame->document()->updateLayoutIgnorePendingStylesheets();
1160 return static_cast<int>(view->scrollY() / m_frame->pageZoomFactor());
1163 bool DOMWindow::closed() const
1168 unsigned DOMWindow::length() const
1173 return m_frame->tree()->childCount();
1176 String DOMWindow::name() const
1181 return m_frame->tree()->name();
1184 void DOMWindow::setName(const String& string)
1189 m_frame->tree()->setName(string);
1192 void DOMWindow::setStatus(const String& string)
1199 Page* page = m_frame->page();
1203 ASSERT(m_frame->document()); // Client calls shouldn't be made when the frame is in inconsistent state.
1204 page->chrome()->setStatusbarText(m_frame, m_status);
1207 void DOMWindow::setDefaultStatus(const String& string)
1209 m_defaultStatus = 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_defaultStatus);
1222 DOMWindow* DOMWindow::self() const
1227 return m_frame->domWindow();
1230 DOMWindow* DOMWindow::opener() const
1235 Frame* opener = m_frame->loader()->opener();
1239 return opener->domWindow();
1242 DOMWindow* DOMWindow::parent() const
1247 Frame* parent = m_frame->tree()->parent(true);
1249 return parent->domWindow();
1251 return m_frame->domWindow();
1254 DOMWindow* DOMWindow::top() const
1259 Page* page = m_frame->page();
1263 return m_frame->tree()->top(true)->domWindow();
1266 Document* DOMWindow::document() const
1268 // FIXME: This function shouldn't need a frame to work.
1272 // 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.
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)
1277 ASSERT(m_frame->document());
1278 return m_frame->document();
1281 PassRefPtr<StyleMedia> DOMWindow::styleMedia() const
1284 m_media = StyleMedia::create(m_frame);
1285 return m_media.get();
1288 PassRefPtr<CSSStyleDeclaration> DOMWindow::getComputedStyle(Element* elt, const String& pseudoElt) const
1293 return computedStyle(elt, false, pseudoElt);
1296 PassRefPtr<CSSRuleList> DOMWindow::getMatchedCSSRules(Element* element, const String&, bool authorOnly) const
1301 unsigned rulesToInclude = CSSStyleSelector::AuthorCSSRules;
1303 rulesToInclude |= CSSStyleSelector::UAAndUserCSSRules;
1304 if (Settings* settings = m_frame->settings()) {
1305 if (settings->crossOriginCheckInGetMatchedCSSRulesDisabled())
1306 rulesToInclude |= CSSStyleSelector::CrossOriginCSSRules;
1309 return m_frame->document()->styleSelector()->styleRulesForElement(element, rulesToInclude);
1312 PassRefPtr<WebKitPoint> DOMWindow::webkitConvertPointFromNodeToPage(Node* node, const WebKitPoint* p) const
1317 m_frame->document()->updateLayoutIgnorePendingStylesheets();
1319 FloatPoint pagePoint(p->x(), p->y());
1320 pagePoint = node->convertToPage(pagePoint);
1321 return WebKitPoint::create(pagePoint.x(), pagePoint.y());
1324 PassRefPtr<WebKitPoint> DOMWindow::webkitConvertPointFromPageToNode(Node* node, const WebKitPoint* p) const
1329 m_frame->document()->updateLayoutIgnorePendingStylesheets();
1331 FloatPoint nodePoint(p->x(), p->y());
1332 nodePoint = node->convertFromPage(nodePoint);
1333 return WebKitPoint::create(nodePoint.x(), nodePoint.y());
1336 double DOMWindow::devicePixelRatio() const
1341 Page* page = m_frame->page();
1345 return page->deviceScaleFactor();
1348 #if ENABLE(DATABASE)
1349 PassRefPtr<Database> DOMWindow::openDatabase(const String& name, const String& version, const String& displayName, unsigned long estimatedSize, PassRefPtr<DatabaseCallback> creationCallback, ExceptionCode& ec)
1351 RefPtr<Database> database = 0;
1352 if (m_frame && AbstractDatabase::isAvailable() && m_frame->document()->securityOrigin()->canAccessDatabase())
1353 database = Database::openDatabase(m_frame->document(), name, version, displayName, estimatedSize, creationCallback, ec);
1355 if (!database && !ec)
1362 void DOMWindow::scrollBy(int x, int y) const
1367 m_frame->document()->updateLayoutIgnorePendingStylesheets();
1369 FrameView* view = m_frame->view();
1373 view->scrollBy(IntSize(x, y));
1376 void DOMWindow::scrollTo(int x, int y) const
1381 m_frame->document()->updateLayoutIgnorePendingStylesheets();
1383 RefPtr<FrameView> view = m_frame->view();
1387 int zoomedX = static_cast<int>(x * m_frame->pageZoomFactor());
1388 int zoomedY = static_cast<int>(y * m_frame->pageZoomFactor());
1389 view->setScrollPosition(IntPoint(zoomedX, zoomedY));
1392 void DOMWindow::moveBy(float x, float y) const
1397 Page* page = m_frame->page();
1401 if (m_frame != page->mainFrame())
1404 FloatRect fr = page->chrome()->windowRect();
1405 FloatRect update = fr;
1407 // Security check (the spec talks about UniversalBrowserWrite to disable this check...)
1408 adjustWindowRect(screenAvailableRect(page->mainFrame()->view()), fr, update);
1409 page->chrome()->setWindowRect(fr);
1412 void DOMWindow::moveTo(float x, float y) const
1417 Page* page = m_frame->page();
1421 if (m_frame != page->mainFrame())
1424 FloatRect fr = page->chrome()->windowRect();
1425 FloatRect sr = screenAvailableRect(page->mainFrame()->view());
1426 fr.setLocation(sr.location());
1427 FloatRect update = fr;
1429 // Security check (the spec talks about UniversalBrowserWrite to disable this check...)
1430 adjustWindowRect(sr, fr, update);
1431 page->chrome()->setWindowRect(fr);
1434 void DOMWindow::resizeBy(float x, float y) const
1439 Page* page = m_frame->page();
1443 if (m_frame != page->mainFrame())
1446 FloatRect fr = page->chrome()->windowRect();
1447 FloatSize dest = fr.size() + FloatSize(x, y);
1448 FloatRect update(fr.location(), dest);
1449 adjustWindowRect(screenAvailableRect(page->mainFrame()->view()), fr, update);
1450 page->chrome()->setWindowRect(fr);
1453 void DOMWindow::resizeTo(float width, float height) const
1458 Page* page = m_frame->page();
1462 if (m_frame != page->mainFrame())
1465 FloatRect fr = page->chrome()->windowRect();
1466 FloatSize dest = FloatSize(width, height);
1467 FloatRect update(fr.location(), dest);
1468 adjustWindowRect(screenAvailableRect(page->mainFrame()->view()), fr, update);
1469 page->chrome()->setWindowRect(fr);
1472 int DOMWindow::setTimeout(PassOwnPtr<ScheduledAction> action, int timeout, ExceptionCode& ec)
1474 ScriptExecutionContext* context = scriptExecutionContext();
1476 ec = INVALID_ACCESS_ERR;
1479 return DOMTimer::install(context, action, timeout, true);
1482 void DOMWindow::clearTimeout(int timeoutId)
1484 ScriptExecutionContext* context = scriptExecutionContext();
1487 DOMTimer::removeById(context, timeoutId);
1490 int DOMWindow::setInterval(PassOwnPtr<ScheduledAction> action, int timeout, ExceptionCode& ec)
1492 ScriptExecutionContext* context = scriptExecutionContext();
1494 ec = INVALID_ACCESS_ERR;
1497 return DOMTimer::install(context, action, timeout, false);
1500 void DOMWindow::clearInterval(int timeoutId)
1502 ScriptExecutionContext* context = scriptExecutionContext();
1505 DOMTimer::removeById(context, timeoutId);
1508 #if ENABLE(REQUEST_ANIMATION_FRAME)
1509 int DOMWindow::webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback> callback, Element* e)
1511 if (Document* d = document())
1512 return d->webkitRequestAnimationFrame(callback, e);
1516 void DOMWindow::webkitCancelRequestAnimationFrame(int id)
1518 if (Document* d = document())
1519 d->webkitCancelRequestAnimationFrame(id);
1523 bool DOMWindow::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture)
1525 if (!EventTarget::addEventListener(eventType, listener, useCapture))
1528 if (Document* document = this->document())
1529 document->addListenerTypeIfNeeded(eventType);
1531 if (eventType == eventNames().unloadEvent)
1532 addUnloadEventListener(this);
1533 else if (eventType == eventNames().beforeunloadEvent && allowsBeforeUnloadListeners(this))
1534 addBeforeUnloadEventListener(this);
1535 #if ENABLE(DEVICE_ORIENTATION)
1536 else if (eventType == eventNames().devicemotionEvent && frame() && frame()->page() && frame()->page()->deviceMotionController())
1537 frame()->page()->deviceMotionController()->addListener(this);
1538 else if (eventType == eventNames().deviceorientationEvent && frame() && frame()->page() && frame()->page()->deviceOrientationController())
1539 frame()->page()->deviceOrientationController()->addListener(this);
1545 bool DOMWindow::removeEventListener(const AtomicString& eventType, EventListener* listener, bool useCapture)
1547 if (!EventTarget::removeEventListener(eventType, listener, useCapture))
1550 if (eventType == eventNames().unloadEvent)
1551 removeUnloadEventListener(this);
1552 else if (eventType == eventNames().beforeunloadEvent && allowsBeforeUnloadListeners(this))
1553 removeBeforeUnloadEventListener(this);
1554 #if ENABLE(DEVICE_ORIENTATION)
1555 else if (eventType == eventNames().devicemotionEvent && frame() && frame()->page() && frame()->page()->deviceMotionController())
1556 frame()->page()->deviceMotionController()->removeListener(this);
1557 else if (eventType == eventNames().deviceorientationEvent && frame() && frame()->page() && frame()->page()->deviceOrientationController())
1558 frame()->page()->deviceOrientationController()->removeListener(this);
1564 void DOMWindow::dispatchLoadEvent()
1566 RefPtr<Event> loadEvent(Event::create(eventNames().loadEvent, false, false));
1567 if (m_frame && m_frame->loader()->documentLoader() && !m_frame->loader()->documentLoader()->timing()->loadEventStart) {
1568 // The DocumentLoader (and thus its DocumentLoadTiming) might get destroyed while dispatching
1569 // the event, so protect it to prevent writing the end time into freed memory.
1570 RefPtr<DocumentLoader> documentLoader = m_frame->loader()->documentLoader();
1571 DocumentLoadTiming* timing = documentLoader->timing();
1572 dispatchTimedEvent(loadEvent, document(), &timing->loadEventStart, &timing->loadEventEnd);
1574 dispatchEvent(loadEvent, document());
1576 // For load events, send a separate load event to the enclosing frame only.
1577 // This is a DOM extension and is independent of bubbling/capturing rules of
1579 Element* ownerElement = m_frame ? m_frame->ownerElement() : 0;
1581 ownerElement->dispatchEvent(Event::create(eventNames().loadEvent, false, false));
1583 InspectorInstrumentation::loadEventFired(frame(), url());
1586 bool DOMWindow::dispatchEvent(PassRefPtr<Event> prpEvent, PassRefPtr<EventTarget> prpTarget)
1588 RefPtr<EventTarget> protect = this;
1589 RefPtr<Event> event = prpEvent;
1591 event->setTarget(prpTarget ? prpTarget : this);
1592 event->setCurrentTarget(this);
1593 event->setEventPhase(Event::AT_TARGET);
1595 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDispatchEventOnWindow(frame(), *event, this);
1597 bool result = fireEventListeners(event.get());
1599 InspectorInstrumentation::didDispatchEventOnWindow(cookie);
1604 void DOMWindow::dispatchTimedEvent(PassRefPtr<Event> event, Document* target, double* startTime, double* endTime)
1608 *startTime = currentTime();
1609 dispatchEvent(event, target);
1610 *endTime = currentTime();
1613 void DOMWindow::removeAllEventListeners()
1615 EventTarget::removeAllEventListeners();
1617 #if ENABLE(DEVICE_ORIENTATION)
1618 if (frame() && frame()->page() && frame()->page()->deviceMotionController())
1619 frame()->page()->deviceMotionController()->removeAllListeners(this);
1620 if (frame() && frame()->page() && frame()->page()->deviceOrientationController())
1621 frame()->page()->deviceOrientationController()->removeAllListeners(this);
1624 removeAllUnloadEventListeners(this);
1625 removeAllBeforeUnloadEventListeners(this);
1628 void DOMWindow::captureEvents()
1633 void DOMWindow::releaseEvents()
1638 void DOMWindow::finishedLoading()
1640 if (m_shouldPrintWhenFinishedLoading) {
1641 m_shouldPrintWhenFinishedLoading = false;
1646 EventTargetData* DOMWindow::eventTargetData()
1648 return &m_eventTargetData;
1651 EventTargetData* DOMWindow::ensureEventTargetData()
1653 return &m_eventTargetData;
1656 void DOMWindow::setLocation(const String& urlString, DOMWindow* activeWindow, DOMWindow* firstWindow, SetLocationLocking locking)
1661 Frame* activeFrame = activeWindow->frame();
1665 if (!activeFrame->loader()->shouldAllowNavigation(m_frame))
1668 Frame* firstFrame = firstWindow->frame();
1672 KURL completedURL = firstFrame->document()->completeURL(urlString);
1673 if (completedURL.isNull())
1676 if (isInsecureScriptAccess(activeWindow, completedURL))
1679 // We want a new history item if we are processing a user gesture.
1680 m_frame->navigationScheduler()->scheduleLocationChange(activeFrame->document()->securityOrigin(),
1681 completedURL, activeFrame->loader()->outgoingReferrer(),
1682 locking != LockHistoryBasedOnGestureState || !ScriptController::processingUserGesture(),
1683 locking != LockHistoryBasedOnGestureState);
1686 void DOMWindow::printErrorMessage(const String& message)
1688 if (message.isEmpty())
1691 Settings* settings = m_frame->settings();
1694 if (settings->privateBrowsingEnabled())
1697 // FIXME: Add arguments so that we can provide a correct source URL and line number.
1698 console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message, 1, String());
1701 String DOMWindow::crossDomainAccessErrorMessage(DOMWindow* activeWindow)
1703 const KURL& activeWindowURL = activeWindow->url();
1704 if (activeWindowURL.isNull())
1707 // FIXME: This error message should contain more specifics of why the same origin check has failed.
1708 // Perhaps we should involve the security origin object in composing it.
1709 // FIXME: This message, and other console messages, have extra newlines. Should remove them.
1710 return "Unsafe JavaScript attempt to access frame with URL " + m_url.string() + " from frame with URL " + activeWindowURL.string() + ". Domains, protocols and ports must match.\n";
1713 bool DOMWindow::isInsecureScriptAccess(DOMWindow* activeWindow, const String& urlString)
1715 if (!protocolIsJavaScript(urlString))
1718 // If m_frame->domWindow() != this, then |this| isn't the DOMWindow that's
1719 // currently active in the frame and there's no way we should allow the
1721 // 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
1723 if (m_frame->domWindow() == this) {
1724 // FIXME: Is there some way to eliminate the need for a separate "activeWindow == this" check?
1725 if (activeWindow == this)
1728 // FIXME: The name canAccess seems to be a roundabout way to ask "can execute script".
1729 // Can we name the SecurityOrigin function better to make this more clear?
1730 if (activeWindow->securityOrigin()->canAccess(securityOrigin()))
1734 printErrorMessage(crossDomainAccessErrorMessage(activeWindow));
1738 Frame* DOMWindow::createWindow(const String& urlString, const AtomicString& frameName, const WindowFeatures& windowFeatures,
1739 DOMWindow* activeWindow, Frame* firstFrame, Frame* openerFrame, PrepareDialogFunction function, void* functionContext)
1741 Frame* activeFrame = activeWindow->frame();
1743 // For whatever reason, Firefox uses the first frame to determine the outgoingReferrer. We replicate that behavior here.
1744 String referrer = firstFrame->loader()->outgoingReferrer();
1746 KURL completedURL = urlString.isEmpty() ? KURL(ParsedURLString, "") : firstFrame->document()->completeURL(urlString);
1747 ResourceRequest request(completedURL, referrer);
1748 FrameLoader::addHTTPOriginIfNeeded(request, firstFrame->loader()->outgoingOrigin());
1749 FrameLoadRequest frameRequest(activeWindow->securityOrigin(), request, frameName);
1751 // We pass the opener frame for the lookupFrame in case the active frame is different from
1752 // the opener frame, and the name references a frame relative to the opener frame.
1754 Frame* newFrame = WebCore::createWindow(activeFrame, openerFrame, frameRequest, windowFeatures, created);
1758 newFrame->loader()->setOpener(openerFrame);
1759 newFrame->page()->setOpenedByDOM();
1761 if (newFrame->domWindow()->isInsecureScriptAccess(activeWindow, completedURL))
1765 function(newFrame->domWindow(), functionContext);
1768 newFrame->loader()->changeLocation(activeWindow->securityOrigin(), completedURL, referrer, false, false);
1769 else if (!urlString.isEmpty()) {
1770 bool lockHistory = !ScriptController::processingUserGesture();
1771 newFrame->navigationScheduler()->scheduleLocationChange(activeWindow->securityOrigin(), completedURL.string(), referrer, lockHistory, false);
1777 PassRefPtr<DOMWindow> DOMWindow::open(const String& urlString, const AtomicString& frameName, const String& windowFeaturesString,
1778 DOMWindow* activeWindow, DOMWindow* firstWindow)
1782 Frame* activeFrame = activeWindow->frame();
1785 Frame* firstFrame = firstWindow->frame();
1789 if (!firstWindow->allowPopUp()) {
1790 // Because FrameTree::find() returns true for empty strings, we must check for empty frame names.
1791 // Otherwise, illegitimate window.open() calls with no name will pass right through the popup blocker.
1792 if (frameName.isEmpty() || !m_frame->tree()->find(frameName))
1796 // Get the target frame for the special cases of _top and _parent.
1797 // In those cases, we schedule a location change right now and return early.
1798 Frame* targetFrame = 0;
1799 if (frameName == "_top")
1800 targetFrame = m_frame->tree()->top();
1801 else if (frameName == "_parent") {
1802 if (Frame* parent = m_frame->tree()->parent())
1803 targetFrame = parent;
1805 targetFrame = m_frame;
1808 if (!activeFrame->loader()->shouldAllowNavigation(targetFrame))
1811 KURL completedURL = firstFrame->document()->completeURL(urlString);
1813 if (targetFrame->domWindow()->isInsecureScriptAccess(activeWindow, completedURL))
1814 return targetFrame->domWindow();
1816 if (urlString.isEmpty())
1817 return targetFrame->domWindow();
1819 // For whatever reason, Firefox uses the first window rather than the active window to
1820 // determine the outgoing referrer. We replicate that behavior here.
1821 bool lockHistory = !ScriptController::processingUserGesture();
1822 targetFrame->navigationScheduler()->scheduleLocationChange(
1823 activeFrame->document()->securityOrigin(),
1825 firstFrame->loader()->outgoingReferrer(),
1828 return targetFrame->domWindow();
1831 WindowFeatures windowFeatures(windowFeaturesString);
1832 FloatRect windowRect(windowFeatures.xSet ? windowFeatures.x : 0, windowFeatures.ySet ? windowFeatures.y : 0,
1833 windowFeatures.widthSet ? windowFeatures.width : 0, windowFeatures.heightSet ? windowFeatures.height : 0);
1834 Page* page = m_frame->page();
1835 DOMWindow::adjustWindowRect(screenAvailableRect(page ? page->mainFrame()->view() : 0), windowRect, windowRect);
1836 windowFeatures.x = windowRect.x();
1837 windowFeatures.y = windowRect.y();
1838 windowFeatures.height = windowRect.height();
1839 windowFeatures.width = windowRect.width();
1841 Frame* result = createWindow(urlString, frameName, windowFeatures, activeWindow, firstFrame, m_frame);
1842 return result ? result->domWindow() : 0;
1845 void DOMWindow::showModalDialog(const String& urlString, const String& dialogFeaturesString,
1846 DOMWindow* activeWindow, DOMWindow* firstWindow, PrepareDialogFunction function, void* functionContext)
1850 Frame* activeFrame = activeWindow->frame();
1853 Frame* firstFrame = firstWindow->frame();
1857 if (!canShowModalDialogNow(m_frame) || !firstWindow->allowPopUp())
1860 Frame* dialogFrame = createWindow(urlString, emptyAtom, WindowFeatures(dialogFeaturesString, screenAvailableRect(m_frame->view())),
1861 activeWindow, firstFrame, m_frame, function, functionContext);
1865 dialogFrame->page()->chrome()->runModal();
1869 DOMURL* DOMWindow::webkitURL() const
1872 m_domURL = DOMURL::create(this->scriptExecutionContext());
1873 return m_domURL.get();
1878 StorageInfo* DOMWindow::webkitStorageInfo() const
1881 m_storageInfo = StorageInfo::create();
1882 return m_storageInfo.get();
1886 } // namespace WebCore