Add skeleton of a WebKit2 ObjC DOM SPI (not intended to be the full DOM)
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Oct 2012 22:31:08 +0000 (22:31 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Oct 2012 22:31:08 +0000 (22:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=98955

Reviewed by Anders Carlsson.

Add a skeleton DOM implementation only exposing Node, Element and Document
for now. It is currently only available in 64-bit as it relies on the non-fragile
ABI for now.

* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/InjectedBundle/API/mac/WKDOMDocument.h: Added.
* WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm: Added.
* WebProcess/InjectedBundle/API/mac/WKDOMElement.h: Added.
* WebProcess/InjectedBundle/API/mac/WKDOMElement.mm: Added.
* WebProcess/InjectedBundle/API/mac/WKDOMInternals.h: Added.
* WebProcess/InjectedBundle/API/mac/WKDOMInternals.mm: Added.
* WebProcess/InjectedBundle/API/mac/WKDOMNode.h: Added.
* WebProcess/InjectedBundle/API/mac/WKDOMNode.mm: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@130971 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.h [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMElement.h [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMElement.mm [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMInternals.h [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMInternals.mm [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.h [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.mm [new file with mode: 0644]

index 2612cb3..fe311c2 100644 (file)
@@ -1,3 +1,24 @@
+2012-10-10  Sam Weinig  <sam@webkit.org>
+
+        Add skeleton of a WebKit2 ObjC DOM SPI (not intended to be the full DOM)
+        https://bugs.webkit.org/show_bug.cgi?id=98955
+
+        Reviewed by Anders Carlsson.
+
+        Add a skeleton DOM implementation only exposing Node, Element and Document
+        for now. It is currently only available in 64-bit as it relies on the non-fragile
+        ABI for now.
+
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/InjectedBundle/API/mac/WKDOMDocument.h: Added.
+        * WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm: Added.
+        * WebProcess/InjectedBundle/API/mac/WKDOMElement.h: Added.
+        * WebProcess/InjectedBundle/API/mac/WKDOMElement.mm: Added.
+        * WebProcess/InjectedBundle/API/mac/WKDOMInternals.h: Added.
+        * WebProcess/InjectedBundle/API/mac/WKDOMInternals.mm: Added.
+        * WebProcess/InjectedBundle/API/mac/WKDOMNode.h: Added.
+        * WebProcess/InjectedBundle/API/mac/WKDOMNode.mm: Added.
+
 2012-10-04  Andy Estes  <aestes@apple.com>
 
         [WebKit2] Create an API for adding and removing user stylesheets from a page group
index 5c390da..18e9781 100644 (file)
                B878B615133428DC006888E9 /* CorrectionPanel.h in Headers */ = {isa = PBXBuildFile; fileRef = B878B613133428DC006888E9 /* CorrectionPanel.h */; };
                B878B616133428DC006888E9 /* CorrectionPanel.mm in Sources */ = {isa = PBXBuildFile; fileRef = B878B614133428DC006888E9 /* CorrectionPanel.mm */; };
                BC0092F8115837A300E0AE2A /* WorkQueueMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC0092F6115837A300E0AE2A /* WorkQueueMac.cpp */; };
+               BC017D0716260FF4007054F5 /* WKDOMDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = BC017CFF16260FF4007054F5 /* WKDOMDocument.h */; };
+               BC017D0816260FF4007054F5 /* WKDOMDocument.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC017D0016260FF4007054F5 /* WKDOMDocument.mm */; };
+               BC017D0916260FF4007054F5 /* WKDOMElement.h in Headers */ = {isa = PBXBuildFile; fileRef = BC017D0116260FF4007054F5 /* WKDOMElement.h */; };
+               BC017D0A16260FF4007054F5 /* WKDOMElement.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC017D0216260FF4007054F5 /* WKDOMElement.mm */; };
+               BC017D0B16260FF4007054F5 /* WKDOMInternals.h in Headers */ = {isa = PBXBuildFile; fileRef = BC017D0316260FF4007054F5 /* WKDOMInternals.h */; };
+               BC017D0C16260FF4007054F5 /* WKDOMInternals.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC017D0416260FF4007054F5 /* WKDOMInternals.mm */; };
+               BC017D0D16260FF4007054F5 /* WKDOMNode.h in Headers */ = {isa = PBXBuildFile; fileRef = BC017D0516260FF4007054F5 /* WKDOMNode.h */; };
+               BC017D0E16260FF4007054F5 /* WKDOMNode.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC017D0616260FF4007054F5 /* WKDOMNode.mm */; };
                BC032D7510F4378D0058C15A /* WebChromeClient.h in Headers */ = {isa = PBXBuildFile; fileRef = BC032D6010F4378D0058C15A /* WebChromeClient.h */; };
                BC032D7710F4378D0058C15A /* WebContextMenuClient.h in Headers */ = {isa = PBXBuildFile; fileRef = BC032D6210F4378D0058C15A /* WebContextMenuClient.h */; };
                BC032D7B10F4378D0058C15A /* WebDragClient.h in Headers */ = {isa = PBXBuildFile; fileRef = BC032D6610F4378D0058C15A /* WebDragClient.h */; };
                B878B613133428DC006888E9 /* CorrectionPanel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CorrectionPanel.h; sourceTree = "<group>"; };
                B878B614133428DC006888E9 /* CorrectionPanel.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CorrectionPanel.mm; sourceTree = "<group>"; };
                BC0092F6115837A300E0AE2A /* WorkQueueMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkQueueMac.cpp; sourceTree = "<group>"; };
+               BC017CFF16260FF4007054F5 /* WKDOMDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKDOMDocument.h; sourceTree = "<group>"; };
+               BC017D0016260FF4007054F5 /* WKDOMDocument.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKDOMDocument.mm; sourceTree = "<group>"; };
+               BC017D0116260FF4007054F5 /* WKDOMElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKDOMElement.h; sourceTree = "<group>"; };
+               BC017D0216260FF4007054F5 /* WKDOMElement.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKDOMElement.mm; sourceTree = "<group>"; };
+               BC017D0316260FF4007054F5 /* WKDOMInternals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKDOMInternals.h; sourceTree = "<group>"; };
+               BC017D0416260FF4007054F5 /* WKDOMInternals.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKDOMInternals.mm; sourceTree = "<group>"; };
+               BC017D0516260FF4007054F5 /* WKDOMNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKDOMNode.h; sourceTree = "<group>"; };
+               BC017D0616260FF4007054F5 /* WKDOMNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKDOMNode.mm; sourceTree = "<group>"; };
                BC032D6010F4378D0058C15A /* WebChromeClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebChromeClient.h; sourceTree = "<group>"; };
                BC032D6210F4378D0058C15A /* WebContextMenuClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebContextMenuClient.h; sourceTree = "<group>"; };
                BC032D6610F4378D0058C15A /* WebDragClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebDragClient.h; sourceTree = "<group>"; };
                        name = mac;
                        sourceTree = "<group>";
                };
+               BC017D1016260FFD007054F5 /* DOM */ = {
+                       isa = PBXGroup;
+                       children = (
+                               BC017CFF16260FF4007054F5 /* WKDOMDocument.h */,
+                               BC017D0016260FF4007054F5 /* WKDOMDocument.mm */,
+                               BC017D0116260FF4007054F5 /* WKDOMElement.h */,
+                               BC017D0216260FF4007054F5 /* WKDOMElement.mm */,
+                               BC017D0316260FF4007054F5 /* WKDOMInternals.h */,
+                               BC017D0416260FF4007054F5 /* WKDOMInternals.mm */,
+                               BC017D0516260FF4007054F5 /* WKDOMNode.h */,
+                               BC017D0616260FF4007054F5 /* WKDOMNode.mm */,
+                       );
+                       name = DOM;
+                       sourceTree = "<group>";
+               };
                BC032D5C10F436D50058C15A /* WebProcess */ = {
                        isa = PBXGroup;
                        children = (
                BC989D4516181691000D46D3 /* mac */ = {
                        isa = PBXGroup;
                        children = (
-                               BC989D7F161A7E5B000D46D3 /* WKWebProcessPlugIn.mm */,
+                               BC017D1016260FFD007054F5 /* DOM */,
                                BC989D80161A7E5C000D46D3 /* WKWebProcessPlugIn.h */,
+                               BC989D7F161A7E5B000D46D3 /* WKWebProcessPlugIn.mm */,
                                BC989D84161A988F000D46D3 /* WKWebProcessPlugInInternal.h */,
                        );
                        path = mac;
                                1A3EED0F161A535400AEB4F5 /* MessageReceiverMap.h in Headers */,
                                1A3EED12161A53D600AEB4F5 /* MessageReceiver.h in Headers */,
                                29D55DF2161BF9F10031A2E3 /* WebPageGroupProxyMessages.h in Headers */,
+                               BC017D0716260FF4007054F5 /* WKDOMDocument.h in Headers */,
+                               BC017D0916260FF4007054F5 /* WKDOMElement.h in Headers */,
+                               BC017D0B16260FF4007054F5 /* WKDOMInternals.h in Headers */,
+                               BC017D0D16260FF4007054F5 /* WKDOMNode.h in Headers */,
                                29121708161CE7360057D451 /* UserContentContainer.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                                BC989D81161A7E5D000D46D3 /* WKWebProcessPlugIn.mm in Sources */,
                                1A3EED0E161A535400AEB4F5 /* MessageReceiverMap.cpp in Sources */,
                                29D55DF1161BF9F10031A2E3 /* WebPageGroupProxyMessageReceiver.cpp in Sources */,
+                               BC017D0816260FF4007054F5 /* WKDOMDocument.mm in Sources */,
+                               BC017D0A16260FF4007054F5 /* WKDOMElement.mm in Sources */,
+                               BC017D0C16260FF4007054F5 /* WKDOMInternals.mm in Sources */,
+                               BC017D0E16260FF4007054F5 /* WKDOMNode.mm in Sources */,
                                29121707161CE7360057D451 /* UserContentContainer.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.h
new file mode 100644 (file)
index 0000000..dd35a6b
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if __LP64__
+
+#import <WebKit2/WKDOMNode.h>
+
+WK_EXPORT
+@interface WKDOMDocument : WKDOMNode
+@end
+
+#endif // __LP64__
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm
new file mode 100644 (file)
index 0000000..13d8f44
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#if __LP64__
+
+#import "WKDOMDocument.h"
+
+#import "WKDOMInternals.h"
+#import <WebCore/Document.h>
+
+@implementation WKDOMDocument
+@end
+
+#endif // __LP64__
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMElement.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMElement.h
new file mode 100644 (file)
index 0000000..6fbf5e8
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if __LP64__
+
+#import <WebKit2/WKDOMNode.h>
+
+WK_EXPORT
+@interface WKDOMElement : WKDOMNode
+@end
+
+#endif // __LP64__
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMElement.mm b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMElement.mm
new file mode 100644 (file)
index 0000000..c66c799
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#if __LP64__
+
+#import "WKDOMElement.h"
+
+#import "WKDOMInternals.h"
+#import <WebCore/Element.h>
+
+@implementation WKDOMElement
+@end
+
+#endif // __LP64__
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMInternals.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMInternals.h
new file mode 100644 (file)
index 0000000..a94f0ca
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if __LP64__
+
+#import "WKDOMNode.h"
+#import <WebCore/Node.h>
+
+namespace WebCore {
+class Element;
+class Document;
+}
+
+@class WKDOMElement;
+@class WKDOMDocument;
+
+@interface WKDOMNode () {
+@public
+    RefPtr<WebCore::Node> _node;
+}
+
+- (id)_initWithNode:(WebCore::Node*)node;
+@end
+
+namespace WebKit {
+
+WebCore::Node* toWebCoreNode(WKDOMNode *);
+WKDOMNode *toWKDOMNode(WebCore::Node*);
+
+WebCore::Element* toWebCoreElement(WKDOMElement *);
+WKDOMElement *toWKDOMElement(WebCore::Element*);
+
+WebCore::Document* toWebCoreDocument(WKDOMDocument *);
+WKDOMDocument *toWKDOMDocument(WebCore::Document*);
+
+void WKDOMNodeCacheAdd(WebCore::Node*, WKDOMNode *);
+WKDOMNode *WKDOMNodeCacheGet(WebCore::Node*);
+void WKDOMNodeCacheRemove(WebCore::Node*);
+
+} // namespace WebKit
+
+#endif // __LP64__
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMInternals.mm b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMInternals.mm
new file mode 100644 (file)
index 0000000..8af9506
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#if __LP64__
+
+#import "WKDOMInternals.h"
+
+#import <WebCore/Document.h>
+#import <WebCore/Element.h>
+#import <WebCore/Node.h>
+#import <wtf/HashMap.h>
+
+// Classes to instantiate.
+#import "WKDOMElement.h"
+#import "WKDOMDocument.h"
+
+namespace WebKit {
+
+typedef HashMap<WebCore::Node*, WKDOMNode*> WKDOMNodeCache;
+static WKDOMNodeCache& wkDOMNodeCache()
+{
+    DEFINE_STATIC_LOCAL(WKDOMNodeCache, cache, ());
+    return cache;
+}
+
+void WKDOMNodeCacheAdd(WebCore::Node* impl, WKDOMNode *wrapper)
+{
+    wkDOMNodeCache().add(impl, wrapper);
+}
+
+WKDOMNode *WKDOMNodeCacheGet(WebCore::Node* impl)
+{
+    return wkDOMNodeCache().get(impl);
+}
+
+void WKDOMNodeCacheRemove(WebCore::Node* impl)
+{
+    wkDOMNodeCache().remove(impl);
+}
+
+static Class WKDOMClass(WebCore::Node* impl)
+{
+    switch (impl->nodeType()) {
+    case WebCore::Node::ELEMENT_NODE:
+        return [WKDOMElement class];
+    case WebCore::Node::DOCUMENT_NODE:
+        return [WKDOMDocument class];
+    case WebCore::Node::TEXT_NODE:
+    case WebCore::Node::ATTRIBUTE_NODE:
+    case WebCore::Node::CDATA_SECTION_NODE:
+    case WebCore::Node::ENTITY_REFERENCE_NODE:
+    case WebCore::Node::ENTITY_NODE:
+    case WebCore::Node::PROCESSING_INSTRUCTION_NODE:
+    case WebCore::Node::COMMENT_NODE:
+    case WebCore::Node::DOCUMENT_TYPE_NODE:
+    case WebCore::Node::DOCUMENT_FRAGMENT_NODE:
+    case WebCore::Node::NOTATION_NODE:
+    case WebCore::Node::XPATH_NAMESPACE_NODE:
+        break;
+    }
+    ASSERT_NOT_REACHED();
+    return nil;
+}
+
+WebCore::Node* toWebCoreNode(WKDOMNode *wrapper)
+{
+    return wrapper ? wrapper->_node.get() : 0;
+}
+
+WKDOMNode *toWKDOMNode(WebCore::Node* impl)
+{
+    if (!impl)
+        return nil;
+    if (WKDOMNode *wrapper = WKDOMNodeCacheGet(impl))
+        return [[wrapper retain] autorelease];
+    WKDOMNode *wrapper = [[WKDOMClass(impl) alloc] _initWithNode:impl];
+    if (!wrapper)
+        return nil;
+    return [wrapper autorelease];
+}
+
+WebCore::Element* toWebCoreElement(WKDOMElement *wrapper)
+{
+    return wrapper ? reinterpret_cast<WebCore::Element*>(wrapper->_node.get()) : 0;
+}
+
+WKDOMElement *toWKDOMElement(WebCore::Element* impl)
+{
+    return static_cast<WKDOMElement*>(toWKDOMNode(static_cast<WebCore::Node*>(impl)));
+}
+
+WebCore::Document* toWebCoreDocument(WKDOMDocument *wrapper)
+{
+    return wrapper ? reinterpret_cast<WebCore::Document*>(wrapper->_node.get()) : 0;
+}
+
+WKDOMDocument *toWKDOMDocument(WebCore::Document* impl)
+{
+    return static_cast<WKDOMDocument*>(toWKDOMNode(static_cast<WebCore::Node*>(impl)));
+}
+
+} // namespace WebKit
+
+#endif // __LP64__
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.h
new file mode 100644 (file)
index 0000000..662d9b0
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if __LP64__
+
+#import <Foundation/Foundation.h>
+#import <WebKit2/WKBase.h>
+
+@class WKDOMDocument;
+
+WK_EXPORT
+@interface WKDOMNode : NSObject
+
+@property(readonly) WKDOMDocument *document;
+
+@end
+
+#endif // __LP64__
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.mm b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.mm
new file mode 100644 (file)
index 0000000..89e1b04
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#if __LP64__
+
+#import "WKDOMNode.h"
+
+#import "WKDOMInternals.h"
+
+@implementation WKDOMNode
+
+- (id)_initWithNode:(WebCore::Node*)node
+{
+    self = [super init];
+    if (!self)
+        return nil;
+
+    WebKit::WKDOMNodeCacheAdd(node, self);
+    return self;
+}
+
+- (void)dealloc
+{
+    WebKit::WKDOMNodeCacheRemove(_node.get());
+    [super dealloc];
+}
+
+- (WKDOMDocument *)document
+{
+    return WebKit::toWKDOMDocument(_node->document());
+}
+
+@end
+
+#endif // __LP64__