diff options
Diffstat (limited to 'WebKit/efl')
-rw-r--r-- | WebKit/efl/EWebLauncher/main.c | 71 | ||||
-rw-r--r-- | WebKit/efl/WebCoreSupport/ChromeClientEfl.cpp | 10 | ||||
-rw-r--r-- | WebKit/efl/WebCoreSupport/ChromeClientEfl.h | 2 | ||||
-rw-r--r-- | WebKit/efl/WebCoreSupport/ContextMenuClientEfl.cpp | 13 | ||||
-rw-r--r-- | WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp | 74 | ||||
-rw-r--r-- | WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h | 5 | ||||
-rw-r--r-- | WebKit/efl/ewk/ewk_frame.cpp | 117 | ||||
-rw-r--r-- | WebKit/efl/ewk/ewk_frame.h | 25 | ||||
-rw-r--r-- | WebKit/efl/ewk/ewk_private.h | 120 | ||||
-rw-r--r-- | WebKit/efl/ewk/ewk_view.cpp | 215 | ||||
-rw-r--r-- | WebKit/efl/ewk/ewk_view.h | 8 |
11 files changed, 579 insertions, 81 deletions
diff --git a/WebKit/efl/EWebLauncher/main.c b/WebKit/efl/EWebLauncher/main.c index 6d484e4a..362eefd 100644 --- a/WebKit/efl/EWebLauncher/main.c +++ b/WebKit/efl/EWebLauncher/main.c @@ -47,6 +47,7 @@ #define DEFAULT_WIDTH 800 #define DEFAULT_HEIGHT 600 +#define DEFAULT_ZOOM_INIT 1.0 #define info(format, args...) \ do { \ @@ -125,6 +126,15 @@ static const Ecore_Getopt options = { } }; +typedef struct _Viewport { + int w; + int h; + float initScale; + float minScale; + float maxScale; + Eina_Bool userScalable; +} Viewport; + typedef struct _ELauncher { Ecore_Evas *ee; Evas *evas; @@ -132,6 +142,7 @@ typedef struct _ELauncher { Evas_Object *browser; const char *theme; const char *userAgent; + Viewport viewport; } ELauncher; static void browserDestroy(Ecore_Evas *ee); @@ -225,6 +236,23 @@ title_set(Ecore_Evas *ee, const char *title, int progress) ecore_evas_title_set(ee, label); } +/** + * This is en example function to adjust viewport via viewport tag's arguments. + * Application can invoke this function in order to adjust viewport tag when it is required. + */ +static void +viewport_set() +{ + ELauncher *app; + app = (ELauncher*) eina_list_data_get(windows); + + ewk_view_fixed_layout_size_set(app->browser, app->viewport.w, app->viewport.h); + ewk_view_zoom_set(app->browser, app->viewport.initScale, 0, 0); + if (!ewk_view_zoom_range_set(app->browser, app->viewport.minScale, app->viewport.maxScale)) + info(" Fail to set zoom range. minScale = %f, maxScale = %f\n", app->viewport.minScale, app->viewport.maxScale); + ewk_view_user_scalable_set(app->browser, app->viewport.userScalable); +} + static void on_title_changed(void *user_data, Evas_Object *webview, void *event_info) { @@ -345,6 +373,48 @@ on_tooltip_text_set(void* user_data, Evas_Object* webview, void* event_info) info("%s\n", text); } +/** + * "viewport,changed" signal will be always emitted regardless of the viewport existence. + * + * If you don't want to process the viewport tag, you can either do nothing in this callback + * or simply ignore the signal in your application. + * + * More information about this can be found at http://developer.apple.com/safari/library/docum + * entation/appleapplications/reference/safariwebcontent/usingtheviewport/usingtheviewport.html + */ +static void +on_viewport_changed(void* user_data, Evas_Object* webview, void* event_info) +{ + ELauncher *app = (ELauncher *)user_data; + + float w, h, initScale, minScale, maxScale, userScalable; + + ewk_view_viewport_get(webview, &w, &h, &initScale, &maxScale, &minScale, &userScalable); + + /** + * If there is no argument in viewport tag, argument's value is -1. + */ + if ((int)w == -1) + w = DEFAULT_WIDTH; + if ((int)h == -1) + h = DEFAULT_HEIGHT; + if ((int)initScale == -1) + initScale = DEFAULT_ZOOM_INIT; // There's no scale separated from zooming in webkit-efl. + if ((int)minScale == -1) + minScale = ewk_view_zoom_range_min_get(webview); + if ((int)maxScale == -1) + maxScale = ewk_view_zoom_range_max_get(webview); + if ((int)userScalable == -1) + userScalable = EINA_TRUE; + + app->viewport.w = (int)w; + app->viewport.h = (int)h; + app->viewport.initScale = initScale; + app->viewport.minScale = minScale; + app->viewport.maxScale = maxScale; + app->viewport.userScalable = (Eina_Bool)userScalable; +} + static void on_mouse_down(void* data, Evas* e, Evas_Object* webview, void* event_info) { @@ -579,6 +649,7 @@ browserCreate(const char *url, const char *theme, const char *userAgent, Eina_Re evas_object_smart_callback_add(app->browser, "title,changed", on_title_changed, app); evas_object_smart_callback_add(app->browser, "load,progress", on_progress, app); evas_object_smart_callback_add(app->browser, "load,finished", on_load_finished, app); + evas_object_smart_callback_add(app->browser, "viewport,changed", on_viewport_changed, app); evas_object_smart_callback_add(app->browser, "toolbars,visible,set", on_toolbars_visible_set, app); evas_object_smart_callback_add(app->browser, "toolbars,visible,get", on_toolbars_visible_get, app); diff --git a/WebKit/efl/WebCoreSupport/ChromeClientEfl.cpp b/WebKit/efl/WebCoreSupport/ChromeClientEfl.cpp index 5fef33e..342654a 100644 --- a/WebKit/efl/WebCoreSupport/ChromeClientEfl.cpp +++ b/WebKit/efl/WebCoreSupport/ChromeClientEfl.cpp @@ -47,6 +47,7 @@ #include "KURL.h" #include "NotImplemented.h" #include "PlatformString.h" +#include "ViewportArguments.h" #include "WindowFeatures.h" #include "ewk_private.h" #include <Ecore_Evas.h> @@ -504,4 +505,13 @@ void ChromeClientEfl::chooseIconForFiles(const Vector<String>&, FileChooser*) notImplemented(); } +void ChromeClientEfl::didReceiveViewportArguments(Frame* frame, const ViewportArguments& arguments) const +{ + FrameLoaderClientEfl* client = static_cast<FrameLoaderClientEfl*>(frame->loader()->client()); + if (client->getInitLayoutCompleted()) + return; + + ewk_view_viewport_set(m_view, arguments.width, arguments.height, arguments.initialScale, arguments.minimumScale, arguments.maximumScale, arguments.userScalable); +} + } diff --git a/WebKit/efl/WebCoreSupport/ChromeClientEfl.h b/WebKit/efl/WebCoreSupport/ChromeClientEfl.h index fccf54f..45bda59 100644 --- a/WebKit/efl/WebCoreSupport/ChromeClientEfl.h +++ b/WebKit/efl/WebCoreSupport/ChromeClientEfl.h @@ -135,6 +135,8 @@ public: virtual void cancelGeolocationPermissionRequestForFrame(Frame*); virtual void iconForFiles(const Vector<String, 0u>&, PassRefPtr<FileChooser>); + virtual void didReceiveViewportArguments(Frame* frame, const ViewportArguments& arguments) const; + Evas_Object* m_view; KURL m_hoveredLinkURL; }; diff --git a/WebKit/efl/WebCoreSupport/ContextMenuClientEfl.cpp b/WebKit/efl/WebCoreSupport/ContextMenuClientEfl.cpp index 19c3705..37d7d5a 100644 --- a/WebKit/efl/WebCoreSupport/ContextMenuClientEfl.cpp +++ b/WebKit/efl/WebCoreSupport/ContextMenuClientEfl.cpp @@ -30,11 +30,11 @@ #include "ContextMenu.h" #include "EWebKit.h" -#include "ewk_private.h" #include "HitTestResult.h" #include "KURL.h" #include "NotImplemented.h" #include "PlatformMenuDescription.h" +#include "ewk_private.h" using namespace WebCore; @@ -62,9 +62,16 @@ void ContextMenuClientEfl::contextMenuItemSelected(ContextMenuItem*, const Conte notImplemented(); } -void ContextMenuClientEfl::downloadURL(const KURL&) +void ContextMenuClientEfl::downloadURL(const KURL& url) { - notImplemented(); + if (!m_view) + return; + + Ewk_Download download; + + CString downloadUrl = url.prettyURL().utf8(); + download.url = downloadUrl.data(); + ewk_view_download_request(m_view, &download); } void ContextMenuClientEfl::searchWithGoogle(const Frame*) diff --git a/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp b/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp index 50356e9..5648ec7 100644 --- a/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp +++ b/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp @@ -49,6 +49,7 @@ #include "ProgressTracker.h" #include "RenderPart.h" #include "ResourceRequest.h" +#include "ViewportArguments.h" #include "ewk_private.h" #include <wtf/text/CString.h> @@ -70,6 +71,7 @@ FrameLoaderClientEfl::FrameLoaderClientEfl(Evas_Object *view) , m_customUserAgent("") , m_pluginView(0) , m_hasSentResponseToPlugin(false) + , m_initLayoutCompleted(false) { } @@ -249,9 +251,25 @@ void FrameLoaderClientEfl::dispatchDidCancelAuthenticationChallenge(DocumentLoad notImplemented(); } -void FrameLoaderClientEfl::dispatchWillSendRequest(DocumentLoader*, unsigned long, ResourceRequest&, const ResourceResponse&) +void FrameLoaderClientEfl::dispatchWillSendRequest(DocumentLoader* loader, unsigned long identifier, ResourceRequest& coreRequest, const ResourceResponse& coreResponse) { - notImplemented(); + CString url = coreRequest.url().prettyURL().utf8(); + DBG("Resource url=%s", url.data()); + + Ewk_Frame_Resource_Request request = { 0, identifier }; + Ewk_Frame_Resource_Request orig = request; /* Initialize const fields. */ + + orig.url = request.url = url.data(); + + ewk_frame_request_will_send(m_frame, &request); + + if (request.url != orig.url) { + coreRequest.setURL(KURL(KURL(), request.url)); + + // Calling client might have changed our url pointer. + // Free the new allocated string. + free(const_cast<char*>(request.url)); + } } bool FrameLoaderClientEfl::shouldUseCredentialStorage(DocumentLoader*, unsigned long) @@ -260,9 +278,13 @@ bool FrameLoaderClientEfl::shouldUseCredentialStorage(DocumentLoader*, unsigned return false; } -void FrameLoaderClientEfl::assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&) +void FrameLoaderClientEfl::assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest& coreRequest) { - notImplemented(); + CString url = coreRequest.url().prettyURL().utf8(); + DBG("Resource url=%s", url.data()); + + Ewk_Frame_Resource_Request request = { 0, identifier }; + ewk_frame_request_assign_identifier(m_frame, &request); } void FrameLoaderClientEfl::postProgressStartedNotification() @@ -421,7 +443,7 @@ void FrameLoaderClientEfl::documentElementAvailable() void FrameLoaderClientEfl::didPerformFirstNavigation() const { - notImplemented(); + ewk_frame_did_perform_first_navigation(m_frame); } void FrameLoaderClientEfl::registerForIconNotification(bool) @@ -456,14 +478,17 @@ void FrameLoaderClientEfl::frameLoadCompleted() // Note: Can be called multiple times. } -void FrameLoaderClientEfl::saveViewStateToItem(HistoryItem*) +void FrameLoaderClientEfl::saveViewStateToItem(HistoryItem* item) { - notImplemented(); + ewk_frame_view_state_save(m_frame, item); } void FrameLoaderClientEfl::restoreViewState() { - notImplemented(); + ASSERT(m_frame); + ASSERT(m_view); + + ewk_view_restore_state(m_view, m_frame); } void FrameLoaderClientEfl::updateGlobalHistoryRedirectLinks() @@ -542,7 +567,11 @@ void FrameLoaderClientEfl::dispatchWillPerformClientRedirect(const KURL&, double void FrameLoaderClientEfl::dispatchDidChangeLocationWithinPage() { - notImplemented(); + ewk_frame_uri_changed(m_frame); + + if (ewk_view_frame_main_get(m_view) != m_frame) + return; + ewk_view_uri_changed(m_view); } void FrameLoaderClientEfl::dispatchWillClose() @@ -552,10 +581,18 @@ void FrameLoaderClientEfl::dispatchWillClose() void FrameLoaderClientEfl::dispatchDidReceiveIcon() { + /* report received favicon only for main frame. */ + if (ewk_view_frame_main_get(m_view) != m_frame) + return; + + ewk_view_frame_main_icon_received(m_view); } void FrameLoaderClientEfl::dispatchDidStartProvisionalLoad() { + ewk_frame_load_provisional(m_frame); + if (ewk_view_frame_main_get(m_view) == m_frame) + ewk_view_load_provisional(m_view); } void FrameLoaderClientEfl::dispatchDidReceiveTitle(const String& title) @@ -575,32 +612,37 @@ void FrameLoaderClientEfl::dispatchDidChangeIcons() void FrameLoaderClientEfl::dispatchDidCommitLoad() { + m_initLayoutCompleted = false; + ewk_frame_uri_changed(m_frame); if (ewk_view_frame_main_get(m_view) != m_frame) return; ewk_view_title_set(m_view, 0); ewk_view_uri_changed(m_view); + + ViewportArguments arguments; + ewk_view_viewport_set(m_view, arguments.width, arguments.height, arguments.initialScale, arguments.minimumScale, arguments.maximumScale, arguments.userScalable); } void FrameLoaderClientEfl::dispatchDidFinishDocumentLoad() { - notImplemented(); + ewk_frame_load_document_finished(m_frame); } void FrameLoaderClientEfl::dispatchDidFirstLayout() { - // emit m_frame->initialLayoutCompleted(); - notImplemented(); + m_initLayoutCompleted = true; + ewk_frame_load_firstlayout_finished(m_frame); } void FrameLoaderClientEfl::dispatchDidFirstVisuallyNonEmptyLayout() { - notImplemented(); + ewk_frame_load_firstlayout_nonempty_finished(m_frame); } void FrameLoaderClientEfl::dispatchShow() { - notImplemented(); + ewk_view_load_show(m_view); } void FrameLoaderClientEfl::cancelPolicyCheck() @@ -883,7 +925,11 @@ void FrameLoaderClientEfl::transitionToCommittedForNewPage() { ASSERT(m_frame); ASSERT(m_view); + ewk_frame_view_create_for_view(m_frame, m_view); + + if (m_frame == ewk_view_frame_main_get(m_view)) + ewk_view_frame_main_cleared(m_view); } } diff --git a/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h b/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h index 581ec85..561760c 100644 --- a/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h +++ b/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h @@ -55,6 +55,9 @@ class FrameLoaderClientEfl : public FrameLoaderClient { void setCustomUserAgent(const String &agent); const String& customUserAgent() const; + void setInitLayoutCompleted(bool completed) { m_initLayoutCompleted = completed; } + bool getInitLayoutCompleted() { return m_initLayoutCompleted; } + virtual bool hasWebView() const; virtual bool hasFrameView() const; @@ -213,6 +216,8 @@ class FrameLoaderClientEfl : public FrameLoaderClient { // Plugin view to redirect data to PluginView* m_pluginView; bool m_hasSentResponseToPlugin; + + bool m_initLayoutCompleted; }; } diff --git a/WebKit/efl/ewk/ewk_frame.cpp b/WebKit/efl/ewk/ewk_frame.cpp index ec56221..ca76f02 100644 --- a/WebKit/efl/ewk/ewk_frame.cpp +++ b/WebKit/efl/ewk/ewk_frame.cpp @@ -31,6 +31,7 @@ #include "FrameTree.h" #include "FrameView.h" #include "HTMLPlugInElement.h" +#include "HistoryItem.h" #include "HitTestResult.h" #include "KURL.h" #include "PlatformKeyboardEvent.h" @@ -1633,6 +1634,70 @@ WebCore::Frame* ewk_frame_core_get(const Evas_Object* o) /** * @internal + * Reports a resource will be requested. User may override behavior of webkit by + * changing values in @param request. + * + * @param o Frame. + * @param request Request details that user may override. Whenever values on + * this struct changes, it must be properly malloc'd as it will be freed + * afterwards. + * + * Emits signal: "resource,request,willsend" + */ +void ewk_frame_request_will_send(Evas_Object *o, Ewk_Frame_Resource_Request *request) +{ + evas_object_smart_callback_call(o, "resource,request,willsend", request); +} + +/** + * @internal + * Reports that there's a new resource. + * + * @param o Frame. + * @param request New request details. No changes are allowed to fields. + * + * Emits signal: "resource,request,new" + */ +void ewk_frame_request_assign_identifier(Evas_Object *o, const Ewk_Frame_Resource_Request *request) +{ + evas_object_smart_callback_call(o, "resource,request,new", (void *)request); +} + +/** + * @internal + * Reports that first navigation occurred + * + * @param o Frame. + * + * Emits signal: "navigation,first" + */ +void ewk_frame_did_perform_first_navigation(Evas_Object *o) +{ + evas_object_smart_callback_call(o, "navigation,first", 0); +} + +/** + * @internal + * Reports frame will be saved to current state + * + * @param o Frame. + * @param item History item to save details to. + * + * Emits signal: "state,save" + */ +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(WebCore::String::fromUTF8(title)); + item->setURLString(WebCore::String::fromUTF8(uri)); + + evas_object_smart_callback_call(o, "state,save", 0); +} + +/** + * @internal * Reports the frame started loading something. * * Emits signal: "load,started" with no parameters. @@ -1652,6 +1717,58 @@ void ewk_frame_load_started(Evas_Object* o) /** * @internal + * Reports the frame started provisional load. + * + * @param o Frame. + * + * Emits signal: "load,provisional" with no parameters. + */ +void ewk_frame_load_provisional(Evas_Object* o) +{ + evas_object_smart_callback_call(o, "load,provisional", 0); +} + +/** + * @internal + * Reports the frame finished first layout. + * + * @param o Frame. + * + * Emits signal: "load,firstlayout,finished" with no parameters. + */ +void ewk_frame_load_firstlayout_finished(Evas_Object *o) +{ + evas_object_smart_callback_call(o, "load,firstlayout,finished", 0); +} + +/** + * @internal + * Reports the frame finished first non empty layout. + * + * @param o Frame. + * + * Emits signal: "load,nonemptylayout,finished" with no parameters. + */ +void ewk_frame_load_firstlayout_nonempty_finished(Evas_Object *o) +{ + evas_object_smart_callback_call(o, "load,nonemptylayout,finished", 0); +} + +/** + * @internal + * Reports the loading of a document has finished on frame. + * + * @param o Frame. + * + * Emits signal: "load,document,finished" with no parameters. + */ +void ewk_frame_load_document_finished(Evas_Object *o) +{ + evas_object_smart_callback_call(o, "load,document,finished", 0); +} + +/** + * @internal * Reports load finished, optionally with error information. * * Emits signal: "load,finished" with pointer to Ewk_Frame_Load_Error diff --git a/WebKit/efl/ewk/ewk_frame.h b/WebKit/efl/ewk/ewk_frame.h index c71269b..1a9fe81 100644 --- a/WebKit/efl/ewk/ewk_frame.h +++ b/WebKit/efl/ewk/ewk_frame.h @@ -48,16 +48,28 @@ extern "C" { * * - "title,changed", const char*: title of the main frame changed. * - "uri,changed", const char*: uri of the main frame changed. + * - "load,document,finished", void: loading of a document has + * finished on this frame. + * - "load,nonemptylayout,finished", void: frame finished first + * non-empty layout. * - "load,started", void: frame started loading. * - "load,progress", double*: load progress changed (overall value * from 0.0 to 1.0, connect to individual frames for fine grained). * - "load,finished", const Ewk_Frame_Load_Error*: reports load * finished and as argument @c NULL if successfully or pointer to * structure defining the error. + * - "load,provisional", void: frame started provisional load. + * - "load,firstlayout,finished", void: frame finished first layout. * - "load,error", const Ewk_Frame_Load_Error*: reports load failed * and as argument a pointer to structure defining the error. * - "contents,size,changed", Evas_Coord[2]: reports contents size * changed due new layout, script actions or any other events. + * - "navigation,first", void: first navigation occurred. + * - "resource,request,new", Ewk_Frame_Resource_Request*: reports that + * there's a new resource request. + * - "resource,request,willsend", Ewk_Frame_Resource_Request*: a resource will + * be requested. + * - "state,save", void: frame's state will be saved as a history item. */ @@ -82,6 +94,19 @@ struct _Ewk_Frame_Load_Error { }; /** + * Structure used to report resource requests + * + * Details given before a resource is loaded on a given frame. It's used by + * ewk_frame_request_will_send() to inform the details of a to-be-loaded + * resource, allowing them to be overridden. + */ +typedef struct _Ewk_Frame_Resource_Request Ewk_Frame_Resource_Request; +struct _Ewk_Frame_Resource_Request { + const char *url; /**< url of this resource */ + const unsigned long identifier; /**< resource's identifier. Can not be changed */ +}; + +/** * Structure used to report hit test results. */ typedef struct _Ewk_Hit_Test Ewk_Hit_Test; diff --git a/WebKit/efl/ewk/ewk_private.h b/WebKit/efl/ewk/ewk_private.h index 83eef91..c549ad7 100644 --- a/WebKit/efl/ewk/ewk_private.h +++ b/WebKit/efl/ewk/ewk_private.h @@ -48,85 +48,101 @@ struct ContextMenu; struct ContextMenuItem; } -void ewk_view_ready(Evas_Object *o); -void ewk_view_title_set(Evas_Object *o, const char *title); -void ewk_view_uri_changed(Evas_Object *o); -void ewk_view_load_started(Evas_Object *o); -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_ready(Evas_Object *o); +void ewk_view_title_set(Evas_Object *o, const char *title); +void ewk_view_uri_changed(Evas_Object *o); +void ewk_view_load_started(Evas_Object *o); +void ewk_view_load_provisional(Evas_Object *o); +void ewk_view_frame_main_load_started(Evas_Object *o); +void ewk_view_frame_main_cleared(Evas_Object *o); +void ewk_view_frame_main_icon_received(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); +void ewk_view_load_show(Evas_Object* o); +void ewk_view_restore_state(Evas_Object *o, Evas_Object *frame); +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); +void ewk_view_mouse_link_hover_in(Evas_Object *o, void *data); +void ewk_view_mouse_link_hover_out(Evas_Object *o); -void ewk_view_toolbars_visible_set(Evas_Object *o, Eina_Bool visible); -void ewk_view_toolbars_visible_get(Evas_Object *o, Eina_Bool *visible); +void ewk_view_toolbars_visible_set(Evas_Object *o, Eina_Bool visible); +void ewk_view_toolbars_visible_get(Evas_Object *o, Eina_Bool *visible); -void ewk_view_statusbar_visible_set(Evas_Object *o, Eina_Bool visible); -void ewk_view_statusbar_visible_get(Evas_Object *o, Eina_Bool *visible); -void ewk_view_statusbar_text_set(Evas_Object *o, const char *text); +void ewk_view_statusbar_visible_set(Evas_Object *o, Eina_Bool visible); +void ewk_view_statusbar_visible_get(Evas_Object *o, Eina_Bool *visible); +void ewk_view_statusbar_text_set(Evas_Object *o, const char *text); -void ewk_view_scrollbars_visible_set(Evas_Object *o, Eina_Bool visible); -void ewk_view_scrollbars_visible_get(Evas_Object *o, Eina_Bool *visible); +void ewk_view_scrollbars_visible_set(Evas_Object *o, Eina_Bool visible); +void ewk_view_scrollbars_visible_get(Evas_Object *o, Eina_Bool *visible); -void ewk_view_menubar_visible_set(Evas_Object *o, Eina_Bool visible); -void ewk_view_menubar_visible_get(Evas_Object *o, Eina_Bool *visible); +void ewk_view_menubar_visible_set(Evas_Object *o, Eina_Bool visible); +void ewk_view_menubar_visible_get(Evas_Object *o, Eina_Bool *visible); -void ewk_view_tooltip_text_set(Evas_Object *o, const char *text); +void ewk_view_tooltip_text_set(Evas_Object *o, const char *text); -void ewk_view_add_console_message(Evas_Object *o, const char *message, unsigned int lineNumber, const char *sourceID); +void ewk_view_add_console_message(Evas_Object *o, const char *message, unsigned int lineNumber, const char *sourceID); -void ewk_view_run_javascript_alert(Evas_Object *o, Evas_Object *frame, const char *message); -Eina_Bool ewk_view_run_javascript_confirm(Evas_Object *o, Evas_Object *frame, const char *message); -Eina_Bool ewk_view_run_javascript_prompt(Evas_Object *o, Evas_Object *frame, const char *message, const char *defaultValue, char **value); -Eina_Bool ewk_view_should_interrupt_javascript(Evas_Object *o); -uint64_t ewk_view_exceeded_database_quota(Evas_Object *o, Evas_Object *frame, const char *databaseName, uint64_t current_size, uint64_t expected_size); +void ewk_view_run_javascript_alert(Evas_Object *o, Evas_Object *frame, const char *message); +Eina_Bool ewk_view_run_javascript_confirm(Evas_Object *o, Evas_Object *frame, const char *message); +Eina_Bool ewk_view_run_javascript_prompt(Evas_Object *o, Evas_Object *frame, const char *message, const char *defaultValue, char **value); +Eina_Bool ewk_view_should_interrupt_javascript(Evas_Object *o); +uint64_t ewk_view_exceeded_database_quota(Evas_Object *o, Evas_Object *frame, const char *databaseName, uint64_t current_size, uint64_t expected_size); -Eina_Bool ewk_view_run_open_panel(Evas_Object *o, Evas_Object *frame, Eina_Bool allows_multiple_files, const Eina_List *suggested_filenames, Eina_List **selected_filenames); +Eina_Bool ewk_view_run_open_panel(Evas_Object *o, Evas_Object *frame, Eina_Bool allows_multiple_files, const Eina_List *suggested_filenames, Eina_List **selected_filenames); -void ewk_view_repaint(Evas_Object *o, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h); -void ewk_view_scroll(Evas_Object *o, Evas_Coord dx, Evas_Coord dy, Evas_Coord sx, Evas_Coord sy, Evas_Coord sw, Evas_Coord sh, Evas_Coord cx, Evas_Coord cy, Evas_Coord cw, Evas_Coord ch, Eina_Bool main_frame); -WebCore::Page *ewk_view_core_page_get(const Evas_Object *o); +void ewk_view_repaint(Evas_Object *o, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h); +void ewk_view_scroll(Evas_Object *o, Evas_Coord dx, Evas_Coord dy, Evas_Coord sx, Evas_Coord sy, Evas_Coord sw, Evas_Coord sh, Evas_Coord cx, Evas_Coord cy, Evas_Coord cw, Evas_Coord ch, Eina_Bool main_frame); +WebCore::Page *ewk_view_core_page_get(const Evas_Object *o); WTF::PassRefPtr<WebCore::Frame> ewk_view_frame_create(Evas_Object *o, Evas_Object *frame, const WebCore::String& name, WebCore::HTMLFrameOwnerElement* ownerElement, const WebCore::KURL& url, const WebCore::String& referrer); WTF::PassRefPtr<WebCore::Widget> ewk_view_plugin_create(Evas_Object* o, Evas_Object* frame, const WebCore::IntSize& pluginSize, WebCore::HTMLPlugInElement* element, const WebCore::KURL& url, const WTF::Vector<WebCore::String>& paramNames, const WTF::Vector<WebCore::String>& paramValues, const WebCore::String& mimeType, bool loadManually); -void ewk_view_popup_new(Evas_Object *o, WebCore::PopupMenuClient* client, int selected, const WebCore::IntRect& rect); +void ewk_view_popup_new(Evas_Object *o, WebCore::PopupMenuClient* client, int selected, const WebCore::IntRect& rect); +void ewk_view_viewport_set(Evas_Object *o, float w, float h, float init_scale, float max_scale, float min_scale, float user_scalable); -void ewk_view_download_request(Evas_Object *o, Ewk_Download *download); +void ewk_view_download_request(Evas_Object *o, Ewk_Download *download); -Ewk_History *ewk_history_new(WebCore::BackForwardList *history); -void ewk_history_free(Ewk_History *history); +Ewk_History *ewk_history_new(WebCore::BackForwardList *history); +void ewk_history_free(Ewk_History *history); Ewk_Context_Menu *ewk_context_menu_new(Evas_Object *view, WebCore::ContextMenuController *controller); -Eina_Bool ewk_context_menu_free(Ewk_Context_Menu *o); -void ewk_context_menu_item_append(Ewk_Context_Menu *o, WebCore::ContextMenuItem& core); +Eina_Bool ewk_context_menu_free(Ewk_Context_Menu *o); +void ewk_context_menu_item_append(Ewk_Context_Menu *o, WebCore::ContextMenuItem& core); Ewk_Context_Menu *ewk_context_menu_custom_get(Ewk_Context_Menu *o); -void ewk_context_menu_show(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); +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); -WebCore::Frame *ewk_frame_core_get(const Evas_Object *o); -void ewk_frame_core_gone(Evas_Object *o); +WebCore::Frame *ewk_frame_core_get(const Evas_Object *o); +void ewk_frame_core_gone(Evas_Object *o); -void ewk_frame_load_started(Evas_Object *o); -void ewk_frame_load_finished(Evas_Object *o, const char *error_domain, int error_code, Eina_Bool is_cancellation, const char *error_description, const char *failing_url); -void ewk_frame_load_error(Evas_Object *o, const char *error_domain, int error_code, Eina_Bool is_cancellation, const char *error_description, const char *failing_url); -void ewk_frame_load_progress_changed(Evas_Object *o); +void ewk_frame_load_started(Evas_Object *o); +void ewk_frame_load_provisional(Evas_Object *o); +void ewk_frame_load_firstlayout_finished(Evas_Object *o); +void ewk_frame_load_firstlayout_nonempty_finished(Evas_Object *o); +void ewk_frame_load_document_finished(Evas_Object *o); +void ewk_frame_load_finished(Evas_Object *o, const char *error_domain, int error_code, Eina_Bool is_cancellation, const char *error_description, const char *failing_url); +void ewk_frame_load_error(Evas_Object *o, const char *error_domain, int error_code, Eina_Bool is_cancellation, const char *error_description, const char *failing_url); +void ewk_frame_load_progress_changed(Evas_Object *o); -void ewk_frame_contents_size_changed(Evas_Object *o, Evas_Coord w, Evas_Coord h); -void ewk_frame_title_set(Evas_Object *o, const char *title); +void ewk_frame_request_will_send(Evas_Object *o, Ewk_Frame_Resource_Request *request); +void ewk_frame_request_assign_identifier(Evas_Object *o, const Ewk_Frame_Resource_Request *request); +void ewk_frame_view_state_save(Evas_Object *o, WebCore::HistoryItem* item); -void ewk_frame_view_create_for_view(Evas_Object *o, Evas_Object *view); -Eina_Bool ewk_frame_uri_changed(Evas_Object *o); -void ewk_frame_force_layout(Evas_Object *o); +void ewk_frame_did_perform_first_navigation(Evas_Object *o); + +void ewk_frame_contents_size_changed(Evas_Object *o, Evas_Coord w, Evas_Coord h); +void ewk_frame_title_set(Evas_Object *o, const char *title); + +void ewk_frame_view_create_for_view(Evas_Object *o, Evas_Object *view); +Eina_Bool ewk_frame_uri_changed(Evas_Object *o); +void ewk_frame_force_layout(Evas_Object *o); WTF::PassRefPtr<WebCore::Widget> ewk_frame_plugin_create(Evas_Object* o, const WebCore::IntSize& pluginSize, WebCore::HTMLPlugInElement* element, const WebCore::KURL& url, const WTF::Vector<WebCore::String>& paramNames, const WTF::Vector<WebCore::String>& paramValues, const WebCore::String& mimeType, bool loadManually); diff --git a/WebKit/efl/ewk/ewk_view.cpp b/WebKit/efl/ewk/ewk_view.cpp index ca26f64..39dc0a7 100644 --- a/WebKit/efl/ewk/ewk_view.cpp +++ b/WebKit/efl/ewk/ewk_view.cpp @@ -102,6 +102,19 @@ struct _Ewk_View_Private_Data { Eina_Bool resizable_textareas:1; Eina_Bool private_browsing:1; Eina_Bool caret_browsing:1; + struct { + float w; + float h; + float init_scale; + float min_scale; + float max_scale; + float user_scalable; + } viewport; + struct { + float min_scale; + float max_scale; + Eina_Bool user_scalable:1; + } zoom_range; } settings; struct { struct { @@ -520,6 +533,7 @@ static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* sd) static_cast<WebCore::InspectorClient*>(new WebCore::InspectorClientEfl), 0, 0, + 0, 0); if (!priv->page) { CRITICAL("Could not create WebKit Page"); @@ -576,6 +590,12 @@ static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* sd) priv->settings.private_browsing = priv->page_settings->privateBrowsingEnabled(); priv->settings.caret_browsing = priv->page_settings->caretBrowsingEnabled(); + // 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, + // this functionality will be modified by the scale zoom patch. + priv->settings.zoom_range.min_scale = ZOOM_MIN; + priv->settings.zoom_range.max_scale = ZOOM_MAX; + priv->main_frame = _ewk_view_core_frame_new(sd, priv, 0).get(); if (!priv->main_frame) { CRITICAL("Could not create main frame."); @@ -1001,6 +1021,11 @@ void ewk_view_fixed_layout_size_set(Evas_Object* o, Evas_Coord w, Evas_Coord h) { EWK_VIEW_SD_GET_OR_RETURN(o, sd); EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv); + + WebCore::FrameLoaderClientEfl* client = static_cast<WebCore::FrameLoaderClientEfl*>(priv->main_frame->loader()->client()); + if (!client->getInitLayoutCompleted()) + return; + WebCore::FrameView* view = sd->_priv->main_frame->view(); if (w <= 0 && h <= 0) { if (!priv->fixed_layout.use) @@ -1757,14 +1782,22 @@ float ewk_view_zoom_get(const Evas_Object* o) Eina_Bool ewk_view_zoom_set(Evas_Object* o, float zoom, Evas_Coord cx, Evas_Coord cy) { EWK_VIEW_SD_GET_OR_RETURN(o, sd, EINA_FALSE); + EWK_VIEW_PRIV_GET(sd, priv); + EINA_SAFETY_ON_NULL_RETURN_VAL(sd->api, EINA_FALSE); EINA_SAFETY_ON_NULL_RETURN_VAL(sd->api->zoom_set, EINA_FALSE); - if (zoom < ZOOM_MIN) { - WRN("zoom level is < %f : %f", (double)ZOOM_MIN, (double)zoom); + + if (!priv->settings.zoom_range.user_scalable) { + WRN("userScalable is false"); + return EINA_FALSE; + } + + if (zoom < priv->settings.zoom_range.min_scale) { + WRN("zoom level is < %f : %f", (double)priv->settings.zoom_range.min_scale, (double)zoom); return EINA_FALSE; } - if (zoom > ZOOM_MAX) { - WRN("zoom level is > %f : %f", (double)ZOOM_MAX, (double)zoom); + if (zoom > priv->settings.zoom_range.max_scale) { + WRN("zoom level is > %f : %f", (double)priv->settings.zoom_range.max_scale, (double)zoom); return EINA_FALSE; } @@ -1827,14 +1860,22 @@ void ewk_view_zoom_weak_smooth_scale_set(Evas_Object* o, Eina_Bool smooth_scale) Eina_Bool ewk_view_zoom_weak_set(Evas_Object* o, float zoom, Evas_Coord cx, Evas_Coord cy) { EWK_VIEW_SD_GET_OR_RETURN(o, sd, EINA_FALSE); + EWK_VIEW_PRIV_GET(sd, priv); + EINA_SAFETY_ON_NULL_RETURN_VAL(sd->api, EINA_FALSE); EINA_SAFETY_ON_NULL_RETURN_VAL(sd->api->zoom_weak_set, EINA_FALSE); - if (zoom < ZOOM_MIN) { - WRN("zoom level is < %f : %f", (double)ZOOM_MIN, (double)zoom); + + if (!priv->settings.zoom_range.user_scalable) { + WRN("userScalable is false"); + return EINA_FALSE; + } + + if (zoom < priv->settings.zoom_range.min_scale) { + WRN("zoom level is < %f : %f", (double)priv->settings.zoom_range.min_scale, (double)zoom); return EINA_FALSE; } - if (zoom > ZOOM_MAX) { - WRN("zoom level is > %f : %f", (double)ZOOM_MAX, (double)zoom); + if (zoom > priv->settings.zoom_range.max_scale) { + WRN("zoom level is > %f : %f", (double)priv->settings.zoom_range.max_scale, (double)zoom); return EINA_FALSE; } @@ -1977,12 +2018,17 @@ Eina_Bool ewk_view_zoom_animated_set(Evas_Object* o, float zoom, float duration, EINA_SAFETY_ON_NULL_RETURN_VAL(sd->api, EINA_FALSE); EINA_SAFETY_ON_NULL_RETURN_VAL(sd->api->zoom_weak_set, EINA_FALSE); - if (zoom < ZOOM_MIN) { - WRN("zoom level is < %f : %f", (double)ZOOM_MIN, (double)zoom); + if (!priv->settings.zoom_range.user_scalable) { + WRN("userScalable is false"); return EINA_FALSE; } - if (zoom > ZOOM_MAX) { - WRN("zoom level is > %f : %f", (double)ZOOM_MAX, (double)zoom); + + if (zoom < priv->settings.zoom_range.min_scale) { + WRN("zoom level is < %f : %f", (double)priv->settings.zoom_range.min_scale, (double)zoom); + return EINA_FALSE; + } + if (zoom > priv->settings.zoom_range.max_scale) { + WRN("zoom level is > %f : %f", (double)priv->settings.zoom_range.max_scale, (double)zoom); return EINA_FALSE; } @@ -3710,3 +3756,148 @@ void ewk_view_download_request(Evas_Object* o, Ewk_Download* download) DBG("view=%p", o); evas_object_smart_callback_call(o, "download,request", download); } + +/** + * @internal + * Reports the viewport has changed. + * + * @param o view. + * @param w width. + * @param h height. + * @param init_scale initialScale value. + * @param max_scale maximumScale value. + * @param min_scale minimumScale value. + * @param user_scalable userscalable flag. + * + * Emits signal: "viewport,changed" with no parameters. + */ +void ewk_view_viewport_set(Evas_Object *o, float w, float h, float init_scale, float max_scale, float min_scale, float user_scalable) +{ + EWK_VIEW_SD_GET(o, sd); + EWK_VIEW_PRIV_GET(sd, priv); + + priv->settings.viewport.w = w; + priv->settings.viewport.h = h; + priv->settings.viewport.init_scale = init_scale; + priv->settings.viewport.min_scale = min_scale; + priv->settings.viewport.max_scale = max_scale; + priv->settings.viewport.user_scalable = user_scalable; + + evas_object_smart_callback_call(o, "viewport,changed", 0); +} + +/** + * Gets data of viewport meta tag. + * + * @param o view. + * @param w width. + * @param h height. + * @param init_scale initial Scale value. + * @param max_scale maximum Scale value. + * @param min_scale minimum Scale value. + * @param user_scalable user Scalable value. + */ +void ewk_view_viewport_get(Evas_Object *o, float* w, float* h, float* init_scale, float* max_scale, float* min_scale, float* user_scalable) +{ + EWK_VIEW_SD_GET(o, sd); + EWK_VIEW_PRIV_GET(sd, priv); + + if (w) + *w = priv->settings.viewport.w; + if (h) + *h = priv->settings.viewport.h; + if (init_scale) + *init_scale = priv->settings.viewport.init_scale; + if (max_scale) + *max_scale = priv->settings.viewport.max_scale; + if (min_scale) + *min_scale = priv->settings.viewport.min_scale; + if (user_scalable) + *user_scalable = priv->settings.viewport.user_scalable; +} + +/** + * Sets the zoom range. + * + * @param o view. + * @param min_scale minimum value of zoom range. + * @param max_scale maximum value of zoom range. + * + * @return @c EINA_TRUE if zoom range is changed, @c EINA_FALSE if not or failure. + */ +Eina_Bool ewk_view_zoom_range_set(Evas_Object* o, float min_scale, float max_scale) +{ + EWK_VIEW_SD_GET(o, sd); + EWK_VIEW_PRIV_GET(sd, priv); + + if (max_scale < min_scale) { + WRN("min_scale is larger than max_scale"); + return EINA_FALSE; + } + + priv->settings.zoom_range.min_scale = min_scale; + priv->settings.zoom_range.max_scale = max_scale; + + return EINA_TRUE; +} + +/** + * Gets the minimum value of zoom range. + * + * @param o view. + * + * @return minimum value of zoom range. + */ +float ewk_view_zoom_range_min_get(Evas_Object* o) +{ + EWK_VIEW_SD_GET(o, sd); + EWK_VIEW_PRIV_GET(sd, priv); + + return priv->settings.zoom_range.min_scale; +} + +/** + * Gets the maximum value of zoom range. + * + * @param o view. + * + * @return maximum value of zoom range. + */ +float ewk_view_zoom_range_max_get(Evas_Object* o) +{ + EWK_VIEW_SD_GET(o, sd); + EWK_VIEW_PRIV_GET(sd, priv); + + return priv->settings.zoom_range.max_scale; +} + +/** + * Sets if zoom is enabled. + * + * @param o view. + * @param user_scalable boolean pointer in which to enable zoom. It defaults + * to @c EINA_TRUE. + */ +void ewk_view_user_scalable_set(Evas_Object* o, Eina_Bool user_scalable) +{ + EWK_VIEW_SD_GET(o, sd); + EWK_VIEW_PRIV_GET(sd, priv); + + priv->settings.zoom_range.user_scalable = user_scalable; +} + +/** + * Gets if zoom is enabled. + * + * @param o view. + * @param user_scalable where to return the current user scalable value. + * + * @return @c EINA_TRUE if zoom is enabled, @c EINA_FALSE if not. + */ +Eina_Bool ewk_view_user_scalable_get(Evas_Object* o) +{ + EWK_VIEW_SD_GET(o, sd); + EWK_VIEW_PRIV_GET(sd, priv); + + return priv->settings.zoom_range.user_scalable; +} diff --git a/WebKit/efl/ewk/ewk_view.h b/WebKit/efl/ewk/ewk_view.h index a8fe3b8..209beff 100644 --- a/WebKit/efl/ewk/ewk_view.h +++ b/WebKit/efl/ewk/ewk_view.h @@ -85,6 +85,7 @@ extern "C" { * - "download,request", Ewk_Download: reports a download is being requested * and as arguments gives its details. * - "icon,received", void: main frame received an icon. + * - "viewport,changed", void: Report that viewport has changed. */ typedef struct _Ewk_View_Smart_Data Ewk_View_Smart_Data; @@ -453,6 +454,13 @@ EAPI void ewk_view_paint_context_translate(Ewk_View_Paint_Context *ctxt, float x EAPI Eina_Bool ewk_view_paint(Ewk_View_Private_Data *priv, cairo_t *cr, const Eina_Rectangle *area); EAPI Eina_Bool ewk_view_paint_contents(Ewk_View_Private_Data *priv, cairo_t *cr, const Eina_Rectangle *area); +EAPI void ewk_view_viewport_get(Evas_Object *o, float* w, float* h, float* init_scale, float* max_scale, float* min_scale, float* user_scalable); +EAPI Eina_Bool ewk_view_zoom_range_set(Evas_Object* o, float min_scale, float max_scale); +EAPI float ewk_view_zoom_range_min_get(Evas_Object* o); +EAPI float ewk_view_zoom_range_max_get(Evas_Object* o); +EAPI void ewk_view_user_scalable_set(Evas_Object* o, Eina_Bool user_scalable); +EAPI Eina_Bool ewk_view_user_scalable_get(Evas_Object* o); + #ifdef __cplusplus } #endif |