Title: [141274] trunk/Source/WebKit2
Revision
141274
Author
[email protected]
Date
2013-01-30 08:52:41 -0800 (Wed, 30 Jan 2013)

Log Message

[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):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (141273 => 141274)


--- trunk/Source/WebKit2/ChangeLog	2013-01-30 16:15:38 UTC (rev 141273)
+++ trunk/Source/WebKit2/ChangeLog	2013-01-30 16:52:41 UTC (rev 141274)
@@ -1,3 +1,32 @@
+2013-01-30  Christophe Dumez  <[email protected]>
+
+        [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  <[email protected]>
 
         [Qt] Fix Qt/Mac build after r141024 and r141037

Modified: trunk/Source/WebKit2/UIProcess/API/efl/EwkView.cpp (141273 => 141274)


--- trunk/Source/WebKit2/UIProcess/API/efl/EwkView.cpp	2013-01-30 16:15:38 UTC (rev 141273)
+++ trunk/Source/WebKit2/UIProcess/API/efl/EwkView.cpp	2013-01-30 16:52:41 UTC (rev 141274)
@@ -917,7 +917,7 @@
     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);

Modified: trunk/Source/WebKit2/UIProcess/API/efl/EwkView.h (141273 => 141274)


--- trunk/Source/WebKit2/UIProcess/API/efl/EwkView.h	2013-01-30 16:15:38 UTC (rev 141273)
+++ trunk/Source/WebKit2/UIProcess/API/efl/EwkView.h	2013-01-30 16:52:41 UTC (rev 141274)
@@ -173,7 +173,7 @@
     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);

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_window_features.cpp (141273 => 141274)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_window_features.cpp	2013-01-30 16:15:38 UTC (rev 141273)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_window_features.cpp	2013-01-30 16:52:41 UTC (rev 141274)
@@ -26,48 +26,52 @@
 #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);
+}
 
-        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"));
-    }
+static inline WKTypeRef getWindowFeatureValue(WKDictionaryRef windowFeatures, const char* featureName)
+{
+    ASSERT(featureName);
+    if (!windowFeatures)
+        return 0;
+
+    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;
+}
 
-    return featureValue->value();
+double EwkWindowFeatures::getWindowFeatureDoubleValue(WKDictionaryRef windowFeatures, const char* featureName, double defaultValue)
+{
+    WKDoubleRef value = static_cast<WKDoubleRef>(getWindowFeatureValue(windowFeatures, featureName));
+
+    return value ?  WKDoubleGetValue(value) : defaultValue;
 }
 
 void EwkWindowFeatures::setToolbarVisible(bool toolbarVisible)
@@ -147,15 +151,16 @@
 {
     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;
 }

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_window_features_private.h (141273 => 141274)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_window_features_private.h	2013-01-30 16:15:38 UTC (rev 141273)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_window_features_private.h	2013-01-30 16:52:41 UTC (rev 141274)
@@ -26,11 +26,9 @@
 #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 @@
 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 @@
     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;

Modified: trunk/Source/WebKit2/UIProcess/efl/PageUIClientEfl.cpp (141273 => 141274)


--- trunk/Source/WebKit2/UIProcess/efl/PageUIClientEfl.cpp	2013-01-30 16:15:38 UTC (rev 141273)
+++ trunk/Source/WebKit2/UIProcess/efl/PageUIClientEfl.cpp	2013-01-30 16:52:41 UTC (rev 141274)
@@ -207,7 +207,7 @@
 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)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to