Skip to content
Permalink
Browse files
[EFL][WK2] Stop using COMPILE_ASSERT_MATCHING_ENUM macros in EFL WebKit2
https://bugs.webkit.org/show_bug.cgi?id=128156

Reviewed by Anders Carlsson.

* UIProcess/API/efl/EwkView.cpp:
(EwkView::requestPopupMenu):
* UIProcess/API/efl/ewk_context.cpp:
(toWKCacheModel):
(EwkContext::setCacheModel):
* UIProcess/API/efl/ewk_cookie_manager.cpp:
(ewk_cookie_manager_persistent_storage_set):
(ewk_cookie_manager_accept_policy_set):
* UIProcess/API/efl/ewk_navigation_policy_decision.cpp:
(toEwkNavigationType):
(toEventMouseButton):
(toEventModifierKeys):
(EwkNavigationPolicyDecision::EwkNavigationPolicyDecision):
(EwkNavigationPolicyDecision::navigationType):
(EwkNavigationPolicyDecision::mouseButton):
(EwkNavigationPolicyDecision::modifiers):
(ewk_navigation_policy_decision_download):
* UIProcess/API/efl/ewk_navigation_policy_decision_private.h:
(EwkNavigationPolicyDecision::create):
* UIProcess/API/efl/ewk_popup_menu_item.cpp:
(EwkPopupMenuItem::type):
(EwkPopupMenuItem::textDirection):
* UIProcess/API/efl/ewk_private.h:
* UIProcess/API/efl/ewk_view.cpp:
(toWKFindOptions):
(ewk_view_text_find):
(toWKPaginationMode):
(toEwkPaginationMode):
(ewk_view_pagination_mode_set):
(ewk_view_pagination_mode_get):


Canonical link: https://commits.webkit.org/146174@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@163367 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Jinwoo-Song committed Feb 4, 2014
1 parent 3336356 commit 0f93f6717fb627f7b406048dda1b1e19b8bd44ce
@@ -1,3 +1,41 @@
2014-02-04 Jinwoo Song <jinwoo7.song@samsung.com>

[EFL][WK2] Stop using COMPILE_ASSERT_MATCHING_ENUM macros in EFL WebKit2
https://bugs.webkit.org/show_bug.cgi?id=128156

Reviewed by Anders Carlsson.

* UIProcess/API/efl/EwkView.cpp:
(EwkView::requestPopupMenu):
* UIProcess/API/efl/ewk_context.cpp:
(toWKCacheModel):
(EwkContext::setCacheModel):
* UIProcess/API/efl/ewk_cookie_manager.cpp:
(ewk_cookie_manager_persistent_storage_set):
(ewk_cookie_manager_accept_policy_set):
* UIProcess/API/efl/ewk_navigation_policy_decision.cpp:
(toEwkNavigationType):
(toEventMouseButton):
(toEventModifierKeys):
(EwkNavigationPolicyDecision::EwkNavigationPolicyDecision):
(EwkNavigationPolicyDecision::navigationType):
(EwkNavigationPolicyDecision::mouseButton):
(EwkNavigationPolicyDecision::modifiers):
(ewk_navigation_policy_decision_download):
* UIProcess/API/efl/ewk_navigation_policy_decision_private.h:
(EwkNavigationPolicyDecision::create):
* UIProcess/API/efl/ewk_popup_menu_item.cpp:
(EwkPopupMenuItem::type):
(EwkPopupMenuItem::textDirection):
* UIProcess/API/efl/ewk_private.h:
* UIProcess/API/efl/ewk_view.cpp:
(toWKFindOptions):
(ewk_view_text_find):
(toWKPaginationMode):
(toEwkPaginationMode):
(ewk_view_pagination_mode_set):
(ewk_view_pagination_mode_get):

2014-02-03 Brady Eidson <beidson@apple.com>

Unreviewed build fix after http://trac.webkit.org/changeset/163364
@@ -876,9 +876,6 @@ void EwkView::dismissColorPicker()
}
#endif

COMPILE_ASSERT_MATCHING_ENUM(EWK_TEXT_DIRECTION_RIGHT_TO_LEFT, RTL);
COMPILE_ASSERT_MATCHING_ENUM(EWK_TEXT_DIRECTION_LEFT_TO_RIGHT, LTR);

void EwkView::customContextMenuItemSelected(WKContextMenuItemRef contextMenuItem)
{
Ewk_View_Smart_Data* sd = smartData();
@@ -924,9 +921,6 @@ void EwkView::hideContextMenu()
m_contextMenu.clear();
}

COMPILE_ASSERT_MATCHING_ENUM(EWK_TEXT_DIRECTION_RIGHT_TO_LEFT, kWKPopupItemTextDirectionRTL);
COMPILE_ASSERT_MATCHING_ENUM(EWK_TEXT_DIRECTION_LEFT_TO_RIGHT, kWKPopupItemTextDirectionLTR);

void EwkView::requestPopupMenu(WKPopupMenuListenerRef popupMenuListener, const WKRect& rect, WKPopupItemTextDirection textDirection, double pageScaleFactor, WKArrayRef items, int32_t selectedIndex)
{
Ewk_View_Smart_Data* sd = smartData();
@@ -947,7 +941,14 @@ void EwkView::requestPopupMenu(WKPopupMenuListenerRef popupMenuListener, const W
Eina_Rectangle einaRect;
EINA_RECTANGLE_SET(&einaRect, popupMenuPosition.x, popupMenuPosition.y, rect.size.width, rect.size.height);

sd->api->popup_menu_show(sd, einaRect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, m_popupMenu.get());
switch (textDirection) {
case kWKPopupItemTextDirectionRTL:
sd->api->popup_menu_show(sd, einaRect, EWK_TEXT_DIRECTION_RIGHT_TO_LEFT, pageScaleFactor, m_popupMenu.get());
break;
case EWK_TEXT_DIRECTION_LEFT_TO_RIGHT:
sd->api->popup_menu_show(sd, einaRect, EWK_TEXT_DIRECTION_LEFT_TO_RIGHT, pageScaleFactor, m_popupMenu.get());
break;
}
}

void EwkView::closePopupMenu()
@@ -198,9 +198,25 @@ void EwkContext::addVisitedLink(const String& visitedURL)
WKContextAddVisitedLink(m_context.get(), adoptWK(toCopiedAPI(visitedURL)).get());
}

// Ewk_Cache_Model enum validation
inline WKCacheModel toWKCacheModel(Ewk_Cache_Model cacheModel)
{
switch (cacheModel) {
case EWK_CACHE_MODEL_DOCUMENT_VIEWER:
return kWKCacheModelDocumentViewer;
case EWK_CACHE_MODEL_DOCUMENT_BROWSER:
return kWKCacheModelDocumentBrowser;
case EWK_CACHE_MODEL_PRIMARY_WEBBROWSER:
return kWKCacheModelPrimaryWebBrowser;
}
ASSERT_NOT_REACHED();

return kWKCacheModelDocumentViewer;
}

void EwkContext::setCacheModel(Ewk_Cache_Model cacheModel)
{
WKContextSetCacheModel(m_context.get(), static_cast<WebKit::CacheModel>(cacheModel));
WKContextSetCacheModel(m_context.get(), toWKCacheModel(cacheModel));
}

Ewk_Cache_Model EwkContext::cacheModel() const
@@ -318,11 +334,6 @@ void ewk_context_visited_link_add(Ewk_Context* ewkContext, const char* visitedUR
impl->addVisitedLink(visitedURL);
}

// Ewk_Cache_Model enum validation
COMPILE_ASSERT_MATCHING_ENUM(EWK_CACHE_MODEL_DOCUMENT_VIEWER, kWKCacheModelDocumentViewer);
COMPILE_ASSERT_MATCHING_ENUM(EWK_CACHE_MODEL_DOCUMENT_BROWSER, kWKCacheModelDocumentBrowser);
COMPILE_ASSERT_MATCHING_ENUM(EWK_CACHE_MODEL_PRIMARY_WEBBROWSER, kWKCacheModelPrimaryWebBrowser);

Eina_Bool ewk_context_cache_model_set(Ewk_Context* ewkContext, Ewk_Cache_Model cacheModel)
{
EWK_OBJ_GET_IMPL_OR_RETURN(EwkContext, ewkContext, impl, false);
@@ -33,6 +33,7 @@
#include "ewk_cookie_manager_private.h"
#include "ewk_error_private.h"
#include "ewk_private.h"
#include <wtf/Assertions.h>
#include <wtf/OwnPtr.h>

using namespace WebKit;
@@ -120,28 +121,48 @@ void EwkCookieManager::cookiesDidChange(WKCookieManagerRef, const void* clientIn
manager->m_changeHandler.callback(manager->m_changeHandler.userData);
}

// Ewk_Cookie_Persistent_Storage enum validation.
COMPILE_ASSERT_MATCHING_ENUM(EWK_COOKIE_PERSISTENT_STORAGE_TEXT, kWKCookieStorageTypeText);
COMPILE_ASSERT_MATCHING_ENUM(EWK_COOKIE_PERSISTENT_STORAGE_SQLITE, kWKCookieStorageTypeSQLite);

void ewk_cookie_manager_persistent_storage_set(Ewk_Cookie_Manager* manager, const char* filename, Ewk_Cookie_Persistent_Storage storage)
{
EINA_SAFETY_ON_NULL_RETURN(manager);
EINA_SAFETY_ON_NULL_RETURN(filename);

manager->setPersistentStorage(filename, static_cast<WKCookieStorageType>(storage));
}
WKCookieStorageType wkCookieStorageType = kWKCookieStorageTypeText;

switch (storage) {
case EWK_COOKIE_PERSISTENT_STORAGE_TEXT:
wkCookieStorageType = kWKCookieStorageTypeText;
break;
case EWK_COOKIE_PERSISTENT_STORAGE_SQLITE:
wkCookieStorageType = kWKCookieStorageTypeSQLite;
break;
default:
ASSERT_NOT_REACHED();
}

// Ewk_Cookie_Accept_Policy enum validation.
COMPILE_ASSERT_MATCHING_ENUM(EWK_COOKIE_ACCEPT_POLICY_ALWAYS, kWKHTTPCookieAcceptPolicyAlways);
COMPILE_ASSERT_MATCHING_ENUM(EWK_COOKIE_ACCEPT_POLICY_NEVER, kWKHTTPCookieAcceptPolicyNever);
COMPILE_ASSERT_MATCHING_ENUM(EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY, kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain);
manager->setPersistentStorage(filename, wkCookieStorageType);
}

void ewk_cookie_manager_accept_policy_set(Ewk_Cookie_Manager* manager, Ewk_Cookie_Accept_Policy policy)
{
EINA_SAFETY_ON_NULL_RETURN(manager);

manager->setHTTPAcceptPolicy(static_cast<WKHTTPCookieAcceptPolicy>(policy));
WKHTTPCookieAcceptPolicy wkPolicy = kWKHTTPCookieAcceptPolicyAlways;

switch (policy) {
case EWK_COOKIE_ACCEPT_POLICY_ALWAYS:
wkPolicy = kWKHTTPCookieAcceptPolicyAlways;
break;
case EWK_COOKIE_ACCEPT_POLICY_NEVER:
wkPolicy = kWKHTTPCookieAcceptPolicyNever;
break;
case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY:
wkPolicy = kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
break;
default:
ASSERT_NOT_REACHED();
}

manager->setHTTPAcceptPolicy(wkPolicy);
}

struct Get_Policy_Async_Data {
@@ -32,7 +32,59 @@

using namespace WebKit;

EwkNavigationPolicyDecision::EwkNavigationPolicyDecision(WKFramePolicyListenerRef listener, Ewk_Navigation_Type navigationType, Event_Mouse_Button mouseButton, Event_Modifier_Keys modifiers, PassRefPtr<EwkUrlRequest> request, const char* frameName)
inline static Ewk_Navigation_Type toEwkNavigationType(WKFrameNavigationType navigationType)
{
switch (navigationType) {
case kWKFrameNavigationTypeLinkClicked:
return EWK_NAVIGATION_TYPE_LINK_ACTIVATED;
case kWKFrameNavigationTypeFormSubmitted:
return EWK_NAVIGATION_TYPE_FORM_SUBMITTED;
case kWKFrameNavigationTypeBackForward:
return EWK_NAVIGATION_TYPE_BACK_FORWARD;
case kWKFrameNavigationTypeReload:
return EWK_NAVIGATION_TYPE_RELOAD;
case kWKFrameNavigationTypeFormResubmitted:
return EWK_NAVIGATION_TYPE_FORM_RESUBMITTED;
case kWKFrameNavigationTypeOther:
return EWK_NAVIGATION_TYPE_OTHER;
}
ASSERT_NOT_REACHED();

return EWK_NAVIGATION_TYPE_LINK_ACTIVATED;
}

inline static Event_Mouse_Button toEventMouseButton(WKEventMouseButton mouseButton)
{
switch (mouseButton) {
case kWKEventMouseButtonNoButton:
return EVENT_MOUSE_BUTTON_NONE;
case kWKEventMouseButtonLeftButton:
return EVENT_MOUSE_BUTTON_LEFT;
case kWKEventMouseButtonMiddleButton:
return EVENT_MOUSE_BUTTON_MIDDLE;
case kWKEventMouseButtonRightButton:
return EVENT_MOUSE_BUTTON_RIGHT;
}
ASSERT_NOT_REACHED();

return EVENT_MOUSE_BUTTON_NONE;
}

inline static Event_Modifier_Keys toEventModifierKeys(WKEventModifiers modifiers)
{
unsigned keys = 0;
if (modifiers & kWKEventModifiersShiftKey)
keys |= EVENT_MODIFIER_KEY_SHIFT;
if (modifiers & kWKEventModifiersControlKey)
keys |= kWKEventModifiersControlKey;
if (modifiers & kWKEventModifiersAltKey)
keys |= EVENT_MODIFIER_KEY_ALT;
if (modifiers & kWKEventModifiersMetaKey)
keys |= EVENT_MODIFIER_KEY_META;
return static_cast<Event_Modifier_Keys>(keys);
}

EwkNavigationPolicyDecision::EwkNavigationPolicyDecision(WKFramePolicyListenerRef listener, WKFrameNavigationType navigationType, WKEventMouseButton mouseButton, WKEventModifiers modifiers, PassRefPtr<EwkUrlRequest> request, const char* frameName)
: m_listener(listener)
, m_actedUponByClient(false)
, m_navigationType(navigationType)
@@ -51,17 +103,17 @@ EwkNavigationPolicyDecision::~EwkNavigationPolicyDecision()

Ewk_Navigation_Type EwkNavigationPolicyDecision::navigationType() const
{
return m_navigationType;
return toEwkNavigationType(m_navigationType);
}

Event_Mouse_Button EwkNavigationPolicyDecision::mouseButton() const
{
return m_mouseButton;
return toEventMouseButton(m_mouseButton);
}

Event_Modifier_Keys EwkNavigationPolicyDecision::modifiers() const
{
return m_modifiers;
return toEventModifierKeys(m_modifiers);
}

const char* EwkNavigationPolicyDecision::frameName() const
@@ -147,23 +199,3 @@ void ewk_navigation_policy_decision_download(Ewk_Navigation_Policy_Decision* dec

impl->download();
}

// Ewk_Navigation_Type enum validation
COMPILE_ASSERT_MATCHING_ENUM(EWK_NAVIGATION_TYPE_LINK_ACTIVATED, kWKFrameNavigationTypeLinkClicked);
COMPILE_ASSERT_MATCHING_ENUM(EWK_NAVIGATION_TYPE_FORM_SUBMITTED, kWKFrameNavigationTypeFormSubmitted);
COMPILE_ASSERT_MATCHING_ENUM(EWK_NAVIGATION_TYPE_BACK_FORWARD, kWKFrameNavigationTypeBackForward);
COMPILE_ASSERT_MATCHING_ENUM(EWK_NAVIGATION_TYPE_RELOAD, kWKFrameNavigationTypeReload);
COMPILE_ASSERT_MATCHING_ENUM(EWK_NAVIGATION_TYPE_FORM_RESUBMITTED, kWKFrameNavigationTypeFormResubmitted);
COMPILE_ASSERT_MATCHING_ENUM(EWK_NAVIGATION_TYPE_OTHER, kWKFrameNavigationTypeOther);

// Event_Mouse_Button enum validation
COMPILE_ASSERT_MATCHING_ENUM(EVENT_MOUSE_BUTTON_NONE, kWKEventMouseButtonNoButton);
COMPILE_ASSERT_MATCHING_ENUM(EVENT_MOUSE_BUTTON_LEFT, kWKEventMouseButtonLeftButton);
COMPILE_ASSERT_MATCHING_ENUM(EVENT_MOUSE_BUTTON_MIDDLE, kWKEventMouseButtonMiddleButton);
COMPILE_ASSERT_MATCHING_ENUM(EVENT_MOUSE_BUTTON_RIGHT, kWKEventMouseButtonRightButton);

// Event_Modifier_Keys validation
COMPILE_ASSERT_MATCHING_ENUM(EVENT_MODIFIER_KEY_SHIFT, kWKEventModifiersShiftKey);
COMPILE_ASSERT_MATCHING_ENUM(EVENT_MODIFIER_KEY_CTRL, kWKEventModifiersControlKey);
COMPILE_ASSERT_MATCHING_ENUM(EVENT_MODIFIER_KEY_ALT, kWKEventModifiersAltKey);
COMPILE_ASSERT_MATCHING_ENUM(EVENT_MODIFIER_KEY_META, kWKEventModifiersMetaKey);
@@ -48,7 +48,7 @@ class EwkNavigationPolicyDecision : public EwkObject {

static PassRefPtr<EwkNavigationPolicyDecision> create(WKFrameNavigationType navigationType, WKEventMouseButton mouseButton, WKEventModifiers modifiers, WKURLRequestRef requestRef, const char* frameName, WKFramePolicyListenerRef listener)
{
return adoptRef(new EwkNavigationPolicyDecision(listener, static_cast<Ewk_Navigation_Type>(navigationType), static_cast<Event_Mouse_Button>(mouseButton), static_cast<Event_Modifier_Keys>(modifiers), EwkUrlRequest::create(requestRef), frameName));
return adoptRef(new EwkNavigationPolicyDecision(listener, navigationType, mouseButton, modifiers, EwkUrlRequest::create(requestRef), frameName));
}

void accept();
@@ -62,13 +62,13 @@ class EwkNavigationPolicyDecision : public EwkObject {
EwkUrlRequest* request() const;

private:
EwkNavigationPolicyDecision(WKFramePolicyListenerRef listener, Ewk_Navigation_Type navigationType, Event_Mouse_Button mouseButton, Event_Modifier_Keys modifiers, PassRefPtr<EwkUrlRequest> request, const char* frameName);
EwkNavigationPolicyDecision(WKFramePolicyListenerRef listener, WKFrameNavigationType navigationType, WKEventMouseButton mouseButton, WKEventModifiers modifiers, PassRefPtr<EwkUrlRequest> request, const char* frameName);

WKRetainPtr<WKFramePolicyListenerRef> m_listener;
bool m_actedUponByClient;
Ewk_Navigation_Type m_navigationType;
Event_Mouse_Button m_mouseButton;
Event_Modifier_Keys m_modifiers;
WKFrameNavigationType m_navigationType;
WKEventMouseButton m_mouseButton;
WKEventModifiers m_modifiers;
RefPtr<EwkUrlRequest> m_request;
WKEinaSharedString m_frameName;
};
@@ -34,17 +34,30 @@ EwkPopupMenuItem::EwkPopupMenuItem(WKPopupItemRef item)
: m_wkItem(item)
{ }

COMPILE_ASSERT_MATCHING_ENUM(EWK_POPUP_MENU_SEPARATOR, kWKPopupItemTypeSeparator);
COMPILE_ASSERT_MATCHING_ENUM(EWK_POPUP_MENU_ITEM, kWKPopupItemTypeItem);

Ewk_Popup_Menu_Item_Type EwkPopupMenuItem::type() const
{
return static_cast<Ewk_Popup_Menu_Item_Type>(WKPopupItemGetType(m_wkItem.get()));
switch (WKPopupItemGetType(m_wkItem.get())) {
case kWKPopupItemTypeSeparator:
return EWK_POPUP_MENU_SEPARATOR;
case kWKPopupItemTypeItem:
return EWK_POPUP_MENU_ITEM;
}
ASSERT_NOT_REACHED();

return EWK_POPUP_MENU_UNKNOWN;
}

Ewk_Text_Direction EwkPopupMenuItem::textDirection() const
{
return static_cast<Ewk_Text_Direction>(WKPopupItemGetTextDirection(m_wkItem.get()));
switch (WKPopupItemGetTextDirection(m_wkItem.get())) {
case kWKPopupItemTextDirectionRTL:
return EWK_TEXT_DIRECTION_RIGHT_TO_LEFT;
case kWKPopupItemTextDirectionLTR:
return EWK_TEXT_DIRECTION_LEFT_TO_RIGHT;
}
ASSERT_NOT_REACHED();

return EWK_TEXT_DIRECTION_LEFT_TO_RIGHT;
}

const char* EwkPopupMenuItem::text() const
@@ -26,11 +26,6 @@
#ifndef ewk_private_h
#define ewk_private_h

#include <wtf/Assertions.h>

#define COMPILE_ASSERT_MATCHING_ENUM(ewkName, webcoreName) \
COMPILE_ASSERT(int(ewkName) == int(webcoreName), mismatchingEnums)

extern int _ewk_log_dom;

#define CRITICAL(...) EINA_LOG_DOM_CRIT(_ewk_log_dom, __VA_ARGS__)

0 comments on commit 0f93f67

Please sign in to comment.