summaryrefslogtreecommitdiff
path: root/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp')
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp218
1 files changed, 190 insertions, 28 deletions
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
index a7a4855e3..94ab4da75 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, 2011, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011, 2013, 2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -33,6 +33,9 @@
#include "APIURLRequest.h"
#include "InjectedBundleBackForwardList.h"
#include "InjectedBundleNodeHandle.h"
+#include "InjectedBundlePageEditorClient.h"
+#include "InjectedBundlePageFormClient.h"
+#include "InjectedBundlePageUIClient.h"
#include "PageBanner.h"
#include "WKAPICast.h"
#include "WKArray.h"
@@ -44,14 +47,22 @@
#include "WebFrame.h"
#include "WebFullScreenManager.h"
#include "WebImage.h"
+#include "WebInspector.h"
#include "WebPage.h"
+#include "WebPageGroupProxy.h"
+#include "WebPageOverlay.h"
#include "WebRenderLayer.h"
#include "WebRenderObject.h"
#include <WebCore/AXObjectCache.h>
#include <WebCore/AccessibilityObject.h>
+#include <WebCore/ApplicationCacheStorage.h>
#include <WebCore/MainFrame.h>
#include <WebCore/Page.h>
+#include <WebCore/PageOverlay.h>
+#include <WebCore/PageOverlayController.h>
+#include <WebCore/SecurityOriginData.h>
#include <WebCore/URL.h>
+#include <WebCore/WheelEventTestTrigger.h>
#include <wtf/StdLibExtras.h>
using namespace WebKit;
@@ -64,7 +75,7 @@ WKTypeID WKBundlePageGetTypeID()
void WKBundlePageSetContextMenuClient(WKBundlePageRef pageRef, WKBundlePageContextMenuClientBase* wkClient)
{
#if ENABLE(CONTEXT_MENUS)
- toImpl(pageRef)->initializeInjectedBundleContextMenuClient(wkClient);
+ toImpl(pageRef)->setInjectedBundleContextMenuClient(std::make_unique<InjectedBundlePageContextMenuClient>(wkClient));
#else
UNUSED_PARAM(pageRef);
UNUSED_PARAM(wkClient);
@@ -73,12 +84,12 @@ void WKBundlePageSetContextMenuClient(WKBundlePageRef pageRef, WKBundlePageConte
void WKBundlePageSetEditorClient(WKBundlePageRef pageRef, WKBundlePageEditorClientBase* wkClient)
{
- toImpl(pageRef)->initializeInjectedBundleEditorClient(wkClient);
+ toImpl(pageRef)->setInjectedBundleEditorClient(wkClient ? std::make_unique<InjectedBundlePageEditorClient>(*wkClient) : std::make_unique<API::InjectedBundle::EditorClient>());
}
void WKBundlePageSetFormClient(WKBundlePageRef pageRef, WKBundlePageFormClientBase* wkClient)
{
- toImpl(pageRef)->initializeInjectedBundleFormClient(wkClient);
+ toImpl(pageRef)->setInjectedBundleFormClient(std::make_unique<InjectedBundlePageFormClient>(wkClient));
}
void WKBundlePageSetPageLoaderClient(WKBundlePageRef pageRef, WKBundlePageLoaderClientBase* wkClient)
@@ -98,7 +109,7 @@ void WKBundlePageSetPolicyClient(WKBundlePageRef pageRef, WKBundlePagePolicyClie
void WKBundlePageSetUIClient(WKBundlePageRef pageRef, WKBundlePageUIClientBase* wkClient)
{
- toImpl(pageRef)->initializeInjectedBundleUIClient(wkClient);
+ toImpl(pageRef)->setInjectedBundleUIClient(std::make_unique<InjectedBundlePageUIClient>(wkClient));
}
void WKBundlePageSetFullScreenClient(WKBundlePageRef pageRef, WKBundlePageFullScreenClientBase* wkClient)
@@ -147,11 +158,6 @@ void WKBundlePageDidExitFullScreen(WKBundlePageRef pageRef)
#endif
}
-void WKBundlePageSetDiagnosticLoggingClient(WKBundlePageRef pageRef, WKBundlePageDiagnosticLoggingClientBase* client)
-{
- toImpl(pageRef)->initializeInjectedBundleDiagnosticLoggingClient(client);
-}
-
WKBundlePageGroupRef WKBundlePageGetPageGroup(WKBundlePageRef pageRef)
{
return toAPI(toImpl(pageRef)->pageGroup());
@@ -165,7 +171,7 @@ WKBundleFrameRef WKBundlePageGetMainFrame(WKBundlePageRef pageRef)
void WKBundlePageClickMenuItem(WKBundlePageRef pageRef, WKContextMenuItemRef item)
{
#if ENABLE(CONTEXT_MENUS)
- toImpl(pageRef)->contextMenu()->itemSelected(*toImpl(item)->data());
+ toImpl(pageRef)->contextMenu()->itemSelected(toImpl(item)->data());
#else
UNUSED_PARAM(pageRef);
UNUSED_PARAM(item);
@@ -183,7 +189,7 @@ static PassRefPtr<API::Array> contextMenuItems(const WebContextMenu& contextMenu
for (const auto& item : items)
menuItems.uncheckedAppend(WebContextMenuItem::create(item));
- return API::Array::create(std::move(menuItems));
+ return API::Array::create(WTFMove(menuItems));
}
#endif
@@ -214,6 +220,11 @@ WKArrayRef WKBundlePageCopyContextMenuAtPointInWindow(WKBundlePageRef pageRef, W
#endif
}
+void WKBundlePageInsertNewlineInQuotedContent(WKBundlePageRef pageRef)
+{
+ toImpl(pageRef)->insertNewlineInQuotedContent();
+}
+
void* WKAccessibilityRootObject(WKBundlePageRef pageRef)
{
#if HAVE(ACCESSIBILITY)
@@ -264,6 +275,22 @@ void* WKAccessibilityFocusedObject(WKBundlePageRef pageRef)
#endif
}
+void WKAccessibilityEnableEnhancedAccessibility(bool enable)
+{
+#if HAVE(ACCESSIBILITY)
+ WebCore::AXObjectCache::setEnhancedUserInterfaceAccessibility(enable);
+#endif
+}
+
+bool WKAccessibilityEnhancedAccessibilityEnabled()
+{
+#if HAVE(ACCESSIBILITY)
+ return WebCore::AXObjectCache::accessibilityEnhancedUserInterfaceEnabled();
+#else
+ return false;
+#endif
+}
+
void WKBundlePageStopLoading(WKBundlePageRef pageRef)
{
toImpl(pageRef)->stopLoading();
@@ -336,27 +363,27 @@ WKBundleBackForwardListRef WKBundlePageGetBackForwardList(WKBundlePageRef pageRe
void WKBundlePageInstallPageOverlay(WKBundlePageRef pageRef, WKBundlePageOverlayRef pageOverlayRef)
{
- toImpl(pageRef)->installPageOverlay(toImpl(pageOverlayRef));
+ toImpl(pageRef)->mainFrame()->pageOverlayController().installPageOverlay(*toImpl(pageOverlayRef)->coreOverlay(), WebCore::PageOverlay::FadeMode::DoNotFade);
}
void WKBundlePageUninstallPageOverlay(WKBundlePageRef pageRef, WKBundlePageOverlayRef pageOverlayRef)
{
- toImpl(pageRef)->uninstallPageOverlay(toImpl(pageOverlayRef));
+ toImpl(pageRef)->mainFrame()->pageOverlayController().uninstallPageOverlay(*toImpl(pageOverlayRef)->coreOverlay(), WebCore::PageOverlay::FadeMode::DoNotFade);
}
void WKBundlePageInstallPageOverlayWithAnimation(WKBundlePageRef pageRef, WKBundlePageOverlayRef pageOverlayRef)
{
- toImpl(pageRef)->installPageOverlay(toImpl(pageOverlayRef), true);
+ toImpl(pageRef)->mainFrame()->pageOverlayController().installPageOverlay(*toImpl(pageOverlayRef)->coreOverlay(), WebCore::PageOverlay::FadeMode::Fade);
}
void WKBundlePageUninstallPageOverlayWithAnimation(WKBundlePageRef pageRef, WKBundlePageOverlayRef pageOverlayRef)
{
- toImpl(pageRef)->uninstallPageOverlay(toImpl(pageOverlayRef), true);
+ toImpl(pageRef)->mainFrame()->pageOverlayController().uninstallPageOverlay(*toImpl(pageOverlayRef)->coreOverlay(), WebCore::PageOverlay::FadeMode::Fade);
}
void WKBundlePageSetTopOverhangImage(WKBundlePageRef pageRef, WKImageRef imageRef)
{
-#if PLATFORM(MAC) && !PLATFORM(IOS)
+#if PLATFORM(MAC)
toImpl(pageRef)->setTopOverhangImage(toImpl(imageRef));
#else
UNUSED_PARAM(pageRef);
@@ -366,7 +393,7 @@ void WKBundlePageSetTopOverhangImage(WKBundlePageRef pageRef, WKImageRef imageRe
void WKBundlePageSetBottomOverhangImage(WKBundlePageRef pageRef, WKImageRef imageRef)
{
-#if PLATFORM(MAC) && !PLATFORM(IOS)
+#if PLATFORM(MAC)
toImpl(pageRef)->setBottomOverhangImage(toImpl(imageRef));
#else
UNUSED_PARAM(pageRef);
@@ -404,7 +431,7 @@ bool WKBundlePageFindString(WKBundlePageRef pageRef, WKStringRef target, WKFindO
WKImageRef WKBundlePageCreateSnapshotWithOptions(WKBundlePageRef pageRef, WKRect rect, WKSnapshotOptions options)
{
RefPtr<WebImage> webImage = toImpl(pageRef)->scaledSnapshotWithOptions(toIntRect(rect), 1, toSnapshotOptions(options));
- return toAPI(webImage.release().leakRef());
+ return toAPI(webImage.leakRef());
}
WKImageRef WKBundlePageCreateSnapshotInViewCoordinates(WKBundlePageRef pageRef, WKRect rect, WKImageOptions options)
@@ -412,19 +439,19 @@ WKImageRef WKBundlePageCreateSnapshotInViewCoordinates(WKBundlePageRef pageRef,
SnapshotOptions snapshotOptions = snapshotOptionsFromImageOptions(options);
snapshotOptions |= SnapshotOptionsInViewCoordinates;
RefPtr<WebImage> webImage = toImpl(pageRef)->scaledSnapshotWithOptions(toIntRect(rect), 1, snapshotOptions);
- return toAPI(webImage.release().leakRef());
+ return toAPI(webImage.leakRef());
}
WKImageRef WKBundlePageCreateSnapshotInDocumentCoordinates(WKBundlePageRef pageRef, WKRect rect, WKImageOptions options)
{
RefPtr<WebImage> webImage = toImpl(pageRef)->scaledSnapshotWithOptions(toIntRect(rect), 1, snapshotOptionsFromImageOptions(options));
- return toAPI(webImage.release().leakRef());
+ return toAPI(webImage.leakRef());
}
WKImageRef WKBundlePageCreateScaledSnapshotInDocumentCoordinates(WKBundlePageRef pageRef, WKRect rect, double scaleFactor, WKImageOptions options)
{
RefPtr<WebImage> webImage = toImpl(pageRef)->scaledSnapshotWithOptions(toIntRect(rect), scaleFactor, snapshotOptionsFromImageOptions(options));
- return toAPI(webImage.release().leakRef());
+ return toAPI(webImage.leakRef());
}
double WKBundlePageGetBackingScaleFactor(WKBundlePageRef pageRef)
@@ -439,12 +466,7 @@ void WKBundlePageListenForLayoutMilestones(WKBundlePageRef pageRef, WKLayoutMile
WKBundleInspectorRef WKBundlePageGetInspector(WKBundlePageRef pageRef)
{
-#if ENABLE(INSPECTOR)
return toAPI(toImpl(pageRef)->inspector());
-#else
- UNUSED_PARAM(pageRef);
- return 0;
-#endif
}
void WKBundlePageForceRepaint(WKBundlePageRef page)
@@ -505,7 +527,7 @@ void WKBundlePageResetTrackedRepaints(WKBundlePageRef pageRef)
WKArrayRef WKBundlePageCopyTrackedRepaintRects(WKBundlePageRef pageRef)
{
- return toAPI(toImpl(pageRef)->trackedRepaintRects().leakRef());
+ return toAPI(&toImpl(pageRef)->trackedRepaintRects().leakRef());
}
void WKBundlePageSetComposition(WKBundlePageRef pageRef, WKStringRef text, int from, int length)
@@ -542,3 +564,143 @@ void WKBundlePageStopExtendingIncrementalRenderingSuppression(WKBundlePageRef pa
{
toImpl(pageRef)->stopExtendingIncrementalRenderingSuppression(token);
}
+
+bool WKBundlePageIsUsingEphemeralSession(WKBundlePageRef pageRef)
+{
+ return toImpl(pageRef)->usesEphemeralSession();
+}
+
+bool WKBundlePageIsControlledByAutomation(WKBundlePageRef pageRef)
+{
+ return toImpl(pageRef)->isControlledByAutomation();
+}
+
+#if TARGET_OS_IPHONE
+void WKBundlePageSetUseTestingViewportConfiguration(WKBundlePageRef pageRef, bool useTestingViewportConfiguration)
+{
+ toImpl(pageRef)->setUseTestingViewportConfiguration(useTestingViewportConfiguration);
+}
+#endif
+
+void WKBundlePageStartMonitoringScrollOperations(WKBundlePageRef pageRef)
+{
+ WebKit::WebPage* webPage = toImpl(pageRef);
+ WebCore::Page* page = webPage ? webPage->corePage() : nullptr;
+
+ if (!page)
+ return;
+
+ page->ensureTestTrigger();
+}
+
+void WKBundlePageRegisterScrollOperationCompletionCallback(WKBundlePageRef pageRef, WKBundlePageTestNotificationCallback callback, void* context)
+{
+ if (!callback)
+ return;
+
+ WebKit::WebPage* webPage = toImpl(pageRef);
+ WebCore::Page* page = webPage ? webPage->corePage() : nullptr;
+ if (!page || !page->expectsWheelEventTriggers())
+ return;
+
+ page->ensureTestTrigger().setTestCallbackAndStartNotificationTimer([=]() {
+ callback(context);
+ });
+}
+
+void WKBundlePagePostMessage(WKBundlePageRef pageRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef)
+{
+ toImpl(pageRef)->postMessage(toWTFString(messageNameRef), toImpl(messageBodyRef));
+}
+
+void WKBundlePagePostSynchronousMessageForTesting(WKBundlePageRef pageRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef, WKTypeRef* returnDataRef)
+{
+ WebPage* page = toImpl(pageRef);
+ page->layoutIfNeeded();
+
+ RefPtr<API::Object> returnData;
+ page->postSynchronousMessageForTesting(toWTFString(messageNameRef), toImpl(messageBodyRef), returnData);
+ if (returnDataRef)
+ *returnDataRef = toAPI(returnData.leakRef());
+}
+
+void WKBundlePageAddUserScript(WKBundlePageRef pageRef, WKStringRef source, _WKUserScriptInjectionTime injectionTime, WKUserContentInjectedFrames injectedFrames)
+{
+ toImpl(pageRef)->addUserScript(toWTFString(source), toUserContentInjectedFrames(injectedFrames), toUserScriptInjectionTime(injectionTime));
+}
+
+void WKBundlePageAddUserStyleSheet(WKBundlePageRef pageRef, WKStringRef source, WKUserContentInjectedFrames injectedFrames)
+{
+ toImpl(pageRef)->addUserStyleSheet(toWTFString(source), toUserContentInjectedFrames(injectedFrames));
+}
+
+void WKBundlePageRemoveAllUserContent(WKBundlePageRef pageRef)
+{
+ toImpl(pageRef)->removeAllUserContent();
+}
+
+WKStringRef WKBundlePageCopyGroupIdentifier(WKBundlePageRef pageRef)
+{
+ return toCopiedAPI(toImpl(pageRef)->pageGroup()->identifier());
+}
+
+void WKBundlePageClearApplicationCache(WKBundlePageRef page)
+{
+ toImpl(page)->corePage()->applicationCacheStorage().deleteAllEntries();
+}
+
+void WKBundlePageClearApplicationCacheForOrigin(WKBundlePageRef page, WKStringRef origin)
+{
+ toImpl(page)->corePage()->applicationCacheStorage().deleteCacheForOrigin(WebCore::SecurityOrigin::createFromString(toImpl(origin)->string()));
+}
+
+void WKBundlePageSetAppCacheMaximumSize(WKBundlePageRef page, uint64_t size)
+{
+ toImpl(page)->corePage()->applicationCacheStorage().setMaximumSize(size);
+}
+
+uint64_t WKBundlePageGetAppCacheUsageForOrigin(WKBundlePageRef page, WKStringRef origin)
+{
+ return toImpl(page)->corePage()->applicationCacheStorage().diskUsageForOrigin(WebCore::SecurityOrigin::createFromString(toImpl(origin)->string()));
+}
+
+void WKBundlePageSetApplicationCacheOriginQuota(WKBundlePageRef page, WKStringRef origin, uint64_t bytes)
+{
+ toImpl(page)->corePage()->applicationCacheStorage().storeUpdatedQuotaForOrigin(WebCore::SecurityOrigin::createFromString(toImpl(origin)->string()).ptr(), bytes);
+}
+
+void WKBundlePageResetApplicationCacheOriginQuota(WKBundlePageRef page, WKStringRef origin)
+{
+ toImpl(page)->corePage()->applicationCacheStorage().storeUpdatedQuotaForOrigin(WebCore::SecurityOrigin::createFromString(toImpl(origin)->string()).ptr(), toImpl(page)->corePage()->applicationCacheStorage().defaultOriginQuota());
+}
+
+WKArrayRef WKBundlePageCopyOriginsWithApplicationCache(WKBundlePageRef page)
+{
+ HashSet<RefPtr<WebCore::SecurityOrigin>> origins;
+ toImpl(page)->corePage()->applicationCacheStorage().getOriginsWithCache(origins);
+
+ Vector<RefPtr<API::Object>> originIdentifiers;
+ originIdentifiers.reserveInitialCapacity(origins.size());
+
+ for (const auto& origin : origins)
+ originIdentifiers.uncheckedAppend(API::String::create(WebCore::SecurityOriginData::fromSecurityOrigin(*origin).databaseIdentifier()));
+
+ return toAPI(&API::Array::create(WTFMove(originIdentifiers)).leakRef());
+}
+
+void WKBundlePageSetEventThrottlingBehaviorOverride(WKBundlePageRef page, WKEventThrottlingBehavior* behavior)
+{
+ std::optional<WebCore::EventThrottlingBehavior> behaviorValue;
+ if (behavior) {
+ switch (*behavior) {
+ case kWKEventThrottlingBehaviorResponsive:
+ behaviorValue = WebCore::EventThrottlingBehavior::Responsive;
+ break;
+ case kWKEventThrottlingBehaviorUnresponsive:
+ behaviorValue = WebCore::EventThrottlingBehavior::Unresponsive;
+ break;
+ }
+ }
+
+ toImpl(page)->corePage()->setEventThrottlingBehaviorOverride(behaviorValue);
+}