[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
kocienda
kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:28:11 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit bb0f45201ace459aa63735b00c52281f7875c9d2
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Mar 2 17:03:56 2004 +0000
WebCore:
Reviewed by me
Rollout last night's checkin. The tree was closed.
* kwq/DOM.h
* kwq/DOM.mm
* kwq/DOMInternal.h
* kwq/KWQKHTMLPart.mm
* kwq/WebCoreBridge.mm
WebKit:
Reviewed by me
* DOM.subproj/DOM.h: Rollout last night's checkin.
The tree was closed.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6152 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 913dca2..e69d5f4 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,5 +1,17 @@
2004-03-01 Ken Kocienda <kocienda at apple.com>
+ Reviewed by me
+
+ Rollout last night's checkin. The tree was closed.
+
+ * kwq/DOM.h
+ * kwq/DOM.mm
+ * kwq/DOMInternal.h
+ * kwq/KWQKHTMLPart.mm
+ * kwq/WebCoreBridge.mm
+
+2004-03-01 Ken Kocienda <kocienda at apple.com>
+
Reviewed by me, changes by Darin.
Yet another pass at the DOM API, this one by
diff --git a/WebCore/kwq/DOM.h b/WebCore/kwq/DOM.h
index f997918..1795c1f 100644
--- a/WebCore/kwq/DOM.h
+++ b/WebCore/kwq/DOM.h
@@ -23,8 +23,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#import <Foundation/Foundation.h>
-
//=========================================================================
//=========================================================================
//=========================================================================
@@ -73,27 +71,28 @@ enum DOMErrorCode {
extern NSString * const DOMErrorDomain;
+ at class NSError;
+ at class NSString;
+
+ at class DOMNode;
+ at class DOMNamedNodeMap;
+ at class DOMNodeList;
+ at class DOMDocumentFragment;
+ at class DOMDocument;
+ at class DOMCharacterData;
@class DOMAttr;
- at class DOMCDATASection;
+ at class DOMElement;
+ at class DOMText;
@class DOMComment;
- at class DOMDocument;
+ at class DOMCDATASection;
@class DOMDocumentType;
- at class DOMElement;
+ at class DOMNotation;
+ at class DOMEntity;
@class DOMEntityReference;
- at class DOMNamedNodeMap;
- at class DOMNodeList;
@class DOMProcessingInstruction;
- at class DOMText;
-
-typedef struct DOMObjectInternal DOMObjectInternal;
+ at class DOMRange;
- at interface DOMObject : NSObject <NSCopying>
-{
- DOMObjectInternal *_internal;
-}
- at end
-
- at interface DOMNode : DOMObject
+ at interface DOMNode : NSObject <NSCopying>
- (NSString *)nodeName;
- (NSString *)nodeValue;
- (void)setNodeValue:(NSString *)string error:(NSError **)error;
@@ -122,7 +121,7 @@ typedef struct DOMObjectInternal DOMObjectInternal;
- (NSString *)HTMLString;
@end
- at interface DOMNamedNodeMap : DOMObject
+ at interface DOMNamedNodeMap : NSObject <NSCopying>
- (DOMNode *)getNamedItem:(NSString *)name;
- (DOMNode *)setNamedItem:(DOMNode *)arg error:(NSError **)error;
- (DOMNode *)removeNamedItem:(NSString *)name error:(NSError **)error;
@@ -134,13 +133,13 @@ typedef struct DOMObjectInternal DOMObjectInternal;
@end
- at interface DOMNodeList : DOMObject
+ at interface DOMNodeList : NSObject <NSCopying>
- (DOMNode *)item:(unsigned long)index;
- (unsigned long)length;
@end
- at interface DOMImplementation : DOMObject
+ at interface DOMImplementation : NSObject <NSCopying>
- (BOOL)hasFeature:(NSString *)feature :(NSString *)version;
- (DOMDocumentType *)createDocumentType:(NSString *)qualifiedName :(NSString *)publicId :(NSString *)systemId error:(NSError **)error;
- (DOMDocument *)createDocument:(NSString *)namespaceURI :(NSString *)qualifiedName :(DOMDocumentType *)doctype error:(NSError **)error;
@@ -268,7 +267,7 @@ enum DOMCompareHow
DOMCompareEndToStart = 3,
};
- at interface DOMRange : DOMObject
+ at interface DOMRange : NSObject
- (DOMNode *)startContainer:(NSError **)error;
- (long)startOffset:(NSError **)error;
- (DOMNode *)endContainer:(NSError **)error;
@@ -294,3 +293,4 @@ enum DOMCompareHow
- (NSString *)toString:(NSError **)error;
- (void)detach:(NSError **)error;
@end
+
diff --git a/WebCore/kwq/DOM.mm b/WebCore/kwq/DOM.mm
index 15f0121..e19ea64 100644
--- a/WebCore/kwq/DOM.mm
+++ b/WebCore/kwq/DOM.mm
@@ -23,8 +23,13 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#import "DOM.h"
#import "DOMInternal.h"
+#import <Foundation/Foundation.h>
+
+#include <objc/objc-class.h>
+
#import <dom/dom_doc.h>
#import <dom/dom_element.h>
#import <dom/dom_exception.h>
@@ -42,11 +47,14 @@
#import <xml/dom2_rangeimpl.h>
#import "KWQAssertions.h"
+#import "KWQLogging.h"
using DOM::Attr;
using DOM::AttrImpl;
+using DOM::CDATASectionImpl;
using DOM::CharacterData;
using DOM::CharacterDataImpl;
+using DOM::CommentImpl;
using DOM::DocumentFragmentImpl;
using DOM::DocumentType;
using DOM::DocumentTypeImpl;
@@ -59,6 +67,7 @@ using DOM::DOMStringImpl;
using DOM::Element;
using DOM::ElementImpl;
using DOM::EntityImpl;
+using DOM::EntityReferenceImpl;
using DOM::NamedNodeMap;
using DOM::NamedNodeMapImpl;
using DOM::Node;
@@ -73,156 +82,158 @@ using DOM::RangeImpl;
using DOM::Text;
using DOM::TextImpl;
- at interface DOMNamedNodeMap (WebCoreInternal)
-+ (DOMNamedNodeMap *)namedNodeMapWithImpl:(NamedNodeMapImpl *)impl;
- at end
-
- at interface DOMNodeList (WebCoreInternal)
-+ (DOMNodeList *)nodeListWithImpl:(NodeListImpl *)impl;
- at end
-
- at interface DOMImplementation (WebCoreInternal)
-+ (DOMImplementation *)DOMImplementationWithImpl:(DOMImplementationImpl *)impl;
- at end
-
- at interface DOMDocumentFragment (WebCoreInternal)
-+ (DOMDocumentFragment *)documentFragmentWithImpl:(DocumentFragmentImpl *)impl;
- at end
-
- at interface DOMAttr (WebCoreInternal)
-+ (DOMAttr *)attrWithImpl:(AttrImpl *)impl;
-- (AttrImpl *)attrImpl;
- at end
-
- at interface DOMRange (WebCoreInternal)
-+ (DOMRange *)rangeWithImpl:(RangeImpl *)impl;
- at end
+ at class WebCoreDOMAttr;
+ at class WebCoreDOMCDATASection;
+ at class WebCoreDOMCharacterData;
+ at class WebCoreDOMComment;
+ at class WebCoreDOMDocumentFragment;
+ at class WebCoreDOMDocumentType;
+ at class WebCoreDOMDocument;
+ at class WebCoreDOMImplementation;
+ at class WebCoreDOMElement;
+ at class WebCoreDOMEntity;
+ at class WebCoreDOMEntityReference;
+ at class WebCoreDOMNamedNodeMap;
+ at class WebCoreDOMNode;
+ at class WebCoreDOMNodeList;
+ at class WebCoreDOMNotation;
+ at class WebCoreDOMProcessingInstruction;
+ at class WebCoreDOMRange;
+ at class WebCoreDOMText;
//------------------------------------------------------------------------------------------
// Static functions and data
NSString * const DOMErrorDomain = @"DOMErrorDomain";
-static CFMutableDictionaryRef wrapperCache = NULL;
+static CFMutableDictionaryRef wrapperCache(void)
+{
+ static CFMutableDictionaryRef wrapperCache = NULL;
+ if (!wrapperCache) {
+ // No need to retain/free either impl key, or id value. Items will be removed
+ // from the cache in WebCoreDOMNode's dealloc method.
+ wrapperCache = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
+ }
+ return wrapperCache;
+}
static id wrapperForImpl(const void *impl)
{
- if (!wrapperCache)
- return nil;
- return (id)CFDictionaryGetValue(wrapperCache, impl);
+ return (id)CFDictionaryGetValue(wrapperCache(), impl);
}
static void setWrapperForImpl(id wrapper, const void *impl)
{
- if (!wrapperCache) {
- // No need to retain/free either impl key, or id value. Items will be removed
- // from the cache in dealloc methods.
- wrapperCache = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
- }
- CFDictionarySetValue(wrapperCache, impl, wrapper);
+ CFDictionarySetValue(wrapperCache(), impl, wrapper);
}
static void removeWrapperForImpl(const void *impl)
{
- if (!wrapperCache)
- return;
- CFDictionaryRemoveValue(wrapperCache, impl);
+ CFDictionaryRemoveValue(wrapperCache(), impl);
}
static NSString *DOMStringToNSString(const DOMString &aString)
{
- return [NSString stringWithCharacters:reinterpret_cast<const unichar *>(aString.unicode()) length:aString.length()];
+ return [NSString stringWithCharacters:(unichar *)aString.unicode() length:aString.length()];
}
static DOMString NSStringToDOMString(NSString *aString)
{
- ASSERT(aString);
-
- CFIndex size = CFStringGetLength(reinterpret_cast<CFStringRef>(aString));
- UniChar fixedSizeBuffer[1024];
- UniChar *buffer;
- if (size > static_cast<CFIndex>(sizeof(fixedSizeBuffer) / sizeof(UniChar))) {
- buffer = static_cast<UniChar *>(malloc(size * sizeof(UniChar)));
- } else {
- buffer = fixedSizeBuffer;
- }
- CFStringGetCharacters(reinterpret_cast<CFStringRef>(aString), CFRangeMake(0, size), buffer);
- DOMString ret(reinterpret_cast<const QChar *>(buffer), (uint)size);
- if (buffer != fixedSizeBuffer) {
- free(buffer);
- }
+ QChar *chars = (QChar *)malloc([aString length] * sizeof(QChar));
+ [aString getCharacters:(unichar *)chars];
+ DOMString ret(chars, [aString length]);
+ free(chars);
return ret;
}
static void fillInError(NSError **error, int code)
{
- if (!error)
+ if (!error || !code)
return;
- if (!code)
- *error = nil;
- else
- *error = [NSError errorWithDomain:DOMErrorDomain code:code userInfo:nil];
+
+ *error = [NSError errorWithDomain:DOMErrorDomain code:code userInfo:nil];
}
+#define AbstractMethodCalled(absClass) do { \
+ if ([self class] == absClass) \
+ [NSException raise:NSInvalidArgumentException format:@"*** -%s cannot be sent to an abstract object of class %s: You must create a concrete instance.", sel_getName(_cmd), absClass->name]; \
+ else \
+ [NSException raise:NSInvalidArgumentException format:@"*** -%s only defined for abstract class. You must define -[%s %s]", sel_getName(_cmd), object_getClassName(self), sel_getName(_cmd)]; \
+ } while (0)
+
//------------------------------------------------------------------------------------------
// Factory methods
-inline NamedNodeMap NamedNodeMapImpl::createInstance(NamedNodeMapImpl *impl)
+NodeList NodeListImpl::createInstance(NodeListImpl *impl)
+{
+ return NodeList(impl);
+}
+
+NamedNodeMap NamedNodeMapImpl::createInstance(NamedNodeMapImpl *impl)
{
return NamedNodeMap(impl);
}
-inline Attr AttrImpl::createInstance(AttrImpl *impl)
+Attr AttrImpl::createInstance(AttrImpl *impl)
{
return Attr(impl);
}
-inline Element ElementImpl::createInstance(ElementImpl *impl)
+Element ElementImpl::createInstance(ElementImpl *impl)
{
return Element(impl);
}
-inline DocumentType DocumentTypeImpl::createInstance(DocumentTypeImpl *impl)
+CharacterData CharacterDataImpl::createInstance(CharacterDataImpl *impl)
{
- return DocumentType(impl);
+ return CharacterData(impl);
}
-inline Document DocumentImpl::createInstance(DocumentImpl *impl)
+Text TextImpl::createInstance(TextImpl *impl)
{
- return Document(impl);
+ return Text(impl);
}
-//------------------------------------------------------------------------------------------
-// DOMObject
-
- at implementation DOMObject
+ProcessingInstruction ProcessingInstructionImpl::createInstance(ProcessingInstructionImpl *impl)
+{
+ return ProcessingInstruction(impl);
+}
-- (void)dealloc
+DocumentType DocumentTypeImpl::createInstance(DocumentTypeImpl *impl)
{
- if (_internal) {
- removeWrapperForImpl(_internal);
- }
- [super dealloc];
+ return DocumentType(impl);
}
-- (id)copyWithZone:(NSZone *)zone
+Document DocumentImpl::createInstance(DocumentImpl *impl)
{
- return [self retain];
+ return Document(impl);
}
- at end
+Range RangeImpl::createInstance(RangeImpl *impl)
+{
+ return Range(impl);
+}
//------------------------------------------------------------------------------------------
// DOMNode
@implementation DOMNode
-- (void)dealloc
+- (NodeImpl *)nodeImpl
{
- if (_internal) {
- reinterpret_cast<NodeImpl *>(_internal)->deref();
- }
- [super dealloc];
+ AbstractMethodCalled([DOMNode class]);
+ return nil;
+}
+
+- (Class)classForDOMDocument
+{
+ AbstractMethodCalled([DOMNode class]);
+ return nil;
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ return [self retain];
}
- (NSString *)nodeName
@@ -290,7 +301,7 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
- (DOMDocument *)ownerDocument
{
- return [DOMDocument documentWithImpl:[self nodeImpl]->getDocument()];
+ return [[self classForDOMDocument] documentWithImpl:[self nodeImpl]->getDocument()];
}
- (DOMNode *)insertBefore:(DOMNode *)newChild :(DOMNode *)refChild error:(NSError **)error
@@ -356,13 +367,15 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
ASSERT(version);
// Method not reflected in DOM::NodeImpl interface
- return Node([self nodeImpl]).isSupported(NSStringToDOMString(feature), NSStringToDOMString(version));
+ Node node([self nodeImpl]);
+ return node.isSupported(NSStringToDOMString(feature), NSStringToDOMString(version));
}
- (NSString *)namespaceURI
{
// Method not reflected in DOM::NodeImpl interface
- return DOMStringToNSString(Node([self nodeImpl]).namespaceURI());
+ Node node([self nodeImpl]);
+ return DOMStringToNSString(node.namespaceURI());
}
- (NSString *)prefix
@@ -387,7 +400,8 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
- (BOOL)hasAttributes
{
// Method not reflected in DOM::NodeImpl interface
- return Node([self nodeImpl]).hasAttributes();
+ Node node([self nodeImpl]);
+ return node.hasAttributes();
}
- (NSString *)HTMLString
@@ -397,16 +411,31 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
@end
- at implementation DOMNode (WebCoreInternal)
+//------------------------------------------------------------------------------------------
+// WebCoreDOMNode
-- (id)initWithNodeImpl:(NodeImpl *)impl
+ at implementation WebCoreDOMNode
+
+- (id)initWithNodeImpl:(NodeImpl *)impl checkCache:(BOOL)checkCache
{
- ASSERT(impl);
+ if (!impl) {
+ [self release];
+ return nil;
+ }
+
+ if (checkCache) {
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance) {
+ [self release];
+ return [cachedInstance retain];
+ }
+ }
[super init];
- _internal = reinterpret_cast<DOMObjectInternal *>(impl);
+ m_impl = impl;
impl->ref();
- setWrapperForImpl(self, impl);
+ setWrapperForImpl(self, m_impl);
return self;
}
@@ -420,51 +449,31 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
if (cachedInstance)
return [[cachedInstance retain] autorelease];
- Class wrapperClass = nil;
- switch (impl->nodeType()) {
- case Node::ELEMENT_NODE:
- wrapperClass = [DOMElement class];
- break;
- case Node::ATTRIBUTE_NODE:
- wrapperClass = [DOMAttr class];
- break;
- case Node::TEXT_NODE:
- wrapperClass = [DOMText class];
- break;
- case Node::CDATA_SECTION_NODE:
- wrapperClass = [DOMCDATASection class];
- break;
- case Node::ENTITY_REFERENCE_NODE:
- wrapperClass = [DOMEntityReference class];
- break;
- case Node::ENTITY_NODE:
- wrapperClass = [DOMEntity class];
- break;
- case Node::PROCESSING_INSTRUCTION_NODE:
- wrapperClass = [DOMProcessingInstruction class];
- break;
- case Node::COMMENT_NODE:
- wrapperClass = [DOMComment class];
- break;
- case Node::DOCUMENT_NODE:
- wrapperClass = [DOMDocument class];
- break;
- case Node::DOCUMENT_TYPE_NODE:
- wrapperClass = [DOMDocumentType class];
- break;
- case Node::DOCUMENT_FRAGMENT_NODE:
- wrapperClass = [DOMDocumentFragment class];
- break;
- case Node::NOTATION_NODE:
- wrapperClass = [DOMNotation class];
- break;
- }
- return [[[wrapperClass alloc] initWithNodeImpl:impl] autorelease];
+ return [[[self alloc] initWithNodeImpl:impl checkCache:NO] autorelease];
+}
+
+- (id)initWithNodeImpl:(NodeImpl *)impl
+{
+ return [self initWithNodeImpl:impl checkCache:YES];
}
- (NodeImpl *)nodeImpl
{
- return reinterpret_cast<NodeImpl *>(_internal);
+ return m_impl;
+}
+
+- (Class)classForDOMDocument
+{
+ return [WebCoreDOMDocument class];
+}
+
+- (void)dealloc
+{
+ if (m_impl) {
+ removeWrapperForImpl(m_impl);
+ m_impl->deref();
+ }
+ [super dealloc];
}
@end
@@ -474,17 +483,21 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
@implementation DOMNamedNodeMap
-- (void)dealloc
+- (NamedNodeMapImpl *)namedNodeMapImpl
{
- if (_internal) {
- reinterpret_cast<NamedNodeMapImpl *>(_internal)->deref();
- }
- [super dealloc];
+ AbstractMethodCalled([DOMNamedNodeMap class]);
+ return nil;
}
-- (NamedNodeMapImpl *)namedNodeMapImpl
+- (Class)classForDOMNode
+{
+ AbstractMethodCalled([DOMNamedNodeMap class]);
+ return nil;
+}
+
+- (id)copyWithZone:(NSZone *)zone
{
- return reinterpret_cast<NamedNodeMapImpl *>(_internal);
+ return [self retain];
}
- (DOMNode *)getNamedItem:(NSString *)name
@@ -494,7 +507,7 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
// Method not reflected in DOM::NamedNodeMapImpl interface
NamedNodeMap map = NamedNodeMapImpl::createInstance([self namedNodeMapImpl]);
Node result(map.getNamedItem(NSStringToDOMString(name)));
- return [DOMNode nodeWithImpl:result.handle()];
+ return [[self classForDOMNode] nodeWithImpl:result.handle()];
}
- (DOMNode *)setNamedItem:(DOMNode *)arg error:(NSError **)error
@@ -505,10 +518,7 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
try {
NamedNodeMap map = NamedNodeMapImpl::createInstance([self namedNodeMapImpl]);
Node result(map.setNamedItem([arg nodeImpl]));
- if (error) {
- *error = nil;
- }
- return [DOMNode nodeWithImpl:result.handle()];
+ return [[self classForDOMNode] nodeWithImpl:result.handle()];
}
catch (const DOMException &e) {
fillInError(error, e.code);
@@ -524,10 +534,7 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
try {
NamedNodeMap map = NamedNodeMapImpl::createInstance([self namedNodeMapImpl]);
Node result(map.removeNamedItem(NSStringToDOMString(name)));
- if (error) {
- *error = nil;
- }
- return [DOMNode nodeWithImpl:result.handle()];
+ return [[self classForDOMNode] nodeWithImpl:result.handle()];
}
catch (const DOMException &e) {
fillInError(error, e.code);
@@ -537,7 +544,7 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
- (DOMNode *)item:(unsigned long)index
{
- return [DOMNode nodeWithImpl:[self namedNodeMapImpl]->item(index)];
+ return [[self classForDOMNode] nodeWithImpl:[self namedNodeMapImpl]->item(index)];
}
- (unsigned long)length
@@ -554,7 +561,7 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
// Method not reflected in DOM::NamedNodeMapImpl interface
NamedNodeMap map = NamedNodeMapImpl::createInstance([self namedNodeMapImpl]);
Node result(map.getNamedItemNS(NSStringToDOMString(namespaceURI), NSStringToDOMString(localName)));
- return [DOMNode nodeWithImpl:result.handle()];
+ return [[self classForDOMNode] nodeWithImpl:result.handle()];
}
- (DOMNode *)setNamedItemNS:(DOMNode *)arg error:(NSError **)error
@@ -565,10 +572,7 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
try {
NamedNodeMap map = NamedNodeMapImpl::createInstance([self namedNodeMapImpl]);
Node result(map.setNamedItemNS([arg nodeImpl]));
- if (error) {
- *error = nil;
- }
- return [DOMNode nodeWithImpl:result.handle()];
+ return [[self classForDOMNode] nodeWithImpl:result.handle()];
}
catch (const DOMException &e) {
fillInError(error, e.code);
@@ -585,10 +589,7 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
try {
NamedNodeMap map = NamedNodeMapImpl::createInstance([self namedNodeMapImpl]);
Node result(map.removeNamedItemNS(NSStringToDOMString(namespaceURI), NSStringToDOMString(localName)));
- if (error) {
- *error = nil;
- }
- return [DOMNode nodeWithImpl:result.handle()];
+ return [[self classForDOMNode] nodeWithImpl:result.handle()];
}
catch (const DOMException &e) {
fillInError(error, e.code);
@@ -598,16 +599,31 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
@end
- at implementation DOMNamedNodeMap (WebCoreInternal)
+//------------------------------------------------------------------------------------------
+// WebCoreDOMNamedNodeMap
-- (id)initWithNamedNodeMapImpl:(NamedNodeMapImpl *)impl
+ at implementation WebCoreDOMNamedNodeMap
+
+- (id)initWithNamedNodeMapImpl:(NamedNodeMapImpl *)impl checkCache:(BOOL)checkCache
{
- ASSERT(impl);
+ if (!impl) {
+ [self release];
+ return nil;
+ }
+
+ if (checkCache) {
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance) {
+ [self release];
+ return [cachedInstance retain];
+ }
+ }
[super init];
- _internal = reinterpret_cast<DOMObjectInternal *>(impl);
+ m_impl = impl;
impl->ref();
- setWrapperForImpl(self, impl);
+ setWrapperForImpl(self, m_impl);
return self;
}
@@ -621,32 +637,60 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
if (cachedInstance)
return [[cachedInstance retain] autorelease];
- return [[[self alloc] initWithNamedNodeMapImpl:impl] autorelease];
+ return [[[self alloc] initWithNamedNodeMapImpl:impl checkCache:NO] autorelease];
}
- at end
+- (id)initWithNamedNodeMapImpl:(NamedNodeMapImpl *)impl
+{
+ return [self initWithNamedNodeMapImpl:impl checkCache:YES];
+}
-//------------------------------------------------------------------------------------------
-// DOMNodeList
+- (NamedNodeMapImpl *)namedNodeMapImpl
+{
+ return m_impl;
+}
- at implementation DOMNodeList
+- (Class)classForDOMNode
+{
+ return [WebCoreDOMNode class];
+}
- (void)dealloc
{
- if (_internal) {
- reinterpret_cast<NodeListImpl *>(_internal)->deref();
+ if (m_impl) {
+ removeWrapperForImpl(m_impl);
+ m_impl->deref();
}
[super dealloc];
}
+ at end
+
+//------------------------------------------------------------------------------------------
+// DOMNodeList
+
+ at implementation DOMNodeList
+
- (NodeListImpl *)nodeListImpl
{
- return reinterpret_cast<NodeListImpl *>(_internal);
+ AbstractMethodCalled([DOMNodeList class]);
+ return nil;
+}
+
+- (Class)classForDOMNode
+{
+ AbstractMethodCalled([DOMNodeList class]);
+ return nil;
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ return [self retain];
}
- (DOMNode *)item:(unsigned long)index
{
- return [DOMNode nodeWithImpl:[self nodeListImpl]->item(index)];
+ return [[self classForDOMNode] nodeWithImpl:[self nodeListImpl]->item(index)];
}
- (unsigned long)length
@@ -656,16 +700,31 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
@end
- at implementation DOMNodeList (WebCoreInternal)
+//------------------------------------------------------------------------------------------
+// WebCoreDOMNodeList
-- (id)initWithNodeListImpl:(NodeListImpl *)impl
+ at implementation WebCoreDOMNodeList
+
+- (id)initWithNodeListImpl:(NodeListImpl *)impl checkCache:(BOOL)checkCache
{
- ASSERT(impl);
+ if (!impl) {
+ [self release];
+ return nil;
+ }
+
+ if (checkCache) {
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance) {
+ [self release];
+ return [cachedInstance retain];
+ }
+ }
[super init];
- _internal = reinterpret_cast<DOMObjectInternal *>(impl);
+ m_impl = impl;
impl->ref();
- setWrapperForImpl(self, impl);
+ setWrapperForImpl(self, m_impl);
return self;
}
@@ -679,27 +738,66 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
if (cachedInstance)
return [[cachedInstance retain] autorelease];
- return [[[self alloc] initWithNodeListImpl:impl] autorelease];
+ return [[[self alloc] initWithNodeListImpl:impl checkCache:NO] autorelease];
}
- at end
+- (id)initWithNodeListImpl:(NodeListImpl *)impl
+{
+ return [self initWithNodeListImpl:impl checkCache:YES];
+}
-//------------------------------------------------------------------------------------------
-// DOMImplementation
+- (NodeListImpl *)nodeListImpl
+{
+ return m_impl;
+}
- at implementation DOMImplementation
+- (Class)classForDOMNode
+{
+ return [WebCoreDOMNode class];
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ return [self retain];
+}
- (void)dealloc
{
- if (_internal) {
- reinterpret_cast<DOMImplementationImpl *>(_internal)->deref();
+ if (m_impl) {
+ removeWrapperForImpl(m_impl);
+ m_impl->deref();
}
[super dealloc];
}
+ at end
+
+//------------------------------------------------------------------------------------------
+// DOMImplementation
+
+ at implementation DOMImplementation
+
- (DOMImplementationImpl *)DOMImplementationImpl
{
- return reinterpret_cast<DOMImplementationImpl *>(_internal);
+ AbstractMethodCalled([DOMImplementation class]);
+ return nil;
+}
+
+- (Class)classForDOMDocumentType
+{
+ AbstractMethodCalled([DOMImplementation class]);
+ return nil;
+}
+
+- (Class)classForDOMDocument
+{
+ AbstractMethodCalled([DOMImplementation class]);
+ return nil;
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ return [self retain];
}
- (BOOL)hasFeature:(NSString *)feature :(NSString *)version
@@ -718,8 +816,9 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
int code;
DocumentTypeImpl *impl = [self DOMImplementationImpl]->createDocumentType(NSStringToDOMString(qualifiedName), NSStringToDOMString(publicId), NSStringToDOMString(systemId), code);
+ DOMDocumentType * result = [[self classForDOMDocumentType] documentTypeWithImpl:impl];
fillInError(error, code);
- return static_cast<DOMDocumentType *>([DOMNode nodeWithImpl:impl]);
+ return result;
}
- (DOMDocument *)createDocument:(NSString *)namespaceURI :(NSString *)qualifiedName :(DOMDocumentType *)doctype error:(NSError **)error
@@ -728,24 +827,40 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
ASSERT(qualifiedName);
int code;
- DocumentType dt = DocumentTypeImpl::createInstance(static_cast<DocumentTypeImpl *>([doctype nodeImpl]));
+ DocumentType dt = DocumentTypeImpl::createInstance([doctype documentTypeImpl]);
DocumentImpl *impl = [self DOMImplementationImpl]->createDocument(NSStringToDOMString(namespaceURI), NSStringToDOMString(qualifiedName), dt, code);
+ DOMDocument * result = [[self classForDOMDocument] documentWithImpl:impl];
fillInError(error, code);
- return static_cast<DOMDocument *>([DOMNode nodeWithImpl:impl]);
+ return result;
}
@end
- at implementation DOMImplementation (WebInternal)
+//------------------------------------------------------------------------------------------
+// WebCoreDOMImplementation
-- (id)initWithDOMImplementationImpl:(DOMImplementationImpl *)impl
+ at implementation WebCoreDOMImplementation
+
+- (id)initWithDOMImplementationImpl:(DOMImplementationImpl *)impl checkCache:(BOOL)checkCache
{
- ASSERT(impl);
+ if (!impl) {
+ [self release];
+ return nil;
+ }
+
+ if (checkCache) {
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance) {
+ [self release];
+ return [cachedInstance retain];
+ }
+ }
[super init];
- _internal = reinterpret_cast<DOMObjectInternal *>(impl);
+ m_impl = impl;
impl->ref();
- setWrapperForImpl(self, impl);
+ setWrapperForImpl(self, m_impl);
return self;
}
@@ -759,7 +874,36 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
if (cachedInstance)
return [[cachedInstance retain] autorelease];
- return [[[self alloc] initWithDOMImplementationImpl:impl] autorelease];
+ return [[[self alloc] initWithDOMImplementationImpl:impl checkCache:NO] autorelease];
+}
+
+- (id)initWithDOMImplementationImpl:(DOMImplementationImpl *)impl
+{
+ return [self initWithDOMImplementationImpl:impl checkCache:YES];
+}
+
+- (DOMImplementationImpl *)DOMImplementationImpl
+{
+ return m_impl;
+}
+
+- (Class)classForDOMDocumentType
+{
+ return [WebCoreDOMDocumentType class];
+}
+
+- (Class)classForDOMDocument
+{
+ return [WebCoreDOMDocument class];
+}
+
+- (void)dealloc
+{
+ if (m_impl) {
+ removeWrapperForImpl(m_impl);
+ m_impl->deref();
+ }
+ [super dealloc];
}
@end
@@ -769,13 +913,77 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
@implementation DOMDocumentFragment
+- (DocumentFragmentImpl *)documentFragmentImpl
+{
+ AbstractMethodCalled([DOMDocumentFragment class]);
+ return nil;
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ return [self retain];
+}
+
@end
- at implementation DOMDocumentFragment (WebCoreInternal)
+//------------------------------------------------------------------------------------------
+// WebCoreDOMDocumentFragment
+
+ at implementation WebCoreDOMDocumentFragment
+
+- (id)initWithDocumentFragmentImpl:(DocumentFragmentImpl *)impl checkCache:(BOOL)checkCache
+{
+ if (!impl) {
+ [self release];
+ return nil;
+ }
+
+ if (checkCache) {
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance) {
+ [self release];
+ return [cachedInstance retain];
+ }
+ }
+
+ [super init];
+ m_impl = impl;
+ impl->ref();
+ setWrapperForImpl(self, m_impl);
+ return self;
+}
+ (DOMDocumentFragment *)documentFragmentWithImpl:(DocumentFragmentImpl *)impl
{
- return static_cast<DOMDocumentFragment *>([DOMNode nodeWithImpl:impl]);
+ if (!impl)
+ return nil;
+
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance)
+ return [[cachedInstance retain] autorelease];
+
+ return [[[self alloc] initWithDocumentFragmentImpl:impl checkCache:NO] autorelease];
+}
+
+- (id)initWithDocumentFragmentImpl:(DocumentFragmentImpl *)impl
+{
+ return [self initWithDocumentFragmentImpl:impl checkCache:YES];
+}
+
+- (DocumentFragmentImpl *)documentFragmentImpl
+{
+ return m_impl;
+}
+
+- (void)dealloc
+{
+ if (m_impl) {
+ removeWrapperForImpl(m_impl);
+ m_impl->deref();
+ }
+ [super dealloc];
}
@end
@@ -787,22 +995,100 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
- (DocumentImpl *)documentImpl
{
- return reinterpret_cast<DocumentImpl *>(_internal);
+ AbstractMethodCalled([DOMDocument class]);
+ return nil;
+}
+
+- (Class)classForDOMAttr
+{
+ AbstractMethodCalled([DOMDocument class]);
+ return nil;
+}
+
+- (Class)classForDOMCDATASection
+{
+ AbstractMethodCalled([DOMDocument class]);
+ return nil;
+}
+
+- (Class)classForDOMComment
+{
+ AbstractMethodCalled([DOMDocument class]);
+ return nil;
+}
+
+- (Class)classForDOMDocumentFragment
+{
+ AbstractMethodCalled([DOMDocument class]);
+ return nil;
+}
+
+- (Class)classForDOMDocumentType
+{
+ AbstractMethodCalled([DOMDocument class]);
+ return nil;
+}
+
+- (Class)classForDOMElement
+{
+ AbstractMethodCalled([DOMDocument class]);
+ return nil;
+}
+
+- (Class)classForDOMEntityReference
+{
+ AbstractMethodCalled([DOMDocument class]);
+ return nil;
+}
+
+- (Class)classForDOMImplementation
+{
+ AbstractMethodCalled([DOMDocument class]);
+ return nil;
+}
+
+- (Class)classForDOMNode
+{
+ AbstractMethodCalled([DOMDocument class]);
+ return nil;
+}
+
+- (Class)classForDOMNodeList
+{
+ AbstractMethodCalled([DOMDocument class]);
+ return nil;
+}
+
+- (Class)classForDOMProcessingInstruction
+{
+ AbstractMethodCalled([DOMDocument class]);
+ return nil;
+}
+
+- (Class)classForDOMText
+{
+ AbstractMethodCalled([DOMDocument class]);
+ return nil;
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ return [self retain];
}
- (DOMDocumentType *)doctype
{
- return static_cast<DOMDocumentType *>([DOMNode nodeWithImpl:[self documentImpl]->doctype()]);
+ return [[self classForDOMDocumentType] documentTypeWithImpl:[self documentImpl]->doctype()];
}
- (DOMImplementation *)implementation
{
- return [DOMImplementation DOMImplementationWithImpl:[self documentImpl]->implementation()];
+ return [[self classForDOMImplementation] DOMImplementationWithImpl:[self documentImpl]->implementation()];
}
- (DOMElement *)documentElement
{
- return static_cast<DOMElement *>([DOMNode nodeWithImpl:[self documentImpl]->documentElement()]);
+ return [[self classForDOMElement] elementWithImpl:[self documentImpl]->documentElement()];
}
- (DOMElement *)createElement:(NSString *)tagName error:(NSError **)error
@@ -810,26 +1096,28 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
ASSERT(tagName);
int code;
- DOMElement *result = static_cast<DOMElement *>([DOMNode nodeWithImpl:[self documentImpl]->createElement(NSStringToDOMString(tagName), code)]);
+ DOMElement *result = [[self classForDOMElement] elementWithImpl:[self documentImpl]->createElement(NSStringToDOMString(tagName), code)];
fillInError(error, code);
return result;
}
- (DOMDocumentFragment *)createDocumentFragment
{
- return static_cast<DOMDocumentFragment *>([DOMNode nodeWithImpl:[self documentImpl]->createDocumentFragment()]);
+ return [[self classForDOMDocumentFragment] documentFragmentWithImpl:[self documentImpl]->createDocumentFragment()];
}
- (DOMText *)createTextNode:(NSString *)data
{
ASSERT(data);
- return static_cast<DOMText *>([DOMNode nodeWithImpl:[self documentImpl]->createTextNode(NSStringToDOMString(data))]);
+
+ return [[self classForDOMText] textWithImpl:[self documentImpl]->createTextNode(NSStringToDOMString(data))];
}
- (DOMComment *)createComment:(NSString *)data
{
ASSERT(data);
- return static_cast<DOMComment *>([DOMNode nodeWithImpl:[self documentImpl]->createComment(NSStringToDOMString(data))]);
+
+ return [[self classForDOMComment] commentWithImpl:[self documentImpl]->createComment(NSStringToDOMString(data))];
}
- (DOMCDATASection *)createCDATASection:(NSString *)data error:(NSError **)error
@@ -838,10 +1126,7 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
// Documentation says we can raise a NOT_SUPPORTED_ERR.
// However, the lower layer does not report that error up to us.
- if (error) {
- *error = nil;
- }
- return static_cast<DOMCDATASection *>([DOMNode nodeWithImpl:[self documentImpl]->createCDATASection(NSStringToDOMString(data))]);
+ return [[self classForDOMCDATASection] CDATASectionWithImpl:[self documentImpl]->createCDATASection(NSStringToDOMString(data))];
}
- (DOMProcessingInstruction *)createProcessingInstruction:(NSString *)target :(NSString *)data error:(NSError **)error
@@ -851,10 +1136,7 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
// Documentation says we can raise a INVALID_CHARACTER_ERR or a NOT_SUPPORTED_ERR.
// However, the lower layer does not report these errors up to us.
- if (error) {
- *error = nil;
- }
- return static_cast<DOMProcessingInstruction *>([DOMNode nodeWithImpl:[self documentImpl]->createProcessingInstruction(NSStringToDOMString(target), NSStringToDOMString(data))]);
+ return [[self classForDOMProcessingInstruction] processingInstructionWithImpl:[self documentImpl]->createProcessingInstruction(NSStringToDOMString(target), NSStringToDOMString(data))];
}
- (DOMAttr *)createAttribute:(NSString *)name error:(NSError **)error
@@ -865,10 +1147,8 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
try {
Document doc(DocumentImpl::createInstance([self documentImpl]));
Attr result(doc.createAttribute(NSStringToDOMString(name)));
- if (error) {
- *error = nil;
- }
- return static_cast<DOMAttr *>([DOMNode nodeWithImpl:result.handle()]);
+ AttrImpl *impl = static_cast<AttrImpl *>(result.handle());
+ return [[self classForDOMAttr] attrWithImpl:impl];
}
catch (const DOMException &e) {
fillInError(error, e.code);
@@ -882,22 +1162,20 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
// Documentation says we can raise a INVALID_CHARACTER_ERR or a NOT_SUPPORTED_ERR.
// However, the lower layer does not report these errors up to us.
- if (error) {
- *error = nil;
- }
- return static_cast<DOMEntityReference *>([DOMNode nodeWithImpl:[self documentImpl]->createEntityReference(NSStringToDOMString(name))]);
+ return [WebCoreDOMEntityReference entityReferenceWithImpl:[self documentImpl]->createEntityReference(NSStringToDOMString(name))];
}
- (DOMNodeList *)getElementsByTagName:(NSString *)tagname
{
ASSERT(tagname);
- return [DOMNodeList nodeListWithImpl:[self documentImpl]->getElementsByTagNameNS(0, NSStringToDOMString(tagname).implementation())];
+
+ return [[self classForDOMNodeList] nodeListWithImpl:[self documentImpl]->getElementsByTagNameNS(0, NSStringToDOMString(tagname).implementation())];
}
- (DOMNode *)importNode:(DOMNode *)importedNode :(BOOL)deep error:(NSError **)error
{
int code;
- DOMNode *result = [DOMNode nodeWithImpl:[self documentImpl]->importNode([importedNode nodeImpl], deep, code)];
+ DOMNode *result = [WebCoreDOMNode nodeWithImpl:[self documentImpl]->importNode([importedNode nodeImpl], deep, code)];
fillInError(error, code);
return result;
}
@@ -908,9 +1186,9 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
ASSERT(qualifiedName);
int code;
- DOMNode *result = [DOMNode nodeWithImpl:[self documentImpl]->createElementNS(NSStringToDOMString(namespaceURI), NSStringToDOMString(qualifiedName), code)];
+ DOMElement *result = [[self classForDOMElement] elementWithImpl:[self documentImpl]->createElementNS(NSStringToDOMString(namespaceURI), NSStringToDOMString(qualifiedName), code)];
fillInError(error, code);
- return static_cast<DOMElement *>(result);
+ return result;
}
- (DOMAttr *)createAttributeNS:(NSString *)namespaceURI :(NSString *)qualifiedName error:(NSError **)error
@@ -922,10 +1200,8 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
try {
Document doc(DocumentImpl::createInstance([self documentImpl]));
Attr result(doc.createAttributeNS(NSStringToDOMString(namespaceURI), NSStringToDOMString(qualifiedName)));
- if (error) {
- *error = nil;
- }
- return static_cast<DOMAttr *>([DOMNode nodeWithImpl:result.handle()]);
+ AttrImpl *impl = static_cast<AttrImpl *>(result.handle());
+ return [[self classForDOMAttr] attrWithImpl:impl];
}
catch (const DOMException &e) {
fillInError(error, e.code);
@@ -938,23 +1214,136 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
ASSERT(namespaceURI);
ASSERT(localName);
- return [DOMNodeList nodeListWithImpl:[self documentImpl]->getElementsByTagNameNS(NSStringToDOMString(namespaceURI).implementation(), NSStringToDOMString(localName).implementation())];
+ return [[self classForDOMNodeList] nodeListWithImpl:[self documentImpl]->getElementsByTagNameNS(NSStringToDOMString(namespaceURI).implementation(), NSStringToDOMString(localName).implementation())];
}
- (DOMElement *)getElementById:(NSString *)elementId
{
ASSERT(elementId);
- return static_cast<DOMElement *>([DOMNode nodeWithImpl:[self documentImpl]->getElementById(NSStringToDOMString(elementId))]);
+ return [[self classForDOMElement] elementWithImpl:[self documentImpl]->getElementById(NSStringToDOMString(elementId))];
}
@end
- at implementation DOMDocument (WebCoreInternal)
+//------------------------------------------------------------------------------------------
+// WebCoreDOMDocumentFragment
+
+ at implementation WebCoreDOMDocument
+
+- (id)initWithDocumentImpl:(DocumentImpl *)impl checkCache:(BOOL)checkCache
+{
+ if (!impl) {
+ [self release];
+ return nil;
+ }
+
+ if (checkCache) {
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance) {
+ [self release];
+ return [cachedInstance retain];
+ }
+ }
+
+ [super init];
+ m_impl = impl;
+ impl->ref();
+ setWrapperForImpl(self, m_impl);
+ return self;
+}
+ (DOMDocument *)documentWithImpl:(DocumentImpl *)impl
{
- return static_cast<DOMDocument *>([DOMNode nodeWithImpl:impl]);
+ if (!impl)
+ return nil;
+
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance)
+ return [[cachedInstance retain] autorelease];
+
+ return [[[self alloc] initWithDocumentImpl:impl checkCache:NO] autorelease];
+}
+
+- (id)initWithDocumentImpl:(DocumentImpl *)impl
+{
+ return [self initWithDocumentImpl:impl checkCache:YES];
+}
+
+- (DocumentImpl *)documentImpl
+{
+ return m_impl;
+}
+
+- (Class)classForDOMAttr
+{
+ return [WebCoreDOMAttr class];
+}
+
+- (Class)classForDOMCDATASection
+{
+ return [WebCoreDOMCDATASection class];
+}
+
+- (Class)classForDOMComment
+{
+ return [WebCoreDOMComment class];
+}
+
+- (Class)classForDOMDocumentFragment
+{
+ return [WebCoreDOMDocumentFragment class];
+}
+
+- (Class)classForDOMDocumentType
+{
+ return [WebCoreDOMDocumentType class];
+}
+
+- (Class)classForDOMElement
+{
+ return [WebCoreDOMElement class];
+}
+
+- (Class)classForDOMEntityReference
+{
+ return [WebCoreDOMEntityReference class];
+}
+
+- (Class)classForDOMImplementation
+{
+ return [WebCoreDOMImplementation class];
+}
+
+- (Class)classForDOMNode
+{
+ return [WebCoreDOMNode class];
+}
+
+- (Class)classForDOMNodeList
+{
+ return [WebCoreDOMNodeList class];
+}
+
+- (Class)classForDOMProcessingInstruction
+{
+ return [WebCoreDOMProcessingInstruction class];
+}
+
+- (Class)classForDOMText
+{
+ return [WebCoreDOMText class];
+}
+
+- (void)dealloc
+{
+ if (m_impl) {
+ removeWrapperForImpl(m_impl);
+ m_impl->deref();
+ }
+ [super dealloc];
}
@end
@@ -966,7 +1355,13 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
- (CharacterDataImpl *)characterDataImpl
{
- return reinterpret_cast<CharacterDataImpl *>(_internal);
+ AbstractMethodCalled([DOMCharacterData class]);
+ return nil;
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ return [self retain];
}
- (NSString *)data
@@ -1035,10 +1430,89 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
@end
//------------------------------------------------------------------------------------------
+// WebCoreDOMCharacterData
+
+ at implementation WebCoreDOMCharacterData
+
+- (id)initWithCharacterDataImpl:(CharacterDataImpl *)impl checkCache:(BOOL)checkCache
+{
+ if (!impl) {
+ [self release];
+ return nil;
+ }
+
+ if (checkCache) {
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance) {
+ [self release];
+ return [cachedInstance retain];
+ }
+ }
+
+ [super init];
+ m_impl = impl;
+ impl->ref();
+ setWrapperForImpl(self, m_impl);
+ return self;
+}
+
++ (DOMCharacterData *)characterDataWithImpl:(CharacterDataImpl *)impl
+{
+ if (!impl)
+ return nil;
+
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance)
+ return [[cachedInstance retain] autorelease];
+
+ return [[[self alloc] initWithCharacterDataImpl:impl checkCache:NO] autorelease];
+}
+
+- (id)initWithCharacterDataImpl:(CharacterDataImpl *)impl
+{
+ return [self initWithCharacterDataImpl:impl checkCache:YES];
+}
+
+- (CharacterDataImpl *)characterDataImpl
+{
+ return m_impl;
+}
+
+- (void)dealloc
+{
+ if (m_impl) {
+ removeWrapperForImpl(m_impl);
+ m_impl->deref();
+ }
+ [super dealloc];
+}
+
+ at end
+
+//------------------------------------------------------------------------------------------
// DOMAttr
@implementation DOMAttr
+- (AttrImpl *)attrImpl
+{
+ AbstractMethodCalled([DOMAttr class]);
+ return nil;
+}
+
+- (Class)classForDOMElement
+{
+ AbstractMethodCalled([DOMAttr class]);
+ return nil;
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ return [self retain];
+}
+
- (NSString *)name
{
return DOMStringToNSString([self attrImpl]->nodeName());
@@ -1065,21 +1539,74 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
- (DOMElement *)ownerElement
{
- return [DOMElement elementWithImpl:[self attrImpl]->ownerElement()];
+ return [[self classForDOMElement] elementWithImpl:[self attrImpl]->ownerElement()];
}
@end
- at implementation DOMAttr (WebCoreInternal)
+//------------------------------------------------------------------------------------------
+// WebCoreDOMAttr
+
+ at implementation WebCoreDOMAttr
+
+- (id)initWithAttrImpl:(AttrImpl *)impl checkCache:(BOOL)checkCache
+{
+ if (!impl) {
+ [self release];
+ return nil;
+ }
+
+ if (checkCache) {
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance) {
+ [self release];
+ return [cachedInstance retain];
+ }
+ }
+
+ [super init];
+ m_impl = impl;
+ impl->ref();
+ setWrapperForImpl(self, m_impl);
+ return self;
+}
+ (DOMAttr *)attrWithImpl:(AttrImpl *)impl
{
- return static_cast<DOMAttr *>([DOMNode nodeWithImpl:impl]);
+ if (!impl)
+ return nil;
+
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance)
+ return [[cachedInstance retain] autorelease];
+
+ return [[[self alloc] initWithAttrImpl:impl checkCache:NO] autorelease];
+}
+
+- (id)initWithAttrImpl:(AttrImpl *)impl
+{
+ return [self initWithAttrImpl:impl checkCache:YES];
}
- (AttrImpl *)attrImpl
{
- return reinterpret_cast<AttrImpl *>(_internal);
+ return m_impl;
+}
+
+- (Class)classForDOMElement
+{
+ return [WebCoreDOMElement class];
+}
+
+- (void)dealloc
+{
+ if (m_impl) {
+ removeWrapperForImpl(m_impl);
+ m_impl->deref();
+ }
+ [super dealloc];
}
@end
@@ -1089,14 +1616,32 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
@implementation DOMElement
-- (NSString *)tagName
+- (ElementImpl *)elementImpl
{
- return DOMStringToNSString([self elementImpl]->tagName());
+ AbstractMethodCalled([DOMElement class]);
+ return nil;
}
-- (DOMNamedNodeMap *)attributes
+- (Class)classForDOMAttr
{
- return [DOMNamedNodeMap namedNodeMapWithImpl:[self elementImpl]->attributes()];
+ AbstractMethodCalled([DOMElement class]);
+ return nil;
+}
+
+- (Class)classForDOMNodeList
+{
+ AbstractMethodCalled([DOMElement class]);
+ return nil;
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ return [self retain];
+}
+
+- (NSString *)tagName
+{
+ return DOMStringToNSString([self elementImpl]->tagName());
}
- (NSString *)getAttribute:(NSString *)name
@@ -1115,9 +1660,6 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
try {
Element element(ElementImpl::createInstance([self elementImpl]));
element.setAttribute(NSStringToDOMString(name), NSStringToDOMString(value));
- if (error) {
- *error = nil;
- }
}
catch (const DOMException &e) {
fillInError(error, e.code);
@@ -1132,9 +1674,6 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
try {
Element element(ElementImpl::createInstance([self elementImpl]));
element.removeAttribute(NSStringToDOMString(name));
- if (error) {
- *error = nil;
- }
}
catch (const DOMException &e) {
fillInError(error, e.code);
@@ -1148,7 +1687,7 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
// Method not reflected in DOM::ElementImpl interface
Element element(ElementImpl::createInstance([self elementImpl]));
Attr result(element.getAttributeNode(NSStringToDOMString(name)));
- return [DOMAttr attrWithImpl:static_cast<AttrImpl *>(result.handle())];
+ return [[self classForDOMAttr] attrWithImpl:static_cast<AttrImpl *>(result.handle())];
}
- (DOMAttr *)setAttributeNode:(DOMAttr *)newAttr error:(NSError **)error
@@ -1160,10 +1699,7 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
Element element(ElementImpl::createInstance([self elementImpl]));
Attr attr(AttrImpl::createInstance([newAttr attrImpl]));
Attr result(element.setAttributeNode(attr));
- if (error) {
- *error = nil;
- }
- return [DOMAttr attrWithImpl:static_cast<AttrImpl *>(result.handle())];
+ return [[self classForDOMAttr] attrWithImpl:static_cast<AttrImpl *>(result.handle())];
}
catch (const DOMException &e) {
fillInError(error, e.code);
@@ -1180,10 +1716,7 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
Element element(ElementImpl::createInstance([self elementImpl]));
Attr attr(AttrImpl::createInstance([oldAttr attrImpl]));
Attr result(element.removeAttributeNode(attr));
- if (error) {
- *error = nil;
- }
- return [DOMAttr attrWithImpl:static_cast<AttrImpl *>(result.handle())];
+ return [[self classForDOMAttr] attrWithImpl:static_cast<AttrImpl *>(result.handle())];
}
catch (const DOMException &e) {
fillInError(error, e.code);
@@ -1195,7 +1728,7 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
{
ASSERT(name);
- return [DOMNodeList nodeListWithImpl:[self elementImpl]->getElementsByTagNameNS(0, NSStringToDOMString(name).implementation())];
+ return [[self classForDOMNodeList] nodeListWithImpl:[self elementImpl]->getElementsByTagNameNS(0, NSStringToDOMString(name).implementation())];
}
- (NSString *)getAttributeNS:(NSString *)namespaceURI :(NSString *)localName
@@ -1217,10 +1750,7 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
try {
Element element(ElementImpl::createInstance([self elementImpl]));
element.setAttributeNS(NSStringToDOMString(namespaceURI), NSStringToDOMString(qualifiedName), NSStringToDOMString(value));
- if (error) {
- *error = nil;
- }
- }
+ }
catch (const DOMException &e) {
fillInError(error, e.code);
}
@@ -1235,9 +1765,6 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
try {
Element element(ElementImpl::createInstance([self elementImpl]));
element.removeAttributeNS(NSStringToDOMString(namespaceURI), NSStringToDOMString(localName));
- if (error) {
- *error = nil;
- }
}
catch (const DOMException &e) {
fillInError(error, e.code);
@@ -1252,7 +1779,7 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
// Method not reflected in DOM::ElementImpl interface
Element element(ElementImpl::createInstance([self elementImpl]));
Attr result(element.getAttributeNodeNS(NSStringToDOMString(namespaceURI), NSStringToDOMString(localName)));
- return [DOMAttr attrWithImpl:static_cast<AttrImpl *>(result.handle())];
+ return [[self classForDOMAttr] attrWithImpl:static_cast<AttrImpl *>(result.handle())];
}
- (DOMAttr *)setAttributeNodeNS:(DOMAttr *)newAttr error:(NSError **)error
@@ -1264,10 +1791,7 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
Element element(ElementImpl::createInstance([self elementImpl]));
Attr attr(AttrImpl::createInstance([newAttr attrImpl]));
Attr result(element.setAttributeNodeNS(attr));
- if (error) {
- *error = nil;
- }
- return [DOMAttr attrWithImpl:static_cast<AttrImpl *>(result.handle())];
+ return [[self classForDOMAttr] attrWithImpl:static_cast<AttrImpl *>(result.handle())];
}
catch (const DOMException &e) {
fillInError(error, e.code);
@@ -1280,7 +1804,7 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
ASSERT(namespaceURI);
ASSERT(localName);
- return [DOMNodeList nodeListWithImpl:[self elementImpl]->getElementsByTagNameNS(NSStringToDOMString(namespaceURI).implementation(), NSStringToDOMString(localName).implementation())];
+ return [[self classForDOMNodeList] nodeListWithImpl:[self elementImpl]->getElementsByTagNameNS(NSStringToDOMString(namespaceURI).implementation(), NSStringToDOMString(localName).implementation())];
}
- (BOOL)hasAttribute:(NSString *)name
@@ -1304,16 +1828,74 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
@end
- at implementation DOMElement (WebCoreInternal)
+//------------------------------------------------------------------------------------------
+// WebCoreDOMElement
+
+ at implementation WebCoreDOMElement
+
+- (id)initWithElementImpl:(ElementImpl *)impl checkCache:(BOOL)checkCache
+{
+ if (!impl) {
+ [self release];
+ return nil;
+ }
+
+ if (checkCache) {
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance) {
+ [self release];
+ return [cachedInstance retain];
+ }
+ }
+
+ [super init];
+ m_impl = impl;
+ impl->ref();
+ setWrapperForImpl(self, m_impl);
+ return self;
+}
+ (DOMElement *)elementWithImpl:(ElementImpl *)impl
{
- return static_cast<DOMElement *>([DOMNode nodeWithImpl:impl]);
+ if (!impl)
+ return nil;
+
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance)
+ return [[cachedInstance retain] autorelease];
+
+ return [[[self alloc] initWithElementImpl:impl checkCache:NO] autorelease];
+}
+
+- (id)initWithElementImpl:(ElementImpl *)impl
+{
+ return [self initWithElementImpl:impl checkCache:YES];
}
- (ElementImpl *)elementImpl
{
- return reinterpret_cast<ElementImpl *>(_internal);
+ return m_impl;
+}
+
+- (Class)classForDOMAttr
+{
+ return [WebCoreDOMAttr class];
+}
+
+- (Class)classForDOMNodeList
+{
+ return [WebCoreDOMNodeList class];
+}
+
+- (void)dealloc
+{
+ if (m_impl) {
+ removeWrapperForImpl(m_impl);
+ m_impl->deref();
+ }
+ [super dealloc];
}
@end
@@ -1325,15 +1907,83 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
- (TextImpl *)textImpl
{
- return reinterpret_cast<TextImpl *>(_internal);
+ AbstractMethodCalled([DOMText class]);
+ return nil;
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ return [self retain];
}
- (DOMText *)splitText:(unsigned long)offset error:(NSError **)error
{
int code;
- DOMNode *result = [DOMNode nodeWithImpl:[self textImpl]->splitText(offset, code)];
+ DOMText *result = [[self class] textWithImpl:[self textImpl]->splitText(offset, code)];
fillInError(error, code);
- return static_cast<DOMText *>(result);
+ return result;
+}
+
+ at end
+
+//------------------------------------------------------------------------------------------
+// WebCoreDOMText
+
+ at implementation WebCoreDOMText
+
+- (id)initWithTextImpl:(TextImpl *)impl checkCache:(BOOL)checkCache
+{
+ if (!impl) {
+ [self release];
+ return nil;
+ }
+
+ if (checkCache) {
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance) {
+ [self release];
+ return [cachedInstance retain];
+ }
+ }
+
+ [super init];
+ m_impl = impl;
+ impl->ref();
+ setWrapperForImpl(self, m_impl);
+ return self;
+}
+
++ (DOMText *)textWithImpl:(TextImpl *)impl
+{
+ if (!impl)
+ return nil;
+
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance)
+ return [[cachedInstance retain] autorelease];
+
+ return [[[self alloc] initWithTextImpl:impl checkCache:NO] autorelease];
+}
+
+- (id)initWithTextImpl:(TextImpl *)impl
+{
+ return [self initWithTextImpl:impl checkCache:YES];
+}
+
+- (TextImpl *)textImpl
+{
+ return m_impl;
+}
+
+- (void)dealloc
+{
+ if (m_impl) {
+ removeWrapperForImpl(m_impl);
+ m_impl->deref();
+ }
+ [super dealloc];
}
@end
@@ -1343,6 +1993,79 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
@implementation DOMComment
+- (CommentImpl *)commentImpl
+{
+ AbstractMethodCalled([DOMComment class]);
+ return nil;
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ return [self retain];
+}
+
+ at end
+
+//------------------------------------------------------------------------------------------
+// WebCoreDOMComment
+
+ at implementation WebCoreDOMComment
+
+- (id)initWithCommentImpl:(CommentImpl *)impl checkCache:(BOOL)checkCache
+{
+ if (!impl) {
+ [self release];
+ return nil;
+ }
+
+ if (checkCache) {
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance) {
+ [self release];
+ return [cachedInstance retain];
+ }
+ }
+
+ [super init];
+ m_impl = impl;
+ impl->ref();
+ setWrapperForImpl(self, m_impl);
+ return self;
+}
+
++ (DOMComment *)commentWithImpl:(CommentImpl *)impl
+{
+ if (!impl)
+ return nil;
+
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance)
+ return [[cachedInstance retain] autorelease];
+
+ return [[[self alloc] initWithCommentImpl:impl checkCache:NO] autorelease];
+}
+
+- (id)initWithCommentImpl:(CommentImpl *)impl
+{
+ return [self initWithCommentImpl:impl checkCache:YES];
+}
+
+- (CommentImpl *)commentImpl
+{
+ return m_impl;
+}
+
+- (void)dealloc
+{
+ if (m_impl) {
+ removeWrapperForImpl(m_impl);
+ m_impl->deref();
+ }
+ [super dealloc];
+}
+
@end
//------------------------------------------------------------------------------------------
@@ -1350,6 +2073,79 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
@implementation DOMCDATASection
+- (CDATASectionImpl *)CDATASectionImpl
+{
+ AbstractMethodCalled([DOMCDATASection class]);
+ return nil;
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ return [self retain];
+}
+
+ at end
+
+//------------------------------------------------------------------------------------------
+// WebCoreDOMCDATASection
+
+ at implementation WebCoreDOMCDATASection
+
+- (id)initWithCDATASectionImpl:(CDATASectionImpl *)impl checkCache:(BOOL)checkCache
+{
+ if (!impl) {
+ [self release];
+ return nil;
+ }
+
+ if (checkCache) {
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance) {
+ [self release];
+ return [cachedInstance retain];
+ }
+ }
+
+ [super init];
+ m_impl = impl;
+ impl->ref();
+ setWrapperForImpl(self, m_impl);
+ return self;
+}
+
++ (DOMCDATASection *)CDATASectionWithImpl:(CDATASectionImpl *)impl
+{
+ if (!impl)
+ return nil;
+
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance)
+ return [[cachedInstance retain] autorelease];
+
+ return [[[self alloc] initWithCDATASectionImpl:impl checkCache:NO] autorelease];
+}
+
+- (id)initWithCDATASectionImpl:(CDATASectionImpl *)impl
+{
+ return [self initWithCDATASectionImpl:impl checkCache:YES];
+}
+
+- (CDATASectionImpl *)CDATASectionImpl
+{
+ return m_impl;
+}
+
+- (void)dealloc
+{
+ if (m_impl) {
+ removeWrapperForImpl(m_impl);
+ m_impl->deref();
+ }
+ [super dealloc];
+}
+
@end
//------------------------------------------------------------------------------------------
@@ -1359,7 +2155,19 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
- (DocumentTypeImpl *)documentTypeImpl
{
- return reinterpret_cast<DocumentTypeImpl *>(_internal);
+ AbstractMethodCalled([DOMDocumentType class]);
+ return nil;
+}
+
+- (Class)classForDOMNamedNodeMap
+{
+ AbstractMethodCalled([DOMDocumentType class]);
+ return nil;
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ return [self retain];
}
- (NSString *)name
@@ -1369,12 +2177,12 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
- (DOMNamedNodeMap *)entities
{
- return [DOMNamedNodeMap namedNodeMapWithImpl:[self documentTypeImpl]->entities()];
+ return [[self classForDOMNamedNodeMap] namedNodeMapWithImpl:[self documentTypeImpl]->entities()];
}
- (DOMNamedNodeMap *)notations
{
- return [DOMNamedNodeMap namedNodeMapWithImpl:[self documentTypeImpl]->notations()];
+ return [[self classForDOMNamedNodeMap] namedNodeMapWithImpl:[self documentTypeImpl]->notations()];
}
- (NSString *)publicId
@@ -1395,13 +2203,86 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
@end
//------------------------------------------------------------------------------------------
+// WebCoreDOMDocumentType
+
+ at implementation WebCoreDOMDocumentType
+
+- (id)initWithDocumentTypeImpl:(DocumentTypeImpl *)impl checkCache:(BOOL)checkCache
+{
+ if (!impl) {
+ [self release];
+ return nil;
+ }
+
+ if (checkCache) {
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance) {
+ [self release];
+ return [cachedInstance retain];
+ }
+ }
+
+ [super init];
+ m_impl = impl;
+ impl->ref();
+ setWrapperForImpl(self, m_impl);
+ return self;
+}
+
++ (DOMDocumentType *)documentTypeWithImpl:(DocumentTypeImpl *)impl
+{
+ if (!impl)
+ return nil;
+
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance)
+ return [[cachedInstance retain] autorelease];
+
+ return [[[self alloc] initWithDocumentTypeImpl:impl checkCache:NO] autorelease];
+}
+
+- (id)initWithDocumentTypeImpl:(DocumentTypeImpl *)impl
+{
+ return [self initWithDocumentTypeImpl:impl checkCache:YES];
+}
+
+- (DocumentTypeImpl *)documentTypeImpl
+{
+ return m_impl;
+}
+
+- (Class)classForDOMNamedNodeMap
+{
+ return [WebCoreDOMNamedNodeMap class];
+}
+
+- (void)dealloc
+{
+ if (m_impl) {
+ removeWrapperForImpl(m_impl);
+ m_impl->deref();
+ }
+ [super dealloc];
+}
+
+ at end
+
+//------------------------------------------------------------------------------------------
// DOMNotation
@implementation DOMNotation
- (NotationImpl *)notationImpl
{
- return reinterpret_cast<NotationImpl *>(_internal);
+ AbstractMethodCalled([DOMNotation class]);
+ return nil;
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ return [self retain];
}
- (NSString *)publicId
@@ -1417,13 +2298,81 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
@end
//------------------------------------------------------------------------------------------
+// WebCoreDOMNotation
+
+ at implementation WebCoreDOMNotation
+
+- (id)initWithNotationImpl:(NotationImpl *)impl checkCache:(BOOL)checkCache
+{
+ if (!impl) {
+ [self release];
+ return nil;
+ }
+
+ if (checkCache) {
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance) {
+ [self release];
+ return [cachedInstance retain];
+ }
+ }
+
+ [super init];
+ m_impl = impl;
+ impl->ref();
+ setWrapperForImpl(self, m_impl);
+ return self;
+}
+
++ (DOMNotation *)notationWithImpl:(NotationImpl *)impl
+{
+ if (!impl)
+ return nil;
+
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance)
+ return [[cachedInstance retain] autorelease];
+
+ return [[[self alloc] initWithNotationImpl:impl checkCache:NO] autorelease];
+}
+
+- (id)initWithNotationImpl:(NotationImpl *)impl
+{
+ return [self initWithNotationImpl:impl checkCache:YES];
+}
+
+- (NotationImpl *)notationImpl
+{
+ return m_impl;
+}
+
+- (void)dealloc
+{
+ if (m_impl) {
+ removeWrapperForImpl(m_impl);
+ m_impl->deref();
+ }
+ [super dealloc];
+}
+
+ at end
+
+//------------------------------------------------------------------------------------------
// DOMEntity
@implementation DOMEntity
- (EntityImpl *)entityImpl
{
- return reinterpret_cast<EntityImpl *>(_internal);
+ AbstractMethodCalled([DOMEntity class]);
+ return nil;
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ return [self retain];
}
- (NSString *)publicId
@@ -1444,20 +2393,162 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
@end
//------------------------------------------------------------------------------------------
+// WebCoreDOMEntity
+
+ at implementation WebCoreDOMEntity
+
+- (id)initWithEntityImpl:(EntityImpl *)impl checkCache:(BOOL)checkCache
+{
+ if (!impl) {
+ [self release];
+ return nil;
+ }
+
+ if (checkCache) {
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance) {
+ [self release];
+ return [cachedInstance retain];
+ }
+ }
+
+ [super init];
+ m_impl = impl;
+ impl->ref();
+ setWrapperForImpl(self, m_impl);
+ return self;
+}
+
++ (DOMEntity *)entityWithImpl:(EntityImpl *)impl
+{
+ if (!impl)
+ return nil;
+
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance)
+ return [[cachedInstance retain] autorelease];
+
+ return [[[self alloc] initWithEntityImpl:impl checkCache:NO] autorelease];
+}
+
+- (id)initWithEntityImpl:(EntityImpl *)impl
+{
+ return [self initWithEntityImpl:impl checkCache:YES];
+}
+
+- (EntityImpl *)entityImpl
+{
+ return m_impl;
+}
+
+- (void)dealloc
+{
+ if (m_impl) {
+ removeWrapperForImpl(m_impl);
+ m_impl->deref();
+ }
+ [super dealloc];
+}
+
+ at end
+
+//------------------------------------------------------------------------------------------
// DOMEntityReference
@implementation DOMEntityReference
+- (EntityReferenceImpl *)entityReferenceImpl
+{
+ AbstractMethodCalled([DOMEntityReference class]);
+ return nil;
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ return [self retain];
+}
+
@end
//------------------------------------------------------------------------------------------
+// WebCoreDOMEntityReference
+
+ at implementation WebCoreDOMEntityReference
+
+- (id)initWithEntityReferenceImpl:(EntityReferenceImpl *)impl checkCache:(BOOL)checkCache
+{
+ if (!impl) {
+ [self release];
+ return nil;
+ }
+
+ if (checkCache) {
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance) {
+ [self release];
+ return [cachedInstance retain];
+ }
+ }
+
+ [super init];
+ m_impl = impl;
+ impl->ref();
+ setWrapperForImpl(self, m_impl);
+ return self;
+}
+
++ (DOMEntityReference *)entityReferenceWithImpl:(EntityReferenceImpl *)impl
+{
+ if (!impl)
+ return nil;
+
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance)
+ return [[cachedInstance retain] autorelease];
+
+ return [[[self alloc] initWithEntityReferenceImpl:impl checkCache:NO] autorelease];
+}
+
+- (id)initWithEntityReferenceImpl:(EntityReferenceImpl *)impl
+{
+ return [self initWithEntityReferenceImpl:impl checkCache:YES];
+}
+
+- (EntityReferenceImpl *)entityReferenceImpl
+{
+ return m_impl;
+}
+
+- (void)dealloc
+{
+ if (m_impl) {
+ removeWrapperForImpl(m_impl);
+ m_impl->deref();
+ }
+ [super dealloc];
+}
+
+ at end
+
+
+//------------------------------------------------------------------------------------------
// DOMProcessingInstruction
@implementation DOMProcessingInstruction
- (ProcessingInstructionImpl *)processingInstructionImpl
{
- return reinterpret_cast<ProcessingInstructionImpl *>(_internal);
+ AbstractMethodCalled([DOMProcessingInstruction class]);
+ return nil;
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ return [self retain];
}
- (NSString *)target
@@ -1482,27 +2573,99 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
@end
//------------------------------------------------------------------------------------------
-// DOMRange
+// WebCoreDOMProcessingInstruction
- at implementation DOMRange
+ at implementation WebCoreDOMProcessingInstruction
+
+- (id)initWithProcessingInstructionImpl:(ProcessingInstructionImpl *)impl checkCache:(BOOL)checkCache
+{
+ if (!impl) {
+ [self release];
+ return nil;
+ }
+
+ if (checkCache) {
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance) {
+ [self release];
+ return [cachedInstance retain];
+ }
+ }
+
+ [super init];
+ m_impl = impl;
+ impl->ref();
+ setWrapperForImpl(self, m_impl);
+ return self;
+}
+
++ (DOMProcessingInstruction *)processingInstructionWithImpl:(ProcessingInstructionImpl *)impl
+{
+ if (!impl)
+ return nil;
+
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance)
+ return [[cachedInstance retain] autorelease];
+
+ return [[[self alloc] initWithProcessingInstructionImpl:impl checkCache:NO] autorelease];
+}
+
+- (id)initWithProcessingInstructionImpl:(ProcessingInstructionImpl *)impl
+{
+ return [self initWithProcessingInstructionImpl:impl checkCache:YES];
+}
+
+- (ProcessingInstructionImpl *)processingInstructionImpl
+{
+ return m_impl;
+}
- (void)dealloc
{
- if (_internal) {
- reinterpret_cast<RangeImpl *>(_internal)->deref();
+ if (m_impl) {
+ removeWrapperForImpl(m_impl);
+ m_impl->deref();
}
[super dealloc];
}
+ at end
+
+//------------------------------------------------------------------------------------------
+// DOMRange
+
+ at implementation DOMRange
+
- (RangeImpl *)rangeImpl
{
- return reinterpret_cast<RangeImpl *>(_internal);
+ AbstractMethodCalled([DOMRange class]);
+ return nil;
+}
+
+- (Class)classForDOMDocumentFragment
+{
+ AbstractMethodCalled([DOMRange class]);
+ return nil;
+}
+
+- (Class)classForDOMNode
+{
+ AbstractMethodCalled([DOMRange class]);
+ return nil;
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ return [self retain];
}
- (DOMNode *)startContainer:(NSError **)error
{
int code;
- DOMNode *result = [DOMNode nodeWithImpl:[self rangeImpl]->startContainer(code)];
+ DOMNode *result = [[self classForDOMNode] nodeWithImpl:[self rangeImpl]->startContainer(code)];
fillInError(error, code);
return result;
}
@@ -1518,7 +2681,7 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
- (DOMNode *)endContainer:(NSError **)error
{
int code;
- DOMNode *result = [DOMNode nodeWithImpl:[self rangeImpl]->endContainer(code)];
+ DOMNode *result = [[self classForDOMNode] nodeWithImpl:[self rangeImpl]->endContainer(code)];
fillInError(error, code);
return result;
}
@@ -1542,7 +2705,7 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
- (DOMNode *)commonAncestorContainer:(NSError **)error
{
int code;
- DOMNode *result = [DOMNode nodeWithImpl:[self rangeImpl]->commonAncestorContainer(code)];
+ DOMNode *result = [[self classForDOMNode] nodeWithImpl:[self rangeImpl]->commonAncestorContainer(code)];
fillInError(error, code);
return result;
}
@@ -1628,7 +2791,7 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
- (DOMDocumentFragment *)extractContents:(NSError **)error
{
int code;
- DOMDocumentFragment *result = [DOMDocumentFragment documentFragmentWithImpl:[self rangeImpl]->extractContents(code)];
+ DOMDocumentFragment *result = [[self classForDOMDocumentFragment] documentFragmentWithImpl:[self rangeImpl]->extractContents(code)];
fillInError(error, code);
return result;
}
@@ -1636,7 +2799,7 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
- (DOMDocumentFragment *)cloneContents:(NSError **)error
{
int code;
- DOMDocumentFragment *result = [DOMDocumentFragment documentFragmentWithImpl:[self rangeImpl]->cloneContents(code)];
+ DOMDocumentFragment *result = [[self classForDOMDocumentFragment] documentFragmentWithImpl:[self rangeImpl]->cloneContents(code)];
fillInError(error, code);
return result;
}
@@ -1658,7 +2821,7 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
- (DOMRange *)cloneRange:(NSError **)error
{
int code;
- DOMRange *result = [DOMRange rangeWithImpl:[self rangeImpl]->cloneRange(code)];
+ DOMRange *result = [WebCoreDOMRange rangeWithImpl:[self rangeImpl]->cloneRange(code)];
fillInError(error, code);
return result;
}
@@ -1680,16 +2843,31 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
@end
- at implementation DOMRange (WebCoreInternal)
+//------------------------------------------------------------------------------------------
+// WebCoreDOMRange
+
+ at implementation WebCoreDOMRange
-- (id)initWithRangeImpl:(RangeImpl *)impl
+- (id)initWithRangeImpl:(RangeImpl *)impl checkCache:(BOOL)checkCache
{
- ASSERT(impl);
+ if (!impl) {
+ [self release];
+ return nil;
+ }
+
+ if (checkCache) {
+ id cachedInstance;
+ cachedInstance = wrapperForImpl(impl);
+ if (cachedInstance) {
+ [self release];
+ return [cachedInstance retain];
+ }
+ }
[super init];
- _internal = reinterpret_cast<DOMObjectInternal *>(impl);
+ m_impl = impl;
impl->ref();
- setWrapperForImpl(self, impl);
+ setWrapperForImpl(self, m_impl);
return self;
}
@@ -1703,7 +2881,26 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
if (cachedInstance)
return [[cachedInstance retain] autorelease];
- return [[[self alloc] initWithRangeImpl:impl] autorelease];
+ return [[[self alloc] initWithRangeImpl:impl checkCache:NO] autorelease];
+}
+
+- (id)initWithRangeImpl:(RangeImpl *)impl
+{
+ return [self initWithRangeImpl:impl checkCache:YES];
+}
+
+- (RangeImpl *)rangeImpl
+{
+ return m_impl;
+}
+
+- (void)dealloc
+{
+ if (m_impl) {
+ removeWrapperForImpl(m_impl);
+ m_impl->deref();
+ }
+ [super dealloc];
}
@end
diff --git a/WebCore/kwq/DOMInternal.h b/WebCore/kwq/DOMInternal.h
index 8c0df50..4bb3626 100644
--- a/WebCore/kwq/DOMInternal.h
+++ b/WebCore/kwq/DOMInternal.h
@@ -26,21 +26,260 @@
#import "DOM.h"
namespace DOM {
+ class AttrImpl;
+ class CDATASectionImpl;
+ class CharacterDataImpl;
+ class CommentImpl;
+ class DocumentFragmentImpl;
+ class DocumentTypeImpl;
class DocumentImpl;
+ class DOMImplementationImpl;
class ElementImpl;
+ class EntityImpl;
+ class EntityReferenceImpl;
+ class NamedNodeMapImpl;
class NodeImpl;
+ class NodeListImpl;
+ class NotationImpl;
+ class ProcessingInstructionImpl;
+ class RangeImpl;
+ class TextImpl;
}
- at interface DOMNode (WebCoreInternal)
-+ (DOMNode *)nodeWithImpl:(DOM::NodeImpl *)impl;
+ at interface DOMNode (SubclassResponsibility)
- (DOM::NodeImpl *)nodeImpl;
+- (Class)classForDOMDocument;
@end
- at interface DOMElement (WebCoreInternal)
-+ (DOMElement *)elementWithImpl:(DOM::ElementImpl *)impl;
-- (DOM::ElementImpl *)elementImpl;
+ at interface WebCoreDOMNode : DOMNode
+{
+ DOM::NodeImpl *m_impl;
+}
++ (DOMNode *)nodeWithImpl:(DOM::NodeImpl *)impl;
+- (id)initWithNodeImpl:(DOM::NodeImpl *)impl;
+ at end
+
+ at interface DOMNamedNodeMap (SubclassResponsibility)
+- (DOM::NamedNodeMapImpl *)namedNodeMapImpl;
+- (Class)classForDOMNode;
+ at end
+
+ at interface WebCoreDOMNamedNodeMap : DOMNamedNodeMap
+{
+ DOM::NamedNodeMapImpl *m_impl;
+}
++ (DOMNamedNodeMap *)namedNodeMapWithImpl:(DOM::NamedNodeMapImpl *)impl;
+- (id)initWithNamedNodeMapImpl:(DOM::NamedNodeMapImpl *)impl;
+ at end
+
+ at interface DOMNodeList (SubclassResponsibility)
+- (DOM::NodeListImpl *)nodeListImpl;
@end
- at interface DOMDocument (WebCoreInternal)
+ at interface WebCoreDOMNodeList : DOMNodeList
+{
+ DOM::NodeListImpl *m_impl;
+}
++ (DOMNodeList *)nodeListWithImpl:(DOM::NodeListImpl *)impl;
+- (id)initWithNodeListImpl:(DOM::NodeListImpl *)impl;
+ at end
+
+ at interface DOMImplementation (SubclassResponsibility)
+- (DOM::DOMImplementationImpl *)DOMImplementationImpl;
+- (Class)classForDOMDocumentType;
+- (Class)classForDOMDocument;
+ at end
+
+ at interface WebCoreDOMImplementation : DOMImplementation
+{
+ DOM::DOMImplementationImpl *m_impl;
+}
++ (DOMImplementation *)DOMImplementationWithImpl:(DOM::DOMImplementationImpl *)impl;
+- (id)initWithDOMImplementationImpl:(DOM::DOMImplementationImpl *)impl;
+ at end
+
+ at interface DOMDocumentFragment (SubclassResponsibility)
+- (DOM::DocumentFragmentImpl *)documentFragmentImpl;
+ at end
+
+ at interface WebCoreDOMDocumentFragment : DOMDocumentFragment
+{
+ DOM::DocumentFragmentImpl *m_impl;
+}
++ (DOMDocumentFragment *)documentFragmentWithImpl:(DOM::DocumentFragmentImpl *)impl;
+- (id)initWithDocumentFragmentImpl:(DOM::DocumentFragmentImpl *)impl;
+ at end
+
+ at interface DOMDocument (SubclassResponsibility)
+- (DOM::DocumentImpl *)documentImpl;
+- (Class)classForDOMAttr;
+- (Class)classForDOMCDATASection;
+- (Class)classForDOMComment;
+- (Class)classForDOMDocumentFragment;
+- (Class)classForDOMDocumentType;
+- (Class)classForDOMElement;
+- (Class)classForDOMEntityReference;
+- (Class)classForDOMImplementation;
+- (Class)classForDOMNode;
+- (Class)classForDOMNodeList;
+- (Class)classForDOMProcessingInstruction;
+- (Class)classForDOMText;
+ at end
+
+ at interface WebCoreDOMDocument : DOMDocument
+{
+ DOM::DocumentImpl *m_impl;
+}
+ (DOMDocument *)documentWithImpl:(DOM::DocumentImpl *)impl;
+- (id)initWithDocumentImpl:(DOM::DocumentImpl *)impl;
+ at end
+
+ at interface DOMCharacterData (SubclassResponsibility)
+- (DOM::CharacterDataImpl *)characterDataImpl;
+ at end
+
+ at interface WebCoreDOMCharacterData : DOMCharacterData
+{
+ DOM::CharacterDataImpl *m_impl;
+}
++ (DOMCharacterData *)characterDataWithImpl:(DOM::CharacterDataImpl *)impl;
+- (id)initWithCharacterDataImpl:(DOM::CharacterDataImpl *)impl;
+ at end
+
+ at interface DOMAttr (SubclassResponsibility)
+- (DOM::AttrImpl *)attrImpl;
+- (Class)classForDOMElement;
+ at end
+
+ at interface WebCoreDOMAttr : DOMAttr
+{
+ DOM::AttrImpl *m_impl;
+}
++ (DOMAttr *)attrWithImpl:(DOM::AttrImpl *)impl;
+- (id)initWithAttrImpl:(DOM::AttrImpl *)impl;
+ at end
+
+ at interface DOMElement (SubclassResponsibility)
+- (DOM::ElementImpl *)elementImpl;
+- (Class)classForDOMAttr;
+- (Class)classForDOMNodeList;
+ at end
+
+ at interface WebCoreDOMElement : DOMElement
+{
+ DOM::ElementImpl *m_impl;
+}
++ (DOMElement *)elementWithImpl:(DOM::ElementImpl *)impl;
+- (id)initWithElementImpl:(DOM::ElementImpl *)impl;
+ at end
+
+ at interface DOMText (SubclassResponsibility)
+- (DOM::TextImpl *)textImpl;
+ at end
+
+ at interface WebCoreDOMText : DOMText
+{
+ DOM::TextImpl *m_impl;
+}
++ (DOMText *)textWithImpl:(DOM::TextImpl *)impl;
+- (id)initWithTextImpl:(DOM::TextImpl *)impl;
+ at end
+
+ at interface DOMComment (SubclassResponsibility)
+- (DOM::CommentImpl *)commentImpl;
+ at end
+
+ at interface WebCoreDOMComment : DOMComment
+{
+ DOM::CommentImpl *m_impl;
+}
++ (DOMComment *)commentWithImpl:(DOM::CommentImpl *)impl;
+- (id)initWithCommentImpl:(DOM::CommentImpl *)impl;
+ at end
+
+ at interface DOMCDATASection (SubclassResponsibility)
+- (DOM::CDATASectionImpl *)CDATASectionImpl;
+ at end
+
+ at interface WebCoreDOMCDATASection : DOMCDATASection
+{
+ DOM::CDATASectionImpl *m_impl;
+}
++ (DOMCDATASection *)CDATASectionWithImpl:(DOM::CDATASectionImpl *)impl;
+- (id)initWithCDATASectionImpl:(DOM::CDATASectionImpl *)impl;
+ at end
+
+ at interface DOMDocumentType (SubclassResponsibility)
+- (DOM::DocumentTypeImpl *)documentTypeImpl;
+- (Class)classForDOMNamedNodeMap;
+ at end
+
+ at interface WebCoreDOMDocumentType : DOMDocumentType
+{
+ DOM::DocumentTypeImpl *m_impl;
+}
++ (DOMDocumentType *)documentTypeWithImpl:(DOM::DocumentTypeImpl *)impl;
+- (id)initWithDocumentTypeImpl:(DOM::DocumentTypeImpl *)impl;
+ at end
+
+ at interface DOMNotation (SubclassResponsibility)
+- (DOM::NotationImpl *)notationImpl;
+ at end
+
+ at interface WebCoreDOMNotation : DOMNotation
+{
+ DOM::NotationImpl *m_impl;
+}
++ (DOMNotation *)notationWithImpl:(DOM::NotationImpl *)impl;
+- (id)initWithNotationImpl:(DOM::NotationImpl *)impl;
+ at end
+
+ at interface DOMEntity (SubclassResponsibility)
+- (DOM::EntityImpl *)entityImpl;
+ at end
+
+ at interface WebCoreDOMEntity : DOMEntity
+{
+ DOM::EntityImpl *m_impl;
+}
++ (DOMEntity *)entityWithImpl:(DOM::EntityImpl *)impl;
+- (id)initWithEntityImpl:(DOM::EntityImpl *)impl;
+ at end
+
+ at interface DOMEntityReference (SubclassResponsibility)
+- (DOM::EntityReferenceImpl *)entityReferenceImpl;
+ at end
+
+ at interface WebCoreDOMEntityReference : DOMEntityReference
+{
+ DOM::EntityReferenceImpl *m_impl;
+}
++ (DOMEntityReference *)entityReferenceWithImpl:(DOM::EntityReferenceImpl *)impl;
+- (id)initWithEntityReferenceImpl:(DOM::EntityReferenceImpl *)impl;
+ at end
+
+ at interface DOMProcessingInstruction (SubclassResponsibility)
+- (DOM::ProcessingInstructionImpl *)processingInstructionImpl;
+ at end
+
+ at interface WebCoreDOMProcessingInstruction : DOMProcessingInstruction
+{
+ DOM::ProcessingInstructionImpl *m_impl;
+}
++ (DOMProcessingInstruction *)processingInstructionWithImpl:(DOM::ProcessingInstructionImpl *)impl;
+- (id)initWithProcessingInstructionImpl:(DOM::ProcessingInstructionImpl *)impl;
+ at end
+
+ at interface DOMRange (SubclassResponsibility)
+- (DOM::RangeImpl *)rangeImpl;
+- (Class)classForDOMDocumentFragment;
+- (Class)classForDOMNode;
+ at end
+
+ at interface WebCoreDOMRange : DOMRange
+{
+ DOM::RangeImpl *m_impl;
+}
++ (DOMRange *)rangeWithImpl:(DOM::RangeImpl *)impl;
+- (id)initWithRangeImpl:(DOM::RangeImpl *)impl;
@end
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index e8abf17..d506045 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -35,6 +35,7 @@
#import "KWQWindowWidget.h"
#import "WebCoreBridge.h"
#import "WebCoreViewFactory.h"
+#import "DOM.h"
#import "DOMInternal.h"
#import "csshelper.h"
#import "html_documentimpl.h"
@@ -581,7 +582,7 @@ void KWQKHTMLPart::recordFormValue(const QString &name, const QString &value, HT
if (!_formValuesAboutToBeSubmitted) {
_formValuesAboutToBeSubmitted = [[NSMutableDictionary alloc] init];
ASSERT(!_formAboutToBeSubmitted);
- _formAboutToBeSubmitted = [[DOMElement elementWithImpl:element] retain];
+ _formAboutToBeSubmitted = [[WebCoreDOMElement elementWithImpl:element] retain];
} else {
ASSERT([_formAboutToBeSubmitted elementImpl] == element);
}
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index c3b2ecf..08de72a 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -65,6 +65,7 @@
#import "KWQPrinter.h"
#import "KWQAccObjectCache.h"
+#import "DOM.h"
#import "DOMInternal.h"
#import "WebCoreImageRenderer.h"
#import "WebCoreTextRendererFactory.h"
@@ -746,13 +747,13 @@ static BOOL nowPrinting(WebCoreBridge *self)
QWidget *widget = [widgetHolder widget];
if (widget != nil) {
NodeImpl *node = static_cast<const RenderWidget *>(widget->eventFilterObject())->element();
- return [DOMElement elementWithImpl:static_cast<ElementImpl *>(node)];
+ return [WebCoreDOMElement elementWithImpl:static_cast<ElementImpl *>(node)];
}
}
return nil;
}
-static NSView *viewForElement(ElementImpl *elementImpl)
+static NSView *viewForElement(DOM::ElementImpl *elementImpl)
{
RenderObject *renderer = elementImpl->renderer();
if (renderer && renderer->isWidget()) {
@@ -765,20 +766,20 @@ static NSView *viewForElement(ElementImpl *elementImpl)
return nil;
}
-static HTMLInputElementImpl *inputElementFromDOMElement(DOMElement *element)
+static HTMLInputElementImpl *inputElementFromDOMElement(DOMElement * element)
{
- NodeImpl *node = [element nodeImpl];
- if (node && idFromNode(node) == ID_INPUT) {
- return static_cast<HTMLInputElementImpl *>(node);
+ DOM::ElementImpl *domElement = [element elementImpl];
+ if (domElement && idFromNode(domElement) == ID_INPUT) {
+ return static_cast<HTMLInputElementImpl *>(domElement);
}
return nil;
}
static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
{
- NodeImpl *node = [element nodeImpl];
- if (node && idFromNode(node) == ID_FORM) {
- return static_cast<HTMLFormElementImpl *>(node);
+ DOM::ElementImpl *domElement = [element elementImpl];
+ if (domElement && idFromNode(domElement) == ID_FORM) {
+ return static_cast<HTMLFormElementImpl *>(domElement);
}
return nil;
}
@@ -793,7 +794,7 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
HTMLGenericFormElementImpl *elt = elements.at(i);
// Skip option elements, other duds
if (elt->name() == targetName) {
- return [DOMElement elementWithImpl:elt];
+ return [WebCoreDOMElement elementWithImpl:elt];
}
}
}
@@ -821,7 +822,7 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
if (inputElement) {
HTMLFormElementImpl *formElement = inputElement->form();
if (formElement) {
- return [DOMElement elementWithImpl:formElement];
+ return [WebCoreDOMElement elementWithImpl:formElement];
}
}
return nil;
@@ -830,7 +831,7 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
- (DOMElement *)currentForm
{
HTMLFormElementImpl *formElement = _part->currentForm();
- return formElement ? [DOMElement elementWithImpl:formElement] : nil;
+ return formElement ? [WebCoreDOMElement elementWithImpl:formElement] : nil;
}
- (NSArray *)controlsInForm:(DOMElement *)form
@@ -933,7 +934,7 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
[element setObject:[NSNumber numberWithBool:node->isContentEditable()]
forKey:WebCoreElementIsEditableKey];
- [element setObject:[DOMNode nodeWithImpl:node] forKey:WebCoreElementDOMNodeKey];
+ [element setObject:[WebCoreDOMNode nodeWithImpl:node] forKey:WebCoreElementDOMNodeKey];
if (node->renderer() && node->renderer()->isImage()) {
RenderImage *r = static_cast<RenderImage *>(node->renderer());
@@ -1040,7 +1041,7 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
- (DOMDocument *)DOMDocument
{
- return [DOMDocument documentWithImpl:_part->xmlDocImpl()];
+ return [WebCoreDOMDocument documentWithImpl:_part->xmlDocImpl()];
}
- (void)setSelectionFrom:(DOMNode *)start startOffset:(int)startOffset to:(DOMNode *)end endOffset:(int) endOffset
@@ -1065,7 +1066,7 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
- (DOMNode *)selectionStart
{
- return [DOMNode nodeWithImpl:_part->selectionStart()];
+ return [WebCoreDOMNode nodeWithImpl:_part->selectionStart()];
}
- (int)selectionStartOffset
@@ -1075,7 +1076,7 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
- (DOMNode *)selectionEnd
{
- return [DOMNode nodeWithImpl:_part->selectionEnd()];
+ return [WebCoreDOMNode nodeWithImpl:_part->selectionEnd()];
}
- (int)selectionEndOffset
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index d8b0531..be110cd 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,10 @@
+2004-03-02 Ken Kocienda <kocienda at apple.com>
+
+ Reviewed by me
+
+ * DOM.subproj/DOM.h: Rollout last night's checkin.
+ The tree was closed.
+
2004-03-01 Chris Blumenberg <cblu at apple.com>
Fixed: <rdar://problem/3574979>: REGRESSION (129-TOT): crash loading macromedia.com
diff --git a/WebKit/DOM.subproj/DOM.h b/WebKit/DOM.subproj/DOM.h
index f997918..1795c1f 100644
--- a/WebKit/DOM.subproj/DOM.h
+++ b/WebKit/DOM.subproj/DOM.h
@@ -23,8 +23,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#import <Foundation/Foundation.h>
-
//=========================================================================
//=========================================================================
//=========================================================================
@@ -73,27 +71,28 @@ enum DOMErrorCode {
extern NSString * const DOMErrorDomain;
+ at class NSError;
+ at class NSString;
+
+ at class DOMNode;
+ at class DOMNamedNodeMap;
+ at class DOMNodeList;
+ at class DOMDocumentFragment;
+ at class DOMDocument;
+ at class DOMCharacterData;
@class DOMAttr;
- at class DOMCDATASection;
+ at class DOMElement;
+ at class DOMText;
@class DOMComment;
- at class DOMDocument;
+ at class DOMCDATASection;
@class DOMDocumentType;
- at class DOMElement;
+ at class DOMNotation;
+ at class DOMEntity;
@class DOMEntityReference;
- at class DOMNamedNodeMap;
- at class DOMNodeList;
@class DOMProcessingInstruction;
- at class DOMText;
-
-typedef struct DOMObjectInternal DOMObjectInternal;
+ at class DOMRange;
- at interface DOMObject : NSObject <NSCopying>
-{
- DOMObjectInternal *_internal;
-}
- at end
-
- at interface DOMNode : DOMObject
+ at interface DOMNode : NSObject <NSCopying>
- (NSString *)nodeName;
- (NSString *)nodeValue;
- (void)setNodeValue:(NSString *)string error:(NSError **)error;
@@ -122,7 +121,7 @@ typedef struct DOMObjectInternal DOMObjectInternal;
- (NSString *)HTMLString;
@end
- at interface DOMNamedNodeMap : DOMObject
+ at interface DOMNamedNodeMap : NSObject <NSCopying>
- (DOMNode *)getNamedItem:(NSString *)name;
- (DOMNode *)setNamedItem:(DOMNode *)arg error:(NSError **)error;
- (DOMNode *)removeNamedItem:(NSString *)name error:(NSError **)error;
@@ -134,13 +133,13 @@ typedef struct DOMObjectInternal DOMObjectInternal;
@end
- at interface DOMNodeList : DOMObject
+ at interface DOMNodeList : NSObject <NSCopying>
- (DOMNode *)item:(unsigned long)index;
- (unsigned long)length;
@end
- at interface DOMImplementation : DOMObject
+ at interface DOMImplementation : NSObject <NSCopying>
- (BOOL)hasFeature:(NSString *)feature :(NSString *)version;
- (DOMDocumentType *)createDocumentType:(NSString *)qualifiedName :(NSString *)publicId :(NSString *)systemId error:(NSError **)error;
- (DOMDocument *)createDocument:(NSString *)namespaceURI :(NSString *)qualifiedName :(DOMDocumentType *)doctype error:(NSError **)error;
@@ -268,7 +267,7 @@ enum DOMCompareHow
DOMCompareEndToStart = 3,
};
- at interface DOMRange : DOMObject
+ at interface DOMRange : NSObject
- (DOMNode *)startContainer:(NSError **)error;
- (long)startOffset:(NSError **)error;
- (DOMNode *)endContainer:(NSError **)error;
@@ -294,3 +293,4 @@ enum DOMCompareHow
- (NSString *)toString:(NSError **)error;
- (void)detach:(NSError **)error;
@end
+
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list