Diff
Modified: trunk/Source/WebKit2/ChangeLog (128055 => 128056)
--- trunk/Source/WebKit2/ChangeLog 2012-09-10 13:34:30 UTC (rev 128055)
+++ trunk/Source/WebKit2/ChangeLog 2012-09-10 13:54:40 UTC (rev 128056)
@@ -1,3 +1,35 @@
+2012-09-10 Alexander Shalamov <[email protected]>
+
+ [EFL][WK2] Add fullscreen enter / exit signals to the ewk_view API
+ https://bugs.webkit.org/show_bug.cgi?id=92362
+
+ Reviewed by Gyuyoung Kim.
+
+ Handle WebFullScreenManagerProxy::enterFullScreen and exitFullScreen
+ methods, so that ewk_view could enter and exit fullscreen mode when requested.
+ Also, two callbacks were added to ewk_view API, so that UI could customise
+ behavior when fullscreen mode is requested, e.g. show security dialog.
+
+ * UIProcess/API/efl/ewk_settings.cpp:
+ (ewk_settings_fullscreen_enabled_set):
+ (ewk_settings_fullscreen_enabled_get):
+ * UIProcess/API/efl/ewk_settings.h:
+ * UIProcess/API/efl/ewk_view.cpp:
+ (_ewk_view_initialize):
+ (ewk_view_full_screen_enter):
+ (ewk_view_full_screen_exit):
+ * UIProcess/API/efl/ewk_view.h:
+ * UIProcess/API/efl/ewk_view_private.h:
+ * UIProcess/API/efl/tests/test_ewk2_settings.cpp:
+ (TEST_F):
+ * UIProcess/API/efl/tests/test_ewk2_view.cpp:
+ (fullScreenCallback):
+ (checkFullScreenProperty):
+ (TEST_F):
+ * UIProcess/efl/WebFullScreenManagerProxyEfl.cpp:
+ (WebKit::WebFullScreenManagerProxy::enterFullScreen):
+ (WebKit::WebFullScreenManagerProxy::exitFullScreen):
+
2012-09-10 Kevin Funk <[email protected]>
[Qt] Fix deprecation failures if QT_NO_DEPRECATED enabled
Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp (128055 => 128056)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp 2012-09-10 13:34:30 UTC (rev 128055)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp 2012-09-10 13:54:40 UTC (rev 128056)
@@ -31,6 +31,27 @@
using namespace WebKit;
+Eina_Bool ewk_settings_fullscreen_enabled_set(Ewk_Settings* settings, Eina_Bool enable)
+{
+#if ENABLE(FULLSCREEN_API)
+ EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false);
+ WKPreferencesSetFullScreenEnabled(settings->preferences.get(), enable);
+ return true;
+#else
+ return false;
+#endif
+}
+
+Eina_Bool ewk_settings_fullscreen_enabled_get(const Ewk_Settings* settings)
+{
+#if ENABLE(FULLSCREEN_API)
+ EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false);
+ return WKPreferencesGetFullScreenEnabled(settings->preferences.get());
+#else
+ return false;
+#endif
+}
+
Eina_Bool ewk_settings_javascript_enabled_set(Ewk_Settings* settings, Eina_Bool enable)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false);
Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_settings.h (128055 => 128056)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_settings.h 2012-09-10 13:34:30 UTC (rev 128055)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_settings.h 2012-09-10 13:54:40 UTC (rev 128056)
@@ -44,6 +44,31 @@
typedef struct _Ewk_Settings Ewk_Settings;
/**
+ * Enables/disables the _javascript_ Fullscreen API. The _javascript_ API allows
+ * to request full screen mode, for more information see:
+ * http://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html
+ *
+ * Default value for _javascript_ Fullscreen API setting is @c EINA_TRUE .
+ *
+ * @param settings settings object to enable _javascript_ Fullscreen API
+ * @param enable @c EINA_TRUE to enable _javascript_ Fullscreen API or
+ * @c EINA_FALSE to disable
+ *
+ * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
+ */
+EAPI Eina_Bool ewk_settings_fullscreen_enabled_set(Ewk_Settings *settings, Eina_Bool enable);
+
+/**
+ * Returns whether the _javascript_ Fullscreen API is enabled or not.
+ *
+ * @param settings settings object to query whether _javascript_ Fullscreen API is enabled
+ *
+ * @return @c EINA_TRUE if the _javascript_ Fullscreen API is enabled
+ * @c EINA_FALSE if not or on failure
+ */
+EAPI Eina_Bool ewk_settings_fullscreen_enabled_get(const Ewk_Settings *settings);
+
+/**
* Enables/disables the _javascript_ executing.
*
* @param settings settings object to set _javascript_ executing
Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp (128055 => 128056)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp 2012-09-10 13:34:30 UTC (rev 128055)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp 2012-09-10 13:54:40 UTC (rev 128056)
@@ -35,6 +35,7 @@
#include "WebPageGroup.h"
#include "WebPopupItem.h"
#include "WebPopupMenuProxyEfl.h"
+#include "WebPreferences.h"
#include "ewk_back_forward_list_private.h"
#include "ewk_context.h"
#include "ewk_context_private.h"
@@ -58,6 +59,10 @@
#include <WebKit2/WKPageGroup.h>
#include <wtf/text/CString.h>
+#if ENABLE(FULLSCREEN_API)
+#include "WebFullScreenManagerProxy.h"
+#endif
+
#if USE(ACCELERATED_COMPOSITING)
#include <Evas_GL.h>
#endif
@@ -715,6 +720,10 @@
ewk_view_policy_client_attach(wkPage, ewkView);
ewk_view_resource_load_client_attach(wkPage, ewkView);
ewk_view_ui_client_attach(wkPage, ewkView);
+#if ENABLE(FULLSCREEN_API)
+ priv->pageProxy->fullScreenManager()->setWebView(ewkView);
+ ewk_settings_fullscreen_enabled_set(priv->settings.get(), true);
+#endif
}
static Evas_Object* _ewk_view_add_with_smart(Evas* canvas, Evas_Smart* smart)
@@ -1151,8 +1160,39 @@
evas_object_image_data_update_add(smartData->image, rect.x(), rect.y(), rect.width(), rect.height());
}
+#if ENABLE(FULLSCREEN_API)
/**
* @internal
+ * Calls fullscreen_enter callback or falls back to default behavior and enables fullscreen mode.
+ */
+void ewk_view_full_screen_enter(Evas_Object* ewkView)
+{
+ EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
+
+ if (!smartData->api->fullscreen_enter || !smartData->api->fullscreen_enter(smartData)) {
+ Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(smartData->base.evas);
+ ecore_evas_fullscreen_set(ecoreEvas, true);
+ }
+}
+
+/**
+ * @internal
+ * Calls fullscreen_exit callback or falls back to default behavior and disables fullscreen mode.
+ */
+void ewk_view_full_screen_exit(Evas_Object* ewkView)
+{
+ EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
+
+ if (!smartData->api->fullscreen_exit || !smartData->api->fullscreen_exit(smartData)) {
+ Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(smartData->base.evas);
+ ecore_evas_fullscreen_set(ecoreEvas, false);
+ }
+}
+#endif
+
+
+/**
+ * @internal
* A download for that view was cancelled.
*
* Emits signal: "download,cancelled" with pointer to a Ewk_Download_Job.
Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h (128055 => 128056)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h 2012-09-10 13:34:30 UTC (rev 128055)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h 2012-09-10 13:54:40 UTC (rev 128056)
@@ -106,6 +106,8 @@
// - if overridden, have to call parent method if desired
Eina_Bool (*focus_in)(Ewk_View_Smart_Data *sd);
Eina_Bool (*focus_out)(Ewk_View_Smart_Data *sd);
+ Eina_Bool (*fullscreen_enter)(Ewk_View_Smart_Data *sd);
+ Eina_Bool (*fullscreen_exit)(Ewk_View_Smart_Data *sd);
Eina_Bool (*mouse_wheel)(Ewk_View_Smart_Data *sd, const Evas_Event_Mouse_Wheel *ev);
Eina_Bool (*mouse_down)(Ewk_View_Smart_Data *sd, const Evas_Event_Mouse_Down *ev);
Eina_Bool (*mouse_up)(Ewk_View_Smart_Data *sd, const Evas_Event_Mouse_Up *ev);
@@ -118,7 +120,7 @@
* The version you have to put into the version field
* in the @a Ewk_View_Smart_Class structure.
*/
-#define EWK_VIEW_SMART_CLASS_VERSION 2UL
+#define EWK_VIEW_SMART_CLASS_VERSION 3UL
/**
* Initializer for whole Ewk_View_Smart_Class structure.
@@ -130,7 +132,7 @@
* @see EWK_VIEW_SMART_CLASS_INIT_VERSION
* @see EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION
*/
-#define EWK_VIEW_SMART_CLASS_INIT(smart_class_init) {smart_class_init, EWK_VIEW_SMART_CLASS_VERSION, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+#define EWK_VIEW_SMART_CLASS_INIT(smart_class_init) {smart_class_init, EWK_VIEW_SMART_CLASS_VERSION, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
/**
* Initializer to zero a whole Ewk_View_Smart_Class structure.
Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h (128055 => 128056)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h 2012-09-10 13:34:30 UTC (rev 128055)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h 2012-09-10 13:54:40 UTC (rev 128056)
@@ -59,6 +59,10 @@
void ewk_view_download_job_finished(Evas_Object* ewkView, Ewk_Download_Job*);
void ewk_view_download_job_requested(Evas_Object* ewkView, Ewk_Download_Job*);
void ewk_view_form_submission_request_new(Evas_Object* ewkView, Ewk_Form_Submission_Request*);
+#if ENABLE(FULLSCREEN_API)
+void ewk_view_full_screen_enter(Evas_Object* ewkView);
+void ewk_view_full_screen_exit(Evas_Object* ewkView);
+#endif
void ewk_view_image_data_set(Evas_Object* ewkView, void* imageData, const WebCore::IntSize& size);
void ewk_view_load_error(Evas_Object* ewkView, const Ewk_Web_Error* error);
void ewk_view_load_finished(Evas_Object* ewkView);
Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_settings.cpp (128055 => 128056)
--- trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_settings.cpp 2012-09-10 13:34:30 UTC (rev 128055)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_settings.cpp 2012-09-10 13:54:40 UTC (rev 128056)
@@ -31,6 +31,29 @@
using namespace EWK2UnitTest;
+TEST_F(EWK2UnitTestBase, ewk_settings_fullscreen_enabled)
+{
+ Ewk_Settings* settings = ewk_view_settings_get(webView());
+
+#if ENABLE(FULLSCREEN_API)
+ ASSERT_TRUE(ewk_settings_fullscreen_enabled_get(settings));
+
+ ASSERT_TRUE(ewk_settings_fullscreen_enabled_set(settings, EINA_TRUE));
+ ASSERT_TRUE(ewk_settings_fullscreen_enabled_get(settings));
+
+ ASSERT_TRUE(ewk_settings_fullscreen_enabled_set(settings, EINA_FALSE));
+ ASSERT_FALSE(ewk_settings_fullscreen_enabled_get(settings));
+#else
+ ASSERT_FALSE(ewk_settings_fullscreen_enabled_get(settings));
+
+ ASSERT_FALSE(ewk_settings_fullscreen_enabled_set(settings, EINA_TRUE));
+ ASSERT_FALSE(ewk_settings_fullscreen_enabled_get(settings));
+
+ ASSERT_FALSE(ewk_settings_fullscreen_enabled_set(settings, EINA_FALSE));
+ ASSERT_FALSE(ewk_settings_fullscreen_enabled_get(settings));
+#endif
+}
+
TEST_F(EWK2UnitTestBase, ewk_settings_javascript_enabled)
{
Ewk_Settings* settings = ewk_view_settings_get(webView());
Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp (128055 => 128056)
--- trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp 2012-09-10 13:34:30 UTC (rev 128055)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp 2012-09-10 13:54:40 UTC (rev 128056)
@@ -34,6 +34,7 @@
using namespace EWK2UnitTest;
extern EWK2UnitTestEnvironment* environment;
+bool fullScreenCallbackCalled;
static void onLoadFinishedForRedirection(void* userData, Evas_Object*, void*)
{
@@ -300,3 +301,62 @@
ASSERT_TRUE(ewk_view_mouse_events_enabled_set(webView(), EINA_FALSE));
ASSERT_FALSE(ewk_view_mouse_events_enabled_get(webView()));
}
+
+static Eina_Bool fullScreenCallback(Ewk_View_Smart_Data* smartData)
+{
+ fullScreenCallbackCalled = true;
+ return false;
+}
+
+static void checkFullScreenProperty(Evas_Object* webView, bool expectedState)
+{
+ if (environment->useX11Window()) {
+ Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(webView));
+ Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(smartData->base.evas);
+ bool windowState = false;
+ while (((windowState = ecore_evas_fullscreen_get(ecoreEvas)) != expectedState))
+ ecore_main_loop_iterate();
+ ASSERT_TRUE(expectedState == windowState);
+ }
+}
+
+TEST_F(EWK2UnitTestBase, ewk_view_full_screen_enter)
+{
+ const char fullscreenHTML[] =
+ "<!doctype html><head><script>function makeFullScreen(){"
+ "var div = document.getElementById(\"fullscreen\");"
+ "div.webkitRequestFullScreen();"
+ "document.title = \"fullscreen entered\";"
+ "}</script></head>"
+ "<body><div id=\"fullscreen\" style=\"width:100px; height:100px\" _onclick_=\"makeFullScreen()\"></div></body>";
+
+ ewkViewClass()->fullscreen_enter = fullScreenCallback;
+
+ ewk_view_html_string_load(webView(), fullscreenHTML, "file:///", 0);
+ waitUntilLoadFinished();
+ mouseClick(50, 50);
+ waitUntilTitleChangedTo("fullscreen entered");
+ ASSERT_TRUE(fullScreenCallbackCalled);
+ checkFullScreenProperty(webView(), true);
+}
+
+TEST_F(EWK2UnitTestBase, ewk_view_full_screen_exit)
+{
+ const char fullscreenHTML[] =
+ "<!doctype html><head><script>function makeFullScreenAndExit(){"
+ "var div = document.getElementById(\"fullscreen\");"
+ "div.webkitRequestFullScreen();"
+ "document.webkitCancelFullScreen();"
+ "document.title = \"fullscreen exited\";"
+ "}</script></head>"
+ "<body><div id=\"fullscreen\" style=\"width:100px; height:100px\" _onclick_=\"makeFullScreenAndExit()\"></div></body>";
+
+ ewkViewClass()->fullscreen_exit = fullScreenCallback;
+
+ ewk_view_html_string_load(webView(), fullscreenHTML, "file:///", 0);
+ waitUntilLoadFinished();
+ mouseClick(50, 50);
+ waitUntilTitleChangedTo("fullscreen exited");
+ ASSERT_TRUE(fullScreenCallbackCalled);
+ checkFullScreenProperty(webView(), false);
+}
Modified: trunk/Source/WebKit2/UIProcess/efl/WebFullScreenManagerProxyEfl.cpp (128055 => 128056)
--- trunk/Source/WebKit2/UIProcess/efl/WebFullScreenManagerProxyEfl.cpp 2012-09-10 13:34:30 UTC (rev 128055)
+++ trunk/Source/WebKit2/UIProcess/efl/WebFullScreenManagerProxyEfl.cpp 2012-09-10 13:54:40 UTC (rev 128056)
@@ -25,6 +25,7 @@
#include "config.h"
#include "WebFullScreenManagerProxy.h"
+#include "ewk_view_private.h"
#if ENABLE(FULLSCREEN_API)
@@ -52,12 +53,22 @@
void WebFullScreenManagerProxy::enterFullScreen()
{
- notImplemented();
+ if (!m_webView)
+ return;
+
+ willEnterFullScreen();
+ ewk_view_full_screen_enter(m_webView);
+ didEnterFullScreen();
}
void WebFullScreenManagerProxy::exitFullScreen()
{
- notImplemented();
+ if (!m_webView)
+ return;
+
+ willExitFullScreen();
+ ewk_view_full_screen_exit(m_webView);
+ didExitFullScreen();
}
void WebFullScreenManagerProxy::beganEnterFullScreen(const IntRect& initialFrame, const IntRect& finalFrame)