Changeset 17365 in webkit
- Timestamp:
- Oct 27, 2006 12:09:47 AM (17 years ago)
- Location:
- trunk/WebKit
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/ChangeLog
r17352 r17365 1 2006-10-27 Darin Adler <darin@apple.com> 2 3 Reviewed by Maciej. 4 5 - moved methods that are there just to be called by the frame loader client into the client 6 in an attempt to get back some of the speed we lost yesterday 7 8 * DefaultDelegates/WebDefaultResourceLoadDelegate.m: 9 (-[WebDefaultResourceLoadDelegate webView:resource:didReceiveAuthenticationChallenge:fromDataSource:]): 10 (-[WebDefaultResourceLoadDelegate webView:resource:didCancelAuthenticationChallenge:fromDataSource:]): 11 * WebCoreSupport/WebFrameLoaderClient.h: 12 * WebCoreSupport/WebFrameLoaderClient.mm: 13 (dataSource): 14 (decisionListener): 15 (WebFrameLoaderClient::WebFrameLoaderClient): 16 (WebFrameLoaderClient::hasWebView): 17 (WebFrameLoaderClient::hasFrameView): 18 (WebFrameLoaderClient::hasBackForwardList): 19 (WebFrameLoaderClient::resetBackForwardList): 20 (WebFrameLoaderClient::provisionalItemIsTarget): 21 (WebFrameLoaderClient::loadProvisionalItemFromPageCache): 22 (WebFrameLoaderClient::invalidateCurrentItemPageCache): 23 (WebFrameLoaderClient::privateBrowsingEnabled): 24 (WebFrameLoaderClient::makeDocumentView): 25 (WebFrameLoaderClient::makeRepresentation): 26 (WebFrameLoaderClient::setDocumentViewFromPageCache): 27 (WebFrameLoaderClient::forceLayout): 28 (WebFrameLoaderClient::forceLayoutForNonHTML): 29 (WebFrameLoaderClient::updateHistoryForCommit): 30 (WebFrameLoaderClient::updateHistoryForBackForwardNavigation): 31 (WebFrameLoaderClient::updateHistoryForReload): 32 (WebFrameLoaderClient::updateHistoryForStandardLoad): 33 (WebFrameLoaderClient::updateHistoryForInternalLoad): 34 (WebFrameLoaderClient::updateHistoryAfterClientRedirect): 35 (WebFrameLoaderClient::setCopiesOnScroll): 36 (WebFrameLoaderClient::tokenForLoadErrorReset): 37 (WebFrameLoaderClient::resetAfterLoadError): 38 (WebFrameLoaderClient::doNotResetAfterLoadError): 39 (WebFrameLoaderClient::detachedFromParent1): 40 (WebFrameLoaderClient::detachedFromParent2): 41 (WebFrameLoaderClient::detachedFromParent3): 42 (WebFrameLoaderClient::detachedFromParent4): 43 (WebFrameLoaderClient::loadedFromPageCache): 44 (WebFrameLoaderClient::download): 45 (WebFrameLoaderClient::dispatchIdentifierForInitialRequest): 46 (WebFrameLoaderClient::dispatchWillSendRequest): 47 (WebFrameLoaderClient::dispatchDidReceiveAuthenticationChallenge): 48 (WebFrameLoaderClient::dispatchDidCancelAuthenticationChallenge): 49 (WebFrameLoaderClient::dispatchDidReceiveResponse): 50 (WebFrameLoaderClient::dispatchDidReceiveContentLength): 51 (WebFrameLoaderClient::dispatchDidFinishLoading): 52 (WebFrameLoaderClient::dispatchDidFailLoading): 53 (WebFrameLoaderClient::dispatchDidHandleOnloadEvents): 54 (WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad): 55 (WebFrameLoaderClient::dispatchDidCancelClientRedirect): 56 (WebFrameLoaderClient::dispatchWillPerformClientRedirect): 57 (WebFrameLoaderClient::dispatchDidChangeLocationWithinPage): 58 (WebFrameLoaderClient::dispatchWillClose): 59 (WebFrameLoaderClient::dispatchDidReceiveIcon): 60 (WebFrameLoaderClient::dispatchDidStartProvisionalLoad): 61 (WebFrameLoaderClient::dispatchDidReceiveTitle): 62 (WebFrameLoaderClient::dispatchDidCommitLoad): 63 (WebFrameLoaderClient::dispatchDidFailProvisionalLoad): 64 (WebFrameLoaderClient::dispatchDidFailLoad): 65 (WebFrameLoaderClient::dispatchDidFinishLoad): 66 (WebFrameLoaderClient::dispatchDidFirstLayout): 67 (WebFrameLoaderClient::dispatchCreatePage): 68 (WebFrameLoaderClient::dispatchShow): 69 (WebFrameLoaderClient::dispatchDecidePolicyForMIMEType): 70 (WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction): 71 (WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction): 72 (WebFrameLoaderClient::dispatchUnableToImplementPolicy): 73 (WebFrameLoaderClient::dispatchWillSubmitForm): 74 (WebFrameLoaderClient::dispatchDidLoadMainResource): 75 (WebFrameLoaderClient::clearLoadingFromPageCache): 76 (WebFrameLoaderClient::isLoadingFromPageCache): 77 (WebFrameLoaderClient::revertToProvisionalState): 78 (WebFrameLoaderClient::setMainDocumentError): 79 (WebFrameLoaderClient::clearUnarchivingState): 80 (WebFrameLoaderClient::progressStarted): 81 (WebFrameLoaderClient::progressCompleted): 82 (WebFrameLoaderClient::incrementProgress): 83 (WebFrameLoaderClient::completeProgress): 84 (WebFrameLoaderClient::setMainFrameDocumentReady): 85 (WebFrameLoaderClient::startDownload): 86 (WebFrameLoaderClient::willChangeTitle): 87 (WebFrameLoaderClient::didChangeTitle): 88 (WebFrameLoaderClient::committedLoad): 89 (WebFrameLoaderClient::finishedLoading): 90 (WebFrameLoaderClient::finalSetupForReplace): 91 (WebFrameLoaderClient::cancelledError): 92 (WebFrameLoaderClient::cannotShowURLError): 93 (WebFrameLoaderClient::interruptForPolicyChangeError): 94 (WebFrameLoaderClient::cannotShowMIMETypeError): 95 (WebFrameLoaderClient::fileDoesNotExistError): 96 (WebFrameLoaderClient::shouldFallBack): 97 (WebFrameLoaderClient::mainFrameURL): 98 (WebFrameLoaderClient::setDefersCallbacks): 99 (WebFrameLoaderClient::willUseArchive): 100 (WebFrameLoaderClient::isArchiveLoadPending): 101 (WebFrameLoaderClient::cancelPendingArchiveLoad): 102 (WebFrameLoaderClient::clearArchivedResources): 103 (WebFrameLoaderClient::canHandleRequest): 104 (WebFrameLoaderClient::canShowMIMEType): 105 (WebFrameLoaderClient::representationExistsForURLScheme): 106 (WebFrameLoaderClient::generatedMIMETypeForURLScheme): 107 (WebFrameLoaderClient::elementForEvent): 108 (WebFrameLoaderClient::createPolicyDecider): 109 (WebFrameLoaderClient::frameLoadCompleted): 110 (WebFrameLoaderClient::restoreScrollPositionAndViewState): 111 (WebFrameLoaderClient::provisionalLoadStarted): 112 (WebFrameLoaderClient::shouldTreatURLAsSameAsCurrent): 113 (WebFrameLoaderClient::addHistoryItemForFragmentScroll): 114 (WebFrameLoaderClient::didFinishLoad): 115 (WebFrameLoaderClient::prepareForDataSourceReplacement): 116 (WebFrameLoaderClient::createDocumentLoader): 117 (WebFrameLoaderClient::setTitle): 118 (WebFrameLoaderClient::canUseArchivedResource): 119 (WebFrameLoaderClient::deliverArchivedResourcesAfterDelay): 120 (WebFrameLoaderClient::deliverArchivedResources): 121 (WebFrameLoaderClient::createPageCache): 122 * WebView/WebFrame.mm: 123 (-[NSView setWebFrame:]): 124 (-[WebFrame _createItem:]): 125 (-[WebFrame _loadItem:withLoadType:]): 126 (-[WebFrame _recursiveGoToItem:fromItem:withLoadType:]): 127 (-[WebFrame _loadURL:referrer:intoChild:]): 128 (-[WebFrame _saveScrollPositionAndViewStateToItem:]): 129 (-[WebFrame _hasSelection]): 130 (-[WebFrame _clearSelection]): 131 (-[WebFrame _setProvisionalItem:]): 132 (-[WebFrame _setPreviousItem:]): 133 (-[WebFrame _setCurrentItem:]): 134 (-[WebFrame loadArchive:]): 135 * WebView/WebFrameInternal.h: 136 * WebView/WebHTMLView.m: 137 (-[WebHTMLView _topHTMLView]): 138 * WebView/WebHTMLViewPrivate.h: 139 1 140 2006-10-26 Geoffrey Garen <ggaren@apple.com> 2 141 -
trunk/WebKit/DefaultDelegates/WebDefaultResourceLoadDelegate.m
r14586 r17365 66 66 - (void)webView:(WebView *)wv resource:(id)identifier didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)dataSource 67 67 { 68 NSWindow *window = [wv hostWindow] ? [wv hostWindow] : [wv window];69 [[WebPanelAuthenticationHandler sharedHandler] startAuthentication:challenge window:window];70 68 } 71 69 72 70 - (void)webView:(WebView *)wv resource:(id)identifier didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)dataSource 73 71 { 74 [(WebPanelAuthenticationHandler *)[WebPanelAuthenticationHandler sharedHandler] cancelAuthentication:challenge];75 72 } 76 73 -
trunk/WebKit/WebCoreSupport/WebFrameLoaderClient.h
r17352 r17365 28 28 29 29 #import <WebCore/RetainPtr.h> 30 #import <WebCore/Timer.h> 30 31 #import <WebCore/WebFrameLoaderClient.h> 32 #import <wtf/HashMap.h> 31 33 32 34 @class WebFrame; 35 @class WebHistoryItem; 36 @class WebResource; 33 37 34 38 namespace WebCore { 35 39 class String; 40 class WebResourceLoader; 36 41 } 42 43 typedef HashMap<RefPtr<WebCore::WebResourceLoader>, WebCore::RetainPtr<WebResource> > ResourceMap; 37 44 38 45 class WebFrameLoaderClient : public WebCore::FrameLoaderClient { … … 41 48 WebFrame* webFrame() const { return m_webFrame.get(); } 42 49 50 private: 43 51 virtual void detachFrameLoader(); 44 52 … … 181 189 virtual void setTitle(NSString *title, NSURL *); 182 190 183 private: 191 void deliverArchivedResourcesAfterDelay() const; 192 bool canUseArchivedResource(NSURLRequest *) const; 193 bool canUseArchivedResource(NSURLResponse *) const; 194 void deliverArchivedResources(WebCore::Timer<WebFrameLoaderClient>*); 195 196 bool createPageCache(WebHistoryItem *); 197 184 198 WebCore::RetainPtr<WebFrame> m_webFrame; 199 mutable ResourceMap m_pendingArchivedResources; 200 mutable WebCore::Timer<WebFrameLoaderClient> m_archivedResourcesDeliveryTimer; 185 201 }; -
trunk/WebKit/WebCoreSupport/WebFrameLoaderClient.mm
r17352 r17365 29 29 #import "WebFrameLoaderClient.h" 30 30 31 // Terrible hack, but needed so we can get right at the private structure. 32 #define private public 33 #import "WebFrame.h" 34 #undef private 35 36 #import "WebBackForwardList.h" 37 #import "WebDataSourceInternal.h" 38 #import "WebDocumentInternal.h" 39 #import "WebDocumentLoaderMac.h" 40 #import "WebDownloadInternal.h" 31 41 #import "WebFrameInternal.h" 42 #import "WebFrameLoadDelegate.h" 43 #import "WebFrameViewInternal.h" 44 #import "WebHTMLRepresentation.h" 45 #import "WebHTMLView.h" 46 #import "WebHistoryItemPrivate.h" 47 #import "WebHistoryPrivate.h" 48 #import "WebKitErrorsPrivate.h" 49 #import "WebKitNSStringExtras.h" 50 #import "WebNSURLExtras.h" 51 #import "WebPanelAuthenticationHandler.h" 52 #import "WebPolicyDeciderMac.h" 53 #import "WebPolicyDelegatePrivate.h" 54 #import "WebPreferences.h" 55 #import "WebResourcePrivate.h" 56 #import "WebResourceLoadDelegate.h" 57 #import "WebScriptDebugServerPrivate.h" 58 #import "WebUIDelegate.h" 59 #import "WebViewInternal.h" 32 60 #import <WebCore/FrameMac.h> 61 #import <WebCore/FrameTree.h> 33 62 #import <WebCore/PlatformString.h> 34 63 #import <WebCore/WebCoreFrameBridge.h> 64 #import <WebCore/WebDataProtocol.h> 35 65 #import <WebCore/WebDocumentLoader.h> 36 #import <WebKit/DOMElement.h> 66 #import <WebCore/WebFrameLoader.h> 67 #import <WebCore/WebLoader.h> 68 #import <WebKitSystemInterface.h> 37 69 #import <wtf/PassRefPtr.h> 38 70 39 71 using namespace WebCore; 72 73 static inline WebDataSource *dataSource(DocumentLoader* loader) 74 { 75 return loader ? static_cast<WebDocumentLoaderMac*>(loader)->dataSource() : nil; 76 } 77 78 static inline WebPolicyDecisionListener *decisionListener(WebPolicyDecider *decider) 79 { 80 return [(WebPolicyDeciderMac *)decider decisionListener]; 81 } 40 82 41 83 WebFrameLoaderClient::WebFrameLoaderClient(WebFrame *webFrame) 42 84 : m_webFrame(webFrame) 85 , m_archivedResourcesDeliveryTimer(this, &WebFrameLoaderClient::deliverArchivedResources) 43 86 { 44 87 } … … 51 94 bool WebFrameLoaderClient::hasWebView() const 52 95 { 53 return [m_webFrame.get() _hasWebView];96 return [m_webFrame.get() webView] != nil; 54 97 } 55 98 56 99 bool WebFrameLoaderClient::hasFrameView() const 57 100 { 58 return [m_webFrame.get() _hasFrameView];101 return m_webFrame->_private->webFrameView != nil; 59 102 } 60 103 61 104 bool WebFrameLoaderClient::hasBackForwardList() const 62 105 { 63 return [ m_webFrame.get() _hasBackForwardList];106 return [[m_webFrame.get() webView] backForwardList] != nil; 64 107 } 65 108 66 109 void WebFrameLoaderClient::resetBackForwardList() 67 110 { 68 [m_webFrame.get() _resetBackForwardList]; 111 // Note this doesn't verify the current load type as a b/f operation because it is called from 112 // a subframe in the case of a delegate bailing out of the nav before it even gets to provisional state. 113 WebFrame *mainFrame = [[m_webFrame.get() webView] mainFrame]; 114 WebHistoryItem *resetItem = mainFrame->_private->currentItem; 115 if (resetItem) 116 [[[m_webFrame.get() webView] backForwardList] goToItem:resetItem]; 69 117 } 70 118 71 119 bool WebFrameLoaderClient::provisionalItemIsTarget() const 72 120 { 73 return [m_webFrame .get() _provisionalItemIsTarget];121 return [m_webFrame->_private->provisionalItem isTargetItem]; 74 122 } 75 123 76 124 bool WebFrameLoaderClient::loadProvisionalItemFromPageCache() 77 125 { 78 return [m_webFrame.get() _loadProvisionalItemFromPageCache]; 126 WebHistoryItem *item = m_webFrame->_private->provisionalItem; 127 if (![item hasPageCache]) 128 return false; 129 NSDictionary *pageCache = [item pageCache]; 130 if (![pageCache objectForKey:WebCorePageCacheStateKey]) 131 return false; 132 [[m_webFrame.get() provisionalDataSource] _loadFromPageCache:pageCache]; 133 return true; 79 134 } 80 135 81 136 void WebFrameLoaderClient::invalidateCurrentItemPageCache() 82 137 { 83 [m_webFrame.get() _invalidateCurrentItemPageCache]; 138 // When we are pre-commit, the currentItem is where the pageCache data resides 139 WebHistoryItem *currentItem = m_webFrame->_private->currentItem; 140 NSDictionary *pageCache = [currentItem pageCache]; 141 [m_webFrame->_private->bridge invalidatePageCache:pageCache]; 142 // We're assuming that WebCore invalidates its pageCache state in didNotOpen:pageCache: 143 [currentItem setHasPageCache:NO]; 84 144 } 85 145 86 146 bool WebFrameLoaderClient::privateBrowsingEnabled() const 87 147 { 88 return [ m_webFrame.get() _privateBrowsingEnabled];148 return [[[m_webFrame.get() webView] preferences] privateBrowsingEnabled]; 89 149 } 90 150 91 151 void WebFrameLoaderClient::makeDocumentView() 92 152 { 93 [m_webFrame.get() _makeDocumentView]; 153 WebFrameView *v = m_webFrame->_private->webFrameView; 154 WebDataSource *ds = [m_webFrame.get() dataSource]; 155 156 NSView <WebDocumentView> *documentView = [v _makeDocumentViewForDataSource:ds]; 157 if (!documentView) 158 return; 159 160 WebFrameBridge *bridge = m_webFrame->_private->bridge; 161 162 // FIXME: We could save work and not do this for a top-level view that is not a WebHTMLView. 163 [bridge createFrameViewWithNSView:documentView marginWidth:[v _marginWidth] marginHeight:[v _marginHeight]]; 164 [m_webFrame.get() _updateBackground]; 165 [bridge installInFrame:[v _scrollView]]; 166 167 // Call setDataSource on the document view after it has been placed in the view hierarchy. 168 // This what we for the top-level view, so should do this for views in subframes as well. 169 [documentView setDataSource:ds]; 94 170 } 95 171 96 172 void WebFrameLoaderClient::makeRepresentation(DocumentLoader* loader) 97 173 { 98 [m_webFrame.get() _makeRepresentationForDocumentLoader:loader]; 99 } 100 101 void WebFrameLoaderClient::setDocumentViewFromPageCache(NSDictionary *dictionary) 102 { 103 [m_webFrame.get() _setDocumentViewFromPageCache:dictionary]; 174 [dataSource(loader) _makeRepresentation]; 175 } 176 177 void WebFrameLoaderClient::setDocumentViewFromPageCache(NSDictionary *pageCache) 178 { 179 NSView <WebDocumentView> *cachedView = [pageCache objectForKey:WebPageCacheDocumentViewKey]; 180 ASSERT(cachedView != nil); 181 [m_webFrame->_private->webFrameView _setDocumentView:cachedView]; 104 182 } 105 183 106 184 void WebFrameLoaderClient::forceLayout() 107 185 { 108 [m_webFrame.get() _forceLayout]; 186 NSView <WebDocumentView> *view = [m_webFrame->_private->webFrameView documentView]; 187 if ([view isKindOfClass:[WebHTMLView class]]) 188 [(WebHTMLView *)view setNeedsToApplyStyles:YES]; 189 [view setNeedsLayout:YES]; 190 [view layout]; 109 191 } 110 192 111 193 void WebFrameLoaderClient::forceLayoutForNonHTML() 112 194 { 113 [m_webFrame.get() _forceLayoutForNonHTML]; 195 WebFrameView *thisView = m_webFrame->_private->webFrameView; 196 NSView <WebDocumentView> *thisDocumentView = [thisView documentView]; 197 ASSERT(thisDocumentView != nil); 198 199 // Tell the just loaded document to layout. This may be necessary 200 // for non-html content that needs a layout message. 201 if (!([[m_webFrame.get() dataSource] _isDocumentHTML])) { 202 [thisDocumentView setNeedsLayout:YES]; 203 [thisDocumentView layout]; 204 [thisDocumentView setNeedsDisplay:YES]; 205 } 114 206 } 115 207 116 208 void WebFrameLoaderClient::updateHistoryForCommit() 117 209 { 118 [m_webFrame.get() _updateHistoryForCommit]; 210 FrameLoadType type = core(m_webFrame.get())->loader()->loadType(); 211 if (isBackForwardLoadType(type) || 212 (type == FrameLoadTypeReload && [[m_webFrame.get() provisionalDataSource] unreachableURL] != nil)) { 213 // Once committed, we want to use current item for saving DocState, and 214 // the provisional item for restoring state. 215 // Note previousItem must be set before we close the URL, which will 216 // happen when the data source is made non-provisional below 217 [m_webFrame.get() _setPreviousItem:m_webFrame->_private->currentItem]; 218 ASSERT(m_webFrame->_private->provisionalItem); 219 [m_webFrame.get() _setCurrentItem:m_webFrame->_private->provisionalItem]; 220 [m_webFrame.get() _setProvisionalItem:nil]; 221 } 119 222 } 120 223 121 224 void WebFrameLoaderClient::updateHistoryForBackForwardNavigation() 122 225 { 123 [m_webFrame.get() _updateHistoryForBackForwardNavigation]; 226 // Must grab the current scroll position before disturbing it 227 [m_webFrame.get() _saveScrollPositionAndViewStateToItem:m_webFrame->_private->previousItem]; 124 228 } 125 229 126 230 void WebFrameLoaderClient::updateHistoryForReload() 127 231 { 128 [m_webFrame.get() _updateHistoryForReload]; 232 WebHistoryItem *currItem = m_webFrame->_private->previousItem; 233 [currItem setHasPageCache:NO]; 234 if (core(m_webFrame.get())->loader()->loadType() == FrameLoadTypeReload) 235 [m_webFrame.get() _saveScrollPositionAndViewStateToItem:currItem]; 236 WebDataSource *dataSource = [m_webFrame.get() dataSource]; 237 NSURLRequest *request = [dataSource request]; 238 // Sometimes loading a page again leads to a different result because of cookies. Bugzilla 4072 239 if ([request _webDataRequestUnreachableURL] == nil) 240 [currItem setURL:[request URL]]; 241 // Update the last visited time. Mostly interesting for URL autocompletion statistics. 242 NSURL *URL = [[[dataSource _documentLoader]->originalRequestCopy() URL] _webkit_canonicalize]; 243 WebHistory *sharedHistory = [WebHistory optionalSharedHistory]; 244 WebHistoryItem *oldItem = [sharedHistory itemForURL:URL]; 245 if (oldItem) 246 [sharedHistory setLastVisitedTimeInterval:[NSDate timeIntervalSinceReferenceDate] forItem:oldItem]; 129 247 } 130 248 131 249 void WebFrameLoaderClient::updateHistoryForStandardLoad() 132 250 { 133 [m_webFrame.get() _updateHistoryForStandardLoad]; 251 WebDataSource *dataSource = [m_webFrame.get() dataSource]; 252 if (![dataSource _documentLoader]->isClientRedirect()) { 253 NSURL *URL = [dataSource _URLForHistory]; 254 if (URL && ![URL _web_isEmpty]) { 255 ASSERT([m_webFrame.get() webView]); 256 if (![[[m_webFrame.get() webView] preferences] privateBrowsingEnabled]) { 257 WebHistoryItem *entry = [[WebHistory optionalSharedHistory] addItemForURL:URL]; 258 if ([dataSource pageTitle]) 259 [entry setTitle:[dataSource pageTitle]]; 260 } 261 [m_webFrame.get() _addBackForwardItemClippedAtTarget:YES]; 262 } 263 } else { 264 NSURLRequest *request = [dataSource request]; 265 266 // Update the URL in the BF list that we made before the redirect, unless 267 // this is alternate content for an unreachable URL (we want the BF list 268 // item to remember the unreachable URL in case it becomes reachable later). 269 if ([request _webDataRequestUnreachableURL] == nil) { 270 [m_webFrame->_private->currentItem setURL:[request URL]]; 271 272 // clear out the form data so we don't repost it to the wrong place if we 273 // ever go back/forward to this item 274 [m_webFrame->_private->currentItem _setFormInfoFromRequest:request]; 275 276 // We must also clear out form data so we don't try to restore it into the incoming page, 277 // see -_opened 278 } 279 } 134 280 } 135 281 136 282 void WebFrameLoaderClient::updateHistoryForInternalLoad() 137 283 { 138 [m_webFrame.get() _updateHistoryForInternalLoad]; 139 } 140 284 // Add an item to the item tree for this frame 285 ASSERT(!core(m_webFrame.get())->loader()->documentLoader()->isClientRedirect()); 286 WebFrame *parentFrame = [m_webFrame.get() parentFrame]; 287 if (parentFrame) { 288 WebHistoryItem *parentItem = parentFrame->_private->currentItem; 289 // The only case where parentItem==nil should be when a parent frame loaded an 290 // empty URL, which doesn't set up a current item in that parent. 291 if (parentItem) 292 [parentItem addChildItem:[m_webFrame.get() _createItem:YES]]; 293 } else { 294 // See 3556159. It's not clear if it's valid to be in WebFrameLoadTypeOnLoadEvent 295 // for a top-level frame, but that was a likely explanation for those crashes, 296 // so let's guard against it. 297 // ...and all WebFrameLoadTypeOnLoadEvent uses were folded to WebFrameLoadTypeInternal 298 LOG_ERROR("no parent frame in transitionToCommitted:, WebFrameLoadTypeInternal"); 299 } 300 } 141 301 142 302 void WebFrameLoaderClient::updateHistoryAfterClientRedirect() 143 303 { 144 [m_webFrame.get() _updateHistoryAfterClientRedirect]; 304 // Clear out form data so we don't try to restore it into the incoming page. Must happen after 305 // khtml has closed the URL and saved away the form state. 306 WebHistoryItem *item = m_webFrame->_private->currentItem; 307 [item setDocumentState:nil]; 308 [item setScrollPoint:NSZeroPoint]; 145 309 } 146 310 147 311 void WebFrameLoaderClient::setCopiesOnScroll() 148 312 { 149 [ m_webFrame.get() _setCopiesOnScroll];313 [[[m_webFrame->_private->webFrameView _scrollView] contentView] setCopiesOnScroll:YES]; 150 314 } 151 315 152 316 LoadErrorResetToken* WebFrameLoaderClient::tokenForLoadErrorReset() 153 317 { 154 return [m_webFrame.get() _tokenForLoadErrorReset]; 318 if (isBackForwardLoadType(core(m_webFrame.get())->loader()->loadType()) && [m_webFrame.get() _isMainFrame]) 319 return (LoadErrorResetToken*)[m_webFrame->_private->currentItem retain]; 320 return 0; 155 321 } 156 322 157 323 void WebFrameLoaderClient::resetAfterLoadError(LoadErrorResetToken* token) 158 324 { 159 [m_webFrame.get() _resetAfterLoadError:token]; 325 WebHistoryItem *item = (WebHistoryItem *)token; 326 if (!item) 327 return; 328 [[[m_webFrame.get() webView] backForwardList] goToItem:item]; 329 [item release]; 160 330 } 161 331 162 332 void WebFrameLoaderClient::doNotResetAfterLoadError(LoadErrorResetToken* token) 163 333 { 164 [m_webFrame.get() _doNotResetAfterLoadError:token]; 334 WebHistoryItem *item = (WebHistoryItem *)token; 335 [item release]; 165 336 } 166 337 167 338 void WebFrameLoaderClient::detachedFromParent1() 168 339 { 169 [m_webFrame.get() _ detachedFromParent1];340 [m_webFrame.get() _saveScrollPositionAndViewStateToItem:m_webFrame->_private->currentItem]; 170 341 } 171 342 172 343 void WebFrameLoaderClient::detachedFromParent2() 173 344 { 174 [m_webFrame.get() _detachedFromParent2]; 345 [m_webFrame->_private->inspectors makeObjectsPerformSelector:@selector(_webFrameDetached:) withObject:m_webFrame.get()]; 346 [m_webFrame->_private->webFrameView _setWebFrame:nil]; // needed for now to be compatible w/ old behavior 175 347 } 176 348 177 349 void WebFrameLoaderClient::detachedFromParent3() 178 350 { 179 [m_webFrame.get() _detachedFromParent3]; 351 [m_webFrame->_private->webFrameView release]; 352 m_webFrame->_private->webFrameView = nil; 180 353 } 181 354 182 355 void WebFrameLoaderClient::detachedFromParent4() 183 356 { 184 [m_webFrame.get() _detachedFromParent4];357 m_webFrame->_private->bridge = nil; 185 358 } 186 359 187 360 void WebFrameLoaderClient::loadedFromPageCache() 188 361 { 189 [m_webFrame.get() _loadedFromPageCache]; 362 // Release the resources kept in the page cache. 363 // They will be reset when we leave this page. 364 // The WebCore side of the page cache will have already been invalidated by 365 // the bridge to prevent premature release. 366 [m_webFrame->_private->currentItem setHasPageCache:NO]; 190 367 } 191 368 … … 193 370 NSURLResponse *response, id proxy) 194 371 { 195 [m_webFrame.get() _downloadWithLoadingConnection:connection request:request response:response proxy:proxy]; 372 [WebDownload _downloadWithLoadingConnection:connection 373 request:request 374 response:response 375 delegate:[[m_webFrame.get() webView] downloadDelegate] 376 proxy:proxy]; 196 377 } 197 378 198 379 id WebFrameLoaderClient::dispatchIdentifierForInitialRequest(DocumentLoader* loader, NSURLRequest *request) 199 380 { 200 return [m_webFrame.get() _dispatchIdentifierForInitialRequest:request fromDocumentLoader:loader]; 381 WebView *webView = [m_webFrame.get() webView]; 382 id resourceLoadDelegate = [webView resourceLoadDelegate]; 383 384 if ([webView _resourceLoadDelegateImplementations].delegateImplementsIdentifierForRequest) 385 return [resourceLoadDelegate webView:webView identifierForInitialRequest:request fromDataSource:dataSource(loader)]; 386 return [[[NSObject alloc] init] autorelease]; 201 387 } 202 388 … … 204 390 NSURLRequest *request, NSURLResponse *redirectResponse) 205 391 { 206 return [m_webFrame.get() _dispatchResource:identifier willSendRequest:request 207 redirectResponse:redirectResponse fromDocumentLoader:loader]; 392 WebView *webView = [m_webFrame.get() webView]; 393 id resourceLoadDelegate = [webView resourceLoadDelegate]; 394 395 if ([webView _resourceLoadDelegateImplementations].delegateImplementsWillSendRequest) 396 return [resourceLoadDelegate webView:webView resource:identifier willSendRequest:request redirectResponse:redirectResponse fromDataSource:dataSource(loader)]; 397 398 return request; 208 399 } 209 400 … … 211 402 NSURLAuthenticationChallenge *challenge) 212 403 { 213 [m_webFrame.get() _dispatchDidReceiveAuthenticationChallenge:challenge forResource:identifier 214 fromDocumentLoader:loader]; 404 WebView *webView = [m_webFrame.get() webView]; 405 id resourceLoadDelegate = [webView resourceLoadDelegate]; 406 407 if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidReceiveAuthenticationChallenge) { 408 [resourceLoadDelegate webView:webView resource:identifier didReceiveAuthenticationChallenge:challenge fromDataSource:dataSource(loader)]; 409 return; 410 } 411 412 NSWindow *window = [webView hostWindow] ? [webView hostWindow] : [webView window]; 413 [[WebPanelAuthenticationHandler sharedHandler] startAuthentication:challenge window:window]; 215 414 } 216 415 … … 218 417 NSURLAuthenticationChallenge *challenge) 219 418 { 220 [m_webFrame.get() _dispatchDidCancelAuthenticationChallenge:challenge forResource:identifier 221 fromDocumentLoader:loader]; 419 WebView *webView = [m_webFrame.get() webView]; 420 id resourceLoadDelegate = [webView resourceLoadDelegate]; 421 422 if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidCancelAuthenticationChallenge) { 423 [resourceLoadDelegate webView:webView resource:identifier didCancelAuthenticationChallenge:challenge fromDataSource:dataSource(loader)]; 424 return; 425 } 426 427 [(WebPanelAuthenticationHandler *)[WebPanelAuthenticationHandler sharedHandler] cancelAuthentication:challenge]; 222 428 } 223 429 224 430 void WebFrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader* loader, id identifier, NSURLResponse *response) 225 431 { 226 [m_webFrame.get() _dispatchResource:identifier didReceiveResponse:response fromDocumentLoader:loader]; 432 WebView *webView = [m_webFrame.get() webView]; 433 434 if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidReceiveResponse) 435 [[webView resourceLoadDelegate] webView:webView resource:identifier didReceiveResponse:response fromDataSource:dataSource(loader)]; 227 436 } 228 437 229 438 void WebFrameLoaderClient::dispatchDidReceiveContentLength(DocumentLoader* loader, id identifier, int lengthReceived) 230 439 { 231 [m_webFrame.get() _dispatchResource:identifier didReceiveContentLength:lengthReceived fromDocumentLoader:loader]; 440 WebView *webView = [m_webFrame.get() webView]; 441 442 if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidReceiveContentLength) 443 [[webView resourceLoadDelegate] webView:webView resource:identifier didReceiveContentLength:(WebNSUInteger)lengthReceived fromDataSource:dataSource(loader)]; 232 444 } 233 445 234 446 void WebFrameLoaderClient::dispatchDidFinishLoading(DocumentLoader* loader, id identifier) 235 447 { 236 [m_webFrame.get() _dispatchResource:identifier didFinishLoadingFromDocumentLoader:loader]; 448 WebView *webView = [m_webFrame.get() webView]; 449 450 if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidFinishLoadingFromDataSource) 451 [[webView resourceLoadDelegate] webView:webView resource:identifier didFinishLoadingFromDataSource:dataSource(loader)]; 237 452 } 238 453 239 454 void WebFrameLoaderClient::dispatchDidFailLoading(DocumentLoader* loader, id identifier, NSError *error) 240 455 { 241 [m_webFrame.get() _dispatchResource:identifier didFailLoadingWithError:error fromDocumentLoader:loader]; 456 WebView *webView = [m_webFrame.get() webView]; 457 [[webView _resourceLoadDelegateForwarder] webView:webView resource:identifier didFailLoadingWithError:error fromDataSource:dataSource(loader)]; 242 458 } 243 459 244 460 void WebFrameLoaderClient::dispatchDidHandleOnloadEvents() 245 461 { 246 [m_webFrame.get() _dispatchDidHandleOnloadEventsForFrame]; 462 WebView *webView = [m_webFrame.get() webView]; 463 [[webView _frameLoadDelegateForwarder] webView:webView didHandleOnloadEventsForFrame:m_webFrame.get()]; 247 464 } 248 465 249 466 void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad() 250 467 { 251 [m_webFrame.get() _dispatchDidReceiveServerRedirectForProvisionalLoadForFrame]; 468 WebView *webView = [m_webFrame.get() webView]; 469 [[webView _frameLoadDelegateForwarder] webView:webView 470 didReceiveServerRedirectForProvisionalLoadForFrame:m_webFrame.get()]; 252 471 } 253 472 254 473 void WebFrameLoaderClient::dispatchDidCancelClientRedirect() 255 474 { 256 [m_webFrame.get() _dispatchDidCancelClientRedirectForFrame]; 475 WebView *webView = [m_webFrame.get() webView]; 476 [[webView _frameLoadDelegateForwarder] webView:webView didCancelClientRedirectForFrame:m_webFrame.get()]; 257 477 } 258 478 259 479 void WebFrameLoaderClient::dispatchWillPerformClientRedirect(NSURL *URL, NSTimeInterval delay, NSDate *fireDate) 260 480 { 261 [m_webFrame.get() _dispatchWillPerformClientRedirectToURL:URL delay:delay fireDate:fireDate]; 481 WebView *webView = [m_webFrame.get() webView]; 482 [[webView _frameLoadDelegateForwarder] webView:webView 483 willPerformClientRedirectToURL:URL 484 delay:delay 485 fireDate:fireDate 486 forFrame:m_webFrame.get()]; 262 487 } 263 488 264 489 void WebFrameLoaderClient::dispatchDidChangeLocationWithinPage() 265 490 { 266 [m_webFrame.get() _dispatchDidChangeLocationWithinPageForFrame]; 491 WebView *webView = [m_webFrame.get() webView]; 492 [[webView _frameLoadDelegateForwarder] webView:webView didChangeLocationWithinPageForFrame:m_webFrame.get()]; 267 493 } 268 494 269 495 void WebFrameLoaderClient::dispatchWillClose() 270 496 { 271 [m_webFrame.get() _dispatchWillCloseFrame]; 497 WebView *webView = [m_webFrame.get() webView]; 498 [[webView _frameLoadDelegateForwarder] webView:webView willCloseFrame:m_webFrame.get()]; 272 499 } 273 500 274 501 void WebFrameLoaderClient::dispatchDidReceiveIcon(NSImage *icon) 275 502 { 276 [m_webFrame.get() _dispatchDidReceiveIcon:icon]; 503 WebView *webView = [m_webFrame.get() webView]; 504 ASSERT([m_webFrame.get() _isMainFrame]); 505 [webView _willChangeValueForKey:_WebMainFrameIconKey]; 506 [[webView _frameLoadDelegateForwarder] webView:webView didReceiveIcon:icon forFrame:m_webFrame.get()]; 507 [webView _didChangeValueForKey:_WebMainFrameIconKey]; 277 508 } 278 509 279 510 void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() 280 511 { 281 [m_webFrame.get() _dispatchDidStartProvisionalLoadForFrame]; 512 WebView *webView = [m_webFrame.get() webView]; 513 [webView _didStartProvisionalLoadForFrame:m_webFrame.get()]; 514 [[webView _frameLoadDelegateForwarder] webView:webView didStartProvisionalLoadForFrame:m_webFrame.get()]; 282 515 } 283 516 284 517 void WebFrameLoaderClient::dispatchDidReceiveTitle(const String& title) 285 518 { 286 [m_webFrame.get() _dispatchDidReceiveTitle:title]; 519 WebView *webView = [m_webFrame.get() webView]; 520 [[webView _frameLoadDelegateForwarder] webView:webView didReceiveTitle:title forFrame:m_webFrame.get()]; 287 521 } 288 522 289 523 void WebFrameLoaderClient::dispatchDidCommitLoad() 290 524 { 291 [m_webFrame.get() _dispatchDidCommitLoadForFrame]; 525 // Tell the client we've committed this URL. 526 ASSERT([m_webFrame->_private->webFrameView documentView] != nil); 527 528 WebView *webView = [m_webFrame.get() webView]; 529 [webView _didCommitLoadForFrame:m_webFrame.get()]; 530 [[webView _frameLoadDelegateForwarder] webView:webView didCommitLoadForFrame:m_webFrame.get()]; 292 531 } 293 532 294 533 void WebFrameLoaderClient::dispatchDidFailProvisionalLoad(NSError *error) 295 534 { 296 [m_webFrame.get() _dispatchDidFailProvisionalLoadWithError:error]; 535 WebView *webView = [m_webFrame.get() webView]; 536 [webView _didFailProvisionalLoadWithError:error forFrame:m_webFrame.get()]; 537 [[webView _frameLoadDelegateForwarder] webView:webView didFailProvisionalLoadWithError:error forFrame:m_webFrame.get()]; 538 [m_webFrame->_private->internalLoadDelegate webFrame:m_webFrame.get() didFinishLoadWithError:error]; 297 539 } 298 540 299 541 void WebFrameLoaderClient::dispatchDidFailLoad(NSError *error) 300 542 { 301 [m_webFrame.get() _dispatchDidFailLoadWithError:error]; 543 WebView *webView = [m_webFrame.get() webView]; 544 [webView _didFailLoadWithError:error forFrame:m_webFrame.get()]; 545 [[webView _frameLoadDelegateForwarder] webView:webView didFailLoadWithError:error forFrame:m_webFrame.get()]; 546 [m_webFrame->_private->internalLoadDelegate webFrame:m_webFrame.get() didFinishLoadWithError:error]; 302 547 } 303 548 304 549 void WebFrameLoaderClient::dispatchDidFinishLoad() 305 550 { 306 [m_webFrame.get() _dispatchDidFinishLoadForFrame]; 551 WebView *webView = [m_webFrame.get() webView]; 552 [webView _didFinishLoadForFrame:m_webFrame.get()]; 553 [[webView _frameLoadDelegateForwarder] webView:webView didFinishLoadForFrame:m_webFrame.get()]; 554 [m_webFrame->_private->internalLoadDelegate webFrame:m_webFrame.get() didFinishLoadWithError:nil]; 307 555 } 308 556 309 557 void WebFrameLoaderClient::dispatchDidFirstLayout() 310 558 { 311 [m_webFrame.get() _dispatchDidFirstLayoutInFrame]; 559 WebView *webView = [m_webFrame.get() webView]; 560 [[webView _frameLoadDelegateForwarder] webView:webView didFirstLayoutInFrame:m_webFrame.get()]; 312 561 } 313 562 314 563 Frame* WebFrameLoaderClient::dispatchCreatePage(NSURLRequest *request) 315 564 { 316 return [m_webFrame.get() _dispatchCreateWebViewWithRequest:request]; 565 WebView *currentWebView = [m_webFrame.get() webView]; 566 id wd = [currentWebView UIDelegate]; 567 if ([wd respondsToSelector:@selector(webView:createWebViewWithRequest:)]) 568 return core([[wd webView:currentWebView createWebViewWithRequest:request] mainFrame]); 569 return 0; 317 570 } 318 571 319 572 void WebFrameLoaderClient::dispatchShow() 320 573 { 321 [m_webFrame.get() _dispatchShow]; 574 WebView *webView = [m_webFrame.get() webView]; 575 [[webView _UIDelegateForwarder] webViewShow:webView]; 322 576 } 323 577 324 578 void WebFrameLoaderClient::dispatchDecidePolicyForMIMEType(WebPolicyDecider *decider, const String& MIMEType, NSURLRequest *request) 325 579 { 326 [m_webFrame.get() _dispatchDecidePolicyForMIMEType:MIMEType request:request decider:decider]; 580 WebView *webView = [m_webFrame.get() webView]; 581 582 [[webView _policyDelegateForwarder] webView:webView decidePolicyForMIMEType:MIMEType request:request frame:m_webFrame.get() decisionListener:decisionListener(decider)]; 327 583 } 328 584 329 585 void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(WebPolicyDecider *decider, NSDictionary *action, NSURLRequest *request, const String& frameName) 330 586 { 331 [m_webFrame.get() _dispatchDecidePolicyForNewWindowAction:action request:request newFrameName:frameName 332 decider:decider]; 587 WebView *webView = [m_webFrame.get() webView]; 588 [[webView _policyDelegateForwarder] webView:webView 589 decidePolicyForNewWindowAction:action 590 request:request 591 newFrameName:frameName 592 decisionListener:decisionListener(decider)]; 333 593 } 334 594 … … 336 596 NSURLRequest *request) 337 597 { 338 [m_webFrame.get() _dispatchDecidePolicyForNavigationAction:action request:request decider:decider]; 598 WebView *webView = [m_webFrame.get() webView]; 599 [[webView _policyDelegateForwarder] webView:webView 600 decidePolicyForNavigationAction:action 601 request:request 602 frame:m_webFrame.get() 603 decisionListener:decisionListener(decider)]; 339 604 } 340 605 341 606 void WebFrameLoaderClient::dispatchUnableToImplementPolicy(NSError *error) 342 607 { 343 [m_webFrame.get() _dispatchUnableToImplementPolicyWithError:error]; 608 WebView *webView = [m_webFrame.get() webView]; 609 [[webView _policyDelegateForwarder] webView:webView unableToImplementPolicyWithError:error frame:m_webFrame.get()]; 344 610 } 345 611 … … 347 613 Element* form, NSDictionary *values) 348 614 { 349 [m_webFrame.get() _dispatchSourceFrame:sourceFrame 350 willSubmitForm:form withValues:values submissionDecider:decider]; 615 [[[m_webFrame.get() webView] _formDelegate] frame:m_webFrame.get() sourceFrame:kit(sourceFrame) willSubmitForm:kit(form) withValues:values submissionListener:decisionListener(decider)]; 351 616 } 352 617 353 618 void WebFrameLoaderClient::dispatchDidLoadMainResource(DocumentLoader* loader) 354 619 { 355 [m_webFrame.get() _dispatchDidLoadMainResourceForDocumentLoader:loader]; 620 if ([WebScriptDebugServer listenerCount]) 621 [[WebScriptDebugServer sharedScriptDebugServer] webView:[m_webFrame.get() webView] 622 didLoadMainResourceForDataSource:dataSource(loader)]; 356 623 } 357 624 358 625 void WebFrameLoaderClient::clearLoadingFromPageCache(DocumentLoader* loader) 359 626 { 360 [ m_webFrame.get() _clearLoadingFromPageCacheForDocumentLoader:loader];627 [dataSource(loader) _setLoadingFromPageCache:NO]; 361 628 } 362 629 363 630 bool WebFrameLoaderClient::isLoadingFromPageCache(DocumentLoader* loader) 364 631 { 365 return [ m_webFrame.get() _isDocumentLoaderLoadingFromPageCache:loader];632 return [dataSource(loader) _loadingFromPageCache]; 366 633 } 367 634 368 635 void WebFrameLoaderClient::revertToProvisionalState(DocumentLoader* loader) 369 636 { 370 [ m_webFrame.get() _revertToProvisionalStateForDocumentLoader:loader];637 [dataSource(loader) _revertToProvisionalState]; 371 638 } 372 639 373 640 void WebFrameLoaderClient::setMainDocumentError(DocumentLoader* loader, NSError *error) 374 641 { 375 [ m_webFrame.get() _setMainDocumentError:error forDocumentLoader:loader];642 [dataSource(loader) _setMainDocumentError:error]; 376 643 } 377 644 378 645 void WebFrameLoaderClient::clearUnarchivingState(DocumentLoader* loader) 379 646 { 380 [ m_webFrame.get() _clearUnarchivingStateForLoader:loader];647 [dataSource(loader) _clearUnarchivingState]; 381 648 } 382 649 383 650 void WebFrameLoaderClient::progressStarted() 384 651 { 385 [ m_webFrame.get() _progressStarted];652 [[m_webFrame.get() webView] _progressStarted:m_webFrame.get()]; 386 653 } 387 654 388 655 void WebFrameLoaderClient::progressCompleted() 389 656 { 390 [ m_webFrame.get() _progressCompleted];657 [[m_webFrame.get() webView] _progressCompleted:m_webFrame.get()]; 391 658 } 392 659 393 660 void WebFrameLoaderClient::incrementProgress(id identifier, NSURLResponse *response) 394 661 { 395 [ m_webFrame.get()_incrementProgressForIdentifier:identifier response:response];662 [[m_webFrame.get() webView] _incrementProgressForIdentifier:identifier response:response]; 396 663 } 397 664 398 665 void WebFrameLoaderClient::incrementProgress(id identifier, NSData *data) 399 666 { 400 [ m_webFrame.get()_incrementProgressForIdentifier:identifier data:data];667 [[m_webFrame.get() webView] _incrementProgressForIdentifier:identifier data:data]; 401 668 } 402 669 403 670 void WebFrameLoaderClient::completeProgress(id identifier) 404 671 { 405 [ m_webFrame.get()_completeProgressForIdentifier:identifier];672 [[m_webFrame.get() webView] _completeProgressForIdentifier:identifier]; 406 673 } 407 674 408 675 void WebFrameLoaderClient::setMainFrameDocumentReady(bool ready) 409 676 { 410 [ m_webFrame.get() _setMainFrameDocumentReady:ready];677 [[m_webFrame.get() webView] setMainFrameDocumentReady:ready]; 411 678 } 412 679 413 680 void WebFrameLoaderClient::startDownload(NSURLRequest *request) 414 681 { 415 [m_webFrame.get() _startDownloadWithRequest:request]; 682 // FIXME: Should download full request. 683 [[m_webFrame.get() webView] _downloadURL:[request URL]]; 416 684 } 417 685 418 686 void WebFrameLoaderClient::willChangeTitle(DocumentLoader* loader) 419 687 { 420 [m_webFrame.get() _willChangeTitleForDocument:loader]; 688 // FIXME: Should do this only in main frame case, right? 689 [[m_webFrame.get() webView] _willChangeValueForKey:_WebMainFrameTitleKey]; 421 690 } 422 691 423 692 void WebFrameLoaderClient::didChangeTitle(DocumentLoader* loader) 424 693 { 425 [m_webFrame.get() _didChangeTitleForDocument:loader]; 694 // FIXME: Should do this only in main frame case, right? 695 [[m_webFrame.get() webView] _didChangeValueForKey:_WebMainFrameTitleKey]; 426 696 } 427 697 428 698 void WebFrameLoaderClient::committedLoad(DocumentLoader* loader, NSData *data) 429 699 { 430 [ m_webFrame.get() _committedLoadWithDocumentLoader:loader data:data];700 [dataSource(loader) _receivedData:data]; 431 701 } 432 702 433 703 void WebFrameLoaderClient::finishedLoading(DocumentLoader* loader) 434 704 { 435 [ m_webFrame.get() _finishedLoadingDocument:loader];705 [dataSource(loader) _finishedLoading]; 436 706 } 437 707 438 708 void WebFrameLoaderClient::finalSetupForReplace(DocumentLoader* loader) 439 709 { 440 [ m_webFrame.get() _finalSetupForReplaceWithDocumentLoader:loader];710 [dataSource(loader) _clearUnarchivingState]; 441 711 } 442 712 443 713 NSError *WebFrameLoaderClient::cancelledError(NSURLRequest *request) 444 714 { 445 return [ m_webFrame.get() _cancelledErrorWithRequest:request];715 return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled URL:[request URL]]; 446 716 } 447 717 448 718 NSError *WebFrameLoaderClient::cannotShowURLError(NSURLRequest *request) 449 719 { 450 return [ m_webFrame.get() _cannotShowURLErrorWithRequest:request];720 return [NSError _webKitErrorWithDomain:WebKitErrorDomain code:WebKitErrorCannotShowURL URL:[request URL]]; 451 721 } 452 722 453 723 NSError *WebFrameLoaderClient::interruptForPolicyChangeError(NSURLRequest *request) 454 724 { 455 return [ m_webFrame.get() _interruptForPolicyChangeErrorWithRequest:request];725 return [NSError _webKitErrorWithDomain:WebKitErrorDomain code:WebKitErrorFrameLoadInterruptedByPolicyChange URL:[request URL]]; 456 726 } 457 727 458 728 NSError *WebFrameLoaderClient::cannotShowMIMETypeError(NSURLResponse *response) 459 729 { 460 return [ m_webFrame.get() _cannotShowMIMETypeErrorWithResponse:response];730 return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:WebKitErrorCannotShowMIMEType URL:[response URL]]; 461 731 } 462 732 463 733 NSError *WebFrameLoaderClient::fileDoesNotExistError(NSURLResponse *response) 464 734 { 465 return [ m_webFrame.get() _fileDoesNotExistErrorWithResponse:response];735 return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist URL:[response URL]]; 466 736 } 467 737 468 738 bool WebFrameLoaderClient::shouldFallBack(NSError *error) 469 739 { 470 return [m_webFrame.get() _shouldFallBackForError:error]; 740 // FIXME: Needs to check domain. 741 // FIXME: WebKitErrorPlugInWillHandleLoad is a workaround for the cancel we do to prevent 742 // loading plugin content twice. See <rdar://problem/4258008> 743 return [error code] != NSURLErrorCancelled && [error code] != WebKitErrorPlugInWillHandleLoad; 471 744 } 472 745 473 746 NSURL *WebFrameLoaderClient::mainFrameURL() 474 747 { 475 return [ m_webFrame.get() _mainFrameURL];748 return [[[[m_webFrame.get() webView] mainFrame] dataSource] _URL]; 476 749 } 477 750 478 751 void WebFrameLoaderClient::setDefersCallbacks(bool defers) 479 752 { 480 [m_webFrame.get() _setDefersCallbacks:defers]; 753 if (!defers) 754 deliverArchivedResourcesAfterDelay(); 481 755 } 482 756 483 757 bool WebFrameLoaderClient::willUseArchive(WebResourceLoader* loader, NSURLRequest *request, NSURL *originalURL) const 484 758 { 485 return [m_webFrame.get() _willUseArchiveForRequest:request originalURL:originalURL loader:loader]; 759 if (![[request URL] isEqual:originalURL]) 760 return false; 761 if (!canUseArchivedResource(request)) 762 return false; 763 WebResource *resource = [dataSource(core(m_webFrame.get())->loader()->activeDocumentLoader()) _archivedSubresourceForURL:originalURL]; 764 if (!resource) 765 return false; 766 if (!canUseArchivedResource([resource _response])) 767 return false; 768 m_pendingArchivedResources.set(loader, resource); 769 // Deliver the resource after a delay because callers don't expect to receive callbacks while calling this method. 770 deliverArchivedResourcesAfterDelay(); 771 return true; 486 772 } 487 773 488 774 bool WebFrameLoaderClient::isArchiveLoadPending(WebResourceLoader* loader) const 489 775 { 490 return [m_webFrame.get() _archiveLoadPendingForLoader:loader];776 return m_pendingArchivedResources.contains(loader); 491 777 } 492 778 493 779 void WebFrameLoaderClient::cancelPendingArchiveLoad(WebResourceLoader* loader) 494 780 { 495 [m_webFrame.get() _cancelPendingArchiveLoadForLoader:loader]; 781 if (m_pendingArchivedResources.isEmpty()) 782 return; 783 m_pendingArchivedResources.remove(loader); 784 if (m_pendingArchivedResources.isEmpty()) 785 m_archivedResourcesDeliveryTimer.stop(); 496 786 } 497 787 498 788 void WebFrameLoaderClient::clearArchivedResources() 499 789 { 500 [m_webFrame.get() _clearArchivedResources]; 790 m_pendingArchivedResources.clear(); 791 m_archivedResourcesDeliveryTimer.stop(); 501 792 } 502 793 503 794 bool WebFrameLoaderClient::canHandleRequest(NSURLRequest *request) const 504 795 { 505 return [ m_webFrame.get()_canHandleRequest:request];796 return [WebView _canHandleRequest:request]; 506 797 } 507 798 508 799 bool WebFrameLoaderClient::canShowMIMEType(const String& MIMEType) const 509 800 { 510 return [ m_webFrame.get() _canShowMIMEType:MIMEType];801 return [WebView canShowMIMEType:MIMEType]; 511 802 } 512 803 513 804 bool WebFrameLoaderClient::representationExistsForURLScheme(const String& URLScheme) const 514 805 { 515 return [ m_webFrame.get()_representationExistsForURLScheme:URLScheme];806 return [WebView _representationExistsForURLScheme:URLScheme]; 516 807 } 517 808 518 809 String WebFrameLoaderClient::generatedMIMETypeForURLScheme(const String& URLScheme) const 519 810 { 520 return [ m_webFrame.get()_generatedMIMETypeForURLScheme:URLScheme];811 return [WebView _generatedMIMETypeForURLScheme:URLScheme]; 521 812 } 522 813 523 814 NSDictionary *WebFrameLoaderClient::elementForEvent(NSEvent *event) const 524 815 { 525 return [m_webFrame.get() _elementForEvent:event]; 816 switch ([event type]) { 817 case NSLeftMouseDown: 818 case NSRightMouseDown: 819 case NSOtherMouseDown: 820 case NSLeftMouseUp: 821 case NSRightMouseUp: 822 case NSOtherMouseUp: 823 break; 824 default: 825 return nil; 826 } 827 828 NSView *topViewInEventWindow = [[event window] contentView]; 829 NSView *viewContainingPoint = [topViewInEventWindow hitTest: 830 [topViewInEventWindow convertPoint:[event locationInWindow] fromView:nil]]; 831 while (viewContainingPoint) { 832 if ([viewContainingPoint isKindOfClass:[WebView class]]) 833 return [(WebView *)viewContainingPoint elementAtPoint: 834 [viewContainingPoint convertPoint:[event locationInWindow] fromView:nil]]; 835 viewContainingPoint = [viewContainingPoint superview]; 836 } 837 return nil; 526 838 } 527 839 528 840 WebPolicyDecider *WebFrameLoaderClient::createPolicyDecider(id object, SEL selector) 529 841 { 530 return [ m_webFrame.get() _createPolicyDeciderWithTarget:object action:selector];842 return [[WebPolicyDeciderMac alloc] initWithTarget:object action:selector]; 531 843 } 532 844 533 845 void WebFrameLoaderClient::frameLoadCompleted() 534 846 { 535 [m_webFrame.get() _frameLoadCompleted]; 536 } 537 847 // Note: Can be called multiple times. 848 // Even if already complete, we might have set a previous item on a frame that 849 // didn't do any data loading on the past transaction. Make sure to clear these out. 850 NSScrollView *sv = [m_webFrame->_private->webFrameView _scrollView]; 851 if ([[m_webFrame.get() webView] drawsBackground]) 852 [sv setDrawsBackground:YES]; 853 [m_webFrame.get() _setPreviousItem:nil]; 854 } 855 856 /* 857 There is a race condition between the layout and load completion that affects restoring the scroll position. 858 We try to restore the scroll position at both the first layout and upon load completion. 859 860 1) If first layout happens before the load completes, we want to restore the scroll position then so that the 861 first time we draw the page is already scrolled to the right place, instead of starting at the top and later 862 jumping down. It is possible that the old scroll position is past the part of the doc laid out so far, in 863 which case the restore silent fails and we will fix it in when we try to restore on doc completion. 864 2) If the layout happens after the load completes, the attempt to restore at load completion time silently 865 fails. We then successfully restore it when the layout happens. 866 */ 538 867 void WebFrameLoaderClient::restoreScrollPositionAndViewState() 539 868 { 540 [m_webFrame.get() _restoreScrollPositionAndViewState]; 869 ASSERT(m_webFrame->_private->currentItem); 870 NSView <WebDocumentView> *docView = [m_webFrame->_private->webFrameView documentView]; 871 NSPoint point = [m_webFrame->_private->currentItem scrollPoint]; 872 if ([docView conformsToProtocol:@protocol(_WebDocumentViewState)]) { 873 id state = [m_webFrame->_private->currentItem viewState]; 874 if (state) { 875 [(id <_WebDocumentViewState>)docView setViewState:state]; 876 } 877 878 [(id <_WebDocumentViewState>)docView setScrollPoint:point]; 879 } else { 880 [docView scrollPoint:point]; 881 } 541 882 } 542 883 543 884 void WebFrameLoaderClient::provisionalLoadStarted() 544 885 { 545 [m_webFrame.get() _provisionalLoadStarted]; 886 FrameLoadType loadType = core(m_webFrame.get())->loader()->loadType(); 887 888 // FIXME: This is OK as long as no one resizes the window, 889 // but in the case where someone does, it means garbage outside 890 // the occupied part of the scroll view. 891 [[m_webFrame->_private->webFrameView _scrollView] setDrawsBackground:NO]; 892 893 // Cache the page, if possible. 894 // Don't write to the cache if in the middle of a redirect, since we will want to 895 // store the final page we end up on. 896 // No point writing to the cache on a reload or loadSame, since we will just write 897 // over it again when we leave that page. 898 WebHistoryItem *item = m_webFrame->_private->currentItem; 899 if ([m_webFrame.get() _canCachePage] 900 && item 901 && !core(m_webFrame.get())->loader()->isQuickRedirectComing() 902 && loadType != FrameLoadTypeReload 903 && loadType != FrameLoadTypeReloadAllowingStaleData 904 && loadType != FrameLoadTypeSame 905 && ![[m_webFrame.get() dataSource] isLoading] 906 && !core(m_webFrame.get())->loader()->documentLoader()->isStopping()) { 907 if ([[[m_webFrame.get() dataSource] representation] isKindOfClass:[WebHTMLRepresentation class]]) { 908 if (![item pageCache]) { 909 // Add the items to this page's cache. 910 if (createPageCache(item)) 911 // See if any page caches need to be purged after the addition of this new page cache. 912 [m_webFrame.get() _purgePageCache]; 913 } 914 } else 915 // Put the document into a null state, so it can be restored correctly. 916 core(m_webFrame.get())->clear(); 917 } 546 918 } 547 919 548 920 bool WebFrameLoaderClient::shouldTreatURLAsSameAsCurrent(NSURL *URL) const 549 921 { 550 return [m_webFrame.get() _shouldTreatURLAsSameAsCurrent:URL]; 922 WebHistoryItem *item = m_webFrame->_private->currentItem; 923 NSString* URLString = [URL _web_originalDataAsString]; 924 return [URLString isEqual:[item URLString]] || [URLString isEqual:[item originalURLString]]; 551 925 } 552 926 553 927 void WebFrameLoaderClient::addHistoryItemForFragmentScroll() 554 928 { 555 [m_webFrame.get() _add HistoryItemForFragmentScroll];929 [m_webFrame.get() _addBackForwardItemClippedAtTarget:NO]; 556 930 } 557 931 558 932 void WebFrameLoaderClient::didFinishLoad() 559 933 { 560 [m_webFrame .get() _didFinishLoad];934 [m_webFrame->_private->internalLoadDelegate webFrame:m_webFrame.get() didFinishLoadWithError:nil]; 561 935 } 562 936 563 937 void WebFrameLoaderClient::prepareForDataSourceReplacement() 564 938 { 565 [m_webFrame.get() _prepareForDataSourceReplacement]; 939 if (![m_webFrame.get() dataSource]) { 940 ASSERT(!core(m_webFrame.get())->tree()->childCount()); 941 return; 942 } 943 944 // Make sure that any work that is triggered by resigning first reponder can get done. 945 // The main example where this came up is the textDidEndEditing that is sent to the 946 // FormsDelegate (3223413). We need to do this before _detachChildren, since that will 947 // remove the views as a side-effect of freeing the bridge, at which point we can't 948 // post the FormDelegate messages. 949 // 950 // Note that this can also take FirstResponder away from a child of our frameView that 951 // is not in a child frame's view. This is OK because we are in the process 952 // of loading new content, which will blow away all editors in this top frame, and if 953 // a non-editor is firstReponder it will not be affected by endEditingFor:. 954 // Potentially one day someone could write a DocView whose editors were not all 955 // replaced by loading new content, but that does not apply currently. 956 NSView *frameView = m_webFrame->_private->webFrameView; 957 NSWindow *window = [frameView window]; 958 NSResponder *firstResp = [window firstResponder]; 959 if ([firstResp isKindOfClass:[NSView class]] && [(NSView *)firstResp isDescendantOf:frameView]) 960 [window endEditingFor:firstResp]; 961 962 core(m_webFrame.get())->loader()->detachChildren(); 566 963 } 567 964 568 965 PassRefPtr<DocumentLoader> WebFrameLoaderClient::createDocumentLoader(NSURLRequest *request) 569 966 { 570 return [m_webFrame.get() _createDocumentLoaderWithRequest:request]; 967 RefPtr<WebDocumentLoaderMac> loader = new WebDocumentLoaderMac(request); 968 969 WebDataSource *dataSource = [[WebDataSource alloc] _initWithDocumentLoader:loader.get()]; 970 loader->setDataSource(dataSource); 971 [dataSource release]; 972 973 return loader.release(); 571 974 } 572 975 573 976 void WebFrameLoaderClient::setTitle(NSString *title, NSURL *URL) 574 977 { 575 [m_webFrame.get() _setTitle:title forURL:URL]; 576 } 978 [[[WebHistory optionalSharedHistory] itemForURL:URL] setTitle:title]; 979 [m_webFrame->_private->currentItem setTitle:title]; 980 } 981 982 // The following 2 functions are copied from [NSHTTPURLProtocol _cachedResponsePassesValidityChecks] and modified for our needs. 983 // FIXME: It would be nice to eventually to share this logic somehow. 984 bool WebFrameLoaderClient::canUseArchivedResource(NSURLRequest *request) const 985 { 986 NSURLRequestCachePolicy policy = [request cachePolicy]; 987 if (policy == NSURLRequestReturnCacheDataElseLoad) 988 return true; 989 if (policy == NSURLRequestReturnCacheDataDontLoad) 990 return true; 991 if (policy == NSURLRequestReloadIgnoringCacheData) 992 return false; 993 if ([request valueForHTTPHeaderField:@"must-revalidate"] != nil) 994 return false; 995 if ([request valueForHTTPHeaderField:@"proxy-revalidate"] != nil) 996 return false; 997 if ([request valueForHTTPHeaderField:@"If-Modified-Since"] != nil) 998 return false; 999 if ([request valueForHTTPHeaderField:@"Cache-Control"] != nil) 1000 return false; 1001 if ([@"POST" _webkit_isCaseInsensitiveEqualToString:[request HTTPMethod]]) 1002 return false; 1003 return true; 1004 } 1005 1006 bool WebFrameLoaderClient::canUseArchivedResource(NSURLResponse *response) const 1007 { 1008 if (WKGetNSURLResponseMustRevalidate(response)) 1009 return false; 1010 if (WKGetNSURLResponseCalculatedExpiration(response) - CFAbsoluteTimeGetCurrent() < 1) 1011 return false; 1012 return true; 1013 } 1014 1015 void WebFrameLoaderClient::deliverArchivedResourcesAfterDelay() const 1016 { 1017 if (m_pendingArchivedResources.isEmpty()) 1018 return; 1019 if (core(m_webFrame.get())->loader()->defersCallbacks()) 1020 return; 1021 if (!m_archivedResourcesDeliveryTimer.isActive()) 1022 m_archivedResourcesDeliveryTimer.startOneShot(0); 1023 } 1024 1025 void WebFrameLoaderClient::deliverArchivedResources(Timer<WebFrameLoaderClient>*) 1026 { 1027 if (m_pendingArchivedResources.isEmpty()) 1028 return; 1029 if (core(m_webFrame.get())->loader()->defersCallbacks()) 1030 return; 1031 1032 const ResourceMap copy = m_pendingArchivedResources; 1033 m_pendingArchivedResources.clear(); 1034 1035 ResourceMap::const_iterator end = copy.end(); 1036 for (ResourceMap::const_iterator it = copy.begin(); it != end; ++it) { 1037 RefPtr<WebResourceLoader> loader = it->first; 1038 WebResource *resource = it->second.get(); 1039 NSData *data = [[resource data] retain]; 1040 loader->didReceiveResponse([resource _response]); 1041 loader->didReceiveData(data, [data length], true); 1042 [data release]; 1043 loader->didFinishLoading(); 1044 } 1045 } 1046 1047 bool WebFrameLoaderClient::createPageCache(WebHistoryItem *item) 1048 { 1049 [item setHasPageCache:YES]; 1050 if (![m_webFrame->_private->bridge saveDocumentToPageCache]) { 1051 [item setHasPageCache:NO]; 1052 return NO; 1053 } 1054 NSMutableDictionary *pageCache = [item pageCache]; 1055 [pageCache setObject:[NSDate date] forKey: WebPageCacheEntryDateKey]; 1056 [pageCache setObject:[m_webFrame.get() dataSource] forKey: WebPageCacheDataSourceKey]; 1057 [pageCache setObject:[m_webFrame->_private->webFrameView documentView] forKey: WebPageCacheDocumentViewKey]; 1058 return YES; 1059 } -
trunk/WebKit/WebView/WebFrame.mm
r17352 r17365 29 29 #import "WebFrameInternal.h" 30 30 31 #import "WebArchive.h"32 31 #import "WebBackForwardList.h" 33 32 #import "WebDataSourceInternal.h" 34 #import "WebDefaultResourceLoadDelegate.h"35 #import "WebDefaultUIDelegate.h"36 33 #import "WebDocumentInternal.h" 37 34 #import "WebDocumentLoaderMac.h" 38 #import "WebDownloadInternal.h"39 35 #import "WebFrameBridge.h" 40 36 #import "WebFrameLoadDelegate.h" 41 37 #import "WebFrameLoaderClient.h" 42 38 #import "WebFrameViewInternal.h" 43 #import "WebHTMLRepresentationPrivate.h"44 39 #import "WebHTMLViewInternal.h" 45 #import "WebH TMLViewPrivate.h"40 #import "WebHistoryItem.h" 46 41 #import "WebHistoryItemPrivate.h" 47 #import "WebHistoryPrivate.h"48 #import "WebKitErrorsPrivate.h"49 42 #import "WebKitLogging.h" 50 #import "WebKitNSStringExtras.h"51 43 #import "WebKitStatisticsPrivate.h" 52 #import "WebNSDictionaryExtras.h"53 #import "WebNSObjectExtras.h"54 44 #import "WebNSURLExtras.h" 55 45 #import "WebNSURLRequestExtras.h" 56 #import "WebNetscapePluginEmbeddedView.h" 57 #import "WebNullPluginView.h" 58 #import "WebPlugin.h" 59 #import "WebPluginController.h" 60 #import "WebPolicyDeciderMac.h" 46 #import "WebPolicyDelegatePrivate.h" 61 47 #import "WebPreferencesPrivate.h" 62 #import "WebResourceLoadDelegate.h"63 #import "WebResourcePrivate.h"64 48 #import "WebScriptDebugDelegatePrivate.h" 65 #import "WebScriptDebugServerPrivate.h"66 #import "WebUIDelegate.h"67 49 #import "WebViewInternal.h" 68 50 #import <WebCore/Document.h> 69 #import <WebCore/DocumentMarker.h>70 51 #import <WebCore/FrameLoader.h> 71 52 #import <WebCore/FrameMac.h> … … 77 58 #import <WebCore/WebFormDataStream.h> 78 59 #import <WebCore/WebFormState.h> 79 #import <WebCore/WebLoader.h> 80 #import <WebKit/DOM.h> 81 #import <WebKitSystemInterface.h> 82 #import <objc/objc-runtime.h> 83 #import <wtf/HashMap.h> 60 #import <WebKit/DOMDocument.h> 61 #import <WebKit/DOMElement.h> 62 #import <WebKit/DOMHTMLElement.h> 63 #import <WebKit/DOMRange.h> 84 64 85 65 // FIXME: We should have a way to get the following DOM interface from the WebCore internal headers, but we … … 140 120 using namespace WebCore; 141 121 142 typedef HashMap<RefPtr<WebResourceLoader>, RetainPtr<WebResource> > ResourceMap;143 144 122 NSString *WebPageCacheEntryDateKey = @"WebPageCacheEntryDateKey"; 145 123 NSString *WebPageCacheDataSourceKey = @"WebPageCacheDataSourceKey"; … … 148 126 @interface WebFrame (ForwardDecls) 149 127 - (void)_loadHTMLString:(NSString *)string baseURL:(NSURL *)URL unreachableURL:(NSURL *)unreachableURL; 150 - (void)_saveScrollPositionAndViewStateToItem:(WebHistoryItem *)item;151 128 - (WebHistoryItem *)_createItem:(BOOL)useOriginal; 152 129 - (WebHistoryItem *)_createItemTreeWithTargetFrame:(WebFrame *)targetFrame clippedAtTarget:(BOOL)doClip; … … 156 133 @interface NSView (WebFramePluginHosting) 157 134 - (void)setWebFrame:(WebFrame *)webFrame; 158 @end159 160 @interface WebFramePrivate : NSObject161 {162 @public163 WebFrameView *webFrameView;164 165 WebFrameBridge *bridge;166 WebHistoryItem *currentItem; // BF item for our current content167 WebHistoryItem *provisionalItem; // BF item for where we're trying to go168 // (only known when navigating to a pre-existing BF item)169 WebHistoryItem *previousItem; // BF item for previous content, see _itemForSavingDocState170 171 WebScriptDebugger *scriptDebugger;172 id internalLoadDelegate;173 174 NSMutableSet *plugInViews;175 NSMutableSet *inspectors;176 177 ResourceMap* pendingArchivedResources;178 }179 180 - (void)setWebFrameView:(WebFrameView *)v;181 182 - (void)setProvisionalItem:(WebHistoryItem *)item;183 - (void)setPreviousItem:(WebHistoryItem *)item;184 - (void)setCurrentItem:(WebHistoryItem *)item;185 186 135 @end 187 136 … … 201 150 [inspectors release]; 202 151 203 delete pendingArchivedResources;204 205 152 [super dealloc]; 206 }207 208 - (void)finalize209 {210 delete pendingArchivedResources;211 212 [super finalize];213 153 } 214 154 … … 218 158 [webFrameView release]; 219 159 webFrameView = v; 220 }221 222 - (void)setProvisionalItem:(WebHistoryItem *)item223 {224 [item retain];225 [provisionalItem release];226 provisionalItem = item;227 }228 229 - (void)setPreviousItem:(WebHistoryItem *)item230 {231 [item retain];232 [previousItem release];233 previousItem = item;234 }235 236 - (void)setCurrentItem:(WebHistoryItem *)item237 {238 [item retain];239 [currentItem release];240 currentItem = item;241 160 } 242 161 … … 365 284 366 285 // Set the item for which we will save document state 367 [ _privatesetPreviousItem:_private->currentItem];368 [ _privatesetCurrentItem:bfItem];286 [self _setPreviousItem:_private->currentItem]; 287 [self _setCurrentItem:bfItem]; 369 288 370 289 return bfItem; … … 429 348 { 430 349 return FrameLoader::timeOfLastCompletedLoad(); 431 }432 433 - (BOOL)_createPageCacheForItem:(WebHistoryItem *)item434 {435 NSMutableDictionary *pageCache;436 437 [item setHasPageCache: YES];438 439 if (![_private->bridge saveDocumentToPageCache]){440 [item setHasPageCache: NO];441 return NO;442 }443 else {444 pageCache = [item pageCache];445 [pageCache setObject:[NSDate date] forKey: WebPageCacheEntryDateKey];446 [pageCache setObject:[self dataSource] forKey: WebPageCacheDataSourceKey];447 [pageCache setObject:[[self frameView] documentView] forKey: WebPageCacheDocumentViewKey];448 }449 return YES;450 350 } 451 351 … … 531 431 532 432 // must do this maintenance here, since we don't go through a real page reload 533 [ _privatesetCurrentItem:item];534 [self _restoreScrollPositionAndViewState];433 [self _setCurrentItem:item]; 434 core(self)->loader()->client()->restoreScrollPositionAndViewState(); 535 435 536 436 // Fake the URL change by updating the data source's request. This will no longer … … 543 443 } else { 544 444 // Remember this item so we can traverse any child items as child frames load 545 [ _privatesetProvisionalItem:item];445 [self _setProvisionalItem:item]; 546 446 547 447 WebDataSource *newDataSource; … … 652 552 [self _saveScrollPositionAndViewStateToItem:_private->currentItem]; 653 553 654 [ _privatesetCurrentItem:item];554 [self _setCurrentItem:item]; 655 555 656 556 // Restore form state (works from currentItem) 657 557 [_private->bridge restoreDocumentState]; 658 558 // Restore the scroll position (taken in favor of going back to the anchor) 659 [self _restoreScrollPositionAndViewState];559 core(self)->loader()->client()->restoreScrollPositionAndViewState(); 660 560 661 561 NSArray *childItems = [item children]; … … 724 624 if (isBackForwardLoadType(loadType)) 725 625 // For back/forward, remember this item so we can traverse any child items as child frames load 726 [childFrame ->_privatesetProvisionalItem:childItem];626 [childFrame _setProvisionalItem:childItem]; 727 627 else 728 628 // For reload, just reinstall the current item, since a new child frame was created but we won't be creating a new BF item 729 [childFrame ->_privatesetCurrentItem:childItem];629 [childFrame _setCurrentItem:childItem]; 730 630 } 731 631 } … … 741 641 { 742 642 if (item) { 743 NSView <WebDocumentView> *docView = [ [self frameView]documentView];643 NSView <WebDocumentView> *docView = [_private->webFrameView documentView]; 744 644 NSView *parent = [docView superview]; 745 645 // we might already be detached when this is called from detachFromParent, in which … … 995 895 - (BOOL)_hasSelection 996 896 { 997 id documentView = [ [self frameView]documentView];897 id documentView = [_private->webFrameView documentView]; 998 898 999 899 // optimization for common case to avoid creating potentially large selection string … … 1010 910 - (void)_clearSelection 1011 911 { 1012 id documentView = [ [self frameView]documentView];912 id documentView = [_private->webFrameView documentView]; 1013 913 if ([documentView conformsToProtocol:@protocol(WebDocumentText)]) 1014 914 [documentView deselectAll]; … … 1122 1022 } 1123 1023 1124 - (id <WebFormDelegate>)_formDelegate 1125 { 1126 return [[self webView] _formDelegate]; 1024 - (void)_setProvisionalItem:(WebHistoryItem *)item 1025 { 1026 [item retain]; 1027 [_private->provisionalItem release]; 1028 _private->provisionalItem = item; 1029 } 1030 1031 - (void)_setPreviousItem:(WebHistoryItem *)item 1032 { 1033 [item retain]; 1034 [_private->previousItem release]; 1035 _private->previousItem = item; 1036 } 1037 1038 - (void)_setCurrentItem:(WebHistoryItem *)item 1039 { 1040 [item retain]; 1041 [_private->currentItem release]; 1042 _private->currentItem = item; 1127 1043 } 1128 1044 … … 1292 1208 baseURL:[mainResource URL] 1293 1209 unreachableURL:nil]; 1294 RefPtr<DocumentLoader> documentLoader = [self _createDocumentLoaderWithRequest:request];1210 RefPtr<DocumentLoader> documentLoader = core(self)->loader()->client()->createDocumentLoader(request); 1295 1211 [dataSource(documentLoader.get()) _addToUnarchiveState:archive]; 1296 1212 [self _frameLoader]->load(documentLoader.get()); … … 1336 1252 1337 1253 @end 1338 1339 @implementation WebFrame (WebFrameLoaderClient)1340 1341 - (BOOL)_hasBackForwardList1342 {1343 return [[self webView] backForwardList] != nil;1344 }1345 1346 - (void)_resetBackForwardList1347 {1348 // Note this doesn't verify the current load type as a b/f operation because it is called from1349 // a subframe in the case of a delegate bailing out of the nav before it even gets to provisional state.1350 WebFrame *mainFrame = [[self webView] mainFrame];1351 WebHistoryItem *resetItem = mainFrame->_private->currentItem;1352 if (resetItem)1353 [[[self webView] backForwardList] goToItem:resetItem];1354 }1355 1356 - (void)_invalidateCurrentItemPageCache1357 {1358 // When we are pre-commit, the currentItem is where the pageCache data resides1359 NSDictionary *pageCache = [_private->currentItem pageCache];1360 1361 [_private->bridge invalidatePageCache:pageCache];1362 1363 // We're assuming that WebCore invalidates its pageCache state in didNotOpen:pageCache:1364 [_private->currentItem setHasPageCache:NO];1365 }1366 1367 - (BOOL)_provisionalItemIsTarget1368 {1369 return [_private->provisionalItem isTargetItem];1370 }1371 1372 - (BOOL)_loadProvisionalItemFromPageCache1373 {1374 WebHistoryItem *item = _private->provisionalItem;1375 if (![item hasPageCache])1376 return NO;1377 NSDictionary *pageCache = [item pageCache];1378 if (![pageCache objectForKey:WebCorePageCacheStateKey])1379 return NO;1380 LOG(PageCache, "Restoring page from back/forward cache, %@", [item URL]);1381 [[self provisionalDataSource] _loadFromPageCache:pageCache];1382 return YES;1383 }1384 1385 - (BOOL)_privateBrowsingEnabled1386 {1387 return [[[self webView] preferences] privateBrowsingEnabled];1388 }1389 1390 - (void)_makeDocumentView1391 {1392 NSView <WebDocumentView> *documentView = [_private->webFrameView _makeDocumentViewForDataSource:[self dataSource]];1393 if (!documentView)1394 return;1395 1396 // FIXME: We could save work and not do this for a top-level view that is not a WebHTMLView.1397 WebFrameView *v = _private->webFrameView;1398 [_private->bridge createFrameViewWithNSView:documentView marginWidth:[v _marginWidth] marginHeight:[v _marginHeight]];1399 [self _updateBackground];1400 [_private->bridge installInFrame:[v _scrollView]];1401 1402 // Call setDataSource on the document view after it has been placed in the view hierarchy.1403 // This what we for the top-level view, so should do this for views in subframes as well.1404 [documentView setDataSource:[self dataSource]];1405 }1406 1407 - (void)_forceLayout1408 {1409 NSView <WebDocumentView> *view = [[self frameView] documentView];1410 if ([view isKindOfClass:[WebHTMLView class]])1411 [(WebHTMLView *)view setNeedsToApplyStyles:YES];1412 [view setNeedsLayout:YES];1413 [view layout];1414 }1415 1416 - (void)_updateHistoryForCommit1417 {1418 FrameLoadType type = [self _frameLoader]->loadType();1419 if (isBackForwardLoadType(type) ||1420 (type == FrameLoadTypeReload && [[self provisionalDataSource] unreachableURL] != nil)) {1421 // Once committed, we want to use current item for saving DocState, and1422 // the provisional item for restoring state.1423 // Note previousItem must be set before we close the URL, which will1424 // happen when the data source is made non-provisional below1425 [_private setPreviousItem:_private->currentItem];1426 ASSERT(_private->provisionalItem);1427 [_private setCurrentItem:_private->provisionalItem];1428 [_private setProvisionalItem:nil];1429 }1430 }1431 1432 - (void)_updateHistoryForReload1433 {1434 WebHistoryItem *currItem = _private->currentItem;1435 LOG(PageCache, "Clearing back/forward cache, %@\n", [currItem URL]);1436 [currItem setHasPageCache:NO];1437 if ([self _frameLoader]->loadType() == FrameLoadTypeReload)1438 [self _saveScrollPositionAndViewStateToItem:currItem];1439 WebDataSource *dataSource = [self dataSource];1440 NSURLRequest *request = [dataSource request];1441 // Sometimes loading a page again leads to a different result because of cookies. Bugzilla 40721442 if ([request _webDataRequestUnreachableURL] == nil)1443 [currItem setURL:[request URL]];1444 // Update the last visited time. Mostly interesting for URL autocompletion statistics.1445 NSURL *URL = [[[dataSource _documentLoader]->originalRequestCopy() URL] _webkit_canonicalize];1446 WebHistory *sharedHistory = [WebHistory optionalSharedHistory];1447 WebHistoryItem *oldItem = [sharedHistory itemForURL:URL];1448 if (oldItem)1449 [sharedHistory setLastVisitedTimeInterval:[NSDate timeIntervalSinceReferenceDate] forItem:oldItem];1450 }1451 1452 - (void)_updateHistoryForStandardLoad1453 {1454 WebDataSource *dataSource = [self dataSource];1455 if (![dataSource _documentLoader]->isClientRedirect()) {1456 NSURL *URL = [dataSource _URLForHistory];1457 if (URL && ![URL _web_isEmpty]) {1458 ASSERT([self webView]);1459 if (![[[self webView] preferences] privateBrowsingEnabled]) {1460 WebHistoryItem *entry = [[WebHistory optionalSharedHistory] addItemForURL:URL];1461 if ([dataSource pageTitle])1462 [entry setTitle:[dataSource pageTitle]];1463 }1464 [self _addBackForwardItemClippedAtTarget:YES];1465 }1466 } else {1467 NSURLRequest *request = [dataSource request];1468 1469 // Update the URL in the BF list that we made before the redirect, unless1470 // this is alternate content for an unreachable URL (we want the BF list1471 // item to remember the unreachable URL in case it becomes reachable later).1472 if ([request _webDataRequestUnreachableURL] == nil) {1473 [_private->currentItem setURL:[request URL]];1474 1475 // clear out the form data so we don't repost it to the wrong place if we1476 // ever go back/forward to this item1477 [_private->currentItem _setFormInfoFromRequest:request];1478 1479 // We must also clear out form data so we don't try to restore it into the incoming page,1480 // see -_opened1481 }1482 }1483 }1484 1485 - (void)_updateHistoryForBackForwardNavigation1486 {1487 // Must grab the current scroll position before disturbing it1488 [self _saveScrollPositionAndViewStateToItem:_private->previousItem];1489 }1490 1491 - (void)_updateHistoryForInternalLoad1492 {1493 // Add an item to the item tree for this frame1494 ASSERT(![self _frameLoader]->documentLoader()->isClientRedirect());1495 WebFrame *parentFrame = [self parentFrame];1496 if (parentFrame) {1497 WebHistoryItem *parentItem = parentFrame->_private->currentItem;1498 // The only case where parentItem==nil should be when a parent frame loaded an1499 // empty URL, which doesn't set up a current item in that parent.1500 if (parentItem)1501 [parentItem addChildItem:[self _createItem:YES]];1502 } else {1503 // See 3556159. It's not clear if it's valid to be in WebFrameLoadTypeOnLoadEvent1504 // for a top-level frame, but that was a likely explanation for those crashes,1505 // so let's guard against it.1506 // ...and all WebFrameLoadTypeOnLoadEvent uses were folded to WebFrameLoadTypeInternal1507 LOG_ERROR("no parent frame in transitionToCommitted:, WebFrameLoadTypeInternal");1508 }1509 }1510 1511 - (LoadErrorResetToken *)_tokenForLoadErrorReset1512 {1513 return (LoadErrorResetToken*)[[self _currentBackForwardListItemToResetTo] retain];1514 }1515 1516 - (void)_resetAfterLoadError:(LoadErrorResetToken *)token1517 {1518 WebHistoryItem *item = (WebHistoryItem *)token;1519 if (item)1520 [[[self webView] backForwardList] goToItem:item];1521 [item release];1522 }1523 1524 - (void)_doNotResetAfterLoadError:(LoadErrorResetToken *)token1525 {1526 WebHistoryItem *item = (WebHistoryItem *)token;1527 [item release];1528 }1529 1530 - (void)_dispatchDidHandleOnloadEventsForFrame1531 {1532 WebView *webView = [self webView];1533 [[webView _frameLoadDelegateForwarder] webView:webView didHandleOnloadEventsForFrame:self];1534 }1535 1536 - (void)_dispatchDidReceiveServerRedirectForProvisionalLoadForFrame1537 {1538 WebView *webView = [self webView];1539 [[webView _frameLoadDelegateForwarder] webView:webView1540 didReceiveServerRedirectForProvisionalLoadForFrame:self];1541 }1542 1543 - (id)_dispatchIdentifierForInitialRequest:(NSURLRequest *)clientRequest fromDocumentLoader:(DocumentLoader*)loader1544 {1545 WebView *webView = [self webView];1546 id resourceLoadDelegate = [webView resourceLoadDelegate];1547 1548 if ([webView _resourceLoadDelegateImplementations].delegateImplementsIdentifierForRequest)1549 return [resourceLoadDelegate webView:webView identifierForInitialRequest:clientRequest fromDataSource:dataSource(loader)];1550 1551 return [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView identifierForInitialRequest:clientRequest fromDataSource:dataSource(loader)];1552 }1553 1554 - (NSURLRequest *)_dispatchResource:(id)identifier willSendRequest:(NSURLRequest *)clientRequest redirectResponse:(NSURLResponse *)redirectResponse fromDocumentLoader:(DocumentLoader*)loader1555 {1556 WebView *webView = [self webView];1557 id resourceLoadDelegate = [webView resourceLoadDelegate];1558 1559 if ([webView _resourceLoadDelegateImplementations].delegateImplementsWillSendRequest)1560 return [resourceLoadDelegate webView:webView resource:identifier willSendRequest:clientRequest redirectResponse:redirectResponse fromDataSource:dataSource(loader)];1561 else1562 return [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier willSendRequest:clientRequest redirectResponse:redirectResponse fromDataSource:dataSource(loader)];1563 }1564 1565 - (void)_dispatchDidReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier fromDocumentLoader:(DocumentLoader*)loader1566 {1567 WebView *webView = [self webView];1568 id resourceLoadDelegate = [webView resourceLoadDelegate];1569 1570 if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidReceiveAuthenticationChallenge)1571 [resourceLoadDelegate webView:webView resource:identifier didReceiveAuthenticationChallenge:currentWebChallenge fromDataSource:dataSource(loader)];1572 else1573 [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didReceiveAuthenticationChallenge:currentWebChallenge fromDataSource:dataSource(loader)];1574 }1575 1576 - (void)_dispatchDidCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier fromDocumentLoader:(DocumentLoader*)loader1577 {1578 WebView *webView = [self webView];1579 id resourceLoadDelegate = [webView resourceLoadDelegate];1580 1581 if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidCancelAuthenticationChallenge)1582 [resourceLoadDelegate webView:webView resource:identifier didCancelAuthenticationChallenge:currentWebChallenge fromDataSource:dataSource(loader)];1583 else1584 [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didCancelAuthenticationChallenge:currentWebChallenge fromDataSource:dataSource(loader)];1585 }1586 1587 - (void)_dispatchResource:(id)identifier didReceiveResponse:(NSURLResponse *)r fromDocumentLoader:(DocumentLoader*)loader1588 {1589 WebView *webView = [self webView];1590 1591 if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidReceiveResponse)1592 [[webView resourceLoadDelegate] webView:webView resource:identifier didReceiveResponse:r fromDataSource:dataSource(loader)];1593 else1594 [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didReceiveResponse:r fromDataSource:dataSource(loader)];1595 }1596 1597 - (void)_dispatchResource:(id)identifier didReceiveContentLength:(int)lengthReceived fromDocumentLoader:(DocumentLoader*)loader1598 {1599 WebView *webView = [self webView];1600 1601 if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidReceiveContentLength)1602 [[webView resourceLoadDelegate] webView:webView resource:identifier didReceiveContentLength:(WebNSUInteger)lengthReceived fromDataSource:dataSource(loader)];1603 else1604 [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didReceiveContentLength:(WebNSUInteger)lengthReceived fromDataSource:dataSource(loader)];1605 }1606 1607 - (void)_dispatchResource:(id)identifier didFinishLoadingFromDocumentLoader:(DocumentLoader*)loader1608 {1609 WebView *webView = [self webView];1610 1611 if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidFinishLoadingFromDataSource)1612 [[webView resourceLoadDelegate] webView:webView resource:identifier didFinishLoadingFromDataSource:dataSource(loader)];1613 else1614 [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didFinishLoadingFromDataSource:dataSource(loader)];1615 }1616 1617 1618 - (void)_dispatchResource:(id)identifier didFailLoadingWithError:error fromDocumentLoader:(DocumentLoader*)loader1619 {1620 WebView *webView = [self webView];1621 [[webView _resourceLoadDelegateForwarder] webView:webView resource:identifier didFailLoadingWithError:error fromDataSource:dataSource(loader)];1622 }1623 1624 - (void)_dispatchDidCancelClientRedirectForFrame1625 {1626 WebView *webView = [self webView];1627 [[webView _frameLoadDelegateForwarder] webView:webView didCancelClientRedirectForFrame:self];1628 }1629 1630 - (void)_dispatchWillPerformClientRedirectToURL:(NSURL *)URL delay:(NSTimeInterval)seconds fireDate:(NSDate *)date1631 {1632 WebView *webView = [self webView];1633 [[webView _frameLoadDelegateForwarder] webView:webView1634 willPerformClientRedirectToURL:URL1635 delay:seconds1636 fireDate:date1637 forFrame:self];1638 }1639 1640 - (void)_dispatchDidChangeLocationWithinPageForFrame1641 {1642 WebView *webView = [self webView];1643 [[webView _frameLoadDelegateForwarder] webView:webView didChangeLocationWithinPageForFrame:self];1644 }1645 1646 - (void)_dispatchWillCloseFrame1647 {1648 WebView *webView = [self webView];1649 [[webView _frameLoadDelegateForwarder] webView:webView willCloseFrame:self];1650 }1651 1652 - (void)_dispatchDidReceiveIcon:(NSImage *)icon1653 {1654 WebView *webView = [self webView];1655 ASSERT([self _isMainFrame]);1656 [webView _willChangeValueForKey:_WebMainFrameIconKey];1657 [[webView _frameLoadDelegateForwarder] webView:webView didReceiveIcon:icon forFrame:self];1658 [webView _didChangeValueForKey:_WebMainFrameIconKey];1659 }1660 1661 - (void)_dispatchDidStartProvisionalLoadForFrame1662 {1663 WebView *webView = [self webView];1664 [webView _didStartProvisionalLoadForFrame:self];1665 [[webView _frameLoadDelegateForwarder] webView:webView didStartProvisionalLoadForFrame:self];1666 }1667 1668 - (void)_dispatchDidReceiveTitle:(NSString *)title1669 {1670 WebView *webView = [self webView];1671 [[webView _frameLoadDelegateForwarder] webView:webView didReceiveTitle:title forFrame:self];1672 }1673 1674 - (void)_dispatchDidCommitLoadForFrame1675 {1676 // Tell the client we've committed this URL.1677 ASSERT([[self frameView] documentView] != nil);1678 1679 WebView *webView = [self webView];1680 [webView _didCommitLoadForFrame:self];1681 [[webView _frameLoadDelegateForwarder] webView:webView didCommitLoadForFrame:self];1682 }1683 1684 - (void)_dispatchDidFailProvisionalLoadWithError:(NSError *)error1685 {1686 WebView *webView = [self webView];1687 [webView _didFailProvisionalLoadWithError:error forFrame:self];1688 [[webView _frameLoadDelegateForwarder] webView:webView didFailProvisionalLoadWithError:error forFrame:self];1689 [_private->internalLoadDelegate webFrame:self didFinishLoadWithError:error];1690 }1691 1692 - (void)_dispatchDidFailLoadWithError:(NSError *)error1693 {1694 WebView *webView = [self webView];1695 [webView _didFailLoadWithError:error forFrame:self];1696 [[webView _frameLoadDelegateForwarder] webView:webView didFailLoadWithError:error forFrame:self];1697 [_private->internalLoadDelegate webFrame:self didFinishLoadWithError:error];1698 }1699 1700 - (void)_dispatchDidFinishLoadForFrame1701 {1702 WebView *webView = [self webView];1703 [webView _didFinishLoadForFrame:self];1704 [[webView _frameLoadDelegateForwarder] webView:webView didFinishLoadForFrame:self];1705 [_private->internalLoadDelegate webFrame:self didFinishLoadWithError:nil];1706 }1707 1708 - (void)_dispatchDidFirstLayoutInFrame1709 {1710 WebView *webView = [self webView];1711 [[webView _frameLoadDelegateForwarder] webView:webView didFirstLayoutInFrame:self];1712 }1713 1714 - (Frame*)_dispatchCreateWebViewWithRequest:(NSURLRequest *)request1715 {1716 WebView *currentWebView = [self webView];1717 id wd = [currentWebView UIDelegate];1718 if ([wd respondsToSelector:@selector(webView:createWebViewWithRequest:)])1719 return core([[wd webView:currentWebView createWebViewWithRequest:request] mainFrame]);1720 return core([[[WebDefaultUIDelegate sharedUIDelegate] webView:currentWebView createWebViewWithRequest:request] mainFrame]);1721 }1722 1723 - (void)_dispatchShow1724 {1725 WebView *webView = [self webView];1726 [[webView _UIDelegateForwarder] webViewShow:webView];1727 }1728 1729 - (WebPolicyDecider *)_createPolicyDeciderWithTarget:(id)target action:(SEL)action1730 {1731 return [[WebPolicyDeciderMac alloc] initWithTarget:target action:action];1732 }1733 1734 static inline WebPolicyDecisionListener *decisionListener(WebPolicyDecider *decider)1735 {1736 return [(WebPolicyDeciderMac *)decider decisionListener];1737 }1738 1739 - (void)_dispatchDecidePolicyForMIMEType:(NSString *)MIMEType request:(NSURLRequest *)request decider:(WebPolicyDecider *)decider1740 {1741 WebView *webView = [self webView];1742 1743 [[webView _policyDelegateForwarder] webView:webView decidePolicyForMIMEType:MIMEType request:request frame:self decisionListener:decisionListener(decider)];1744 }1745 1746 - (void)_dispatchDecidePolicyForNewWindowAction:(NSDictionary *)action request:(NSURLRequest *)request newFrameName:(NSString *)frameName decider:(WebPolicyDecider *)decider1747 {1748 WebView *webView = [self webView];1749 [[webView _policyDelegateForwarder] webView:webView1750 decidePolicyForNewWindowAction:action1751 request:request1752 newFrameName:frameName1753 decisionListener:decisionListener(decider)];1754 }1755 1756 - (void)_dispatchDecidePolicyForNavigationAction:(NSDictionary *)action request:(NSURLRequest *)request decider:(WebPolicyDecider *)decider1757 {1758 WebView *webView = [self webView];1759 [[webView _policyDelegateForwarder] webView:webView1760 decidePolicyForNavigationAction:action1761 request:request1762 frame:self1763 decisionListener:decisionListener(decider)];1764 }1765 1766 - (void)_dispatchUnableToImplementPolicyWithError:(NSError *)error1767 {1768 WebView *webView = [self webView];1769 [[webView _policyDelegateForwarder] webView:webView unableToImplementPolicyWithError:error frame:self];1770 }1771 1772 - (void)_dispatchSourceFrame:(Frame*)sourceFrame willSubmitForm:(Element*)form withValues:(NSDictionary *)values submissionDecider:(WebPolicyDecider *)decider1773 {1774 [[self _formDelegate] frame:self sourceFrame:kit(sourceFrame) willSubmitForm:kit(form) withValues:values submissionListener:decisionListener(decider)];1775 }1776 1777 - (void)_detachedFromParent11778 {1779 [self _saveScrollPositionAndViewStateToItem:_private->currentItem];1780 }1781 1782 - (void)_detachedFromParent21783 {1784 [_private->inspectors makeObjectsPerformSelector:@selector(_webFrameDetached:) withObject:self];1785 [_private->webFrameView _setWebFrame:nil]; // needed for now to be compatible w/ old behavior1786 }1787 1788 - (void)_detachedFromParent31789 {1790 [_private setWebFrameView:nil];1791 }1792 1793 - (void)_detachedFromParent41794 {1795 _private->bridge = nil;1796 }1797 1798 - (void)_updateHistoryAfterClientRedirect1799 {1800 // Clear out form data so we don't try to restore it into the incoming page. Must happen after1801 // khtml has closed the URL and saved away the form state.1802 WebHistoryItem *item = _private->currentItem;1803 [item setDocumentState:nil];1804 [item setScrollPoint:NSZeroPoint];1805 }1806 1807 - (void)_loadedFromPageCache1808 {1809 // Release the resources kept in the page cache.1810 // They will be reset when we leave this page.1811 // The WebCore side of the page cache will have already been invalidated by1812 // the bridge to prevent premature release.1813 [_private->currentItem setHasPageCache:NO];1814 }1815 1816 - (void)_downloadWithLoadingConnection:(NSURLConnection *)connection request:(NSURLRequest *)request response:(NSURLResponse *)response proxy:(id)proxy1817 {1818 [WebDownload _downloadWithLoadingConnection:connection1819 request:request1820 response:response1821 delegate:[[self webView] downloadDelegate]1822 proxy:proxy];1823 }1824 1825 - (void)_setDocumentViewFromPageCache:(NSDictionary *)pageCache1826 {1827 NSView <WebDocumentView> *cachedView = [pageCache objectForKey:WebPageCacheDocumentViewKey];1828 ASSERT(cachedView != nil);1829 [[self frameView] _setDocumentView:cachedView];1830 }1831 1832 - (void)_setCopiesOnScroll1833 {1834 [[[[self frameView] _scrollView] contentView] setCopiesOnScroll:YES];1835 }1836 1837 - (void)_dispatchDidLoadMainResourceForDocumentLoader:(DocumentLoader*)loader1838 {1839 if ([WebScriptDebugServer listenerCount])1840 [[WebScriptDebugServer sharedScriptDebugServer] webView:[self webView]1841 didLoadMainResourceForDataSource:dataSource(loader)];1842 }1843 1844 - (void)_forceLayoutForNonHTML1845 {1846 WebFrameView *thisView = [self frameView];1847 NSView <WebDocumentView> *thisDocumentView = [thisView documentView];1848 ASSERT(thisDocumentView != nil);1849 1850 // Tell the just loaded document to layout. This may be necessary1851 // for non-html content that needs a layout message.1852 if (!([[self dataSource] _isDocumentHTML])) {1853 [thisDocumentView setNeedsLayout:YES];1854 [thisDocumentView layout];1855 [thisDocumentView setNeedsDisplay:YES];1856 }1857 }1858 1859 - (void)_clearLoadingFromPageCacheForDocumentLoader:(DocumentLoader*)loader1860 {1861 [dataSource(loader) _setLoadingFromPageCache:NO];1862 }1863 1864 - (BOOL)_isDocumentLoaderLoadingFromPageCache:(DocumentLoader*)loader1865 {1866 return [dataSource(loader) _loadingFromPageCache];1867 }1868 1869 - (void)_makeRepresentationForDocumentLoader:(DocumentLoader*)loader1870 {1871 [dataSource(loader) _makeRepresentation];1872 }1873 1874 - (void)_revertToProvisionalStateForDocumentLoader:(DocumentLoader*)loader1875 {1876 [dataSource(loader) _revertToProvisionalState];1877 }1878 1879 - (void)_setMainDocumentError:(NSError *)error forDocumentLoader:(DocumentLoader*)loader1880 {1881 [dataSource(loader) _setMainDocumentError:error];1882 }1883 1884 - (void)_clearUnarchivingStateForLoader:(DocumentLoader*)loader1885 {1886 [dataSource(loader) _clearUnarchivingState];1887 }1888 1889 - (void)_progressStarted1890 {1891 [[self webView] _progressStarted:self];1892 }1893 1894 - (void)_progressCompleted1895 {1896 [[self webView] _progressCompleted:self];1897 }1898 1899 - (void)_incrementProgressForIdentifier:(id)identifier response:(NSURLResponse *)response1900 {1901 [[self webView] _incrementProgressForIdentifier:identifier response:response];1902 }1903 1904 - (void)_incrementProgressForIdentifier:(id)identifier data:(NSData *)data1905 {1906 [[self webView] _incrementProgressForIdentifier:identifier data:data];1907 }1908 1909 - (void)_completeProgressForIdentifier:(id)identifier1910 {1911 [[self webView] _completeProgressForIdentifier:identifier];1912 }1913 1914 - (void)_setMainFrameDocumentReady:(BOOL)ready1915 {1916 [[self webView] setMainFrameDocumentReady:ready];1917 }1918 1919 - (void)_willChangeTitleForDocument:(DocumentLoader*)loader1920 {1921 // FIXME: Should do this only in main frame case, right?1922 [[self webView] _willChangeValueForKey:_WebMainFrameTitleKey];1923 }1924 1925 - (void)_didChangeTitleForDocument:(DocumentLoader*)loader1926 {1927 // FIXME: Should do this only in main frame case, right?1928 [[self webView] _didChangeValueForKey:_WebMainFrameTitleKey];1929 }1930 1931 - (void)_startDownloadWithRequest:(NSURLRequest *)request1932 {1933 // FIXME: Should download full request.1934 [[self webView] _downloadURL:[request URL]];1935 }1936 1937 - (void)_finishedLoadingDocument:(DocumentLoader*)loader1938 {1939 [dataSource(loader) _finishedLoading];1940 }1941 1942 - (void)_committedLoadWithDocumentLoader:(DocumentLoader*)loader data:(NSData *)data1943 {1944 [dataSource(loader) _receivedData:data];1945 }1946 1947 - (void)_documentLoader:(DocumentLoader*)loader setMainDocumentError:(NSError *)error1948 {1949 [dataSource(loader) _setMainDocumentError:error];1950 }1951 1952 - (void)_finalSetupForReplaceWithDocumentLoader:(DocumentLoader*)loader1953 {1954 [dataSource(loader) _clearUnarchivingState];1955 }1956 1957 - (NSError *)_cancelledErrorWithRequest:(NSURLRequest *)request1958 {1959 return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled URL:[request URL]];1960 }1961 1962 - (NSError *)_cannotShowURLErrorWithRequest:(NSURLRequest *)request1963 {1964 return [NSError _webKitErrorWithDomain:WebKitErrorDomain code:WebKitErrorCannotShowURL URL:[request URL]];1965 }1966 1967 - (NSError *)_interruptForPolicyChangeErrorWithRequest:(NSURLRequest *)request1968 {1969 return [NSError _webKitErrorWithDomain:WebKitErrorDomain code:WebKitErrorFrameLoadInterruptedByPolicyChange URL:[request URL]];1970 }1971 1972 - (NSError *)_cannotShowMIMETypeErrorWithResponse:(NSURLResponse *)response1973 {1974 return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:WebKitErrorCannotShowMIMEType URL:[response URL]];1975 }1976 1977 - (NSError *)_fileDoesNotExistErrorWithResponse:(NSURLResponse *)response1978 {1979 return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist URL:[response URL]];1980 }1981 1982 - (BOOL)_shouldFallBackForError:(NSError *)error1983 {1984 // FIXME: Needs to check domain.1985 // FIXME: WebKitErrorPlugInWillHandleLoad is a workaround for the cancel we do to prevent1986 // loading plugin content twice. See <rdar://problem/4258008>1987 return [error code] != NSURLErrorCancelled && [error code] != WebKitErrorPlugInWillHandleLoad;1988 }1989 1990 - (BOOL)_hasWebView1991 {1992 return [self webView] != nil;1993 }1994 1995 - (BOOL)_hasFrameView1996 {1997 return [self frameView] != nil;1998 }1999 2000 - (NSURL *)_mainFrameURL2001 {2002 return [[[[self webView] mainFrame] dataSource] _URL];2003 }2004 2005 // The following 2 methods are copied from [NSHTTPURLProtocol _cachedResponsePassesValidityChecks] and modified for our needs.2006 // FIXME: It would be nice to eventually to share this code somehow.2007 - (BOOL)_canUseResourceForRequest:(NSURLRequest *)request2008 {2009 NSURLRequestCachePolicy policy = [request cachePolicy];2010 if (policy == NSURLRequestReturnCacheDataElseLoad)2011 return YES;2012 if (policy == NSURLRequestReturnCacheDataDontLoad)2013 return YES;2014 if (policy == NSURLRequestReloadIgnoringCacheData)2015 return NO;2016 if ([request valueForHTTPHeaderField:@"must-revalidate"] != nil)2017 return NO;2018 if ([request valueForHTTPHeaderField:@"proxy-revalidate"] != nil)2019 return NO;2020 if ([request valueForHTTPHeaderField:@"If-Modified-Since"] != nil)2021 return NO;2022 if ([request valueForHTTPHeaderField:@"Cache-Control"] != nil)2023 return NO;2024 if ([@"POST" _webkit_isCaseInsensitiveEqualToString:[request HTTPMethod]])2025 return NO;2026 return YES;2027 }2028 2029 - (BOOL)_canUseResourceWithResponse:(NSURLResponse *)response2030 {2031 if (WKGetNSURLResponseMustRevalidate(response))2032 return NO;2033 if (WKGetNSURLResponseCalculatedExpiration(response) - CFAbsoluteTimeGetCurrent() < 1)2034 return NO;2035 return YES;2036 }2037 2038 - (void)_deliverArchivedResourcesAfterDelay2039 {2040 if (!_private->pendingArchivedResources)2041 return;2042 if (_private->pendingArchivedResources->isEmpty())2043 return;2044 if ([self _frameLoader]->defersCallbacks())2045 return;2046 2047 [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(_deliverArchivedResources) object:nil];2048 [self performSelector:@selector(_deliverArchivedResources) withObject:nil afterDelay:0];2049 }2050 2051 - (BOOL)_willUseArchiveForRequest:(NSURLRequest *)r originalURL:(NSURL *)originalURL loader:(WebResourceLoader*)loader2052 {2053 if (![[r URL] isEqual:originalURL])2054 return NO;2055 if (![self _canUseResourceForRequest:r])2056 return NO;2057 WebResource *resource = [dataSource([self _frameLoader]->activeDocumentLoader()) _archivedSubresourceForURL:originalURL];2058 if (!resource)2059 return NO;2060 if (![self _canUseResourceWithResponse:[resource _response]])2061 return NO;2062 if (!_private->pendingArchivedResources)2063 _private->pendingArchivedResources = new ResourceMap;2064 _private->pendingArchivedResources->set(loader, resource);2065 // Deliver the resource after a delay because callers don't expect to receive callbacks while calling this method.2066 [self _deliverArchivedResourcesAfterDelay];2067 return YES;2068 }2069 2070 - (BOOL)_archiveLoadPendingForLoader:(WebResourceLoader*)loader2071 {2072 if (!_private->pendingArchivedResources)2073 return false;2074 return _private->pendingArchivedResources->contains(loader);2075 }2076 2077 - (void)_cancelPendingArchiveLoadForLoader:(WebResourceLoader*)loader2078 {2079 if (!_private->pendingArchivedResources)2080 return;2081 if (_private->pendingArchivedResources->isEmpty())2082 return;2083 _private->pendingArchivedResources->remove(loader);2084 if (_private->pendingArchivedResources->isEmpty())2085 [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(_deliverArchivedResources) object:nil];2086 }2087 2088 - (void)_clearArchivedResources2089 {2090 if (_private->pendingArchivedResources)2091 _private->pendingArchivedResources->clear();2092 [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(_deliverArchivedResources) object:nil];2093 }2094 2095 - (void)_deliverArchivedResources2096 {2097 if (!_private->pendingArchivedResources)2098 return;2099 if (_private->pendingArchivedResources->isEmpty())2100 return;2101 if ([self _frameLoader]->defersCallbacks())2102 return;2103 2104 const ResourceMap copy = *_private->pendingArchivedResources;2105 _private->pendingArchivedResources->clear();2106 2107 ResourceMap::const_iterator end = copy.end();2108 for (ResourceMap::const_iterator it = copy.begin(); it != end; ++it) {2109 RefPtr<WebResourceLoader> loader = it->first;2110 WebResource *resource = it->second.get();2111 NSData *data = [[resource data] retain];2112 loader->didReceiveResponse([resource _response]);2113 loader->didReceiveData(data, [data length], true);2114 [data release];2115 loader->didFinishLoading();2116 }2117 }2118 2119 - (void)_setDefersCallbacks:(BOOL)defers2120 {2121 if (!defers)2122 [self _deliverArchivedResourcesAfterDelay];2123 }2124 2125 - (BOOL)_canHandleRequest:(NSURLRequest *)request2126 {2127 return [WebView _canHandleRequest:request];2128 }2129 2130 - (BOOL)_canShowMIMEType:(NSString *)MIMEType2131 {2132 return [WebView canShowMIMEType:MIMEType];2133 }2134 2135 - (BOOL)_representationExistsForURLScheme:(NSString *)URLScheme2136 {2137 return [WebView _representationExistsForURLScheme:URLScheme];2138 }2139 2140 - (NSString *)_generatedMIMETypeForURLScheme:(NSString *)URLScheme2141 {2142 return [WebView _generatedMIMETypeForURLScheme:URLScheme];2143 }2144 2145 - (NSDictionary *)_elementForEvent:(NSEvent *)event2146 {2147 switch ([event type]) {2148 case NSLeftMouseDown:2149 case NSRightMouseDown:2150 case NSOtherMouseDown:2151 case NSLeftMouseUp:2152 case NSRightMouseUp:2153 case NSOtherMouseUp:2154 break;2155 default:2156 return nil;2157 }2158 2159 NSView *topViewInEventWindow = [[event window] contentView];2160 NSView *viewContainingPoint = [topViewInEventWindow hitTest:2161 [topViewInEventWindow convertPoint:[event locationInWindow] fromView:nil]];2162 while (viewContainingPoint) {2163 if ([viewContainingPoint isKindOfClass:[WebView class]])2164 return [(WebView *)viewContainingPoint elementAtPoint:2165 [viewContainingPoint convertPoint:[event locationInWindow] fromView:nil]];2166 viewContainingPoint = [viewContainingPoint superview];2167 }2168 return nil;2169 }2170 2171 - (void)_frameLoadCompleted2172 {2173 // Note: Can be called multiple times.2174 // Even if already complete, we might have set a previous item on a frame that2175 // didn't do any data loading on the past transaction. Make sure to clear these out.2176 NSScrollView *sv = [[self frameView] _scrollView];2177 if ([[self webView] drawsBackground])2178 [sv setDrawsBackground:YES];2179 [_private setPreviousItem:nil];2180 }2181 2182 /*2183 There is a race condition between the layout and load completion that affects restoring the scroll position.2184 We try to restore the scroll position at both the first layout and upon load completion.2185 2186 1) If first layout happens before the load completes, we want to restore the scroll position then so that the2187 first time we draw the page is already scrolled to the right place, instead of starting at the top and later2188 jumping down. It is possible that the old scroll position is past the part of the doc laid out so far, in2189 which case the restore silent fails and we will fix it in when we try to restore on doc completion.2190 2) If the layout happens after the load completes, the attempt to restore at load completion time silently2191 fails. We then successfully restore it when the layout happens.2192 */2193 2194 - (void)_restoreScrollPositionAndViewState2195 {2196 ASSERT(_private->currentItem);2197 NSView <WebDocumentView> *docView = [[self frameView] documentView];2198 NSPoint point = [_private->currentItem scrollPoint];2199 if ([docView conformsToProtocol:@protocol(_WebDocumentViewState)]) {2200 id state = [_private->currentItem viewState];2201 if (state) {2202 [(id <_WebDocumentViewState>)docView setViewState:state];2203 }2204 2205 [(id <_WebDocumentViewState>)docView setScrollPoint:point];2206 } else {2207 [docView scrollPoint:point];2208 }2209 }2210 2211 - (void)_setTitle:(NSString *)title forURL:(NSURL *)URL2212 {2213 [[[WebHistory optionalSharedHistory] itemForURL:URL] setTitle:title];2214 [_private->currentItem setTitle:title];2215 }2216 2217 - (PassRefPtr<DocumentLoader>)_createDocumentLoaderWithRequest:(NSURLRequest *)request2218 {2219 RefPtr<WebDocumentLoaderMac> loader = new WebDocumentLoaderMac(request);2220 2221 WebDataSource *dataSource = [[WebDataSource alloc] _initWithDocumentLoader:loader.get()];2222 loader->setDataSource(dataSource);2223 [dataSource release];2224 2225 return loader.release();2226 }2227 2228 - (void)_prepareForDataSourceReplacement2229 {2230 if (![self dataSource]) {2231 ASSERT(!core(self)->tree()->childCount());2232 return;2233 }2234 2235 // Make sure that any work that is triggered by resigning first reponder can get done.2236 // The main example where this came up is the textDidEndEditing that is sent to the2237 // FormsDelegate (3223413). We need to do this before _detachChildren, since that will2238 // remove the views as a side-effect of freeing the bridge, at which point we can't2239 // post the FormDelegate messages.2240 //2241 // Note that this can also take FirstResponder away from a child of our frameView that2242 // is not in a child frame's view. This is OK because we are in the process2243 // of loading new content, which will blow away all editors in this top frame, and if2244 // a non-editor is firstReponder it will not be affected by endEditingFor:.2245 // Potentially one day someone could write a DocView whose editors were not all2246 // replaced by loading new content, but that does not apply currently.2247 NSView *frameView = [self frameView];2248 NSWindow *window = [frameView window];2249 NSResponder *firstResp = [window firstResponder];2250 if ([firstResp isKindOfClass:[NSView class]] && [(NSView *)firstResp isDescendantOf:frameView])2251 [window endEditingFor:firstResp];2252 2253 [self _frameLoader]->detachChildren();2254 }2255 2256 - (void)_didFinishLoad2257 {2258 [_private->internalLoadDelegate webFrame:self didFinishLoadWithError:nil];2259 }2260 2261 - (void)_addHistoryItemForFragmentScroll2262 {2263 [self _addBackForwardItemClippedAtTarget:NO];2264 }2265 2266 - (BOOL)_shouldTreatURLAsSameAsCurrent:(NSURL *)URL2267 {2268 WebHistoryItem *item = _private->currentItem;2269 NSString* URLString = [URL _web_originalDataAsString];2270 return [URLString isEqual:[item URLString]] || [URLString isEqual:[item originalURLString]];2271 }2272 2273 - (void)_provisionalLoadStarted2274 {2275 FrameLoadType loadType = [self _frameLoader]->loadType();2276 2277 // FIXME: This is OK as long as no one resizes the window,2278 // but in the case where someone does, it means garbage outside2279 // the occupied part of the scroll view.2280 [[[self frameView] _scrollView] setDrawsBackground:NO];2281 2282 // Cache the page, if possible.2283 // Don't write to the cache if in the middle of a redirect, since we will want to2284 // store the final page we end up on.2285 // No point writing to the cache on a reload or loadSame, since we will just write2286 // over it again when we leave that page.2287 WebHistoryItem *item = _private->currentItem;2288 if ([self _canCachePage]2289 && item2290 && ![self _frameLoader]->isQuickRedirectComing()2291 && loadType != FrameLoadTypeReload2292 && loadType != FrameLoadTypeReloadAllowingStaleData2293 && loadType != FrameLoadTypeSame2294 && ![[self dataSource] isLoading]2295 && ![self _frameLoader]->documentLoader()->isStopping()) {2296 if ([[[self dataSource] representation] isKindOfClass:[WebHTMLRepresentation class]]) {2297 if (![item pageCache]){2298 // Add the items to this page's cache.2299 if ([self _createPageCacheForItem:item]) {2300 LOG(PageCache, "Saving page to back/forward cache, %@\n", [[self dataSource] _URL]);2301 2302 // See if any page caches need to be purged after the addition of this2303 // new page cache.2304 [self _purgePageCache];2305 }2306 else2307 LOG(PageCache, "NOT saving page to back/forward cache, unable to create items, %@\n", [[self dataSource] _URL]);2308 }2309 } else2310 // Put the document into a null state, so it can be restored correctly.2311 core(self)->clear();2312 } else2313 LOG(PageCache, "NOT saving page to back/forward cache, %@\n", [[self dataSource] _URL]);2314 }2315 2316 @end -
trunk/WebKit/WebView/WebFrameInternal.h
r17299 r17365 30 30 31 31 #import "WebFramePrivate.h" 32 #import "WebPolicyDelegatePrivate.h"33 32 34 33 #ifdef __cplusplus 35 34 #import <WebCore/FrameLoaderTypes.h> 36 #import <wtf/Forward.h>37 35 #endif 38 36 37 @class DOMElement; 39 38 @class DOMRange; 40 39 @class WebInspector; 41 40 @class WebFrameView; 42 41 @class WebFrameBridge; 43 @class WebPolicyDecider; 42 @class WebHistoryItem; 43 @class WebScriptDebugger; 44 44 45 45 #ifdef __cplusplus … … 54 54 class HTMLElement; 55 55 class Range; 56 class WebResourceLoader;57 struct LoadErrorResetToken;58 56 } 59 57 … … 72 70 WebCore::Range* core(DOMRange *); 73 71 DOMRange *kit(WebCore::Range*); 72 73 @interface WebFramePrivate : NSObject 74 { 75 @public 76 WebFrameView *webFrameView; 77 78 WebFrameBridge *bridge; 79 WebHistoryItem *currentItem; // BF item for our current content 80 WebHistoryItem *provisionalItem; // BF item for where we're trying to go 81 // (only known when navigating to a pre-existing BF item) 82 WebHistoryItem *previousItem; // BF item for previous content, see _itemForSavingDocState 83 84 WebScriptDebugger *scriptDebugger; 85 id internalLoadDelegate; 86 87 NSMutableSet *plugInViews; 88 NSMutableSet *inspectors; 89 } 90 @end 74 91 75 92 #endif … … 148 165 - (void)_recursive_resumeNullEventsForAllNetscapePlugins; 149 166 150 @end 167 - (void)_setProvisionalItem:(WebHistoryItem *)item; 168 - (void)_setPreviousItem:(WebHistoryItem *)item; 169 - (void)_setCurrentItem:(WebHistoryItem *)item; 151 170 152 #ifdef __cplusplus 171 - (void)_saveScrollPositionAndViewStateToItem:(WebHistoryItem *)item; 153 172 154 @interface WebFrame (WebFrameLoaderClient) 173 - (void)_addBackForwardItemClippedAtTarget:(BOOL)doClip; 155 174 156 - (BOOL)_hasBackForwardList; 157 - (void)_resetBackForwardList; 158 - (void)_invalidateCurrentItemPageCache; 159 - (BOOL)_provisionalItemIsTarget; 160 - (BOOL)_loadProvisionalItemFromPageCache; 161 - (BOOL)_privateBrowsingEnabled; 162 - (void)_makeDocumentView; 163 - (void)_forceLayout; 164 - (void)_updateHistoryForCommit; 165 - (void)_updateHistoryForReload; 166 - (void)_updateHistoryForStandardLoad; 167 - (void)_updateHistoryForBackForwardNavigation; 168 - (void)_updateHistoryForInternalLoad; 169 - (WebCore::LoadErrorResetToken*)_tokenForLoadErrorReset; 170 - (void)_resetAfterLoadError:(WebCore::LoadErrorResetToken*)token; 171 - (void)_doNotResetAfterLoadError:(WebCore::LoadErrorResetToken*)token; 172 - (void)_dispatchDidHandleOnloadEventsForFrame; 173 - (void)_dispatchDidReceiveServerRedirectForProvisionalLoadForFrame; 174 - (id)_dispatchIdentifierForInitialRequest:(NSURLRequest *)clientRequest fromDocumentLoader:(WebCore::DocumentLoader*)loader; 175 - (NSURLRequest *)_dispatchResource:(id)identifier willSendRequest:(NSURLRequest *)clientRequest redirectResponse:(NSURLResponse *)redirectResponse fromDocumentLoader:(WebCore::DocumentLoader*)loader; 176 - (void)_dispatchDidReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier fromDocumentLoader:(WebCore::DocumentLoader*)loader; 177 - (void)_dispatchDidCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier fromDocumentLoader:(WebCore::DocumentLoader*)loader; 178 - (void)_dispatchResource:(id)identifier didReceiveResponse:(NSURLResponse *)r fromDocumentLoader:(WebCore::DocumentLoader*)loader; 179 - (void)_dispatchResource:(id)identifier didReceiveContentLength:(int)lengthReceived fromDocumentLoader:(WebCore::DocumentLoader*)loader; 180 - (void)_dispatchResource:(id)identifier didFinishLoadingFromDocumentLoader:(WebCore::DocumentLoader*)loader; 181 - (void)_dispatchResource:(id)identifier didFailLoadingWithError:error fromDocumentLoader:(WebCore::DocumentLoader*)loader; 182 - (void)_dispatchDidCancelClientRedirectForFrame; 183 - (void)_dispatchWillPerformClientRedirectToURL:(NSURL *)URL delay:(NSTimeInterval)seconds fireDate:(NSDate *)date; 184 - (void)_dispatchDidChangeLocationWithinPageForFrame; 185 - (void)_dispatchWillCloseFrame; 186 - (void)_dispatchDidReceiveIcon:(NSImage *)icon; 187 - (void)_dispatchDidStartProvisionalLoadForFrame; 188 - (void)_dispatchDidReceiveTitle:(NSString *)title; 189 - (void)_dispatchDidCommitLoadForFrame; 190 - (void)_dispatchDidFailProvisionalLoadWithError:(NSError *)error; 191 - (void)_dispatchDidFailLoadWithError:(NSError *)error; 192 - (void)_dispatchDidFinishLoadForFrame; 193 - (void)_dispatchDidFirstLayoutInFrame; 194 - (WebCore::Frame*)_dispatchCreateWebViewWithRequest:(NSURLRequest *)request; 195 - (void)_dispatchShow; 196 - (WebPolicyDecider *)_createPolicyDeciderWithTarget:(id)target action:(SEL)action; 197 - (void)_dispatchDecidePolicyForMIMEType:(NSString *)MIMEType request:(NSURLRequest *)request decider:(WebPolicyDecider *)decider; 198 - (void)_dispatchDecidePolicyForNewWindowAction:(NSDictionary *)action request:(NSURLRequest *)request newFrameName:(NSString *)frameName decider:(WebPolicyDecider *)decider; 199 - (void)_dispatchDecidePolicyForNavigationAction:(NSDictionary *)action request:(NSURLRequest *)request decider:(WebPolicyDecider *)decider; 200 - (void)_dispatchUnableToImplementPolicyWithError:(NSError *)error; 201 - (void)_dispatchSourceFrame:(WebCore::Frame*)sourceFrame willSubmitForm:(WebCore::Element*)form withValues:(NSDictionary *)values submissionDecider:(WebPolicyDecider *)decider; 202 - (void)_detachedFromParent1; 203 - (void)_detachedFromParent2; 204 - (void)_detachedFromParent3; 205 - (void)_detachedFromParent4; 206 - (void)_updateHistoryAfterClientRedirect; 207 - (void)_loadedFromPageCache; 208 - (void)_downloadWithLoadingConnection:(NSURLConnection *)connection request:(NSURLRequest *)request response:(NSURLResponse *)response proxy:(id)proxy; 209 - (void)_setDocumentViewFromPageCache:(NSDictionary *)pageCache; 210 - (void)_setCopiesOnScroll; 211 - (void)_dispatchDidLoadMainResourceForDocumentLoader:(WebCore::DocumentLoader*)loader; 212 - (void)_forceLayoutForNonHTML; 213 - (void)_clearLoadingFromPageCacheForDocumentLoader:(WebCore::DocumentLoader*)loader; 214 - (BOOL)_isDocumentLoaderLoadingFromPageCache:(WebCore::DocumentLoader*)loader; 215 - (void)_makeRepresentationForDocumentLoader:(WebCore::DocumentLoader*)loader; 216 - (void)_revertToProvisionalStateForDocumentLoader:(WebCore::DocumentLoader*)loader; 217 - (void)_setMainDocumentError:(NSError *)error forDocumentLoader:(WebCore::DocumentLoader*)loader; 218 - (void)_clearUnarchivingStateForLoader:(WebCore::DocumentLoader*)loader; 219 - (void)_progressStarted; 220 - (void)_progressCompleted; 221 - (void)_incrementProgressForIdentifier:(id)identifier response:(NSURLResponse *)response; 222 - (void)_incrementProgressForIdentifier:(id)identifier data:(NSData *)data; 223 - (void)_completeProgressForIdentifier:(id)identifier; 224 - (void)_setMainFrameDocumentReady:(BOOL)ready; 225 - (void)_willChangeTitleForDocument:(WebCore::DocumentLoader*)loader; 226 - (void)_didChangeTitleForDocument:(WebCore::DocumentLoader*)loader; 227 - (void)_startDownloadWithRequest:(NSURLRequest *)request; 228 - (void)_finishedLoadingDocument:(WebCore::DocumentLoader*)loader; 229 - (void)_committedLoadWithDocumentLoader:(WebCore::DocumentLoader*)loader data:(NSData *)data; 230 - (void)_documentLoader:(WebCore::DocumentLoader*)loader setMainDocumentError:(NSError *)error; 231 - (void)_finalSetupForReplaceWithDocumentLoader:(WebCore::DocumentLoader*)loader; 232 - (NSError *)_cancelledErrorWithRequest:(NSURLRequest *)request; 233 - (NSError *)_cannotShowURLErrorWithRequest:(NSURLRequest *)request; 234 - (NSError *)_interruptForPolicyChangeErrorWithRequest:(NSURLRequest *)request; 235 - (NSError *)_cannotShowMIMETypeErrorWithResponse:(NSURLResponse *)response; 236 - (NSError *)_fileDoesNotExistErrorWithResponse:(NSURLResponse *)response; 237 - (BOOL)_shouldFallBackForError:(NSError *)error; 238 - (BOOL)_hasWebView; 239 - (BOOL)_hasFrameView; 240 - (NSURL *)_mainFrameURL; 241 - (BOOL)_canUseResourceForRequest:(NSURLRequest *)request; 242 - (BOOL)_canUseResourceWithResponse:(NSURLResponse *)response; 243 - (void)_deliverArchivedResourcesAfterDelay; 244 - (BOOL)_willUseArchiveForRequest:(NSURLRequest *)r originalURL:(NSURL *)originalURL loader:(WebCore::WebResourceLoader*)loader; 245 - (BOOL)_archiveLoadPendingForLoader:(WebCore::WebResourceLoader*)loader; 246 - (void)_cancelPendingArchiveLoadForLoader:(WebCore::WebResourceLoader*)loader; 247 - (void)_clearArchivedResources; 248 - (void)_deliverArchivedResources; 249 - (void)_setDefersCallbacks:(BOOL)defers; 250 - (BOOL)_canHandleRequest:(NSURLRequest *)request; 251 - (BOOL)_canShowMIMEType:(NSString *)MIMEType; 252 - (BOOL)_representationExistsForURLScheme:(NSString *)URLScheme; 253 - (NSString *)_generatedMIMETypeForURLScheme:(NSString *)URLScheme; 254 - (NSDictionary *)_elementForEvent:(NSEvent *)event; 255 - (void)_frameLoadCompleted; 256 - (void)_restoreScrollPositionAndViewState; 257 - (void)_setTitle:(NSString *)title forURL:(NSURL *)URL; 258 - (PassRefPtr<WebCore::DocumentLoader>)_createDocumentLoaderWithRequest:(NSURLRequest *)request; 259 - (void)_prepareForDataSourceReplacement; 260 - (void)_didFinishLoad; 261 - (void)_addHistoryItemForFragmentScroll; 262 - (BOOL)_shouldTreatURLAsSameAsCurrent:(NSURL *)URL; 263 - (void)_provisionalLoadStarted; 175 - (WebHistoryItem *)_createItem:(BOOL)useOriginal; 264 176 265 177 @end 266 267 #endif268 178 269 179 @interface NSObject (WebInternalFrameLoadDelegate) -
trunk/WebKit/WebView/WebHTMLView.m
r17303 r17365 944 944 { 945 945 WebHTMLView *view = (WebHTMLView *)[[[[_private->dataSource _webView] mainFrame] frameView] documentView]; 946 ASSERT(view); 946 947 ASSERT([view isKindOfClass:[WebHTMLView class]]); 947 948 return view; -
trunk/WebKit/WebView/WebHTMLViewPrivate.h
r16975 r17365 30 30 31 31 @class DOMDocumentFragment; 32 @class DOMNode; 32 33 @class DOMRange; 33 34 @class WebArchive;
Note: See TracChangeset
for help on using the changeset viewer.