summaryrefslogtreecommitdiff
path: root/Source/WebKit2/WebProcess/InjectedBundle/API/mac
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/WebProcess/InjectedBundle/API/mac')
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.h44
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm64
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMElement.h41
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMElement.mm61
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMInternals.h116
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMInternals.mm170
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.h48
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.mm100
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMRange.h53
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMRange.mm142
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMText.h37
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMText.mm43
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.h47
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm83
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.h45
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm129
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.h40
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm86
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerInternal.h36
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerPrivate.h36
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInInternal.h37
21 files changed, 1458 insertions, 0 deletions
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.h
new file mode 100644
index 000000000..4495055cb
--- /dev/null
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.h
@@ -0,0 +1,44 @@
+/*
+ * 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 defined(__LP64__) && defined(__clang__)
+
+#import <WebKit2/WKDOMNode.h>
+
+@class WKDOMElement;
+@class WKDOMText;
+
+WK_EXPORT
+@interface WKDOMDocument : WKDOMNode
+
+- (WKDOMElement *)createElement:(NSString *)tagName;
+- (WKDOMText *)createTextNode:(NSString *)data;
+
+@property(readonly) WKDOMElement *body;
+
+@end
+
+#endif // defined(__LP64__) && defined(__clang__)
+
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm
new file mode 100644
index 000000000..99f515021
--- /dev/null
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm
@@ -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.
+ */
+
+#import "config.h"
+
+#if defined(__LP64__) && defined(__clang__)
+
+#import "WKDOMDocument.h"
+
+#import "WKDOMInternals.h"
+#import <WebCore/Document.h>
+#import <WebCore/HTMLElement.h>
+#import <WebCore/Text.h>
+
+static inline WebCore::Document* toDocument(WebCore::Node* node)
+{
+ ASSERT(!node || node->isDocumentNode());
+ return static_cast<WebCore::Document*>(node);
+}
+
+@implementation WKDOMDocument
+
+- (WKDOMElement *)createElement:(NSString *)tagName
+{
+ // FIXME: Do something about the exception.
+ WebCore::ExceptionCode ec = 0;
+ return WebKit::toWKDOMElement(toDocument(_impl.get())->createElement(tagName, ec).get());
+}
+
+- (WKDOMText *)createTextNode:(NSString *)data
+{
+ return WebKit::toWKDOMText(toDocument(_impl.get())->createTextNode(data).get());
+}
+
+- (WKDOMElement *)body
+{
+ return WebKit::toWKDOMElement(toDocument(_impl.get())->body());
+}
+
+@end
+
+#endif // defined(__LP64__) && defined(__clang__)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMElement.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMElement.h
new file mode 100644
index 000000000..aa03cd4d9
--- /dev/null
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMElement.h
@@ -0,0 +1,41 @@
+/*
+ * 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 defined(__LP64__) && defined(__clang__)
+
+#import <WebKit2/WKDOMNode.h>
+
+WK_EXPORT
+@interface WKDOMElement : WKDOMNode
+
+- (BOOL)hasAttribute:(NSString *)attribute;
+- (NSString *)getAttribute:(NSString *)attribute;
+- (void)setAttribute:(NSString *)name value:(NSString *)value;
+
+@property(readonly) NSString *tagName;
+
+@end
+
+#endif // defined(__LP64__) && defined(__clang__)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMElement.mm b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMElement.mm
new file mode 100644
index 000000000..72cf5ab40
--- /dev/null
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMElement.mm
@@ -0,0 +1,61 @@
+/*
+ * 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 defined(__LP64__) && defined(__clang__)
+
+#import "WKDOMElement.h"
+
+#import "WKDOMInternals.h"
+#import <WebCore/Element.h>
+
+@implementation WKDOMElement
+
+- (BOOL)hasAttribute:(NSString *)attribute
+{
+ return WebCore::toElement(_impl.get())->hasAttribute(attribute);
+}
+
+- (NSString *)getAttribute:(NSString *)attribute
+{
+ return WebCore::toElement(_impl.get())->getAttribute(attribute);
+}
+
+- (void)setAttribute:(NSString *)name value:(NSString *)value
+{
+ // FIXME: Do something about the exception.
+ WebCore::ExceptionCode ec;
+ WebCore::toElement(_impl.get())->setAttribute(name, value, ec);
+}
+
+- (NSString *)tagName
+{
+ return WebCore::toElement(_impl.get())->tagName();
+}
+
+@end
+
+#endif // defined(__LP64__) && defined(__clang__)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMInternals.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMInternals.h
new file mode 100644
index 000000000..f33e454cd
--- /dev/null
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMInternals.h
@@ -0,0 +1,116 @@
+/*
+ * 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 defined(__LP64__) && defined(__clang__)
+
+#import "WKDOMNode.h"
+#import "WKDOMRange.h"
+#import <WebCore/Node.h>
+#import <WebCore/Range.h>
+#import <wtf/HashMap.h>
+
+namespace WebCore {
+class Element;
+class Document;
+}
+
+@class WKDOMElement;
+@class WKDOMDocument;
+@class WKDOMText;
+
+@interface WKDOMNode () {
+@public
+ RefPtr<WebCore::Node> _impl;
+}
+
+- (id)_initWithImpl:(WebCore::Node*)impl;
+@end
+
+@interface WKDOMRange () {
+@public
+ RefPtr<WebCore::Range> _impl;
+}
+
+- (id)_initWithImpl:(WebCore::Range*)impl;
+@end
+
+namespace WebKit {
+
+template<typename WebCoreType, typename WKDOMType>
+class DOMCache {
+public:
+ DOMCache()
+ {
+ }
+
+ void add(WebCoreType core, WKDOMType kit)
+ {
+ m_map.add(core, kit);
+ }
+
+ WKDOMType get(WebCoreType core)
+ {
+ return m_map.get(core);
+ }
+
+ void remove(WebCoreType core)
+ {
+ m_map.remove(core);
+ }
+
+private:
+ // This class should only ever be used as a singleton.
+ ~DOMCache() = delete;
+
+ HashMap<WebCoreType, WKDOMType> m_map;
+};
+
+// -- Caches --
+
+DOMCache<WebCore::Node*, WKDOMNode *>& WKDOMNodeCache();
+DOMCache<WebCore::Range*, WKDOMRange *>& WKDOMRangeCache();
+
+// -- Node and classes derived from Node. --
+
+WebCore::Node* toWebCoreNode(WKDOMNode *);
+WKDOMNode *toWKDOMNode(WebCore::Node*);
+
+WebCore::Element* toWebCoreElement(WKDOMElement *);
+WKDOMElement *toWKDOMElement(WebCore::Element*);
+
+WebCore::Document* toWebCoreDocument(WKDOMDocument *);
+WKDOMDocument *toWKDOMDocument(WebCore::Document*);
+
+WebCore::Text* toWebCoreText(WKDOMText *);
+WKDOMText *toWKDOMText(WebCore::Text*);
+
+// -- Range. --
+
+WebCore::Range* toWebCoreRange(WKDOMRange *);
+WKDOMRange *toWKDOMRange(WebCore::Range*);
+
+} // namespace WebKit
+
+#endif // defined(__LP64__) && defined(__clang__)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMInternals.mm b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMInternals.mm
new file mode 100644
index 000000000..ab9046613
--- /dev/null
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMInternals.mm
@@ -0,0 +1,170 @@
+/*
+ * 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 defined(__LP64__) && defined(__clang__)
+
+#import "WKDOMInternals.h"
+
+#import <WebCore/Document.h>
+#import <WebCore/Element.h>
+#import <WebCore/Node.h>
+#import <WebCore/Range.h>
+#import <WebCore/Text.h>
+
+// Classes to instantiate.
+#import "WKDOMElement.h"
+#import "WKDOMDocument.h"
+#import "WKDOMText.h"
+
+namespace WebKit {
+
+template<typename WebCoreType, typename WKDOMType>
+static WKDOMType toWKDOMType(WebCoreType impl, DOMCache<WebCoreType, WKDOMType>& cache);
+
+// -- Caches --
+
+DOMCache<WebCore::Node*, WKDOMNode *>& WKDOMNodeCache()
+{
+ typedef DOMCache<WebCore::Node*, WKDOMNode *> Cache;
+ DEFINE_STATIC_LOCAL(Cache, cache, ());
+ return cache;
+}
+
+DOMCache<WebCore::Range*, WKDOMRange *>& WKDOMRangeCache()
+{
+ typedef DOMCache<WebCore::Range*, WKDOMRange *> Cache;
+ DEFINE_STATIC_LOCAL(Cache, cache, ());
+ return cache;
+}
+
+// -- Node and classes derived from Node. --
+
+static Class WKDOMNodeClass(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:
+ return [WKDOMText class];
+ 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;
+}
+
+static WKDOMNode *initWithImpl(WebCore::Node* impl)
+{
+ return [[WKDOMNodeClass(impl) alloc] _initWithImpl:impl];
+}
+
+WebCore::Node* toWebCoreNode(WKDOMNode *wrapper)
+{
+ return wrapper ? wrapper->_impl.get() : 0;
+}
+
+WKDOMNode *toWKDOMNode(WebCore::Node* impl)
+{
+ return toWKDOMType<WebCore::Node*, WKDOMNode *>(impl, WKDOMNodeCache());
+}
+
+WebCore::Element* toWebCoreElement(WKDOMElement *wrapper)
+{
+ return wrapper ? reinterpret_cast<WebCore::Element*>(wrapper->_impl.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->_impl.get()) : 0;
+}
+
+WKDOMDocument *toWKDOMDocument(WebCore::Document* impl)
+{
+ return static_cast<WKDOMDocument*>(toWKDOMNode(static_cast<WebCore::Node*>(impl)));
+}
+
+WebCore::Text* toWebCoreText(WKDOMText *wrapper)
+{
+ return wrapper ? reinterpret_cast<WebCore::Text*>(wrapper->_impl.get()) : 0;
+}
+
+WKDOMText *toWKDOMText(WebCore::Text* impl)
+{
+ return static_cast<WKDOMText*>(toWKDOMNode(static_cast<WebCore::Node*>(impl)));
+}
+
+// -- Range. --
+
+static WKDOMRange *initWithImpl(WebCore::Range* impl)
+{
+ return [[WKDOMRange alloc] _initWithImpl:impl];
+}
+
+WebCore::Range* toWebCoreRange(WKDOMRange * wrapper)
+{
+ return wrapper ? wrapper->_impl.get() : 0;
+}
+
+WKDOMRange *toWKDOMRange(WebCore::Range* impl)
+{
+ return toWKDOMType<WebCore::Range*, WKDOMRange *>(impl, WKDOMRangeCache());
+}
+
+// -- Helpers --
+
+template<typename WebCoreType, typename WKDOMType>
+static WKDOMType toWKDOMType(WebCoreType impl, DOMCache<WebCoreType, WKDOMType>& cache)
+{
+ if (!impl)
+ return nil;
+ if (WKDOMType wrapper = cache.get(impl))
+ return [[wrapper retain] autorelease];
+ WKDOMType wrapper = initWithImpl(impl);
+ if (!wrapper)
+ return nil;
+ return [wrapper autorelease];
+}
+
+} // namespace WebKit
+
+#endif // defined(__LP64__) && defined(__clang__)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.h
new file mode 100644
index 000000000..c0e03937c
--- /dev/null
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.h
@@ -0,0 +1,48 @@
+/*
+ * 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 defined(__LP64__) && defined(__clang__)
+
+#import <Foundation/Foundation.h>
+#import <WebKit2/WKBase.h>
+
+@class WKDOMDocument;
+
+WK_EXPORT
+@interface WKDOMNode : NSObject
+
+- (void)insertNode:(WKDOMNode *)node before:(WKDOMNode *)refNode;
+- (void)appendChild:(WKDOMNode *)node;
+
+@property(readonly) WKDOMDocument *document;
+@property(readonly) WKDOMNode *parentNode;
+@property(readonly) WKDOMNode *firstChild;
+@property(readonly) WKDOMNode *lastChild;
+@property(readonly) WKDOMNode *previousSibling;
+@property(readonly) WKDOMNode *nextSibling;
+
+@end
+
+#endif // defined(__LP64__) && defined(__clang__)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.mm b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.mm
new file mode 100644
index 000000000..4308ff3ab
--- /dev/null
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.mm
@@ -0,0 +1,100 @@
+/*
+ * 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 defined(__LP64__) && defined(__clang__)
+
+#import "WKDOMNode.h"
+
+#import "WKDOMInternals.h"
+
+@implementation WKDOMNode
+
+- (id)_initWithImpl:(WebCore::Node*)impl
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ _impl = impl;
+ WebKit::WKDOMNodeCache().add(impl, self);
+
+ return self;
+}
+
+- (void)dealloc
+{
+ WebKit::WKDOMNodeCache().remove(_impl.get());
+ [super dealloc];
+}
+
+- (void)insertNode:(WKDOMNode *)node before:(WKDOMNode *)refNode
+{
+ // FIXME: Do something about the exception.
+ WebCore::ExceptionCode ec;
+ _impl->insertBefore(WebKit::toWebCoreNode(node), WebKit::toWebCoreNode(refNode), ec);
+}
+
+- (void)appendChild:(WKDOMNode *)node
+{
+ // FIXME: Do something about the exception.
+ WebCore::ExceptionCode ec;
+ _impl->appendChild(WebKit::toWebCoreNode(node), ec);
+}
+
+- (WKDOMDocument *)document
+{
+ return WebKit::toWKDOMDocument(_impl->document());
+}
+
+- (WKDOMNode *)parentNode
+{
+ return WebKit::toWKDOMNode(_impl->parentNode());
+}
+
+- (WKDOMNode *)firstChild
+{
+ return WebKit::toWKDOMNode(_impl->firstChild());
+}
+
+- (WKDOMNode *)lastChild
+{
+ return WebKit::toWKDOMNode(_impl->lastChild());
+}
+
+- (WKDOMNode *)previousSibling
+{
+ return WebKit::toWKDOMNode(_impl->previousSibling());
+}
+
+- (WKDOMNode *)nextSibling
+{
+ return WebKit::toWKDOMNode(_impl->nextSibling());
+}
+
+@end
+
+#endif // defined(__LP64__) && defined(__clang__)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMRange.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMRange.h
new file mode 100644
index 000000000..64ed00ce2
--- /dev/null
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMRange.h
@@ -0,0 +1,53 @@
+/*
+ * 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 defined(__LP64__) && defined(__clang__)
+
+#import <Foundation/Foundation.h>
+#import <WebKit2/WKBase.h>
+
+@class WKDOMNode, WKDOMDocument;
+
+WK_EXPORT
+@interface WKDOMRange : NSObject
+
+- (id)initWithDocument:(WKDOMDocument *)document;
+
+- (void)setStart:(WKDOMNode *)node offset:(int)offset;
+- (void)setEnd:(WKDOMNode *)node offset:(int)offset;
+- (void)collapse:(BOOL)toStart;
+- (void)selectNode:(WKDOMNode *)node;
+- (void)selectNodeContents:(WKDOMNode *)node;
+
+@property(readonly, retain) WKDOMNode *startContainer;
+@property(readonly) NSInteger startOffset;
+@property(readonly, retain) WKDOMNode *endContainer;
+@property(readonly) NSInteger endOffset;
+@property(readonly, copy) NSString *text;
+@property(readonly) BOOL isCollapsed;
+
+@end
+
+#endif // defined(__LP64__) && defined(__clang__)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMRange.mm b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMRange.mm
new file mode 100644
index 000000000..1cc408408
--- /dev/null
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMRange.mm
@@ -0,0 +1,142 @@
+/*
+ * 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 defined(__LP64__) && defined(__clang__)
+
+#import "WKDOMRange.h"
+
+#import "WKDOMInternals.h"
+#import <WebCore/Document.h>
+
+@implementation WKDOMRange
+
+- (id)_initWithImpl:(WebCore::Range*)impl
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ _impl = impl;
+ WebKit::WKDOMRangeCache().add(impl, self);
+
+ return self;
+}
+
+- (id)initWithDocument:(WKDOMDocument *)document
+{
+ RefPtr<WebCore::Range> range = WebCore::Range::create(WebKit::toWebCoreDocument(document));
+ self = [self _initWithImpl:range.get()];
+ if (!self)
+ return nil;
+
+ return self;
+}
+
+- (void)dealloc
+{
+ WebKit::WKDOMRangeCache().remove(_impl.get());
+ [super dealloc];
+}
+
+- (void)setStart:(WKDOMNode *)node offset:(int)offset
+{
+ // FIXME: Do something about the exception.
+ WebCore::ExceptionCode ec = 0;
+ _impl->setStart(WebKit::toWebCoreNode(node), offset, ec);
+}
+
+- (void)setEnd:(WKDOMNode *)node offset:(int)offset
+{
+ // FIXME: Do something about the exception.
+ WebCore::ExceptionCode ec = 0;
+ _impl->setEnd(WebKit::toWebCoreNode(node), offset, ec);
+}
+
+- (void)collapse:(BOOL)toStart
+{
+ // FIXME: Do something about the exception.
+ WebCore::ExceptionCode ec = 0;
+ _impl->collapse(toStart, ec);
+}
+
+- (void)selectNode:(WKDOMNode *)node
+{
+ // FIXME: Do something about the exception.
+ WebCore::ExceptionCode ec = 0;
+ _impl->selectNode(WebKit::toWebCoreNode(node), ec);
+}
+
+- (void)selectNodeContents:(WKDOMNode *)node
+{
+ // FIXME: Do something about the exception.
+ WebCore::ExceptionCode ec = 0;
+ _impl->selectNodeContents(WebKit::toWebCoreNode(node), ec);
+}
+
+- (WKDOMNode *)startContainer
+{
+ // FIXME: Do something about the exception.
+ WebCore::ExceptionCode ec = 0;
+ return WebKit::toWKDOMNode(_impl->startContainer(ec));
+}
+
+- (NSInteger)startOffset
+{
+ // FIXME: Do something about the exception.
+ WebCore::ExceptionCode ec = 0;
+ return _impl->startOffset(ec);
+}
+
+- (WKDOMNode *)endContainer
+{
+ // FIXME: Do something about the exception.
+ WebCore::ExceptionCode ec = 0;
+ return WebKit::toWKDOMNode(_impl->endContainer(ec));
+}
+
+- (NSInteger)endOffset
+{
+ // FIXME: Do something about the exception.
+ WebCore::ExceptionCode ec = 0;
+ return _impl->endOffset(ec);
+}
+
+- (NSString *)text
+{
+ return _impl->text();
+}
+
+- (BOOL)isCollapsed
+{
+ // FIXME: Do something about the exception.
+ WebCore::ExceptionCode ec = 0;
+ return _impl->collapsed(ec);
+}
+
+@end
+
+#endif // defined(__LP64__) && defined(__clang__)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMText.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMText.h
new file mode 100644
index 000000000..eb8552e3f
--- /dev/null
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMText.h
@@ -0,0 +1,37 @@
+/*
+ * 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 defined(__LP64__) && defined(__clang__)
+
+#import <WebKit2/WKDOMNode.h>
+
+WK_EXPORT
+@interface WKDOMText : WKDOMNode
+
+@property(readonly) NSString *data;
+
+@end
+
+#endif // defined(__LP64__) && defined(__clang__)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMText.mm b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMText.mm
new file mode 100644
index 000000000..4f4f627ab
--- /dev/null
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMText.mm
@@ -0,0 +1,43 @@
+/*
+ * 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"
+#import "WKDOMText.h"
+
+#if defined(__LP64__) && defined(__clang__)
+
+#import "WKDOMInternals.h"
+#import <WebCore/Text.h>
+
+@implementation WKDOMText
+
+- (NSString *)data
+{
+ return WebCore::toText(_impl.get())->data();
+}
+
+@end
+
+#endif // defined(__LP64__) && defined(__clang__)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.h
new file mode 100644
index 000000000..e34c18e44
--- /dev/null
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.h
@@ -0,0 +1,47 @@
+/*
+ * 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 defined(__LP64__) && defined(__clang__)
+
+#import <Foundation/Foundation.h>
+#import <WebKit2/WKBase.h>
+
+@class WKDOMRange;
+
+WK_EXPORT
+@interface WKDOMTextIterator : NSObject
+
+- (id)initWithRange:(WKDOMRange *)range;
+
+- (void)advance;
+
+@property (readonly) BOOL atEnd;
+@property (readonly) WKDOMRange *currentRange;
+@property (readonly) NSUInteger currentTextLength;
+@property (readonly) const unichar *currentTextPointer;
+
+@end
+
+#endif // defined(__LP64__) && defined(__clang__)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm
new file mode 100644
index 000000000..0f9ae6191
--- /dev/null
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm
@@ -0,0 +1,83 @@
+/*
+ * 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 defined(__LP64__) && defined(__clang__)
+
+#import "WKDOMTextIterator.h"
+
+#import "WKDOMInternals.h"
+#import "WKDOMRange.h"
+#import <WebCore/TextIterator.h>
+#import <wtf/OwnPtr.h>
+
+@interface WKDOMTextIterator () {
+@public
+ OwnPtr<WebCore::TextIterator> _textIterator;
+}
+@end
+
+@implementation WKDOMTextIterator
+
+- (id)initWithRange:(WKDOMRange *)range
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ _textIterator = adoptPtr(new WebCore::TextIterator(WebKit::toWebCoreRange(range)));
+
+ return self;
+}
+
+- (void)advance
+{
+ _textIterator->advance();
+}
+
+- (BOOL)atEnd
+{
+ return _textIterator->atEnd();
+}
+
+- (WKDOMRange *)currentRange
+{
+ return WebKit::toWKDOMRange(_textIterator->range().get());
+}
+
+- (const unichar *)currentTextPointer
+{
+ return _textIterator->characters();
+}
+
+- (NSUInteger)currentTextLength
+{
+ return _textIterator->length();
+}
+
+@end
+
+#endif // defined(__LP64__) && defined(__clang__)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.h
new file mode 100644
index 000000000..4a7cc50a6
--- /dev/null
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.h
@@ -0,0 +1,45 @@
+/*
+ * 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 defined(__LP64__) && defined(__clang__)
+
+#import <Foundation/Foundation.h>
+#import <WebKit2/WKBase.h>
+
+@class WKWebProcessPlugInController;
+@class WKWebProcessPlugInBrowserContextController;
+
+@protocol WKWebProcessPlugIn <NSObject>
+@optional
+- (void)webProcessPlugInInitialize:(WKWebProcessPlugInController *)plugInController;
+- (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController didCreateBrowserContextController:(WKWebProcessPlugInBrowserContextController *)browserContextController;
+- (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController willDestroyBrowserContextController:(WKWebProcessPlugInBrowserContextController *)browserContextController;
+@end
+
+WK_EXPORT
+@interface WKWebProcessPlugInController : NSObject
+@end
+
+#endif // defined(__LP64__) && defined(__clang__)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm
new file mode 100644
index 000000000..d967ec29b
--- /dev/null
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm
@@ -0,0 +1,129 @@
+/*
+ * 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 defined(__LP64__) && defined(__clang__)
+
+#import "WKWebProcessPlugIn.h"
+#import "WKWebProcessPlugInInternal.h"
+
+#import "InjectedBundle.h"
+#import "WKBundle.h"
+#import "WKBundleAPICast.h"
+#import "WKRetainPtr.h"
+#import "WKWebProcessPlugInBrowserContextControllerInternal.h"
+#import <wtf/RetainPtr.h>
+
+typedef HashMap<WKBundlePageRef, RetainPtr<WKWebProcessPlugInBrowserContextController *> > BundlePageWrapperCache;
+
+@interface WKWebProcessPlugInController () {
+ RetainPtr<id<WKWebProcessPlugIn> > _principalClassInstance;
+ WKRetainPtr<WKBundleRef> _bundleRef;
+ BundlePageWrapperCache _bundlePageWrapperCache;
+}
+@end
+
+@implementation WKWebProcessPlugInController (Internal)
+
+static void didCreatePage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo)
+{
+ WKWebProcessPlugInController *plugInController = (WKWebProcessPlugInController *)clientInfo;
+ id<WKWebProcessPlugIn> principalClassInstance = plugInController->_principalClassInstance.get();
+
+ if ([principalClassInstance respondsToSelector:@selector(webProcessPlugIn:didCreateBrowserContextController:)]) {
+ ASSERT(!plugInController->_bundlePageWrapperCache.contains(page));
+
+ WKWebProcessPlugInBrowserContextController* browserContextController = [[WKWebProcessPlugInBrowserContextController alloc] _initWithBundlePageRef:page];
+ plugInController->_bundlePageWrapperCache.set(page, browserContextController);
+
+ [principalClassInstance webProcessPlugIn:plugInController didCreateBrowserContextController:browserContextController];
+ }
+}
+
+static void willDestroyPage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo)
+{
+ WKWebProcessPlugInController *plugInController = (WKWebProcessPlugInController *)clientInfo;
+ id<WKWebProcessPlugIn> principalClassInstance = plugInController->_principalClassInstance.get();
+
+ // If we never added the bundle page to the cache, which can happen if webProcessPlugIn:didCreateBrowserContextController: is not implemented,
+ // there is no reason to call webProcessPlugIn:willDestroyBrowserContextController:, so don't.
+ BundlePageWrapperCache::iterator it = plugInController->_bundlePageWrapperCache.find(page);
+ if (it == plugInController->_bundlePageWrapperCache.end()) {
+ ASSERT(![principalClassInstance respondsToSelector:@selector(webProcessPlugIn:didCreateBrowserContextController:)]);
+ return;
+ }
+
+ if ([principalClassInstance respondsToSelector:@selector(webProcessPlugIn:willDestroyBrowserContextController:)])
+ [principalClassInstance webProcessPlugIn:plugInController willDestroyBrowserContextController:it->value.get()];
+
+ plugInController->_bundlePageWrapperCache.remove(it);
+}
+
+static void setUpBundleClient(WKWebProcessPlugInController *plugInController, WKBundleRef bundleRef)
+{
+ WKBundleClient bundleClient;
+ memset(&bundleClient, 0, sizeof(bundleClient));
+
+ bundleClient.version = kWKBundleClientCurrentVersion;
+ bundleClient.clientInfo = plugInController;
+ bundleClient.didCreatePage = didCreatePage;
+ bundleClient.willDestroyPage = willDestroyPage;
+
+ WKBundleSetClient(bundleRef, &bundleClient);
+}
+
+static WKWebProcessPlugInController *sharedInstance;
+
++ (WKWebProcessPlugInController *)_shared
+{
+ ASSERT_WITH_MESSAGE(sharedInstance, "+[WKWebProcessPlugIn _shared] called without first initializing it.");
+ return sharedInstance;
+}
+
+- (id)_initWithPrincipalClassInstance:(id<WKWebProcessPlugIn>)principalClassInstance bundleRef:(WKBundleRef)bundleRef
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ _principalClassInstance = principalClassInstance;
+ _bundleRef = bundleRef;
+
+ ASSERT_WITH_MESSAGE(!sharedInstance, "WKWebProcessPlugInController initialized multiple times.");
+ sharedInstance = self;
+
+ setUpBundleClient(self, bundleRef);
+
+ return self;
+}
+
+@end
+
+@implementation WKWebProcessPlugInController
+
+@end
+
+#endif // defined(__LP64__) && defined(__clang__)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.h
new file mode 100644
index 000000000..5a0db8d05
--- /dev/null
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.h
@@ -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 defined(__LP64__) && defined(__clang__)
+
+#import <Foundation/Foundation.h>
+#import <WebKit2/WKBase.h>
+
+@class WKDOMDocument;
+
+WK_EXPORT
+@interface WKWebProcessPlugInBrowserContextController : NSObject
+
+@property(readonly) WKDOMDocument *mainFrameDocument;
+
+@end
+
+#endif // defined(__LP64__) && defined(__clang__)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm
new file mode 100644
index 000000000..3d39be033
--- /dev/null
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm
@@ -0,0 +1,86 @@
+/*
+ * 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 defined(__LP64__) && defined(__clang__)
+
+#import "WKWebProcessPlugInBrowserContextController.h"
+#import "WKWebProcessPlugInBrowserContextControllerInternal.h"
+#import "WKWebProcessPlugInBrowserContextControllerPrivate.h"
+
+#import "WKBundleAPICast.h"
+#import "WKBundlePage.h"
+#import "WKBundlePagePrivate.h"
+#import "WKDOMInternals.h"
+#import "WKRetainPtr.h"
+#import "WebPage.h"
+#import <WebCore/Document.h>
+#import <WebCore/Frame.h>
+
+@interface WKWebProcessPlugInBrowserContextController () {
+ // Underlying WKBundlePageRef.
+ WKRetainPtr<WKBundlePageRef> _bundlePageRef;
+}
+@end
+
+@implementation WKWebProcessPlugInBrowserContextController (Internal)
+
+- (id)_initWithBundlePageRef:(WKBundlePageRef)bundlePageRef
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ _bundlePageRef = bundlePageRef;
+
+ return self;
+}
+
+@end
+
+@implementation WKWebProcessPlugInBrowserContextController
+
+- (WKDOMDocument *)mainFrameDocument
+{
+ WebCore::Frame* webCoreMainFrame = WebKit::toImpl(self._bundlePageRef)->mainFrame();
+ if (!webCoreMainFrame)
+ return nil;
+
+ return WebKit::toWKDOMDocument(webCoreMainFrame->document());
+}
+
+@end
+
+@implementation WKWebProcessPlugInBrowserContextController (Private)
+
+- (WKBundlePageRef)_bundlePageRef
+{
+ return _bundlePageRef.get();
+}
+
+@end
+
+#endif // defined(__LP64__) && defined(__clang__)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerInternal.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerInternal.h
new file mode 100644
index 000000000..62f06238a
--- /dev/null
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerInternal.h
@@ -0,0 +1,36 @@
+/*
+ * 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 defined(__LP64__) && defined(__clang__)
+
+#import "WKWebProcessPlugInBrowserContextController.h"
+
+@interface WKWebProcessPlugInBrowserContextController (Internal)
+
+- (id)_initWithBundlePageRef:(WKBundlePageRef)bundlePageRef;
+
+@end
+
+#endif // defined(__LP64__) && defined(__clang__)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerPrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerPrivate.h
new file mode 100644
index 000000000..59aac108c
--- /dev/null
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerPrivate.h
@@ -0,0 +1,36 @@
+/*
+ * 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 defined(__LP64__) && defined(__clang__)
+
+#import <WebKit2/WKWebProcessPlugInBrowserContextController.h>
+
+@interface WKWebProcessPlugInBrowserContextController (Private)
+
+@property(readonly) WKBundlePageRef _bundlePageRef;
+
+@end
+
+#endif // defined(__LP64__) && defined(__clang__)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInInternal.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInInternal.h
new file mode 100644
index 000000000..58b3cc3f7
--- /dev/null
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInInternal.h
@@ -0,0 +1,37 @@
+/*
+ * 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 defined(__LP64__) && defined(__clang__)
+
+#import "WKWebProcessPlugIn.h"
+
+@interface WKWebProcessPlugInController (Internal)
+
++ (WKWebProcessPlugInController *)_shared;
+- (id)_initWithPrincipalClassInstance:(id<WKWebProcessPlugIn>)principalClassInstance bundleRef:(WKBundleRef)bundleRef;
+
+@end
+
+#endif // defined(__LP64__) && defined(__clang__)