1/*
2   Copyright (C) 2011 Samsung Electronics
3   Copyright (C) 2012 Intel Corporation. All rights reserved.
4
5    This library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Library General Public
7    License as published by the Free Software Foundation; either
8    version 2 of the License, or (at your option) any later version.
9
10    This library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Library General Public License for more details.
14
15    You should have received a copy of the GNU Library General Public License
16    along with this library; see the file COPYING.LIB.  If not, write to
17    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18    Boston, MA 02110-1301, USA.
19*/
20
21/**
22 * @file    ewk_view.h
23 * @brief   WebKit main smart object.
24 *
25 * This object provides view related APIs of WebKit2 to EFL object.
26 *
27 * The following signals (see evas_object_smart_callback_add()) are emitted:
28 *
29 * - "authentication,request", Ewk_Auth_Request*: reports that user authentication was requested. Call
30 *   ewk_auth_request_ref() on the request object to process the authentication asynchronously.
31 * - "back,forward,list,changed", void: reports that the view's back / forward list had changed.
32 * - "cancel,vibration", void: request to cancel the vibration.
33 * - "contents,size,changed", Ewk_CSS_Size*: reports that contents size was changed.
34 * - "download,cancelled", Ewk_Download_Job*: reports that a download was effectively cancelled.
35 * - "download,failed", Ewk_Download_Job_Error*: reports that a download failed with the given error.
36 * - "download,finished", Ewk_Download_Job*: reports that a download completed successfully.
37 * - "download,request", Ewk_Download_Job*: reports that a new download has been requested. The client should set the
38 *   destination path by calling ewk_download_job_destination_set() or the download will fail.
39 * - "file,chooser,request", Ewk_File_Chooser_Request*: reports that a request has been made for the user to choose
40 *   a file (or several) on the file system. Call ewk_file_chooser_request_ref() on the request object to process it
41 *   asynchronously.
42 * - "form,submission,request", Ewk_Form_Submission_Request*: Reports that a form request is about to be submitted.
43 *   The Ewk_Form_Submission_Request passed contains information about the text fields of the form. This
44 *   is typically used to store login information that can be used later to pre-fill the form.
45 *   The form will not be submitted until ewk_form_submission_request_submit() is called.
46 *   It is possible to handle the form submission request asynchronously, by simply calling
47 *   ewk_form_submission_request_ref() on the request and calling ewk_form_submission_request_submit()
48 *   when done to continue with the form submission. If the last reference is removed on a
49 *   #Ewk_Form_Submission_Request and the form has not been submitted yet,
50 *   ewk_form_submission_request_submit() will be called automatically.
51 * - "load,error", const Ewk_Error*: reports main frame load failed.
52 * - "load,finished", void: reports load finished.
53 * - "load,progress", double*: load progress has changed (value from 0.0 to 1.0).
54 * - "load,provisional,failed", const Ewk_Error*: view provisional load failed.
55 * - "load,provisional,redirect", void: view received redirect for provisional load.
56 * - "load,provisional,started", void: view started provisional load.
57 * - "policy,decision,navigation", Ewk_Navigation_Policy_Decision*: a navigation policy decision should be taken.
58 *   To make a policy decision asynchronously, simply increment the reference count of the
59 *   #Ewk_Navigation_Policy_Decision object using ewk_navigation_policy_decision_ref().
60 * - "policy,decision,new,window", Ewk_Navigation_Policy_Decision*: a new window policy decision should be taken.
61 *   To make a policy decision asynchronously, simply increment the reference count of the
62 *   #Ewk_Navigation_Policy_Decision object using ewk_navigation_policy_decision_ref().
63 * - "text,found", unsigned int*: the requested text was found and it gives the number of matches.
64 * - "title,changed", const char*: title of the main frame was changed.
65 * - "tooltip,text,set", const char*: tooltip was set.
66 * - "tooltip,text,unset", void: tooltip was unset.
67 * - "url,changed", const char*: url of the main frame was changed.
68 * - "vibrate", uint64_t*: request to vibrate. (value is vibration time)
69 * - "webprocess,crashed", Eina_Bool*: expects a @c EINA_TRUE if web process crash is handled; @c EINA_FALSE, otherwise.
70 */
71
72#ifndef ewk_view_h
73#define ewk_view_h
74
75#include "ewk_back_forward_list.h"
76#include "ewk_color_picker.h"
77#include "ewk_context.h"
78#include "ewk_context_menu.h"
79#include "ewk_download_job.h"
80#include "ewk_error.h"
81#include "ewk_page_group.h"
82#include "ewk_popup_menu.h"
83#include "ewk_security_origin.h"
84#include "ewk_touch.h"
85#include "ewk_url_request.h"
86#include "ewk_url_response.h"
87#include "ewk_window_features.h"
88#include <Evas.h>
89
90#ifdef __cplusplus
91extern "C" {
92#endif
93
94/// Enum values containing text directionality values.
95typedef enum {
96    EWK_TEXT_DIRECTION_RIGHT_TO_LEFT,
97    EWK_TEXT_DIRECTION_LEFT_TO_RIGHT
98} Ewk_Text_Direction;
99
100/// Enum values containing page contents type values.
101typedef enum {
102    EWK_PAGE_CONTENTS_TYPE_MHTML,
103    EWK_PAGE_CONTENTS_TYPE_STRING
104} Ewk_Page_Contents_Type;
105
106typedef struct Ewk_View_Smart_Data Ewk_View_Smart_Data;
107typedef struct Ewk_View_Smart_Class Ewk_View_Smart_Class;
108
109/// Ewk view's class, to be overridden by sub-classes.
110struct Ewk_View_Smart_Class {
111    Evas_Smart_Class sc; /**< all but 'data' is free to be changed. */
112    unsigned long version;
113
114    Eina_Bool (*custom_item_selected)(Ewk_View_Smart_Data *sd, Ewk_Context_Menu_Item *item);
115    Eina_Bool (*context_menu_show)(Ewk_View_Smart_Data *sd, Evas_Coord x, Evas_Coord y, Ewk_Context_Menu *menu);
116    Eina_Bool (*context_menu_hide)(Ewk_View_Smart_Data *sd);
117
118    Eina_Bool (*popup_menu_show)(Ewk_View_Smart_Data *sd, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Ewk_Popup_Menu *menu);
119    Eina_Bool (*popup_menu_hide)(Ewk_View_Smart_Data *sd);
120
121    // event handling:
122    //  - returns true if handled
123    //  - if overridden, have to call parent method if desired
124    Eina_Bool (*focus_in)(Ewk_View_Smart_Data *sd);
125    Eina_Bool (*focus_out)(Ewk_View_Smart_Data *sd);
126    Eina_Bool (*fullscreen_enter)(Ewk_View_Smart_Data *sd, Ewk_Security_Origin *origin);
127    Eina_Bool (*fullscreen_exit)(Ewk_View_Smart_Data *sd);
128    Eina_Bool (*mouse_wheel)(Ewk_View_Smart_Data *sd, const Evas_Event_Mouse_Wheel *ev);
129    Eina_Bool (*mouse_down)(Ewk_View_Smart_Data *sd, const Evas_Event_Mouse_Down *ev);
130    Eina_Bool (*mouse_up)(Ewk_View_Smart_Data *sd, const Evas_Event_Mouse_Up *ev);
131    Eina_Bool (*mouse_move)(Ewk_View_Smart_Data *sd, const Evas_Event_Mouse_Move *ev);
132    Eina_Bool (*key_down)(Ewk_View_Smart_Data *sd, const Evas_Event_Key_Down *ev);
133    Eina_Bool (*key_up)(Ewk_View_Smart_Data *sd, const Evas_Event_Key_Up *ev);
134    Eina_Bool (*window_geometry_set)(Ewk_View_Smart_Data *sd, Evas_Coord x, Evas_Coord y, Evas_Coord width, Evas_Coord height);
135    Eina_Bool (*window_geometry_get)(Ewk_View_Smart_Data *sd, Evas_Coord *x, Evas_Coord *y, Evas_Coord *width, Evas_Coord *height);
136
137    // javascript popup:
138    //   - All strings should be guaranteed to be stringshared.
139    void (*run_javascript_alert)(Ewk_View_Smart_Data *sd, const char *message);
140    Eina_Bool (*run_javascript_confirm)(Ewk_View_Smart_Data *sd, const char *message);
141    const char *(*run_javascript_prompt)(Ewk_View_Smart_Data *sd, const char *message, const char *default_value); /**< return string should be stringshared. */
142
143    // color picker:
144    //   - Shows and hides color picker.
145    Eina_Bool (*input_picker_color_request)(Ewk_View_Smart_Data *sd, Ewk_Color_Picker *color_picker);
146    Eina_Bool (*input_picker_color_dismiss)(Ewk_View_Smart_Data *sd);
147
148    // storage:
149    //   - Web database.
150    unsigned long long (*exceeded_database_quota)(Ewk_View_Smart_Data *sd, const char *databaseName, const char *displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage);
151
152    // window creation and closing:
153    //   - Create a new window with specified features and close window.
154    Evas_Object *(*window_create)(Ewk_View_Smart_Data *sd, const Ewk_Window_Features *window_features);
155    void (*window_close)(Ewk_View_Smart_Data *sd);
156};
157
158/**
159 * The version you have to put into the version field
160 * in the @a Ewk_View_Smart_Class structure.
161 */
162#define EWK_VIEW_SMART_CLASS_VERSION 8UL
163
164/**
165 * Initializer for whole Ewk_View_Smart_Class structure.
166 *
167 * @param smart_class_init initializer to use for the "base" field
168 * (Evas_Smart_Class).
169 *
170 * @see EWK_VIEW_SMART_CLASS_INIT_NULL
171 * @see EWK_VIEW_SMART_CLASS_INIT_VERSION
172 * @see EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION
173 */
174#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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
175
176/**
177 * Initializer to zero a whole Ewk_View_Smart_Class structure.
178 *
179 * @see EWK_VIEW_SMART_CLASS_INIT_VERSION
180 * @see EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION
181 * @see EWK_VIEW_SMART_CLASS_INIT
182 */
183#define EWK_VIEW_SMART_CLASS_INIT_NULL EWK_VIEW_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NULL)
184
185/**
186 * Initializer to zero a whole Ewk_View_Smart_Class structure and set
187 * name and version.
188 *
189 * Similar to EWK_VIEW_SMART_CLASS_INIT_NULL, but will set version field of
190 * Evas_Smart_Class (base field) to latest EVAS_SMART_CLASS_VERSION and name
191 * to the specific value.
192 *
193 * It will keep a reference to name field as a "const char *", that is,
194 * name must be available while the structure is used (hint: static or global!)
195 * and will not be modified.
196 *
197 * @see EWK_VIEW_SMART_CLASS_INIT_NULL
198 * @see EWK_VIEW_SMART_CLASS_INIT_VERSION
199 * @see EWK_VIEW_SMART_CLASS_INIT
200 */
201#define EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION(name) EWK_VIEW_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NAME_VERSION(name))
202
203typedef struct EwkView EwkView;
204/**
205 * @brief Contains an internal View data.
206 *
207 * It is to be considered private by users, but may be extended or
208 * changed by sub-classes (that's why it's in public header file).
209 */
210struct Ewk_View_Smart_Data {
211    Evas_Object_Smart_Clipped_Data base;
212    const Ewk_View_Smart_Class* api; /**< reference to casted class instance */
213    Evas_Object* self; /**< reference to owner object */
214    Evas_Object* image; /**< reference to evas_object_image for drawing web contents */
215    EwkView* priv; /**< should never be accessed, c++ stuff */
216    struct {
217        Evas_Coord x, y, w, h; /**< last used viewport */
218    } view;
219    struct { /**< what changed since last smart_calculate */
220        Eina_Bool any:1;
221        Eina_Bool size:1;
222        Eina_Bool position:1;
223    } changed;
224};
225
226/// Creates a type name for Ewk_Download_Job_Error.
227typedef struct Ewk_Download_Job_Error Ewk_Download_Job_Error;
228
229/**
230 * @brief Structure containing details about a download failure.
231 */
232struct Ewk_Download_Job_Error {
233    Ewk_Download_Job *download_job; /**< download that failed */
234    Ewk_Error *error; /**< download error */
235};
236
237/// Creates a type name for Ewk_CSS_Size.
238typedef struct Ewk_CSS_Size Ewk_CSS_Size;
239
240/**
241 * @brief Structure representing size.
242 */
243struct Ewk_CSS_Size {
244    Evas_Coord w; /**< width */
245    Evas_Coord h; /**< height */
246};
247
248/**
249 * Enum values used to specify search options.
250 * @brief   Provides option to find text
251 * @info    Keep this in sync with WKFindOptions.h
252 */
253enum Ewk_Find_Options {
254    EWK_FIND_OPTIONS_NONE, /**< no search flags, this means a case sensitive, no wrap, forward only search. */
255    EWK_FIND_OPTIONS_CASE_INSENSITIVE = 1 << 0, /**< case insensitive search. */
256    EWK_FIND_OPTIONS_AT_WORD_STARTS = 1 << 1, /**< search text only at the beginning of the words. */
257    EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START = 1 << 2, /**< treat capital letters in the middle of words as word start. */
258    EWK_FIND_OPTIONS_BACKWARDS = 1 << 3, /**< search backwards. */
259    EWK_FIND_OPTIONS_WRAP_AROUND = 1 << 4, /**< if not present search will stop at the end of the document. */
260    EWK_FIND_OPTIONS_SHOW_OVERLAY = 1 << 5, /**< show overlay */
261    EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR = 1 << 6, /**< show indicator */
262    EWK_FIND_OPTIONS_SHOW_HIGHLIGHT = 1 << 7 /**< show highlight */
263};
264typedef enum Ewk_Find_Options Ewk_Find_Options;
265
266/**
267 * Enum values used to set pagination mode.
268 */
269typedef enum {
270    EWK_PAGINATION_MODE_INVALID = -1, /**< invalid pagination mode that will be returned when error occured. */
271    EWK_PAGINATION_MODE_UNPAGINATED, /**< default mode for pagination. not paginated  */
272    EWK_PAGINATION_MODE_LEFT_TO_RIGHT, /**< go to the next page with scrolling left to right horizontally. */
273    EWK_PAGINATION_MODE_RIGHT_TO_LEFT, /**< go to the next page with scrolling right to left horizontally. */
274    EWK_PAGINATION_MODE_TOP_TO_BOTTOM, /**< go to the next page with scrolling top to bottom vertically. */
275    EWK_PAGINATION_MODE_BOTTOM_TO_TOP /**< go to the next page with scrolling bottom to top vertically. */
276} Ewk_Pagination_Mode;
277
278/**
279 * @typedef Ewk_View_Script_Execute_Cb Ewk_View_Script_Execute_Cb
280 * @brief Callback type for use with ewk_view_script_execute()
281 */
282typedef void (*Ewk_View_Script_Execute_Cb)(Evas_Object *o, const char *return_value, void *user_data);
283
284/**
285 * Creates a type name for the callback function used to get the page contents.
286 *
287 * @param type type of the contents
288 * @param data string buffer of the contents
289 * @param user_data user data will be passed when ewk_view_page_contents_get is called
290 */
291typedef void (*Ewk_Page_Contents_Cb)(Ewk_Page_Contents_Type type, const char *data, void *user_data);
292
293/**
294 * Sets the smart class APIs, enabling view to be inherited.
295 *
296 * @param api class definition to set, all members with the
297 *        exception of @a Evas_Smart_Class->data may be overridden, must
298 *        @b not be @c NULL
299 *
300 * @note @a Evas_Smart_Class->data is used to implement type checking and
301 *       is not supposed to be changed/overridden. If you need extra
302 *       data for your smart class to work, just extend
303 *       Ewk_View_Smart_Class instead.
304 *       The Evas_Object which inherits the ewk_view should use
305 *       ewk_view_smart_add() to create Evas_Object instead of
306 *       evas_object_smart_add() because it performs additional initialization
307 *       for the ewk_view.
308 *
309 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure (probably
310 *         version mismatch)
311 *
312 * @see ewk_view_smart_add()
313 */
314EAPI Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class *api);
315
316/**
317 * Creates a new EFL WebKit view object with Evas_Smart and Ewk_Context.
318 *
319 * @note The Evas_Object which inherits the ewk_view should create its
320 *       Evas_Object using this API instead of evas_object_smart_add()
321 *       because the default initialization for ewk_view is done in this API.
322 *
323 * @param e canvas object where to create the view object
324 * @param smart Evas_Smart object. Its type should be EWK_VIEW_TYPE_STR
325 * @param context Ewk_Context object which is used for initializing
326 * @param pageGroup Ewk_Page_Group object which is used for initializing
327 *
328 * @return view object on success or @c NULL on failure
329 */
330EAPI Evas_Object *ewk_view_smart_add(Evas *e, Evas_Smart *smart, Ewk_Context *context, Ewk_Page_Group *pageGroup);
331
332/**
333 * Creates a new EFL WebKit view object.
334 *
335 * @param e canvas object where to create the view object
336 *
337 * @return view object on success or @c NULL on failure
338 */
339EAPI Evas_Object *ewk_view_add(Evas *e);
340
341/**
342 * Creates a new EFL WebKit view object based on specific Ewk_Context.
343 *
344 * @param e canvas object where to create the view object
345 * @param context Ewk_Context object to declare process model
346 *
347 * @return view object on success or @c NULL on failure
348 */
349EAPI Evas_Object *ewk_view_add_with_context(Evas *e, Ewk_Context *context);
350
351/**
352 * Gets the Ewk_Context of this view.
353 *
354 * @param o the view object to get the Ewk_Context
355 *
356 * @return the Ewk_Context of this view or @c NULL on failure
357 */
358EAPI Ewk_Context *ewk_view_context_get(const Evas_Object *o);
359
360/**
361 * Gets the Ewk_Page_Group of this view.
362 *
363 * @param o the view object to get the Ewk_Page_Group
364 *
365 * @return the Ewk_Page_Group of this view or @c NULL on failure
366 */
367EAPI Ewk_Page_Group *ewk_view_page_group_get(const Evas_Object *o);
368
369/**
370 * Asks the object to load the given URL.
371 *
372 * @param o view object to load @a URL
373 * @param url uniform resource identifier to load
374 *
375 * @return @c EINA_TRUE is returned if @a o is valid, irrespective of load,
376 *         or @c EINA_FALSE on failure
377 */
378EAPI Eina_Bool ewk_view_url_set(Evas_Object *o, const char *url);
379
380/**
381 * Returns the current URL string of view object.
382 *
383 * It returns an internal string and should not
384 * be modified. The string is guaranteed to be stringshared.
385 *
386 * @param o view object to get current URL
387 *
388 * @return current URL on success or @c NULL on failure
389 */
390EAPI const char *ewk_view_url_get(const Evas_Object *o);
391
392/**
393 * Asks the main frame to reload the current document.
394 *
395 * @param o view object to reload current document
396 *
397 * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise
398 *
399 * @see ewk_view_reload_bypass_cache()
400 */
401EAPI Eina_Bool    ewk_view_reload(Evas_Object *o);
402
403/**
404 * Reloads the current page's document without cache.
405 *
406 * @param o view object to reload current document
407 *
408 * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise
409 */
410EAPI Eina_Bool ewk_view_reload_bypass_cache(Evas_Object *o);
411
412/**
413 * Asks the main frame to stop loading.
414 *
415 * @param o view object to stop loading
416 *
417 * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise.
418 */
419EAPI Eina_Bool    ewk_view_stop(Evas_Object *o);
420
421/**
422 * Asks the main frame to navigate back in the history.
423 *
424 * @param o view object to navigate back
425 *
426 * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise
427 *
428 * @see ewk_frame_back()
429 */
430EAPI Eina_Bool    ewk_view_back(Evas_Object *o);
431
432/**
433 * Asks the main frame to navigate forward in the history.
434 *
435 * @param o view object to navigate forward
436 *
437 * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise
438 *
439 * @see ewk_frame_forward()
440 */
441EAPI Eina_Bool    ewk_view_forward(Evas_Object *o);
442
443/**
444 * Queries if it is possible to navigate backwards one item in the history.
445 *
446 * @param o view object to query if backward navigation is possible
447 *
448 * @return @c EINA_TRUE if it is possible to navigate backwards in the history, @c EINA_FALSE otherwise
449 */
450EAPI Eina_Bool    ewk_view_back_possible(Evas_Object *o);
451
452/**
453 * Queries if it is possible to navigate forwards one item in the history.
454 *
455 * @param o view object to query if forward navigation is possible
456 *
457 * @return @c EINA_TRUE if it is possible to navigate forwards in the history, @c EINA_FALSE otherwise
458 */
459EAPI Eina_Bool    ewk_view_forward_possible(Evas_Object *o);
460
461/**
462 * Gets the back-forward list associated with this view.
463 *
464 * The returned instance is unique for this view and thus multiple calls
465 * to this function with the same view as parameter returns the same
466 * handle. This handle is alive while view is alive, thus one
467 * might want to listen for EVAS_CALLBACK_DEL on given view
468 * (@a o) to know when to stop using returned handle.
469 *
470 * @param o view object to get navigation back-forward list
471 *
472 * @return the back-forward list instance handle associated with this view
473 */
474EAPI Ewk_Back_Forward_List *ewk_view_back_forward_list_get(const Evas_Object *o);
475
476/**
477 * Navigates to specified back-forward list item.
478 *
479 * @param o view object to navigate in the history
480 * @param item the back-forward list item
481 *
482 * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise
483 */
484EAPI Eina_Bool ewk_view_navigate_to(Evas_Object *o, const Ewk_Back_Forward_List_Item *item);
485
486/**
487 * Gets the current title of the main frame.
488 *
489 * It returns an internal string and should not
490 * be modified. The string is guaranteed to be stringshared.
491 *
492 * @param o view object to get current title
493 *
494 * @return current title on success or @c NULL on failure
495 */
496EAPI const char *ewk_view_title_get(const Evas_Object *o);
497
498/**
499 * Gets the current load progress of page.
500 *
501 * The progress estimation from 0.0 to 1.0.
502 *
503 * @param o view object to get the current progress
504 *
505 * @return the load progress of page, value from 0.0 to 1.0,
506 *         or @c -1.0 on failure
507 */
508EAPI double ewk_view_load_progress_get(const Evas_Object *o);
509
510/**
511 * Loads the specified @a html string as the content of the view.
512 *
513 * External objects such as stylesheets or images referenced in the HTML
514 * document are located relative to @a baseUrl.
515 *
516 * If an @a unreachableUrl is passed it is used as the url for the loaded
517 * content. This is typically used to display error pages for a failed
518 * load.
519 *
520 * @param o view object to load the HTML into
521 * @param html HTML data to load
522 * @param baseUrl Base URL used for relative paths to external objects (optional)
523 * @param unreachableUrl URL that could not be reached (optional)
524 *
525 * @return @c EINA_TRUE if it the HTML was successfully loaded, @c EINA_FALSE otherwise
526 */
527EAPI Eina_Bool ewk_view_html_string_load(Evas_Object *o, const char *html, const char *baseUrl, const char *unreachableUrl);
528
529/**
530 * Scales the current page, centered at the given point.
531 *
532 * @param o view object to set the zoom level
533 * @param scale_factor a new level to set
534 * @param cx x of center coordinate
535 * @param cy y of center coordinate
536 *
537 * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise
538 */
539EAPI Eina_Bool ewk_view_scale_set(Evas_Object *o, double scaleFactor, int x, int y);
540
541/**
542 * Queries the current scale factor of the page.
543 *
544 * It returns previous scale factor after ewk_view_scale_set is called immediately
545 * until scale factor of page is really changed.
546 *
547 * @param o view object to get the scale factor
548 *
549 * @return current scale factor in use on success or @c -1.0 on failure
550 */
551EAPI double ewk_view_scale_get(const Evas_Object *o);
552
553/**
554 * Sets zoom of the current page.
555 *
556 * @param o view object to set the zoom level
557 * @param zoom_factor a new level to set
558 *
559 * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise
560 */
561EAPI Eina_Bool ewk_view_page_zoom_set(Evas_Object *o, double zoom_factor);
562
563/**
564 * Queries the current zoom factor of the page.
565 *
566 * It returns previous zoom factor after ewk_view_page_zoom_factor_set is called immediately
567 * until zoom factor of page is really changed.
568 *
569 * @param o view object to get the zoom factor
570 *
571 * @return current zoom factor in use on success or @c -1.0 on failure
572 */
573EAPI double ewk_view_page_zoom_get(const Evas_Object *o);
574
575/**
576 * Queries the ratio between the CSS units and device pixels when the content is unscaled.
577 *
578 * When designing touch-friendly contents, knowing the approximated target size on a device
579 * is important for contents providers in order to get the intented layout and element
580 * sizes.
581 *
582 * As most first generation touch devices had a PPI of approximately 160, this became a
583 * de-facto value, when used in conjunction with the viewport meta tag.
584 *
585 * Devices with a higher PPI learning towards 240 or 320, applies a pre-scaling on all
586 * content, of either 1.5 or 2.0, not affecting the CSS scale or pinch zooming.
587 *
588 * This value can be set using this property and it is exposed to CSS media queries using
589 * the -webkit-device-pixel-ratio query.
590 *
591 * For instance, if you want to load an image without having it upscaled on a web view
592 * using a device pixel ratio of 2.0 it can be done by loading an image of say 100x100
593 * pixels but showing it at half the size.
594 *
595 * @media (-webkit-min-device-pixel-ratio: 1.5) {
596 *     .icon {
597 *         width: 50px;
598 *         height: 50px;
599 *         url: "/images/icon@2x.png"; // This is actually a 100x100 image
600 *     }
601 * }
602 *
603 * If the above is used on a device with device pixel ratio of 1.5, it will be scaled
604 * down but still provide a better looking image.
605 *
606 * @param o view object to get device pixel ratio
607 *
608 * @return the ratio between the CSS units and device pixels,
609 *         or @c -1.0 on failure
610 */
611EAPI float ewk_view_device_pixel_ratio_get(const Evas_Object *o);
612
613/**
614 * Sets the ratio between the CSS units and device pixels when the content is unscaled.
615 *
616 * @param o view object to set device pixel ratio
617 *
618 * @return @c EINA_TRUE if the device pixel ratio was set, @c EINA_FALSE otherwise
619 *
620 * @see ewk_view_device_pixel_ratio_get()
621 */
622EAPI Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object *o, float ratio);
623
624/**
625 * Sets the theme path that will be used by this view.
626 *
627 * This also sets the theme on the main frame. As frames inherit theme
628 * from their parent, this will have all frames with unset theme to
629 * use this one.
630 *
631 * @param o view object to change theme
632 * @param path theme path
633 */
634EAPI void ewk_view_theme_set(Evas_Object *o, const char *path);
635
636/**
637 * Gets the theme set on this view.
638 *
639 * This returns the value set by ewk_view_theme_set().
640 *
641 * @param o view object to get theme path
642 *
643 * @return the theme path, may be @c NULL if not set
644 */
645EAPI const char *ewk_view_theme_get(const Evas_Object *o);
646
647/**
648 * Gets the current custom character encoding name.
649 *
650 * @param o view object to get the current encoding
651 *
652 * @return @c eina_stringshare containing the current encoding, or
653 *         @c NULL if it's not set
654 */
655EAPI const char *ewk_view_custom_encoding_get(const Evas_Object *o);
656
657/**
658 * Sets the custom character encoding and reloads the page.
659 *
660 * @param o view to set the encoding
661 * @param encoding the new encoding to set or @c NULL to restore the default one
662 *
663 * @return @c EINA_TRUE on success @c EINA_FALSE otherwise
664 */
665EAPI Eina_Bool ewk_view_custom_encoding_set(Evas_Object *o, const char *encoding);
666
667/**
668 * Gets the current user agent string.
669 *
670 * @param o view object to get the current user agent
671 *
672 * @return @c eina_stringshare containing the current user agent, or
673 *         @c default user agent if it's not set
674 */
675EAPI const char *ewk_view_user_agent_get(const Evas_Object *o);
676
677/**
678 * Sets the user agent string.
679 *
680 * @param o view to set the user agent
681 * @param user_agent the user agent string to set or @c NULL to restore the default one
682 *
683 * @return @c EINA_TRUE on success @c EINA_FALSE otherwise
684 */
685EAPI Eina_Bool ewk_view_user_agent_set(Evas_Object *o, const char *user_agent);
686
687/**
688 * Searches and hightlights the given string in the document.
689 *
690 * @param o view object to find text
691 * @param text text to find
692 * @param options options to find
693 * @param max_match_count maximum match count to find, unlimited if 0
694 *
695 * @return @c EINA_TRUE on success, @c EINA_FALSE on errors
696 */
697EAPI Eina_Bool ewk_view_text_find(Evas_Object *o, const char *text, Ewk_Find_Options options, unsigned max_match_count);
698
699/**
700 * Clears the highlight of searched text.
701 *
702 * @param o view object to find text
703 *
704 * @return @c EINA_TRUE on success, @c EINA_FALSE on errors
705 */
706EAPI Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object *o);
707
708/**
709 * Counts the given string in the document.
710 *
711 * This does not highlight the matched string and just count the matched string.
712 *
713 * As the search is carried out through the whole document,
714 * only the following EWK_FIND_OPTIONS are valid.
715 *  - EWK_FIND_OPTIONS_NONE
716 *  - EWK_FIND_OPTIONS_CASE_INSENSITIVE
717 *  - EWK_FIND_OPTIONS_AT_WORD_START
718 *  - EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START
719 *
720 * The "text,found" callback will be called with the number of matched string.
721 *
722 * @param o view object to find text
723 * @param text text to find
724 * @param options options to find
725 * @param max_match_count maximum match count to find, unlimited if 0
726 *
727 * @return @c EINA_TRUE on success, @c EINA_FALSE on errors
728 */
729EAPI Eina_Bool ewk_view_text_matches_count(Evas_Object *o, const char *text, Ewk_Find_Options options, unsigned max_match_count);
730
731/**
732 * Sets whether the ewk_view supports the mouse events or not.
733 *
734 * The ewk_view will support the mouse events if EINA_TRUE or not support the
735 * mouse events otherwise. The default value is EINA_TRUE.
736 *
737 * @param o view object to enable/disable the mouse events
738 * @param enabled a state to set
739 *
740 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
741 */
742EAPI Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object *o, Eina_Bool enabled);
743
744/**
745 * Queries if the ewk_view supports the mouse events.
746 *
747 * @param o view object to query if the mouse events are enabled
748 *
749 * @return @c EINA_TRUE if the mouse events are enabled or @c EINA_FALSE otherwise
750 */
751EAPI Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object *o);
752
753/**
754 * Feeds the touch event to the view.
755 *
756 * @param o view object to feed touch event
757 * @param type the type of touch event
758 * @param points a list of points (Ewk_Touch_Point) to process
759 * @param modifiers an Evas_Modifier handle to the list of modifier keys
760 *        registered in the Evas. Users can get the Evas_Modifier from the Evas
761 *        using evas_key_modifier_get() and can set each modifier key using
762 *        evas_key_modifier_on() and evas_key_modifier_off()
763 *
764 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
765 */
766EAPI Eina_Bool ewk_view_feed_touch_event(Evas_Object *o, Ewk_Touch_Event_Type type, const Eina_List *points, const Evas_Modifier *modifiers);
767
768/**
769 * Sets whether the ewk_view supports the touch events or not.
770 *
771 * The ewk_view will support the touch events if @c EINA_TRUE or not support the
772 * touch events otherwise. The default value is @c EINA_FALSE.
773 *
774 * @param o view object to enable/disable the touch events
775 * @param enabled a state to set
776 *
777 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
778 */
779EAPI Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object *o, Eina_Bool enabled);
780
781/**
782 * Queries if the ewk_view supports the touch events.
783 *
784 * @param o view object to query if the touch events are enabled
785 *
786 * @return @c EINA_TRUE if the touch events are enabled or @c EINA_FALSE otherwise
787 */
788EAPI Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object *o);
789
790/**
791 * Show the inspector to debug a web page.
792 *
793 * @param o The view to show the inspector.
794 *
795 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
796 *
797 * @see ewk_settings_developer_extras_enabled_set()
798 */
799EAPI Eina_Bool ewk_view_inspector_show(Evas_Object *o);
800
801/**
802 * Close the inspector
803 *
804 * @param o The view to close the inspector.
805 *
806 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
807 */
808EAPI Eina_Bool ewk_view_inspector_close(Evas_Object *o);
809
810/**
811 * Set pagination mode to the current web page.
812 *
813 * @param o view object to set the pagenation mode
814 * @param mode The Ewk_Pagination_Mode to set
815 *
816 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
817 */
818EAPI Eina_Bool ewk_view_pagination_mode_set(Evas_Object *o, Ewk_Pagination_Mode mode);
819
820/**
821 * Get pagination mode of the current web page.
822 *
823 * The default value is EWK_PAGINATION_MODE_UNPAGINATED.
824 * When error occured, EWK_PAGINATION_MODE_INVALID is returned.
825 *
826 * @param o view object to get the pagination mode
827 *
828 * @return The pagination mode of the current web page
829 */
830EAPI Ewk_Pagination_Mode ewk_view_pagination_mode_get(const Evas_Object *o);
831
832/**
833 * Exit fullscreen mode.
834 *
835 * @param o view object where to exit fullscreen
836 *
837 * @return @c EINA_TRUE if successful, @c EINA_FALSE otherwise
838 */
839EAPI Eina_Bool ewk_view_fullscreen_exit(Evas_Object *o);
840
841/**
842 * Get contents of the current web page.
843 *
844 * @param o view object to get the page contents
845 * @param type type of the page contents
846 * @param callback callback function to be called when the operation is finished
847 * @param user_data user data to be passed to the callback function
848 *
849 * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise
850 */
851EAPI Eina_Bool ewk_view_page_contents_get(const Evas_Object *o, Ewk_Page_Contents_Type type, Ewk_Page_Contents_Cb callback, void *user_data);
852
853/**
854 * Requests execution of the given script.
855 *
856 * The result value for the execution can be retrieved from the asynchronous callback.
857 *
858 * @param o The view to execute script
859 * @param script JavaScript to execute
860 * @param callback The function to call when the execution is completed, may be @c NULL
861 * @param user_data User data, may be @c NULL
862 *
863 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
864 */
865EAPI Eina_Bool ewk_view_script_execute(Evas_Object *o, const char *script, Ewk_View_Script_Execute_Cb callback, void *user_data);
866
867/**
868 * Sets whether the ewk_view use fixed layout or not.
869 *
870 * The webview will use fixed layout if EINA_TRUE or not use it otherwise.
871 * The default value is EINA_FALSE.
872 *
873 * @param o view object to set fixed layout
874 * @param enabled a state to set
875 *
876 * @return @c EINA_TRUE on success, or @c EINA_FALSE on failure
877 */
878EAPI Eina_Bool ewk_view_layout_fixed_set(Evas_Object *o, Eina_Bool enabled);
879
880/**
881 * Queries if the webview is using fixed layout.
882 *
883 * @param o view object to query the status
884 *
885 * @return @c EINA_TRUE if the webview is using fixed layout, or
886 *         @c EINA_FALSE otherwise
887 */
888EAPI Eina_Bool ewk_view_layout_fixed_get(const Evas_Object *o);
889
890/**
891 * Sets size of fixed layout to web page.
892 *
893 * The webview size will be set with given size.
894 *
895 * @param o view object to set fixed layout
896 * @param width an integer value in which to set width of fixed layout
897 * @param height an integer value in which to set height of fixed layout
898 */
899EAPI void ewk_view_layout_fixed_size_set(const Evas_Object *o, Evas_Coord width, Evas_Coord height);
900
901/**
902 * Gets the fixed layout size of current web page.
903 *
904 * @param o view object to query the size
905 *
906 * @param width pointer to an integer value in which to get the width of fixed layout
907 * @param height pointer to an integer value in which to get the height of fixed layout
908 */
909EAPI void ewk_view_layout_fixed_size_get(const Evas_Object *o, Evas_Coord *width, Evas_Coord *height);
910
911/**
912 * Sets the background color and transparency of the view.
913 *
914 * @param o view object to change the background color
915 * @param r red color component
916 * @param g green color component
917 * @param b blue color component
918 * @param a transparency
919 */
920EAPI void ewk_view_bg_color_set(Evas_Object *o, int r, int g, int b, int a);
921
922/**
923 * Gets the background color of the view.
924 *
925 * @param o view object to get the background color
926 * @param r the pointer to store red color component
927 * @param g the pointer to store green color component
928 * @param b the pointer to store blue color component
929 * @param a the pointer to store alpha value
930 */
931EAPI void ewk_view_bg_color_get(const Evas_Object *o, int *r, int *g, int *b, int *a);
932
933/**
934 * Get contents size of current web page.
935 *
936 * If it fails to get the content size, the width and height will be set to 0.
937 *
938 * @param o view object to get contents size
939 * @param width pointer to an integer in which to store the width of contents.
940 * @param height pointer to an integer in which to store the height of contents.
941 *
942 * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise
943 */
944EAPI Eina_Bool ewk_view_contents_size_get(const Evas_Object *o, Evas_Coord *width, Evas_Coord *height);
945
946#ifdef __cplusplus
947}
948#endif
949#endif // ewk_view_h
950