diff options
Diffstat (limited to 'Source/WebKit2/WebProcess/InjectedBundle')
105 files changed, 1074 insertions, 3171 deletions
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/APIInjectedBundlePageContextMenuClient.h b/Source/WebKit2/WebProcess/InjectedBundle/API/APIInjectedBundlePageContextMenuClient.h deleted file mode 100644 index 7962483d6..000000000 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/APIInjectedBundlePageContextMenuClient.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2014 Igalia S.L. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef APIInjectedBundlePageContextMenuClient_h -#define APIInjectedBundlePageContextMenuClient_h - -#if ENABLE(CONTEXT_MENUS) - -#include <wtf/Vector.h> - -namespace WebCore { -class ContextMenuItem; -class HitTestResult; -} - -namespace WebKit { -class WebContextMenuItemData; -class WebFrame; -class WebPage; -class WebSecurityOrigin; -} - -namespace API { -class Object; - -namespace InjectedBundle { - -class PageContextMenuClient { -public: - virtual ~PageContextMenuClient() { } - - virtual bool getCustomMenuFromDefaultItems(WebKit::WebPage&, const WebCore::HitTestResult&, const Vector<WebCore::ContextMenuItem>& /* defaultMenu */, Vector<WebKit::WebContextMenuItemData>& /* newMenu */, RefPtr<API::Object>& /* userData */) { return false; } - virtual void prepareForImmediateAction(WebKit::WebPage&, const WebCore::HitTestResult&, RefPtr<API::Object>& /* userData */) { } -}; - -} // namespace InjectedBundle - -} // namespace API - -#endif // ENABLE(CONTEXT_MENUS) -#endif // APIInjectedBundlePageContextMenuClient_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/APIInjectedBundlePageUIClient.h b/Source/WebKit2/WebProcess/InjectedBundle/API/APIInjectedBundlePageUIClient.h deleted file mode 100644 index c8ea05a61..000000000 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/APIInjectedBundlePageUIClient.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2014 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef APIInjectedBundlePageUIClient_h -#define APIInjectedBundlePageUIClient_h - -#include "WebEvent.h" -#include <runtime/ConsoleTypes.h> - -namespace WebCore { -class HitTestResult; -} - -namespace WebKit { -class InjectedBundleNodeHandle; -class WebFrame; -class WebPage; -} - -namespace API { - -class Object; -class SecurityOrigin; - -namespace InjectedBundle { - -class PageUIClient { -public: - virtual ~PageUIClient() { } - - virtual void willAddMessageToConsole(WebKit::WebPage*, JSC::MessageSource, JSC::MessageLevel, const WTF::String& message, unsigned lineNumber, unsigned columnNumber, const WTF::String& sourceID) { UNUSED_PARAM(message); UNUSED_PARAM(lineNumber); UNUSED_PARAM(columnNumber); UNUSED_PARAM(sourceID); } - virtual void willSetStatusbarText(WebKit::WebPage*, const WTF::String&) { } - virtual void willRunJavaScriptAlert(WebKit::WebPage*, const WTF::String&, WebKit::WebFrame*) { } - virtual void willRunJavaScriptConfirm(WebKit::WebPage*, const WTF::String&, WebKit::WebFrame*) { } - virtual void willRunJavaScriptPrompt(WebKit::WebPage*, const WTF::String&, const WTF::String&, WebKit::WebFrame*) { } - virtual void mouseDidMoveOverElement(WebKit::WebPage*, const WebCore::HitTestResult&, WebKit::WebEvent::Modifiers, RefPtr<API::Object>& userData) { UNUSED_PARAM(userData); } - virtual void pageDidScroll(WebKit::WebPage*) { } - - virtual WTF::String shouldGenerateFileForUpload(WebKit::WebPage*, const WTF::String& originalFilePath) { UNUSED_PARAM(originalFilePath); return WTF::String(); } - virtual WTF::String generateFileForUpload(WebKit::WebPage*, const WTF::String& originalFilePath) { UNUSED_PARAM(originalFilePath); return emptyString(); } - - enum class UIElementVisibility { - Unknown, - Visible, - Hidden, - }; - - virtual UIElementVisibility statusBarIsVisible(WebKit::WebPage*) { return UIElementVisibility::Unknown; } - virtual UIElementVisibility menuBarIsVisible(WebKit::WebPage*) { return UIElementVisibility::Unknown; } - virtual UIElementVisibility toolbarsAreVisible(WebKit::WebPage*) { return UIElementVisibility::Unknown; } - - virtual bool didReachApplicationCacheOriginQuota(WebKit::WebPage*, SecurityOrigin*, int64_t totalBytesNeeded) { UNUSED_PARAM(totalBytesNeeded); return false; } - virtual uint64_t didExceedDatabaseQuota(WebKit::WebPage*, SecurityOrigin*, const WTF::String& databaseName, const WTF::String& databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes) - { - UNUSED_PARAM(databaseName); - UNUSED_PARAM(databaseDisplayName); - UNUSED_PARAM(currentQuotaBytes); - UNUSED_PARAM(currentOriginUsageBytes); - UNUSED_PARAM(currentDatabaseUsageBytes); - UNUSED_PARAM(expectedUsageBytes); - return 0; - } - - virtual WTF::String plugInStartLabelTitle(const WTF::String& mimeType) const { UNUSED_PARAM(mimeType); return emptyString(); } - virtual WTF::String plugInStartLabelSubtitle(const WTF::String& mimeType) const { UNUSED_PARAM(mimeType); return emptyString(); } - virtual WTF::String plugInExtraStyleSheet() const { return emptyString(); } - virtual WTF::String plugInExtraScript() const { return emptyString(); } - - virtual void didClickAutoFillButton(WebKit::WebPage&, WebKit::InjectedBundleNodeHandle&, RefPtr<API::Object>&) { } -}; - -} // namespace InjectedBundle - -} // namespace API - -#endif // APIInjectedBundlePageUIClient_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp index 3320f610b..bc0ca142e 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp @@ -29,17 +29,10 @@ #include "APIArray.h" #include "APIData.h" #include "InjectedBundle.h" -#include "InjectedBundleScriptWorld.h" #include "WKAPICast.h" #include "WKBundleAPICast.h" #include "WKBundlePrivate.h" -#include "WebConnection.h" -#include "WebFrame.h" -#include "WebPage.h" -#include "WebPageGroupProxy.h" -#include <WebCore/DatabaseManager.h> -using namespace WebCore; using namespace WebKit; WKTypeID WKBundleGetTypeID() @@ -70,6 +63,26 @@ WKConnectionRef WKBundleGetApplicationConnection(WKBundleRef bundleRef) return toAPI(toImpl(bundleRef)->webConnectionToUIProcess()); } +void WKBundleSetShouldTrackVisitedLinks(WKBundleRef bundleRef, bool shouldTrackVisitedLinks) +{ + toImpl(bundleRef)->setShouldTrackVisitedLinks(shouldTrackVisitedLinks); +} + +void WKBundleRemoveAllVisitedLinks(WKBundleRef bundleRef) +{ + toImpl(bundleRef)->removeAllVisitedLinks(); +} + +void WKBundleActivateMacFontAscentHack(WKBundleRef bundleRef) +{ + toImpl(bundleRef)->activateMacFontAscentHack(); +} + +void WKBundleSetCacheModel(WKBundleRef bundleRef, uint32_t cacheModel) +{ + toImpl(bundleRef)->setCacheModel(cacheModel); +} + void WKBundleGarbageCollectJavaScriptObjects(WKBundleRef bundleRef) { toImpl(bundleRef)->garbageCollectJavaScriptObjects(); @@ -85,7 +98,12 @@ size_t WKBundleGetJavaScriptObjectsCount(WKBundleRef bundleRef) return toImpl(bundleRef)->javaScriptObjectsCount(); } -void WKBundleAddUserScript(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, WKBundleScriptWorldRef scriptWorldRef, WKStringRef sourceRef, WKURLRef urlRef, WKArrayRef whitelistRef, WKArrayRef blacklistRef, _WKUserScriptInjectionTime injectionTimeRef, WKUserContentInjectedFrames injectedFramesRef) +void WKBundleSetAlwaysAcceptCookies(WKBundleRef bundleRef, bool accept) +{ + toImpl(bundleRef)->setAlwaysAcceptCookies(accept); +} + +void WKBundleAddUserScript(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, WKBundleScriptWorldRef scriptWorldRef, WKStringRef sourceRef, WKURLRef urlRef, WKArrayRef whitelistRef, WKArrayRef blacklistRef, WKUserScriptInjectionTime injectionTimeRef, WKUserContentInjectedFrames injectedFramesRef) { toImpl(bundleRef)->addUserScript(toImpl(pageGroupRef), toImpl(scriptWorldRef), toWTFString(sourceRef), toWTFString(urlRef), toImpl(whitelistRef), toImpl(blacklistRef), toUserScriptInjectionTime(injectionTimeRef), toUserContentInjectedFrames(injectedFramesRef)); } @@ -200,16 +218,50 @@ void WKBundleReportException(JSContextRef context, JSValueRef exception) InjectedBundle::reportException(context, exception); } -void WKBundleClearAllDatabases(WKBundleRef) +void WKBundleClearAllDatabases(WKBundleRef bundleRef) { - DatabaseManager::singleton().deleteAllDatabases(); + toImpl(bundleRef)->clearAllDatabases(); } void WKBundleSetDatabaseQuota(WKBundleRef bundleRef, uint64_t quota) { - // Historically, we've used the following (somewhat non-sensical) string - // for the databaseIdentifier of local files. - DatabaseManager::singleton().setQuota(SecurityOrigin::createFromDatabaseIdentifier("file__0").ptr(), quota); + toImpl(bundleRef)->setDatabaseQuota(quota); +} + +void WKBundleClearApplicationCache(WKBundleRef bundleRef) +{ + toImpl(bundleRef)->clearApplicationCache(); +} + +void WKBundleClearApplicationCacheForOrigin(WKBundleRef bundleRef, WKStringRef origin) +{ + toImpl(bundleRef)->clearApplicationCacheForOrigin(toWTFString(origin)); +} + +void WKBundleSetAppCacheMaximumSize(WKBundleRef bundleRef, uint64_t size) +{ + toImpl(bundleRef)->setAppCacheMaximumSize(size); +} + +uint64_t WKBundleGetAppCacheUsageForOrigin(WKBundleRef bundleRef, WKStringRef origin) +{ + return toImpl(bundleRef)->appCacheUsageForOrigin(toWTFString(origin)); +} + +void WKBundleSetApplicationCacheOriginQuota(WKBundleRef bundleRef, WKStringRef origin, uint64_t bytes) +{ + toImpl(bundleRef)->setApplicationCacheOriginQuota(toWTFString(origin), bytes); +} + +void WKBundleResetApplicationCacheOriginQuota(WKBundleRef bundleRef, WKStringRef origin) +{ + toImpl(bundleRef)->resetApplicationCacheOriginQuota(toWTFString(origin)); +} + +WKArrayRef WKBundleCopyOriginsWithApplicationCache(WKBundleRef bundleRef) +{ + RefPtr<API::Array> origins = toImpl(bundleRef)->originsWithApplicationCache(); + return toAPI(origins.release().leakRef()); } WKDataRef WKBundleCreateWKDataFromUInt8Array(WKBundleRef bundle, JSContextRef context, JSValueRef data) @@ -266,3 +318,23 @@ void WKBundleSetTabKeyCyclesThroughElements(WKBundleRef bundleRef, WKBundlePageR { toImpl(bundleRef)->setTabKeyCyclesThroughElements(toImpl(pageRef), enabled); } + +void WKBundleSetSerialLoadingEnabled(WKBundleRef bundleRef, bool enabled) +{ + toImpl(bundleRef)->setSerialLoadingEnabled(enabled); +} + +void WKBundleSetShadowDOMEnabled(WKBundleRef bundleRef, bool enabled) +{ + toImpl(bundleRef)->setShadowDOMEnabled(enabled); +} + +void WKBundleSetSeamlessIFramesEnabled(WKBundleRef bundleRef, bool enabled) +{ + toImpl(bundleRef)->setSeamlessIFramesEnabled(enabled); +} + +void WKBundleDispatchPendingLoadRequests(WKBundleRef bundleRef) +{ + toImpl(bundleRef)->dispatchPendingLoadRequests(); +} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.h index 60014f78e..3a3308328 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.h @@ -27,7 +27,7 @@ #define WKBundle_h #include <JavaScriptCore/JavaScript.h> -#include <WebKit/WKBase.h> +#include <WebKit2/WKBase.h> #ifdef __cplusplus extern "C" { @@ -68,6 +68,21 @@ typedef struct WKBundleClientV1 { WKBundleDidReceiveMessageToPageCallback didReceiveMessageToPage; } WKBundleClientV1; +enum { kWKBundleClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 1 }; +typedef struct WKBundleClient { + int version; + const void * clientInfo; + + // Version 0. + WKBundleDidCreatePageCallback didCreatePage; + WKBundleWillDestroyPageCallback willDestroyPage; + WKBundleDidInitializePageGroupCallback didInitializePageGroup; + WKBundleDidReceiveMessageCallback didReceiveMessage; + + // Version 1. + WKBundleDidReceiveMessageToPageCallback didReceiveMessageToPage; +} WKBundleClient WK_DEPRECATED("Use an explicit versioned struct instead"); + WK_EXPORT WKTypeID WKBundleGetTypeID(); WK_EXPORT void WKBundleSetClient(WKBundleRef bundle, WKBundleClientBase* client); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h index 9ed888536..15ac158bd 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h @@ -33,31 +33,32 @@ #include <WebCore/EditorInsertAction.h> #include <WebCore/TextAffinity.h> +namespace WebCore { + class CSSStyleDeclaration; +} + namespace WebKit { class InjectedBundle; class InjectedBundleBackForwardList; class InjectedBundleBackForwardListItem; -class InjectedBundleCSSStyleDeclarationHandle; class InjectedBundleDOMWindowExtension; -class InjectedBundleFileHandle; class InjectedBundleHitTestResult; class InjectedBundleNavigationAction; class InjectedBundleNodeHandle; class InjectedBundleRangeHandle; class InjectedBundleScriptWorld; class PageBanner; +class PageOverlay; class WebFrame; class WebInspector; class WebPage; class WebPageGroupProxy; -class WebPageOverlay; WK_ADD_API_MAPPING(WKBundleBackForwardListItemRef, InjectedBundleBackForwardListItem) WK_ADD_API_MAPPING(WKBundleBackForwardListRef, InjectedBundleBackForwardList) -WK_ADD_API_MAPPING(WKBundleCSSStyleDeclarationRef, InjectedBundleCSSStyleDeclarationHandle) +WK_ADD_API_MAPPING(WKBundleCSSStyleDeclarationRef, WebCore::CSSStyleDeclaration) WK_ADD_API_MAPPING(WKBundleDOMWindowExtensionRef, InjectedBundleDOMWindowExtension) -WK_ADD_API_MAPPING(WKBundleFileHandleRef, InjectedBundleFileHandle) WK_ADD_API_MAPPING(WKBundleFrameRef, WebFrame) WK_ADD_API_MAPPING(WKBundleHitTestResultRef, InjectedBundleHitTestResult) WK_ADD_API_MAPPING(WKBundleInspectorRef, WebInspector) @@ -65,7 +66,7 @@ WK_ADD_API_MAPPING(WKBundleNavigationActionRef, InjectedBundleNavigationAction) WK_ADD_API_MAPPING(WKBundleNodeHandleRef, InjectedBundleNodeHandle) WK_ADD_API_MAPPING(WKBundlePageBannerRef, PageBanner) WK_ADD_API_MAPPING(WKBundlePageGroupRef, WebPageGroupProxy) -WK_ADD_API_MAPPING(WKBundlePageOverlayRef, WebPageOverlay) +WK_ADD_API_MAPPING(WKBundlePageOverlayRef, PageOverlay) WK_ADD_API_MAPPING(WKBundlePageRef, WebPage) WK_ADD_API_MAPPING(WKBundleRangeHandleRef, InjectedBundleRangeHandle) WK_ADD_API_MAPPING(WKBundleRef, InjectedBundle) @@ -76,10 +77,13 @@ inline WKInsertActionType toAPI(WebCore::EditorInsertAction action) switch (action) { case WebCore::EditorInsertActionTyped: return kWKInsertActionTyped; + break; case WebCore::EditorInsertActionPasted: return kWKInsertActionPasted; + break; case WebCore::EditorInsertActionDropped: return kWKInsertActionDropped; + break; } ASSERT_NOT_REACHED(); return kWKInsertActionTyped; @@ -90,8 +94,10 @@ inline WKAffinityType toAPI(WebCore::EAffinity affinity) switch (affinity) { case WebCore::UPSTREAM: return kWKAffinityUpstream; + break; case WebCore::DOWNSTREAM: return kWKAffinityDownstream; + break; } ASSERT_NOT_REACHED(); return kWKAffinityUpstream; diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardList.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardList.h index 03e36e051..7aa573aa6 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardList.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardList.h @@ -26,7 +26,7 @@ #ifndef WKBundleBackForwardList_h #define WKBundleBackForwardList_h -#include <WebKit/WKBase.h> +#include <WebKit2/WKBase.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.cpp index c6ef6ad6c..755bf3ecc 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.cpp @@ -79,6 +79,6 @@ bool WKBundleBackForwardListItemHasCachedPageExpired(WKBundleBackForwardListItem WKArrayRef WKBundleBackForwardListItemCopyChildren(WKBundleBackForwardListItemRef itemRef) { - return toAPI(&toImpl(itemRef)->children().leakRef()); + return toAPI(toImpl(itemRef)->children().leakRef()); } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.h index 409c16faf..5ad9abe79 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.h @@ -26,7 +26,7 @@ #ifndef WKBundleBackForwardListItem_h #define WKBundleBackForwardListItem_h -#include <WebKit/WKBase.h> +#include <WebKit2/WKBase.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.cpp index b660e815f..6e5bd62a8 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.cpp @@ -27,9 +27,7 @@ #include "WKBundleDOMWindowExtension.h" #include "InjectedBundleDOMWindowExtension.h" -#include "InjectedBundleScriptWorld.h" #include "WKBundleAPICast.h" -#include "WebFrame.h" using namespace WebKit; diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.h index 61a3a753b..409a74289 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.h @@ -26,7 +26,7 @@ #ifndef WKBundleDOMWindowExtension_h #define WKBundleDOMWindowExtension_h -#include <WebKit/WKBase.h> +#include <WebKit2/WKBase.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFileHandleRef.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFileHandleRef.cpp deleted file mode 100644 index da8cae86e..000000000 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFileHandleRef.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 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 - * 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. - */ - -#include "config.h" -#include "WKBundleFileHandleRef.h" - -#include "InjectedBundleFileHandle.h" -#include "WKAPICast.h" -#include "WKBundleAPICast.h" - -using namespace WebKit; - -WKTypeID WKBundleFileHandleGetTypeID() -{ - return toAPI(InjectedBundleFileHandle::APIType); -} - -WKBundleFileHandleRef WKBundleFileHandleCreateWithPath(WKStringRef pathRef) -{ - return toAPI(InjectedBundleFileHandle::create(toWTFString(pathRef)).leakRef()); -} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFileHandleRef.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFileHandleRef.h deleted file mode 100644 index e1a16fb69..000000000 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFileHandleRef.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 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 - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef WKBundleFileHandleRef_h -#define WKBundleFileHandleRef_h - -#include <WebKit/WKBase.h> - -#ifdef __cplusplus -extern "C" { -#endif - -WK_EXPORT WKTypeID WKBundleFileHandleGetTypeID(); - -WK_EXPORT WKBundleFileHandleRef WKBundleFileHandleCreateWithPath(WKStringRef path); - -#ifdef __cplusplus -} -#endif - - -#endif /* WKBundleFileHandleRef_h */ diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp index 0b6dc7f7a..91279cb78 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp @@ -28,23 +28,16 @@ #include "WKBundleFramePrivate.h" #include "APIArray.h" -#include "APISecurityOrigin.h" -#include "InjectedBundleFileHandle.h" #include "InjectedBundleHitTestResult.h" -#include "InjectedBundleNodeHandle.h" -#include "InjectedBundleRangeHandle.h" -#include "InjectedBundleScriptWorld.h" #include "WKAPICast.h" #include "WKBundleAPICast.h" #include "WKData.h" #include "WebFrame.h" -#include "WebPage.h" +#include "WebSecurityOrigin.h" #include <WebCore/Document.h> -#include <WebCore/FocusController.h> #include <WebCore/Frame.h> #include <WebCore/FrameLoader.h> #include <WebCore/FrameView.h> -#include <WebCore/Page.h> using namespace WebCore; using namespace WebKit; @@ -95,7 +88,7 @@ WKFrameLoadState WKBundleFrameGetFrameLoadState(WKBundleFrameRef frameRef) WKArrayRef WKBundleFrameCopyChildFrames(WKBundleFrameRef frameRef) { - return toAPI(&toImpl(frameRef)->childFrames().leakRef()); + return toAPI(toImpl(frameRef)->childFrames().leakRef()); } JSGlobalContextRef WKBundleFrameGetJavaScriptContext(WKBundleFrameRef frameRef) @@ -123,11 +116,6 @@ JSValueRef WKBundleFrameGetJavaScriptWrapperForRangeForWorld(WKBundleFrameRef fr return toImpl(frameRef)->jsWrapperForWorld(toImpl(rangeHandleRef), toImpl(worldRef)); } -JSValueRef WKBundleFrameGetJavaScriptWrapperForFileForWorld(WKBundleFrameRef frameRef, WKBundleFileHandleRef fileHandleRef, WKBundleScriptWorldRef worldRef) -{ - return toImpl(frameRef)->jsWrapperForWorld(toImpl(fileHandleRef), toImpl(worldRef)); -} - WKStringRef WKBundleFrameCopyName(WKBundleFrameRef frameRef) { return toCopiedAPI(toImpl(frameRef)->name()); @@ -240,11 +228,6 @@ void WKBundleFrameSetTextDirection(WKBundleFrameRef frameRef, WKStringRef direct toImpl(frameRef)->setTextDirection(toWTFString(directionRef)); } -void WKBundleFrameSetAccessibleName(WKBundleFrameRef frameRef, WKStringRef accessibleNameRef) -{ - toImpl(frameRef)->setAccessibleName(toWTFString(accessibleNameRef)); -} - WKDataRef WKBundleFrameCopyWebArchive(WKBundleFrameRef frameRef) { return WKBundleFrameCopyWebArchiveFilteringSubframes(frameRef, 0, 0); @@ -252,7 +235,7 @@ WKDataRef WKBundleFrameCopyWebArchive(WKBundleFrameRef frameRef) WKDataRef WKBundleFrameCopyWebArchiveFilteringSubframes(WKBundleFrameRef frameRef, WKBundleFrameFrameFilterCallback frameFilterCallback, void* context) { -#if PLATFORM(COCOA) +#if PLATFORM(MAC) RetainPtr<CFDataRef> data = toImpl(frameRef)->webArchiveData(frameFilterCallback, context); if (data) return WKDataCreate(CFDataGetBytePtr(data.get()), CFDataGetLength(data.get())); @@ -287,12 +270,3 @@ WKSecurityOriginRef WKBundleFrameCopySecurityOrigin(WKBundleFrameRef frameRef) return toCopiedAPI(coreFrame->document()->securityOrigin()); } - -void WKBundleFrameFocus(WKBundleFrameRef frameRef) -{ - Frame* coreFrame = toImpl(frameRef)->coreFrame(); - if (!coreFrame) - return; - - coreFrame->page()->focusController().setFocusedFrame(coreFrame); -} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h index 6654f0029..8c2b875f5 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h @@ -27,9 +27,9 @@ #define WKBundleFrame_h #include <JavaScriptCore/JavaScript.h> -#include <WebKit/WKBase.h> -#include <WebKit/WKFrame.h> -#include <WebKit/WKGeometry.h> +#include <WebKit2/WKBase.h> +#include <WebKit2/WKFrame.h> +#include <WebKit2/WKGeometry.h> #ifdef __cplusplus extern "C" { @@ -55,7 +55,6 @@ WK_EXPORT WKBundleFrameRef WKBundleFrameForJavaScriptContext(JSContextRef contex WK_EXPORT JSValueRef WKBundleFrameGetJavaScriptWrapperForNodeForWorld(WKBundleFrameRef frame, WKBundleNodeHandleRef nodeHandle, WKBundleScriptWorldRef world); WK_EXPORT JSValueRef WKBundleFrameGetJavaScriptWrapperForRangeForWorld(WKBundleFrameRef frame, WKBundleRangeHandleRef rangeHandle, WKBundleScriptWorldRef world); -WK_EXPORT JSValueRef WKBundleFrameGetJavaScriptWrapperForFileForWorld(WKBundleFrameRef frame, WKBundleFileHandleRef fileHandle, WKBundleScriptWorldRef world); WK_EXPORT WKBundlePageRef WKBundleFrameGetPage(WKBundleFrameRef frame); @@ -74,8 +73,6 @@ WK_EXPORT bool WKBundleFrameGetDocumentBackgroundColor(WKBundleFrameRef frame, d WK_EXPORT WKStringRef WKBundleFrameCopySuggestedFilenameForResourceWithURL(WKBundleFrameRef frame, WKURLRef url); WK_EXPORT WKStringRef WKBundleFrameCopyMIMETypeForResourceWithURL(WKBundleFrameRef frame, WKURLRef url); -WK_EXPORT void WKBundleFrameSetAccessibleName(WKBundleFrameRef frame, WKStringRef accessibleName); - WK_EXPORT WKDataRef WKBundleFrameCopyWebArchive(WKBundleFrameRef frame); typedef bool (*WKBundleFrameFrameFilterCallback)(WKBundleFrameRef frame, WKBundleFrameRef subframe, void* context); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h index 0e83d35c8..fa5cb759d 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h @@ -27,8 +27,8 @@ #define WKBundleFramePrivate_h #include <JavaScriptCore/JavaScript.h> -#include <WebKit/WKBase.h> -#include <WebKit/WKGeometry.h> +#include <WebKit2/WKBase.h> +#include <WebKit2/WKGeometry.h> #ifndef __cplusplus #include <stdbool.h> @@ -54,8 +54,6 @@ WK_EXPORT WKBundleHitTestResultRef WKBundleFrameCreateHitTestResult(WKBundleFram WK_EXPORT bool WKBundleFrameHandlesPageScaleGesture(WKBundleFrameRef frame); -WK_EXPORT void WKBundleFrameFocus(WKBundleFrameRef frame); - #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp index 46f699926..60a4c68b0 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp @@ -30,7 +30,6 @@ #include "InjectedBundleNodeHandle.h" #include "WKAPICast.h" #include "WKBundleAPICast.h" -#include "WebFrame.h" using namespace WebKit; @@ -45,12 +44,6 @@ WKBundleNodeHandleRef WKBundleHitTestResultCopyNodeHandle(WKBundleHitTestResultR return toAPI(nodeHandle.release().leakRef()); } -WKBundleNodeHandleRef WKBundleHitTestResultCopyURLElementHandle(WKBundleHitTestResultRef hitTestResultRef) -{ - RefPtr<InjectedBundleNodeHandle> urlElementNodeHandle = toImpl(hitTestResultRef)->urlElementHandle(); - return toAPI(urlElementNodeHandle.release().leakRef()); -} - WKBundleFrameRef WKBundleHitTestResultGetFrame(WKBundleHitTestResultRef hitTestResultRef) { return toAPI(toImpl(hitTestResultRef)->frame()); @@ -91,11 +84,6 @@ bool WKBundleHitTestResultMediaHasAudio(WKBundleHitTestResultRef hitTestResultRe return toImpl(hitTestResultRef)->mediaHasAudio(); } -bool WKBundleHitTestResultIsDownloadableMedia(WKBundleHitTestResultRef hitTestResultRef) -{ - return toImpl(hitTestResultRef)->isDownloadableMedia(); -} - WKBundleHitTestResultMediaType WKBundleHitTestResultGetMediaType(WKBundleHitTestResultRef hitTestResultRef) { return toAPI(toImpl(hitTestResultRef)->mediaType()); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h index 941becab3..839e9850d 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h @@ -26,8 +26,8 @@ #ifndef WKBundleHitTestResult_h #define WKBundleHitTestResult_h -#include <WebKit/WKBase.h> -#include <WebKit/WKGeometry.h> +#include <WebKit2/WKBase.h> +#include <WebKit2/WKGeometry.h> #ifdef __cplusplus extern "C" { @@ -43,7 +43,6 @@ typedef uint32_t WKBundleHitTestResultMediaType; WK_EXPORT WKTypeID WKBundleHitTestResultGetTypeID(); WK_EXPORT WKBundleNodeHandleRef WKBundleHitTestResultCopyNodeHandle(WKBundleHitTestResultRef hitTestResult); -WK_EXPORT WKBundleNodeHandleRef WKBundleHitTestResultCopyURLElementHandle(WKBundleHitTestResultRef hitTestResult); WK_EXPORT WKBundleFrameRef WKBundleHitTestResultGetFrame(WKBundleHitTestResultRef hitTestResult); WK_EXPORT WKBundleFrameRef WKBundleHitTestResultGetTargetFrame(WKBundleHitTestResultRef hitTestResult); @@ -54,7 +53,6 @@ WK_EXPORT WKURLRef WKBundleHitTestResultCopyAbsoluteLinkURL(WKBundleHitTestResul WK_EXPORT WKURLRef WKBundleHitTestResultCopyAbsoluteMediaURL(WKBundleHitTestResultRef hitTestResult); WK_EXPORT bool WKBundleHitTestResultMediaIsInFullscreen(WKBundleHitTestResultRef hitTestResult); WK_EXPORT bool WKBundleHitTestResultMediaHasAudio(WKBundleHitTestResultRef hitTestResult); -WK_EXPORT bool WKBundleHitTestResultIsDownloadableMedia(WKBundleHitTestResultRef hitTestResultRef); WK_EXPORT WKBundleHitTestResultMediaType WKBundleHitTestResultGetMediaType(WKBundleHitTestResultRef hitTestResult); WK_EXPORT WKRect WKBundleHitTestResultGetImageRect(WKBundleHitTestResultRef hitTestResult); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInitialize.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInitialize.h index 86a897e39..f10b7b400 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInitialize.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInitialize.h @@ -26,7 +26,7 @@ #ifndef WKBundleInitialize_h #define WKBundleInitialize_h -#include <WebKit/WKBase.h> +#include <WebKit2/WKBase.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp index 0f0e0afe9..554cf3cd8 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp @@ -35,28 +35,40 @@ using namespace WebKit; WKTypeID WKBundleInspectorGetTypeID() { +#if ENABLE(INSPECTOR) return toAPI(WebInspector::APIType); +#else + return toAPI(API::Object::Type::Null); +#endif } void WKBundleInspectorShow(WKBundleInspectorRef inspectorRef) { +#if ENABLE(INSPECTOR) toImpl(inspectorRef)->show(); +#endif } void WKBundleInspectorClose(WKBundleInspectorRef inspectorRef) { +#if ENABLE(INSPECTOR) toImpl(inspectorRef)->close(); +#endif } -void WKBundleInspectorEvaluateScriptForTest(WKBundleInspectorRef inspectorRef, WKStringRef script) +void WKBundleInspectorEvaluateScriptForTest(WKBundleInspectorRef inspectorRef, long callID, WKStringRef script) { - toImpl(inspectorRef)->evaluateScriptForTest(toWTFString(script)); +#if ENABLE(INSPECTOR) + toImpl(inspectorRef)->evaluateScriptForTest(callID, toWTFString(script)); +#endif } void WKBundleInspectorSetPageProfilingEnabled(WKBundleInspectorRef inspectorRef, bool enabled) { +#if ENABLE(INSPECTOR) if (enabled) toImpl(inspectorRef)->startPageProfiling(); else toImpl(inspectorRef)->stopPageProfiling(); +#endif } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.h index ddc3318b7..20d070995 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.h @@ -26,7 +26,7 @@ #ifndef WKBundleInspector_h #define WKBundleInspector_h -#include <WebKit/WKBase.h> +#include <WebKit2/WKBase.h> #ifndef __cplusplus #include <stdbool.h> @@ -41,7 +41,7 @@ WK_EXPORT WKTypeID WKBundleInspectorGetTypeID(); WK_EXPORT void WKBundleInspectorShow(WKBundleInspectorRef inspector); WK_EXPORT void WKBundleInspectorClose(WKBundleInspectorRef inspector); -WK_EXPORT void WKBundleInspectorEvaluateScriptForTest(WKBundleInspectorRef inspector, WKStringRef script); +WK_EXPORT void WKBundleInspectorEvaluateScriptForTest(WKBundleInspectorRef inspector, long callID, WKStringRef script); WK_EXPORT void WKBundleInspectorSetPageProfilingEnabled(WKBundleInspectorRef inspector, bool enabled); #ifdef __cplusplus diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp index 84392c7d1..c26ec3ecf 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp @@ -25,7 +25,6 @@ #include "config.h" #include "WKBundleNavigationAction.h" -#include "WKBundleNavigationActionPrivate.h" #include "InjectedBundleHitTestResult.h" #include "InjectedBundleNavigationAction.h" @@ -66,13 +65,3 @@ WKBundleNodeHandleRef WKBundleNavigationActionCopyFormElement(WKBundleNavigation RefPtr<InjectedBundleNodeHandle> formElement = toImpl(navigationActionRef)->formElement(); return toAPI(formElement.release().leakRef()); } - -bool WKBundleNavigationActionGetShouldOpenExternalURLs(WKBundleNavigationActionRef navigationActionRef) -{ - return toImpl(navigationActionRef)->shouldOpenExternalURLs(); -} - -bool WKBundleNavigationActionGetShouldTryAppLinks(WKBundleNavigationActionRef navigationActionRef) -{ - return toImpl(navigationActionRef)->shouldTryAppLinks(); -} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.h index 3b95cf1bf..03f083a29 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.h @@ -26,9 +26,9 @@ #ifndef WKBundleNavigationAction_h #define WKBundleNavigationAction_h -#include <WebKit/WKBase.h> -#include <WebKit/WKEvent.h> -#include <WebKit/WKPageLoadTypes.h> +#include <WebKit2/WKBase.h> +#include <WebKit2/WKEvent.h> +#include <WebKit2/WKPageLoadTypes.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationActionPrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationActionPrivate.h deleted file mode 100644 index 474692963..000000000 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationActionPrivate.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 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 - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef WKBundleNavigationActionPrivate_h -#define WKBundleNavigationActionPrivate_h - -#include <WebKit/WKBase.h> - -#ifdef __cplusplus -extern "C" { -#endif - -WK_EXPORT bool WKBundleNavigationActionGetShouldOpenExternalURLs(WKBundleNavigationActionRef); -WK_EXPORT bool WKBundleNavigationActionGetShouldTryAppLinks(WKBundleNavigationActionRef); - -#ifdef __cplusplus -} -#endif - -#endif // WKBundleNavigationActionPrivate_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp index 8a913013e..cb3f9b6e6 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp @@ -28,29 +28,13 @@ #include "WKBundleNodeHandlePrivate.h" #include "InjectedBundleNodeHandle.h" -#include "InjectedBundleRangeHandle.h" #include "WKAPICast.h" #include "WKBundleAPICast.h" #include "WebFrame.h" #include "WebImage.h" -#include <WebCore/HTMLTextFormControlElement.h> using namespace WebKit; -static WebCore::AutoFillButtonType toAutoFillButtonType(WKAutoFillButtonType wkAutoFillButtonType) -{ - switch (wkAutoFillButtonType) { - case kWKAutoFillButtonTypeNone: - return WebCore::AutoFillButtonType::None; - case kWKAutoFillButtonTypeContacts: - return WebCore::AutoFillButtonType::Contacts; - case kWKAutoFillButtonTypeCredentials: - return WebCore::AutoFillButtonType::Credentials; - } - ASSERT_NOT_REACHED(); - return WebCore::AutoFillButtonType::None; -} - WKTypeID WKBundleNodeHandleGetTypeID() { return toAPI(InjectedBundleNodeHandle::APIType); @@ -79,12 +63,6 @@ WKImageRef WKBundleNodeHandleCopySnapshotWithOptions(WKBundleNodeHandleRef nodeH return toAPI(image.release().leakRef()); } -WKBundleRangeHandleRef WKBundleNodeHandleCopyVisibleRange(WKBundleNodeHandleRef nodeHandleRef) -{ - RefPtr<InjectedBundleRangeHandle> rangeHandle = toImpl(nodeHandleRef)->visibleRange(); - return toAPI(rangeHandle.release().leakRef()); -} - WKRect WKBundleNodeHandleGetElementBounds(WKBundleNodeHandleRef elementHandleRef) { return toAPI(toImpl(elementHandleRef)->elementBounds()); @@ -95,29 +73,14 @@ void WKBundleNodeHandleSetHTMLInputElementValueForUser(WKBundleNodeHandleRef htm toImpl(htmlInputElementHandleRef)->setHTMLInputElementValueForUser(toWTFString(valueRef)); } -bool WKBundleNodeHandleGetHTMLInputElementAutoFilled(WKBundleNodeHandleRef htmlInputElementHandleRef) -{ - return toImpl(htmlInputElementHandleRef)->isHTMLInputElementAutoFilled(); -} - -void WKBundleNodeHandleSetHTMLInputElementAutoFilled(WKBundleNodeHandleRef htmlInputElementHandleRef, bool filled) -{ - toImpl(htmlInputElementHandleRef)->setHTMLInputElementAutoFilled(filled); -} - -bool WKBundleNodeHandleGetHTMLInputElementAutoFillButtonEnabled(WKBundleNodeHandleRef htmlInputElementHandleRef) -{ - return toImpl(htmlInputElementHandleRef)->isHTMLInputElementAutoFillButtonEnabled(); -} - -void WKBundleNodeHandleSetHTMLInputElementAutoFillButtonEnabledWithButtonType(WKBundleNodeHandleRef htmlInputElementHandleRef, WKAutoFillButtonType autoFillButtonType) +bool WKBundleNodeHandleGetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandleRef) { - toImpl(htmlInputElementHandleRef)->setHTMLInputElementAutoFillButtonEnabled(toAutoFillButtonType(autoFillButtonType)); + return toImpl(htmlInputElementHandleRef)->isHTMLInputElementAutofilled(); } -WKRect WKBundleNodeHandleGetHTMLInputElementAutoFillButtonBounds(WKBundleNodeHandleRef htmlInputElementHandleRef) +void WKBundleNodeHandleSetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandleRef, bool filled) { - return toAPI(toImpl(htmlInputElementHandleRef)->htmlInputElementAutoFillButtonBounds()); + toImpl(htmlInputElementHandleRef)->setHTMLInputElementAutofilled(filled); } bool WKBundleNodeHandleGetHTMLInputElementLastChangeWasUserEdit(WKBundleNodeHandleRef htmlInputElementHandleRef) @@ -153,23 +116,3 @@ WKBundleFrameRef WKBundleNodeHandleCopyHTMLIFrameElementContentFrame(WKBundleNod RefPtr<WebFrame> frame = toImpl(htmlIFrameElementHandleRef)->htmlIFrameElementContentFrame(); return toAPI(frame.release().leakRef()); } - -// Deprecated - use WKBundleNodeHandleGetHTMLInputElementAutoFilled(WKBundleNodeHandleRef). -bool WKBundleNodeHandleGetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandleRef) -{ - return toImpl(htmlInputElementHandleRef)->isHTMLInputElementAutoFilled(); -} - -// Deprecated - use WKBundleNodeHandleSetHTMLInputElementAutoFilled(WKBundleNodeHandleRef, bool). -void WKBundleNodeHandleSetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandleRef, bool filled) -{ - toImpl(htmlInputElementHandleRef)->setHTMLInputElementAutoFilled(filled); -} - -// Deprecated - use WKBundleNodeHandleSetHTMLInputElementAutoFillButtonEnabledWithButtonType(WKBundleNodeHandleRef, WKAutoFillButtonType). -void WKBundleNodeHandleSetHTMLInputElementAutoFillButtonEnabled(WKBundleNodeHandleRef htmlInputElementHandleRef, bool enabled) -{ - WebCore::AutoFillButtonType autoFillButtonType = enabled ? WebCore::AutoFillButtonType::Credentials : WebCore::AutoFillButtonType::None; - - toImpl(htmlInputElementHandleRef)->setHTMLInputElementAutoFillButtonEnabled(autoFillButtonType); -} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.h index 6b0bfe958..3cdad1761 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.h @@ -26,7 +26,7 @@ #ifndef WKBundleNodeHandle_h #define WKBundleNodeHandle_h -#include <WebKit/WKBase.h> +#include <WebKit2/WKBase.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h index 696d464a8..1ad192915 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h @@ -27,21 +27,14 @@ #define WKBundleNodeHandlePrivate_h #include <JavaScriptCore/JavaScript.h> -#include <WebKit/WKBase.h> -#include <WebKit/WKGeometry.h> -#include <WebKit/WKImage.h> +#include <WebKit2/WKBase.h> +#include <WebKit2/WKGeometry.h> +#include <WebKit2/WKImage.h> #ifdef __cplusplus extern "C" { #endif -enum { - kWKAutoFillButtonTypeNone, - kWKAutoFillButtonTypeCredentials, - kWKAutoFillButtonTypeContacts -}; -typedef uint8_t WKAutoFillButtonType; - WK_EXPORT WKBundleNodeHandleRef WKBundleNodeHandleCreate(JSContextRef context, JSObjectRef object); /* Convenience Operations */ @@ -52,18 +45,14 @@ WK_EXPORT WKBundleNodeHandleRef WKBundleNodeHandleCopyDocument(WKBundleNodeHandl WK_EXPORT WKRect WKBundleNodeHandleGetRenderRect(WKBundleNodeHandleRef nodeHandle, bool* isReplaced); WK_EXPORT WKImageRef WKBundleNodeHandleCopySnapshotWithOptions(WKBundleNodeHandleRef nodeHandle, WKSnapshotOptions options); -WK_EXPORT WKBundleRangeHandleRef WKBundleNodeHandleCopyVisibleRange(WKBundleNodeHandleRef nodeHandle); /* Element Specific Operations */ WK_EXPORT WKRect WKBundleNodeHandleGetElementBounds(WKBundleNodeHandleRef elementHandle); /* HTMLInputElement Specific Operations */ WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementValueForUser(WKBundleNodeHandleRef htmlInputElementHandle, WKStringRef value); -WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementAutoFilled(WKBundleNodeHandleRef htmlInputElementHandle); -WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementAutoFilled(WKBundleNodeHandleRef htmlInputElementHandle, bool filled); -WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementAutoFillButtonEnabled(WKBundleNodeHandleRef htmlInputElementHandle); -WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementAutoFillButtonEnabledWithButtonType(WKBundleNodeHandleRef htmlInputElementHandle, WKAutoFillButtonType autoFillButtonType); -WK_EXPORT WKRect WKBundleNodeHandleGetHTMLInputElementAutoFillButtonBounds(WKBundleNodeHandleRef htmlInputElementHandle); +WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandle); +WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandle, bool filled); WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementLastChangeWasUserEdit(WKBundleNodeHandleRef htmlInputElementHandle); /* HTMLTextAreaElement Specific Operations */ @@ -81,14 +70,6 @@ WK_EXPORT WKBundleFrameRef WKBundleNodeHandleCopyHTMLFrameElementContentFrame(WK /* HTMLIFrameElement Specific Operations */ WK_EXPORT WKBundleFrameRef WKBundleNodeHandleCopyHTMLIFrameElementContentFrame(WKBundleNodeHandleRef htmlIFrameElementHandle); - -/* Deprecated - use WKBundleNodeHandleGetHTMLInputElementAutoFilled(WKBundleNodeHandleRef) */ -WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandle); -/* Deprecated - use WKBundleNodeHandleSetHTMLInputElementAutoFilled(WKBundleNodeHandleRef, bool) */ -WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandle, bool filled); -/* Deprecated - use WKBundleNodeHandleSetHTMLInputElementAutoFillButtonEnabled(WKBundleNodeHandleRef, WKAutoFillButtonType)*/ -WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementAutoFillButtonEnabled(WKBundleNodeHandleRef htmlInputElementHandle, bool enabled); - #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp index 44c29e883..a7a4855e3 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, 2015 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011, 2013 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -33,8 +33,6 @@ #include "APIURLRequest.h" #include "InjectedBundleBackForwardList.h" #include "InjectedBundleNodeHandle.h" -#include "InjectedBundlePageFormClient.h" -#include "InjectedBundlePageUIClient.h" #include "PageBanner.h" #include "WKAPICast.h" #include "WKArray.h" @@ -46,21 +44,14 @@ #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/URL.h> -#include <WebCore/WheelEventTestTrigger.h> #include <wtf/StdLibExtras.h> using namespace WebKit; @@ -73,7 +64,7 @@ WKTypeID WKBundlePageGetTypeID() void WKBundlePageSetContextMenuClient(WKBundlePageRef pageRef, WKBundlePageContextMenuClientBase* wkClient) { #if ENABLE(CONTEXT_MENUS) - toImpl(pageRef)->setInjectedBundleContextMenuClient(std::make_unique<InjectedBundlePageContextMenuClient>(wkClient)); + toImpl(pageRef)->initializeInjectedBundleContextMenuClient(wkClient); #else UNUSED_PARAM(pageRef); UNUSED_PARAM(wkClient); @@ -87,7 +78,7 @@ void WKBundlePageSetEditorClient(WKBundlePageRef pageRef, WKBundlePageEditorClie void WKBundlePageSetFormClient(WKBundlePageRef pageRef, WKBundlePageFormClientBase* wkClient) { - toImpl(pageRef)->setInjectedBundleFormClient(std::make_unique<InjectedBundlePageFormClient>(wkClient)); + toImpl(pageRef)->initializeInjectedBundleFormClient(wkClient); } void WKBundlePageSetPageLoaderClient(WKBundlePageRef pageRef, WKBundlePageLoaderClientBase* wkClient) @@ -107,7 +98,7 @@ void WKBundlePageSetPolicyClient(WKBundlePageRef pageRef, WKBundlePagePolicyClie void WKBundlePageSetUIClient(WKBundlePageRef pageRef, WKBundlePageUIClientBase* wkClient) { - toImpl(pageRef)->setInjectedBundleUIClient(std::make_unique<InjectedBundlePageUIClient>(wkClient)); + toImpl(pageRef)->initializeInjectedBundleUIClient(wkClient); } void WKBundlePageSetFullScreenClient(WKBundlePageRef pageRef, WKBundlePageFullScreenClientBase* wkClient) @@ -174,7 +165,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); @@ -192,7 +183,7 @@ static PassRefPtr<API::Array> contextMenuItems(const WebContextMenu& contextMenu for (const auto& item : items) menuItems.uncheckedAppend(WebContextMenuItem::create(item)); - return API::Array::create(WTFMove(menuItems)); + return API::Array::create(std::move(menuItems)); } #endif @@ -273,22 +264,6 @@ 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(); @@ -361,27 +336,27 @@ WKBundleBackForwardListRef WKBundlePageGetBackForwardList(WKBundlePageRef pageRe void WKBundlePageInstallPageOverlay(WKBundlePageRef pageRef, WKBundlePageOverlayRef pageOverlayRef) { - toImpl(pageRef)->mainFrame()->pageOverlayController().installPageOverlay(toImpl(pageOverlayRef)->coreOverlay(), WebCore::PageOverlay::FadeMode::DoNotFade); + toImpl(pageRef)->installPageOverlay(toImpl(pageOverlayRef)); } void WKBundlePageUninstallPageOverlay(WKBundlePageRef pageRef, WKBundlePageOverlayRef pageOverlayRef) { - toImpl(pageRef)->mainFrame()->pageOverlayController().uninstallPageOverlay(toImpl(pageOverlayRef)->coreOverlay(), WebCore::PageOverlay::FadeMode::DoNotFade); + toImpl(pageRef)->uninstallPageOverlay(toImpl(pageOverlayRef)); } void WKBundlePageInstallPageOverlayWithAnimation(WKBundlePageRef pageRef, WKBundlePageOverlayRef pageOverlayRef) { - toImpl(pageRef)->mainFrame()->pageOverlayController().installPageOverlay(toImpl(pageOverlayRef)->coreOverlay(), WebCore::PageOverlay::FadeMode::Fade); + toImpl(pageRef)->installPageOverlay(toImpl(pageOverlayRef), true); } void WKBundlePageUninstallPageOverlayWithAnimation(WKBundlePageRef pageRef, WKBundlePageOverlayRef pageOverlayRef) { - toImpl(pageRef)->mainFrame()->pageOverlayController().uninstallPageOverlay(toImpl(pageOverlayRef)->coreOverlay(), WebCore::PageOverlay::FadeMode::Fade); + toImpl(pageRef)->uninstallPageOverlay(toImpl(pageOverlayRef), true); } void WKBundlePageSetTopOverhangImage(WKBundlePageRef pageRef, WKImageRef imageRef) { -#if PLATFORM(MAC) +#if PLATFORM(MAC) && !PLATFORM(IOS) toImpl(pageRef)->setTopOverhangImage(toImpl(imageRef)); #else UNUSED_PARAM(pageRef); @@ -391,7 +366,7 @@ void WKBundlePageSetTopOverhangImage(WKBundlePageRef pageRef, WKImageRef imageRe void WKBundlePageSetBottomOverhangImage(WKBundlePageRef pageRef, WKImageRef imageRef) { -#if PLATFORM(MAC) +#if PLATFORM(MAC) && !PLATFORM(IOS) toImpl(pageRef)->setBottomOverhangImage(toImpl(imageRef)); #else UNUSED_PARAM(pageRef); @@ -464,7 +439,12 @@ 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) @@ -525,7 +505,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) @@ -562,121 +542,3 @@ void WKBundlePageStopExtendingIncrementalRenderingSuppression(WKBundlePageRef pa { toImpl(pageRef)->stopExtendingIncrementalRenderingSuppression(token); } - -bool WKBundlePageIsUsingEphemeralSession(WKBundlePageRef pageRef) -{ - return toImpl(pageRef)->usesEphemeralSession(); -} - -#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.release().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(origin->databaseIdentifier())); - - return toAPI(&API::Array::create(WTFMove(originIdentifiers)).leakRef()); -} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h index 0564481c3..6c3ac2a26 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010, 2015 Apple Inc. All rights reserved. + * Copyright (C) 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,18 +27,18 @@ #define WKBundlePage_h #include <JavaScriptCore/JavaScript.h> -#include <WebKit/WKBase.h> -#include <WebKit/WKBundlePageContextMenuClient.h> -#include <WebKit/WKBundlePageDiagnosticLoggingClient.h> -#include <WebKit/WKBundlePageEditorClient.h> -#include <WebKit/WKBundlePageFormClient.h> -#include <WebKit/WKBundlePageFullScreenClient.h> -#include <WebKit/WKBundlePageLoaderClient.h> -#include <WebKit/WKBundlePagePolicyClient.h> -#include <WebKit/WKBundlePageResourceLoadClient.h> -#include <WebKit/WKBundlePageUIClient.h> -#include <WebKit/WKFindOptions.h> -#include <WebKit/WKImage.h> +#include <WebKit2/WKBase.h> +#include <WebKit2/WKBundlePageContextMenuClient.h> +#include <WebKit2/WKBundlePageDiagnosticLoggingClient.h> +#include <WebKit2/WKBundlePageEditorClient.h> +#include <WebKit2/WKBundlePageFormClient.h> +#include <WebKit2/WKBundlePageFullScreenClient.h> +#include <WebKit2/WKBundlePageLoaderClient.h> +#include <WebKit2/WKBundlePagePolicyClient.h> +#include <WebKit2/WKBundlePageResourceLoadClient.h> +#include <WebKit2/WKBundlePageUIClient.h> +#include <WebKit2/WKFindOptions.h> +#include <WebKit2/WKImage.h> #ifndef __cplusplus #include <stdbool.h> @@ -107,20 +107,6 @@ WK_EXPORT void WKBundlePageListenForLayoutMilestones(WKBundlePageRef page, WKLay WK_EXPORT WKBundleInspectorRef WKBundlePageGetInspector(WKBundlePageRef page); -WK_EXPORT bool WKBundlePageIsUsingEphemeralSession(WKBundlePageRef page); - -WK_EXPORT void WKBundlePageStartMonitoringScrollOperations(WKBundlePageRef page); - -WK_EXPORT WKStringRef WKBundlePageCopyGroupIdentifier(WKBundlePageRef page); - -typedef void (*WKBundlePageTestNotificationCallback)(void* context); -WK_EXPORT void WKBundlePageRegisterScrollOperationCompletionCallback(WKBundlePageRef, WKBundlePageTestNotificationCallback, void* context); - -WK_EXPORT void WKBundlePagePostMessage(WKBundlePageRef page, WKStringRef messageName, WKTypeRef messageBody); - -// Switches a connection into a fully synchronous mode, so all messages become synchronous until we get a response. -WK_EXPORT void WKBundlePagePostSynchronousMessageForTesting(WKBundlePageRef page, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData); - #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageBanner.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageBanner.cpp deleted file mode 100644 index be0955e1c..000000000 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageBanner.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2013 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "WKBundlePageBanner.h" - -#include "PageBanner.h" -#include "WKAPICast.h" -#include "WKBundleAPICast.h" - -using namespace WebKit; - -WKTypeID WKBundlePageBannerGetTypeID() -{ - return toAPI(PageBanner::APIType); -} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageBanner.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageBanner.h deleted file mode 100644 index 13525724c..000000000 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageBanner.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2013 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef WKBundlePageBanner_h -#define WKBundlePageBanner_h - -#include <WebKit/WKBase.h> -#include <WebKit/WKEvent.h> -#include <WebKit/WKGeometry.h> - -#ifndef __cplusplus -#include <stdbool.h> -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -// Page banner client. -typedef bool (*WKBundlePageBannerMouseDownCallback)(WKBundlePageBannerRef pageBanner, WKPoint position, WKEventMouseButton mouseButton, const void* clientInfo); -typedef bool (*WKBundlePageBannerMouseUpCallback)(WKBundlePageBannerRef pageBanner, WKPoint position, WKEventMouseButton mouseButton, const void* clientInfo); -typedef bool (*WKBundlePageBannerMouseMovedCallback)(WKBundlePageBannerRef pageBanner, WKPoint position, const void* clientInfo); -typedef bool (*WKBundlePageBannerMouseDraggedCallback)(WKBundlePageBannerRef pageBanner, WKPoint position, WKEventMouseButton mouseButton, const void* clientInfo); - -typedef struct WKBundlePageBannerClientBase { - int version; - const void * clientInfo; -} WKBundlePageBannerClientBase; - -typedef struct WKBundlePageBannerClientV0 { - WKBundlePageBannerClientBase base; - - // Version 0. - WKBundlePageBannerMouseDownCallback mouseDown; - WKBundlePageBannerMouseUpCallback mouseUp; - WKBundlePageBannerMouseMovedCallback mouseMoved; - WKBundlePageBannerMouseDraggedCallback mouseDragged; -} WKBundlePageBannerClientV0; - -WK_EXPORT WKTypeID WKBundlePageBannerGetTypeID(); - -#ifdef __cplusplus -} -#endif - -#endif // WKBundlePageBanner_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageContextMenuClient.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageContextMenuClient.h index 00b1f048a..55cdb18a3 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageContextMenuClient.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageContextMenuClient.h @@ -26,10 +26,9 @@ #ifndef WKBundlePageContextMenuClient_h #define WKBundlePageContextMenuClient_h -#include <WebKit/WKBase.h> +#include <WebKit2/WKBase.h> typedef void (*WKBundlePageGetContextMenuFromDefaultContextMenuCallback)(WKBundlePageRef page, WKBundleHitTestResultRef hitTestResult, WKArrayRef defaultMenu, WKArrayRef* newMenu, WKTypeRef* userData, const void* clientInfo); -typedef void (*WKBundlePagePrepareForActionMenuCallback)(WKBundlePageRef page, WKBundleHitTestResultRef hitTestResult, WKTypeRef* userData, const void* clientInfo); typedef struct WKBundlePageContextMenuClientBase { int version; @@ -39,16 +38,17 @@ typedef struct WKBundlePageContextMenuClientBase { typedef struct WKBundlePageContextMenuClientV0 { WKBundlePageContextMenuClientBase base; + // Version 0. WKBundlePageGetContextMenuFromDefaultContextMenuCallback getContextMenuFromDefaultMenu; } WKBundlePageContextMenuClientV0; -typedef struct WKBundlePageContextMenuClientV1 { - WKBundlePageContextMenuClientBase base; +enum { kWKBundlePageContextMenuClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 0 }; +typedef struct WKBundlePageContextMenuClient { + int version; + const void * clientInfo; + // Version 0. WKBundlePageGetContextMenuFromDefaultContextMenuCallback getContextMenuFromDefaultMenu; - - // This is actually about immediate actions; we should consider deprecating and renaming. - WKBundlePagePrepareForActionMenuCallback prepareForActionMenu; -} WKBundlePageContextMenuClientV1; +} WKBundlePageContextMenuClient WK_DEPRECATED("Use an explicit versioned struct instead"); #endif // WKBundlePageContextMenuClient_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageDiagnosticLoggingClient.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageDiagnosticLoggingClient.h index 3925f1035..f0dc04139 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageDiagnosticLoggingClient.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageDiagnosticLoggingClient.h @@ -26,13 +26,9 @@ #ifndef WKBundlePageDiagnosticLoggingClient_h #define WKBundlePageDiagnosticLoggingClient_h -#include <WebKit/WKBase.h> -#include <WebKit/WKDiagnosticLoggingResultType.h> +#include <WebKit2/WKBase.h> typedef void (*WKBundlePageDiagnosticLoggingCallback)(WKBundlePageRef page, WKStringRef message, WKStringRef description, WKStringRef success, const void* clientInfo); -typedef void (*WKBundlePageLogDiagnosticMessageCallback)(WKBundlePageRef page, WKStringRef message, WKStringRef description, const void* clientInfo); -typedef void (*WKBundlePageLogDiagnosticMessageWithResultCallback)(WKBundlePageRef page, WKStringRef message, WKStringRef description, WKDiagnosticLoggingResultType result, const void* clientInfo); -typedef void (*WKBundlePageLogDiagnosticMessageWithValueCallback)(WKBundlePageRef page, WKStringRef message, WKStringRef description, WKStringRef value, const void* clientInfo); typedef struct WKBundlePageDiagnosticLoggingClientBase { int version; @@ -46,16 +42,13 @@ typedef struct WKBundlePageDiagnosticLoggingClientV0 { WKBundlePageDiagnosticLoggingCallback logDiagnosticMessage; } WKBundlePageDiagnosticLoggingClientV0; -typedef struct WKBundlePageDiagnosticLoggingClientV1 { - WKBundlePageDiagnosticLoggingClientBase base; +enum { kWKBundlePageDiagnosticLoggingClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 0 }; +typedef struct WKBundlePageDiagnosticLoggingClient { + int version; + const void * clientInfo; // Version 0. - WKBundlePageDiagnosticLoggingCallback logDiagnosticMessageDeprecated; - - // Version 1. - WKBundlePageLogDiagnosticMessageCallback logDiagnosticMessage; - WKBundlePageLogDiagnosticMessageWithResultCallback logDiagnosticMessageWithResult; - WKBundlePageLogDiagnosticMessageWithValueCallback logDiagnosticMessageWithValue; -} WKBundlePageDiagnosticLoggingClientV1; + WKBundlePageDiagnosticLoggingCallback logDiagnosticMessage; +} WKBundlePageDiagnosticLoggingClient WK_DEPRECATED("Use an explicit versioned struct instead"); #endif // WKBundlePageDiagnosticLoggingClient_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageEditorClient.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageEditorClient.h index 998e3e8da..570d4e6f2 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageEditorClient.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageEditorClient.h @@ -26,7 +26,7 @@ #ifndef WKBundlePageEditorClient_h #define WKBundlePageEditorClient_h -#include <WebKit/WKBase.h> +#include <WebKit2/WKBase.h> enum { kWKInsertActionTyped = 0, @@ -114,4 +114,28 @@ typedef struct WKBundlePageEditorClientV1 { WKBundlePageDidWriteToPasteboard didWriteToPasteboard; } WKBundlePageEditorClientV1; +enum { kWKBundlePageEditorClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 1 }; +typedef struct WKBundlePageEditorClient { + int version; + const void * clientInfo; + + // Version 0. + WKBundlePageShouldBeginEditingCallback shouldBeginEditing; + WKBundlePageShouldEndEditingCallback shouldEndEditing; + WKBundlePageShouldInsertNodeCallback shouldInsertNode; + WKBundlePageShouldInsertTextCallback shouldInsertText; + WKBundlePageShouldDeleteRangeCallback shouldDeleteRange; + WKBundlePageShouldChangeSelectedRange shouldChangeSelectedRange; + WKBundlePageShouldApplyStyle shouldApplyStyle; + WKBundlePageEditingNotification didBeginEditing; + WKBundlePageEditingNotification didEndEditing; + WKBundlePageEditingNotification didChange; + WKBundlePageEditingNotification didChangeSelection; + + // Version 1. + WKBundlePageWillWriteToPasteboard willWriteToPasteboard; + WKBundlePageGetPasteboardDataForRange getPasteboardDataForRange; + WKBundlePageDidWriteToPasteboard didWriteToPasteboard; +} WKBundlePageEditorClient WK_DEPRECATED("Use an explicit versioned struct instead"); + #endif // WKBundlePageEditorClient_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageFormClient.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageFormClient.h index 3fc33b98d..5bd3ed428 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageFormClient.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageFormClient.h @@ -26,8 +26,7 @@ #ifndef WKBundlePageFormClient_h #define WKBundlePageFormClient_h -#include <WebKit/WKBase.h> -#include <WebKit/WKBundlePageEditorClient.h> +#include <WebKit2/WKBase.h> typedef void (*WKBundlePageTextFieldDidBeginEditingCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKBundleFrameRef frame, const void* clientInfo); typedef void (*WKBundlePageTextFieldDidEndEditingCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKBundleFrameRef frame, const void* clientInfo); @@ -92,4 +91,26 @@ typedef struct WKBundlePageFormClientV2 { WKBundlePageDidAssociateFormControlsCallback didAssociateFormControls; } WKBundlePageFormClientV2; +enum { kWKBundlePageFormClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 2 }; +typedef struct WKBundlePageFormClient { + int version; + const void * clientInfo; + + // Version 0. + WKBundlePageTextFieldDidBeginEditingCallback textFieldDidBeginEditing; + WKBundlePageTextFieldDidEndEditingCallback textFieldDidEndEditing; + WKBundlePageTextDidChangeInTextFieldCallback textDidChangeInTextField; + WKBundlePageTextDidChangeInTextAreaCallback textDidChangeInTextArea; + WKBundlePageShouldPerformActionInTextFieldCallback shouldPerformActionInTextField; + WKBundlePageWillSubmitFormCallback willSubmitForm; + + // Version 1. + WKBundlePageWillSendSubmitEventCallback willSendSubmitEvent; + + // version 2. + WKBundlePageDidFocusTextFieldCallback didFocusTextField; + WKBundlePageShouldNotifyOnFormChangesCallback shouldNotifyOnFormChanges; + WKBundlePageDidAssociateFormControlsCallback didAssociateFormControls; +} WKBundlePageFormClient WK_DEPRECATED("Use an explicit versioned struct instead"); + #endif // WKBundlePageFormClient_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageFullScreenClient.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageFullScreenClient.h index 687fb122b..38fe5d38c 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageFullScreenClient.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageFullScreenClient.h @@ -26,8 +26,8 @@ #ifndef WKBundlePageFullScreenClient_h #define WKBundlePageFullScreenClient_h -#include <WebKit/WKBase.h> -#include <WebKit/WKGeometry.h> +#include <WebKit2/WKBase.h> +#include <WebKit2/WKGeometry.h> typedef bool (*WKBundlePageSupportsFullScreen)(WKBundlePageRef page, WKFullScreenKeyboardRequestType requestType); typedef void (*WKBundlePageEnterFullScreenForElement)(WKBundlePageRef page, WKBundleNodeHandleRef element); @@ -64,4 +64,20 @@ typedef struct WKBundlePageFullScreenClientV1 { WKBundlePageCloseFullScreen closeFullScreen; } WKBundlePageFullScreenClientV1; +enum { kWKBundlePageFullScreenClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 1 }; +typedef struct WKBundlePageFullScreenClient { + int version; + const void * clientInfo; + + // Version 0: + WKBundlePageSupportsFullScreen supportsFullScreen; + WKBundlePageEnterFullScreenForElement enterFullScreenForElement; + WKBundlePageExitFullScreenForElement exitFullScreenForElement; + + // Version 1: + WKBundlePageBeganEnterFullScreen beganEnterFullScreen; + WKBundlePageBeganExitFullScreen beganExitFullScreen; + WKBundlePageCloseFullScreen closeFullScreen; +} WKBundlePageFullScreenClient WK_DEPRECATED("Use an explicit versioned struct instead"); + #endif // WKBundlePageFullScreenClient_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageGroup.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageGroup.h index 2438943b8..e0bf64525 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageGroup.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageGroup.h @@ -26,7 +26,7 @@ #ifndef WKBundlePageGroup_h #define WKBundlePageGroup_h -#include <WebKit/WKBase.h> +#include <WebKit2/WKBase.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageLoaderClient.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageLoaderClient.h index ee142dedf..0224a6f7b 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageLoaderClient.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageLoaderClient.h @@ -26,8 +26,8 @@ #ifndef WKBundlePageLoaderClient_h #define WKBundlePageLoaderClient_h -#include <WebKit/WKBase.h> -#include <WebKit/WKPageLoadTypes.h> +#include <WebKit2/WKBase.h> +#include <WebKit2/WKPageLoadTypes.h> typedef void (*WKBundlePageDidStartProvisionalLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); typedef void (*WKBundlePageDidReceiveServerRedirectForProvisionalLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); @@ -61,7 +61,7 @@ typedef void (*WKBundlePageDidLayoutCallback)(WKBundlePageRef page, WKLayoutMile typedef void (*WKBundlePageFeaturesUsedInPageCallback)(WKBundlePageRef page, WKArrayRef featureStrings, const void *clientInfo); typedef void (*WKBundlePageWillLoadURLRequestCallback)(WKBundlePageRef page, WKURLRequestRef request, WKTypeRef userData, const void *clientInfo); typedef void (*WKBundlePageWillLoadDataRequestCallback)(WKBundlePageRef page, WKURLRequestRef request, WKDataRef data, WKStringRef MIMEType, WKStringRef encodingName, WKURLRef unreachableURL, WKTypeRef userData, const void *clientInfo); -typedef WKStringRef (*WKBundlePageUserAgentForURLCallback)(WKBundleFrameRef frame, WKURLRef url, const void *clientInfo); +typedef void (*WKBundlePageWillDestroyFrame)(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo); typedef struct WKBundlePageLoaderClientBase { int version; @@ -403,12 +403,14 @@ typedef struct WKBundlePageLoaderClientV7 { WKBundlePageWillLoadDataRequestCallback willLoadDataRequest; // Version 7 - void * willDestroyFrame_unavailable; + WKBundlePageWillDestroyFrame willDestroyFrame; } WKBundlePageLoaderClientV7; -typedef struct WKBundlePageLoaderClientV8 { - WKBundlePageLoaderClientBase base; - +enum { kWKBundlePageLoaderClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 7 }; +typedef struct WKBundlePageLoaderClient { + int version; + const void * clientInfo; + // Version 0. WKBundlePageDidStartProvisionalLoadForFrameCallback didStartProvisionalLoadForFrame; WKBundlePageDidReceiveServerRedirectForProvisionalLoadForFrameCallback didReceiveServerRedirectForProvisionalLoadForFrame; @@ -428,7 +430,7 @@ typedef struct WKBundlePageLoaderClientV8 { WKBundlePageDidCancelClientRedirectForFrameCallback didCancelClientRedirectForFrame; WKBundlePageWillPerformClientRedirectForFrameCallback willPerformClientRedirectForFrame; WKBundlePageDidHandleOnloadEventsForFrameCallback didHandleOnloadEventsForFrame; - + // Version 1. WKBundlePageDidLayoutForFrameCallback didLayoutForFrame; void * didNewFirstVisuallyNonEmptyLayout_unavailable; @@ -442,26 +444,23 @@ typedef struct WKBundlePageLoaderClientV8 { // Version 2 WKBundlePageDidFinishProgressCallback didFinishProgress; WKBundlePageShouldForceUniversalAccessFromLocalURLCallback shouldForceUniversalAccessFromLocalURL; - + // Version 3 void * didReceiveIntentForFrame_unavailable; void * registerIntentServiceForFrame_unavailable; - + // Version 4 WKBundlePageDidLayoutCallback didLayout; - + // Version 5 WKBundlePageFeaturesUsedInPageCallback featuresUsedInPage; // Version 6 WKBundlePageWillLoadURLRequestCallback willLoadURLRequest; WKBundlePageWillLoadDataRequestCallback willLoadDataRequest; - + // Version 7 - void * willDestroyFrame_unavailable; - - // Version 8 - WKBundlePageUserAgentForURLCallback userAgentForURL; -} WKBundlePageLoaderClientV8; + WKBundlePageWillDestroyFrame willDestroyFrame; +} WKBundlePageLoaderClient WK_DEPRECATED("Use an explicit versioned struct instead"); #endif // WKBundlePageLoaderClient_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp index fc6b635e9..bba8626a5 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp @@ -27,24 +27,15 @@ #include "WKBundlePageOverlay.h" #include "APIClient.h" -#include "InjectedBundleRangeHandle.h" +#include "PageOverlay.h" #include "WKAPICast.h" -#include "WKArray.h" #include "WKBundleAPICast.h" -#include "WKNumber.h" -#include "WKRetainPtr.h" -#include "WKSharedAPICast.h" -#include "WKStringPrivate.h" -#include "WebPage.h" #include <WebCore/GraphicsContext.h> -#include <WebCore/PageOverlay.h> -#include <WebCore/PlatformMouseEvent.h> -#include <WebKit/WebPageOverlay.h> namespace API { template<> struct ClientTraits<WKBundlePageOverlayClientBase> { - typedef std::tuple<WKBundlePageOverlayClientV0, WKBundlePageOverlayClientV1> Versions; + typedef std::tuple<WKBundlePageOverlayClientV0> Versions; }; template<> struct ClientTraits<WKBundlePageOverlayAccessibilityClientBase> { @@ -56,7 +47,7 @@ template<> struct ClientTraits<WKBundlePageOverlayAccessibilityClientBase> { using namespace WebCore; using namespace WebKit; -class PageOverlayClientImpl : API::Client<WKBundlePageOverlayClientBase>, public WebPageOverlay::Client { +class PageOverlayClientImpl : API::Client<WKBundlePageOverlayClientBase>, public PageOverlay::Client { public: explicit PageOverlayClientImpl(WKBundlePageOverlayClientBase* client) { @@ -69,149 +60,83 @@ public: } private: - // WebPageOverlay::Client. - virtual void pageOverlayDestroyed(WebPageOverlay&) override + // PageOverlay::Client. + virtual void pageOverlayDestroyed(PageOverlay*) { delete this; } - virtual void willMoveToPage(WebPageOverlay& pageOverlay, WebPage* page) override + virtual void willMoveToWebPage(PageOverlay* pageOverlay, WebPage* page) { if (!m_client.willMoveToPage) return; - m_client.willMoveToPage(toAPI(&pageOverlay), toAPI(page), m_client.base.clientInfo); + m_client.willMoveToPage(toAPI(pageOverlay), toAPI(page), m_client.base.clientInfo); } - virtual void didMoveToPage(WebPageOverlay& pageOverlay, WebPage* page) override + virtual void didMoveToWebPage(PageOverlay* pageOverlay, WebPage* page) { if (!m_client.didMoveToPage) return; - m_client.didMoveToPage(toAPI(&pageOverlay), toAPI(page), m_client.base.clientInfo); + m_client.didMoveToPage(toAPI(pageOverlay), toAPI(page), m_client.base.clientInfo); } - virtual void drawRect(WebPageOverlay& pageOverlay, GraphicsContext& graphicsContext, const IntRect& dirtyRect) override + virtual void drawRect(PageOverlay* pageOverlay, GraphicsContext& graphicsContext, const IntRect& dirtyRect) { if (!m_client.drawRect) return; - m_client.drawRect(toAPI(&pageOverlay), graphicsContext.platformContext(), toAPI(dirtyRect), m_client.base.clientInfo); + m_client.drawRect(toAPI(pageOverlay), graphicsContext.platformContext(), toAPI(dirtyRect), m_client.base.clientInfo); } - virtual bool mouseEvent(WebPageOverlay& pageOverlay, const PlatformMouseEvent& event) override + virtual bool mouseEvent(PageOverlay* pageOverlay, const WebMouseEvent& event) { switch (event.type()) { - case PlatformMouseEvent::Type::MousePressed: { + case WebEvent::MouseDown: { if (!m_client.mouseDown) return false; - return m_client.mouseDown(toAPI(&pageOverlay), toAPI(event.position()), toAPI(event.button()), m_client.base.clientInfo); + return m_client.mouseDown(toAPI(pageOverlay), toAPI(event.position()), toAPI(event.button()), m_client.base.clientInfo); } - case PlatformMouseEvent::Type::MouseReleased: { + case WebEvent::MouseUp: { if (!m_client.mouseUp) return false; - return m_client.mouseUp(toAPI(&pageOverlay), toAPI(event.position()), toAPI(event.button()), m_client.base.clientInfo); + return m_client.mouseUp(toAPI(pageOverlay), toAPI(event.position()), toAPI(event.button()), m_client.base.clientInfo); } - case PlatformMouseEvent::Type::MouseMoved: { - if (event.button() == MouseButton::NoButton) { + case WebEvent::MouseMove: { + if (event.button() == WebMouseEvent::NoButton) { if (!m_client.mouseMoved) return false; - return m_client.mouseMoved(toAPI(&pageOverlay), toAPI(event.position()), m_client.base.clientInfo); + return m_client.mouseMoved(toAPI(pageOverlay), toAPI(event.position()), m_client.base.clientInfo); } // This is a MouseMove event with a mouse button pressed. Call mouseDragged. if (!m_client.mouseDragged) return false; - return m_client.mouseDragged(toAPI(&pageOverlay), toAPI(event.position()), toAPI(event.button()), m_client.base.clientInfo); + return m_client.mouseDragged(toAPI(pageOverlay), toAPI(event.position()), toAPI(event.button()), m_client.base.clientInfo); } default: return false; } } - -#if PLATFORM(MAC) - virtual DDActionContext *actionContextForResultAtPoint(WebPageOverlay& pageOverlay, WebCore::FloatPoint location, RefPtr<WebCore::Range>& rangeHandle) override - { - if (m_client.actionContextForResultAtPoint) { - WKBundleRangeHandleRef apiRange = nullptr; - DDActionContext *actionContext = (DDActionContext *)m_client.actionContextForResultAtPoint(toAPI(&pageOverlay), WKPointMake(location.x(), location.y()), &apiRange, m_client.base.clientInfo); - - if (apiRange) - rangeHandle = toImpl(apiRange)->coreRange(); - - return actionContext; - } - - return nil; - } - - virtual void dataDetectorsDidPresentUI(WebPageOverlay& pageOverlay) override - { - if (!m_client.dataDetectorsDidPresentUI) - return; - - m_client.dataDetectorsDidPresentUI(toAPI(&pageOverlay), m_client.base.clientInfo); - } - - virtual void dataDetectorsDidChangeUI(WebPageOverlay& pageOverlay) override - { - if (!m_client.dataDetectorsDidChangeUI) - return; - - m_client.dataDetectorsDidChangeUI(toAPI(&pageOverlay), m_client.base.clientInfo); - } - - virtual void dataDetectorsDidHideUI(WebPageOverlay& pageOverlay) override - { - if (!m_client.dataDetectorsDidHideUI) - return; - - m_client.dataDetectorsDidHideUI(toAPI(&pageOverlay), m_client.base.clientInfo); - } -#endif // PLATFORM(MAC) - - virtual bool copyAccessibilityAttributeStringValueForPoint(WebPageOverlay& pageOverlay, String attribute, WebCore::FloatPoint parameter, String& value) override - { - if (!m_accessibilityClient.client().copyAccessibilityAttributeValue) - return false; - auto wkType = m_accessibilityClient.client().copyAccessibilityAttributeValue(toAPI(&pageOverlay), toCopiedAPI(attribute), WKPointCreate(WKPointMake(parameter.x(), parameter.y())), m_accessibilityClient.client().base.clientInfo); - if (toImpl(wkType)->type() != API::String::APIType) - return false; - value = toWTFString(static_cast<WKStringRef>(wkType)); - return true; - } - - virtual bool copyAccessibilityAttributeBoolValueForPoint(WebPageOverlay& pageOverlay, String attribute, WebCore::FloatPoint parameter, bool& value) override + + virtual WKTypeRef copyAccessibilityAttributeValue(PageOverlay* pageOverlay, WKStringRef attribute, WKTypeRef parameter) { if (!m_accessibilityClient.client().copyAccessibilityAttributeValue) - return false; - auto wkType = m_accessibilityClient.client().copyAccessibilityAttributeValue(toAPI(&pageOverlay), toCopiedAPI(attribute), WKPointCreate(WKPointMake(parameter.x(), parameter.y())), m_accessibilityClient.client().base.clientInfo); - if (toImpl(wkType)->type() != API::Boolean::APIType) - return false; - value = WKBooleanGetValue(static_cast<WKBooleanRef>(wkType)); - return true; + return 0; + return m_accessibilityClient.client().copyAccessibilityAttributeValue(toAPI(pageOverlay), attribute, parameter, m_accessibilityClient.client().base.clientInfo); } - virtual Vector<String> copyAccessibilityAttributeNames(WebPageOverlay& pageOverlay, bool paramerizedNames) override + virtual WKArrayRef copyAccessibilityAttributeNames(PageOverlay* pageOverlay, bool paramerizedNames) { - Vector<String> names; if (!m_accessibilityClient.client().copyAccessibilityAttributeNames) - return names; - auto wkNames = m_accessibilityClient.client().copyAccessibilityAttributeNames(toAPI(&pageOverlay), paramerizedNames, m_accessibilityClient.client().base.clientInfo); - - size_t count = WKArrayGetSize(wkNames); - for (size_t k = 0; k < count; k++) { - WKTypeRef item = WKArrayGetItemAtIndex(wkNames, k); - if (toImpl(item)->type() == API::String::APIType) - names.append(toWTFString(static_cast<WKStringRef>(item))); - } - - return names; + return 0; + return m_accessibilityClient.client().copyAccessibilityAttributeNames(toAPI(pageOverlay), paramerizedNames, m_accessibilityClient.client().base.clientInfo); } API::Client<WKBundlePageOverlayAccessibilityClientBase> m_accessibilityClient; @@ -219,18 +144,25 @@ private: WKTypeID WKBundlePageOverlayGetTypeID() { - return toAPI(WebPageOverlay::APIType); + return toAPI(PageOverlay::APIType); } WKBundlePageOverlayRef WKBundlePageOverlayCreate(WKBundlePageOverlayClientBase* wkClient) { + if (wkClient && wkClient->version) + return 0; + auto clientImpl = std::make_unique<PageOverlayClientImpl>(wkClient); - return toAPI(&WebPageOverlay::create(WTFMove(clientImpl)).leakRef()); + + // FIXME: Looks like this leaks the clientImpl. + return toAPI(PageOverlay::create(clientImpl.release()).leakRef()); } void WKBundlePageOverlaySetAccessibilityClient(WKBundlePageOverlayRef bundlePageOverlayRef, WKBundlePageOverlayAccessibilityClientBase* client) { - static_cast<PageOverlayClientImpl&>(toImpl(bundlePageOverlayRef)->client()).setAccessibilityClient(client); + if (client && client->version) + return; + static_cast<PageOverlayClientImpl*>(toImpl(bundlePageOverlayRef)->client())->setAccessibilityClient(client); } void WKBundlePageOverlaySetNeedsDisplay(WKBundlePageOverlayRef bundlePageOverlayRef, WKRect rect) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.h index ae76a5f77..c96bb4cf3 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.h @@ -26,9 +26,9 @@ #ifndef WKBundlePageOverlay_h #define WKBundlePageOverlay_h -#include <WebKit/WKBase.h> -#include <WebKit/WKEvent.h> -#include <WebKit/WKGeometry.h> +#include <WebKit2/WKBase.h> +#include <WebKit2/WKEvent.h> +#include <WebKit2/WKGeometry.h> #ifndef __cplusplus #include <stdbool.h> @@ -49,11 +49,6 @@ typedef bool (*WKBundlePageOverlayMouseUpCallback)(WKBundlePageOverlayRef pageOv typedef bool (*WKBundlePageOverlayMouseMovedCallback)(WKBundlePageOverlayRef pageOverlay, WKPoint position, const void* clientInfo); typedef bool (*WKBundlePageOverlayMouseDraggedCallback)(WKBundlePageOverlayRef pageOverlay, WKPoint position, WKEventMouseButton mouseButton, const void* clientInfo); -typedef void* (*WKBundlePageOverlayActionContextForResultAtPointCallback)(WKBundlePageOverlayRef pageOverlay, WKPoint position, WKBundleRangeHandleRef* rangeHandle, const void* clientInfo); -typedef void (*WKBundlePageOverlayDataDetectorsDidPresentUI)(WKBundlePageOverlayRef pageOverlay, const void* clientInfo); -typedef void (*WKBundlePageOverlayDataDetectorsDidChangeUI)(WKBundlePageOverlayRef pageOverlay, const void* clientInfo); -typedef void (*WKBundlePageOverlayDataDetectorsDidHideUI)(WKBundlePageOverlayRef pageOverlay, const void* clientInfo); - typedef struct WKBundlePageOverlayClientBase { int version; const void * clientInfo; @@ -62,6 +57,7 @@ typedef struct WKBundlePageOverlayClientBase { typedef struct WKBundlePageOverlayClientV0 { WKBundlePageOverlayClientBase base; + // Version 0. WKBundlePageOverlayWillMoveToPageCallback willMoveToPage; WKBundlePageOverlayDidMoveToPageCallback didMoveToPage; WKBundlePageOverlayDrawRectCallback drawRect; @@ -71,9 +67,12 @@ typedef struct WKBundlePageOverlayClientV0 { WKBundlePageOverlayMouseDraggedCallback mouseDragged; } WKBundlePageOverlayClientV0; -typedef struct WKBundlePageOverlayClientV1 { - WKBundlePageOverlayClientBase base; +enum { kWKBundlePageOverlayClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 0 }; +typedef struct WKBundlePageOverlayClient { + int version; + const void * clientInfo; + // Version 0. WKBundlePageOverlayWillMoveToPageCallback willMoveToPage; WKBundlePageOverlayDidMoveToPageCallback didMoveToPage; WKBundlePageOverlayDrawRectCallback drawRect; @@ -81,12 +80,7 @@ typedef struct WKBundlePageOverlayClientV1 { WKBundlePageOverlayMouseUpCallback mouseUp; WKBundlePageOverlayMouseMovedCallback mouseMoved; WKBundlePageOverlayMouseDraggedCallback mouseDragged; - - WKBundlePageOverlayActionContextForResultAtPointCallback actionContextForResultAtPoint; - WKBundlePageOverlayDataDetectorsDidPresentUI dataDetectorsDidPresentUI; - WKBundlePageOverlayDataDetectorsDidChangeUI dataDetectorsDidChangeUI; - WKBundlePageOverlayDataDetectorsDidHideUI dataDetectorsDidHideUI; -} WKBundlePageOverlayClientV1; +} WKBundlePageOverlayClient WK_DEPRECATED("Use an explicit versioned struct instead"); typedef WKTypeRef (*WKAccessibilityAttributeValueCallback)(WKBundlePageOverlayRef pageOverlay, WKStringRef attribute, WKTypeRef parameter, const void* clientInfo); typedef WKArrayRef (*WKAccessibilityAttributeNamesCallback)(WKBundlePageOverlayRef pageOverlay, bool parameterizedNames, const void* clientInfo); @@ -104,6 +98,16 @@ typedef struct WKBundlePageOverlayAccessibilityClientV0 { WKAccessibilityAttributeNamesCallback copyAccessibilityAttributeNames; } WKBundlePageOverlayAccessibilityClientV0; +enum { kWKBundlePageOverlayAccessibilityClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 0 }; +typedef struct WKBundlePageOverlayAccessibilityClient { + int version; + const void * clientInfo; + + // Version 0. + WKAccessibilityAttributeValueCallback copyAccessibilityAttributeValue; + WKAccessibilityAttributeNamesCallback copyAccessibilityAttributeNames; +} WKBundlePageOverlayAccessibilityClient WK_DEPRECATED("Use an explicit versioned struct instead"); + WK_EXPORT WKTypeID WKBundlePageOverlayGetTypeID(); WK_EXPORT WKBundlePageOverlayRef WKBundlePageOverlayCreate(WKBundlePageOverlayClientBase* client); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePolicyClient.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePolicyClient.h index cb2ef16b3..a421c6742 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePolicyClient.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePolicyClient.h @@ -26,7 +26,7 @@ #ifndef WKBundlePagePolicyClient_h #define WKBundlePagePolicyClient_h -#include <WebKit/WKBase.h> +#include <WebKit2/WKBase.h> enum { WKBundlePagePolicyActionPassThrough, @@ -54,4 +54,16 @@ typedef struct WKBundlePagePolicyClientV0 { WKBundlePageUnableToImplementPolicyCallback unableToImplementPolicy; } WKBundlePagePolicyClientV0; +enum { kWKBundlePagePolicyClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 0 }; +typedef struct WKBundlePagePolicyClient { + int version; + const void * clientInfo; + + // Version 0. + WKBundlePageDecidePolicyForNavigationActionCallback decidePolicyForNavigationAction; + WKBundlePageDecidePolicyForNewWindowActionCallback decidePolicyForNewWindowAction; + WKBundlePageDecidePolicyForResponseCallback decidePolicyForResponse; + WKBundlePageUnableToImplementPolicyCallback unableToImplementPolicy; +} WKBundlePagePolicyClient WK_DEPRECATED("Use an explicit versioned struct instead"); + #endif // WKBundlePagePolicyClient_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h index 6e00abb54..2461c3826 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h @@ -26,11 +26,9 @@ #ifndef WKBundlePagePrivate_h #define WKBundlePagePrivate_h -#include <WebKit/WKBase.h> -#include <WebKit/WKEvent.h> -#include <WebKit/WKGeometry.h> -#include <WebKit/WKUserContentInjectedFrames.h> -#include <WebKit/WKUserScriptInjectionTime.h> +#include <WebKit2/WKBase.h> +#include <WebKit2/WKEvent.h> +#include <WebKit2/WKGeometry.h> #ifdef __cplusplus extern "C" { @@ -82,9 +80,6 @@ WK_EXPORT bool WKBundlePageCanShowMIMEType(WKBundlePageRef, WKStringRef mimeType WK_EXPORT void* WKAccessibilityRootObject(WKBundlePageRef); WK_EXPORT void* WKAccessibilityFocusedObject(WKBundlePageRef); -WK_EXPORT void WKAccessibilityEnableEnhancedAccessibility(bool); -WK_EXPORT bool WKAccessibilityEnhancedAccessibilityEnabled(); - WK_EXPORT WKStringRef WKBundlePageCopyContextMenuItemTitle(WKContextMenuItemRef); WK_EXPORT void WKBundlePageClickMenuItem(WKBundlePageRef, WKContextMenuItemRef); WK_EXPORT WKArrayRef WKBundlePageCopyContextMenuItems(WKBundlePageRef); @@ -95,24 +90,6 @@ typedef unsigned WKRenderingSuppressionToken; WK_EXPORT WKRenderingSuppressionToken WKBundlePageExtendIncrementalRenderingSuppression(WKBundlePageRef); WK_EXPORT void WKBundlePageStopExtendingIncrementalRenderingSuppression(WKBundlePageRef, WKRenderingSuppressionToken); -// UserContent API (compatible with Modern API, for WKTR) -WK_EXPORT void WKBundlePageAddUserScript(WKBundlePageRef page, WKStringRef source, _WKUserScriptInjectionTime injectionTime, WKUserContentInjectedFrames injectedFrames); -WK_EXPORT void WKBundlePageAddUserStyleSheet(WKBundlePageRef page, WKStringRef source, WKUserContentInjectedFrames injectedFrames); -WK_EXPORT void WKBundlePageRemoveAllUserContent(WKBundlePageRef page); - -// Application Cache API, for WKTR. -WK_EXPORT void WKBundlePageClearApplicationCache(WKBundlePageRef page); -WK_EXPORT void WKBundlePageClearApplicationCacheForOrigin(WKBundlePageRef page, WKStringRef origin); -WK_EXPORT void WKBundlePageSetAppCacheMaximumSize(WKBundlePageRef page, uint64_t size); -WK_EXPORT uint64_t WKBundlePageGetAppCacheUsageForOrigin(WKBundlePageRef page, WKStringRef origin); -WK_EXPORT void WKBundlePageSetApplicationCacheOriginQuota(WKBundlePageRef page, WKStringRef origin, uint64_t bytes); -WK_EXPORT void WKBundlePageResetApplicationCacheOriginQuota(WKBundlePageRef page, WKStringRef origin); -WK_EXPORT WKArrayRef WKBundlePageCopyOriginsWithApplicationCache(WKBundlePageRef page); - -#if TARGET_OS_IPHONE -WK_EXPORT void WKBundlePageSetUseTestingViewportConfiguration(WKBundlePageRef, bool); -#endif - #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageResourceLoadClient.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageResourceLoadClient.h index fee6cc2e7..2acde682c 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageResourceLoadClient.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageResourceLoadClient.h @@ -26,7 +26,7 @@ #ifndef WKBundlePageResourceLoadClient_h #define WKBundlePageResourceLoadClient_h -#include <WebKit/WKBase.h> +#include <WebKit2/WKBase.h> typedef void (*WKBundlePageDidInitiateLoadForResourceCallback)(WKBundlePageRef, WKBundleFrameRef, uint64_t resourceIdentifier, WKURLRequestRef, bool pageIsProvisionallyLoading, const void* clientInfo); typedef WKURLRequestRef (*WKBundlePageWillSendRequestForFrameCallback)(WKBundlePageRef, WKBundleFrameRef, uint64_t resourceIdentifier, WKURLRequestRef, WKURLResponseRef redirectResponse, const void *clientInfo); @@ -76,4 +76,25 @@ typedef struct WKBundlePageResourceLoadClientV1 { WKBundlePageShouldUseCredentialStorageCallback shouldUseCredentialStorage; } WKBundlePageResourceLoadClientV1; +enum { kWKBundlePageResourceLoadClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 1 }; +typedef struct WKBundlePageResourceLoadClient { + int version; + const void * clientInfo; + + // Version 0. + WKBundlePageDidInitiateLoadForResourceCallback didInitiateLoadForResource; + + // willSendRequestForFrame is supposed to return a retained reference to the URL request. + WKBundlePageWillSendRequestForFrameCallback willSendRequestForFrame; + + WKBundlePageDidReceiveResponseForResourceCallback didReceiveResponseForResource; + WKBundlePageDidReceiveContentLengthForResourceCallback didReceiveContentLengthForResource; + WKBundlePageDidFinishLoadForResourceCallback didFinishLoadForResource; + WKBundlePageDidFailLoadForResourceCallback didFailLoadForResource; + + // Version 1. + WKBundlePageShouldCacheResponseCallback shouldCacheResponse; + WKBundlePageShouldUseCredentialStorageCallback shouldUseCredentialStorage; +} WKBundlePageResourceLoadClient WK_DEPRECATED("Use an explicit versioned struct instead"); + #endif // WKBundlePageResourceLoadClient_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageUIClient.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageUIClient.h index e07a6b2e6..e29656eb7 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageUIClient.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageUIClient.h @@ -26,8 +26,8 @@ #ifndef WKBundlePageUIClient_h #define WKBundlePageUIClient_h -#include <WebKit/WKBase.h> -#include <WebKit/WKEvent.h> +#include <WebKit2/WKBase.h> +#include <WebKit2/WKEvent.h> enum { WKBundlePageUIElementVisibilityUnknown, @@ -54,7 +54,6 @@ typedef WKStringRef (*WKBundlePagePlugInCreateStartLabelTitleCallback)(WKStringR typedef WKStringRef (*WKBundlePagePlugInCreateStartLabelSubtitleCallback)(WKStringRef mimeType, const void *clientInfo); typedef WKStringRef (*WKBundlePagePlugInCreateExtraStyleSheetCallback)(const void *clientInfo); typedef WKStringRef (*WKBundlePagePlugInCreateExtraScriptCallback)(const void *clientInfo); -typedef void (*WKBundlePageDidClickAutoFillButtonCallback)(WKBundlePageRef page, WKBundleNodeHandleRef inputElement, WKTypeRef* userData, const void *clientInfo); typedef struct WKBundlePageUIClientBase { int version; @@ -134,8 +133,10 @@ typedef struct WKBundlePageUIClientV2 { WKBundlePagePlugInCreateExtraScriptCallback createPlugInExtraScript; } WKBundlePageUIClientV2; -typedef struct WKBundlePageUIClientV3 { - WKBundlePageUIClientBase base; +enum { kWKBundlePageUIClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 2 }; +typedef struct WKBundlePageUIClient { + int version; + const void * clientInfo; // Version 0. WKBundlePageWillAddMessageToConsoleCallback willAddMessageToConsole; @@ -162,13 +163,6 @@ typedef struct WKBundlePageUIClientV3 { WKBundlePagePlugInCreateStartLabelSubtitleCallback createPlugInStartLabelSubtitle; WKBundlePagePlugInCreateExtraStyleSheetCallback createPlugInExtraStyleSheet; WKBundlePagePlugInCreateExtraScriptCallback createPlugInExtraScript; - - // Version 3. - void* unused3; - void* unused4; - void* unused5; - - WKBundlePageDidClickAutoFillButtonCallback didClickAutoFillButton; -} WKBundlePageUIClientV3; +} WKBundlePageUIClient WK_DEPRECATED("Use an explicit versioned struct instead"); #endif // WKBundlePageUIClient_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h index 205e72ab9..f7d7e25dc 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h @@ -26,21 +26,26 @@ #ifndef WKBundlePrivate_h #define WKBundlePrivate_h -#include <WebKit/WKBase.h> +#include <WebKit2/WKBase.h> #ifndef __cplusplus #include <stdbool.h> #endif #include <JavaScriptCore/JSBase.h> -#include <WebKit/WKUserContentInjectedFrames.h> -#include <WebKit/WKUserScriptInjectionTime.h> +#include <WebKit2/WKUserContentInjectedFrames.h> +#include <WebKit2/WKUserScriptInjectionTime.h> #ifdef __cplusplus extern "C" { #endif -// TestRunner only SPIs. +// TestRunner only SPI +WK_EXPORT void WKBundleSetShouldTrackVisitedLinks(WKBundleRef bundle, bool shouldTrackVisitedLinks); +WK_EXPORT void WKBundleSetAlwaysAcceptCookies(WKBundleRef bundle, bool); +WK_EXPORT void WKBundleRemoveAllVisitedLinks(WKBundleRef bundle); +WK_EXPORT void WKBundleActivateMacFontAscentHack(WKBundleRef bundle); +WK_EXPORT void WKBundleSetCacheModel(WKBundleRef bundle, uint32_t cacheModel); // Will make WebProcess ignore this preference until a preferences change notification, only for WebKitTestRunner use. WK_EXPORT void WKBundleOverrideBoolPreferenceForTestRunner(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, WKStringRef preference, bool enabled); WK_EXPORT void WKBundleSetAllowUniversalAccessFromFileURLs(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled); @@ -68,7 +73,7 @@ WK_EXPORT WKDataRef WKBundleCreateWKDataFromUInt8Array(WKBundleRef bundle, JSCon WK_EXPORT void WKBundleSetAsynchronousSpellCheckingEnabled(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, bool enabled); // UserContent API -WK_EXPORT void WKBundleAddUserScript(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, WKBundleScriptWorldRef scriptWorld, WKStringRef source, WKURLRef url, WKArrayRef whitelist, WKArrayRef blacklist, _WKUserScriptInjectionTime injectionTime, WKUserContentInjectedFrames injectedFrames); +WK_EXPORT void WKBundleAddUserScript(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, WKBundleScriptWorldRef scriptWorld, WKStringRef source, WKURLRef url, WKArrayRef whitelist, WKArrayRef blacklist, WKUserScriptInjectionTime injectionTime, WKUserContentInjectedFrames injectedFrames); WK_EXPORT void WKBundleAddUserStyleSheet(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, WKBundleScriptWorldRef scriptWorld, WKStringRef source, WKURLRef url, WKArrayRef whitelist, WKArrayRef blacklist, WKUserContentInjectedFrames injectedFrames); WK_EXPORT void WKBundleRemoveUserScript(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, WKBundleScriptWorldRef scriptWorld, WKURLRef url); WK_EXPORT void WKBundleRemoveUserStyleSheet(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, WKBundleScriptWorldRef scriptWorld, WKURLRef url); @@ -80,6 +85,15 @@ WK_EXPORT void WKBundleRemoveAllUserContent(WKBundleRef bundle, WKBundlePageGrou WK_EXPORT void WKBundleClearAllDatabases(WKBundleRef bundle); WK_EXPORT void WKBundleSetDatabaseQuota(WKBundleRef bundle, uint64_t); +// Application Cache API +WK_EXPORT void WKBundleClearApplicationCache(WKBundleRef bundle); +WK_EXPORT void WKBundleClearApplicationCacheForOrigin(WKBundleRef bundle, WKStringRef origin); +WK_EXPORT void WKBundleSetAppCacheMaximumSize(WKBundleRef bundle, uint64_t size); +WK_EXPORT uint64_t WKBundleGetAppCacheUsageForOrigin(WKBundleRef bundle, WKStringRef origin); +WK_EXPORT void WKBundleSetApplicationCacheOriginQuota(WKBundleRef bundle, WKStringRef origin, uint64_t bytes); +WK_EXPORT void WKBundleResetApplicationCacheOriginQuota(WKBundleRef bundle, WKStringRef origin); +WK_EXPORT WKArrayRef WKBundleCopyOriginsWithApplicationCache(WKBundleRef bundle); + // Garbage collection API WK_EXPORT void WKBundleGarbageCollectJavaScriptObjects(WKBundleRef bundle); WK_EXPORT void WKBundleGarbageCollectJavaScriptObjectsOnAlternateThreadForDebugging(WKBundleRef bundle, bool waitUntilDone); @@ -88,6 +102,10 @@ WK_EXPORT size_t WKBundleGetJavaScriptObjectsCount(WKBundleRef bundle); WK_EXPORT bool WKBundleIsProcessingUserGesture(WKBundleRef bundle); WK_EXPORT void WKBundleSetTabKeyCyclesThroughElements(WKBundleRef bundle, WKBundlePageRef page, bool enabled); +WK_EXPORT void WKBundleSetSerialLoadingEnabled(WKBundleRef bundle, bool enabled); +WK_EXPORT void WKBundleSetShadowDOMEnabled(WKBundleRef bundle, bool enabled); +WK_EXPORT void WKBundleSetSeamlessIFramesEnabled(WKBundleRef bundle, bool enabled); +WK_EXPORT void WKBundleDispatchPendingLoadRequests(WKBundleRef bundle); #ifdef __cplusplus } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.cpp index 73b88c134..fb2f7d05f 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.cpp @@ -30,8 +30,6 @@ #include "InjectedBundleRangeHandle.h" #include "WKAPICast.h" #include "WKBundleAPICast.h" -#include "WebImage.h" -#include <WebCore/IntRect.h> using namespace WebKit; @@ -45,15 +43,3 @@ WKBundleRangeHandleRef WKBundleRangeHandleCreate(JSContextRef contextRef, JSObje RefPtr<InjectedBundleRangeHandle> rangeHandle = InjectedBundleRangeHandle::getOrCreate(contextRef, objectRef); return toAPI(rangeHandle.release().leakRef()); } - -WKRect WKBundleRangeHandleGetBoundingRectInWindowCoordinates(WKBundleRangeHandleRef rangeHandleRef) -{ - WebCore::IntRect boundingRect = toImpl(rangeHandleRef)->boundingRectInWindowCoordinates(); - return WKRectMake(boundingRect.x(), boundingRect.y(), boundingRect.width(), boundingRect.height()); -} - -WKImageRef WKBundleRangeHandleCopySnapshotWithOptions(WKBundleRangeHandleRef rangeHandleRef, WKSnapshotOptions options) -{ - RefPtr<WebImage> image = toImpl(rangeHandleRef)->renderedImage(toSnapshotOptions(options)); - return toAPI(image.release().leakRef()); -} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.h index b3d542440..8d1d35928 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.h @@ -26,7 +26,7 @@ #ifndef WKBundleRangeHandle_h #define WKBundleRangeHandle_h -#include <WebKit/WKBase.h> +#include <WebKit2/WKBase.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandlePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandlePrivate.h index c6ab5bff2..54f845024 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandlePrivate.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandlePrivate.h @@ -27,9 +27,7 @@ #define WKBundleRangeHandlePrivate_h #include <JavaScriptCore/JavaScript.h> -#include <WebKit/WKBase.h> -#include <WebKit/WKGeometry.h> -#include <WebKit/WKImage.h> +#include <WebKit2/WKBase.h> #ifdef __cplusplus extern "C" { @@ -37,9 +35,6 @@ extern "C" { WK_EXPORT WKBundleRangeHandleRef WKBundleRangeHandleCreate(JSContextRef context, JSObjectRef object); -WK_EXPORT WKRect WKBundleRangeHandleGetBoundingRectInWindowCoordinates(WKBundleRangeHandleRef rangeHandle); -WK_EXPORT WKImageRef WKBundleRangeHandleCopySnapshotWithOptions(WKBundleRangeHandleRef rangeHandle, WKSnapshotOptions options); - #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp index 3ae871201..87ccf11e9 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp @@ -52,8 +52,3 @@ void WKBundleScriptWorldClearWrappers(WKBundleScriptWorldRef scriptWorldRef) { toImpl(scriptWorldRef)->clearWrappers(); } - -void WKBundleScriptWorldMakeAllShadowRootsOpen(WKBundleScriptWorldRef scriptWorldRef) -{ - toImpl(scriptWorldRef)->makeAllShadowRootsOpen(); -} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h index f1fb5d344..013cdc9a3 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h @@ -26,7 +26,7 @@ #ifndef WKBundleScriptWorld_h #define WKBundleScriptWorld_h -#include <WebKit/WKBase.h> +#include <WebKit2/WKBase.h> #ifdef __cplusplus extern "C" { @@ -37,7 +37,6 @@ WK_EXPORT WKTypeID WKBundleScriptWorldGetTypeID(); WK_EXPORT WKBundleScriptWorldRef WKBundleScriptWorldCreateWorld(); WK_EXPORT WKBundleScriptWorldRef WKBundleScriptWorldNormalWorld(); WK_EXPORT void WKBundleScriptWorldClearWrappers(WKBundleScriptWorldRef scriptWorld); -WK_EXPORT void WKBundleScriptWorldMakeAllShadowRootsOpen(WKBundleScriptWorldRef scriptWorld); #ifdef __cplusplus } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitConsoleMessage.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitConsoleMessage.cpp deleted file mode 100644 index 418e3ee28..000000000 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitConsoleMessage.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (C) 2015 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "config.h" -#include "WebKitConsoleMessage.h" - -#include "WebKitConsoleMessagePrivate.h" - -G_DEFINE_BOXED_TYPE(WebKitConsoleMessage, webkit_console_message, webkit_console_message_copy, webkit_console_message_free) - -/** - * webkit_console_message_copy: - * @console_message: a #WebKitConsoleMessage - * - * Make a copy of @console_message. - * - * Returns: (transfer full): A copy of passed in #WebKitConsoleMessage - * - * Since: 2.12 - */ -WebKitConsoleMessage* webkit_console_message_copy(WebKitConsoleMessage* consoleMessage) -{ - g_return_val_if_fail(consoleMessage, nullptr); - WebKitConsoleMessage* copy = static_cast<WebKitConsoleMessage*>(fastZeroedMalloc(sizeof(WebKitConsoleMessage))); - new (copy) WebKitConsoleMessage(consoleMessage); - return copy; -} - -/** - * webkit_console_message_free: - * @console_message: a #WebKitConsoleMessage - * - * Free the #WebKitConsoleMessage - * - * Since: 2.12 - */ -void webkit_console_message_free(WebKitConsoleMessage* consoleMessage) -{ - g_return_if_fail(consoleMessage); - consoleMessage->~WebKitConsoleMessage(); - fastFree(consoleMessage); -} - -/** - * webkit_console_message_get_source: - * @console_message: a #WebKitConsoleMessage - * - * Gets the source of a #WebKitConsoleMessage - * - * Returns: a #WebKitConsoleMessageSource indicating the source of @console_message - * - * Since: 2.12 - */ -WebKitConsoleMessageSource webkit_console_message_get_source(WebKitConsoleMessage* consoleMessage) -{ - g_return_val_if_fail(consoleMessage, WEBKIT_CONSOLE_MESSAGE_SOURCE_OTHER); - switch (consoleMessage->source) { - case JSC::MessageSource::JS: - return WEBKIT_CONSOLE_MESSAGE_SOURCE_JAVASCRIPT; - case JSC::MessageSource::Network: - return WEBKIT_CONSOLE_MESSAGE_SOURCE_NETWORK; - case JSC::MessageSource::ConsoleAPI: - return WEBKIT_CONSOLE_MESSAGE_SOURCE_CONSOLE_API; - case JSC::MessageSource::Security: - return WEBKIT_CONSOLE_MESSAGE_SOURCE_SECURITY; - case JSC::MessageSource::Other: - default: - break; - } - - return WEBKIT_CONSOLE_MESSAGE_SOURCE_OTHER; -} - -/** - * webkit_console_message_get_level: - * @console_message: a #WebKitConsoleMessage - * - * Gets the log level of a #WebKitConsoleMessage - * - * Returns: a #WebKitConsoleMessageLevel indicating the log level of @console_message - * - * Since: 2.12 - */ -WebKitConsoleMessageLevel webkit_console_message_get_level(WebKitConsoleMessage* consoleMessage) -{ - g_return_val_if_fail(consoleMessage, WEBKIT_CONSOLE_MESSAGE_LEVEL_LOG); - switch (consoleMessage->level) { - case JSC::MessageLevel::Log: - return WEBKIT_CONSOLE_MESSAGE_LEVEL_LOG; - case JSC::MessageLevel::Warning: - return WEBKIT_CONSOLE_MESSAGE_LEVEL_WARNING; - case JSC::MessageLevel::Error: - return WEBKIT_CONSOLE_MESSAGE_LEVEL_ERROR; - case JSC::MessageLevel::Debug: - return WEBKIT_CONSOLE_MESSAGE_LEVEL_DEBUG; - case JSC::MessageLevel::Info: - return WEBKIT_CONSOLE_MESSAGE_LEVEL_INFO; - } - - ASSERT_NOT_REACHED(); - return WEBKIT_CONSOLE_MESSAGE_LEVEL_LOG; -} - -/** - * webkit_console_message_get_text: - * @console_message: a #WebKitConsoleMessage - * - * Gets the text message of a #WebKitConsoleMessage - * - * Returns: the text message of @console_message - * - * Since: 2.12 - */ -const gchar* webkit_console_message_get_text(WebKitConsoleMessage* consoleMessage) -{ - g_return_val_if_fail(consoleMessage, nullptr); - return consoleMessage->message.data(); -} - -/** - * webkit_console_message_get_line: - * @console_message: a #WebKitConsoleMessage - * - * Gets the line number of a #WebKitConsoleMessage - * - * Returns: the line number of @console_message - * - * Since: 2.12 - */ -guint webkit_console_message_get_line(WebKitConsoleMessage* consoleMessage) -{ - g_return_val_if_fail(consoleMessage, 0); - return consoleMessage->lineNumber; -} - -/** - * webkit_console_message_get_source_id: - * @console_message: a #WebKitConsoleMessage - * - * Gets the source identifier of a #WebKitConsoleMessage - * - * Returns: the source identifier of @console_message - * - * Since: 2.12 - */ -const gchar* webkit_console_message_get_source_id(WebKitConsoleMessage* consoleMessage) -{ - g_return_val_if_fail(consoleMessage, nullptr); - return consoleMessage->sourceID.data(); -} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitConsoleMessage.h b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitConsoleMessage.h deleted file mode 100644 index cbfbcdf31..000000000 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitConsoleMessage.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2015 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#if !defined(__WEBKIT_WEB_EXTENSION_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit-web-extension.h> can be included directly." -#endif - -#ifndef WebKitConsoleMessage_h -#define WebKitConsoleMessage_h - -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_CONSOLE_MESSAGE (webkit_console_message_get_type()) - -/** - * WebKitConsoleMessageSource: - * @WEBKIT_CONSOLE_MESSAGE_SOURCE_JAVASCRIPT: Message produced by JavaScript. - * @WEBKIT_CONSOLE_MESSAGE_SOURCE_NETWORK: Network messages. - * @WEBKIT_CONSOLE_MESSAGE_SOURCE_CONSOLE_API: Messages produced by console API. - * @WEBKIT_CONSOLE_MESSAGE_SOURCE_SECURITY: Security messages. - * @WEBKIT_CONSOLE_MESSAGE_SOURCE_OTHER: Other messages. - * - * Enum values used to denote the various sources of console messages. - * - * Since: 2.12 - */ -typedef enum { - WEBKIT_CONSOLE_MESSAGE_SOURCE_JAVASCRIPT, - WEBKIT_CONSOLE_MESSAGE_SOURCE_NETWORK, - WEBKIT_CONSOLE_MESSAGE_SOURCE_CONSOLE_API, - WEBKIT_CONSOLE_MESSAGE_SOURCE_SECURITY, - WEBKIT_CONSOLE_MESSAGE_SOURCE_OTHER -} WebKitConsoleMessageSource; - -/** - * WebKitConsoleMessageLevel: - * @WEBKIT_CONSOLE_MESSAGE_LEVEL_INFO: Information message. - * @WEBKIT_CONSOLE_MESSAGE_LEVEL_LOG: Log message. - * @WEBKIT_CONSOLE_MESSAGE_LEVEL_WARNING: Warning message. - * @WEBKIT_CONSOLE_MESSAGE_LEVEL_ERROR: Error message. - * @WEBKIT_CONSOLE_MESSAGE_LEVEL_DEBUG: Debug message. - * - * Enum values used to denote the various levels of console messages. - * - * Since: 2.12 - */ -typedef enum { - WEBKIT_CONSOLE_MESSAGE_LEVEL_INFO, - WEBKIT_CONSOLE_MESSAGE_LEVEL_LOG, - WEBKIT_CONSOLE_MESSAGE_LEVEL_WARNING, - WEBKIT_CONSOLE_MESSAGE_LEVEL_ERROR, - WEBKIT_CONSOLE_MESSAGE_LEVEL_DEBUG -} WebKitConsoleMessageLevel; - -typedef struct _WebKitConsoleMessage WebKitConsoleMessage; - -WEBKIT_API GType -webkit_console_message_get_type (void); - -WEBKIT_API WebKitConsoleMessage * -webkit_console_message_copy (WebKitConsoleMessage *console_message); - -WEBKIT_API void -webkit_console_message_free (WebKitConsoleMessage *console_message); - -WEBKIT_API WebKitConsoleMessageSource -webkit_console_message_get_source (WebKitConsoleMessage *console_message); - -WEBKIT_API WebKitConsoleMessageLevel -webkit_console_message_get_level (WebKitConsoleMessage *console_message); - -WEBKIT_API const gchar * -webkit_console_message_get_text (WebKitConsoleMessage *console_message); - -WEBKIT_API guint -webkit_console_message_get_line (WebKitConsoleMessage *console_message); - -WEBKIT_API const gchar * -webkit_console_message_get_source_id (WebKitConsoleMessage *console_message); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitConsoleMessagePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitConsoleMessagePrivate.h deleted file mode 100644 index afad00549..000000000 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitConsoleMessagePrivate.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2015 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef WebKitConsoleMessagePrivate_h -#define WebKitConsoleMessagePrivate_h - -#include "WebKitConsoleMessage.h" -#include <runtime/ConsoleTypes.h> -#include <wtf/text/CString.h> -#include <wtf/text/WTFString.h> - -struct _WebKitConsoleMessage { - _WebKitConsoleMessage(JSC::MessageSource source, JSC::MessageLevel level, const String& message, unsigned lineNumber, const String& sourceID) - : source(source) - , level(level) - , message(message.utf8()) - , lineNumber(lineNumber) - , sourceID(sourceID.utf8()) - { - } - - _WebKitConsoleMessage(WebKitConsoleMessage* consoleMessage) - : source(consoleMessage->source) - , level(consoleMessage->level) - , message(consoleMessage->message) - , lineNumber(consoleMessage->lineNumber) - , sourceID(consoleMessage->sourceID) - { - } - - JSC::MessageSource source; - JSC::MessageLevel level; - CString message; - unsigned lineNumber; - CString sourceID; -}; - -#endif // WebKitConsoleMessagePrivate_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitFrame.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitFrame.cpp index d7b1bddac..1691587aa 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitFrame.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitFrame.cpp @@ -36,7 +36,7 @@ struct _WebKitFramePrivate { WEBKIT_DEFINE_TYPE(WebKitFrame, webkit_frame, G_TYPE_OBJECT) -static void webkit_frame_class_init(WebKitFrameClass*) +static void webkit_frame_class_init(WebKitFrameClass* klass) { } @@ -47,11 +47,6 @@ WebKitFrame* webkitFrameCreate(WebFrame* webFrame) return frame; } -WebFrame* webkitFrameGetWebFrame(WebKitFrame* frame) -{ - return frame->priv->webFrame.get(); -} - /** * webkit_frame_is_main_frame: * @frame: a #WebKitFrame diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitFramePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitFramePrivate.h index 81bc8ac40..3c7fab464 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitFramePrivate.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitFramePrivate.h @@ -24,6 +24,5 @@ #include "WebKitFrame.h" WebKitFrame* webkitFrameCreate(WebKit::WebFrame*); -WebKit::WebFrame* webkitFrameGetWebFrame(WebKitFrame*); #endif // WebKitFramePrivate_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebEditor.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebEditor.cpp deleted file mode 100644 index 5e3653de7..000000000 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebEditor.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2015 Red Hat Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "config.h" -#include "WebKitWebEditor.h" - -#include "WebKitPrivate.h" -#include "WebKitWebEditorPrivate.h" -#include "WebKitWebPagePrivate.h" -#include "WKBundleAPICast.h" - -using namespace WebKit; -using namespace WebCore; - -/** - * SECTION: WebKitWebEditor - * @Short_description: Access to editing capabilities of a #WebKitWebPage - * @Title: WebKitWebEditor - * @See_also: #WebKitWebPage - * - * The WebKitWebEditor provides access to various editing capabilities of - * a #WebKitWebPage such as a possibility to react to the current selection in - * #WebKitWebPage. - * - * Since: 2.10 - */ -enum { - SELECTION_CHANGED, - - LAST_SIGNAL -}; - -struct _WebKitWebEditorPrivate { - WebKitWebPage* webPage; -}; - -static guint signals[LAST_SIGNAL] = { 0, }; - -WEBKIT_DEFINE_TYPE(WebKitWebEditor, webkit_web_editor, G_TYPE_OBJECT) - -static void webkit_web_editor_class_init(WebKitWebEditorClass* klass) -{ - /** - * WebKitWebEditor::selection-changed: - * @editor: the #WebKitWebEditor on which the signal is emitted - * - * This signal is emitted for every selection change inside a #WebKitWebPage - * as well as for every caret position change as the caret is a collapsed - * selection. - * - * Since: 2.10 - */ - signals[SELECTION_CHANGED] = g_signal_new( - "selection-changed", - G_TYPE_FROM_CLASS(klass), - G_SIGNAL_RUN_LAST, - 0, nullptr, nullptr, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); -} - -static void didChangeSelection(WKBundlePageRef, WKStringRef /* notificationName */, const void* clientInfo) -{ - g_signal_emit(WEBKIT_WEB_EDITOR(clientInfo), signals[SELECTION_CHANGED], 0); -} - -WebKitWebEditor* webkitWebEditorCreate(WebKitWebPage* webPage) -{ - WebKitWebEditor* editor = WEBKIT_WEB_EDITOR(g_object_new(WEBKIT_TYPE_WEB_EDITOR, nullptr)); - editor->priv->webPage = webPage; - - WKBundlePageEditorClientV0 editorClient = { - { - 0, // version - editor, // clientInfo - }, - nullptr, // shouldBeginEditing - nullptr, // shouldEndEditing - nullptr, // shouldInsertNode - nullptr, // shouldInsertText - nullptr, // shouldDeleteRange - nullptr, // shouldChangeSelectedRange - nullptr, // shouldApplyStyle - nullptr, // didBeginEditing - nullptr, // didEndEditing - nullptr, // didChange - didChangeSelection - }; - WKBundlePageSetEditorClient(toAPI(webkitWebPageGetPage(webPage)), &editorClient.base); - - return editor; -} - -/** - * webkit_web_editor_get_page: - * @editor: a #WebKitWebEditor - * - * Gets the #WebKitWebPage that is associated with the #WebKitWebEditor that can - * be used to access the #WebKitDOMDocument currently loaded into it. - * - * Returns: (transfer none): the associated #WebKitWebPage - * - * Since: 2.10 - */ -WebKitWebPage* webkit_web_editor_get_page(WebKitWebEditor* editor) -{ - return editor->priv->webPage; -} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebEditor.h b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebEditor.h deleted file mode 100644 index 0cfe9f008..000000000 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebEditor.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2015 Red Hat Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#if !defined(__WEBKIT_WEB_EXTENSION_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit-web-extension.h> can be included directly." -#endif - -#ifndef WebKitWebEditor_h -#define WebKitWebEditor_h - -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> -#include <webkit2/WebKitWebPage.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_WEB_EDITOR (webkit_web_editor_get_type()) -#define WEBKIT_WEB_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_EDITOR, WebKitWebEditor)) -#define WEBKIT_IS_WEB_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_EDITOR)) -#define WEBKIT_WEB_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_EDITOR, WebKitWebEditorClass)) -#define WEBKIT_IS_WEB_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_EDITOR)) -#define WEBKIT_WEB_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_EDITOR, WebKitWebEditorClass)) - -typedef struct _WebKitWebEditor WebKitWebEditor; -typedef struct _WebKitWebEditorClass WebKitWebEditorClass; -typedef struct _WebKitWebEditorPrivate WebKitWebEditorPrivate; - -/* Forward declarations */ -typedef struct _WebKitWebPage WebKitWebPage; - -struct _WebKitWebEditor { - GObject parent; - - WebKitWebEditorPrivate *priv; -}; - -struct _WebKitWebEditorClass { - GObjectClass parent_class; -}; - -WEBKIT_API GType -webkit_web_editor_get_type (void); - -WEBKIT_API WebKitWebPage * -webkit_web_editor_get_page (WebKitWebEditor *editor); - -G_END_DECLS - -#endif // WebKitWebEditor_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebEditorPrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebEditorPrivate.h deleted file mode 100644 index 88159eb20..000000000 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebEditorPrivate.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2015 Red Hat Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef WebKitWebEditorPrivate_h -#define WebKitWebEditorPrivate_h - -#include "WebKitWebEditor.h" -#include "WebKitWebPage.h" - -WebKitWebEditor* webkitWebEditorCreate(WebKitWebPage*); - -#endif // WebKitWebEditor_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp index 344fb22ea..a8dbb55dc 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp @@ -20,95 +20,19 @@ #include "config.h" #include "WebKitWebExtension.h" -#include "APIDictionary.h" #include "APIString.h" +#include "ImmutableDictionary.h" #include "WKBundleAPICast.h" #include "WKBundlePage.h" #include "WebKitPrivate.h" #include "WebKitWebExtensionPrivate.h" #include "WebKitWebPagePrivate.h" -#include "WebProcess.h" +#include <WebCore/DNS.h> #include <wtf/HashMap.h> -#include <wtf/glib/GRefPtr.h> +#include <wtf/gobject/GRefPtr.h> using namespace WebKit; -/** - * SECTION: WebKitWebExtension - * @Short_description: Represents a WebExtension of the WebProcess - * @Title: WebKitWebExtension - * - * WebKitWebExtension is a loadable module for the WebProcess. It allows you to execute code in the - * WebProcess and being able to use the DOM API, to change any request or to inject custom - * JavaScript code, for example. - * - * To create a WebKitWebExtension you should write a module with an initialization function that could - * be either webkit_web_extension_initialize() with prototype #WebKitWebExtensionInitializeFunction or - * webkit_web_extension_initialize_with_user_data() with prototype #WebKitWebExtensionInitializeWithUserDataFunction. - * This function has to be public and it has to use the #G_MODULE_EXPORT macro. It is called when the - * web process is initialized. - * - * <informalexample><programlisting> - * static void - * web_page_created_callback (WebKitWebExtension *extension, - * WebKitWebPage *web_page, - * gpointer user_data) - * { - * g_print ("Page %d created for %s\n", - * webkit_web_page_get_id (web_page), - * webkit_web_page_get_uri (web_page)); - * } - * - * G_MODULE_EXPORT void - * webkit_web_extension_initialize (WebKitWebExtension *extension) - * { - * g_signal_connect (extension, "page-created", - * G_CALLBACK (web_page_created_callback), - * NULL); - * } - * </programlisting></informalexample> - * - * The previous piece of code shows a trivial example of an extension that notifies when - * a #WebKitWebPage is created. - * - * WebKit has to know where it can find the created WebKitWebExtension. To do so you - * should use the webkit_web_context_set_web_extensions_directory() function. The signal - * #WebKitWebContext::initialize-web-extensions is the recommended place to call it. - * - * To provide the initialization data used by the webkit_web_extension_initialize_with_user_data() - * function, you have to call webkit_web_context_set_web_extensions_initialization_user_data() with - * the desired data as parameter. You can see an example of this in the following piece of code: - * - * <informalexample><programlisting> - * #define WEB_EXTENSIONS_DIRECTORY /<!-- -->* ... *<!-- -->/ - * - * static void - * initialize_web_extensions (WebKitWebContext *context, - * gpointer user_data) - * { - * /<!-- -->* Web Extensions get a different ID for each Web Process *<!-- -->/ - * static guint32 unique_id = 0; - * - * webkit_web_context_set_web_extensions_directory ( - * context, WEB_EXTENSIONS_DIRECTORY); - * webkit_web_context_set_web_extensions_initialization_user_data ( - * context, g_variant_new_uint32 (unique_id++)); - * } - * - * int main (int argc, char **argv) - * { - * g_signal_connect (webkit_web_context_get_default (), - * "initialize-web-extensions", - * G_CALLBACK (initialize_web_extensions), - * NULL); - * - * GtkWidget *view = webkit_web_view_new (); - * - * /<!-- -->* ... *<!-- -->/ - * } - * </programlisting></informalexample> - */ - enum { PAGE_CREATED, @@ -157,32 +81,32 @@ static void webkitWebExtensionPageDestroy(WebKitWebExtension* extension, WebPage extension->priv->pages.remove(page); } -static void webkitWebExtensionDidReceiveMessage(WebKitWebExtension*, const String& messageName, API::Dictionary& message) +static void webkitWebExtensionDidReceiveMessage(WebKitWebExtension* extension, const String& messageName, ImmutableDictionary& message) { if (messageName == String::fromUTF8("PrefetchDNS")) { API::String* hostname = static_cast<API::String*>(message.get(String::fromUTF8("Hostname"))); - WebProcess::singleton().prefetchDNS(hostname->string()); + WebCore::prefetchDNS(hostname->string()); } else ASSERT_NOT_REACHED(); } -static void didCreatePage(WKBundleRef, WKBundlePageRef page, const void* clientInfo) +static void didCreatePage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo) { webkitWebExtensionPageCreated(WEBKIT_WEB_EXTENSION(clientInfo), toImpl(page)); } -static void willDestroyPage(WKBundleRef, WKBundlePageRef page, const void* clientInfo) +static void willDestroyPage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo) { webkitWebExtensionPageDestroy(WEBKIT_WEB_EXTENSION(clientInfo), toImpl(page)); } -static void didReceiveMessage(WKBundleRef, WKStringRef name, WKTypeRef messageBody, const void* clientInfo) +static void didReceiveMessage(WKBundleRef bundle, WKStringRef name, WKTypeRef messageBody, const void* clientInfo) { ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID()); webkitWebExtensionDidReceiveMessage(WEBKIT_WEB_EXTENSION(clientInfo), toImpl(name)->string(), *toImpl(static_cast<WKDictionaryRef>(messageBody))); } -static void didReceiveMessageToPage(WKBundleRef, WKBundlePageRef page, WKStringRef name, WKTypeRef messageBody, const void* clientInfo) +static void didReceiveMessageToPage(WKBundleRef bundle, WKBundlePageRef page, WKStringRef name, WKTypeRef messageBody, const void* clientInfo) { ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID()); if (WebKitWebPage* webPage = WEBKIT_WEB_EXTENSION(clientInfo)->priv->pages.get(toImpl(page)).get()) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtensionAutocleanups.h b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtensionAutocleanups.h deleted file mode 100644 index d2729109c..000000000 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtensionAutocleanups.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2015 Igalia S.L. - * - * 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(__WEBKIT_WEB_EXTENSION_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit-web-extension.h> can be included directly." -#endif - -#ifndef WebKitWebExtensionAutocleanups_h -#define WebKitWebExtensionAutocleanups_h - -#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC -#ifndef __GI_SCANNER__ - -G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitFrame, g_object_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitScriptWorld, g_object_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitWebEditor, g_object_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitWebExtension, g_object_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitWebHitTestResult, g_object_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitWebPage, g_object_unref) - -#endif // __GI_SCANNER__ -#endif // G_DEFINE_AUTOPTR_CLEANUP_FUNC - -#endif // WebKitWebExtensionAutocleanups_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebHitTestResult.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebHitTestResult.cpp deleted file mode 100644 index fc20969a6..000000000 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebHitTestResult.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (C) 2014 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "config.h" -#include "WebKitWebHitTestResult.h" - -#include "InjectedBundleHitTestResult.h" -#include "WebKitDOMNodePrivate.h" -#include "WebKitPrivate.h" -#include "WebKitWebHitTestResultPrivate.h" -#include <glib/gi18n-lib.h> -#include <wtf/glib/GRefPtr.h> -#include <wtf/text/CString.h> - -using namespace WebKit; -using namespace WebCore; - -/** - * SECTION: WebKitWebHitTestResult - * @Short_description: Result of a Hit Test (Web Process Extensions) - * @Title: WebKitWebHitTestResult - * @See_also: #WebKitHitTestResult, #WebKitWebPage - * - * WebKitWebHitTestResult extends #WebKitHitTestResult to provide information - * about the #WebKitDOMNode in the coordinates of the Hit Test. - * - * Since: 2.8 - */ - -enum { - PROP_0, - - PROP_NODE -}; - -struct _WebKitWebHitTestResultPrivate { - GRefPtr<WebKitDOMNode> node; -}; - -WEBKIT_DEFINE_TYPE(WebKitWebHitTestResult, webkit_web_hit_test_result, WEBKIT_TYPE_HIT_TEST_RESULT) - -static void webkitWebHitTestResultGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec) -{ - WebKitWebHitTestResult* webHitTestResult = WEBKIT_WEB_HIT_TEST_RESULT(object); - - switch (propId) { - case PROP_NODE: - g_value_set_object(value, webkit_web_hit_test_result_get_node(webHitTestResult)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); - } -} - -static void webkitWebHitTestResultSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec) -{ - WebKitWebHitTestResult* webHitTestResult = WEBKIT_WEB_HIT_TEST_RESULT(object); - - switch (propId) { - case PROP_NODE: { - gpointer node = g_value_get_object(value); - webHitTestResult->priv->node = node ? WEBKIT_DOM_NODE(node) : nullptr; - break; - } - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); - } -} - -static void webkit_web_hit_test_result_class_init(WebKitWebHitTestResultClass* klass) -{ - GObjectClass* gObjectClass = G_OBJECT_CLASS(klass); - - gObjectClass->get_property = webkitWebHitTestResultGetProperty; - gObjectClass->set_property = webkitWebHitTestResultSetProperty; - - /** - * WebKitWebHitTestResult:node: - * - * The #WebKitDOMNode - */ - g_object_class_install_property( - gObjectClass, - PROP_NODE, - g_param_spec_object( - "node", - _("Node"), - _("The WebKitDOMNode"), - WEBKIT_DOM_TYPE_NODE, - static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY))); -} - -WebKitWebHitTestResult* webkitWebHitTestResultCreate(const HitTestResult& hitTestResult) -{ - unsigned context = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT; - String absoluteLinkURL = hitTestResult.absoluteLinkURL().string(); - if (!absoluteLinkURL.isEmpty()) - context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK; - String absoluteImageURL = hitTestResult.absoluteImageURL().string(); - if (!absoluteImageURL.isEmpty()) - context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE; - String absoluteMediaURL = hitTestResult.absoluteMediaURL().string(); - if (!absoluteMediaURL.isEmpty()) - context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA; - if (hitTestResult.isContentEditable()) - context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE; - if (hitTestResult.scrollbar()) - context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_SCROLLBAR; - if (hitTestResult.isSelected()) - context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION; - - String linkTitle = hitTestResult.titleDisplayString(); - String linkLabel = hitTestResult.textContent(); - - return WEBKIT_WEB_HIT_TEST_RESULT(g_object_new(WEBKIT_TYPE_WEB_HIT_TEST_RESULT, - "context", context, - "link-uri", context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK ? absoluteLinkURL.utf8().data() : nullptr, - "image-uri", context & WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE ? absoluteImageURL.utf8().data() : nullptr, - "media-uri", context & WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA ? absoluteMediaURL.utf8().data() : nullptr, - "link-title", !linkTitle.isEmpty() ? linkTitle.utf8().data() : nullptr, - "link-label", !linkLabel.isEmpty() ? linkLabel.utf8().data() : nullptr, - "node", kit(hitTestResult.innerNonSharedNode()), - nullptr)); -} - -/** - * webkit_web_hit_test_result_get_node: - * @hit_test_result: a #WebKitWebHitTestResult - * - * Get the #WebKitDOMNode in the coordinates of the Hit Test. - * - * Returns: (transfer none): a #WebKitDOMNode - * - * Since: 2.8 - */ -WebKitDOMNode* webkit_web_hit_test_result_get_node(WebKitWebHitTestResult* webHitTestResult) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_HIT_TEST_RESULT(webHitTestResult), nullptr); - - return webHitTestResult->priv->node.get(); -} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebHitTestResult.h b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebHitTestResult.h deleted file mode 100644 index 8ce847d87..000000000 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebHitTestResult.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2014 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#if !defined(__WEBKIT_WEB_EXTENSION_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit-web-extension.h> can be included directly." -#endif - -#ifndef WebKitWebHitTestResult_h -#define WebKitWebHitTestResult_h - -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> -#include <webkit2/WebKitHitTestResult.h> -#include <webkitdom/webkitdom.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_WEB_HIT_TEST_RESULT (webkit_web_hit_test_result_get_type()) -#define WEBKIT_WEB_HIT_TEST_RESULT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_HIT_TEST_RESULT, WebKitWebHitTestResult)) -#define WEBKIT_IS_WEB_HIT_TEST_RESULT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_HIT_TEST_RESULT)) -#define WEBKIT_WEB_HIT_TEST_RESULT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_HIT_TEST_RESULT, WebKitWebHitTestResultClass)) -#define WEBKIT_IS_WEB_HIT_TEST_RESULT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_HIT_TEST_RESULT)) -#define WEBKIT_WEB_HIT_TEST_RESULT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_HIT_TEST_RESULT, WebKitWebHitTestResultClass)) - -typedef struct _WebKitWebHitTestResult WebKitWebHitTestResult; -typedef struct _WebKitWebHitTestResultClass WebKitWebHitTestResultClass; -typedef struct _WebKitWebHitTestResultPrivate WebKitWebHitTestResultPrivate; - -struct _WebKitWebHitTestResult { - WebKitHitTestResult parent; - - WebKitWebHitTestResultPrivate *priv; -}; - -struct _WebKitWebHitTestResultClass { - WebKitHitTestResultClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_web_hit_test_result_get_type (void); - -WEBKIT_API WebKitDOMNode * -webkit_web_hit_test_result_get_node (WebKitWebHitTestResult *hit_test_result); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebHitTestResultPrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebHitTestResultPrivate.h deleted file mode 100644 index 66dd7e7ec..000000000 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebHitTestResultPrivate.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2014 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef WebKitWebHitTestResultPrivate_h -#define WebKitWebHitTestResultPrivate_h - -#include "WebKitWebHitTestResult.h" -#include <WebCore/HitTestResult.h> - -WebKitWebHitTestResult* webkitWebHitTestResultCreate(const WebCore::HitTestResult&); - -#endif // WebKitWebHitTestResultPrivate_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp index faa8578a0..272c9ed2f 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp @@ -20,16 +20,12 @@ #include "config.h" #include "WebKitWebPage.h" -#include "APIArray.h" -#include "APIDictionary.h" #include "ImageOptions.h" +#include "ImmutableDictionary.h" #include "InjectedBundle.h" #include "WKBundleAPICast.h" #include "WKBundleFrame.h" -#include "WebContextMenuItem.h" #include "WebImage.h" -#include "WebKitConsoleMessagePrivate.h" -#include "WebKitContextMenuPrivate.h" #include "WebKitDOMDocumentPrivate.h" #include "WebKitFramePrivate.h" #include "WebKitMarshal.h" @@ -37,20 +33,15 @@ #include "WebKitScriptWorldPrivate.h" #include "WebKitURIRequestPrivate.h" #include "WebKitURIResponsePrivate.h" -#include "WebKitWebEditorPrivate.h" -#include "WebKitWebHitTestResultPrivate.h" #include "WebKitWebPagePrivate.h" #include "WebProcess.h" #include <WebCore/Document.h> #include <WebCore/DocumentLoader.h> #include <WebCore/Frame.h> -#include <WebCore/FrameDestructionObserver.h> #include <WebCore/FrameView.h> -#include <WebCore/MainFrame.h> #include <glib/gi18n-lib.h> #include <wtf/NeverDestroyed.h> #include <wtf/text/CString.h> -#include <wtf/text/StringBuilder.h> using namespace WebKit; using namespace WebCore; @@ -58,8 +49,6 @@ using namespace WebCore; enum { DOCUMENT_LOADED, SEND_REQUEST, - CONTEXT_MENU, - CONSOLE_MESSAGE_SENT, LAST_SIGNAL }; @@ -74,37 +63,13 @@ struct _WebKitWebPagePrivate { WebPage* webPage; CString uri; - - GRefPtr<WebKitWebEditor> webEditor; }; static guint signals[LAST_SIGNAL] = { 0, }; WEBKIT_DEFINE_TYPE(WebKitWebPage, webkit_web_page, G_TYPE_OBJECT) -static void webFrameDestroyed(WebFrame*); - -class WebKitFrameWrapper final: public FrameDestructionObserver { -public: - WebKitFrameWrapper(WebFrame& webFrame) - : FrameDestructionObserver(webFrame.coreFrame()) - , m_webkitFrame(adoptGRef(webkitFrameCreate(&webFrame))) - { - } - - WebKitFrame* webkitFrame() const { return m_webkitFrame.get(); } - -private: - virtual void frameDestroyed() override - { - FrameDestructionObserver::frameDestroyed(); - webFrameDestroyed(webkitFrameGetWebFrame(m_webkitFrame.get())); - } - - GRefPtr<WebKitFrame> m_webkitFrame; -}; - -typedef HashMap<WebFrame*, std::unique_ptr<WebKitFrameWrapper>> WebFrameMap; +typedef HashMap<WebFrame*, GRefPtr<WebKitFrame>> WebFrameMap; static WebFrameMap& webFrameMap() { @@ -114,19 +79,14 @@ static WebFrameMap& webFrameMap() static WebKitFrame* webkitFrameGetOrCreate(WebFrame* webFrame) { - auto wrapperPtr = webFrameMap().get(webFrame); - if (wrapperPtr) - return wrapperPtr->webkitFrame(); - - std::unique_ptr<WebKitFrameWrapper> wrapper = std::make_unique<WebKitFrameWrapper>(*webFrame); - wrapperPtr = wrapper.get(); - webFrameMap().set(webFrame, WTFMove(wrapper)); - return wrapperPtr->webkitFrame(); -} + GRefPtr<WebKitFrame> frame = webFrameMap().get(webFrame); + if (frame) + return frame.get(); -static void webFrameDestroyed(WebFrame* webFrame) -{ - webFrameMap().remove(webFrame); + frame = adoptGRef(webkitFrameCreate(webFrame)); + webFrameMap().set(webFrame, frame); + + return frame.get(); } static CString getProvisionalURLForFrame(WebFrame* webFrame) @@ -147,12 +107,6 @@ static void webkitWebPageSetURI(WebKitWebPage* webPage, const CString& uri) g_object_notify(G_OBJECT(webPage), "uri"); } -static void webkitWebPageDidSendConsoleMessage(WebKitWebPage* webPage, MessageSource source, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceID) -{ - WebKitConsoleMessage consoleMessage(source, level, message, lineNumber, sourceID); - g_signal_emit(webPage, signals[CONSOLE_MESSAGE_SENT], 0, &consoleMessage); -} - static void didStartProvisionalLoadForFrame(WKBundlePageRef, WKBundleFrameRef frame, WKTypeRef*, const void *clientInfo) { if (!WKBundleFrameIsMainFrame(frame)) @@ -161,7 +115,7 @@ static void didStartProvisionalLoadForFrame(WKBundlePageRef, WKBundleFrameRef fr webkitWebPageSetURI(WEBKIT_WEB_PAGE(clientInfo), getProvisionalURLForFrame(toImpl(frame))); } -static void didReceiveServerRedirectForProvisionalLoadForFrame(WKBundlePageRef, WKBundleFrameRef frame, WKTypeRef* /* userData */, const void *clientInfo) +static void didReceiveServerRedirectForProvisionalLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo) { if (!WKBundleFrameIsMainFrame(frame)) return; @@ -169,7 +123,7 @@ static void didReceiveServerRedirectForProvisionalLoadForFrame(WKBundlePageRef, webkitWebPageSetURI(WEBKIT_WEB_PAGE(clientInfo), getProvisionalURLForFrame(toImpl(frame))); } -static void didSameDocumentNavigationForFrame(WKBundlePageRef, WKBundleFrameRef frame, WKSameDocumentNavigationType, WKTypeRef* /* userData */, const void *clientInfo) +static void didSameDocumentNavigationForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKSameDocumentNavigationType type, WKTypeRef* userData, const void *clientInfo) { if (!WKBundleFrameIsMainFrame(frame)) return; @@ -185,20 +139,25 @@ static void didFinishDocumentLoadForFrame(WKBundlePageRef, WKBundleFrameRef fram g_signal_emit(WEBKIT_WEB_PAGE(clientInfo), signals[DOCUMENT_LOADED], 0); } +static void willDestroyFrame(WKBundlePageRef, WKBundleFrameRef frame, const void *clientInfo) +{ + webFrameMap().remove(toImpl(frame)); +} + static void didClearWindowObjectForFrame(WKBundlePageRef, WKBundleFrameRef frame, WKBundleScriptWorldRef wkWorld, const void* clientInfo) { if (WebKitScriptWorld* world = webkitScriptWorldGet(toImpl(wkWorld))) webkitScriptWorldWindowObjectCleared(world, WEBKIT_WEB_PAGE(clientInfo), webkitFrameGetOrCreate(toImpl(frame))); } -static void didInitiateLoadForResource(WKBundlePageRef page, WKBundleFrameRef frame, uint64_t identifier, WKURLRequestRef request, bool /* pageLoadIsProvisional */, const void*) +static void didInitiateLoadForResource(WKBundlePageRef page, WKBundleFrameRef frame, uint64_t identifier, WKURLRequestRef request, bool pageLoadIsProvisional, const void*) { - API::Dictionary::MapType message; + ImmutableDictionary::MapType message; message.set(String::fromUTF8("Page"), toImpl(page)); message.set(String::fromUTF8("Frame"), toImpl(frame)); message.set(String::fromUTF8("Identifier"), API::UInt64::create(identifier)); message.set(String::fromUTF8("Request"), toImpl(request)); - WebProcess::singleton().injectedBundle()->postMessage(String::fromUTF8("WebPage.DidInitiateLoadForResource"), API::Dictionary::create(WTFMove(message)).ptr()); + WebProcess::shared().injectedBundle()->postMessage(String::fromUTF8("WebPage.DidInitiateLoadForResource"), ImmutableDictionary::create(std::move(message)).get()); } static WKURLRequestRef willSendRequestForFrame(WKBundlePageRef page, WKBundleFrameRef, uint64_t identifier, WKURLRequestRef wkRequest, WKURLResponseRef wkRedirectResponse, const void* clientInfo) @@ -215,123 +174,54 @@ static WKURLRequestRef willSendRequestForFrame(WKBundlePageRef page, WKBundleFra ResourceRequest resourceRequest; webkitURIRequestGetResourceRequest(request.get(), resourceRequest); resourceRequest.setInitiatingPageID(toImpl(page)->pageID()); - Ref<API::URLRequest> newRequest = API::URLRequest::create(resourceRequest); + RefPtr<API::URLRequest> newRequest = API::URLRequest::create(resourceRequest); - API::Dictionary::MapType message; + ImmutableDictionary::MapType message; message.set(String::fromUTF8("Page"), toImpl(page)); message.set(String::fromUTF8("Identifier"), API::UInt64::create(identifier)); - message.set(String::fromUTF8("Request"), newRequest.ptr()); + message.set(String::fromUTF8("Request"), newRequest.get()); if (!redirectResourceResponse.isNull()) message.set(String::fromUTF8("RedirectResponse"), toImpl(wkRedirectResponse)); - WebProcess::singleton().injectedBundle()->postMessage(String::fromUTF8("WebPage.DidSendRequestForResource"), API::Dictionary::create(WTFMove(message)).ptr()); + WebProcess::shared().injectedBundle()->postMessage(String::fromUTF8("WebPage.DidSendRequestForResource"), ImmutableDictionary::create(std::move(message)).get()); - return toAPI(&newRequest.leakRef()); + return toAPI(newRequest.release().leakRef()); } -static void didReceiveResponseForResource(WKBundlePageRef page, WKBundleFrameRef, uint64_t identifier, WKURLResponseRef response, const void* clientInfo) +static void didReceiveResponseForResource(WKBundlePageRef page, WKBundleFrameRef, uint64_t identifier, WKURLResponseRef response, const void*) { - API::Dictionary::MapType message; + ImmutableDictionary::MapType message; message.set(String::fromUTF8("Page"), toImpl(page)); message.set(String::fromUTF8("Identifier"), API::UInt64::create(identifier)); message.set(String::fromUTF8("Response"), toImpl(response)); - WebProcess::singleton().injectedBundle()->postMessage(String::fromUTF8("WebPage.DidReceiveResponseForResource"), API::Dictionary::create(WTFMove(message)).ptr()); - - // Post on the console as well to be consistent with the inspector. - const ResourceResponse& resourceResponse = toImpl(response)->resourceResponse(); - if (resourceResponse.httpStatusCode() >= 400) { - StringBuilder errorMessage; - errorMessage.appendLiteral("Failed to load resource: the server responded with a status of "); - errorMessage.appendNumber(resourceResponse.httpStatusCode()); - errorMessage.appendLiteral(" ("); - errorMessage.append(resourceResponse.httpStatusText()); - errorMessage.append(')'); - webkitWebPageDidSendConsoleMessage(WEBKIT_WEB_PAGE(clientInfo), MessageSource::Network, MessageLevel::Error, errorMessage.toString(), 0, resourceResponse.url().string()); - } + WebProcess::shared().injectedBundle()->postMessage(String::fromUTF8("WebPage.DidReceiveResponseForResource"), ImmutableDictionary::create(std::move(message)).get()); } static void didReceiveContentLengthForResource(WKBundlePageRef page, WKBundleFrameRef, uint64_t identifier, uint64_t length, const void*) { - API::Dictionary::MapType message; + ImmutableDictionary::MapType message; message.set(String::fromUTF8("Page"), toImpl(page)); message.set(String::fromUTF8("Identifier"), API::UInt64::create(identifier)); message.set(String::fromUTF8("ContentLength"), API::UInt64::create(length)); - WebProcess::singleton().injectedBundle()->postMessage(String::fromUTF8("WebPage.DidReceiveContentLengthForResource"), API::Dictionary::create(WTFMove(message)).ptr()); + WebProcess::shared().injectedBundle()->postMessage(String::fromUTF8("WebPage.DidReceiveContentLengthForResource"), ImmutableDictionary::create(std::move(message)).get()); } static void didFinishLoadForResource(WKBundlePageRef page, WKBundleFrameRef, uint64_t identifier, const void*) { - API::Dictionary::MapType message; + ImmutableDictionary::MapType message; message.set(String::fromUTF8("Page"), toImpl(page)); message.set(String::fromUTF8("Identifier"), API::UInt64::create(identifier)); - WebProcess::singleton().injectedBundle()->postMessage(String::fromUTF8("WebPage.DidFinishLoadForResource"), API::Dictionary::create(WTFMove(message)).ptr()); + WebProcess::shared().injectedBundle()->postMessage(String::fromUTF8("WebPage.DidFinishLoadForResource"), ImmutableDictionary::create(std::move(message)).get()); } -static void didFailLoadForResource(WKBundlePageRef page, WKBundleFrameRef, uint64_t identifier, WKErrorRef error, const void* clientInfo) +static void didFailLoadForResource(WKBundlePageRef page, WKBundleFrameRef, uint64_t identifier, WKErrorRef error, const void*) { - API::Dictionary::MapType message; + ImmutableDictionary::MapType message; message.set(String::fromUTF8("Page"), toImpl(page)); message.set(String::fromUTF8("Identifier"), API::UInt64::create(identifier)); message.set(String::fromUTF8("Error"), toImpl(error)); - WebProcess::singleton().injectedBundle()->postMessage(String::fromUTF8("WebPage.DidFailLoadForResource"), API::Dictionary::create(WTFMove(message)).ptr()); - - // Post on the console as well to be consistent with the inspector. - const ResourceError& resourceError = toImpl(error)->platformError(); - if (!resourceError.isCancellation()) { - StringBuilder errorMessage; - errorMessage.appendLiteral("Failed to load resource"); - if (!resourceError.localizedDescription().isEmpty()) { - errorMessage.appendLiteral(": "); - errorMessage.append(resourceError.localizedDescription()); - } - webkitWebPageDidSendConsoleMessage(WEBKIT_WEB_PAGE(clientInfo), MessageSource::Network, MessageLevel::Error, errorMessage.toString(), 0, resourceError.failingURL()); - } + WebProcess::shared().injectedBundle()->postMessage(String::fromUTF8("WebPage.DidFailLoadForResource"), ImmutableDictionary::create(std::move(message)).get()); } -class PageContextMenuClient final : public API::InjectedBundle::PageContextMenuClient { -public: - explicit PageContextMenuClient(WebKitWebPage* webPage) - : m_webPage(webPage) - { - } - -private: - bool getCustomMenuFromDefaultItems(WebPage&, const WebCore::HitTestResult& hitTestResult, const Vector<WebCore::ContextMenuItem>& defaultMenu, Vector<WebContextMenuItemData>& newMenu, RefPtr<API::Object>& userData) override - { - GRefPtr<WebKitContextMenu> contextMenu = adoptGRef(webkitContextMenuCreate(kitItems(defaultMenu))); - GRefPtr<WebKitWebHitTestResult> webHitTestResult = adoptGRef(webkitWebHitTestResultCreate(hitTestResult)); - gboolean returnValue; - g_signal_emit(m_webPage, signals[CONTEXT_MENU], 0, contextMenu.get(), webHitTestResult.get(), &returnValue); - if (GVariant* variant = webkit_context_menu_get_user_data(contextMenu.get())) { - GUniquePtr<gchar> dataString(g_variant_print(variant, TRUE)); - userData = API::String::create(String::fromUTF8(dataString.get())); - } - - if (!returnValue) - return false; - - webkitContextMenuPopulate(contextMenu.get(), newMenu); - return true; - } - - WebKitWebPage* m_webPage; -}; - -class PageUIClient final : public API::InjectedBundle::PageUIClient { -public: - explicit PageUIClient(WebKitWebPage* webPage) - : m_webPage(webPage) - { - } - -private: - void willAddMessageToConsole(WebPage*, MessageSource source, MessageLevel level, const String& message, unsigned lineNumber, unsigned /*columnNumber*/, const String& sourceID) override - { - webkitWebPageDidSendConsoleMessage(m_webPage, source, level, message, lineNumber, sourceID); - } - - WebKitWebPage* m_webPage; -}; - static void webkitWebPageGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec) { WebKitWebPage* webPage = WEBKIT_WEB_PAGE(object); @@ -414,62 +304,6 @@ static void webkit_web_page_class_init(WebKitWebPageClass* klass) G_TYPE_BOOLEAN, 2, WEBKIT_TYPE_URI_REQUEST, WEBKIT_TYPE_URI_RESPONSE); - - /** - * WebKitWebPage::context-menu: - * @web_page: the #WebKitWebPage on which the signal is emitted - * @context_menu: the proposed #WebKitContextMenu - * @hit_test_result: a #WebKitWebHitTestResult - * - * Emmited before a context menu is displayed in the UI Process to - * give the application a chance to customize the proposed menu, - * build its own context menu or pass user data to the UI Process. - * This signal is useful when the information available in the UI Process - * is not enough to build or customize the context menu, for example, to - * add menu entries depending on the #WebKitDOMNode at the coordinates of the - * @hit_test_result. Otherwise, it's recommened to use #WebKitWebView::context-menu - * signal instead. - * - * Returns: %TRUE if the proposed @context_menu has been modified, or %FALSE otherwise. - * - * Since: 2.8 - */ - signals[CONTEXT_MENU] = g_signal_new( - "context-menu", - G_TYPE_FROM_CLASS(klass), - G_SIGNAL_RUN_LAST, - 0, - g_signal_accumulator_true_handled, 0, - webkit_marshal_BOOLEAN__OBJECT_OBJECT, - G_TYPE_BOOLEAN, 2, - WEBKIT_TYPE_CONTEXT_MENU, - WEBKIT_TYPE_WEB_HIT_TEST_RESULT); - - /** - * WebKitWebPage::console-message-sent: - * @web_page: the #WebKitWebPage on which the signal is emitted - * @console_message: the #WebKitConsoleMessage - * - * Emmited when a message is sent to the console. This can be a message - * produced by the use of JavaScript console API, a javascript exception, - * a security error or other errors, warnings, debug or log messages. - * The @console_message contains information of the message. - * - * Since: 2.12 - */ - signals[CONSOLE_MESSAGE_SENT] = g_signal_new( - "console-message-sent", - G_TYPE_FROM_CLASS(klass), - G_SIGNAL_RUN_LAST, - 0, 0, nullptr, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, 1, - WEBKIT_TYPE_CONSOLE_MESSAGE | G_SIGNAL_TYPE_STATIC_SCOPE); -} - -WebPage* webkitWebPageGetPage(WebKitWebPage *webPage) -{ - return webPage->priv->webPage; } WebKitWebPage* webkitWebPageCreate(WebPage* webPage) @@ -477,9 +311,9 @@ WebKitWebPage* webkitWebPageCreate(WebPage* webPage) WebKitWebPage* page = WEBKIT_WEB_PAGE(g_object_new(WEBKIT_TYPE_WEB_PAGE, NULL)); page->priv->webPage = webPage; - WKBundlePageLoaderClientV6 loaderClient = { + WKBundlePageLoaderClientV7 loaderClient = { { - 6, // version + 7, // version page, // clientInfo }, didStartProvisionalLoadForFrame, @@ -493,7 +327,7 @@ WebKitWebPage* webkitWebPageCreate(WebPage* webPage) 0, // didReceiveTitleForFrame 0, // didFirstLayoutForFrame 0, // didFirstVisuallyNonEmptyLayoutForFrame - 0, // didRemoveFrameFromHierarchy, + 0, // didRemoveFrameFromHierarchy 0, // didDisplayInsecureContentForFrame 0, // didRunInsecureContentForFrame didClearWindowObjectForFrame, @@ -516,6 +350,7 @@ WebKitWebPage* webkitWebPageCreate(WebPage* webPage) 0, // featuresUsedInPage 0, // willLoadURLRequest 0, // willLoadDataRequest + willDestroyFrame }; WKBundlePageSetPageLoaderClient(toAPI(webPage), &loaderClient.base); @@ -535,19 +370,15 @@ WebKitWebPage* webkitWebPageCreate(WebPage* webPage) }; WKBundlePageSetResourceLoadClient(toAPI(webPage), &resourceLoadClient.base); - webPage->setInjectedBundleContextMenuClient(std::make_unique<PageContextMenuClient>(page)); - webPage->setInjectedBundleUIClient(std::make_unique<PageUIClient>(page)); - return page; } -void webkitWebPageDidReceiveMessage(WebKitWebPage* page, const String& messageName, API::Dictionary& message) +void webkitWebPageDidReceiveMessage(WebKitWebPage* page, const String& messageName, ImmutableDictionary& message) { if (messageName == String("GetSnapshot")) { SnapshotOptions snapshotOptions = static_cast<SnapshotOptions>(static_cast<API::UInt64*>(message.get("SnapshotOptions"))->value()); uint64_t callbackID = static_cast<API::UInt64*>(message.get("CallbackID"))->value(); SnapshotRegion region = static_cast<SnapshotRegion>(static_cast<API::UInt64*>(message.get("SnapshotRegion"))->value()); - bool transparentBackground = static_cast<API::Boolean*>(message.get("TransparentBackground"))->value(); RefPtr<WebImage> snapshotImage; WebPage* webPage = page->priv->webPage; @@ -563,23 +394,15 @@ void webkitWebPageDidReceiveMessage(WebKitWebPage* page, const String& messageNa default: ASSERT_NOT_REACHED(); } - if (!snapshotRect.isEmpty()) { - Color savedBackgroundColor; - if (transparentBackground) { - savedBackgroundColor = frameView->baseBackgroundColor(); - frameView->setBaseBackgroundColor(Color::transparent); - } + if (!snapshotRect.isEmpty()) snapshotImage = webPage->scaledSnapshotWithOptions(snapshotRect, 1, snapshotOptions | SnapshotOptionsShareable); - if (transparentBackground) - frameView->setBaseBackgroundColor(savedBackgroundColor); - } } - API::Dictionary::MapType messageReply; + ImmutableDictionary::MapType messageReply; messageReply.set("Page", webPage); messageReply.set("CallbackID", API::UInt64::create(callbackID)); messageReply.set("Snapshot", snapshotImage); - WebProcess::singleton().injectedBundle()->postMessage("WebPage.DidGetSnapshot", API::Dictionary::create(WTFMove(messageReply)).ptr()); + WebProcess::shared().injectedBundle()->postMessage("WebPage.DidGetSnapshot", ImmutableDictionary::create(std::move(messageReply)).get()); } else ASSERT_NOT_REACHED(); } @@ -597,7 +420,7 @@ WebKitDOMDocument* webkit_web_page_get_dom_document(WebKitWebPage* webPage) { g_return_val_if_fail(WEBKIT_IS_WEB_PAGE(webPage), 0); - MainFrame* coreFrame = webPage->priv->webPage->mainFrame(); + Frame* coreFrame = webPage->priv->webPage->mainFrame(); if (!coreFrame) return 0; @@ -654,23 +477,3 @@ WebKitFrame* webkit_web_page_get_main_frame(WebKitWebPage* webPage) return webkitFrameGetOrCreate(webPage->priv->webPage->mainWebFrame()); } - -/** - * webkit_web_page_get_editor: - * @web_page: a #WebKitWebPage - * - * Gets the #WebKitWebEditor of a #WebKitWebPage. - * - * Returns: (transfer none): the #WebKitWebEditor - * - * Since: 2.10 - */ -WebKitWebEditor* webkit_web_page_get_editor(WebKitWebPage* webPage) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_PAGE(webPage), nullptr); - - if (!webPage->priv->webEditor) - webPage->priv->webEditor = adoptGRef(webkitWebEditorCreate(webPage)); - - return webPage->priv->webEditor.get(); -} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h index 033b3cd8b..37455286f 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h @@ -27,7 +27,6 @@ #include <glib-object.h> #include <webkit2/WebKitDefines.h> #include <webkit2/WebKitFrame.h> -#include <webkit2/WebKitWebEditor.h> #include <webkitdom/webkitdom.h> G_BEGIN_DECLS @@ -43,9 +42,6 @@ typedef struct _WebKitWebPage WebKitWebPage; typedef struct _WebKitWebPageClass WebKitWebPageClass; typedef struct _WebKitWebPagePrivate WebKitWebPagePrivate; -/* Forward declarations */ -typedef struct _WebKitWebEditor WebKitWebEditor; - struct _WebKitWebPage { GObject parent; @@ -71,9 +67,6 @@ webkit_web_page_get_uri (WebKitWebPage *web_page); WEBKIT_API WebKitFrame * webkit_web_page_get_main_frame (WebKitWebPage *web_page); -WEBKIT_API WebKitWebEditor * -webkit_web_page_get_editor (WebKitWebPage *web_page); - G_END_DECLS #endif diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPagePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPagePrivate.h index 8dcd42a9d..3fec56e73 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPagePrivate.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPagePrivate.h @@ -20,12 +20,11 @@ #ifndef WebKitWebPagePrivate_h #define WebKitWebPagePrivate_h -#include "APIDictionary.h" +#include "ImmutableDictionary.h" #include "WebKitWebPage.h" #include "WebPage.h" WebKitWebPage* webkitWebPageCreate(WebKit::WebPage*); -void webkitWebPageDidReceiveMessage(WebKitWebPage*, const String& messageName, API::Dictionary& message); -WebKit::WebPage* webkitWebPageGetPage(WebKitWebPage*); +void webkitWebPageDidReceiveMessage(WebKitWebPage*, const String& messageName, WebKit::ImmutableDictionary& message); #endif // WebKitWebPagePrivate_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h index 7ff6d777f..2a0881e52 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h @@ -26,22 +26,14 @@ #define __WEBKIT_WEB_EXTENSION_H_INSIDE__ -#include <webkit2/WebKitConsoleMessage.h> -#include <webkit2/WebKitContextMenu.h> -#include <webkit2/WebKitContextMenuActions.h> -#include <webkit2/WebKitContextMenuItem.h> #include <webkit2/WebKitFrame.h> #include <webkit2/WebKitScriptWorld.h> #include <webkit2/WebKitURIRequest.h> #include <webkit2/WebKitURIResponse.h> #include <webkit2/WebKitVersion.h> -#include <webkit2/WebKitWebEditor.h> #include <webkit2/WebKitWebExtension.h> -#include <webkit2/WebKitWebHitTestResult.h> #include <webkit2/WebKitWebPage.h> -#include <webkit2/WebKitWebExtensionAutocleanups.h> - #undef __WEBKIT_WEB_EXTENSION_H_INSIDE__ #endif diff --git a/Source/WebKit2/WebProcess/InjectedBundle/APIInjectedBundleFormClient.h b/Source/WebKit2/WebProcess/InjectedBundle/APIInjectedBundleFormClient.h deleted file mode 100644 index d67aaa16a..000000000 --- a/Source/WebKit2/WebProcess/InjectedBundle/APIInjectedBundleFormClient.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2014 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef APIInjectedBundleFormClient_h -#define APIInjectedBundleFormClient_h - -#include <wtf/Forward.h> -#include <wtf/Vector.h> - -namespace WebCore { -class Element; -class HTMLFormElement; -class HTMLInputElement; -class HTMLTextAreaElement; -} - -namespace WebKit { -class WebFrame; -class WebPage; -} - -namespace API { - -class Object; - -namespace InjectedBundle { - -class FormClient { -public: - virtual ~FormClient() { } - - virtual void didFocusTextField(WebKit::WebPage*, WebCore::HTMLInputElement*, WebKit::WebFrame*) { } - virtual void textFieldDidBeginEditing(WebKit::WebPage*, WebCore::HTMLInputElement*, WebKit::WebFrame*) { } - virtual void textFieldDidEndEditing(WebKit::WebPage*, WebCore::HTMLInputElement*, WebKit::WebFrame*) { } - virtual void textDidChangeInTextField(WebKit::WebPage*, WebCore::HTMLInputElement*, WebKit::WebFrame*, bool) { } - virtual void textDidChangeInTextArea(WebKit::WebPage*, WebCore::HTMLTextAreaElement*, WebKit::WebFrame*) { } - - enum class InputFieldAction { - MoveUp, - MoveDown, - Cancel, - InsertTab, - InsertBacktab, - InsertNewline, - InsertDelete, - }; - - virtual bool shouldPerformActionInTextField(WebKit::WebPage*, WebCore::HTMLInputElement*, InputFieldAction, WebKit::WebFrame*) { return false; } - virtual void willSubmitForm(WebKit::WebPage*, WebCore::HTMLFormElement*, WebKit::WebFrame*, WebKit::WebFrame*, const Vector<std::pair<WTF::String, WTF::String>>&, RefPtr<API::Object>& userData) { UNUSED_PARAM(userData); } - virtual void willSendSubmitEvent(WebKit::WebPage*, WebCore::HTMLFormElement*, WebKit::WebFrame*, WebKit::WebFrame*, const Vector<std::pair<WTF::String, WTF::String>>&) { } - virtual void didAssociateFormControls(WebKit::WebPage*, const Vector<RefPtr<WebCore::Element>>&) { } - virtual bool shouldNotifyOnFormChanges(WebKit::WebPage*) { return false; } - virtual void willBeginInputSession(WebKit::WebPage*, WebCore::Element*, WebKit::WebFrame*, RefPtr<API::Object>& userData) { UNUSED_PARAM(userData); } -}; - -} // namespace InjectedBundle - -} // namespace API - -#endif // APIInjectedBundleFormClient_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.cpp deleted file mode 100644 index ac11d11a7..000000000 --- a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -#include "config.h" -#include "InjectedBundleCSSStyleDeclarationHandle.h" - -#include <WebCore/CSSStyleDeclaration.h> -#include <wtf/HashMap.h> -#include <wtf/NeverDestroyed.h> - -using namespace WebCore; - -namespace WebKit { - -typedef HashMap<CSSStyleDeclaration*, InjectedBundleCSSStyleDeclarationHandle*> DOMHandleCache; - -static DOMHandleCache& domHandleCache() -{ - static NeverDestroyed<DOMHandleCache> cache; - return cache; -} - -PassRefPtr<InjectedBundleCSSStyleDeclarationHandle> InjectedBundleCSSStyleDeclarationHandle::getOrCreate(CSSStyleDeclaration* styleDeclaration) -{ - if (!styleDeclaration) - return nullptr; - - DOMHandleCache::AddResult result = domHandleCache().add(styleDeclaration, nullptr); - if (!result.isNewEntry) - return PassRefPtr<InjectedBundleCSSStyleDeclarationHandle>(result.iterator->value); - - RefPtr<InjectedBundleCSSStyleDeclarationHandle> styleDeclarationHandle = adoptRef(new InjectedBundleCSSStyleDeclarationHandle(*styleDeclaration)); - result.iterator->value = styleDeclarationHandle.get(); - return styleDeclarationHandle.release(); -} - -InjectedBundleCSSStyleDeclarationHandle::InjectedBundleCSSStyleDeclarationHandle(CSSStyleDeclaration& styleDeclaration) - : m_styleDeclaration(styleDeclaration) -{ -} - -InjectedBundleCSSStyleDeclarationHandle::~InjectedBundleCSSStyleDeclarationHandle() -{ - domHandleCache().remove(m_styleDeclaration.ptr()); -} - -} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.h b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.h deleted file mode 100644 index 84c93c1ed..000000000 --- a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2014 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef InjectedBundleCSSStyleDeclarationHandle_h -#define InjectedBundleCSSStyleDeclarationHandle_h - -#include "APIObject.h" -#include <wtf/PassRefPtr.h> -#include <wtf/Ref.h> - -namespace WebCore { -class CSSStyleDeclaration; -} - -namespace WebKit { - -class InjectedBundleCSSStyleDeclarationHandle : public API::ObjectImpl<API::Object::Type::BundleCSSStyleDeclarationHandle> { -public: - static PassRefPtr<InjectedBundleCSSStyleDeclarationHandle> getOrCreate(WebCore::CSSStyleDeclaration*); - virtual ~InjectedBundleCSSStyleDeclarationHandle(); - -private: - InjectedBundleCSSStyleDeclarationHandle(WebCore::CSSStyleDeclaration&); - - Ref<WebCore::CSSStyleDeclaration> m_styleDeclaration; -}; - -} // namespace WebKit - -#endif // InjectedBundleCSSStyleDeclarationHandle_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleFileHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleFileHandle.cpp deleted file mode 100644 index 193403a4e..000000000 --- a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleFileHandle.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 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 - * 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. - */ - -#include "config.h" -#include "InjectedBundleFileHandle.h" - -#include <WebCore/File.h> -#include <wtf/HashMap.h> -#include <wtf/NeverDestroyed.h> - -using namespace WebCore; - -namespace WebKit { - -typedef HashMap<File*, InjectedBundleFileHandle*> DOMHandleCache; - -static DOMHandleCache& domHandleCache() -{ - static NeverDestroyed<DOMHandleCache> cache; - return cache; -} - -RefPtr<InjectedBundleFileHandle> InjectedBundleFileHandle::create(const String& path) -{ - auto file = File::create(path); - return adoptRef(new InjectedBundleFileHandle(file.get())); -} - -RefPtr<InjectedBundleFileHandle> InjectedBundleFileHandle::getOrCreate(File* file) -{ - if (!file) - return nullptr; - - DOMHandleCache::AddResult result = domHandleCache().add(file, nullptr); - if (!result.isNewEntry) - return RefPtr<InjectedBundleFileHandle>(result.iterator->value); - - RefPtr<InjectedBundleFileHandle> fileHandle = adoptRef(new InjectedBundleFileHandle(*file)); - result.iterator->value = fileHandle.get(); - return fileHandle; -} - -InjectedBundleFileHandle::InjectedBundleFileHandle(File& file) - : m_file(file) -{ -} - -InjectedBundleFileHandle::~InjectedBundleFileHandle() -{ - domHandleCache().remove(m_file.ptr()); -} - -File* InjectedBundleFileHandle::coreFile() -{ - return m_file.ptr(); -} - -} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleFileHandle.h b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleFileHandle.h deleted file mode 100644 index 27fd2cb5d..000000000 --- a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleFileHandle.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 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 - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef InjectedBundleFileHandle_h -#define InjectedBundleFileHandle_h - -#include "APIObject.h" -#include <wtf/Forward.h> -#include <wtf/PassRefPtr.h> -#include <wtf/RefPtr.h> - -namespace WebCore { -class File; -} - -namespace WebKit { - -class InjectedBundleFileHandle : public API::ObjectImpl<API::Object::Type::BundleFileHandle> { -public: - static RefPtr<InjectedBundleFileHandle> create(const WTF::String&); - static RefPtr<InjectedBundleFileHandle> getOrCreate(WebCore::File*); - - virtual ~InjectedBundleFileHandle(); - - WebCore::File* coreFile(); - -private: - InjectedBundleFileHandle(WebCore::File&); - - Ref<WebCore::File> m_file; -}; - -} // namespace WebKit - -#endif // InjectedBundleFileHandle_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp index e4dccb8d4..ccff2b36f 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp @@ -26,7 +26,6 @@ #include "config.h" #include "InjectedBundleNodeHandle.h" -#include "InjectedBundleRangeHandle.h" #include "ShareableBitmap.h" #include "WebFrame.h" #include "WebFrameLoaderClient.h" @@ -47,10 +46,7 @@ #include <WebCore/JSNode.h> #include <WebCore/Node.h> #include <WebCore/Page.h> -#include <WebCore/Position.h> -#include <WebCore/Range.h> #include <WebCore/RenderObject.h> -#include <WebCore/VisiblePosition.h> #include <wtf/HashMap.h> #include <wtf/NeverDestroyed.h> #include <wtf/text/WTFString.h> @@ -68,70 +64,65 @@ static DOMHandleCache& domHandleCache() return cache; } -RefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::getOrCreate(JSContextRef, JSObjectRef object) +PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::getOrCreate(JSContextRef, JSObjectRef object) { - Node* node = JSNode::toWrapped(toJS(object)); + Node* node = toNode(toJS(object)); return getOrCreate(node); } -RefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::getOrCreate(Node* node) +PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::getOrCreate(Node* node) { if (!node) - return nullptr; - - return InjectedBundleNodeHandle::getOrCreate(*node); -} + return 0; -Ref<InjectedBundleNodeHandle> InjectedBundleNodeHandle::getOrCreate(Node& node) -{ - DOMHandleCache::AddResult result = domHandleCache().add(&node, nullptr); + DOMHandleCache::AddResult result = domHandleCache().add(node, nullptr); if (!result.isNewEntry) - return Ref<InjectedBundleNodeHandle>(*result.iterator->value); + return PassRefPtr<InjectedBundleNodeHandle>(result.iterator->value); - Ref<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::create(node); - result.iterator->value = nodeHandle.ptr(); - return nodeHandle; + RefPtr<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::create(node); + result.iterator->value = nodeHandle.get(); + return nodeHandle.release(); } -Ref<InjectedBundleNodeHandle> InjectedBundleNodeHandle::create(Node& node) +PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::create(Node* node) { - return adoptRef(*new InjectedBundleNodeHandle(node)); + return adoptRef(new InjectedBundleNodeHandle(node)); } -InjectedBundleNodeHandle::InjectedBundleNodeHandle(Node& node) +InjectedBundleNodeHandle::InjectedBundleNodeHandle(Node* node) : m_node(node) { } InjectedBundleNodeHandle::~InjectedBundleNodeHandle() { - domHandleCache().remove(m_node.ptr()); + domHandleCache().remove(m_node.get()); } -Node* InjectedBundleNodeHandle::coreNode() +Node* InjectedBundleNodeHandle::coreNode() const { - return m_node.ptr(); + return m_node.get(); } -Ref<InjectedBundleNodeHandle> InjectedBundleNodeHandle::document() +PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::document() { - return getOrCreate(m_node->document()); + return getOrCreate(&m_node->document()); } // Additional DOM Operations // Note: These should only be operations that are not exposed to JavaScript. -IntRect InjectedBundleNodeHandle::elementBounds() +IntRect InjectedBundleNodeHandle::elementBounds() const { - if (!is<Element>(m_node)) + if (!m_node->isElementNode()) return IntRect(); - return downcast<Element>(m_node.get()).boundsInRootViewSpace(); + return toElement(m_node.get())->boundsInRootViewSpace(); } -IntRect InjectedBundleNodeHandle::renderRect(bool* isReplaced) +IntRect InjectedBundleNodeHandle::renderRect(bool* isReplaced) const { - return m_node->pixelSnappedRenderRect(isReplaced); + return m_node.get()->pixelSnappedRenderRect(isReplaced); } static PassRefPtr<WebImage> imageForRect(FrameView* frameView, const IntRect& rect, SnapshotOptions options) @@ -153,16 +144,7 @@ static PassRefPtr<WebImage> imageForRect(FrameView* frameView, const IntRect& re if (options & SnapshotOptionsExcludeSelectionHighlighting) shouldPaintSelection = FrameView::ExcludeSelection; - PaintBehavior paintBehavior = frameView->paintBehavior() | PaintBehaviorFlattenCompositingLayers; - if (options & SnapshotOptionsForceBlackText) - paintBehavior |= PaintBehaviorForceBlackText; - if (options & SnapshotOptionsForceWhiteText) - paintBehavior |= PaintBehaviorForceWhiteText; - - PaintBehavior oldPaintBehavior = frameView->paintBehavior(); - frameView->setPaintBehavior(paintBehavior); - frameView->paintContentsForSnapshot(*graphicsContext.get(), rect, shouldPaintSelection, FrameView::DocumentCoordinates); - frameView->setPaintBehavior(oldPaintBehavior); + frameView->paintContentsForSnapshot(graphicsContext.get(), rect, shouldPaintSelection, FrameView::DocumentCoordinates); return snapshot.release(); } @@ -171,155 +153,113 @@ PassRefPtr<WebImage> InjectedBundleNodeHandle::renderedImage(SnapshotOptions opt { Frame* frame = m_node->document().frame(); if (!frame) - return nullptr; + return 0; FrameView* frameView = frame->view(); if (!frameView) - return nullptr; + return 0; m_node->document().updateLayout(); RenderObject* renderer = m_node->renderer(); if (!renderer) - return nullptr; + return 0; LayoutRect topLevelRect; - IntRect paintingRect = snappedIntRect(renderer->paintingRootRect(topLevelRect)); + IntRect paintingRect = pixelSnappedIntRect(renderer->paintingRootRect(topLevelRect)); - frameView->setNodeToDraw(m_node.ptr()); + frameView->setNodeToDraw(m_node.get()); RefPtr<WebImage> image = imageForRect(frameView, paintingRect, options); frameView->setNodeToDraw(0); return image.release(); } -PassRefPtr<InjectedBundleRangeHandle> InjectedBundleNodeHandle::visibleRange() -{ - VisiblePosition start = firstPositionInNode(m_node.ptr()); - VisiblePosition end = lastPositionInNode(m_node.ptr()); - - RefPtr<Range> range = makeRange(start, end); - return InjectedBundleRangeHandle::getOrCreate(range.get()); -} - void InjectedBundleNodeHandle::setHTMLInputElementValueForUser(const String& value) { - if (!is<HTMLInputElement>(m_node)) + if (!isHTMLInputElement(m_node.get())) return; - downcast<HTMLInputElement>(m_node.get()).setValueForUser(value); + toHTMLInputElement(m_node.get())->setValueForUser(value); } -bool InjectedBundleNodeHandle::isHTMLInputElementAutoFilled() const +bool InjectedBundleNodeHandle::isHTMLInputElementAutofilled() const { - if (!is<HTMLInputElement>(m_node)) + if (!isHTMLInputElement(m_node.get())) return false; - return downcast<HTMLInputElement>(m_node.get()).isAutoFilled(); + return toHTMLInputElement(m_node.get())->isAutofilled(); } -void InjectedBundleNodeHandle::setHTMLInputElementAutoFilled(bool filled) +void InjectedBundleNodeHandle::setHTMLInputElementAutofilled(bool filled) { - if (!is<HTMLInputElement>(m_node)) + if (!isHTMLInputElement(m_node.get())) return; - downcast<HTMLInputElement>(m_node.get()).setAutoFilled(filled); -} - -bool InjectedBundleNodeHandle::isHTMLInputElementAutoFillButtonEnabled() const -{ - if (!is<HTMLInputElement>(m_node)) - return false; - - return downcast<HTMLInputElement>(m_node.get()).autoFillButtonType() != AutoFillButtonType::None; -} - -void InjectedBundleNodeHandle::setHTMLInputElementAutoFillButtonEnabled(AutoFillButtonType autoFillButtonType) -{ - if (!is<HTMLInputElement>(m_node)) - return; - - downcast<HTMLInputElement>(m_node.get()).setShowAutoFillButton(autoFillButtonType); -} - -IntRect InjectedBundleNodeHandle::htmlInputElementAutoFillButtonBounds() -{ - if (!is<HTMLInputElement>(m_node)) - return IntRect(); - - auto autoFillButton = downcast<HTMLInputElement>(m_node.get()).autoFillButtonElement(); - if (!autoFillButton) - return IntRect(); - - return autoFillButton->boundsInRootViewSpace(); + toHTMLInputElement(m_node.get())->setAutofilled(filled); } bool InjectedBundleNodeHandle::htmlInputElementLastChangeWasUserEdit() { - if (!is<HTMLInputElement>(m_node)) + if (!isHTMLInputElement(m_node.get())) return false; - return downcast<HTMLInputElement>(m_node.get()).lastChangeWasUserEdit(); + return toHTMLInputElement(m_node.get())->lastChangeWasUserEdit(); } bool InjectedBundleNodeHandle::htmlTextAreaElementLastChangeWasUserEdit() { - if (!is<HTMLTextAreaElement>(m_node)) - return false; - - return downcast<HTMLTextAreaElement>(m_node.get()).lastChangeWasUserEdit(); -} - -bool InjectedBundleNodeHandle::isTextField() const -{ - if (!is<HTMLInputElement>(m_node)) + if (!isHTMLTextAreaElement(m_node.get())) return false; - return downcast<HTMLInputElement>(m_node.get()).isText(); + return toHTMLTextAreaElement(m_node.get())->lastChangeWasUserEdit(); } PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::htmlTableCellElementCellAbove() { - if (!is<HTMLTableCellElement>(m_node)) - return nullptr; + if (!m_node->hasTagName(tdTag)) + return 0; - return getOrCreate(downcast<HTMLTableCellElement>(m_node.get()).cellAbove()); + return getOrCreate(static_cast<HTMLTableCellElement*>(m_node.get())->cellAbove()); } PassRefPtr<WebFrame> InjectedBundleNodeHandle::documentFrame() { if (!m_node->isDocumentNode()) - return nullptr; + return 0; - Frame* frame = downcast<Document>(m_node.get()).frame(); + Frame* frame = static_cast<Document*>(m_node.get())->frame(); if (!frame) - return nullptr; + return 0; - return WebFrame::fromCoreFrame(*frame); + WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame->loader().client()); + return webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0; } PassRefPtr<WebFrame> InjectedBundleNodeHandle::htmlFrameElementContentFrame() { - if (!is<HTMLFrameElement>(m_node)) - return nullptr; + if (!m_node->hasTagName(frameTag)) + return 0; - Frame* frame = downcast<HTMLFrameElement>(m_node.get()).contentFrame(); + Frame* frame = static_cast<HTMLFrameElement*>(m_node.get())->contentFrame(); if (!frame) - return nullptr; + return 0; - return WebFrame::fromCoreFrame(*frame); + WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame->loader().client()); + return webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0; } PassRefPtr<WebFrame> InjectedBundleNodeHandle::htmlIFrameElementContentFrame() { - if (!is<HTMLIFrameElement>(m_node)) - return nullptr; + if (!m_node->hasTagName(iframeTag)) + return 0; - Frame* frame = downcast<HTMLIFrameElement>(m_node.get()).contentFrame(); + Frame* frame = toHTMLIFrameElement(m_node.get())->contentFrame(); if (!frame) - return nullptr; + return 0; - return WebFrame::fromCoreFrame(*frame); + WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame->loader().client()); + return webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0; } } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h index 5ecfabd44..4cb3ec93c 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h @@ -36,44 +36,36 @@ namespace WebCore { class IntRect; class Node; - enum class AutoFillButtonType : uint8_t; } namespace WebKit { -class InjectedBundleRangeHandle; class InjectedBundleScriptWorld; class WebFrame; class WebImage; class InjectedBundleNodeHandle : public API::ObjectImpl<API::Object::Type::BundleNodeHandle> { public: - static RefPtr<InjectedBundleNodeHandle> getOrCreate(JSContextRef, JSObjectRef); - static RefPtr<InjectedBundleNodeHandle> getOrCreate(WebCore::Node*); - static Ref<InjectedBundleNodeHandle> getOrCreate(WebCore::Node&); + static PassRefPtr<InjectedBundleNodeHandle> getOrCreate(JSContextRef, JSObjectRef); + static PassRefPtr<InjectedBundleNodeHandle> getOrCreate(WebCore::Node*); virtual ~InjectedBundleNodeHandle(); - WebCore::Node* coreNode(); + WebCore::Node* coreNode() const; // Convenience DOM Operations - Ref<InjectedBundleNodeHandle> document(); + PassRefPtr<InjectedBundleNodeHandle> document(); // Additional DOM Operations // Note: These should only be operations that are not exposed to JavaScript. - WebCore::IntRect elementBounds(); - WebCore::IntRect renderRect(bool*); + WebCore::IntRect elementBounds() const; + WebCore::IntRect renderRect(bool*) const; PassRefPtr<WebImage> renderedImage(SnapshotOptions); - PassRefPtr<InjectedBundleRangeHandle> visibleRange(); void setHTMLInputElementValueForUser(const String&); - bool isHTMLInputElementAutoFilled() const; - void setHTMLInputElementAutoFilled(bool); - bool isHTMLInputElementAutoFillButtonEnabled() const; - void setHTMLInputElementAutoFillButtonEnabled(WebCore::AutoFillButtonType); - WebCore::IntRect htmlInputElementAutoFillButtonBounds(); + bool isHTMLInputElementAutofilled() const; + void setHTMLInputElementAutofilled(bool); bool htmlInputElementLastChangeWasUserEdit(); bool htmlTextAreaElementLastChangeWasUserEdit(); - bool isTextField() const; PassRefPtr<InjectedBundleNodeHandle> htmlTableCellElementCellAbove(); @@ -82,10 +74,10 @@ public: PassRefPtr<WebFrame> htmlIFrameElementContentFrame(); private: - static Ref<InjectedBundleNodeHandle> create(WebCore::Node&); - InjectedBundleNodeHandle(WebCore::Node&); + static PassRefPtr<InjectedBundleNodeHandle> create(WebCore::Node*); + InjectedBundleNodeHandle(WebCore::Node*); - Ref<WebCore::Node> m_node; + RefPtr<WebCore::Node> m_node; }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp index 8a945149b..9b947d103 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010, 2015 Apple Inc. All rights reserved. + * Copyright (C) 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,20 +26,9 @@ #include "config.h" #include "InjectedBundleRangeHandle.h" -#include "ShareableBitmap.h" -#include "WebImage.h" #include <JavaScriptCore/APICast.h> -#include <WebCore/Document.h> -#include <WebCore/FloatRect.h> -#include <WebCore/Frame.h> -#include <WebCore/FrameSelection.h> -#include <WebCore/FrameView.h> -#include <WebCore/GraphicsContext.h> -#include <WebCore/IntRect.h> #include <WebCore/JSRange.h> -#include <WebCore/Page.h> #include <WebCore/Range.h> -#include <WebCore/VisibleSelection.h> #include <wtf/HashMap.h> #include <wtf/NeverDestroyed.h> @@ -57,7 +46,7 @@ static DOMHandleCache& domHandleCache() PassRefPtr<InjectedBundleRangeHandle> InjectedBundleRangeHandle::getOrCreate(JSContextRef, JSObjectRef object) { - Range* range = JSRange::toWrapped(toJS(object)); + Range* range = toRange(toJS(object)); return getOrCreate(range); } @@ -75,9 +64,9 @@ PassRefPtr<InjectedBundleRangeHandle> InjectedBundleRangeHandle::getOrCreate(Ran return rangeHandle.release(); } -Ref<InjectedBundleRangeHandle> InjectedBundleRangeHandle::create(Range* range) +PassRefPtr<InjectedBundleRangeHandle> InjectedBundleRangeHandle::create(Range* range) { - return adoptRef(*new InjectedBundleRangeHandle(range)); + return adoptRef(new InjectedBundleRangeHandle(range)); } InjectedBundleRangeHandle::InjectedBundleRangeHandle(Range* range) @@ -95,60 +84,4 @@ Range* InjectedBundleRangeHandle::coreRange() const return m_range.get(); } -WebCore::IntRect InjectedBundleRangeHandle::boundingRectInWindowCoordinates() const -{ - FloatRect boundingRect = m_range->absoluteBoundingRect(); - Frame* frame = m_range->ownerDocument().frame(); - return frame->view()->contentsToWindow(enclosingIntRect(boundingRect)); -} - -PassRefPtr<WebImage> InjectedBundleRangeHandle::renderedImage(SnapshotOptions options) -{ - Document& ownerDocument = m_range->ownerDocument(); - Frame* frame = ownerDocument.frame(); - if (!frame) - return nullptr; - - FrameView* frameView = frame->view(); - if (!frameView) - return nullptr; - - VisibleSelection oldSelection = frame->selection().selection(); - frame->selection().setSelection(VisibleSelection(*m_range)); - - float scaleFactor = (options & SnapshotOptionsExcludeDeviceScaleFactor) ? 1 : frame->page()->deviceScaleFactor(); - IntRect paintRect = enclosingIntRect(m_range->absoluteBoundingRect()); - IntSize backingStoreSize = paintRect.size(); - backingStoreSize.scale(scaleFactor); - - RefPtr<ShareableBitmap> backingStore = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha); - if (!backingStore) - return nullptr; - - auto graphicsContext = backingStore->createGraphicsContext(); - graphicsContext->scale(FloatSize(scaleFactor, scaleFactor)); - - paintRect.move(frameView->frameRect().x(), frameView->frameRect().y()); - paintRect.moveBy(-frameView->scrollPosition()); - - graphicsContext->translate(-paintRect.x(), -paintRect.y()); - - PaintBehavior oldPaintBehavior = frameView->paintBehavior(); - PaintBehavior paintBehavior = oldPaintBehavior | PaintBehaviorSelectionOnly | PaintBehaviorFlattenCompositingLayers; - if (options & SnapshotOptionsForceBlackText) - paintBehavior |= PaintBehaviorForceBlackText; - if (options & SnapshotOptionsForceWhiteText) - paintBehavior |= PaintBehaviorForceWhiteText; - - frameView->setPaintBehavior(paintBehavior); - ownerDocument.updateLayout(); - - frameView->paint(*graphicsContext, paintRect); - frameView->setPaintBehavior(oldPaintBehavior); - - frame->selection().setSelection(oldSelection); - - return WebImage::create(backingStore); -} - } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.h b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.h index aeef69e2c..7695b4366 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.h @@ -27,20 +27,17 @@ #define InjectedBundleRangeHandle_h #include "APIObject.h" -#include "ImageOptions.h" #include <JavaScriptCore/JSBase.h> #include <wtf/PassRefPtr.h> #include <wtf/RefPtr.h> namespace WebCore { -class IntRect; -class Range; + class Range; } namespace WebKit { class InjectedBundleScriptWorld; -class WebImage; class InjectedBundleRangeHandle : public API::ObjectImpl<API::Object::Type::BundleRangeHandle> { public: @@ -49,13 +46,10 @@ public: virtual ~InjectedBundleRangeHandle(); - WebCore::IntRect boundingRectInWindowCoordinates() const; - PassRefPtr<WebImage> renderedImage(SnapshotOptions); - WebCore::Range* coreRange() const; private: - static Ref<InjectedBundleRangeHandle> create(WebCore::Range*); + static PassRefPtr<InjectedBundleRangeHandle> create(WebCore::Range*); InjectedBundleRangeHandle(WebCore::Range*); RefPtr<WebCore::Range> m_range; diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp index 1cafb9c49..c23ce4bc7 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp @@ -27,28 +27,26 @@ #include "InjectedBundle.h" #include "APIArray.h" -#include "APIData.h" #include "Arguments.h" #include "InjectedBundleScriptWorld.h" +#include "InjectedBundleUserMessageCoders.h" +#include "LayerTreeHost.h" #include "NotificationPermissionRequestManager.h" #include "SessionTracker.h" -#include "UserData.h" #include "WKAPICast.h" #include "WKBundleAPICast.h" +#include "WebApplicationCacheManager.h" #include "WebConnectionToUIProcess.h" +#include "WebContextMessageKinds.h" #include "WebCookieManager.h" #include "WebCoreArgumentCoders.h" +#include "WebDatabaseManager.h" #include "WebFrame.h" #include "WebFrameNetworkingContext.h" #include "WebPage.h" -#include "WebPageGroupProxy.h" -#include "WebPreferencesKeys.h" #include "WebPreferencesStore.h" #include "WebProcess.h" -#include "WebProcessCreationParameters.h" -#include "WebProcessPoolMessages.h" #include <JavaScriptCore/APICast.h> -#include <JavaScriptCore/Exception.h> #include <JavaScriptCore/JSLock.h> #include <WebCore/ApplicationCache.h> #include <WebCore/ApplicationCacheStorage.h> @@ -65,15 +63,14 @@ #include <WebCore/PageGroup.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> -#include <WebCore/SessionID.h> #include <WebCore/Settings.h> -#include <WebCore/UserContentController.h> #include <WebCore/UserGestureIndicator.h> -#if ENABLE(CSS_REGIONS) || ENABLE(CSS_COMPOSITING) +#if ENABLE(SHADOW_DOM) || ENABLE(CSS_REGIONS) || ENABLE(IFRAME_SEAMLESS) || ENABLE(CSS_COMPOSITING) #include <WebCore/RuntimeEnabledFeatures.h> #endif @@ -86,21 +83,11 @@ using namespace JSC; namespace WebKit { -PassRefPtr<InjectedBundle> InjectedBundle::create(const WebProcessCreationParameters& parameters, API::Object* initializationUserData) -{ - RefPtr<InjectedBundle> bundle = adoptRef(new InjectedBundle(parameters)); - - bundle->m_sandboxExtension = SandboxExtension::create(parameters.injectedBundlePathExtensionHandle); - if (!bundle->initialize(parameters, initializationUserData)) - return nullptr; - - return bundle.release(); -} - -InjectedBundle::InjectedBundle(const WebProcessCreationParameters& parameters) - : m_path(parameters.injectedBundlePath) +InjectedBundle::InjectedBundle(const String& path) + : m_path(path) , m_platformBundle(0) { + initializeClient(0); } InjectedBundle::~InjectedBundle() @@ -114,24 +101,52 @@ void InjectedBundle::initializeClient(const WKBundleClientBase* client) void InjectedBundle::postMessage(const String& messageName, API::Object* messageBody) { - auto& webProcess = WebProcess::singleton(); - webProcess.parentProcessConnection()->send(Messages::WebProcessPool::HandleMessage(messageName, UserData(webProcess.transformObjectsToHandles(messageBody))), 0); + auto encoder = std::make_unique<IPC::MessageEncoder>(WebContextLegacyMessages::messageReceiverName(), WebContextLegacyMessages::postMessageMessageName(), 0); + encoder->encode(messageName); + encoder->encode(InjectedBundleUserMessageEncoder(messageBody)); + + WebProcess::shared().parentProcessConnection()->sendMessage(std::move(encoder)); } void InjectedBundle::postSynchronousMessage(const String& messageName, API::Object* messageBody, RefPtr<API::Object>& returnData) { - UserData returnUserData; + InjectedBundleUserMessageDecoder messageDecoder(returnData); + + uint64_t syncRequestID; + std::unique_ptr<IPC::MessageEncoder> encoder = WebProcess::shared().parentProcessConnection()->createSyncMessageEncoder(WebContextLegacyMessages::messageReceiverName(), WebContextLegacyMessages::postSynchronousMessageMessageName(), 0, syncRequestID); + encoder->encode(messageName); + encoder->encode(InjectedBundleUserMessageEncoder(messageBody)); - auto& webProcess = WebProcess::singleton(); - if (!webProcess.parentProcessConnection()->sendSync(Messages::WebProcessPool::HandleSynchronousMessage(messageName, UserData(webProcess.transformObjectsToHandles(messageBody))), Messages::WebProcessPool::HandleSynchronousMessage::Reply(returnUserData), 0)) + std::unique_ptr<IPC::MessageDecoder> replyDecoder = WebProcess::shared().parentProcessConnection()->sendSyncMessage(syncRequestID, std::move(encoder), std::chrono::milliseconds::max()); + if (!replyDecoder || !replyDecoder->decode(messageDecoder)) { returnData = nullptr; - else - returnData = webProcess.transformHandlesToObjects(returnUserData.object()); + return; + } } WebConnection* InjectedBundle::webConnectionToUIProcess() const { - return WebProcess::singleton().webConnectionToUIProcess(); + return WebProcess::shared().webConnectionToUIProcess(); +} + +void InjectedBundle::setShouldTrackVisitedLinks(bool shouldTrackVisitedLinks) +{ + WebProcess::shared().setShouldTrackVisitedLinks(shouldTrackVisitedLinks); +} + +void InjectedBundle::setAlwaysAcceptCookies(bool accept) +{ + WebProcess::shared().supplement<WebCookieManager>()->setHTTPCookieAcceptPolicy(accept ? HTTPCookieAcceptPolicyAlways : HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain); +} + +void InjectedBundle::removeAllVisitedLinks() +{ + PageGroup::removeAllVisitedLinks(); +} + +void InjectedBundle::setCacheModel(uint32_t cacheModel) +{ + WebProcess::shared().setCacheModel(cacheModel); } void InjectedBundle::overrideBoolPreferenceForTestRunner(WebPageGroupProxy* pageGroup, const String& preference, bool enabled) @@ -140,46 +155,39 @@ void InjectedBundle::overrideBoolPreferenceForTestRunner(WebPageGroupProxy* page if (preference == "WebKitTabToLinksPreferenceKey") { WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::tabsToLinksKey(), enabled); - for (auto* page : pages) - WebPage::fromCorePage(page)->setTabToLinksEnabled(enabled); + for (HashSet<Page*>::iterator i = pages.begin(); i != pages.end(); ++i) { + WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient((*i)->mainFrame().loader().client()); + ASSERT(webFrameLoaderClient); + webFrameLoaderClient->webFrame()->page()->setTabToLinksEnabled(enabled); + } } if (preference == "WebKit2AsynchronousPluginInitializationEnabled") { WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::asynchronousPluginInitializationEnabledKey(), enabled); - for (auto* page : pages) - WebPage::fromCorePage(page)->setAsynchronousPluginInitializationEnabled(enabled); + for (HashSet<Page*>::iterator i = pages.begin(); i != pages.end(); ++i) { + WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient((*i)->mainFrame().loader().client()); + ASSERT(webFrameLoaderClient); + webFrameLoaderClient->webFrame()->page()->setAsynchronousPluginInitializationEnabled(enabled); + } } if (preference == "WebKit2AsynchronousPluginInitializationEnabledForAllPlugins") { WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::asynchronousPluginInitializationEnabledForAllPluginsKey(), enabled); - for (auto* page : pages) - WebPage::fromCorePage(page)->setAsynchronousPluginInitializationEnabledForAllPlugins(enabled); + for (HashSet<Page*>::iterator i = pages.begin(); i != pages.end(); ++i) { + WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient((*i)->mainFrame().loader().client()); + ASSERT(webFrameLoaderClient); + webFrameLoaderClient->webFrame()->page()->setAsynchronousPluginInitializationEnabledForAllPlugins(enabled); + } } if (preference == "WebKit2ArtificialPluginInitializationDelayEnabled") { WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::artificialPluginInitializationDelayEnabledKey(), enabled); - for (auto* page : pages) - WebPage::fromCorePage(page)->setArtificialPluginInitializationDelayEnabled(enabled); - } - -#if ENABLE(SERVICE_CONTROLS) - if (preference == "WebKitImageControlsEnabled") { - WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::imageControlsEnabledKey(), enabled); - for (auto* page : pages) - page->settings().setImageControlsEnabled(enabled); - return; + for (HashSet<Page*>::iterator i = pages.begin(); i != pages.end(); ++i) { + WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient((*i)->mainFrame().loader().client()); + ASSERT(webFrameLoaderClient); + webFrameLoaderClient->webFrame()->page()->setArtificialPluginInitializationDelayEnabled(enabled); + } } -#endif - -#if ENABLE(CSS_ANIMATIONS_LEVEL_2) - if (preference == "WebKitCSSAnimationTriggersEnabled") - RuntimeEnabledFeatures::sharedFeatures().setAnimationTriggersEnabled(enabled); -#endif - -#if ENABLE(WEB_ANIMATIONS) - if (preference == "WebKitWebAnimationsEnabled") - RuntimeEnabledFeatures::sharedFeatures().setWebAnimationsEnabled(enabled); -#endif #if ENABLE(CSS_REGIONS) if (preference == "WebKitCSSRegionsEnabled") @@ -195,6 +203,7 @@ void InjectedBundle::overrideBoolPreferenceForTestRunner(WebPageGroupProxy* page #define FOR_EACH_OVERRIDE_BOOL_PREFERENCE(macro) \ macro(WebKitAcceleratedCompositingEnabled, AcceleratedCompositingEnabled, acceleratedCompositingEnabled) \ macro(WebKitCanvasUsesAcceleratedDrawing, CanvasUsesAcceleratedDrawing, canvasUsesAcceleratedDrawing) \ + macro(WebKitCSSGridLayoutEnabled, CSSGridLayoutEnabled, cssGridLayoutEnabled) \ macro(WebKitFrameFlatteningEnabled, FrameFlatteningEnabled, frameFlatteningEnabled) \ macro(WebKitJavaEnabled, JavaEnabled, javaEnabled) \ macro(WebKitJavaScriptEnabled, ScriptEnabled, javaScriptEnabled) \ @@ -209,8 +218,10 @@ void InjectedBundle::overrideBoolPreferenceForTestRunner(WebPageGroupProxy* page macro(WebKitShouldRespectImageOrientation, ShouldRespectImageOrientation, shouldRespectImageOrientation) \ macro(WebKitEnableCaretBrowsing, CaretBrowsingEnabled, caretBrowsingEnabled) \ macro(WebKitDisplayImagesKey, LoadsImagesAutomatically, loadsImagesAutomatically) \ - macro(WebKitMediaStreamEnabled, MediaStreamEnabled, mediaStreamEnabled) \ - macro(WebKitHTTPEquivEnabled, HttpEquivEnabled, httpEquivEnabled) + macro(WebKitMediaStreamEnabled, MediaStreamEnabled, mediaStreamEnabled) + + if (preference == "WebKitAcceleratedCompositingEnabled") + enabled = enabled && LayerTreeHost::supportsAcceleratedCompositing(); #define OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES(TestRunnerName, SettingsName, WebPreferencesName) \ if (preference == #TestRunnerName) { \ @@ -286,15 +297,15 @@ void InjectedBundle::setJavaScriptCanAccessClipboard(WebPageGroupProxy* pageGrou void InjectedBundle::setPrivateBrowsingEnabled(WebPageGroupProxy* pageGroup, bool enabled) { // FIXME (NetworkProcess): This test-only function doesn't work with NetworkProcess, <https://bugs.webkit.org/show_bug.cgi?id=115274>. -#if PLATFORM(COCOA) || USE(CFNETWORK) || USE(SOUP) +#if PLATFORM(MAC) || USE(CFNETWORK) || USE(SOUP) if (enabled) - WebFrameNetworkingContext::ensurePrivateBrowsingSession(SessionID::legacyPrivateSessionID()); + WebFrameNetworkingContext::ensurePrivateBrowsingSession(SessionTracker::legacyPrivateSessionID); else - SessionTracker::destroySession(SessionID::legacyPrivateSessionID()); + SessionTracker::destroySession(SessionTracker::legacyPrivateSessionID); #endif const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages(); for (HashSet<Page*>::iterator iter = pages.begin(); iter != pages.end(); ++iter) - (*iter)->enableLegacyPrivateBrowsing(enabled); + (*iter)->settings().setPrivateBrowsingEnabled(enabled); } void InjectedBundle::setPopupBlockingEnabled(WebPageGroupProxy* pageGroup, bool enabled) @@ -321,12 +332,12 @@ void InjectedBundle::setSpatialNavigationEnabled(WebPageGroupProxy* pageGroup, b void InjectedBundle::addOriginAccessWhitelistEntry(const String& sourceOrigin, const String& destinationProtocol, const String& destinationHost, bool allowDestinationSubdomains) { - SecurityPolicy::addOriginAccessWhitelistEntry(SecurityOrigin::createFromString(sourceOrigin).get(), destinationProtocol, destinationHost, allowDestinationSubdomains); + SecurityPolicy::addOriginAccessWhitelistEntry(*SecurityOrigin::createFromString(sourceOrigin), destinationProtocol, destinationHost, allowDestinationSubdomains); } void InjectedBundle::removeOriginAccessWhitelistEntry(const String& sourceOrigin, const String& destinationProtocol, const String& destinationHost, bool allowDestinationSubdomains) { - SecurityPolicy::removeOriginAccessWhitelistEntry(SecurityOrigin::createFromString(sourceOrigin).get(), destinationProtocol, destinationHost, allowDestinationSubdomains); + SecurityPolicy::removeOriginAccessWhitelistEntry(*SecurityOrigin::createFromString(sourceOrigin), destinationProtocol, destinationHost, allowDestinationSubdomains); } void InjectedBundle::resetOriginAccessWhitelists() @@ -341,6 +352,72 @@ void InjectedBundle::setAsynchronousSpellCheckingEnabled(WebPageGroupProxy* page (*iter)->settings().setAsynchronousSpellCheckingEnabled(enabled); } +void InjectedBundle::clearAllDatabases() +{ +#if ENABLE(SQL_DATABASE) + WebProcess::shared().supplement<WebDatabaseManager>()->deleteAllDatabases(); +#endif +} + +void InjectedBundle::setDatabaseQuota(uint64_t quota) +{ +#if ENABLE(SQL_DATABASE) + // Historically, we've used the following (somewhat non-sensical) string + // for the databaseIdentifier of local files. + WebProcess::shared().supplement<WebDatabaseManager>()->setQuotaForOrigin("file__0", quota); +#else + UNUSED_PARAM(quota); +#endif +} + +void InjectedBundle::clearApplicationCache() +{ + WebProcess::shared().supplement<WebApplicationCacheManager>()->deleteAllEntries(); +} + +void InjectedBundle::clearApplicationCacheForOrigin(const String& originString) +{ + RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString(originString); + ApplicationCache::deleteCacheForOrigin(origin.get()); +} + +void InjectedBundle::setAppCacheMaximumSize(uint64_t size) +{ + WebProcess::shared().supplement<WebApplicationCacheManager>()->setAppCacheMaximumSize(size); +} + +uint64_t InjectedBundle::appCacheUsageForOrigin(const String& originString) +{ + RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString(originString); + return ApplicationCache::diskUsageForOrigin(origin.get()); +} + +void InjectedBundle::setApplicationCacheOriginQuota(const String& originString, uint64_t bytes) +{ + RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString(originString); + cacheStorage().storeUpdatedQuotaForOrigin(origin.get(), bytes); +} + +void InjectedBundle::resetApplicationCacheOriginQuota(const String& originString) +{ + RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString(originString); + cacheStorage().storeUpdatedQuotaForOrigin(origin.get(), cacheStorage().defaultOriginQuota()); +} + +PassRefPtr<API::Array> InjectedBundle::originsWithApplicationCache() +{ + HashSet<RefPtr<SecurityOrigin>> origins; + cacheStorage().getOriginsWithCache(origins); + + Vector<RefPtr<API::Object>> originIdentifiers; + originIdentifiers.reserveInitialCapacity(origins.size()); + + for (const auto& origin : origins) + originIdentifiers.uncheckedAppend(API::String::create(origin->databaseIdentifier())); + + return API::Array::create(std::move(originIdentifiers)); +} + int InjectedBundle::numberOfPages(WebFrame* frame, double pageWidthInPixels, double pageHeightInPixels) { Frame* coreFrame = frame ? frame->coreFrame() : 0; @@ -351,7 +428,7 @@ int InjectedBundle::numberOfPages(WebFrame* frame, double pageWidthInPixels, dou if (!pageHeightInPixels) pageHeightInPixels = coreFrame->view()->height(); - return PrintContext::numberOfPages(*coreFrame, FloatSize(pageWidthInPixels, pageHeightInPixels)); + return PrintContext::numberOfPages(coreFrame, FloatSize(pageWidthInPixels, pageHeightInPixels)); } int InjectedBundle::pageNumberForElementById(WebFrame* frame, const String& id, double pageWidthInPixels, double pageHeightInPixels) @@ -360,7 +437,7 @@ int InjectedBundle::pageNumberForElementById(WebFrame* frame, const String& id, if (!coreFrame) return -1; - Element* element = coreFrame->document()->getElementById(id); + Element* element = coreFrame->document()->getElementById(AtomicString(id)); if (!element) return -1; @@ -398,60 +475,56 @@ bool InjectedBundle::isProcessingUserGesture() void InjectedBundle::addUserScript(WebPageGroupProxy* pageGroup, InjectedBundleScriptWorld* scriptWorld, const String& source, const String& url, API::Array* whitelist, API::Array* blacklist, WebCore::UserScriptInjectionTime injectionTime, WebCore::UserContentInjectedFrames injectedFrames) { // url is not from URL::string(), i.e. it has not already been parsed by URL, so we have to use the relative URL constructor for URL instead of the ParsedURLStringTag version. - auto userScript = std::make_unique<UserScript>(source, URL(URL(), url), whitelist ? whitelist->toStringVector() : Vector<String>(), blacklist ? blacklist->toStringVector() : Vector<String>(), injectionTime, injectedFrames); - - pageGroup->userContentController().addUserScript(scriptWorld->coreWorld(), WTFMove(userScript)); + PageGroup::pageGroup(pageGroup->identifier())->addUserScriptToWorld(scriptWorld->coreWorld(), source, URL(URL(), url), whitelist ? whitelist->toStringVector() : Vector<String>(), blacklist ? blacklist->toStringVector() : Vector<String>(), injectionTime, injectedFrames); } void InjectedBundle::addUserStyleSheet(WebPageGroupProxy* pageGroup, InjectedBundleScriptWorld* scriptWorld, const String& source, const String& url, API::Array* whitelist, API::Array* blacklist, WebCore::UserContentInjectedFrames injectedFrames) { // url is not from URL::string(), i.e. it has not already been parsed by URL, so we have to use the relative URL constructor for URL instead of the ParsedURLStringTag version. - auto userStyleSheet = std::make_unique<UserStyleSheet>(source, URL(URL(), url), whitelist ? whitelist->toStringVector() : Vector<String>(), blacklist ? blacklist->toStringVector() : Vector<String>(), injectedFrames, UserStyleUserLevel); - - pageGroup->userContentController().addUserStyleSheet(scriptWorld->coreWorld(), WTFMove(userStyleSheet), InjectInExistingDocuments); + PageGroup::pageGroup(pageGroup->identifier())->addUserStyleSheetToWorld(scriptWorld->coreWorld(), source, URL(URL(), url), whitelist ? whitelist->toStringVector() : Vector<String>(), blacklist ? blacklist->toStringVector() : Vector<String>(), injectedFrames); } void InjectedBundle::removeUserScript(WebPageGroupProxy* pageGroup, InjectedBundleScriptWorld* scriptWorld, const String& url) { // url is not from URL::string(), i.e. it has not already been parsed by URL, so we have to use the relative URL constructor for URL instead of the ParsedURLStringTag version. - pageGroup->userContentController().removeUserScript(scriptWorld->coreWorld(), URL(URL(), url)); + PageGroup::pageGroup(pageGroup->identifier())->removeUserScriptFromWorld(scriptWorld->coreWorld(), URL(URL(), url)); } void InjectedBundle::removeUserStyleSheet(WebPageGroupProxy* pageGroup, InjectedBundleScriptWorld* scriptWorld, const String& url) { // url is not from URL::string(), i.e. it has not already been parsed by URL, so we have to use the relative URL constructor for URL instead of the ParsedURLStringTag version. - pageGroup->userContentController().removeUserStyleSheet(scriptWorld->coreWorld(), URL(URL(), url)); + PageGroup::pageGroup(pageGroup->identifier())->removeUserStyleSheetFromWorld(scriptWorld->coreWorld(), URL(URL(), url)); } void InjectedBundle::removeUserScripts(WebPageGroupProxy* pageGroup, InjectedBundleScriptWorld* scriptWorld) { - pageGroup->userContentController().removeUserScripts(scriptWorld->coreWorld()); + PageGroup::pageGroup(pageGroup->identifier())->removeUserScriptsFromWorld(scriptWorld->coreWorld()); } void InjectedBundle::removeUserStyleSheets(WebPageGroupProxy* pageGroup, InjectedBundleScriptWorld* scriptWorld) { - pageGroup->userContentController().removeUserStyleSheets(scriptWorld->coreWorld()); + PageGroup::pageGroup(pageGroup->identifier())->removeUserStyleSheetsFromWorld(scriptWorld->coreWorld()); } void InjectedBundle::removeAllUserContent(WebPageGroupProxy* pageGroup) { - pageGroup->userContentController().removeAllUserContent(); + PageGroup::pageGroup(pageGroup->identifier())->removeAllUserContent(); } void InjectedBundle::garbageCollectJavaScriptObjects() { - GCController::singleton().garbageCollectNow(); + gcController().garbageCollectNow(); } void InjectedBundle::garbageCollectJavaScriptObjectsOnAlternateThreadForDebugging(bool waitUntilDone) { - GCController::singleton().garbageCollectOnAlternateThreadForDebugging(waitUntilDone); + gcController().garbageCollectOnAlternateThreadForDebugging(waitUntilDone); } size_t InjectedBundle::javaScriptObjectsCount() { JSLockHolder lock(JSDOMWindow::commonVM()); - return JSDOMWindow::commonVM().heap.objectCount(); + return JSDOMWindow::commonVM()->heap.objectCount(); } void InjectedBundle::reportException(JSContextRef context, JSValueRef exception) @@ -524,10 +597,10 @@ void InjectedBundle::removeAllWebNotificationPermissions(WebPage* page) uint64_t InjectedBundle::webNotificationID(JSContextRef jsContext, JSValueRef jsNotification) { #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) - WebCore::Notification* notification = JSNotification::toWrapped(toJS(toJS(jsContext), jsNotification)); + WebCore::Notification* notification = toNotification(toJS(toJS(jsContext), jsNotification)); if (!notification) return 0; - return WebProcess::singleton().supplement<WebNotificationManager>()->notificationIDForTesting(notification); + return WebProcess::shared().supplement<WebNotificationManager>()->notificationIDForTesting(notification); #else UNUSED_PARAM(jsContext); UNUSED_PARAM(jsNotification); @@ -548,19 +621,15 @@ void InjectedBundle::setTabKeyCyclesThroughElements(WebPage* page, bool enabled) page->corePage()->setTabKeyCyclesThroughElements(enabled); } -void InjectedBundle::setCSSAnimationTriggersEnabled(bool enabled) +void InjectedBundle::setSerialLoadingEnabled(bool enabled) { -#if ENABLE(CSS_ANIMATIONS_LEVEL_2) - RuntimeEnabledFeatures::sharedFeatures().setAnimationTriggersEnabled(enabled); -#else - UNUSED_PARAM(enabled); -#endif + resourceLoadScheduler()->setSerialLoadingEnabled(enabled); } -void InjectedBundle::setWebAnimationsEnabled(bool enabled) +void InjectedBundle::setShadowDOMEnabled(bool enabled) { -#if ENABLE(WEB_ANIMATIONS) - RuntimeEnabledFeatures::sharedFeatures().setWebAnimationsEnabled(enabled); +#if ENABLE(SHADOW_DOM) + RuntimeEnabledFeatures::sharedFeatures().setShadowDOMEnabled(enabled); #else UNUSED_PARAM(enabled); #endif @@ -584,4 +653,18 @@ void InjectedBundle::setCSSCompositingEnabled(bool enabled) #endif } +void InjectedBundle::setSeamlessIFramesEnabled(bool enabled) +{ +#if ENABLE(IFRAME_SEAMLESS) + RuntimeEnabledFeatures::sharedFeatures().setSeamlessIFramesEnabled(enabled); +#else + UNUSED_PARAM(enabled); +#endif +} + +void InjectedBundle::dispatchPendingLoadRequests() +{ + resourceLoadScheduler()->servePendingRequests(); +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h index 609512f55..23508ce1b 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h @@ -33,7 +33,6 @@ #include <WebCore/UserContentTypes.h> #include <WebCore/UserScriptTypes.h> #include <wtf/PassRefPtr.h> -#include <wtf/RetainPtr.h> #include <wtf/text/WTFString.h> #if PLATFORM(GTK) @@ -44,10 +43,8 @@ typedef struct _GModule GModule; #include <Eina.h> #endif -#if USE(FOUNDATION) +#if PLATFORM(MAC) OBJC_CLASS NSBundle; -OBJC_CLASS NSMutableDictionary; -OBJC_CLASS WKWebProcessBundleParameters; #endif namespace API { @@ -58,12 +55,11 @@ class Data; namespace IPC { class ArgumentDecoder; class Connection; -class DataReference; } namespace WebKit { -#if USE(FOUNDATION) +#if PLATFORM(MAC) typedef NSBundle *PlatformBundle; #elif PLATFORM(GTK) typedef ::GModule* PlatformBundle; @@ -77,18 +73,17 @@ class WebConnection; class WebFrame; class WebPage; class WebPageGroupProxy; -struct WebProcessCreationParameters; class InjectedBundle : public API::ObjectImpl<API::Object::Type::Bundle> { public: - static PassRefPtr<InjectedBundle> create(const WebProcessCreationParameters&, API::Object* initializationUserData); - + static PassRefPtr<InjectedBundle> create(const String& path) + { + return adoptRef(new InjectedBundle(path)); + } ~InjectedBundle(); - bool initialize(const WebProcessCreationParameters&, API::Object* initializationUserData); - - void setBundleParameter(const String&, const IPC::DataReference&); - void setBundleParameters(const IPC::DataReference&); + bool load(API::Object* initializationUserData); + void setSandboxExtension(PassRefPtr<SandboxExtension> sandboxExtension) { m_sandboxExtension = sandboxExtension; } // API void initializeClient(const WKBundleClientBase*); @@ -98,6 +93,11 @@ public: WebConnection* webConnectionToUIProcess() const; // TestRunner only SPI + void setShouldTrackVisitedLinks(bool); + void setAlwaysAcceptCookies(bool); + void removeAllVisitedLinks(); + void setCacheModel(uint32_t); + void activateMacFontAscentHack(); void overrideBoolPreferenceForTestRunner(WebPageGroupProxy*, const String& preference, bool enabled); void overrideXSSAuditorEnabledForTestRunner(WebPageGroupProxy* pageGroup, bool enabled); void setAllowUniversalAccessFromFileURLs(WebPageGroupProxy*, bool); @@ -133,6 +133,19 @@ public: void removeUserStyleSheets(WebPageGroupProxy*, InjectedBundleScriptWorld*); void removeAllUserContent(WebPageGroupProxy*); + // Local storage API + void clearAllDatabases(); + void setDatabaseQuota(uint64_t); + + // Application Cache API + void clearApplicationCache(); + void clearApplicationCacheForOrigin(const String& origin); + void setAppCacheMaximumSize(uint64_t); + uint64_t appCacheUsageForOrigin(const String& origin); + void setApplicationCacheOriginQuota(const String& origin, uint64_t); + void resetApplicationCacheOriginQuota(const String& origin); + PassRefPtr<API::Array> originsWithApplicationCache(); + // Garbage collection API void garbageCollectJavaScriptObjects(); void garbageCollectJavaScriptObjectsOnAlternateThreadForDebugging(bool waitUntilDone); @@ -151,18 +164,14 @@ public: void setTabKeyCyclesThroughElements(WebPage*, bool enabled); void setSerialLoadingEnabled(bool); - void setCSSAnimationTriggersEnabled(bool); - void setWebAnimationsEnabled(bool); + void setShadowDOMEnabled(bool); void setCSSRegionsEnabled(bool); void setCSSCompositingEnabled(bool); + void setSeamlessIFramesEnabled(bool); void dispatchPendingLoadRequests(); -#if PLATFORM(COCOA) && WK_API_ENABLED - WKWebProcessBundleParameters *bundleParameters(); -#endif - private: - explicit InjectedBundle(const WebProcessCreationParameters&); + explicit InjectedBundle(const String&); String m_path; PlatformBundle m_platformBundle; // This is leaked right now, since we never unload the bundle/module. @@ -170,10 +179,6 @@ private: RefPtr<SandboxExtension> m_sandboxExtension; InjectedBundleClient m_client; - -#if PLATFORM(COCOA) && WK_API_ENABLED - RetainPtr<WKWebProcessBundleParameters> m_bundleParameters; -#endif }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardList.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardList.h index a44d0b962..ccbf97bd2 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardList.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardList.h @@ -37,9 +37,9 @@ class InjectedBundleBackForwardListItem; class InjectedBundleBackForwardList : public API::ObjectImpl<API::Object::Type::BundleBackForwardList> { public: - static Ref<InjectedBundleBackForwardList> create(WebPage* page) + static PassRefPtr<InjectedBundleBackForwardList> create(WebPage* page) { - return adoptRef(*new InjectedBundleBackForwardList(page)); + return adoptRef(new InjectedBundleBackForwardList(page)); } void detach() { m_page = 0; } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardListItem.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardListItem.cpp index 91a06ee2b..79c545b93 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardListItem.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardListItem.cpp @@ -32,15 +32,15 @@ using namespace WebCore; namespace WebKit { -Ref<API::Array> InjectedBundleBackForwardListItem::children() const +PassRefPtr<API::Array> InjectedBundleBackForwardListItem::children() const { Vector<RefPtr<API::Object>> children; children.reserveInitialCapacity(m_item->children().size()); for (const auto& child : m_item->children()) - children.uncheckedAppend(InjectedBundleBackForwardListItem::create(const_cast<HistoryItem*>(child.ptr()))); + children.uncheckedAppend(InjectedBundleBackForwardListItem::create(child)); - return API::Array::create(WTFMove(children)); + return API::Array::create(std::move(children)); } } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardListItem.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardListItem.h index 42827f6f4..516a5c15a 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardListItem.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardListItem.h @@ -57,7 +57,7 @@ public: bool isInPageCache() const { return m_item->isInPageCache(); } bool hasCachedPageExpired() const { return m_item->hasCachedPageExpired(); } - Ref<API::Array> children() const; + PassRefPtr<API::Array> children() const; private: InjectedBundleBackForwardListItem(PassRefPtr<WebCore::HistoryItem> item) : m_item(item) { } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleClient.cpp index 15df16c2e..4e215826e 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleClient.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleClient.cpp @@ -26,10 +26,7 @@ #include "config.h" #include "InjectedBundleClient.h" -#include "InjectedBundle.h" #include "WKBundleAPICast.h" -#include "WebPage.h" -#include "WebPageGroupProxy.h" namespace WebKit { diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.cpp index edfaf78f7..5108e8075 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.cpp @@ -47,9 +47,9 @@ static ExtensionMap& allExtensions() return map; } -Ref<InjectedBundleDOMWindowExtension> InjectedBundleDOMWindowExtension::create(WebFrame* frame, InjectedBundleScriptWorld* world) +PassRefPtr<InjectedBundleDOMWindowExtension> InjectedBundleDOMWindowExtension::create(WebFrame* frame, InjectedBundleScriptWorld* world) { - return adoptRef(*new InjectedBundleDOMWindowExtension(frame, world)); + return adoptRef(new InjectedBundleDOMWindowExtension(frame, world)); } InjectedBundleDOMWindowExtension* InjectedBundleDOMWindowExtension::get(DOMWindowExtension* extension) @@ -73,10 +73,8 @@ InjectedBundleDOMWindowExtension::~InjectedBundleDOMWindowExtension() WebFrame* InjectedBundleDOMWindowExtension::frame() const { Frame* frame = m_coreExtension->frame(); - if (!frame) - return nullptr; - - return WebFrame::fromCoreFrame(*frame); + WebFrameLoaderClient* webFrameLoaderClient = frame ? toWebFrameLoaderClient(frame->loader().client()) : 0; + return webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0; } InjectedBundleScriptWorld* InjectedBundleDOMWindowExtension::world() const diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.h index 065f728f8..1caf39638 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.h @@ -42,7 +42,7 @@ class WebFrame; class InjectedBundleDOMWindowExtension : public API::ObjectImpl<API::Object::Type::BundleDOMWindowExtension> { public: - static Ref<InjectedBundleDOMWindowExtension> create(WebFrame*, InjectedBundleScriptWorld*); + static PassRefPtr<InjectedBundleDOMWindowExtension> create(WebFrame*, InjectedBundleScriptWorld*); static InjectedBundleDOMWindowExtension* get(WebCore::DOMWindowExtension*); virtual ~InjectedBundleDOMWindowExtension(); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp index c1305ebd8..ef92d9b68 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp @@ -41,9 +41,9 @@ using namespace WebCore; namespace WebKit { -Ref<InjectedBundleHitTestResult> InjectedBundleHitTestResult::create(const WebCore::HitTestResult& hitTestResult) +PassRefPtr<InjectedBundleHitTestResult> InjectedBundleHitTestResult::create(const WebCore::HitTestResult& hitTestResult) { - return adoptRef(*new InjectedBundleHitTestResult(hitTestResult)); + return adoptRef(new InjectedBundleHitTestResult(hitTestResult)); } PassRefPtr<InjectedBundleNodeHandle> InjectedBundleHitTestResult::nodeHandle() const @@ -51,31 +51,28 @@ PassRefPtr<InjectedBundleNodeHandle> InjectedBundleHitTestResult::nodeHandle() c return InjectedBundleNodeHandle::getOrCreate(m_hitTestResult.innerNonSharedNode()); } -PassRefPtr<InjectedBundleNodeHandle> InjectedBundleHitTestResult::urlElementHandle() const -{ - return InjectedBundleNodeHandle::getOrCreate(m_hitTestResult.URLElement()); -} - WebFrame* InjectedBundleHitTestResult::frame() const { Node* node = m_hitTestResult.innerNonSharedNode(); if (!node) - return nullptr; + return 0; Frame* frame = node->document().frame(); if (!frame) - return nullptr; + return 0; - return WebFrame::fromCoreFrame(*frame); + WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame->loader().client()); + return webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0; } WebFrame* InjectedBundleHitTestResult::targetFrame() const { Frame* frame = m_hitTestResult.targetFrame(); if (!frame) - return nullptr; + return 0; - return WebFrame::fromCoreFrame(*frame); + WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame->loader().client()); + return webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0; } String InjectedBundleHitTestResult::absoluteImageURL() const @@ -108,21 +105,16 @@ bool InjectedBundleHitTestResult::mediaHasAudio() const return m_hitTestResult.mediaHasAudio(); } -bool InjectedBundleHitTestResult::isDownloadableMedia() const -{ - return m_hitTestResult.isDownloadableMedia(); -} - BundleHitTestResultMediaType InjectedBundleHitTestResult::mediaType() const { #if !ENABLE(VIDEO) return BundleHitTestResultMediaTypeNone; #else WebCore::Node* node = m_hitTestResult.innerNonSharedNode(); - if (!is<Element>(*node)) + if (!node->isElementNode()) return BundleHitTestResultMediaTypeNone; - if (!downcast<Element>(*node).isMediaElement()) + if (!toElement(node)->isMediaElement()) return BundleHitTestResultMediaTypeNone; return m_hitTestResult.mediaIsVideo() ? BundleHitTestResultMediaTypeVideo : BundleHitTestResultMediaTypeAudio; diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.h index cb7589eee..a23d00908 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.h @@ -40,12 +40,11 @@ class WebFrame; class InjectedBundleHitTestResult : public API::ObjectImpl<API::Object::Type::BundleHitTestResult> { public: - static Ref<InjectedBundleHitTestResult> create(const WebCore::HitTestResult&); + static PassRefPtr<InjectedBundleHitTestResult> create(const WebCore::HitTestResult&); const WebCore::HitTestResult& coreHitTestResult() const { return m_hitTestResult; } - PassRefPtr<InjectedBundleNodeHandle> nodeHandle() const; - PassRefPtr<InjectedBundleNodeHandle> urlElementHandle() const; + PassRefPtr<InjectedBundleNodeHandle> nodeHandle() const; WebFrame* frame() const; WebFrame* targetFrame() const; @@ -55,7 +54,6 @@ public: String absoluteMediaURL() const; bool mediaIsInFullscreen() const; bool mediaHasAudio() const; - bool isDownloadableMedia() const; BundleHitTestResultMediaType mediaType() const; String linkLabel() const; diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp index ae8a9fa03..f37f7336a 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp @@ -81,17 +81,15 @@ WebMouseEvent::Button InjectedBundleNavigationAction::mouseButtonForNavigationAc } -Ref<InjectedBundleNavigationAction> InjectedBundleNavigationAction::create(WebFrame* frame, const NavigationAction& action, PassRefPtr<FormState> formState) +PassRefPtr<InjectedBundleNavigationAction> InjectedBundleNavigationAction::create(WebFrame* frame, const NavigationAction& action, PassRefPtr<FormState> formState) { - return adoptRef(*new InjectedBundleNavigationAction(frame, action, formState)); + return adoptRef(new InjectedBundleNavigationAction(frame, action, formState)); } InjectedBundleNavigationAction::InjectedBundleNavigationAction(WebFrame* frame, const NavigationAction& navigationAction, PassRefPtr<FormState> prpFormState) : m_navigationType(navigationAction.type()) , m_modifiers(modifiersForNavigationAction(navigationAction)) , m_mouseButton(WebMouseEvent::NoButton) - , m_shouldOpenExternalURLs(navigationAction.shouldOpenExternalURLsPolicy() == ShouldOpenExternalURLsPolicy::ShouldAllow || navigationAction.shouldOpenExternalURLsPolicy() == ShouldOpenExternalURLsPolicy::ShouldAllowExternalSchemes) - , m_shouldTryAppLinks(navigationAction.shouldOpenExternalURLsPolicy() == ShouldOpenExternalURLsPolicy::ShouldAllow) { if (const MouseEvent* mouseEvent = mouseEventForNavigationAction(navigationAction)) { m_hitTestResult = InjectedBundleHitTestResult::create(frame->coreFrame()->eventHandler().hitTestResultAtPoint(mouseEvent->absoluteLocation())); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.h index fb84e6a1e..04e7a6b43 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.h @@ -45,7 +45,7 @@ class WebFrame; class InjectedBundleNavigationAction : public API::ObjectImpl<API::Object::Type::BundleNavigationAction> { public: - static Ref<InjectedBundleNavigationAction> create(WebFrame*, const WebCore::NavigationAction&, PassRefPtr<WebCore::FormState>); + static PassRefPtr<InjectedBundleNavigationAction> create(WebFrame*, const WebCore::NavigationAction&, PassRefPtr<WebCore::FormState>); static WebEvent::Modifiers modifiersForNavigationAction(const WebCore::NavigationAction&); static WebMouseEvent::Button mouseButtonForNavigationAction(const WebCore::NavigationAction&); @@ -56,9 +56,6 @@ public: InjectedBundleHitTestResult* hitTestResult() const { return m_hitTestResult.get(); } InjectedBundleNodeHandle* formElement() const { return m_formElement.get(); } - bool shouldOpenExternalURLs() const { return m_shouldOpenExternalURLs; } - bool shouldTryAppLinks() const { return m_shouldTryAppLinks; } - private: InjectedBundleNavigationAction(WebFrame*, const WebCore::NavigationAction&, PassRefPtr<WebCore::FormState>); @@ -67,8 +64,6 @@ private: WebMouseEvent::Button m_mouseButton; RefPtr<InjectedBundleHitTestResult> m_hitTestResult; RefPtr<InjectedBundleNodeHandle> m_formElement; - bool m_shouldOpenExternalURLs; - bool m_shouldTryAppLinks; }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.cpp index d04333ae9..36233874d 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.cpp @@ -35,32 +35,25 @@ #include "WebContextMenuItem.h" #include "WKAPICast.h" #include "WKBundleAPICast.h" -#include "WebPage.h" #include <WebCore/ContextMenu.h> using namespace WebCore; namespace WebKit { -InjectedBundlePageContextMenuClient::InjectedBundlePageContextMenuClient(const WKBundlePageContextMenuClientBase* client) -{ - initialize(client); -} - -bool InjectedBundlePageContextMenuClient::getCustomMenuFromDefaultItems(WebPage& page, const HitTestResult& hitTestResult, const Vector<ContextMenuItem>& proposedMenu, Vector<WebContextMenuItemData>& newMenu, RefPtr<API::Object>& userData) +bool InjectedBundlePageContextMenuClient::getCustomMenuFromDefaultItems(WebPage* page, InjectedBundleHitTestResult* hitTestResult, const Vector<WebContextMenuItemData>& defaultMenu, Vector<WebContextMenuItemData>& newMenu, RefPtr<API::Object>& userData) { if (!m_client.getContextMenuFromDefaultMenu) return false; - Vector<WebContextMenuItemData> defaultMenu = kitItems(proposedMenu); Vector<RefPtr<API::Object>> defaultMenuItems; defaultMenuItems.reserveInitialCapacity(defaultMenu.size()); for (const auto& item : defaultMenu) defaultMenuItems.uncheckedAppend(WebContextMenuItem::create(item)); - WKArrayRef newMenuWK = nullptr; - WKTypeRef userDataToPass = nullptr; - m_client.getContextMenuFromDefaultMenu(toAPI(&page), toAPI(&InjectedBundleHitTestResult::create(hitTestResult).get()), toAPI(API::Array::create(WTFMove(defaultMenuItems)).ptr()), &newMenuWK, &userDataToPass, m_client.base.clientInfo); + WKArrayRef newMenuWK = 0; + WKTypeRef userDataToPass = 0; + m_client.getContextMenuFromDefaultMenu(toAPI(page), toAPI(hitTestResult), toAPI(API::Array::create(std::move(defaultMenuItems)).get()), &newMenuWK, &userDataToPass, m_client.base.clientInfo); RefPtr<API::Array> array = adoptRef(toImpl(newMenuWK)); userData = adoptRef(toImpl(userDataToPass)); @@ -77,21 +70,11 @@ bool InjectedBundlePageContextMenuClient::getCustomMenuFromDefaultItems(WebPage& continue; } - newMenu.append(item->data()); + newMenu.append(*item->data()); } return true; } -void InjectedBundlePageContextMenuClient::prepareForImmediateAction(WebPage& page, const HitTestResult& hitTestResult, RefPtr<API::Object>& userData) -{ - if (!m_client.prepareForActionMenu) - return; - - WKTypeRef userDataToPass = nullptr; - m_client.prepareForActionMenu(toAPI(&page), toAPI(&InjectedBundleHitTestResult::create(hitTestResult).get()), &userDataToPass, m_client.base.clientInfo); - userData = adoptRef(toImpl(userDataToPass)); -} - } // namespace WebKit #endif // ENABLE(CONTEXT_MENUS) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.h index 9a3263a35..944065e3a 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.h @@ -29,33 +29,30 @@ #if ENABLE(CONTEXT_MENUS) #include "APIClient.h" -#include "APIInjectedBundlePageContextMenuClient.h" #include "WKBundlePage.h" +#include <wtf/Vector.h> namespace API { class Object; template<> struct ClientTraits<WKBundlePageContextMenuClientBase> { - typedef std::tuple<WKBundlePageContextMenuClientV0, WKBundlePageContextMenuClientV1> Versions; + typedef std::tuple<WKBundlePageContextMenuClientV0> Versions; }; } namespace WebCore { -class ContextMenuItem; -class HitTestResult; +class ContextMenu; } namespace WebKit { + +class InjectedBundleHitTestResult; class WebContextMenuItemData; class WebPage; -class InjectedBundlePageContextMenuClient : public API::Client<WKBundlePageContextMenuClientBase>, public API::InjectedBundle::PageContextMenuClient { +class InjectedBundlePageContextMenuClient : public API::Client<WKBundlePageContextMenuClientBase> { public: - explicit InjectedBundlePageContextMenuClient(const WKBundlePageContextMenuClientBase*); - -private: - bool getCustomMenuFromDefaultItems(WebPage&, const WebCore::HitTestResult&, const Vector<WebCore::ContextMenuItem>& defaultMenu, Vector<WebContextMenuItemData>& newMenu, RefPtr<API::Object>& userData) override; - void prepareForImmediateAction(WebPage&, const WebCore::HitTestResult&, RefPtr<API::Object>& userData) override; + bool getCustomMenuFromDefaultItems(WebPage*, InjectedBundleHitTestResult*, const Vector<WebContextMenuItemData>& defaultMenu, Vector<WebContextMenuItemData>& newMenu, RefPtr<API::Object>& userData); }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.cpp index 443f0c6b2..06fcc5a64 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.cpp @@ -28,36 +28,14 @@ #include "WKAPICast.h" #include "WKBundleAPICast.h" -#include "WebPage.h" namespace WebKit { -void InjectedBundlePageDiagnosticLoggingClient::logDiagnosticMessageDeprecated(WebPage* page, const String& message, const String& description, const String& success) -{ - if (!m_client.logDiagnosticMessageDeprecated) - return; - m_client.logDiagnosticMessageDeprecated(toAPI(page), toAPI(message.impl()), toAPI(description.impl()), toAPI(success.impl()), m_client.base.clientInfo); -} - -void InjectedBundlePageDiagnosticLoggingClient::logDiagnosticMessage(WebPage* page, const String& message, const String& description) +void InjectedBundlePageDiagnosticLoggingClient::logDiagnosticMessage(WebPage* page, const String& message, const String& description, const String& success) { if (!m_client.logDiagnosticMessage) return; - m_client.logDiagnosticMessage(toAPI(page), toAPI(message.impl()), toAPI(description.impl()), m_client.base.clientInfo); -} - -void InjectedBundlePageDiagnosticLoggingClient::logDiagnosticMessageWithResult(WebPage* page, const String& message, const String& description, WebCore::DiagnosticLoggingResultType result) -{ - if (!m_client.logDiagnosticMessageWithResult) - return; - m_client.logDiagnosticMessageWithResult(toAPI(page), toAPI(message.impl()), toAPI(description.impl()), toAPI(result), m_client.base.clientInfo); -} - -void InjectedBundlePageDiagnosticLoggingClient::logDiagnosticMessageWithValue(WebPage* page, const String& message, const String& description, const String& value) -{ - if (!m_client.logDiagnosticMessageWithValue) - return; - m_client.logDiagnosticMessageWithValue(toAPI(page), toAPI(message.impl()), toAPI(description.impl()), toAPI(value.impl()), m_client.base.clientInfo); + m_client.logDiagnosticMessage(toAPI(page), toCopiedAPI(message), toCopiedAPI(description), toCopiedAPI(success), m_client.base.clientInfo); } } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.h index 9edaa7c76..ddf838039 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.h @@ -29,12 +29,11 @@ #include "APIClient.h" #include "WKBundlePage.h" #include <JavaScriptCore/JSBase.h> -#include <WebCore/DiagnosticLoggingResultType.h> #include <wtf/Forward.h> namespace API { template<> struct ClientTraits<WKBundlePageDiagnosticLoggingClientBase> { - typedef std::tuple<WKBundlePageDiagnosticLoggingClientV0, WKBundlePageDiagnosticLoggingClientV1> Versions; + typedef std::tuple<WKBundlePageDiagnosticLoggingClientV0> Versions; }; } @@ -46,10 +45,7 @@ class WebPage; class InjectedBundlePageDiagnosticLoggingClient : public API::Client<WKBundlePageDiagnosticLoggingClientBase> { public: - void logDiagnosticMessageDeprecated(WebPage*, const String& message, const String& description, const String& success); - void logDiagnosticMessage(WebPage*, const String& message, const String& description); - void logDiagnosticMessageWithResult(WebPage*, const String& message, const String& description, WebCore::DiagnosticLoggingResultType); - void logDiagnosticMessageWithValue(WebPage*, const String& message, const String& description, const String& value); + void logDiagnosticMessage(WebPage*, const String& message, const String& description, const String& success); }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageEditorClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageEditorClient.cpp index b71c9fb3e..277a9ed54 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageEditorClient.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageEditorClient.cpp @@ -28,13 +28,11 @@ #include "APIArray.h" #include "APIData.h" -#include "InjectedBundleCSSStyleDeclarationHandle.h" #include "InjectedBundleNodeHandle.h" #include "InjectedBundleRangeHandle.h" #include "WKAPICast.h" #include "WKBundleAPICast.h" #include "WKString.h" -#include "WebPage.h" #include <wtf/text/WTFString.h> using namespace WebCore; @@ -100,9 +98,8 @@ bool InjectedBundlePageEditorClient::shouldChangeSelectedRange(WebPage* page, Ra bool InjectedBundlePageEditorClient::shouldApplyStyle(WebPage* page, CSSStyleDeclaration* style, Range* range) { if (m_client.shouldApplyStyle) { - RefPtr<InjectedBundleCSSStyleDeclarationHandle> styleHandle = InjectedBundleCSSStyleDeclarationHandle::getOrCreate(style); RefPtr<InjectedBundleRangeHandle> rangeHandle = InjectedBundleRangeHandle::getOrCreate(range); - return m_client.shouldApplyStyle(toAPI(page), toAPI(styleHandle.get()), toAPI(rangeHandle.get()), m_client.base.clientInfo); + return m_client.shouldApplyStyle(toAPI(page), toAPI(style), toAPI(rangeHandle.get()), m_client.base.clientInfo); } return true; } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageEditorClient.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageEditorClient.h index 6803c63f0..24c6a882a 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageEditorClient.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageEditorClient.h @@ -40,9 +40,10 @@ template<> struct ClientTraits<WKBundlePageEditorClientBase> { } namespace WebCore { -class CSSStyleDeclaration; -class Node; -class Range; + class CSSStyleDeclaration; + class Node; + class Range; + class SharedBuffer; } namespace WebKit { diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp index d642dc0b6..f93bb9631 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp @@ -27,12 +27,10 @@ #include "InjectedBundlePageFormClient.h" #include "APIArray.h" -#include "APIDictionary.h" +#include "ImmutableDictionary.h" #include "InjectedBundleNodeHandle.h" #include "WKAPICast.h" #include "WKBundleAPICast.h" -#include "WebFrame.h" -#include "WebPage.h" #include <WebCore/HTMLFormElement.h> #include <WebCore/HTMLInputElement.h> #include <WebCore/HTMLTextAreaElement.h> @@ -41,11 +39,6 @@ using namespace WebCore; namespace WebKit { -InjectedBundlePageFormClient::InjectedBundlePageFormClient(const WKBundlePageFormClientBase* client) -{ - initialize(client); -} - void InjectedBundlePageFormClient::didFocusTextField(WebPage* page, HTMLInputElement* inputElement, WebFrame* frame) { if (!m_client.didFocusTextField) @@ -73,14 +66,11 @@ void InjectedBundlePageFormClient::textFieldDidEndEditing(WebPage* page, HTMLInp m_client.textFieldDidEndEditing(toAPI(page), toAPI(nodeHandle.get()), toAPI(frame), m_client.base.clientInfo); } -void InjectedBundlePageFormClient::textDidChangeInTextField(WebPage* page, HTMLInputElement* inputElement, WebFrame* frame, bool initiatedByUserTyping) +void InjectedBundlePageFormClient::textDidChangeInTextField(WebPage* page, HTMLInputElement* inputElement, WebFrame* frame) { if (!m_client.textDidChangeInTextField) return; - if (!initiatedByUserTyping) - return; - RefPtr<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::getOrCreate(inputElement); m_client.textDidChangeInTextField(toAPI(page), toAPI(nodeHandle.get()), toAPI(frame), m_client.base.clientInfo); } @@ -94,36 +84,13 @@ void InjectedBundlePageFormClient::textDidChangeInTextArea(WebPage* page, HTMLTe m_client.textDidChangeInTextArea(toAPI(page), toAPI(nodeHandle.get()), toAPI(frame), m_client.base.clientInfo); } -static WKInputFieldActionType toWKInputFieldActionType(API::InjectedBundle::FormClient::InputFieldAction action) -{ - switch (action) { - case API::InjectedBundle::FormClient::InputFieldAction::MoveUp: - return WKInputFieldActionTypeMoveUp; - case API::InjectedBundle::FormClient::InputFieldAction::MoveDown: - return WKInputFieldActionTypeMoveDown; - case API::InjectedBundle::FormClient::InputFieldAction::Cancel: - return WKInputFieldActionTypeCancel; - case API::InjectedBundle::FormClient::InputFieldAction::InsertTab: - return WKInputFieldActionTypeInsertTab; - case API::InjectedBundle::FormClient::InputFieldAction::InsertBacktab: - return WKInputFieldActionTypeInsertBacktab; - case API::InjectedBundle::FormClient::InputFieldAction::InsertNewline: - return WKInputFieldActionTypeInsertNewline; - case API::InjectedBundle::FormClient::InputFieldAction::InsertDelete: - return WKInputFieldActionTypeInsertDelete; - } - - ASSERT_NOT_REACHED(); - return WKInputFieldActionTypeCancel; -} - -bool InjectedBundlePageFormClient::shouldPerformActionInTextField(WebPage* page, HTMLInputElement* inputElement, API::InjectedBundle::FormClient::InputFieldAction actionType, WebFrame* frame) +bool InjectedBundlePageFormClient::shouldPerformActionInTextField(WebPage* page, HTMLInputElement* inputElement, WKInputFieldActionType actionType, WebFrame* frame) { if (!m_client.shouldPerformActionInTextField) return false; RefPtr<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::getOrCreate(inputElement); - return m_client.shouldPerformActionInTextField(toAPI(page), toAPI(nodeHandle.get()), toWKInputFieldActionType(actionType), toAPI(frame), m_client.base.clientInfo); + return m_client.shouldPerformActionInTextField(toAPI(page), toAPI(nodeHandle.get()), actionType, toAPI(frame), m_client.base.clientInfo); } void InjectedBundlePageFormClient::willSendSubmitEvent(WebPage* page, HTMLFormElement* formElement, WebFrame* frame, WebFrame* sourceFrame, const Vector<std::pair<String, String>>& values) @@ -133,12 +100,12 @@ void InjectedBundlePageFormClient::willSendSubmitEvent(WebPage* page, HTMLFormEl RefPtr<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::getOrCreate(formElement); - API::Dictionary::MapType map; + ImmutableDictionary::MapType map; for (size_t i = 0; i < values.size(); ++i) map.set(values[i].first, API::String::create(values[i].second)); - auto textFieldsMap = API::Dictionary::create(WTFMove(map)); + auto textFieldsMap = ImmutableDictionary::create(std::move(map)); - m_client.willSendSubmitEvent(toAPI(page), toAPI(nodeHandle.get()), toAPI(frame), toAPI(sourceFrame), toAPI(textFieldsMap.ptr()), m_client.base.clientInfo); + m_client.willSendSubmitEvent(toAPI(page), toAPI(nodeHandle.get()), toAPI(frame), toAPI(sourceFrame), toAPI(textFieldsMap.get()), m_client.base.clientInfo); } void InjectedBundlePageFormClient::willSubmitForm(WebPage* page, HTMLFormElement* formElement, WebFrame* frame, WebFrame* sourceFrame, const Vector<std::pair<String, String>>& values, RefPtr<API::Object>& userData) @@ -148,13 +115,13 @@ void InjectedBundlePageFormClient::willSubmitForm(WebPage* page, HTMLFormElement RefPtr<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::getOrCreate(formElement); - API::Dictionary::MapType map; + ImmutableDictionary::MapType map; for (size_t i = 0; i < values.size(); ++i) map.set(values[i].first, API::String::create(values[i].second)); - auto textFieldsMap = API::Dictionary::create(WTFMove(map)); + auto textFieldsMap = ImmutableDictionary::create(std::move(map)); WKTypeRef userDataToPass = 0; - m_client.willSubmitForm(toAPI(page), toAPI(nodeHandle.get()), toAPI(frame), toAPI(sourceFrame), toAPI(textFieldsMap.ptr()), &userDataToPass, m_client.base.clientInfo); + m_client.willSubmitForm(toAPI(page), toAPI(nodeHandle.get()), toAPI(frame), toAPI(sourceFrame), toAPI(textFieldsMap.get()), &userDataToPass, m_client.base.clientInfo); userData = adoptRef(toImpl(userDataToPass)); } @@ -169,7 +136,7 @@ void InjectedBundlePageFormClient::didAssociateFormControls(WebPage* page, const for (const auto& element : elements) elementHandles.uncheckedAppend(InjectedBundleNodeHandle::getOrCreate(element.get())); - m_client.didAssociateFormControls(toAPI(page), toAPI(API::Array::create(WTFMove(elementHandles)).ptr()), m_client.base.clientInfo); + m_client.didAssociateFormControls(toAPI(page), toAPI(API::Array::create(std::move(elementHandles)).get()), m_client.base.clientInfo); } bool InjectedBundlePageFormClient::shouldNotifyOnFormChanges(WebPage* page) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.h index c2bc2fa4e..6dcfc78ae 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.h @@ -27,32 +27,44 @@ #define InjectedBundlePageFormClient_h #include "APIClient.h" -#include "APIInjectedBundleFormClient.h" -#include "WKBundlePageFormClient.h" +#include "WKBundlePage.h" +#include <algorithm> +#include <wtf/Forward.h> +#include <wtf/Vector.h> namespace API { +class Object; template<> struct ClientTraits<WKBundlePageFormClientBase> { typedef std::tuple<WKBundlePageFormClientV0, WKBundlePageFormClientV1, WKBundlePageFormClientV2> Versions; }; } +namespace WebCore { +class Element; +class HTMLFormElement; +class HTMLInputElement; +class HTMLTextAreaElement; +} + namespace WebKit { -class InjectedBundlePageFormClient : public API::Client<WKBundlePageFormClientBase>, public API::InjectedBundle::FormClient { +class ImmutableDictionary; +class WebFrame; +class WebPage; + +class InjectedBundlePageFormClient : public API::Client<WKBundlePageFormClientBase> { public: - explicit InjectedBundlePageFormClient(const WKBundlePageFormClientBase*); - - virtual void didFocusTextField(WebPage*, WebCore::HTMLInputElement*, WebFrame*) override; - virtual void textFieldDidBeginEditing(WebPage*, WebCore::HTMLInputElement*, WebFrame*) override; - virtual void textFieldDidEndEditing(WebPage*, WebCore::HTMLInputElement*, WebFrame*) override; - virtual void textDidChangeInTextField(WebPage*, WebCore::HTMLInputElement*, WebFrame*, bool initiatedByUserTyping) override; - virtual void textDidChangeInTextArea(WebPage*, WebCore::HTMLTextAreaElement*, WebFrame*) override; - virtual bool shouldPerformActionInTextField(WebPage*, WebCore::HTMLInputElement*, InputFieldAction, WebFrame*) override; - virtual void willSubmitForm(WebPage*, WebCore::HTMLFormElement*, WebFrame*, WebFrame* sourceFrame, const Vector<std::pair<String, String>>&, RefPtr<API::Object>& userData) override; - virtual void willSendSubmitEvent(WebPage*, WebCore::HTMLFormElement*, WebFrame*, WebFrame* sourceFrame, const Vector<std::pair<String, String>>&) override; - virtual void didAssociateFormControls(WebPage*, const Vector<RefPtr<WebCore::Element>>&) override; - virtual bool shouldNotifyOnFormChanges(WebPage*) override; + void didFocusTextField(WebPage*, WebCore::HTMLInputElement*, WebFrame*); + void textFieldDidBeginEditing(WebPage*, WebCore::HTMLInputElement*, WebFrame*); + void textFieldDidEndEditing(WebPage*, WebCore::HTMLInputElement*, WebFrame*); + void textDidChangeInTextField(WebPage*, WebCore::HTMLInputElement*, WebFrame*); + void textDidChangeInTextArea(WebPage*, WebCore::HTMLTextAreaElement*, WebFrame*); + bool shouldPerformActionInTextField(WebPage*, WebCore::HTMLInputElement*, WKInputFieldActionType, WebFrame*); + void willSubmitForm(WebPage*, WebCore::HTMLFormElement*, WebFrame*, WebFrame* sourceFrame, const Vector<std::pair<String, String>>&, RefPtr<API::Object>& userData); + void willSendSubmitEvent(WebPage*, WebCore::HTMLFormElement*, WebFrame*, WebFrame* sourceFrame, const Vector<std::pair<String, String>>&); + void didAssociateFormControls(WebPage*, const Vector<RefPtr<WebCore::Element>>&); + bool shouldNotifyOnFormChanges(WebPage*); }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp index 696a18e99..47f326439 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp @@ -29,16 +29,11 @@ #include "APIArray.h" #include "APIData.h" #include "APIError.h" -#include "APIURL.h" #include "APIURLRequest.h" -#include "InjectedBundleBackForwardListItem.h" #include "InjectedBundleDOMWindowExtension.h" #include "InjectedBundleScriptWorld.h" #include "WKAPICast.h" #include "WKBundleAPICast.h" -#include "WKSharedAPICast.h" -#include "WebFrame.h" -#include "WebPage.h" #include <WebCore/SharedBuffer.h> #include <wtf/text/WTFString.h> @@ -346,15 +341,15 @@ void InjectedBundlePageLoaderClient::featuresUsedInPage(WebPage* page, const Vec if (!m_client.featuresUsedInPage) return; - return m_client.featuresUsedInPage(toAPI(page), toAPI(API::Array::createStringArray(features).ptr()), m_client.base.clientInfo); + return m_client.featuresUsedInPage(toAPI(page), toAPI(API::Array::createStringArray(features).get()), m_client.base.clientInfo); } -API::String* InjectedBundlePageLoaderClient::userAgentForURL(WebFrame* frame, API::URL* url) const +void InjectedBundlePageLoaderClient::willDestroyFrame(WebPage* page, WebFrame* frame) { - if (!m_client.userAgentForURL) - return nullptr; - WKStringRef userAgent = m_client.userAgentForURL(toAPI(frame), toAPI(url), m_client.base.clientInfo); - return toImpl(userAgent); + if (!m_client.willDestroyFrame) + return; + + m_client.willDestroyFrame(toAPI(page), toAPI(frame), m_client.base.clientInfo); } - + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h index b4cb0eb10..ae2b9503a 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h @@ -27,8 +27,6 @@ #define InjectedBundlePageLoaderClient_h #include "APIClient.h" -#include "APIString.h" -#include "APIURL.h" #include "SameDocumentNavigationType.h" #include "WKBundlePage.h" #include <JavaScriptCore/JSBase.h> @@ -40,7 +38,7 @@ namespace API { class Object; template<> struct ClientTraits<WKBundlePageLoaderClientBase> { - typedef std::tuple<WKBundlePageLoaderClientV0, WKBundlePageLoaderClientV1, WKBundlePageLoaderClientV2, WKBundlePageLoaderClientV3, WKBundlePageLoaderClientV4, WKBundlePageLoaderClientV5, WKBundlePageLoaderClientV6, WKBundlePageLoaderClientV7, WKBundlePageLoaderClientV8> Versions; + typedef std::tuple<WKBundlePageLoaderClientV0, WKBundlePageLoaderClientV1, WKBundlePageLoaderClientV2, WKBundlePageLoaderClientV3, WKBundlePageLoaderClientV4, WKBundlePageLoaderClientV5, WKBundlePageLoaderClientV6, WKBundlePageLoaderClientV7> Versions; }; } @@ -101,7 +99,6 @@ public: void featuresUsedInPage(WebPage*, const Vector<String>&); void willDestroyFrame(WebPage*, WebFrame*); - API::String* userAgentForURL(WebFrame*, API::URL*) const; }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.cpp index 2cb977cd8..a067e3f5d 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.cpp @@ -28,10 +28,7 @@ #include "APIError.h" #include "APIURLRequest.h" -#include "InjectedBundleNavigationAction.h" #include "WKBundleAPICast.h" -#include "WebFrame.h" -#include "WebPage.h" using namespace WebCore; @@ -42,10 +39,10 @@ WKBundlePagePolicyAction InjectedBundlePagePolicyClient::decidePolicyForNavigati if (!m_client.decidePolicyForNavigationAction) return WKBundlePagePolicyActionPassThrough; - Ref<API::URLRequest> request = API::URLRequest::create(resourceRequest); + RefPtr<API::URLRequest> request = API::URLRequest::create(resourceRequest); WKTypeRef userDataToPass = 0; - WKBundlePagePolicyAction policy = m_client.decidePolicyForNavigationAction(toAPI(page), toAPI(frame), toAPI(action), toAPI(request.ptr()), &userDataToPass, m_client.base.clientInfo); + WKBundlePagePolicyAction policy = m_client.decidePolicyForNavigationAction(toAPI(page), toAPI(frame), toAPI(action), toAPI(request.get()), &userDataToPass, m_client.base.clientInfo); userData = adoptRef(toImpl(userDataToPass)); return policy; } @@ -55,10 +52,10 @@ WKBundlePagePolicyAction InjectedBundlePagePolicyClient::decidePolicyForNewWindo if (!m_client.decidePolicyForNewWindowAction) return WKBundlePagePolicyActionPassThrough; - Ref<API::URLRequest> request = API::URLRequest::create(resourceRequest); + RefPtr<API::URLRequest> request = API::URLRequest::create(resourceRequest); WKTypeRef userDataToPass = 0; - WKBundlePagePolicyAction policy = m_client.decidePolicyForNewWindowAction(toAPI(page), toAPI(frame), toAPI(action), toAPI(request.ptr()), toAPI(frameName.impl()), &userDataToPass, m_client.base.clientInfo); + WKBundlePagePolicyAction policy = m_client.decidePolicyForNewWindowAction(toAPI(page), toAPI(frame), toAPI(action), toAPI(request.get()), toAPI(frameName.impl()), &userDataToPass, m_client.base.clientInfo); userData = adoptRef(toImpl(userDataToPass)); return policy; } @@ -68,11 +65,11 @@ WKBundlePagePolicyAction InjectedBundlePagePolicyClient::decidePolicyForResponse if (!m_client.decidePolicyForResponse) return WKBundlePagePolicyActionPassThrough; - Ref<API::URLResponse> response = API::URLResponse::create(resourceResponse); - Ref<API::URLRequest> request = API::URLRequest::create(resourceRequest); + RefPtr<API::URLResponse> response = API::URLResponse::create(resourceResponse); + RefPtr<API::URLRequest> request = API::URLRequest::create(resourceRequest); WKTypeRef userDataToPass = 0; - WKBundlePagePolicyAction policy = m_client.decidePolicyForResponse(toAPI(page), toAPI(frame), toAPI(response.ptr()), toAPI(request.ptr()), &userDataToPass, m_client.base.clientInfo); + WKBundlePagePolicyAction policy = m_client.decidePolicyForResponse(toAPI(page), toAPI(frame), toAPI(response.get()), toAPI(request.get()), &userDataToPass, m_client.base.clientInfo); userData = adoptRef(toImpl(userDataToPass)); return policy; } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageResourceLoadClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageResourceLoadClient.cpp index 132e26dc8..800b40790 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageResourceLoadClient.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageResourceLoadClient.cpp @@ -28,8 +28,6 @@ #include "WKAPICast.h" #include "WKBundleAPICast.h" -#include "WebFrame.h" -#include "WebPage.h" using namespace WebCore; @@ -49,15 +47,10 @@ void InjectedBundlePageResourceLoadClient::willSendRequestForFrame(WebPage* page return; RefPtr<API::URLRequest> returnedRequest = adoptRef(toImpl(m_client.willSendRequestForFrame(toAPI(page), toAPI(frame), identifier, toAPI(request), toAPI(redirectResponse), m_client.base.clientInfo))); - if (returnedRequest) { - // If the client returned an HTTP body, we want to use that http body. This is needed to fix <rdar://problem/23763584> - auto& returnedResourceRequest = returnedRequest->resourceRequest(); - RefPtr<FormData> returnedHTTPBody = returnedResourceRequest.httpBody(); - request.updateFromDelegatePreservingOldProperties(returnedResourceRequest); - if (returnedHTTPBody) - request.setHTTPBody(WTFMove(returnedHTTPBody)); - } else - request = { }; + if (returnedRequest) + request.updateFromDelegatePreservingOldHTTPBody(returnedRequest->resourceRequest()); + else + request = ResourceRequest(); } void InjectedBundlePageResourceLoadClient::didReceiveResponseForResource(WebPage* page, WebFrame* frame, uint64_t identifier, const WebCore::ResourceResponse& response) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp index 38e6c23ae..da02c8866 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp @@ -26,25 +26,17 @@ #include "config.h" #include "InjectedBundlePageUIClient.h" -#include "APISecurityOrigin.h" #include "InjectedBundleHitTestResult.h" -#include "InjectedBundleNodeHandle.h" #include "WKAPICast.h" #include "WKBundleAPICast.h" -#include "WebFrame.h" -#include "WebPage.h" +#include "WebSecurityOrigin.h" #include <wtf/text/WTFString.h> using namespace WebCore; namespace WebKit { -InjectedBundlePageUIClient::InjectedBundlePageUIClient(const WKBundlePageUIClientBase* client) -{ - initialize(client); -} - -void InjectedBundlePageUIClient::willAddMessageToConsole(WebPage* page, MessageSource, MessageLevel, const String& message, unsigned lineNumber, unsigned /*columnNumber*/, const String& /*sourceID*/) +void InjectedBundlePageUIClient::willAddMessageToConsole(WebPage* page, const String& message, int32_t lineNumber) { if (m_client.willAddMessageToConsole) m_client.willAddMessageToConsole(toAPI(page), toAPI(message.impl()), lineNumber, m_client.base.clientInfo); @@ -104,61 +96,45 @@ String InjectedBundlePageUIClient::shouldGenerateFileForUpload(WebPage* page, co String InjectedBundlePageUIClient::generateFileForUpload(WebPage* page, const String& originalFilePath) { - if (!m_client.generateFileForUpload) + if (!m_client.shouldGenerateFileForUpload) return String(); RefPtr<API::String> generatedFilePath = adoptRef(toImpl(m_client.generateFileForUpload(toAPI(page), toAPI(originalFilePath.impl()), m_client.base.clientInfo))); return generatedFilePath ? generatedFilePath->string() : String(); } -static API::InjectedBundle::PageUIClient::UIElementVisibility toUIElementVisibility(WKBundlePageUIElementVisibility visibility) -{ - switch (visibility) { - case WKBundlePageUIElementVisibilityUnknown: - return API::InjectedBundle::PageUIClient::UIElementVisibility::Unknown; - case WKBundlePageUIElementVisible: - return API::InjectedBundle::PageUIClient::UIElementVisibility::Visible; - case WKBundlePageUIElementHidden: - return API::InjectedBundle::PageUIClient::UIElementVisibility::Hidden; - } - - ASSERT_NOT_REACHED(); - return API::InjectedBundle::PageUIClient::UIElementVisibility::Unknown; -} - -API::InjectedBundle::PageUIClient::UIElementVisibility InjectedBundlePageUIClient::statusBarIsVisible(WebPage* page) +WKBundlePageUIElementVisibility InjectedBundlePageUIClient::statusBarIsVisible(WebPage* page) { if (!m_client.statusBarIsVisible) - return API::InjectedBundle::PageUIClient::UIElementVisibility::Unknown; + return WKBundlePageUIElementVisibilityUnknown; - return toUIElementVisibility(m_client.statusBarIsVisible(toAPI(page), m_client.base.clientInfo)); + return m_client.statusBarIsVisible(toAPI(page), m_client.base.clientInfo); } -API::InjectedBundle::PageUIClient::UIElementVisibility InjectedBundlePageUIClient::menuBarIsVisible(WebPage* page) +WKBundlePageUIElementVisibility InjectedBundlePageUIClient::menuBarIsVisible(WebPage* page) { if (!m_client.menuBarIsVisible) - return API::InjectedBundle::PageUIClient::UIElementVisibility::Unknown; + return WKBundlePageUIElementVisibilityUnknown; - return toUIElementVisibility(m_client.menuBarIsVisible(toAPI(page), m_client.base.clientInfo)); + return m_client.menuBarIsVisible(toAPI(page), m_client.base.clientInfo); } -API::InjectedBundle::PageUIClient::UIElementVisibility InjectedBundlePageUIClient::toolbarsAreVisible(WebPage* page) +WKBundlePageUIElementVisibility InjectedBundlePageUIClient::toolbarsAreVisible(WebPage* page) { if (!m_client.toolbarsAreVisible) - return API::InjectedBundle::PageUIClient::UIElementVisibility::Unknown; + return WKBundlePageUIElementVisibilityUnknown; - return toUIElementVisibility(m_client.toolbarsAreVisible(toAPI(page), m_client.base.clientInfo)); + return m_client.toolbarsAreVisible(toAPI(page), m_client.base.clientInfo); } -bool InjectedBundlePageUIClient::didReachApplicationCacheOriginQuota(WebPage* page, API::SecurityOrigin* origin, int64_t totalBytesNeeded) +void InjectedBundlePageUIClient::didReachApplicationCacheOriginQuota(WebPage* page, WebSecurityOrigin* origin, int64_t totalBytesNeeded) { if (!m_client.didReachApplicationCacheOriginQuota) - return false; + return; m_client.didReachApplicationCacheOriginQuota(toAPI(page), toAPI(origin), totalBytesNeeded, m_client.base.clientInfo); - return true; } -uint64_t InjectedBundlePageUIClient::didExceedDatabaseQuota(WebPage* page, API::SecurityOrigin* origin, const String& databaseName, const String& databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes) +uint64_t InjectedBundlePageUIClient::didExceedDatabaseQuota(WebPage* page, WebSecurityOrigin* origin, const String& databaseName, const String& databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes) { if (!m_client.didExceedDatabaseQuota) return 0; @@ -202,14 +178,4 @@ String InjectedBundlePageUIClient::plugInExtraScript() const return script ? script->string() : String(); } -void InjectedBundlePageUIClient::didClickAutoFillButton(WebPage& page, InjectedBundleNodeHandle& nodeHandle, RefPtr<API::Object>& userData) -{ - if (!m_client.didClickAutoFillButton) - return; - - WKTypeRef userDataToPass = nullptr; - m_client.didClickAutoFillButton(toAPI(&page), toAPI(&nodeHandle), &userDataToPass, m_client.base.clientInfo); - userData = adoptRef(toImpl(userDataToPass)); -} - } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h index bc246ec24..9d417df3c 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h @@ -27,7 +27,6 @@ #define InjectedBundlePageUIClient_h #include "APIClient.h" -#include "APIInjectedBundlePageUIClient.h" #include "WKBundlePage.h" #include "WebEvent.h" #include <WebCore/RenderSnapshottedPlugIn.h> @@ -37,40 +36,47 @@ namespace API { class Object; template<> struct ClientTraits<WKBundlePageUIClientBase> { - typedef std::tuple<WKBundlePageUIClientV0, WKBundlePageUIClientV1, WKBundlePageUIClientV2, WKBundlePageUIClientV3> Versions; + typedef std::tuple<WKBundlePageUIClientV0, WKBundlePageUIClientV1, WKBundlePageUIClientV2> Versions; }; } +namespace WebCore { +class GraphicsContext; +class HitTestResult; +class IntRect; +} + namespace WebKit { -class InjectedBundlePageUIClient : public API::Client<WKBundlePageUIClientBase>, public API::InjectedBundle::PageUIClient { -public: - explicit InjectedBundlePageUIClient(const WKBundlePageUIClientBase*); +class WebFrame; +class WebPage; +class WebSecurityOrigin; - void willAddMessageToConsole(WebPage*, MessageSource, MessageLevel, const String& message, unsigned lineNumber, unsigned columnNumber, const String& sourceID) override; - void willSetStatusbarText(WebPage*, const String&) override; - void willRunJavaScriptAlert(WebPage*, const String&, WebFrame*) override; - void willRunJavaScriptConfirm(WebPage*, const String&, WebFrame*) override; - void willRunJavaScriptPrompt(WebPage*, const String&, const String&, WebFrame*) override; - void mouseDidMoveOverElement(WebPage*, const WebCore::HitTestResult&, WebEvent::Modifiers, RefPtr<API::Object>& userData) override; - void pageDidScroll(WebPage*) override; +class InjectedBundlePageUIClient : public API::Client<WKBundlePageUIClientBase> { +public: + void willAddMessageToConsole(WebPage*, const String& message, int32_t lineNumber); + void willSetStatusbarText(WebPage*, const String&); + void willRunJavaScriptAlert(WebPage*, const String&, WebFrame*); + void willRunJavaScriptConfirm(WebPage*, const String&, WebFrame*); + void willRunJavaScriptPrompt(WebPage*, const String&, const String&, WebFrame*); + void mouseDidMoveOverElement(WebPage*, const WebCore::HitTestResult&, WebEvent::Modifiers, RefPtr<API::Object>& userData); + void pageDidScroll(WebPage*); - String shouldGenerateFileForUpload(WebPage*, const String& originalFilePath) override; - String generateFileForUpload(WebPage*, const String& originalFilePath) override; + String shouldGenerateFileForUpload(WebPage*, const String& originalFilePath); + String generateFileForUpload(WebPage*, const String& originalFilePath); - UIElementVisibility statusBarIsVisible(WebPage*) override; - UIElementVisibility menuBarIsVisible(WebPage*) override; - UIElementVisibility toolbarsAreVisible(WebPage*) override; + WKBundlePageUIElementVisibility statusBarIsVisible(WebPage*); + WKBundlePageUIElementVisibility menuBarIsVisible(WebPage*); + WKBundlePageUIElementVisibility toolbarsAreVisible(WebPage*); - bool didReachApplicationCacheOriginQuota(WebPage*, API::SecurityOrigin*, int64_t totalBytesNeeded) override; - uint64_t didExceedDatabaseQuota(WebPage*, API::SecurityOrigin*, const String& databaseName, const String& databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes) override; + void didReachApplicationCacheOriginQuota(WebPage*, WebSecurityOrigin*, int64_t totalBytesNeeded); + uint64_t didExceedDatabaseQuota(WebPage*, WebSecurityOrigin*, const String& databaseName, const String& databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes); - String plugInStartLabelTitle(const String& mimeType) const override; - String plugInStartLabelSubtitle(const String& mimeType) const override; - String plugInExtraStyleSheet() const override; - String plugInExtraScript() const override; + String plugInStartLabelTitle(const String& mimeType) const; + String plugInStartLabelSubtitle(const String& mimeType) const; + String plugInExtraStyleSheet() const; + String plugInExtraScript() const; - void didClickAutoFillButton(WebPage&, InjectedBundleNodeHandle&, RefPtr<API::Object>& userData) override; }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp index 347ea7bce..1d81b8c72 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp @@ -43,9 +43,9 @@ static WorldMap& allWorlds() return map; } -Ref<InjectedBundleScriptWorld> InjectedBundleScriptWorld::create() +PassRefPtr<InjectedBundleScriptWorld> InjectedBundleScriptWorld::create() { - return adoptRef(*new InjectedBundleScriptWorld(ScriptController::createWorld())); + return adoptRef(new InjectedBundleScriptWorld(ScriptController::createWorld())); } PassRefPtr<InjectedBundleScriptWorld> InjectedBundleScriptWorld::getOrCreate(DOMWrapperWorld& world) @@ -88,9 +88,4 @@ void InjectedBundleScriptWorld::clearWrappers() m_world->clearWrappers(); } -void InjectedBundleScriptWorld::makeAllShadowRootsOpen() -{ - m_world->setShadowRootIsAlwaysOpen(); -} - } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.h index b3e07f445..70f6ffcf8 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.h @@ -38,16 +38,15 @@ namespace WebKit { class InjectedBundleScriptWorld : public API::ObjectImpl<API::Object::Type::BundleScriptWorld> { public: - static Ref<InjectedBundleScriptWorld> create(); + static PassRefPtr<InjectedBundleScriptWorld> create(); static PassRefPtr<InjectedBundleScriptWorld> getOrCreate(WebCore::DOMWrapperWorld&); static InjectedBundleScriptWorld* normalWorld(); virtual ~InjectedBundleScriptWorld(); WebCore::DOMWrapperWorld& coreWorld() const; - + void clearWrappers(); - void makeAllShadowRootsOpen(); private: InjectedBundleScriptWorld(PassRefPtr<WebCore::DOMWrapperWorld>); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleUserMessageCoders.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleUserMessageCoders.h new file mode 100644 index 000000000..4f39a8f89 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleUserMessageCoders.h @@ -0,0 +1,167 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef InjectedBundleUserMessageCoders_h +#define InjectedBundleUserMessageCoders_h + +#include "UserMessageCoders.h" +#include "WebFrame.h" +#include "WebPage.h" +#include "WebPageGroupData.h" +#include "WebPageGroupProxy.h" +#include "WebProcess.h" + +#if PLATFORM(MAC) +#include "ObjCObjectGraphCoders.h" +#endif + +namespace WebKit { + +// Adds +// - BundlePage -> Page +// - BundleFrame -> Frame +// - BundlePageGroup -> PageGroup + +class InjectedBundleUserMessageEncoder : public UserMessageEncoder<InjectedBundleUserMessageEncoder> { +public: + typedef UserMessageEncoder<InjectedBundleUserMessageEncoder> Base; + + InjectedBundleUserMessageEncoder(API::Object* root) + : Base(root) + { + } + + InjectedBundleUserMessageEncoder(const InjectedBundleUserMessageEncoder&, API::Object* root) + : Base(root) + { + } + + void encode(IPC::ArgumentEncoder& encoder) const + { + API::Object::Type type = API::Object::Type::Null; + if (baseEncode(encoder, *this, type)) + return; + + switch (type) { + case API::Object::Type::BundlePage: { + WebPage* page = static_cast<WebPage*>(m_root); + encoder << page->pageID(); + break; + } + case API::Object::Type::BundleFrame: { + WebFrame* frame = static_cast<WebFrame*>(m_root); + encoder << frame->frameID(); + break; + } + case API::Object::Type::BundlePageGroup: { + WebPageGroupProxy* pageGroup = static_cast<WebPageGroupProxy*>(m_root); + encoder << pageGroup->pageGroupID(); + break; + } +#if PLATFORM(MAC) + case API::Object::Type::ObjCObjectGraph: { + ObjCObjectGraph* objectGraph = static_cast<ObjCObjectGraph*>(m_root); + encoder << InjectedBundleObjCObjectGraphEncoder(objectGraph, WebProcess::shared()); + break; + } +#endif + default: + ASSERT_NOT_REACHED(); + break; + } + } +}; + +// Adds +// - Page -> BundlePage +// - Frame -> BundleFrame +// - PageGroup -> BundlePageGroup + +class InjectedBundleUserMessageDecoder : public UserMessageDecoder<InjectedBundleUserMessageDecoder> { +public: + typedef UserMessageDecoder<InjectedBundleUserMessageDecoder> Base; + + InjectedBundleUserMessageDecoder(RefPtr<API::Object>& root) + : Base(root) + { + } + + InjectedBundleUserMessageDecoder(InjectedBundleUserMessageDecoder&, RefPtr<API::Object>& root) + : Base(root) + { + } + + static bool decode(IPC::ArgumentDecoder& decoder, InjectedBundleUserMessageDecoder& coder) + { + API::Object::Type type = API::Object::Type::Null; + if (!Base::baseDecode(decoder, coder, type)) + return false; + + if (coder.m_root || type == API::Object::Type::Null) + return true; + + switch (type) { + case API::Object::Type::Page: { + uint64_t pageID; + if (!decoder.decode(pageID)) + return false; + coder.m_root = WebProcess::shared().webPage(pageID); + break; + } + case API::Object::Type::Frame: { + uint64_t frameID; + if (!decoder.decode(frameID)) + return false; + coder.m_root = WebProcess::shared().webFrame(frameID); + break; + } + case API::Object::Type::PageGroup: { + WebPageGroupData pageGroupData; + if (!decoder.decode(pageGroupData)) + return false; + coder.m_root = WebProcess::shared().webPageGroup(pageGroupData); + break; + } +#if PLATFORM(MAC) + case API::Object::Type::ObjCObjectGraph: { + RefPtr<ObjCObjectGraph> objectGraph; + InjectedBundleObjCObjectGraphDecoder objectGraphDecoder(objectGraph, WebProcess::shared()); + if (!decoder.decode(objectGraphDecoder)) + return false; + coder.m_root = objectGraph.get(); + break; + } +#endif + default: + return false; + } + + return true; + } +}; + +} // namespace WebKit + +#endif // InjectedBundleUserMessageCoders_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/gtk/InjectedBundleGtk.cpp b/Source/WebKit2/WebProcess/InjectedBundle/gtk/InjectedBundleGtk.cpp index a20a5fe42..a7dfcfd59 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/gtk/InjectedBundleGtk.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/gtk/InjectedBundleGtk.cpp @@ -36,7 +36,7 @@ using namespace WebCore; namespace WebKit { -bool InjectedBundle::initialize(const WebProcessCreationParameters&, API::Object* initializationUserData) +bool InjectedBundle::load(API::Object* initializationUserData) { m_platformBundle = g_module_open(fileSystemRepresentation(m_path).data(), G_MODULE_BIND_LOCAL); if (!m_platformBundle) { @@ -54,11 +54,7 @@ bool InjectedBundle::initialize(const WebProcessCreationParameters&, API::Object return true; } -void InjectedBundle::setBundleParameter(WTF::String const&, IPC::DataReference const&) -{ -} - -void InjectedBundle::setBundleParameters(const IPC::DataReference&) +void InjectedBundle::activateMacFontAscentHack() { } |
