[webkit-changes] cvs commit: WebKit/WebView.subproj WebFrame.m WebFramePrivate.h WebMainResourceLoader.m WebView.m

Maciej mjs at opensource.apple.com
Thu Dec 29 21:11:49 PST 2005


mjs         05/12/29 21:11:49

  Modified:    .        ChangeLog
               kwq      WebCoreBridge.h
               .        ChangeLog
               WebCoreSupport.subproj WebBridge.m
               WebView.subproj WebFrame.m WebFramePrivate.h
                        WebMainResourceLoader.m WebView.m
  Log:
  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
  
  Revision  Changes    Path
  1.60      +10 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.59
  retrieving revision 1.60
  diff -u -r1.59 -r1.60
  --- ChangeLog	30 Dec 2005 04:11:47 -0000	1.59
  +++ ChangeLog	30 Dec 2005 05:11:36 -0000	1.60
  @@ -1,3 +1,13 @@
  +2005-12-29  Maciej Stachowiak  <mjs at 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 at apple.com>
   
           File accidentally omitted from previous commit.
  
  
  
  1.357     +0 -1      WebCore/kwq/WebCoreBridge.h
  
  Index: WebCoreBridge.h
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/WebCoreBridge.h,v
  retrieving revision 1.356
  retrieving revision 1.357
  diff -u -r1.356 -r1.357
  --- WebCoreBridge.h	26 Dec 2005 21:46:17 -0000	1.356
  +++ WebCoreBridge.h	30 Dec 2005 05:11:37 -0000	1.357
  @@ -468,7 +468,6 @@
   
   @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. */
  
  
  
  1.3434    +46 -0     WebKit/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebKit/ChangeLog,v
  retrieving revision 1.3433
  retrieving revision 1.3434
  diff -u -r1.3433 -r1.3434
  --- ChangeLog	30 Dec 2005 00:37:48 -0000	1.3433
  +++ ChangeLog	30 Dec 2005 05:11:38 -0000	1.3434
  @@ -1,5 +1,51 @@
   2005-12-29  Maciej Stachowiak  <mjs at 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 at apple.com>
  +
           Reviewed by Darin.
   
   	- abstract frame traversal in WebFrame more
  
  
  
  1.382     +0 -15     WebKit/WebCoreSupport.subproj/WebBridge.m
  
  Index: WebBridge.m
  ===================================================================
  RCS file: /cvs/root/WebKit/WebCoreSupport.subproj/WebBridge.m,v
  retrieving revision 1.381
  retrieving revision 1.382
  diff -u -r1.381 -r1.382
  --- WebBridge.m	26 Dec 2005 21:46:26 -0000	1.381
  +++ WebBridge.m	30 Dec 2005 05:11:45 -0000	1.382
  @@ -168,21 +168,6 @@
       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);
  
  
  
  1.266     +60 -65    WebKit/WebView.subproj/WebFrame.m
  
  Index: WebFrame.m
  ===================================================================
  RCS file: /cvs/root/WebKit/WebView.subproj/WebFrame.m,v
  retrieving revision 1.265
  retrieving revision 1.266
  diff -u -r1.265 -r1.266
  --- WebFrame.m	30 Dec 2005 00:37:53 -0000	1.265
  +++ WebFrame.m	30 Dec 2005 05:11:46 -0000	1.266
  @@ -191,9 +191,12 @@
   @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 @@
       return [_private->children lastObject];
   }
   
  +- (unsigned)_childFrameCount
  +{
  +    return [_private->children count];
  +}
  +
   - (WebFrame *)_previousSiblingFrame;
   {
       return _private->previousSibling;
  @@ -427,6 +435,39 @@
       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 @@
       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 @@
   
           [_private->dataSource _setWebFrame:nil];
       } else {
  -        ASSERT(!_private->children);
  +        ASSERT(![self _childFrameCount]);
       }
   
       [_private setDataSource:ds];
  @@ -1140,6 +1178,7 @@
           [[_private currentItem] setHasPageCache: NO];
   
           [[self dataSource] _setPrimaryLoadComplete: YES];
  +        // why only this frame and not parent frames?
           [self _checkLoadCompleteForThisFrame];
       }
   }
  @@ -1297,22 +1336,13 @@
       [[[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 @@
   {
       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)_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 @@
       [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 @@
       }
   }
   
  -- (NSArray *)_internalChildFrames
  -{
  -    return _private->children;
  -}
  -
   - (void)_attachScriptDebugger
   {
       if (!_private->scriptDebugger) {
  @@ -2906,7 +2900,8 @@
   
   - (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 *)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 @@
   
   - (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
  
  
  
  1.165     +0 -3      WebKit/WebView.subproj/WebFramePrivate.h
  
  Index: WebFramePrivate.h
  ===================================================================
  RCS file: /cvs/root/WebKit/WebView.subproj/WebFramePrivate.h,v
  retrieving revision 1.164
  retrieving revision 1.165
  diff -u -r1.164 -r1.165
  --- WebFramePrivate.h	20 Dec 2005 20:41:54 -0000	1.164
  +++ WebFramePrivate.h	30 Dec 2005 05:11:46 -0000	1.165
  @@ -128,7 +128,6 @@
   - (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 @@
   
   - (void)_reloadForPluginChanges;
   
  -- (NSArray *)_internalChildFrames;
  -
   - (BOOL)_isDescendantOfFrame:(WebFrame *)frame;
   - (BOOL)_isFrameSet;
   
  
  
  
  1.276     +1 -1      WebKit/WebView.subproj/WebMainResourceLoader.m
  
  Index: WebMainResourceLoader.m
  ===================================================================
  RCS file: /cvs/root/WebKit/WebView.subproj/WebMainResourceLoader.m,v
  retrieving revision 1.275
  retrieving revision 1.276
  diff -u -r1.275 -r1.276
  --- WebMainResourceLoader.m	28 Sep 2005 18:43:14 -0000	1.275
  +++ WebMainResourceLoader.m	30 Dec 2005 05:11:47 -0000	1.276
  @@ -329,7 +329,7 @@
       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]]];
  
  
  
  1.323     +5 -5      WebKit/WebView.subproj/WebView.m
  
  Index: WebView.m
  ===================================================================
  RCS file: /cvs/root/WebKit/WebView.subproj/WebView.m,v
  retrieving revision 1.322
  retrieving revision 1.323
  diff -u -r1.322 -r1.323
  --- WebView.m	24 Dec 2005 00:54:10 -0000	1.322
  +++ WebView.m	30 Dec 2005 05:11:47 -0000	1.323
  @@ -572,7 +572,7 @@
       return newFrame;
   }
   
  -- (void)_finishedLoadingResourceFromDataSource: (WebDataSource *)dataSource
  +- (void)_finishedLoadingResourceFromDataSource:(WebDataSource *)dataSource
   {
       WebFrame *frame = [dataSource webFrame];
       
  @@ -585,7 +585,7 @@
       }
   }
   
  -- (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 @@
       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)_receivedError: (NSError *)error fromDataSource: (WebDataSource *)dataSource
  +- (void)_receivedError:(NSError *)error fromDataSource:(WebDataSource *)dataSource
   {
       WebFrame *frame = [dataSource webFrame];
   
  
  
  



More information about the webkit-changes mailing list