Commit 05011d70 authored by mjs's avatar mjs
Browse files

Reviewed by Geoff.

        
        <rdar://problem/5205358> REGRESSION (r21367): All messages appear entirely blank when running Mail off of tip of tree WebKit
        
        The fix is to return nil from [WebFrame dataSource] when it has not loaded anything but the fake
        empty initial document. However, WebKit still needs the real data source internally, so I also
        added a [WebFrame _dataSource] method that skips this check, and made WebKit use it throughout.

        * Misc/WebNSAttributedStringExtras.mm:
        (fileWrapperForElement):
        * Plugins/WebBaseNetscapePluginView.mm:
        (-[WebBaseNetscapePluginView dataSource]):
        * Plugins/WebNullPluginView.mm:
        (-[WebNullPluginView viewDidMoveToWindow]):
        * Plugins/WebPluginController.mm:
        (-[WebPluginController URLPolicyCheckReferrer]):
        * WebCoreSupport/WebFrameBridge.mm:
        (-[WebFrameBridge dataSource]):
        (-[WebFrameBridge redirectDataToPlugin:]):
        * WebCoreSupport/WebFrameLoaderClient.mm:
        (WebFrameLoaderClient::makeDocumentView):
        (WebFrameLoaderClient::forceLayoutForNonHTML):
        (WebFrameLoaderClient::prepareForDataSourceReplacement):
        (WebFrameLoaderClient::canCachePage):
        * WebCoreSupport/WebViewFactory.mm:
        (-[WebViewFactory bridgeForView:]):
        * WebKit.xcodeproj/project.pbxproj:
        * WebView/WebArchiver.mm:
        (+[WebArchiver archiveFrame:]):
        (+[WebArchiver archiveMainResourceForFrame:]):
        (+[WebArchiver _archiveWithMarkupString:fromFrame:nodes:]):
        (+[WebArchiver archiveSelectionInFrame:]):
        * WebView/WebFrame.mm:
        (-[WebFrame _loadURL:referrer:intoChild:]):
        (-[WebFrame _addChild:]):
        (-[WebFrame _dataSource]):
        (-[WebFrame DOMDocument]):
        (-[WebFrame dataSource]):
        * WebView/WebFrameInternal.h:
        * WebView/WebHTMLView.mm:
        (-[WebHTMLView _setPrinting:minimumPageWidth:maximumPageWidth:adjustViewSize:]):
        * WebView/WebRenderNode.mm:
        (-[WebRenderNode initWithWebFrameView:]):
        * WebView/WebView.mm:
        (-[WebView _mainFrameOverrideEncoding]):
        (-[WebView mainFrameURL]):
        (-[WebView mainFrameTitle]):
        (-[WebView mainFrameIcon]):
        (-[WebView validateUserInterfaceItemWithoutDelegate:]):
        (-[WebView replaceSelectionWithArchive:]):
        (-[WebView _isLoading]):
        (-[WebView _performTextSizingSelector:withObject:onTrackingDocs:selForNonTrackingDocs:newScaleFactor:]):
        (-[WebView _notifyTextSizeMultiplierChanged]):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@21618 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 60ada7c5
2007-05-19 Maciej Stachowiak <mjs@apple.com>
Reviewed by Geoff.
<rdar://problem/5205358> REGRESSION (r21367): All messages appear entirely blank when running Mail off of tip of tree WebKit
The fix is to return nil from [WebFrame dataSource] when it has not loaded anything but the fake
empty initial document. However, WebKit still needs the real data source internally, so I also
added a [WebFrame _dataSource] method that skips this check, and made WebKit use it throughout.
* Misc/WebNSAttributedStringExtras.mm:
(fileWrapperForElement):
* Plugins/WebBaseNetscapePluginView.mm:
(-[WebBaseNetscapePluginView dataSource]):
* Plugins/WebNullPluginView.mm:
(-[WebNullPluginView viewDidMoveToWindow]):
* Plugins/WebPluginController.mm:
(-[WebPluginController URLPolicyCheckReferrer]):
* WebCoreSupport/WebFrameBridge.mm:
(-[WebFrameBridge dataSource]):
(-[WebFrameBridge redirectDataToPlugin:]):
* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::makeDocumentView):
(WebFrameLoaderClient::forceLayoutForNonHTML):
(WebFrameLoaderClient::prepareForDataSourceReplacement):
(WebFrameLoaderClient::canCachePage):
* WebCoreSupport/WebViewFactory.mm:
(-[WebViewFactory bridgeForView:]):
* WebKit.xcodeproj/project.pbxproj:
* WebView/WebArchiver.mm:
(+[WebArchiver archiveFrame:]):
(+[WebArchiver archiveMainResourceForFrame:]):
(+[WebArchiver _archiveWithMarkupString:fromFrame:nodes:]):
(+[WebArchiver archiveSelectionInFrame:]):
* WebView/WebFrame.mm:
(-[WebFrame _loadURL:referrer:intoChild:]):
(-[WebFrame _addChild:]):
(-[WebFrame _dataSource]):
(-[WebFrame DOMDocument]):
(-[WebFrame dataSource]):
* WebView/WebFrameInternal.h:
* WebView/WebHTMLView.mm:
(-[WebHTMLView _setPrinting:minimumPageWidth:maximumPageWidth:adjustViewSize:]):
* WebView/WebRenderNode.mm:
(-[WebRenderNode initWithWebFrameView:]):
* WebView/WebView.mm:
(-[WebView _mainFrameOverrideEncoding]):
(-[WebView mainFrameURL]):
(-[WebView mainFrameTitle]):
(-[WebView mainFrameIcon]):
(-[WebView validateUserInterfaceItemWithoutDelegate:]):
(-[WebView replaceSelectionWithArchive:]):
(-[WebView _isLoading]):
(-[WebView _performTextSizingSelector:withObject:onTrackingDocs:selForNonTrackingDocs:newScaleFactor:]):
(-[WebView _notifyTextSizeMultiplierChanged]):
2007-05-18 Oliver Hunt <oliver@apple.com>
 
Reviewed by Sam.
......
......@@ -94,7 +94,7 @@ static NSFileWrapper *fileWrapperForElement(Element* e)
const AtomicString& attr = e->getAttribute(srcAttr);
if (!attr.isEmpty()) {
NSURL *URL = KURL(e->document()->completeURL(attr.deprecatedString())).getNSURL();
wrapper = [[kit(e->document()->frame()) dataSource] _fileWrapperForURL:URL];
wrapper = [[kit(e->document()->frame()) _dataSource] _fileWrapperForURL:URL];
}
if (!wrapper) {
RenderImage* renderer = static_cast<RenderImage*>(e->renderer());
......
......@@ -1447,7 +1447,7 @@ static OSStatus TSMEventHandler(EventHandlerCallRef inHandlerRef, EventRef inEve
- (WebDataSource *)dataSource
{
WebFrame *webFrame = kit(core(element)->document()->frame());
return [webFrame dataSource];
return [webFrame _dataSource];
}
- (WebFrame *)webFrame
......
......@@ -75,7 +75,7 @@ static NSImage *image = nil;
didSendError = YES;
WebFrame *webFrame = kit(core(element)->document()->frame());
WebView *webView = [webFrame webView];
WebDataSource *dataSource = [webFrame dataSource];
WebDataSource *dataSource = [webFrame _dataSource];
id resourceLoadDelegate = [webView resourceLoadDelegate];
if ([resourceLoadDelegate respondsToSelector:@selector(webView:plugInFailedWithError:dataSource:)])
......
......@@ -379,7 +379,7 @@ static void cancelOutstandingCheck(const void *item, void *context)
- (NSString *)URLPolicyCheckReferrer
{
NSURL *responseURL = [[[[self webFrame] dataSource] response] URL];
NSURL *responseURL = [[[[self webFrame] _dataSource] response] URL];
ASSERT(responseURL);
return [responseURL _web_originalDataAsString];
}
......
......@@ -321,7 +321,7 @@ NSString *WebPluginContainerKey = @"WebPluginContainer";
- (WebDataSource *)dataSource
{
ASSERT(_frame != nil);
WebDataSource *dataSource = [_frame dataSource];
WebDataSource *dataSource = [_frame _dataSource];
ASSERT(dataSource != nil);
......@@ -530,7 +530,7 @@ NSString *WebPluginContainerKey = @"WebPluginContainer";
- (void)redirectDataToPlugin:(NSView *)pluginView
{
WebHTMLRepresentation *representation = (WebHTMLRepresentation *)[[_frame dataSource] representation];
WebHTMLRepresentation *representation = (WebHTMLRepresentation *)[[_frame _dataSource] representation];
if ([pluginView isKindOfClass:[WebNetscapePluginEmbeddedView class]])
[representation _redirectDataToManualLoader:(WebNetscapePluginEmbeddedView *)pluginView forPluginView:pluginView];
......
......@@ -159,7 +159,7 @@ bool WebFrameLoaderClient::privateBrowsingEnabled() const
void WebFrameLoaderClient::makeDocumentView()
{
WebFrameView *v = m_webFrame->_private->webFrameView;
WebDataSource *ds = [m_webFrame.get() dataSource];
WebDataSource *ds = [m_webFrame.get() _dataSource];
NSView <WebDocumentView> *documentView = [v _makeDocumentViewForDataSource:ds];
if (!documentView)
......@@ -210,7 +210,7 @@ void WebFrameLoaderClient::forceLayoutForNonHTML()
// 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])) {
if (!([[m_webFrame.get() _dataSource] _isDocumentHTML])) {
[thisDocumentView setNeedsLayout:YES];
[thisDocumentView layout];
[thisDocumentView setNeedsDisplay:YES];
......@@ -954,7 +954,7 @@ void WebFrameLoaderClient::didFinishLoad()
void WebFrameLoaderClient::prepareForDataSourceReplacement()
{
if (![m_webFrame.get() dataSource]) {
if (![m_webFrame.get() _dataSource]) {
ASSERT(!core(m_webFrame.get())->tree()->childCount());
return;
}
......@@ -1147,7 +1147,7 @@ NSDictionary *WebFrameLoaderClient::actionDictionary(const NavigationAction& act
bool WebFrameLoaderClient::canCachePage() const
{
// We can only cache HTML pages right now
return [[[m_webFrame.get() dataSource] representation] isKindOfClass:[WebHTMLRepresentation class]];
return [[[m_webFrame.get() _dataSource] representation] isKindOfClass:[WebHTMLRepresentation class]];
}
Frame* WebFrameLoaderClient::createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement,
......
......@@ -90,7 +90,7 @@
while (aView) {
if ([aView isKindOfClass:[WebHTMLView class]]) {
return [[[(WebHTMLView *)aView _frame] dataSource] _bridge];
return [[[(WebHTMLView *)aView _frame] _dataSource] _bridge];
}
aView = [aView superview];
}
......
......@@ -1317,6 +1317,7 @@
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 149C283208902B0F008A9EFC /* Build configuration list for PBXProject "WebKit" */;
compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
knownRegions = (
English,
......@@ -1331,6 +1332,7 @@
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
projectDirPath = "";
projectRoot = "";
shouldCheckCompatibility = 1;
targets = (
9398100A0824BF01008DF038 /* WebKit */,
);
......
......@@ -61,14 +61,14 @@ using namespace WebCore;
+ (WebArchive *)archiveFrame:(WebFrame *)frame;
{
return [[[WebArchive alloc] initWithMainResource:[[frame dataSource] mainResource]
subresources:[[frame dataSource] subresources]
return [[[WebArchive alloc] initWithMainResource:[[frame _dataSource] mainResource]
subresources:[[frame _dataSource] subresources]
subframeArchives:[self _subframeArchivesForFrame:frame]] autorelease];
}
+ (WebArchive *)archiveMainResourceForFrame:(WebFrame *)frame;
{
return [[[WebArchive alloc] initWithMainResource:[[frame dataSource] mainResource]
return [[[WebArchive alloc] initWithMainResource:[[frame _dataSource] mainResource]
subresources:nil
subframeArchives:nil] autorelease];
}
......@@ -83,7 +83,7 @@ using namespace WebCore;
+ (WebArchive *)_archiveWithMarkupString:(NSString *)markupString fromFrame:(WebFrame *)frame nodes:(NSArray *)nodes
{
NSURLResponse *response = [[frame dataSource] response];
NSURLResponse *response = [[frame _dataSource] response];
WebResource *mainResource = [[WebResource alloc] initWithData:[markupString dataUsingEncoding:NSUTF8StringEncoding]
URL:[response URL]
MIMEType:[response MIMEType]
......@@ -109,7 +109,7 @@ using namespace WebCore;
if ([uniqueSubresources containsObject:URL])
continue;
[uniqueSubresources addObject:URL];
WebResource *subresource = [[frame dataSource] subresourceForURL:URL];
WebResource *subresource = [[frame _dataSource] subresourceForURL:URL];
if (subresource)
[subresources addObject:subresource];
else
......@@ -161,7 +161,7 @@ using namespace WebCore;
// Wrap the frameset document in an iframe so it can be pasted into
// another document (which will have a body or frameset of its own).
NSString *iframeMarkup = [[NSString alloc] initWithFormat:@"<iframe frameborder=\"no\" marginwidth=\"0\" marginheight=\"0\" width=\"98%%\" height=\"98%%\" src=\"%@\"></iframe>", [[[frame dataSource] response] URL]];
NSString *iframeMarkup = [[NSString alloc] initWithFormat:@"<iframe frameborder=\"no\" marginwidth=\"0\" marginheight=\"0\" width=\"98%%\" height=\"98%%\" src=\"%@\"></iframe>", [[[frame _dataSource] response] URL]];
WebResource *iframeResource = [[WebResource alloc] initWithData:[iframeMarkup dataUsingEncoding:NSUTF8StringEncoding]
URL:[NSURL URLWithString:@"about:blank"]
MIMEType:@"text/html"
......
......@@ -320,7 +320,7 @@ WebView *getWebView(WebFrame *webFrame)
}
}
WebArchive *archive = [[self dataSource] _popSubframeArchiveWithName:[childFrame name]];
WebArchive *archive = [[self _dataSource] _popSubframeArchiveWithName:[childFrame name]];
if (archive)
[childFrame loadArchive:archive];
else
......@@ -346,8 +346,8 @@ WebView *getWebView(WebFrame *webFrame)
- (void)_addChild:(WebFrame *)child
{
core(self)->tree()->appendChild(adoptRef(core(child)));
if ([child dataSource])
[[child dataSource] _documentLoader]->setOverrideEncoding([[self dataSource] _documentLoader]->overrideEncoding());
if ([child _dataSource])
[[child _dataSource] _documentLoader]->setOverrideEncoding([[self _dataSource] _documentLoader]->overrideEncoding());
}
- (int)_numPendingOrLoadingRequests:(BOOL)recurse
......@@ -574,6 +574,16 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
[dataSource(loader) _addToUnarchiveState:archive];
}
- (WebDataSource *)_dataSource
{
FrameLoader* frameLoader = [self _frameLoader];
if (!frameLoader)
return nil;
return dataSource(frameLoader->documentLoader());
}
@end
@implementation WebFrame (WebPrivate)
......@@ -735,7 +745,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
// FIXME: <rdar://problem/5145841> When loading a custom view/representation
// into a web frame, the old document can still be around. This makes sure that
// we'll return nil in those cases.
if (![[self dataSource] _isDocumentHTML])
if (![[self _dataSource] _isDocumentHTML])
return nil;
Document* document = coreFrame->document();
......@@ -765,8 +775,10 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
- (WebDataSource *)dataSource
{
FrameLoader* frameLoader = [self _frameLoader];
return frameLoader ? dataSource(frameLoader->documentLoader()) : nil;
if (![self _frameLoader]->frameHasLoaded())
return nil;
return [self _dataSource];
}
- (void)loadRequest:(NSURLRequest *)request
......
......@@ -164,6 +164,12 @@ struct WebCoreHistoryItem;
- (void)_attachScriptDebugger;
- (void)_detachScriptDebugger;
// dataSource reports null for the initial empty document's data source; this is needed
// to preserve compatibility with Mail and Safari among others. But internal to WebKit,
// we need to be able to get the initial data source as well, so the _dataSource method
// should be used instead.
- (WebDataSource *)_dataSource;
@end
@interface NSObject (WebInternalFrameLoadDelegate)
......
......@@ -3087,7 +3087,7 @@ noPromisedData:
for (i = 0; i != n; ++i) {
WebFrame *subframe = [subframes objectAtIndex:i];
WebFrameView *frameView = [subframe frameView];
if ([[subframe dataSource] _isDocumentHTML]) {
if ([[subframe _dataSource] _isDocumentHTML]) {
[(WebHTMLView *)[frameView documentView] _setPrinting:printing minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:adjustViewSize];
}
}
......
......@@ -33,6 +33,7 @@
#import <WebKit/WebHTMLView.h>
#import <WebKit/WebDataSourceInternal.h>
#import <WebKit/WebNSViewExtras.h>
#import "WebFrameInternal.h"
@interface WebKitRenderTreeCopier : NSObject <WebCoreRenderTreeCopier>
@end
......@@ -81,7 +82,7 @@
}
copier = [[WebKitRenderTreeCopier alloc] init];
self = [[[[[view webFrame] dataSource] _bridge] copyRenderTree:copier] retain];
self = [[[[[view webFrame] _dataSource] _bridge] copyRenderTree:copier] retain];
[copier release];
return self;
......
......@@ -2163,7 +2163,7 @@ NS_ENDHANDLER
{
WebDataSource *dataSource = [[self mainFrame] provisionalDataSource];
if (dataSource == nil)
dataSource = [[self mainFrame] dataSource];
dataSource = [[self mainFrame] _dataSource];
if (dataSource == nil)
return nil;
return [dataSource _documentLoader]->overrideEncoding();
......@@ -2487,7 +2487,7 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
WebDataSource *ds;
ds = [[self mainFrame] provisionalDataSource];
if (!ds)
ds = [[self mainFrame] dataSource];
ds = [[self mainFrame] _dataSource];
return [[[ds request] URL] _web_originalDataAsString];
}
......@@ -2499,13 +2499,13 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
- (NSString *)mainFrameTitle
{
NSString *mainFrameTitle = [[[self mainFrame] dataSource] pageTitle];
NSString *mainFrameTitle = [[[self mainFrame] _dataSource] pageTitle];
return (mainFrameTitle != nil) ? mainFrameTitle : (NSString *)@"";
}
- (NSImage *)mainFrameIcon
{
return [[WebIconDatabase sharedIconDatabase] iconForURL:[[[[self mainFrame] dataSource] _URL] _web_originalDataAsString] withSize:WebIconSmallSize];
return [[WebIconDatabase sharedIconDatabase] iconForURL:[[[[self mainFrame] _dataSource] _URL] _web_originalDataAsString] withSize:WebIconSmallSize];
}
- (DOMDocument *)mainFrameDocument
......@@ -2683,7 +2683,7 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
} else if (action == @selector(makeTextStandardSize:)) {
return [self canMakeTextStandardSize];
} else if (action == @selector(reload:)) {
return [[self mainFrame] dataSource] != nil;
return [[self mainFrame] _dataSource] != nil;
} else if (action == @selector(stopLoading:)) {
return [self _isLoading];
} else if (action == @selector(toggleContinuousSpellChecking:)) {
......@@ -3370,7 +3370,7 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
- (void)replaceSelectionWithArchive:(WebArchive *)archive
{
[[[[self _bridgeForSelectedOrMainFrame] webFrame] dataSource] _replaceSelectionWithArchive:archive selectReplacement:YES];
[[[[self _bridgeForSelectedOrMainFrame] webFrame] _dataSource] _replaceSelectionWithArchive:archive selectReplacement:YES];
}
- (void)deleteSelection
......@@ -3494,7 +3494,7 @@ static WebFrameView *containingFrameView(NSView *view)
- (BOOL)_isLoading
{
WebFrame *mainFrame = [self mainFrame];
return [[mainFrame dataSource] isLoading]
return [[mainFrame _dataSource] isLoading]
|| [[mainFrame provisionalDataSource] isLoading];
}
......@@ -3608,7 +3608,7 @@ static WebFrameView *containingFrameView(NSView *view)
// to that new factor before we send sel to any of them.
- (BOOL)_performTextSizingSelector:(SEL)sel withObject:(id)arg onTrackingDocs:(BOOL)doTrackingViews selForNonTrackingDocs:(SEL)testSel newScaleFactor:(float)newScaleFactor
{
if ([[self mainFrame] dataSource] == nil)
if ([[self mainFrame] _dataSource] == nil)
return NO;
BOOL foundSome = NO;
......@@ -3644,7 +3644,7 @@ static WebFrameView *containingFrameView(NSView *view)
- (void)_notifyTextSizeMultiplierChanged
{
if ([[self mainFrame] dataSource] == nil)
if ([[self mainFrame] _dataSource] == nil)
return;
NSArray *docViews = [[self mainFrame] _documentViews];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment