WebKitGTK+ should stop using COMPILE_ASSERT_MATCHING_ENUM macros
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Feb 2014 19:31:02 +0000 (19:31 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Feb 2014 19:31:02 +0000 (19:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=127800

Patch by Enrique Ocaña González <eocanha@igalia.com> on 2014-02-20
Reviewed by Martin Robinson.

Source/WebKit:

* PlatformGTK.cmake: Removed AssertMatchingEnums.cpp

Source/WebKit/gtk:

* GNUmakefile.am: Removed AssertMatchingEnums.cpp
* WebCoreSupport/AssertMatchingEnums.cpp: Removed.
* WebCoreSupport/DumpRenderTreeSupportGtk.cpp: Defined and applied type conversions.
(toWebCoreFindOptions):
(DumpRenderTreeSupportGtk::findString):
* WebCoreSupport/FrameLoaderClientGtk.cpp: Defined and applied type conversions.
(WebKit::toWebKitNetworkError):
(WebKit::FrameLoaderClient::dispatchDidFailLoading):
(WebKit::FrameLoaderClient::dispatchDidFailLoad):
(WebKit::FrameLoaderClient::shouldFallBack):
* webkit/webkitwebnavigationaction.cpp: Defined and applied type conversions.
(WebKit::kit):
(WebKit::core):
* webkit/webkitwebsettings.cpp: Defined and applied type conversions.
(WebKit::core):
* webkit/webkitwebview.cpp: Defined and applied type conversions.
(copyGtkTargetListConvertingWebCoreEnumValuesToWebKitEnumValues):
(webkit_web_view_dispose):
(webkit_web_view_init):
(webkit_web_view_get_copy_target_list):
(webkit_web_view_get_paste_target_list):
* webkit/webkitwebviewprivate.h: Added targetList private field, which mirrors PasteboardHelper::defaultPasteboardHelper()->targetList() but with the flags converted to WebKitWebViewTargetInfo

Source/WebKit2:

* UIProcess/API/gtk/WebKitAuthenticationRequest.cpp: Defined and applied type conversions.
(webkit_authentication_request_get_scheme):
* UIProcess/API/gtk/WebKitCookieManager.cpp: Defined and applied type conversions.
(toWebKitCookieAcceptPolicy):
(toHTTPCookieAcceptPolicy):
(webkit_cookie_manager_set_persistent_storage):
(webkit_cookie_manager_set_accept_policy):
(webkitCookieManagerGetAcceptPolicyCallback):
* UIProcess/API/gtk/WebKitCredential.cpp: Defined and applied type conversions.
(toWebKitCredentialPersistence):
(toWebCoreCredentialPersistence):
(webkit_credential_new):
(webkit_credential_get_persistence):
* UIProcess/API/gtk/WebKitDownload.cpp: Defined and applied type conversions.
(webkitDownloadFailed):
* UIProcess/API/gtk/WebKitError.cpp: Defined and applied type conversions.
* UIProcess/API/gtk/WebKitFindController.cpp: Defined and applied type conversions.
(toWebKitFindOptions):
(webKitFindControllerPerform):
(webkit_find_controller_search_next):
(webkit_find_controller_search_previous):
* UIProcess/API/gtk/WebKitFindController.h: Added new private fields to the enum, needed to match conversions.
* UIProcess/API/gtk/WebKitInjectedBundleClient.cpp: Defined and applied type conversions.
(didReceiveWebViewMessageFromInjectedBundle):
* UIProcess/API/gtk/WebKitLoaderClient.cpp: Defined and applied type conversions.
(didFailProvisionalLoadWithErrorForFrame):
(didFailLoadWithErrorForFrame):
* UIProcess/API/gtk/WebKitNavigationPolicyDecision.cpp: Defined and applied type conversions.
* UIProcess/API/gtk/WebKitPolicyClient.cpp: Defined and applied type conversions.
(toWebKitNavigationType):
(decidePolicyForNavigationAction):
(decidePolicyForNewWindowAction):
* UIProcess/API/gtk/WebKitPrintOperation.cpp: Defined and applied type conversions.
(drawPagesForPrintingCompleted):
* UIProcess/API/gtk/WebKitPrivate.cpp: Defined and applied type conversions.
(toWebKitError):
(toWebCoreError):
* UIProcess/API/gtk/WebKitPrivate.h: Defined and applied type conversions.
* UIProcess/API/gtk/WebKitURISchemeRequest.cpp: Defined and applied type conversions.
(webkit_uri_scheme_request_finish_error):
* UIProcess/API/gtk/WebKitWebContext.cpp: Defined and applied type conversions.
(toWebKitProcessModel):
(webkit_web_context_set_process_model):
(webkit_web_context_get_process_model):
* UIProcess/API/gtk/WebKitWebView.cpp: Defined and applied type conversions.
(toSnapshotRegion):
(webkit_web_view_get_snapshot):
* UIProcess/API/gtk/WebKitWebViewGroup.cpp: Defined and applied type conversions.
(toWebCoreUserContentInjectedFrames):
(webkit_web_view_group_add_user_style_sheet):

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

30 files changed:
Source/WebKit/ChangeLog
Source/WebKit/PlatformGTK.cmake
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/GNUmakefile.am
Source/WebKit/gtk/WebCoreSupport/AssertMatchingEnums.cpp [deleted file]
Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp
Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
Source/WebKit/gtk/webkit/webkitwebnavigationaction.cpp
Source/WebKit/gtk/webkit/webkitwebsettings.cpp
Source/WebKit/gtk/webkit/webkitwebview.cpp
Source/WebKit/gtk/webkit/webkitwebviewprivate.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/gtk/WebKitAuthenticationRequest.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitCookieManager.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitCredential.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitDownload.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitError.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitFindController.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitFindController.h
Source/WebKit2/UIProcess/API/gtk/WebKitInjectedBundleClient.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitNavigationPolicyDecision.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitPolicyClient.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h
Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitWebViewGroup.cpp

index 31e9f67..aaaa6bc 100644 (file)
@@ -1,3 +1,12 @@
+2014-02-20  Enrique Ocaña González  <eocanha@igalia.com>
+
+        WebKitGTK+ should stop using COMPILE_ASSERT_MATCHING_ENUM macros
+        https://bugs.webkit.org/show_bug.cgi?id=127800
+
+        Reviewed by Martin Robinson.
+
+        * PlatformGTK.cmake: Removed AssertMatchingEnums.cpp
+
 2014-02-18  Ryosuke Niwa  <rniwa@webkit.org>
 
         Changing selection shouldn't synchronously update editor UI components
index 1cb2184..6280128 100644 (file)
@@ -40,7 +40,6 @@ list(APPEND WebKit_SOURCES
     ${DERIVED_SOURCES_WEBKITGTK_API_DIR}/webkitmarshal.cpp
 
     gtk/WebCoreSupport/AcceleratedCompositingContextGL.cpp
-    gtk/WebCoreSupport/AssertMatchingEnums.cpp
     gtk/WebCoreSupport/ChromeClientGtk.cpp
     gtk/WebCoreSupport/ContextMenuClientGtk.cpp
     gtk/WebCoreSupport/DeviceMotionClientGtk.cpp
index afa5ecb..cccdfc0 100644 (file)
@@ -1,3 +1,33 @@
+2014-02-20  Enrique Ocaña González  <eocanha@igalia.com>
+
+        WebKitGTK+ should stop using COMPILE_ASSERT_MATCHING_ENUM macros
+        https://bugs.webkit.org/show_bug.cgi?id=127800
+
+        Reviewed by Martin Robinson.
+
+        * GNUmakefile.am: Removed AssertMatchingEnums.cpp
+        * WebCoreSupport/AssertMatchingEnums.cpp: Removed.
+        * WebCoreSupport/DumpRenderTreeSupportGtk.cpp: Defined and applied type conversions.
+        (toWebCoreFindOptions):
+        (DumpRenderTreeSupportGtk::findString):
+        * WebCoreSupport/FrameLoaderClientGtk.cpp: Defined and applied type conversions.
+        (WebKit::toWebKitNetworkError):
+        (WebKit::FrameLoaderClient::dispatchDidFailLoading):
+        (WebKit::FrameLoaderClient::dispatchDidFailLoad):
+        (WebKit::FrameLoaderClient::shouldFallBack):
+        * webkit/webkitwebnavigationaction.cpp: Defined and applied type conversions.
+        (WebKit::kit):
+        (WebKit::core):
+        * webkit/webkitwebsettings.cpp: Defined and applied type conversions.
+        (WebKit::core):
+        * webkit/webkitwebview.cpp: Defined and applied type conversions.
+        (copyGtkTargetListConvertingWebCoreEnumValuesToWebKitEnumValues):
+        (webkit_web_view_dispose):
+        (webkit_web_view_init):
+        (webkit_web_view_get_copy_target_list):
+        (webkit_web_view_get_paste_target_list):
+        * webkit/webkitwebviewprivate.h: Added targetList private field, which mirrors PasteboardHelper::defaultPasteboardHelper()->targetList() but with the flags converted to WebKitWebViewTargetInfo
+
 2014-02-17  Sergio Correia  <sergio.correia@openbossa.org>
 
         Replace uses of PassOwnPtr/OwnPtr with std::unique_ptr in WebCore/inspector
index 64ed53e..d53f1b0 100644 (file)
@@ -190,7 +190,6 @@ BUILT_SOURCES += $(webkitgtk_built_sources)
 webkitgtk_sources += \
        Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContext.h \
        Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContextGL.cpp \
-       Source/WebKit/gtk/WebCoreSupport/AssertMatchingEnums.cpp \
        Source/WebKit/gtk/WebCoreSupport/BatteryClientGtk.cpp \
        Source/WebKit/gtk/WebCoreSupport/BatteryClientGtk.h \
        Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp \
diff --git a/Source/WebKit/gtk/WebCoreSupport/AssertMatchingEnums.cpp b/Source/WebKit/gtk/WebCoreSupport/AssertMatchingEnums.cpp
deleted file mode 100644 (file)
index c2fe809..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- *  Copyright (C) 2011 Collabora Ltd.
- *
- *  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 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
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this library; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-// Use this file to assert that various WebKit API enum values continue
-// matching WebCore defined enum values.
-
-#include "config.h"
-
-#include "DumpRenderTreeSupportGtk.h"
-#include "EditingBehaviorTypes.h"
-#include "ErrorsGtk.h"
-#include "FindOptions.h"
-#include "FrameLoaderTypes.h"
-#include "PasteboardHelper.h"
-#include "webkiterror.h"
-#include "webkitwebnavigationaction.h"
-#include "webkitwebsettings.h"
-#include "webkitwebview.h"
-#include <wtf/Assertions.h>
-
-#define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, webcore_name) \
-    COMPILE_ASSERT(int(webkit_name) == int(WebCore::webcore_name), mismatching_enums)
-
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_EDITING_BEHAVIOR_MAC, EditingMacBehavior);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_EDITING_BEHAVIOR_WINDOWS, EditingWindowsBehavior);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_EDITING_BEHAVIOR_UNIX, EditingUnixBehavior);
-
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED, NavigationTypeLinkClicked);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_WEB_NAVIGATION_REASON_FORM_SUBMITTED, NavigationTypeFormSubmitted);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_WEB_NAVIGATION_REASON_BACK_FORWARD, NavigationTypeBackForward);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_WEB_NAVIGATION_REASON_RELOAD, NavigationTypeReload);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_WEB_NAVIGATION_REASON_FORM_RESUBMITTED, NavigationTypeFormResubmitted);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_WEB_NAVIGATION_REASON_OTHER, NavigationTypeOther);
-
-COMPILE_ASSERT_MATCHING_ENUM(WebKit::WebFindOptionsAtWordStarts, AtWordStarts);
-COMPILE_ASSERT_MATCHING_ENUM(WebKit::WebFindOptionsTreatMedialCapitalAsWordStart, TreatMedialCapitalAsWordStart);
-COMPILE_ASSERT_MATCHING_ENUM(WebKit::WebFindOptionsBackwards, Backwards);
-COMPILE_ASSERT_MATCHING_ENUM(WebKit::WebFindOptionsWrapAround, WrapAround);
-COMPILE_ASSERT_MATCHING_ENUM(WebKit::WebFindOptionsStartInSelection, StartInSelection);
-
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_WEB_VIEW_TARGET_INFO_HTML, PasteboardHelper::TargetTypeMarkup);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_WEB_VIEW_TARGET_INFO_TEXT, PasteboardHelper::TargetTypeText);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_WEB_VIEW_TARGET_INFO_IMAGE, PasteboardHelper::TargetTypeImage);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST, PasteboardHelper::TargetTypeURIList);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_WEB_VIEW_TARGET_INFO_NETSCAPE_URL, PasteboardHelper::TargetTypeNetscapeURL);
-
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NETWORK_ERROR_FAILED, NetworkErrorFailed);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NETWORK_ERROR_TRANSPORT, NetworkErrorTransport);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NETWORK_ERROR_UNKNOWN_PROTOCOL, NetworkErrorUnknownProtocol);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NETWORK_ERROR_CANCELLED, NetworkErrorCancelled);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NETWORK_ERROR_FILE_DOES_NOT_EXIST, NetworkErrorFileDoesNotExist);
-
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_POLICY_ERROR_FAILED, PolicyErrorFailed);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_POLICY_ERROR_CANNOT_SHOW_MIME_TYPE, PolicyErrorCannotShowMimeType);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_POLICY_ERROR_CANNOT_SHOW_URL, PolicyErrorCannotShowURL);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE, PolicyErrorFrameLoadInterruptedByPolicyChange);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_POLICY_ERROR_CANNOT_USE_RESTRICTED_PORT, PolicyErrorCannotUseRestrictedPort);
-
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_FAILED, PluginErrorFailed);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_CANNOT_FIND_PLUGIN, PluginErrorCannotFindPlugin);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_CANNOT_LOAD_PLUGIN, PluginErrorCannotLoadPlugin);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_JAVA_UNAVAILABLE, PluginErrorJavaUnavailable);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_CONNECTION_CANCELLED, PluginErrorConnectionCancelled);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_WILL_HANDLE_LOAD, PluginErrorWillHandleLoad);
index 9dd9e71..f45877c 100644 (file)
@@ -86,6 +86,16 @@ bool DumpRenderTreeSupportGtk::s_linksIncludedInTabChain = true;
 DumpRenderTreeSupportGtk::FrameLoadEventCallback DumpRenderTreeSupportGtk::s_frameLoadEventCallback = 0;
 DumpRenderTreeSupportGtk::AuthenticationCallback DumpRenderTreeSupportGtk::s_authenticationCallback = 0;
 
+static inline WebCore::FindOptions toWebCoreFindOptions(WebKitFindOptions type)
+{
+    return static_cast<WebCore::FindOptions>((type & WebFindOptionsCaseInsensitive ? CaseInsensitive : 0)
+        | (type & WebFindOptionsAtWordStarts ? AtWordStarts : 0)
+        | (type & WebFindOptionsTreatMedialCapitalAsWordStart ? TreatMedialCapitalAsWordStart : 0)
+        | (type & WebFindOptionsBackwards ? Backwards : 0)
+        | (type & WebFindOptionsWrapAround ? WrapAround : 0)
+        | (type & WebFindOptionsStartInSelection ? StartInSelection : 0));
+}
+
 DumpRenderTreeSupportGtk::DumpRenderTreeSupportGtk()
 {
 }
@@ -475,7 +485,7 @@ void DumpRenderTreeSupportGtk::clearOpener(WebKitWebFrame* frame)
 
 bool DumpRenderTreeSupportGtk::findString(WebKitWebView* webView, const gchar* targetString, WebKitFindOptions findOptions)
 {
-    return core(webView)->findString(String::fromUTF8(targetString), findOptions);
+    return core(webView)->findString(String::fromUTF8(targetString), toWebCoreFindOptions(findOptions));
 }
 
 void DumpRenderTreeSupportGtk::setValueForUser(JSContextRef context, JSValueRef nodeObject, JSStringRef value)
index b24e089..2f8acbb 100644 (file)
@@ -104,6 +104,47 @@ using namespace WebCore;
 
 namespace WebKit {
 
+inline int toWebKitNetworkError(int errorCode)
+{
+    switch (errorCode) {
+    case NetworkErrorFailed:
+        return WEBKIT_NETWORK_ERROR_FAILED;
+    case NetworkErrorTransport:
+        return WEBKIT_NETWORK_ERROR_TRANSPORT;
+    case NetworkErrorUnknownProtocol:
+        return WEBKIT_NETWORK_ERROR_UNKNOWN_PROTOCOL;
+    case NetworkErrorCancelled:
+        return WEBKIT_NETWORK_ERROR_CANCELLED;
+    case NetworkErrorFileDoesNotExist:
+        return WEBKIT_NETWORK_ERROR_FILE_DOES_NOT_EXIST;
+    case PolicyErrorFailed:
+        return WEBKIT_POLICY_ERROR_FAILED;
+    case PolicyErrorCannotShowMimeType:
+        return WEBKIT_POLICY_ERROR_CANNOT_SHOW_MIME_TYPE;
+    case PolicyErrorCannotShowURL:
+        return WEBKIT_POLICY_ERROR_CANNOT_SHOW_URL;
+    case PolicyErrorFrameLoadInterruptedByPolicyChange:
+        return WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE;
+    case PolicyErrorCannotUseRestrictedPort:
+        return WEBKIT_POLICY_ERROR_CANNOT_USE_RESTRICTED_PORT;
+    case PluginErrorFailed:
+        return WEBKIT_PLUGIN_ERROR_FAILED;
+    case PluginErrorCannotFindPlugin:
+        return WEBKIT_PLUGIN_ERROR_CANNOT_FIND_PLUGIN;
+    case PluginErrorCannotLoadPlugin:
+        return WEBKIT_PLUGIN_ERROR_CANNOT_LOAD_PLUGIN;
+    case PluginErrorJavaUnavailable:
+        return WEBKIT_PLUGIN_ERROR_JAVA_UNAVAILABLE;
+    case PluginErrorConnectionCancelled:
+        return WEBKIT_PLUGIN_ERROR_CONNECTION_CANCELLED;
+    case PluginErrorWillHandleLoad:
+        return WEBKIT_PLUGIN_ERROR_WILL_HANDLE_LOAD;
+    default:
+        ASSERT_NOT_REACHED();
+        return WEBKIT_NETWORK_ERROR_FAILED;
+    }
+}
+
 FrameLoaderClient::FrameLoaderClient(WebKitWebFrame* frame)
     : m_frame(frame)
     , m_policyDecision(0)
@@ -992,7 +1033,7 @@ void FrameLoaderClient::dispatchDidFailLoading(WebCore::DocumentLoader* loader,
         return;
 
     GUniquePtr<GError> webError(g_error_new_literal(g_quark_from_string(error.domain().utf8().data()),
-        error.errorCode(), error.localizedDescription().utf8().data()));
+        toWebKitNetworkError(error.errorCode()), error.localizedDescription().utf8().data()));
 
     g_signal_emit_by_name(webResource, "load-failed", webError.get());
     g_signal_emit_by_name(m_frame, "resource-load-failed", webResource, webError.get());
@@ -1020,9 +1061,10 @@ void FrameLoaderClient::dispatchDidFailLoad(const ResourceError& error)
     notifyStatus(m_frame, WEBKIT_LOAD_FAILED);
 
     WebKitWebView* webView = getViewFromFrame(m_frame);
+
     GUniquePtr<GError> webError(g_error_new_literal(
         g_quark_from_string(error.domain().utf8().data()),
-        error.errorCode(),
+        toWebKitNetworkError(error.errorCode()),
         error.localizedDescription().utf8().data()));
     gboolean isHandled = false;
     g_signal_emit_by_name(webView, "load-error", m_frame, error.failingURL().utf8().data(), webError.get(), &isHandled);
@@ -1094,7 +1136,7 @@ ResourceError FrameLoaderClient::pluginWillHandleLoadError(const ResourceRespons
 
 bool FrameLoaderClient::shouldFallBack(const ResourceError& error)
 {
-    return !(error.isCancellation() || error.errorCode() == WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE || error.errorCode() == WEBKIT_PLUGIN_ERROR_WILL_HANDLE_LOAD);
+    return !(error.isCancellation() || error.errorCode() == PolicyErrorFrameLoadInterruptedByPolicyChange || error.errorCode() == PluginErrorWillHandleLoad);
 }
 
 bool FrameLoaderClient::canCachePage() const
index c78e754..ad6f0c8 100644 (file)
@@ -364,12 +364,44 @@ namespace WebKit {
 
 WebKitWebNavigationReason kit(WebCore::NavigationType type)
 {
-    return (WebKitWebNavigationReason)type;
+    switch(type) {
+    case WebCore::NavigationTypeLinkClicked:
+        return WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED;
+    case WebCore::NavigationTypeFormSubmitted:
+        return WEBKIT_WEB_NAVIGATION_REASON_FORM_SUBMITTED;
+    case WebCore::NavigationTypeBackForward:
+        return WEBKIT_WEB_NAVIGATION_REASON_BACK_FORWARD;
+    case WebCore::NavigationTypeReload:
+        return WEBKIT_WEB_NAVIGATION_REASON_RELOAD;
+    case WebCore::NavigationTypeFormResubmitted:
+        return WEBKIT_WEB_NAVIGATION_REASON_FORM_RESUBMITTED;
+    case WebCore::NavigationTypeOther:
+        return WEBKIT_WEB_NAVIGATION_REASON_OTHER;
+    default:
+        ASSERT_NOT_REACHED();
+        return WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED;
+    }
 }
 
 WebCore::NavigationType core(WebKitWebNavigationReason type)
 {
-    return static_cast<WebCore::NavigationType>(type);
+    switch(type) {
+    case WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED:
+        return WebCore::NavigationTypeLinkClicked;
+    case WEBKIT_WEB_NAVIGATION_REASON_FORM_SUBMITTED:
+        return WebCore::NavigationTypeFormSubmitted;
+    case WEBKIT_WEB_NAVIGATION_REASON_BACK_FORWARD:
+        return WebCore::NavigationTypeBackForward;
+    case WEBKIT_WEB_NAVIGATION_REASON_RELOAD:
+        return WebCore::NavigationTypeReload;
+    case WEBKIT_WEB_NAVIGATION_REASON_FORM_RESUBMITTED:
+        return WebCore::NavigationTypeFormResubmitted;
+    case WEBKIT_WEB_NAVIGATION_REASON_OTHER:
+        return WebCore::NavigationTypeOther;
+    default:
+        ASSERT_NOT_REACHED();
+        return WebCore::NavigationTypeLinkClicked;
+    }
 }
 
 }
index 742b23d..c13bc0e 100644 (file)
@@ -1658,9 +1658,19 @@ char* webkitWebSettingsUserAgentForURI(WebKitWebSettings* webSettings, const cha
 
 namespace WebKit {
 
-WebCore::EditingBehaviorType core(WebKitEditingBehavior type)
+inline WebCore::EditingBehaviorType core(WebKitEditingBehavior type)
 {
-    return static_cast<WebCore::EditingBehaviorType>(type);
+    switch (type) {
+    case WEBKIT_EDITING_BEHAVIOR_MAC:
+        return EditingMacBehavior;
+    case WEBKIT_EDITING_BEHAVIOR_WINDOWS:
+        return EditingWindowsBehavior;
+    case WEBKIT_EDITING_BEHAVIOR_UNIX:
+        return EditingUnixBehavior;
+    default:
+        ASSERT_NOT_REACHED();
+        return EditingMacBehavior;
+    }
 }
 
 }
index 48f15c9..1a2b017 100644 (file)
 #include <bindings/ScriptValue.h>
 #include <gdk/gdkkeysyms.h>
 #include <glib/gi18n-lib.h>
+#include <gtk/gtk.h>
 #include <wtf/text/CString.h>
 
 #if ENABLE(DEVICE_ORIENTATION)
@@ -282,6 +283,47 @@ static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GPar
 static void webkit_web_view_set_window_features(WebKitWebView* webView, WebKitWebWindowFeatures* webWindowFeatures);
 static void webkitWebViewDirectionChanged(WebKitWebView*, GtkTextDirection previousDirection, gpointer);
 
+static inline WebKitWebViewTargetInfo toWebKitWebViewTargetInfo(PasteboardHelper::PasteboardTargetType flags)
+{
+    switch (flags) {
+    case PasteboardHelper::TargetTypeMarkup:
+        return WEBKIT_WEB_VIEW_TARGET_INFO_HTML;
+        break;
+    case PasteboardHelper::TargetTypeText:
+        return WEBKIT_WEB_VIEW_TARGET_INFO_TEXT;
+        break;
+    case PasteboardHelper::TargetTypeImage:
+        return WEBKIT_WEB_VIEW_TARGET_INFO_IMAGE;
+        break;
+    case PasteboardHelper::TargetTypeURIList:
+        return WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST;
+        break;
+    case PasteboardHelper::TargetTypeNetscapeURL:
+        return WEBKIT_WEB_VIEW_TARGET_INFO_NETSCAPE_URL;
+        break;
+    default:
+        ASSERT_NOT_REACHED();
+        return WEBKIT_WEB_VIEW_TARGET_INFO_HTML;
+    }
+}
+
+static GtkTargetList* copyGtkTargetListConvertingWebCoreEnumValuesToWebKitEnumValues(GtkTargetList* coreGtkTargetList)
+{
+    g_return_val_if_fail(coreGtkTargetList, nullptr);
+
+    GtkTargetList* targetListWithWebKitEnumValues = nullptr;
+    int tableSize = 0;
+    GtkTargetEntry* table(gtk_target_table_new_from_list(coreGtkTargetList, &tableSize));
+
+    for (int i = 0; i < tableSize; i++)
+        table[i].flags = toWebKitWebViewTargetInfo(static_cast<PasteboardHelper::PasteboardTargetType>(table[i].flags));
+
+    targetListWithWebKitEnumValues = gtk_target_list_new(table, tableSize);
+    gtk_target_table_free(table, tableSize);
+
+    return targetListWithWebKitEnumValues;
+}
+
 #if ENABLE(CONTEXT_MENUS)
 static void PopupMenuPositionFunc(GtkMenu* menu, gint *x, gint *y, gboolean *pushIn, gpointer userData)
 {
@@ -1380,6 +1422,7 @@ static void webkit_web_view_dispose(GObject* object)
     priv->webWindowFeatures.clear();
     priv->mainResource.clear();
     priv->subResources.clear();
+    priv->targetList.clear();
 
     G_OBJECT_CLASS(webkit_web_view_parent_class)->dispose(object);
 
@@ -3873,10 +3916,12 @@ static void webkit_web_view_init(WebKitWebView* webView)
 
     priv->subResources = adoptGRef(g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref));
 
+    priv->targetList = adoptGRef(copyGtkTargetListConvertingWebCoreEnumValuesToWebKitEnumValues(PasteboardHelper::defaultPasteboardHelper()->targetList()));
+
 #if ENABLE(DRAG_SUPPORT)
     priv->dragAndDropHelper.setWidget(GTK_WIDGET(webView));
     gtk_drag_dest_set(GTK_WIDGET(webView), static_cast<GtkDestDefaults>(0), 0, 0, static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_PRIVATE));
-    gtk_drag_dest_set_target_list(GTK_WIDGET(webView), PasteboardHelper::defaultPasteboardHelper()->targetList());
+    gtk_drag_dest_set_target_list(GTK_WIDGET(webView), priv->targetList.get());
 #endif
 
     priv->selfScrolling = false;
@@ -4691,7 +4736,8 @@ void webkit_web_view_set_editable(WebKitWebView* webView, gboolean flag)
  **/
 GtkTargetList* webkit_web_view_get_copy_target_list(WebKitWebView* webView)
 {
-    return PasteboardHelper::defaultPasteboardHelper()->targetList();
+    webView->priv->targetList = adoptGRef(copyGtkTargetListConvertingWebCoreEnumValuesToWebKitEnumValues(PasteboardHelper::defaultPasteboardHelper()->targetList()));
+    return webView->priv->targetList.get();
 }
 
 /**
@@ -4708,7 +4754,8 @@ GtkTargetList* webkit_web_view_get_copy_target_list(WebKitWebView* webView)
  **/
 GtkTargetList* webkit_web_view_get_paste_target_list(WebKitWebView* webView)
 {
-    return PasteboardHelper::defaultPasteboardHelper()->targetList();
+    webView->priv->targetList = adoptGRef(copyGtkTargetListConvertingWebCoreEnumValuesToWebKitEnumValues(PasteboardHelper::defaultPasteboardHelper()->targetList()));
+    return webView->priv->targetList.get();
 }
 
 /**
index 3f6927e..6b9036c 100644 (file)
@@ -100,6 +100,7 @@ struct _WebKitWebViewPrivate {
     WebCore::GtkClickCounter clickCounter;
     WebCore::GtkDragAndDropHelper dragAndDropHelper;
     bool selfScrolling;
+    GRefPtr<GtkTargetList> targetList;
 
     OwnPtr<WebKit::AcceleratedCompositingContext> acceleratedCompositingContext;
 
index 6625988..85fd40d 100644 (file)
@@ -1,3 +1,61 @@
+2014-02-20  Enrique Ocaña González  <eocanha@igalia.com>
+
+        WebKitGTK+ should stop using COMPILE_ASSERT_MATCHING_ENUM macros
+        https://bugs.webkit.org/show_bug.cgi?id=127800
+
+        Reviewed by Martin Robinson.
+
+        * UIProcess/API/gtk/WebKitAuthenticationRequest.cpp: Defined and applied type conversions.
+        (webkit_authentication_request_get_scheme):
+        * UIProcess/API/gtk/WebKitCookieManager.cpp: Defined and applied type conversions.
+        (toWebKitCookieAcceptPolicy):
+        (toHTTPCookieAcceptPolicy):
+        (webkit_cookie_manager_set_persistent_storage):
+        (webkit_cookie_manager_set_accept_policy):
+        (webkitCookieManagerGetAcceptPolicyCallback):
+        * UIProcess/API/gtk/WebKitCredential.cpp: Defined and applied type conversions.
+        (toWebKitCredentialPersistence):
+        (toWebCoreCredentialPersistence):
+        (webkit_credential_new):
+        (webkit_credential_get_persistence):
+        * UIProcess/API/gtk/WebKitDownload.cpp: Defined and applied type conversions.
+        (webkitDownloadFailed):
+        * UIProcess/API/gtk/WebKitError.cpp: Defined and applied type conversions.
+        * UIProcess/API/gtk/WebKitFindController.cpp: Defined and applied type conversions.
+        (toWebKitFindOptions):
+        (webKitFindControllerPerform):
+        (webkit_find_controller_search_next):
+        (webkit_find_controller_search_previous):
+        * UIProcess/API/gtk/WebKitFindController.h: Added new private fields to the enum, needed to match conversions.
+        * UIProcess/API/gtk/WebKitInjectedBundleClient.cpp: Defined and applied type conversions.
+        (didReceiveWebViewMessageFromInjectedBundle):
+        * UIProcess/API/gtk/WebKitLoaderClient.cpp: Defined and applied type conversions.
+        (didFailProvisionalLoadWithErrorForFrame):
+        (didFailLoadWithErrorForFrame):
+        * UIProcess/API/gtk/WebKitNavigationPolicyDecision.cpp: Defined and applied type conversions.
+        * UIProcess/API/gtk/WebKitPolicyClient.cpp: Defined and applied type conversions.
+        (toWebKitNavigationType):
+        (decidePolicyForNavigationAction):
+        (decidePolicyForNewWindowAction):
+        * UIProcess/API/gtk/WebKitPrintOperation.cpp: Defined and applied type conversions.
+        (drawPagesForPrintingCompleted):
+        * UIProcess/API/gtk/WebKitPrivate.cpp: Defined and applied type conversions.
+        (toWebKitError):
+        (toWebCoreError):
+        * UIProcess/API/gtk/WebKitPrivate.h: Defined and applied type conversions.
+        * UIProcess/API/gtk/WebKitURISchemeRequest.cpp: Defined and applied type conversions.
+        (webkit_uri_scheme_request_finish_error):
+        * UIProcess/API/gtk/WebKitWebContext.cpp: Defined and applied type conversions.
+        (toWebKitProcessModel):
+        (webkit_web_context_set_process_model):
+        (webkit_web_context_get_process_model):
+        * UIProcess/API/gtk/WebKitWebView.cpp: Defined and applied type conversions.
+        (toSnapshotRegion):
+        (webkit_web_view_get_snapshot):
+        * UIProcess/API/gtk/WebKitWebViewGroup.cpp: Defined and applied type conversions.
+        (toWebCoreUserContentInjectedFrames):
+        (webkit_web_view_group_add_user_style_sheet):
+
 2014-02-20  Csaba Osztrogonác  <ossy@webkit.org>
 
         Get rid of redundant Platform.h includes
index 6f0c370..6e25972 100644 (file)
@@ -67,18 +67,35 @@ struct _WebKitAuthenticationRequestPrivate {
 
 static guint signals[LAST_SIGNAL] = { 0, };
 
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_AUTHENTICATION_SCHEME_DEFAULT, ProtectionSpaceAuthenticationSchemeDefault);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_AUTHENTICATION_SCHEME_HTTP_BASIC, ProtectionSpaceAuthenticationSchemeHTTPBasic);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_AUTHENTICATION_SCHEME_HTTP_DIGEST, ProtectionSpaceAuthenticationSchemeHTTPDigest);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_AUTHENTICATION_SCHEME_HTML_FORM, ProtectionSpaceAuthenticationSchemeHTMLForm);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_AUTHENTICATION_SCHEME_NTLM, ProtectionSpaceAuthenticationSchemeNTLM);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_AUTHENTICATION_SCHEME_NEGOTIATE, ProtectionSpaceAuthenticationSchemeNegotiate);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_AUTHENTICATION_SCHEME_CLIENT_CERTIFICATE_REQUESTED, ProtectionSpaceAuthenticationSchemeClientCertificateRequested);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_AUTHENTICATION_SCHEME_SERVER_TRUST_EVALUATION_REQUESTED, ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_AUTHENTICATION_SCHEME_UNKNOWN, ProtectionSpaceAuthenticationSchemeUnknown);
-
 WEBKIT_DEFINE_TYPE(WebKitAuthenticationRequest, webkit_authentication_request, G_TYPE_OBJECT)
 
+static inline WebKitAuthenticationScheme toWebKitAuthenticationScheme(WebCore::ProtectionSpaceAuthenticationScheme coreScheme)
+{
+    switch (coreScheme) {
+    case WebCore::ProtectionSpaceAuthenticationSchemeDefault:
+        return WEBKIT_AUTHENTICATION_SCHEME_DEFAULT;
+    case WebCore::ProtectionSpaceAuthenticationSchemeHTTPBasic:
+        return WEBKIT_AUTHENTICATION_SCHEME_HTTP_BASIC;
+    case WebCore::ProtectionSpaceAuthenticationSchemeHTTPDigest:
+        return WEBKIT_AUTHENTICATION_SCHEME_HTTP_DIGEST;
+    case WebCore::ProtectionSpaceAuthenticationSchemeHTMLForm:
+        return WEBKIT_AUTHENTICATION_SCHEME_HTML_FORM;
+    case WebCore::ProtectionSpaceAuthenticationSchemeNTLM:
+        return WEBKIT_AUTHENTICATION_SCHEME_NTLM;
+    case WebCore::ProtectionSpaceAuthenticationSchemeNegotiate:
+        return WEBKIT_AUTHENTICATION_SCHEME_NEGOTIATE;
+    case WebCore::ProtectionSpaceAuthenticationSchemeClientCertificateRequested:
+        return WEBKIT_AUTHENTICATION_SCHEME_CLIENT_CERTIFICATE_REQUESTED;
+    case WebCore::ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested:
+        return WEBKIT_AUTHENTICATION_SCHEME_SERVER_TRUST_EVALUATION_REQUESTED;
+    case WebCore::ProtectionSpaceAuthenticationSchemeUnknown:
+        return WEBKIT_AUTHENTICATION_SCHEME_UNKNOWN;
+    default:
+        ASSERT_NOT_REACHED();
+        return WEBKIT_AUTHENTICATION_SCHEME_DEFAULT;
+    }
+}
+
 static void webkitAuthenticationRequestDispose(GObject* object)
 {
     WebKitAuthenticationRequest* request = WEBKIT_AUTHENTICATION_REQUEST(object);
@@ -244,7 +261,7 @@ WebKitAuthenticationScheme webkit_authentication_request_get_scheme(WebKitAuthen
 {
     g_return_val_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request), WEBKIT_AUTHENTICATION_SCHEME_UNKNOWN);
 
-    return static_cast<WebKitAuthenticationScheme>(request->priv->authenticationChallenge->protectionSpace()->authenticationScheme());
+    return toWebKitAuthenticationScheme(request->priv->authenticationChallenge->protectionSpace()->authenticationScheme());
 }
 
 /**
index 364e4e4..c95fac8 100644 (file)
@@ -68,12 +68,48 @@ static guint signals[LAST_SIGNAL] = { 0, };
 
 WEBKIT_DEFINE_TYPE(WebKitCookieManager, webkit_cookie_manager, G_TYPE_OBJECT)
 
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT, SoupCookiePersistentStorageText);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE, SoupCookiePersistentStorageSQLite);
+static inline SoupCookiePersistentStorageType toSoupCookiePersistentStorageType(WebKitCookiePersistentStorage kitStorage)
+{
+    switch (kitStorage) {
+    case WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT:
+        return SoupCookiePersistentStorageText;
+    case WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE:
+        return SoupCookiePersistentStorageSQLite;
+    default:
+        ASSERT_NOT_REACHED();
+        return SoupCookiePersistentStorageText;
+    }
+}
+
+static inline WebKitCookieAcceptPolicy toWebKitCookieAcceptPolicy(HTTPCookieAcceptPolicy httpPolicy)
+{
+    switch (httpPolicy) {
+    case HTTPCookieAcceptPolicyAlways:
+        return WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS;
+    case HTTPCookieAcceptPolicyNever:
+        return WEBKIT_COOKIE_POLICY_ACCEPT_NEVER;
+    case HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain:
+        return WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY;
+    default:
+        ASSERT_NOT_REACHED();
+        return WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS;
+    }
+}
 
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS, HTTPCookieAcceptPolicyAlways);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_COOKIE_POLICY_ACCEPT_NEVER, HTTPCookieAcceptPolicyNever);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY, HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain);
+static inline HTTPCookieAcceptPolicy toHTTPCookieAcceptPolicy(WebKitCookieAcceptPolicy kitPolicy)
+{
+    switch (kitPolicy) {
+    case WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS:
+        return HTTPCookieAcceptPolicyAlways;
+    case WEBKIT_COOKIE_POLICY_ACCEPT_NEVER:
+        return HTTPCookieAcceptPolicyNever;
+    case WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY:
+        return HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
+    default:
+        ASSERT_NOT_REACHED();
+        return HTTPCookieAcceptPolicyAlways;
+    }
+}
 
 static void webkit_cookie_manager_class_init(WebKitCookieManagerClass* findClass)
 {
@@ -137,7 +173,7 @@ void webkit_cookie_manager_set_persistent_storage(WebKitCookieManager* manager,
     g_return_if_fail(filename);
 
     manager->priv->webCookieManager->stopObservingCookieChanges();
-    manager->priv->webCookieManager->setCookiePersistentStorage(String::fromUTF8(filename), storage);
+    manager->priv->webCookieManager->setCookiePersistentStorage(String::fromUTF8(filename), toSoupCookiePersistentStorageType(storage));
     manager->priv->webCookieManager->startObservingCookieChanges();
 }
 
@@ -152,13 +188,13 @@ void webkit_cookie_manager_set_accept_policy(WebKitCookieManager* manager, WebKi
 {
     g_return_if_fail(WEBKIT_IS_COOKIE_MANAGER(manager));
 
-    manager->priv->webCookieManager->setHTTPCookieAcceptPolicy(policy);
+    manager->priv->webCookieManager->setHTTPCookieAcceptPolicy(toHTTPCookieAcceptPolicy(policy));
 }
 
 static void webkitCookieManagerGetAcceptPolicyCallback(WKHTTPCookieAcceptPolicy policy, WKErrorRef, void* context)
 {
     GRefPtr<GTask> task = adoptGRef(G_TASK(context));
-    g_task_return_int(task.get(), policy);
+    g_task_return_int(task.get(), toWebKitCookieAcceptPolicy(toHTTPCookieAcceptPolicy(policy)));
 }
 
 /**
index 5755fd5..c8dc474 100644 (file)
@@ -37,12 +37,38 @@ struct _WebKitCredential {
     CString password;
 };
 
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_CREDENTIAL_PERSISTENCE_NONE, WebCore::CredentialPersistenceNone);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_CREDENTIAL_PERSISTENCE_FOR_SESSION, WebCore::CredentialPersistenceForSession);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_CREDENTIAL_PERSISTENCE_PERMANENT, WebCore::CredentialPersistencePermanent);
-
 G_DEFINE_BOXED_TYPE(WebKitCredential, webkit_credential, webkit_credential_copy, webkit_credential_free)
 
+static inline WebKitCredentialPersistence toWebKitCredentialPersistence(WebCore::CredentialPersistence corePersistence)
+{
+    switch (corePersistence) {
+    case WebCore::CredentialPersistenceNone:
+        return WEBKIT_CREDENTIAL_PERSISTENCE_NONE;
+    case WebCore::CredentialPersistenceForSession:
+        return WEBKIT_CREDENTIAL_PERSISTENCE_FOR_SESSION;
+    case WebCore::CredentialPersistencePermanent:
+        return WEBKIT_CREDENTIAL_PERSISTENCE_PERMANENT;
+    default:
+        ASSERT_NOT_REACHED();
+        return WEBKIT_CREDENTIAL_PERSISTENCE_NONE;
+    }
+}
+
+static inline WebCore::CredentialPersistence toWebCoreCredentialPersistence(WebKitCredentialPersistence kitPersistence)
+{
+    switch (kitPersistence) {
+    case WEBKIT_CREDENTIAL_PERSISTENCE_NONE:
+        return WebCore::CredentialPersistenceNone;
+    case WEBKIT_CREDENTIAL_PERSISTENCE_FOR_SESSION:
+        return WebCore::CredentialPersistenceForSession;
+    case WEBKIT_CREDENTIAL_PERSISTENCE_PERMANENT:
+        return WebCore::CredentialPersistencePermanent;
+    default:
+        ASSERT_NOT_REACHED();
+        return WebCore::CredentialPersistenceNone;
+    }
+}
+
 WebKitCredential* webkitCredentialCreate(const WebCore::Credential& coreCredential)
 {
     WebKitCredential* credential = g_slice_new(WebKitCredential);
@@ -73,7 +99,7 @@ WebKitCredential* webkit_credential_new(const gchar* username, const gchar* pass
     g_return_val_if_fail(username, 0);
     g_return_val_if_fail(password, 0);
 
-    return webkitCredentialCreate(WebCore::Credential(String::fromUTF8(username), String::fromUTF8(password), static_cast<WebCore::CredentialPersistence>(persistence)));
+    return webkitCredentialCreate(WebCore::Credential(String::fromUTF8(username), String::fromUTF8(password), toWebCoreCredentialPersistence(persistence)));
 }
 
 /**
@@ -178,5 +204,5 @@ WebKitCredentialPersistence webkit_credential_get_persistence(WebKitCredential*
 {
     g_return_val_if_fail(credential, WEBKIT_CREDENTIAL_PERSISTENCE_NONE);
 
-    return static_cast<WebKitCredentialPersistence>(credential->credential.persistence());
+    return toWebKitCredentialPersistence(credential->credential.persistence());
 }
index e95e4c0..c483b92 100644 (file)
@@ -23,6 +23,7 @@
 #include "DownloadProxy.h"
 #include "WebKitDownloadPrivate.h"
 #include "WebKitMarshal.h"
+#include "WebKitPrivate.h"
 #include "WebKitURIRequestPrivate.h"
 #include "WebKitURIResponsePrivate.h"
 #include <WebCore/ErrorsGtk.h>
@@ -340,7 +341,7 @@ void webkitDownloadNotifyProgress(WebKitDownload* download, guint64 bytesReceive
 void webkitDownloadFailed(WebKitDownload* download, const ResourceError& resourceError)
 {
     GUniquePtr<GError> webError(g_error_new_literal(g_quark_from_string(resourceError.domain().utf8().data()),
-        resourceError.errorCode(), resourceError.localizedDescription().utf8().data()));
+        toWebKitError(resourceError.errorCode()), resourceError.localizedDescription().utf8().data()));
     if (download->priv->timer)
         g_timer_stop(download->priv->timer.get());
 
index c06dc61..7419ee7 100644 (file)
@@ -40,53 +40,26 @@ GQuark webkit_network_error_quark()
     return g_quark_from_static_string(WebCore::errorDomainNetwork);
 }
 
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NETWORK_ERROR_FAILED, NetworkErrorFailed);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NETWORK_ERROR_TRANSPORT, NetworkErrorTransport);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NETWORK_ERROR_UNKNOWN_PROTOCOL, NetworkErrorUnknownProtocol);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NETWORK_ERROR_CANCELLED, NetworkErrorCancelled);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NETWORK_ERROR_FILE_DOES_NOT_EXIST, NetworkErrorFileDoesNotExist);
-
 GQuark webkit_policy_error_quark()
 {
     return g_quark_from_static_string(WebCore::errorDomainPolicy);
 }
 
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_POLICY_ERROR_FAILED, PolicyErrorFailed);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_POLICY_ERROR_CANNOT_SHOW_MIME_TYPE, PolicyErrorCannotShowMimeType);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_POLICY_ERROR_CANNOT_SHOW_URI, PolicyErrorCannotShowURL);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE, PolicyErrorFrameLoadInterruptedByPolicyChange);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_POLICY_ERROR_CANNOT_USE_RESTRICTED_PORT, PolicyErrorCannotUseRestrictedPort);
-
 GQuark webkit_plugin_error_quark()
 {
     return g_quark_from_static_string(WebCore::errorDomainPlugin);
 }
 
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_FAILED, PluginErrorFailed);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_CANNOT_FIND_PLUGIN, PluginErrorCannotFindPlugin);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_CANNOT_LOAD_PLUGIN, PluginErrorCannotLoadPlugin);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_JAVA_UNAVAILABLE, PluginErrorJavaUnavailable);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_CONNECTION_CANCELLED, PluginErrorConnectionCancelled);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_WILL_HANDLE_LOAD, PluginErrorWillHandleLoad);
-
 GQuark webkit_download_error_quark()
 {
     return g_quark_from_static_string(WebCore::errorDomainDownload);
 }
 
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_DOWNLOAD_ERROR_NETWORK, DownloadErrorNetwork);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_DOWNLOAD_ERROR_CANCELLED_BY_USER, DownloadErrorCancelledByUser);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_DOWNLOAD_ERROR_DESTINATION, DownloadErrorDestination);
-
 GQuark webkit_print_error_quark()
 {
     return g_quark_from_static_string(WebCore::errorDomainPrint);
 }
 
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PRINT_ERROR_GENERAL, PrintErrorGeneral);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PRINT_ERROR_PRINTER_NOT_FOUND, PrintErrorPrinterNotFound);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PRINT_ERROR_INVALID_PAGE_RANGE, PrintErrorInvalidPageRange);
-
 GQuark webkit_javascript_error_quark()
 {
     return g_quark_from_static_string("WebKitJavascriptError");
index 8759306..6e7141e 100644 (file)
@@ -82,11 +82,22 @@ static guint signals[LAST_SIGNAL] = { 0, };
 
 WEBKIT_DEFINE_TYPE(WebKitFindController, webkit_find_controller, G_TYPE_OBJECT)
 
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE, FindOptionsCaseInsensitive);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_FIND_OPTIONS_AT_WORD_STARTS, FindOptionsAtWordStarts);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START, FindOptionsTreatMedialCapitalAsWordStart);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_FIND_OPTIONS_BACKWARDS, FindOptionsBackwards);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_FIND_OPTIONS_WRAP_AROUND, FindOptionsWrapAround);
+static inline WebKit::FindOptions toWebKitFindOptions(WebKitFindOptions type)
+{
+    return static_cast<WebKit::FindOptions>((type & WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE ? FindOptionsCaseInsensitive : 0)
+        | (type & WEBKIT_FIND_OPTIONS_AT_WORD_STARTS ? FindOptionsAtWordStarts : 0)
+        | (type & WEBKIT_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START ? FindOptionsTreatMedialCapitalAsWordStart : 0)
+        | (type & WEBKIT_FIND_OPTIONS_BACKWARDS ? FindOptionsBackwards : 0)
+        | (type & WEBKIT_FIND_OPTIONS_WRAP_AROUND ? FindOptionsWrapAround : 0)
+        | (type & WEBKIT_FIND_OPTIONS_SHOW_OVERLAY ? FindOptionsShowOverlay : 0)
+        | (type & WEBKIT_FIND_OPTIONS_SHOW_FIND_INDICATOR ? FindOptionsShowFindIndicator : 0)
+        | (type & WEBKIT_FIND_OPTIONS_SHOW_HIGHLIGHT ? FindOptionsShowHighlight : 0));
+}
+
+static inline WebKit::FindOptions toWebKitFindOptions(uint32_t type)
+{
+    return toWebKitFindOptions(static_cast<WebKitFindOptions>(type));
+}
 
 static void didFindString(WKPageRef page, WKStringRef string, unsigned matchCount, const void* clientInfo)
 {
@@ -349,7 +360,7 @@ static void webKitFindControllerPerform(WebKitFindController* findController, We
     WebKitFindControllerPrivate* priv = findController->priv;
     if (operation == CountOperation) {
         getPage(findController)->countStringMatches(String::fromUTF8(priv->searchText.data()),
-                                                    static_cast<WebKit::FindOptions>(priv->findOptions), priv->maxMatchCount);
+            toWebKitFindOptions(priv->findOptions), priv->maxMatchCount);
         return;
     }
 
@@ -362,9 +373,9 @@ static void webKitFindControllerPerform(WebKitFindController* findController, We
         // unconditionally show highlights. Both search_next() and
         // search_prev() should not enable highlighting to avoid an
         // extra unmarkAllTextMatches() + markAllTextMatches()
-        findOptions |= FindOptionsShowHighlight;
+        findOptions |= WEBKIT_FIND_OPTIONS_SHOW_HIGHLIGHT;
 
-    getPage(findController)->findString(String::fromUTF8(priv->searchText.data()), static_cast<WebKit::FindOptions>(findOptions),
+    getPage(findController)->findString(String::fromUTF8(priv->searchText.data()), toWebKitFindOptions(findOptions),
                                         priv->maxMatchCount);
 }
 
@@ -425,7 +436,7 @@ void webkit_find_controller_search_next(WebKitFindController* findController)
     g_return_if_fail(WEBKIT_IS_FIND_CONTROLLER(findController));
 
     findController->priv->findOptions &= ~WEBKIT_FIND_OPTIONS_BACKWARDS;
-    findController->priv->findOptions &= ~FindOptionsShowHighlight;
+    findController->priv->findOptions &= ~WEBKIT_FIND_OPTIONS_SHOW_HIGHLIGHT;
     webKitFindControllerPerform(findController, FindNextPrevOperation);
 }
 
@@ -443,7 +454,7 @@ void webkit_find_controller_search_previous(WebKitFindController* findController
     g_return_if_fail(WEBKIT_IS_FIND_CONTROLLER(findController));
 
     findController->priv->findOptions |= WEBKIT_FIND_OPTIONS_BACKWARDS;
-    findController->priv->findOptions &= ~FindOptionsShowHighlight;
+    findController->priv->findOptions &= ~WEBKIT_FIND_OPTIONS_SHOW_HIGHLIGHT;
     webKitFindControllerPerform(findController, FindNextPrevOperation);
 }
 
index 7bad1d0..c89c386 100644 (file)
@@ -63,6 +63,10 @@ typedef enum {
   WEBKIT_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START = 1 << 2,
   WEBKIT_FIND_OPTIONS_BACKWARDS =                          1 << 3,
   WEBKIT_FIND_OPTIONS_WRAP_AROUND =                        1 << 4,
+  /*< private >*/
+  WEBKIT_FIND_OPTIONS_SHOW_OVERLAY =                       1 << 5,
+  WEBKIT_FIND_OPTIONS_SHOW_FIND_INDICATOR =                1 << 6,
+  WEBKIT_FIND_OPTIONS_SHOW_HIGHLIGHT =                     1 << 7,
 } WebKitFindOptions;
 
 struct _WebKitFindController {
index 1b77b6e..b9ac234 100644 (file)
@@ -21,6 +21,7 @@
 #include "WebKitInjectedBundleClient.h"
 
 #include "WebImage.h"
+#include "WebKitPrivate.h"
 #include "WebKitURIRequestPrivate.h"
 #include "WebKitURIResponsePrivate.h"
 #include "WebKitWebContextPrivate.h"
@@ -87,7 +88,7 @@ static void didReceiveWebViewMessageFromInjectedBundle(WebKitWebView* webView, c
         API::Error* webError = static_cast<API::Error*>(message.get(String::fromUTF8("Error")));
         const ResourceError& platformError = webError->platformError();
         GUniquePtr<GError> resourceError(g_error_new_literal(g_quark_from_string(platformError.domain().utf8().data()),
-            platformError.errorCode(), platformError.localizedDescription().utf8().data()));
+            toWebKitError(platformError.errorCode()), platformError.localizedDescription().utf8().data()));
 
         webkitWebResourceFailed(resource.get(), resourceError.get());
         webkitWebViewRemoveLoadingWebResource(webView, resourceIdentifier->value());
index 4b2e59c..ab97d29 100644 (file)
@@ -22,6 +22,7 @@
 #include "WebKitLoaderClient.h"
 
 #include "WebKitBackForwardListPrivate.h"
+#include "WebKitPrivate.h"
 #include "WebKitURIResponsePrivate.h"
 #include "WebKitWebViewBasePrivate.h"
 #include "WebKitWebViewPrivate.h"
@@ -54,7 +55,7 @@ static void didFailProvisionalLoadWithErrorForFrame(WKPageRef page, WKFrameRef f
 
     const ResourceError& resourceError = toImpl(error)->platformError();
     GUniquePtr<GError> webError(g_error_new_literal(g_quark_from_string(resourceError.domain().utf8().data()),
-        resourceError.errorCode(), resourceError.localizedDescription().utf8().data()));
+        toWebKitError(resourceError.errorCode()), resourceError.localizedDescription().utf8().data()));
     if (resourceError.tlsErrors()) {
         webkitWebViewLoadFailedWithTLSErrors(WEBKIT_WEB_VIEW(clientInfo), resourceError.failingURL().utf8().data(), webError.get(),
             static_cast<GTlsCertificateFlags>(resourceError.tlsErrors()), resourceError.certificate());
@@ -85,7 +86,7 @@ static void didFailLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErr
 
     const ResourceError& resourceError = toImpl(error)->platformError();
     GUniquePtr<GError> webError(g_error_new_literal(g_quark_from_string(resourceError.domain().utf8().data()),
-        resourceError.errorCode(), resourceError.localizedDescription().utf8().data()));
+        toWebKitError(resourceError.errorCode()), resourceError.localizedDescription().utf8().data()));
     webkitWebViewLoadFailed(WEBKIT_WEB_VIEW(clientInfo), WEBKIT_LOAD_COMMITTED,
                             resourceError.failingURL().utf8().data(), webError.get());
 }
index f03446b..83366dc 100644 (file)
@@ -243,13 +243,6 @@ const char* webkit_navigation_policy_decision_get_frame_name(WebKitNavigationPol
     return decision->priv->frameName.data();
 }
 
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NAVIGATION_TYPE_LINK_CLICKED, NavigationTypeLinkClicked);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED, NavigationTypeFormSubmitted);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NAVIGATION_TYPE_BACK_FORWARD, NavigationTypeBackForward);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NAVIGATION_TYPE_RELOAD, NavigationTypeReload);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED, NavigationTypeFormResubmitted);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NAVIGATION_TYPE_OTHER, NavigationTypeOther);
-
 WebKitNavigationPolicyDecision* webkitNavigationPolicyDecisionCreate(WebKitNavigationType navigationType, unsigned mouseButton, unsigned modifiers, API::URLRequest* request, const char* frameName, WebFramePolicyListenerProxy* listener)
 {
     WebKitNavigationPolicyDecision* decision = WEBKIT_NAVIGATION_POLICY_DECISION(g_object_new(WEBKIT_TYPE_NAVIGATION_POLICY_DECISION, NULL));
index 1eb6b1e..082c3c4 100644 (file)
 
 using namespace WebKit;
 
+static inline WebKitNavigationType toWebKitNavigationType(WKFrameNavigationType type)
+{
+    switch (type) {
+    case kWKFrameNavigationTypeLinkClicked:
+        return WEBKIT_NAVIGATION_TYPE_LINK_CLICKED;
+    case kWKFrameNavigationTypeFormSubmitted:
+        return WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED;
+    case kWKFrameNavigationTypeBackForward:
+        return WEBKIT_NAVIGATION_TYPE_BACK_FORWARD;
+    case kWKFrameNavigationTypeReload:
+        return WEBKIT_NAVIGATION_TYPE_RELOAD;
+    case kWKFrameNavigationTypeFormResubmitted:
+        return WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED;
+    case kWKFrameNavigationTypeOther:
+        return WEBKIT_NAVIGATION_TYPE_OTHER;
+    default:
+        ASSERT_NOT_REACHED();
+        return WEBKIT_NAVIGATION_TYPE_LINK_CLICKED;
+    }
+}
+
 static void decidePolicyForNavigationAction(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKFrameRef originatingFrame, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
 {
     GRefPtr<WebKitNavigationPolicyDecision> decision =
-        adoptGRef(webkitNavigationPolicyDecisionCreate(static_cast<WebKitNavigationType>(navigationType),
+        adoptGRef(webkitNavigationPolicyDecisionCreate(toWebKitNavigationType(navigationType),
                                                        wkEventMouseButtonToWebKitMouseButton(mouseButton),
                                                        wkEventModifiersToGdkModifiers(modifiers),
                                                        toImpl(request),
@@ -46,7 +67,7 @@ static void decidePolicyForNavigationAction(WKPageRef page, WKFrameRef frame, WK
 static void decidePolicyForNewWindowAction(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKStringRef frameName, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
 {
     GRefPtr<WebKitNavigationPolicyDecision> decision =
-        adoptGRef(webkitNavigationPolicyDecisionCreate(static_cast<WebKitNavigationType>(navigationType),
+        adoptGRef(webkitNavigationPolicyDecisionCreate(toWebKitNavigationType(navigationType),
                                                        wkEventMouseButtonToWebKitMouseButton(mouseButton),
                                                        wkEventModifiersToGdkModifiers(modifiers),
                                                        toImpl(request),
index 810d2c7..0a0386a 100644 (file)
@@ -263,7 +263,7 @@ static void drawPagesForPrintingCompleted(API::Error* wkPrintError, WebKitPrintO
     const WebCore::ResourceError& resourceError = wkPrintError ? wkPrintError->platformError() : WebCore::ResourceError();
     if (!resourceError.isNull()) {
         GUniquePtr<GError> printError(g_error_new_literal(g_quark_from_string(resourceError.domain().utf8().data()),
-            resourceError.errorCode(), resourceError.localizedDescription().utf8().data()));
+            toWebKitError(resourceError.errorCode()), resourceError.localizedDescription().utf8().data()));
         g_signal_emit(printOperation, signals[FAILED], 0, printError.get());
     }
     g_signal_emit(printOperation, signals[FINISHED], 0, NULL);
index d34b9c4..6a6d92a 100644 (file)
@@ -20,6 +20,8 @@
 #include "config.h"
 #include "WebKitPrivate.h"
 
+#include "ErrorsGtk.h"
+#include "WebKitError.h"
 #include <gdk/gdk.h>
 
 unsigned wkEventModifiersToGdkModifiers(WKEventModifiers wkModifiers)
@@ -51,3 +53,109 @@ unsigned wkEventMouseButtonToWebKitMouseButton(WKEventMouseButton wkButton)
     ASSERT_NOT_REACHED();
     return 0;
 }
+
+unsigned toWebKitError(unsigned webCoreError)
+{
+    switch (webCoreError) {
+    case WebCore::NetworkErrorFailed:
+        return WEBKIT_NETWORK_ERROR_FAILED;
+    case WebCore::NetworkErrorTransport:
+        return WEBKIT_NETWORK_ERROR_TRANSPORT;
+    case WebCore::NetworkErrorUnknownProtocol:
+        return WEBKIT_NETWORK_ERROR_UNKNOWN_PROTOCOL;
+    case WebCore::NetworkErrorCancelled:
+        return WEBKIT_NETWORK_ERROR_CANCELLED;
+    case WebCore::NetworkErrorFileDoesNotExist:
+        return WEBKIT_NETWORK_ERROR_FILE_DOES_NOT_EXIST;
+    case WebCore::PolicyErrorFailed:
+        return WEBKIT_POLICY_ERROR_FAILED;
+    case WebCore::PolicyErrorCannotShowMimeType:
+        return WEBKIT_POLICY_ERROR_CANNOT_SHOW_MIME_TYPE;
+    case WebCore::PolicyErrorCannotShowURL:
+        return WEBKIT_POLICY_ERROR_CANNOT_SHOW_URI;
+    case WebCore::PolicyErrorFrameLoadInterruptedByPolicyChange:
+        return WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE;
+    case WebCore::PolicyErrorCannotUseRestrictedPort:
+        return WEBKIT_POLICY_ERROR_CANNOT_USE_RESTRICTED_PORT;
+    case WebCore::PluginErrorFailed:
+        return WEBKIT_PLUGIN_ERROR_FAILED;
+    case WebCore::PluginErrorCannotFindPlugin:
+        return WEBKIT_PLUGIN_ERROR_CANNOT_FIND_PLUGIN;
+    case WebCore::PluginErrorCannotLoadPlugin:
+        return WEBKIT_PLUGIN_ERROR_CANNOT_LOAD_PLUGIN;
+    case WebCore::PluginErrorJavaUnavailable:
+        return WEBKIT_PLUGIN_ERROR_JAVA_UNAVAILABLE;
+    case WebCore::PluginErrorConnectionCancelled:
+        return WEBKIT_PLUGIN_ERROR_CONNECTION_CANCELLED;
+    case WebCore::PluginErrorWillHandleLoad:
+        return WEBKIT_PLUGIN_ERROR_WILL_HANDLE_LOAD;
+    case WebCore::DownloadErrorNetwork:
+        return WEBKIT_DOWNLOAD_ERROR_NETWORK;
+    case WebCore::DownloadErrorCancelledByUser:
+        return WEBKIT_DOWNLOAD_ERROR_CANCELLED_BY_USER;
+    case WebCore::DownloadErrorDestination:
+        return WEBKIT_DOWNLOAD_ERROR_DESTINATION;
+    case WebCore::PrintErrorGeneral:
+        return WEBKIT_PRINT_ERROR_GENERAL;
+    case WebCore::PrintErrorPrinterNotFound:
+        return WEBKIT_PRINT_ERROR_PRINTER_NOT_FOUND;
+    case WebCore::PrintErrorInvalidPageRange:
+        return WEBKIT_PRINT_ERROR_INVALID_PAGE_RANGE;
+    default:
+        ASSERT_NOT_REACHED();
+        return WEBKIT_NETWORK_ERROR_FAILED;
+    }
+}
+
+unsigned toWebCoreError(unsigned webKitError)
+{
+    switch (webKitError) {
+    case WEBKIT_NETWORK_ERROR_FAILED:
+        return WebCore::NetworkErrorFailed;
+    case WEBKIT_NETWORK_ERROR_TRANSPORT:
+        return WebCore::NetworkErrorTransport;
+    case WEBKIT_NETWORK_ERROR_UNKNOWN_PROTOCOL:
+        return WebCore::NetworkErrorUnknownProtocol;
+    case WEBKIT_NETWORK_ERROR_CANCELLED:
+        return WebCore::NetworkErrorCancelled;
+    case WEBKIT_NETWORK_ERROR_FILE_DOES_NOT_EXIST:
+        return WebCore::NetworkErrorFileDoesNotExist;
+    case WEBKIT_POLICY_ERROR_FAILED:
+        return WebCore::PolicyErrorFailed;
+    case WEBKIT_POLICY_ERROR_CANNOT_SHOW_MIME_TYPE:
+        return WebCore::PolicyErrorCannotShowMimeType;
+    case WEBKIT_POLICY_ERROR_CANNOT_SHOW_URI:
+        return WebCore::PolicyErrorCannotShowURL;
+    case WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE:
+        return WebCore::PolicyErrorFrameLoadInterruptedByPolicyChange;
+    case WEBKIT_POLICY_ERROR_CANNOT_USE_RESTRICTED_PORT:
+        return WebCore::PolicyErrorCannotUseRestrictedPort;
+    case WEBKIT_PLUGIN_ERROR_FAILED:
+        return WebCore::PluginErrorFailed;
+    case WEBKIT_PLUGIN_ERROR_CANNOT_FIND_PLUGIN:
+        return WebCore::PluginErrorCannotFindPlugin;
+    case WEBKIT_PLUGIN_ERROR_CANNOT_LOAD_PLUGIN:
+        return WebCore::PluginErrorCannotLoadPlugin;
+    case WEBKIT_PLUGIN_ERROR_JAVA_UNAVAILABLE:
+        return WebCore::PluginErrorJavaUnavailable;
+    case WEBKIT_PLUGIN_ERROR_CONNECTION_CANCELLED:
+        return WebCore::PluginErrorConnectionCancelled;
+    case WEBKIT_PLUGIN_ERROR_WILL_HANDLE_LOAD:
+        return WebCore::PluginErrorWillHandleLoad;
+    case WEBKIT_DOWNLOAD_ERROR_NETWORK:
+        return WebCore::DownloadErrorNetwork;
+    case WEBKIT_DOWNLOAD_ERROR_CANCELLED_BY_USER:
+        return WebCore::DownloadErrorCancelledByUser;
+    case WEBKIT_DOWNLOAD_ERROR_DESTINATION:
+        return WebCore::DownloadErrorDestination;
+    case WEBKIT_PRINT_ERROR_GENERAL:
+        return WebCore::PrintErrorGeneral;
+    case WEBKIT_PRINT_ERROR_PRINTER_NOT_FOUND:
+        return WebCore::PrintErrorPrinterNotFound;
+    case WEBKIT_PRINT_ERROR_INVALID_PAGE_RANGE:
+        return WebCore::PrintErrorInvalidPageRange;
+    default:
+        ASSERT_NOT_REACHED();
+        return WebCore::NetworkErrorFailed;
+    }
+}
index bd060ed..315bd16 100644 (file)
@@ -49,9 +49,6 @@
 #define WEBKIT_PARAM_WRITABLE (static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB))
 #define WEBKIT_PARAM_READWRITE (static_cast<GParamFlags>(G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB))
 
-#define COMPILE_ASSERT_MATCHING_ENUM(webkitName, webcoreName) \
-        COMPILE_ASSERT(int(webkitName) == int(webcoreName), mismatchingEnums)
-
 #define WEBKIT_DEFINE_ASYNC_DATA_STRUCT(structName) \
 static structName* create##structName() \
 { \
@@ -118,6 +115,8 @@ GType type_name##_get_type(void) \
 
 unsigned wkEventModifiersToGdkModifiers(WKEventModifiers);
 unsigned wkEventMouseButtonToWebKitMouseButton(WKEventMouseButton);
+unsigned toWebKitError(unsigned webCoreError);
+unsigned toWebCoreError(unsigned webKitError);
 
 enum SnapshotRegion {
     SnapshotRegionVisible,
index 6d8c684..fc8b4b6 100644 (file)
@@ -21,6 +21,7 @@
 #include "WebKitURISchemeRequest.h"
 
 #include "APIData.h"
+#include "WebKitPrivate.h"
 #include "WebKitURISchemeRequestPrivate.h"
 #include "WebKitWebContextPrivate.h"
 #include "WebKitWebView.h"
@@ -230,7 +231,7 @@ void webkit_uri_scheme_request_finish_error(WebKitURISchemeRequest* request, GEr
 
     WebKitURISchemeRequestPrivate* priv = request->priv;
 
-    WebCore::ResourceError resourceError(g_quark_to_string(error->domain), error->code, priv->uri.data(), String::fromUTF8(error->message));
+    WebCore::ResourceError resourceError(g_quark_to_string(error->domain), toWebCoreError(error->code), priv->uri.data(), String::fromUTF8(error->message));
     priv->webRequestManager->didFailWithError(priv->requestID, resourceError);
     webkitWebContextDidFinishLoadingCustomProtocol(priv->webContext, priv->requestID);
 }
index 3bd8930..6123ad1 100644 (file)
@@ -165,6 +165,32 @@ static guint signals[LAST_SIGNAL] = { 0, };
 
 WEBKIT_DEFINE_TYPE(WebKitWebContext, webkit_web_context, G_TYPE_OBJECT)
 
+static inline WebKit::ProcessModel toProcessModel(WebKitProcessModel webKitProcessModel)
+{
+    switch (webKitProcessModel) {
+    case WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS:
+        return ProcessModelSharedSecondaryProcess;
+    case WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES:
+        return ProcessModelMultipleSecondaryProcesses;
+    default:
+        ASSERT_NOT_REACHED();
+        return ProcessModelSharedSecondaryProcess;
+    }
+}
+
+static inline WebKitProcessModel toWebKitProcessModel(WebKit::ProcessModel processModel)
+{
+    switch (processModel) {
+    case ProcessModelSharedSecondaryProcess:
+        return WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS;
+    case ProcessModelMultipleSecondaryProcesses:
+        return WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES;
+    default:
+        ASSERT_NOT_REACHED();
+        return WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS;
+    }
+}
+
 static void webkit_web_context_class_init(WebKitWebContextClass* webContextClass)
 {
     GObjectClass* gObjectClass = G_OBJECT_CLASS(webContextClass);
@@ -917,18 +943,7 @@ void webkit_web_context_set_process_model(WebKitWebContext* context, WebKitProce
 {
     g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
 
-    ProcessModel newProcessModel;
-
-    switch (processModel) {
-    case WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS:
-        newProcessModel = ProcessModelSharedSecondaryProcess;
-        break;
-    case WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES:
-        newProcessModel = ProcessModelMultipleSecondaryProcesses;
-        break;
-    default:
-        g_assert_not_reached();
-    }
+    ProcessModel newProcessModel(toProcessModel(processModel));
 
     if (newProcessModel == context->priv->context->processModel())
         return;
@@ -952,14 +967,7 @@ WebKitProcessModel webkit_web_context_get_process_model(WebKitWebContext* contex
 {
     g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS);
 
-    switch (context->priv->context->processModel()) {
-    case ProcessModelSharedSecondaryProcess:
-        return WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS;
-    case ProcessModelMultipleSecondaryProcesses:
-        return WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES;
-    default:
-        g_assert_not_reached();
-    }
+    return toWebKitProcessModel(context->priv->context->processModel());
 }
 
 WebKitDownload* webkitWebContextGetOrCreateDownload(DownloadProxy* downloadProxy)
index 8f7290b..f7e13fd 100644 (file)
@@ -3106,9 +3106,6 @@ void webKitWebViewDidReceiveSnapshot(WebKitWebView* webView, uint64_t callbackID
         g_task_return_pointer(task.get(), 0, 0);
 }
 
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_SNAPSHOT_REGION_VISIBLE, SnapshotRegionVisible);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT, SnapshotRegionFullDocument);
-
 static inline unsigned webKitSnapshotOptionsToSnapshotOptions(WebKitSnapshotOptions options)
 {
     SnapshotOptions snapshotOptions = 0;
@@ -3119,6 +3116,19 @@ static inline unsigned webKitSnapshotOptionsToSnapshotOptions(WebKitSnapshotOpti
     return snapshotOptions;
 }
 
+static inline SnapshotRegion toSnapshotRegion(WebKitSnapshotRegion region)
+{
+    switch (region) {
+    case WEBKIT_SNAPSHOT_REGION_VISIBLE:
+        return SnapshotRegionVisible;
+    case WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT:
+        return SnapshotRegionFullDocument;
+    default:
+        ASSERT_NOT_REACHED();
+        return SnapshotRegionVisible;
+    }
+}
+
 static inline uint64_t generateSnapshotCallbackID()
 {
     static uint64_t uniqueCallbackID = 1;
@@ -3148,7 +3158,7 @@ void webkit_web_view_get_snapshot(WebKitWebView* webView, WebKitSnapshotRegion r
     ImmutableDictionary::MapType message;
     uint64_t callbackID = generateSnapshotCallbackID();
     message.set(String::fromUTF8("SnapshotOptions"), API::UInt64::create(static_cast<uint64_t>(webKitSnapshotOptionsToSnapshotOptions(options))));
-    message.set(String::fromUTF8("SnapshotRegion"), API::UInt64::create(static_cast<uint64_t>(region)));
+    message.set(String::fromUTF8("SnapshotRegion"), API::UInt64::create(static_cast<uint64_t>(toSnapshotRegion(region))));
     message.set(String::fromUTF8("CallbackID"), API::UInt64::create(callbackID));
 
     webView->priv->snapshotResultsMap.set(callbackID, adoptGRef(g_task_new(webView, cancellable, callback, userData)));
index 289ecdf..b21e79f 100644 (file)
@@ -67,6 +67,19 @@ struct _WebKitWebViewGroupPrivate {
 
 WEBKIT_DEFINE_TYPE(WebKitWebViewGroup, webkit_web_view_group, G_TYPE_OBJECT)
 
+static inline WebCore::UserContentInjectedFrames toWebCoreUserContentInjectedFrames(WebKitInjectedContentFrames kitFrames)
+{
+    switch (kitFrames) {
+    case WEBKIT_INJECTED_CONTENT_FRAMES_ALL:
+        return WebCore::InjectInAllFrames;
+    case WEBKIT_INJECTED_CONTENT_FRAMES_TOP_ONLY:
+        return WebCore::InjectInTopFrameOnly;
+    default:
+        ASSERT_NOT_REACHED();
+        return WebCore::InjectInAllFrames;
+    }
+}
+
 static void webkitWebViewGroupSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec)
 {
     WebKitWebViewGroup* group = WEBKIT_WEB_VIEW_GROUP(object);
@@ -224,9 +237,6 @@ void webkit_web_view_group_set_settings(WebKitWebViewGroup* group, WebKitSetting
     g_object_notify(G_OBJECT(group), "settings");
 }
 
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_INJECTED_CONTENT_FRAMES_ALL, WebCore::InjectInAllFrames);
-COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_INJECTED_CONTENT_FRAMES_TOP_ONLY, WebCore::InjectInTopFrameOnly);
-
 static PassRefPtr<API::Array> toAPIArray(const char* const* list)
 {
     if (!list)
@@ -270,7 +280,7 @@ void webkit_web_view_group_add_user_style_sheet(WebKitWebViewGroup* group, const
         String::fromUTF8(baseURI),
         webWhitelist.get(),
         webBlacklist.get(),
-        static_cast<WebCore::UserContentInjectedFrames>(injectedFrames),
+        toWebCoreUserContentInjectedFrames(injectedFrames),
         WebCore::UserStyleUserLevel);
 }