[EFL][WK2] Use C API inside ewk_window_features
authorchristophe.dumez@intel.com <christophe.dumez@intel.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Jan 2013 16:52:41 +0000 (16:52 +0000)
committerchristophe.dumez@intel.com <christophe.dumez@intel.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Jan 2013 16:52:41 +0000 (16:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=107924

Reviewed by Sam Weinig.

Use C API inside ewk_window_features instead of accessing
internal C++ classes directly, to avoid violating API
layering.

* UIProcess/API/efl/EwkView.cpp:
(EwkView::createNewPage):
* UIProcess/API/efl/EwkView.h:
(EwkView):
* UIProcess/API/efl/ewk_window_features.cpp:
(EwkWindowFeatures::EwkWindowFeatures):
(getWindowFeatureValue):
(EwkWindowFeatures::getWindowFeatureBoolValue):
(EwkWindowFeatures::getWindowFeatureDoubleValue):
(ewk_window_features_geometry_get):
* UIProcess/API/efl/ewk_window_features_private.h:
(EwkWindowFeatures::create):
(EwkWindowFeatures::geometry):
(EwkWindowFeatures::setGeometry):
(EwkWindowFeatures):
* UIProcess/efl/PageUIClientEfl.cpp:
(WebKit::PageUIClientEfl::createNewPage):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@141274 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_window_features.cpp
Source/WebKit2/UIProcess/API/efl/ewk_window_features_private.h
Source/WebKit2/UIProcess/efl/PageUIClientEfl.cpp

index 2c4167ec87b2dd4ef78c2d0d1a058104f49570e4..ae45f5c3a0c781c5f67224705e1b650db267494c 100644 (file)
@@ -1,3 +1,32 @@
+2013-01-30  Christophe Dumez  <christophe.dumez@intel.com>
+
+        [EFL][WK2] Use C API inside ewk_window_features
+        https://bugs.webkit.org/show_bug.cgi?id=107924
+
+        Reviewed by Sam Weinig.
+
+        Use C API inside ewk_window_features instead of accessing
+        internal C++ classes directly, to avoid violating API
+        layering.
+
+        * UIProcess/API/efl/EwkView.cpp:
+        (EwkView::createNewPage):
+        * UIProcess/API/efl/EwkView.h:
+        (EwkView):
+        * UIProcess/API/efl/ewk_window_features.cpp:
+        (EwkWindowFeatures::EwkWindowFeatures):
+        (getWindowFeatureValue):
+        (EwkWindowFeatures::getWindowFeatureBoolValue):
+        (EwkWindowFeatures::getWindowFeatureDoubleValue):
+        (ewk_window_features_geometry_get):
+        * UIProcess/API/efl/ewk_window_features_private.h:
+        (EwkWindowFeatures::create):
+        (EwkWindowFeatures::geometry):
+        (EwkWindowFeatures::setGeometry):
+        (EwkWindowFeatures):
+        * UIProcess/efl/PageUIClientEfl.cpp:
+        (WebKit::PageUIClientEfl::createNewPage):
+
 2013-01-30  Zeno Albisser  <zeno@webkit.org>
 
         [Qt] Fix Qt/Mac build after r141024 and r141037
index 7f238f8fc888f96056ec95ebfe2f1fc58e870162..5bb446477cbd2575f56d0cc93dea0211f721a903 100644 (file)
@@ -917,7 +917,7 @@ EwkWindowFeatures* EwkView::windowFeatures()
     return m_windowFeatures.get();
 }
 
-WKPageRef EwkView::createNewPage(PassRefPtr<EwkUrlRequest> request, ImmutableDictionary* windowFeatures)
+WKPageRef EwkView::createNewPage(PassRefPtr<EwkUrlRequest> request, WKDictionaryRef windowFeatures)
 {
     Ewk_View_Smart_Data* sd = smartData();
     ASSERT(sd->api);
index a213f97d5ebb4196316a9eace128b9a229ed500d..37a8d1bdbbbac801df9b51a27f66d28e146eb76b 100644 (file)
@@ -173,7 +173,7 @@ public:
     void dismissColorPicker();
 #endif
 
-    WKPageRef createNewPage(PassRefPtr<EwkUrlRequest>, WebKit::ImmutableDictionary* windowFeatures);
+    WKPageRef createNewPage(PassRefPtr<EwkUrlRequest>, WKDictionaryRef windowFeatures);
     void close();
 
     void requestPopupMenu(WebKit::WebPopupMenuProxyEfl*, const WebCore::IntRect&, WebCore::TextDirection, double pageScaleFactor, const Vector<WebKit::WebPopupItem>& items, int32_t selectedIndex);
index e305832b39afece9263f7e0926b978aa8304c50f..8824cafbe34759319a3478f148a46f0e13f397af 100644 (file)
 #include "config.h"
 #include "ewk_window_features.h"
 
-#include "WebNumber.h"
+#include "EwkView.h"
+#include "WKDictionary.h"
+#include "WKNumber.h"
+#include "WKString.h"
 #include "ewk_window_features_private.h"
-#include <Eina.h>
 
 using namespace WebKit;
 
-EwkWindowFeatures::EwkWindowFeatures(ImmutableDictionary* windowFeatures, EwkView* view)
+EwkWindowFeatures::EwkWindowFeatures(WKDictionaryRef windowFeatures, EwkView* view)
     : m_view(view)
-    , m_geometry(0, 0, 100, 100)
-    , m_toolbarVisible(true)
-    , m_statusBarVisible(true)
-    , m_scrollbarsVisible(true)
-    , m_menuBarVisible(true)
-    , m_locationBarVisible(true)
-    , m_resizable(true)
-    , m_fullScreen(false)
+    , m_toolbarVisible(getWindowFeatureBoolValue(windowFeatures, "toolBarVisible", true))
+    , m_statusBarVisible(getWindowFeatureBoolValue(windowFeatures, "statusBarVisible", true))
+    , m_scrollbarsVisible(getWindowFeatureBoolValue(windowFeatures, "scrollbarsVisible", true))
+    , m_menuBarVisible(getWindowFeatureBoolValue(windowFeatures, "menuBarVisible", true))
+    , m_locationBarVisible(getWindowFeatureBoolValue(windowFeatures, "locationBarVisible", true))
+    , m_resizable(getWindowFeatureBoolValue(windowFeatures, "resizable", true))
+    , m_fullScreen(getWindowFeatureBoolValue(windowFeatures, "fullscreen", false))
 {
-    if (windowFeatures) {
-        m_geometry.setX(getWindowFeatureValue<double, WebDouble>(windowFeatures, ASCIILiteral("x")));
-        m_geometry.setY(getWindowFeatureValue<double, WebDouble>(windowFeatures, ASCIILiteral("y")));
-        m_geometry.setWidth(getWindowFeatureValue<double, WebDouble>(windowFeatures, ASCIILiteral("width")));
-        m_geometry.setHeight(getWindowFeatureValue<double, WebDouble>(windowFeatures, ASCIILiteral("height")));
+    m_geometry.x = getWindowFeatureDoubleValue(windowFeatures, "x", 0);
+    m_geometry.y = getWindowFeatureDoubleValue(windowFeatures, "y", 0);
+    m_geometry.w = getWindowFeatureDoubleValue(windowFeatures, "width", 0);
+    m_geometry.h = getWindowFeatureDoubleValue(windowFeatures, "height", 0);
+}
+
+static inline WKTypeRef getWindowFeatureValue(WKDictionaryRef windowFeatures, const char* featureName)
+{
+    ASSERT(featureName);
+    if (!windowFeatures)
+        return 0;
 
-        m_toolbarVisible = getWindowFeatureValue<bool, WebBoolean>(windowFeatures, ASCIILiteral("toolBarVisible"));
-        m_statusBarVisible = getWindowFeatureValue<bool, WebBoolean>(windowFeatures, ASCIILiteral("statusBarVisible"));
-        m_scrollbarsVisible = getWindowFeatureValue<bool, WebBoolean>(windowFeatures, ASCIILiteral("scrollbarsVisible"));
-        m_menuBarVisible = getWindowFeatureValue<bool, WebBoolean>(windowFeatures, ASCIILiteral("menuBarVisible"));
-        m_locationBarVisible = getWindowFeatureValue<bool, WebBoolean>(windowFeatures, ASCIILiteral("locationBarVisible"));
-        m_resizable = getWindowFeatureValue<bool, WebBoolean>(windowFeatures, ASCIILiteral("resizable"));
-        m_fullScreen = getWindowFeatureValue<bool, WebBoolean>(windowFeatures, ASCIILiteral("fullscreen"));
-    }
+    WKRetainPtr<WKStringRef> key(AdoptWK, WKStringCreateWithUTF8CString(featureName));
+    return WKDictionaryGetItemForKey(windowFeatures, key.get());
 }
 
-template <typename T1, typename T2>
-T1 EwkWindowFeatures::getWindowFeatureValue(ImmutableDictionary* windowFeatures, const String& featureName)
+bool EwkWindowFeatures::getWindowFeatureBoolValue(WKDictionaryRef windowFeatures, const char* featureName, bool defaultValue)
 {
-    T2* featureValue = static_cast<T2*>(windowFeatures->get(featureName));
+    WKBooleanRef value = static_cast<WKBooleanRef>(getWindowFeatureValue(windowFeatures, featureName));
 
-    if (!featureValue)
-        return false;
+    return value ? WKBooleanGetValue(value) : defaultValue;
+}
+
+double EwkWindowFeatures::getWindowFeatureDoubleValue(WKDictionaryRef windowFeatures, const char* featureName, double defaultValue)
+{
+    WKDoubleRef value = static_cast<WKDoubleRef>(getWindowFeatureValue(windowFeatures, featureName));
 
-    return featureValue->value();
+    return value ?  WKDoubleGetValue(value) : defaultValue;
 }
 
 void EwkWindowFeatures::setToolbarVisible(bool toolbarVisible)
@@ -147,15 +151,16 @@ void ewk_window_features_geometry_get(const Ewk_Window_Features* window_features
 {
     EWK_OBJ_GET_IMPL_OR_RETURN(const EwkWindowFeatures, window_features, impl);
 
+    const Evas_Coord_Rectangle& geometry = impl->geometry();
     if (x)
-        *x = static_cast<Evas_Coord>(impl->geometry().x());
+        *x = geometry.x;
 
     if (y)
-        *y = static_cast<Evas_Coord>(impl->geometry().y());
+        *y = geometry.y;
 
     if (width)
-        *width = static_cast<Evas_Coord>(impl->geometry().width());
+        *width = geometry.w;
 
     if (height)
-        *height = static_cast<Evas_Coord>(impl->geometry().height());
+        *height = geometry.h;
 }
index 4532d1523ad5cefe9ed352c1b5810a7193ae0257..8ae6c90c1f8e64297008488b1ac4c0c6a553ffae 100644 (file)
 #ifndef ewk_window_features_private_h
 #define ewk_window_features_private_h
 
-#include "EwkView.h"
-#include "ImmutableDictionary.h"
-#include "WindowFeatures.h"
 #include "ewk_object_private.h"
-#include <WebCore/FloatRect.h>
+#include <Evas.h>
+#include <WebKit2/WKBase.h>
 #include <wtf/RefCounted.h>
 
 class EwkView;
@@ -39,13 +37,13 @@ class EwkWindowFeatures : public EwkObject {
 public:
     EWK_OBJECT_DECLARE(EwkWindowFeatures)
 
-    static PassRefPtr<EwkWindowFeatures> create(WebKit::ImmutableDictionary* windowFeatures, EwkView* viewImpl)
+    static PassRefPtr<EwkWindowFeatures> create(WKDictionaryRef windowFeatures, EwkView* viewImpl)
     {
         return adoptRef(new EwkWindowFeatures(windowFeatures, viewImpl));
     }
 
-    WebCore::FloatRect geometry() const { return m_geometry; }
-    void setGeometry(WebCore::FloatRect& geometry) { m_geometry = geometry; }
+    const Evas_Coord_Rectangle& geometry() const { return m_geometry; }
+    void setGeometry(const Evas_Coord_Rectangle& geometry) { m_geometry = geometry; }
 
     bool toolbarVisible() const { return m_toolbarVisible; }
     void setToolbarVisible(bool toolbarVisible);
@@ -69,13 +67,14 @@ public:
     void setFullScreen(bool fullScreen) { m_fullScreen = fullScreen; }
 
 private:
-    EwkWindowFeatures(WebKit::ImmutableDictionary* windowFeatures, EwkView* viewImpl);
-    template <typename T1, typename T2>
-    static T1 getWindowFeatureValue(WebKit::ImmutableDictionary* windowFeatures, const String& featureName);
+    EwkWindowFeatures(WKDictionaryRef windowFeatures, EwkView* viewImpl);
+
+    static bool getWindowFeatureBoolValue(WKDictionaryRef windowFeatures, const char* featureName, bool defaultValue);
+    static double getWindowFeatureDoubleValue(WKDictionaryRef windowFeatures, const char* featureName, double defaultValue);
 
     EwkView* m_view;
 
-    WebCore::FloatRect m_geometry;
+    Evas_Coord_Rectangle m_geometry;
     bool m_toolbarVisible;
     bool m_statusBarVisible;
     bool m_scrollbarsVisible;
index 811db060bf06792e4fc35c8db58c6f47de4d1a6c..1e008c41f3bfdaf5a53f4950ab069e7586a7758b 100644 (file)
@@ -207,7 +207,7 @@ void PageUIClientEfl::runOpenPanel(WKPageRef, WKFrameRef, WKOpenPanelParametersR
 WKPageRef PageUIClientEfl::createNewPage(WKPageRef, WKURLRequestRef wkRequest, WKDictionaryRef wkWindowFeatures, WKEventModifiers, WKEventMouseButton, const void* clientInfo)
 {
     RefPtr<EwkUrlRequest> request = EwkUrlRequest::create(wkRequest);
-    return toPageUIClientEfl(clientInfo)->m_view->createNewPage(request, toImpl(wkWindowFeatures));
+    return toPageUIClientEfl(clientInfo)->m_view->createNewPage(request, wkWindowFeatures);
 }
 
 #if ENABLE(INPUT_TYPE_COLOR)