Add conversions between ObjC and C DOM wrappers
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Feb 2013 20:53:22 +0000 (20:53 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Feb 2013 20:53:22 +0000 (20:53 +0000)
<rdar://problem/13205468>
https://bugs.webkit.org/show_bug.cgi?id=109851

Reviewed by Anders Carlsson.

* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.cpp:
(WKBundleRangeHandleCreate):
* WebProcess/InjectedBundle/API/c/WKBundleRangeHandlePrivate.h: Added.
* WebProcess/InjectedBundle/API/mac/WKDOMNode.mm:
(-[WKDOMNode _copyBundleNodeHandleRef]):
* WebProcess/InjectedBundle/API/mac/WKDOMNodePrivate.h: Added.
* WebProcess/InjectedBundle/API/mac/WKDOMRange.mm:
(-[WKDOMRange _copyBundleRangeHandleRef]):
* WebProcess/InjectedBundle/API/mac/WKDOMRangePrivate.h: Added.
* WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
(WebKit::InjectedBundleRangeHandle::getOrCreate):
* WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.h:
(InjectedBundleRangeHandle):

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

Source/WebKit2/ChangeLog
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandlePrivate.h [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.mm
Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNodePrivate.h [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMRange.mm
Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMRangePrivate.h [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp
Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.h

index c08685e..6c62b7b 100644 (file)
@@ -1,3 +1,26 @@
+2013-02-14  Sam Weinig  <sam@webkit.org>
+
+        Add conversions between ObjC and C DOM wrappers
+        <rdar://problem/13205468>
+        https://bugs.webkit.org/show_bug.cgi?id=109851
+
+        Reviewed by Anders Carlsson.
+
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.cpp:
+        (WKBundleRangeHandleCreate):
+        * WebProcess/InjectedBundle/API/c/WKBundleRangeHandlePrivate.h: Added.
+        * WebProcess/InjectedBundle/API/mac/WKDOMNode.mm:
+        (-[WKDOMNode _copyBundleNodeHandleRef]):
+        * WebProcess/InjectedBundle/API/mac/WKDOMNodePrivate.h: Added.
+        * WebProcess/InjectedBundle/API/mac/WKDOMRange.mm:
+        (-[WKDOMRange _copyBundleRangeHandleRef]):
+        * WebProcess/InjectedBundle/API/mac/WKDOMRangePrivate.h: Added.
+        * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
+        (WebKit::InjectedBundleRangeHandle::getOrCreate):
+        * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.h:
+        (InjectedBundleRangeHandle):
+
 2013-02-13  Anders Carlsson  <andersca@apple.com>
 
         Remove StringPairVector
index ee684c7..00ef776 100644 (file)
                BC5D24B516CC3F46007D5461 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BC3DE46815A91763008D26FC /* Foundation.framework */; };
                BC5D24B616CC3F4D007D5461 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BC3DE46815A91763008D26FC /* Foundation.framework */; };
                BC5D24B716CC3F5D007D5461 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BC3DE46815A91763008D26FC /* Foundation.framework */; };
+               BC5D24C216CD706D007D5461 /* WKDOMNodePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = BC5D24C116CD706D007D5461 /* WKDOMNodePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               BC5D24C516CD7088007D5461 /* WKDOMRangePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = BC5D24C416CD7088007D5461 /* WKDOMRangePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               BC5D24C716CD73C5007D5461 /* WKBundleRangeHandlePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = BC5D24C616CD73C5007D5461 /* WKBundleRangeHandlePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                BC60C5791240A546008C5E29 /* WKBundleRangeHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = BC60C5771240A546008C5E29 /* WKBundleRangeHandle.h */; settings = {ATTRIBUTES = (Private, ); }; };
                BC60C57A1240A546008C5E29 /* WKBundleRangeHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC60C5781240A546008C5E29 /* WKBundleRangeHandle.cpp */; };
                BC64696F11DBE603006455B0 /* ImmutableArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC64696D11DBE603006455B0 /* ImmutableArray.cpp */; };
                BC5C75C614954DA600BC4775 /* WKConnectionInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKConnectionInternal.h; sourceTree = "<group>"; };
                BC5D249F16CC3B9E007D5461 /* ChildProcessMain.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ChildProcessMain.mm; sourceTree = "<group>"; };
                BC5D24B816CC40BB007D5461 /* BaseLegacyProcess.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = BaseLegacyProcess.xcconfig; sourceTree = "<group>"; };
+               BC5D24C116CD706D007D5461 /* WKDOMNodePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKDOMNodePrivate.h; sourceTree = "<group>"; };
+               BC5D24C416CD7088007D5461 /* WKDOMRangePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKDOMRangePrivate.h; sourceTree = "<group>"; };
+               BC5D24C616CD73C5007D5461 /* WKBundleRangeHandlePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundleRangeHandlePrivate.h; sourceTree = "<group>"; };
                BC60C5771240A546008C5E29 /* WKBundleRangeHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundleRangeHandle.h; sourceTree = "<group>"; };
                BC60C5781240A546008C5E29 /* WKBundleRangeHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundleRangeHandle.cpp; sourceTree = "<group>"; };
                BC64696D11DBE603006455B0 /* ImmutableArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImmutableArray.cpp; sourceTree = "<group>"; };
                                BC017D0416260FF4007054F5 /* WKDOMInternals.mm */,
                                BC017D0516260FF4007054F5 /* WKDOMNode.h */,
                                BC017D0616260FF4007054F5 /* WKDOMNode.mm */,
+                               BC5D24C116CD706D007D5461 /* WKDOMNodePrivate.h */,
                                BC39C4341626366F008BC689 /* WKDOMRange.h */,
                                BC39C4331626366F008BC689 /* WKDOMRange.mm */,
+                               BC5D24C416CD7088007D5461 /* WKDOMRangePrivate.h */,
                                293EBEA91627D9C9005F89F1 /* WKDOMText.h */,
                                293EBEAA1627D9C9005F89F1 /* WKDOMText.mm */,
                                BC017D1F16263308007054F5 /* WKDOMTextIterator.h */,
                                BCF049E511FE20F600F86A58 /* WKBundlePrivate.h */,
                                BC60C5781240A546008C5E29 /* WKBundleRangeHandle.cpp */,
                                BC60C5771240A546008C5E29 /* WKBundleRangeHandle.h */,
+                               BC5D24C616CD73C5007D5461 /* WKBundleRangeHandlePrivate.h */,
                                BC14DF9C120B635F00826C0C /* WKBundleScriptWorld.cpp */,
                                BC14DF9D120B635F00826C0C /* WKBundleScriptWorld.h */,
                        );
                                BCAF35E416CA24DA00D4E9FC /* OfflineStorageProcessMessages.h in Headers */,
                                BCAF35EA16CA253B00D4E9FC /* OfflineStorageProcessCreationParameters.h in Headers */,
                                514BDED316C98EDD00E4E25E /* StatisticsRequest.h in Headers */,
+                               BC5D24C216CD706D007D5461 /* WKDOMNodePrivate.h in Headers */,
+                               BC5D24C516CD7088007D5461 /* WKDOMRangePrivate.h in Headers */,
+                               BC5D24C716CD73C5007D5461 /* WKBundleRangeHandlePrivate.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index c868fab..fb2f7d0 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "config.h"
 #include "WKBundleRangeHandle.h"
+#include "WKBundleRangeHandlePrivate.h"
 
 #include "InjectedBundleRangeHandle.h"
 #include "WKAPICast.h"
@@ -36,3 +37,9 @@ WKTypeID WKBundleRangeHandleGetTypeID()
 {
     return toAPI(InjectedBundleRangeHandle::APIType);
 }
+
+WKBundleRangeHandleRef WKBundleRangeHandleCreate(JSContextRef contextRef, JSObjectRef objectRef)
+{
+    RefPtr<InjectedBundleRangeHandle> rangeHandle = InjectedBundleRangeHandle::getOrCreate(contextRef, objectRef);
+    return toAPI(rangeHandle.release().leakRef());
+}
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandlePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandlePrivate.h
new file mode 100644 (file)
index 0000000..54f8450
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+#ifndef WKBundleRangeHandlePrivate_h
+#define WKBundleRangeHandlePrivate_h
+
+#include <JavaScriptCore/JavaScript.h>
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKBundleRangeHandleRef WKBundleRangeHandleCreate(JSContextRef context, JSObjectRef object);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKBundleRangeHandlePrivate_h
index 5b86f74..3377697 100644 (file)
@@ -29,6 +29,8 @@
 
 #import "WKDOMNode.h"
 
+#import "InjectedBundleNodeHandle.h"
+#import "WKBundleAPICast.h"
 #import "WKDOMInternals.h"
 #import <WebCore/Document.h>
 
 
 @end
 
+@implementation WKDOMNode (WKPrivate)
+
+- (WKBundleNodeHandleRef)_copyBundleNodeHandleRef
+{
+    RefPtr<WebKit::InjectedBundleNodeHandle> nodeHandle = WebKit::InjectedBundleNodeHandle::getOrCreate(_impl.get());
+    return toAPI(nodeHandle.release().leakRef());
+}
+
+@end
+
 #endif // defined(__LP64__) && defined(__clang__)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNodePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNodePrivate.h
new file mode 100644 (file)
index 0000000..9a48117
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2013 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 defined(__LP64__) && defined(__clang__)
+
+#import <WebKit2/WKDOMNode.h>
+
+@interface WKDOMNode (WKPrivate)
+
+- (WKBundleNodeHandleRef)_copyWKBundleNodeHandleRef;
+
+@end
+
+#endif // defined(__LP64__) && defined(__clang__)
index 81f066c..76f8c1c 100644 (file)
@@ -29,6 +29,8 @@
 
 #import "WKDOMRange.h"
 
+#import "InjectedBundleRangeHandle.h"
+#import "WKBundleAPICast.h"
 #import "WKDOMInternals.h"
 #import <WebCore/Document.h>
 
 
 @end
 
+@implementation WKDOMRange (WKPrivate)
+
+- (WKBundleRangeHandleRef)_copyBundleRangeHandleRef
+{
+    RefPtr<WebKit::InjectedBundleRangeHandle> rangeHandle = WebKit::InjectedBundleRangeHandle::getOrCreate(_impl.get());
+    return toAPI(rangeHandle.release().leakRef());
+}
+
+@end
+
 #endif // defined(__LP64__) && defined(__clang__)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMRangePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMRangePrivate.h
new file mode 100644 (file)
index 0000000..eff23fd
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2013 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 defined(__LP64__) && defined(__clang__)
+
+#import <WebKit2/WKRangeNode.h>
+
+@interface WKRangeNode (WKPrivate)
+
+- (WKBundleRangeHandleRef)_copyWKBundleRangeHandleRef;
+
+@end
+
+#endif // defined(__LP64__) && defined(__clang__)
index d6000ab..f6a844e 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "InjectedBundleRangeHandle.h"
 
+#include <JavaScriptCore/APICast.h>
+#include <WebCore/JSRange.h>
 #include <WebCore/Range.h>
 #include <wtf/HashMap.h>
 
@@ -41,6 +43,12 @@ static DOMHandleCache& domHandleCache()
     return cache;
 }
 
+PassRefPtr<InjectedBundleRangeHandle> InjectedBundleRangeHandle::getOrCreate(JSContextRef, JSObjectRef object)
+{
+    Range* range = toRange(toJS(object));
+    return getOrCreate(range);
+}
+
 PassRefPtr<InjectedBundleRangeHandle> InjectedBundleRangeHandle::getOrCreate(Range* range)
 {
     if (!range)
index 4d6789a..4887971 100644 (file)
@@ -27,6 +27,7 @@
 #define InjectedBundleRangeHandle_h
 
 #include "APIObject.h"
+#include <JavaScriptCore/JSBase.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
 
@@ -42,6 +43,7 @@ class InjectedBundleRangeHandle : public APIObject {
 public:
     static const Type APIType = TypeBundleRangeHandle;
 
+    static PassRefPtr<InjectedBundleRangeHandle> getOrCreate(JSContextRef, JSObjectRef);
     static PassRefPtr<InjectedBundleRangeHandle> getOrCreate(WebCore::Range*);
 
     virtual ~InjectedBundleRangeHandle();