summaryrefslogtreecommitdiffstats
path: root/WebKit/efl/ewk
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/efl/ewk')
-rw-r--r--WebKit/efl/ewk/ewk_frame.cpp62
-rw-r--r--WebKit/efl/ewk/ewk_frame.h1
-rw-r--r--WebKit/efl/ewk/ewk_main.cpp94
-rw-r--r--WebKit/efl/ewk/ewk_view.cpp83
-rw-r--r--WebKit/efl/ewk/ewk_view.h8
5 files changed, 205 insertions, 43 deletions
diff --git a/WebKit/efl/ewk/ewk_frame.cpp b/WebKit/efl/ewk/ewk_frame.cpp
index 7a2af5a..a7ce1ff 100644
--- a/WebKit/efl/ewk/ewk_frame.cpp
+++ b/WebKit/efl/ewk/ewk_frame.cpp
@@ -44,14 +44,15 @@
#include "ScriptValue.h"
#include "SharedBuffer.h"
#include "SubstituteData.h"
-#include "ZoomMode.h"
#include "WindowsKeyboardCodes.h"
+#include "ZoomMode.h"
#include "ewk_private.h"
-#include <wtf/text/CString.h>
#include <Eina.h>
#include <Evas.h>
+#include <algorithm>
#include <eina_safety_checks.h>
+#include <wtf/text/CString.h>
static const char EWK_FRAME_TYPE_STR[] = "EWK_Frame";
@@ -771,7 +772,7 @@ unsigned int ewk_frame_text_matches_mark(Evas_Object* o, const char* string, Ein
EINA_SAFETY_ON_NULL_RETURN_VAL(string, 0);
sd->frame->setMarkedTextMatchesAreHighlighted(highlight);
- return sd->frame->markAllMatchesForText(WTF::String::fromUTF8(string), case_sensitive, limit);
+ return sd->frame->countMatchesForText(WTF::String::fromUTF8(string), case_sensitive, limit, true);
}
/**
@@ -820,6 +821,55 @@ Eina_Bool ewk_frame_text_matches_highlight_get(const Evas_Object* o)
return sd->frame->markedTextMatchesAreHighlighted();
}
+/**
+ * Comparison function used by ewk_frame_text_matches_nth_pos_get
+ */
+static bool _ewk_frame_rect_cmp_less_than(const WebCore::IntRect& i, const WebCore::IntRect& j)
+{
+ return (i.y() < j.y() || (i.y() == j.y() && i.x() < j.x()));
+}
+
+/**
+ * Predicate used by ewk_frame_text_matches_nth_pos_get
+ */
+static bool _ewk_frame_rect_is_negative_value(const WebCore::IntRect& i)
+{
+ return (i.x() < 0 || i.y() < 0);
+}
+
+/**
+ * Get x, y position of n-th text match in frame
+ *
+ * @param o frame object where matches are highlighted.
+ * @param n index of element
+ * @param x where to return x position. May be @c NULL.
+ * @param y where to return y position. May be @c NULL.
+ *
+ * @return @c EINA_TRUE on success, @c EINA_FALSE for failure - when no matches found or
+ * n bigger than search results.
+ */
+Eina_Bool ewk_frame_text_matches_nth_pos_get(Evas_Object* o, int n, int* x, int* y)
+{
+ EWK_FRAME_SD_GET_OR_RETURN(o, sd, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(sd->frame, EINA_FALSE);
+
+ Vector<WebCore::IntRect> intRects = sd->frame->document()->markers()->renderedRectsForMarkers(WebCore::DocumentMarker::TextMatch);
+
+ /* remove useless values */
+ std::remove_if(intRects.begin(), intRects.end(), _ewk_frame_rect_is_negative_value);
+
+ if (intRects.isEmpty() || n > intRects.size())
+ return EINA_FALSE;
+
+ std::sort(intRects.begin(), intRects.end(), _ewk_frame_rect_cmp_less_than);
+
+ if (x)
+ *x = intRects[n - 1].x();
+ if (y)
+ *y = intRects[n - 1].y();
+ return EINA_TRUE;
+}
+
/**
* Ask frame to stop loading.
*
@@ -1687,12 +1737,6 @@ void ewk_frame_did_perform_first_navigation(Evas_Object *o)
*/
void ewk_frame_view_state_save(Evas_Object *o, WebCore::HistoryItem* item)
{
- const char *title = ewk_frame_title_get(o);
- const char *uri = ewk_frame_uri_get(o);
-
- item->setTitle(WTF::String::fromUTF8(title));
- item->setURLString(WTF::String::fromUTF8(uri));
-
evas_object_smart_callback_call(o, "state,save", 0);
}
diff --git a/WebKit/efl/ewk/ewk_frame.h b/WebKit/efl/ewk/ewk_frame.h
index 1a9fe81..9394446 100644
--- a/WebKit/efl/ewk/ewk_frame.h
+++ b/WebKit/efl/ewk/ewk_frame.h
@@ -160,6 +160,7 @@ EAPI unsigned int ewk_frame_text_matches_mark(Evas_Object *o, const char *string
EAPI Eina_Bool ewk_frame_text_matches_unmark_all(Evas_Object *o);
EAPI Eina_Bool ewk_frame_text_matches_highlight_set(Evas_Object *o, Eina_Bool highlight);
EAPI Eina_Bool ewk_frame_text_matches_highlight_get(const Evas_Object *o);
+EAPI Eina_Bool ewk_frame_text_matches_nth_pos_get(Evas_Object *o, int n, int *x, int *y);
EAPI Eina_Bool ewk_frame_stop(Evas_Object *o);
EAPI Eina_Bool ewk_frame_reload(Evas_Object *o);
diff --git a/WebKit/efl/ewk/ewk_main.cpp b/WebKit/efl/ewk/ewk_main.cpp
index 1cd5e42..8c27478 100644
--- a/WebKit/efl/ewk/ewk_main.cpp
+++ b/WebKit/efl/ewk/ewk_main.cpp
@@ -21,6 +21,7 @@
#include "config.h"
#include "ewk_main.h"
+#include "appcache/ApplicationCacheStorage.h"
#include "EWebKit.h"
#include "Logging.h"
#include "PageCache.h"
@@ -36,6 +37,7 @@
#include <Eina.h>
#include <Evas.h>
#include <stdlib.h>
+#include <sys/stat.h>
#if ENABLE(GLIB_SUPPORT)
#include <glib-object.h>
@@ -56,6 +58,8 @@
static int _ewk_init_count = 0;
int _ewk_log_dom = -1;
+static Eina_Bool _ewk_init_body(void);
+
int ewk_init(void)
{
if (_ewk_init_count)
@@ -90,6 +94,44 @@ int ewk_init(void)
goto error_edje;
}
+ _ewk_init_body();
+
+ return ++_ewk_init_count;
+
+error_edje:
+ ecore_evas_shutdown();
+error_ecore_evas:
+ ecore_shutdown();
+error_ecore:
+ evas_shutdown();
+error_evas:
+ eina_log_domain_unregister(_ewk_log_dom);
+ _ewk_log_dom = -1;
+error_log_domain:
+ eina_shutdown();
+error_eina:
+ return 0;
+}
+
+int ewk_shutdown(void)
+{
+ _ewk_init_count--;
+ if (_ewk_init_count)
+ return _ewk_init_count;
+
+ ecore_evas_shutdown();
+ ecore_shutdown();
+ evas_shutdown();
+ eina_log_domain_unregister(_ewk_log_dom);
+ _ewk_log_dom = -1;
+ eina_shutdown();
+
+ return 0;
+}
+
+Eina_Bool _ewk_init_body(void)
+{
+
#if ENABLE(GLIB_SUPPORT)
g_type_init();
@@ -117,8 +159,24 @@ int ewk_init(void)
WebCore::pageCache()->setCapacity(3);
WebCore::PageGroup::setShouldTrackVisitedLinks(true);
- // set default location of web database path
- ewk_settings_web_database_path_set(getenv("HOME"));
+ // set default location of web database path and appcache dir
+ const char* home = getenv("HOME");
+ if (!home) // don't forget about the homeless
+ home = "/tmp"; // this directory must always exist
+
+ // anyway, check it first
+ struct stat state;
+ if (stat(home, &state) == -1) {
+ // Exit now - otherwise you may have some crash later
+ int errnowas = errno;
+ CRITICAL("Can't access HOME dir (or /tmp) - no place to save databases: %s", strerror(errnowas));
+ return EINA_FALSE;
+ }
+
+ WTF::String wkdir = WTF::String(home) + "/.webkit";
+ ewk_settings_web_database_path_set(wkdir.utf8().data());
+
+ WebCore::cacheStorage().setCacheDirectory(wkdir);
// TODO: this should move to WebCore, already reported to webkit-gtk folks:
#ifdef WTF_USE_SOUP
@@ -129,36 +187,6 @@ int ewk_init(void)
}
#endif
- return ++_ewk_init_count;
-
-error_edje:
- ecore_evas_shutdown();
-error_ecore_evas:
- ecore_shutdown();
-error_ecore:
- evas_shutdown();
-error_evas:
- eina_log_domain_unregister(_ewk_log_dom);
- _ewk_log_dom = -1;
-error_log_domain:
- eina_shutdown();
-error_eina:
- return 0;
-}
-
-int ewk_shutdown(void)
-{
- _ewk_init_count--;
- if (_ewk_init_count)
- return _ewk_init_count;
-
- ecore_evas_shutdown();
- ecore_shutdown();
- evas_shutdown();
- eina_log_domain_unregister(_ewk_log_dom);
- _ewk_log_dom = -1;
- eina_shutdown();
-
- return 0;
+ return EINA_TRUE;
}
diff --git a/WebKit/efl/ewk/ewk_view.cpp b/WebKit/efl/ewk/ewk_view.cpp
index 4a100d7..ea54167 100644
--- a/WebKit/efl/ewk/ewk_view.cpp
+++ b/WebKit/efl/ewk/ewk_view.cpp
@@ -22,6 +22,7 @@
#include "config.h"
#include "ewk_view.h"
+#include "appcache/ApplicationCacheStorage.h"
#include "ChromeClientEfl.h"
#include "ContextMenuClientEfl.h"
#include "ContextMenuController.h"
@@ -88,6 +89,7 @@ struct _Ewk_View_Private_Data {
const char* user_stylesheet;
const char* encoding_default;
const char* encoding_custom;
+ const char* cache_directory;
int font_minimum_size;
int font_minimum_logical_size;
int font_default_size;
@@ -108,6 +110,8 @@ struct _Ewk_View_Private_Data {
Eina_Bool private_browsing:1;
Eina_Bool caret_browsing:1;
Eina_Bool spatial_navigation:1;
+ Eina_Bool local_storage:1;
+ Eina_Bool offline_app_cache: 1;
struct {
float w;
float h;
@@ -560,6 +564,7 @@ static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* sd)
priv->page_settings->setJavaScriptEnabled(true);
priv->page_settings->setPluginsEnabled(true);
priv->page_settings->setLocalStorageEnabled(true);
+ priv->page_settings->setOfflineWebApplicationCacheEnabled(true);
url = priv->page_settings->userStyleSheetLocation();
priv->settings.user_stylesheet = eina_stringshare_add(url.prettyURL().utf8().data());
@@ -568,6 +573,9 @@ static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* sd)
(priv->page_settings->defaultTextEncodingName().utf8().data());
priv->settings.encoding_custom = 0;
+ priv->settings.cache_directory = eina_stringshare_add
+ (WebCore::cacheStorage().cacheDirectory().utf8().data());
+
priv->settings.font_minimum_size = priv->page_settings->minimumFontSize();
priv->settings.font_minimum_logical_size = priv->page_settings->minimumLogicalFontSize();
priv->settings.font_default_size = priv->page_settings->defaultFontSize();
@@ -595,6 +603,8 @@ static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* sd)
priv->settings.resizable_textareas = priv->page_settings->textAreasAreResizable();
priv->settings.private_browsing = priv->page_settings->privateBrowsingEnabled();
priv->settings.caret_browsing = priv->page_settings->caretBrowsingEnabled();
+ priv->settings.local_storage = priv->page_settings->localStorageEnabled();
+ priv->settings.offline_app_cache = true; // XXX no function to read setting; this keeps the original setting
// Since there's no scale separated from zooming in webkit-efl, this functionality of
// viewport meta tag is implemented using zoom. When scale zoom is supported by webkit-efl,
@@ -641,6 +651,7 @@ static void _ewk_view_priv_del(Ewk_View_Private_Data* priv)
eina_stringshare_del(priv->settings.user_stylesheet);
eina_stringshare_del(priv->settings.encoding_default);
eina_stringshare_del(priv->settings.encoding_custom);
+ eina_stringshare_del(priv->settings.cache_directory);
eina_stringshare_del(priv->settings.font_standard);
eina_stringshare_del(priv->settings.font_cursive);
eina_stringshare_del(priv->settings.font_monospace);
@@ -794,6 +805,9 @@ static void _ewk_view_smart_calculate(Evas_Object* o)
sd->changed.frame_rect = EINA_TRUE;
sd->view.w = w;
sd->view.h = h;
+
+ // This callback is a good place e.g. to change fixed layout size (ewk_view_fixed_layout_size_set).
+ evas_object_smart_callback_call(o, "view,resized", 0);
}
sd->changed.size = EINA_FALSE;
@@ -2385,6 +2399,26 @@ Eina_Bool ewk_view_setting_private_browsing_set(Evas_Object* o, Eina_Bool enable
return EINA_TRUE;
}
+Eina_Bool ewk_view_setting_offline_app_cache_get(const Evas_Object* o)
+{
+ EWK_VIEW_SD_GET_OR_RETURN(o, sd, EINA_FALSE);
+ EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, EINA_FALSE);
+ return priv->settings.offline_app_cache;
+}
+
+Eina_Bool ewk_view_setting_offline_app_cache_set(Evas_Object* o, Eina_Bool enable)
+{
+ EWK_VIEW_SD_GET_OR_RETURN(o, sd, EINA_FALSE);
+ EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, EINA_FALSE);
+ enable = !!enable;
+ if (priv->settings.offline_app_cache != enable) {
+ priv->page_settings->setOfflineWebApplicationCacheEnabled(enable);
+ priv->settings.offline_app_cache = enable;
+ }
+ return EINA_TRUE;
+}
+
+
Eina_Bool ewk_view_setting_caret_browsing_get(const Evas_Object* o)
{
EWK_VIEW_SD_GET_OR_RETURN(o, sd, EINA_FALSE);
@@ -2465,6 +2499,22 @@ Eina_Bool ewk_view_setting_encoding_default_set(Evas_Object* o, const char* enco
return EINA_TRUE;
}
+const char* ewk_view_setting_cache_directory_get(const Evas_Object* o)
+{
+ EWK_VIEW_SD_GET_OR_RETURN(o, sd, 0);
+ EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, 0);
+ return priv->settings.cache_directory;
+}
+
+Eina_Bool ewk_view_setting_cache_directory_set(Evas_Object* o, const char* path)
+{
+ EWK_VIEW_SD_GET_OR_RETURN(o, sd, EINA_FALSE);
+ EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, EINA_FALSE);
+ if (eina_stringshare_replace(&priv->settings.cache_directory, path))
+ WebCore::cacheStorage().setCacheDirectory(WTF::String::fromUTF8(path));
+ return EINA_TRUE;
+}
+
int ewk_view_setting_font_minimum_size_get(const Evas_Object* o)
{
EWK_VIEW_SD_GET_OR_RETURN(o, sd, 0);
@@ -2665,6 +2715,37 @@ Eina_Bool ewk_view_setting_spatial_navigation_set(Evas_Object* o, Eina_Bool enab
}
/**
+ * Gets if the local storage is enabled.
+ *
+ * @param o view object to set if local storage is enabled.
+ * @return @c EINA_TRUE if local storage is enabled, @c EINA_FALSE if not.
+ */
+Eina_Bool ewk_view_setting_local_storage_get(Evas_Object* o)
+{
+ EWK_VIEW_SD_GET_OR_RETURN(o, sd, EINA_FALSE);
+ EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, EINA_FALSE);
+ return priv->settings.local_storage;
+}
+
+/**
+ * Sets the local storage of HTML5.
+ *
+ * @param o view object to set if local storage is enabled.
+ * @return @c EINA_TRUE on success and @c EINA_FALSE on failure
+ */
+Eina_Bool ewk_view_setting_local_storage_set(Evas_Object* o, Eina_Bool enable)
+{
+ EWK_VIEW_SD_GET_OR_RETURN(o, sd, EINA_FALSE);
+ EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, EINA_FALSE);
+ enable = !!enable;
+ if (priv->settings.local_storage != enable) {
+ priv->page_settings->setLocalStorageEnabled(enable);
+ priv->settings.local_storage = enable;
+ }
+ return EINA_TRUE;
+}
+
+/**
* Similar to evas_object_smart_data_get(), but does type checking.
*
* @param o view object to query internal data.
@@ -2769,7 +2850,7 @@ void ewk_view_layout_if_needed_recursive(Ewk_View_Private_Data* priv)
ERR("no main frame view");
return;
}
- v->layoutIfNeededRecursive();
+ v->updateLayoutAndStyleIfNeededRecursive();
}
void ewk_view_scrolls_process(Ewk_View_Smart_Data* sd)
diff --git a/WebKit/efl/ewk/ewk_view.h b/WebKit/efl/ewk/ewk_view.h
index 9d5997c..c5d2d45 100644
--- a/WebKit/efl/ewk/ewk_view.h
+++ b/WebKit/efl/ewk/ewk_view.h
@@ -88,6 +88,7 @@ extern "C" {
* - "icon,received", void: main frame received an icon.
* - "viewport,changed", void: Report that viewport has changed.
* - "inputmethods,changed" with a boolean indicating whether it's enabled or not.
+ * - "view,resized", void: view object's size has changed.
*/
typedef struct _Ewk_View_Smart_Data Ewk_View_Smart_Data;
@@ -403,6 +404,8 @@ EAPI Eina_Bool ewk_view_setting_user_stylesheet_set(Evas_Object *o, const cha
EAPI Eina_Bool ewk_view_setting_private_browsing_get(const Evas_Object *o);
EAPI Eina_Bool ewk_view_setting_private_browsing_set(Evas_Object *o, Eina_Bool enable);
+EAPI Eina_Bool ewk_view_setting_offline_app_cache_get(const Evas_Object *o);
+EAPI Eina_Bool ewk_view_setting_offline_app_cache_set(Evas_Object *o, Eina_Bool enable);
EAPI Eina_Bool ewk_view_setting_caret_browsing_get(const Evas_Object *o);
EAPI Eina_Bool ewk_view_setting_caret_browsing_set(Evas_Object *o, Eina_Bool enable);
@@ -411,6 +414,8 @@ EAPI const char *ewk_view_setting_encoding_custom_get(const Evas_Object *o);
EAPI Eina_Bool ewk_view_setting_encoding_custom_set(Evas_Object *o, const char *encoding);
EAPI const char *ewk_view_setting_encoding_default_get(const Evas_Object *o);
EAPI Eina_Bool ewk_view_setting_encoding_default_set(Evas_Object *o, const char *encoding);
+EAPI const char *ewk_view_setting_cache_directory_get(const Evas_Object *o);
+EAPI Eina_Bool ewk_view_setting_cache_directory_set(Evas_Object *o, const char *path);
EAPI int ewk_view_setting_font_minimum_size_get(const Evas_Object *o);
EAPI Eina_Bool ewk_view_setting_font_minimum_size_set(Evas_Object *o, int size);
@@ -442,6 +447,9 @@ EAPI Eina_Bool ewk_view_setting_font_sans_serif_set(Evas_Object *o, const cha
EAPI Eina_Bool ewk_view_setting_spatial_navigation_get(Evas_Object* o);
EAPI Eina_Bool ewk_view_setting_spatial_navigation_set(Evas_Object* o, Eina_Bool enable);
+EAPI Eina_Bool ewk_view_setting_local_storage_get(Evas_Object* o);
+EAPI Eina_Bool ewk_view_setting_local_storage_set(Evas_Object* o, Eina_Bool enable);
+
/* to be used by subclass implementations */
EAPI Ewk_View_Smart_Data *ewk_view_smart_data_get(const Evas_Object *o);