[webkit-changes] cvs commit: WebCore/kwq KWQApplication.h
KWQApplication.mm KWQKHTMLPartBrowserExtension.h
KWQKHTMLPartBrowserExtension.mm KWQKPartsBrowserExtension.h
WebCoreBridge.h
Adele
adele at opensource.apple.com
Fri Jul 1 18:33:01 PDT 2005
adele 05/07/01 18:33:00
Modified: . Tag: Safari-2-0-branch ChangeLog
WebCoreSupport.subproj Tag: Safari-2-0-branch WebBridge.m
WebView.subproj Tag: Safari-2-0-branch
WebBaseResourceHandleDelegate.h
WebBaseResourceHandleDelegate.m WebLoader.h
WebLoader.m WebMainResourceClient.m
WebMainResourceLoader.m WebUIDelegatePrivate.h
. Tag: Safari-2-0-branch ChangeLog
khtml Tag: Safari-2-0-branch khtml_part.cpp khtml_part.h
khtmlpart_p.h
khtml/ecma Tag: Safari-2-0-branch kjs_window.cpp
kjs_window.h kjs_window.lut.h
kwq Tag: Safari-2-0-branch KWQApplication.h
KWQApplication.mm KWQKHTMLPartBrowserExtension.h
KWQKHTMLPartBrowserExtension.mm
KWQKPartsBrowserExtension.h WebCoreBridge.h
Log:
WebCore:
Merged fix from TOT to Safari-2-0-branch
<rdar://problem/4164982> add IE JavaScript extension window.showModalDialog
2005-06-01 Darin Adler <darin at apple.com>
Reviewed by John Sullivan.
No layout tests added because showModalDialog won't work in DumpRenderTree at the moment.
- WebCore 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:
Merged fix from TOT to Safari-2-0-branch
<rdar://problem/4164982> add IE JavaScript extension window.showModalDialog
2005-06-01 Darin Adler <darin at apple.com>
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.
Revision Changes Path
No revision
No revision
1.3118.4.15 +49 -0 WebKit/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebKit/ChangeLog,v
retrieving revision 1.3118.4.14
retrieving revision 1.3118.4.15
diff -u -r1.3118.4.14 -r1.3118.4.15
--- ChangeLog 28 Jun 2005 00:24:03 -0000 1.3118.4.14
+++ ChangeLog 2 Jul 2005 01:32:41 -0000 1.3118.4.15
@@ -1,3 +1,52 @@
+2005-07-01 Adele Peterson <adele at apple.com>
+
+ Merged fix from TOT to Safari-2-0-branch
+ <rdar://problem/4164982> add IE JavaScript extension window.showModalDialog
+
+ 2005-06-01 Darin Adler <darin at apple.com>
+
+ 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.
+
=== WebKit-412.6.1 ===
2005-06-27 Adele Peterson <adele at apple.com>
No revision
No revision
1.340.8.3 +76 -0 WebKit/WebCoreSupport.subproj/WebBridge.m
Index: WebBridge.m
===================================================================
RCS file: /cvs/root/WebKit/WebCoreSupport.subproj/WebBridge.m,v
retrieving revision 1.340.8.2
retrieving revision 1.340.8.3
diff -u -r1.340.8.2 -r1.340.8.3
--- WebBridge.m 27 Jun 2005 23:54:12 -0000 1.340.8.2
+++ WebBridge.m 2 Jul 2005 01:32:44 -0000 1.340.8.3
@@ -10,6 +10,7 @@
#import <WebKit/WebBaseNetscapePluginView.h>
#import <WebKit/WebBasePluginPackage.h>
#import <WebKit/WebBaseResourceHandleDelegate.h>
+#import "WebControllerSets.h"
#import <WebKit/WebDataSourcePrivate.h>
#import <WebKit/WebDefaultUIDelegate.h>
#import <WebKit/WebEditingDelegate.h>
@@ -1566,4 +1567,79 @@
return [isPreviousCharacter ? _getPreSmartSet() : _getPostSmartSet() characterIsMember:c];
}
+- (WebCoreBridge *)createModalDialogWithURL:(NSURL *)URL
+{
+ ASSERT(_frame != nil);
+
+ NSMutableURLRequest *request = nil;
+
+ if (URL != nil && ![URL _web_isEmpty]) {
+ request = [NSMutableURLRequest requestWithURL:URL];
+ [request setHTTPReferrer:[self referrer]];
+ }
+
+ WebView *currentWebView = [_frame webView];
+ id UIDelegate = [currentWebView UIDelegate];
+
+ WebView *newWebView = nil;
+ if ([UIDelegate respondsToSelector:@selector(webView:createWebViewModalDialogWithRequest:)])
+ newWebView = [UIDelegate webView:currentWebView createWebViewModalDialogWithRequest:request];
+ else if ([UIDelegate respondsToSelector:@selector(webView:createWebViewWithRequest:)])
+ newWebView = [UIDelegate webView:currentWebView createWebViewWithRequest:request];
+ else
+ newWebView = [[WebDefaultUIDelegate sharedUIDelegate] webView:currentWebView createWebViewWithRequest:request];
+
+ return [[newWebView mainFrame] _bridge];
+}
+
+- (BOOL)canRunModal
+{
+ WebView *webView = [_frame webView];
+ id UIDelegate = [webView UIDelegate];
+ return [UIDelegate respondsToSelector:@selector(webViewRunModal:)];
+}
+
+- (BOOL)canRunModalNow
+{
+ return [self canRunModal] && ![WebBaseResourceHandleDelegate inConnectionCallback];
+}
+
+- (void)runModal
+{
+ if (![self canRunModal])
+ return;
+
+ WebView *webView = [_frame webView];
+ if ([webView defersCallbacks]) {
+ ERROR("tried to run modal in a view when it was deferring callbacks -- should never happen");
+ return;
+ }
+
+ // Defer callbacks in all the other views in this group, so we don't try to run JavaScript
+ // in a way that could interact with this view.
+ NSMutableArray *deferredWebViews = [NSMutableArray array];
+ NSString *setName = [webView groupName];
+ if (setName) {
+ NSEnumerator *enumerator = [WebViewSets webViewsInSetNamed:setName];
+ WebView *otherWebView;
+ while ((otherWebView = [enumerator nextObject]) != nil) {
+ if (otherWebView != webView && ![otherWebView defersCallbacks]) {
+ [otherWebView setDefersCallbacks:YES];
+ [deferredWebViews addObject:otherWebView];
+ }
+ }
+ }
+
+ // Go run the modal event loop.
+ [[webView UIDelegate] webViewRunModal:webView];
+
+ // Restore the callbacks for any views that we deferred them for.
+ unsigned count = [deferredWebViews count];
+ unsigned i;
+ for (i = 0; i < count; ++i) {
+ WebView *otherWebView = [deferredWebViews objectAtIndex:i];
+ [otherWebView setDefersCallbacks:NO];
+ }
+}
+
@end
No revision
No revision
1.38.10.2 +4 -1 WebKit/WebView.subproj/Attic/WebBaseResourceHandleDelegate.h
Index: WebBaseResourceHandleDelegate.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/Attic/WebBaseResourceHandleDelegate.h,v
retrieving revision 1.38.10.1
retrieving revision 1.38.10.2
diff -u -r1.38.10.1 -r1.38.10.2
--- WebBaseResourceHandleDelegate.h 28 Jun 2005 00:20:34 -0000 1.38.10.1
+++ WebBaseResourceHandleDelegate.h 2 Jul 2005 01:32:45 -0000 1.38.10.2
@@ -78,10 +78,13 @@
- (void)didFailWithError:(NSError *)error;
- (NSCachedURLResponse *)willCacheResponse:(NSCachedURLResponse *)cachedResponse;
+// Used to work around the fact that you don't get any more NSURLConnection callbacks until you return from the first one.
++ (BOOL)inConnectionCallback;
+
@end
// Note: This interface can be removed once this method is declared
// in Foundation (probably will be in Foundation-485).
@interface NSObject (WebBaseResourceHandleDelegateExtras)
- (void)connection:(NSURLConnection *)con didReceiveData:(NSData *)data lengthReceived:(long long)lengthReceived;
- at end
\ No newline at end of file
+ at end
1.83.4.2 +29 -2 WebKit/WebView.subproj/Attic/WebBaseResourceHandleDelegate.m
Index: WebBaseResourceHandleDelegate.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/Attic/WebBaseResourceHandleDelegate.m,v
retrieving revision 1.83.4.1
retrieving revision 1.83.4.2
diff -u -r1.83.4.1 -r1.83.4.2
--- WebBaseResourceHandleDelegate.m 24 May 2005 01:22:43 -0000 1.83.4.1
+++ WebBaseResourceHandleDelegate.m 2 Jul 2005 01:32:45 -0000 1.83.4.2
@@ -27,6 +27,7 @@
#import <WebKit/WebResourcePrivate.h>
#import <WebKit/WebViewPrivate.h>
+static unsigned inNSURLConnectionCallback;
static BOOL NSURLConnectionSupportsBufferedData;
@interface NSURLConnection (NSURLConnectionTigerPrivate)
@@ -564,37 +565,50 @@
- (NSURLRequest *)connection:(NSURLConnection *)con willSendRequest:(NSURLRequest *)newRequest redirectResponse:(NSURLResponse *)redirectResponse
{
ASSERT(con == connection);
- return [self willSendRequest:newRequest redirectResponse:redirectResponse];
+ ++inNSURLConnectionCallback;
+ NSURLRequest *result = [self willSendRequest:newRequest redirectResponse:redirectResponse];
+ --inNSURLConnectionCallback;
+ return result;
}
- (void)connection:(NSURLConnection *)con didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
ASSERT(con == connection);
+ ++inNSURLConnectionCallback;
[self didReceiveAuthenticationChallenge:challenge];
+ --inNSURLConnectionCallback;
}
- (void)connection:(NSURLConnection *)con didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
ASSERT(con == connection);
+ ++inNSURLConnectionCallback;
[self didCancelAuthenticationChallenge:challenge];
+ --inNSURLConnectionCallback;
}
- (void)connection:(NSURLConnection *)con didReceiveResponse:(NSURLResponse *)r
{
ASSERT(con == connection);
+ ++inNSURLConnectionCallback;
[self didReceiveResponse:r];
+ --inNSURLConnectionCallback;
}
- (void)connection:(NSURLConnection *)con didReceiveData:(NSData *)data lengthReceived:(long long)lengthReceived
{
ASSERT(con == connection);
+ ++inNSURLConnectionCallback;
[self didReceiveData:data lengthReceived:lengthReceived];
+ --inNSURLConnectionCallback;
}
- (void)connection:(NSURLConnection *)con willStopBufferingData:(NSData *)data
{
ASSERT(con == connection);
+ ++inNSURLConnectionCallback;
[self willStopBufferingData:data];
+ --inNSURLConnectionCallback;
}
- (void)connectionDidFinishLoading:(NSURLConnection *)con
@@ -602,19 +616,27 @@
// don't worry about checking connection consistency if this load
// got cancelled while finishing.
ASSERT(cancelledFlag || con == connection);
+ ++inNSURLConnectionCallback;
[self didFinishLoading];
+ --inNSURLConnectionCallback;
}
- (void)connection:(NSURLConnection *)con didFailWithError:(NSError *)error
{
ASSERT(con == connection);
+ ++inNSURLConnectionCallback;
[self didFailWithError:error];
+ --inNSURLConnectionCallback;
}
- (NSCachedURLResponse *)connection:(NSURLConnection *)con willCacheResponse:(NSCachedURLResponse *)cachedResponse
{
ASSERT(con == connection);
- return [self willCacheResponse:cachedResponse];
+
+ ++inNSURLConnectionCallback;
+ NSCachedURLResponse *result = [self willCacheResponse:cachedResponse];
+ --inNSURLConnectionCallback;
+ return result;
}
- (void)cancelWithError:(NSError *)error
@@ -673,4 +695,9 @@
return response;
}
++ (BOOL)inConnectionCallback
+{
+ return inNSURLConnectionCallback != 0;
+}
+
@end
1.38.10.2 +4 -1 WebKit/WebView.subproj/WebLoader.h
Index: WebLoader.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebLoader.h,v
retrieving revision 1.38.10.1
retrieving revision 1.38.10.2
diff -u -r1.38.10.1 -r1.38.10.2
--- WebLoader.h 28 Jun 2005 00:20:34 -0000 1.38.10.1
+++ WebLoader.h 2 Jul 2005 01:32:45 -0000 1.38.10.2
@@ -78,10 +78,13 @@
- (void)didFailWithError:(NSError *)error;
- (NSCachedURLResponse *)willCacheResponse:(NSCachedURLResponse *)cachedResponse;
+// Used to work around the fact that you don't get any more NSURLConnection callbacks until you return from the first one.
++ (BOOL)inConnectionCallback;
+
@end
// Note: This interface can be removed once this method is declared
// in Foundation (probably will be in Foundation-485).
@interface NSObject (WebBaseResourceHandleDelegateExtras)
- (void)connection:(NSURLConnection *)con didReceiveData:(NSData *)data lengthReceived:(long long)lengthReceived;
- at end
\ No newline at end of file
+ at end
1.83.4.2 +29 -2 WebKit/WebView.subproj/WebLoader.m
Index: WebLoader.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebLoader.m,v
retrieving revision 1.83.4.1
retrieving revision 1.83.4.2
diff -u -r1.83.4.1 -r1.83.4.2
--- WebLoader.m 24 May 2005 01:22:43 -0000 1.83.4.1
+++ WebLoader.m 2 Jul 2005 01:32:45 -0000 1.83.4.2
@@ -27,6 +27,7 @@
#import <WebKit/WebResourcePrivate.h>
#import <WebKit/WebViewPrivate.h>
+static unsigned inNSURLConnectionCallback;
static BOOL NSURLConnectionSupportsBufferedData;
@interface NSURLConnection (NSURLConnectionTigerPrivate)
@@ -564,37 +565,50 @@
- (NSURLRequest *)connection:(NSURLConnection *)con willSendRequest:(NSURLRequest *)newRequest redirectResponse:(NSURLResponse *)redirectResponse
{
ASSERT(con == connection);
- return [self willSendRequest:newRequest redirectResponse:redirectResponse];
+ ++inNSURLConnectionCallback;
+ NSURLRequest *result = [self willSendRequest:newRequest redirectResponse:redirectResponse];
+ --inNSURLConnectionCallback;
+ return result;
}
- (void)connection:(NSURLConnection *)con didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
ASSERT(con == connection);
+ ++inNSURLConnectionCallback;
[self didReceiveAuthenticationChallenge:challenge];
+ --inNSURLConnectionCallback;
}
- (void)connection:(NSURLConnection *)con didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
ASSERT(con == connection);
+ ++inNSURLConnectionCallback;
[self didCancelAuthenticationChallenge:challenge];
+ --inNSURLConnectionCallback;
}
- (void)connection:(NSURLConnection *)con didReceiveResponse:(NSURLResponse *)r
{
ASSERT(con == connection);
+ ++inNSURLConnectionCallback;
[self didReceiveResponse:r];
+ --inNSURLConnectionCallback;
}
- (void)connection:(NSURLConnection *)con didReceiveData:(NSData *)data lengthReceived:(long long)lengthReceived
{
ASSERT(con == connection);
+ ++inNSURLConnectionCallback;
[self didReceiveData:data lengthReceived:lengthReceived];
+ --inNSURLConnectionCallback;
}
- (void)connection:(NSURLConnection *)con willStopBufferingData:(NSData *)data
{
ASSERT(con == connection);
+ ++inNSURLConnectionCallback;
[self willStopBufferingData:data];
+ --inNSURLConnectionCallback;
}
- (void)connectionDidFinishLoading:(NSURLConnection *)con
@@ -602,19 +616,27 @@
// don't worry about checking connection consistency if this load
// got cancelled while finishing.
ASSERT(cancelledFlag || con == connection);
+ ++inNSURLConnectionCallback;
[self didFinishLoading];
+ --inNSURLConnectionCallback;
}
- (void)connection:(NSURLConnection *)con didFailWithError:(NSError *)error
{
ASSERT(con == connection);
+ ++inNSURLConnectionCallback;
[self didFailWithError:error];
+ --inNSURLConnectionCallback;
}
- (NSCachedURLResponse *)connection:(NSURLConnection *)con willCacheResponse:(NSCachedURLResponse *)cachedResponse
{
ASSERT(con == connection);
- return [self willCacheResponse:cachedResponse];
+
+ ++inNSURLConnectionCallback;
+ NSCachedURLResponse *result = [self willCacheResponse:cachedResponse];
+ --inNSURLConnectionCallback;
+ return result;
}
- (void)cancelWithError:(NSError *)error
@@ -673,4 +695,9 @@
return response;
}
++ (BOOL)inConnectionCallback
+{
+ return inNSURLConnectionCallback != 0;
+}
+
@end
1.260.8.2 +18 -20 WebKit/WebView.subproj/Attic/WebMainResourceClient.m
Index: WebMainResourceClient.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/Attic/WebMainResourceClient.m,v
retrieving revision 1.260.8.1
retrieving revision 1.260.8.2
diff -u -r1.260.8.1 -r1.260.8.2
--- WebMainResourceClient.m 28 Jun 2005 00:20:34 -0000 1.260.8.1
+++ WebMainResourceClient.m 2 Jul 2005 01:32:45 -0000 1.260.8.2
@@ -70,7 +70,7 @@
// Calling _receivedMainResourceError will likely result in a call to release, so we must retain.
[self retain];
[dataSource _receivedMainResourceError:error complete:YES];
- [super connection:connection didFailWithError:error];
+ [super didFailWithError:error];
[self release];
}
@@ -141,7 +141,7 @@
// Override. We don't want to save the main resource as a subresource of the data source.
}
-- (NSURLRequest *)connection:(NSURLConnection *)con willSendRequest:(NSURLRequest *)newRequest redirectResponse:(NSURLResponse *)redirectResponse
+- (NSURLRequest *)willSendRequest:(NSURLRequest *)newRequest redirectResponse:(NSURLResponse *)redirectResponse
{
// Note that there are no asserts here as there are for the other callbacks. This is due to the
// fact that this "callback" is sent when starting every load, and the state of callback
@@ -183,7 +183,7 @@
// Note super will make a copy for us, so reassigning newRequest is important. Since we are returning this value, but
// it's only guaranteed to be retained by self, and self might be dealloc'ed in this method, we have to autorelease.
// See 3777253 for an example.
- newRequest = [[[super connection:con willSendRequest:newRequest redirectResponse:redirectResponse] retain] autorelease];
+ newRequest = [[[super willSendRequest:newRequest redirectResponse:redirectResponse] retain] autorelease];
// Don't set this on the first request. It is set
// when the main load was started.
@@ -242,12 +242,10 @@
[self retain];
- [super connection:connection didReceiveResponse:r];
-
- if (![dataSource _isStopping]
- && ([[request URL] _webkit_shouldLoadAsEmptyDocument]
- || [WebView _representationExistsForURLScheme:[[request URL] scheme]])) {
- [self connectionDidFinishLoading:connection];
+ [super didReceiveResponse:r];
+
+ if (![dataSource _isStopping] && ([URL _webkit_shouldLoadAsEmptyDocument] || [WebView _representationExistsForURLScheme:[URL scheme]])) {
+ [self didFinishLoading];
}
[self release];
@@ -282,9 +280,9 @@
}
-- (void)connection:(NSURLConnection *)con didReceiveResponse:(NSURLResponse *)r
+- (void)didReceiveResponse:(NSURLResponse *)r
{
- ASSERT([[r URL] _webkit_shouldLoadAsEmptyDocument] || ![con defersCallbacks]);
+ ASSERT([[r URL] _webkit_shouldLoadAsEmptyDocument] || ![connection defersCallbacks]);
ASSERT([[r URL] _webkit_shouldLoadAsEmptyDocument] || ![self defersCallbacks]);
ASSERT([[r URL] _webkit_shouldLoadAsEmptyDocument] || ![[dataSource _webView] defersCallbacks]);
@@ -323,7 +321,7 @@
[self release];
}
-- (void)connection:(NSURLConnection *)con didReceiveData:(NSData *)data lengthReceived:(long long)lengthReceived
+- (void)didReceiveData:(NSData *)data lengthReceived:(long long)lengthReceived
{
ASSERT(data);
ASSERT([data length] != 0);
@@ -340,16 +338,16 @@
fromDataSource:dataSource
complete:NO];
- [super connection:con didReceiveData:data lengthReceived:lengthReceived];
+ [super didReceiveData:data lengthReceived:lengthReceived];
_bytesReceived += [data length];
LOG(Loading, "%d of %d", _bytesReceived, _contentLength);
[self release];
}
-- (void)connectionDidFinishLoading:(NSURLConnection *)con
+- (void)didFinishLoading
{
- ASSERT([[dataSource _URL] _webkit_shouldLoadAsEmptyDocument] || ![con defersCallbacks]);
+ ASSERT([[dataSource _URL] _webkit_shouldLoadAsEmptyDocument] || ![connection defersCallbacks]);
ASSERT([[dataSource _URL] _webkit_shouldLoadAsEmptyDocument] || ![self defersCallbacks]);
ASSERT([[dataSource _URL] _webkit_shouldLoadAsEmptyDocument] || ![[dataSource _webView] defersCallbacks]);
@@ -362,14 +360,14 @@
[[dataSource _webView] _mainReceivedBytesSoFar:_bytesReceived
fromDataSource:dataSource
complete:YES];
- [super connectionDidFinishLoading:con];
+ [super didFinishLoading];
[self release];
}
-- (void)connection:(NSURLConnection *)con didFailWithError:(NSError *)error
+- (void)didFailWithError:(NSError *)error
{
- ASSERT(![con defersCallbacks]);
+ ASSERT(![connection defersCallbacks]);
ASSERT(![self defersCallbacks]);
ASSERT(![[dataSource _webView] defersCallbacks]);
@@ -389,7 +387,7 @@
// Send this synthetic delegate callback since clients expect it, and
// we no longer send the callback from within NSURLConnection for
// initial requests.
- r = [self connection:nil willSendRequest:r redirectResponse:nil];
+ r = [self willSendRequest:r redirectResponse:nil];
NSURL *URL = [r URL];
BOOL shouldLoadEmpty = [URL _webkit_shouldLoadAsEmptyDocument];
@@ -407,7 +405,7 @@
NSURLResponse *resp = [[NSURLResponse alloc] initWithURL:URL MIMEType:MIMEType
expectedContentLength:0 textEncodingName:nil];
- [self connection:nil didReceiveResponse:resp];
+ [self didReceiveResponse:resp];
[resp release];
} else {
connection = [[NSURLConnection alloc] initWithRequest:r delegate:proxy];
1.260.8.2 +18 -20 WebKit/WebView.subproj/WebMainResourceLoader.m
Index: WebMainResourceLoader.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebMainResourceLoader.m,v
retrieving revision 1.260.8.1
retrieving revision 1.260.8.2
diff -u -r1.260.8.1 -r1.260.8.2
--- WebMainResourceLoader.m 28 Jun 2005 00:20:34 -0000 1.260.8.1
+++ WebMainResourceLoader.m 2 Jul 2005 01:32:45 -0000 1.260.8.2
@@ -70,7 +70,7 @@
// Calling _receivedMainResourceError will likely result in a call to release, so we must retain.
[self retain];
[dataSource _receivedMainResourceError:error complete:YES];
- [super connection:connection didFailWithError:error];
+ [super didFailWithError:error];
[self release];
}
@@ -141,7 +141,7 @@
// Override. We don't want to save the main resource as a subresource of the data source.
}
-- (NSURLRequest *)connection:(NSURLConnection *)con willSendRequest:(NSURLRequest *)newRequest redirectResponse:(NSURLResponse *)redirectResponse
+- (NSURLRequest *)willSendRequest:(NSURLRequest *)newRequest redirectResponse:(NSURLResponse *)redirectResponse
{
// Note that there are no asserts here as there are for the other callbacks. This is due to the
// fact that this "callback" is sent when starting every load, and the state of callback
@@ -183,7 +183,7 @@
// Note super will make a copy for us, so reassigning newRequest is important. Since we are returning this value, but
// it's only guaranteed to be retained by self, and self might be dealloc'ed in this method, we have to autorelease.
// See 3777253 for an example.
- newRequest = [[[super connection:con willSendRequest:newRequest redirectResponse:redirectResponse] retain] autorelease];
+ newRequest = [[[super willSendRequest:newRequest redirectResponse:redirectResponse] retain] autorelease];
// Don't set this on the first request. It is set
// when the main load was started.
@@ -242,12 +242,10 @@
[self retain];
- [super connection:connection didReceiveResponse:r];
-
- if (![dataSource _isStopping]
- && ([[request URL] _webkit_shouldLoadAsEmptyDocument]
- || [WebView _representationExistsForURLScheme:[[request URL] scheme]])) {
- [self connectionDidFinishLoading:connection];
+ [super didReceiveResponse:r];
+
+ if (![dataSource _isStopping] && ([URL _webkit_shouldLoadAsEmptyDocument] || [WebView _representationExistsForURLScheme:[URL scheme]])) {
+ [self didFinishLoading];
}
[self release];
@@ -282,9 +280,9 @@
}
-- (void)connection:(NSURLConnection *)con didReceiveResponse:(NSURLResponse *)r
+- (void)didReceiveResponse:(NSURLResponse *)r
{
- ASSERT([[r URL] _webkit_shouldLoadAsEmptyDocument] || ![con defersCallbacks]);
+ ASSERT([[r URL] _webkit_shouldLoadAsEmptyDocument] || ![connection defersCallbacks]);
ASSERT([[r URL] _webkit_shouldLoadAsEmptyDocument] || ![self defersCallbacks]);
ASSERT([[r URL] _webkit_shouldLoadAsEmptyDocument] || ![[dataSource _webView] defersCallbacks]);
@@ -323,7 +321,7 @@
[self release];
}
-- (void)connection:(NSURLConnection *)con didReceiveData:(NSData *)data lengthReceived:(long long)lengthReceived
+- (void)didReceiveData:(NSData *)data lengthReceived:(long long)lengthReceived
{
ASSERT(data);
ASSERT([data length] != 0);
@@ -340,16 +338,16 @@
fromDataSource:dataSource
complete:NO];
- [super connection:con didReceiveData:data lengthReceived:lengthReceived];
+ [super didReceiveData:data lengthReceived:lengthReceived];
_bytesReceived += [data length];
LOG(Loading, "%d of %d", _bytesReceived, _contentLength);
[self release];
}
-- (void)connectionDidFinishLoading:(NSURLConnection *)con
+- (void)didFinishLoading
{
- ASSERT([[dataSource _URL] _webkit_shouldLoadAsEmptyDocument] || ![con defersCallbacks]);
+ ASSERT([[dataSource _URL] _webkit_shouldLoadAsEmptyDocument] || ![connection defersCallbacks]);
ASSERT([[dataSource _URL] _webkit_shouldLoadAsEmptyDocument] || ![self defersCallbacks]);
ASSERT([[dataSource _URL] _webkit_shouldLoadAsEmptyDocument] || ![[dataSource _webView] defersCallbacks]);
@@ -362,14 +360,14 @@
[[dataSource _webView] _mainReceivedBytesSoFar:_bytesReceived
fromDataSource:dataSource
complete:YES];
- [super connectionDidFinishLoading:con];
+ [super didFinishLoading];
[self release];
}
-- (void)connection:(NSURLConnection *)con didFailWithError:(NSError *)error
+- (void)didFailWithError:(NSError *)error
{
- ASSERT(![con defersCallbacks]);
+ ASSERT(![connection defersCallbacks]);
ASSERT(![self defersCallbacks]);
ASSERT(![[dataSource _webView] defersCallbacks]);
@@ -389,7 +387,7 @@
// Send this synthetic delegate callback since clients expect it, and
// we no longer send the callback from within NSURLConnection for
// initial requests.
- r = [self connection:nil willSendRequest:r redirectResponse:nil];
+ r = [self willSendRequest:r redirectResponse:nil];
NSURL *URL = [r URL];
BOOL shouldLoadEmpty = [URL _webkit_shouldLoadAsEmptyDocument];
@@ -407,7 +405,7 @@
NSURLResponse *resp = [[NSURLResponse alloc] initWithURL:URL MIMEType:MIMEType
expectedContentLength:0 textEncodingName:nil];
- [self connection:nil didReceiveResponse:resp];
+ [self didReceiveResponse:resp];
[resp release];
} else {
connection = [[NSURLConnection alloc] initWithRequest:r delegate:proxy];
1.11.8.1 +3 -0 WebKit/WebView.subproj/WebUIDelegatePrivate.h
Index: WebUIDelegatePrivate.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebUIDelegatePrivate.h,v
retrieving revision 1.11
retrieving revision 1.11.8.1
diff -u -r1.11 -r1.11.8.1
--- WebUIDelegatePrivate.h 25 Jan 2005 22:41:36 -0000 1.11
+++ WebUIDelegatePrivate.h 2 Jul 2005 01:32:46 -0000 1.11.8.1
@@ -27,4 +27,7 @@
// regions is an dictionary whose keys are regions label and values are arrays of WebDashboardRegions.
- (void)webView:(WebView *)webView dashboardRegionsChanged:(NSDictionary *)regions;
+- (WebView *)webView:(WebView *)sender createWebViewModalDialogWithRequest:(NSURLRequest *)request;
+- (void)webViewRunModal:(WebView *)sender;
+
@end
No revision
No revision
1.4104.2.41 +65 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.4104.2.40
retrieving revision 1.4104.2.41
diff -u -r1.4104.2.40 -r1.4104.2.41
--- ChangeLog 1 Jul 2005 23:02:36 -0000 1.4104.2.40
+++ ChangeLog 2 Jul 2005 01:32:47 -0000 1.4104.2.41
@@ -1,6 +1,71 @@
2005-07-01 Adele Peterson <adele at apple.com>
Merged fix from TOT to Safari-2-0-branch
+ <rdar://problem/4164982> add IE JavaScript extension window.showModalDialog
+
+ 2005-06-01 Darin Adler <darin at apple.com>
+
+ Reviewed by John Sullivan.
+ No layout tests added because showModalDialog won't work in DumpRenderTree at the moment.
+
+ - WebCore 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.
+
+
+2005-07-01 Adele Peterson <adele at apple.com>
+
+ Merged fix from TOT to Safari-2-0-branch
<rdar://problem/4164966> Crash will occur when double-clicking outerHTML link on W3 DOM test
<rdar://problem/4164988> support outerHTML on IMG elements
No revision
No revision
1.311.8.6 +36 -27 WebCore/khtml/khtml_part.cpp
Index: khtml_part.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/khtml_part.cpp,v
retrieving revision 1.311.8.5
retrieving revision 1.311.8.6
diff -u -r1.311.8.5 -r1.311.8.6
--- khtml_part.cpp 14 Jun 2005 01:27:50 -0000 1.311.8.5
+++ khtml_part.cpp 2 Jul 2005 01:32:55 -0000 1.311.8.6
@@ -2105,6 +2105,30 @@
}
}
+void KHTMLPart::changeLocation(const QString &URL, const QString &referrer, bool lockHistory, bool userGesture)
+{
+ if (URL.find("javascript:", 0, false) == 0) {
+ QString script = KURL::decode_string(URL.mid(11));
+ QVariant result = executeScript(script, userGesture);
+ if (result.type() == QVariant::String) {
+ begin(url());
+ write(result.asString());
+ end();
+ }
+ return;
+ }
+
+ KParts::URLArgs args;
+
+ if (urlcmp(URL, m_url.url(), true, false))
+ args.reload = true;
+ args.setLockHistory(lockHistory);
+ if (!referrer.isEmpty())
+ args.metaData()["referrer"] = referrer;
+
+ urlSelected(URL, 0, 0, "_self", args);
+}
+
void KHTMLPart::slotRedirect()
{
if (d->m_scheduledRedirection == historyNavigationScheduled) {
@@ -2125,34 +2149,18 @@
}
return;
}
-
- QString u = d->m_redirectURL;
-
- d->m_scheduledRedirection = noRedirectionScheduled;
- d->m_delayRedirect = 0;
- d->m_redirectURL = QString::null;
- if ( u.find( QString::fromLatin1( "javascript:" ), 0, false ) == 0 )
- {
- QString script = KURL::decode_string( u.right( u.length() - 11 ) );
- //kdDebug( 6050 ) << "KHTMLPart::slotRedirect script=" << script << endl;
- QVariant res = executeScript( script, d->m_redirectUserGesture );
- if ( res.type() == QVariant::String ) {
- begin( url() );
- write( res.asString() );
- end();
- }
- return;
- }
- KParts::URLArgs args;
- if ( urlcmp( u, m_url.url(), true, false ) )
- args.reload = true;
- args.setLockHistory( d->m_redirectLockHistory );
- if (!d->m_redirectReferrer.isEmpty())
- args.metaData()["referrer"] = d->m_redirectReferrer;
- d->m_redirectReferrer = QString::null;
+ QString URL = d->m_redirectURL;
+ QString referrer = d->m_redirectReferrer;
+ bool lockHistory = d->m_redirectLockHistory;
+ bool userGesture = d->m_redirectUserGesture;
+
+ d->m_scheduledRedirection = noRedirectionScheduled;
+ d->m_delayRedirect = 0;
+ d->m_redirectURL = QString::null;
+ d->m_redirectReferrer = QString::null;
- urlSelected( u, 0, 0, "_self", args );
+ changeLocation(URL, referrer, lockHistory, userGesture);
}
void KHTMLPart::slotRedirection(KIO::Job*, const KURL& url)
@@ -2859,7 +2867,8 @@
#endif
#if APPLE_CHANGES
- args.metaData()["referrer"] = d->m_referrer;
+ if (!d->m_referrer.isEmpty())
+ args.metaData()["referrer"] = d->m_referrer;
KWQ(this)->urlSelected(cURL, button, state, args);
#else
if ( hasTarget )
1.127.8.2 +6 -5 WebCore/khtml/khtml_part.h
Index: khtml_part.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/khtml_part.h,v
retrieving revision 1.127.8.1
retrieving revision 1.127.8.2
diff -u -r1.127.8.1 -r1.127.8.2
--- khtml_part.h 14 Jun 2005 01:27:50 -0000 1.127.8.1
+++ khtml_part.h 2 Jul 2005 01:32:55 -0000 1.127.8.2
@@ -393,9 +393,10 @@
void scheduleRedirection(double delay, const QString &url, bool lockHistory = true);
/**
- * Schedules a location change.
- * This is used for JavaScript-triggered location changes.
+ * Make a location change, or schedule one for later.
+ * These are used for JavaScript-triggered location changes.
*/
+ void changeLocation(const QString &URL, const QString &referrer, bool lockHistory = true, bool userGesture = false);
void scheduleLocationChange(const QString &url, const QString &referrer, bool lockHistory = true, bool userGesture = false);
bool isScheduledLocationChangePending() const;
@@ -1315,13 +1316,13 @@
public:
#endif
KHTMLPart *opener();
+ void setOpener(KHTMLPart *_opener);
+ bool openedByJS();
+ void setOpenedByJS(bool _openedByJS);
#if APPLE_CHANGES
private:
#endif
long cacheId() const;
- void setOpener(KHTMLPart *_opener);
- bool openedByJS();
- void setOpenedByJS(bool _openedByJS);
void checkEmitLoadEvent();
void emitLoadEvent();
1.52.8.1 +1 -1 WebCore/khtml/khtmlpart_p.h
Index: khtmlpart_p.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/khtmlpart_p.h,v
retrieving revision 1.52
retrieving revision 1.52.8.1
diff -u -r1.52 -r1.52.8.1
--- khtmlpart_p.h 10 Mar 2005 01:00:26 -0000 1.52
+++ khtmlpart_p.h 2 Jul 2005 01:32:55 -0000 1.52.8.1
@@ -128,7 +128,7 @@
m_settings = new KHTMLSettings(*KHTMLFactory::defaultHTMLSettings());
#endif
m_bClearing = false;
- m_bCleared = false;
+ m_bCleared = true;
m_zoomFactor = 100;
m_bDnd = true;
#if !APPLE_CHANGES
No revision
No revision
1.146.8.4 +216 -2 WebCore/khtml/ecma/kjs_window.cpp
Index: kjs_window.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_window.cpp,v
retrieving revision 1.146.8.3
retrieving revision 1.146.8.4
diff -u -r1.146.8.3 -r1.146.8.4
--- kjs_window.cpp 24 May 2005 01:10:02 -0000 1.146.8.3
+++ kjs_window.cpp 2 Jul 2005 01:32:57 -0000 1.146.8.4
@@ -53,6 +53,7 @@
#include "khtmlview.h"
#include "khtml_part.h"
+#include "khtml_ext.h"
#include "dom/dom_string.h"
#include "dom/dom_node.h"
#include "editing/htmlediting.h"
@@ -71,6 +72,10 @@
using DOM::Position;
using khtml::TypingCommand;
+using KParts::ReadOnlyPart;
+using KParts::URLArgs;
+using KParts::WindowArgs;
+
using namespace KJS;
namespace KJS {
@@ -294,6 +299,7 @@
onsubmit Window::Onsubmit DontDelete
onunload Window::Onunload DontDelete
frameElement Window::FrameElement DontDelete|ReadOnly
+ showModalDialog Window::ShowModalDialog DontDelete|Function 1
@end
*/
IMPLEMENT_PROTOFUNC(WindowFunc)
@@ -460,6 +466,206 @@
return "[object Window]";
}
+static bool allowPopUp(ExecState *exec, Window *window)
+{
+#if APPLE_CHANGES
+ return window->part()
+ && (window->part()->settings()->JavaScriptCanOpenWindowsAutomatically()
+ || static_cast<ScriptInterpreter *>(exec->dynamicInterpreter())->wasRunByUserGesture());
+#else
+ KConfig config("konquerorrc");
+ config.setGroup("Java/JavaScript Settings");
+ switch (config.readUnsignedNumEntry("WindowOpenPolicy", 0)) { // 0=allow, 1=ask, 2=deny, 3=smart
+ default:
+ case 0: // allow
+ return true;
+ case 1: // ask
+ return KMessageBox::questionYesNo(widget,
+ i18n("This site is trying to open up a new browser window using Javascript.\n"
+ "Do you want to allow this?"),
+ i18n("Confirmation: Javascript Popup")) == KMessageBox::Yes;
+ case 2: // deny
+ return false;
+ case 3: // smart
+ return static_cast<ScriptInterpreter *>(exec->dynamicInterpreter())->wasRunByUserGesture();
+ }
+#endif
+}
+
+static QMap<QString, QString> parseFeatures(ExecState *exec, ValueImp *featuresArg)
+{
+ QMap<QString, QString> map;
+
+ QStringList features = QStringList::split(';', featuresArg->dispatchToString(exec).qstring());
+ QStringList::ConstIterator end = features.end();
+ for (QStringList::ConstIterator it = features.begin(); it != end; ++it) {
+ QString s = *it;
+ int pos = s.find('=');
+ if (pos < 0) {
+ // null string for value means key without value
+ map.insert(s.stripWhiteSpace().lower(), QString());
+ } else {
+ QString key = s.left(pos).stripWhiteSpace().lower();
+ QString val = s.mid(pos + 1).stripWhiteSpace().lower();
+ int spacePos = val.find(' ');
+ if (spacePos != -1)
+ val = val.left(spacePos);
+ map.insert(key, val);
+ }
+ }
+
+ return map;
+}
+
+static bool boolFeature(const QMap<QString, QString> &features, const char *key, bool defaultValue = false)
+{
+ QMap<QString, QString>::ConstIterator it = features.find(key);
+ if (it == features.end())
+ return defaultValue;
+ QString value = it.data();
+ return value.isNull() || value == "1" || value == "yes" || value == "on";
+}
+
+static int intFeature(const QMap<QString, QString> &features, const char *key, int min, int max, int defaultValue)
+{
+ QMap<QString, QString>::ConstIterator it = features.find(key);
+ if (it == features.end())
+ return defaultValue;
+ QString value = it.data();
+ // FIXME: Can't distinguish "0q" from string with no digits in it -- both return d == 0 and ok == false.
+ // Would be good to tell them apart somehow since string with no digits should be default value and
+ // "0q" should be minimum value.
+ bool ok;
+ double d = value.toDouble(&ok);
+ if ((d == 0 && !ok) || isnan(d))
+ return defaultValue;
+ if (d < min || max <= min)
+ return min;
+ if (d > max)
+ return max;
+ return static_cast<int>(d);
+}
+
+static KHTMLPart *createNewWindow(ExecState *exec, Window *openerWindow, const QString &URL,
+ const QString &frameName, const WindowArgs &windowArgs, ValueImp *dialogArgs)
+{
+ KHTMLPart *openerPart = openerWindow->part();
+ KHTMLPart *activePart = Window::retrieveActive(exec)->part();
+
+ URLArgs uargs;
+
+ uargs.frameName = frameName;
+ if (activePart)
+ uargs.metaData()["referrer"] = activePart->referrer();
+ uargs.serviceType = "text/html";
+
+ // FIXME: It's much better for client API if a new window starts with a URL, here where we
+ // know what URL we are going to open. Unfortunately, this code passes the empty string
+ // for the URL, but there's a reason for that. Before loading we have to set up the opener,
+ // openedByJS, and dialogArguments values. Also, to decide whether to use the URL we currently
+ // do an isSafeScript call using the window we create, which can't be done before creating it.
+ // We'd have to resolve all those issues to pass the URL instead of "".
+
+ ReadOnlyPart *newReadOnlyPart = 0;
+ emit openerPart->browserExtension()->createNewWindow("", uargs, windowArgs, newReadOnlyPart);
+
+ if (!newReadOnlyPart || !newReadOnlyPart->inherits("KHTMLPart"))
+ return 0;
+
+ KHTMLPart *newPart = static_cast<KHTMLPart *>(newReadOnlyPart);
+ Window *newWindow = Window::retrieveWindow(newPart);
+
+ newPart->setOpener(openerPart);
+ newPart->setOpenedByJS(true);
+ if (dialogArgs)
+ newWindow->putDirect("dialogArguments", dialogArgs);
+
+ DocumentImpl *activeDoc = activePart ? activePart->xmlDocImpl() : 0;
+ if (!URL.isEmpty() && activeDoc) {
+ QString completedURL = activeDoc->completeURL(URL);
+ if (!completedURL.startsWith("javascript:", false) || newWindow->isSafeScript(exec)) {
+ bool userGesture = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter())->wasRunByUserGesture();
+ newPart->changeLocation(completedURL, activePart->referrer(), false, userGesture);
+ }
+ }
+
+ return newPart;
+}
+
+static bool canShowModalDialog(const Window *window)
+{
+ KHTMLPart *part = window->part();
+ return part && static_cast<KHTMLPartBrowserExtension *>(part->browserExtension())->canRunModal();
+}
+
+static bool canShowModalDialogNow(const Window *window)
+{
+ KHTMLPart *part = window->part();
+ return part && static_cast<KHTMLPartBrowserExtension *>(part->browserExtension())->canRunModalNow();
+}
+
+static ValueImp *showModalDialog(ExecState *exec, Window *openerWindow, const List &args)
+{
+ UString URL = args[0].toString(exec);
+
+ if (!canShowModalDialogNow(openerWindow) || !allowPopUp(exec, openerWindow))
+ return Undefined().imp();
+
+ const QMap<QString, QString> features = parseFeatures(exec, args[2].imp());
+
+ bool trusted = false;
+
+ WindowArgs wargs;
+
+ // The following features from Microsoft's documentation are not implemented:
+ // - default font settings
+ // - width, height, left, and top specified in units other than "px"
+ // - edge (sunken or raised, default is raised)
+ // - dialogHide: trusted && boolFeature(features, "dialoghide"), makes dialog hide when you print
+ // - help: boolFeature(features, "help", true), makes help icon appear in dialog (what does it do on Windows?)
+ // - unadorned: trusted && boolFeature(features, "unadorned");
+
+ QRect screenRect = QApplication::desktop()->availableGeometry(openerWindow->part()->view());
+
+ wargs.width = intFeature(features, "dialogwidth", 100, screenRect.width(), 620); // default here came from frame size of dialog in MacIE
+ wargs.widthSet = true;
+ wargs.height = intFeature(features, "dialogheight", 100, screenRect.height(), 450); // default here came from frame size of dialog in MacIE
+ wargs.heightSet = true;
+
+ wargs.x = intFeature(features, "dialogleft", screenRect.x(), screenRect.x() + screenRect.width() - wargs.width, -1);
+ wargs.xSet = wargs.x > 0;
+ wargs.y = intFeature(features, "dialogtop", screenRect.y(), screenRect.y() + screenRect.height() - wargs.height, -1);
+ wargs.ySet = wargs.y > 0;
+
+ if (boolFeature(features, "center", true)) {
+ if (!wargs.xSet) {
+ wargs.x = screenRect.x() + (screenRect.width() - wargs.width) / 2;
+ wargs.xSet = true;
+ }
+ if (!wargs.ySet) {
+ wargs.y = screenRect.y() + (screenRect.height() - wargs.height) / 2;
+ wargs.ySet = true;
+ }
+ }
+
+ wargs.dialog = true;
+ wargs.resizable = boolFeature(features, "resizable");
+ wargs.scrollbarsVisible = boolFeature(features, "scroll", true);
+ wargs.statusBarVisible = boolFeature(features, "status", !trusted);
+ wargs.toolBarsVisible = false;
+
+ KHTMLPart *dialogPart = createNewWindow(exec, openerWindow, URL.qstring(), "", wargs, args[1].imp());
+ if (!dialogPart)
+ return Undefined().imp();
+
+ Window *dialogWindow = Window::retrieveWindow(dialogPart);
+ ValueImp *returnValue = Undefined().imp();
+ dialogWindow->setReturnValueSlot(&returnValue);
+ static_cast<KHTMLPartBrowserExtension *>(dialogPart->browserExtension())->runModal();
+ dialogWindow->setReturnValueSlot(NULL);
+ return returnValue;
+}
+
Value Window::get(ExecState *exec, const Identifier &p) const
{
#ifdef KJS_VERBOSE
@@ -673,6 +879,10 @@
case Blur:
case Close:
return lookupOrCreateFunction<WindowFunc>(exec,p,this,entry->value,entry->params,entry->attr);
+ case ShowModalDialog:
+ if (!canShowModalDialog(this))
+ return Undefined();
+ // fall through
case Alert:
case Confirm:
case Prompt:
@@ -1317,9 +1527,12 @@
void Window::clear( ExecState *exec )
{
KJS::Interpreter::lock();
+ if (m_returnValueSlot)
+ if (ValueImp *returnValue = getDirect("returnValue"))
+ *m_returnValueSlot = returnValue;
kdDebug(6070) << "Window::clear " << this << endl;
delete winq;
- winq = new WindowQObject(this);;
+ winq = new WindowQObject(this);
// Get rid of everything, those user vars could hold references to DOM nodes
deleteAllProperties( exec );
// Really delete those properties, so that the DOM nodes get deref'ed
@@ -1844,7 +2057,8 @@
}
return Undefined();
}
-
+ case Window::ShowModalDialog:
+ return Value(showModalDialog(exec, window, args));
}
return Undefined();
}
1.34.8.3 +5 -1 WebCore/khtml/ecma/kjs_window.h
Index: kjs_window.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_window.h,v
retrieving revision 1.34.8.2
retrieving revision 1.34.8.3
diff -u -r1.34.8.2 -r1.34.8.3
--- kjs_window.h 24 May 2005 00:17:03 -0000 1.34.8.2
+++ kjs_window.h 2 Jul 2005 01:32:57 -0000 1.34.8.3
@@ -124,6 +124,9 @@
// Set the current "event" object
void setCurrentEvent( DOM::Event *evt );
+ // Set a place to put a dialog return value when the window is cleared.
+ void setReturnValueSlot(ValueImp **slot) { m_returnValueSlot = slot; }
+
QPtrDict<JSEventListener> jsEventListeners;
QPtrDict<JSUnprotectedEventListener> jsUnprotectedEventListeners;
virtual const ClassInfo* classInfo() const { return &info; }
@@ -142,7 +145,7 @@
Onfocus, Onkeydown, Onkeypress, Onkeyup, Onload, Onmousedown, Onmousemove,
Onmouseout, Onmouseover, Onmouseup, OnWindowMouseWheel, Onmove, Onreset, Onresize, Onscroll, Onsearch,
Onselect, Onsubmit, Onunload,
- Statusbar, Toolbar, FrameElement };
+ Statusbar, Toolbar, FrameElement, ShowModalDialog };
protected:
Value getListener(ExecState *exec, int eventId) const;
void setListener(ExecState *exec, int eventId, Value func);
@@ -163,6 +166,7 @@
BarInfo *m_toolbar;
WindowQObject *winq;
DOM::Event *m_evt;
+ ValueImp **m_returnValueSlot;
};
/**
1.17.12.3 +4 -3 WebCore/khtml/ecma/Attic/kjs_window.lut.h
Index: kjs_window.lut.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/Attic/kjs_window.lut.h,v
retrieving revision 1.17.12.2
retrieving revision 1.17.12.3
diff -u -r1.17.12.2 -r1.17.12.3
--- kjs_window.lut.h 24 May 2005 00:17:03 -0000 1.17.12.2
+++ kjs_window.lut.h 2 Jul 2005 01:32:57 -0000 1.17.12.3
@@ -100,7 +100,7 @@
{ "DOMException", Window::DOMException, DontDelete, 0, &WindowTableEntries[96] },
{ 0, 0, 0, 0, 0 },
{ "setInterval", Window::SetInterval, DontDelete|Function, 2, 0 },
- { "scrollbars", Window::Scrollbars, DontDelete|ReadOnly, 0, 0 },
+ { "scrollbars", Window::Scrollbars, DontDelete|ReadOnly, 0, &WindowTableEntries[125] },
{ "clearTimeout", Window::ClearTimeout, DontDelete|Function, 1, &WindowTableEntries[107] },
{ "moveBy", Window::MoveBy, DontDelete|Function, 2, &WindowTableEntries[117] },
{ "alert", Window::Alert, DontDelete|Function, 1, 0 },
@@ -146,10 +146,11 @@
{ "onmousedown", Window::Onmousedown, DontDelete, 0, 0 },
{ "onmouseout", Window::Onmouseout, DontDelete, 0, 0 },
{ "onmove", Window::Onmove, DontDelete, 0, 0 },
- { "onsubmit", Window::Onsubmit, DontDelete, 0, 0 }
+ { "onsubmit", Window::Onsubmit, DontDelete, 0, 0 },
+ { "showModalDialog", Window::ShowModalDialog, DontDelete|Function, 1, 0 }
};
-const struct HashTable WindowTable = { 2, 125, WindowTableEntries, 91 };
+const struct HashTable WindowTable = { 2, 126, WindowTableEntries, 91 };
} // namespace
No revision
No revision
1.21.10.1 +1 -0 WebCore/kwq/KWQApplication.h
Index: KWQApplication.h
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQApplication.h,v
retrieving revision 1.21
retrieving revision 1.21.10.1
diff -u -r1.21 -r1.21.10.1
--- KWQApplication.h 20 Oct 2004 19:01:16 -0000 1.21
+++ KWQApplication.h 2 Jul 2005 01:32:58 -0000 1.21.10.1
@@ -46,6 +46,7 @@
public:
static int screenNumber(QWidget *);
static QRect screenGeometry(int screenNumber);
+ static QRect availableGeometry(QWidget *);
static int width();
static int height();
};
1.42.10.1 +10 -0 WebCore/kwq/KWQApplication.mm
Index: KWQApplication.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQApplication.mm,v
retrieving revision 1.42
retrieving revision 1.42.10.1
diff -u -r1.42 -r1.42.10.1
--- KWQApplication.mm 20 Oct 2004 19:01:16 -0000 1.42
+++ KWQApplication.mm 2 Jul 2005 01:32:58 -0000 1.42.10.1
@@ -58,6 +58,16 @@
return QRect(rect);
}
+QRect QDesktopWidget::availableGeometry(QWidget *widget)
+{
+ NSScreen *screen = widget ? [[widget->getView() window] screen] : nil;
+ if (!screen)
+ screen = [NSScreen mainScreen];
+ NSRect rect = [screen visibleFrame];
+ rect.origin.y = NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]) - NSMaxY(rect);
+ return QRect(rect);
+}
+
void QApplication::setOverrideCursor(const QCursor &c)
{
// FIXME: Should implement this so that frame border dragging has the proper cursor.
1.9.72.1 +6 -2 WebCore/kwq/KWQKHTMLPartBrowserExtension.h
Index: KWQKHTMLPartBrowserExtension.h
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQKHTMLPartBrowserExtension.h,v
retrieving revision 1.9
retrieving revision 1.9.72.1
diff -u -r1.9 -r1.9.72.1
--- KWQKHTMLPartBrowserExtension.h 26 Jan 2003 05:04:57 -0000 1.9
+++ KWQKHTMLPartBrowserExtension.h 2 Jul 2005 01:32:58 -0000 1.9.72.1
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -24,7 +24,6 @@
*/
#include "KWQKPartsBrowserExtension.h"
-
#include "KWQKPartsBrowserInterface.h"
class QWidget;
@@ -33,6 +32,7 @@
class KHTMLPartBrowserExtension : public KParts::BrowserExtension {
public:
KHTMLPartBrowserExtension(KHTMLPart *);
+
void editableWidgetFocused(QWidget *) { }
void editableWidgetBlurred(QWidget *) { }
void setLocationBarURL(const QString &) { }
@@ -52,6 +52,10 @@
virtual void setIconURL(const KURL &url);
virtual void setTypedIconURL(const KURL &url, const QString &type);
+
+ bool canRunModal();
+ bool canRunModalNow();
+ void runModal();
private:
void createNewWindow(const KURL &url,
1.49.8.1 +33 -6 WebCore/kwq/KWQKHTMLPartBrowserExtension.mm
Index: KWQKHTMLPartBrowserExtension.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQKHTMLPartBrowserExtension.mm,v
retrieving revision 1.49
retrieving revision 1.49.8.1
diff -u -r1.49 -r1.49.8.1
--- KWQKHTMLPartBrowserExtension.mm 10 Mar 2005 01:00:26 -0000 1.49
+++ KWQKHTMLPartBrowserExtension.mm 2 Jul 2005 01:32:59 -0000 1.49.8.1
@@ -82,6 +82,10 @@
referrer = [_part->bridge() referrer];
}
+ ASSERT(!winArgs.dialog || urlArgs.frameName.isEmpty());
+
+ if (partResult)
+ *partResult = NULL;
if (frameName != nil) {
bridge = [_part->bridge() findFrameNamed:frameName];
@@ -97,7 +101,12 @@
}
}
- bridge = [_part->bridge() createWindowWithURL:url.getNSURL() frameName:frameName];
+ if (winArgs.dialog)
+ bridge = [_part->bridge() createModalDialogWithURL:url.getNSURL()];
+ else
+ bridge = [_part->bridge() createWindowWithURL:url.getNSURL() frameName:frameName];
+ if (!bridge)
+ return;
if (!winArgs.toolBarsVisible) {
[bridge setToolbarsVisible:NO];
@@ -150,13 +159,8 @@
if (partResult) {
*partResult = [bridge part];
}
- return;
KWQ_UNBLOCK_EXCEPTIONS;
-
- if (partResult) {
- *partResult = NULL;
- }
}
void KHTMLPartBrowserExtension::setIconURL(const KURL &url)
@@ -172,3 +176,26 @@
[_part->bridge() setIconURL:url.getNSURL() withType:type.getNSString()];
KWQ_UNBLOCK_EXCEPTIONS;
}
+
+bool KHTMLPartBrowserExtension::canRunModal()
+{
+ KWQ_BLOCK_EXCEPTIONS;
+ return [_part->bridge() canRunModal];
+ KWQ_UNBLOCK_EXCEPTIONS;
+ return false;
+}
+
+bool KHTMLPartBrowserExtension::canRunModalNow()
+{
+ KWQ_BLOCK_EXCEPTIONS;
+ return [_part->bridge() canRunModalNow];
+ KWQ_UNBLOCK_EXCEPTIONS;
+ return false;
+}
+
+void KHTMLPartBrowserExtension::runModal()
+{
+ KWQ_BLOCK_EXCEPTIONS;
+ [_part->bridge() runModal];
+ KWQ_UNBLOCK_EXCEPTIONS;
+}
1.25.10.1 +8 -2 WebCore/kwq/KWQKPartsBrowserExtension.h
Index: KWQKPartsBrowserExtension.h
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQKPartsBrowserExtension.h,v
retrieving revision 1.25
retrieving revision 1.25.10.1
diff -u -r1.25 -r1.25.10.1
--- KWQKPartsBrowserExtension.h 30 Aug 2004 20:35:39 -0000 1.25
+++ KWQKPartsBrowserExtension.h 2 Jul 2005 01:32:59 -0000 1.25.10.1
@@ -50,7 +50,7 @@
int xOffset;
int yOffset;
- URLArgs() : reload(false), xOffset(0), yOffset(0), m_doPost(false) { }
+ URLArgs() : reload(false), xOffset(0), yOffset(0), m_doPost(false), m_lockHistory(false) { }
QString contentType() const { return m_contentType; }
void setContentType(const QString &t) { m_contentType = t; }
@@ -88,8 +88,14 @@
bool ySet;
bool widthSet;
bool heightSet;
+ bool dialog;
- WindowArgs() : x(0), y(0), width(0), height(0), menuBarVisible(false), statusBarVisible(true), toolBarsVisible(true), scrollbarsVisible(true), resizable(true), fullscreen(true), xSet(false), ySet(false), widthSet(false), heightSet(false) { }
+ WindowArgs() : x(0), y(0), width(0), height(0),
+ menuBarVisible(false), statusBarVisible(true), toolBarsVisible(true), scrollbarsVisible(true),
+ resizable(true), fullscreen(false),
+ xSet(false), ySet(false), widthSet(false), heightSet(false),
+ dialog(false)
+ { }
};
1.327.8.2 +5 -0 WebCore/kwq/WebCoreBridge.h
Index: WebCoreBridge.h
===================================================================
RCS file: /cvs/root/WebCore/kwq/WebCoreBridge.h,v
retrieving revision 1.327.8.1
retrieving revision 1.327.8.2
diff -u -r1.327.8.1 -r1.327.8.2
--- WebCoreBridge.h 14 Jun 2005 01:27:51 -0000 1.327.8.1
+++ WebCoreBridge.h 2 Jul 2005 01:32:59 -0000 1.327.8.2
@@ -461,6 +461,11 @@
- (WebCoreBridge *)createWindowWithURL:(NSURL *)URL frameName:(NSString *)name;
- (void)showWindow;
+- (BOOL)canRunModal;
+- (BOOL)canRunModalNow;
+- (WebCoreBridge *)createModalDialogWithURL:(NSURL *)URL;
+- (void)runModal;
+
- (NSString *)userAgentForURL:(NSURL *)URL;
- (void)setTitle:(NSString *)title;
More information about the webkit-changes
mailing list