Commit 20be1bdc authored by cblu's avatar cblu
Browse files

WebCore:

	Cleaned up the frame searching shenanigans. Things are much cleaner and clearer now.

        * kwq/KWQKHTMLPartBrowserExtension.mm:
        (KHTMLPartBrowserExtension::createNewWindow): call findFrameNamed
        * kwq/KWQKHTMLPartImpl.mm:
        (KWQKHTMLPartImpl::bridgeForFrameName): call findOrCreateFramedNamed
        * kwq/WebCoreBridge.h:

WebKit:

	Cleaned up the frame searching shenanigans. Things are much cleaner and clearer now.

        * Plugins.subproj/WebBaseNetscapePluginView.m:
        (-[WebBaseNetscapePluginView loadRequest:inTarget:withNotifyData:]): call findOrCreateFramedNamed
        * Plugins.subproj/WebPluginController.m:
        (-[WebPluginController showURL:inFrame:]): call findOrCreateFramedNamed
        * WebCoreSupport.subproj/WebBridge.m:
        (-[WebBridge childFrames]): moved
        (-[WebBridge mainFrame]): moved
        (-[WebBridge findOrCreateFramedNamed:]): call findOrCreateFramedNamed on the frame
        (-[WebBridge pluginViewWithPackage:attributes:baseURL:]): call _pluginController
        * WebView.subproj/WebControllerPrivate.m:
        (-[WebController _frameInThisWindowNamed:]): call _descendantFrameNamed
        * WebView.subproj/WebFrame.h:
        * WebView.subproj/WebFrame.m:
        (-[WebFrame findFrameNamed:]): was frameNamed. First checks special-case frame names, descendant frames, then the whole controller, then other controllers.
        (-[WebFrame findOrCreateFramedNamed:]): calls findFrameNamed, opens new window if necessary
        * WebView.subproj/WebFramePrivate.h:
        * WebView.subproj/WebFramePrivate.m:
        (-[WebFrame _descendantFrameNamed:]): searches children, children's children etc.
        (-[WebFrame _pluginController]): this method needed an "_"
        * WebView.subproj/WebHTMLView.m:
        (-[WebHTMLView addSubview:]): call _pluginController
        * WebView.subproj/WebHTMLViewPrivate.m:
        (-[WebHTMLView _elementAtPoint:]): no need to special case for "_blank" since findFrameNamed will return nil for that name


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2469 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3629d5a8
2002-10-25 Chris Blumenberg <cblu@apple.com>
Cleaned up the frame searching shenanigans. Things are much cleaner and clearer now.
* kwq/KWQKHTMLPartBrowserExtension.mm:
(KHTMLPartBrowserExtension::createNewWindow): call findFrameNamed
* kwq/KWQKHTMLPartImpl.mm:
(KWQKHTMLPartImpl::bridgeForFrameName): call findOrCreateFramedNamed
* kwq/WebCoreBridge.h:
2002-10-25 Maciej Stachowiak <mjs@apple.com>
 
- fixed 3065638 - "undefined" output to screen on empty document.write()
......
2002-10-25 Chris Blumenberg <cblu@apple.com>
Cleaned up the frame searching shenanigans. Things are much cleaner and clearer now.
* kwq/KWQKHTMLPartBrowserExtension.mm:
(KHTMLPartBrowserExtension::createNewWindow): call findFrameNamed
* kwq/KWQKHTMLPartImpl.mm:
(KWQKHTMLPartImpl::bridgeForFrameName): call findOrCreateFramedNamed
* kwq/WebCoreBridge.h:
2002-10-25 Maciej Stachowiak <mjs@apple.com>
 
- fixed 3065638 - "undefined" output to screen on empty document.write()
......
2002-10-25 Chris Blumenberg <cblu@apple.com>
Cleaned up the frame searching shenanigans. Things are much cleaner and clearer now.
* kwq/KWQKHTMLPartBrowserExtension.mm:
(KHTMLPartBrowserExtension::createNewWindow): call findFrameNamed
* kwq/KWQKHTMLPartImpl.mm:
(KWQKHTMLPartImpl::bridgeForFrameName): call findOrCreateFramedNamed
* kwq/WebCoreBridge.h:
2002-10-25 Maciej Stachowiak <mjs@apple.com>
 
- fixed 3065638 - "undefined" output to screen on empty document.write()
......
......@@ -112,14 +112,7 @@ WebCoreBridge *KWQKHTMLPartImpl::bridgeForFrameName(const QString &frameName)
frame = _bridge;
}
} else {
frame = [_bridge descendantFrameNamed:frameName.getNSString()];
if (frame == nil) {
frame = [_bridge frameNamed:frameName.getNSString()];
}
if (frame == nil) {
frame = [_bridge createWindowWithURL:nil frameName:frameName.getNSString()];
[frame showWindow];
}
frame = [_bridge findOrCreateFramedNamed:frameName.getNSString()];
}
return frame;
......
......@@ -66,7 +66,7 @@ void KHTMLPartBrowserExtension::createNewWindow(const KURL &url,
WebCoreBridge *bridge;
if (frameName != nil) {
bridge = [m_part->impl->bridge() frameNamed:frameName];
bridge = [m_part->impl->bridge() findFramedNamed:frameName];
if (bridge != nil) {
if (!url.isEmpty()) {
[bridge openURL:url.getNSURL()];
......
......@@ -112,14 +112,7 @@ WebCoreBridge *KWQKHTMLPartImpl::bridgeForFrameName(const QString &frameName)
frame = _bridge;
}
} else {
frame = [_bridge descendantFrameNamed:frameName.getNSString()];
if (frame == nil) {
frame = [_bridge frameNamed:frameName.getNSString()];
}
if (frame == nil) {
frame = [_bridge createWindowWithURL:nil frameName:frameName.getNSString()];
[frame showWindow];
}
frame = [_bridge findOrCreateFramedNamed:frameName.getNSString()];
}
return frame;
......
......@@ -170,10 +170,9 @@ enum FrameBorderStyle {
@protocol WebCoreBridge
- (NSArray *)childFrames; // WebCoreBridge objects
- (WebCoreBridge *)descendantFrameNamed:(NSString *)name;
- (WebCoreBridge *)mainFrame;
- (WebCoreBridge *)frameNamed:(NSString *)name; // searches entire hierarchy starting with mainFrame
- (WebCoreBridge *)findFramedNamed:(NSString *)name;
- (WebCoreBridge *)findOrCreateFramedNamed:(NSString *)name;
- (void)loadURL:(NSURL *)URL;
- (void)postWithURL:(NSURL *)URL data:(NSData *)data contentType:(NSString *)contentType;
......
2002-10-25 Chris Blumenberg <cblu@apple.com>
Cleaned up the frame searching shenanigans. Things are much cleaner and clearer now.
* Plugins.subproj/WebBaseNetscapePluginView.m:
(-[WebBaseNetscapePluginView loadRequest:inTarget:withNotifyData:]): call findOrCreateFramedNamed
* Plugins.subproj/WebPluginController.m:
(-[WebPluginController showURL:inFrame:]): call findOrCreateFramedNamed
* WebCoreSupport.subproj/WebBridge.m:
(-[WebBridge childFrames]): moved
(-[WebBridge mainFrame]): moved
(-[WebBridge findOrCreateFramedNamed:]): call findOrCreateFramedNamed on the frame
(-[WebBridge pluginViewWithPackage:attributes:baseURL:]): call _pluginController
* WebView.subproj/WebControllerPrivate.m:
(-[WebController _frameInThisWindowNamed:]): call _descendantFrameNamed
* WebView.subproj/WebFrame.h:
* WebView.subproj/WebFrame.m:
(-[WebFrame findFrameNamed:]): was frameNamed. First checks special-case frame names, descendant frames, then the whole controller, then other controllers.
(-[WebFrame findOrCreateFramedNamed:]): calls findFrameNamed, opens new window if necessary
* WebView.subproj/WebFramePrivate.h:
* WebView.subproj/WebFramePrivate.m:
(-[WebFrame _descendantFrameNamed:]): searches children, children's children etc.
(-[WebFrame _pluginController]): this method needed an "_"
* WebView.subproj/WebHTMLView.m:
(-[WebHTMLView addSubview:]): call _pluginController
* WebView.subproj/WebHTMLViewPrivate.m:
(-[WebHTMLView _elementAtPoint:]): no need to special case for "_blank" since findFrameNamed will return nil for that name
2002-10-25 Trey Matteson <trey@apple.com>
2919039 - Implement limit on back/forward history list
......
2002-10-25 Chris Blumenberg <cblu@apple.com>
Cleaned up the frame searching shenanigans. Things are much cleaner and clearer now.
* Plugins.subproj/WebBaseNetscapePluginView.m:
(-[WebBaseNetscapePluginView loadRequest:inTarget:withNotifyData:]): call findOrCreateFramedNamed
* Plugins.subproj/WebPluginController.m:
(-[WebPluginController showURL:inFrame:]): call findOrCreateFramedNamed
* WebCoreSupport.subproj/WebBridge.m:
(-[WebBridge childFrames]): moved
(-[WebBridge mainFrame]): moved
(-[WebBridge findOrCreateFramedNamed:]): call findOrCreateFramedNamed on the frame
(-[WebBridge pluginViewWithPackage:attributes:baseURL:]): call _pluginController
* WebView.subproj/WebControllerPrivate.m:
(-[WebController _frameInThisWindowNamed:]): call _descendantFrameNamed
* WebView.subproj/WebFrame.h:
* WebView.subproj/WebFrame.m:
(-[WebFrame findFrameNamed:]): was frameNamed. First checks special-case frame names, descendant frames, then the whole controller, then other controllers.
(-[WebFrame findOrCreateFramedNamed:]): calls findFrameNamed, opens new window if necessary
* WebView.subproj/WebFramePrivate.h:
* WebView.subproj/WebFramePrivate.m:
(-[WebFrame _descendantFrameNamed:]): searches children, children's children etc.
(-[WebFrame _pluginController]): this method needed an "_"
* WebView.subproj/WebHTMLView.m:
(-[WebHTMLView addSubview:]): call _pluginController
* WebView.subproj/WebHTMLViewPrivate.m:
(-[WebHTMLView _elementAtPoint:]): no need to special case for "_blank" since findFrameNamed will return nil for that name
2002-10-25 Trey Matteson <trey@apple.com>
2919039 - Implement limit on back/forward history list
......
......@@ -791,35 +791,26 @@ - (NPError)loadRequest:(WebResourceRequest *)request inTarget:(NSString *)target
return NPERR_INVALID_URL;
}
}else{
WebFrame *frame = [[self webFrame] frameNamed:target];
if(!frame){
// FIXME: Why is it OK to just discard all the attributes in this case?
// FIXME: Do we need a referrer here?
[[self controller] _openNewWindowWithURL:URL referrer:nil behind:NO];
// FIXME: Need to send NPP_URLNotify at the right time.
// FIXME: Need to name new frame
if(notifyData){
NPP_URLNotify(instance, [[URL absoluteString] cString], NPRES_DONE, notifyData);
}
}else{
if(notifyData){
if(![target isEqualToString:@"_self"] && ![target isEqualToString:@"_current"] &&
![target isEqualToString:@"_parent"] && ![target isEqualToString:@"_top"]){
[notificationData setObject:[NSValue valueWithPointer:notifyData] forKey:URL];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(frameStateChanged:) name:WebFrameStateChangedNotification object:frame];
}
// Plug-in docs say to return NPERR_INVALID_PARAM here
// but IE allows an NPP_*URLNotify when the target is _self, _current, _parent or _top
// so we have to allow this as well. Needed for iTools.
}
WebDataSource *dataSource = [[WebDataSource alloc] initWithRequest:request];
if ([frame setProvisionalDataSource:dataSource]) {
[frame startLoading];
WebFrame *frame = [[self webFrame] findOrCreateFramedNamed:target];
if(notifyData){
if(![target isEqualToString:@"_self"] && ![target isEqualToString:@"_current"] &&
![target isEqualToString:@"_parent"] && ![target isEqualToString:@"_top"]){
[notificationData setObject:[NSValue valueWithPointer:notifyData] forKey:URL];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(frameStateChanged:) name:WebFrameStateChangedNotification object:frame];
}
[dataSource release];
// Plug-in docs say to return NPERR_INVALID_PARAM here
// but IE allows an NPP_*URLNotify when the target is _self, _current, _parent or _top
// so we have to allow this as well. Needed for iTools.
}
WebDataSource *dataSource = [[WebDataSource alloc] initWithRequest:request];
if ([frame setProvisionalDataSource:dataSource]) {
[frame startLoading];
}
[dataSource release];
}
return NPERR_NO_ERROR;
......
......@@ -97,11 +97,7 @@ - (void)showURL:(NSURL *)URL inFrame:(NSString *)target
return;
}
WebFrame *otherFrame = [frame frameNamed:target];
if(!otherFrame){
// FIXME: Open new window instead of return.
return;
}
WebFrame *otherFrame = [frame findOrCreateFramedNamed:target];
WebDataSource *dataSource = [[WebDataSource alloc] initWithRequest:[WebResourceRequest requestWithURL:URL]];
if(!dataSource){
......
......@@ -62,6 +62,7 @@ - (void)dealloc
- (NSArray *)childFrames
{
ASSERT(frame != nil);
NSArray *frames = [frame children];
NSEnumerator *e = [frames objectEnumerator];
NSMutableArray *frameBridges = [NSMutableArray arrayWithCapacity:[frames count]];
......@@ -74,10 +75,22 @@ - (NSArray *)childFrames
return frameBridges;
}
- (WebCoreBridge *)descendantFrameNamed:(NSString *)name
- (WebCoreBridge *)mainFrame
{
ASSERT(frame != nil);
return [[[frame controller] mainFrame] _bridge];
}
- (WebCoreBridge *)findFramedNamed:(NSString *)name;
{
ASSERT(frame != nil);
return [[frame findFrameNamed:name] _bridge];
}
- (WebCoreBridge *)findOrCreateFramedNamed:(NSString *)name
{
ASSERT(frame != nil);
return [[frame frameNamed:name] _bridge];
return [[frame findOrCreateFramedNamed:name] _bridge];
}
- (WebCoreBridge *)createWindowWithURL:(NSURL *)URL frameName:(NSString *)name
......@@ -153,18 +166,6 @@ - (void)setStatusText:(NSString *)status
[[[frame controller] windowOperationsDelegate] setStatusText:status];
}
- (WebCoreBridge *)mainFrame
{
ASSERT(frame != nil);
return [[[frame controller] mainFrame] _bridge];
}
- (WebCoreBridge *)frameNamed:(NSString *)name
{
ASSERT(frame != nil);
return [[[frame controller] frameNamed:name] _bridge];
}
- (void)receivedData:(NSData *)data withDataSource:(WebDataSource *)withDataSource
{
ASSERT([self dataSource] == withDataSource);
......@@ -429,7 +430,7 @@ - (NSURL *)requestedURL
attributes:(NSDictionary *)attributes
baseURL:(NSURL *)baseURL
{
WebPluginController *pluginController = [frame pluginController];
WebPluginController *pluginController = [frame _pluginController];
NSDictionary *arguments = [NSDictionary dictionaryWithObjectsAndKeys:
baseURL, WebPluginBaseURLKey,
......
......@@ -224,7 +224,7 @@ - (WebFrame *)_frameInThisWindowNamed:(NSString *)name
if ([_private->topLevelFrameName isEqualToString:name]) {
return [self mainFrame];
} else {
return [[self mainFrame] frameNamed:name];
return [[self mainFrame] _descendantFrameNamed:name];
}
}
......
......@@ -119,15 +119,26 @@
- (void)reload;
/*!
@method frameNamed:
@discussion This method returns a frame with the given name. frameNamed returns self
@method findFrameNamed:
@discussion This method returns a frame with the given name. findFrameNamed returns self
for _self and _current, the parent frame for _parent and the main frame for _top.
frameNamed returns self for _parent and _top if the receiver it is the mainFrame.
nil is returned if a frame with the given name is not found.
findFrameNamed returns self for _parent and _top if the receiver it is the mainFrame.
findFrameNamed first searches from the current frame to all descending frames then the
rest of the frames in the controller. If still not found, findFrameNamed searches the
frames of the other controllers.
@param name The name of the frame to find.
@result The frame matching the provided name.
@result The frame matching the provided name. nil if the frame is not found.
*/
- (WebFrame *)frameNamed:(NSString *)name;
- (WebFrame *)findFrameNamed:(NSString *)name;
/*!
@method findOrCreateFramedNamed:
@discussion This method calls findFrameNamed but if no frame is found, a new window is opened
and the main frame of the new window is named with the given name.
@param name The name of the frame to find.
@result The frame matching the provided name. Won't be nil.
*/
- (WebFrame *)findOrCreateFramedNamed:(NSString *)name;
/*!
@method parent
......@@ -142,4 +153,5 @@
*/
- (NSArray *)children;
@end
......@@ -199,33 +199,7 @@ - (void)reload
[newDataSource release];
}
+ _frameNamed:(NSString *)name fromFrame: (WebFrame *)aFrame
{
int i, count;
WebFrame *foundFrame;
NSArray *children;
if ([[aFrame name] isEqualToString: name])
return aFrame;
children = [aFrame children];
count = [children count];
for (i = 0; i < count; i++){
aFrame = [children objectAtIndex: i];
foundFrame = [WebFrame _frameNamed: name fromFrame: aFrame];
if (foundFrame)
return foundFrame;
}
// FIXME: Need to look in other controller's frame namespaces.
// FIXME: What do we do if a frame name isn't found? create a new window
return nil;
}
- (WebFrame *)frameNamed:(NSString *)name
- (WebFrame *)findFrameNamed:(NSString *)name
{
// First, deal with 'special' names.
if ([name isEqualToString:@"_self"] || [name isEqualToString:@"_current"]){
......@@ -242,11 +216,40 @@ - (WebFrame *)frameNamed:(NSString *)name
}
if ([name isEqualToString:@"_blank"]) {
return [[[self controller] _openNewWindowWithURL:nil referrer:nil behind:NO] mainFrame];
return nil;
}
// Search from this frame down.
WebFrame *frame = [self _descendantFrameNamed:name];
if(!frame){
// Search in this controller and other controllers.
frame = [[self controller] frameNamed:name];
}
return frame;
}
- (WebFrame *)findOrCreateFramedNamed:(NSString *)name
{
WebFrame *frame = [self findFrameNamed:name];
if(!frame){
WebController *controller = [[[self controller] windowOperationsDelegate]
createWindowWithURL:nil referrer:[[self _bridge] referrer]];
if(![name isEqualToString:@"_blank"]){
[controller _setTopLevelFrameName:name];
}
[[controller windowOperationsDelegate] showWindow];
frame = [controller mainFrame];
}
ASSERT(frame);
// Now search the name space associated with this frame's controller.
return [WebFrame _frameNamed:name fromFrame:[[self controller] mainFrame]];
return frame;
}
- (WebFrame *)parent
......
......@@ -78,10 +78,9 @@ typedef enum {
@end
@interface WebFrame (WebPrivate)
- (WebFrame *)_descendantFrameNamed:(NSString *)name;
- (void)_controllerWillBeDeallocated;
- (void)_detachFromParent;
- (void)_setController: (WebController *)controller;
- (void)_setDataSource: (WebDataSource *)d;
- (void)_transitionToCommitted;
......@@ -110,6 +109,6 @@ typedef enum {
- (void)_addChild:(WebFrame *)child;
- (WebPluginController *)pluginController;
- (WebPluginController *)_pluginController;
@end
......@@ -132,6 +132,27 @@ - (void)setBackForwardItem: (WebHistoryItem *)item
@implementation WebFrame (WebPrivate)
- (WebFrame *)_descendantFrameNamed:(NSString *)name
{
if ([[self name] isEqualToString: name]){
return self;
}
NSArray *children = [self children];
WebFrame *frame;
unsigned i;
for (i = 0; i < [children count]; i++){
frame = [children objectAtIndex: i];
frame = [frame _descendantFrameNamed:name];
if (frame){
return frame;
}
}
return nil;
}
- (void)_controllerWillBeDeallocated
{
[self _detachFromParent];
......@@ -830,7 +851,7 @@ - (void)_addChild:(WebFrame *)child
[[child dataSource] _setOverrideEncoding:[[self dataSource] _overrideEncoding]];
}
- (WebPluginController *)pluginController
- (WebPluginController *)_pluginController
{
if(!_private->pluginController){
_private->pluginController = [[WebPluginController alloc] initWithWebFrame:self];
......
......@@ -239,7 +239,7 @@ - (void)addSubview:(NSView *)view
[super addSubview:view];
if([view conformsToProtocol:@protocol(WebPlugin)]){
[[[self _frame] pluginController] didAddPluginView:view];
[[[self _frame] _pluginController] didAddPluginView:view];
}
}
......
......@@ -149,8 +149,8 @@ - (NSDictionary *)_elementAtPoint:(NSPoint)point
NSString *frameName = [elementInfoWC objectForKey:WebCoreElementLinkTarget];
if ([frameName length] == 0) {
[elementInfo setObject:webFrame forKey:WebElementLinkTargetFrameKey];
} else if (![frameName isEqualToString:@"_blank"]) {
[elementInfo _web_setObjectIfNotNil:[webFrame frameNamed:frameName] forKey:WebElementLinkTargetFrameKey];
} else {
[elementInfo _web_setObjectIfNotNil:[webFrame findFrameNamed:frameName] forKey:WebElementLinkTargetFrameKey];
}
[elementInfo setObject:webFrame forKey:WebElementFrameKey];
......
......@@ -224,7 +224,7 @@ - (WebFrame *)_frameInThisWindowNamed:(NSString *)name
if ([_private->topLevelFrameName isEqualToString:name]) {
return [self mainFrame];
} else {
return [[self mainFrame] frameNamed:name];
return [[self mainFrame] _descendantFrameNamed:name];
}
}
......
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