From 0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5 Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Tue, 11 Aug 2009 17:01:47 +0100 Subject: Merge in WebKit r47029. --- WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm | 149 ++++++++++++++-------- 1 file changed, 94 insertions(+), 55 deletions(-) (limited to 'WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm') diff --git a/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm b/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm index 95ac174..42b7ff8 100644 --- a/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm +++ b/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm @@ -38,6 +38,7 @@ #import "WebCachedFramePlatformData.h" #import "WebChromeClient.h" #import "WebDataSourceInternal.h" +#import "WebDelegateImplementationCaching.h" #import "WebDocumentInternal.h" #import "WebDocumentLoaderMac.h" #import "WebDownloadInternal.h" @@ -78,6 +79,7 @@ #import #import #import +#import #import #import #import @@ -104,6 +106,7 @@ #import #import #import +#import #import #import #import @@ -117,6 +120,7 @@ #endif #if USE(PLUGIN_HOST_PROCESS) +#import "NetscapePluginHostManager.h" #import "WebHostedNetscapePluginView.h" #endif @@ -216,6 +220,11 @@ void WebFrameLoaderClient::makeRepresentation(DocumentLoader* loader) bool WebFrameLoaderClient::hasHTMLView() const { + if (![getWebView(m_webFrame.get()) _usesDocumentViews]) { + // FIXME (Viewless): For now we just assume that all frames have an HTML view + return true; + } + NSView *view = [m_webFrame->_private->webFrameView documentView]; return [view isKindOfClass:[WebHTMLView class]]; } @@ -335,6 +344,10 @@ bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache(DocumentLoader return true; } +void WebFrameLoaderClient::dispatchDidLoadResourceByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString) +{ +} + void WebFrameLoaderClient::assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request) { WebView *webView = getWebView(m_webFrame.get()); @@ -531,9 +544,11 @@ void WebFrameLoaderClient::dispatchWillClose() void WebFrameLoaderClient::dispatchDidReceiveIcon() { +#if ENABLE(ICONDATABASE) WebView *webView = getWebView(m_webFrame.get()); ASSERT(m_webFrame == [webView mainFrame]); [webView _dispatchDidReceiveIconFromWebFrame:m_webFrame.get()]; +#endif } void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() @@ -635,6 +650,12 @@ Frame* WebFrameLoaderClient::dispatchCreatePage() createWebViewWithRequest:nil windowFeatures:features]; [features release]; + +#if USE(PLUGIN_HOST_PROCESS) + if (newWebView) + WebKit::NetscapePluginHostManager::shared().didCreateWindow(); +#endif + return core([newWebView mainFrame]); } @@ -699,10 +720,11 @@ void WebFrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction function, return; } - NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] initWithCapacity:formState->values().size()]; - HashMap::const_iterator end = formState->values().end(); - for (HashMap::const_iterator it = formState->values().begin(); it != end; ++it) - [dictionary setObject:it->second forKey:it->first]; + const StringPairVector& textFieldValues = formState->textFieldValues(); + size_t size = textFieldValues.size(); + NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] initWithCapacity:size]; + for (size_t i = 0; i < size; ++i) + [dictionary setObject:textFieldValues[i].second forKey:textFieldValues[i].first]; CallFormDelegate(getWebView(m_webFrame.get()), @selector(frame:sourceFrame:willSubmitForm:withValues:submissionListener:), m_webFrame.get(), kit(formState->sourceFrame()), kit(formState->form()), dictionary, setUpPolicyListener(function).get()); @@ -791,14 +813,14 @@ void WebFrameLoaderClient::updateGlobalHistory() [[WebHistory optionalSharedHistory] _visitedURL:loader->urlForHistory() withTitle:loader->title() method:loader->originalRequestCopy().httpMethod() - wasFailure:loader->urlForHistoryReflectsFailure()]; - - updateGlobalHistoryRedirectLinks(); + wasFailure:loader->urlForHistoryReflectsFailure() + increaseVisitCount:!loader->clientRedirectSourceForHistory()]; // Do not increase visit count due to navigations that were not initiated by the user directly, avoiding growth from programmatic reloads. } void WebFrameLoaderClient::updateGlobalHistoryRedirectLinks() { DocumentLoader* loader = core(m_webFrame.get())->loader()->documentLoader(); + ASSERT(loader->unreachableURL().isEmpty()); if (!loader->clientRedirectSourceForHistory().isNull()) { if (WebHistoryItem *item = [[WebHistory optionalSharedHistory] _itemForURLString:loader->clientRedirectSourceForHistory()]) @@ -1025,28 +1047,30 @@ void WebFrameLoaderClient::transitionToCommittedFromCachedFrame(CachedFrame* cac void WebFrameLoaderClient::transitionToCommittedForNewPage() { - WebFrameView *v = m_webFrame->_private->webFrameView; - WebDataSource *ds = [m_webFrame.get() _dataSource]; + WebView *webView = getWebView(m_webFrame.get()); + WebDataSource *dataSource = [m_webFrame.get() _dataSource]; + bool usesDocumentViews = [webView _usesDocumentViews]; + + if (usesDocumentViews) { + // FIXME (Viewless): I assume we want the equivalent of this optimization for viewless mode too. + bool willProduceHTMLView = [[WebFrameView class] _viewClassForMIMEType:[dataSource _responseMIMEType]] == [WebHTMLView class]; + bool canSkipCreation = core(m_webFrame.get())->loader()->committingFirstRealLoad() && willProduceHTMLView; + if (canSkipCreation) { + [[m_webFrame->_private->webFrameView documentView] setDataSource:dataSource]; + return; + } - bool willProduceHTMLView = [[WebFrameView class] _viewClassForMIMEType:[ds _responseMIMEType]] == [WebHTMLView class]; - bool canSkipCreation = core(m_webFrame.get())->loader()->committingFirstRealLoad() && willProduceHTMLView; - if (canSkipCreation) { - [[v documentView] setDataSource:ds]; - return; + // Don't suppress scrollbars before the view creation if we're making the view for a non-HTML view. + if (!willProduceHTMLView) + [[m_webFrame->_private->webFrameView _scrollView] setScrollBarsSuppressed:NO repaintOnUnsuppress:NO]; } - - // Don't suppress scrollbars before the view creation if we're making the view for a non-HTML view. - if (!willProduceHTMLView) - [[v _scrollView] setScrollBarsSuppressed:NO repaintOnUnsuppress:NO]; // clean up webkit plugin instances before WebHTMLView gets freed. - WebView *webView = getWebView(m_webFrame.get()); [webView removePluginInstanceViewsFor:(m_webFrame.get())]; - BOOL useDocumentViews = [webView _usesDocumentViews]; NSView *documentView = nil; - if (useDocumentViews) { - documentView = [v _makeDocumentViewForDataSource:ds]; + if (usesDocumentViews) { + documentView = [m_webFrame->_private->webFrameView _makeDocumentViewForDataSource:dataSource]; if (!documentView) return; } @@ -1060,28 +1084,41 @@ void WebFrameLoaderClient::transitionToCommittedForNewPage() if (isMainFrame && coreFrame->view()) coreFrame->view()->setParentVisible(false); coreFrame->setView(0); - FrameView* coreView; - if (useDocumentViews) - coreView = new FrameView(coreFrame); + RefPtr coreView; + if (usesDocumentViews) + coreView = FrameView::create(coreFrame); else - coreView = new FrameView(coreFrame, IntSize([webView bounds].size)); + coreView = FrameView::create(coreFrame, IntSize([webView bounds].size)); coreFrame->setView(coreView); - coreView->deref(); // FIXME: Eliminate this crazy refcounting! [m_webFrame.get() _updateBackgroundAndUpdatesWhileOffscreen]; - [v _install]; + if (usesDocumentViews) + [m_webFrame->_private->webFrameView _install]; if (isMainFrame) coreView->setParentVisible(true); - // Call setDataSource on the document view after it has been placed in the view hierarchy. - // This what we for the top-level view, so should do this for views in subframes as well. - [documentView setDataSource:ds]; - + if (usesDocumentViews) { + // Call setDataSource on the document view after it has been placed in the view hierarchy. + // This what we for the top-level view, so should do this for views in subframes as well. + [documentView setDataSource:dataSource]; + + // The following is a no-op for WebHTMLRepresentation, but for custom document types + // like the ones that Safari uses for bookmarks it is the only way the DocumentLoader + // will get the proper title. + if (DocumentLoader* documentLoader = [dataSource _documentLoader]) + documentLoader->setTitle([dataSource pageTitle]); + } + if (HTMLFrameOwnerElement* owner = coreFrame->ownerElement()) coreFrame->view()->setCanHaveScrollbars(owner->scrollingMode() != ScrollbarAlwaysOff); - + + // If the document view implicitly became first responder, make sure to set the focused frame properly. + if (usesDocumentViews && [[documentView window] firstResponder] == documentView) { + page->focusController()->setFocusedFrame(coreFrame); + page->focusController()->setFocused(true); + } } RetainPtr WebFrameLoaderClient::setUpPolicyListener(FramePolicyFunction function) @@ -1158,9 +1195,8 @@ NSDictionary *WebFrameLoaderClient::actionDictionary(const NavigationAction& act nil]; if (const MouseEvent* mouseEvent = findMouseEvent(event)) { - IntPoint point(mouseEvent->pageX(), mouseEvent->pageY()); WebElementDictionary *element = [[WebElementDictionary alloc] - initWithHitTestResult:core(m_webFrame.get())->eventHandler()->hitTestResultAtPoint(point, false)]; + initWithHitTestResult:core(m_webFrame.get())->eventHandler()->hitTestResultAtPoint(mouseEvent->absoluteLocation(), false)]; [result setObject:element forKey:WebActionElementKey]; [element release]; @@ -1375,16 +1411,13 @@ public: #endif // ENABLE(NETSCAPE_PLUGIN_API) -static Class netscapePluginViewClass() -{ #if USE(PLUGIN_HOST_PROCESS) - return [WebHostedNetscapePluginView class]; +#define NETSCAPE_PLUGIN_VIEW WebHostedNetscapePluginView #else - return [WebNetscapePluginView class]; +#define NETSCAPE_PLUGIN_VIEW WebNetscapePluginView #endif -} -Widget* WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLPlugInElement* element, const KURL& url, +PassRefPtr WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLPlugInElement* element, const KURL& url, const Vector& paramNames, const Vector& paramValues, const String& mimeType, bool loadManually) { BEGIN_BLOCK_OBJC_EXCEPTIONS; @@ -1413,7 +1446,7 @@ Widget* WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLPlugInElemen [arguments release]; if (view) - return new PluginWidget(view); + return adoptRef(new PluginWidget(view)); } NSString *MIMEType; @@ -1452,7 +1485,7 @@ Widget* WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLPlugInElemen #if ENABLE(NETSCAPE_PLUGIN_API) else if ([pluginPackage isKindOfClass:[WebNetscapePluginPackage class]]) { - WebBaseNetscapePluginView *pluginView = [[[netscapePluginViewClass() alloc] + WebBaseNetscapePluginView *pluginView = [[[NETSCAPE_PLUGIN_VIEW alloc] initWithFrame:NSMakeRect(0, 0, size.width(), size.height()) pluginPackage:(WebNetscapePluginPackage *)pluginPackage URL:URL @@ -1463,7 +1496,7 @@ Widget* WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLPlugInElemen loadManually:loadManually element:element] autorelease]; - return new NetscapePluginWidget(pluginView); + return adoptRef(new NetscapePluginWidget(pluginView)); } #endif } else @@ -1473,11 +1506,11 @@ Widget* WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLPlugInElemen errorCode = WebKitErrorCannotLoadPlugIn; if (errorCode) { + KURL pluginPageURL = document->completeURL(deprecatedParseURL(parameterValue(paramNames, paramValues, "pluginspage"))); + if (!pluginPageURL.protocolInHTTPFamily()) + pluginPageURL = KURL(); NSError *error = [[NSError alloc] _initWithPluginErrorCode:errorCode - contentURL:URL - pluginPageURL:document->completeURL(parseURL(parameterValue(paramNames, paramValues, "pluginspage"))) - pluginName:[pluginPackage name] - MIMEType:MIMEType]; + contentURL:URL pluginPageURL:pluginPageURL pluginName:[pluginPackage name] MIMEType:MIMEType]; WebNullPluginView *nullView = [[[WebNullPluginView alloc] initWithFrame:NSMakeRect(0, 0, size.width(), size.height()) error:error DOMElement:kit(element)] autorelease]; view = nullView; @@ -1485,7 +1518,7 @@ Widget* WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLPlugInElemen } ASSERT(view); - return new PluginWidget(view); + return adoptRef(new PluginWidget(view)); END_BLOCK_OBJC_EXCEPTIONS; @@ -1501,8 +1534,8 @@ void WebFrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget) NSView *pluginView = pluginWidget->platformWidget(); #if ENABLE(NETSCAPE_PLUGIN_API) - if ([pluginView isKindOfClass:[WebNetscapePluginView class]]) - [representation _redirectDataToManualLoader:(WebNetscapePluginView *)pluginView forPluginView:pluginView]; + if ([pluginView isKindOfClass:[NETSCAPE_PLUGIN_VIEW class]]) + [representation _redirectDataToManualLoader:(NETSCAPE_PLUGIN_VIEW *)pluginView forPluginView:pluginView]; else { #else { @@ -1515,9 +1548,10 @@ void WebFrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget) END_BLOCK_OBJC_EXCEPTIONS; } -Widget* WebFrameLoaderClient::createJavaAppletWidget(const IntSize& size, HTMLAppletElement* element, const KURL& baseURL, +PassRefPtr WebFrameLoaderClient::createJavaAppletWidget(const IntSize& size, HTMLAppletElement* element, const KURL& baseURL, const Vector& paramNames, const Vector& paramValues) { +#if ENABLE(MAC_JAVA_BRIDGE) BEGIN_BLOCK_OBJC_EXCEPTIONS; NSView *view = nil; @@ -1545,7 +1579,7 @@ Widget* WebFrameLoaderClient::createJavaAppletWidget(const IntSize& size, HTMLAp } #if ENABLE(NETSCAPE_PLUGIN_API) else if ([pluginPackage isKindOfClass:[WebNetscapePluginPackage class]]) { - view = [[[netscapePluginViewClass() alloc] initWithFrame:NSMakeRect(0, 0, size.width(), size.height()) + view = [[[NETSCAPE_PLUGIN_VIEW alloc] initWithFrame:NSMakeRect(0, 0, size.width(), size.height()) pluginPackage:(WebNetscapePluginPackage *)pluginPackage URL:nil baseURL:baseURL @@ -1572,11 +1606,14 @@ Widget* WebFrameLoaderClient::createJavaAppletWidget(const IntSize& size, HTMLAp } ASSERT(view); - return new PluginWidget(view); + return adoptRef(new PluginWidget(view)); END_BLOCK_OBJC_EXCEPTIONS; - return new PluginWidget; + return adoptRef(new PluginWidget); +#else + return 0; +#endif // ENABLE(MAC_JAVA_BRIDGE) } String WebFrameLoaderClient::overrideMediaType() const @@ -1612,7 +1649,9 @@ void WebFrameLoaderClient::windowObjectCleared() void WebFrameLoaderClient::registerForIconNotification(bool listen) { +#if ENABLE(ICONDATABASE) [[m_webFrame.get() webView] _registerForIconNotification:listen]; +#endif } void WebFrameLoaderClient::didPerformFirstNavigation() const -- cgit v1.1