[EFL][WK2] Make Ewk_Context_Menu Ewk_Object
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 May 2013 00:36:49 +0000 (00:36 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 May 2013 00:36:49 +0000 (00:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=116097

Patch by Michał Pakuła vel Rutka <m.pakula@samsung.com> on 2013-05-16
Reviewed by Gyuyoung Kim.

Changed Ewk_Context_Menu to be an Ewk_Object so pointer to menu
object can be shared between different modules.

* UIProcess/API/efl/EwkView.cpp:
(EwkView::showContextMenu):
* UIProcess/API/efl/EwkView.h:
(EwkView):
* UIProcess/API/efl/ewk_context_menu.cpp:
(EwkContextMenu::appendItem):
(EwkContextMenu::removeItem):
(ewk_context_menu_new):
(ewk_context_menu_new_with_items):
(ewk_context_menu_item_append):
(ewk_context_menu_item_remove):
(ewk_context_menu_hide):
(ewk_context_menu_items_get):
(ewk_context_menu_item_select):
* UIProcess/API/efl/ewk_context_menu_item.cpp:
(EwkContextMenuItem::EwkContextMenuItem):
(ewk_context_menu_item_new_with_submenu):
* UIProcess/API/efl/ewk_context_menu_item_private.h:
(EwkContextMenuItem):
* UIProcess/API/efl/ewk_context_menu_private.h:
(EwkContextMenu):
(EwkContextMenu::create):
* UIProcess/API/efl/ewk_defines.h:

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/efl/EwkView.cpp
Source/WebKit2/UIProcess/API/efl/EwkView.h
Source/WebKit2/UIProcess/API/efl/ewk_context_menu.cpp
Source/WebKit2/UIProcess/API/efl/ewk_context_menu_item.cpp
Source/WebKit2/UIProcess/API/efl/ewk_context_menu_item_private.h
Source/WebKit2/UIProcess/API/efl/ewk_context_menu_private.h
Source/WebKit2/UIProcess/API/efl/ewk_defines.h

index 8c91f9c..9364eb7 100644 (file)
@@ -1,3 +1,37 @@
+2013-05-16  Michał Pakuła vel Rutka  <m.pakula@samsung.com>
+
+        [EFL][WK2] Make Ewk_Context_Menu Ewk_Object
+        https://bugs.webkit.org/show_bug.cgi?id=116097
+
+        Reviewed by Gyuyoung Kim.
+
+        Changed Ewk_Context_Menu to be an Ewk_Object so pointer to menu
+        object can be shared between different modules.
+
+        * UIProcess/API/efl/EwkView.cpp:
+        (EwkView::showContextMenu):
+        * UIProcess/API/efl/EwkView.h:
+        (EwkView):
+        * UIProcess/API/efl/ewk_context_menu.cpp:
+        (EwkContextMenu::appendItem):
+        (EwkContextMenu::removeItem):
+        (ewk_context_menu_new):
+        (ewk_context_menu_new_with_items):
+        (ewk_context_menu_item_append):
+        (ewk_context_menu_item_remove):
+        (ewk_context_menu_hide):
+        (ewk_context_menu_items_get):
+        (ewk_context_menu_item_select):
+        * UIProcess/API/efl/ewk_context_menu_item.cpp:
+        (EwkContextMenuItem::EwkContextMenuItem):
+        (ewk_context_menu_item_new_with_submenu):
+        * UIProcess/API/efl/ewk_context_menu_item_private.h:
+        (EwkContextMenuItem):
+        * UIProcess/API/efl/ewk_context_menu_private.h:
+        (EwkContextMenu):
+        (EwkContextMenu::create):
+        * UIProcess/API/efl/ewk_defines.h:
+
 2013-05-16  Andreas Kling  <akling@apple.com>
 
         Page::chrome() should return a reference.
index e381644..5ecb49b 100644 (file)
@@ -844,7 +844,7 @@ void EwkView::showContextMenu(WKPoint position, WKArrayRef items)
     if (m_contextMenu)
         hideContextMenu();
 
-    m_contextMenu = Ewk_Context_Menu::create(this, items);
+    m_contextMenu = EwkContextMenu::create(this, items);
 
     sd->api->context_menu_show(sd, position.x, position.y, m_contextMenu.get());
 }
index c67c376..9ce93d4 100644 (file)
@@ -278,7 +278,7 @@ private:
     bool m_touchEventsEnabled;
 #endif
     WebCore::Timer<EwkView> m_displayTimer;
-    OwnPtr<EwkContextMenu> m_contextMenu;
+    RefPtr<EwkContextMenu> m_contextMenu;
     OwnPtr<EwkPopupMenu> m_popupMenu;
     OwnPtr<WebKit::InputMethodContextEfl> m_inputMethodContext;
 #if ENABLE(INPUT_TYPE_COLOR)
index a480ad5..0bef0be 100644 (file)
@@ -80,12 +80,12 @@ void EwkContextMenu::hide()
     m_viewImpl->hideContextMenu();
 }
 
-void Ewk_Context_Menu::appendItem(EwkContextMenuItem* item)
+void EwkContextMenu::appendItem(EwkContextMenuItem* item)
 {
     m_contextMenuItems = eina_list_append(m_contextMenuItems, item);
 }
 
-void Ewk_Context_Menu::removeItem(EwkContextMenuItem* item)
+void EwkContextMenu::removeItem(EwkContextMenuItem* item)
 {
     m_contextMenuItems = eina_list_remove(m_contextMenuItems, item);
 }
@@ -97,51 +97,51 @@ void EwkContextMenu::contextMenuItemSelected(WKContextMenuItemRef item)
 
 Ewk_Context_Menu* ewk_context_menu_new()
 {
-    return EwkContextMenu::create().leakPtr();
+    return EwkContextMenu::create().leakRef();
 }
 
 Ewk_Context_Menu* ewk_context_menu_new_with_items(Eina_List* items)
 {
-    return EwkContextMenu::create(items).leakPtr();
+    return EwkContextMenu::create(items).leakRef();
 }
 
 Eina_Bool ewk_context_menu_item_append(Ewk_Context_Menu* menu, Ewk_Context_Menu_Item* item)
 {
-    EINA_SAFETY_ON_NULL_RETURN_VAL(menu, false);
+    EWK_OBJ_GET_IMPL_OR_RETURN(EwkContextMenu, menu, impl, false);
 
-    menu->appendItem(item);
+    impl->appendItem(item);
 
     return true;
 }
 
 Eina_Bool ewk_context_menu_item_remove(Ewk_Context_Menu* menu, Ewk_Context_Menu_Item* item)
 {
-    EINA_SAFETY_ON_NULL_RETURN_VAL(menu, false);
+    EWK_OBJ_GET_IMPL_OR_RETURN(EwkContextMenu, menu, impl, false);
 
-    menu->removeItem(item);
+    impl->removeItem(item);
 
     return true;
 }
 
 Eina_Bool ewk_context_menu_hide(Ewk_Context_Menu* menu)
 {
-    EINA_SAFETY_ON_NULL_RETURN_VAL(menu, false);
+    EWK_OBJ_GET_IMPL_OR_RETURN(EwkContextMenu, menu, impl, false);
 
-    menu->hide();
+    impl->hide();
 
     return true;
 }
 
 const Eina_List* ewk_context_menu_items_get(const Ewk_Context_Menu* menu)
 {
-    EINA_SAFETY_ON_NULL_RETURN_VAL(menu, 0);
+    EWK_OBJ_GET_IMPL_OR_RETURN(const EwkContextMenu, menu, impl, 0);
 
-    return menu->items();
+    return impl->items();
 }
 
 Eina_Bool ewk_context_menu_item_select(Ewk_Context_Menu* menu, Ewk_Context_Menu_Item* item)
 {
-    EINA_SAFETY_ON_NULL_RETURN_VAL(menu, false);
+    EWK_OBJ_GET_IMPL_OR_RETURN(EwkContextMenu, menu, impl, false);
     EINA_SAFETY_ON_NULL_RETURN_VAL(item, false);
 
     WKContextMenuItemRef wkItem;
@@ -158,7 +158,7 @@ Eina_Bool ewk_context_menu_item_select(Ewk_Context_Menu* menu, Ewk_Context_Menu_
         return false;
     }
 
-    menu->contextMenuItemSelected(wkItem);
+    impl->contextMenuItemSelected(wkItem);
 
     return true;
 }
index 9b85ba9..780850b 100644 (file)
@@ -35,7 +35,7 @@ using namespace WebKit;
 
 static Ewk_Context_Menu_Item_Action getEwkActionFromWKTag(WKContextMenuItemTag action);
 
-EwkContextMenuItem::EwkContextMenuItem(WKContextMenuItemRef item, Ewk_Context_Menu* parentMenu)
+EwkContextMenuItem::EwkContextMenuItem(WKContextMenuItemRef item, EwkContextMenu* parentMenu)
     : m_type(static_cast<Ewk_Context_Menu_Item_Type>(WKContextMenuItemGetType(item)))
     , m_action(getEwkActionFromWKTag((WKContextMenuItemGetTag(item))))
     , m_title(WKEinaSharedString(AdoptWK, WKContextMenuItemCopyTitle(item)))
@@ -46,7 +46,7 @@ EwkContextMenuItem::EwkContextMenuItem(WKContextMenuItemRef item, Ewk_Context_Me
 {
 }
 
-EwkContextMenuItem::EwkContextMenuItem(Ewk_Context_Menu_Item_Type type, Ewk_Context_Menu_Item_Action action, const char* title, Eina_Bool checked, Eina_Bool enabled, Ewk_Context_Menu* subMenu, Ewk_Context_Menu* parentMenu)
+EwkContextMenuItem::EwkContextMenuItem(Ewk_Context_Menu_Item_Type type, Ewk_Context_Menu_Item_Action action, const char* title, Eina_Bool checked, Eina_Bool enabled, EwkContextMenu* subMenu, EwkContextMenu* parentMenu)
     : m_type(type)
     , m_action(action)
     , m_title(title)
@@ -64,7 +64,9 @@ Ewk_Context_Menu_Item* ewk_context_menu_item_new(Ewk_Context_Menu_Item_Type type
 
 Ewk_Context_Menu_Item* ewk_context_menu_item_new_with_submenu(Ewk_Context_Menu_Item_Type type, Ewk_Context_Menu_Item_Action action, const char* title, Eina_Bool checked, Eina_Bool enabled, Ewk_Context_Menu* subMenu)
 {
-    return Ewk_Context_Menu_Item::create(type, action, title, checked, enabled, subMenu).leakPtr();
+    EWK_OBJ_GET_IMPL_OR_RETURN(EwkContextMenu, subMenu, subMenuImpl, 0);
+
+    return Ewk_Context_Menu_Item::create(type, action, title, checked, enabled, subMenuImpl).leakPtr();
 }
 
 Ewk_Context_Menu_Item_Type ewk_context_menu_item_type_get(const Ewk_Context_Menu_Item* item)
index 2511183..e9c446e 100644 (file)
@@ -30,6 +30,7 @@
 #include "WKEinaSharedString.h"
 #include "ewk_context_menu.h"
 #include "ewk_context_menu_item.h"
+#include "ewk_context_menu_private.h"
 #include <wtf/PassOwnPtr.h>
 
 /**
@@ -78,8 +79,8 @@ private:
     bool m_isChecked;
     bool m_isEnabled;
 
-    Ewk_Context_Menu* m_parentMenu;
-    Ewk_Context_Menu* m_subMenu;
+    EwkContextMenu* m_parentMenu;
+    EwkContextMenu* m_subMenu;
 };
 
 #endif // ewk_context_menu_item_private_h
index a6cea2d..8fc3d2e 100644 (file)
 #define ewk_context_menu_private_h
 
 #include "ewk_context_menu_item.h"
+#include "ewk_object_private.h"
 #include <Eina.h>
-#include <wtf/PassOwnPtr.h>
+#include <wtf/PassRefPtr.h>
 
 class EwkView;
 
-class EwkContextMenu {
+class EwkContextMenu : public EwkObject {
 public:
-    static PassOwnPtr<EwkContextMenu> create(EwkView* viewImpl, WKArrayRef items)
+    EWK_OBJECT_DECLARE(EwkContextMenu)
+
+    static PassRefPtr<EwkContextMenu> create(EwkView* viewImpl, WKArrayRef items)
     {
-        return adoptPtr(new EwkContextMenu(viewImpl, items));
+        return adoptRef(new EwkContextMenu(viewImpl, items));
     }
 
-    static PassOwnPtr<EwkContextMenu> create()
+    static PassRefPtr<EwkContextMenu> create()
     {
-        return adoptPtr(new EwkContextMenu());
+        return adoptRef(new EwkContextMenu());
     }
 
-    static PassOwnPtr<EwkContextMenu> create(Eina_List* items)
+    static PassRefPtr<EwkContextMenu> create(Eina_List* items)
     {
-        return adoptPtr(new EwkContextMenu(items));
+        return adoptRef(new EwkContextMenu(items));
     }
 
     ~EwkContextMenu();
index 97320fb..bf0177f 100644 (file)
 extern "C" {
 #endif
 
-/** Creates a type name for Ewk_Context_Menu */
-typedef struct EwkContextMenu Ewk_Context_Menu;
+/**
+ * Declare Ewk_Context_Menu as Ewk_Object.
+ *
+ * @see Ewk_Object
+ */
+typedef struct EwkObject Ewk_Context_Menu;
 
 /** Creates a type name for Ewk_Context_Menu_Item */
 typedef struct EwkContextMenuItem Ewk_Context_Menu_Item;