WebCore:
Reviewed by John Sullivan.
No layout tests added because showModalDialog won't work in DumpRenderTree at the moment.
- WebKit part of fix for <rdar://problem/
3166090> add IE JavaScript extension window.showModalDialog
* khtml/ecma/kjs_window.cpp:
(KJS::allowPopUp): Added. Used by showModalDialog now and should be used by window.open later.
(KJS::parseFeatures): Ditto.
(KJS::boolFeature): Ditto.
(KJS::intFeature): Ditto.
(KJS::createNewWindow): Ditto.
(KJS::canShowModalDialog): Added.
(KJS::canShowModalDialogNow): Added.
(KJS::showModalDialog): Added.
(KJS::Window::get): Return the showModalDialog function object if the extension can run modal.
(KJS::Window::clear): Add code to store the return value for the case where the window is a modal dialog.
(KJS::WindowFunc::tryCall): Add the call to the showModalDialog function.
* khtml/ecma/kjs_window.h: Add setReturnValueSlot function so showModalDialog can get the return
value from the dialog it creates. Also add a data member to keep track of the pointer and a constant
for the ShowModalDialog method.
* khtml/khtml_part.h: Added new changeLocation member function. Made setOpener, openedByJS, and
setOpenedByJS public.
* khtml/khtml_part.cpp:
(KHTMLPart::changeLocation): Broke out the part of slotRedirect that actually does the location change
into a separate function so it can be called when needed. The case using it now is to load the content
of a new window in KJS::createNewWindow.
(KHTMLPart::slotRedirect): Call changeLocation to do most of the work.
(KHTMLPart::urlSelected): Fixed a broken case where the "lack of referrer" in a new window would cause
the referrer passed in by JavaScript to be ignored when opening a new window -- match logic elsewhere
that leaves the referrer in the args alone if one is not set in the window.
* khtml/khtmlpart_p.h: Initialize m_bCleared to true to avoid an unnecessary clear before loading the
first URL in a new window. This change is needed to avoid blowing away the "dialogArguments" value in
a modal dialog window, but it also avoid unnecessary work for each new window.
* kwq/KWQApplication.h: Add availableGeometry function for QDesktopWidget. Used by the showModalDialog
function inside kjs_window.cpp (and should be used elsewhere eventually too). Matches a Qt function that
we just didn't have implemented before.
* kwq/KWQApplication.mm: (QDesktopWidget::availableGeometry): Added.
* kwq/KWQKHTMLPartBrowserExtension.h: Added new canRunModal, canRunModalNow, and runModal functions.
* kwq/KWQKHTMLPartBrowserExtension.mm:
(KHTMLPartBrowserExtension::createNewWindow): Call createModalDialogWithURL on the bridge if the
new window is a dialog. Also fixed the early return case for when the bridge returns nil.
(KHTMLPartBrowserExtension::canRunModal): Added. Calls bridge.
(KHTMLPartBrowserExtension::canRunModalNow): Ditto.
(KHTMLPartBrowserExtension::runModal): Ditto.
* kwq/KWQKPartsBrowserExtension.h:
(KParts::URLArgs::URLArgs): Initialize m_lockHistory to false.
(KParts::WindowArgs::WindowArgs): Add a dialog boolean.
* kwq/WebCoreBridge.h: Declared canRunModal, canRunModalNow, createModalDialogWithURL, and runModal methods.
WebKit:
Reviewed by John Sullivan.
- WebKit part of fix for <rdar://problem/
3166090> add IE JavaScript extension window.showModalDialog
* WebCoreSupport.subproj/WebBridge.m:
(-[WebBridge createModalDialogWithURL:]): Added. Calls the UI delegate, falling back to the generic
"create WebView" method.
(-[WebBridge canRunModal]): Added. Checks the UI delegate to see if it implements runModal.
(-[WebBridge canRunModalNow]): Added. Checks the "inConnectionCallback" field so we can prevent
deadlock since we can't do any I/O while inside a connection callback until this aspect of NSURLConnection
is changed.
(-[WebBridge runModal]): Added. Sets "defersCallbacks" on all other web views in the group, then
calls runModal on the UI delegate.
* WebView.subproj/WebBaseResourceHandleDelegate.h: Added inConnectionCallback class method.
* WebView.subproj/WebBaseResourceHandleDelegate.m:
(-[WebBaseResourceHandleDelegate connection:willSendRequest:redirectResponse:]): Bump count and then
decrement count so we can tell if we are in a callback.
(-[WebBaseResourceHandleDelegate connection:didReceiveAuthenticationChallenge:]): Ditto.
(-[WebBaseResourceHandleDelegate connection:didCancelAuthenticationChallenge:]): Ditto.
(-[WebBaseResourceHandleDelegate connection:didReceiveResponse:]): Ditto.
(-[WebBaseResourceHandleDelegate connection:didReceiveData:lengthReceived:]): Ditto.
(-[WebBaseResourceHandleDelegate connection:willStopBufferingData:]): Ditto.
(-[WebBaseResourceHandleDelegate connectionDidFinishLoading:]): Ditto.
(-[WebBaseResourceHandleDelegate connection:didFailWithError:]): Ditto.
(-[WebBaseResourceHandleDelegate connection:willCacheResponse:]): Ditto.
(+[WebBaseResourceHandleDelegate inConnectionCallback]): Added. Return YES if count is not 0.
* WebView.subproj/WebMainResourceClient.m:
(-[WebMainResourceClient receivedError:]): Changed to use the method without the connection: parameter
in the base class, since we no longer are overriding the connection: version.
(-[WebMainResourceClient willSendRequest:redirectResponse:]): Change to override the version without
the connection prefix/parameter; now only the base class overrides the actual connection delegate methods.
(-[WebMainResourceClient continueAfterContentPolicy:response:]): Ditto.
(-[WebMainResourceClient didReceiveResponse:]): Ditto.
(-[WebMainResourceClient didReceiveData:lengthReceived:]): Ditto.
(-[WebMainResourceClient didFinishLoading]): Ditto.
(-[WebMainResourceClient didFailWithError:]): Ditto.
(-[WebMainResourceClient loadWithRequestNow:]): Call the method without the connection parameter.
* WebView.subproj/WebUIDelegatePrivate.h: Added new SPI here that WebBrowser implements.
WebBrowser:
Reviewed by John.
- WebBrowser part of fix for <rdar://problem/
3166090> add IE JavaScript extension window.showModalDialog
* AppController.m: (-[AppController validateUserInterfaceItem:]): Disable the find panel
when there's a modal panel up.
* BrowserApplication.m: (-[BrowserApplication nextEventMatchingMask:untilDate:inMode:dequeue:]):
Force the event loop to use the default run loop mode instead of the modal panel mode for
modal BrowserWindows. This is required to work around the WebFoundation issue where it will
only give us data in the default run loop mode.
* BrowserDocument.m:
(-[BrowserDocument canAddBookmark]): Return NO when a modal window is up.
(-[BrowserDocument canViewSource]): Ditto.
(-[BrowserDocument canMailPage]): Ditto.
(-[BrowserDocument canMailPageAddress]): Ditto.
(-[BrowserDocument canOpenInDashboard]): Ditto.
(-[BrowserDocument canSave]): Ditto.
(-[BrowserDocument validateUserInterfaceItem:]): Disable save commands when modal window is up.
Also implement validation for all three of the save commands that we implement.
* BrowserDocumentController.m: (-[BrowserDocumentController validateUserInterfaceItem:]):
Disable newTab: when modal window is up.
* BrowserWebView.m:
(-[BrowserWebView webView:createWebViewModalDialogWithRequest:]): Added. Creates a window that
has no toolbar, which is an efficient way to disable all the toolbar-related commands for that
window, even ones built into AppKit which otherwise would be difficult to disable.
(-[BrowserWebView webViewRunModal:]): Added. Currently just calls -[NSApplication runModalForWindow:]
but could do more in the future. More importantly, having this implemented is how the Web Kit can
tell that this application supports modal web dialogs.
(-[BrowserWebView validateUserInterfaceItem:]): Disable setPageForSnapBackToCurrentPage: for
modal windows.
* BrowserWindow.m: (-[BrowserWindow close]): Abort the modal session if the window being closed is
the modal window. This is the only way we return from webViewRunModal:.
* BrowserWindowController.m:
(-[BrowserWindowController canShowInputFields]): Return no when this window is modal.
(-[BrowserWindowController validateUserInterfaceItem:]): Disable newTab: and newBookmarkFolder: when
modal window is up.
(-[BrowserWindowController validateMenuItem:]): Disable Show/Hide of address bar, bookmarks bar,
bookmarks collection, and toggleFullScreen: when modal window is up.
(-[BrowserWindowController showWindow:]): Change code so that a new window always comes up behind
a modal window. Also rearranged things so that setWindowFocusDisabled:YES will be called in any
case where the window does not start out as key.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@9250
268f45cc-cd09-0410-ab3c-
d52691b4dbfc