Commit 22c193be authored by mjs's avatar mjs

WebCore:

        Reviewed by Eric.

        Based on a patch by Eric.

        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=6180
        "text" output in fragment produced by XSLTProccessor is wrong (has xhtml garbage)

        * khtml/xsl/xslt_processorimpl.cpp:
        (DOM::xsltParamArrayFromParameterMap):
        (DOM::freeXsltParamArray):
        Use fastMalloc/fastFree.

        (DOM::createFragmentFromSource):
        If the output is "text", just create a text node and add
        it to the fragment.

WebKit:

        Reviewed by Darin.

	- move frame management and finding code from WebKit to WebCore
	http://bugzilla.opendarwin.org/show_bug.cgi?id=6368

        * Plugins.subproj/WebBaseNetscapePluginView.m:
        (-[WebBaseNetscapePluginView loadPluginRequest:]): Set frame name straight on the bridge,
	instead of having it bubble through the view and frame.
        * WebCoreSupport.subproj/WebBridge.m:
        (-[WebBridge initWithFrameName:view:]): don't pass name to frame, we own it now; set it
	on ourselves directly
	(-[WebBridge findFrameNamed:]): removed
        (-[WebBridge createWindowWithURL:frameName:]): set name on bridge, not webview
        (-[WebBridge createChildFrameNamed:withURL:referrer:renderPart:allowsScrolling:marginWidth:marginHeight:]):
        (-[WebBridge runModal]): remove excess braces
        * WebKit.xcodeproj/project.pbxproj:
        * WebView.subproj/WebControllerSets.h: Removed.
        * WebView.subproj/WebControllerSets.m: Removed.
        * WebView.subproj/WebFrame.m:
        (-[WebFramePrivate name]): removed
        (-[WebFramePrivate setName:]): removed
        (-[WebFramePrivate dealloc]): don't release name, we no longer have one
        (-[WebFrame _appendChild:]): removed
        (-[WebFrame _removeChild:]): removed
        (-[WebFrame _createItem:]): removed stray space
        (-[WebFrame _immediateChildFrameNamed:]): Just call the bridge
        (-[WebFrame _setName:]): removed
        (-[WebFrame _detachFromParent]): remove bridge from parent note self
        (-[WebFrame _continueLoadRequestAfterNewWindowPolicy:frameName:formState:]):
        (-[WebFrame _addChild:]): Call appendChild: on bridge, not self
        (-[WebFrame _nextFrameWithWrap:]): just call bridge (and moved helpers there)
        (-[WebFrame _previousFrameWithWrap:]): just call bridge (and moved helpers there)
        (-[WebFrame _initWithWebFrameView:webView:bridge:]): don't take a name any more
        (-[WebFrame _setFrameNamespace:]): just call bridge
        (-[WebFrame _frameNamespace]): just call bridge
        (-[WebFrame _hasSelection]): remove excess braces
        (-[WebFrame _clearSelection]): ditto
        (-[WebFrame initWithName:webFrameView:webView:]): no more name
        (-[WebFrame name]): just call bridge
        (-[WebFrame findFrameNamed:]): just call bridge (and moved helpers there)
        (-[WebFrame parentFrame]): fixed for new style
        * WebView.subproj/WebFrameInternal.h:
        * WebView.subproj/WebFramePrivate.h:
        * WebView.subproj/WebView.m:
        * WebView.subproj/WebViewPrivate.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@11882 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a5089b89
...@@ -174,6 +174,36 @@ ...@@ -174,6 +174,36 @@
(SVGSVGElementImpl::checkIntersection): QRect -> QRectF, removed integer conversions (SVGSVGElementImpl::checkIntersection): QRect -> QRectF, removed integer conversions
(SVGSVGElementImpl::checkEnclosure): QRect -> QRectF, removed integer conversions (SVGSVGElementImpl::checkEnclosure): QRect -> QRectF, removed integer conversions
2006-01-03 Maciej Stachowiak <mjs@apple.com>
Reviewed by Darin.
- move frame management and finding code from WebKit to WebCore
http://bugzilla.opendarwin.org/show_bug.cgi?id=6368
* WebCore.exp: export WebCoreFrameNamespace
* WebCore.xcodeproj/project.pbxproj: add new files
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::setName): Don't call to bridge any more, not needed
* kwq/WebCoreBridge.h:
* kwq/WebCoreBridge.mm:
(isCaseSensitiveEqual): helper function
(-[WebCoreBridge appendChild:]): remove excess braces
(-[WebCoreBridge childFrameNamed:]): moved here from WebFrame
(-[WebCoreBridge _deepLastChildFrame]): ditto
(-[WebCoreBridge nextFrameWithWrap:]): ditto
(-[WebCoreBridge previousFrameWithWrap:]): ditto
(-[WebCoreBridge setFrameNamespace:]): ditto
(-[WebCoreBridge frameNamespace]): ditto
(-[WebCoreBridge _shouldAllowAccessFrom:]): ditto
(-[WebCoreBridge _descendantFrameNamed:sourceFrame:]): ditto
(-[WebCoreBridge _frameInAnyWindowNamed:sourceFrame:]): ditto
(-[WebCoreBridge findFrameNamed:]): ditto
(-[WebCoreBridge setName:]): don't call KHTMLPart setName directly,
the kwq version is fine
(-[WebCoreBridge _addFramePathToString:]): moved from WebFrame
(-[WebCoreBridge generateFrameName]): ditto
2006-01-03 Maciej Stachowiak <mjs@apple.com> 2006-01-03 Maciej Stachowiak <mjs@apple.com>
Reviewed by Vicki. Reviewed by Vicki.
......
...@@ -106,6 +106,7 @@ ...@@ -106,6 +106,7 @@
.objc_class_name_WebCoreCache .objc_class_name_WebCoreCache
.objc_class_name_WebCoreCookieAdapter .objc_class_name_WebCoreCookieAdapter
.objc_class_name_WebCoreEncodings .objc_class_name_WebCoreEncodings
.objc_class_name_WebCoreFrameNamespaces
.objc_class_name_WebCoreGraphicsBridge .objc_class_name_WebCoreGraphicsBridge
.objc_class_name_WebCoreHistory .objc_class_name_WebCoreHistory
.objc_class_name_WebCoreImageRendererFactory .objc_class_name_WebCoreImageRendererFactory
......
...@@ -68,6 +68,8 @@ ...@@ -68,6 +68,8 @@
65436082083DB9FC00C20475 /* wrap_contents_in_dummy_span_command.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6543606E083DB9FB00C20475 /* wrap_contents_in_dummy_span_command.cpp */; }; 65436082083DB9FC00C20475 /* wrap_contents_in_dummy_span_command.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6543606E083DB9FB00C20475 /* wrap_contents_in_dummy_span_command.cpp */; };
654D87B70831973B0082DCA1 /* edit_command.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 654D87B50831973B0082DCA1 /* edit_command.cpp */; }; 654D87B70831973B0082DCA1 /* edit_command.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 654D87B50831973B0082DCA1 /* edit_command.cpp */; };
654D87B80831973B0082DCA1 /* edit_command.h in Headers */ = {isa = PBXBuildFile; fileRef = 654D87B60831973B0082DCA1 /* edit_command.h */; }; 654D87B80831973B0082DCA1 /* edit_command.h in Headers */ = {isa = PBXBuildFile; fileRef = 654D87B60831973B0082DCA1 /* edit_command.h */; };
6552E7AA096AA11B0006F248 /* WebCoreFrameNamespaces.h in Headers */ = {isa = PBXBuildFile; fileRef = 6552E7A8096AA11B0006F248 /* WebCoreFrameNamespaces.h */; settings = {ATTRIBUTES = (Private, ); }; };
6552E7AB096AA11B0006F248 /* WebCoreFrameNamespaces.m in Sources */ = {isa = PBXBuildFile; fileRef = 6552E7A9096AA11B0006F248 /* WebCoreFrameNamespaces.m */; };
65AC79A10831ED6D009385CE /* append_node_command.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65AC799F0831ED6D009385CE /* append_node_command.cpp */; }; 65AC79A10831ED6D009385CE /* append_node_command.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65AC799F0831ED6D009385CE /* append_node_command.cpp */; };
65AC79A20831ED6D009385CE /* append_node_command.h in Headers */ = {isa = PBXBuildFile; fileRef = 65AC79A00831ED6D009385CE /* append_node_command.h */; }; 65AC79A20831ED6D009385CE /* append_node_command.h in Headers */ = {isa = PBXBuildFile; fileRef = 65AC79A00831ED6D009385CE /* append_node_command.h */; };
65AC79A90831F006009385CE /* apply_style_command.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65AC79A70831F006009385CE /* apply_style_command.cpp */; }; 65AC79A90831F006009385CE /* apply_style_command.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65AC79A70831F006009385CE /* apply_style_command.cpp */; };
...@@ -1700,6 +1702,8 @@ ...@@ -1700,6 +1702,8 @@
654D87B60831973B0082DCA1 /* edit_command.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; name = edit_command.h; path = editing/edit_command.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; 654D87B60831973B0082DCA1 /* edit_command.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; name = edit_command.h; path = editing/edit_command.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
654E7EE00569FD4600358BD2 /* xmlhttprequest.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = xmlhttprequest.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; 654E7EE00569FD4600358BD2 /* xmlhttprequest.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = xmlhttprequest.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
654E7EE10569FD4600358BD2 /* xmlhttprequest.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = xmlhttprequest.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; 654E7EE10569FD4600358BD2 /* xmlhttprequest.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = xmlhttprequest.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
6552E7A8096AA11B0006F248 /* WebCoreFrameNamespaces.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCoreFrameNamespaces.h; sourceTree = "<group>"; };
6552E7A9096AA11B0006F248 /* WebCoreFrameNamespaces.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = WebCoreFrameNamespaces.m; sourceTree = "<group>"; };
65732B68054EF483007B42F8 /* KWQKPartsPart.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = KWQKPartsPart.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; 65732B68054EF483007B42F8 /* KWQKPartsPart.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = KWQKPartsPart.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
65912B0D0586921000123A69 /* xmlserializer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = xmlserializer.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; 65912B0D0586921000123A69 /* xmlserializer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = xmlserializer.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
65912B0E0586921000123A69 /* xmlserializer.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = xmlserializer.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; 65912B0E0586921000123A69 /* xmlserializer.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = xmlserializer.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
...@@ -3945,6 +3949,8 @@ ...@@ -3945,6 +3949,8 @@
F58785E902DE378A01EA4122 /* WebCore SPI */ = { F58785E902DE378A01EA4122 /* WebCore SPI */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
6552E7A8096AA11B0006F248 /* WebCoreFrameNamespaces.h */,
6552E7A9096AA11B0006F248 /* WebCoreFrameNamespaces.m */,
F587854702DE375901EA4122 /* WebCoreBridge.h */, F587854702DE375901EA4122 /* WebCoreBridge.h */,
F587854802DE375901EA4122 /* WebCoreBridge.mm */, F587854802DE375901EA4122 /* WebCoreBridge.mm */,
F5B2A4FC02E2220F018635CB /* WebCoreCache.h */, F5B2A4FC02E2220F018635CB /* WebCoreCache.h */,
...@@ -4719,6 +4725,7 @@ ...@@ -4719,6 +4725,7 @@
A88AD5180952499F001DD196 /* RGBColorImpl.h in Headers */, A88AD5180952499F001DD196 /* RGBColorImpl.h in Headers */,
A88AD5190952499F001DD196 /* KDOMHeaders.h in Headers */, A88AD5190952499F001DD196 /* KDOMHeaders.h in Headers */,
A88AD51A0952499F001DD196 /* KDOMSettings.h in Headers */, A88AD51A0952499F001DD196 /* KDOMSettings.h in Headers */,
6552E7AA096AA11B0006F248 /* WebCoreFrameNamespaces.h in Headers */,
4756536509652C5D00BD9F29 /* KWQPointF.h in Headers */, 4756536509652C5D00BD9F29 /* KWQPointF.h in Headers */,
4756536709652C5D00BD9F29 /* KWQRectF.h in Headers */, 4756536709652C5D00BD9F29 /* KWQRectF.h in Headers */,
4756536909652C5D00BD9F29 /* KWQSizeF.h in Headers */, 4756536909652C5D00BD9F29 /* KWQSizeF.h in Headers */,
...@@ -6561,6 +6568,7 @@ ...@@ -6561,6 +6568,7 @@
A88AD51D0952499F001DD196 /* XLinkNamesWrapper.cpp in Sources */, A88AD51D0952499F001DD196 /* XLinkNamesWrapper.cpp in Sources */,
A88AD51E0952499F001DD196 /* SVGNamesWrapper.cpp in Sources */, A88AD51E0952499F001DD196 /* SVGNamesWrapper.cpp in Sources */,
A88AD5AA09525131001DD196 /* SVGCSSStyleSelector.cpp in Sources */, A88AD5AA09525131001DD196 /* SVGCSSStyleSelector.cpp in Sources */,
6552E7AB096AA11B0006F248 /* WebCoreFrameNamespaces.m in Sources */,
4756536609652C5D00BD9F29 /* KWQPointF.mm in Sources */, 4756536609652C5D00BD9F29 /* KWQPointF.mm in Sources */,
4756536809652C5D00BD9F29 /* KWQRectF.mm in Sources */, 4756536809652C5D00BD9F29 /* KWQRectF.mm in Sources */,
4756536A09652C5D00BD9F29 /* KWQSizeF.mm in Sources */, 4756536A09652C5D00BD9F29 /* KWQSizeF.mm in Sources */,
......
...@@ -3825,15 +3825,11 @@ void KWQKHTMLPart::setName(const QString &name) ...@@ -3825,15 +3825,11 @@ void KWQKHTMLPart::setName(const QString &name)
KWQKHTMLPart *parent = KWQ(parentPart()); KWQKHTMLPart *parent = KWQ(parentPart());
if (parent && (name.isEmpty() || parent->frameExists(name))) { // FIXME: is the blank rule needed or useful?
if (parent && (name.isEmpty() || parent->frameExists(name)) || name == "_blank")
n = parent->requestFrameName(); n = parent->requestFrameName();
}
KHTMLPart::setName(n); KHTMLPart::setName(n);
KWQ_BLOCK_EXCEPTIONS;
[_bridge didSetName:n.getNSString()];
KWQ_UNBLOCK_EXCEPTIONS;
} }
void KWQKHTMLPart::didTellBridgeAboutLoad(const QString &urlString) void KWQKHTMLPart::didTellBridgeAboutLoad(const QString &urlString)
......
...@@ -196,6 +196,8 @@ typedef enum ...@@ -196,6 +196,8 @@ typedef enum
WebCoreBridge *_firstChild; WebCoreBridge *_firstChild;
WebCoreBridge *_lastChild; WebCoreBridge *_lastChild;
int _childCount; int _childCount;
NSString *_frameNamespace;
} }
+ (WebCoreBridge *)bridgeForDOMDocument:(DOMDocument *)document; + (WebCoreBridge *)bridgeForDOMDocument:(DOMDocument *)document;
...@@ -209,6 +211,8 @@ typedef enum ...@@ -209,6 +211,8 @@ typedef enum
- (void)setName:(NSString *)name; - (void)setName:(NSString *)name;
- (NSString *)name; - (NSString *)name;
/* Creates a name for an frame unnamed in the HTML. It should produce repeatable results for loads of the same frameset. */
- (NSString *)generateFrameName;
- (KWQKHTMLPart *)part; - (KWQKHTMLPart *)part;
...@@ -227,6 +231,14 @@ typedef enum ...@@ -227,6 +231,14 @@ typedef enum
- (BOOL)isDescendantOfFrame:(WebCoreBridge *)ancestor; - (BOOL)isDescendantOfFrame:(WebCoreBridge *)ancestor;
- (WebCoreBridge *)traverseNextFrameStayWithin:(WebCoreBridge *)stayWithin; - (WebCoreBridge *)traverseNextFrameStayWithin:(WebCoreBridge *)stayWithin;
- (WebCoreBridge *)nextFrameWithWrap:(BOOL)wrap;
- (WebCoreBridge *)previousFrameWithWrap:(BOOL)wrap;
- (WebCoreBridge *)childFrameNamed:(NSString *)name;
- (WebCoreBridge *)findFrameNamed:(NSString *)name;
- (void)setFrameNamespace:(NSString *)ns;
- (NSString *)frameNamespace;
- (void)provisionalLoadStarted; - (void)provisionalLoadStarted;
- (void)openURL:(NSURL *)URL reload:(BOOL)reload - (void)openURL:(NSURL *)URL reload:(BOOL)reload
...@@ -487,9 +499,6 @@ typedef enum ...@@ -487,9 +499,6 @@ typedef enum
@protocol WebCoreBridge @protocol WebCoreBridge
- (WebCoreBridge *)mainFrame; - (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. */
- (NSString *)generateFrameName;
- (void)frameDetached; - (void)frameDetached;
- (NSView *)documentView; - (NSView *)documentView;
- (WebView *)webView; - (WebView *)webView;
...@@ -626,8 +635,6 @@ typedef enum ...@@ -626,8 +635,6 @@ typedef enum
- (WebCoreKeyboardUIMode)keyboardUIMode; - (WebCoreKeyboardUIMode)keyboardUIMode;
- (void)didSetName:(NSString *)name;
- (NSFileWrapper *)fileWrapperForURL:(NSURL *)URL; - (NSFileWrapper *)fileWrapperForURL:(NSURL *)URL;
- (void)print; - (void)print;
......
...@@ -84,6 +84,7 @@ ...@@ -84,6 +84,7 @@
#import "WebCoreTextRendererFactory.h" #import "WebCoreTextRendererFactory.h"
#import "WebCoreViewFactory.h" #import "WebCoreViewFactory.h"
#import "WebCoreSettings.h" #import "WebCoreSettings.h"
#import "WebCoreFrameNamespaces.h"
@class NSView; @class NSView;
...@@ -146,13 +147,13 @@ using KJS::Bindings::RootObject; ...@@ -146,13 +147,13 @@ using KJS::Bindings::RootObject;
NSString *WebCoreElementDOMNodeKey = @"WebElementDOMNode"; NSString *WebCoreElementDOMNodeKey = @"WebElementDOMNode";
NSString *WebCoreElementFrameKey = @"WebElementFrame"; NSString *WebCoreElementFrameKey = @"WebElementFrame";
NSString *WebCoreElementImageAltStringKey = @"WebElementImageAltString"; NSString *WebCoreElementImageAltStringKey = @"WebElementImageAltString";
NSString *WebCoreElementImageRendererKey = @"WebCoreElementImageRenderer"; NSString *WebCoreElementImageRendererKey = @"WebCoreElementImageRenderer";
NSString *WebCoreElementImageRectKey = @"WebElementImageRect"; NSString *WebCoreElementImageRectKey = @"WebElementImageRect";
NSString *WebCoreElementImageURLKey = @"WebElementImageURL"; NSString *WebCoreElementImageURLKey = @"WebElementImageURL";
NSString *WebCoreElementIsSelectedKey = @"WebElementIsSelected"; NSString *WebCoreElementIsSelectedKey = @"WebElementIsSelected";
NSString *WebCoreElementLinkURLKey = @"WebElementLinkURL"; NSString *WebCoreElementLinkURLKey = @"WebElementLinkURL";
NSString *WebCoreElementLinkTargetFrameKey = @"WebElementTargetFrame"; NSString *WebCoreElementLinkTargetFrameKey = @"WebElementTargetFrame";
NSString *WebCoreElementLinkLabelKey = @"WebElementLinkLabel"; NSString *WebCoreElementLinkLabelKey = @"WebElementLinkLabel";
NSString *WebCoreElementLinkTitleKey = @"WebElementLinkTitle"; NSString *WebCoreElementLinkTitleKey = @"WebElementLinkTitle";
NSString *WebCoreElementNameKey = @"WebElementName"; NSString *WebCoreElementNameKey = @"WebElementName";
...@@ -219,6 +220,11 @@ static BOOL hasCaseInsensitivePrefix(NSString *string, NSString *prefix) ...@@ -219,6 +220,11 @@ static BOOL hasCaseInsensitivePrefix(NSString *string, NSString *prefix)
NSNotFound; NSNotFound;
} }
static BOOL isCaseSensitiveEqual(NSString *a, NSString *b)
{
return [a caseInsensitiveCompare:b] == NSOrderedSame;
}
@implementation WebCoreBridge @implementation WebCoreBridge
static bool initializedObjectCacheSize = FALSE; static bool initializedObjectCacheSize = FALSE;
...@@ -300,9 +306,8 @@ static bool initializedKJS = FALSE; ...@@ -300,9 +306,8 @@ static bool initializedKJS = FALSE;
if (last) { if (last) {
last->_nextSibling = child; last->_nextSibling = child;
child->_previousSibling = last; child->_previousSibling = last;
} else { } else
_firstChild = child; _firstChild = child;
}
_lastChild = child; _lastChild = child;
...@@ -331,6 +336,175 @@ static bool initializedKJS = FALSE; ...@@ -331,6 +336,175 @@ static bool initializedKJS = FALSE;
[child release]; [child release];
} }
- (WebCoreBridge *)childFrameNamed:(NSString *)name
{
// FIXME: with a better data structure this could be O(1) instead of O(n) in number
// of child frames
for (WebCoreBridge *child = [self firstChild]; child; child = [child nextSibling])
if ([[child name] isEqualToString:name])
return child;
return nil;
}
// Returns the last child of us and any children, or self
- (WebCoreBridge *)_deepLastChildFrame
{
WebCoreBridge *result = self;
for (WebCoreBridge *lastChild = [self lastChild]; lastChild; lastChild = [lastChild lastChild])
result = lastChild;
return result;
}
// Return next frame to be traversed, visiting children after parent
- (WebCoreBridge *)nextFrameWithWrap:(BOOL)wrapFlag
{
WebCoreBridge *result = [self traverseNextFrameStayWithin:nil];
if (!result && wrapFlag)
return [self mainFrame];
return result;
}
// Return previous frame to be traversed, exact reverse order of _nextFrame
- (WebCoreBridge *)previousFrameWithWrap:(BOOL)wrapFlag
{
// FIXME: besides the wrap feature, this is just the traversePreviousNode algorithm
WebCoreBridge *prevSibling = [self previousSibling];
if (prevSibling)
return [prevSibling _deepLastChildFrame];
if ([self parent])
return [self parent];
// no siblings, no parent, self==top
if (wrapFlag)
return [self _deepLastChildFrame];
// top view is always the last one in this ordering, so prev is nil without wrap
return nil;
}
- (void)setFrameNamespace:(NSString *)ns
{
ASSERT(self == [self mainFrame]);
if (ns != _frameNamespace){
[WebCoreFrameNamespaces removeFrame:self fromNamespace:_frameNamespace];
ns = [ns copy];
[_frameNamespace release];
_frameNamespace = ns;
[WebCoreFrameNamespaces addFrame:self toNamespace:_frameNamespace];
}
}
- (NSString *)frameNamespace
{
ASSERT(self == [self mainFrame]);
return _frameNamespace;
}
- (BOOL)_shouldAllowAccessFrom:(WebCoreBridge *)source
{
// if no source frame, allow access
if (source == nil)
return YES;
// - allow access if the two frames are in the same window
if ([self mainFrame] == [source mainFrame])
return YES;
// - allow if the request is made from a local file.
NSString *sourceDomain = [self domain];
if ([sourceDomain length] == 0)
return YES;
// - allow access if this frame or one of its ancestors
// has the same origin as source
for (WebCoreBridge *ancestor = self; ancestor; ancestor = [ancestor parent]) {
NSString *ancestorDomain = [ancestor domain];
if (ancestorDomain != nil &&
isCaseSensitiveEqual(sourceDomain, ancestorDomain))
return YES;
ancestor = [ancestor parent];
}
// - allow access if this frame is a toplevel window and the source
// can access its opener. Note that we only allow one level of
// recursion here.
if ([self parent] == nil) {
NSString *openerDomain = [[self opener] domain];
if (openerDomain != nil && isCaseSensitiveEqual(sourceDomain, openerDomain))
return YES;
}
// otherwise deny access
return NO;
}
- (WebCoreBridge *)_descendantFrameNamed:(NSString *)name sourceFrame:(WebCoreBridge *)source
{
for (WebCoreBridge *frame = self; frame; frame = [frame traverseNextFrameStayWithin:self])
// for security reasons, we do not want to even make frames visible to frames that
// can't access them
if ([[frame name] isEqualToString:name] && [frame _shouldAllowAccessFrom:source])
return frame;
return nil;
}
- (WebCoreBridge *)_frameInAnyWindowNamed:(NSString *)name sourceFrame:(WebCoreBridge *)source
{
ASSERT(self == [self mainFrame]);
// Try this WebView first.
WebCoreBridge *frame = [self _descendantFrameNamed:name sourceFrame:source];
if (frame != nil)
return frame;
// Try other WebViews in the same set
if ([self frameNamespace] != nil) {
NSEnumerator *enumerator = [WebCoreFrameNamespaces framesInNamespace:[self frameNamespace]];
WebCoreBridge *searchFrame;
while ((searchFrame = [enumerator nextObject]))
frame = [searchFrame _descendantFrameNamed:name sourceFrame:source];
}
return frame;
}
- (WebCoreBridge *)findFrameNamed:(NSString *)name
{
// First, deal with 'special' names.
if ([name isEqualToString:@"_self"] || [name isEqualToString:@"_current"])
return self;
if ([name isEqualToString:@"_top"])
return [self mainFrame];
if ([name isEqualToString:@"_parent"]) {
WebCoreBridge *parent = [self parent];
return parent ? parent : self;
}
if ([name isEqualToString:@"_blank"])
return nil;
// Search from this frame down.
WebCoreBridge *frame = [self _descendantFrameNamed:name sourceFrame:self];
// Search in the main frame for this window then in others.
if (!frame)
frame = [[self mainFrame] _frameInAnyWindowNamed:name sourceFrame:self];
return frame;
}
+ (NSArray *)supportedMIMETypes + (NSArray *)supportedMIMETypes
{ {
return [NSArray arrayWithObjects: return [NSArray arrayWithObjects:
...@@ -459,7 +633,7 @@ static bool initializedKJS = FALSE; ...@@ -459,7 +633,7 @@ static bool initializedKJS = FALSE;
if (pageCache) { if (pageCache) {
KWQPageState *state = [pageCache objectForKey:WebCorePageCacheStateKey]; KWQPageState *state = [pageCache objectForKey:WebCorePageCacheStateKey];
_part->openURLFromPageCache(state); _part->openURLFromPageCache(state);
[state invalidate]; [state invalidate];
return; return;
} }
...@@ -794,7 +968,7 @@ static bool initializedKJS = FALSE; ...@@ -794,7 +968,7 @@ static bool initializedKJS = FALSE;
if (doc) { if (doc) {
static QPaintDevice screen; static QPaintDevice screen;
static QPrinter printer; static QPrinter printer;
doc->setPaintDevice(deviceType == WebCoreDeviceScreen ? &screen : &printer); doc->setPaintDevice(deviceType == WebCoreDeviceScreen ? &screen : &printer);
} }
return _part->reparseConfiguration(); return _part->reparseConfiguration();
} }
...@@ -875,7 +1049,7 @@ static BOOL nowPrinting(WebCoreBridge *self) ...@@ -875,7 +1049,7 @@ static BOOL nowPrinting(WebCoreBridge *self)
ERROR("printHeight has bad value %.2f", printHeight); ERROR("printHeight has bad value %.2f", printHeight);
return pages; return pages;
} }
if (!_part || !_part->xmlDocImpl() || !_part->view()) return pages; if (!_part || !_part->xmlDocImpl() || !_part->view()) return pages;
RenderCanvas* root = static_cast<khtml::RenderCanvas *>(_part->xmlDocImpl()->renderer()); RenderCanvas* root = static_cast<khtml::RenderCanvas *>(_part->xmlDocImpl()->renderer());
if (!root) return pages; if (!root) return pages;
...@@ -884,7 +1058,7 @@ static BOOL nowPrinting(WebCoreBridge *self) ...@@ -884,7 +1058,7 @@ static BOOL nowPrinting(WebCoreBridge *self)
NSView* documentView = view->getDocumentView(); NSView* documentView = view->getDocumentView();
if (!documentView) if (!documentView)
return pages; return pages;
float currPageHeight = printHeight; float currPageHeight = printHeight;
float docHeight = root->layer()->height(); float docHeight = root->layer()->height();
float docWidth = root->layer()->width(); float docWidth = root->layer()->width();
...@@ -1115,7 +1289,7 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element) ...@@ -1115,7 +1289,7 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
if (formElement) { if (formElement) {
QPtrVector<HTMLGenericFormElementImpl> &elements = formElement->formElements; QPtrVector<HTMLGenericFormElementImpl> &elements = formElement->formElements;
for (unsigned int i = 0; i < elements.count(); i++) { for (unsigned int i = 0; i < elements.count(); i++) {
if (elements.at(i)->isEnumeratable()) { // Skip option elements, other duds if (elements.at(i)->isEnumeratable()) { // Skip option elements, other duds
DOMElement *de = [DOMElement _elementWithImpl:elements.at(i)]; DOMElement *de = [DOMElement _elementWithImpl:elements.at(i)];
if (!results) { if (!results) {
results = [NSMutableArray arrayWithObject:de]; results = [NSMutableArray arrayWithObject:de];
...@@ -1450,7 +1624,7 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element) ...@@ -1450,7 +1624,7 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
- (void)setName:(NSString *)name - (void)setName:(NSString *)name
{ {
_part->KHTMLPart::setName(QString::fromNSString(name)); _part->setName(QString::fromNSString(name));
} }
- (NSString *)name - (NSString *)name
...@@ -1458,6 +1632,38 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element) ...@@ -1458,6 +1632,38 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
return _part->name().getNSString(); return _part->name().getNSString();
} }
- (void)_addFramePathToString:(NSMutableString *)path
{
NSString *name = [self name];
if ([name hasPrefix:@"<!--framePath "]) {
// we have a generated name - take the path from our name
NSRange ourPathRange = {14, [name length] - 14 - 3};
[path appendString:[name substringWithRange:ourPathRange]];
} else {
// we don't have a generated name - just add our simple name to the end
[[self parent] _addFramePathToString:path];
[path appendString:@"/"];
if (name)
[path appendString:name];
}
}
// Generate a repeatable name for a child about to be added to us. The name must be
// unique within the frame tree. The string we generate includes a "path" of names
// from the root frame down to us. For this path to be unique, each set of siblings must
// contribute a unique name to the path, which can't collide with any HTML-assigned names.
// We generate this path component by index in the child list along with an unlikely frame name.
- (NSString *)generateFrameName
{
NSMutableString *path = [NSMutableString stringWithCapacity:256];
[path insertString:@"<!--framePath " atIndex:0];
[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-->-->", [self childCount]];
return path;
}
- (NSURL *)URL - (NSURL *)URL
{ {
return _part->url().getNSURL(); return _part->url().getNSURL();
......
...@@ -28,10 +28,10 @@ ...@@ -28,10 +28,10 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@class WebFrame; @class WebCoreBridge;
@interface WebFrameNamespaces : NSObject @interface WebCoreFrameNamespaces : NSObject
+ (void)addFrame:(WebFrame *)frame toNamespace:(NSString *)name; + (void)addFrame:(WebCoreBridge *)frame toNamespace:(NSString *)name;
+ (void)removeFrame:(WebFrame *)frame fromNamespace:(NSString *)name; + (void)removeFrame:(WebCoreBridge *)frame fromNamespace:(NSString *)name;
+ (NSEnumerator *)framesInNamespace:(NSString *)name; + (NSEnumerator *)framesInNamespace:(NSString *)name;
@end @end
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#import <WebKit/WebControllerSets.h> #import "WebCoreFrameNamespaces.h"
static CFSetCallBacks NonRetainingSetCallbacks = { static CFSetCallBacks NonRetainingSetCallbacks = {
0, 0,
...@@ -37,11 +37,11 @@ ...@@ -37,11 +37,11 @@
CFHash CFHash