Commit 6b709be4 authored by mjs's avatar mjs

WebCore:

        Reviewed by Eric.

        - finished frame traversal cleanup
        http://bugzilla.opendarwin.org/show_bug.cgi?id=6293

        * kwq/WebCoreBridge.h: Removed childFrames method from WebCoreBridge protocol
	since it is not actually used.

WebKit:

        Reviewed by Eric.

        - finished frame traversal cleanup
        http://bugzilla.opendarwin.org/show_bug.cgi?id=6293

        * WebCoreSupport.subproj/WebBridge.m:
        (-[WebBridge childFrames]): Removed (this was unused)
        * WebView.subproj/WebFrame.m:
        (-[WebFrame _removeChild::]): Moved to FrameTraversal category.
        (-[WebFrame _childFrameCount]): New frame traversal method to avoid
	getting the count from the array directly.
        (-[WebFrame _appendChild:]): Factored out the parts of addChild: that
	seem directly relevant to adding a child.
        (-[WebFrame _removeChild:]): Moved to FrameTraversal category.
        (-[WebFrame _detachChildren]): Don't deallocate children array because
	there's no particular need to.
        (-[WebFrame _setDataSource:]): make the assert use _childFrameCount
        (-[WebFrame _opened]):
        (-[WebFrame _checkLoadComplete]): Instead of checking all frames starting
	from the main frame, check this frame and all ancestors. If a resource
	for a frame completes, that con only possibly finish loading for that
	frame and its ancestors, not any other frame in the tree.
	(-[WebFrame _recursiveCheckLoadComplete]): Removed, no longer needed.
        (-[WebFrame _childFramesMatchItem:]): Get child frame count in the new
	approved way.
        (-[WebFrame _internalChildFrames]): removed
	(-[WebFrame _addChild:]): Use _appendChild: for most of the work.
        (-[WebFrame _generateFrameName]): Get child frame count in the new
	approved way.
        (-[WebFrame _stopLoadingSubframes]): Use new frame traversal mechanisms,
	upon further consideration there's no need to copy part of the frame tree here.
        (-[WebFrame findFrameNamed:]): Remove extra braces.
        (-[WebFrame childFrames]): Make a new array using the frame traversal methods.
        * WebView.subproj/WebFramePrivate.h: Remove some methods.
        * WebView.subproj/WebMainResourceLoader.m:
        (-[WebMainResourceLoader didReceiveResponse:]): Do _checkLoadComplete on the current
	frame not the main frame (before there was no difference and now the new version is
	what is desired).
        * WebView.subproj/WebView.m:
        (-[WebView _finishedLoadingResourceFromDataSource:]): Remove stray space
        (-[WebView _mainReceivedBytesSoFar:fromDataSource:complete:]): Remove stray spaces
	and update FIXME comment.
        (-[WebView _receivedError:fromDataSource:]): Remove stray space


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@11819 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 07480eea
2005-12-29 Maciej Stachowiak <mjs@apple.com>
Reviewed by Eric.
- finished frame traversal cleanup
http://bugzilla.opendarwin.org/show_bug.cgi?id=6293
* kwq/WebCoreBridge.h: Removed childFrames method from WebCoreBridge protocol
since it is not actually used.
2005-12-29 Eric Seidel <eseidel@apple.com>
File accidentally omitted from previous commit.
......
......@@ -468,7 +468,6 @@ typedef enum
@protocol WebCoreBridge
- (NSArray *)childFrames; // WebCoreBridge objects
- (WebCoreBridge *)mainFrame;
- (WebCoreBridge *)findFrameNamed:(NSString *)name;
/* Creates a name for an frame unnamed in the HTML. It should produce repeatable results for loads of the same frameset. */
......
2005-12-29 Maciej Stachowiak <mjs@apple.com>
Reviewed by Eric.
- finished frame traversal cleanup
http://bugzilla.opendarwin.org/show_bug.cgi?id=6293
* WebCoreSupport.subproj/WebBridge.m:
(-[WebBridge childFrames]): Removed (this was unused)
* WebView.subproj/WebFrame.m:
(-[WebFrame _removeChild::]): Moved to FrameTraversal category.
(-[WebFrame _childFrameCount]): New frame traversal method to avoid
getting the count from the array directly.
(-[WebFrame _appendChild:]): Factored out the parts of addChild: that
seem directly relevant to adding a child.
(-[WebFrame _removeChild:]): Moved to FrameTraversal category.
(-[WebFrame _detachChildren]): Don't deallocate children array because
there's no particular need to.
(-[WebFrame _setDataSource:]): make the assert use _childFrameCount
(-[WebFrame _opened]):
(-[WebFrame _checkLoadComplete]): Instead of checking all frames starting
from the main frame, check this frame and all ancestors. If a resource
for a frame completes, that con only possibly finish loading for that
frame and its ancestors, not any other frame in the tree.
(-[WebFrame _recursiveCheckLoadComplete]): Removed, no longer needed.
(-[WebFrame _childFramesMatchItem:]): Get child frame count in the new
approved way.
(-[WebFrame _internalChildFrames]): removed
(-[WebFrame _addChild:]): Use _appendChild: for most of the work.
(-[WebFrame _generateFrameName]): Get child frame count in the new
approved way.
(-[WebFrame _stopLoadingSubframes]): Use new frame traversal mechanisms,
upon further consideration there's no need to copy part of the frame tree here.
(-[WebFrame findFrameNamed:]): Remove extra braces.
(-[WebFrame childFrames]): Make a new array using the frame traversal methods.
* WebView.subproj/WebFramePrivate.h: Remove some methods.
* WebView.subproj/WebMainResourceLoader.m:
(-[WebMainResourceLoader didReceiveResponse:]): Do _checkLoadComplete on the current
frame not the main frame (before there was no difference and now the new version is
what is desired).
* WebView.subproj/WebView.m:
(-[WebView _finishedLoadingResourceFromDataSource:]): Remove stray space
(-[WebView _mainReceivedBytesSoFar:fromDataSource:complete:]): Remove stray spaces
and update FIXME comment.
(-[WebView _receivedError:fromDataSource:]): Remove stray space
2005-12-29 Maciej Stachowiak <mjs@apple.com>
Reviewed by Darin.
......@@ -168,21 +168,6 @@ - (WebFrame *)webFrame
return _frame;
}
- (NSArray *)childFrames
{
ASSERT(_frame != nil);
NSArray *frames = [_frame childFrames];
NSEnumerator *e = [frames objectEnumerator];
NSMutableArray *frameBridges = [NSMutableArray arrayWithCapacity:[frames count]];
WebFrame *childFrame;
while ((childFrame = [e nextObject])) {
id frameBridge = [childFrame _bridge];
if (frameBridge)
[frameBridges addObject:frameBridge];
}
return frameBridges;
}
- (WebCoreBridge *)mainFrame
{
ASSERT(_frame != nil);
......
......@@ -191,9 +191,12 @@ - (void)_stopLoadingSubframes;
@interface WebFrame (FrameTraversal)
- (WebFrame *)_firstChildFrame;
- (WebFrame *)_lastChildFrame;
- (unsigned)_childFrameCount;
- (WebFrame *)_previousSiblingFrame;
- (WebFrame *)_nextSiblingFrame;
- (WebFrame *)_traverseNextFrameStayWithin:(WebFrame *)stayWithin;
- (void)_appendChild:(WebFrame *)child;
- (void)_removeChild:(WebFrame *)child;
@end
@interface WebFramePrivate : NSObject
......@@ -386,6 +389,11 @@ - (WebFrame *)_lastChildFrame
return [_private->children lastObject];
}
- (unsigned)_childFrameCount
{
return [_private->children count];
}
- (WebFrame *)_previousSiblingFrame;
{
return _private->previousSibling;
......@@ -427,6 +435,39 @@ - (WebFrame *)_traverseNextFrameStayWithin:(WebFrame *)stayWithin
return nil;
}
- (void)_appendChild:(WebFrame *)child
{
[[child _bridge] setParent:_private->bridge];
if (_private->children == nil)
_private->children = [[NSMutableArray alloc] init];
WebFrame *previousFrame = [self _lastChildFrame];
if (previousFrame) {
previousFrame->_private->nextSibling = child;
child->_private->previousSibling = previousFrame;
}
ASSERT(child->_private->nextSibling == nil);
[_private->children addObject:child];
}
- (void)_removeChild:(WebFrame *)child
{
// move corresponding previous and next WebFrame sibling pointers to their new positions
// when we remove a child we may have to reattach the previous frame's next frame and visa versa
if (child->_private->previousSibling)
child->_private->previousSibling->_private->nextSibling = child->_private->nextSibling;
if (child->_private->nextSibling)
child->_private->nextSibling->_private->previousSibling = child->_private->previousSibling;
child->_private->previousSibling = nil;
child->_private->nextSibling = nil;
[_private->children removeObject:child];
}
@end
@implementation WebFrame (WebPrivate)
......@@ -633,9 +674,6 @@ - (void)_detachChildren
WebFrame *prev = [child _previousSiblingFrame];
for (; child; child = prev, prev = [child _previousSiblingFrame])
[child _detachFromParent];
[_private->children release];
_private->children = nil;
}
- (void)_closeOldDataSources
......@@ -713,7 +751,7 @@ - (void)_setDataSource:(WebDataSource *)ds
[_private->dataSource _setWebFrame:nil];
} else {
ASSERT(!_private->children);
ASSERT(![self _childFrameCount]);
}
[_private setDataSource:ds];
......@@ -1140,6 +1178,7 @@ - (void)_opened
[[_private currentItem] setHasPageCache: NO];
[[self dataSource] _setPrimaryLoadComplete: YES];
// why only this frame and not parent frames?
[self _checkLoadCompleteForThisFrame];
}
}
......@@ -1297,22 +1336,13 @@ - (void)_handledOnloadEvents
[[[self webView] _frameLoadDelegateForwarder] webView:_private->webView didHandleOnloadEventsForFrame:self];
}
- (void)_recursiveCheckLoadComplete
{
// Checking for load complete may indeed alter the set of child
// frames. However, _web_safeMakeObjectsPerformSelector: makes
// sure to copy the array so it is safe against changes.
[[self _internalChildFrames] _web_safeMakeObjectsPerformSelector:@selector(_recursiveCheckLoadComplete)];
[self _checkLoadCompleteForThisFrame];
}
// Called every time a resource is completely loaded, or an error is received.
- (void)_checkLoadComplete
{
ASSERT([self webView] != nil);
// Now walk the frame tree to see if any frame that may have initiated a load is done.
[[[self webView] mainFrame] _recursiveCheckLoadComplete];
for (WebFrame *frame = self; frame; frame = [frame parentFrame])
[frame _checkLoadCompleteForThisFrame];
}
- (WebBridge *)_bridge
......@@ -1340,7 +1370,7 @@ - (BOOL)_childFramesMatchItem:(WebHistoryItem *)item
{
NSArray *childItems = [item children];
int numChildItems = [childItems count];
int numChildFrames = [_private->children count];
int numChildFrames = [self _childFrameCount];
if (numChildFrames != numChildItems)
return NO;
......@@ -2240,39 +2270,8 @@ - (void)_reloadAllowingStaleDataWithOverrideEncoding:(NSString *)encoding
- (void)_addChild:(WebFrame *)child
{
if (_private->children == nil)
_private->children = [[NSMutableArray alloc] init];
[_private->children addObject:child];
[[child _bridge] setParent:_private->bridge];
[self _appendChild:child];
[[child dataSource] _setOverrideEncoding:[[self dataSource] _overrideEncoding]];
unsigned currentIndex = [_private->children count] - 1;
// we keep track of sibling pointers to avoid the overhead of a lookup in the children array
if (currentIndex > 0) {
WebFrame *previousFrame = [_private->children objectAtIndex:currentIndex - 1];
previousFrame->_private->nextSibling = child;
child->_private->previousSibling = previousFrame;
ASSERT(child->_private->nextSibling == nil);
}
}
- (void)_removeChild:(WebFrame *)child
{
// move corresponding previous and next WebFrame sibling pointers to their new positions
// when we remove a child we may have to reattach the previous frame's next frame and visa versa
if (child->_private->previousSibling)
child->_private->previousSibling->_private->nextSibling = child->_private->nextSibling;
if (child->_private->nextSibling)
child->_private->nextSibling->_private->previousSibling = child->_private->previousSibling;
child->_private->previousSibling = nil;
child->_private->nextSibling = nil;
[_private->children removeObject:child];
}
- (void)_addFramePathToString:(NSMutableString *)path
......@@ -2303,7 +2302,7 @@ - (NSString *)_generateFrameName
[self _addFramePathToString:path];
// The new child's path component is all but the 1st char and the last 3 chars
// FIXME: Shouldn't this number be the index of this frame in its parent rather than the child count?
[path appendFormat:@"/<!--frame%d-->-->", [_private->children count]];
[path appendFormat:@"/<!--frame%d-->-->", [self _childFrameCount]];
return path;
}
......@@ -2616,11 +2615,6 @@ - (void)_reloadForPluginChanges
}
}
- (NSArray *)_internalChildFrames
{
return _private->children;
}
- (void)_attachScriptDebugger
{
if (!_private->scriptDebugger) {
......@@ -2906,7 +2900,8 @@ - (void)_clearSelectionInOtherFrames
- (void)_stopLoadingSubframes
{
[[self childFrames] makeObjectsPerformSelector:@selector(stopLoading)];
for (WebFrame *child = [self _firstChildFrame]; child; child = [child _nextSiblingFrame])
[child stopLoading];
}
- (BOOL)_subframeIsLoading
......@@ -3262,30 +3257,26 @@ - (WebFrame *)_frameInAnyWindowNamed:(NSString *)name sourceFrame:(WebFrame *)so
- (WebFrame *)findFrameNamed:(NSString *)name
{
// First, deal with 'special' names.
if ([name isEqualToString:@"_self"] || [name isEqualToString:@"_current"]){
if ([name isEqualToString:@"_self"] || [name isEqualToString:@"_current"])
return self;
}
if ([name isEqualToString:@"_top"]) {
if ([name isEqualToString:@"_top"])
return [[self webView] mainFrame];
}
if ([name isEqualToString:@"_parent"]) {
WebFrame *parent = [self parentFrame];
return parent ? parent : self;
}
if ([name isEqualToString:@"_blank"]) {
if ([name isEqualToString:@"_blank"])
return nil;
}
// Search from this frame down.
WebFrame *frame = [self _descendantFrameNamed:name sourceFrame:self];
if (!frame) {
// Search in the main frame for this window then in others.
// Search in the main frame for this window then in others.
if (!frame)
frame = [[[self webView] mainFrame] _frameInAnyWindowNamed:name sourceFrame:self];
}
return frame;
}
......@@ -3297,7 +3288,11 @@ - (WebFrame *)parentFrame
- (NSArray *)childFrames
{
return [[_private->children copy] autorelease];
NSMutableArray *children = [NSMutableArray arrayWithCapacity:[self _childFrameCount]];
for (WebFrame *child = [self _firstChildFrame]; child; child = [child _nextSiblingFrame])
[children addObject:child];
return children;
}
@end
......@@ -128,7 +128,6 @@ extern NSString *WebPageCacheDocumentViewKey;
- (void)_reloadAllowingStaleDataWithOverrideEncoding:(NSString *)encoding;
- (void)_addChild:(WebFrame *)child;
- (void)_removeChild:(WebFrame *)child;
- (NSString *)_generateFrameName;
- (NSDictionary *)_actionInformationForNavigationType:(WebNavigationType)navigationType event:(NSEvent *)event originalURL:(NSURL *)URL;
......@@ -167,8 +166,6 @@ extern NSString *WebPageCacheDocumentViewKey;
- (void)_reloadForPluginChanges;
- (NSArray *)_internalChildFrames;
- (BOOL)_isDescendantOfFrame:(WebFrame *)frame;
- (BOOL)_isFrameSet;
......
......@@ -329,7 +329,7 @@ - (void)didReceiveResponse:(NSURLResponse *)r
if ([[r MIMEType] isEqualToString:@"multipart/x-mixed-replace"]) {
if (!supportsMultipartContent) {
[dataSource _removeSubresourceLoader:self];
[[[dataSource _webView] mainFrame] _checkLoadComplete];
[[dataSource webFrame] _checkLoadComplete];
[self cancelWithError:[NSError _webKitErrorWithDomain:NSURLErrorDomain
code:NSURLErrorUnsupportedURL
URL:[r URL]]];
......
......@@ -572,7 +572,7 @@ - (WebFrame *)_createFrameNamed:(NSString *)fname inParent:(WebFrame *)parent al
return newFrame;
}
- (void)_finishedLoadingResourceFromDataSource: (WebDataSource *)dataSource
- (void)_finishedLoadingResourceFromDataSource:(WebDataSource *)dataSource
{
WebFrame *frame = [dataSource webFrame];
......@@ -585,7 +585,7 @@ - (void)_finishedLoadingResourceFromDataSource: (WebDataSource *)dataSource
}
}
- (void)_mainReceivedBytesSoFar: (unsigned)bytesSoFar fromDataSource: (WebDataSource *)dataSource complete: (BOOL)isComplete
- (void)_mainReceivedBytesSoFar:(unsigned)bytesSoFar fromDataSource:(WebDataSource *)dataSource complete: (BOOL)isComplete
{
WebFrame *frame = [dataSource webFrame];
......@@ -595,11 +595,11 @@ - (void)_mainReceivedBytesSoFar: (unsigned)bytesSoFar fromDataSource: (WebDataSo
if (frame == nil)
return;
// This resource has completed, so check if the load is complete for all frames.
// This resource has completed, so check if the load is complete for this frame and its ancestors
if (isComplete){
// If the load is complete, mark the primary load as done. The primary load is the load
// of the main document. Other resources may still be arriving.
[dataSource _setPrimaryLoadComplete: YES];
[dataSource _setPrimaryLoadComplete:YES];
[frame _checkLoadComplete];
}
else {
......@@ -611,7 +611,7 @@ - (void)_mainReceivedBytesSoFar: (unsigned)bytesSoFar fromDataSource: (WebDataSo
}
}
- (void)_receivedError: (NSError *)error fromDataSource: (WebDataSource *)dataSource
- (void)_receivedError:(NSError *)error fromDataSource:(WebDataSource *)dataSource
{
WebFrame *frame = [dataSource webFrame];
......
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