[EFL][WK2] Move isEwkViewEvasObject back to ewk_view.cpp
authorryuan.choi@samsung.com <ryuan.choi@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Jan 2014 05:26:40 +0000 (05:26 +0000)
committerryuan.choi@samsung.com <ryuan.choi@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Jan 2014 05:26:40 +0000 (05:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=127261

Reviewed by Gyuyoung Kim.

isEwkViewEvasObject is general check routine of EFL and mainly used in
ewk_view.cpp but it was in EwkView.cpp since separated EwkView.cpp from ewk_view.cpp

This patch moves it to EwkView.h as inline function with small refactoring.
In addition, this patch added EINA_UNLIKELY keyword in cold paths.

* UIProcess/API/efl/EwkView.cpp:
(defaultSmartClassInstance):
(toSmartData):
(toEwkView): Moved it from bottom not to expose it to header file.
* UIProcess/API/efl/EwkView.h:
* UIProcess/API/efl/ewk_view.cpp:
(isEwkViewEvasObject):
(toEwkViewChecked):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@162426 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_view.cpp

index 2dc9ebd..ca0611b 100644 (file)
@@ -1,3 +1,25 @@
+2014-01-20  Ryuan Choi  <ryuan.choi@samsung.com>
+
+        [EFL][WK2] Move isEwkViewEvasObject back to ewk_view.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=127261
+
+        Reviewed by Gyuyoung Kim.
+
+        isEwkViewEvasObject is general check routine of EFL and mainly used in
+        ewk_view.cpp but it was in EwkView.cpp since separated EwkView.cpp from ewk_view.cpp
+
+        This patch moves it to EwkView.h as inline function with small refactoring.
+        In addition, this patch added EINA_UNLIKELY keyword in cold paths.
+
+        * UIProcess/API/efl/EwkView.cpp:
+        (defaultSmartClassInstance):
+        (toSmartData):
+        (toEwkView): Moved it from bottom not to expose it to header file.
+        * UIProcess/API/efl/EwkView.h:
+        * UIProcess/API/efl/ewk_view.cpp:
+        (isEwkViewEvasObject):
+        (toEwkViewChecked):
+
 2014-01-20  Eunmi Lee  <eunmi15.lee@samsung.com>
 
         [EFL][WK2] Amount of scrolling is different from movement of touch when device pixel ratio is not 1.
index 7482060..0d95a26 100644 (file)
@@ -62,7 +62,6 @@
 #include "ewk_private.h"
 #include "ewk_security_origin_private.h"
 #include "ewk_settings_private.h"
-#include "ewk_view.h"
 #include "ewk_window_features_private.h"
 #include <Ecore_Evas.h>
 #include <Ecore_X.h>
@@ -91,11 +90,12 @@ using namespace EwkViewCallbacks;
 using namespace WebCore;
 using namespace WebKit;
 
-static const char smartClassName[] = "EWK2_View";
 static const int defaultCursorSize = 16;
 
 // Auxiliary functions.
 
+const char EwkView::smartClassName[] = "EWK2_View";
+
 static inline void smartDataChanged(Ewk_View_Smart_Data* smartData)
 {
     ASSERT(smartData);
@@ -109,7 +109,7 @@ static inline void smartDataChanged(Ewk_View_Smart_Data* smartData)
 
 static Evas_Smart* defaultSmartClassInstance()
 {
-    static Ewk_View_Smart_Class api = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION(smartClassName);
+    static Ewk_View_Smart_Class api = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION(EwkView::smartClassName);
     static Evas_Smart* smart = 0;
 
     if (!smart) {
@@ -136,6 +136,14 @@ static inline EwkView* toEwkView(const Ewk_View_Smart_Data* smartData)
     return smartData->priv;
 }
 
+static inline EwkView* toEwkView(const Evas_Object* evasObject)
+{
+    ASSERT(evasObject);
+    ASSERT(isEwkViewEvasObject(evasObject));
+
+    return toEwkView(static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(evasObject)));
+}
+
 static inline void showEvasObjectsIfNeeded(const Ewk_View_Smart_Data* smartData)
 {
     ASSERT(smartData);
@@ -1432,38 +1440,3 @@ bool EwkView::scrollBy(const IntSize& offset)
 
 Evas_Smart_Class EwkView::parentSmartClass = EVAS_SMART_CLASS_INIT_NULL;
 
-// Free Ewk View functions.
-
-EwkView* toEwkView(const Evas_Object* evasObject)
-{
-    ASSERT(evasObject);
-    ASSERT(isEwkViewEvasObject(evasObject));
-
-    return toEwkView(static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(evasObject)));
-}
-
-bool isEwkViewEvasObject(const Evas_Object* evasObject)
-{
-    ASSERT(evasObject);
-
-    const char* evasObjectType = evas_object_type_get(evasObject);
-    const Evas_Smart* evasSmart = evas_object_smart_smart_get(evasObject);
-    if (!evasSmart) {
-        EINA_LOG_CRIT("%p (%s) is not a smart object!", evasObject, evasObjectType ? evasObjectType : "(null)");
-        return false;
-    }
-
-    const Evas_Smart_Class* smartClass = evas_smart_class_get(evasSmart);
-    if (!smartClass) {
-        EINA_LOG_CRIT("%p (%s) is not a smart class object!", evasObject, evasObjectType ? evasObjectType : "(null)");
-        return false;
-    }
-
-    if (smartClass->data != smartClassName) {
-        EINA_LOG_CRIT("%p (%s) is not of an ewk_view (need %p, got %p)!", evasObject, evasObjectType ? evasObjectType : "(null)",
-            smartClassName, smartClass->data);
-        return false;
-    }
-
-    return true;
-}
index c6b2209..c53ccbb 100644 (file)
@@ -206,6 +206,8 @@ public:
 
     void didFindZoomableArea(const WKPoint&, const WKRect&);
 
+    static const char smartClassName[];
+
 private:
     EwkView(WKViewRef, Evas_Object*);
     ~EwkView();
@@ -302,8 +304,32 @@ private:
     static Evas_Smart_Class parentSmartClass;
 };
 
-EwkView* toEwkView(const Evas_Object*);
+inline bool isEwkViewEvasObject(const Evas_Object* evasObject)
+{
+    ASSERT(evasObject);
+
+    const Evas_Smart* evasSmart = evas_object_smart_smart_get(evasObject);
+    if (EINA_UNLIKELY(!evasSmart)) {
+        const char* evasObjectType = evas_object_type_get(evasObject);
+        EINA_LOG_CRIT("%p (%s) is not a smart object!", evasObject, evasObjectType ? evasObjectType : "(null)");
+        return false;
+    }
+
+    const Evas_Smart_Class* smartClass = evas_smart_class_get(evasSmart);
+    if (EINA_UNLIKELY(!smartClass)) {
+        const char* evasObjectType = evas_object_type_get(evasObject);
+        EINA_LOG_CRIT("%p (%s) is not a smart class object!", evasObject, evasObjectType ? evasObjectType : "(null)");
+        return false;
+    }
+
+    if (EINA_UNLIKELY(smartClass->data != EwkView::smartClassName)) {
+        const char* evasObjectType = evas_object_type_get(evasObject);
+        EINA_LOG_CRIT("%p (%s) is not of an ewk_view (need %p, got %p)!", evasObject, evasObjectType ? evasObjectType : "(null)",
+            EwkView::smartClassName, smartClass->data);
+        return false;
+    }
 
-bool isEwkViewEvasObject(const Evas_Object*);
+    return true;
+}
 
 #endif // EwkView_h
index f397780..a83f441 100644 (file)
@@ -63,7 +63,7 @@ using namespace WebKit;
 static inline EwkView* toEwkViewChecked(const Evas_Object* evasObject)
 {
     EINA_SAFETY_ON_NULL_RETURN_VAL(evasObject, nullptr);
-    if (!isEwkViewEvasObject(evasObject))
+    if (EINA_UNLIKELY(!isEwkViewEvasObject(evasObject)))
         return 0;
 
     Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(evasObject));
@@ -75,7 +75,7 @@ static inline EwkView* toEwkViewChecked(const Evas_Object* evasObject)
 #define EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, ...)                        \
     EwkView* impl = toEwkViewChecked(ewkView);                                 \
     do {                                                                       \
-        if (!impl) {                                                           \
+        if (EINA_UNLIKELY(!impl)) {                                            \
             EINA_LOG_CRIT("no private data for object %p", ewkView);           \
             return __VA_ARGS__;                                                \
         }                                                                      \