+2006-10-27 Darin Adler <darin@apple.com>
+
+ Reviewed by Maciej.
+
+ - moved methods that are there just to be called by the frame loader client into the client
+ in an attempt to get back some of the speed we lost yesterday
+
+ * DefaultDelegates/WebDefaultResourceLoadDelegate.m:
+ (-[WebDefaultResourceLoadDelegate webView:resource:didReceiveAuthenticationChallenge:fromDataSource:]):
+ (-[WebDefaultResourceLoadDelegate webView:resource:didCancelAuthenticationChallenge:fromDataSource:]):
+ * WebCoreSupport/WebFrameLoaderClient.h:
+ * WebCoreSupport/WebFrameLoaderClient.mm:
+ (dataSource):
+ (decisionListener):
+ (WebFrameLoaderClient::WebFrameLoaderClient):
+ (WebFrameLoaderClient::hasWebView):
+ (WebFrameLoaderClient::hasFrameView):
+ (WebFrameLoaderClient::hasBackForwardList):
+ (WebFrameLoaderClient::resetBackForwardList):
+ (WebFrameLoaderClient::provisionalItemIsTarget):
+ (WebFrameLoaderClient::loadProvisionalItemFromPageCache):
+ (WebFrameLoaderClient::invalidateCurrentItemPageCache):
+ (WebFrameLoaderClient::privateBrowsingEnabled):
+ (WebFrameLoaderClient::makeDocumentView):
+ (WebFrameLoaderClient::makeRepresentation):
+ (WebFrameLoaderClient::setDocumentViewFromPageCache):
+ (WebFrameLoaderClient::forceLayout):
+ (WebFrameLoaderClient::forceLayoutForNonHTML):
+ (WebFrameLoaderClient::updateHistoryForCommit):
+ (WebFrameLoaderClient::updateHistoryForBackForwardNavigation):
+ (WebFrameLoaderClient::updateHistoryForReload):
+ (WebFrameLoaderClient::updateHistoryForStandardLoad):
+ (WebFrameLoaderClient::updateHistoryForInternalLoad):
+ (WebFrameLoaderClient::updateHistoryAfterClientRedirect):
+ (WebFrameLoaderClient::setCopiesOnScroll):
+ (WebFrameLoaderClient::tokenForLoadErrorReset):
+ (WebFrameLoaderClient::resetAfterLoadError):
+ (WebFrameLoaderClient::doNotResetAfterLoadError):
+ (WebFrameLoaderClient::detachedFromParent1):
+ (WebFrameLoaderClient::detachedFromParent2):
+ (WebFrameLoaderClient::detachedFromParent3):
+ (WebFrameLoaderClient::detachedFromParent4):
+ (WebFrameLoaderClient::loadedFromPageCache):
+ (WebFrameLoaderClient::download):
+ (WebFrameLoaderClient::dispatchIdentifierForInitialRequest):
+ (WebFrameLoaderClient::dispatchWillSendRequest):
+ (WebFrameLoaderClient::dispatchDidReceiveAuthenticationChallenge):
+ (WebFrameLoaderClient::dispatchDidCancelAuthenticationChallenge):
+ (WebFrameLoaderClient::dispatchDidReceiveResponse):
+ (WebFrameLoaderClient::dispatchDidReceiveContentLength):
+ (WebFrameLoaderClient::dispatchDidFinishLoading):
+ (WebFrameLoaderClient::dispatchDidFailLoading):
+ (WebFrameLoaderClient::dispatchDidHandleOnloadEvents):
+ (WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad):
+ (WebFrameLoaderClient::dispatchDidCancelClientRedirect):
+ (WebFrameLoaderClient::dispatchWillPerformClientRedirect):
+ (WebFrameLoaderClient::dispatchDidChangeLocationWithinPage):
+ (WebFrameLoaderClient::dispatchWillClose):
+ (WebFrameLoaderClient::dispatchDidReceiveIcon):
+ (WebFrameLoaderClient::dispatchDidStartProvisionalLoad):
+ (WebFrameLoaderClient::dispatchDidReceiveTitle):
+ (WebFrameLoaderClient::dispatchDidCommitLoad):
+ (WebFrameLoaderClient::dispatchDidFailProvisionalLoad):
+ (WebFrameLoaderClient::dispatchDidFailLoad):
+ (WebFrameLoaderClient::dispatchDidFinishLoad):
+ (WebFrameLoaderClient::dispatchDidFirstLayout):
+ (WebFrameLoaderClient::dispatchCreatePage):
+ (WebFrameLoaderClient::dispatchShow):
+ (WebFrameLoaderClient::dispatchDecidePolicyForMIMEType):
+ (WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction):
+ (WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
+ (WebFrameLoaderClient::dispatchUnableToImplementPolicy):
+ (WebFrameLoaderClient::dispatchWillSubmitForm):
+ (WebFrameLoaderClient::dispatchDidLoadMainResource):
+ (WebFrameLoaderClient::clearLoadingFromPageCache):
+ (WebFrameLoaderClient::isLoadingFromPageCache):
+ (WebFrameLoaderClient::revertToProvisionalState):
+ (WebFrameLoaderClient::setMainDocumentError):
+ (WebFrameLoaderClient::clearUnarchivingState):
+ (WebFrameLoaderClient::progressStarted):
+ (WebFrameLoaderClient::progressCompleted):
+ (WebFrameLoaderClient::incrementProgress):
+ (WebFrameLoaderClient::completeProgress):
+ (WebFrameLoaderClient::setMainFrameDocumentReady):
+ (WebFrameLoaderClient::startDownload):
+ (WebFrameLoaderClient::willChangeTitle):
+ (WebFrameLoaderClient::didChangeTitle):
+ (WebFrameLoaderClient::committedLoad):
+ (WebFrameLoaderClient::finishedLoading):
+ (WebFrameLoaderClient::finalSetupForReplace):
+ (WebFrameLoaderClient::cancelledError):
+ (WebFrameLoaderClient::cannotShowURLError):
+ (WebFrameLoaderClient::interruptForPolicyChangeError):
+ (WebFrameLoaderClient::cannotShowMIMETypeError):
+ (WebFrameLoaderClient::fileDoesNotExistError):
+ (WebFrameLoaderClient::shouldFallBack):
+ (WebFrameLoaderClient::mainFrameURL):
+ (WebFrameLoaderClient::setDefersCallbacks):
+ (WebFrameLoaderClient::willUseArchive):
+ (WebFrameLoaderClient::isArchiveLoadPending):
+ (WebFrameLoaderClient::cancelPendingArchiveLoad):
+ (WebFrameLoaderClient::clearArchivedResources):
+ (WebFrameLoaderClient::canHandleRequest):
+ (WebFrameLoaderClient::canShowMIMEType):
+ (WebFrameLoaderClient::representationExistsForURLScheme):
+ (WebFrameLoaderClient::generatedMIMETypeForURLScheme):
+ (WebFrameLoaderClient::elementForEvent):
+ (WebFrameLoaderClient::createPolicyDecider):
+ (WebFrameLoaderClient::frameLoadCompleted):
+ (WebFrameLoaderClient::restoreScrollPositionAndViewState):
+ (WebFrameLoaderClient::provisionalLoadStarted):
+ (WebFrameLoaderClient::shouldTreatURLAsSameAsCurrent):
+ (WebFrameLoaderClient::addHistoryItemForFragmentScroll):
+ (WebFrameLoaderClient::didFinishLoad):
+ (WebFrameLoaderClient::prepareForDataSourceReplacement):
+ (WebFrameLoaderClient::createDocumentLoader):
+ (WebFrameLoaderClient::setTitle):
+ (WebFrameLoaderClient::canUseArchivedResource):
+ (WebFrameLoaderClient::deliverArchivedResourcesAfterDelay):
+ (WebFrameLoaderClient::deliverArchivedResources):
+ (WebFrameLoaderClient::createPageCache):
+ * WebView/WebFrame.mm:
+ (-[NSView setWebFrame:]):
+ (-[WebFrame _createItem:]):
+ (-[WebFrame _loadItem:withLoadType:]):
+ (-[WebFrame _recursiveGoToItem:fromItem:withLoadType:]):
+ (-[WebFrame _loadURL:referrer:intoChild:]):
+ (-[WebFrame _saveScrollPositionAndViewStateToItem:]):
+ (-[WebFrame _hasSelection]):
+ (-[WebFrame _clearSelection]):
+ (-[WebFrame _setProvisionalItem:]):
+ (-[WebFrame _setPreviousItem:]):
+ (-[WebFrame _setCurrentItem:]):
+ (-[WebFrame loadArchive:]):
+ * WebView/WebFrameInternal.h:
+ * WebView/WebHTMLView.m:
+ (-[WebHTMLView _topHTMLView]):
+ * WebView/WebHTMLViewPrivate.h:
+
2006-10-26 Geoffrey Garen <ggaren@apple.com>
Reviewed by Darin, Maciej.
- (void)webView:(WebView *)wv resource:(id)identifier didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)dataSource
{
- NSWindow *window = [wv hostWindow] ? [wv hostWindow] : [wv window];
- [[WebPanelAuthenticationHandler sharedHandler] startAuthentication:challenge window:window];
}
- (void)webView:(WebView *)wv resource:(id)identifier didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)dataSource
{
- [(WebPanelAuthenticationHandler *)[WebPanelAuthenticationHandler sharedHandler] cancelAuthentication:challenge];
}
-(void)webView: (WebView *)wv resource:identifier didReceiveResponse: (NSURLResponse *)response fromDataSource:(WebDataSource *)dataSource
*/
#import <WebCore/RetainPtr.h>
+#import <WebCore/Timer.h>
#import <WebCore/WebFrameLoaderClient.h>
+#import <wtf/HashMap.h>
@class WebFrame;
+@class WebHistoryItem;
+@class WebResource;
namespace WebCore {
class String;
+ class WebResourceLoader;
}
+typedef HashMap<RefPtr<WebCore::WebResourceLoader>, WebCore::RetainPtr<WebResource> > ResourceMap;
+
class WebFrameLoaderClient : public WebCore::FrameLoaderClient {
public:
WebFrameLoaderClient(WebFrame*);
WebFrame* webFrame() const { return m_webFrame.get(); }
+private:
virtual void detachFrameLoader();
virtual bool hasWebView() const; // mainly for assertions
virtual PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(NSURLRequest *);
virtual void setTitle(NSString *title, NSURL *);
-private:
+ void deliverArchivedResourcesAfterDelay() const;
+ bool canUseArchivedResource(NSURLRequest *) const;
+ bool canUseArchivedResource(NSURLResponse *) const;
+ void deliverArchivedResources(WebCore::Timer<WebFrameLoaderClient>*);
+
+ bool createPageCache(WebHistoryItem *);
+
WebCore::RetainPtr<WebFrame> m_webFrame;
+ mutable ResourceMap m_pendingArchivedResources;
+ mutable WebCore::Timer<WebFrameLoaderClient> m_archivedResourcesDeliveryTimer;
};
#import "WebFrameLoaderClient.h"
+// Terrible hack, but needed so we can get right at the private structure.
+#define private public
+#import "WebFrame.h"
+#undef private
+
+#import "WebBackForwardList.h"
+#import "WebDataSourceInternal.h"
+#import "WebDocumentInternal.h"
+#import "WebDocumentLoaderMac.h"
+#import "WebDownloadInternal.h"
#import "WebFrameInternal.h"
+#import "WebFrameLoadDelegate.h"
+#import "WebFrameViewInternal.h"
+#import "WebHTMLRepresentation.h"
+#import "WebHTMLView.h"
+#import "WebHistoryItemPrivate.h"
+#import "WebHistoryPrivate.h"
+#import "WebKitErrorsPrivate.h"
+#import "WebKitNSStringExtras.h"
+#import "WebNSURLExtras.h"
+#import "WebPanelAuthenticationHandler.h"
+#import "WebPolicyDeciderMac.h"
+#import "WebPolicyDelegatePrivate.h"
+#import "WebPreferences.h"
+#import "WebResourcePrivate.h"
+#import "WebResourceLoadDelegate.h"
+#import "WebScriptDebugServerPrivate.h"
+#import "WebUIDelegate.h"
+#import "WebViewInternal.h"
#import <WebCore/FrameMac.h>
+#import <WebCore/FrameTree.h>
#import <WebCore/PlatformString.h>
#import <WebCore/WebCoreFrameBridge.h>
+#import <WebCore/WebDataProtocol.h>
#import <WebCore/WebDocumentLoader.h>
-#import <WebKit/DOMElement.h>
+#import <WebCore/WebFrameLoader.h>
+#import <WebCore/WebLoader.h>
+#import <WebKitSystemInterface.h>
#import <wtf/PassRefPtr.h>
using namespace WebCore;
+static inline WebDataSource *dataSource(DocumentLoader* loader)
+{
+ return loader ? static_cast<WebDocumentLoaderMac*>(loader)->dataSource() : nil;
+}
+
+static inline WebPolicyDecisionListener *decisionListener(WebPolicyDecider *decider)
+{
+ return [(WebPolicyDeciderMac *)decider decisionListener];
+}
+
WebFrameLoaderClient::WebFrameLoaderClient(WebFrame *webFrame)
: m_webFrame(webFrame)
+ , m_archivedResourcesDeliveryTimer(this, &WebFrameLoaderClient::deliverArchivedResources)
{
}
bool WebFrameLoaderClient::hasWebView() const
{
- return [m_webFrame.get() _hasWebView];
+ return [m_webFrame.get() webView] != nil;
}
bool WebFrameLoaderClient::hasFrameView() const
{
- return [m_webFrame.get() _hasFrameView];
+ return m_webFrame->_private->webFrameView != nil;
}
bool WebFrameLoaderClient::hasBackForwardList() const
{
- return [m_webFrame.get() _hasBackForwardList];
+ return [[m_webFrame.get() webView] backForwardList] != nil;
}
void WebFrameLoaderClient::resetBackForwardList()
{
- [m_webFrame.get() _resetBackForwardList];
+ // Note this doesn't verify the current load type as a b/f operation because it is called from
+ // a subframe in the case of a delegate bailing out of the nav before it even gets to provisional state.
+ WebFrame *mainFrame = [[m_webFrame.get() webView] mainFrame];
+ WebHistoryItem *resetItem = mainFrame->_private->currentItem;
+ if (resetItem)
+ [[[m_webFrame.get() webView] backForwardList] goToItem:resetItem];
}
bool WebFrameLoaderClient::provisionalItemIsTarget() const
{
- return [m_webFrame.get() _provisionalItemIsTarget];
+ return [m_webFrame->_private->provisionalItem isTargetItem];
}
bool WebFrameLoaderClient::loadProvisionalItemFromPageCache()
{
- return [m_webFrame.get() _loadProvisionalItemFromPageCache];
+ WebHistoryItem *item = m_webFrame->_private->provisionalItem;
+ if (![item hasPageCache])
+ return false;
+ NSDictionary *pageCache = [item pageCache];
+ if (![pageCache objectForKey:WebCorePageCacheStateKey])
+ return false;
+ [[m_webFrame.get() provisionalDataSource] _loadFromPageCache:pageCache];
+ return true;
}
void WebFrameLoaderClient::invalidateCurrentItemPageCache()
{
- [m_webFrame.get() _invalidateCurrentItemPageCache];
+ // When we are pre-commit, the currentItem is where the pageCache data resides
+ WebHistoryItem *currentItem = m_webFrame->_private->currentItem;
+ NSDictionary *pageCache = [currentItem pageCache];
+ [m_webFrame->_private->bridge invalidatePageCache:pageCache];
+ // We're assuming that WebCore invalidates its pageCache state in didNotOpen:pageCache:
+ [currentItem setHasPageCache:NO];
}
bool WebFrameLoaderClient::privateBrowsingEnabled() const
{
- return [m_webFrame.get() _privateBrowsingEnabled];
+ return [[[m_webFrame.get() webView] preferences] privateBrowsingEnabled];
}
void WebFrameLoaderClient::makeDocumentView()
{
- [m_webFrame.get() _makeDocumentView];
+ WebFrameView *v = m_webFrame->_private->webFrameView;
+ WebDataSource *ds = [m_webFrame.get() dataSource];
+
+ NSView <WebDocumentView> *documentView = [v _makeDocumentViewForDataSource:ds];
+ if (!documentView)
+ return;
+
+ WebFrameBridge *bridge = m_webFrame->_private->bridge;
+
+ // FIXME: We could save work and not do this for a top-level view that is not a WebHTMLView.
+ [bridge createFrameViewWithNSView:documentView marginWidth:[v _marginWidth] marginHeight:[v _marginHeight]];
+ [m_webFrame.get() _updateBackground];
+ [bridge installInFrame:[v _scrollView]];
+
+ // Call setDataSource on the document view after it has been placed in the view hierarchy.
+ // This what we for the top-level view, so should do this for views in subframes as well.
+ [documentView setDataSource:ds];
}
void WebFrameLoaderClient::makeRepresentation(DocumentLoader* loader)
{
- [m_webFrame.get() _makeRepresentationForDocumentLoader:loader];
+ [dataSource(loader) _makeRepresentation];
}
-void WebFrameLoaderClient::setDocumentViewFromPageCache(NSDictionary *dictionary)
+void WebFrameLoaderClient::setDocumentViewFromPageCache(NSDictionary *pageCache)
{
- [m_webFrame.get() _setDocumentViewFromPageCache:dictionary];
+ NSView <WebDocumentView> *cachedView = [pageCache objectForKey:WebPageCacheDocumentViewKey];
+ ASSERT(cachedView != nil);
+ [m_webFrame->_private->webFrameView _setDocumentView:cachedView];
}
void WebFrameLoaderClient::forceLayout()
{
- [m_webFrame.get() _forceLayout];
+ NSView <WebDocumentView> *view = [m_webFrame->_private->webFrameView documentView];
+ if ([view isKindOfClass:[WebHTMLView class]])
+ [(WebHTMLView *)view setNeedsToApplyStyles:YES];
+ [view setNeedsLayout:YES];
+ [view layout];
}
void WebFrameLoaderClient::forceLayoutForNonHTML()
{
- [m_webFrame.get() _forceLayoutForNonHTML];
+ WebFrameView *thisView = m_webFrame->_private->webFrameView;
+ NSView <WebDocumentView> *thisDocumentView = [thisView documentView];
+ ASSERT(thisDocumentView != nil);
+
+ // Tell the just loaded document to layout. This may be necessary
+ // for non-html content that needs a layout message.
+ if (!([[m_webFrame.get() dataSource] _isDocumentHTML])) {
+ [thisDocumentView setNeedsLayout:YES];
+ [thisDocumentView layout];
+ [thisDocumentView setNeedsDisplay:YES];
+ }
}
void WebFrameLoaderClient::updateHistoryForCommit()
{
- [m_webFrame.get() _updateHistoryForCommit];
+ FrameLoadType type = core(m_webFrame.get())->loader()->loadType();
+ if (isBackForwardLoadType(type) ||
+ (type == FrameLoadTypeReload && [[m_webFrame.get() provisionalDataSource] unreachableURL] != nil)) {
+ // Once committed, we want to use current item for saving DocState, and
+ // the provisional item for restoring state.
+ // Note previousItem must be set before we close the URL, which will
+ // happen when the data source is made non-provisional below
+ [m_webFrame.get() _setPreviousItem:m_webFrame->_private->currentItem];
+ ASSERT(m_webFrame->_private->provisionalItem);
+ [m_webFrame.get() _setCurrentItem:m_webFrame->_private->provisionalItem];
+ [m_webFrame.get() _setProvisionalItem:nil];
+ }
}
void WebFrameLoaderClient::updateHistoryForBackForwardNavigation()
{
- [m_webFrame.get() _updateHistoryForBackForwardNavigation];
+ // Must grab the current scroll position before disturbing it
+ [m_webFrame.get() _saveScrollPositionAndViewStateToItem:m_webFrame->_private->previousItem];
}
void WebFrameLoaderClient::updateHistoryForReload()
{
- [m_webFrame.get() _updateHistoryForReload];
+ WebHistoryItem *currItem = m_webFrame->_private->previousItem;
+ [currItem setHasPageCache:NO];
+ if (core(m_webFrame.get())->loader()->loadType() == FrameLoadTypeReload)
+ [m_webFrame.get() _saveScrollPositionAndViewStateToItem:currItem];
+ WebDataSource *dataSource = [m_webFrame.get() dataSource];
+ NSURLRequest *request = [dataSource request];
+ // Sometimes loading a page again leads to a different result because of cookies. Bugzilla 4072
+ if ([request _webDataRequestUnreachableURL] == nil)
+ [currItem setURL:[request URL]];
+ // Update the last visited time. Mostly interesting for URL autocompletion statistics.
+ NSURL *URL = [[[dataSource _documentLoader]->originalRequestCopy() URL] _webkit_canonicalize];
+ WebHistory *sharedHistory = [WebHistory optionalSharedHistory];
+ WebHistoryItem *oldItem = [sharedHistory itemForURL:URL];
+ if (oldItem)
+ [sharedHistory setLastVisitedTimeInterval:[NSDate timeIntervalSinceReferenceDate] forItem:oldItem];
}
void WebFrameLoaderClient::updateHistoryForStandardLoad()
{
- [m_webFrame.get() _updateHistoryForStandardLoad];
+ WebDataSource *dataSource = [m_webFrame.get() dataSource];
+ if (![dataSource _documentLoader]->isClientRedirect()) {
+ NSURL *URL = [dataSource _URLForHistory];
+ if (URL && ![URL _web_isEmpty]) {
+ ASSERT([m_webFrame.get() webView]);
+ if (![[[m_webFrame.get() webView] preferences] privateBrowsingEnabled]) {
+ WebHistoryItem *entry = [[WebHistory optionalSharedHistory] addItemForURL:URL];
+ if ([dataSource pageTitle])
+ [entry setTitle:[dataSource pageTitle]];
+ }
+ [m_webFrame.get() _addBackForwardItemClippedAtTarget:YES];
+ }
+ } else {
+ NSURLRequest *request = [dataSource request];
+
+ // Update the URL in the BF list that we made before the redirect, unless
+ // this is alternate content for an unreachable URL (we want the BF list
+ // item to remember the unreachable URL in case it becomes reachable later).
+ if ([request _webDataRequestUnreachableURL] == nil) {
+ [m_webFrame->_private->currentItem setURL:[request URL]];
+
+ // clear out the form data so we don't repost it to the wrong place if we
+ // ever go back/forward to this item
+ [m_webFrame->_private->currentItem _setFormInfoFromRequest:request];
+
+ // We must also clear out form data so we don't try to restore it into the incoming page,
+ // see -_opened
+ }
+ }
}
void WebFrameLoaderClient::updateHistoryForInternalLoad()
{
- [m_webFrame.get() _updateHistoryForInternalLoad];
+ // Add an item to the item tree for this frame
+ ASSERT(!core(m_webFrame.get())->loader()->documentLoader()->isClientRedirect());
+ WebFrame *parentFrame = [m_webFrame.get() parentFrame];
+ if (parentFrame) {
+ WebHistoryItem *parentItem = parentFrame->_private->currentItem;
+ // The only case where parentItem==nil should be when a parent frame loaded an
+ // empty URL, which doesn't set up a current item in that parent.
+ if (parentItem)
+ [parentItem addChildItem:[m_webFrame.get() _createItem:YES]];
+ } else {
+ // See 3556159. It's not clear if it's valid to be in WebFrameLoadTypeOnLoadEvent
+ // for a top-level frame, but that was a likely explanation for those crashes,
+ // so let's guard against it.
+ // ...and all WebFrameLoadTypeOnLoadEvent uses were folded to WebFrameLoadTypeInternal
+ LOG_ERROR("no parent frame in transitionToCommitted:, WebFrameLoadTypeInternal");
+ }
}
-
void WebFrameLoaderClient::updateHistoryAfterClientRedirect()
{
- [m_webFrame.get() _updateHistoryAfterClientRedirect];
+ // Clear out form data so we don't try to restore it into the incoming page. Must happen after
+ // khtml has closed the URL and saved away the form state.
+ WebHistoryItem *item = m_webFrame->_private->currentItem;
+ [item setDocumentState:nil];
+ [item setScrollPoint:NSZeroPoint];
}
void WebFrameLoaderClient::setCopiesOnScroll()
{
- [m_webFrame.get() _setCopiesOnScroll];
+ [[[m_webFrame->_private->webFrameView _scrollView] contentView] setCopiesOnScroll:YES];
}
LoadErrorResetToken* WebFrameLoaderClient::tokenForLoadErrorReset()
{
- return [m_webFrame.get() _tokenForLoadErrorReset];
+ if (isBackForwardLoadType(core(m_webFrame.get())->loader()->loadType()) && [m_webFrame.get() _isMainFrame])
+ return (LoadErrorResetToken*)[m_webFrame->_private->currentItem retain];
+ return 0;
}
void WebFrameLoaderClient::resetAfterLoadError(LoadErrorResetToken* token)
{
- [m_webFrame.get() _resetAfterLoadError:token];
+ WebHistoryItem *item = (WebHistoryItem *)token;
+ if (!item)
+ return;
+ [[[m_webFrame.get() webView] backForwardList] goToItem:item];
+ [item release];
}
void WebFrameLoaderClient::doNotResetAfterLoadError(LoadErrorResetToken* token)
{
- [m_webFrame.get() _doNotResetAfterLoadError:token];
+ WebHistoryItem *item = (WebHistoryItem *)token;
+ [item release];
}
void WebFrameLoaderClient::detachedFromParent1()
{
- [m_webFrame.get() _detachedFromParent1];
+ [m_webFrame.get() _saveScrollPositionAndViewStateToItem:m_webFrame->_private->currentItem];
}
void WebFrameLoaderClient::detachedFromParent2()
{
- [m_webFrame.get() _detachedFromParent2];
+ [m_webFrame->_private->inspectors makeObjectsPerformSelector:@selector(_webFrameDetached:) withObject:m_webFrame.get()];
+ [m_webFrame->_private->webFrameView _setWebFrame:nil]; // needed for now to be compatible w/ old behavior
}
void WebFrameLoaderClient::detachedFromParent3()
{
- [m_webFrame.get() _detachedFromParent3];
+ [m_webFrame->_private->webFrameView release];
+ m_webFrame->_private->webFrameView = nil;
}
void WebFrameLoaderClient::detachedFromParent4()
{
- [m_webFrame.get() _detachedFromParent4];
+ m_webFrame->_private->bridge = nil;
}
void WebFrameLoaderClient::loadedFromPageCache()
{
- [m_webFrame.get() _loadedFromPageCache];
+ // Release the resources kept in the page cache.
+ // They will be reset when we leave this page.
+ // The WebCore side of the page cache will have already been invalidated by
+ // the bridge to prevent premature release.
+ [m_webFrame->_private->currentItem setHasPageCache:NO];
}
void WebFrameLoaderClient::download(NSURLConnection *connection, NSURLRequest *request,
NSURLResponse *response, id proxy)
{
- [m_webFrame.get() _downloadWithLoadingConnection:connection request:request response:response proxy:proxy];
+ [WebDownload _downloadWithLoadingConnection:connection
+ request:request
+ response:response
+ delegate:[[m_webFrame.get() webView] downloadDelegate]
+ proxy:proxy];
}
id WebFrameLoaderClient::dispatchIdentifierForInitialRequest(DocumentLoader* loader, NSURLRequest *request)
{
- return [m_webFrame.get() _dispatchIdentifierForInitialRequest:request fromDocumentLoader:loader];
+ WebView *webView = [m_webFrame.get() webView];
+ id resourceLoadDelegate = [webView resourceLoadDelegate];
+
+ if ([webView _resourceLoadDelegateImplementations].delegateImplementsIdentifierForRequest)
+ return [resourceLoadDelegate webView:webView identifierForInitialRequest:request fromDataSource:dataSource(loader)];
+ return [[[NSObject alloc] init] autorelease];
}
NSURLRequest *WebFrameLoaderClient::dispatchWillSendRequest(DocumentLoader* loader, id identifier,
NSURLRequest *request, NSURLResponse *redirectResponse)
{
- return [m_webFrame.get() _dispatchResource:identifier willSendRequest:request
- redirectResponse:redirectResponse fromDocumentLoader:loader];
+ WebView *webView = [m_webFrame.get() webView];
+ id resourceLoadDelegate = [webView resourceLoadDelegate];
+
+ if ([webView _resourceLoadDelegateImplementations].delegateImplementsWillSendRequest)
+ return [resourceLoadDelegate webView:webView resource:identifier willSendRequest:request redirectResponse:redirectResponse fromDataSource:dataSource(loader)];
+
+ return request;
}
void WebFrameLoaderClient::dispatchDidReceiveAuthenticationChallenge(DocumentLoader* loader, id identifier,
NSURLAuthenticationChallenge *challenge)
{
- [m_webFrame.get() _dispatchDidReceiveAuthenticationChallenge:challenge forResource:identifier
- fromDocumentLoader:loader];
+ WebView *webView = [m_webFrame.get() webView];
+ id resourceLoadDelegate = [webView resourceLoadDelegate];
+
+ if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidReceiveAuthenticationChallenge) {
+ [resourceLoadDelegate webView:webView resource:identifier didReceiveAuthenticationChallenge:challenge fromDataSource:dataSource(loader)];
+ return;
+ }
+
+ NSWindow *window = [webView hostWindow] ? [webView hostWindow] : [webView window];
+ [[WebPanelAuthenticationHandler sharedHandler] startAuthentication:challenge window:window];
}
void WebFrameLoaderClient::dispatchDidCancelAuthenticationChallenge(DocumentLoader* loader, id identifier,
NSURLAuthenticationChallenge *challenge)
{
- [m_webFrame.get() _dispatchDidCancelAuthenticationChallenge:challenge forResource:identifier
- fromDocumentLoader:loader];
+ WebView *webView = [m_webFrame.get() webView];
+ id resourceLoadDelegate = [webView resourceLoadDelegate];
+
+ if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidCancelAuthenticationChallenge) {
+ [resourceLoadDelegate webView:webView resource:identifier didCancelAuthenticationChallenge:challenge fromDataSource:dataSource(loader)];
+ return;
+ }
+
+ [(WebPanelAuthenticationHandler *)[WebPanelAuthenticationHandler sharedHandler] cancelAuthentication:challenge];
}
void WebFrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader* loader, id identifier, NSURLResponse *response)
{
- [m_webFrame.get() _dispatchResource:identifier didReceiveResponse:response fromDocumentLoader:loader];
+ WebView *webView = [m_webFrame.get() webView];
+
+ if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidReceiveResponse)
+ [[webView resourceLoadDelegate] webView:webView resource:identifier didReceiveResponse:response fromDataSource:dataSource(loader)];
}
void WebFrameLoaderClient::dispatchDidReceiveContentLength(DocumentLoader* loader, id identifier, int lengthReceived)
{
- [m_webFrame.get() _dispatchResource:identifier didReceiveContentLength:lengthReceived fromDocumentLoader:loader];
+ WebView *webView = [m_webFrame.get() webView];
+
+ if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidReceiveContentLength)
+ [[webView resourceLoadDelegate] webView:webView resource:identifier didReceiveContentLength:(WebNSUInteger)lengthReceived fromDataSource:dataSource(loader)];
}
void WebFrameLoaderClient::dispatchDidFinishLoading(DocumentLoader* loader, id identifier)
{
- [m_webFrame.get() _dispatchResource:identifier didFinishLoadingFromDocumentLoader:loader];
+ WebView *webView = [m_webFrame.get() webView];
+
+ if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidFinishLoadingFromDataSource)
+ [[webView resourceLoadDelegate] webView:webView resource:identifier didFinishLoadingFromDataSource:dataSource(loader)];
}
void WebFrameLoaderClient::dispatchDidFailLoading(DocumentLoader* loader, id identifier, NSError *error)
{
- [m_webFrame.get() _dispatchResource:identifier didFailLoadingWithError:error fromDocumentLoader:loader];
+ WebView *webView = [m_webFrame.get() webView];
+ [[webView _resourceLoadDelegateForwarder] webView:webView resource:identifier didFailLoadingWithError:error fromDataSource:dataSource(loader)];
}
void WebFrameLoaderClient::dispatchDidHandleOnloadEvents()
{
- [m_webFrame.get() _dispatchDidHandleOnloadEventsForFrame];
+ WebView *webView = [m_webFrame.get() webView];
+ [[webView _frameLoadDelegateForwarder] webView:webView didHandleOnloadEventsForFrame:m_webFrame.get()];
}
void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad()
{
- [m_webFrame.get() _dispatchDidReceiveServerRedirectForProvisionalLoadForFrame];
+ WebView *webView = [m_webFrame.get() webView];
+ [[webView _frameLoadDelegateForwarder] webView:webView
+ didReceiveServerRedirectForProvisionalLoadForFrame:m_webFrame.get()];
}
void WebFrameLoaderClient::dispatchDidCancelClientRedirect()
{
- [m_webFrame.get() _dispatchDidCancelClientRedirectForFrame];
+ WebView *webView = [m_webFrame.get() webView];
+ [[webView _frameLoadDelegateForwarder] webView:webView didCancelClientRedirectForFrame:m_webFrame.get()];
}
void WebFrameLoaderClient::dispatchWillPerformClientRedirect(NSURL *URL, NSTimeInterval delay, NSDate *fireDate)
{
- [m_webFrame.get() _dispatchWillPerformClientRedirectToURL:URL delay:delay fireDate:fireDate];
+ WebView *webView = [m_webFrame.get() webView];
+ [[webView _frameLoadDelegateForwarder] webView:webView
+ willPerformClientRedirectToURL:URL
+ delay:delay
+ fireDate:fireDate
+ forFrame:m_webFrame.get()];
}
void WebFrameLoaderClient::dispatchDidChangeLocationWithinPage()
{
- [m_webFrame.get() _dispatchDidChangeLocationWithinPageForFrame];
+ WebView *webView = [m_webFrame.get() webView];
+ [[webView _frameLoadDelegateForwarder] webView:webView didChangeLocationWithinPageForFrame:m_webFrame.get()];
}
void WebFrameLoaderClient::dispatchWillClose()
{
- [m_webFrame.get() _dispatchWillCloseFrame];
+ WebView *webView = [m_webFrame.get() webView];
+ [[webView _frameLoadDelegateForwarder] webView:webView willCloseFrame:m_webFrame.get()];
}
void WebFrameLoaderClient::dispatchDidReceiveIcon(NSImage *icon)
{
- [m_webFrame.get() _dispatchDidReceiveIcon:icon];
+ WebView *webView = [m_webFrame.get() webView];
+ ASSERT([m_webFrame.get() _isMainFrame]);
+ [webView _willChangeValueForKey:_WebMainFrameIconKey];
+ [[webView _frameLoadDelegateForwarder] webView:webView didReceiveIcon:icon forFrame:m_webFrame.get()];
+ [webView _didChangeValueForKey:_WebMainFrameIconKey];
}
void WebFrameLoaderClient::dispatchDidStartProvisionalLoad()
{
- [m_webFrame.get() _dispatchDidStartProvisionalLoadForFrame];
+ WebView *webView = [m_webFrame.get() webView];
+ [webView _didStartProvisionalLoadForFrame:m_webFrame.get()];
+ [[webView _frameLoadDelegateForwarder] webView:webView didStartProvisionalLoadForFrame:m_webFrame.get()];
}
void WebFrameLoaderClient::dispatchDidReceiveTitle(const String& title)
{
- [m_webFrame.get() _dispatchDidReceiveTitle:title];
+ WebView *webView = [m_webFrame.get() webView];
+ [[webView _frameLoadDelegateForwarder] webView:webView didReceiveTitle:title forFrame:m_webFrame.get()];
}
void WebFrameLoaderClient::dispatchDidCommitLoad()
{
- [m_webFrame.get() _dispatchDidCommitLoadForFrame];
+ // Tell the client we've committed this URL.
+ ASSERT([m_webFrame->_private->webFrameView documentView] != nil);
+
+ WebView *webView = [m_webFrame.get() webView];
+ [webView _didCommitLoadForFrame:m_webFrame.get()];
+ [[webView _frameLoadDelegateForwarder] webView:webView didCommitLoadForFrame:m_webFrame.get()];
}
void WebFrameLoaderClient::dispatchDidFailProvisionalLoad(NSError *error)
{
- [m_webFrame.get() _dispatchDidFailProvisionalLoadWithError:error];
+ WebView *webView = [m_webFrame.get() webView];
+ [webView _didFailProvisionalLoadWithError:error forFrame:m_webFrame.get()];
+ [[webView _frameLoadDelegateForwarder] webView:webView didFailProvisionalLoadWithError:error forFrame:m_webFrame.get()];
+ [m_webFrame->_private->internalLoadDelegate webFrame:m_webFrame.get() didFinishLoadWithError:error];
}
void WebFrameLoaderClient::dispatchDidFailLoad(NSError *error)
{
- [m_webFrame.get() _dispatchDidFailLoadWithError:error];
+ WebView *webView = [m_webFrame.get() webView];
+ [webView _didFailLoadWithError:error forFrame:m_webFrame.get()];
+ [[webView _frameLoadDelegateForwarder] webView:webView didFailLoadWithError:error forFrame:m_webFrame.get()];
+ [m_webFrame->_private->internalLoadDelegate webFrame:m_webFrame.get() didFinishLoadWithError:error];
}
void WebFrameLoaderClient::dispatchDidFinishLoad()
{
- [m_webFrame.get() _dispatchDidFinishLoadForFrame];
+ WebView *webView = [m_webFrame.get() webView];
+ [webView _didFinishLoadForFrame:m_webFrame.get()];
+ [[webView _frameLoadDelegateForwarder] webView:webView didFinishLoadForFrame:m_webFrame.get()];
+ [m_webFrame->_private->internalLoadDelegate webFrame:m_webFrame.get() didFinishLoadWithError:nil];
}
void WebFrameLoaderClient::dispatchDidFirstLayout()
{
- [m_webFrame.get() _dispatchDidFirstLayoutInFrame];
+ WebView *webView = [m_webFrame.get() webView];
+ [[webView _frameLoadDelegateForwarder] webView:webView didFirstLayoutInFrame:m_webFrame.get()];
}
Frame* WebFrameLoaderClient::dispatchCreatePage(NSURLRequest *request)
{
- return [m_webFrame.get() _dispatchCreateWebViewWithRequest:request];
+ WebView *currentWebView = [m_webFrame.get() webView];
+ id wd = [currentWebView UIDelegate];
+ if ([wd respondsToSelector:@selector(webView:createWebViewWithRequest:)])
+ return core([[wd webView:currentWebView createWebViewWithRequest:request] mainFrame]);
+ return 0;
}
void WebFrameLoaderClient::dispatchShow()
{
- [m_webFrame.get() _dispatchShow];
+ WebView *webView = [m_webFrame.get() webView];
+ [[webView _UIDelegateForwarder] webViewShow:webView];
}
void WebFrameLoaderClient::dispatchDecidePolicyForMIMEType(WebPolicyDecider *decider, const String& MIMEType, NSURLRequest *request)
{
- [m_webFrame.get() _dispatchDecidePolicyForMIMEType:MIMEType request:request decider:decider];
+ WebView *webView = [m_webFrame.get() webView];
+
+ [[webView _policyDelegateForwarder] webView:webView decidePolicyForMIMEType:MIMEType request:request frame:m_webFrame.get() decisionListener:decisionListener(decider)];
}
void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(WebPolicyDecider *decider, NSDictionary *action, NSURLRequest *request, const String& frameName)
{
- [m_webFrame.get() _dispatchDecidePolicyForNewWindowAction:action request:request newFrameName:frameName
- decider:decider];
+ WebView *webView = [m_webFrame.get() webView];
+ [[webView _policyDelegateForwarder] webView:webView
+ decidePolicyForNewWindowAction:action
+ request:request
+ newFrameName:frameName
+ decisionListener:decisionListener(decider)];
}
void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(WebPolicyDecider *decider, NSDictionary *action,
NSURLRequest *request)
{
- [m_webFrame.get() _dispatchDecidePolicyForNavigationAction:action request:request decider:decider];
+ WebView *webView = [m_webFrame.get() webView];
+ [[webView _policyDelegateForwarder] webView:webView
+ decidePolicyForNavigationAction:action
+ request:request
+ frame:m_webFrame.get()
+ decisionListener:decisionListener(decider)];
}
void WebFrameLoaderClient::dispatchUnableToImplementPolicy(NSError *error)
{
- [m_webFrame.get() _dispatchUnableToImplementPolicyWithError:error];
+ WebView *webView = [m_webFrame.get() webView];
+ [[webView _policyDelegateForwarder] webView:webView unableToImplementPolicyWithError:error frame:m_webFrame.get()];
}
void WebFrameLoaderClient::dispatchWillSubmitForm(WebPolicyDecider *decider, Frame* sourceFrame,
Element* form, NSDictionary *values)
{
- [m_webFrame.get() _dispatchSourceFrame:sourceFrame
- willSubmitForm:form withValues:values submissionDecider:decider];
+ [[[m_webFrame.get() webView] _formDelegate] frame:m_webFrame.get() sourceFrame:kit(sourceFrame) willSubmitForm:kit(form) withValues:values submissionListener:decisionListener(decider)];
}
void WebFrameLoaderClient::dispatchDidLoadMainResource(DocumentLoader* loader)
{
- [m_webFrame.get() _dispatchDidLoadMainResourceForDocumentLoader:loader];
+ if ([WebScriptDebugServer listenerCount])
+ [[WebScriptDebugServer sharedScriptDebugServer] webView:[m_webFrame.get() webView]
+ didLoadMainResourceForDataSource:dataSource(loader)];
}
void WebFrameLoaderClient::clearLoadingFromPageCache(DocumentLoader* loader)
{
- [m_webFrame.get() _clearLoadingFromPageCacheForDocumentLoader:loader];
+ [dataSource(loader) _setLoadingFromPageCache:NO];
}
bool WebFrameLoaderClient::isLoadingFromPageCache(DocumentLoader* loader)
{
- return [m_webFrame.get() _isDocumentLoaderLoadingFromPageCache:loader];
+ return [dataSource(loader) _loadingFromPageCache];
}
void WebFrameLoaderClient::revertToProvisionalState(DocumentLoader* loader)
{
- [m_webFrame.get() _revertToProvisionalStateForDocumentLoader:loader];
+ [dataSource(loader) _revertToProvisionalState];
}
void WebFrameLoaderClient::setMainDocumentError(DocumentLoader* loader, NSError *error)
{
- [m_webFrame.get() _setMainDocumentError:error forDocumentLoader:loader];
+ [dataSource(loader) _setMainDocumentError:error];
}
void WebFrameLoaderClient::clearUnarchivingState(DocumentLoader* loader)
{
- [m_webFrame.get() _clearUnarchivingStateForLoader:loader];
+ [dataSource(loader) _clearUnarchivingState];
}
void WebFrameLoaderClient::progressStarted()
{
- [m_webFrame.get() _progressStarted];
+ [[m_webFrame.get() webView] _progressStarted:m_webFrame.get()];
}
void WebFrameLoaderClient::progressCompleted()
{
- [m_webFrame.get() _progressCompleted];
+ [[m_webFrame.get() webView] _progressCompleted:m_webFrame.get()];
}
void WebFrameLoaderClient::incrementProgress(id identifier, NSURLResponse *response)
{
- [m_webFrame.get() _incrementProgressForIdentifier:identifier response:response];
+ [[m_webFrame.get() webView] _incrementProgressForIdentifier:identifier response:response];
}
void WebFrameLoaderClient::incrementProgress(id identifier, NSData *data)
{
- [m_webFrame.get() _incrementProgressForIdentifier:identifier data:data];
+ [[m_webFrame.get() webView] _incrementProgressForIdentifier:identifier data:data];
}
void WebFrameLoaderClient::completeProgress(id identifier)
{
- [m_webFrame.get() _completeProgressForIdentifier:identifier];
+ [[m_webFrame.get() webView] _completeProgressForIdentifier:identifier];
}
void WebFrameLoaderClient::setMainFrameDocumentReady(bool ready)
{
- [m_webFrame.get() _setMainFrameDocumentReady:ready];
+ [[m_webFrame.get() webView] setMainFrameDocumentReady:ready];
}
void WebFrameLoaderClient::startDownload(NSURLRequest *request)
{
- [m_webFrame.get() _startDownloadWithRequest:request];
+ // FIXME: Should download full request.
+ [[m_webFrame.get() webView] _downloadURL:[request URL]];
}
void WebFrameLoaderClient::willChangeTitle(DocumentLoader* loader)
{
- [m_webFrame.get() _willChangeTitleForDocument:loader];
+ // FIXME: Should do this only in main frame case, right?
+ [[m_webFrame.get() webView] _willChangeValueForKey:_WebMainFrameTitleKey];
}
void WebFrameLoaderClient::didChangeTitle(DocumentLoader* loader)
{
- [m_webFrame.get() _didChangeTitleForDocument:loader];
+ // FIXME: Should do this only in main frame case, right?
+ [[m_webFrame.get() webView] _didChangeValueForKey:_WebMainFrameTitleKey];
}
void WebFrameLoaderClient::committedLoad(DocumentLoader* loader, NSData *data)
{
- [m_webFrame.get() _committedLoadWithDocumentLoader:loader data:data];
+ [dataSource(loader) _receivedData:data];
}
void WebFrameLoaderClient::finishedLoading(DocumentLoader* loader)
{
- [m_webFrame.get() _finishedLoadingDocument:loader];
+ [dataSource(loader) _finishedLoading];
}
void WebFrameLoaderClient::finalSetupForReplace(DocumentLoader* loader)
{
- [m_webFrame.get() _finalSetupForReplaceWithDocumentLoader:loader];
+ [dataSource(loader) _clearUnarchivingState];
}
NSError *WebFrameLoaderClient::cancelledError(NSURLRequest *request)
{
- return [m_webFrame.get() _cancelledErrorWithRequest:request];
+ return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled URL:[request URL]];
}
NSError *WebFrameLoaderClient::cannotShowURLError(NSURLRequest *request)
{
- return [m_webFrame.get() _cannotShowURLErrorWithRequest:request];
+ return [NSError _webKitErrorWithDomain:WebKitErrorDomain code:WebKitErrorCannotShowURL URL:[request URL]];
}
NSError *WebFrameLoaderClient::interruptForPolicyChangeError(NSURLRequest *request)
{
- return [m_webFrame.get() _interruptForPolicyChangeErrorWithRequest:request];
+ return [NSError _webKitErrorWithDomain:WebKitErrorDomain code:WebKitErrorFrameLoadInterruptedByPolicyChange URL:[request URL]];
}
NSError *WebFrameLoaderClient::cannotShowMIMETypeError(NSURLResponse *response)
{
- return [m_webFrame.get() _cannotShowMIMETypeErrorWithResponse:response];
+ return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:WebKitErrorCannotShowMIMEType URL:[response URL]];
}
NSError *WebFrameLoaderClient::fileDoesNotExistError(NSURLResponse *response)
{
- return [m_webFrame.get() _fileDoesNotExistErrorWithResponse:response];
+ return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist URL:[response URL]];
}
bool WebFrameLoaderClient::shouldFallBack(NSError *error)
{
- return [m_webFrame.get() _shouldFallBackForError:error];
+ // FIXME: Needs to check domain.
+ // FIXME: WebKitErrorPlugInWillHandleLoad is a workaround for the cancel we do to prevent
+ // loading plugin content twice. See <rdar://problem/4258008>
+ return [error code] != NSURLErrorCancelled && [error code] != WebKitErrorPlugInWillHandleLoad;
}
NSURL *WebFrameLoaderClient::mainFrameURL()
{
- return [m_webFrame.get() _mainFrameURL];
+ return [[[[m_webFrame.get() webView] mainFrame] dataSource] _URL];
}
void WebFrameLoaderClient::setDefersCallbacks(bool defers)
{
- [m_webFrame.get() _setDefersCallbacks:defers];
+ if (!defers)
+ deliverArchivedResourcesAfterDelay();
}
bool WebFrameLoaderClient::willUseArchive(WebResourceLoader* loader, NSURLRequest *request, NSURL *originalURL) const
{
- return [m_webFrame.get() _willUseArchiveForRequest:request originalURL:originalURL loader:loader];
+ if (![[request URL] isEqual:originalURL])
+ return false;
+ if (!canUseArchivedResource(request))
+ return false;
+ WebResource *resource = [dataSource(core(m_webFrame.get())->loader()->activeDocumentLoader()) _archivedSubresourceForURL:originalURL];
+ if (!resource)
+ return false;
+ if (!canUseArchivedResource([resource _response]))
+ return false;
+ m_pendingArchivedResources.set(loader, resource);
+ // Deliver the resource after a delay because callers don't expect to receive callbacks while calling this method.
+ deliverArchivedResourcesAfterDelay();
+ return true;
}
bool WebFrameLoaderClient::isArchiveLoadPending(WebResourceLoader* loader) const
{
- return [m_webFrame.get() _archiveLoadPendingForLoader:loader];
+ return m_pendingArchivedResources.contains(loader);
}
void WebFrameLoaderClient::cancelPendingArchiveLoad(WebResourceLoader* loader)
{
- [m_webFrame.get() _cancelPendingArchiveLoadForLoader:loader];
+ if (m_pendingArchivedResources.isEmpty())
+ return;
+ m_pendingArchivedResources.remove(loader);
+ if (m_pendingArchivedResources.isEmpty())
+ m_archivedResourcesDeliveryTimer.stop();
}
void WebFrameLoaderClient::clearArchivedResources()
{
- [m_webFrame.get() _clearArchivedResources];
+ m_pendingArchivedResources.clear();
+ m_archivedResourcesDeliveryTimer.stop();
}
bool WebFrameLoaderClient::canHandleRequest(NSURLRequest *request) const
{
- return [m_webFrame.get() _canHandleRequest:request];
+ return [WebView _canHandleRequest:request];
}
bool WebFrameLoaderClient::canShowMIMEType(const String& MIMEType) const
{
- return [m_webFrame.get() _canShowMIMEType:MIMEType];
+ return [WebView canShowMIMEType:MIMEType];
}
bool WebFrameLoaderClient::representationExistsForURLScheme(const String& URLScheme) const
{
- return [m_webFrame.get() _representationExistsForURLScheme:URLScheme];
+ return [WebView _representationExistsForURLScheme:URLScheme];
}
String WebFrameLoaderClient::generatedMIMETypeForURLScheme(const String& URLScheme) const
{
- return [m_webFrame.get() _generatedMIMETypeForURLScheme:URLScheme];
+ return [WebView _generatedMIMETypeForURLScheme:URLScheme];
}
NSDictionary *WebFrameLoaderClient::elementForEvent(NSEvent *event) const
{
- return [m_webFrame.get() _elementForEvent:event];
+ switch ([event type]) {
+ case NSLeftMouseDown:
+ case NSRightMouseDown:
+ case NSOtherMouseDown:
+ case NSLeftMouseUp:
+ case NSRightMouseUp:
+ case NSOtherMouseUp:
+ break;
+ default:
+ return nil;
+ }
+
+ NSView *topViewInEventWindow = [[event window] contentView];
+ NSView *viewContainingPoint = [topViewInEventWindow hitTest:
+ [topViewInEventWindow convertPoint:[event locationInWindow] fromView:nil]];
+ while (viewContainingPoint) {
+ if ([viewContainingPoint isKindOfClass:[WebView class]])
+ return [(WebView *)viewContainingPoint elementAtPoint:
+ [viewContainingPoint convertPoint:[event locationInWindow] fromView:nil]];
+ viewContainingPoint = [viewContainingPoint superview];
+ }
+ return nil;
}
WebPolicyDecider *WebFrameLoaderClient::createPolicyDecider(id object, SEL selector)
{
- return [m_webFrame.get() _createPolicyDeciderWithTarget:object action:selector];
+ return [[WebPolicyDeciderMac alloc] initWithTarget:object action:selector];
}
void WebFrameLoaderClient::frameLoadCompleted()
{
- [m_webFrame.get() _frameLoadCompleted];
+ // Note: Can be called multiple times.
+ // Even if already complete, we might have set a previous item on a frame that
+ // didn't do any data loading on the past transaction. Make sure to clear these out.
+ NSScrollView *sv = [m_webFrame->_private->webFrameView _scrollView];
+ if ([[m_webFrame.get() webView] drawsBackground])
+ [sv setDrawsBackground:YES];
+ [m_webFrame.get() _setPreviousItem:nil];
}
+/*
+ There is a race condition between the layout and load completion that affects restoring the scroll position.
+ We try to restore the scroll position at both the first layout and upon load completion.
+
+ 1) If first layout happens before the load completes, we want to restore the scroll position then so that the
+ first time we draw the page is already scrolled to the right place, instead of starting at the top and later
+ jumping down. It is possible that the old scroll position is past the part of the doc laid out so far, in
+ which case the restore silent fails and we will fix it in when we try to restore on doc completion.
+ 2) If the layout happens after the load completes, the attempt to restore at load completion time silently
+ fails. We then successfully restore it when the layout happens.
+*/
void WebFrameLoaderClient::restoreScrollPositionAndViewState()
{
- [m_webFrame.get() _restoreScrollPositionAndViewState];
+ ASSERT(m_webFrame->_private->currentItem);
+ NSView <WebDocumentView> *docView = [m_webFrame->_private->webFrameView documentView];
+ NSPoint point = [m_webFrame->_private->currentItem scrollPoint];
+ if ([docView conformsToProtocol:@protocol(_WebDocumentViewState)]) {
+ id state = [m_webFrame->_private->currentItem viewState];
+ if (state) {
+ [(id <_WebDocumentViewState>)docView setViewState:state];
+ }
+
+ [(id <_WebDocumentViewState>)docView setScrollPoint:point];
+ } else {
+ [docView scrollPoint:point];
+ }
}
void WebFrameLoaderClient::provisionalLoadStarted()
{
- [m_webFrame.get() _provisionalLoadStarted];
+ FrameLoadType loadType = core(m_webFrame.get())->loader()->loadType();
+
+ // FIXME: This is OK as long as no one resizes the window,
+ // but in the case where someone does, it means garbage outside
+ // the occupied part of the scroll view.
+ [[m_webFrame->_private->webFrameView _scrollView] setDrawsBackground:NO];
+
+ // Cache the page, if possible.
+ // Don't write to the cache if in the middle of a redirect, since we will want to
+ // store the final page we end up on.
+ // No point writing to the cache on a reload or loadSame, since we will just write
+ // over it again when we leave that page.
+ WebHistoryItem *item = m_webFrame->_private->currentItem;
+ if ([m_webFrame.get() _canCachePage]
+ && item
+ && !core(m_webFrame.get())->loader()->isQuickRedirectComing()
+ && loadType != FrameLoadTypeReload
+ && loadType != FrameLoadTypeReloadAllowingStaleData
+ && loadType != FrameLoadTypeSame
+ && ![[m_webFrame.get() dataSource] isLoading]
+ && !core(m_webFrame.get())->loader()->documentLoader()->isStopping()) {
+ if ([[[m_webFrame.get() dataSource] representation] isKindOfClass:[WebHTMLRepresentation class]]) {
+ if (![item pageCache]) {
+ // Add the items to this page's cache.
+ if (createPageCache(item))
+ // See if any page caches need to be purged after the addition of this new page cache.
+ [m_webFrame.get() _purgePageCache];
+ }
+ } else
+ // Put the document into a null state, so it can be restored correctly.
+ core(m_webFrame.get())->clear();
+ }
}
bool WebFrameLoaderClient::shouldTreatURLAsSameAsCurrent(NSURL *URL) const
{
- return [m_webFrame.get() _shouldTreatURLAsSameAsCurrent:URL];
+ WebHistoryItem *item = m_webFrame->_private->currentItem;
+ NSString* URLString = [URL _web_originalDataAsString];
+ return [URLString isEqual:[item URLString]] || [URLString isEqual:[item originalURLString]];
}
void WebFrameLoaderClient::addHistoryItemForFragmentScroll()
{
- [m_webFrame.get() _addHistoryItemForFragmentScroll];
+ [m_webFrame.get() _addBackForwardItemClippedAtTarget:NO];
}
void WebFrameLoaderClient::didFinishLoad()
{
- [m_webFrame.get() _didFinishLoad];
+ [m_webFrame->_private->internalLoadDelegate webFrame:m_webFrame.get() didFinishLoadWithError:nil];
}
void WebFrameLoaderClient::prepareForDataSourceReplacement()
{
- [m_webFrame.get() _prepareForDataSourceReplacement];
+ if (![m_webFrame.get() dataSource]) {
+ ASSERT(!core(m_webFrame.get())->tree()->childCount());
+ return;
+ }
+
+ // Make sure that any work that is triggered by resigning first reponder can get done.
+ // The main example where this came up is the textDidEndEditing that is sent to the
+ // FormsDelegate (3223413). We need to do this before _detachChildren, since that will
+ // remove the views as a side-effect of freeing the bridge, at which point we can't
+ // post the FormDelegate messages.
+ //
+ // Note that this can also take FirstResponder away from a child of our frameView that
+ // is not in a child frame's view. This is OK because we are in the process
+ // of loading new content, which will blow away all editors in this top frame, and if
+ // a non-editor is firstReponder it will not be affected by endEditingFor:.
+ // Potentially one day someone could write a DocView whose editors were not all
+ // replaced by loading new content, but that does not apply currently.
+ NSView *frameView = m_webFrame->_private->webFrameView;
+ NSWindow *window = [frameView window];
+ NSResponder *firstResp = [window firstResponder];
+ if ([firstResp isKindOfClass:[NSView class]] && [(NSView *)firstResp isDescendantOf:frameView])
+ [window endEditingFor:firstResp];
+
+ core(m_webFrame.get())->loader()->detachChildren();
}
PassRefPtr<DocumentLoader> WebFrameLoaderClient::createDocumentLoader(NSURLRequest *request)
{
- return [m_webFrame.get() _createDocumentLoaderWithRequest:request];
+ RefPtr<WebDocumentLoaderMac> loader = new WebDocumentLoaderMac(request);
+
+ WebDataSource *dataSource = [[WebDataSource alloc] _initWithDocumentLoader:loader.get()];
+ loader->setDataSource(dataSource);
+ [dataSource release];
+
+ return loader.release();
}
void WebFrameLoaderClient::setTitle(NSString *title, NSURL *URL)
{
- [m_webFrame.get() _setTitle:title forURL:URL];
+ [[[WebHistory optionalSharedHistory] itemForURL:URL] setTitle:title];
+ [m_webFrame->_private->currentItem setTitle:title];
+}
+
+// The following 2 functions are copied from [NSHTTPURLProtocol _cachedResponsePassesValidityChecks] and modified for our needs.
+// FIXME: It would be nice to eventually to share this logic somehow.
+bool WebFrameLoaderClient::canUseArchivedResource(NSURLRequest *request) const
+{
+ NSURLRequestCachePolicy policy = [request cachePolicy];
+ if (policy == NSURLRequestReturnCacheDataElseLoad)
+ return true;
+ if (policy == NSURLRequestReturnCacheDataDontLoad)
+ return true;
+ if (policy == NSURLRequestReloadIgnoringCacheData)
+ return false;
+ if ([request valueForHTTPHeaderField:@"must-revalidate"] != nil)
+ return false;
+ if ([request valueForHTTPHeaderField:@"proxy-revalidate"] != nil)
+ return false;
+ if ([request valueForHTTPHeaderField:@"If-Modified-Since"] != nil)
+ return false;
+ if ([request valueForHTTPHeaderField:@"Cache-Control"] != nil)
+ return false;
+ if ([@"POST" _webkit_isCaseInsensitiveEqualToString:[request HTTPMethod]])
+ return false;
+ return true;
+}
+
+bool WebFrameLoaderClient::canUseArchivedResource(NSURLResponse *response) const
+{
+ if (WKGetNSURLResponseMustRevalidate(response))
+ return false;
+ if (WKGetNSURLResponseCalculatedExpiration(response) - CFAbsoluteTimeGetCurrent() < 1)
+ return false;
+ return true;
+}
+
+void WebFrameLoaderClient::deliverArchivedResourcesAfterDelay() const
+{
+ if (m_pendingArchivedResources.isEmpty())
+ return;
+ if (core(m_webFrame.get())->loader()->defersCallbacks())
+ return;
+ if (!m_archivedResourcesDeliveryTimer.isActive())
+ m_archivedResourcesDeliveryTimer.startOneShot(0);
+}
+
+void WebFrameLoaderClient::deliverArchivedResources(Timer<WebFrameLoaderClient>*)
+{
+ if (m_pendingArchivedResources.isEmpty())
+ return;
+ if (core(m_webFrame.get())->loader()->defersCallbacks())
+ return;
+
+ const ResourceMap copy = m_pendingArchivedResources;
+ m_pendingArchivedResources.clear();
+
+ ResourceMap::const_iterator end = copy.end();
+ for (ResourceMap::const_iterator it = copy.begin(); it != end; ++it) {
+ RefPtr<WebResourceLoader> loader = it->first;
+ WebResource *resource = it->second.get();
+ NSData *data = [[resource data] retain];
+ loader->didReceiveResponse([resource _response]);
+ loader->didReceiveData(data, [data length], true);
+ [data release];
+ loader->didFinishLoading();
+ }
+}
+
+bool WebFrameLoaderClient::createPageCache(WebHistoryItem *item)
+{
+ [item setHasPageCache:YES];
+ if (![m_webFrame->_private->bridge saveDocumentToPageCache]) {
+ [item setHasPageCache:NO];
+ return NO;
+ }
+ NSMutableDictionary *pageCache = [item pageCache];
+ [pageCache setObject:[NSDate date] forKey: WebPageCacheEntryDateKey];
+ [pageCache setObject:[m_webFrame.get() dataSource] forKey: WebPageCacheDataSourceKey];
+ [pageCache setObject:[m_webFrame->_private->webFrameView documentView] forKey: WebPageCacheDocumentViewKey];
+ return YES;
}
#import "WebFrameInternal.h"
-#import "WebArchive.h"
#import "WebBackForwardList.h"
#import "WebDataSourceInternal.h"
-#import "WebDefaultResourceLoadDelegate.h"
-#import "WebDefaultUIDelegate.h"
#import "WebDocumentInternal.h"
#import "WebDocumentLoaderMac.h"
-#import "WebDownloadInternal.h"
#import "WebFrameBridge.h"
#import "WebFrameLoadDelegate.h"
#import "WebFrameLoaderClient.h"
#import "WebFrameViewInternal.h"
-#import "WebHTMLRepresentationPrivate.h"
#import "WebHTMLViewInternal.h"
-#import "WebHTMLViewPrivate.h"
+#import "WebHistoryItem.h"
#import "WebHistoryItemPrivate.h"
-#import "WebHistoryPrivate.h"
-#import "WebKitErrorsPrivate.h"
#import "WebKitLogging.h"
-#import "WebKitNSStringExtras.h"
#import "WebKitStatisticsPrivate.h"
-#import "WebNSDictionaryExtras.h"
-#import "WebNSObjectExtras.h"
#import "WebNSURLExtras.h"
#import "WebNSURLRequestExtras.h"
-#import "WebNetscapePluginEmbeddedView.h"
-#import "WebNullPluginView.h"
-#import "WebPlugin.h"
-#import "WebPluginController.h"
-#import "WebPolicyDeciderMac.h"
+#import "WebPolicyDelegatePrivate.h"
#import "WebPreferencesPrivate.h"
-#import "WebResourceLoadDelegate.h"
-#import "WebResourcePrivate.h"
#import "WebScriptDebugDelegatePrivate.h"
-#import "WebScriptDebugServerPrivate.h"
-#import "WebUIDelegate.h"
#import "WebViewInternal.h"
#import <WebCore/Document.h>
-#import <WebCore/DocumentMarker.h>
#import <WebCore/FrameLoader.h>
#import <WebCore/FrameMac.h>
#import <WebCore/FrameTree.h>
#import <WebCore/WebDataProtocol.h>
#import <WebCore/WebFormDataStream.h>
#import <WebCore/WebFormState.h>
-#import <WebCore/WebLoader.h>
-#import <WebKit/DOM.h>
-#import <WebKitSystemInterface.h>
-#import <objc/objc-runtime.h>
-#import <wtf/HashMap.h>
+#import <WebKit/DOMDocument.h>
+#import <WebKit/DOMElement.h>
+#import <WebKit/DOMHTMLElement.h>
+#import <WebKit/DOMRange.h>
// FIXME: We should have a way to get the following DOM interface from the WebCore internal headers, but we
// can't make the internal DOM headers private since they are not generated at the time installhdrs is called.
using namespace WebCore;
-typedef HashMap<RefPtr<WebResourceLoader>, RetainPtr<WebResource> > ResourceMap;
-
NSString *WebPageCacheEntryDateKey = @"WebPageCacheEntryDateKey";
NSString *WebPageCacheDataSourceKey = @"WebPageCacheDataSourceKey";
NSString *WebPageCacheDocumentViewKey = @"WebPageCacheDocumentViewKey";
@interface WebFrame (ForwardDecls)
- (void)_loadHTMLString:(NSString *)string baseURL:(NSURL *)URL unreachableURL:(NSURL *)unreachableURL;
-- (void)_saveScrollPositionAndViewStateToItem:(WebHistoryItem *)item;
- (WebHistoryItem *)_createItem:(BOOL)useOriginal;
- (WebHistoryItem *)_createItemTreeWithTargetFrame:(WebFrame *)targetFrame clippedAtTarget:(BOOL)doClip;
- (WebHistoryItem *)_currentBackForwardListItemToResetTo;
- (void)setWebFrame:(WebFrame *)webFrame;
@end
-@interface WebFramePrivate : NSObject
-{
-@public
- WebFrameView *webFrameView;
-
- WebFrameBridge *bridge;
- WebHistoryItem *currentItem; // BF item for our current content
- WebHistoryItem *provisionalItem; // BF item for where we're trying to go
- // (only known when navigating to a pre-existing BF item)
- WebHistoryItem *previousItem; // BF item for previous content, see _itemForSavingDocState
-
- WebScriptDebugger *scriptDebugger;
- id internalLoadDelegate;
-
- NSMutableSet *plugInViews;
- NSMutableSet *inspectors;
-
- ResourceMap* pendingArchivedResources;
-}
-
-- (void)setWebFrameView:(WebFrameView *)v;
-
-- (void)setProvisionalItem:(WebHistoryItem *)item;
-- (void)setPreviousItem:(WebHistoryItem *)item;
-- (void)setCurrentItem:(WebHistoryItem *)item;
-
-@end
-
@implementation WebFramePrivate
- (void)dealloc
ASSERT(plugInViews == nil);
[inspectors release];
- delete pendingArchivedResources;
-
[super dealloc];
}
-- (void)finalize
-{
- delete pendingArchivedResources;
-
- [super finalize];
-}
-
- (void)setWebFrameView:(WebFrameView *)v
{
[v retain];
webFrameView = v;
}
-- (void)setProvisionalItem:(WebHistoryItem *)item
-{
- [item retain];
- [provisionalItem release];
- provisionalItem = item;
-}
-
-- (void)setPreviousItem:(WebHistoryItem *)item
-{
- [item retain];
- [previousItem release];
- previousItem = item;
-}
-
-- (void)setCurrentItem:(WebHistoryItem *)item
-{
- [item retain];
- [currentItem release];
- currentItem = item;
-}
-
@end
static inline WebFrame *frame(WebCoreFrameBridge *bridge)
[bfItem _setFormInfoFromRequest:request];
// Set the item for which we will save document state
- [_private setPreviousItem:_private->currentItem];
- [_private setCurrentItem:bfItem];
+ [self _setPreviousItem:_private->currentItem];
+ [self _setCurrentItem:bfItem];
return bfItem;
}
return FrameLoader::timeOfLastCompletedLoad();
}
-- (BOOL)_createPageCacheForItem:(WebHistoryItem *)item
-{
- NSMutableDictionary *pageCache;
-
- [item setHasPageCache: YES];
-
- if (![_private->bridge saveDocumentToPageCache]){
- [item setHasPageCache: NO];
- return NO;
- }
- else {
- pageCache = [item pageCache];
- [pageCache setObject:[NSDate date] forKey: WebPageCacheEntryDateKey];
- [pageCache setObject:[self dataSource] forKey: WebPageCacheDataSourceKey];
- [pageCache setObject:[[self frameView] documentView] forKey: WebPageCacheDocumentViewKey];
- }
- return YES;
-}
-
- (WebFrameBridge *)_bridge
{
return _private->bridge;
core(self)->scrollToAnchor([item URL]);
// must do this maintenance here, since we don't go through a real page reload
- [_private setCurrentItem:item];
- [self _restoreScrollPositionAndViewState];
+ [self _setCurrentItem:item];
+ core(self)->loader()->client()->restoreScrollPositionAndViewState();
// Fake the URL change by updating the data source's request. This will no longer
// be necessary if we do the better fix described above.
[_private->internalLoadDelegate webFrame:self didFinishLoadWithError:nil];
} else {
// Remember this item so we can traverse any child items as child frames load
- [_private setProvisionalItem:item];
+ [self _setProvisionalItem:item];
WebDataSource *newDataSource;
BOOL inPageCache = NO;
[_private->bridge saveDocumentState];
[self _saveScrollPositionAndViewStateToItem:_private->currentItem];
- [_private setCurrentItem:item];
+ [self _setCurrentItem:item];
// Restore form state (works from currentItem)
[_private->bridge restoreDocumentState];
// Restore the scroll position (taken in favor of going back to the anchor)
- [self _restoreScrollPositionAndViewState];
+ core(self)->loader()->client()->restoreScrollPositionAndViewState();
NSArray *childItems = [item children];
int numChildItems = childItems ? [childItems count] : 0;
if (isBackForwardLoadType(loadType))
// For back/forward, remember this item so we can traverse any child items as child frames load
- [childFrame->_private setProvisionalItem:childItem];
+ [childFrame _setProvisionalItem:childItem];
else
// For reload, just reinstall the current item, since a new child frame was created but we won't be creating a new BF item
- [childFrame->_private setCurrentItem:childItem];
+ [childFrame _setCurrentItem:childItem];
}
}
- (void)_saveScrollPositionAndViewStateToItem:(WebHistoryItem *)item
{
if (item) {
- NSView <WebDocumentView> *docView = [[self frameView] documentView];
+ NSView <WebDocumentView> *docView = [_private->webFrameView documentView];
NSView *parent = [docView superview];
// we might already be detached when this is called from detachFromParent, in which
// case we don't want to override real data earlier gathered with (0,0)
- (BOOL)_hasSelection
{
- id documentView = [[self frameView] documentView];
+ id documentView = [_private->webFrameView documentView];
// optimization for common case to avoid creating potentially large selection string
if ([documentView isKindOfClass:[WebHTMLView class]])
- (void)_clearSelection
{
- id documentView = [[self frameView] documentView];
+ id documentView = [_private->webFrameView documentView];
if ([documentView conformsToProtocol:@protocol(WebDocumentText)])
[documentView deselectAll];
}
[dataSource(loader) _addToUnarchiveState:archive];
}
-- (id <WebFormDelegate>)_formDelegate
+- (void)_setProvisionalItem:(WebHistoryItem *)item
{
- return [[self webView] _formDelegate];
+ [item retain];
+ [_private->provisionalItem release];
+ _private->provisionalItem = item;
+}
+
+- (void)_setPreviousItem:(WebHistoryItem *)item
+{
+ [item retain];
+ [_private->previousItem release];
+ _private->previousItem = item;
+}
+
+- (void)_setCurrentItem:(WebHistoryItem *)item
+{
+ [item retain];
+ [_private->currentItem release];
+ _private->currentItem = item;
}
@end
textEncodingName:[mainResource textEncodingName]
baseURL:[mainResource URL]
unreachableURL:nil];
- RefPtr<DocumentLoader> documentLoader = [self _createDocumentLoaderWithRequest:request];
+ RefPtr<DocumentLoader> documentLoader = core(self)->loader()->client()->createDocumentLoader(request);
[dataSource(documentLoader.get()) _addToUnarchiveState:archive];
[self _frameLoader]->load(documentLoader.get());
}
}
@end
-
-@implementation WebFrame (WebFrameLoaderClient)
-
-- (BOOL)_hasBackForwardList
-{
- return [[self webView] backForwardList] != nil;
-}
-
-- (void)_resetBackForwardList
-{
- // Note this doesn't verify the current load type as a b/f operation because it is called from
- // a subframe in the case of a delegate bailing out of the nav before it even gets to provisional state.
- WebFrame *mainFrame = [[self webView] mainFrame];
- WebHistoryItem *resetItem = mainFrame->_private->currentItem;
- if (resetItem)
- [[[self webView] backForwardList] goToItem:resetItem];
-}
-
-- (void)_invalidateCurrentItemPageCache
-{
- // When we are pre-commit, the currentItem is where the pageCache data resides
- NSDictionary *pageCache = [_private->currentItem pageCache];
-
- [_private->bridge invalidatePageCache:pageCache];
-
- // We're assuming that WebCore invalidates its pageCache state in didNotOpen:pageCache:
- [_private->currentItem setHasPageCache:NO];
-}
-
-- (BOOL)_provisionalItemIsTarget
-{
- return [_private->provisionalItem isTargetItem];
-}
-
-- (BOOL)_loadProvisionalItemFromPageCache
-{
- WebHistoryItem *item = _private->provisionalItem;
- if (![item hasPageCache])
- return NO;
- NSDictionary *pageCache = [item pageCache];
- if (![pageCache objectForKey:WebCorePageCacheStateKey])
- return NO;
- LOG(PageCache, "Restoring page from back/forward cache, %@", [item URL]);
- [[self provisionalDataSource] _loadFromPageCache:pageCache];
- return YES;
-}
-
-- (BOOL)_privateBrowsingEnabled
-{
- return [[[self webView] preferences] privateBrowsingEnabled];
-}
-
-- (void)_makeDocumentView
-{
- NSView <WebDocumentView> *documentView = [_private->webFrameView _makeDocumentViewForDataSource:[self dataSource]];
- if (!documentView)
- return;
-
- // FIXME: We could save work and not do this for a top-level view that is not a WebHTMLView.
- WebFrameView *v = _private->webFrameView;
- [_private->bridge createFrameViewWithNSView:documentView marginWidth:[v _marginWidth] marginHeight:[v _marginHeight]];
- [self _updateBackground];
- [_private->bridge installInFrame:[v _scrollView]];
-
- // Call setDataSource on the document view after it has been placed in the view hierarchy.
- // This what we for the top-level view, so should do this for views in subframes as well.
- [documentView setDataSource:[self dataSource]];
-}
-
-- (void)_forceLayout
-{
- NSView <WebDocumentView> *view = [[self frameView] documentView];
- if ([view isKindOfClass:[WebHTMLView class]])
- [(WebHTMLView *)view setNeedsToApplyStyles:YES];
- [view setNeedsLayout:YES];
- [view layout];
-}
-
-- (void)_updateHistoryForCommit
-{
- FrameLoadType type = [self _frameLoader]->loadType();
- if (isBackForwardLoadType(type) ||
- (type == FrameLoadTypeReload && [[self provisionalDataSource] unreachableURL] != nil)) {
- // Once committed, we want to use current item for saving DocState, and
- // the provisional item for restoring state.
- // Note previousItem must be set before we close the URL, which will
- // happen when the data source is made non-provisional below
- [_private setPreviousItem:_private->currentItem];
- ASSERT(_private->provisionalItem);
- [_private setCurrentItem:_private->provisionalItem];
- [_private setProvisionalItem:nil];
- }
-}
-
-- (void)_updateHistoryForReload
-{
- WebHistoryItem *currItem = _private->currentItem;
- LOG(PageCache, "Clearing back/forward cache, %@\n", [currItem URL]);
- [currItem setHasPageCache:NO];
- if ([self _frameLoader]->loadType() == FrameLoadTypeReload)
- [self _saveScrollPositionAndViewStateToItem:currItem];
- WebDataSource *dataSource = [self dataSource];
- NSURLRequest *request = [dataSource request];
- // Sometimes loading a page again leads to a different result because of cookies. Bugzilla 4072
- if ([request _webDataRequestUnreachableURL] == nil)
- [currItem setURL:[request URL]];
- // Update the last visited time. Mostly interesting for URL autocompletion statistics.
- NSURL *URL = [[[dataSource _documentLoader]->originalRequestCopy() URL] _webkit_canonicalize];
- WebHistory *sharedHistory = [WebHistory optionalSharedHistory];
- WebHistoryItem *oldItem = [sharedHistory itemForURL:URL];
- if (oldItem)
- [sharedHistory setLastVisitedTimeInterval:[NSDate timeIntervalSinceReferenceDate] forItem:oldItem];
-}
-
-- (void)_updateHistoryForStandardLoad
-{
- WebDataSource *dataSource = [self dataSource];
- if (![dataSource _documentLoader]->isClientRedirect()) {
- NSURL *URL = [dataSource _URLForHistory];
- if (URL && ![URL _web_isEmpty]) {
- ASSERT([self webView]);
- if (![[[self webView] preferences] privateBrowsingEnabled]) {
- WebHistoryItem *entry = [[WebHistory optionalSharedHistory] addItemForURL:URL];
- if ([dataSource pageTitle])
- [entry setTitle:[dataSource pageTitle]];
- }
- [self _addBackForwardItemClippedAtTarget:YES];
- }
- } else {
- NSURLRequest *request = [dataSource request];
-
- // Update the URL in the BF list that we made before the redirect, unless
- // this is alternate content for an unreachable URL (we want the BF list
- // item to remember the unreachable URL in case it becomes reachable later).
- if ([request _webDataRequestUnreachableURL] == nil) {
- [_private->currentItem setURL:[request URL]];
-
- // clear out the form data so we don't repost it to the wrong place if we
- // ever go back/forward to this item
- [_private->currentItem _setFormInfoFromRequest:request];
-
- // We must also clear out form data so we don't try to restore it into the incoming page,
- // see -_opened
- }
- }
-}
-
-- (void)_updateHistoryForBackForwardNavigation
-{
- // Must grab the current scroll position before disturbing it
- [self _saveScrollPositionAndViewStateToItem:_private->previousItem];
-}
-
-- (void)_updateHistoryForInternalLoad
-{
- // Add an item to the item tree for this frame
- ASSERT(![self _frameLoader]->documentLoader()->isClientRedirect());
- WebFrame *parentFrame = [self parentFrame];
- if (parentFrame) {
- WebHistoryItem *parentItem = parentFrame->_private->currentItem;
- // The only case where parentItem==nil should be when a parent frame loaded an
- // empty URL, which doesn't set up a current item in that parent.
- if (parentItem)
- [parentItem addChildItem:[self _createItem:YES]];
- } else {
- // See 3556159. It's not clear if it's valid to be in WebFrameLoadTypeOnLoadEvent
- // for a top-level frame, but that was a likely explanation for those crashes,
- // so let's guard against it.
- // ...and all WebFrameLoadTypeOnLoadEvent uses were folded to WebFrameLoadTypeInternal
- LOG_ERROR("no parent frame in transitionToCommitted:, WebFrameLoadTypeInternal");
- }
-}
-
-- (LoadErrorResetToken *)_tokenForLoadErrorReset
-{
- return (LoadErrorResetToken*)[[self _currentBackForwardListItemToResetTo] retain];
-}
-
-- (void)_resetAfterLoadError:(LoadErrorResetToken *)token
-{
- WebHistoryItem *item = (WebHistoryItem *)token;
- if (item)
- [[[self webView] backForwardList] goToItem:item];
- [item release];
-}
-
-- (void)_doNotResetAfterLoadError:(LoadErrorResetToken *)token
-{
- WebHistoryItem *item = (WebHistoryItem *)token;
- [item release];
-}
-
-- (void)_dispatchDidHandleOnloadEventsForFrame
-{
- WebView *webView = [self webView];
- [[webView _frameLoadDelegateForwarder] webView:webView didHandleOnloadEventsForFrame:self];
-}
-
-- (void)_dispatchDidReceiveServerRedirectForProvisionalLoadForFrame
-{
- WebView *webView = [self webView];
- [[webView _frameLoadDelegateForwarder] webView:webView
- didReceiveServerRedirectForProvisionalLoadForFrame:self];
-}
-
-- (id)_dispatchIdentifierForInitialRequest:(NSURLRequest *)clientRequest fromDocumentLoader:(DocumentLoader*)loader
-{
- WebView *webView = [self webView];
- id resourceLoadDelegate = [webView resourceLoadDelegate];
-
- if ([webView _resourceLoadDelegateImplementations].delegateImplementsIdentifierForRequest)
- return [resourceLoadDelegate webView:webView identifierForInitialRequest:clientRequest fromDataSource:dataSource(loader)];
-
- return [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView identifierForInitialRequest:clientRequest fromDataSource:dataSource(loader)];
-}
-
-- (NSURLRequest *)_dispatchResource:(id)identifier willSendRequest:(NSURLRequest *)clientRequest redirectResponse:(NSURLResponse *)redirectResponse fromDocumentLoader:(DocumentLoader*)loader
-{
- WebView *webView = [self webView];
- id resourceLoadDelegate = [webView resourceLoadDelegate];
-
- if ([webView _resourceLoadDelegateImplementations].delegateImplementsWillSendRequest)
- return [resourceLoadDelegate webView:webView resource:identifier willSendRequest:clientRequest redirectResponse:redirectResponse fromDataSource:dataSource(loader)];
- else
- return [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier willSendRequest:clientRequest redirectResponse:redirectResponse fromDataSource:dataSource(loader)];
-}
-
-- (void)_dispatchDidReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier fromDocumentLoader:(DocumentLoader*)loader
-{
- WebView *webView = [self webView];
- id resourceLoadDelegate = [webView resourceLoadDelegate];
-
- if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidReceiveAuthenticationChallenge)
- [resourceLoadDelegate webView:webView resource:identifier didReceiveAuthenticationChallenge:currentWebChallenge fromDataSource:dataSource(loader)];
- else
- [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didReceiveAuthenticationChallenge:currentWebChallenge fromDataSource:dataSource(loader)];
-}
-
-- (void)_dispatchDidCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier fromDocumentLoader:(DocumentLoader*)loader
-{
- WebView *webView = [self webView];
- id resourceLoadDelegate = [webView resourceLoadDelegate];
-
- if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidCancelAuthenticationChallenge)
- [resourceLoadDelegate webView:webView resource:identifier didCancelAuthenticationChallenge:currentWebChallenge fromDataSource:dataSource(loader)];
- else
- [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didCancelAuthenticationChallenge:currentWebChallenge fromDataSource:dataSource(loader)];
-}
-
-- (void)_dispatchResource:(id)identifier didReceiveResponse:(NSURLResponse *)r fromDocumentLoader:(DocumentLoader*)loader
-{
- WebView *webView = [self webView];
-
- if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidReceiveResponse)
- [[webView resourceLoadDelegate] webView:webView resource:identifier didReceiveResponse:r fromDataSource:dataSource(loader)];
- else
- [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didReceiveResponse:r fromDataSource:dataSource(loader)];
-}
-
-- (void)_dispatchResource:(id)identifier didReceiveContentLength:(int)lengthReceived fromDocumentLoader:(DocumentLoader*)loader
-{
- WebView *webView = [self webView];
-
- if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidReceiveContentLength)
- [[webView resourceLoadDelegate] webView:webView resource:identifier didReceiveContentLength:(WebNSUInteger)lengthReceived fromDataSource:dataSource(loader)];
- else
- [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didReceiveContentLength:(WebNSUInteger)lengthReceived fromDataSource:dataSource(loader)];
-}
-
-- (void)_dispatchResource:(id)identifier didFinishLoadingFromDocumentLoader:(DocumentLoader*)loader
-{
- WebView *webView = [self webView];
-
- if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidFinishLoadingFromDataSource)
- [[webView resourceLoadDelegate] webView:webView resource:identifier didFinishLoadingFromDataSource:dataSource(loader)];
- else
- [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didFinishLoadingFromDataSource:dataSource(loader)];
-}
-
-
-- (void)_dispatchResource:(id)identifier didFailLoadingWithError:error fromDocumentLoader:(DocumentLoader*)loader
-{
- WebView *webView = [self webView];
- [[webView _resourceLoadDelegateForwarder] webView:webView resource:identifier didFailLoadingWithError:error fromDataSource:dataSource(loader)];
-}
-
-- (void)_dispatchDidCancelClientRedirectForFrame
-{
- WebView *webView = [self webView];
- [[webView _frameLoadDelegateForwarder] webView:webView didCancelClientRedirectForFrame:self];
-}
-
-- (void)_dispatchWillPerformClientRedirectToURL:(NSURL *)URL delay:(NSTimeInterval)seconds fireDate:(NSDate *)date
-{
- WebView *webView = [self webView];
- [[webView _frameLoadDelegateForwarder] webView:webView
- willPerformClientRedirectToURL:URL
- delay:seconds
- fireDate:date
- forFrame:self];
-}
-
-- (void)_dispatchDidChangeLocationWithinPageForFrame
-{
- WebView *webView = [self webView];
- [[webView _frameLoadDelegateForwarder] webView:webView didChangeLocationWithinPageForFrame:self];
-}
-
-- (void)_dispatchWillCloseFrame
-{
- WebView *webView = [self webView];
- [[webView _frameLoadDelegateForwarder] webView:webView willCloseFrame:self];
-}
-
-- (void)_dispatchDidReceiveIcon:(NSImage *)icon
-{
- WebView *webView = [self webView];
- ASSERT([self _isMainFrame]);
- [webView _willChangeValueForKey:_WebMainFrameIconKey];
- [[webView _frameLoadDelegateForwarder] webView:webView didReceiveIcon:icon forFrame:self];
- [webView _didChangeValueForKey:_WebMainFrameIconKey];
-}
-
-- (void)_dispatchDidStartProvisionalLoadForFrame
-{
- WebView *webView = [self webView];
- [webView _didStartProvisionalLoadForFrame:self];
- [[webView _frameLoadDelegateForwarder] webView:webView didStartProvisionalLoadForFrame:self];
-}
-
-- (void)_dispatchDidReceiveTitle:(NSString *)title
-{
- WebView *webView = [self webView];
- [[webView _frameLoadDelegateForwarder] webView:webView didReceiveTitle:title forFrame:self];
-}
-
-- (void)_dispatchDidCommitLoadForFrame
-{
- // Tell the client we've committed this URL.
- ASSERT([[self frameView] documentView] != nil);
-
- WebView *webView = [self webView];
- [webView _didCommitLoadForFrame:self];
- [[webView _frameLoadDelegateForwarder] webView:webView didCommitLoadForFrame:self];
-}
-
-- (void)_dispatchDidFailProvisionalLoadWithError:(NSError *)error
-{
- WebView *webView = [self webView];
- [webView _didFailProvisionalLoadWithError:error forFrame:self];
- [[webView _frameLoadDelegateForwarder] webView:webView didFailProvisionalLoadWithError:error forFrame:self];
- [_private->internalLoadDelegate webFrame:self didFinishLoadWithError:error];
-}
-
-- (void)_dispatchDidFailLoadWithError:(NSError *)error
-{
- WebView *webView = [self webView];
- [webView _didFailLoadWithError:error forFrame:self];
- [[webView _frameLoadDelegateForwarder] webView:webView didFailLoadWithError:error forFrame:self];
- [_private->internalLoadDelegate webFrame:self didFinishLoadWithError:error];
-}
-
-- (void)_dispatchDidFinishLoadForFrame
-{
- WebView *webView = [self webView];
- [webView _didFinishLoadForFrame:self];
- [[webView _frameLoadDelegateForwarder] webView:webView didFinishLoadForFrame:self];
- [_private->internalLoadDelegate webFrame:self didFinishLoadWithError:nil];
-}
-
-- (void)_dispatchDidFirstLayoutInFrame
-{
- WebView *webView = [self webView];
- [[webView _frameLoadDelegateForwarder] webView:webView didFirstLayoutInFrame:self];
-}
-
-- (Frame*)_dispatchCreateWebViewWithRequest:(NSURLRequest *)request
-{
- WebView *currentWebView = [self webView];
- id wd = [currentWebView UIDelegate];
- if ([wd respondsToSelector:@selector(webView:createWebViewWithRequest:)])
- return core([[wd webView:currentWebView createWebViewWithRequest:request] mainFrame]);
- return core([[[WebDefaultUIDelegate sharedUIDelegate] webView:currentWebView createWebViewWithRequest:request] mainFrame]);
-}
-
-- (void)_dispatchShow
-{
- WebView *webView = [self webView];
- [[webView _UIDelegateForwarder] webViewShow:webView];
-}
-
-- (WebPolicyDecider *)_createPolicyDeciderWithTarget:(id)target action:(SEL)action
-{
- return [[WebPolicyDeciderMac alloc] initWithTarget:target action:action];
-}
-
-static inline WebPolicyDecisionListener *decisionListener(WebPolicyDecider *decider)
-{
- return [(WebPolicyDeciderMac *)decider decisionListener];
-}
-
-- (void)_dispatchDecidePolicyForMIMEType:(NSString *)MIMEType request:(NSURLRequest *)request decider:(WebPolicyDecider *)decider
-{
- WebView *webView = [self webView];
-
- [[webView _policyDelegateForwarder] webView:webView decidePolicyForMIMEType:MIMEType request:request frame:self decisionListener:decisionListener(decider)];
-}
-
-- (void)_dispatchDecidePolicyForNewWindowAction:(NSDictionary *)action request:(NSURLRequest *)request newFrameName:(NSString *)frameName decider:(WebPolicyDecider *)decider
-{
- WebView *webView = [self webView];
- [[webView _policyDelegateForwarder] webView:webView
- decidePolicyForNewWindowAction:action
- request:request
- newFrameName:frameName
- decisionListener:decisionListener(decider)];
-}
-
-- (void)_dispatchDecidePolicyForNavigationAction:(NSDictionary *)action request:(NSURLRequest *)request decider:(WebPolicyDecider *)decider
-{
- WebView *webView = [self webView];
- [[webView _policyDelegateForwarder] webView:webView
- decidePolicyForNavigationAction:action
- request:request
- frame:self
- decisionListener:decisionListener(decider)];
-}
-
-- (void)_dispatchUnableToImplementPolicyWithError:(NSError *)error
-{
- WebView *webView = [self webView];
- [[webView _policyDelegateForwarder] webView:webView unableToImplementPolicyWithError:error frame:self];
-}
-
-- (void)_dispatchSourceFrame:(Frame*)sourceFrame willSubmitForm:(Element*)form withValues:(NSDictionary *)values submissionDecider:(WebPolicyDecider *)decider
-{
- [[self _formDelegate] frame:self sourceFrame:kit(sourceFrame) willSubmitForm:kit(form) withValues:values submissionListener:decisionListener(decider)];
-}
-
-- (void)_detachedFromParent1
-{
- [self _saveScrollPositionAndViewStateToItem:_private->currentItem];
-}
-
-- (void)_detachedFromParent2
-{
- [_private->inspectors makeObjectsPerformSelector:@selector(_webFrameDetached:) withObject:self];
- [_private->webFrameView _setWebFrame:nil]; // needed for now to be compatible w/ old behavior
-}
-
-- (void)_detachedFromParent3
-{
- [_private setWebFrameView:nil];
-}
-
-- (void)_detachedFromParent4
-{
- _private->bridge = nil;
-}
-
-- (void)_updateHistoryAfterClientRedirect
-{
- // Clear out form data so we don't try to restore it into the incoming page. Must happen after
- // khtml has closed the URL and saved away the form state.
- WebHistoryItem *item = _private->currentItem;
- [item setDocumentState:nil];
- [item setScrollPoint:NSZeroPoint];
-}
-
-- (void)_loadedFromPageCache
-{
- // Release the resources kept in the page cache.
- // They will be reset when we leave this page.
- // The WebCore side of the page cache will have already been invalidated by
- // the bridge to prevent premature release.
- [_private->currentItem setHasPageCache:NO];
-}
-
-- (void)_downloadWithLoadingConnection:(NSURLConnection *)connection request:(NSURLRequest *)request response:(NSURLResponse *)response proxy:(id)proxy
-{
- [WebDownload _downloadWithLoadingConnection:connection
- request:request
- response:response
- delegate:[[self webView] downloadDelegate]
- proxy:proxy];
-}
-
-- (void)_setDocumentViewFromPageCache:(NSDictionary *)pageCache
-{
- NSView <WebDocumentView> *cachedView = [pageCache objectForKey:WebPageCacheDocumentViewKey];
- ASSERT(cachedView != nil);
- [[self frameView] _setDocumentView:cachedView];
-}
-
-- (void)_setCopiesOnScroll
-{
- [[[[self frameView] _scrollView] contentView] setCopiesOnScroll:YES];
-}
-
-- (void)_dispatchDidLoadMainResourceForDocumentLoader:(DocumentLoader*)loader
-{
- if ([WebScriptDebugServer listenerCount])
- [[WebScriptDebugServer sharedScriptDebugServer] webView:[self webView]
- didLoadMainResourceForDataSource:dataSource(loader)];
-}
-
-- (void)_forceLayoutForNonHTML
-{
- WebFrameView *thisView = [self frameView];
- NSView <WebDocumentView> *thisDocumentView = [thisView documentView];
- ASSERT(thisDocumentView != nil);
-
- // Tell the just loaded document to layout. This may be necessary
- // for non-html content that needs a layout message.
- if (!([[self dataSource] _isDocumentHTML])) {
- [thisDocumentView setNeedsLayout:YES];
- [thisDocumentView layout];
- [thisDocumentView setNeedsDisplay:YES];
- }
-}
-
-- (void)_clearLoadingFromPageCacheForDocumentLoader:(DocumentLoader*)loader
-{
- [dataSource(loader) _setLoadingFromPageCache:NO];
-}
-
-- (BOOL)_isDocumentLoaderLoadingFromPageCache:(DocumentLoader*)loader
-{
- return [dataSource(loader) _loadingFromPageCache];
-}
-
-- (void)_makeRepresentationForDocumentLoader:(DocumentLoader*)loader
-{
- [dataSource(loader) _makeRepresentation];
-}
-
-- (void)_revertToProvisionalStateForDocumentLoader:(DocumentLoader*)loader
-{
- [dataSource(loader) _revertToProvisionalState];
-}
-
-- (void)_setMainDocumentError:(NSError *)error forDocumentLoader:(DocumentLoader*)loader
-{
- [dataSource(loader) _setMainDocumentError:error];
-}
-
-- (void)_clearUnarchivingStateForLoader:(DocumentLoader*)loader
-{
- [dataSource(loader) _clearUnarchivingState];
-}
-
-- (void)_progressStarted
-{
- [[self webView] _progressStarted:self];
-}
-
-- (void)_progressCompleted
-{
- [[self webView] _progressCompleted:self];
-}
-
-- (void)_incrementProgressForIdentifier:(id)identifier response:(NSURLResponse *)response
-{
- [[self webView] _incrementProgressForIdentifier:identifier response:response];
-}
-
-- (void)_incrementProgressForIdentifier:(id)identifier data:(NSData *)data
-{
- [[self webView] _incrementProgressForIdentifier:identifier data:data];
-}
-
-- (void)_completeProgressForIdentifier:(id)identifier
-{
- [[self webView] _completeProgressForIdentifier:identifier];
-}
-
-- (void)_setMainFrameDocumentReady:(BOOL)ready
-{
- [[self webView] setMainFrameDocumentReady:ready];
-}
-
-- (void)_willChangeTitleForDocument:(DocumentLoader*)loader
-{
- // FIXME: Should do this only in main frame case, right?
- [[self webView] _willChangeValueForKey:_WebMainFrameTitleKey];
-}
-
-- (void)_didChangeTitleForDocument:(DocumentLoader*)loader
-{
- // FIXME: Should do this only in main frame case, right?
- [[self webView] _didChangeValueForKey:_WebMainFrameTitleKey];
-}
-
-- (void)_startDownloadWithRequest:(NSURLRequest *)request
-{
- // FIXME: Should download full request.
- [[self webView] _downloadURL:[request URL]];
-}
-
-- (void)_finishedLoadingDocument:(DocumentLoader*)loader
-{
- [dataSource(loader) _finishedLoading];
-}
-
-- (void)_committedLoadWithDocumentLoader:(DocumentLoader*)loader data:(NSData *)data
-{
- [dataSource(loader) _receivedData:data];
-}
-
-- (void)_documentLoader:(DocumentLoader*)loader setMainDocumentError:(NSError *)error
-{
- [dataSource(loader) _setMainDocumentError:error];
-}
-
-- (void)_finalSetupForReplaceWithDocumentLoader:(DocumentLoader*)loader
-{
- [dataSource(loader) _clearUnarchivingState];
-}
-
-- (NSError *)_cancelledErrorWithRequest:(NSURLRequest *)request
-{
- return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled URL:[request URL]];
-}
-
-- (NSError *)_cannotShowURLErrorWithRequest:(NSURLRequest *)request
-{
- return [NSError _webKitErrorWithDomain:WebKitErrorDomain code:WebKitErrorCannotShowURL URL:[request URL]];
-}
-
-- (NSError *)_interruptForPolicyChangeErrorWithRequest:(NSURLRequest *)request
-{
- return [NSError _webKitErrorWithDomain:WebKitErrorDomain code:WebKitErrorFrameLoadInterruptedByPolicyChange URL:[request URL]];
-}
-
-- (NSError *)_cannotShowMIMETypeErrorWithResponse:(NSURLResponse *)response
-{
- return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:WebKitErrorCannotShowMIMEType URL:[response URL]];
-}
-
-- (NSError *)_fileDoesNotExistErrorWithResponse:(NSURLResponse *)response
-{
- return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist URL:[response URL]];
-}
-
-- (BOOL)_shouldFallBackForError:(NSError *)error
-{
- // FIXME: Needs to check domain.
- // FIXME: WebKitErrorPlugInWillHandleLoad is a workaround for the cancel we do to prevent
- // loading plugin content twice. See <rdar://problem/4258008>
- return [error code] != NSURLErrorCancelled && [error code] != WebKitErrorPlugInWillHandleLoad;
-}
-
-- (BOOL)_hasWebView
-{
- return [self webView] != nil;
-}
-
-- (BOOL)_hasFrameView
-{
- return [self frameView] != nil;
-}
-
-- (NSURL *)_mainFrameURL
-{
- return [[[[self webView] mainFrame] dataSource] _URL];
-}
-
-// The following 2 methods are copied from [NSHTTPURLProtocol _cachedResponsePassesValidityChecks] and modified for our needs.
-// FIXME: It would be nice to eventually to share this code somehow.
-- (BOOL)_canUseResourceForRequest:(NSURLRequest *)request
-{
- NSURLRequestCachePolicy policy = [request cachePolicy];
- if (policy == NSURLRequestReturnCacheDataElseLoad)
- return YES;
- if (policy == NSURLRequestReturnCacheDataDontLoad)
- return YES;
- if (policy == NSURLRequestReloadIgnoringCacheData)
- return NO;
- if ([request valueForHTTPHeaderField:@"must-revalidate"] != nil)
- return NO;
- if ([request valueForHTTPHeaderField:@"proxy-revalidate"] != nil)
- return NO;
- if ([request valueForHTTPHeaderField:@"If-Modified-Since"] != nil)
- return NO;
- if ([request valueForHTTPHeaderField:@"Cache-Control"] != nil)
- return NO;
- if ([@"POST" _webkit_isCaseInsensitiveEqualToString:[request HTTPMethod]])
- return NO;
- return YES;
-}
-
-- (BOOL)_canUseResourceWithResponse:(NSURLResponse *)response
-{
- if (WKGetNSURLResponseMustRevalidate(response))
- return NO;
- if (WKGetNSURLResponseCalculatedExpiration(response) - CFAbsoluteTimeGetCurrent() < 1)
- return NO;
- return YES;
-}
-
-- (void)_deliverArchivedResourcesAfterDelay
-{
- if (!_private->pendingArchivedResources)
- return;
- if (_private->pendingArchivedResources->isEmpty())
- return;
- if ([self _frameLoader]->defersCallbacks())
- return;
-
- [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(_deliverArchivedResources) object:nil];
- [self performSelector:@selector(_deliverArchivedResources) withObject:nil afterDelay:0];
-}
-
-- (BOOL)_willUseArchiveForRequest:(NSURLRequest *)r originalURL:(NSURL *)originalURL loader:(WebResourceLoader*)loader
-{
- if (![[r URL] isEqual:originalURL])
- return NO;
- if (![self _canUseResourceForRequest:r])
- return NO;
- WebResource *resource = [dataSource([self _frameLoader]->activeDocumentLoader()) _archivedSubresourceForURL:originalURL];
- if (!resource)
- return NO;
- if (![self _canUseResourceWithResponse:[resource _response]])
- return NO;
- if (!_private->pendingArchivedResources)
- _private->pendingArchivedResources = new ResourceMap;
- _private->pendingArchivedResources->set(loader, resource);
- // Deliver the resource after a delay because callers don't expect to receive callbacks while calling this method.
- [self _deliverArchivedResourcesAfterDelay];
- return YES;
-}
-
-- (BOOL)_archiveLoadPendingForLoader:(WebResourceLoader*)loader
-{
- if (!_private->pendingArchivedResources)
- return false;
- return _private->pendingArchivedResources->contains(loader);
-}
-
-- (void)_cancelPendingArchiveLoadForLoader:(WebResourceLoader*)loader
-{
- if (!_private->pendingArchivedResources)
- return;
- if (_private->pendingArchivedResources->isEmpty())
- return;
- _private->pendingArchivedResources->remove(loader);
- if (_private->pendingArchivedResources->isEmpty())
- [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(_deliverArchivedResources) object:nil];
-}
-
-- (void)_clearArchivedResources
-{
- if (_private->pendingArchivedResources)
- _private->pendingArchivedResources->clear();
- [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(_deliverArchivedResources) object:nil];
-}
-
-- (void)_deliverArchivedResources
-{
- if (!_private->pendingArchivedResources)
- return;
- if (_private->pendingArchivedResources->isEmpty())
- return;
- if ([self _frameLoader]->defersCallbacks())
- return;
-
- const ResourceMap copy = *_private->pendingArchivedResources;
- _private->pendingArchivedResources->clear();
-
- ResourceMap::const_iterator end = copy.end();
- for (ResourceMap::const_iterator it = copy.begin(); it != end; ++it) {
- RefPtr<WebResourceLoader> loader = it->first;
- WebResource *resource = it->second.get();
- NSData *data = [[resource data] retain];
- loader->didReceiveResponse([resource _response]);
- loader->didReceiveData(data, [data length], true);
- [data release];
- loader->didFinishLoading();
- }
-}
-
-- (void)_setDefersCallbacks:(BOOL)defers
-{
- if (!defers)
- [self _deliverArchivedResourcesAfterDelay];
-}
-
-- (BOOL)_canHandleRequest:(NSURLRequest *)request
-{
- return [WebView _canHandleRequest:request];
-}
-
-- (BOOL)_canShowMIMEType:(NSString *)MIMEType
-{
- return [WebView canShowMIMEType:MIMEType];
-}
-
-- (BOOL)_representationExistsForURLScheme:(NSString *)URLScheme
-{
- return [WebView _representationExistsForURLScheme:URLScheme];
-}
-
-- (NSString *)_generatedMIMETypeForURLScheme:(NSString *)URLScheme
-{
- return [WebView _generatedMIMETypeForURLScheme:URLScheme];
-}
-
-- (NSDictionary *)_elementForEvent:(NSEvent *)event
-{
- switch ([event type]) {
- case NSLeftMouseDown:
- case NSRightMouseDown:
- case NSOtherMouseDown:
- case NSLeftMouseUp:
- case NSRightMouseUp:
- case NSOtherMouseUp:
- break;
- default:
- return nil;
- }
-
- NSView *topViewInEventWindow = [[event window] contentView];
- NSView *viewContainingPoint = [topViewInEventWindow hitTest:
- [topViewInEventWindow convertPoint:[event locationInWindow] fromView:nil]];
- while (viewContainingPoint) {
- if ([viewContainingPoint isKindOfClass:[WebView class]])
- return [(WebView *)viewContainingPoint elementAtPoint:
- [viewContainingPoint convertPoint:[event locationInWindow] fromView:nil]];
- viewContainingPoint = [viewContainingPoint superview];
- }
- return nil;
-}
-
-- (void)_frameLoadCompleted
-{
- // Note: Can be called multiple times.
- // Even if already complete, we might have set a previous item on a frame that
- // didn't do any data loading on the past transaction. Make sure to clear these out.
- NSScrollView *sv = [[self frameView] _scrollView];
- if ([[self webView] drawsBackground])
- [sv setDrawsBackground:YES];
- [_private setPreviousItem:nil];
-}
-
-/*
- There is a race condition between the layout and load completion that affects restoring the scroll position.
- We try to restore the scroll position at both the first layout and upon load completion.
-
- 1) If first layout happens before the load completes, we want to restore the scroll position then so that the
- first time we draw the page is already scrolled to the right place, instead of starting at the top and later
- jumping down. It is possible that the old scroll position is past the part of the doc laid out so far, in
- which case the restore silent fails and we will fix it in when we try to restore on doc completion.
- 2) If the layout happens after the load completes, the attempt to restore at load completion time silently
- fails. We then successfully restore it when the layout happens.
- */
-
-- (void)_restoreScrollPositionAndViewState
-{
- ASSERT(_private->currentItem);
- NSView <WebDocumentView> *docView = [[self frameView] documentView];
- NSPoint point = [_private->currentItem scrollPoint];
- if ([docView conformsToProtocol:@protocol(_WebDocumentViewState)]) {
- id state = [_private->currentItem viewState];
- if (state) {
- [(id <_WebDocumentViewState>)docView setViewState:state];
- }
-
- [(id <_WebDocumentViewState>)docView setScrollPoint:point];
- } else {
- [docView scrollPoint:point];
- }
-}
-
-- (void)_setTitle:(NSString *)title forURL:(NSURL *)URL
-{
- [[[WebHistory optionalSharedHistory] itemForURL:URL] setTitle:title];
- [_private->currentItem setTitle:title];
-}
-
-- (PassRefPtr<DocumentLoader>)_createDocumentLoaderWithRequest:(NSURLRequest *)request
-{
- RefPtr<WebDocumentLoaderMac> loader = new WebDocumentLoaderMac(request);
-
- WebDataSource *dataSource = [[WebDataSource alloc] _initWithDocumentLoader:loader.get()];
- loader->setDataSource(dataSource);
- [dataSource release];
-
- return loader.release();
-}
-
-- (void)_prepareForDataSourceReplacement
-{
- if (![self dataSource]) {
- ASSERT(!core(self)->tree()->childCount());
- return;
- }
-
- // Make sure that any work that is triggered by resigning first reponder can get done.
- // The main example where this came up is the textDidEndEditing that is sent to the
- // FormsDelegate (3223413). We need to do this before _detachChildren, since that will
- // remove the views as a side-effect of freeing the bridge, at which point we can't
- // post the FormDelegate messages.
- //
- // Note that this can also take FirstResponder away from a child of our frameView that
- // is not in a child frame's view. This is OK because we are in the process
- // of loading new content, which will blow away all editors in this top frame, and if
- // a non-editor is firstReponder it will not be affected by endEditingFor:.
- // Potentially one day someone could write a DocView whose editors were not all
- // replaced by loading new content, but that does not apply currently.
- NSView *frameView = [self frameView];
- NSWindow *window = [frameView window];
- NSResponder *firstResp = [window firstResponder];
- if ([firstResp isKindOfClass:[NSView class]] && [(NSView *)firstResp isDescendantOf:frameView])
- [window endEditingFor:firstResp];
-
- [self _frameLoader]->detachChildren();
-}
-
-- (void)_didFinishLoad
-{
- [_private->internalLoadDelegate webFrame:self didFinishLoadWithError:nil];
-}
-
-- (void)_addHistoryItemForFragmentScroll
-{
- [self _addBackForwardItemClippedAtTarget:NO];
-}
-
-- (BOOL)_shouldTreatURLAsSameAsCurrent:(NSURL *)URL
-{
- WebHistoryItem *item = _private->currentItem;
- NSString* URLString = [URL _web_originalDataAsString];
- return [URLString isEqual:[item URLString]] || [URLString isEqual:[item originalURLString]];
-}
-
-- (void)_provisionalLoadStarted
-{
- FrameLoadType loadType = [self _frameLoader]->loadType();
-
- // FIXME: This is OK as long as no one resizes the window,
- // but in the case where someone does, it means garbage outside
- // the occupied part of the scroll view.
- [[[self frameView] _scrollView] setDrawsBackground:NO];
-
- // Cache the page, if possible.
- // Don't write to the cache if in the middle of a redirect, since we will want to
- // store the final page we end up on.
- // No point writing to the cache on a reload or loadSame, since we will just write
- // over it again when we leave that page.
- WebHistoryItem *item = _private->currentItem;
- if ([self _canCachePage]
- && item
- && ![self _frameLoader]->isQuickRedirectComing()
- && loadType != FrameLoadTypeReload
- && loadType != FrameLoadTypeReloadAllowingStaleData
- && loadType != FrameLoadTypeSame
- && ![[self dataSource] isLoading]
- && ![self _frameLoader]->documentLoader()->isStopping()) {
- if ([[[self dataSource] representation] isKindOfClass:[WebHTMLRepresentation class]]) {
- if (![item pageCache]){
- // Add the items to this page's cache.
- if ([self _createPageCacheForItem:item]) {
- LOG(PageCache, "Saving page to back/forward cache, %@\n", [[self dataSource] _URL]);
-
- // See if any page caches need to be purged after the addition of this
- // new page cache.
- [self _purgePageCache];
- }
- else
- LOG(PageCache, "NOT saving page to back/forward cache, unable to create items, %@\n", [[self dataSource] _URL]);
- }
- } else
- // Put the document into a null state, so it can be restored correctly.
- core(self)->clear();
- } else
- LOG(PageCache, "NOT saving page to back/forward cache, %@\n", [[self dataSource] _URL]);
-}
-
-@end
// This header contains WebFrame declarations that can be used anywhere in WebKit, but are neither SPI nor API.
#import "WebFramePrivate.h"
-#import "WebPolicyDelegatePrivate.h"
#ifdef __cplusplus
#import <WebCore/FrameLoaderTypes.h>
-#import <wtf/Forward.h>
#endif
+@class DOMElement;
@class DOMRange;
@class WebInspector;
@class WebFrameView;
@class WebFrameBridge;
-@class WebPolicyDecider;
+@class WebHistoryItem;
+@class WebScriptDebugger;
#ifdef __cplusplus
class FrameLoader;
class HTMLElement;
class Range;
- class WebResourceLoader;
- struct LoadErrorResetToken;
}
WebCore::FrameMac* core(WebFrame *);
WebCore::Range* core(DOMRange *);
DOMRange *kit(WebCore::Range*);
+@interface WebFramePrivate : NSObject
+{
+@public
+ WebFrameView *webFrameView;
+
+ WebFrameBridge *bridge;
+ WebHistoryItem *currentItem; // BF item for our current content
+ WebHistoryItem *provisionalItem; // BF item for where we're trying to go
+ // (only known when navigating to a pre-existing BF item)
+ WebHistoryItem *previousItem; // BF item for previous content, see _itemForSavingDocState
+
+ WebScriptDebugger *scriptDebugger;
+ id internalLoadDelegate;
+
+ NSMutableSet *plugInViews;
+ NSMutableSet *inspectors;
+}
+@end
+
#endif
@interface WebFrame (WebInternal)
- (void)_recursive_pauseNullEventsForAllNetscapePlugins;
- (void)_recursive_resumeNullEventsForAllNetscapePlugins;
-@end
+- (void)_setProvisionalItem:(WebHistoryItem *)item;
+- (void)_setPreviousItem:(WebHistoryItem *)item;
+- (void)_setCurrentItem:(WebHistoryItem *)item;
-#ifdef __cplusplus
+- (void)_saveScrollPositionAndViewStateToItem:(WebHistoryItem *)item;
-@interface WebFrame (WebFrameLoaderClient)
-
-- (BOOL)_hasBackForwardList;
-- (void)_resetBackForwardList;
-- (void)_invalidateCurrentItemPageCache;
-- (BOOL)_provisionalItemIsTarget;
-- (BOOL)_loadProvisionalItemFromPageCache;
-- (BOOL)_privateBrowsingEnabled;
-- (void)_makeDocumentView;
-- (void)_forceLayout;
-- (void)_updateHistoryForCommit;
-- (void)_updateHistoryForReload;
-- (void)_updateHistoryForStandardLoad;
-- (void)_updateHistoryForBackForwardNavigation;
-- (void)_updateHistoryForInternalLoad;
-- (WebCore::LoadErrorResetToken*)_tokenForLoadErrorReset;
-- (void)_resetAfterLoadError:(WebCore::LoadErrorResetToken*)token;
-- (void)_doNotResetAfterLoadError:(WebCore::LoadErrorResetToken*)token;
-- (void)_dispatchDidHandleOnloadEventsForFrame;
-- (void)_dispatchDidReceiveServerRedirectForProvisionalLoadForFrame;
-- (id)_dispatchIdentifierForInitialRequest:(NSURLRequest *)clientRequest fromDocumentLoader:(WebCore::DocumentLoader*)loader;
-- (NSURLRequest *)_dispatchResource:(id)identifier willSendRequest:(NSURLRequest *)clientRequest redirectResponse:(NSURLResponse *)redirectResponse fromDocumentLoader:(WebCore::DocumentLoader*)loader;
-- (void)_dispatchDidReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier fromDocumentLoader:(WebCore::DocumentLoader*)loader;
-- (void)_dispatchDidCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier fromDocumentLoader:(WebCore::DocumentLoader*)loader;
-- (void)_dispatchResource:(id)identifier didReceiveResponse:(NSURLResponse *)r fromDocumentLoader:(WebCore::DocumentLoader*)loader;
-- (void)_dispatchResource:(id)identifier didReceiveContentLength:(int)lengthReceived fromDocumentLoader:(WebCore::DocumentLoader*)loader;
-- (void)_dispatchResource:(id)identifier didFinishLoadingFromDocumentLoader:(WebCore::DocumentLoader*)loader;
-- (void)_dispatchResource:(id)identifier didFailLoadingWithError:error fromDocumentLoader:(WebCore::DocumentLoader*)loader;
-- (void)_dispatchDidCancelClientRedirectForFrame;
-- (void)_dispatchWillPerformClientRedirectToURL:(NSURL *)URL delay:(NSTimeInterval)seconds fireDate:(NSDate *)date;
-- (void)_dispatchDidChangeLocationWithinPageForFrame;
-- (void)_dispatchWillCloseFrame;
-- (void)_dispatchDidReceiveIcon:(NSImage *)icon;
-- (void)_dispatchDidStartProvisionalLoadForFrame;
-- (void)_dispatchDidReceiveTitle:(NSString *)title;
-- (void)_dispatchDidCommitLoadForFrame;
-- (void)_dispatchDidFailProvisionalLoadWithError:(NSError *)error;
-- (void)_dispatchDidFailLoadWithError:(NSError *)error;
-- (void)_dispatchDidFinishLoadForFrame;
-- (void)_dispatchDidFirstLayoutInFrame;
-- (WebCore::Frame*)_dispatchCreateWebViewWithRequest:(NSURLRequest *)request;
-- (void)_dispatchShow;
-- (WebPolicyDecider *)_createPolicyDeciderWithTarget:(id)target action:(SEL)action;
-- (void)_dispatchDecidePolicyForMIMEType:(NSString *)MIMEType request:(NSURLRequest *)request decider:(WebPolicyDecider *)decider;
-- (void)_dispatchDecidePolicyForNewWindowAction:(NSDictionary *)action request:(NSURLRequest *)request newFrameName:(NSString *)frameName decider:(WebPolicyDecider *)decider;
-- (void)_dispatchDecidePolicyForNavigationAction:(NSDictionary *)action request:(NSURLRequest *)request decider:(WebPolicyDecider *)decider;
-- (void)_dispatchUnableToImplementPolicyWithError:(NSError *)error;
-- (void)_dispatchSourceFrame:(WebCore::Frame*)sourceFrame willSubmitForm:(WebCore::Element*)form withValues:(NSDictionary *)values submissionDecider:(WebPolicyDecider *)decider;
-- (void)_detachedFromParent1;
-- (void)_detachedFromParent2;
-- (void)_detachedFromParent3;
-- (void)_detachedFromParent4;
-- (void)_updateHistoryAfterClientRedirect;
-- (void)_loadedFromPageCache;
-- (void)_downloadWithLoadingConnection:(NSURLConnection *)connection request:(NSURLRequest *)request response:(NSURLResponse *)response proxy:(id)proxy;
-- (void)_setDocumentViewFromPageCache:(NSDictionary *)pageCache;
-- (void)_setCopiesOnScroll;
-- (void)_dispatchDidLoadMainResourceForDocumentLoader:(WebCore::DocumentLoader*)loader;
-- (void)_forceLayoutForNonHTML;
-- (void)_clearLoadingFromPageCacheForDocumentLoader:(WebCore::DocumentLoader*)loader;
-- (BOOL)_isDocumentLoaderLoadingFromPageCache:(WebCore::DocumentLoader*)loader;
-- (void)_makeRepresentationForDocumentLoader:(WebCore::DocumentLoader*)loader;
-- (void)_revertToProvisionalStateForDocumentLoader:(WebCore::DocumentLoader*)loader;
-- (void)_setMainDocumentError:(NSError *)error forDocumentLoader:(WebCore::DocumentLoader*)loader;
-- (void)_clearUnarchivingStateForLoader:(WebCore::DocumentLoader*)loader;
-- (void)_progressStarted;
-- (void)_progressCompleted;
-- (void)_incrementProgressForIdentifier:(id)identifier response:(NSURLResponse *)response;
-- (void)_incrementProgressForIdentifier:(id)identifier data:(NSData *)data;
-- (void)_completeProgressForIdentifier:(id)identifier;
-- (void)_setMainFrameDocumentReady:(BOOL)ready;
-- (void)_willChangeTitleForDocument:(WebCore::DocumentLoader*)loader;
-- (void)_didChangeTitleForDocument:(WebCore::DocumentLoader*)loader;
-- (void)_startDownloadWithRequest:(NSURLRequest *)request;
-- (void)_finishedLoadingDocument:(WebCore::DocumentLoader*)loader;
-- (void)_committedLoadWithDocumentLoader:(WebCore::DocumentLoader*)loader data:(NSData *)data;
-- (void)_documentLoader:(WebCore::DocumentLoader*)loader setMainDocumentError:(NSError *)error;
-- (void)_finalSetupForReplaceWithDocumentLoader:(WebCore::DocumentLoader*)loader;
-- (NSError *)_cancelledErrorWithRequest:(NSURLRequest *)request;
-- (NSError *)_cannotShowURLErrorWithRequest:(NSURLRequest *)request;
-- (NSError *)_interruptForPolicyChangeErrorWithRequest:(NSURLRequest *)request;
-- (NSError *)_cannotShowMIMETypeErrorWithResponse:(NSURLResponse *)response;
-- (NSError *)_fileDoesNotExistErrorWithResponse:(NSURLResponse *)response;
-- (BOOL)_shouldFallBackForError:(NSError *)error;
-- (BOOL)_hasWebView;
-- (BOOL)_hasFrameView;
-- (NSURL *)_mainFrameURL;
-- (BOOL)_canUseResourceForRequest:(NSURLRequest *)request;
-- (BOOL)_canUseResourceWithResponse:(NSURLResponse *)response;
-- (void)_deliverArchivedResourcesAfterDelay;
-- (BOOL)_willUseArchiveForRequest:(NSURLRequest *)r originalURL:(NSURL *)originalURL loader:(WebCore::WebResourceLoader*)loader;
-- (BOOL)_archiveLoadPendingForLoader:(WebCore::WebResourceLoader*)loader;
-- (void)_cancelPendingArchiveLoadForLoader:(WebCore::WebResourceLoader*)loader;
-- (void)_clearArchivedResources;
-- (void)_deliverArchivedResources;
-- (void)_setDefersCallbacks:(BOOL)defers;
-- (BOOL)_canHandleRequest:(NSURLRequest *)request;
-- (BOOL)_canShowMIMEType:(NSString *)MIMEType;
-- (BOOL)_representationExistsForURLScheme:(NSString *)URLScheme;
-- (NSString *)_generatedMIMETypeForURLScheme:(NSString *)URLScheme;
-- (NSDictionary *)_elementForEvent:(NSEvent *)event;
-- (void)_frameLoadCompleted;
-- (void)_restoreScrollPositionAndViewState;
-- (void)_setTitle:(NSString *)title forURL:(NSURL *)URL;
-- (PassRefPtr<WebCore::DocumentLoader>)_createDocumentLoaderWithRequest:(NSURLRequest *)request;
-- (void)_prepareForDataSourceReplacement;
-- (void)_didFinishLoad;
-- (void)_addHistoryItemForFragmentScroll;
-- (BOOL)_shouldTreatURLAsSameAsCurrent:(NSURL *)URL;
-- (void)_provisionalLoadStarted;
+- (void)_addBackForwardItemClippedAtTarget:(BOOL)doClip;
-@end
+- (WebHistoryItem *)_createItem:(BOOL)useOriginal;
-#endif
+@end
@interface NSObject (WebInternalFrameLoadDelegate)
- (void)webFrame:(WebFrame *)webFrame didFinishLoadWithError:(NSError *)error;
- (WebHTMLView *)_topHTMLView
{
WebHTMLView *view = (WebHTMLView *)[[[[_private->dataSource _webView] mainFrame] frameView] documentView];
+ ASSERT(view);
ASSERT([view isKindOfClass:[WebHTMLView class]]);
return view;
}
#import <WebKit/WebHTMLView.h>
@class DOMDocumentFragment;
+@class DOMNode;
@class DOMRange;
@class WebArchive;
@class WebFrameBridge;