[EFL] Add method in ewk_settings for setting the CSS media type
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Apr 2013 12:43:45 +0000 (12:43 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Apr 2013 12:43:45 +0000 (12:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=113284

Patch by Jose Lejin PJ <jose.lejin@gmail.com> on 2013-04-19
Reviewed by Gyuyoung Kim.

Source/WebKit:

test_ewk_setting is added.

* PlatformEfl.cmake:

Source/WebKit/efl:

Added APIs to set and get CSS media type.
Added unit tests for these APIs.

* WebCoreSupport/FrameLoaderClientEfl.cpp:
(WebCore::FrameLoaderClientEfl::overrideMediaType):
* ewk/ewk_settings.cpp:
(ewk_settings_css_media_type_set):
(ewk_settings_css_media_type_get):
* ewk/ewk_settings.h:
* tests/test_ewk_setting.cpp: Added.
(TEST_F):

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

Source/WebKit/ChangeLog
Source/WebKit/PlatformEfl.cmake
Source/WebKit/efl/ChangeLog
Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp
Source/WebKit/efl/ewk/ewk_settings.cpp
Source/WebKit/efl/ewk/ewk_settings.h
Source/WebKit/efl/tests/test_ewk_setting.cpp [new file with mode: 0644]

index 4abcdde..e5a16a7 100644 (file)
@@ -1,3 +1,14 @@
+2013-04-19  Jose Lejin PJ  <jose.lejin@gmail.com>
+
+        [EFL] Add method in ewk_settings for setting the CSS media type
+        https://bugs.webkit.org/show_bug.cgi?id=113284
+
+        Reviewed by Gyuyoung Kim.
+
+        test_ewk_setting is added.
+
+        * PlatformEfl.cmake:
+
 2013-04-18  Sam Weinig  <sam@webkit.org>
 
         Network Process crashing trying to read in IDNScriptWhiteList.txt
index 011804c..df705a8 100644 (file)
@@ -261,6 +261,7 @@ set(EWKUnitTests_BINARIES
     test_ewk_contextmenu
     test_ewk_frame
     test_ewk_view
+    test_ewk_setting
 )
 
 if (ENABLE_API_TESTS)
index 34038e6..dcf60af 100644 (file)
@@ -1,3 +1,22 @@
+2013-04-19  Jose Lejin PJ  <jose.lejin@gmail.com>
+
+        [EFL] Add method in ewk_settings for setting the CSS media type
+        https://bugs.webkit.org/show_bug.cgi?id=113284
+
+        Reviewed by Gyuyoung Kim.
+
+        Added APIs to set and get CSS media type.
+        Added unit tests for these APIs.
+
+        * WebCoreSupport/FrameLoaderClientEfl.cpp:
+        (WebCore::FrameLoaderClientEfl::overrideMediaType):
+        * ewk/ewk_settings.cpp:
+        (ewk_settings_css_media_type_set):
+        (ewk_settings_css_media_type_get):
+        * ewk/ewk_settings.h:
+        * tests/test_ewk_setting.cpp: Added.
+        (TEST_F):
+
 2013-04-17  Geoffrey Garen  <ggaren@apple.com>
 
         Renamed JSGlobalData to VM
index aa7c3c4..d44782d 100644 (file)
@@ -59,6 +59,7 @@
 #include "WebKitVersion.h"
 #include "ewk_frame_private.h"
 #include "ewk_private.h"
+#include "ewk_settings.h"
 #include "ewk_settings_private.h"
 #include "ewk_view_private.h"
 #include <Ecore_Evas.h>
@@ -425,8 +426,7 @@ ObjectContentType FrameLoaderClientEfl::objectContentType(const KURL& url, const
 
 String FrameLoaderClientEfl::overrideMediaType() const
 {
-    notImplemented();
-    return String();
+    return String::fromUTF8(ewk_settings_css_media_type_get());
 }
 
 void FrameLoaderClientEfl::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world)
index 395c55a..ad0ecc7 100644 (file)
@@ -66,6 +66,7 @@ static const char* _ewk_icon_database_path = 0;
 
 static const char* s_webDatabasePath = 0;
 static const char* s_localStoragePath = 0;
+static const char* s_cssMediaType = 0;
 static uint64_t s_webDatabaseQuota = 1 * 1024 * 1024; // 1MB.
 
 static WTF::String _ewk_settings_webkit_platform_get()
@@ -388,3 +389,13 @@ double ewk_settings_default_timer_interval_get(void)
 {
     return WebCore::Settings::defaultMinDOMTimerInterval();
 }
+
+void ewk_settings_css_media_type_set(const char* type)
+{
+    eina_stringshare_replace(&s_cssMediaType, type);
+}
+
+const char* ewk_settings_css_media_type_get()
+{
+    return s_cssMediaType;
+}
index fb79279..6a29e26 100644 (file)
@@ -385,6 +385,34 @@ EAPI void             ewk_settings_repaint_throttling_set(double deferred_repain
  */
 EAPI double           ewk_settings_default_timer_interval_get(void);
 
+/**
+ * Sets the CSS media type.
+ *
+ * Setting this will override the normal value of the CSS media property.
+ *
+ * Setting the value to @c NULL will restore the internal default value.
+ *
+ * @param type css media type to be set, must be write-able
+ *
+ * @sa ewk_settings_css_media_type_get
+ */
+EAPI void             ewk_settings_css_media_type_set(const char *type);
+
+/**
+ * Returns the current CSS media type.
+ *
+ * It will only return the value set through ewk_settings_css_media_type_set and not the one used internally.
+ *
+ * This is guaranteed to be eina_stringshare, so whenever possible
+ * save yourself some cpu cycles and use eina_stringshare_ref()
+ * instead of eina_stringshare_add() or strdup().
+ * 
+ * @return css media type set by user or @c NULL if none is set
+ *
+ * @sa ewk_settings_css_media_type_set
+ */
+EAPI const char      *ewk_settings_css_media_type_get(void);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/Source/WebKit/efl/tests/test_ewk_setting.cpp b/Source/WebKit/efl/tests/test_ewk_setting.cpp
new file mode 100644 (file)
index 0000000..7b3f495
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2013 Cisco Systems, Inc. 
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Red istributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND ITS CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "UnitTestUtils/EWKTestBase.h"
+#include "UnitTestUtils/EWKTestConfig.h"
+#include <EWebKit.h>
+
+using namespace EWKUnitTests;
+
+/**
+ * @brief Unit test for checking set/get of css media type by ewk settings API.
+ */
+TEST_F(EWKTestBase, ewk_settings_css_media_type)
+{
+    ASSERT_STREQ(ewk_settings_css_media_type_get(), 0);
+
+    ewk_settings_css_media_type_set("handheld");
+    ASSERT_STREQ(ewk_settings_css_media_type_get(), "handheld");
+
+    ewk_settings_css_media_type_set("tv");
+    ASSERT_STREQ(ewk_settings_css_media_type_get(), "tv");
+
+    ewk_settings_css_media_type_set("screen");
+    ASSERT_STREQ(ewk_settings_css_media_type_get(), "screen");
+
+    ewk_settings_css_media_type_set(0);
+    ASSERT_STREQ(ewk_settings_css_media_type_get(), 0);
+}