diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 38e4275f9933cf18abcfc92926560f121be08d23..58b9657228d43521bdfd34421830f5dfa6336233 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,25 @@ +2006-01-03 Maciej Stachowiak + + Reviewed by Vicki. + + - moved frame traversal code across from bridge, also dropped the children + array + + * kwq/WebCoreBridge.h: + * kwq/WebCoreBridge.mm: + (-[WebCoreBridge firstChild]): Moved from WebBridge. Use new _firstChild + pointer. + (-[WebCoreBridge lastChild]): Moved from WebBridge. Use new _lastChild pointer. + (-[WebCoreBridge childCount]): Moved from WebBridge. Use _childCount variable. + (-[WebCoreBridge previousSibling]): Moved from WebBridge. + (-[WebCoreBridge nextSibling]): ditt + (-[WebCoreBridge isDescendantOfFrame:]): ditto + (-[WebCoreBridge traverseNextFrameStayWithin:]): ditto + (-[WebCoreBridge appendChild:]): Moved from WebBridge, maintain count and first/last + pointers. + (-[WebCoreBridge removeChild:]): Moved from WebBridge, maintain count and first/last + pointers. + 2006-01-03 Justin Garcia Reviewed by harrison diff --git a/WebCore/kwq/WebCoreBridge.h b/WebCore/kwq/WebCoreBridge.h index 3f15276349affc996d7c16f452cd2ff272b9f608..b4bd70001df316cb8c21aef93add08784e730756 100644 --- a/WebCore/kwq/WebCoreBridge.h +++ b/WebCore/kwq/WebCoreBridge.h @@ -190,6 +190,12 @@ typedef enum KHTMLRenderPart *_renderPart; RenderArena *_renderPartArena; BOOL _shouldCreateRenderers; + + WebCoreBridge *_nextSibling; + WebCoreBridge *_previousSibling; + WebCoreBridge *_firstChild; + WebCoreBridge *_lastChild; + int _childCount; } + (WebCoreBridge *)bridgeForDOMDocument:(DOMDocument *)document; @@ -209,6 +215,18 @@ typedef enum - (void)setParent:(WebCoreBridge *)parent; - (WebCoreBridge *)parent; +- (WebCoreBridge *)firstChild; +- (WebCoreBridge *)lastChild; +- (WebCoreBridge *)previousSibling; +- (WebCoreBridge *)nextSibling; + +- (void)appendChild:(WebCoreBridge *)child; +- (void)removeChild:(WebCoreBridge *)child; + +- (unsigned)childCount; +- (BOOL)isDescendantOfFrame:(WebCoreBridge *)ancestor; +- (WebCoreBridge *)traverseNextFrameStayWithin:(WebCoreBridge *)stayWithin; + - (void)provisionalLoadStarted; - (void)openURL:(NSURL *)URL reload:(BOOL)reload diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm index 5e7f5d639ab65b834571c3841f66bd2edf789060..8d3623e63a33c0ab64fd9df95a787ad58857f2d0 100644 --- a/WebCore/kwq/WebCoreBridge.mm +++ b/WebCore/kwq/WebCoreBridge.mm @@ -224,6 +224,113 @@ static BOOL hasCaseInsensitivePrefix(NSString *string, NSString *prefix) static bool initializedObjectCacheSize = FALSE; static bool initializedKJS = FALSE; +- (WebCoreBridge *)firstChild +{ + return _firstChild; +} + +- (WebCoreBridge *)lastChild +{ + return _lastChild; +} + +- (unsigned)childCount +{ + return _childCount; +} + +- (WebCoreBridge *)previousSibling; +{ + return _previousSibling; +} + +- (WebCoreBridge *)nextSibling; +{ + return _nextSibling; +} + +- (BOOL)isDescendantOfFrame:(WebCoreBridge *)ancestor +{ + for (WebCoreBridge *frame = self; frame; frame = (WebCoreBridge *)[frame parent]) + if (frame == ancestor) + return YES; + + return NO; +} + +- (WebCoreBridge *)traverseNextFrameStayWithin:(WebCoreBridge *)stayWithin +{ + WebCoreBridge *firstChild = [self firstChild]; + if (firstChild) { + ASSERT(!stayWithin || [firstChild isDescendantOfFrame:stayWithin]); + return firstChild; + } + + if (self == stayWithin) + return 0; + + WebCoreBridge *nextSibling = [self nextSibling]; + if (nextSibling) { + assert(!stayWithin || [nextSibling isDescendantOfFrame:stayWithin]); + return nextSibling; + } + + WebCoreBridge *frame = self; + while (frame && !nextSibling && (!stayWithin || [frame parent] != stayWithin)) { + frame = (WebCoreBridge *)[frame parent]; + nextSibling = [frame nextSibling]; + } + + if (frame) { + ASSERT(!stayWithin || !nextSibling || [nextSibling isDescendantOfFrame:stayWithin]); + return nextSibling; + } + + return nil; +} + +- (void)appendChild:(WebCoreBridge *)child +{ + [child retain]; + + [child setParent:self]; + + WebCoreBridge *last = _lastChild; + + if (last) { + last->_nextSibling = child; + child->_previousSibling = last; + } else { + _firstChild = child; + } + + _lastChild = child; + + _childCount++; + + ASSERT(child->_nextSibling == nil); +} + +- (void)removeChild:(WebCoreBridge *)child +{ + if (child->_previousSibling) + child->_previousSibling->_nextSibling = child->_nextSibling; + else + _firstChild = child->_nextSibling; + + if (child->_nextSibling) + child->_nextSibling->_previousSibling = child->_previousSibling; + else + _lastChild = child->_previousSibling; + + child->_previousSibling = nil; + child->_nextSibling = nil; + + _childCount--; + + [child release]; +} + + (NSArray *)supportedMIMETypes { return [NSArray arrayWithObjects: diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog index c8c5e63ce5c6259ecd8d712d10f2459ba65ce508..98e29c274838ba2199a1ff6c5923159587e56814 100644 --- a/WebKit/ChangeLog +++ b/WebKit/ChangeLog @@ -1,3 +1,25 @@ +2006-01-03 Maciej Stachowiak + + Reviewed by Vicki. + + - moved frame traversal code across from bridge, also dropped the children + array + + * WebCoreSupport.subproj/WebBridge.h: + * WebCoreSupport.subproj/WebBridge.m: + (-[WebBridge dealloc]): Don't release children array, that was moved + down to WebCore. + (-[WebBridge saveDocumentState:]): + - many methods moved to WebCore. + * WebView.subproj/WebFrame.m: + (Frame): New convenience method to get a WebFrame * from a method that + returns WebCoreBridge *. + (-[WebFrame _firstChildFrame]): use Frame() + (-[WebFrame _lastChildFrame]): ditto + (-[WebFrame _previousSiblingFrame]): ditto + (-[WebFrame _nextSiblingFrame]): ditto + (-[WebFrame _traverseNextFrameStayWithin:]): ditto + 2006-01-03 Anders Carlsson Reviewed by Darin. diff --git a/WebKit/WebCoreSupport.subproj/WebBridge.h b/WebKit/WebCoreSupport.subproj/WebBridge.h index 886f60660b64e5f44bd92c6645ea212a28ac96e4..6468c782d96680b614f79f0280ddf482e37a5e10 100644 --- a/WebKit/WebCoreSupport.subproj/WebBridge.h +++ b/WebKit/WebCoreSupport.subproj/WebBridge.h @@ -34,10 +34,6 @@ @interface WebBridge : WebCoreBridge { - WebBridge *_nextSibling; - WebBridge *_previousSibling; - NSMutableArray *_children; - WebFrame *_frame; WebCoreKeyboardUIMode _keyboardUIMode; BOOL _keyboardUIModeAccessed; @@ -57,17 +53,4 @@ - (WebFrame *)webFrame; -- (WebBridge *)firstChild; -- (WebBridge *)lastChild; -- (WebBridge *)previousSibling; -- (WebBridge *)nextSibling; - -- (void)appendChild:(WebBridge *)child; -- (void)removeChild:(WebBridge *)child; - -- (unsigned)childCount; -- (BOOL)isDescendantOfFrame:(WebBridge *)ancestor; -- (WebBridge *)traverseNextFrameStayWithin:(WebBridge *)stayWithin; - - @end diff --git a/WebKit/WebCoreSupport.subproj/WebBridge.m b/WebKit/WebCoreSupport.subproj/WebBridge.m index 3d5ce35f275176ce0dccb3fcf0b0dfa2163555e3..5ab80e3eb2c4de2e17ea1f3f41bcb576b4f7983f 100644 --- a/WebKit/WebCoreSupport.subproj/WebBridge.m +++ b/WebKit/WebCoreSupport.subproj/WebBridge.m @@ -150,7 +150,6 @@ - (void)dealloc { [lastDashboardRegions release]; [_frame release]; - [_children release]; [self fini]; [super dealloc]; @@ -788,7 +787,7 @@ - (WebCoreBridge *)createChildFrameNamed:(NSString *)frameName return [newFrame _bridge]; } -- (void)saveDocumentState: (NSArray *)documentState +- (void)saveDocumentState:(NSArray *)documentState { WebHistoryItem *item = [_frame _itemForSavingDocState]; LOG(Loading, "%@: saving form state from to 0x%x", [_frame name], item); @@ -1726,103 +1725,4 @@ - (void)handledOnloadEvents [_frame _handledOnloadEvents]; } -- (WebBridge *)firstChild -{ - if (![_children count]) - return nil; - - return [_children objectAtIndex:0]; -} - -- (WebBridge *)lastChild -{ - return [_children lastObject]; -} - -- (unsigned)childCount -{ - return [_children count]; -} - -- (WebBridge *)previousSibling; -{ - return _previousSibling; -} - -- (WebBridge *)nextSibling; -{ - return _nextSibling; -} - -- (BOOL)isDescendantOfFrame:(WebBridge *)ancestor -{ - for (WebBridge *frame = self; frame; frame = (WebBridge *)[frame parent]) - if (frame == ancestor) - return YES; - - return NO; -} - -- (WebBridge *)traverseNextFrameStayWithin:(WebBridge *)stayWithin -{ - WebBridge *firstChild = [self firstChild]; - if (firstChild) { - ASSERT(!stayWithin || [firstChild isDescendantOfFrame:stayWithin]); - return firstChild; - } - - if (self == stayWithin) - return 0; - - WebBridge *nextSibling = [self nextSibling]; - if (nextSibling) { - assert(!stayWithin || [nextSibling isDescendantOfFrame:stayWithin]); - return nextSibling; - } - - WebBridge *frame = self; - while (frame && !nextSibling && (!stayWithin || [frame parent] != stayWithin)) { - frame = (WebBridge *)[frame parent]; - nextSibling = [frame nextSibling]; - } - - if (frame) { - ASSERT(!stayWithin || !nextSibling || [nextSibling isDescendantOfFrame:stayWithin]); - return nextSibling; - } - - return nil; -} - -- (void)appendChild:(WebBridge *)child -{ - [child setParent:self]; - - if (_children == nil) - _children = [[NSMutableArray alloc] init]; - - WebBridge *previous = [self lastChild]; - if (previous) { - previous->_nextSibling = child; - child->_previousSibling = previous; - } - ASSERT(child->_nextSibling == nil); - - [_children addObject:child]; -} - -- (void)removeChild:(WebBridge *)child -{ - if (child->_previousSibling) - child->_previousSibling->_nextSibling = child->_nextSibling; - - if (child->_nextSibling) - child->_nextSibling->_previousSibling = child->_previousSibling; - - child->_previousSibling = nil; - child->_nextSibling = nil; - - [_children removeObject:child]; -} - @end diff --git a/WebKit/WebView.subproj/WebFrame.m b/WebKit/WebView.subproj/WebFrame.m index ef126309a373267447ceb0664fd7ead6222d810a..fad8b7bb248ca14a616033cfc4d2662f36b03d2d 100644 --- a/WebKit/WebView.subproj/WebFrame.m +++ b/WebKit/WebView.subproj/WebFrame.m @@ -339,15 +339,20 @@ - (void)setCurrentItem:(WebHistoryItem *)item @end +static inline WebFrame *Frame(WebCoreBridge *bridge) +{ + return [(WebBridge *)bridge webFrame]; +} + @implementation WebFrame (FrameTraversal) - (WebFrame *)_firstChildFrame { - return [[[self _bridge] firstChild] webFrame]; + return Frame([[self _bridge] firstChild]); } - (WebFrame *)_lastChildFrame { - return [[[self _bridge] lastChild] webFrame]; + return Frame([[self _bridge] lastChild]); } - (unsigned)_childFrameCount @@ -357,17 +362,17 @@ - (unsigned)_childFrameCount - (WebFrame *)_previousSiblingFrame; { - return [[[self _bridge] previousSibling] webFrame]; + return Frame([[self _bridge] previousSibling]); } - (WebFrame *)_nextSiblingFrame; { - return [[[self _bridge] nextSibling] webFrame]; + return Frame([[self _bridge] nextSibling]); } - (WebFrame *)_traverseNextFrameStayWithin:(WebFrame *)stayWithin { - return [[[self _bridge] traverseNextFrameStayWithin:[stayWithin _bridge]] webFrame]; + return Frame([[self _bridge] traverseNextFrameStayWithin:[stayWithin _bridge]]); } - (void)_appendChild:(WebFrame *)child