summaryrefslogtreecommitdiff
path: root/Source/WebKit2/WebProcess/InjectedBundle
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/WebProcess/InjectedBundle')
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp34
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h28
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp12
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp2
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntent.cpp2
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp30
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h4
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h14
-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
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp4
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp4
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp68
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h10
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntent.cpp2
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm (renamed from Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.cpp)63
35 files changed, 1583 insertions, 152 deletions
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp
index 2085253ba..7210a9d9e 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp
@@ -46,13 +46,13 @@ void WKBundleSetClient(WKBundleRef bundleRef, WKBundleClient * wkClient)
void WKBundlePostMessage(WKBundleRef bundleRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef)
{
- toImpl(bundleRef)->postMessage(toImpl(messageNameRef)->string(), toImpl(messageBodyRef));
+ toImpl(bundleRef)->postMessage(toWTFString(messageNameRef), toImpl(messageBodyRef));
}
void WKBundlePostSynchronousMessage(WKBundleRef bundleRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef, WKTypeRef* returnDataRef)
{
RefPtr<APIObject> returnData;
- toImpl(bundleRef)->postSynchronousMessage(toImpl(messageNameRef)->string(), toImpl(messageBodyRef), returnData);
+ toImpl(bundleRef)->postSynchronousMessage(toWTFString(messageNameRef), toImpl(messageBodyRef), returnData);
if (returnDataRef)
*returnDataRef = toAPI(returnData.release().leakRef());
}
@@ -134,7 +134,7 @@ void WKBundleRemoveAllUserContent(WKBundleRef bundleRef, WKBundlePageGroupRef pa
void WKBundleOverrideBoolPreferenceForTestRunner(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, WKStringRef preference, bool enabled)
{
- toImpl(bundleRef)->overrideBoolPreferenceForTestRunner(toImpl(pageGroupRef), toImpl(preference)->string(), enabled);
+ toImpl(bundleRef)->overrideBoolPreferenceForTestRunner(toImpl(pageGroupRef), toWTFString(preference), enabled);
}
void WKBundleSetAllowUniversalAccessFromFileURLs(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, bool enabled)
@@ -194,12 +194,12 @@ void WKBundleSetSpatialNavigationEnabled(WKBundleRef bundleRef, WKBundlePageGrou
void WKBundleAddOriginAccessWhitelistEntry(WKBundleRef bundleRef, WKStringRef sourceOrigin, WKStringRef destinationProtocol, WKStringRef destinationHost, bool allowDestinationSubdomains)
{
- toImpl(bundleRef)->addOriginAccessWhitelistEntry(toImpl(sourceOrigin)->string(), toImpl(destinationProtocol)->string(), toImpl(destinationHost)->string(), allowDestinationSubdomains);
+ toImpl(bundleRef)->addOriginAccessWhitelistEntry(toWTFString(sourceOrigin), toWTFString(destinationProtocol), toWTFString(destinationHost), allowDestinationSubdomains);
}
void WKBundleRemoveOriginAccessWhitelistEntry(WKBundleRef bundleRef, WKStringRef sourceOrigin, WKStringRef destinationProtocol, WKStringRef destinationHost, bool allowDestinationSubdomains)
{
- toImpl(bundleRef)->removeOriginAccessWhitelistEntry(toImpl(sourceOrigin)->string(), toImpl(destinationProtocol)->string(), toImpl(destinationHost)->string(), allowDestinationSubdomains);
+ toImpl(bundleRef)->removeOriginAccessWhitelistEntry(toWTFString(sourceOrigin), toWTFString(destinationProtocol), toWTFString(destinationHost), allowDestinationSubdomains);
}
void WKBundleResetOriginAccessWhitelists(WKBundleRef bundleRef)
@@ -229,7 +229,7 @@ void WKBundleClearApplicationCache(WKBundleRef bundleRef)
void WKBundleClearApplicationCacheForOrigin(WKBundleRef bundleRef, WKStringRef origin)
{
- toImpl(bundleRef)->clearApplicationCacheForOrigin(toImpl(origin)->string());
+ toImpl(bundleRef)->clearApplicationCacheForOrigin(toWTFString(origin));
}
void WKBundleSetAppCacheMaximumSize(WKBundleRef bundleRef, uint64_t size)
@@ -239,17 +239,17 @@ void WKBundleSetAppCacheMaximumSize(WKBundleRef bundleRef, uint64_t size)
uint64_t WKBundleGetAppCacheUsageForOrigin(WKBundleRef bundleRef, WKStringRef origin)
{
- return toImpl(bundleRef)->appCacheUsageForOrigin(toImpl(origin)->string());
+ return toImpl(bundleRef)->appCacheUsageForOrigin(toWTFString(origin));
}
void WKBundleSetApplicationCacheOriginQuota(WKBundleRef bundleRef, WKStringRef origin, uint64_t bytes)
{
- toImpl(bundleRef)->setApplicationCacheOriginQuota(toImpl(origin)->string(), bytes);
+ toImpl(bundleRef)->setApplicationCacheOriginQuota(toWTFString(origin), bytes);
}
void WKBundleResetApplicationCacheOriginQuota(WKBundleRef bundleRef, WKStringRef origin)
{
- toImpl(bundleRef)->resetApplicationCacheOriginQuota(toImpl(origin)->string());
+ toImpl(bundleRef)->resetApplicationCacheOriginQuota(toWTFString(origin));
}
WKArrayRef WKBundleCopyOriginsWithApplicationCache(WKBundleRef bundleRef)
@@ -270,7 +270,7 @@ int WKBundleNumberOfPages(WKBundleRef bundleRef, WKBundleFrameRef frameRef, doub
int WKBundlePageNumberForElementById(WKBundleRef bundleRef, WKBundleFrameRef frameRef, WKStringRef idRef, double pageWidthInPixels, double pageHeightInPixels)
{
- return toImpl(bundleRef)->pageNumberForElementById(toImpl(frameRef), toImpl(idRef)->string(), pageWidthInPixels, pageHeightInPixels);
+ return toImpl(bundleRef)->pageNumberForElementById(toImpl(frameRef), toWTFString(idRef), pageWidthInPixels, pageHeightInPixels);
}
WKStringRef WKBundlePageSizeAndMarginsInPixels(WKBundleRef bundleRef, WKBundleFrameRef frameRef, int pageIndex, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft)
@@ -301,12 +301,12 @@ size_t WKBundleGetWorkerThreadCount(WKBundleRef)
void WKBundleSetUserStyleSheetLocation(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, WKStringRef location)
{
- toImpl(bundleRef)->setUserStyleSheetLocation(toImpl(pageGroupRef), toImpl(location)->string());
+ toImpl(bundleRef)->setUserStyleSheetLocation(toImpl(pageGroupRef), toWTFString(location));
}
void WKBundleSetWebNotificationPermission(WKBundleRef bundleRef, WKBundlePageRef pageRef, WKStringRef originStringRef, bool allowed)
{
- toImpl(bundleRef)->setWebNotificationPermission(toImpl(pageRef), toImpl(originStringRef)->string(), allowed);
+ toImpl(bundleRef)->setWebNotificationPermission(toImpl(pageRef), toWTFString(originStringRef), allowed);
}
void WKBundleRemoveAllWebNotificationPermissions(WKBundleRef bundleRef, WKBundlePageRef pageRef)
@@ -323,3 +323,13 @@ void WKBundleSetTabKeyCyclesThroughElements(WKBundleRef bundleRef, WKBundlePageR
{
toImpl(bundleRef)->setTabKeyCyclesThroughElements(toImpl(pageRef), enabled);
}
+
+void WKBundleSetSerialLoadingEnabled(WKBundleRef bundleRef, bool enabled)
+{
+ toImpl(bundleRef)->setSerialLoadingEnabled(enabled);
+}
+
+void WKBundleDispatchPendingLoadRequests(WKBundleRef bundleRef)
+{
+ toImpl(bundleRef)->dispatchPendingLoadRequests();
+}
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h
index 018ef7970..59c3570bd 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h
@@ -32,8 +32,6 @@
#include "WKBundlePrivate.h"
#include <WebCore/EditorInsertAction.h>
#include <WebCore/TextAffinity.h>
-#include <WebCore/UserContentTypes.h>
-#include <WebCore/UserScriptTypes.h>
namespace WebCore {
class CSSStyleDeclaration;
@@ -107,32 +105,6 @@ inline WKAffinityType toAPI(WebCore::EAffinity affinity)
return kWKAffinityUpstream;
}
-inline WebCore::UserScriptInjectionTime toUserScriptInjectionTime(WKUserScriptInjectionTime wkInjectedTime)
-{
- switch (wkInjectedTime) {
- case kWKInjectAtDocumentStart:
- return WebCore::InjectAtDocumentStart;
- case kWKInjectAtDocumentEnd:
- return WebCore::InjectAtDocumentEnd;
- }
-
- ASSERT_NOT_REACHED();
- return WebCore::InjectAtDocumentStart;
-}
-
-inline WebCore::UserContentInjectedFrames toUserContentInjectedFrames(WKUserContentInjectedFrames wkInjectedFrames)
-{
- switch (wkInjectedFrames) {
- case kWKInjectInAllFrames:
- return WebCore::InjectInAllFrames;
- case kWKInjectInTopFrameOnly:
- return WebCore::InjectInTopFrameOnly;
- }
-
- ASSERT_NOT_REACHED();
- return WebCore::InjectInAllFrames;
-}
-
} // namespace WebKit
#endif // WKBundleAPICast_h
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp
index 9a2b9fc00..fe6d79ed8 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp
@@ -97,12 +97,12 @@ unsigned WKBundleFrameGetNumberOfActiveAnimations(WKBundleFrameRef frameRef)
bool WKBundleFramePauseAnimationOnElementWithId(WKBundleFrameRef frameRef, WKStringRef animationName, WKStringRef elementID, double time)
{
- return toImpl(frameRef)->pauseAnimationOnElementWithId(toImpl(animationName)->string(), toImpl(elementID)->string(), time);
+ return toImpl(frameRef)->pauseAnimationOnElementWithId(toWTFString(animationName), toWTFString(elementID), time);
}
bool WKBundleFramePauseTransitionOnElementWithId(WKBundleFrameRef frameRef, WKStringRef propertyName, WKStringRef elementID, double time)
{
- return toImpl(frameRef)->pauseTransitionOnElementWithId(toImpl(propertyName)->string(), toImpl(elementID)->string(), time);
+ return toImpl(frameRef)->pauseTransitionOnElementWithId(toWTFString(propertyName), toWTFString(elementID), time);
}
void WKBundleFrameSuspendAnimations(WKBundleFrameRef frameRef)
@@ -194,7 +194,7 @@ WKStringRef WKBundleFrameCopyLayerTreeAsText(WKBundleFrameRef frameRef)
bool WKBundleFrameAllowsFollowingLink(WKBundleFrameRef frameRef, WKURLRef urlRef)
{
- return toImpl(frameRef)->allowsFollowingLink(WebCore::KURL(WebCore::KURL(), toImpl(urlRef)->string()));
+ return toImpl(frameRef)->allowsFollowingLink(WebCore::KURL(WebCore::KURL(), toWTFString(urlRef)));
}
WKRect WKBundleFrameGetContentBounds(WKBundleFrameRef frameRef)
@@ -234,12 +234,12 @@ bool WKBundleFrameGetDocumentBackgroundColor(WKBundleFrameRef frameRef, double*
WKStringRef WKBundleFrameCopySuggestedFilenameForResourceWithURL(WKBundleFrameRef frameRef, WKURLRef urlRef)
{
- return toCopiedAPI(toImpl(frameRef)->suggestedFilenameForResourceWithURL(WebCore::KURL(WebCore::KURL(), toImpl(urlRef)->string())));
+ return toCopiedAPI(toImpl(frameRef)->suggestedFilenameForResourceWithURL(WebCore::KURL(WebCore::KURL(), toWTFString(urlRef))));
}
WKStringRef WKBundleFrameCopyMIMETypeForResourceWithURL(WKBundleFrameRef frameRef, WKURLRef urlRef)
{
- return toCopiedAPI(toImpl(frameRef)->mimeTypeForResourceWithURL(WebCore::KURL(WebCore::KURL(), toImpl(urlRef)->string())));
+ return toCopiedAPI(toImpl(frameRef)->mimeTypeForResourceWithURL(WebCore::KURL(WebCore::KURL(), toWTFString(urlRef))));
}
bool WKBundleFrameContainsAnyFormElements(WKBundleFrameRef frameRef)
@@ -249,7 +249,7 @@ bool WKBundleFrameContainsAnyFormElements(WKBundleFrameRef frameRef)
void WKBundleFrameSetTextDirection(WKBundleFrameRef frameRef, WKStringRef directionRef)
{
- toImpl(frameRef)->setTextDirection(toImpl(directionRef)->string());
+ toImpl(frameRef)->setTextDirection(toWTFString(directionRef));
}
WKDataRef WKBundleFrameCopyWebArchive(WKBundleFrameRef frameRef)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp
index ae69a5394..cc22499a0 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp
@@ -52,7 +52,7 @@ void WKBundleInspectorClose(WKBundleInspectorRef inspectorRef)
void WKBundleInspectorEvaluateScriptForTest(WKBundleInspectorRef inspectorRef, long callID, WKStringRef script)
{
- return toImpl(inspectorRef)->evaluateScriptForTest(callID, toImpl(script)->string());
+ return toImpl(inspectorRef)->evaluateScriptForTest(callID, toWTFString(script));
}
void WKBundleInspectorSetPageProfilingEnabled(WKBundleInspectorRef inspectorRef, bool enabled)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntent.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntent.cpp
index dc13c57fc..66bee90b0 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntent.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntent.cpp
@@ -64,7 +64,7 @@ WKBundleIntentRef WKBundleIntentCreate(WKDictionaryRef dictionaryRef)
MessagePortArray dummyPorts;
ExceptionCode ec;
- RefPtr<Intent> coreIntent = Intent::create(toImpl(action)->string(), toImpl(type)->string(), data ? static_cast<SerializedScriptValue*>(toImpl(data)->internalRepresentation()) : 0, dummyPorts, ec);
+ RefPtr<Intent> coreIntent = Intent::create(toWTFString(action), toWTFString(type), data ? static_cast<SerializedScriptValue*>(toImpl(data)->internalRepresentation()) : 0, dummyPorts, ec);
return toAPI(InjectedBundleIntent::create(coreIntent.get()).leakRef());
#else
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
index 15088e7d6..53ddf6107 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
@@ -212,12 +212,12 @@ WKStringRef WKBundlePageCopyRenderTreeExternalRepresentation(WKBundlePageRef pag
void WKBundlePageExecuteEditingCommand(WKBundlePageRef pageRef, WKStringRef name, WKStringRef argument)
{
- toImpl(pageRef)->executeEditingCommand(toImpl(name)->string(), toImpl(argument)->string());
+ toImpl(pageRef)->executeEditingCommand(toWTFString(name), toWTFString(argument));
}
bool WKBundlePageIsEditingCommandEnabled(WKBundlePageRef pageRef, WKStringRef name)
{
- return toImpl(pageRef)->isEditingCommandEnabled(toImpl(name)->string());
+ return toImpl(pageRef)->isEditingCommandEnabled(toWTFString(name));
}
void WKBundlePageClearMainFrameName(WKBundlePageRef pageRef)
@@ -277,7 +277,7 @@ void WKBundlePageUninstallPageOverlay(WKBundlePageRef pageRef, WKBundlePageOverl
bool WKBundlePageHasLocalDataForURL(WKBundlePageRef pageRef, WKURLRef urlRef)
{
- return toImpl(pageRef)->hasLocalDataForURL(WebCore::KURL(WebCore::KURL(), toImpl(urlRef)->string()));
+ return toImpl(pageRef)->hasLocalDataForURL(WebCore::KURL(WebCore::KURL(), toWTFString(urlRef)));
}
bool WKBundlePageCanHandleRequest(WKURLRequestRef requestRef)
@@ -287,7 +287,7 @@ bool WKBundlePageCanHandleRequest(WKURLRequestRef requestRef)
bool WKBundlePageFindString(WKBundlePageRef pageRef, WKStringRef target, WKFindOptions findOptions)
{
- return toImpl(pageRef)->findStringFromInjectedBundle(toImpl(target)->string(), toFindOptions(findOptions));
+ return toImpl(pageRef)->findStringFromInjectedBundle(toWTFString(target), toFindOptions(findOptions));
}
WKImageRef WKBundlePageCreateSnapshotWithOptions(WKBundlePageRef pageRef, WKRect rect, WKSnapshotOptions options)
@@ -403,7 +403,7 @@ WKArrayRef WKBundlePageCopyTrackedRepaintRects(WKBundlePageRef pageRef)
void WKBundlePageSetComposition(WKBundlePageRef pageRef, WKStringRef text, int from, int length)
{
- toImpl(pageRef)->setCompositionForTesting(toImpl(text)->string(), from, length);
+ toImpl(pageRef)->setCompositionForTesting(toWTFString(text), from, length);
}
bool WKBundlePageHasComposition(WKBundlePageRef pageRef)
@@ -418,26 +418,12 @@ void WKBundlePageConfirmComposition(WKBundlePageRef pageRef)
void WKBundlePageConfirmCompositionWithText(WKBundlePageRef pageRef, WKStringRef text)
{
- toImpl(pageRef)->confirmCompositionForTesting(toImpl(text)->string());
+ toImpl(pageRef)->confirmCompositionForTesting(toWTFString(text));
}
bool WKBundlePageCanShowMIMEType(WKBundlePageRef, WKStringRef mimeTypeRef)
{
- using WebCore::MIMETypeRegistry;
+ const String mimeType = toWTFString(mimeTypeRef);
- const WTF::String mimeType = toImpl(mimeTypeRef)->string();
-
- if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType))
- return true;
-
- if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType))
- return true;
-
- if (MIMETypeRegistry::isSupportedMediaMIMEType(mimeType))
- return true;
-
- if (mimeType.startsWith("text/", false))
- return !MIMETypeRegistry::isUnsupportedTextMIMEType(mimeType);
-
- return false;
+ return WebCore::MIMETypeRegistry::canShowMIMEType(mimeType);
}
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h
index dce7cf862..c2b37894a 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h
@@ -154,11 +154,13 @@ struct WKBundlePageLoaderClient {
// Version 3
WKBundlePageDidReceiveIntentForFrameCallback didReceiveIntentForFrame;
WKBundlePageRegisterIntentServiceForFrameCallback registerIntentServiceForFrame;
+
+ // Version 4
WKBundlePageDidLayoutCallback didLayout;
};
typedef struct WKBundlePageLoaderClient WKBundlePageLoaderClient;
-enum { kWKBundlePageLoaderClientCurrentVersion = 3 };
+enum { kWKBundlePageLoaderClientCurrentVersion = 4 };
enum {
WKBundlePagePolicyActionPassThrough,
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h
index f032c6222..369c4302f 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h
@@ -36,18 +36,6 @@
extern "C" {
#endif
-enum WKUserScriptInjectionTime {
- kWKInjectAtDocumentStart,
- kWKInjectAtDocumentEnd
-};
-typedef enum WKUserScriptInjectionTime WKUserScriptInjectionTime;
-
-enum WKUserContentInjectedFrames {
- kWKInjectInAllFrames,
- kWKInjectInTopFrameOnly
-};
-typedef enum WKUserContentInjectedFrames WKUserContentInjectedFrames;
-
// TestRunner only SPI
WK_EXPORT void WKBundleSetShouldTrackVisitedLinks(WKBundleRef bundle, bool shouldTrackVisitedLinks);
WK_EXPORT void WKBundleSetAlwaysAcceptCookies(WKBundleRef bundle, bool);
@@ -113,6 +101,8 @@ WK_EXPORT void WKBundleSetPageVisibilityState(WKBundleRef bundle, WKBundlePageRe
WK_EXPORT size_t WKBundleGetWorkerThreadCount(WKBundleRef bundle);
WK_EXPORT void WKBundleSetTabKeyCyclesThroughElements(WKBundleRef bundle, WKBundlePageRef page, bool enabled);
+WK_EXPORT void WKBundleSetSerialLoadingEnabled(WKBundleRef bundle, bool enabled);
+WK_EXPORT void WKBundleDispatchPendingLoadRequests(WKBundleRef bundle);
#ifdef __cplusplus
}
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__)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp
index 0c4295e61..77e03093d 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp
@@ -69,10 +69,10 @@ PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::getOrCreate(Node*
DOMHandleCache::AddResult result = domHandleCache().add(node, 0);
if (!result.isNewEntry)
- return PassRefPtr<InjectedBundleNodeHandle>(result.iterator->second);
+ return PassRefPtr<InjectedBundleNodeHandle>(result.iterator->value);
RefPtr<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::create(node);
- result.iterator->second = nodeHandle.get();
+ result.iterator->value = nodeHandle.get();
return nodeHandle.release();
}
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp
index 1b74f0124..d6000ab91 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp
@@ -48,10 +48,10 @@ PassRefPtr<InjectedBundleRangeHandle> InjectedBundleRangeHandle::getOrCreate(Ran
DOMHandleCache::AddResult result = domHandleCache().add(range, 0);
if (!result.isNewEntry)
- return PassRefPtr<InjectedBundleRangeHandle>(result.iterator->second);
+ return PassRefPtr<InjectedBundleRangeHandle>(result.iterator->value);
RefPtr<InjectedBundleRangeHandle> rangeHandle = InjectedBundleRangeHandle::create(range);
- result.iterator->second = rangeHandle.get();
+ result.iterator->value = rangeHandle.get();
return rangeHandle.release();
}
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
index 44d9a10ab..458b1c169 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
@@ -28,7 +28,6 @@
#include "Arguments.h"
#include "ImmutableArray.h"
-#include "InjectedBundleMessageKinds.h"
#include "InjectedBundleScriptWorld.h"
#include "InjectedBundleUserMessageCoders.h"
#include "LayerTreeHost.h"
@@ -61,6 +60,7 @@
#include <WebCore/PageVisibilityState.h>
#include <WebCore/PrintContext.h>
#include <WebCore/ResourceHandle.h>
+#include <WebCore/ResourceLoadScheduler.h>
#include <WebCore/ScriptController.h>
#include <WebCore/SecurityOrigin.h>
#include <WebCore/SecurityPolicy.h>
@@ -426,23 +426,24 @@ bool InjectedBundle::isProcessingUserGesture()
return ScriptController::processingUserGesture();
}
-static PassOwnPtr<Vector<String> > toStringVector(ImmutableArray* patterns)
+static Vector<String> toStringVector(ImmutableArray* patterns)
{
+ Vector<String> patternsVector;
+
if (!patterns)
- return nullptr;
+ return patternsVector;
- size_t size = patterns->size();
+ size_t size = patterns->size();
if (!size)
- return nullptr;
+ return patternsVector;
- OwnPtr<Vector<String> > patternsVector = adoptPtr(new Vector<String>);
- patternsVector->reserveInitialCapacity(size);
+ patternsVector.reserveInitialCapacity(size);
for (size_t i = 0; i < size; ++i) {
WebString* entry = patterns->at<WebString>(i);
if (entry)
- patternsVector->uncheckedAppend(entry->string());
+ patternsVector.uncheckedAppend(entry->string());
}
- return patternsVector.release();
+ return patternsVector;
}
void InjectedBundle::addUserScript(WebPageGroupProxy* pageGroup, InjectedBundleScriptWorld* scriptWorld, const String& source, const String& url, ImmutableArray* whitelist, ImmutableArray* blacklist, WebCore::UserScriptInjectionTime injectionTime, WebCore::UserContentInjectedFrames injectedFrames)
@@ -540,46 +541,9 @@ void InjectedBundle::didReceiveMessageToPage(WebPage* page, const String& messag
m_client.didReceiveMessageToPage(this, page, messageName, messageBody);
}
-void InjectedBundle::didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
-{
- switch (messageID.get<InjectedBundleMessage::Kind>()) {
- case InjectedBundleMessage::PostMessage: {
- String messageName;
- RefPtr<APIObject> messageBody;
- InjectedBundleUserMessageDecoder messageDecoder(messageBody);
- if (!arguments->decode(CoreIPC::Out(messageName, messageDecoder)))
- return;
-
- didReceiveMessage(messageName, messageBody.get());
- return;
- }
-
- case InjectedBundleMessage::PostMessageToPage: {
- uint64_t pageID = arguments->destinationID();
- if (!pageID)
- return;
-
- WebPage* page = WebProcess::shared().webPage(pageID);
- if (!page)
- return;
-
- String messageName;
- RefPtr<APIObject> messageBody;
- InjectedBundleUserMessageDecoder messageDecoder(messageBody);
- if (!arguments->decode(CoreIPC::Out(messageName, messageDecoder)))
- return;
-
- didReceiveMessageToPage(page, messageName, messageBody.get());
- return;
- }
- }
-
- ASSERT_NOT_REACHED();
-}
-
void InjectedBundle::setPageVisibilityState(WebPage* page, int state, bool isInitialState)
{
-#if ENABLE(PAGE_VISIBILITY_API)
+#if ENABLE(PAGE_VISIBILITY_API) || ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
page->corePage()->setVisibilityState(static_cast<PageVisibilityState>(state), isInitialState);
#endif
}
@@ -646,4 +610,14 @@ void InjectedBundle::setTabKeyCyclesThroughElements(WebPage* page, bool enabled)
page->corePage()->setTabKeyCyclesThroughElements(enabled);
}
+void InjectedBundle::setSerialLoadingEnabled(bool enabled)
+{
+ resourceLoadScheduler()->setSerialLoadingEnabled(enabled);
+}
+
+void InjectedBundle::dispatchPendingLoadRequests()
+{
+ resourceLoadScheduler()->servePendingRequests();
+}
+
} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h
index 1197256d5..754b13320 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h
+++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h
@@ -47,6 +47,10 @@ typedef struct _GModule GModule;
#include <Eina.h>
#endif
+#if PLATFORM(MAC)
+OBJC_CLASS NSBundle;
+#endif
+
namespace CoreIPC {
class ArgumentDecoder;
class Connection;
@@ -56,7 +60,7 @@ namespace CoreIPC {
namespace WebKit {
#if PLATFORM(MAC)
-typedef CFBundleRef PlatformBundle;
+typedef NSBundle *PlatformBundle;
#elif PLATFORM(WIN)
typedef HMODULE PlatformBundle;
#elif PLATFORM(QT)
@@ -164,8 +168,6 @@ public:
void didReceiveMessage(const String&, APIObject*);
void didReceiveMessageToPage(WebPage*, const String&, APIObject*);
- void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
-
static void reportException(JSContextRef, JSValueRef exception);
static bool isProcessingUserGesture();
@@ -175,6 +177,8 @@ public:
static size_t workerThreadCount();
void setTabKeyCyclesThroughElements(WebPage*, bool enabled);
+ void setSerialLoadingEnabled(bool);
+ void dispatchPendingLoadRequests();
private:
explicit InjectedBundle(const String&);
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntent.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntent.cpp
index 92de61c6c..d8ac3a25d 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntent.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntent.cpp
@@ -79,7 +79,7 @@ PassRefPtr<ImmutableDictionary> InjectedBundleIntent::extras() const
ImmutableDictionary::MapType wkExtras;
HashMap<String, String>::const_iterator end = extras.end();
for (HashMap<String, String>::const_iterator it = extras.begin(); it != end; ++it)
- wkExtras.set(it->first, WebString::create(it->second));
+ wkExtras.set(it->key, WebString::create(it->value));
return ImmutableDictionary::adopt(wkExtras);
}
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.cpp b/Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm
index cb59192a9..de5eaf7de 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm
@@ -23,18 +23,25 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "config.h"
-#include "InjectedBundle.h"
+#import "config.h"
+#import "InjectedBundle.h"
-#include "WKBundleAPICast.h"
-#include "WKBundleInitialize.h"
-#include <stdio.h>
-#include <wtf/RetainPtr.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
+#import "WKBundleAPICast.h"
+#import "WKBundleInitialize.h"
+#import "WKWebProcessPlugInInternal.h"
+
+#import <Foundation/NSBundle.h>
+#import <stdio.h>
+#import <wtf/RetainPtr.h>
+#import <wtf/text/CString.h>
+#import <wtf/text/WTFString.h>
using namespace WebCore;
+@interface NSBundle (WKAppDetails)
+- (CFBundleRef)_cfBundle;
+@end
+
namespace WebKit {
bool InjectedBundle::load(APIObject* initializationUserData)
@@ -60,25 +67,53 @@ bool InjectedBundle::load(APIObject* initializationUserData)
return false;
}
- m_platformBundle = CFBundleCreate(0, bundleURL.get());
+ m_platformBundle = [[NSBundle alloc] initWithURL:(NSURL *)bundleURL.get()];
if (!m_platformBundle) {
WTFLogAlways("InjectedBundle::load failed - Could not create the bundle.\n");
return false;
}
- if (!CFBundleLoadExecutable(m_platformBundle)) {
+ if (![m_platformBundle load]) {
WTFLogAlways("InjectedBundle::load failed - Could not load the executable from the bundle.\n");
return false;
}
- WKBundleInitializeFunctionPtr initializeFunction = reinterpret_cast<WKBundleInitializeFunctionPtr>(CFBundleGetFunctionPointerForName(m_platformBundle, CFSTR("WKBundleInitialize")));
- if (!initializeFunction) {
- WTFLogAlways("InjectedBundle::load failed - Could not find the initialize function in the bundle executable.\n");
+ // First check to see if the bundle has a WKBundleInitialize function.
+ WKBundleInitializeFunctionPtr initializeFunction = reinterpret_cast<WKBundleInitializeFunctionPtr>(CFBundleGetFunctionPointerForName([m_platformBundle _cfBundle], CFSTR("WKBundleInitialize")));
+ if (initializeFunction) {
+ initializeFunction(toAPI(this), toAPI(initializationUserData));
+ return true;
+ }
+
+#if defined(__LP64__) && defined(__clang__)
+ // Otherwise, look to see if the bundle has a principal class
+ Class principalClass = [m_platformBundle principalClass];
+ if (!principalClass) {
+ WTFLogAlways("InjectedBundle::load failed - No initialize function or principal class found in the bundle executable.\n");
+ return false;
+ }
+
+ if (![principalClass conformsToProtocol:@protocol(WKWebProcessPlugIn)]) {
+ WTFLogAlways("InjectedBundle::load failed - Principal class does not conform to the WKWebProcessPlugIn protocol.\n");
+ return false;
+ }
+
+ id<WKWebProcessPlugIn> instance = (id<WKWebProcessPlugIn>)[[principalClass alloc] init];
+ if (!instance) {
+ WTFLogAlways("InjectedBundle::load failed - Could not initialize an instance of the principal class.\n");
return false;
}
- initializeFunction(toAPI(this), toAPI(initializationUserData));
+ // Create the shared WKWebProcessPlugInController.
+ [[WKWebProcessPlugInController alloc] _initWithPrincipalClassInstance:instance bundleRef:toAPI(this)];
+
+ if ([instance respondsToSelector:@selector(webProcessPlugInInitialize:)])
+ [instance webProcessPlugInInitialize:[WKWebProcessPlugInController _shared]];
+
return true;
+#else
+ return false;
+#endif
}
void InjectedBundle::activateMacFontAscentHack()