2010-06-23 Lucas De Marchi <lucas.demarchi@profusion.mobi>
authorleandro@webkit.org <leandro@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Jun 2010 19:39:54 +0000 (19:39 +0000)
committerleandro@webkit.org <leandro@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Jun 2010 19:39:54 +0000 (19:39 +0000)
        Reviewed by Gustavo Noronha Silva.

        Add implementaion of new windows for EFL port. Both cases of a link
        with target="_blank" and a javascript that does window.open() are
        treated, delegating to browser the role of actually creating the
        window (or blocking it).
        https://bugs.webkit.org/show_bug.cgi?id=40930

        * CMakeListsEfl.txt: add new file that wraps the WindowFeatures struct
        * efl/WebCoreSupport/ChromeClientEfl.cpp:
        (WebCore::ChromeClientEfl::createWindow): implement method for
        creating new window by delegating to browser its creation. Browser
        might decide to continue on the same window by returning the same
        view object.
        * efl/WebCoreSupport/FrameLoaderClientEfl.cpp:
        (WebCore::FrameLoaderClientEfl::dispatchCreatePage): implement method
        for creating new window when its creation is done by a javascript
        script.
        * efl/ewk/EWebKit.h: new header for WindowFeatures.
        * efl/ewk/ewk_private.h:
        * efl/ewk/ewk_view.cpp:
        (ewk_view_window_create): call the method implemented by browser.
        * efl/ewk/ewk_view.h:
        * efl/ewk/ewk_window_features.cpp: Added.
        (ewk_window_features_unref):
        (ewk_window_features_ref):
        (ewk_window_features_bool_property_get):
        (ewk_window_features_int_property_get):
        (ewk_window_features_new_from_core): create and wrapped struct
        containing the core struct.
        * efl/ewk/ewk_window_features.h: Added.

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

WebKit/CMakeListsEfl.txt
WebKit/ChangeLog
WebKit/efl/WebCoreSupport/ChromeClientEfl.cpp
WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp
WebKit/efl/ewk/EWebKit.h
WebKit/efl/ewk/ewk_private.h
WebKit/efl/ewk/ewk_view.cpp
WebKit/efl/ewk/ewk_view.h
WebKit/efl/ewk/ewk_window_features.cpp [new file with mode: 0644]
WebKit/efl/ewk/ewk_window_features.h [new file with mode: 0644]

index cbc0d9290882d1edfaec7f67134ccf3a0136c580..defe7c11527e72921cf48f8c454ed60823e62db0 100644 (file)
@@ -39,6 +39,7 @@ LIST(APPEND WebKit_SOURCES
     efl/ewk/ewk_util.cpp
     efl/ewk/ewk_view.cpp
     efl/ewk/ewk_view_single.c
+    efl/ewk/ewk_window_features.cpp
 )
 
 LIST(APPEND WebKit_LIBRARIES
index 9ebdb783d4be3954a112f12d185d27dfa4e447d3..3492164bef000faa0d7a9ab15772c1c1a96f7a27 100644 (file)
@@ -1,3 +1,37 @@
+2010-06-23  Lucas De Marchi  <lucas.demarchi@profusion.mobi>
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Add implementaion of new windows for EFL port. Both cases of a link
+        with target="_blank" and a javascript that does window.open() are
+        treated, delegating to browser the role of actually creating the
+        window (or blocking it).
+        https://bugs.webkit.org/show_bug.cgi?id=40930
+
+        * CMakeListsEfl.txt: add new file that wraps the WindowFeatures struct
+        * efl/WebCoreSupport/ChromeClientEfl.cpp:
+        (WebCore::ChromeClientEfl::createWindow): implement method for
+        creating new window by delegating to browser its creation. Browser
+        might decide to continue on the same window by returning the same
+        view object.
+        * efl/WebCoreSupport/FrameLoaderClientEfl.cpp:
+        (WebCore::FrameLoaderClientEfl::dispatchCreatePage): implement method
+        for creating new window when its creation is done by a javascript
+        script.
+        * efl/ewk/EWebKit.h: new header for WindowFeatures.
+        * efl/ewk/ewk_private.h:
+        * efl/ewk/ewk_view.cpp:
+        (ewk_view_window_create): call the method implemented by browser.
+        * efl/ewk/ewk_view.h:
+        * efl/ewk/ewk_window_features.cpp: Added.
+        (ewk_window_features_unref):
+        (ewk_window_features_ref):
+        (ewk_window_features_bool_property_get):
+        (ewk_window_features_int_property_get):
+        (ewk_window_features_new_from_core): create and wrapped struct
+        containing the core struct.
+        * efl/ewk/ewk_window_features.h: Added.
+
 2010-06-18  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Sam Weinig.
index bc75ddbd404b3bf8105258dae331301bfc692a2d..7a661e8b7d4457f6f65f447be1fec761679b4b30 100644 (file)
@@ -117,10 +117,16 @@ void ChromeClientEfl::unfocus()
     evas_object_focus_set(m_view, EINA_FALSE);
 }
 
-Page* ChromeClientEfl::createWindow(Frame*, const FrameLoadRequest& request, const WindowFeatures& features)
+Page* ChromeClientEfl::createWindow(Frame*, const FrameLoadRequest& frameLoadRequest, const WindowFeatures& features)
 {
-    notImplemented();
-    return 0;
+    Evas_Object* newView = ewk_view_window_create(m_view, EINA_TRUE, &features);
+    if (!newView)
+        return 0;
+
+    if (!frameLoadRequest.isEmpty())
+        ewk_view_uri_set(newView, frameLoadRequest.resourceRequest().url().string().utf8().data());
+
+    return ewk_view_core_page_get(newView);
 }
 
 void ChromeClientEfl::show()
index 2358faba3a064c92bb3f3dff895d08e77629d73d..af1abeb6b7cd35ef2b2d46b0358fd89bfda871fa 100644 (file)
@@ -816,8 +816,17 @@ bool FrameLoaderClientEfl::canCachePage() const
 
 Frame* FrameLoaderClientEfl::dispatchCreatePage()
 {
-    notImplemented();
-    return 0;
+    if (!m_view)
+        return 0;
+
+    Evas_Object* newView = ewk_view_window_create(m_view, EINA_FALSE, 0);
+    Evas_Object* mainFrame;
+    if (!newView)
+        mainFrame = m_frame;
+    else
+        mainFrame = ewk_view_frame_main_get(newView);
+
+    return ewk_frame_core_get(mainFrame);
 }
 
 void FrameLoaderClientEfl::dispatchUnableToImplementPolicy(const ResourceError&)
index a61cc9d459a0a2271485d5ccb8da4e87092b74db..e08c4a5cf1e676afc0a3fbab086b8ab1453b8375 100644 (file)
@@ -29,6 +29,7 @@
 #include "ewk_main.h"
 #include "ewk_settings.h"
 #include "ewk_view.h"
+#include "ewk_window_features.h"
 
 #include <Evas.h>
 
index 5f66fd862700dfa0e54e550a5be74ea4d7609f3f..3ad65fc1a3d6b3daff8dfa357455170fd00e53b1 100644 (file)
@@ -56,6 +56,7 @@ void             ewk_view_frame_main_load_started(Evas_Object *o);
 void             ewk_view_load_finished(Evas_Object *o, const Ewk_Frame_Load_Error *error);
 void             ewk_view_load_error(Evas_Object *o, const Ewk_Frame_Load_Error *error);
 void             ewk_view_load_progress_changed(Evas_Object *o);
+Evas_Object     *ewk_view_window_create(Evas_Object *o, Eina_Bool javascript, const WebCore::WindowFeatures* coreFeatures);
 
 void             ewk_view_mouse_link_hover_in(Evas_Object *o, void *data);
 void             ewk_view_mouse_link_hover_out(Evas_Object *o);
@@ -102,6 +103,8 @@ void              ewk_context_menu_item_append(Ewk_Context_Menu *o, WebCore::Con
 Ewk_Context_Menu *ewk_context_menu_custom_get(Ewk_Context_Menu *o);
 void              ewk_context_menu_show(Ewk_Context_Menu *o);
 
+Ewk_Window_Features *ewk_window_features_new_from_core(const WebCore::WindowFeatures* core);
+
 Evas_Object      *ewk_frame_add(Evas *e);
 Eina_Bool         ewk_frame_init(Evas_Object *o, Evas_Object *view, WebCore::Frame *frame);
 Evas_Object      *ewk_frame_child_add(Evas_Object *o, WTF::PassRefPtr<WebCore::Frame> child, const WebCore::String& name, const WebCore::KURL& url, const WebCore::String& referrer);
index d5920e5eb7bfc761797440b9e60e553fc14e5f29..e4e534134a6677806061402f118e1ce6c7abf008 100644 (file)
@@ -3150,21 +3150,36 @@ void ewk_view_restore_state(Evas_Object* o, Evas_Object* frame)
 /**
  * @internal
  * Delegates to browser the creation of a new window. If it is not implemented,
- * current view is returned, so navigation might continue in same window.
+ * current view is returned, so navigation might continue in same window. If
+ * browser supports the creation of new windows, a new Ewk_Window_Features is
+ * created and passed to browser. If it intends to keep the request for opening
+ * the window later it must increments the Ewk_Winwdow_Features ref count by
+ * calling ewk_window_features_ref(window_features). Otherwise this struct will
+ * be freed after returning to this function.
  *
  * @param o Current view.
+ * @param javascript @c EINA_TRUE if the new window is originated from javascript,
+ * @c EINA_FALSE otherwise
+ * @param window_features Features of the new window being created. If it's @c
+ * NULL, it will be created a window with default features.
  *
  * @return New view, in case smart class implements the creation of new windows;
  * else, current view @param o.
+ *
+ * @see ewk_window_features_ref().
  */
-Evas_Object* ewk_view_window_create(Evas_Object* o)
+Evas_Object* ewk_view_window_create(Evas_Object* o, Eina_Bool javascript, const WebCore::WindowFeatures* coreFeatures)
 {
     EWK_VIEW_SD_GET_OR_RETURN(o, sd, 0);
 
     if (!sd->api->window_create)
         return o;
 
-    return sd->api->window_create(sd);
+    Ewk_Window_Features* window_features = ewk_window_features_new_from_core(coreFeatures);
+    Evas_Object* view = sd->api->window_create(sd, javascript, window_features);
+    ewk_window_features_unref(window_features);
+
+    return view;
 }
 
 /**
index b029a686074a5c06cce1aa6d4b07d7f84b00bb2e..a8fe3b87f193212f9288747f6f9a9a8b3d2a86d9 100644 (file)
 #ifndef ewk_view_h
 #define ewk_view_h
 
+#include "ewk_history.h"
+#include "ewk_window_features.h"
+
 #include <Evas.h>
 #include <cairo.h>
-#include <ewk_history.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -95,7 +97,7 @@ struct _Ewk_View_Smart_Class {
     Evas_Smart_Class sc; /**< all but 'data' is free to be changed. */
     unsigned long version;
 
-    Evas_Object *(*window_create)(Ewk_View_Smart_Data *sd); /**< creates a new window, requested by webkit */
+    Evas_Object *(*window_create)(Ewk_View_Smart_Data *sd, Eina_Bool javascript, const Ewk_Window_Features *window_features); /**< creates a new window, requested by webkit */
     // hooks to allow different backing stores
     Evas_Object *(*backing_store_add)(Ewk_View_Smart_Data *sd); /**< must be defined */
     Eina_Bool (*scrolls_process)(Ewk_View_Smart_Data *sd); /**< must be defined */
diff --git a/WebKit/efl/ewk/ewk_window_features.cpp b/WebKit/efl/ewk/ewk_window_features.cpp
new file mode 100644 (file)
index 0000000..3855e89
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+    Copyright (C) 2010 ProFUSION embedded systems
+    Copyright (C) 2010 Samsung Electronics
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "ewk_window_features.h"
+
+#include "WindowFeatures.h"
+#include "ewk_private.h"
+
+#include <Eina.h>
+
+struct _Ewk_Window_Features {
+    unsigned int __ref;
+    WebCore::WindowFeatures* core;
+};
+
+/**
+ * Decrease the ref count of an Ewk_Window_Features, possibly freeing it.
+ *
+ * When its ref count reaches 0, @param window_features is freed.
+ *
+ * @param window_features The window's features.
+ */
+EAPI void ewk_window_features_unref(Ewk_Window_Features* window_features)
+{
+    EINA_SAFETY_ON_NULL_RETURN(window_features);
+    EINA_SAFETY_ON_FALSE_RETURN(window_features->__ref > 0);
+
+    if (--window_features->__ref)
+        return;
+
+    delete window_features->core;
+    window_features->core = 0;
+    free(window_features);
+}
+
+/**
+ * Increase the ref count of an Ewk_Window_Features
+ *
+ * @param window_features The window's features.
+ */
+EAPI void ewk_window_features_ref(Ewk_Window_Features* window_features)
+{
+    EINA_SAFETY_ON_NULL_RETURN(window_features);
+    window_features->__ref++;
+}
+
+/**
+ * Get boolean properties
+ *
+ * @param window_features A window_features.
+ * @param toolbar_visible pointer to store if toolbar is visible.
+ * @param statusbar_visible pointer to store if statusbar is visible.
+ * @param scrollbars_visible pointer to store if scrollbars is visible.
+ * @param menubar_visible pointer to store if menubar is visible.
+ * @param locationbar_visible pointer to store if locationbar is visible.
+ * @param fullscreen pointer to store if fullscreen is enabled.
+ */
+EAPI void ewk_window_features_bool_property_get(Ewk_Window_Features* window_features, Eina_Bool* toolbar_visible, Eina_Bool* statusbar_visible, Eina_Bool* scrollbars_visible, Eina_Bool* menubar_visible, Eina_Bool* locationbar_visible, Eina_Bool* fullscreen)
+{
+    EINA_SAFETY_ON_NULL_RETURN(window_features);
+    EINA_SAFETY_ON_NULL_RETURN(window_features->core);
+
+    if (toolbar_visible)
+        *toolbar_visible = window_features->core->toolBarVisible;
+
+    if (statusbar_visible)
+        *statusbar_visible = window_features->core->statusBarVisible;
+
+    if (scrollbars_visible)
+        *scrollbars_visible = window_features->core->scrollbarsVisible;
+
+    if (menubar_visible)
+        *menubar_visible = window_features->core->menuBarVisible;
+
+    if (locationbar_visible)
+        *locationbar_visible = window_features->core->locationBarVisible;
+
+    if (fullscreen)
+        *fullscreen = window_features->core->fullscreen;
+}
+
+/**
+ * Get int properties
+ *
+ * Properties are returned in the respective pointers. Passing NULL to any of
+ * these pointers will make that property to not be returned. Make sure to check
+ * if the value returned is less than 0 before using it, since in that case it
+ * means that property was not set in @param winwdow_features.
+ *
+ * @param window_features A window_features.
+ * @param x pointer to store x position or -1 if it's not set in window_features.
+ * @param y pointer to store y position or-1 if it's not set in window_features.
+ * @param w pointer to store width or-1 if it's not set in window_features.
+ * @param h pointer to store height or-1 if it's not set in window_features.
+ */
+EAPI void ewk_window_features_int_property_get(Ewk_Window_Features* window_features, int* x, int* y, int* w, int* h)
+{
+    EINA_SAFETY_ON_NULL_RETURN(window_features);
+    EINA_SAFETY_ON_NULL_RETURN(window_features->core);
+
+    if (x)
+        *x = window_features->core->xSet ? static_cast<int>(window_features->core->x) : -1;
+
+    if (y)
+        *y = window_features->core->ySet ? static_cast<int>(window_features->core->y) : -1;
+
+    if (w)
+        *w = window_features->core->widthSet ? static_cast<int>(window_features->core->width) : -1;
+
+    if (h)
+        *h = window_features->core->heightSet ? static_cast<int>(window_features->core->height) : -1;
+}
+
+/* internal methods ****************************************************/
+
+/**
+ * @internal
+ * Create a new Ewk_Window_Features from a WebCore::WindowFeatures if @param
+ * core is not NULL or a new one with default features.
+ *
+ * A new WebCore::WindowFeatures is allocated copying @param core features and
+ * it is embedded inside an Ewk_Window_Features whose ref count is initialized.
+ *
+ * @returns a new allocated Ewk_Window_Features
+ */
+Ewk_Window_Features* ewk_window_features_new_from_core(const WebCore::WindowFeatures* core)
+{
+    Ewk_Window_Features* window_features = static_cast<Ewk_Window_Features*>(malloc(sizeof(*window_features)));
+
+    if (core)
+        window_features->core = new WebCore::WindowFeatures(*core);
+    else
+        window_features->core = new WebCore::WindowFeatures();
+
+    window_features->__ref = 1;
+
+    return window_features;
+}
diff --git a/WebKit/efl/ewk/ewk_window_features.h b/WebKit/efl/ewk/ewk_window_features.h
new file mode 100644 (file)
index 0000000..b579dc4
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+    Copyright (C) 2010 ProFUSION embedded systems
+    Copyright (C) 2010 Samsung Electronics
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef ewk_window_features_h
+#define ewk_window_features_h
+
+#include "ewk_eapi.h"
+
+#include <Eina.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct _Ewk_Window_Features Ewk_Window_Features;
+
+EAPI void         ewk_window_features_unref(Ewk_Window_Features* window_features);
+EAPI void         ewk_window_features_ref(Ewk_Window_Features* window_features);
+
+EAPI void         ewk_window_features_bool_property_get(Ewk_Window_Features* window_features, Eina_Bool* toolbar_visible, Eina_Bool* statusbar_visible, Eina_Bool* scrollbars_visible, Eina_Bool* menubar_visible, Eina_Bool* locationbar_visible, Eina_Bool* fullscreen);
+EAPI void         ewk_window_features_int_property_get(Ewk_Window_Features* window_features, int* x, int* y, int* w, int* h);
+
+#ifdef __cplusplus
+}
+#endif
+#endif // ewk_window_features_h