Remove deprecated old Reader code
[framework/web/webkit-efl.git] / Source / WebKit / efl / ewk / ewk_view.cpp
1 /*
2     Copyright (C) 2009-2010 ProFUSION embedded systems
3     Copyright (C) 2009-2012 Samsung Electronics
4     Copyright (C) 2012 Intel Corporation
5
6     This library is free software; you can redistribute it and/or
7     modify it under the terms of the GNU Library General Public
8     License as published by the Free Software Foundation; either
9     version 2 of the License, or (at your option) any later version.
10
11     This library is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14     Library General Public License for more details.
15
16     You should have received a copy of the GNU Library General Public License
17     along with this library; see the file COPYING.LIB.  If not, write to
18     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19     Boston, MA 02110-1301, USA.
20 */
21 #define __STDC_FORMAT_MACROS
22 #include "config.h"
23 #include "ewk_view.h"
24
25 #include "BackForwardListImpl.h"
26 #include "Bridge.h"
27 #include "Chrome.h"
28 #include "ChromeClientEfl.h"
29 #include "ContextMenuController.h"
30 #include "DocumentLoader.h"
31 #include "DragClientEfl.h"
32 #include "EditorClientEfl.h"
33 #include "EflScreenUtilities.h"
34 #include "EventHandler.h"
35 #include "FocusController.h"
36 #include "FrameLoaderClientEfl.h"
37 #include "FrameView.h"
38 #include "GraphicsContext.h"
39 #include "HTMLElement.h"
40 #include "HTMLInputElement.h"
41 #include "HTMLNames.h"
42 #if ENABLE(TIZEN_PAGE_CACHE)
43 #include "HistoryItem.h"
44 #endif
45 #include "InspectorClientEfl.h"
46 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
47 #include "InspectorController.h"
48 #include "InspectorServerEfl.h"
49 #endif
50 #include "IntSize.h"
51 #include "JSDOMBinding.h"
52 #include "JSDOMWindow.h"
53 #include "JSLock.h"
54 #include "LayoutTypes.h"
55 #include "PageClientEfl.h"
56 #include "PageGroup.h"
57 #include "PlatformMouseEvent.h"
58 #include "PopupMenuClient.h"
59 #include "ProgressTracker.h"
60 #include "RefPtrCairo.h"
61 #include "RenderTheme.h"
62 #include "ResourceHandle.h"
63 #include "Settings.h"
64 #include "c_instance.h"
65 #include "ewk_frame.h"
66 #include "ewk_frame_private.h"
67 #include "ewk_history_private.h"
68 #include "ewk_js_private.h"
69 #include "ewk_private.h"
70 #include "ewk_settings_private.h"
71 #include "ewk_view_private.h"
72 #include "ewk_window_features_private.h"
73 #include <Ecore.h>
74 #include <Ecore_Evas.h>
75 #include <Edje.h>
76 #include <Eina.h>
77 #include <Evas.h>
78 #include <eina_safety_checks.h>
79 #include <inttypes.h>
80 #include <libsoup/soup-session.h>
81 #include <limits>
82 #include <math.h>
83 #include <sys/time.h>
84
85 #if ENABLE(DEVICE_ORIENTATION)
86 #include "DeviceMotionClientEfl.h"
87 #include "DeviceOrientationClientEfl.h"
88 #endif
89
90 #if ENABLE(BATTERY_STATUS)
91 #include "BatteryClientEfl.h"
92 #endif
93
94 #if ENABLE(TIZEN_DYNAMIC_LOADED_PLUGINS) || ENABLE(TIZEN_ON_OFF_SPECIFIED_PLUGINS)
95 #include "PluginDatabase.h"
96 #include "PluginPackage.h"
97 #endif
98
99 #if ENABLE(TIZEN_JS_EXT_API)
100 #include "JSStringRef.h"
101 #include <wtf/Vector.h>
102 #endif
103
104 #if ENABLE(TIZEN_EFL_EXT_API)
105 #include "CachedImage.h"
106 #include "HTMLCollection.h"
107 #include "HTMLImageElement.h"
108 #include "HTMLOptionElement.h"
109 #include "HTMLOptionsCollection.h"
110 #include "HTMLSelectElement.h"
111 #include "HitTestRequest.h"
112 #include "HitTestResult.h"
113 #include "Image.h"
114 #include "KURL.h"
115 #include "MemoryCache.h" // needed by ewk_webcore_cache_clean function
116 #include "MouseEventWithHitTestResults.h"
117 #include "NamedNodeMap.h"
118 #include "SharedBuffer.h"
119 #endif
120
121 #if ENABLE(NETSCAPE_PLUGIN_API)
122 #if ENABLE(TIZEN_SUPPORT_PLUGINS)
123 #include "PluginView.h"
124 #endif
125 #if ENABLE(TIZEN_NPAPI)
126 #include "HTMLObjectElement.h"
127 #include "HTMLPlugInElement.h"
128 #define FLASH_CLASS_ID "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
129 #define FLASH_SERVICE_TYPE "application/x-shockwave-flash"
130 #endif
131 #endif
132
133 #if ENABLE(TIZEN_PASSWORD_MANAGER)
134 #include "HTMLFormElement.h"
135 #endif
136
137 #if ENABLE(TIZEN_PAUSE_NETWORK)
138 #include "HTMLMediaElement.h"
139 #include "HTMLVideoElement.h"
140 #include "MainResourceLoader.h"
141 #include "MediaPlayer.h"
142 #include "NodeList.h"
143 #include "ResourceHandleInternal.h"
144 #endif
145
146 #if ENABLE(TIZEN_WEBCORE_SELECTIVE_RENDERING)
147 #include "IntRect.h"
148 #endif
149
150 #if ENABLE(TIZEN_SUPPORT_RSS_LINK_PARSING)
151 #include "HTMLAllCollection.h"
152 #include "HTMLLinkElement.h"
153 #endif
154
155 #if USE(ACCELERATED_COMPOSITING) && ENABLE(TIZEN_ACCELERATED_COMPOSITING)
156     #include "AcceleratedCompositor.h"
157 #endif
158
159 #if ENABLE(TIZEN_INSTALL_CONTENT)
160 #include "InstallContentClientEfl.h"
161 #endif
162
163 #if ENABLE(TIZEN_ISF_PORT)
164 #include <Ecore_IMF_Evas.h>
165 #endif
166
167 #if ENABLE(TIZEN_DROPDOWN_SUPPORT)
168 #include "KeyboardEvent.h"
169 #endif
170
171 #if ENABLE(TIZEN_CONTEXT_MENU)
172 #include "ContextMenuClientEfl.h"
173 #endif
174
175 #if ENABLE(TIZEN_IMAGE_PASTE)
176 #include "Base64.h"
177 #endif
178
179 #if USE(SKIA)
180 #include "PlatformContextSkia.h"
181 #include "SkBitmap.h"
182 #include "SkImageEncoder.h"
183
184 #include "platform_canvas.h"
185 #endif
186
187 #if ENABLE(TIZEN_RENDERING_PROFILE_TEST)
188 #include "TizenProfiler.h"
189 #endif // ENABLE(TIZEN_RENDERING_PROFILE_TEST)
190
191 #if ENABLE(TIZEN_RECORDING_SURFACE)
192 #include "ewk_recording_surface_set.h"
193 #endif
194
195 #if ENABLE(TIZEN_NOTIFICATION)
196 #if ENABLE(NOTIFICATIONS)
197 #include "NotificationController.h"
198 #include "NotificationClientEfl.h"
199 #endif
200 #endif
201
202 #if ENABLE(VIBRATION)
203 #include "VibrationClientEfl.h"
204 #endif
205
206 #if ENABLE(BATTERY_STATUS)
207 #include "BatteryClientEfl.h"
208 #endif
209
210 #if USE(ACCELERATED_COMPOSITING)
211 #include "NotImplemented.h"
212 #endif
213
214 #if ENABLE(NETWORK_INFO)
215 #include "NetworkInfoClientEfl.h"
216 #endif
217
218 #if ENABLE(INPUT_TYPE_COLOR)
219 #include "ColorChooserClient.h"
220 #endif
221
222 static const float zoomMinimum = 0.05;
223 static const float zoomMaximum = 4.0;
224
225 static const float devicePixelRatio = 1.0;
226
227 #define CENTI_PER_INCH 2.54
228
229 #if ENABLE(TIZEN_BG_RECT_SUPPORT)
230 #define ZOOM_BOUNCE_LIMIT_RATIO (0.25f)
231 #endif
232
233 #if ENABLE(CDOM_BINDINGS)
234 #include "WebKitDOM_Defines.h"
235 #include "WebKitDOM_Object.h"
236 #include "WebKitDOM_Document.h"
237 #include "WebKitDOM_Document_Private.h"
238 #endif
239
240 #if ENABLE(TIZEN_PARAGRAPH_SELECTION)
241 #include "RenderThemeEfl.h"
242 #endif
243
244 #if ENABLE(TIZEN_PLUGIN_PARENT_WINDOW)
245 #include <Ecore_Evas.h>
246 #endif
247
248 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
249 #include "HTMLLinkElement.h"
250 #include "HTMLMetaElement.h"
251 #endif
252
253 static const char ewkViewTypeString[] = "EWK_View";
254
255 static const size_t ewkViewRepaintsSizeInitial = 32;
256 static const size_t ewkViewRepaintsSizeStep = 8;
257 static const size_t ewkViewRepaintsSizeMaximumFree = 64;
258
259 static const size_t ewkViewScrollsSizeInitial = 8;
260 static const size_t ewkViewScrollsSizeStep = 2;
261 static const size_t ewkViewScrollsSizeMaximumFree = 32;
262 #if !ENABLE(TIZEN_DAILY_UPVERSIONING)
263 static const Evas_Smart_Cb_Description _ewk_view_callback_names[] = {
264     { "colorchooser,create", "(yyyy)" },
265     { "colorchooser,willdelete", "" },
266     { "colorchooser,color,changed", "(yyyy)" },
267     { "download,request", "p" },
268     { "editorclient,contents,changed", "" },
269     { "editorclient,selection,changed", "" },
270     { "frame,created", "p" },
271     { "icon,received", "" },
272     { "inputmethod,changed", "b" },
273     { "js,windowobject,clear", "" },
274     { "link,hover,in", "p" },
275     { "link,hover,out", "" },
276     { "load,document,finished", "p" },
277     { "load,error", "p" },
278     { "load,finished", "p" },
279     { "load,newwindow,show", "" },
280     { "load,progress", "d" },
281     { "load,provisional", "" },
282     { "load,started", "" },
283     { "menubar,visible,get", "b" },
284     { "menubar,visible,set", "b" },
285     { "popup,created", "p" },
286     { "popup,willdelete", "p" },
287     { "ready", "" },
288     { "scrollbars,visible,get", "b" },
289     { "scrollbars,visible,set", "b" },
290     { "statusbar,text,set", "s" },
291     { "statusbar,visible,get", "b" },
292     { "statusbar,visible,set", "b" },
293     { "title,changed", "s" },
294     { "toolbars,visible,get", "b" },
295     { "toolbars,visible,set", "b" },
296     { "tooltip,text,set", "s" },
297     { "uri,changed", "s" },
298     { "view,resized", "" },
299     { "zoom,animated,end", "" },
300     { 0, 0 }
301 };
302 #endif
303 /**
304  * @brief Private data that is used internally by EFL Port Page Cache
305  * and should never be modified from outside.
306  *
307  * @internal
308  */
309 #if ENABLE(TIZEN_PAGE_CACHE)
310 struct Ewk_View_Pagecache_Data {
311     Eina_Bool isRestored;
312     float zoomLevel;
313     WebCore::IntPoint scrollPos;
314 };
315 #endif
316
317 struct EditorCommand {
318     Ewk_Editor_Command ewkEditorCommand;
319     const char* editorCommandString;
320 };
321
322 /**
323  * @brief A table grouping Ewk_Editor_Command enums with corresponding command
324  * strings used by WebCore::EditorCommand, keeping both in sync.
325  *
326  * @internal
327  */
328 static const EditorCommand editorCommands[] = {
329     { EWK_EDITOR_COMMAND_UNDO, "Undo" },
330     { EWK_EDITOR_COMMAND_REDO, "Redo" },
331     { EWK_EDITOR_COMMAND_TOGGLE_BOLD, "ToggleBold" },
332     { EWK_EDITOR_COMMAND_TOGGLE_ITALIC, "ToggleItalic" },
333     { EWK_EDITOR_COMMAND_TOGGLE_UNDERLINE, "ToggleUnderline" },
334     { EWK_EDITOR_COMMAND_TOGGLE_STRIKETHROUGH, "Strikethrough" },
335     { EWK_EDITOR_COMMAND_TOGGLE_SUBSCRIPT, "SubScript" },
336     { EWK_EDITOR_COMMAND_TOGGLE_SUPERSCRIPT, "SuperScript" },
337     { EWK_EDITOR_COMMAND_INDENT, "Indent" },
338     { EWK_EDITOR_COMMAND_OUTDENT, "Outdent" },
339     { EWK_EDITOR_COMMAND_INSERT_ORDEREDLIST, "InsertOrderedList" },
340     { EWK_EDITOR_COMMAND_INSERT_UNORDEREDLIST, "InsertUnorderedList" },
341     { EWK_EDITOR_COMMAND_INSERT_IMAGE, "InsertImage" },
342     { EWK_EDITOR_COMMAND_INSERT_TEXT, "InsertText" },
343     { EWK_EDITOR_COMMAND_INSERT_HTML, "InsertHTML" },
344     { EWK_EDITOR_COMMAND_INSERT_PARAGRAPH, "InsertParagraph" },
345     { EWK_EDITOR_COMMAND_INSERT_PARAGRAPH_SEPARATOR, "InsertNewLine" },
346     { EWK_EDITOR_COMMAND_INSERT_LINE_SEPARATOR, "InsertLineBreak" },
347     { EWK_EDITOR_COMMAND_BACK_COLOR, "BackColor" },
348     { EWK_EDITOR_COMMAND_FORE_COLOR, "ForeColor" },
349     { EWK_EDITOR_COMMAND_HILITE_COLOR, "HiliteColor" },
350     { EWK_EDITOR_COMMAND_FONT_SIZE, "FontSize" },
351     { EWK_EDITOR_COMMAND_ALIGN_CENTER, "AlignCenter" },
352     { EWK_EDITOR_COMMAND_ALIGN_JUSTIFIED, "AlignJustified" },
353     { EWK_EDITOR_COMMAND_ALIGN_LEFT, "AlignLeft" },
354     { EWK_EDITOR_COMMAND_ALIGN_RIGHT, "AlignRight" },
355     { EWK_EDITOR_COMMAND_MOVE_TO_NEXT_CHAR, "MoveForward" },
356     { EWK_EDITOR_COMMAND_MOVE_TO_PREVIOUS_CHAR, "MoveBackward" },
357     { EWK_EDITOR_COMMAND_MOVE_TO_NEXT_WORD, "MoveWordForward" },
358     { EWK_EDITOR_COMMAND_MOVE_TO_PREVIOUS_WORD, "MoveWordBackward" },
359     { EWK_EDITOR_COMMAND_MOVE_TO_NEXT_LINE, "MoveDown" },
360     { EWK_EDITOR_COMMAND_MOVE_TO_PREVIOUS_LINE, "MoveUp" },
361     { EWK_EDITOR_COMMAND_MOVE_TO_BEGINNING_OF_LINE, "MoveToBeginningOfLine" },
362     { EWK_EDITOR_COMMAND_MOVE_TO_END_OF_LINE, "MoveToEndOfLine" },
363     { EWK_EDITOR_COMMAND_MOVE_TO_BEGINNING_OF_PARAGRAPH, "MoveToBeginningOfParagraph" },
364     { EWK_EDITOR_COMMAND_MOVE_TO_END_OF_PARAGRAPH, "MoveToEndOfParagraph" },
365     { EWK_EDITOR_COMMAND_MOVE_TO_BEGINNING_OF_DOCUMENT, "MoveToBeginningOfDocument" },
366     { EWK_EDITOR_COMMAND_MOVE_TO_END_OF_DOCUMENT, "MoveToEndOfDocument" },
367     { EWK_EDITOR_COMMAND_SELECT_NONE, "SelectNone" },
368     { EWK_EDITOR_COMMAND_SELECT_ALL, "SelectAll" },
369     { EWK_EDITOR_COMMAND_SELECT_PARAGRAPH, "SelectParagraph" },
370     { EWK_EDITOR_COMMAND_SELECT_SENTENCE, "SelectSentence" },
371     { EWK_EDITOR_COMMAND_SELECT_LINE, "SelectLine" },
372     { EWK_EDITOR_COMMAND_SELECT_WORD, "SelectWord" },
373     { EWK_EDITOR_COMMAND_SELECT_NEXT_CHAR, "MoveForwardAndModifySelection" },
374     { EWK_EDITOR_COMMAND_SELECT_PREVIOUS_CHAR, "MoveBackwardAndModifySelection" },
375     { EWK_EDITOR_COMMAND_SELECT_NEXT_WORD, "MoveWordForwardAndModifySelection" },
376     { EWK_EDITOR_COMMAND_SELECT_PREVIOUS_WORD, "MoveWordBackwardAndModifySelection" },
377     { EWK_EDITOR_COMMAND_SELECT_NEXT_LINE, "MoveDownAndModifySelection" },
378     { EWK_EDITOR_COMMAND_SELECT_PREVIOUS_LINE, "MoveUpAndModifySelection" },
379     { EWK_EDITOR_COMMAND_SELECT_START_OF_LINE, "MoveToBeginningOfLineAndModifySelection" },
380     { EWK_EDITOR_COMMAND_SELECT_END_OF_LINE, "MoveToEndOfLineAndModifySelection" },
381     { EWK_EDITOR_COMMAND_SELECT_START_OF_PARAGRAPH, "MoveToBeginningOfParagraphAndModifySelection" },
382     { EWK_EDITOR_COMMAND_SELECT_END_OF_PARAGRAPH, "MoveToEndOfParagraphAndModifySelection" },
383     { EWK_EDITOR_COMMAND_SELECT_START_OF_DOCUMENT, "MoveToBeginningOfDocumentAndModifySelection" },
384     { EWK_EDITOR_COMMAND_SELECT_END_OF_DOCUMENT, "MoveToEndOfDocumentAndModifySelection" },
385     { EWK_EDITOR_COMMAND_DELETE_WORD_BACKWARD, "DeleteWordBackward" },
386     { EWK_EDITOR_COMMAND_DELETE_WORD_FORWARD, "DeleteWordForward" },
387     { EWK_EDITOR_COMMAND_NONE, 0 } // EWK_EDITOR_COMMAND_NONE must be the last element.
388 };
389
390 >>>>>>> 7933b20e3b4cf85cba3b092c5effe184f784be72
391 /**
392  * @brief Private data that is used internally by EFL WebKit
393  * and should never be modified from outside.
394  *
395  * @internal
396  */
397 struct _Ewk_View_Private_Data {
398     OwnPtr<WebCore::Page> page;
399     WebCore::Settings* pageSettings;
400     WebCore::Frame* mainFrame;
401     WebCore::ViewportArguments viewportArguments;
402 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
403     Ewk_Viewport_Attributes viewportAttributes;
404 #endif
405 #if ENABLE(TIZEN_ISF_PORT)
406     Ecore_IMF_Context* imContext;
407 #endif
408     Ewk_History* history;
409     OwnPtr<PageClientEfl> pageClient;
410 #if ENABLE(NETWORK_INFO)
411     OwnPtr<WebCore::NetworkInfoClientEfl> networkInfoClient;
412 #endif
413 #if ENABLE(INPUT_TYPE_COLOR)
414     WebCore::ColorChooserClient* colorChooserClient;
415 #endif
416 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
417     Ewk_Screen_Orientation orientation;
418 #endif
419     struct {
420         Ewk_Menu menu;
421         WebCore::PopupMenuClient* menuClient;
422     } popup;
423 #if USE(ACCELERATED_COMPOSITING) && ENABLE(TIZEN_ACCELERATED_COMPOSITING)
424     OwnPtr<WebCore::AcceleratedCompositor> compositor;
425     Evas_Object* compositingSurface;
426     bool compositingActive;
427 #endif
428     struct {
429         Eina_Rectangle* array;
430         size_t count;
431         size_t allocated;
432     } repaints;
433     struct {
434         Ewk_Scroll_Request* array;
435         size_t count;
436         size_t allocated;
437     } scrolls;
438     unsigned int imh; /**< input method hints */
439     struct {
440         bool viewCleared : 1;
441 #if ENABLE(TIZEN_VIEW_ACTIVE_SET)
442         bool active:1;
443 #endif
444         bool needTouchEvents : 1;
445         bool hasDisplayedMixedContent : 1;
446         bool hasRunMixedContent : 1;
447     } flags;
448     struct {
449         const char* userAgent;
450         const char* userStylesheet;
451         const char* encodingDefault;
452         const char* encodingCustom;
453         const char* theme;
454         const char* localStorageDatabasePath;
455         int fontMinimumSize;
456         int fontMinimumLogicalSize;
457         int fontDefaultSize;
458         int fontMonospaceSize;
459         const char* fontStandard;
460         const char* fontCursive;
461         const char* fontMonospace;
462         const char* fontFantasy;
463         const char* fontSerif;
464         const char* fontSansSerif;
465         bool autoLoadImages : 1;
466         bool autoShrinkImages : 1;
467         bool enableAutoResizeWindow : 1;
468         bool enableDeveloperExtras : 1;
469         bool enableScripts : 1;
470         bool enablePlugins : 1;
471         bool enableFrameFlattening : 1;
472         bool encodingDetector : 1;
473         bool hyperlinkAuditingEnabled : 1;
474         bool scriptsCanOpenWindows : 1;
475         bool scriptsCanCloseWindows : 1;
476 #if ENABLE(VIDEO_TRACK)
477         bool shouldDisplayCaptions : 1;
478         bool shouldDisplaySubtitles : 1;
479         bool shouldDisplayTextDescriptions: 1;
480 #endif
481         bool scriptsCanAccessClipboard : 1;
482         bool resizableTextareas : 1;
483         bool privateBrowsing : 1;
484         bool caretBrowsing : 1;
485         bool spatialNavigation : 1;
486         bool localStorage : 1;
487 #if ENABLE(TIZEN_WEB_AUDIO)
488         bool webAudio:1;
489 #endif
490         bool offlineAppCache : 1;
491         bool pageCache : 1;
492 #if ENABLE(TIZEN_ONSCROLL_EVENT_SUPPRESSION)
493         Eina_Bool enableOnscrollEventSuppression : 1;
494 #endif
495 #if ENABLE(TIZEN_WEBKIT_EFL_DRT)
496         Eina_Bool scriptsWindowClose : 1;
497 #endif
498         bool enableXSSAuditor : 1;
499 #if ENABLE(WEB_AUDIO)
500         bool webAudio : 1;
501 #endif
502         bool webGLEnabled : 1;
503         bool tabsToLinks : 1;
504         struct {
505             float minScale;
506             float maxScale;
507             Eina_Bool userScalable : 1;
508         } zoomRange;
509         float devicePixelRatio;
510         double domTimerInterval;
511 #if ENABLE(TIZEN_CUSTOM_HEADERS)
512         WebCore::HTTPHeaderMap customHeaders;
513 #endif
514 #if ENABLE(TIZEN_GEOLOCATION)
515         Eina_Bool geolocation:1;
516 #endif
517 #if ENABLE(TIZEN_EDITABLE_LINK_ACTIVE_SET)
518         Eina_Bool editableLinkBehavior:1;
519 #endif
520 #if ENABLE(TIZEN_SUPPORT_PLUGINS) && ENABLE(TIZEN_DONT_PAN_OVER_SOME_PLUGINS)
521         Eina_Bool blockPanning: 1;
522 #endif
523 #if ENABLE(TIZEN_PLUGIN_PARENT_WINDOW)
524       Evas_Object* parentWindow; /**< application's window used by flash engine to popups and ui gadgets */
525 #endif
526 #if ENABLE(TIZEN_CSS_FIXED_AS_ABSOLUTE)
527         Eina_Bool fixedAsAbsolute: 1;
528 #endif
529 #if ENABLE(TIZEN_CSS_FIXED_FAST_PATH)
530         Eina_Bool fixedFastPath: 1;
531 #endif
532 #if ENABLE(TIZEN_AUTOFOCUS_BLOCK)
533         Eina_Bool showImeOnAutofocus: 1;
534 #endif
535 #if ENABLE(TIZEN_FOCUS_RING)
536         Eina_Bool enableFocusRing: 1;
537 #endif
538     } settings;
539     struct {
540         struct {
541             double start;
542             double end;
543             double duration;
544         } time;
545         struct {
546             float start;
547             float end;
548             float range;
549         } zoom;
550         struct {
551             Evas_Coord x, y;
552         } center;
553         Ecore_Animator* animator;
554     } animatedZoom;
555     SoupSession* soupSession;
556 #if ENABLE(TIZEN_DROPDOWN_SUPPORT)
557     WebCore::Node* currentSelectedNode;
558 #endif
559 #if ENABLE(TIZEN_FORM_SUBMIT_SUPPORT)
560     Evas_Object* formWindow;
561     const char* frameName;
562 #endif
563 #if ENABLE(TIZEN_WEBCORE_SELECTIVE_RENDERING)
564     Eina_Bool delaysHeavyTiles;
565 #endif
566 #if ENABLE(TIZEN_PAGE_CACHE)
567     Ewk_View_Pagecache_Data cachedPageData;
568 #endif
569 #if ENABLE(TIZEN_RECORDING_SURFACE)
570     Eina_Bool callOnceAfterLoadFinished;
571     Eina_Bool recordingSurfaceEnable;
572     Eina_List * recordingSurfaceSetList;
573     int recordingSurfaceSetState;
574     Eina_Bool recordingSurfaceSetLoadFinished;
575     Eina_Bool recordingSurfaceSetScrollState;
576 #endif
577     const char* cursorGroup;
578     Evas_Object* cursorObject;
579 #ifdef HAVE_ECORE_X
580     bool isUsingEcoreX;
581 #endif
582 };
583
584 #if ENABLE(TIZEN_SMART_CLASS_TYPE_STR)
585
586 #ifndef EWK_TYPE_CHECK
587 #define EWK_VIEW_TYPE_CHECK(ewkView, ...) do { } while (0)
588 #else
589 #define EWK_VIEW_TYPE_CHECK(ewkView, ...)                                     \
590     do {                                                                \
591         const char *_tmp_otype = evas_object_type_get(ewkView);               \
592         const Evas_Smart *_tmp_s = evas_object_smart_smart_get(ewkView);      \
593         if (EINA_UNLIKELY(!_tmp_s)) {                                   \
594             EINA_LOG_CRIT                                               \
595                 ("%p (%s) is not a smart object!", ewkView,                   \
596                  _tmp_otype ? _tmp_otype : "(null)");                   \
597             return __VA_ARGS__;                                         \
598         }                                                               \
599         const Evas_Smart_Class *_tmp_sc = evas_smart_class_get(_tmp_s); \
600         if (EINA_UNLIKELY(!_tmp_sc)) {                                  \
601             EINA_LOG_CRIT                                               \
602                 ("%p (%s) is not a smart object!", ewkView,                   \
603                  _tmp_otype ? _tmp_otype : "(null)");                   \
604             return __VA_ARGS__;                                         \
605         }                                                               \
606         if (EINA_UNLIKELY(!_tmp_sc->data)) {                            \
607             EINA_LOG_CRIT("%p (null) is not of an ewk_view", ewkView);        \
608             return __VA_ARGS__;                                         \
609         }                                                               \
610         if (EINA_UNLIKELY(strncmp((char*)_tmp_sc->data, ewkViewTypeString, strlen(ewkViewTypeString)))) {        \
611             EINA_LOG_CRIT                                               \
612                 ("%p (%s) is not of an ewk_view (need %p, got %p)!",    \
613                  ewkView, _tmp_otype ? _tmp_otype : "(null)",                 \
614                  ewkViewTypeString, _tmp_sc->data);                     \
615             return __VA_ARGS__;                                         \
616         }                                                               \
617     } while (0)
618 #endif
619
620 #else //ENABLE(TIZEN_SMART_CLASS_TYPE_STR)
621
622 #ifndef EWK_TYPE_CHECK
623 #define EWK_VIEW_TYPE_CHECK(ewkView, ...) do { } while (0)
624 #else
625 #define EWK_VIEW_TYPE_CHECK(ewkView, ...) \
626     do { \
627         const char* _tmp_otype = evas_object_type_get(ewkView); \
628         const Evas_Smart* _tmp_s = evas_object_smart_smart_get(ewkView); \
629         if (EINA_UNLIKELY(!_tmp_s)) { \
630             EINA_LOG_CRIT \
631                 ("%p (%s) is not a smart object!", ewkView, \
632                 _tmp_otype ? _tmp_otype : "(null)"); \
633             return __VA_ARGS__; \
634         } \
635         const Evas_Smart_Class* _tmp_sc = evas_smart_class_get(_tmp_s); \
636         if (EINA_UNLIKELY(!_tmp_sc)) { \
637             EINA_LOG_CRIT \
638                 ("%p (%s) is not a smart object!", ewkView, \
639                 _tmp_otype ? _tmp_otype : "(null)"); \
640             return __VA_ARGS__; \
641         } \
642         if (EINA_UNLIKELY(_tmp_sc->data != ewkViewTypeString)) { \
643             EINA_LOG_CRIT \
644                 ("%p (%s) is not of an ewk_view (need %p, got %p)!", \
645                 ewkView, _tmp_otype ? _tmp_otype : "(null)", \
646                 ewkViewTypeString, _tmp_sc->data); \
647             return __VA_ARGS__; \
648         } \
649     } while (0)
650 #endif
651
652 #endif
653
654 #define EWK_VIEW_SD_GET(ewkView, pointer) \
655     Ewk_View_Smart_Data* pointer = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(ewkView))
656
657 #define EWK_VIEW_SD_GET_OR_RETURN(ewkView, pointer, ...) \
658     EWK_VIEW_TYPE_CHECK(ewkView, __VA_ARGS__); \
659     EWK_VIEW_SD_GET(ewkView, pointer); \
660     if (!pointer) { \
661         CRITICAL("no smart data for object %p (%s)", \
662                  ewkView, evas_object_type_get(ewkView)); \
663         return __VA_ARGS__; \
664     }
665
666 #define EWK_VIEW_PRIV_GET(smartData, pointer) \
667     Ewk_View_Private_Data* pointer = smartData->_priv
668
669 #define EWK_VIEW_PRIV_GET_OR_RETURN(smartData, pointer, ...) \
670     EWK_VIEW_PRIV_GET(smartData, pointer); \
671     if (!pointer) { \
672         CRITICAL("no private data for object %p (%s)", \
673                  smartData->self, evas_object_type_get(smartData->self)); \
674         return __VA_ARGS__; \
675     }
676
677 /**
678  * Iterating through frame tree. For each node in frame tree, delivered function is invoked
679  *
680  * @param [in] frame which will be iterated
681  * @param [in] pointer to function which will be invoked
682  * @param [in] data which will be passed to fun
683  */
684 void _iterate_frames(WebCore::Frame* frameIt, void (*fun)(WebCore::Frame* frame, void* data), void* data)
685 {
686     WebCore::FrameTree* frameTree = frameIt->tree();
687     for (unsigned int i = 0; i < frameTree->childCount(); ++i) {
688          WebCore::Frame* child = frameTree->child(i);
689          _iterate_frames(child, fun, data);
690     }
691     fun(frameIt, data);
692 }
693
694 #if ENABLE(TIZEN_WEBCORE_SELECTIVE_RENDERING)
695 static Eina_Bool _ewk_view_update_delayed_updates(Ewk_View_Smart_Data* smartData)
696 {
697     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
698
699     WebCore::FrameView* view = priv->mainFrame->view();
700     Eina_Bool old = priv->delaysHeavyTiles;
701     priv->delaysHeavyTiles = false;
702
703     view->paintDelayedUpdateRegions();
704     priv->delaysHeavyTiles = old;
705
706     return true;
707 }
708 #endif
709
710 static void _ewk_view_smart_changed(Ewk_View_Smart_Data* smartData)
711 {
712     if (smartData->changed.any)
713         return;
714     smartData->changed.any = true;
715     evas_object_smart_changed(smartData->self);
716 }
717
718 static Eina_Bool _ewk_view_repaints_resize(Ewk_View_Private_Data* priv, size_t size)
719 {
720     void* tmp = realloc(priv->repaints.array, size * sizeof(Eina_Rectangle));
721     if (!tmp) {
722         CRITICAL("could not realloc repaints array to %zu elements.", size);
723         return false;
724     }
725     priv->repaints.allocated = size;
726     priv->repaints.array = static_cast<Eina_Rectangle*>(tmp);
727     return true;
728 }
729
730 static void _ewk_view_repaint_add(Ewk_View_Private_Data* priv, Evas_Coord x, Evas_Coord y, Evas_Coord width, Evas_Coord height)
731 {
732     size_t newSize = 0;
733
734     if (priv->repaints.allocated == priv->repaints.count)
735         newSize = priv->repaints.allocated + ewkViewRepaintsSizeStep;
736     else if (!priv->repaints.count && priv->repaints.allocated > ewkViewRepaintsSizeInitial)
737         newSize = ewkViewRepaintsSizeInitial;
738
739     if (newSize) {
740         if (!_ewk_view_repaints_resize(priv, newSize))
741             return;
742     }
743
744     Eina_Rectangle* rect = priv->repaints.array + priv->repaints.count;
745     priv->repaints.count++;
746
747     rect->x = x;
748     rect->y = y;
749     rect->w = width;
750     rect->h = height;
751
752     DBG("add repaint %d, %d+%dx%d", x, y, width, height);
753 }
754
755 static void _ewk_view_repaints_flush(Ewk_View_Private_Data* priv)
756 {
757     priv->repaints.count = 0;
758     if (priv->repaints.allocated <= ewkViewRepaintsSizeMaximumFree)
759         return;
760     _ewk_view_repaints_resize(priv, ewkViewRepaintsSizeMaximumFree);
761 }
762
763 static Eina_Bool _ewk_view_scrolls_resize(Ewk_View_Private_Data* priv, size_t size)
764 {
765     void* tmp = realloc(priv->scrolls.array, size * sizeof(Ewk_Scroll_Request));
766     if (!tmp) {
767         CRITICAL("could not realloc scrolls array to %zu elements.", size);
768         return false;
769     }
770     priv->scrolls.allocated = size;
771     priv->scrolls.array = static_cast<Ewk_Scroll_Request*>(tmp);
772     return true;
773 }
774
775 static void _ewk_view_scroll_add(Ewk_View_Private_Data* priv, Evas_Coord deltaX, Evas_Coord deltaY, Evas_Coord x, Evas_Coord y, Evas_Coord width, Evas_Coord height)
776 {
777     Ewk_Scroll_Request* rect;
778     Ewk_Scroll_Request* rect_end;
779     Evas_Coord x2 = x + width, y2 = y + height;
780
781     rect = priv->scrolls.array;
782     rect_end = rect + priv->scrolls.count;
783     for (; rect < rect_end; rect++) {
784         if (rect->x == x && rect->y == y && rect->w == width && rect->h == height) {
785             DBG("region already scrolled %d,%d+%dx%d %+03d,%+03d add "
786                 "%+03d,%+03d",
787                 rect->x, rect->y, rect->w, rect->h, rect->dx, rect->dy, deltaX, deltaY);
788             rect->dx += deltaX;
789             rect->dy += deltaY;
790             return;
791         }
792         if ((x <= rect->x && x2 >= rect->x2) && (y <= rect->y && y2 >= rect->y2)) {
793             DBG("old viewport (%d,%d+%dx%d %+03d,%+03d) was scrolled itself, "
794                 "add %+03d,%+03d",
795                 rect->x, rect->y, rect->w, rect->h, rect->dx, rect->dy, deltaX, deltaY);
796             rect->x += deltaX;
797             rect->y += deltaY;
798         }
799     }
800
801     if (priv->scrolls.allocated == priv->scrolls.count) {
802         size_t size;
803         if (!priv->scrolls.allocated)
804             size = ewkViewScrollsSizeInitial;
805         else
806             size = priv->scrolls.allocated + ewkViewScrollsSizeStep;
807         if (!_ewk_view_scrolls_resize(priv, size))
808             return;
809     }
810
811     rect = priv->scrolls.array + priv->scrolls.count;
812     priv->scrolls.count++;
813
814     rect->x = x;
815     rect->y = y;
816     rect->w = width;
817     rect->h = height;
818     rect->x2 = x2;
819     rect->y2 = y2;
820     rect->dx = deltaX;
821     rect->dy = deltaY;
822     DBG("add scroll in region: %d, %d+%dx%d %+03d, %+03d", x, y, width, height, deltaX, deltaY);
823
824 #if !ENABLE(TIZEN_SCROLL_ADDING_FIX)
825     Eina_Rectangle* pr;
826     Eina_Rectangle* pr_end;
827     size_t count;
828     pr = priv->repaints.array;
829     count = priv->repaints.count;
830     pr_end = pr + count;
831     for (; pr < pr_end; pr++) {
832         pr->x += deltaX;
833         pr->y += deltaY;
834     }
835 #endif
836 }
837
838 static void _ewk_view_scrolls_flush(Ewk_View_Private_Data* priv)
839 {
840     priv->scrolls.count = 0;
841     if (priv->scrolls.allocated <= ewkViewScrollsSizeMaximumFree)
842         return;
843     _ewk_view_scrolls_resize(priv, ewkViewScrollsSizeMaximumFree);
844 }
845
846 // Default Event Handling //////////////////////////////////////////////
847 static Eina_Bool _ewk_view_smart_focus_in(Ewk_View_Smart_Data* smartData)
848 {
849     EWK_VIEW_PRIV_GET(smartData, priv);
850     WebCore::FocusController* focusController = priv->page->focusController();
851     DBG("ewkView=%p, focusController=%p", smartData->self, focusController);
852     EINA_SAFETY_ON_NULL_RETURN_VAL(focusController, false);
853
854     focusController->setActive(true);
855     focusController->setFocused(true);
856 #if ENABLE(TIZEN_SHOW_IME_ON_FOCUS_IN)
857     WebCore::Frame* focusedFrame = focusController->focusedOrMainFrame();
858     if (focusedFrame
859         && focusedFrame->document()
860         && focusedFrame->document()->focusedNode())
861         priv->page->editorClient()->setInputMethodState(focusedFrame->document()->focusedNode()->shouldUseInputMethod());
862 #endif
863     return true;
864 }
865
866 static Eina_Bool _ewk_view_smart_focus_out(Ewk_View_Smart_Data* smartData)
867 {
868     EWK_VIEW_PRIV_GET(smartData, priv);
869 #if ENABLE(TIZEN_ISF_PORT)
870     // input panel should be hided when webview is focused out.
871     // actually, it is the normal operation and input panel should be hided without this patch.
872     // However, we do not show/hide ime when we are not click the any area,
873     // because of html5demos.com/contenteditable issue in the EditClientEfl.cpp.
874     // so, we have to hide input panel explicitly here.
875     if (priv && priv->imContext) {
876         ecore_imf_context_input_panel_hide(priv->imContext);
877         ecore_imf_context_focus_out(priv->imContext);
878     }
879 #endif
880     WebCore::FocusController* focusController = priv->page->focusController();
881     DBG("ewkView=%p, fc=%p", smartData->self, focusController);
882     EINA_SAFETY_ON_NULL_RETURN_VAL(focusController, false);
883
884     focusController->setActive(false);
885     focusController->setFocused(false);
886     return true;
887 }
888
889 static Eina_Bool _ewk_view_smart_mouse_wheel(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Wheel* wheelEvent)
890 {
891     return ewk_frame_feed_mouse_wheel(smartData->main_frame, wheelEvent);
892 }
893
894 static Eina_Bool _ewk_view_smart_mouse_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Down* downEvent)
895 {
896     return ewk_frame_feed_mouse_down(smartData->main_frame, downEvent);
897 }
898
899 static Eina_Bool _ewk_view_smart_mouse_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Up* upEvent)
900 {
901     return ewk_frame_feed_mouse_up(smartData->main_frame, upEvent);
902 }
903
904 static Eina_Bool _ewk_view_smart_mouse_move(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Move* moveEvent)
905 {
906     return ewk_frame_feed_mouse_move(smartData->main_frame, moveEvent);
907 }
908
909 static Eina_Bool _ewk_view_smart_key_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Down* downEvent)
910 {
911     Evas_Object* frame = ewk_view_frame_focused_get(smartData->self);
912
913     if (!frame)
914         frame = smartData->main_frame;
915
916     return ewk_frame_feed_key_down(frame, downEvent);
917 }
918
919 static Eina_Bool _ewk_view_smart_key_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Up* upEvent)
920 {
921     Evas_Object* frame = ewk_view_frame_focused_get(smartData->self);
922
923     if (!frame)
924         frame = smartData->main_frame;
925
926     return ewk_frame_feed_key_up(frame, upEvent);
927 }
928
929 static void _ewk_view_smart_add_console_message(Ewk_View_Smart_Data* smartData, const char* message, unsigned int lineNumber, const char* sourceID)
930 {
931     INF("console message: %s @%d: %s\n", sourceID, lineNumber, message);
932 }
933
934 static void _ewk_view_smart_run_javascript_alert(Ewk_View_Smart_Data* smartData, Evas_Object* frame, const char* message)
935 {
936     INF("javascript alert: %s\n", message);
937 }
938
939 static Eina_Bool _ewk_view_smart_run_javascript_confirm(Ewk_View_Smart_Data* smartData, Evas_Object* frame, const char* message)
940 {
941     INF("javascript confirm: %s", message);
942     INF("javascript confirm (HARD CODED)? YES");
943     return true;
944 }
945
946 static Eina_Bool _ewk_view_smart_should_interrupt_javascript(Ewk_View_Smart_Data* smartData)
947 {
948     INF("should interrupt javascript?\n"
949         "\t(HARD CODED) NO");
950     return false;
951 }
952
953 static Eina_Bool _ewk_view_smart_run_javascript_prompt(Ewk_View_Smart_Data* smartData, Evas_Object* frame, const char* message, const char* defaultValue, char** value)
954 {
955     *value = strdup("test");
956     Eina_Bool result = true;
957     INF("javascript prompt:\n"
958         "\t      message: %s\n"
959         "\tdefault value: %s\n"
960         "\tgiving answer: %s\n"
961         "\t       button: %s", message, defaultValue, *value, result ? "ok" : "cancel");
962
963     return result;
964 }
965
966 // Event Handling //////////////////////////////////////////////////////
967 static void _ewk_view_on_focus_in(void* data, Evas*, Evas_Object*, void*)
968 {
969     Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
970     EINA_SAFETY_ON_NULL_RETURN(smartData->api);
971     EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_in);
972     smartData->api->focus_in(smartData);
973 }
974
975 static void _ewk_view_on_focus_out(void* data, Evas*, Evas_Object*, void*)
976 {
977     Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
978     EINA_SAFETY_ON_NULL_RETURN(smartData->api);
979     EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_out);
980     smartData->api->focus_out(smartData);
981 }
982
983 static void _ewk_view_on_mouse_wheel(void* data, Evas*, Evas_Object*, void* eventInfo)
984 {
985     Evas_Event_Mouse_Wheel* wheelEvent = static_cast<Evas_Event_Mouse_Wheel*>(eventInfo);
986     Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
987     EINA_SAFETY_ON_NULL_RETURN(smartData->api);
988     EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_wheel);
989     smartData->api->mouse_wheel(smartData, wheelEvent);
990 }
991
992 static void _ewk_view_on_mouse_down(void* data, Evas*, Evas_Object*, void* eventInfo)
993 {
994     Evas_Event_Mouse_Down* downEvent = static_cast<Evas_Event_Mouse_Down*>(eventInfo);
995     Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
996     EINA_SAFETY_ON_NULL_RETURN(smartData->api);
997     EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_down);
998     smartData->api->mouse_down(smartData, downEvent);
999 }
1000
1001 static void _ewk_view_on_mouse_up(void* data, Evas*, Evas_Object*, void* eventInfo)
1002 {
1003     Evas_Event_Mouse_Up* upEvent = static_cast<Evas_Event_Mouse_Up*>(eventInfo);
1004     Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
1005     EINA_SAFETY_ON_NULL_RETURN(smartData->api);
1006     EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_up);
1007     smartData->api->mouse_up(smartData, upEvent);
1008 }
1009
1010 static void _ewk_view_on_mouse_move(void* data, Evas*, Evas_Object*, void* eventInfo)
1011 {
1012     Evas_Event_Mouse_Move* moveEvent = static_cast<Evas_Event_Mouse_Move*>(eventInfo);
1013     Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
1014     EINA_SAFETY_ON_NULL_RETURN(smartData->api);
1015     EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_move);
1016     smartData->api->mouse_move(smartData, moveEvent);
1017 }
1018
1019 static void _ewk_view_on_key_down(void* data, Evas*, Evas_Object*, void* eventInfo)
1020 {
1021     Evas_Event_Key_Down* downEvent = static_cast<Evas_Event_Key_Down*>(eventInfo);
1022     Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
1023     EINA_SAFETY_ON_NULL_RETURN(smartData->api);
1024     EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_down);
1025 #if ENABLE(TIZEN_ISF_PORT)
1026     EWK_VIEW_PRIV_GET(smartData, priv);
1027     Ecore_IMF_Event_Key_Down ecore_ev;
1028     ecore_imf_evas_event_key_down_wrap(downEvent, &ecore_ev);
1029     if (ecore_imf_context_filter_event(priv->imContext, ECORE_IMF_EVENT_KEY_DOWN, (Ecore_IMF_Event*)&ecore_ev))
1030         return;
1031 #endif
1032     smartData->api->key_down(smartData, downEvent);
1033 }
1034
1035 static void _ewk_view_on_key_up(void* data, Evas*, Evas_Object*, void* eventInfo)
1036 {
1037     Evas_Event_Key_Up* upEvent = static_cast<Evas_Event_Key_Up*>(eventInfo);
1038     Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
1039     EINA_SAFETY_ON_NULL_RETURN(smartData->api);
1040     EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_up);
1041     smartData->api->key_up(smartData, upEvent);
1042 }
1043
1044 #if ENABLE(TIZEN_PRE_RENDERING_ENABLE)
1045 static void _ewk_view_on_pan_end(void* data, Evas_Object* ewkView, void*)
1046 {
1047     Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
1048     EINA_SAFETY_ON_NULL_RETURN(smartData->api->pre_render_start);
1049
1050     smartData->api->pre_render_start(smartData, false);
1051 }
1052 #endif
1053
1054 static WTF::PassRefPtr<WebCore::Frame> _ewk_view_core_frame_new(Ewk_View_Smart_Data* smartData, Ewk_View_Private_Data* priv, WebCore::HTMLFrameOwnerElement* owner)
1055 {
1056     WebCore::FrameLoaderClientEfl* frameLoaderClient = new WebCore::FrameLoaderClientEfl(smartData->self);
1057     frameLoaderClient->setCustomUserAgent(String::fromUTF8(priv->settings.userAgent));
1058 #if ENABLE(TIZEN_CUSTOM_HEADERS)
1059     frameLoaderClient->setCustomHeaders(priv->settings.customHeaders);
1060 #endif
1061
1062     return WebCore::Frame::create(priv->page.get(), owner, frameLoaderClient);
1063 }
1064
1065 static Evas_Smart_Class _parent_sc = EVAS_SMART_CLASS_INIT_NULL;
1066
1067 static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData)
1068 {
1069     Ewk_View_Private_Data* priv = new Ewk_View_Private_Data;
1070     memset(priv, 0, sizeof(Ewk_View_Private_Data));
1071     AtomicString string;
1072     WebCore::KURL url;
1073
1074 #if ENABLE(TIZEN_ISF_PORT) 
1075     ecore_imf_init();
1076
1077     const char* ctx_id = ecore_imf_context_default_id_get();
1078     if (ctx_id)
1079         priv->imContext = ecore_imf_context_add(ctx_id);
1080
1081     smartData->_priv = priv;
1082 #endif
1083
1084     WebCore::Page::PageClients pageClients;
1085     pageClients.chromeClient = new WebCore::ChromeClientEfl(smartData->self);
1086     pageClients.editorClient = new WebCore::EditorClientEfl(smartData->self);
1087     pageClients.dragClient = new WebCore::DragClientEfl;
1088 #if ENABLE(TIZEN_CONTEXT_MENU)
1089     pageClients.contextMenuClient = static_cast<WebCore::ContextMenuClient*>(new WebCore::ContextMenuClientEfl(smartData->self));
1090 #endif
1091
1092 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
1093     pageClients.inspectorClient = new WebCore::InspectorClientEfl(smartData->self);
1094 #else
1095     pageClients.inspectorClient = new WebCore::InspectorClientEfl;
1096 #endif
1097
1098 #if ENABLE(TIZEN_INSTALL_CONTENT)
1099     pageClients.installContentClient = static_cast<WebCore::InstallContentClient*>(new WebCore::InstallContentClientEfl(smartData->self));
1100 #endif
1101     priv->page = adoptPtr(new WebCore::Page(pageClients));
1102 #if ENABLE(TIZEN_VIEW_MODE)
1103     priv->page->setViewMode(WebCore::Page::ViewModeMaximized);
1104 #endif
1105
1106 #if ENABLE(DEVICE_ORIENTATION)
1107     WebCore::provideDeviceMotionTo(priv->page.get(), new WebCore::DeviceMotionClientEfl);
1108     WebCore::provideDeviceOrientationTo(priv->page.get(), new WebCore::DeviceOrientationClientEfl);
1109 #endif
1110
1111 #if ENABLE(TIZEN_NOTIFICATION)
1112 #if ENABLE(NOTIFICATIONS)
1113     WebCore::provideNotification(priv->page.get(), new WebCore::NotificationClientEfl(smartData->self));
1114 #endif
1115 #endif
1116
1117 #if ENABLE(NETWORK_INFO)
1118     priv->networkInfoClient = adoptPtr(new WebCore::NetworkInfoClientEfl);
1119     WebCore::provideNetworkInfoTo(priv->page.get(), priv->networkInfoClient.get());
1120 #endif
1121
1122 #if ENABLE(VIBRATION)
1123     WebCore::provideVibrationTo(priv->page.get(), new WebCore::VibrationClientEfl(smartData->self));
1124 #endif
1125
1126 #if ENABLE(BATTERY_STATUS)
1127     WebCore::provideBatteryTo(priv->page.get(), new BatteryClientEfl);
1128 #endif
1129
1130     priv->pageSettings = priv->page->settings();
1131
1132     priv->viewportArguments.width = WebCore::ViewportArguments::ValueAuto;
1133     priv->viewportArguments.height = WebCore::ViewportArguments::ValueAuto;
1134     priv->viewportArguments.initialScale = WebCore::ViewportArguments::ValueAuto;
1135     priv->viewportArguments.minimumScale = WebCore::ViewportArguments::ValueAuto;
1136     priv->viewportArguments.maximumScale = WebCore::ViewportArguments::ValueAuto;
1137     priv->viewportArguments.targetDensityDpi = WebCore::ViewportArguments::ValueAuto;
1138     priv->viewportArguments.userScalable = true;
1139
1140 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
1141     priv->viewportAttributes.width = WebCore::ViewportArguments::ValueAuto;
1142     priv->viewportAttributes.height = WebCore::ViewportArguments::ValueAuto;
1143     priv->viewportAttributes.initial_scale = WebCore::ViewportArguments::ValueAuto;
1144     priv->viewportAttributes.minimum_scale = WebCore::ViewportArguments::ValueAuto;
1145     priv->viewportAttributes.maximum_scale = WebCore::ViewportArguments::ValueAuto;
1146     priv->viewportAttributes.device_pixel_ratio = devicePixelRatio;
1147     priv->viewportAttributes.user_scalable = true;
1148 #if ENABLE(TIZEN_VIEWPORT_ORIENTATION)
1149     priv->viewportAttributes.orientation = EWK_VIEWPORT_ORIENTATION_AUTO;
1150 #endif
1151 #endif
1152
1153     priv->pageSettings->setLoadsImagesAutomatically(true);
1154     priv->pageSettings->setDefaultFixedFontSize(12);
1155     priv->pageSettings->setDefaultFontSize(16);
1156     priv->pageSettings->setSerifFontFamily("serif");
1157     priv->pageSettings->setFixedFontFamily("monotype");
1158     priv->pageSettings->setSansSerifFontFamily("sans");
1159     priv->pageSettings->setStandardFontFamily("sans");
1160     priv->pageSettings->setHyperlinkAuditingEnabled(false);
1161     priv->pageSettings->setScriptEnabled(true);
1162     priv->pageSettings->setPluginsEnabled(true);
1163     priv->pageSettings->setLocalStorageEnabled(true);
1164 #if ENABLE(TIZEN_WEB_AUDIO)
1165     priv->pageSettings->setWebAudioEnabled(true);
1166 #endif
1167     priv->pageSettings->setOfflineWebApplicationCacheEnabled(true);
1168     priv->pageSettings->setUsesPageCache(true);
1169 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
1170     priv->pageSettings->setDeveloperExtrasEnabled(true);
1171 #endif
1172 #if ENABLE(TIZEN_ENCODING_DETECTOR_TRUE)
1173     priv->pageSettings->setUsesEncodingDetector(true);
1174 #else
1175     priv->pageSettings->setUsesEncodingDetector(false);
1176 #endif
1177 #if ENABLE(WEB_AUDIO)
1178     priv->pageSettings->setWebAudioEnabled(false);
1179 #endif
1180     priv->pageSettings->setWebGLEnabled(true);
1181 #if ENABLE(TIZEN_PASSWORD_SHOW_PATCH)
1182     priv->pageSettings->setPasswordEchoEnabled(true);
1183     priv->pageSettings->setPasswordEchoDurationInSeconds(1);
1184 #endif
1185     priv->pageSettings->setXSSAuditorEnabled(true);
1186 #if ENABLE(FULLSCREEN_API)
1187     priv->pageSettings->setFullScreenEnabled(true);
1188 #endif
1189
1190     url = priv->pageSettings->userStyleSheetLocation();
1191     priv->settings.userStylesheet = eina_stringshare_add(url.string().utf8().data());
1192
1193     priv->settings.encodingDefault = eina_stringshare_add
1194                                           (priv->pageSettings->defaultTextEncodingName().utf8().data());
1195     priv->settings.encodingCustom = 0;
1196
1197     string = priv->pageSettings->localStorageDatabasePath();
1198     priv->settings.localStorageDatabasePath = eina_stringshare_add(string.string().utf8().data());
1199
1200     priv->settings.fontMinimumSize = priv->pageSettings->minimumFontSize();
1201     priv->settings.fontMinimumLogicalSize = priv->pageSettings->minimumLogicalFontSize();
1202     priv->settings.fontDefaultSize = priv->pageSettings->defaultFontSize();
1203     priv->settings.fontMonospaceSize = priv->pageSettings->defaultFixedFontSize();
1204
1205     string = priv->pageSettings->standardFontFamily();
1206     priv->settings.fontStandard = eina_stringshare_add(string.string().utf8().data());
1207     string = priv->pageSettings->cursiveFontFamily();
1208     priv->settings.fontCursive = eina_stringshare_add(string.string().utf8().data());
1209     string = priv->pageSettings->fixedFontFamily();
1210     priv->settings.fontMonospace = eina_stringshare_add(string.string().utf8().data());
1211     string = priv->pageSettings->fantasyFontFamily();
1212     priv->settings.fontFantasy = eina_stringshare_add(string.string().utf8().data());
1213     string = priv->pageSettings->serifFontFamily();
1214     priv->settings.fontSerif = eina_stringshare_add(string.string().utf8().data());
1215     string = priv->pageSettings->sansSerifFontFamily();
1216     priv->settings.fontSansSerif = eina_stringshare_add(string.string().utf8().data());
1217
1218     priv->settings.autoLoadImages = priv->pageSettings->loadsImagesAutomatically();
1219     priv->settings.autoShrinkImages = priv->pageSettings->shrinksStandaloneImagesToFit();
1220     priv->settings.enableAutoResizeWindow = true;
1221     priv->settings.enableDeveloperExtras = priv->pageSettings->developerExtrasEnabled();
1222     priv->settings.enableScripts = priv->pageSettings->isScriptEnabled();
1223     priv->settings.enablePlugins = priv->pageSettings->arePluginsEnabled();
1224     priv->settings.enableFrameFlattening = priv->pageSettings->frameFlatteningEnabled();
1225 #if ENABLE(TIZEN_ONSCROLL_EVENT_SUPPRESSION)
1226     priv->settings.enableOnscrollEventSuppression = priv->pageSettings->onscrollEventSuppressionEnabled();
1227 #endif
1228 #if !ENABLE(TIZEN_DAILY_UPVERSIONING)
1229     priv->settings.scriptsWindowOpen = priv->pageSettings->allowScriptsToCloseWindows();
1230 #endif
1231     priv->settings.enableXSSAuditor = priv->pageSettings->xssAuditorEnabled();
1232     priv->settings.hyperlinkAuditingEnabled = priv->pageSettings->hyperlinkAuditingEnabled();
1233     priv->settings.scriptsCanOpenWindows = priv->pageSettings->javaScriptCanOpenWindowsAutomatically();
1234 #if ENABLE(TIZEN_WEBKIT_EFL_DRT)
1235     priv->settings.scriptsWindowClose = priv->pageSettings->allowScriptsToCloseWindows();
1236 #endif
1237 #if ENABLE(TIZEN_ONSCROLL_EVENT_SUPPRESSION)
1238     priv->settings.enableOnscrollEventSuppression = priv->pageSettings->onscrollEventSuppressionEnabled();
1239 #endif
1240     priv->settings.scriptsCanCloseWindows = priv->pageSettings->allowScriptsToCloseWindows();
1241 #if ENABLE(VIDEO_TRACK)
1242     priv->settings.shouldDisplayCaptions = priv->pageSettings->shouldDisplayCaptions();
1243     priv->settings.shouldDisplaySubtitles = priv->pageSettings->shouldDisplaySubtitles();
1244     priv->settings.shouldDisplayTextDescriptions = priv->pageSettings->shouldDisplayTextDescriptions();
1245 #endif
1246     priv->settings.scriptsCanAccessClipboard = priv->pageSettings->javaScriptCanAccessClipboard() && priv->pageSettings->isDOMPasteAllowed();
1247     priv->settings.resizableTextareas = priv->pageSettings->textAreasAreResizable();
1248     priv->settings.privateBrowsing = priv->pageSettings->privateBrowsingEnabled();
1249     priv->settings.caretBrowsing = priv->pageSettings->caretBrowsingEnabled();
1250     priv->settings.spatialNavigation = priv->pageSettings->isSpatialNavigationEnabled();
1251     priv->settings.localStorage = priv->pageSettings->localStorageEnabled();
1252 #if ENABLE(TIZEN_WEB_AUDIO)
1253     priv->settings.webAudio = priv->pageSettings->webAudioEnabled();
1254 #endif
1255     priv->settings.offlineAppCache = true; // XXX no function to read setting; this keeps the original setting
1256     priv->settings.pageCache = priv->pageSettings->usesPageCache();
1257     priv->settings.encodingDetector = priv->pageSettings->usesEncodingDetector();
1258     priv->settings.webGLEnabled = priv->pageSettings->webGLEnabled();
1259     priv->settings.tabsToLinks = true;
1260
1261     priv->settings.userAgent = ewk_settings_default_user_agent_get();
1262 #if ENABLE(WEB_AUDIO)
1263     priv->settings.webAudio = priv->pageSettings->webAudioEnabled();
1264 #endif
1265
1266     // Since there's no scale separated from zooming in webkit-efl, this functionality of
1267     // viewport meta tag is implemented using zoom. When scale zoom is supported by webkit-efl,
1268     // this functionality will be modified by the scale zoom patch.
1269     priv->settings.zoomRange.minScale = zoomMinimum;
1270     priv->settings.zoomRange.maxScale = zoomMaximum;
1271     priv->settings.zoomRange.userScalable = true;
1272     priv->settings.devicePixelRatio = devicePixelRatio;
1273
1274     priv->settings.domTimerInterval = priv->pageSettings->defaultMinDOMTimerInterval();
1275
1276 #if ENABLE(TIZEN_PLUGIN_PARENT_WINDOW)
1277     priv->settings.parentWindow = 0;
1278 #endif
1279 #if ENABLE(TIZEN_CSS_FIXED_AS_ABSOLUTE)
1280     priv->settings.fixedAsAbsolute = false;
1281     priv->pageSettings->setFixedAsAbsoluteEnabled(false);
1282 #endif
1283 #if ENABLE(TIZEN_CSS_FIXED_FAST_PATH)
1284     priv->settings.fixedFastPath = true;
1285     priv->pageSettings->setFixedFastPathImprovementsEnabled(true);
1286 #endif
1287 #if ENABLE(TIZEN_AUTOFOCUS_BLOCK)
1288     priv->settings.showImeOnAutofocus = true;
1289 #endif
1290 #if ENABLE(TIZEN_GEOLOCATION)
1291     priv->settings.geolocation = 0;
1292     priv->pageSettings->setGeolocationEnabled(false);
1293 #endif
1294 #if ENABLE(TIZEN_FOCUS_RING)
1295     priv->settings.enableFocusRing = priv->pageSettings->isFocusRingEnabled();
1296 #endif
1297
1298     priv->mainFrame = _ewk_view_core_frame_new(smartData, priv, 0).get();
1299
1300     priv->history = ewk_history_new(static_cast<WebCore::BackForwardListImpl*>(priv->page->backForwardList()));
1301
1302     priv->soupSession = WebCore::ResourceHandle::defaultSession();
1303
1304 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
1305     // ewk_view_inspector_server_start(9222);
1306 #endif
1307
1308 #if USE(ACCELERATED_COMPOSITING) && ENABLE(TIZEN_ACCELERATED_COMPOSITING)
1309     priv->compositingSurface = 0;
1310     priv->compositingActive = false;
1311     priv->compositor = nullptr;
1312     priv->pageSettings->setAcceleratedCompositingEnabled(true);
1313     priv->pageSettings->setAcceleratedCompositingFor3DTransformsEnabled(true);
1314     priv->pageSettings->setAcceleratedCompositingForAnimationEnabled(false);
1315     priv->pageSettings->setAcceleratedCompositingForVideoEnabled(true);
1316     priv->pageSettings->setAcceleratedCompositingForCanvasEnabled(true);
1317     priv->pageSettings->setAcceleratedCompositingForPluginsEnabled(false);
1318     priv->pageSettings->setWebGLEnabled(true);
1319 #endif
1320
1321 #if ENABLE(TIZEN_FULLSCREEN_API)
1322     priv->pageSettings->setFullScreenEnabled(true);
1323 #endif
1324     priv->pageClient = adoptPtr(new PageClientEfl(smartData->self));
1325 #ifdef HAVE_ECORE_X
1326     priv->isUsingEcoreX = WebCore::isUsingEcoreX(smartData->base.evas);
1327 #endif
1328
1329     return priv;
1330 }
1331
1332 static void _ewk_view_priv_del(Ewk_View_Private_Data* priv)
1333 {
1334     if (!priv)
1335         return;
1336
1337 #if ENABLE(TIZEN_ISF_PORT) 
1338     ecore_imf_shutdown();
1339 #endif    
1340
1341     /* do not delete priv->mainFrame */
1342
1343     free(priv->repaints.array);
1344     free(priv->scrolls.array);
1345
1346     eina_stringshare_del(priv->settings.userAgent);
1347     eina_stringshare_del(priv->settings.userStylesheet);
1348     eina_stringshare_del(priv->settings.encodingDefault);
1349     eina_stringshare_del(priv->settings.encodingCustom);
1350     eina_stringshare_del(priv->settings.fontStandard);
1351     eina_stringshare_del(priv->settings.fontCursive);
1352     eina_stringshare_del(priv->settings.fontMonospace);
1353     eina_stringshare_del(priv->settings.fontFantasy);
1354     eina_stringshare_del(priv->settings.fontSerif);
1355     eina_stringshare_del(priv->settings.fontSansSerif);
1356     eina_stringshare_del(priv->settings.localStorageDatabasePath);
1357
1358     if (priv->animatedZoom.animator)
1359         ecore_animator_del(priv->animatedZoom.animator);
1360
1361     ewk_history_free(priv->history);
1362
1363 #if USE(ACCELERATED_COMPOSITING) && ENABLE(TIZEN_ACCELERATED_COMPOSITING)
1364     priv->compositor.clear();
1365     evas_object_del(priv->compositingSurface);
1366     priv->compositingSurface = 0;
1367     priv->compositingActive = false;
1368 #endif
1369     if (priv->cursorObject)
1370         evas_object_del(priv->cursorObject);
1371
1372     delete priv;
1373 }
1374
1375 #if ENABLE(NETSCAPE_PLUGIN_API) && ENABLE(TIZEN_NPAPI)
1376
1377 /**
1378  * Checking specified HTMLPlugInElement if it is proper running plugin
1379  *
1380  * @param [in]  HTMLPlugInElement to check
1381  *
1382  * @return      PluginView's pointer representing running plugin, or 0 otherwise
1383  */
1384 WebCore::PluginView* _check_for_running_plugin(WebCore::HTMLPlugInElement* pluginElement)
1385 {
1386     if (!pluginElement)
1387         return 0;
1388
1389     WebCore::Widget* widget  = pluginElement->pluginWidget();
1390     if (widget && widget->isPluginView()) {
1391         WebCore::PluginView* pluginView = static_cast<WebCore::PluginView*>(widget);
1392         if (pluginView && pluginView->isPluginStarted())
1393             return pluginView;
1394     }
1395     return 0;
1396 }
1397
1398 /**
1399  * Send TNPEvent to all plugins in specified Frame
1400  *
1401  * @param [in] frame
1402  * @param [in] pointer to TNPEvent which will be send to plugins
1403  */
1404 void _send_event_to_all_plugins(WebCore::Frame* frame, void* data)
1405 {
1406     // plugins can be created as object tag with data attribute or embed tag with src
1407     RefPtr<WebCore::HTMLCollection> objects = frame->document()->objects(); // /< getting all objects from current frame
1408     for (unsigned int i = 0; i < objects->length(); ++i) {
1409         WebCore::Node* node = objects->item(i);
1410         if (node) { 
1411             WebCore::HTMLObjectElement* objectElement = static_cast<WebCore::HTMLObjectElement*>(node);
1412             // check this objectElement contains Flash classid.
1413             if ((!objectElement->classId().isEmpty() && objectElement->classId() == WTF::String(FLASH_CLASS_ID))
1414                 || (!objectElement->serviceType().isEmpty() && objectElement->serviceType() == WTF::String(FLASH_SERVICE_TYPE))) {
1415                 WebCore::PluginView* pluginView = _check_for_running_plugin(static_cast<WebCore::HTMLPlugInElement*>(node));
1416                 if (pluginView)
1417                     pluginView->dispatchTNPEvent(static_cast<TNPEvent*>(data));
1418             }
1419         }
1420     }
1421
1422     RefPtr<WebCore::HTMLCollection> plugins = frame->document()->plugins();
1423     for (unsigned int i = 0; i < plugins->length(); ++i) {
1424         WebCore::Node* node = plugins->item(i);
1425         if (node) {
1426             WebCore::HTMLPlugInElement* pluginElement = static_cast<WebCore::HTMLPlugInElement*>(node);
1427
1428             WebCore::PluginView* pluginView = _check_for_running_plugin(pluginElement);
1429             if (pluginView)
1430                 pluginView->dispatchTNPEvent(static_cast<TNPEvent*>(data));
1431         }
1432     }
1433 }
1434 #endif // ENABLE(NETSCAPE_PLUGIN_API) && ENABLE(TIZEN_NPAPI)
1435
1436 #if ENABLE(TIZEN_EVAS_OBJECT_PLUGIN)
1437 Evas_Object* ewk_plugin_store_add(Evas* e);
1438
1439 static Evas_Object* _ewk_view_plugin_store_add(Ewk_View_Smart_Data* smartData)
1440 {
1441     Evas_Object* bs = ewk_plugin_store_add(smartData->base.evas);
1442     return bs;
1443 }
1444
1445 Evas_Object* ewk_plugin_store_add(Evas* e)
1446 {
1447     static Evas_Smart* smart = 0;
1448
1449     if (!smart) {
1450 #if ENABLE(TIZEN_SMART_CLASS_TYPE_STR)
1451         static Evas_Smart_Class sc = EVAS_SMART_CLASS_INIT_VERSION;
1452         const char* name = eina_stringshare_add("Ewk_Plugin_Store");
1453         sc.name = name;
1454 #else
1455         static Evas_Smart_Class sc =
1456         EVAS_SMART_CLASS_INIT_NAME_VERSION("Ewk_Plugin_Store");
1457 #endif
1458         evas_object_smart_clipped_smart_set(&sc);
1459         smart = evas_smart_class_new(&sc);
1460     }
1461
1462     return evas_object_smart_add(e, smart);
1463 }
1464 #endif
1465
1466 static void _ewk_view_smart_add(Evas_Object* ewkView)
1467 {
1468     const Evas_Smart* smart = evas_object_smart_smart_get(ewkView);
1469     const Evas_Smart_Class* smartClass = evas_smart_class_get(smart);
1470     const Ewk_View_Smart_Class* api = reinterpret_cast<const Ewk_View_Smart_Class*>(smartClass);
1471     EINA_SAFETY_ON_NULL_RETURN(api->backing_store_add);
1472     EWK_VIEW_SD_GET(ewkView, smartData);
1473
1474     if (!smartData) {
1475         smartData = static_cast<Ewk_View_Smart_Data*>(calloc(1, sizeof(Ewk_View_Smart_Data)));
1476         if (!smartData) {
1477             CRITICAL("could not allocate Ewk_View_Smart_Data");
1478             return;
1479         }
1480         evas_object_smart_data_set(ewkView, smartData);
1481     }
1482
1483     smartData->bg_color.r = 255;
1484     smartData->bg_color.g = 255;
1485     smartData->bg_color.b = 255;
1486     smartData->bg_color.a = 255;
1487
1488     smartData->self = ewkView;
1489     smartData->api = api;
1490
1491     _parent_sc.add(ewkView);
1492
1493     smartData->_priv = _ewk_view_priv_new(smartData);
1494     if (!smartData->_priv)
1495         return;
1496
1497     EWK_VIEW_PRIV_GET(smartData, priv);
1498
1499     smartData->backing_store = api->backing_store_add(smartData);
1500     if (!smartData->backing_store) {
1501         ERR("Could not create backing store object.");
1502         return;
1503     }
1504
1505 #if ENABLE(TIZEN_EVAS_OBJECT_PLUGIN)
1506     smartData->plugin_store = _ewk_view_plugin_store_add(smartData);
1507     if (!smartData->plugin_store) {
1508         ERR("Could not create plugin store object.");
1509         return;
1510     }
1511 #endif
1512
1513 #if ENABLE(TIZEN_BG_RECT_SUPPORT)
1514     smartData->bg_rect.bg_rect = evas_object_rectangle_add(smartData->base.evas);
1515     ewk_view_bg_rect_color_set(ewkView, 255, 255, 255, 255);
1516     evas_object_smart_member_add(smartData->bg_rect.bg_rect, ewkView);
1517     evas_object_show(smartData->bg_rect.bg_rect);
1518 #endif
1519
1520     evas_object_smart_member_add(smartData->backing_store, ewkView);
1521     evas_object_show(smartData->backing_store);
1522     evas_object_pass_events_set(smartData->backing_store, true);
1523
1524 #if ENABLE(TIZEN_EVAS_OBJECT_PLUGIN)
1525     evas_object_smart_member_add(smartData->plugin_store, ewkView);
1526     evas_object_show(smartData->plugin_store);
1527     // evas_object_pass_events_set(smartData->plugin_store, true);
1528 #endif
1529
1530     smartData->events_rect = evas_object_rectangle_add(smartData->base.evas);
1531     evas_object_color_set(smartData->events_rect, 0, 0, 0, 0);
1532     evas_object_smart_member_add(smartData->events_rect, ewkView);
1533     evas_object_show(smartData->events_rect);
1534
1535     smartData->main_frame = ewk_frame_add(smartData->base.evas);
1536     if (!smartData->main_frame) {
1537         ERR("Could not create main frame object.");
1538         return;
1539     }
1540
1541     if (!ewk_frame_init(smartData->main_frame, ewkView, priv->mainFrame)) {
1542         ERR("Could not initialize main frme object.");
1543         evas_object_del(smartData->main_frame);
1544         smartData->main_frame = 0;
1545
1546         delete priv->mainFrame;
1547         priv->mainFrame = 0;
1548         return;
1549     }
1550
1551     evas_object_name_set(smartData->main_frame, "EWK_Frame:main");
1552     evas_object_smart_member_add(smartData->main_frame, ewkView);
1553     evas_object_show(smartData->main_frame);
1554
1555 #define CONNECT(s, c) evas_object_event_callback_add(ewkView, s, c, smartData)
1556     CONNECT(EVAS_CALLBACK_FOCUS_IN, _ewk_view_on_focus_in);
1557     CONNECT(EVAS_CALLBACK_FOCUS_OUT, _ewk_view_on_focus_out);
1558     CONNECT(EVAS_CALLBACK_MOUSE_WHEEL, _ewk_view_on_mouse_wheel);
1559     CONNECT(EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down);
1560     CONNECT(EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up);
1561     CONNECT(EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move);
1562     CONNECT(EVAS_CALLBACK_KEY_DOWN, _ewk_view_on_key_down);
1563     CONNECT(EVAS_CALLBACK_KEY_UP, _ewk_view_on_key_up);
1564 #undef CONNECT
1565 #if ENABLE(TIZEN_PRE_RENDERING_ENABLE)
1566     evas_object_smart_callback_add(ewkView, "pan,end", _ewk_view_on_pan_end, smartData);
1567 #endif
1568 }
1569
1570 static void _ewk_view_smart_del(Evas_Object* ewkView)
1571 {
1572     EWK_VIEW_SD_GET(ewkView, smartData);
1573     Ewk_View_Private_Data* priv = smartData ? smartData->_priv : 0;
1574
1575 #if ENABLE(TIZEN_RECORDING_SURFACE)
1576     if (smartData->_priv->recordingSurfaceEnable) {
1577         smartData->_priv->recordingSurfaceSetState = RECORDING_SURFACE_SET_STATE_INIT;
1578         smartData->_priv->recordingSurfaceSetList = ewk_recording_surface_set_free(smartData->_priv->recordingSurfaceSetList);
1579         smartData->_priv->recordingSurfaceSetScrollState = false;
1580         smartData->_priv->recordingSurfaceSetLoadFinished = false;
1581     }
1582 #endif
1583
1584     ewk_view_stop(ewkView);
1585 #if ENABLE(TIZEN_ISF_PORT)
1586     if (priv && priv->imContext) {
1587         ecore_imf_context_input_panel_hide(priv->imContext);
1588         ecore_imf_context_del(priv->imContext);
1589         priv->imContext = 0;
1590     }
1591 #endif
1592 #if ENABLE(TIZEN_INSTALL_CONTENT)
1593     WebCore::Page* page = EWKPrivate::corePage(ewkView);
1594     if (page) {
1595         WebCore::InstallContentClient* installContentClient = page->installContentClient();
1596         installContentClient->removeTempDir();
1597     }
1598 #endif
1599 #if !ENABLE(TIZEN_DESTROY_FIX)
1600     _parent_sc.del(ewkView);
1601 #else
1602     evas_object_del(smartData->main_frame);
1603 #endif
1604     if (priv)
1605         _ewk_view_priv_del(priv);
1606 #if ENABLE(TIZEN_DESTROY_FIX)
1607     _parent_sc.del(ewkView);
1608 #endif
1609 }
1610
1611 static void _ewk_view_smart_resize(Evas_Object* ewkView, Evas_Coord w, Evas_Coord h)
1612 {
1613     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1614
1615 #if ENABLE(TIZEN_ACCELERATED_COMPOSITING)
1616     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1617 #endif
1618     // these should be queued and processed in calculate as well!
1619     evas_object_resize(smartData->backing_store, w, h);
1620
1621     smartData->changed.size = true;
1622
1623     _ewk_view_smart_changed(smartData);
1624 }
1625
1626 static void _ewk_view_smart_move(Evas_Object* ewkView, Evas_Coord x, Evas_Coord y)
1627 {
1628     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1629     smartData->changed.position = true;
1630     _ewk_view_smart_changed(smartData);
1631 }
1632
1633 static void _ewk_view_smart_calculate(Evas_Object* ewkView)
1634 {
1635     EWK_VIEW_SD_GET(ewkView, smartData);
1636     EWK_VIEW_PRIV_GET(smartData, priv);
1637     EINA_SAFETY_ON_NULL_RETURN(smartData->api->contents_resize);
1638     EINA_SAFETY_ON_NULL_RETURN(smartData->api->scrolls_process);
1639     EINA_SAFETY_ON_NULL_RETURN(smartData->api->repaints_process);
1640     Evas_Coord x, y, width, height;
1641
1642     smartData->changed.any = false;
1643
1644     if (!smartData->main_frame || !priv->mainFrame)
1645         return;
1646
1647     evas_object_geometry_get(ewkView, &x, &y, &width, &height);
1648
1649     DBG("ewkView=%p geo=[%d, %d + %dx%d], changed: size=%hhu, "
1650         "scrolls=%zu, repaints=%zu",
1651         ewkView, x, y, width, height, smartData->changed.size,
1652         priv->scrolls.count, priv->repaints.count);
1653
1654     if (smartData->changed.size && ((width != smartData->view.w) || (height != smartData->view.h))) {
1655         WebCore::FrameView* view = priv->mainFrame->view();
1656         if (view) {
1657             view->resize(width, height);
1658             view->forceLayout();
1659             view->adjustViewSize();
1660         }
1661         evas_object_resize(smartData->main_frame, width, height);
1662         evas_object_resize(smartData->events_rect, width, height);
1663 #if ENABLE(TIZEN_BG_RECT_SUPPORT)
1664         evas_object_resize(smartData->bg_rect.bg_rect, width, height);
1665 #endif
1666         smartData->changed.frame_rect = true;
1667         smartData->view.w = width;
1668         smartData->view.h = height;
1669
1670         _ewk_view_repaint_add(priv, 0, 0, width, height);
1671 #if ENABLE(TIZEN_ACCELERATED_COMPOSITING)
1672         if (priv->compositingActive) {
1673             evas_object_image_native_surface_set(priv->compositingSurface, 0);
1674             evas_object_image_size_set(priv->compositingSurface, width, height);
1675
1676             priv->compositor->resize(priv->compositingSurface);
1677
1678             evas_object_resize(priv->compositingSurface, width, height);
1679
1680             ewk_view_mark_for_sync(ewkView, false);
1681         }
1682 #endif
1683         // This callback is a good place e.g. to change fixed layout size (ewk_view_fixed_layout_size_set).
1684         evas_object_smart_callback_call(ewkView, "view,resized", 0);
1685     }
1686     smartData->changed.size = false;
1687
1688     if (smartData->changed.position && ((x != smartData->view.x) || (y != smartData->view.y))) {
1689         evas_object_move(smartData->main_frame, x, y);
1690         evas_object_move(smartData->backing_store, x, y);
1691         evas_object_move(smartData->events_rect, x, y);
1692 #if ENABLE(TIZEN_BG_RECT_SUPPORT)
1693         evas_object_move(smartData->bg_rect.bg_rect, x, y);
1694 #endif
1695 #if USE(ACCELERATED_COMPOSITING) && ENABLE(TIZEN_ACCELERATED_COMPOSITING)
1696         if (priv->compositingSurface)
1697             evas_object_move(priv->compositingSurface, x, y);
1698 #endif
1699         smartData->changed.frame_rect = true;
1700         smartData->view.x = x;
1701         smartData->view.y = y;
1702     }
1703     smartData->changed.position = false;
1704
1705     if (!smartData->api->scrolls_process(smartData))
1706         ERR("failed to process scrolls.");
1707     _ewk_view_scrolls_flush(priv);
1708
1709     if (!smartData->api->repaints_process(smartData))
1710         ERR("failed to process repaints.");
1711
1712     if (smartData->changed.frame_rect) {
1713         WebCore::FrameView* view = priv->mainFrame->view();
1714         view->frameRectsChanged(); /* force tree to get position from root */
1715         smartData->changed.frame_rect = false;
1716     }
1717 }
1718
1719 static void _ewk_view_smart_show(Evas_Object* ewkView)
1720 {
1721     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1722
1723 #if ENABLE(TIZEN_RECORDING_SURFACE)
1724     if (smartData->_priv->recordingSurfaceEnable) {
1725         unsigned int cnt = eina_list_count(smartData->_priv->recordingSurfaceSetList);
1726
1727         if (smartData->_priv->recordingSurfaceSetLoadFinished && !cnt) {
1728             float zoom = ewk_view_zoom_get(ewkView);
1729             smartData->_priv->recordingSurfaceSetState =  RECORDING_SURFACE_SET_STATE_INIT;
1730             smartData->_priv->recordingSurfaceSetList = ewk_recording_surface_set_free(smartData->_priv->recordingSurfaceSetList);
1731             smartData->_priv->recordingSurfaceSetList = ewk_recording_surface_set_base_record(smartData->_priv->recordingSurfaceSetList, ewkView, zoom);
1732             smartData->_priv->recordingSurfaceSetState = RECORDING_SURFACE_SET_STATE_COMPLETE;
1733         }
1734     }
1735 #endif
1736
1737 #if ENABLE(TIZEN_VIEW_ACTIVE_SET)
1738     ewk_view_active_set(ewkView, true);
1739 #endif
1740
1741     if (evas_object_clipees_get(smartData->base.clipper))
1742         evas_object_show(smartData->base.clipper);
1743     evas_object_show(smartData->backing_store);
1744 }
1745
1746 static void _ewk_view_smart_hide(Evas_Object* ewkView)
1747 {
1748     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1749
1750 #if ENABLE(TIZEN_RECORDING_SURFACE)
1751     if (smartData->_priv->recordingSurfaceEnable) {
1752         smartData->_priv->recordingSurfaceSetState = RECORDING_SURFACE_SET_STATE_INIT;
1753         smartData->_priv->recordingSurfaceSetList = ewk_recording_surface_set_free(smartData->_priv->recordingSurfaceSetList);
1754         smartData->_priv->recordingSurfaceSetScrollState = false;
1755         smartData->_priv->recordingSurfaceSetLoadFinished = false;
1756     }
1757 #endif
1758
1759     evas_object_hide(smartData->base.clipper);
1760     evas_object_hide(smartData->backing_store);
1761
1762 #if ENABLE(TIZEN_VIEW_ACTIVE_SET)
1763     ewk_view_active_set(ewkView, false);
1764 #endif
1765 }
1766
1767 static Eina_Bool _ewk_view_smart_contents_resize(Ewk_View_Smart_Data* smartData, int width, int height)
1768 {
1769     return true;
1770 }
1771
1772 static Eina_Bool _ewk_view_smart_zoom_set(Ewk_View_Smart_Data* smartData, float zoom, Evas_Coord centerX, Evas_Coord centerY)
1773 {
1774     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1775
1776     float currentScaleFactor = ewk_view_scale_get(smartData->self);
1777     if (currentScaleFactor == -1)
1778         return false;
1779
1780     int x, y;
1781     ewk_frame_scroll_pos_get(smartData->main_frame, &x, &y);
1782
1783     x = static_cast<int>(((x + centerX) / currentScaleFactor) * zoom) - centerX;
1784     y = static_cast<int>(((y + centerY) / currentScaleFactor) * zoom) - centerY;
1785
1786     priv->page->setPageScaleFactor(zoom, WebCore::LayoutPoint(x, y));
1787
1788 #if ENABLE(TIZEN_PLUGIN_EXT)
1789     /* update plugins position after weak zoom even if view's size and position were not changed
1790        to enusure plugins position after zoom bounce */
1791     smartData->changed.frame_rect = true;
1792     _ewk_view_smart_changed(smartData);
1793 #endif
1794
1795     return true;
1796 }
1797
1798 static void _ewk_view_smart_flush(Ewk_View_Smart_Data* smartData)
1799 {
1800     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1801     _ewk_view_repaints_flush(priv);
1802     _ewk_view_scrolls_flush(priv);
1803 }
1804
1805 static Eina_Bool _ewk_view_smart_pre_render_region(Ewk_View_Smart_Data* smartData, Evas_Coord x, Evas_Coord y, Evas_Coord width, Evas_Coord height, float zoom)
1806 {
1807     WRN("not supported by engine. smartData=%p area=%d,%d+%dx%d, zoom=%f",
1808         smartData, x, y, width, height, zoom);
1809     return false;
1810 }
1811
1812 static Eina_Bool _ewk_view_smart_pre_render_relative_radius(Ewk_View_Smart_Data* smartData, unsigned int number, float zoom)
1813 {
1814     WRN("not supported by engine. smartData=%p, n=%u zoom=%f",
1815         smartData, number, zoom);
1816     return false;
1817 }
1818
1819 #if ENABLE(TIZEN_PRE_RENDERING_ENABLE)
1820 static Eina_Bool _ewk_view_smart_pre_render_start(Ewk_View_Smart_Data* smartData, Eina_Bool forceToPrerender)
1821 #else
1822 static Eina_Bool _ewk_view_smart_pre_render_start(Ewk_View_Smart_Data* smartData)
1823 #endif
1824 {
1825     WRN("not supported by engine. smartData=%p", smartData);
1826     return false;
1827 }
1828
1829 static void _ewk_view_smart_pre_render_cancel(Ewk_View_Smart_Data* smartData)
1830 {
1831     WRN("not supported by engine. smartData=%p", smartData);
1832 }
1833
1834 static void _ewk_view_zoom_animated_mark_stop(Ewk_View_Smart_Data* smartData)
1835 {
1836     smartData->animated_zoom.zoom.start = 0.0;
1837     smartData->animated_zoom.zoom.end = 0.0;
1838     smartData->animated_zoom.zoom.current = 0.0;
1839 }
1840
1841 static void _ewk_view_zoom_animated_finish(Ewk_View_Smart_Data* smartData)
1842 {
1843     EWK_VIEW_PRIV_GET(smartData, priv);
1844     ecore_animator_del(priv->animatedZoom.animator);
1845     priv->animatedZoom.animator = 0;
1846     _ewk_view_zoom_animated_mark_stop(smartData);
1847     evas_object_smart_callback_call(smartData->self, "zoom,animated,end", 0);
1848 }
1849
1850 static float _ewk_view_zoom_animated_current(Ewk_View_Private_Data* priv)
1851 {
1852     double now = ecore_loop_time_get();
1853     double delta = now - priv->animatedZoom.time.start;
1854
1855     if (delta > priv->animatedZoom.time.duration)
1856         delta = priv->animatedZoom.time.duration;
1857     if (delta < 0.0) // time went back, clock adjusted?
1858         delta = 0.0;
1859
1860     delta /= priv->animatedZoom.time.duration;
1861
1862     return ((priv->animatedZoom.zoom.range * delta)
1863             + priv->animatedZoom.zoom.start);
1864 }
1865
1866 static Eina_Bool _ewk_view_zoom_animator_cb(void* data)
1867 {
1868     Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
1869     Evas_Coord centerX, centerY;
1870     EWK_VIEW_PRIV_GET(smartData, priv);
1871     double now = ecore_loop_time_get();
1872
1873     centerX = priv->animatedZoom.center.x;
1874     centerY = priv->animatedZoom.center.y;
1875
1876     // TODO: progressively center (cx, cy) -> (view.x + view.h/2, view.y + view.h/2)
1877     if (centerX >= smartData->view.w)
1878         centerX = smartData->view.w - 1;
1879     if (centerY >= smartData->view.h)
1880         centerY = smartData->view.h - 1;
1881
1882     if ((now >= priv->animatedZoom.time.end)
1883         || (now < priv->animatedZoom.time.start)) {
1884         _ewk_view_zoom_animated_finish(smartData);
1885         ewk_view_zoom_set(smartData->self, priv->animatedZoom.zoom.end, centerX, centerY);
1886         smartData->api->sc.calculate(smartData->self);
1887         return false;
1888     }
1889
1890     smartData->animated_zoom.zoom.current = _ewk_view_zoom_animated_current(priv);
1891     smartData->api->zoom_weak_set(smartData, smartData->animated_zoom.zoom.current, centerX, centerY);
1892     return true;
1893 }
1894
1895 static void _ewk_view_zoom_animation_start(Ewk_View_Smart_Data* smartData)
1896 {
1897     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1898     if (priv->animatedZoom.animator)
1899         return;
1900     priv->animatedZoom.animator = ecore_animator_add
1901                                        (_ewk_view_zoom_animator_cb, smartData);
1902 }
1903
1904 static WebCore::ViewportAttributes _ewk_view_viewport_attributes_compute(const Evas_Object* ewkView)
1905 {
1906     EWK_VIEW_SD_GET(ewkView, smartData); // how to notify about failure?
1907     EWK_VIEW_PRIV_GET(smartData, priv);
1908
1909     int desktop_width = 980;
1910     int device_dpi = WebCore::getDPI();
1911
1912     WebCore::IntRect available_rect = enclosingIntRect(priv->page->chrome()->client()->pageRect());
1913     WebCore::IntRect device_rect = enclosingIntRect(priv->page->chrome()->client()->windowRect());
1914
1915 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
1916     device_dpi = WebCore::getMobileDPI();
1917 #endif
1918
1919     WebCore::ViewportAttributes attributes = WebCore::computeViewportAttributes(priv->viewportArguments, desktop_width, device_rect.width(), device_rect.height(), device_dpi, available_rect.size());
1920     WebCore::restrictMinimumScaleFactorToViewportSize(attributes, available_rect.size());
1921     WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(attributes);
1922
1923 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
1924     const char* url = ewk_view_uri_get(ewkView);
1925     String problem_url(url);
1926     // FIXME: Emberwind is developed on fixed position value.
1927     // Therefore, if we do not revert dPR on it, game screen is to small to show full contents.
1928     if (problem_url.startsWith("http://operasoftware.github.com/Emberwind/")) {
1929         // revert applied devicePixelRatio
1930         attributes.layoutSize.setWidth((int)(attributes.layoutSize.width() * attributes.devicePixelRatio));
1931         attributes.layoutSize.setHeight((int)(attributes.layoutSize.height() * attributes.devicePixelRatio));
1932     }
1933
1934     float device_width, device_height;
1935     ewk_view_device_size_get(ewkView, &device_width, &device_height);
1936     WebCore::ViewportAttributes opt_attributes = ewk_viewport_attributes_optimize(attributes, device_rect.width(), device_rect.height(), device_width, device_height);
1937
1938     // FIXME : This code should be removed after finishing scale page patch.
1939     // Adjust zoom of tiled backing store to initialScale for now.
1940     Evas_Coord tw = defaultTileWidth;
1941 #if ENABLE(TIZEN_TILE_SIZE_GET)
1942     ewk_view_tiled_tile_size_get(ewkView, &tw, 0);
1943 #endif
1944     opt_attributes.initialScale = ROUNDED_ZOOM(tw, opt_attributes.initialScale);
1945     opt_attributes.minimumScale = ROUNDED_ZOOM(tw, opt_attributes.minimumScale);
1946     opt_attributes.maximumScale = ROUNDED_ZOOM(tw, opt_attributes.maximumScale);
1947     opt_attributes.devicePixelRatio = ROUNDED_ZOOM(tw, opt_attributes.devicePixelRatio);
1948
1949     return opt_attributes;
1950 #endif
1951     return attributes;
1952 }
1953
1954 static Eina_Bool _ewk_view_smart_disable_render(Ewk_View_Smart_Data* smartData)
1955 {
1956     WRN("not supported by engine. smartData=%p", smartData);
1957     return false;
1958 }
1959
1960 static Eina_Bool _ewk_view_smart_enable_render(Ewk_View_Smart_Data* smartData)
1961 {
1962     WRN("not supported by engine. smartData=%p", smartData);
1963     return false;
1964 }
1965 #if ENABLE(TIZEN_WINDOW_CLOSE)
1966 static void _ewk_view_smart_window_close(Ewk_View_Smart_Data* smartData)
1967 {
1968     evas_object_smart_callback_call(smartData->self, "window,close", 0);
1969 }
1970 #endif
1971
1972 #if ENABLE(TIZEN_DYNAMIC_LOADED_PLUGINS) || ENABLE(TIZEN_ON_OFF_SPECIFIED_PLUGINS)
1973 WebCore::PluginPackage* _ewk_view_plugin_for_mime_type(const Vector<WebCore::PluginPackage*> &pluginsDB, const char* mimeType)
1974 {
1975     if (mimeType) {
1976         WTF::String key = WTF::String(mimeType).lower();
1977
1978         Vector<WebCore::PluginPackage*, 2> pluginChoices;
1979
1980         for (unsigned int i = 0; i < pluginsDB.size(); i++) {
1981             WebCore::PluginPackage* plugin = pluginsDB[i];
1982
1983             if (plugin->mimeToDescriptions().contains(key))
1984                 pluginChoices.append(plugin);
1985         }
1986
1987         if (!pluginChoices.isEmpty()) {
1988             qsort(pluginChoices.data(), pluginChoices.size(), sizeof(WebCore::PluginPackage*), WebCore::PluginDatabase::preferredPluginCompare);
1989             return pluginChoices[0];
1990         }
1991     }
1992     return 0;
1993 }
1994
1995 Eina_Bool _ewk_view_setting_enable_plugins_set(Eina_Bool enable)
1996 {
1997     static Eina_Bool startApplication = true;
1998
1999     // If we have disabled option "Run flash/enable plugins" on start an application we don't want to scan the directories to find plugins
2000     if (!enable) {
2001         if (startApplication)
2002             WebCore::PluginDatabase::installedPlugins(false); // do installedPlugins without scanning directories
2003         else // if we've disabled option "Run flash/enable plugins" in runtime of application
2004             // Plugins aren't being destroyed now. Plugins will be destroyed by Browser if any tab/pages won't have any flash elements
2005             return false;
2006     } else { // enables reading plugins from default directories
2007         WebCore::PluginDatabase* pluginDatabase = WebCore::PluginDatabase::installedPlugins(false);
2008         if (pluginDatabase && pluginDatabase->pluginDirectories().isEmpty())
2009             pluginDatabase->setPluginDirectories(WebCore::PluginDatabase::defaultPluginDirectories());
2010     }
2011
2012     if (startApplication)
2013         startApplication = false;
2014
2015     return true;
2016 }
2017
2018 Eina_Bool _ewk_view_setting_enable_specified_plugin_set(Eina_Bool enable, const char* mimeType)
2019 {
2020     if (!mimeType)
2021         return false;
2022
2023     enable = !!enable;
2024
2025     WebCore::PluginDatabase* pluginDatabase = WebCore::PluginDatabase::installedPlugins(false); // don't do scan
2026
2027     if (!pluginDatabase)
2028         return false;
2029
2030     if (!pluginDatabase->plugins().isEmpty()) { // this means that there are plugins working
2031         const Vector<WebCore::PluginPackage*> pluginsDB = pluginDatabase->plugins();
2032         WebCore::PluginPackage* pluginForMime = _ewk_view_plugin_for_mime_type(pluginsDB, mimeType);
2033         if (pluginForMime)
2034             pluginForMime->setEnabled(enable);
2035     }
2036
2037 #if ENABLE(TIZEN_DYNAMIC_LOADED_PLUGINS) && ENABLE(TIZEN_ON_OFF_SPECIFIED_PLUGINS)
2038     // store info in hash map for situation that plugins will be unloaded and loaded again
2039     pluginDatabase->setSpecifiedPluginEnabled(WTF::String(mimeType), enable);
2040 #endif
2041     return true;
2042 }
2043 #endif
2044
2045 #if ENABLE(TIZEN_FIRST_PAINT_NOTI)
2046 static void _ewk_view_first_paint_noti(void* data, Evas_Object* ewkView, void* ev)
2047 {
2048     Ewk_View_Smart_Data* smartData = (Ewk_View_Smart_Data*) data;
2049     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2050
2051     /* dispatchDidFirstVisuallyNonEmptyLayout will set priv->flags.viewCleared to TRUE */
2052     if (priv->flags.viewCleared) {
2053         evas_object_smart_callback_call(smartData->self, "paint,first", 0);
2054         evas_object_smart_callback_del(ewkView, "paint,first", _ewk_view_first_paint_noti);
2055     }
2056 }
2057 #endif
2058
2059 #if ENABLE(TIZEN_VIEW_ACTIVE_SET)
2060 static Eina_Bool _ewk_view_smart_active_set(Ewk_View_Smart_Data* smartData, Eina_Bool value)
2061 {
2062     WRN("not supported by engine. smartData=%p", smartData);
2063     return false;
2064 }
2065 #endif
2066
2067 /**
2068  * Sending document loaded event to all plugins in specified view
2069  *
2070  * @param [in] view object
2071  */
2072 void _ewk_view_send_document_loaded_to_plugins(Evas_Object* ewkView)
2073 {
2074 #if ENABLE(TIZEN_EVAS_OBJECT_PLUGIN) && ENABLE(NETSCAPE_PLUGIN_API) && ENABLE(TIZEN_NPAPI)
2075     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2076     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2077
2078     TNPEvent tnpevent;
2079     tnpevent.type = TNPDocumentLoaded;
2080
2081     _iterate_frames(priv->mainFrame, _send_event_to_all_plugins, &tnpevent);
2082 #else
2083     LOG_ERROR("TIZEN_EVAS_OBJECT_PLUGIN or netscape api or tizen npapi are disabled. \n");
2084 #endif
2085 }
2086
2087 static const char* _ewk_view_editor_command_string_get(Ewk_View_Private_Data* priv, Ewk_Editor_Command ewkCommand)
2088 {
2089     static OwnPtr<Eina_Hash> editorCommandHash;
2090
2091     if (!editorCommandHash) {
2092         editorCommandHash = adoptPtr(eina_hash_int32_new(0));
2093         for (int i = 0; editorCommands[i].ewkEditorCommand != EWK_EDITOR_COMMAND_NONE; i++)
2094             eina_hash_add(editorCommandHash.get(), &editorCommands[i].ewkEditorCommand, editorCommands[i].editorCommandString);
2095     }
2096     return reinterpret_cast<const char*>(eina_hash_find(editorCommandHash.get(), &ewkCommand));
2097 }
2098
2099 Eina_Bool ewk_view_base_smart_set(Ewk_View_Smart_Class* api)
2100 {
2101     EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
2102
2103     if (api->version != EWK_VIEW_SMART_CLASS_VERSION) {
2104         EINA_LOG_CRIT
2105             ("Ewk_View_Smart_Class %p is version %lu while %lu was expected.",
2106             api, api->version, EWK_VIEW_SMART_CLASS_VERSION);
2107         return false;
2108     }
2109
2110     if (EINA_UNLIKELY(!_parent_sc.add))
2111         evas_object_smart_clipped_smart_set(&_parent_sc);
2112
2113     evas_object_smart_clipped_smart_set(&api->sc);
2114     api->sc.add = _ewk_view_smart_add;
2115     api->sc.del = _ewk_view_smart_del;
2116     api->sc.resize = _ewk_view_smart_resize;
2117     api->sc.move = _ewk_view_smart_move;
2118     api->sc.calculate = _ewk_view_smart_calculate;
2119     api->sc.show = _ewk_view_smart_show;
2120     api->sc.hide = _ewk_view_smart_hide;
2121 #if ENABLE(TIZEN_SMART_CLASS_TYPE_STR)
2122     api->sc.data = eina_stringshare_add("EWK_View"); /* used by type checking */
2123 #else
2124     api->sc.data = ewkViewTypeString; /* used by type checking */
2125 #endif
2126 #if !ENABLE(TIZEN_DAILY_UPVERSIONING)
2127     api->sc.callbacks = _ewk_view_callback_names;
2128 #endif
2129     api->contents_resize = _ewk_view_smart_contents_resize;
2130     api->zoom_set = _ewk_view_smart_zoom_set;
2131     api->flush = _ewk_view_smart_flush;
2132     api->pre_render_region = _ewk_view_smart_pre_render_region;
2133     api->pre_render_relative_radius = _ewk_view_smart_pre_render_relative_radius;
2134     api->pre_render_start = _ewk_view_smart_pre_render_start;
2135     api->pre_render_cancel = _ewk_view_smart_pre_render_cancel;
2136     api->disable_render = _ewk_view_smart_disable_render;
2137     api->enable_render = _ewk_view_smart_enable_render;
2138 #if ENABLE(TIZEN_VIEW_ACTIVE_SET)
2139     api->active_set = _ewk_view_smart_active_set;
2140 #endif
2141
2142     api->focus_in = _ewk_view_smart_focus_in;
2143     api->focus_out = _ewk_view_smart_focus_out;
2144     api->mouse_wheel = _ewk_view_smart_mouse_wheel;
2145     api->mouse_down = _ewk_view_smart_mouse_down;
2146     api->mouse_up = _ewk_view_smart_mouse_up;
2147     api->mouse_move = _ewk_view_smart_mouse_move;
2148     api->key_down = _ewk_view_smart_key_down;
2149     api->key_up = _ewk_view_smart_key_up;
2150
2151     api->add_console_message = _ewk_view_smart_add_console_message;
2152     api->run_javascript_alert = _ewk_view_smart_run_javascript_alert;
2153     api->run_javascript_confirm = _ewk_view_smart_run_javascript_confirm;
2154     api->run_javascript_prompt = _ewk_view_smart_run_javascript_prompt;
2155     api->should_interrupt_javascript = _ewk_view_smart_should_interrupt_javascript;
2156
2157 #if ENABLE(TIZEN_WINDOW_CLOSE)
2158     api->window_close = _ewk_view_smart_window_close;
2159 #endif
2160     return true;
2161 }
2162
2163 void ewk_view_fixed_layout_size_set(Evas_Object* ewkView, Evas_Coord width, Evas_Coord height)
2164 {
2165     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2166     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2167
2168     WebCore::FrameView* view = priv->mainFrame->view();
2169     if (!view)
2170         return;
2171
2172     WebCore::IntSize layoutSize(width, height);
2173 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
2174     if (priv->viewportAttributes.width != width || priv->viewportAttributes.height != height) {
2175         priv->viewportAttributes.width = width;
2176         priv->viewportAttributes.height = height;
2177     }
2178 #endif
2179     if (layoutSize.width() <= 0 && layoutSize.height() <= 0) {
2180         if (!view->useFixedLayout())
2181             return;
2182         view->setUseFixedLayout(false);
2183     } else {
2184         WebCore::IntSize fixedLayoutSize = view->fixedLayoutSize();
2185         if (fixedLayoutSize == layoutSize)
2186             return;
2187         view->setFixedLayoutSize(layoutSize);
2188         view->setUseFixedLayout(true);
2189     }
2190
2191     view->setNeedsLayout();
2192 }
2193
2194 void ewk_view_fixed_layout_size_get(const Evas_Object* ewkView, Evas_Coord* width, Evas_Coord* height)
2195 {
2196     if (width)
2197         *width = 0;
2198     if (height)
2199         *height = 0;
2200     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2201     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2202     WebCore::FrameView* view = priv->mainFrame->view();
2203     if (view->useFixedLayout()) {
2204         WebCore::IntSize size = view->fixedLayoutSize();
2205         if (width)
2206             *width = size.width();
2207         if (height)
2208             *height = size.height();
2209     }
2210 }
2211
2212 void ewk_view_theme_set(Evas_Object* ewkView, const char* path)
2213 {
2214     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2215     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2216     if (!eina_stringshare_replace(&priv->settings.theme, path))
2217         return;
2218
2219     WebCore::FrameView* view = priv->mainFrame->view();
2220     if (view) {
2221         view->setEdjeTheme(WTF::String(path));
2222         priv->page->theme()->themeChanged();
2223     }
2224
2225 }
2226
2227 const char* ewk_view_theme_get(const Evas_Object* ewkView)
2228 {
2229     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2230     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2231     return priv->settings.theme;
2232 }
2233
2234 Evas_Object* ewk_view_frame_main_get(const Evas_Object* ewkView)
2235 {
2236     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2237     return smartData->main_frame;
2238 }
2239
2240 Evas_Object* ewk_view_frame_focused_get(const Evas_Object* ewkView)
2241 {
2242     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2243     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2244
2245     WebCore::Frame* core = priv->page->focusController()->focusedFrame();
2246     if (!core)
2247         return 0;
2248
2249     WebCore::FrameLoaderClientEfl* client = static_cast<WebCore::FrameLoaderClientEfl*>(core->loader()->client());
2250     if (!client)
2251         return 0;
2252     return client->webFrame();
2253 }
2254
2255 Eina_Bool ewk_view_uri_set(Evas_Object* ewkView, const char* uri)
2256 {
2257     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2258     return ewk_frame_uri_set(smartData->main_frame, uri);
2259 }
2260
2261 const char* ewk_view_uri_get(const Evas_Object* ewkView)
2262 {
2263     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2264     return ewk_frame_uri_get(smartData->main_frame);
2265 }
2266
2267 const Ewk_Text_With_Direction* ewk_view_title_get(const Evas_Object* ewkView)
2268 {
2269     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2270     return ewk_frame_title_get(smartData->main_frame);
2271 }
2272
2273 Eina_Bool ewk_view_editable_get(const Evas_Object* ewkView)
2274 {
2275     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2276     return ewk_frame_editable_get(smartData->main_frame);
2277 }
2278
2279 void ewk_view_bg_color_set(Evas_Object* ewkView, int red, int green, int blue, int alpha)
2280 {
2281     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2282     EINA_SAFETY_ON_NULL_RETURN(smartData->api);
2283     EINA_SAFETY_ON_NULL_RETURN(smartData->api->bg_color_set);
2284
2285     if (alpha < 0) {
2286         WRN("Alpha less than zero (%d).", alpha);
2287         alpha = 0;
2288     } else if (alpha > 255) {
2289         WRN("Alpha is larger than 255 (%d).", alpha);
2290         alpha = 255;
2291     }
2292
2293 #define CHECK_PREMUL_COLOR(color, alpha)                                        \
2294     if (color < 0) {                                                        \
2295         WRN("Color component " #color " is less than zero (%d).", color);         \
2296         color = 0;                                                          \
2297     } else if (color > alpha) {                                                 \
2298         WRN("Color component " #color " is greater than alpha (%d, alpha=%d).", \
2299             color, alpha);                                                      \
2300         color = alpha;                                                          \
2301     }
2302     CHECK_PREMUL_COLOR(red, alpha);
2303     CHECK_PREMUL_COLOR(green, alpha);
2304     CHECK_PREMUL_COLOR(blue, alpha);
2305 #undef CHECK_PREMUL_COLOR
2306
2307     smartData->bg_color.r = red;
2308     smartData->bg_color.g = green;
2309     smartData->bg_color.b = blue;
2310     smartData->bg_color.a = alpha;
2311
2312     smartData->api->bg_color_set(smartData, red, green, blue, alpha);
2313
2314     WebCore::FrameView* view = smartData->_priv->mainFrame->view();
2315     if (view) {
2316         WebCore::Color color;
2317
2318         if (!alpha)
2319             color = WebCore::Color(0, 0, 0, 0);
2320         else if (alpha == 255)
2321             color = WebCore::Color(red, green, blue, alpha);
2322         else
2323             color = WebCore::Color(red * 255 / alpha, green * 255 / alpha, blue * 255 / alpha, alpha);
2324
2325         view->updateBackgroundRecursively(color, !alpha);
2326     }
2327 }
2328
2329 void ewk_view_bg_color_get(const Evas_Object* ewkView, int* red, int* green, int* blue, int* alpha)
2330 {
2331     if (red)
2332         *red = 0;
2333     if (green)
2334         *green = 0;
2335     if (blue)
2336         *blue = 0;
2337     if (alpha)
2338         *alpha = 0;
2339     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2340     if (red)
2341         *red = smartData->bg_color.r;
2342     if (green)
2343         *green = smartData->bg_color.g;
2344     if (blue)
2345         *blue = smartData->bg_color.b;
2346     if (alpha)
2347         *alpha = smartData->bg_color.a;
2348 }
2349
2350 #if ENABLE(TIZEN_BG_RECT_SUPPORT)
2351 /**
2352  * Set view's background rect color
2353  *
2354  * This is used for setting the color of the rectangle behind the view. Unlike
2355  * what is done in ewk_view_bg_color_set(), this color is not passed to WebCore.
2356  * It's sole purpose is instead to put a rectangle behind the view in order to
2357  * be possible to have different backgrounds for bouncer effects and for areas
2358  * not rendered yet.
2359  *
2360  * Just as in Evas, colors are pre-multiplied, so 50% red is
2361  * (128, 0, 0, 128) and not (255, 0, 0, 128)!
2362  *
2363  * @param ewkView view object to change.
2364  * @param r red component.
2365  * @param g green component.
2366  * @param b blue component.
2367  * @param a transparency.
2368  */
2369 void ewk_view_bg_rect_color_set(Evas_Object* ewkView, int r, int g, int b, int a)
2370 {
2371     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2372     EINA_SAFETY_ON_NULL_RETURN(smartData->bg_rect.bg_rect);
2373
2374     if (a < 0) {
2375         WRN("Alpha less than zero (%d).", a);
2376         a = 0;
2377     } else if (a > 255) {
2378         WRN("Alpha is larger than 255 (%d).", a);
2379         a = 255;
2380     }
2381
2382 #define CHECK_PREMUL_COLOR(c, a)                                        \
2383     if (c < 0) {                                                        \
2384         WRN("Color component "#c" is less than zero (%d).", c);         \
2385         c = 0;                                                          \
2386     } else if (c > a) {                                                 \
2387         WRN("Color component "#c" is greater than alpha (%d, alpha=%d).", \
2388             c, a);                                                      \
2389         c = a;                                                          \
2390     }
2391     CHECK_PREMUL_COLOR(r, a);
2392     CHECK_PREMUL_COLOR(g, a);
2393     CHECK_PREMUL_COLOR(b, a);
2394 #undef CHECK_PREMUL_COLOR
2395
2396     smartData->bg_rect.color.r = r;
2397     smartData->bg_rect.color.g = g;
2398     smartData->bg_rect.color.b = b;
2399     smartData->bg_rect.color.a = a;
2400     evas_object_color_set(smartData->bg_rect.bg_rect, smartData->bg_rect.color.r, smartData->bg_rect.color.g,
2401             smartData->bg_rect.color.b, smartData->bg_rect.color.a);
2402 }
2403
2404 /**
2405  * Get view's background rect color
2406  *
2407  * This is used for getting the color of the rectangle behind the view. Unlike
2408  * what is done in ewk_view_bg_color_get(), this color is not passed to WebCore.
2409  * It's sole purpose is instead to put a rectangle behind the view in order to
2410  * be possible to have different backgrounds for bouncer effects and for areas
2411  * not rendered yet.
2412  *
2413  * Just as in Evas, colors are pre-multiplied, so 50% red is
2414  * (128, 0, 0, 128) and not (255, 0, 0, 128)!
2415  *
2416  * @param ewkView view object to query.
2417  * @param r where to return red color component.
2418  * @param g where to return green color component.
2419  * @param b where to return blue color component.
2420  * @param a where to return alpha value.
2421  */
2422 void ewk_view_bg_rect_color_get(const Evas_Object* ewkView, int* r, int* g, int* b, int* a)
2423 {
2424     if (r)
2425         *r = 0;
2426     if (g)
2427         *g = 0;
2428     if (b)
2429         *b = 0;
2430     if (a)
2431         *a = 0;
2432     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2433     if (r)
2434         *r = smartData->bg_rect.color.r;
2435     if (g)
2436         *g = smartData->bg_rect.color.g;
2437     if (b)
2438         *b = smartData->bg_rect.color.b;
2439     if (a)
2440         *a = smartData->bg_rect.color.a;
2441 }
2442 #endif
2443
2444 /**
2445  * Search the given text string in document.
2446  *
2447  * @param ewkView view object where to search text.
2448  * @param string reference string to search.
2449  * @param case_sensitive if search should be case sensitive or not.
2450  * @param forward if search is from cursor and on or backwards.
2451  * @param wrap if search should wrap at end.
2452  *
2453  * @return @c true if found, @c false if not or failure.
2454  */
2455 Eina_Bool ewk_view_text_search(const Evas_Object* ewkView, const char* string, Eina_Bool caseSensitive, Eina_Bool forward, Eina_Bool wrap)
2456 {
2457     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2458     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2459     EINA_SAFETY_ON_NULL_RETURN_VAL(string, false);
2460     WTF::TextCaseSensitivity sensitive;
2461     WebCore::FindDirection direction;
2462
2463     if (caseSensitive)
2464         sensitive = WTF::TextCaseSensitive;
2465     else
2466         sensitive = WTF::TextCaseInsensitive;
2467
2468     if (forward)
2469         direction = WebCore::FindDirectionForward;
2470     else
2471         direction = WebCore::FindDirectionBackward;
2472
2473     return priv->page->findString(String::fromUTF8(string), sensitive, direction, wrap);
2474 }
2475
2476 /**
2477  * Mark matches the given text string in document.
2478  *
2479  * @param ewkView view object where to search text.
2480  * @param string reference string to match.
2481  * @param caseSensitive if match should be case sensitive or not.
2482  * @param heightighlight if matches should be highlighted.
2483  * @param limit maximum amount of matches, or zero to unlimited.
2484  *
2485  * @return number of matches.
2486  */
2487 unsigned int ewk_view_text_matches_mark(Evas_Object* ewkView, const char* string, Eina_Bool caseSensitive, Eina_Bool highlight, unsigned int limit)
2488 {
2489     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2490     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2491     EINA_SAFETY_ON_NULL_RETURN_VAL(string, 0);
2492     WTF::TextCaseSensitivity sensitive;
2493
2494     if (caseSensitive)
2495         sensitive = WTF::TextCaseSensitive;
2496     else
2497         sensitive = WTF::TextCaseInsensitive;
2498
2499     return priv->page->markAllMatchesForText(String::fromUTF8(string), sensitive, highlight, limit);
2500 }
2501
2502 Eina_Bool ewk_view_text_matches_unmark_all(Evas_Object* ewkView)
2503 {
2504     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2505     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2506     priv->page->unmarkAllTextMatches();
2507     return true;
2508 }
2509
2510 Eina_Bool ewk_view_text_matches_highlight_set(Evas_Object* ewkView, Eina_Bool highlight)
2511 {
2512     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2513     return ewk_frame_text_matches_highlight_set(smartData->main_frame, highlight);
2514 }
2515
2516 Eina_Bool ewk_view_text_matches_highlight_get(const Evas_Object* ewkView)
2517 {
2518     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2519     return ewk_frame_text_matches_highlight_get(smartData->main_frame);
2520 }
2521
2522 Eina_Bool ewk_view_editable_set(Evas_Object* ewkView, Eina_Bool editable)
2523 {
2524     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2525     return ewk_frame_editable_set(smartData->main_frame, editable);
2526 }
2527
2528 char* ewk_view_selection_get(const Evas_Object* ewkView)
2529 {
2530     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2531     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2532     CString selectedString = priv->page->focusController()->focusedOrMainFrame()->editor()->selectedText().utf8();
2533     if (selectedString.isNull())
2534         return 0;
2535     return strdup(selectedString.data());
2536 }
2537
2538 Eina_Bool ewk_view_editor_command_execute(const Evas_Object* ewkView, const Ewk_Editor_Command command, const char* value)
2539 {
2540     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2541     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2542
2543 #if ENABLE(TIZEN_EDITOR_COMMAND)
2544     case EWK_EDITOR_COMMAND_TOGGLE_BOLD:
2545         return _ewk_view_editor_command(priv, "ToggleBold");
2546     case EWK_EDITOR_COMMAND_TOGGLE_ITALIC:
2547         return _ewk_view_editor_command(priv, "ToggleItalic");
2548     case EWK_EDITOR_COMMAND_TOGGLE_UNDERLINE:
2549         return _ewk_view_editor_command(priv, "ToggleUnderline");
2550     case EWK_EDITOR_COMMAND_UNDO:
2551         return _ewk_view_editor_command(priv, "Undo");
2552     case EWK_EDITOR_COMMAND_REDO:
2553         return _ewk_view_editor_command(priv, "Redo");
2554     case EWK_EDITOR_COMMAND_INDENT:
2555         return _ewk_view_editor_command(priv, "Indent");
2556     case EWK_EDITOR_COMMAND_OUTDENT:
2557         return _ewk_view_editor_command(priv, "Outdent");
2558     case EWK_EDITOR_COMMAND_INSERT_ORDEREDLIST:
2559         return _ewk_view_editor_command(priv, "InsertOrderedList");
2560     case EWK_EDITOR_COMMAND_INSERT_UNORDEREDLIST:
2561         return _ewk_view_editor_command(priv, "InsertUnorderedList");
2562     case EWK_EDITOR_COMMAND_INSERT_PARAGRAPH:
2563         return _ewk_view_editor_command(priv, "InsertParagraph");
2564     case EWK_EDITOR_COMMAND_ALIGN_CENTER:
2565         return _ewk_view_editor_command(priv, "AlignCenter");
2566     case EWK_EDITOR_COMMAND_ALIGN_JUSTIFIED:
2567         return _ewk_view_editor_command(priv, "AlignJustified");
2568     case EWK_EDITOR_COMMAND_ALIGN_LEFT:
2569         return _ewk_view_editor_command(priv, "AlignLeft");
2570     case EWK_EDITOR_COMMAND_ALIGN_RIGHT:
2571         return _ewk_view_editor_command(priv, "AlignRight");
2572     case EWK_EDITOR_COMMAND_BACKCOLOR:
2573         return _ewk_view_editor_command(priv, "BackColor", value);
2574     case EWK_EDITOR_COMMAND_FORECOLOR:
2575         return _ewk_view_editor_command(priv, "ForeColor", value);
2576     case EWK_EDITOR_COMMAND_FONTSIZE:
2577         return _ewk_view_editor_command(priv, "FontSize", value);
2578     case EWK_EDITOR_COMMAND_INSERT_HTML:
2579         return _ewk_view_editor_command(priv, "InsertHTML", value);
2580     case EWK_EDITOR_COMMAND_MOVE_TO_BEGINNING_OF_DOCUMENT:
2581         return _ewk_view_editor_command(priv, "MoveToBeginningOfDocument");
2582 #endif // ENABLE(TIZEN_EDITOR_COMMAND)
2583     default:
2584
2585     const char* commandString = _ewk_view_editor_command_string_get(priv, command);
2586     if (!commandString)
2587         return false;
2588
2589     return priv->page->focusController()->focusedOrMainFrame()->editor()->command(commandString).execute(WTF::String::fromUTF8(value));
2590 }
2591
2592 Eina_Bool ewk_view_context_menu_forward_event(Evas_Object* ewkView, const Evas_Event_Mouse_Down* downEvent)
2593 {
2594 #if ENABLE(CONTEXT_MENUS)
2595     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2596     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2597     Eina_Bool mouse_press_handled = false;
2598
2599     priv->page->contextMenuController()->clearContextMenu();
2600     WebCore::Frame* mainFrame = priv->page->mainFrame();
2601     Evas_Coord x, y;
2602     evas_object_geometry_get(smartData->self, &x, &y, 0, 0);
2603
2604     WebCore::PlatformMouseEvent event(downEvent, WebCore::IntPoint(x, y));
2605
2606     if (mainFrame->view()) {
2607         mouse_press_handled =
2608             mainFrame->eventHandler()->handleMousePressEvent(event);
2609     }
2610
2611     if (mainFrame->eventHandler()->sendContextMenuEvent(event))
2612         return false;
2613
2614     WebCore::ContextMenu* coreMenu =
2615         priv->page->contextMenuController()->contextMenu();
2616     if (!coreMenu) {
2617         // WebCore decided not to create a context menu, return true if event
2618         // was handled by handleMouseReleaseEvent
2619         return mouse_press_handled;
2620     }
2621
2622     return true;
2623 #else
2624     return false;
2625 #endif
2626 }
2627
2628 double ewk_view_load_progress_get(const Evas_Object* ewkView)
2629 {
2630     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
2631     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1.0);
2632     return priv->page->progress()->estimatedProgress();
2633 }
2634
2635 Eina_Bool ewk_view_stop(Evas_Object* ewkView)
2636 {
2637     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2638     evas_object_smart_callback_call(ewkView, "load,stop", 0);
2639     return ewk_frame_stop(smartData->main_frame);
2640 }
2641
2642 Eina_Bool ewk_view_reload(Evas_Object* ewkView)
2643 {
2644     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2645     return ewk_frame_reload(smartData->main_frame);
2646 }
2647
2648 Eina_Bool ewk_view_reload_full(Evas_Object* ewkView)
2649 {
2650     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2651     return ewk_frame_reload_full(smartData->main_frame);
2652 }
2653
2654 Eina_Bool ewk_view_back(Evas_Object* ewkView)
2655 {
2656     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2657     return ewk_frame_back(smartData->main_frame);
2658 }
2659
2660 Eina_Bool ewk_view_forward(Evas_Object* ewkView)
2661 {
2662     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2663     return ewk_frame_forward(smartData->main_frame);
2664 }
2665
2666 Eina_Bool ewk_view_load_in_progress(Evas_Object* ewkView)
2667 {
2668 #if ENABLE(TIZEN_LOADING_STATE_CHECK)
2669     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2670     return ewk_frame_load_in_progress(smartData->main_frame);
2671 #else
2672     LOG_ERROR("TIZEN_LOADING_STATE_CHECK is disabled. \n");
2673     return false;
2674 #endif
2675 }
2676
2677 Eina_Bool ewk_view_contents_set(Evas_Object* ewkView, const char* contents, size_t contents_size, const char* mime_type, const char* encoding, const char* base_uri)
2678 {
2679 #if ENABLE(TIZEN_CONTENTS_SET)
2680     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2681     return ewk_frame_contents_set(smartData->main_frame, (char*)contents, contents_size, mime_type, encoding, base_uri);
2682 #else
2683     LOG_ERROR("TIZEN_CONTENTS_SET is disabled. \n");
2684     return false;
2685 #endif
2686 }
2687
2688 Eina_Bool ewk_view_navigate(Evas_Object* ewkView, int steps)
2689 {
2690     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2691     return ewk_frame_navigate(smartData->main_frame, steps);
2692 }
2693
2694 Eina_Bool ewk_view_back_possible(Evas_Object* ewkView)
2695 {
2696     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2697     return ewk_frame_back_possible(smartData->main_frame);
2698 }
2699
2700 Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView)
2701 {
2702     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2703     return ewk_frame_forward_possible(smartData->main_frame);
2704 }
2705
2706 Eina_Bool ewk_view_navigate_possible(Evas_Object* ewkView, int steps)
2707 {
2708     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2709     return ewk_frame_navigate_possible(smartData->main_frame, steps);
2710 }
2711
2712 Eina_Bool ewk_view_history_enable_get(const Evas_Object* ewkView)
2713 {
2714     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2715     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2716     return static_cast<WebCore::BackForwardListImpl*>(priv->page->backForwardList())->enabled();
2717 }
2718
2719 Eina_Bool ewk_view_history_enable_set(Evas_Object* ewkView, Eina_Bool enable)
2720 {
2721     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2722     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2723     static_cast<WebCore::BackForwardListImpl*>(priv->page->backForwardList())->setEnabled(enable);
2724     return true;
2725 }
2726
2727 Ewk_History* ewk_view_history_get(const Evas_Object* ewkView)
2728 {
2729     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2730     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2731     if (!static_cast<WebCore::BackForwardListImpl*>(priv->page->backForwardList())->enabled()) {
2732         ERR("asked history, but it's disabled! Returning 0!");
2733         return 0;
2734     }
2735     return priv->history;
2736 }
2737
2738 Eina_Bool ewk_view_visited_link_add(Evas_Object* ewkView, const char* visitedUrl)
2739 {
2740     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2741     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2742
2743     EINA_SAFETY_ON_NULL_RETURN_VAL(priv->page, false);
2744     EINA_SAFETY_ON_NULL_RETURN_VAL(priv->page->groupPtr(), false);
2745
2746     WebCore::KURL kurl(WebCore::KURL(), WTF::String::fromUTF8(visitedUrl));
2747     priv->page->groupPtr()->addVisitedLink(kurl);
2748     return true;
2749 }
2750
2751 float ewk_view_zoom_get(const Evas_Object* ewkView)
2752 {
2753     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
2754
2755     return ewk_view_scale_get(ewkView);
2756 }
2757
2758 Eina_Bool ewk_view_zoom_set(Evas_Object* ewkView, float zoom, Evas_Coord centerX, Evas_Coord centerY)
2759 {
2760     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2761     EWK_VIEW_PRIV_GET(smartData, priv);
2762
2763     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
2764     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api->zoom_set, false);
2765
2766     Eina_Bool ret = true;
2767 #if ENABLE(TIZEN_WEBCORE_SELECTIVE_RENDERING)
2768     WebCore::FrameView* view = priv->mainFrame->view();
2769     view->clearDelayedUpdateRegions();
2770 #endif
2771     if (!priv->settings.zoomRange.userScalable) {
2772         WRN("userScalable is false");
2773         return false;
2774     }
2775
2776     if (zoom < priv->settings.zoomRange.minScale) {
2777         WRN("zoom level is < %f : %f", (double)priv->settings.zoomRange.minScale, (double)zoom);
2778 #if ENABLE(TIZEN_FIX_MESH_TILE_ISSUE)
2779         zoom = priv->settings.zoomRange.minScale;
2780         ret = false;
2781 #else
2782         return false;
2783 #endif
2784     }
2785     if (zoom > priv->settings.zoomRange.maxScale) {
2786         WRN("zoom level is > %f : %f", (double)priv->settings.zoomRange.maxScale, (double)zoom);
2787 #if ENABLE(TIZEN_FIX_MESH_TILE_ISSUE)
2788         zoom = priv->settings.zoomRange.maxScale;
2789         ret = false;
2790 #else
2791         return false;
2792 #endif
2793     }
2794
2795 #if USE(ACCELERATED_COMPOSITING) && ENABLE(TIZEN_ACCELERATED_COMPOSITING)
2796     if (priv->compositingActive) {
2797         priv->compositor->setZoom(zoom);
2798         ewk_view_mark_for_sync(ewkView, false);
2799     }
2800 #endif // USE(ACCELERATED_COMPOSITING) && ENABLE(TIZEN_ACCELERATED_COMPOSITING)
2801     _ewk_view_zoom_animated_mark_stop(smartData);
2802
2803 #if ENABLE(TIZEN_RECORDING_SURFACE)
2804     if (priv->recordingSurfaceEnable && priv->recordingSurfaceSetLoadFinished) {
2805         priv->recordingSurfaceSetState = RECORDING_SURFACE_SET_STATE_INIT;
2806         priv->recordingSurfaceSetList = ewk_recording_surface_set_free(priv->recordingSurfaceSetList);
2807         priv->recordingSurfaceSetList = ewk_recording_surface_set_base_record(priv->recordingSurfaceSetList, ewkView, zoom);
2808         priv->recordingSurfaceSetState = RECORDING_SURFACE_SET_STATE_COMPLETE;
2809         return smartData->api->zoom_set(smartData, zoom, centerX, centerY);
2810     }
2811 #if ENABLE(TIZEN_FIX_MESH_TILE_ISSUE)
2812         return ret & smartData->api->zoom_set(smartData, zoom, centerX, centerY);
2813 #else
2814         return smartData->api->zoom_set(smartData, zoom, centerX, centerY);
2815 #endif
2816 #else
2817 #if ENABLE(TIZEN_FIX_MESH_TILE_ISSUE)
2818 #if ENABLE(TIZEN_FIX_PAINT_BEFORE_NONEMPTYLAYOUT_ISSUE)
2819     if (!view->isVisuallyNonEmpty())
2820         ret = ret & _ewk_view_smart_zoom_set(smartData, zoom, centerX, centerY);
2821     else
2822         ret = ret & smartData->api->zoom_set(smartData, zoom, centerX, centerY);
2823 #else
2824     ret = ret & smartData->api->zoom_set(smartData, zoom, centerX, centerY);
2825 #endif
2826 #if ENABLE(TIZEN_PRE_RENDERING_ENABLE)
2827     ewk_view_pre_render_start(ewkView);
2828 #endif
2829 #if ENABLE(TIZEN_RECORDING_SURFACE)
2830     ewk_view_recording_surface_start(ewkView);
2831 #endif
2832     return ret;
2833 #else
2834     return smartData->api->zoom_set(smartData, zoom, centerX, centerY);
2835 #endif
2836 #endif // ENABLE(TIZEN_RECORDING_SURFACE)
2837 }
2838
2839 float ewk_view_page_zoom_get(const Evas_Object* ewkView)
2840 {
2841     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
2842     return ewk_frame_page_zoom_get(smartData->main_frame);
2843 }
2844
2845 Eina_Bool ewk_view_page_zoom_set(Evas_Object* ewkView, float pageZoomFactor)
2846 {
2847     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2848     return ewk_frame_page_zoom_set(smartData->main_frame, pageZoomFactor);
2849 }
2850
2851 float ewk_view_scale_get(const Evas_Object* ewkView)
2852 {
2853     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
2854     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1.0);
2855     return priv->page->pageScaleFactor();
2856 }
2857
2858 Eina_Bool ewk_view_scale_set(Evas_Object* ewkView, float scaleFactor, Evas_Coord scrollX, Evas_Coord scrollY)
2859 {
2860     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2861     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2862
2863     float currentScaleFactor = ewk_view_scale_get(ewkView);
2864     if (currentScaleFactor == -1)
2865         return false;
2866
2867     priv->page->setPageScaleFactor(scaleFactor, WebCore::IntPoint(scrollX, scrollY));
2868     return true;
2869 }
2870
2871 float ewk_view_text_zoom_get(const Evas_Object* ewkView)
2872 {
2873     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
2874     return ewk_frame_text_zoom_get(smartData->main_frame);
2875 }
2876
2877 Eina_Bool ewk_view_text_zoom_set(Evas_Object* ewkView, float textZoomFactor)
2878 {
2879     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2880     return ewk_frame_text_zoom_set(smartData->main_frame, textZoomFactor);
2881 }
2882
2883 Eina_Bool ewk_view_zoom_weak_smooth_scale_get(const Evas_Object* ewkView)
2884 {
2885     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2886     return smartData->zoom_weak_smooth_scale;
2887 }
2888
2889 void ewk_view_zoom_weak_smooth_scale_set(Evas_Object* ewkView, Eina_Bool smoothScale)
2890 {
2891     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2892     smoothScale = !!smoothScale;
2893     if (smartData->zoom_weak_smooth_scale == smoothScale)
2894         return;
2895     smartData->zoom_weak_smooth_scale = smoothScale;
2896     EINA_SAFETY_ON_NULL_RETURN(smartData->api);
2897     EINA_SAFETY_ON_NULL_RETURN(smartData->api->zoom_weak_smooth_scale_set);
2898     smartData->api->zoom_weak_smooth_scale_set(smartData, smoothScale);
2899 }
2900
2901 Eina_Bool ewk_view_zoom_weak_set(Evas_Object* ewkView, float zoom, Evas_Coord centerX, Evas_Coord centerY)
2902 {
2903     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2904     EWK_VIEW_PRIV_GET(smartData, priv);
2905
2906     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, EINA_FALSE);
2907     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api->zoom_weak_set, EINA_FALSE);
2908
2909 #if ENABLE(TIZEN_WEAK_ZOOM_POSITION)
2910     zoom = ROUNDED_ZOOM(defaultTileWidth, zoom);
2911 #endif
2912
2913 #if ENABLE(TIZEN_BG_RECT_SUPPORT)
2914     double limit_max_zoom_level = priv->settings.zoomRange.maxScale * (1.0f + ZOOM_BOUNCE_LIMIT_RATIO);
2915     double limit_min_zoom_level = priv->settings.zoomRange.minScale * (1.0f - ZOOM_BOUNCE_LIMIT_RATIO);
2916
2917     if (limit_min_zoom_level < 0)
2918         limit_min_zoom_level = 0;
2919 #endif
2920
2921     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
2922     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api->zoom_weak_set, false);
2923
2924     if (!priv->settings.zoomRange.userScalable) {
2925         WRN("userScalable is false");
2926         return false;
2927     }
2928
2929 #if ENABLE(TIZEN_BG_RECT_SUPPORT)
2930     if (zoom < limit_min_zoom_level) {
2931         WRN("zoom level is < %f : %f", (double)limit_min_zoom_level, (double)zoom);
2932         return false;
2933     }
2934     if (zoom > limit_max_zoom_level) {
2935         WRN("zoom level is > %f : %f", (double) limit_max_zoom_level, (double)zoom);
2936         return false;
2937     }
2938 #else
2939     if (zoom < priv->settings.zoomRange.minScale) {
2940         WRN("zoom level is < %f : %f", priv->settings.zoomRange.minScale, zoom);
2941         return false;
2942     }
2943     if (zoom > priv->settings.zoomRange.maxScale) {
2944         WRN("zoom level is > %f : %f", priv->settings.zoomRange.maxScale, zoom);
2945         return false;
2946     }
2947 #endif
2948
2949     smartData->animated_zoom.zoom.start = ewk_frame_page_zoom_get(smartData->main_frame);
2950     smartData->animated_zoom.zoom.end = zoom;
2951     smartData->animated_zoom.zoom.current = zoom;
2952
2953 #if ENABLE(TIZEN_EVAS_OBJECT_PLUGIN) && ENABLE(TIZEN_PLUGIN_EXT) && ENABLE(NETSCAPE_PLUGIN_API) && ENABLE(TIZEN_NPAPI)
2954     TNPEvent tnpevent;
2955     tnpevent.type = TNPWeakZoom;
2956     // add view's location to (centerX, centerY)
2957     // because (centerX, centerY)'s basis is webview's left-top
2958     tnpevent.zoom.position.x = centerX + smartData->view.x;
2959     tnpevent.zoom.position.y = centerY + smartData->view.y;
2960     tnpevent.zoom.zoomFactor = zoom / smartData->animated_zoom.zoom.start;
2961
2962     _iterate_frames(priv->mainFrame, _send_event_to_all_plugins, &tnpevent);
2963 #endif // ENABLE(TIZEN_EVAS_OBJECT_PLUGIN) && ENABLE(TIZEN_PLUGIN_EXT) && ENABLE(NETSCAPE_PLUGIN_API) && ENABLE(TIZEN_NPAPI)
2964
2965 #if USE(ACCELERATED_COMPOSITING) && ENABLE(TIZEN_ACCELERATED_COMPOSITING)
2966     if (priv->compositingActive) {
2967         priv->compositor->setWeakZoom(smartData->animated_zoom.zoom.start, zoom, centerX, centerY);
2968         ewk_view_mark_for_sync(ewkView, false);
2969     }
2970 #endif // USE(ACCELERATED_COMPOSITING) & ENABLE(TIZEN_ACCELERATED_COMPOSITING)
2971     return smartData->api->zoom_weak_set(smartData, zoom, centerX, centerY);
2972 }
2973
2974 Eina_Bool ewk_view_zoom_animated_mark_start(Evas_Object* ewkView, float zoom)
2975 {
2976     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2977     smartData->animated_zoom.zoom.start = zoom;
2978     return true;
2979 }
2980
2981 Eina_Bool ewk_view_zoom_animated_mark_end(Evas_Object* ewkView, float zoom)
2982 {
2983     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2984     smartData->animated_zoom.zoom.end = zoom;
2985     return true;
2986 }
2987
2988 Eina_Bool ewk_view_zoom_animated_mark_current(Evas_Object* ewkView, float zoom)
2989 {
2990     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2991     smartData->animated_zoom.zoom.current = zoom;
2992     return true;
2993 }
2994
2995 Eina_Bool ewk_view_zoom_animated_mark_stop(Evas_Object* ewkView)
2996 {
2997     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2998     _ewk_view_zoom_animated_mark_stop(smartData);
2999     return true;
3000 }
3001
3002 Eina_Bool ewk_view_zoom_animated_set(Evas_Object* ewkView, float zoom, float duration, Evas_Coord centerX, Evas_Coord centerY)
3003 {
3004     double now;
3005     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3006     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3007     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
3008     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api->zoom_weak_set, false);
3009
3010     if (!priv->settings.zoomRange.userScalable) {
3011         WRN("userScalable is false");
3012         return false;
3013     }
3014
3015     if (zoom < priv->settings.zoomRange.minScale) {
3016         WRN("zoom level is < %f : %f", priv->settings.zoomRange.minScale, zoom);
3017         return false;
3018     }
3019     if (zoom > priv->settings.zoomRange.maxScale) {
3020         WRN("zoom level is > %f : %f", priv->settings.zoomRange.maxScale, zoom);
3021         return false;
3022     }
3023
3024     if (priv->animatedZoom.animator)
3025         priv->animatedZoom.zoom.start = _ewk_view_zoom_animated_current(priv);
3026     else {
3027         priv->animatedZoom.zoom.start = ewk_frame_page_zoom_get(smartData->main_frame);
3028         _ewk_view_zoom_animation_start(smartData);
3029     }
3030
3031     if (centerX < 0)
3032         centerX = 0;
3033     if (centerY < 0)
3034         centerY = 0;
3035
3036     now = ecore_loop_time_get();
3037     priv->animatedZoom.time.start = now;
3038     priv->animatedZoom.time.end = now + duration;
3039     priv->animatedZoom.time.duration = duration;
3040     priv->animatedZoom.zoom.end = zoom;
3041     priv->animatedZoom.zoom.range = (priv->animatedZoom.zoom.end - priv->animatedZoom.zoom.start);
3042     priv->animatedZoom.center.x = centerX;
3043     priv->animatedZoom.center.y = centerY;
3044     smartData->animated_zoom.zoom.current = priv->animatedZoom.zoom.start;
3045     smartData->animated_zoom.zoom.start = priv->animatedZoom.zoom.start;
3046     smartData->animated_zoom.zoom.end = priv->animatedZoom.zoom.end;
3047
3048     return true;
3049 }
3050
3051 Eina_Bool ewk_view_pre_render_region(Evas_Object* ewkView, Evas_Coord x, Evas_Coord y, Evas_Coord width, Evas_Coord height, float zoom)
3052 {
3053     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3054     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3055     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api->pre_render_region, false);
3056     float currentZoom;
3057     Evas_Coord contentsWidth, contentsHeight;
3058
3059     /* When doing animated zoom it's not possible to call pre-render since it
3060      * would screw up parameters that animation is currently using
3061      */
3062     if (priv->animatedZoom.animator)
3063         return false;
3064
3065     currentZoom = ewk_frame_page_zoom_get(smartData->main_frame);
3066
3067     if (currentZoom < 0.00001)
3068         return false;
3069     if (!ewk_frame_contents_size_get(smartData->main_frame, &contentsWidth, &contentsHeight))
3070         return false;
3071
3072     contentsWidth *= zoom / currentZoom;
3073     contentsHeight *= zoom / currentZoom;
3074     DBG("region %d,%d+%dx%d @ %f contents=%dx%d", x, y, width, height, zoom, contentsWidth, contentsHeight);
3075
3076     if (x + width > contentsWidth)
3077         width = contentsWidth - x;
3078
3079     if (y + height > contentsHeight)
3080         height = contentsHeight - y;
3081
3082     if (x < 0) {
3083         width += x;
3084         x = 0;
3085     }
3086     if (y < 0) {
3087         height += y;
3088         y = 0;
3089     }
3090
3091     return smartData->api->pre_render_region(smartData, x, y, width, height, zoom);
3092 }
3093
3094 #if ENABLE(TIZEN_RECORDING_SURFACE)
3095 Eina_Bool ewk_view_recording_surface_start(Evas_Object* ewkView)
3096 {
3097     EWK_VIEW_TYPE_CHECK_OR_RETURN(ewkView, ewkViewTiledName, false);
3098     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3099     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3100
3101     if (priv->recordingSurfaceEnable)
3102         ewk_view_recording_surface_set_base_if_needed(ewkView);
3103     return true;
3104 }
3105 #endif
3106
3107 /**
3108  * Hint engine to pre-render region, given n extra cols/rows
3109  *
3110  * This is an alternative method to ewk_view_pre_render_region(). It does not
3111  * make sense in all engines and therefore it might not be implemented at all.
3112  *
3113  * It's only useful if engine divide the area being rendered in smaller tiles,
3114  * forming a grid. Then, browser could call this function to pre-render @param n
3115  * rows/cols involving the current viewport.
3116  *
3117  * @param ewkView view to ask pre-render on.
3118  * @param n number of cols/rows that must be part of the region pre-rendered
3119  *
3120  * @see ewk_view_pre_render_region()
3121  */
3122 Eina_Bool ewk_view_pre_render_relative_radius(Evas_Object* ewkView, unsigned int number)
3123 {
3124     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3125     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3126     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api->pre_render_relative_radius, false);
3127     float currentZoom;
3128
3129     if (priv->animatedZoom.animator)
3130         return false;
3131
3132     currentZoom = ewk_frame_page_zoom_get(smartData->main_frame);
3133     return smartData->api->pre_render_relative_radius(smartData, number, currentZoom);
3134 }
3135
3136 Eina_Bool ewk_view_pre_render_start(Evas_Object* ewkView)
3137 {
3138     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3139     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api->pre_render_start, false);
3140
3141 #if ENABLE(TIZEN_PRE_RENDERING_ENABLE)
3142     return smartData->api->pre_render_start(smartData, true);
3143 #else
3144     return smartData->api->pre_render_start(smartData);
3145 #endif
3146 }
3147
3148 unsigned int ewk_view_imh_get(const Evas_Object* ewkView)
3149 {
3150     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3151     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3152     return priv->imh;
3153 }
3154
3155 /**
3156  * Cancel (clear) previous pre-render requests.
3157  *
3158  * @param ewkView view to clear pre-render requests.
3159  */
3160 void ewk_view_pre_render_cancel(Evas_Object* ewkView)
3161 {
3162     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3163     EINA_SAFETY_ON_NULL_RETURN(smartData->api->pre_render_cancel);
3164     smartData->api->pre_render_cancel(smartData);
3165 }
3166
3167 Eina_Bool ewk_view_enable_render(const Evas_Object* ewkView)
3168 {
3169 #if ENABLE(TIZEN_RENDERING_PROFILE_TEST)
3170     return false;
3171 #endif
3172     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3173     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api->enable_render, false);
3174
3175 #if ENABLE(TIZEN_RECORDING_SURFACE)
3176     if (smartData->_priv->recordingSurfaceEnable)
3177         smartData->_priv->recordingSurfaceSetScrollState = false;
3178 #endif
3179
3180     return smartData->api->enable_render(smartData);
3181 }
3182
3183 Eina_Bool ewk_view_disable_render(const Evas_Object* ewkView)
3184 {
3185     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3186     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api->disable_render, false);
3187
3188 #if ENABLE(TIZEN_RECORDING_SURFACE)
3189     if (smartData->_priv->recordingSurfaceEnable)
3190         smartData->_priv->recordingSurfaceSetScrollState = true;
3191 #endif
3192
3193     return smartData->api->disable_render(smartData);
3194 }
3195
3196 const char* ewk_view_setting_user_agent_get(const Evas_Object* ewkView)
3197 {
3198     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3199     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3200     return priv->settings.userAgent;
3201 }
3202
3203 Eina_Bool ewk_view_setting_user_agent_set(Evas_Object* ewkView, const char* userAgent)
3204 {
3205     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3206     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3207     if (eina_stringshare_replace(&priv->settings.userAgent, userAgent)) {
3208         WebCore::FrameLoaderClientEfl* client = static_cast<WebCore::FrameLoaderClientEfl*>(priv->mainFrame->loader()->client());
3209         client->setCustomUserAgent(String::fromUTF8(userAgent));
3210     }
3211     return true;
3212 }
3213
3214 const char* ewk_view_setting_user_stylesheet_get(const Evas_Object* ewkView)
3215 {
3216     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3217     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3218     return priv->settings.userStylesheet;
3219 }
3220
3221 Eina_Bool ewk_view_setting_user_stylesheet_set(Evas_Object* ewkView, const char* uri)
3222 {
3223     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3224     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3225     if (eina_stringshare_replace(&priv->settings.userStylesheet, uri)) {
3226         WebCore::KURL kurl(WebCore::KURL(), String::fromUTF8(uri));
3227         priv->pageSettings->setUserStyleSheetLocation(kurl);
3228     }
3229     return true;
3230 }
3231
3232 Eina_Bool ewk_view_setting_auto_load_images_get(const Evas_Object* ewkView)
3233 {
3234     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3235     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3236     return priv->settings.autoLoadImages;
3237 }
3238
3239 Eina_Bool ewk_view_setting_auto_load_images_set(Evas_Object* ewkView, Eina_Bool automatic)
3240 {
3241     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3242     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3243     automatic = !!automatic;
3244     if (priv->settings.autoLoadImages != automatic) {
3245         priv->pageSettings->setLoadsImagesAutomatically(automatic);
3246         priv->settings.autoLoadImages = automatic;
3247     }
3248     return true;
3249 }
3250
3251 Eina_Bool ewk_view_setting_auto_shrink_images_get(const Evas_Object* ewkView)
3252 {
3253     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3254     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3255     return priv->settings.autoShrinkImages;
3256 }
3257
3258 Eina_Bool ewk_view_setting_auto_shrink_images_set(Evas_Object* ewkView, Eina_Bool automatic)
3259 {
3260     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3261     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3262     automatic = !!automatic;
3263     if (priv->settings.autoShrinkImages != automatic) {
3264         priv->pageSettings->setShrinksStandaloneImagesToFit(automatic);
3265         priv->settings.autoShrinkImages = automatic;
3266     }
3267     return true;
3268 }
3269
3270 Eina_Bool ewk_view_setting_enable_auto_resize_window_get(const Evas_Object* ewkView)
3271 {
3272     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3273     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3274     return priv->settings.enableAutoResizeWindow;
3275 }
3276
3277 Eina_Bool ewk_view_setting_enable_auto_resize_window_set(Evas_Object* ewkView, Eina_Bool resizable)
3278 {
3279     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3280     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3281     priv->settings.enableAutoResizeWindow = resizable;
3282     return true;
3283 }
3284
3285 Eina_Bool ewk_view_setting_enable_scripts_get(const Evas_Object* ewkView)
3286 {
3287     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3288     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3289     return priv->settings.enableScripts;
3290 }
3291
3292 Eina_Bool ewk_view_setting_enable_scripts_set(Evas_Object* ewkView, Eina_Bool enable)
3293 {
3294     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3295     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3296     enable = !!enable;
3297     if (priv->settings.enableScripts != enable) {
3298         priv->pageSettings->setScriptEnabled(enable);
3299         priv->settings.enableScripts = enable;
3300     }
3301     return true;
3302 }
3303
3304 Eina_Bool ewk_view_setting_enable_plugins_get(const Evas_Object* ewkView)
3305 {
3306     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3307     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3308     return priv->settings.enablePlugins;
3309 }
3310
3311 Eina_Bool ewk_view_setting_enable_plugins_set(Evas_Object* ewkView, Eina_Bool enable)
3312 {
3313     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3314     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3315     enable = !!enable;
3316 #if ENABLE(TIZEN_DYNAMIC_LOADED_PLUGINS)
3317     Eina_Bool pluginsStatus = _ewk_view_setting_enable_plugins_set(enable);
3318 #endif
3319     if (priv->settings.enablePlugins != enable) {
3320         priv->pageSettings->setPluginsEnabled(enable);
3321         priv->settings.enablePlugins = enable;
3322     }
3323 #if ENABLE(TIZEN_DYNAMIC_LOADED_PLUGINS)
3324     return pluginsStatus;
3325 #else
3326     return true;
3327 #endif
3328 }
3329
3330 Eina_Bool ewk_view_setting_enable_frame_flattening_get(const Evas_Object* ewkView)
3331 {
3332     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3333     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3334     return priv->settings.enableFrameFlattening;
3335 }
3336
3337 Eina_Bool ewk_view_setting_enable_frame_flattening_set(Evas_Object* ewkView, Eina_Bool enable)
3338 {
3339     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3340     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3341     enable = !!enable;
3342     if (priv->settings.enableFrameFlattening != enable) {
3343         priv->pageSettings->setFrameFlatteningEnabled(enable);
3344         priv->settings.enableFrameFlattening = enable;
3345     }
3346     return true;
3347 }
3348
3349 Eina_Bool ewk_view_setting_scripts_can_open_windows_get(const Evas_Object* ewkView)
3350 {
3351     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3352     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3353     return priv->settings.scriptsCanOpenWindows;
3354 }
3355
3356 Eina_Bool ewk_view_setting_scripts_can_open_windows_set(Evas_Object* ewkView, Eina_Bool allow)
3357 {
3358     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3359     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3360     allow = !!allow;
3361     if (priv->settings.scriptsCanOpenWindows != allow) {
3362         priv->pageSettings->setJavaScriptCanOpenWindowsAutomatically(allow);
3363         priv->settings.scriptsCanOpenWindows = allow;
3364     }
3365     return true;
3366 }
3367
3368 Eina_Bool ewk_view_setting_scripts_can_close_windows_get(const Evas_Object* ewkView)
3369 {
3370     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3371     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3372     return priv->settings.scriptsCanCloseWindows;
3373 }
3374
3375 Eina_Bool ewk_view_setting_scripts_can_close_windows_set(Evas_Object* ewkView, Eina_Bool allow)
3376 {
3377     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3378     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3379     allow = !!allow;
3380     if (priv->settings.scriptsCanCloseWindows != allow) {
3381         priv->pageSettings->setAllowScriptsToCloseWindows(allow);
3382         priv->settings.scriptsCanCloseWindows = allow;
3383     }
3384     return true;
3385 }
3386
3387 Eina_Bool ewk_view_setting_scripts_can_access_clipboard_get(const Evas_Object* ewkView)
3388 {
3389     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3390     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3391     return priv->settings.scriptsCanAccessClipboard;
3392 }
3393
3394 Eina_Bool ewk_view_setting_scripts_can_access_clipboard_set(Evas_Object* ewkView, Eina_Bool allow)
3395 {
3396     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3397     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3398     allow = !!allow;
3399     if (priv->settings.scriptsCanAccessClipboard != allow) {
3400         priv->pageSettings->setJavaScriptCanAccessClipboard(allow);
3401         priv->pageSettings->setDOMPasteAllowed(allow);
3402         priv->settings.scriptsCanAccessClipboard = allow;
3403     }
3404     return true;
3405 }
3406
3407 #if ENABLE(TIZEN_WEBKIT_EFL_DRT)
3408 /**
3409  * Returns whether scripts can close windows automatically.
3410  *
3411  * @param ewkView View whose settings to check.
3412  *
3413  * @return @c true if scripts can close windows, @c false otherwise.
3414  */
3415 Eina_Bool ewk_view_setting_scripts_window_close_get(const Evas_Object* ewkView)
3416 {
3417     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3418     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3419     return priv->settings.scriptsWindowClose;
3420 }
3421
3422 /**
3423  * Sets whether scripts are allowed to close windows automatically.
3424  *
3425  * @param ewkView View whose settings to change.
3426  * @param allow @c true to allow scripts to close windows,
3427  *              @c false otherwise.
3428  *
3429  * @return @c true if the setting could be changed successfully,
3430  *         @c false in case an error occurred.
3431  */
3432 Eina_Bool ewk_view_setting_scripts_window_close_set(Evas_Object* ewkView, Eina_Bool allow)
3433 {
3434     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3435     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3436     allow = !!allow;
3437     if (priv->settings.scriptsWindowClose != allow) {
3438         priv->pageSettings->setAllowScriptsToCloseWindows(allow);
3439         priv->settings.scriptsWindowClose = allow;
3440     }
3441     return true;
3442 }
3443
3444 /**
3445  * @internal
3446  */
3447 void ewk_view_page_scale(const Evas_Object* ewkView, float scaleFactor, float x, float y)
3448 {
3449     EWK_VIEW_SD_GET(ewkView, smartData);
3450     EWK_VIEW_PRIV_GET(smartData, priv);
3451
3452 #if ENABLE(TIZEN_DAILY_UPVERSIONING)
3453     if (WebCore::Page* page = priv->mainFrame->page())
3454         page->setPageScaleFactor(scaleFactor, WebCore::IntPoint(x, y));
3455 #else
3456     priv->mainFrame->scalePage(scaleFactor, WebCore::IntPoint(x, y));
3457 #endif
3458 }
3459
3460 Eina_Bool ewk_view_text_search_with_options(const Evas_Object* ewkView, const char* string, WebCore::FindOptions options)
3461 {
3462     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3463     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3464     EINA_SAFETY_ON_NULL_RETURN_VAL(string, false);
3465
3466     return priv->page->findString(String::fromUTF8(string), options);
3467 }
3468 #endif
3469
3470 Eina_Bool ewk_view_setting_resizable_textareas_get(const Evas_Object* ewkView)
3471 {
3472     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3473     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3474     return priv->settings.resizableTextareas;
3475 }
3476
3477 Eina_Bool ewk_view_setting_resizable_textareas_set(Evas_Object* ewkView, Eina_Bool enable)
3478 {
3479     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3480     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3481     enable = !!enable;
3482     if (priv->settings.resizableTextareas != enable) {
3483         priv->pageSettings->setTextAreasAreResizable(enable);
3484         priv->settings.resizableTextareas = enable;
3485     }
3486     return true;
3487 }
3488
3489 Eina_Bool ewk_view_setting_private_browsing_get(const Evas_Object* ewkView)
3490 {
3491     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3492     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3493     return priv->settings.privateBrowsing;
3494 }
3495
3496 Eina_Bool ewk_view_setting_private_browsing_set(Evas_Object* ewkView, Eina_Bool enable)
3497 {
3498     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3499     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3500     enable = !!enable;
3501     if (priv->settings.privateBrowsing != enable) {
3502         priv->pageSettings->setPrivateBrowsingEnabled(enable);
3503         priv->settings.privateBrowsing = enable;
3504     }
3505     return true;
3506 }
3507
3508 Eina_Bool ewk_view_setting_application_cache_get(const Evas_Object* ewkView)
3509 {
3510     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3511     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3512     return priv->settings.offlineAppCache;
3513 }
3514
3515 Eina_Bool ewk_view_setting_application_cache_set(Evas_Object* ewkView, Eina_Bool enable)
3516 {
3517     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3518     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3519     enable = !!enable;
3520     if (priv->settings.offlineAppCache != enable) {
3521         priv->pageSettings->setOfflineWebApplicationCacheEnabled(enable);
3522         priv->settings.offlineAppCache = enable;
3523     }
3524     return true;
3525 }
3526
3527 Eina_Bool ewk_view_setting_caret_browsing_get(const Evas_Object* ewkView)
3528 {
3529     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3530     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3531     return priv->settings.caretBrowsing;
3532 }
3533
3534 Eina_Bool ewk_view_setting_caret_browsing_set(Evas_Object* ewkView, Eina_Bool enable)
3535 {
3536     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3537     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3538     enable = !!enable;
3539     if (priv->settings.caretBrowsing != enable) {
3540         priv->pageSettings->setCaretBrowsingEnabled(enable);
3541         priv->settings.caretBrowsing = enable;
3542     }
3543     return true;
3544 }
3545
3546 const char* ewk_view_setting_encoding_custom_get(const Evas_Object* ewkView)
3547 {
3548     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3549     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3550     Evas_Object* mainFrame = ewk_view_frame_main_get(ewkView);
3551     WebCore::Frame* core_frame = EWKPrivate::coreFrame(mainFrame);
3552
3553     String overrideEncoding = core_frame->loader()->documentLoader()->overrideEncoding();
3554
3555     if (overrideEncoding.isEmpty())
3556         return 0;
3557
3558     eina_stringshare_replace(&priv->settings.encodingCustom, overrideEncoding.utf8().data());
3559     return priv->settings.encodingCustom;
3560 }
3561
3562 Eina_Bool ewk_view_setting_encoding_custom_set(Evas_Object* ewkView, const char* encoding)
3563 {
3564     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3565     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3566     Evas_Object* mainFrame = ewk_view_frame_main_get(ewkView);
3567     WebCore::Frame* coreFrame = EWKPrivate::coreFrame(mainFrame);
3568     DBG("%s", encoding);
3569     if (eina_stringshare_replace(&priv->settings.encodingCustom, encoding))
3570         coreFrame->loader()->reloadWithOverrideEncoding(String::fromUTF8(encoding));
3571     return true;
3572 }
3573
3574 const char* ewk_view_setting_encoding_default_get(const Evas_Object* ewkView)
3575 {
3576     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3577     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3578     return priv->settings.encodingDefault;
3579 }
3580
3581 Eina_Bool ewk_view_setting_encoding_default_set(Evas_Object* ewkView, const char* encoding)
3582 {
3583     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3584     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3585     if (eina_stringshare_replace(&priv->settings.encodingDefault, encoding))
3586         priv->pageSettings->setDefaultTextEncodingName(String::fromUTF8(encoding));
3587
3588 #if ENABLE(TIZEN_SET_DEFAULT_ENCODING)
3589     Evas_Object* mainFrame = ewk_view_frame_main_get(ewkView);
3590     WebCore::Frame* core_frame = ewk_frame_core_get(mainFrame);
3591     core_frame->loader()->documentLoader()->setOverrideEncoding(String::fromUTF8(encoding));
3592 #endif
3593
3594     return true;
3595 }
3596
3597 Eina_Bool ewk_view_setting_encoding_detector_set(Evas_Object* ewkView, Eina_Bool enable)
3598 {
3599     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3600     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3601     enable = !!enable;
3602     if (priv->settings.encodingDetector != enable) {
3603         priv->pageSettings->setUsesEncodingDetector(enable);
3604         priv->settings.encodingDetector = enable;
3605     }
3606     return true;
3607 }
3608
3609 Eina_Bool ewk_view_setting_encoding_detector_get(const Evas_Object* ewkView)
3610 {
3611     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3612     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3613     return priv->settings.encodingDetector;
3614 }
3615
3616 Eina_Bool ewk_view_setting_enable_developer_extras_get(const Evas_Object* ewkView)
3617 {
3618     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3619     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3620     return priv->settings.enableDeveloperExtras;
3621 }
3622
3623 Eina_Bool ewk_view_setting_enable_developer_extras_set(Evas_Object* ewkView, Eina_Bool enable)
3624 {
3625     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3626     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3627     enable = !!enable;
3628     if (priv->settings.enableDeveloperExtras != enable) {
3629         priv->pageSettings->setDeveloperExtrasEnabled(enable);
3630         priv->settings.enableDeveloperExtras = enable;
3631     }
3632     return true;
3633 }
3634
3635 int ewk_view_setting_font_minimum_size_get(const Evas_Object* ewkView)
3636 {
3637     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3638     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3639     return priv->settings.fontMinimumSize;
3640 }
3641
3642 Eina_Bool ewk_view_setting_font_minimum_size_set(Evas_Object* ewkView, int size)
3643 {
3644     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3645     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3646     if (priv->settings.fontMinimumSize != size) {
3647         priv->pageSettings->setMinimumFontSize(size);
3648         priv->settings.fontMinimumSize = size;
3649     }
3650     return true;
3651 }
3652
3653 int ewk_view_setting_font_minimum_logical_size_get(const Evas_Object* ewkView)
3654 {
3655     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3656     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3657     return priv->settings.fontMinimumLogicalSize;
3658 }
3659
3660 Eina_Bool ewk_view_setting_font_minimum_logical_size_set(Evas_Object* ewkView, int size)
3661 {
3662     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3663     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3664     if (priv->settings.fontMinimumLogicalSize != size) {
3665         priv->pageSettings->setMinimumLogicalFontSize(size);
3666         priv->settings.fontMinimumLogicalSize = size;
3667     }
3668     return true;
3669 }
3670
3671 int ewk_view_setting_font_default_size_get(const Evas_Object* ewkView)
3672 {
3673     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3674     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3675     return priv->settings.fontDefaultSize;
3676 }
3677
3678 Eina_Bool ewk_view_setting_font_default_size_set(Evas_Object* ewkView, int size)
3679 {
3680     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3681     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3682     if (priv->settings.fontDefaultSize != size) {
3683         priv->pageSettings->setDefaultFontSize(size);
3684         priv->settings.fontDefaultSize = size;
3685     }
3686     return true;
3687 }
3688
3689 int ewk_view_setting_font_monospace_size_get(const Evas_Object* ewkView)
3690 {
3691     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3692     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3693     return priv->settings.fontMonospaceSize;
3694 }
3695
3696 Eina_Bool ewk_view_setting_font_monospace_size_set(Evas_Object* ewkView, int size)
3697 {
3698     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3699     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3700     if (priv->settings.fontMonospaceSize != size) {
3701         priv->pageSettings->setDefaultFixedFontSize(size);
3702         priv->settings.fontMonospaceSize = size;
3703     }
3704     return true;
3705 }
3706
3707 const char* ewk_view_font_family_name_get(const Evas_Object* ewkView, Ewk_Font_Family fontFamily)
3708 {
3709     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3710     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3711
3712     switch (fontFamily) {
3713     case EWK_FONT_FAMILY_STANDARD:
3714         return priv->settings.fontStandard;
3715     case EWK_FONT_FAMILY_CURSIVE:
3716         return priv->settings.fontCursive;
3717     case EWK_FONT_FAMILY_FANTASY:
3718         return priv->settings.fontFantasy;
3719     case EWK_FONT_FAMILY_MONOSPACE:
3720         return priv->settings.fontMonospace;
3721     case EWK_FONT_FAMILY_SERIF:
3722         return priv->settings.fontSerif;
3723     case EWK_FONT_FAMILY_SANS_SERIF:
3724         return priv->settings.fontSansSerif;
3725     }
3726     return 0;
3727 }
3728
3729 Eina_Bool ewk_view_font_family_name_set(Evas_Object* ewkView, Ewk_Font_Family fontFamily, const char* name)
3730 {
3731     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3732     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3733
3734     switch (fontFamily) {
3735     case EWK_FONT_FAMILY_STANDARD:
3736         if (eina_stringshare_replace(&priv->settings.fontStandard, name))
3737             priv->pageSettings->setStandardFontFamily(AtomicString::fromUTF8(name));
3738         break;
3739     case EWK_FONT_FAMILY_CURSIVE:
3740         if (eina_stringshare_replace(&priv->settings.fontCursive, name))
3741             priv->pageSettings->setCursiveFontFamily(AtomicString::fromUTF8(name));
3742         break;
3743     case EWK_FONT_FAMILY_FANTASY:
3744         if (eina_stringshare_replace(&priv->settings.fontFantasy, name))
3745             priv->pageSettings->setFantasyFontFamily(AtomicString::fromUTF8(name));
3746         break;
3747     case EWK_FONT_FAMILY_MONOSPACE:
3748         if (eina_stringshare_replace(&priv->settings.fontMonospace, name))
3749             priv->pageSettings->setFixedFontFamily(AtomicString::fromUTF8(name));
3750         break;
3751     case EWK_FONT_FAMILY_SERIF:
3752         if (eina_stringshare_replace(&priv->settings.fontSerif, name))
3753             priv->pageSettings->setSerifFontFamily(AtomicString::fromUTF8(name));
3754         break;
3755     case EWK_FONT_FAMILY_SANS_SERIF:
3756         if (eina_stringshare_replace(&priv->settings.fontSansSerif, name))
3757             priv->pageSettings->setSansSerifFontFamily(AtomicString::fromUTF8(name));
3758         break;
3759     default:
3760         return false;
3761     }
3762
3763     return true;
3764 }
3765
3766 Eina_Bool ewk_view_setting_spatial_navigation_get(const Evas_Object* ewkView)
3767 {
3768     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3769     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3770     return priv->settings.spatialNavigation;
3771 }
3772
3773 Eina_Bool ewk_view_setting_spatial_navigation_set(Evas_Object* ewkView, Eina_Bool enable)
3774 {
3775     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3776     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3777     enable = !!enable;
3778     if (priv->settings.spatialNavigation != enable) {
3779         priv->pageSettings->setSpatialNavigationEnabled(enable);
3780         priv->settings.spatialNavigation = enable;
3781     }
3782     return true;
3783 }
3784
3785 Eina_Bool ewk_view_setting_local_storage_get(const Evas_Object* ewkView)
3786 {
3787     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3788     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3789     return priv->settings.localStorage;
3790 }
3791
3792 Eina_Bool ewk_view_setting_local_storage_set(Evas_Object* ewkView, Eina_Bool enable)
3793 {
3794     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3795     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3796     enable = !!enable;
3797     if (priv->settings.localStorage != enable) {
3798         priv->pageSettings->setLocalStorageEnabled(enable);
3799         priv->settings.localStorage = enable;
3800     }
3801     return true;
3802 }
3803
3804 Eina_Bool ewk_view_setting_web_audio_get(const Evas_Object* ewkView)
3805 {
3806 #if ENABLE(TIZEN_WEB_AUDIO)
3807     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, EINA_FALSE);
3808     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, EINA_FALSE);
3809     return priv->settings.webAudio;
3810 #else
3811     return false;
3812 #endif
3813 }
3814
3815 Eina_Bool ewk_view_setting_web_audio_set(Evas_Object* ewkView, Eina_Bool enable)
3816 {
3817 #if ENABLE(TIZEN_WEB_AUDIO)
3818     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, EINA_FALSE);
3819     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, EINA_FALSE);
3820     enable = !!enable;
3821     if (priv->settings.webAudio != enable) {
3822         priv->pageSettings->setWebAudioEnabled(enable);
3823         priv->settings.webAudio = enable;
3824     }
3825     return true;
3826 #else
3827     return false;
3828 #endif
3829 }
3830
3831 Eina_Bool ewk_view_setting_page_cache_get(const Evas_Object* ewkView)
3832 {
3833     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3834     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3835     return priv->settings.pageCache;
3836 }
3837
3838 Eina_Bool ewk_view_setting_page_cache_set(Evas_Object* ewkView, Eina_Bool enable)
3839 {
3840     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3841     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3842     enable = !!enable;
3843     if (priv->settings.pageCache != enable) {
3844         priv->pageSettings->setUsesPageCache(enable);
3845         priv->settings.pageCache = enable;
3846     }
3847     return true;
3848 }
3849
3850 const char* ewk_view_setting_local_storage_database_path_get(const Evas_Object* ewkView)
3851 {
3852     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3853     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3854     return priv->settings.localStorageDatabasePath;
3855 }
3856
3857 Eina_Bool ewk_view_setting_local_storage_database_path_set(Evas_Object* ewkView, const char* path)
3858 {
3859     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3860     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3861     if (eina_stringshare_replace(&priv->settings.localStorageDatabasePath, path))
3862         priv->pageSettings->setLocalStorageDatabasePath(String::fromUTF8(path));
3863     return true;
3864 }
3865
3866 Eina_Bool ewk_view_setting_minimum_timer_interval_set(Evas_Object* ewkView, double interval)
3867 {
3868     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3869     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3870     if (fabs(priv->settings.domTimerInterval - interval) >= std::numeric_limits<double>::epsilon()) {
3871         priv->pageSettings->setMinDOMTimerInterval(interval);
3872         priv->settings.domTimerInterval = interval;
3873     }
3874     return true;
3875 }
3876
3877 double ewk_view_setting_minimum_timer_interval_get(const Evas_Object* ewkView)
3878 {
3879     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3880     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3881     return priv->settings.domTimerInterval;
3882 }
3883
3884 Eina_Bool ewk_view_setting_enable_focus_ring_get(const Evas_Object* ewkView)
3885 {
3886 #if ENABLE(TIZEN_FOCUS_RING)
3887     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3888     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3889     return priv->settings.enableFocusRing;
3890 #else
3891     return false;
3892 #endif
3893 }
3894
3895 Eina_Bool ewk_view_setting_enable_focus_ring_set(Evas_Object* ewkView, Eina_Bool enable)
3896 {
3897 #if ENABLE(TIZEN_FOCUS_RING)
3898     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3899     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3900     enable = !!enable;
3901     if (priv->settings.enableFocusRing != enable) {
3902         priv->pageSettings->setFocusRingEnabled(enable);
3903         priv->settings.enableFocusRing = enable;
3904     }
3905     return true;
3906 #else
3907     return false;
3908 #endif
3909 }
3910
3911 /**
3912  * Get status of onscroll event suppression.
3913  *
3914  * @param ewkView view to check status
3915  *
3916  * @return true if suppression is enabled, false
3917  *         otherwise (errors, suppression disabled).
3918  */
3919
3920 Eina_Bool ewk_view_setting_enable_onscroll_event_suppression_get(const Evas_Object* ewkView)
3921 {
3922 #if ENABLE(TIZEN_ONSCROLL_EVENT_SUPPRESSION)
3923     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3924     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3925     return priv->settings.enableOnscrollEventSuppression;
3926 #else
3927     LOG_ERROR("TIZEN_ONSCROLL_EVENT_SUPPRESSION is disabled. \n");
3928     return false;
3929 #endif
3930 }
3931
3932 /**
3933  * Set onscroll event suppression.
3934  *
3935  * @param ewkView view to set suppression
3936  *
3937  * @return true if suppression status set, false
3938  *         otherwise (errors).
3939  */
3940 Eina_Bool ewk_view_setting_enable_onscroll_event_suppression_set(Evas_Object* ewkView, Eina_Bool enable)
3941 {
3942 #if ENABLE(TIZEN_ONSCROLL_EVENT_SUPPRESSION)
3943     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3944     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3945     enable = !!enable;
3946     if (priv->settings.enableOnscrollEventSuppression != enable) {
3947         priv->pageSettings->setOnscrollEventSuppressionEnabled(enable);
3948         priv->settings.enableOnscrollEventSuppression = enable;
3949     }
3950     return true;
3951 #else
3952     LOG_ERROR("TIZEN_ONSCROLL_EVENT_SUPPRESSION is disabled. \n");
3953     return false;
3954 #endif
3955 }
3956
3957 /**
3958  * Function sets selection visibility.
3959  *
3960  * @param [in] ewkView view
3961  * @param [in] flag @c true if selection should be visibile, @c false if not
3962  *
3963  * @return true If setting visibility succeeds, false if setting visibility was not possible
3964  */
3965 Eina_Bool ewk_view_selection_visibility_set(Evas_Object* ewkView, Eina_Bool flag)
3966 {
3967 #if ENABLE(TIZEN_PARAGRAPH_SELECTION)
3968     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3969     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3970     WebCore::Page* page = priv->page.get();
3971
3972     if (!flag) {
3973          // Invisible background and black text for selection.
3974          ((WebCore::RenderThemeEfl*)page->theme())->setActiveSelectionColor(0, 0, 0, 255, 255, 255, 255, 0);
3975          ((WebCore::RenderThemeEfl*)page->theme())->setInactiveSelectionColor(0, 0, 0, 255, 255, 255, 255, 0);
3976     } else {
3977          // Not really changing theme but I want to use defined colors again.
3978          ((WebCore::RenderThemeEfl*)page->theme())->themeChanged();
3979     }
3980     return true;
3981 #else
3982     LOG_ERROR("TIZEN_PARAGRAPH_SELECTION is disabled. \n");
3983     return false;
3984 #endif
3985 }
3986
3987 Eina_Bool ewk_view_setting_enable_webgl_get(const Evas_Object* ewkView)
3988 {
3989     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3990     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3991     return priv->settings.webGLEnabled;
3992 }
3993
3994 Eina_Bool ewk_view_setting_enable_webgl_set(Evas_Object* ewkView, Eina_Bool enable)
3995 {
3996     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3997     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3998     enable = !!enable;
3999     if (priv->settings.webGLEnabled != enable) {
4000         priv->pageSettings->setWebGLEnabled(enable);
4001         priv->settings.webGLEnabled = enable;
4002     }
4003     return true;
4004 }
4005
4006 Eina_Bool ewk_view_setting_include_links_in_focus_chain_get(const Evas_Object* ewkView)
4007 {
4008     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4009     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4010     return priv->settings.tabsToLinks;
4011 }
4012
4013 Eina_Bool ewk_view_setting_include_links_in_focus_chain_set(Evas_Object* ewkView, Eina_Bool enable)
4014 {
4015     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4016     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4017     enable = !!enable;
4018     priv->settings.tabsToLinks = enable;
4019     return true;
4020 }
4021
4022 Eina_Bool ewk_view_setting_enable_hyperlink_auditing_get(const Evas_Object* ewkView)
4023 {
4024     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4025     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4026     return priv->settings.hyperlinkAuditingEnabled;
4027 }
4028
4029 Eina_Bool ewk_view_setting_enable_hyperlink_auditing_set(Evas_Object* ewkView, Eina_Bool enable)
4030 {
4031     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4032     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4033     enable = !!enable;
4034     if (priv->settings.hyperlinkAuditingEnabled != enable) {
4035         priv->pageSettings->setHyperlinkAuditingEnabled(enable);
4036         priv->settings.hyperlinkAuditingEnabled = enable;
4037     }
4038     return true;
4039 }
4040
4041 Ewk_View_Smart_Data* ewk_view_smart_data_get(const Evas_Object* ewkView)
4042 {
4043     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4044     return smartData;
4045 }
4046
4047 /**
4048  * Gets the internal array of repaint requests.
4049  *
4050  * This array should not be modified anyhow. It should be processed
4051  * immediately as any further ewk_view call might change it, like
4052  * those that add repaints or flush them, so be sure that your code
4053  * does not call any of those while you process the repaints,
4054  * otherwise copy the array.
4055  *
4056  * @param priv private handle pointer of the view to get repaints.
4057  * @param count where to return the number of elements of returned array, may be @c 0.
4058  *
4059  * @return reference to array of requested repaints.
4060  *
4061  * @note this is not for general use but just for subclasses that want
4062  *       to define their own backing store.
4063  */
4064 const Eina_Rectangle* ewk_view_repaints_pop(Ewk_View_Private_Data* priv, size_t* count)
4065 {
4066     if (count)
4067         *count = 0;
4068     EINA_SAFETY_ON_NULL_RETURN_VAL(priv, 0);
4069     if (count)
4070         *count = priv->repaints.count;
4071
4072     priv->repaints.count = 0;
4073
4074     return priv->repaints.array;
4075 }
4076
4077 /**
4078  * Gets the internal array of scroll requests.
4079  *
4080  * This array should not be modified anyhow. It should be processed
4081  * immediately as any further ewk_view call might change it, like
4082  * those that add scrolls or flush them, so be sure that your code
4083  * does not call any of those while you process the scrolls,
4084  * otherwise copy the array.
4085  *
4086  * @param priv private handle pointer of the view to get scrolls.
4087  * @param count where to return the number of elements of returned array, may be @c 0.
4088  *
4089  * @return reference to array of requested scrolls.
4090  *
4091  * @note this is not for general use but just for subclasses that want
4092  *       to define their own backing store.
4093  */
4094 const Ewk_Scroll_Request* ewk_view_scroll_requests_get(const Ewk_View_Private_Data* priv, size_t* count)
4095 {
4096     if (count)
4097         *count = 0;
4098     EINA_SAFETY_ON_NULL_RETURN_VAL(priv, 0);
4099     if (count)
4100         *count = priv->scrolls.count;
4101     return priv->scrolls.array;
4102 }
4103
4104 /**
4105  * Add a new repaint request to queue.
4106  *
4107  * The repaints are assumed to be relative to current viewport.
4108  *
4109  * @param priv private handle pointer of the view to add repaint request.
4110  * @param x horizontal position relative to current view port (scrolled).
4111  * @param y vertical position relative to current view port (scrolled).
4112  * @param width width of area to be repainted
4113  * @param height height of area to be repainted
4114  *
4115  * @note this is not for general use but just for subclasses that want
4116  *       to define their own backing store.
4117  */
4118 void ewk_view_repaint_add(Ewk_View_Private_Data* priv, Evas_Coord x, Evas_Coord y, Evas_Coord width, Evas_Coord height)
4119 {
4120     EINA_SAFETY_ON_NULL_RETURN(priv);
4121     _ewk_view_repaint_add(priv, x, y, width, height);
4122 }
4123
4124 /**
4125  * Do layout if required, applied recursively.
4126  *
4127  * @param priv private handle pointer of the view to layout.
4128  *
4129  * @note this is not for general use but just for subclasses that want
4130  *       to define their own backing store.
4131  */
4132 void ewk_view_layout_if_needed_recursive(Ewk_View_Private_Data* priv)
4133 {
4134     EINA_SAFETY_ON_NULL_RETURN(priv);
4135
4136     WebCore::FrameView* view = priv->mainFrame->view();
4137     if (!view) {
4138         ERR("no main frame view");
4139         return;
4140     }
4141     view->updateLayoutAndStyleIfNeededRecursive();
4142 }
4143
4144 void ewk_view_scrolls_process(Ewk_View_Smart_Data* smartData)
4145 {
4146     EINA_SAFETY_ON_NULL_RETURN(smartData);
4147     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4148     if (!smartData->api->scrolls_process(smartData))
4149         ERR("failed to process scrolls.");
4150     _ewk_view_scrolls_flush(priv);
4151 }
4152
4153 /**
4154  * @brief Structure that keeps the paint context.
4155  *
4156  * @internal
4157  *
4158  * @note This is not for general use but just for subclasses that want
4159  *       to define their own backing store.
4160  */
4161 struct _Ewk_View_Paint_Context {
4162     WebCore::FrameView* view;
4163     OwnPtr<WebCore::GraphicsContext> graphicContext;
4164     RefPtr<cairo_t> cairo;
4165 };
4166
4167 Ewk_View_Paint_Context* ewk_view_paint_context_new(Ewk_View_Private_Data* priv, cairo_t* cairo)
4168 {
4169     EINA_SAFETY_ON_NULL_RETURN_VAL(priv, 0);
4170     EINA_SAFETY_ON_NULL_RETURN_VAL(cairo, 0);
4171     EINA_SAFETY_ON_NULL_RETURN_VAL(priv->mainFrame, 0);
4172     EINA_SAFETY_ON_NULL_RETURN_VAL(priv->mainFrame->view(), 0);
4173
4174     Ewk_View_Paint_Context* context = new Ewk_View_Paint_Context;
4175     context->view = priv->mainFrame->view();
4176     context->graphicContext = adoptPtr(new WebCore::GraphicsContext(cairo));
4177     context->cairo = adoptRef(cairo_reference(cairo));
4178     return context;
4179 }
4180
4181 void ewk_view_paint_context_free(Ewk_View_Paint_Context* context)
4182 {
4183     EINA_SAFETY_ON_NULL_RETURN(context);
4184
4185     delete context;
4186 }
4187
4188 void ewk_view_paint_context_save(Ewk_View_Paint_Context* context)
4189 {
4190     EINA_SAFETY_ON_NULL_RETURN(context);
4191
4192     cairo_save(context->cairo.get());
4193     context->graphicContext->save();
4194 }
4195
4196 void ewk_view_paint_context_restore(Ewk_View_Paint_Context* context)
4197 {
4198     EINA_SAFETY_ON_NULL_RETURN(context);
4199
4200     context->graphicContext->restore();
4201     cairo_restore(context->cairo.get());
4202 }
4203
4204 void ewk_view_paint_context_clip(Ewk_View_Paint_Context* context, const Eina_Rectangle* area)
4205 {
4206     EINA_SAFETY_ON_NULL_RETURN(context);
4207     EINA_SAFETY_ON_NULL_RETURN(area);
4208     context->graphicContext->clip(WebCore::IntRect(*area));
4209 }
4210
4211 void ewk_view_paint_context_paint(Ewk_View_Paint_Context* context, const Eina_Rectangle* area)
4212 {
4213     EINA_SAFETY_ON_NULL_RETURN(context);
4214     EINA_SAFETY_ON_NULL_RETURN(area);
4215
4216     WebCore::IntRect rect(*area);
4217
4218     if (context->view->isTransparent())
4219         context->graphicContext->clearRect(rect);
4220     context->view->paint(context->graphicContext.get(), rect);
4221 }
4222
4223 void ewk_view_paint_context_paint_contents(Ewk_View_Paint_Context* context, const Eina_Rectangle* area)
4224 {
4225     EINA_SAFETY_ON_NULL_RETURN(context);
4226     EINA_SAFETY_ON_NULL_RETURN(area);
4227
4228     WebCore::IntRect rect(*area);
4229
4230     if (context->view->isTransparent())
4231         context->graphicContext->clearRect(rect);
4232
4233     context->view->paintContents(context->graphicContext.get(), rect);
4234 }
4235
4236 void ewk_view_paint_context_scale(Ewk_View_Paint_Context* context, float scaleX, float scaleY)
4237 {
4238     EINA_SAFETY_ON_NULL_RETURN(context);
4239
4240     context->graphicContext->scale(WebCore::FloatSize(scaleX, scaleY));
4241 }
4242
4243 void ewk_view_paint_context_translate(Ewk_View_Paint_Context* context, float x, float y)
4244 {
4245     EINA_SAFETY_ON_NULL_RETURN(context);
4246
4247     context->graphicContext->translate(x, y);
4248 }
4249
4250 Eina_Bool ewk_view_paint(Ewk_View_Private_Data* priv, cairo_t* cr, const Eina_Rectangle* area)
4251 {
4252     EINA_SAFETY_ON_NULL_RETURN_VAL(priv, false);
4253     EINA_SAFETY_ON_NULL_RETURN_VAL(cr, false);
4254     EINA_SAFETY_ON_NULL_RETURN_VAL(area, false);
4255     WebCore::FrameView* view = priv->mainFrame->view();
4256     EINA_SAFETY_ON_NULL_RETURN_VAL(view, false);
4257
4258     view->updateLayoutAndStyleIfNeededRecursive();
4259     WebCore::GraphicsContext graphicsContext(cr);
4260     WebCore::IntRect rect(*area);
4261
4262     cairo_save(cr);
4263     graphicsContext.save();
4264     graphicsContext.clip(rect);
4265     if (view->isTransparent())
4266         graphicsContext.clearRect(rect);
4267     view->paint(&graphicsContext, rect);
4268     graphicsContext.restore();
4269     cairo_restore(cr);
4270 #endif
4271
4272     return true;
4273 }
4274
4275 #if ENABLE(TIZEN_SKIA_FOR_PROFILE)
4276 #ifdef __cplusplus
4277 extern "C" {
4278 #endif
4279 Eina_Bool ewk_view_paint_contents_for_profile(Ewk_View_Private_Data* priv, uint8_t* pixels, float zoom, const Eina_Rectangle* dst_area,  const Eina_Rectangle* area);
4280 #ifdef __cplusplus
4281 }
4282 #endif
4283 Eina_Bool ewk_view_paint_contents_for_profile(Ewk_View_Private_Data* priv, uint8_t* pixels, float zoom, const Eina_Rectangle* dst_area,  const Eina_Rectangle* area)
4284 {
4285     EINA_SAFETY_ON_NULL_RETURN_VAL(priv, false);
4286     EINA_SAFETY_ON_NULL_RETURN_VAL(pixels, false);
4287     EINA_SAFETY_ON_NULL_RETURN_VAL(area, false);
4288     WebCore::FrameView* view = priv->mainFrame->view();
4289     EINA_SAFETY_ON_NULL_RETURN_VAL(view, false);
4290 #if USE(CAIRO)
4291     cairo_status_t status;
4292 #endif
4293     Eina_Bool result = true;
4294 #if USE(CAIRO)
4295     cairo_t* cr;
4296     cairo_surface_t* surface;
4297     surface = cairo_image_surface_create_for_data(pixels, CAIRO_FORMAT_ARGB32, dst_area->w, dst_area->h, dst_area->w * 4);
4298     cr = cairo_create(surface);
4299     cairo_scale(cr, zoom, zoom);
4300     cairo_translate(cr, -dst_area->x, -dst_area->y);
4301     cairo_set_antialias(cairo, CAIRO_ANTIALIAS_NONE);
4302     WebCore::GraphicsContext gc(cr);
4303 #elif USE(SKIA)
4304     skia::PlatformCanvas canvas(dst_area->w, dst_area->h, 1, pixels);
4305     WebCore::PlatformContextSkia sContext(&canvas);
4306     WebCore::GraphicsContext gc(&sContext);
4307     gc.scale(WebCore::FloatSize(zoom, zoom));
4308     gc.translate(-dst_area->x, -dst_area->y);
4309 #endif
4310     WebCore::IntRect rect(area->x, area->y, area->w, area->h);
4311 #if USE(CAIRO)
4312     cairo_save(cr);
4313 #endif
4314     gc.save();
4315     gc.clip(rect);
4316     if (view->isTransparent())
4317         gc.clearRect(rect);
4318     view->paintContents(&gc, rect);
4319
4320 #if USE(CAIRO)
4321     status = cairo_status(cr);
4322     if (status != CAIRO_STATUS_SUCCESS) {
4323         ERR("Invalid status of cario context: %s", cairo_status_to_string(status));
4324         result = false;
4325     }
4326 #endif
4327     gc.restore();
4328 #if USE(CAIRO)
4329     cairo_restore(cr);
4330     cairo_identity_matrix(cr);
4331     cairo_surface_destroy(surface);
4332     cairo_destroy(cr);
4333 #endif
4334     return result;
4335 }
4336 #endif
4337
4338 Eina_Bool ewk_view_paint_contents(Ewk_View_Private_Data* priv, cairo_t* cr, const Eina_Rectangle* area)
4339 {
4340     EINA_SAFETY_ON_NULL_RETURN_VAL(priv, false);
4341     EINA_SAFETY_ON_NULL_RETURN_VAL(cr, false);
4342     EINA_SAFETY_ON_NULL_RETURN_VAL(area, false);
4343     WebCore::FrameView* view = priv->mainFrame->view();
4344     EINA_SAFETY_ON_NULL_RETURN_VAL(view, false);
4345
4346     WebCore::GraphicsContext graphicsContext(cr);
4347     WebCore::IntRect rect(*area);
4348
4349     view->updateLayoutAndStyleIfNeededRecursive();
4350     cairo_save(cr);
4351     graphicsContext.save();
4352     graphicsContext.clip(rect);
4353     if (view->isTransparent())
4354         graphicsContext.clearRect(rect);
4355
4356 #if ENABLE(TIZEN_WEBCORE_SELECTIVE_RENDERING)
4357     view->paintContents(&graphicsContext, rect, priv->delaysHeavyTiles);
4358 #else
4359     view->paintContents(&graphicsContext, rect);
4360 #endif
4361
4362 #if ENABLE(INSPECTOR) && ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
4363     WebCore::InspectorController* controller = priv->page->inspectorController();
4364     if (controller && controller->highlightedNode())
4365         controller->drawHighlight(graphicsContext);
4366 #endif
4367
4368     graphicsContext.restore();
4369     cairo_restore(cr);
4370
4371     return true;
4372 }
4373
4374
4375 /* internal methods ****************************************************/
4376 /**
4377  * @internal
4378  * Reports the view is ready to be displayed as all elements are aready.
4379  *
4380  * Emits signal: "ready" with no parameters.
4381  */
4382 void ewk_view_ready(Evas_Object* ewkView)
4383 {
4384     DBG("ewkView=%p", ewkView);
4385     evas_object_smart_callback_call(ewkView, "ready", 0);
4386 }
4387
4388 /**
4389  * @internal
4390  * Reports the state of input method changed. This is triggered, for example
4391  * when a input field received/lost focus
4392  *
4393  * Emits signal: "inputmethod,changed" with a boolean indicating whether it's
4394  * enabled or not.
4395  */
4396 void ewk_view_input_method_state_set(Evas_Object* ewkView, bool active)
4397 {
4398     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4399     EWK_VIEW_PRIV_GET(smartData, priv);
4400     WebCore::Frame* focusedFrame = priv->page->focusController()->focusedOrMainFrame();
4401
4402     priv->imh = 0;
4403     if (focusedFrame
4404         && focusedFrame->document()
4405         && focusedFrame->document()->focusedNode()
4406         && focusedFrame->document()->focusedNode()->hasTagName(WebCore::HTMLNames::inputTag)) {
4407         WebCore::HTMLInputElement* inputElement;
4408
4409         inputElement = static_cast<WebCore::HTMLInputElement*>(focusedFrame->document()->focusedNode());
4410         if (inputElement) {
4411             // for password fields, active == false
4412             if (!active) {
4413                 active = inputElement->isPasswordField();
4414                 priv->imh = inputElement->isPasswordField() * EWK_IMH_PASSWORD;
4415             } else {
4416                 // Set input method hints for "number", "tel", "email", and "url" input elements.
4417                 priv->imh |= inputElement->isTelephoneField() * EWK_IMH_TELEPHONE;
4418                 priv->imh |= inputElement->isNumberField() * EWK_IMH_NUMBER;
4419                 priv->imh |= inputElement->isEmailField() * EWK_IMH_EMAIL;
4420                 priv->imh |= inputElement->isURLField() * EWK_IMH_URL;
4421 #if ENABLE(TIZEN_INPUT_TAG_SUPPORT)
4422                 priv->imh |= inputElement->isColorField() * EWK_IMH_COLOR;
4423                 priv->imh |= inputElement->isDateField() * EWK_IMH_DATE;
4424                 priv->imh |= inputElement->isDateTimeField() * EWK_IMH_DATETIME;
4425                 priv->imh |= inputElement->isDateTimeLocalField() * EWK_IMH_DATETIMELOCAL;
4426                 priv->imh |= inputElement->isMonthField() * EWK_IMH_MONTH;
4427                 priv->imh |= inputElement->isTimeField() * EWK_IMH_TIME;
4428                 priv->imh |= inputElement->isWeekField() * EWK_IMH_WEEK;
4429 #endif
4430             }
4431         }
4432     }
4433 #if ENABLE(TIZEN_ISF_PORT)
4434     // pass the focused input element's rect as a event-info.
4435     if (active
4436         && focusedFrame
4437         && focusedFrame->document()) {
4438         if (focusedFrame->document()->focusedNode()) {
4439             WebCore::IntRect focusedRect = focusedFrame->document()->focusedNode()->getRect();
4440
4441             // add for inner frame
4442             WebCore::Frame* mainFrame = priv->page->mainFrame();
4443             WebCore::Frame* innerFrame = focusedFrame;
4444             while (innerFrame && innerFrame != mainFrame) {
4445                 WebCore::Node* owner = innerFrame->ownerElement();
4446                 if (owner) {
4447                     focusedRect.move(owner->getRect().x(), owner->getRect().y());
4448                     innerFrame = owner->document()->frame();
4449                 } else
4450                     break;
4451             }
4452
4453             // pass rect with inputmethod,changed event
4454             Eina_Rectangle rect = {focusedRect.x(), focusedRect.y(), focusedRect.width(), focusedRect.height()};
4455             evas_object_smart_callback_call(ewkView, "inputmethod,changed", (void*)&rect);
4456         } else {
4457             // if we get an input method state true without focused node we pass 0 but we do not clear selection
4458             // zoom will not work but a keyboard will remain shown
4459             evas_object_smart_callback_call(ewkView, "inputmethod,changed", 0);
4460         }
4461     } else {
4462         // if there is no focused inputElement, the inputmethod,changed's data will be null.
4463         evas_object_smart_callback_call(ewkView, "inputmethod,changed", 0);
4464     }
4465 #else
4466     evas_object_smart_callback_call(ewkView, "inputmethod,changed", (void*)active);
4467 #endif
4468 }
4469
4470 /**
4471  * @internal
4472  * The view title was changed by the frame loader.
4473  *
4474  * Emits signal: "title,changed" with pointer to new title string.
4475  */
4476 void ewk_view_title_set(Evas_Object* ewkView, const Ewk_Text_With_Direction* title)
4477 {
4478     DBG("ewkView=%p, title=%s", ewkView, (title && title->string) ? title->string : "(null)");
4479     evas_object_smart_callback_call(ewkView, "title,changed", (void*)title);
4480 }
4481
4482 /**
4483  * @internal
4484  * Reports that main frame's uri changed.
4485  *
4486  * Emits signal: "uri,changed" with pointer to the new uri string.
4487  */
4488 void ewk_view_uri_changed(Evas_Object* ewkView)
4489 {
4490     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4491     const char* uri = ewk_frame_uri_get(smartData->main_frame);
4492     DBG("ewkView=%p, uri=%s", ewkView, uri ? uri : "(null)");
4493     evas_object_smart_callback_call(ewkView, "uri,changed", (void*)uri);
4494 }
4495
4496 /**
4497  * @internal
4498  * Reports that a DOM document object has finished loading for @p frame.
4499  *
4500  * @param ewkView View which contains the frame.
4501  * @param frame The frame whose load has triggered the event.
4502  *
4503  * Emits signal: "load,document,finished" with @p frame as the parameter.
4504  */
4505 void ewk_view_load_document_finished(Evas_Object* ewkView, Evas_Object* frame)
4506 {
4507     evas_object_smart_callback_call(ewkView, "load,document,finished", frame);
4508 }
4509
4510 /**
4511  * @internal
4512  * Reports the view started loading something.
4513  *
4514  * @param ewkView View.
4515  * @param ewkFrame Frame being loaded.
4516  *
4517  * Emits signal: "load,started" with no parameters.
4518  */
4519 void ewk_view_load_started(Evas_Object* ewkView, Evas_Object* ewkFrame)
4520 {
4521     DBG("ewkView=%p, ewkFrame=%p", ewkView, ewkFrame);
4522 #if ENABLE(TIZEN_ISF_PORT) || ENABLE(TIZEN_FIRST_PAINT_NOTI)
4523     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4524     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4525 #endif
4526     evas_object_smart_callback_call(ewkView, "load,started", ewkFrame);
4527
4528 #if ENABLE(TIZEN_RECORDING_SURFACE)
4529     if (priv->recordingSurfaceEnable) {
4530         priv->recordingSurfaceSetLoadFinished = false;
4531         priv->recordingSurfaceSetState = RECORDING_SURFACE_SET_STATE_INIT;
4532         priv->recordingSurfaceSetList = ewk_recording_surface_set_free(priv->recordingSurfaceSetList);
4533     }
4534 #endif
4535
4536 #if ENABLE(TIZEN_FIRST_PAINT_NOTI)
4537     evas_object_smart_callback_del(smartData->backing_store, "paint,first", _ewk_view_first_paint_noti); // in order to prevent duplicated registration
4538     evas_object_smart_callback_add(smartData->backing_store, "paint,first", _ewk_view_first_paint_noti, smartData);
4539 #endif
4540
4541 #if ENABLE(TIZEN_ISF_PORT)
4542     if (priv->imContext
4543         && (ecore_imf_context_input_panel_state_get(priv->imContext) == ECORE_IMF_INPUT_PANEL_STATE_SHOW)) {
4544         ecore_imf_context_input_panel_hide(priv->imContext);
4545         ecore_imf_context_focus_out(priv->imContext);
4546     }
4547 #endif
4548 }
4549
4550 /**
4551  * Reports the frame started loading something.
4552  *
4553  * @param ewkView View.
4554  *
4555  * Emits signal: "load,started" on main frame with no parameters.
4556  */
4557 void ewk_view_frame_main_load_started(Evas_Object* ewkView)
4558 {
4559     DBG("ewkView=%p", ewkView);
4560     Evas_Object* frame = ewk_view_frame_main_get(ewkView);
4561     evas_object_smart_callback_call(frame, "load,started", 0);
4562 }
4563
4564 /**
4565  * @internal
4566  * Reports the main frame started provisional load.
4567  *
4568  * @param ewkView View.
4569  *
4570  * Emits signal: "load,provisional" on View with no parameters.
4571  */
4572 void ewk_view_load_provisional(Evas_Object* ewkView)
4573 {
4574     DBG("ewkView=%p", ewkView);
4575     evas_object_smart_callback_call(ewkView, "load,provisional", 0);
4576 }
4577
4578 /**
4579  * @internal
4580  * Reports the main frame provisional load failed.
4581  *
4582  * @param ewkView View.
4583  * @param error Load error.
4584  *
4585  * Emits signal: "load,provisional" on View with pointer to Ewk_Frame_Load_Error.
4586  */
4587 void ewk_view_load_provisional_failed(Evas_Object* ewkView, const Ewk_Frame_Load_Error* error)
4588 {
4589     DBG("ewkView=%p, error=%p", ewkView, error);
4590     evas_object_smart_callback_call(ewkView, "load,provisional,failed", const_cast<Ewk_Frame_Load_Error*>(error));
4591 }
4592
4593 /**
4594  * @internal
4595  * Reports view can be shown after a new window is created.
4596  *
4597  * @param ewkView Frame.
4598  *
4599  * Emits signal: "load,newwindow,show" on view with no parameters.
4600  */
4601 void ewk_view_load_show(Evas_Object* ewkView)
4602 {
4603     DBG("ewkView=%p", ewkView);
4604     evas_object_smart_callback_call(ewkView, "load,newwindow,show", 0);
4605 }
4606
4607 /**
4608  * @internal
4609  * Reports an onload event for @p frame.
4610  *
4611  * @param ewkView View which contains the frame.
4612  * @param frame The frame whose onload event was received.
4613  *
4614  * Emits signal: "onload,event" with @p frame as the parameter.
4615  */
4616 void ewk_view_onload_event(Evas_Object* ewkView, Evas_Object* frame)
4617 {
4618     evas_object_smart_callback_call(ewkView, "onload,event", frame);
4619 }
4620
4621 /**
4622  * @internal
4623  * Reports the main frame was cleared.
4624  *
4625  * @param ewkView View.
4626  */
4627 void ewk_view_frame_main_cleared(Evas_Object* ewkView)
4628 {
4629     DBG("ewkView=%p", ewkView);
4630     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4631     EINA_SAFETY_ON_NULL_RETURN(smartData->api->flush);
4632     smartData->api->flush(smartData);
4633
4634     ewk_view_mixed_content_displayed_set(ewkView, false);
4635     ewk_view_mixed_content_run_set(ewkView, false);
4636 }
4637
4638 /**
4639  * @internal
4640  * Reports the main frame received an icon.
4641  *
4642  * @param ewkView View.
4643  *
4644  * Emits signal: "icon,received" with no parameters.
4645  */
4646 void ewk_view_frame_main_icon_received(Evas_Object* ewkView)
4647 {
4648     DBG("ewkView=%p", ewkView);
4649     Evas_Object* frame = ewk_view_frame_main_get(ewkView);
4650     evas_object_smart_callback_call(frame, "icon,received", 0);
4651 }
4652
4653 /**
4654  * @internal
4655  * Reports load finished, optionally with error information.
4656  *
4657  * Emits signal: "load,finished" with pointer to #Ewk_Frame_Load_Error
4658  * if any error, or @c 0 if successful load.
4659  *
4660  * @note there should not be any error stuff here, but trying to be
4661  *       compatible with previous WebKit.
4662  */
4663 void ewk_view_load_finished(Evas_Object* ewkView, const Ewk_Frame_Load_Error* error)
4664 {
4665     DBG("ewkView=%p, error=%p", ewkView, error);
4666     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4667     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4668 #if ENABLE(TIZEN_WHITE_LOADING_FIX)
4669     /* If we reach this point and rendering is still disabled, WebCore will not
4670      * trigger the didFirstVisuallyNonEmptyLayout signal anymore. So, we
4671      * forcefully re-enable the rendering.
4672      * This is needed e.g. for standalone svg loading
4673      */
4674     ewk_view_enable_render(ewkView);
4675 #endif
4676
4677 #if ENABLE(TIZEN_RECORDING_SURFACE)
4678     priv->callOnceAfterLoadFinished = true;
4679 #if !ENABLE(TIZEN_PRE_RENDERING_ENABLE)
4680     if (priv->recordingSurfaceEnable) {
4681         float zoom = ewk_view_zoom_get(ewkView);
4682         priv->recordingSurfaceSetState =  RECORDING_SURFACE_SET_STATE_INIT;
4683         priv->recordingSurfaceSetList = ewk_recording_surface_set_free(priv->recordingSurfaceSetList);
4684         priv->recordingSurfaceSetList = ewk_recording_surface_set_base_record(priv->recordingSurfaceSetList, ewkView, zoom);
4685         priv->recordingSurfaceSetState= RECORDING_SURFACE_SET_STATE_COMPLETE;
4686         priv->recordingSurfaceSetLoadFinished = true;
4687     }
4688 #endif
4689 #endif
4690
4691     evas_object_smart_callback_call(ewkView, "load,finished", (void*)error);
4692
4693 #if ENABLE(TIZEN_PAGE_CACHE)
4694     if (priv->cachedPageData.isRestored) {
4695         priv->cachedPageData.isRestored = false;
4696         ewk_view_zoom_set(ewkView, priv->cachedPageData.zoomLevel, 0, 0);
4697         ewk_frame_scroll_set(smartData->main_frame, priv->cachedPageData.scrollPos.x(), priv->cachedPageData.scrollPos.y());
4698     }
4699 #endif
4700 #if ENABLE(TIZEN_PRE_RENDERING_ENABLE)
4701     // when load finished, it need to pre-render forcely.
4702     ewk_view_pre_render_start(ewkView);
4703 #endif
4704 #if ENABLE(TIZEN_RECORDING_SURFACE)
4705     ewk_view_recording_surface_start(ewkView);
4706 #endif
4707 }
4708
4709 /**
4710  * @internal
4711  * Reports load failed with error information.
4712  *
4713  * Emits signal: "load,error" with pointer to Ewk_Frame_Load_Error.
4714  */
4715 void ewk_view_load_error(Evas_Object* ewkView, const Ewk_Frame_Load_Error* error)
4716 {
4717     DBG("ewkView=%p, error=%p", ewkView, error);
4718     evas_object_smart_callback_call(ewkView, "load,error", (void*)error);
4719 }
4720
4721 /**
4722  * @internal
4723  * Reports load progress changed.
4724  *
4725  * Emits signal: "load,progress" with pointer to a double from 0.0 to 1.0.
4726  */
4727 void ewk_view_load_progress_changed(Evas_Object* ewkView)
4728 {
4729     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4730     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4731
4732     // Evas_Coord width, height;
4733     double progress = priv->page->progress()->estimatedProgress();
4734
4735     DBG("ewkView=%p (p=%0.3f)", ewkView, progress);
4736
4737     evas_object_smart_callback_call(ewkView, "load,progress", &progress);
4738 }
4739
4740 /**
4741  * @internal
4742  * Reports view @param ewkView should be restored to default conditions
4743  *
4744  * @param ewkView View.
4745  * @param frame Frame that originated restore.
4746  *
4747  * Emits signal: "restore" with frame.
4748  */
4749 void ewk_view_restore_state(Evas_Object* ewkView, Evas_Object* frame)
4750 {
4751     evas_object_smart_callback_call(ewkView, "restore", frame);
4752 }
4753
4754 /**
4755  * @internal
4756  * Delegates to browser the creation of a new window. If it is not implemented,
4757  * current view is returned, so navigation might continue in same window. If
4758  * browser supports the creation of new windows, a new Ewk_Window_Features is
4759  * created and passed to browser. If it intends to keep the request for opening
4760  * the window later it must increments the Ewk_Winwdow_Features ref count by
4761  * calling ewk_window_features_ref(window_features). Otherwise this struct will
4762  * be freed after returning to this function.
4763  *
4764  * @param ewkView Current view.
4765  * @param javascript @c true if the new window is originated from javascript,
4766  * @c false otherwise
4767  * @param window_features Features of the new window being created. If it's @c
4768  * 0, it will be created a window with default features.
4769  *
4770  * @return New view, in case smart class implements the creation of new windows;
4771  * else, current view @param ewkView or @c 0 on failure.
4772  *
4773  * @see ewk_window_features_ref().
4774  */
4775 #if ENABLE(TIZEN_FORM_SUBMIT_SUPPORT)
4776 Evas_Object* ewk_view_window_create(Evas_Object* ewkView, bool javascript, bool isMobile, const WebCore::WindowFeatures* coreFeatures, const WebCore::NavigationAction& action, const WTF::String& frameName)
4777 #else
4778 Evas_Object* ewk_view_window_create(Evas_Object* ewkView, bool javascript, const WebCore::WindowFeatures* coreFeatures)
4779 #endif
4780 {
4781     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4782 #if ENABLE(TIZEN_FORM_SUBMIT_SUPPORT)
4783     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4784     if (!smartData->api->window_create)
4785         return ewkView;
4786
4787     if (javascript) {
4788         if (!frameName.isEmpty())
4789             priv->frameName = eina_stringshare_add(frameName.utf8().data());
4790         else
4791             priv->frameName = 0;
4792     }
4793
4794     Ewk_Window_Features* window_features = ewk_window_features_new_from_core(coreFeatures);
4795     Evas_Object* view = smartData->api->window_create(smartData, javascript, isMobile, window_features, action.type(), priv->frameName);
4796
4797     if (javascript)
4798         priv->formWindow = view;
4799
4800     ewk_window_features_unref(window_features);
4801 #else
4802     if (!smartData->api->window_create)
4803         return ewkView;
4804
4805     Ewk_Window_Features* windowFeatures = ewk_window_features_new_from_core(coreFeatures);
4806     if (!windowFeatures)
4807         return 0;
4808
4809     Evas_Object* view = smartData->api->window_create(smartData, javascript, windowFeatures);
4810     ewk_window_features_unref(windowFeatures);
4811
4812 #endif
4813     return view;
4814 }
4815
4816 #if ENABLE(TIZEN_FORM_SUBMIT_SUPPORT)
4817 Evas_Object* ewk_view_form_window_get(Evas_Object* ewkView)
4818 {
4819     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4820     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4821     return priv->formWindow;
4822 }
4823 #endif
4824
4825 /**
4826  * @internal
4827  * Reports a window should be closed. It's client responsibility to decide if
4828  * the window should in fact be closed. So, if only windows created by javascript
4829  * are allowed to be closed by this call, browser needs to save the javascript
4830  * flag when the window is created. Since a window can close itself (for example
4831  * with a 'self.close()' in Javascript) browser must postpone the deletion to an
4832  * idler.
4833  *
4834  * @param ewkView View to be closed.
4835  */
4836 void ewk_view_window_close(Evas_Object* ewkView)
4837 {
4838     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4839 #if ENABLE(TIZEN_FORM_SUBMIT_SUPPORT)
4840     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4841 #endif
4842
4843     ewk_view_stop(ewkView);
4844     if (!smartData->api->window_close)
4845         return;
4846     smartData->api->window_close(smartData);
4847 }
4848
4849 /**
4850  * @internal
4851  * Reports mouse has moved over a link.
4852  *
4853  * Emits signal: "link,hover,in"
4854  */
4855 void ewk_view_mouse_link_hover_in(Evas_Object* ewkView, void* data)
4856 {
4857     evas_object_smart_callback_call(ewkView, "link,hover,in", data);
4858 }
4859
4860 /**
4861  * @internal
4862  * Reports mouse is not over a link anymore.
4863  *
4864  * Emits signal: "link,hover,out"
4865  */
4866 void ewk_view_mouse_link_hover_out(Evas_Object* ewkView)
4867 {
4868     evas_object_smart_callback_call(ewkView, "link,hover,out", 0);
4869 }
4870
4871 /**
4872  * @internal
4873  * Set toolbar visible.
4874  *
4875  * Emits signal: "toolbars,visible,set" with a pointer to a boolean.
4876  */
4877 void ewk_view_toolbars_visible_set(Evas_Object* ewkView, bool visible)
4878 {
4879     DBG("ewkView=%p (visible=%d)", ewkView, !!visible);
4880     evas_object_smart_callback_call(ewkView, "toolbars,visible,set", &visible);
4881 }
4882
4883 /**
4884  * @internal
4885  * Get toolbar visibility.
4886  *
4887  * @param ewkView View.
4888  * @param visible boolean pointer in which to save the result. It defaults
4889  * to @c FALSE, i.e. if browser does no listen to emitted signal, it means
4890  * there are no toolbars and therefore they are not visible.
4891  *
4892  * Emits signal: "toolbars,visible,get" with a pointer to a boolean.
4893  */
4894 void ewk_view_toolbars_visible_get(Evas_Object* ewkView, bool* visible)
4895 {
4896     DBG("%s, ewkView=%p", __func__, ewkView);
4897     *visible = false;
4898     evas_object_smart_callback_call(ewkView, "toolbars,visible,get", visible);
4899 }
4900
4901 /**
4902  * @internal
4903  * Set statusbar visible.
4904  *
4905  * @param ewkView View.
4906  * @param visible @c TRUE if statusbar are visible, @c FALSE otherwise.
4907  *
4908  * Emits signal: "statusbar,visible,set" with a pointer to a boolean.
4909  */
4910 void ewk_view_statusbar_visible_set(Evas_Object* ewkView, bool  visible)
4911 {
4912     DBG("ewkView=%p (visible=%d)", ewkView, !!visible);
4913     evas_object_smart_callback_call(ewkView, "statusbar,visible,set", &visible);
4914 }
4915
4916 /**
4917  * @internal
4918  * Get statusbar visibility.
4919  *
4920  * @param ewkView View.
4921  * @param visible boolean pointer in which to save the result. It defaults
4922  * to @c FALSE, i.e. if browser does no listen to emitted signal, it means
4923  * there is no statusbar and therefore it is not visible.
4924  *
4925  * Emits signal: "statusbar,visible,get" with a pointer to a boolean.
4926  */
4927 void ewk_view_statusbar_visible_get(Evas_Object* ewkView, bool* visible)
4928 {
4929     DBG("%s, ewkView=%p", __func__, ewkView);
4930     *visible = false;
4931     evas_object_smart_callback_call(ewkView, "statusbar,visible,get", visible);
4932 }
4933
4934 /**
4935  * @internal
4936  * Set text of statusbar
4937  *
4938  * @param ewkView View.
4939  * @param text New text to put on statusbar.
4940  *
4941  * Emits signal: "statusbar,text,set" with a string.
4942  */
4943 void ewk_view_statusbar_text_set(Evas_Object* ewkView, const char* text)
4944 {
4945     DBG("ewkView=%p (text=%s)", ewkView, text);
4946     INF("status bar text set: %s", text);
4947     evas_object_smart_callback_call(ewkView, "statusbar,text,set", (void*)text);
4948 }
4949
4950 /**
4951  * @internal
4952  * Set scrollbars visible.
4953  *
4954  * @param ewkView View.
4955  * @param visible @c TRUE if scrollbars are visible, @c FALSE otherwise.
4956  *
4957  * Emits signal: "scrollbars,visible,set" with a pointer to a boolean.
4958  */
4959 void ewk_view_scrollbars_visible_set(Evas_Object* ewkView, bool visible)
4960 {
4961     DBG("ewkView=%p (visible=%d)", ewkView, !!visible);
4962     evas_object_smart_callback_call(ewkView, "scrollbars,visible,set", &visible);
4963 }
4964
4965 /**
4966  * @internal
4967  * Get scrollbars visibility.
4968  *
4969  * @param ewkView View.
4970  * @param visible boolean pointer in which to save the result. It defaults
4971  * to @c FALSE, i.e. if browser does no listen to emitted signal, it means
4972  * there are no scrollbars and therefore they are not visible.
4973  *
4974  * Emits signal: "scrollbars,visible,get" with a pointer to a boolean.
4975  */
4976 void ewk_view_scrollbars_visible_get(Evas_Object* ewkView, bool* visible)
4977 {
4978     DBG("%s, ewkView=%p", __func__, ewkView);
4979     *visible = false;
4980     evas_object_smart_callback_call(ewkView, "scrollbars,visible,get", visible);
4981 }
4982
4983 /**
4984  * @internal
4985  * Set menubar visible.
4986  *
4987  * @param ewkView View.
4988  * @param visible @c TRUE if menubar is visible, @c FALSE otherwise.
4989  *
4990  * Emits signal: "menubar,visible,set" with a pointer to a boolean.
4991  */
4992 void ewk_view_menubar_visible_set(Evas_Object* ewkView, bool visible)
4993 {
4994     DBG("ewkView=%p (visible=%d)", ewkView, !!visible);
4995     evas_object_smart_callback_call(ewkView, "menubar,visible,set", &visible);
4996 }
4997
4998 /**
4999  * @internal
5000  * Get menubar visibility.
5001  *
5002  * @param ewkView View.
5003  * @param visible boolean pointer in which to save the result. It defaults
5004  * to @c FALSE, i.e. if browser does no listen to emitted signal, it means
5005  * there is no menubar and therefore it is not visible.
5006  *
5007  * Emits signal: "menubar,visible,get" with a pointer to a boolean.
5008  */
5009 void ewk_view_menubar_visible_get(Evas_Object* ewkView, bool* visible)
5010 {
5011     DBG("%s, ewkView=%p", __func__, ewkView);
5012     *visible = false;
5013     evas_object_smart_callback_call(ewkView, "menubar,visible,get", visible);
5014 }
5015
5016 /**
5017  * @internal
5018  * Set tooltip text and display if it is currently hidden.
5019  *
5020  * @param ewkView View.
5021  * @param text Text to set tooltip to.
5022  *
5023  * Emits signal: "tooltip,text,set" with a string. If tooltip must be actually
5024  * removed, text will be 0 or '\0'
5025  */
5026 void ewk_view_tooltip_text_set(Evas_Object* ewkView, const char* text)
5027 {
5028     DBG("ewkView=%p text=%s", ewkView, text);
5029     evas_object_smart_callback_call(ewkView, "tooltip,text,set", (void*)text);
5030 }
5031
5032 /**
5033  * @internal
5034  *
5035  * @param ewkView View.
5036  * @param message String to show on console.
5037  * @param lineNumber Line number.
5038  * @sourceID Source id.
5039  *
5040  */
5041 void ewk_view_add_console_message(Evas_Object* ewkView, const char* message, unsigned int lineNumber, const char* sourceID)
5042 {
5043     DBG("ewkView=%p message=%s lineNumber=%u sourceID=%s", ewkView, message, lineNumber, sourceID);
5044     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5045     EINA_SAFETY_ON_NULL_RETURN(smartData->api);
5046     EINA_SAFETY_ON_NULL_RETURN(smartData->api->add_console_message);
5047     smartData->api->add_console_message(smartData, message, lineNumber, sourceID);
5048 }
5049
5050 /**
5051  * @internal
5052  *
5053  * Reports that FrameView object has been created.
5054  * Allows to repaint the frame completely even if the areas are out of the screen
5055  * when @ewkView is an instance of ewk_view_tiled.
5056  *
5057  * @param ewkView view object
5058  */
5059 void ewk_view_frame_view_creation_notify(Evas_Object* ewkView)
5060 {
5061     EWK_VIEW_TYPE_CHECK_OR_RETURN(ewkView, ewkViewTiledName);
5062     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5063     ewk_frame_paint_full_set(smartData->main_frame, true);
5064 }
5065
5066 bool ewk_view_focus_can_cycle(Evas_Object* ewkView, Ewk_Focus_Direction direction)
5067 {
5068     DBG("ewkView=%p direction=%d", ewkView, direction);
5069     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5070     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
5071
5072     if (!smartData->api->focus_can_cycle)
5073         return false;
5074
5075     return smartData->api->focus_can_cycle(smartData, direction);
5076 }
5077
5078 void ewk_view_run_javascript_alert(Evas_Object* ewkView, Evas_Object* frame, const char* message)
5079 {
5080     DBG("ewkView=%p frame=%p message=%s", ewkView, frame, message);
5081     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5082     EINA_SAFETY_ON_NULL_RETURN(smartData->api);
5083
5084     if (!smartData->api->run_javascript_alert)
5085         return;
5086
5087     smartData->api->run_javascript_alert(smartData, frame, message);
5088 }
5089
5090 bool ewk_view_run_javascript_confirm(Evas_Object* ewkView, Evas_Object* frame, const char* message)
5091 {
5092     DBG("ewkView=%p frame=%p message=%s", ewkView, frame, message);
5093     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5094     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
5095
5096     if (!smartData->api->run_javascript_confirm)
5097         return false;
5098
5099     return smartData->api->run_javascript_confirm(smartData, frame, message);
5100 }
5101
5102 bool ewk_view_run_javascript_prompt(Evas_Object* ewkView, Evas_Object* frame, const char* message, const char* defaultValue, char** value)
5103 {
5104     DBG("ewkView=%p frame=%p message=%s", ewkView, frame, message);
5105     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5106     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
5107
5108     if (!smartData->api->run_javascript_prompt)
5109         return false;
5110
5111     return smartData->api->run_javascript_prompt(smartData, frame, message, defaultValue, value);
5112 }
5113
5114 /**
5115  * @internal
5116  * Delegates to client to decide whether a script must be stopped because it's
5117  * running for too long. If client does not implement it, it goes to default
5118  * implementation, which logs and returns false. Client may remove log by
5119  * setting this function 0, which will just return false.
5120  *
5121  * @param ewkView View.
5122  *
5123  * @return @c true if script should be stopped; @c false otherwise
5124  */
5125 bool ewk_view_should_interrupt_javascript(Evas_Object* ewkView)
5126 {
5127     DBG("ewkView=%p", ewkView);
5128     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5129     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
5130
5131     if (!smartData->api->should_interrupt_javascript)
5132         return false;
5133
5134     return smartData->api->should_interrupt_javascript(smartData);
5135 }
5136
5137 /**
5138  * @internal
5139  * This is called whenever the application is asking to store data to the cache and the
5140  * quota allocated to that application is exceeded. Browser may use this to increase the
5141  * size of quota before the originating operation fails.
5142  *
5143  * @param ewkView View.
5144  * @param origin Security origin.
5145  * @param defaultOriginQuota Default quota for origin.
5146  * @param totalSpaceNeeded The total space needed in the cache in order to fulfill
5147  * application's requirement.
5148  */
5149 int64_t ewk_view_exceeded_application_cache_quota(Evas_Object* ewkView, Ewk_Security_Origin *origin, int64_t defaultOriginQuota, int64_t totalSpaceNeeded)
5150 {
5151     DBG("ewkView=%p", ewkView);
5152     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
5153     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, 0);
5154     if (!smartData->api->exceeded_application_cache_quota)
5155         return 0;
5156
5157     INF("defaultOriginQuota=%" PRIu64 " totalSpaceNeeded=%" PRIu64, defaultOriginQuota, totalSpaceNeeded);
5158     return smartData->api->exceeded_application_cache_quota(smartData, origin, defaultOriginQuota, totalSpaceNeeded);
5159 }
5160
5161 /**
5162  * @internal
5163  * This is called whenever the web site shown in @param frame is asking to store data
5164  * to the database @param databaseName and the quota allocated to that web site
5165  * is exceeded. Browser may use this to increase the size of quota before the
5166  * originating operationa fails.
5167  *
5168  * @param ewkView View.
5169  * @param frame The frame whose web page exceeded its database quota.
5170  * @param databaseName Database name.
5171  * @param currentSize Current size of this database
5172  * @param expectedSize The expected size of this database in order to fulfill
5173  * site's requirement.
5174  */
5175 uint64_t ewk_view_exceeded_database_quota(Evas_Object* ewkView, Evas_Object* frame, const char* databaseName, uint64_t currentSize, uint64_t expectedSize)
5176 {
5177     DBG("ewkView=%p", ewkView);
5178     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
5179     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, 0);
5180     if (!smartData->api->exceeded_database_quota)
5181         return 0;
5182
5183     INF("currentSize=%" PRIu64 " expectedSize=%" PRIu64, currentSize, expectedSize);
5184     return smartData->api->exceeded_database_quota(smartData, frame, databaseName, currentSize, expectedSize);
5185 }
5186
5187 /**
5188  * @internal
5189  * Open panel to choose a file.
5190  *
5191  * @param ewkView View.
5192  * @param frame Frame in which operation is required.
5193  * @param allowsMultipleFiles @c true when more than one file may be selected, @c false otherwise.
5194  * @param acceptMIMETypes List of accepted mime types. It is passed to child objects as an Eina_List of char pointers that is freed automatically.
5195  * @param selectedFilenames List of files selected.
5196  *
5197  * @return @false if user canceled file selection; @true if confirmed.
5198  */
5199 bool ewk_view_run_open_panel(Evas_Object* ewkView, Evas_Object* frame, bool allowsMultipleFiles, const WTF::Vector<WTF::String>& acceptMIMETypes, Eina_List** selectedFilenames)
5200 {
5201     DBG("ewkView=%p frame=%p allows_multiple_files=%d", ewkView, frame, allowsMultipleFiles);
5202     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5203     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
5204
5205     if (!smartData->api->run_open_panel)
5206         return false;
5207
5208     *selectedFilenames = 0;
5209
5210     Eina_List* cAcceptMIMETypes = 0;
5211     for (WTF::Vector<WTF::String>::const_iterator iterator = acceptMIMETypes.begin(); iterator != acceptMIMETypes.end(); ++iterator)
5212         cAcceptMIMETypes = eina_list_append(cAcceptMIMETypes, strdup((*iterator).utf8().data()));
5213
5214     bool confirm = smartData->api->run_open_panel(smartData, frame, allowsMultipleFiles, cAcceptMIMETypes, selectedFilenames);
5215     if (!confirm && *selectedFilenames)
5216         ERR("Canceled file selection, but selected filenames != 0. Free names before return.");
5217
5218     void* item = 0;
5219     EINA_LIST_FREE(cAcceptMIMETypes, item)
5220         free(item);
5221
5222     return confirm;
5223 }
5224
5225 void ewk_view_repaint(Evas_Object* ewkView, Evas_Coord x, Evas_Coord y, Evas_Coord width, Evas_Coord height)
5226 {
5227     DBG("ewkView=%p, region=%d,%d + %dx%d", ewkView, x, y, width, height);
5228     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5229     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5230
5231     if (!priv->mainFrame->contentRenderer()) {
5232         ERR("no main frame content renderer.");
5233         return;
5234     }
5235
5236     _ewk_view_repaint_add(priv, x, y, width, height);
5237     _ewk_view_smart_changed(smartData);
5238 }
5239
5240 void ewk_view_scroll(Evas_Object* ewkView, Evas_Coord deltaX, Evas_Coord deltaY, Evas_Coord scrollX, Evas_Coord scrollY, Evas_Coord scrollWidth, Evas_Coord scrollHeight, Evas_Coord centerX, Evas_Coord centerY, Evas_Coord centerWidth, Evas_Coord centerHeight)
5241 {
5242     DBG("ewkView=%p, delta: %d,%d, scroll: %d,%d+%dx%d, clip: %d,%d+%dx%d",
5243         ewkView, deltaX, deltaY, scrollX, scrollY, scrollWidth, scrollHeight, centerX, centerY, centerWidth, centerHeight);
5244
5245     if ((scrollX != centerX) || (scrollY != centerY) || (scrollWidth != centerWidth) || (scrollHeight != centerHeight))
5246         WRN("scroll region and clip are different! %d,%d+%dx%d and %d,%d+%dx%d",
5247             scrollX, scrollY, scrollWidth, scrollHeight, centerX, centerY, centerWidth, centerHeight);
5248
5249     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5250
5251 #if ENABLE(TIZEN_WEAK_SCROLL)
5252     if (!ewk_frame_weak_scroll_moving_viewport_get(smartData->main_frame))
5253         return;
5254 #endif
5255
5256     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5257     EINA_SAFETY_ON_TRUE_RETURN(!deltaX && !deltaY);
5258
5259     _ewk_view_scroll_add(priv, deltaX, deltaY, scrollX, scrollY, scrollWidth, scrollHeight);
5260
5261     _ewk_view_smart_changed(smartData);
5262 }
5263
5264 /**
5265  * Creates a new frame for given url and owner element.
5266  *
5267  * Emits "frame,created" with the new frame object on success.
5268  */
5269 WTF::PassRefPtr<WebCore::Frame> ewk_view_frame_create(Evas_Object* ewkView, Evas_Object* frame, const WTF::String& name, WebCore::HTMLFrameOwnerElement* ownerElement, const WebCore::KURL& url, const WTF::String& referrer)
5270 {
5271     DBG("ewkView=%p, frame=%p, name=%s, ownerElement=%p, url=%s, referrer=%s",
5272         ewkView, frame, name.utf8().data(), ownerElement,
5273         url.string().utf8().data(), referrer.utf8().data());
5274
5275     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
5276     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
5277
5278     WTF::RefPtr<WebCore::Frame> coreFrame = _ewk_view_core_frame_new
5279                                          (smartData, priv, ownerElement);
5280     if (!coreFrame) {
5281         ERR("Could not create child core frame '%s'", name.utf8().data());
5282         return 0;
5283     }
5284
5285     if (!ewk_frame_child_add(frame, coreFrame, name, url, referrer)) {
5286         ERR("Could not create child frame object '%s'", name.utf8().data());
5287         return 0;
5288     }
5289
5290     // The creation of the frame may have removed itself already.
5291     if (!coreFrame->page() || !coreFrame->tree() || !coreFrame->tree()->parent())
5292         return 0;
5293
5294     smartData->changed.frame_rect = true;
5295     _ewk_view_smart_changed(smartData);
5296
5297     return coreFrame.release();
5298 }
5299
5300 WTF::PassRefPtr<WebCore::Widget> ewk_view_plugin_create(Evas_Object* ewkView, Evas_Object* frame, const WebCore::IntSize& pluginSize, WebCore::HTMLPlugInElement* element, const WebCore::KURL& url, const WTF::Vector<WTF::String>& paramNames, const WTF::Vector<WTF::String>& paramValues, const WTF::String& mimeType, bool loadManually)
5301 {
5302     DBG("ewkView=%p, frame=%p, size=%dx%d, element=%p, url=%s, mimeType=%s",
5303         ewkView, frame, pluginSize.width(), pluginSize.height(), element,
5304         url.string().utf8().data(), mimeType.utf8().data());
5305
5306     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
5307     smartData->changed.frame_rect = true;
5308     _ewk_view_smart_changed(smartData);
5309
5310     return ewk_frame_plugin_create
5311                (frame, pluginSize, element, url, paramNames, paramValues,
5312                mimeType, loadManually);
5313 }
5314
5315 /**
5316  * @internal
5317  *
5318  * Creates a new popup with options when a select widget was clicked.
5319  *
5320  * @param client PopupMenuClient instance that allows communication with webkit.
5321  * @param selected Selected item.
5322  * @param rect Menu's position.
5323  *
5324  * Emits: "popup,create" with a list of Ewk_Menu containing each item's data
5325  */
5326 void ewk_view_popup_new(Evas_Object* ewkView, WebCore::PopupMenuClient* client, int selected, const WebCore::IntRect& rect)
5327 {
5328     INF("ewkView=%p", ewkView);
5329     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5330     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5331
5332     if (priv->popup.menuClient)
5333         ewk_view_popup_destroy(ewkView);
5334
5335     priv->popup.menuClient = client;
5336
5337     // populate items
5338     const int size = client->listSize();
5339     for (int i = 0; i < size; ++i) {
5340         Ewk_Menu_Item* item = new Ewk_Menu_Item;
5341         if (client->itemIsSeparator(i))
5342             item->type = EWK_MENU_SEPARATOR;
5343         else if (client->itemIsLabel(i))
5344             item->type = EWK_MENU_GROUP;
5345         else
5346             item->type = EWK_MENU_OPTION;
5347         item->text = eina_stringshare_add(client->itemText(i).utf8().data());
5348
5349         priv->popup.menu.items = eina_list_append(priv->popup.menu.items, item);
5350     }
5351
5352     priv->popup.menu.x = rect.x();
5353     priv->popup.menu.y = rect.y();
5354     priv->popup.menu.width = rect.width();
5355     priv->popup.menu.height = rect.height();
5356     evas_object_smart_callback_call(ewkView, "popup,create", &priv->popup.menu);
5357 }
5358
5359 Eina_Bool ewk_view_popup_destroy(Evas_Object* ewkView)
5360 {
5361     INF("ewkView=%p", ewkView);
5362     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5363     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5364
5365     if (!priv->popup.menuClient)
5366         return false;
5367
5368     evas_object_smart_callback_call(ewkView, "popup,willdelete", &priv->popup.menu);
5369
5370     void* itemv;
5371     EINA_LIST_FREE(priv->popup.menu.items, itemv) {
5372         Ewk_Menu_Item* item = static_cast<Ewk_Menu_Item*>(itemv);
5373         eina_stringshare_del(item->text);
5374         delete item;
5375     }
5376     priv->popup.menuClient->popupDidHide();
5377     priv->popup.menuClient = 0;
5378
5379     return true;
5380 }
5381
5382 void ewk_view_popup_selected_set(Evas_Object* ewkView, int index)
5383 {
5384     INF("ewkView=%p", ewkView);
5385     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5386     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5387     EINA_SAFETY_ON_NULL_RETURN(priv->popup.menuClient);
5388
5389     priv->popup.menuClient->valueChanged(index);
5390 }
5391
5392 #if ENABLE(INPUT_TYPE_COLOR)
5393 /**
5394  * @internal
5395  *
5396  * Creates a new color chooser with an initial selected color.
5397  *
5398  * @param client ColorChooserClient instance that allows communication with webkit.
5399  * @param initialColor The initial selected color.
5400  *
5401  */
5402 void ewk_view_color_chooser_new(Evas_Object* ewkView, WebCore::ColorChooserClient* client, const WebCore::Color& initialColor)
5403 {
5404     INF("ewkView=%p", ewkView);
5405     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5406     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5407
5408     if (priv->colorChooserClient)
5409         ewk_view_color_chooser_destroy(ewkView);
5410
5411     priv->colorChooserClient = client;
5412
5413     Ewk_Color color;
5414     color.r = initialColor.red();
5415     color.g = initialColor.green();
5416     color.b = initialColor.blue();
5417     color.a = initialColor.alpha();
5418
5419     evas_object_smart_callback_call(ewkView, "colorchooser,create", &color);
5420 }
5421
5422 Eina_Bool ewk_view_color_chooser_destroy(Evas_Object* ewkView)
5423 {
5424     INF("ewkView=%p", ewkView);
5425     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5426     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5427
5428     if (!priv->colorChooserClient)
5429         return false;
5430
5431     evas_object_smart_callback_call(ewkView, "colorchooser,willdelete", 0);
5432
5433     priv->colorChooserClient->didEndChooser();
5434     priv->colorChooserClient = 0;
5435
5436     return true;
5437 }
5438
5439 void ewk_view_color_chooser_color_set(Evas_Object *ewkView, int r, int g, int b)
5440 {
5441     INF("ewkView=%p", ewkView);
5442     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5443     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5444     EINA_SAFETY_ON_NULL_RETURN(priv->colorChooserClient);
5445
5446     // Alpha channel is not allowed, see ColorInputType::sanitizeValue().
5447     priv->colorChooserClient->didChooseColor(WebCore::Color(r, g, b));
5448 }
5449
5450 /**
5451  * @internal
5452  *
5453  * The selected color of the color input associated with the color chooser has
5454  * changed. Usually the browser should updated the current selected value on the
5455  * color picker if the user is not interacting.
5456  *
5457  * @param newColor The new selected color.
5458  *
5459  */
5460 void ewk_view_color_chooser_changed(Evas_Object* ewkView, const WebCore::Color& newColor)
5461 {
5462     INF("ewkView=%p", ewkView);
5463
5464     Ewk_Color color;
5465     color.r = newColor.red();
5466     color.g = newColor.green();
5467     color.b = newColor.blue();
5468     color.a = newColor.alpha();
5469
5470     evas_object_smart_callback_call(ewkView, "colorchooser,color,changed", &color);
5471 }
5472 #endif
5473
5474 /**
5475  * @internal
5476  * Request a download to user.
5477  *
5478  * @param ewkView View.
5479  * @oaram download Ewk_Download struct to be sent.
5480  *
5481  * Emits: "download,request" with an Ewk_Download containing the details of the
5482  * requested download. The download per se must be handled outside of webkit.
5483  */
5484 void ewk_view_download_request(Evas_Object* ewkView, Ewk_Download* download)
5485 {
5486     DBG("ewkView=%p", ewkView);
5487     evas_object_smart_callback_call(ewkView, "download,request", download);
5488 }
5489
5490 #if ENABLE(NETSCAPE_PLUGIN_API)
5491 /**
5492  * @internal
5493  * Reports the JS window object was cleared.
5494  *
5495  * @param ewkView view.
5496  * @param frame the frame.
5497  */
5498 void ewk_view_js_window_object_clear(Evas_Object* ewkView, Evas_Object* frame)
5499 {
5500     evas_object_smart_callback_call(ewkView, "js,windowobject,clear", frame);
5501 }
5502 #endif
5503
5504 /**
5505  * @internal
5506  * Reports the viewport has changed.
5507  *
5508  * @param arguments viewport argument.
5509  *
5510  * Emits signal: "viewport,changed" with no parameters.
5511  */
5512 void ewk_view_viewport_attributes_set(Evas_Object* ewkView, const WebCore::ViewportArguments& arguments)
5513 {
5514     EWK_VIEW_SD_GET(ewkView, smartData);
5515     EWK_VIEW_PRIV_GET(smartData, priv);
5516
5517     priv->viewportArguments = arguments;
5518 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
5519     bool isViewportArgumentExist = !(arguments == WebCore::ViewportArguments());
5520     evas_object_smart_callback_call(ewkView, "viewport,changed", &isViewportArgumentExist);
5521     return;
5522 #endif
5523     evas_object_smart_callback_call(ewkView, "viewport,changed", 0);
5524 }
5525
5526 void ewk_view_viewport_attributes_get(const Evas_Object* ewkView, int* width, int* height, float* initScale, float* maxScale, float* minScale, float* devicePixelRatio, Eina_Bool* userScalable)
5527 {
5528     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5529     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5530     WebCore::ViewportAttributes attributes = _ewk_view_viewport_attributes_compute(ewkView);
5531
5532     if (width)
5533         *width = attributes.layoutSize.width();
5534     if (height)
5535         *height = attributes.layoutSize.height();
5536     if (initScale)
5537         *initScale = attributes.initialScale;
5538     if (maxScale)
5539         *maxScale = attributes.maximumScale;
5540     if (minScale)
5541         *minScale = attributes.minimumScale;
5542     if (devicePixelRatio)
5543         *devicePixelRatio = attributes.devicePixelRatio;
5544     if (userScalable)
5545         *userScalable = static_cast<bool>(attributes.userScalable);
5546 }
5547
5548 Eina_Bool ewk_view_zoom_range_set(Evas_Object* ewkView, float minScale, float maxScale)
5549 {
5550     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5551     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5552
5553     if (maxScale < minScale) {
5554         WRN("minScale is larger than maxScale");
5555         return false;
5556     }
5557
5558 #if ENABLE(TIZEN_WEAK_ZOOM_POSITION)
5559     minScale = ROUNDED_ZOOM(defaultTileWidth, minScale);
5560     maxScale = ROUNDED_ZOOM(defaultTileWidth, maxScale);
5561 #endif
5562
5563     priv->settings.zoomRange.minScale = minScale;
5564     priv->settings.zoomRange.maxScale = maxScale;
5565
5566     return true;
5567 }
5568
5569 float ewk_view_zoom_range_min_get(const Evas_Object* ewkView)
5570 {
5571     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
5572     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1.0);
5573
5574     return priv->settings.zoomRange.minScale;
5575 }
5576
5577 float ewk_view_zoom_range_max_get(const Evas_Object* ewkView)
5578 {
5579     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
5580     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1.0);
5581
5582     return priv->settings.zoomRange.maxScale;
5583 }
5584
5585 Eina_Bool ewk_view_user_scalable_set(Evas_Object* ewkView, Eina_Bool userScalable)
5586 {
5587     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5588     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5589
5590     priv->settings.zoomRange.userScalable = userScalable;
5591
5592     return true;
5593 }
5594
5595 Eina_Bool ewk_view_user_scalable_get(const Evas_Object* ewkView)
5596 {
5597     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5598     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5599
5600     return priv->settings.zoomRange.userScalable;
5601 }
5602
5603 float ewk_view_device_pixel_ratio_get(const Evas_Object* ewkView)
5604 {
5605     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
5606     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1.0);
5607
5608     return priv->settings.devicePixelRatio;
5609 }
5610
5611 void ewk_view_did_first_visually_nonempty_layout(Evas_Object* ewkView)
5612 {
5613     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5614     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5615     if (!priv->flags.viewCleared) {
5616         ewk_view_frame_main_cleared(ewkView);
5617         ewk_view_enable_render(ewkView);
5618         priv->flags.viewCleared = true;
5619
5620 #if ENABLE(TIZEN_CONTENTS_SIZE_SET_ON_FLUSH)
5621         //Prevent loss of content size after backing store flush.
5622         int width, height;
5623         ewk_frame_contents_size_get(smartData->main_frame, &width, &height);
5624
5625         EINA_SAFETY_ON_NULL_RETURN(smartData->api);  
5626         EINA_SAFETY_ON_NULL_RETURN(smartData->api->contents_resize);  
5627         if (!smartData->api->contents_resize(smartData, width, height))  
5628             ERR("failed to resize contents to %dx%d", width, height);  
5629 #endif
5630
5631     }
5632 }
5633
5634 /**
5635  * @internal
5636  * Dispatch finished loading.
5637  *
5638  * @param ewkView view.
5639  */
5640 void ewk_view_dispatch_did_finish_loading(Evas_Object* ewkView)
5641 {
5642 #if !ENABLE(TIZEN_WHITE_LOADING_FIX)
5643     /* If we reach this point and rendering is still disabled, WebCore will not
5644      * trigger the didFirstVisuallyNonEmptyLayout signal anymore. So, we
5645      * forcefully re-enable the rendering.
5646      */
5647     ewk_view_did_first_visually_nonempty_layout(ewkView);
5648 #endif
5649 }
5650
5651 void ewk_view_transition_to_commited_for_newpage(Evas_Object* ewkView)
5652 {
5653     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5654     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5655
5656     ewk_view_disable_render(ewkView);
5657     priv->flags.viewCleared = false;
5658 }
5659
5660
5661 /**
5662  * @internal
5663  * Reports a requeset will be loaded. It's client responsibility to decide if
5664  * request would be used. If @return is true, loader will try to load. Else,
5665  * Loader ignore action of request.
5666  *
5667  * @param ewkView View to load
5668  * @param request Request which contain url to navigate
5669  * @param navigationType navigation type
5670  */
5671 bool ewk_view_navigation_policy_decision(Evas_Object* ewkView, Ewk_Frame_Resource_Request* request, Ewk_Navigation_Type navigationType)
5672 {
5673     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, true);
5674     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, true);
5675
5676     if (!smartData->api->navigation_policy_decision)
5677         return true;
5678
5679     return smartData->api->navigation_policy_decision(smartData, request, navigationType);
5680 }
5681
5682 Eina_Bool ewk_view_js_object_add(Evas_Object* ewkView, Ewk_JS_Object* object, const char* objectName)
5683 {
5684 #if ENABLE(NETSCAPE_PLUGIN_API)
5685 #if ENABLE(TIZEN_JS_API_FIX)
5686     EINA_SAFETY_ON_NULL_RETURN_VAL(object, false);
5687 #endif // ENABLE_TIZEN_JS_API_FIX
5688     if (object->view) // object has already been added to another ewk_view
5689         return false;
5690     object->name = eina_stringshare_add(objectName);
5691     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5692     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5693
5694     JSC::JSLock lock(JSC::SilenceAssertionsOnly);
5695     WebCore::JSDOMWindow* window = toJSDOMWindow(priv->mainFrame, WebCore::mainThreadNormalWorld());
5696     JSC::Bindings::RootObject* root;
5697     root = priv->mainFrame->script()->bindingRootObject();
5698
5699     if (!window) {
5700         ERR("Warning: couldn't get window object");
5701         return false;
5702     }
5703
5704     JSC::ExecState* executeState = window->globalExec();
5705
5706     object->view = ewkView;
5707     JSC::JSObject* runtimeObject = (JSC::JSObject*)JSC::Bindings::CInstance::create((NPObject*)object, root)->createRuntimeObject(executeState);
5708     JSC::Identifier id = JSC::Identifier(executeState, objectName);
5709
5710     JSC::PutPropertySlot slot;
5711     window->methodTable()->put(window, executeState, id, runtimeObject, slot);
5712     return true;
5713 #else
5714     return false;
5715 #endif // ENABLE(NETSCAPE_PLUGIN_API)
5716 }
5717
5718 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
5719 /**
5720  * @internal
5721  * Reports that the contents will be resized. This function decidess whether
5722  * to allow the resize.
5723  *
5724  * @param ewkView view.
5725  * @param w new content width.
5726  * @param h new content height.
5727  */
5728 Eina_Bool ewk_view_contents_size_change_possible(Evas_Object* ewkView, int w, int h)
5729 {
5730     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, true);
5731     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, true);
5732
5733     const char* url = ewk_view_uri_get(ewkView);
5734     String problem_url(url);
5735
5736     int viewportWidth = priv->viewportAttributes.width;
5737
5738     viewportWidth *= ewk_view_zoom_get(ewkView);
5739
5740     return true;
5741 }
5742 #endif
5743
5744 /**
5745  * @internal
5746  * Reports that the contents have resized. The ewk_view calls contents_resize,
5747  * which can be reimplemented as needed.
5748  *
5749  * @param ewkView view.
5750  * @param width new content width.
5751  * @param height new content height.
5752  */
5753 void ewk_view_contents_size_changed(Evas_Object* ewkView, int width, int height)
5754 {
5755     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5756     EINA_SAFETY_ON_NULL_RETURN(smartData->api);
5757     EINA_SAFETY_ON_NULL_RETURN(smartData->api->contents_resize);
5758
5759 #if ENABLE(TIZEN_RECORDING_SURFACE)
5760     if (smartData->_priv->recordingSurfaceEnable && smartData->_priv->recordingSurfaceSetLoadFinished) {
5761         float zoom = ewk_view_zoom_get(ewkView);
5762
5763         smartData->_priv->recordingSurfaceSetState = RECORDING_SURFACE_SET_STATE_INIT;
5764         smartData->_priv->recordingSurfaceSetList = ewk_recording_surface_set_free(smartData->_priv->recordingSurfaceSetList);
5765         smartData->_priv->recordingSurfaceSetList = ewk_recording_surface_set_base_record(smartData->_priv->recordingSurfaceSetList, ewkView, zoom);
5766         smartData->_priv->recordingSurfaceSetState = RECORDING_SURFACE_SET_STATE_COMPLETE;
5767     }
5768 #endif
5769
5770     if (!smartData->api->contents_resize(smartData, width, height))
5771         ERR("failed to resize contents to %dx%d", width, height);
5772 }
5773
5774 /**
5775  * @internal
5776  * Gets page size from frameview.
5777  *
5778  * @param ewkView view.
5779  *
5780  * @return page size.
5781  */
5782 WebCore::FloatRect ewk_view_page_rect_get(const Evas_Object* ewkView)
5783 {
5784     EWK_VIEW_SD_GET(ewkView, smartData);
5785     EWK_VIEW_PRIV_GET(smartData, priv);
5786
5787     WebCore::Frame* mainFrame = priv->page->mainFrame();
5788     return mainFrame->view()->frameRect();
5789 }
5790
5791 #if ENABLE(TOUCH_EVENTS)
5792 void ewk_view_need_touch_events_set(Evas_Object* ewkView, bool needed)
5793 {
5794     EWK_VIEW_SD_GET(ewkView, smartData);
5795     EWK_VIEW_PRIV_GET(smartData, priv);
5796
5797     priv->flags.needTouchEvents = needed;
5798 }
5799
5800 bool ewk_view_need_touch_events_get(const Evas_Object* ewkView)
5801 {
5802     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5803     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5804     return priv->flags.needTouchEvents;
5805 }
5806 #endif
5807
5808 Eina_Bool ewk_view_mode_set(Evas_Object* ewkView, Ewk_View_Mode viewMode)
5809 {
5810     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5811     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5812
5813     priv->page->setViewMode(static_cast<WebCore::Page::ViewMode>(viewMode));
5814     return true;
5815 }
5816
5817 Ewk_View_Mode ewk_view_mode_get(const Evas_Object* ewkView)
5818 {
5819     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, EWK_VIEW_MODE_INVALID);
5820     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, EWK_VIEW_MODE_INVALID);
5821
5822     return static_cast<Ewk_View_Mode>(priv->page->viewMode());
5823 }
5824
5825 Eina_Bool ewk_view_mixed_content_displayed_get(const Evas_Object* ewkView)
5826 {
5827     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5828     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5829     return priv->flags.hasDisplayedMixedContent;
5830 }
5831
5832 Eina_Bool ewk_view_mixed_content_run_get(const Evas_Object* ewkView)
5833 {
5834     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5835     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5836     return priv->flags.hasRunMixedContent;
5837 }
5838
5839 /**
5840  * @internal
5841  * Reports the view that editor client selection has changed.
5842  *
5843  * @param ewkView View.
5844  *
5845  * Emits signal: "editorclient,selection,changed" with no parameters.
5846  */
5847 void ewk_view_editor_client_selection_changed(Evas_Object* ewkView)
5848 {
5849     evas_object_smart_callback_call(ewkView, "editorclient,selection,changed", 0);
5850 }
5851
5852 /** TIZEN_ APIs */
5853
5854 void ewk_view_device_size_get(const Evas_Object* ewkView, float* w, float* h)
5855 {
5856     EWK_VIEW_SD_GET(ewkView, smartData);
5857     EWK_VIEW_PRIV_GET(smartData, priv);
5858
5859     float device_dpi = WebCore::getDPI();
5860
5861     int device_width_resolution = (int) priv->page->chrome()->client()->windowRect().width();
5862     int device_height_resolution = (int) priv->page->chrome()->client()->windowRect().height();
5863
5864     float aspect_ratio = (float)(device_height_resolution) / (float)(device_width_resolution);
5865
5866     float width_size = (device_width_resolution + device_height_resolution) / (device_dpi * (1 + aspect_ratio));
5867     float height_size = width_size * aspect_ratio;
5868
5869     *w = width_size * CENTI_PER_INCH;
5870     *h = height_size * CENTI_PER_INCH;
5871 }
5872
5873 #if ENABLE(TIZEN_ISF_PORT) 
5874 Ecore_IMF_Context* getImContextFromeView(Evas_Object* webview)
5875 {
5876     if (!webview)
5877         return 0;
5878
5879     EWK_VIEW_SD_GET_OR_RETURN(webview, smartData, 0);
5880     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
5881     return priv->imContext; /* 'priv' can not be 0 */
5882 }
5883 #endif
5884
5885 #if ENABLE(TIZEN_PLUGIN_PARENT_WINDOW)
5886 static Evas_Object* _ewk_view_parent_window_get(Evas_Object* ewkView)
5887 {
5888     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
5889     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
5890     Evas_Object* window = priv->settings.parentWindow;
5891     if (!window && smartData->base.evas) {
5892         Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
5893         if (ee)
5894             window = ecore_evas_object_associate_get(ee);
5895     }
5896     return window;
5897 }
5898 #endif // ENABLE(TIZEN_PLUGIN_PARENT_WINDOW)
5899
5900 #if ENABLE(TIZEN_SUPPORT_PLUGINS) && ENABLE(TIZEN_DONT_PAN_OVER_SOME_PLUGINS) && ENABLE(TIZEN_EVAS_OBJECT_PLUGIN)
5901 void ewk_view_events_repeat_to_plugin(Evas_Object* ewkView, Eina_Bool enabled)
5902 {
5903     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5904     evas_object_repeat_events_set(smartData->events_rect, enabled);
5905 }
5906
5907 void ewk_view_events_handled_by_plugin_changed(Evas_Object* ewkView, Eina_Bool newState)
5908 {
5909     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5910     EINA_SAFETY_ON_NULL_RETURN(smartData->api->events_handled_by_plugin_changed);
5911
5912     smartData->api->events_handled_by_plugin_changed(smartData, newState);
5913 }
5914 #endif
5915
5916 void ewk_view_events_invalidate_on_plugin(Evas_Object* ewkView, Eina_Bool enabled)
5917 {
5918 #if ENABLE(NETSCAPE_PLUGIN_API) && ENABLE(TIZEN_SUPPORT_PLUGINS) && ENABLE(TIZEN_DONT_PAN_OVER_SOME_PLUGINS) && ENABLE(TIZEN_EVAS_OBJECT_PLUGIN)
5919     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5920     if (WebCore::PluginView::currentPluginHandlingEvents()) {
5921         if (enabled)
5922             evas_object_data_set(WebCore::PluginView::currentPluginHandlingEvents()->getPluginCanvas(), "ev",
5923                 reinterpret_cast<void*>(static_cast<intptr_t>(0x01)));
5924         else
5925             evas_object_data_del(WebCore::PluginView::currentPluginHandlingEvents()->getPluginCanvas(), "ev");
5926     }
5927 #else
5928     ERR("NETSCAPE_PLUGIN_API && TIZEN_SUPPORT_PLUGINS && TIZEN_DONT_PAN_OVER_SOME_PLUGINS && TIZEN_EVAS_OBJECT_PLUGIN not enabled!");
5929 #endif
5930 }
5931
5932 #if ENABLE(TIZEN_EVAS_OBJECT_PLUGIN)
5933 void ewk_view_get_plugin_storage(Evas_Object* ewkView , PluginStorage* pluginStorage)
5934 {
5935     pluginStorage->pluginCanvas = 0;
5936     pluginStorage->pluginClipper = 0;
5937     pluginStorage->parentWindow = 0;
5938     pluginStorage->webview = 0;
5939
5940     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5941     Evas_Object* pluginCanvas = evas_object_image_add(smartData->base.evas);
5942     if (!pluginCanvas)
5943         return;
5944         
5945     evas_object_image_colorspace_set(pluginCanvas, EVAS_COLORSPACE_ARGB8888);
5946     evas_object_image_alpha_set(pluginCanvas, false);
5947     evas_object_image_filled_set(pluginCanvas, true);
5948     evas_object_show(pluginCanvas);
5949
5950     pluginStorage->pluginCanvas = pluginCanvas;
5951
5952     evas_object_smart_member_add(pluginCanvas, smartData->plugin_store);
5953
5954     Evas_Object* pluginEvasObjectClipper = evas_object_rectangle_add(smartData->base.evas);
5955     if (pluginEvasObjectClipper) {
5956         evas_object_smart_member_add(pluginEvasObjectClipper, smartData->plugin_store);
5957         evas_object_show(pluginEvasObjectClipper);
5958         pluginStorage->pluginClipper = pluginEvasObjectClipper;
5959     }
5960
5961 #if ENABLE(TIZEN_PLUGIN_PARENT_WINDOW)
5962     pluginStorage->parentWindow = _ewk_view_parent_window_get(ewkView);
5963 #else
5964     pluginStorage->parentWindow = 0;
5965 #endif // ENABLE(TIZEN_PLUGIN_PARENT_WINDOW)
5966     pluginStorage->webview = ewkView;
5967     return;
5968 }
5969 #endif // ENABLE(TIZEN_EVAS_OBJECT_PLUGIN)
5970
5971
5972 #if ENABLE(TIZEN_RENDER_SUSPEND)
5973 static void _ewk_view_smart_disable_render(Ewk_View_Smart_Data* smartData)
5974 {
5975     WRN("not supported by engine. smartData=%p", smartData);
5976 }
5977
5978 static void _ewk_view_smart_enable_render(Ewk_View_Smart_Data* smartData)
5979 {
5980     WRN("not supported by engine. smartData=%p", smartData);
5981 }
5982 #endif
5983
5984 Eina_Bool ewk_view_selective_rendering_is_enabled(const Evas_Object* ewkView)
5985 {
5986 #if ENABLE(TIZEN_SELECTIVE_RENDERING)
5987     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5988     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api->selective_rendering_is_enabled, false);
5989
5990     return smartData->api->selective_rendering_is_enabled(smartData);
5991 #else
5992     return false;
5993 #endif
5994 }
5995
5996 Eina_Bool ewk_view_selective_rendering_set(const Evas_Object* ewkView, Eina_Bool value)
5997 {
5998 #if ENABLE(TIZEN_SELECTIVE_RENDERING)
5999     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
6000     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
6001     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api->selective_rendering_set, false);
6002
6003     Eina_Bool result = smartData->api->selective_rendering_set(smartData, value);
6004 #if ENABLE(TIZEN_WEBCORE_SELECTIVE_RENDERING)
6005     priv->delaysHeavyTiles = value;
6006
6007     if (value == false) {
6008         _ewk_view_update_delayed_updates(smartData);
6009     }
6010 #endif
6011     return result;
6012 #else
6013     return false;
6014 #endif
6015 }
6016
6017 /**
6018  * @internal
6019  * Reports to the view that editor client's contents were changed.
6020  *
6021  * @param ewkView View.
6022  *
6023  * Emits signal: "editorclient,contents,changed" with no parameters.
6024  */
6025 void ewk_view_editor_client_contents_changed(Evas_Object* ewkView)
6026 {
6027     evas_object_smart_callback_call(ewkView, "editorclient,contents,changed", 0);
6028 }
6029
6030 /**
6031  * @internal
6032  * Defines whether the view has displayed mixed content.
6033  *
6034  * When a view has displayed mixed content, any of its frames has loaded an HTTPS URI
6035  * which has itself loaded and displayed a resource (such as an image) from an insecure,
6036  * that is, non-HTTPS, URI.
6037  *
6038  * @param hasDisplayed Do or do not clear the flag from the view.
6039  *
6040  * Emits signal: "mixedcontent,displayed" with no parameters when @p hasDisplayed is @c true.
6041  */
6042 void ewk_view_mixed_content_displayed_set(Evas_Object* ewkView, bool hasDisplayed)
6043 {
6044     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
6045     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
6046
6047     priv->flags.hasDisplayedMixedContent = hasDisplayed;
6048
6049     if (hasDisplayed)
6050         evas_object_smart_callback_call(ewkView, "mixedcontent,displayed", 0);
6051 }
6052
6053 /**
6054  * @internal
6055  * Defines whether the view has run mixed content.
6056  *
6057  * When a view has run mixed content, any of its frames has loaded an HTTPS URI
6058  * which has itself loaded and run a resource (such as a script) from an insecure,
6059  * that is, non-HTTPS, URI.
6060  *
6061  * @param hasRun Do or do not clear the flag from the view.
6062  *
6063  * Emits signal: "mixedcontent,run" with no parameters when @p hasRun is @c true.
6064  */
6065 void ewk_view_mixed_content_run_set(Evas_Object* ewkView, bool hasRun)
6066 {
6067     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
6068     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
6069
6070     priv->flags.hasRunMixedContent = hasRun;
6071
6072     if (hasRun)
6073         evas_object_smart_callback_call(ewkView, "mixedcontent,run", 0);
6074 }
6075
6076 Eina_Bool ewk_view_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State pageVisibilityState, Eina_Bool initialState)
6077 {
6078 #if ENABLE(PAGE_VISIBILITY_API)
6079     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
6080     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
6081
6082     priv->page->setVisibilityState(static_cast<WebCore::PageVisibilityState>(pageVisibilityState), initialState);
6083
6084     return true;
6085 #else
6086     DBG("PAGE_VISIBILITY_API is disabled.");
6087     return false;
6088 #endif
6089 }
6090 Ewk_Page_Visibility_State ewk_view_visibility_state_get(const Evas_Object* ewkView)
6091 {
6092 #if ENABLE(PAGE_VISIBILITY_API)
6093     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, EWK_PAGE_VISIBILITY_STATE_VISIBLE);
6094     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, EWK_PAGE_VISIBILITY_STATE_VISIBLE);
6095
6096     return static_cast<Ewk_Page_Visibility_State>(priv->page->visibilityState());
6097 #else
6098     DBG("PAGE_VISIBILITY_API is disabled.");
6099     return EWK_PAGE_VISIBILITY_STATE_VISIBLE;
6100 #endif
6101 }
6102
6103 SoupSession* ewk_view_soup_session_get(const Evas_Object* ewkView)
6104 {
6105     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
6106     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
6107     return priv->soupSession;
6108 }
6109
6110 void ewk_view_soup_session_set(Evas_Object* ewkView, SoupSession* session)
6111 {
6112     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
6113     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
6114     if (!SOUP_IS_SESSION_ASYNC(session)) {
6115         ERR("WebKit requires an SoupSessionAsync to work properly, but "
6116             "a SoupSessionSync was provided.");
6117         return;
6118     }
6119     priv->soupSession = session;
6120 }
6121
6122 Eina_Bool ewk_view_setting_enable_xss_auditor_get(const Evas_Object* ewkView)
6123 {
6124     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, EINA_FALSE);
6125     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, EINA_FALSE);
6126     return priv->settings.enableXSSAuditor;
6127 }
6128
6129 void ewk_view_setting_enable_xss_auditor_set(Evas_Object* ewkView, Eina_Bool enable)
6130 {
6131     EWK_VIEW_SD_GET(ewkView, smartData);
6132     EWK_VIEW_PRIV_GET(smartData, priv);
6133     enable = !!enable;
6134     if (priv->settings.enableXSSAuditor != enable) {
6135         priv->pageSettings->setXSSAuditorEnabled(enable);
6136         priv->settings.enableXSSAuditor = enable;
6137     }
6138 }
6139
6140 Eina_Bool ewk_view_setting_should_display_subtitles_get(const Evas_Object *ewkView)
6141 {
6142 #if ENABLE(VIDEO_TRACK)
6143     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
6144     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
6145     return priv->settings.shouldDisplaySubtitles;
6146 #else
6147     return false;
6148 #endif
6149 }
6150
6151 Eina_Bool ewk_view_setting_should_display_captions_get(const Evas_Object *ewkView)
6152 {
6153 #if ENABLE(VIDEO_TRACK)
6154     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
6155     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
6156     return priv->settings.shouldDisplayCaptions;
6157 #else
6158     return false;
6159 #endif
6160 }
6161
6162 void ewk_view_setting_should_display_captions_set(Evas_Object *ewkView, Eina_Bool enable)
6163 {
6164 #if ENABLE(VIDEO_TRACK)
6165     EWK_VIEW_SD_GET(ewkView, smartData);
6166     EWK_VIEW_PRIV_GET(smartData, priv);
6167     enable = !!enable;
6168     if (priv->settings.shouldDisplayCaptions != enable) {
6169         priv->pageSettings->setShouldDisplayCaptions(enable);
6170         priv->settings.shouldDisplayCaptions = enable;
6171     }
6172 #endif
6173 }
6174
6175 void ewk_view_setting_should_display_subtitles_set(Evas_Object *ewkView, Eina_Bool enable)
6176 {
6177 #if ENABLE(VIDEO_TRACK)
6178     EWK_VIEW_SD_GET(ewkView, smartData);
6179     EWK_VIEW_PRIV_GET(smartData, priv);
6180     enable = !!enable;
6181     if (priv->settings.shouldDisplaySubtitles != enable) {
6182         priv->pageSettings->setShouldDisplaySubtitles(enable);
6183         priv->settings.shouldDisplaySubtitles = enable;
6184     }
6185 #endif
6186 }
6187
6188 Eina_Bool ewk_view_setting_should_display_text_descriptions_get(const Evas_Object *ewkView)
6189 {
6190 #if ENABLE(VIDEO_TRACK)
6191     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
6192     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
6193     return priv->settings.shouldDisplayTextDescriptions;
6194 #else
6195     return false;
6196 #endif
6197 }
6198
6199 void ewk_view_setting_should_display_text_descriptions_set(Evas_Object *ewkView, Eina_Bool enable)
6200 {
6201 #if ENABLE(VIDEO_TRACK)
6202     EWK_VIEW_SD_GET(ewkView, smartData);
6203     EWK_VIEW_PRIV_GET(smartData, priv);
6204     enable = !!enable;
6205     if (priv->settings.shouldDisplayTextDescriptions != enable) {
6206         priv->pageSettings->setShouldDisplayTextDescriptions(enable);
6207         priv->settings.shouldDisplayTextDescriptions = enable;
6208     }
6209 #endif
6210 }
6211
6212 Eina_Bool ewk_view_setting_custom_header_add(Evas_Object* ewkView, const char* name, const char* value)
6213 {
6214 #if ENABLE(TIZEN_CUSTOM_HEADERS)
6215     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
6216     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
6217     priv->settings.customHeaders.add(WTF::String::fromUTF8(name), WTF::String::fromUTF8(value));
6218
6219     WebCore::FrameLoaderClientEfl* client = static_cast<WebCore::FrameLoaderClientEfl*>(priv->mainFrame->loader()->client());
6220     client->addCustomHeader(WTF::String::fromUTF8(name), WTF::String::fromUTF8(value));
6221     return true;
6222 #else
6223     ERR("TIZEN_CUSTOM_HEADERS not enabled!");
6224     return false;
6225 #endif
6226 }
6227
6228 /**
6229  * Get amount of plugins
6230  *
6231  * @param ewkView view to get amount of plugins
6232  *
6233  * @return amount of plugins, -1 otherwise 
6234  */
6235 #if ENABLE(TIZEN_DYNAMIC_LOADED_PLUGINS)
6236 unsigned int ewk_view_plugins_size_get(Evas_Object* ewkView)
6237 {
6238     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1);
6239     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1);
6240
6241     if (priv && priv->mainFrame && priv->mainFrame->document())
6242         return priv->mainFrame->document()->plugins()->length();
6243
6244     return -1;
6245 }
6246 #endif
6247
6248 /**
6249  * Parameter Evas_Object *ewkView is obsolete since plugin's database is not related with specified webview. Will be removed.
6250  */
6251 Eina_Bool ewk_view_setting_enable_specified_plugin_set(Evas_Object* ewkView, Eina_Bool enable, const char* mimeType)
6252 {
6253 #if ENABLE(TIZEN_ON_OFF_SPECIFIED_PLUGINS)
6254     EINA_SAFETY_ON_NULL_RETURN_VAL(mimeType, false);
6255
6256     enable = !!enable;
6257
6258 #if ENABLE(TIZEN_DYNAMIC_LOADED_PLUGINS)
6259     return _ewk_view_setting_enable_specified_plugin_set(enable, mimeType);
6260 #else
6261     WebCore::PluginDatabase* pluginDatabase = WebCore::PluginDatabase::installedPlugins(true);
6262     EINA_SAFETY_ON_NULL_RETURN_VAL(pluginDatabase, false);
6263     const Vector<WebCore::PluginPackage*> pluginsDB = pluginDatabase->plugins();
6264     WebCore::PluginPackage* pluginForMime = _ewk_view_plugin_for_mime_type(pluginsDB, mimeType);
6265     if (pluginForMime)
6266         pluginForMime->setEnabled(enable);
6267
6268     return true;
6269 #endif
6270 #else
6271     return false;
6272 #endif
6273 }
6274
6275 Eina_Bool ewk_view_setting_editable_link_active_set(Evas_Object* ewkView, Eina_Bool clickable)
6276 {
6277 #if ENABLE(TIZEN_EDITABLE_LINK_ACTIVE_SET)
6278     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
6279     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
6280     WebCore::EditableLinkBehavior linkBehavior;
6281     if (clickable)
6282         linkBehavior = WebCore::EditableLinkDefaultBehavior;
6283     else
6284         linkBehavior = WebCore::EditableLinkNeverLive;
6285     
6286     if (priv->settings.editableLinkBehavior != linkBehavior) {
6287         priv->pageSettings->setEditableLinkBehavior(linkBehavior);
6288         priv->settings.editableLinkBehavior = linkBehavior;
6289     }
6290     return true;
6291 #else
6292     return false;
6293 #endif
6294 }
6295
6296 Eina_Bool ewk_view_setting_geolocation_get(Evas_Object* ewkView)
6297 {
6298 #if ENABLE(TIZEN_GEOLOCATION)
6299     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
6300     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
6301     return priv->settings.geolocation;
6302 #else
6303     return false;
6304 #endif
6305 }
6306
6307 Eina_Bool ewk_view_setting_geolocation_set(Evas_Object* ewkView, Eina_Bool enable)
6308 {
6309 #if ENABLE(TIZEN_GEOLOCATION)
6310     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
6311     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
6312     enable = !!enable;
6313     if (priv->settings.geolocation != enable) {
6314         priv->pageSettings->setGeolocationEnabled(enable);
6315         priv->settings.geolocation = enable;
6316     }
6317     return TRUE;
6318 #else
6319     return false;
6320 #endif
6321 }
6322
6323 Eina_Bool ewk_view_setting_css_fixed_as_absolute_set(Evas_Object* ewkView, Eina_Bool enable)
6324 {
6325 #if ENABLE(TIZEN_CSS_FIXED_AS_ABSOLUTE)
6326     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
6327     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
6328     if (priv->settings.fixedAsAbsolute != enable) {
6329         priv->pageSettings->setFixedAsAbsoluteEnabled(enable);
6330         priv->settings.fixedAsAbsolute = enable;
6331     }
6332     return true;
6333 #else
6334     return false;
6335 #endif
6336 }
6337
6338 Eina_Bool ewk_view_setting_css_fixed_as_absolute_get(Evas_Object* ewkView)
6339 {
6340 #if ENABLE(TIZEN_CSS_FIXED_AS_ABSOLUTE)
6341     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
6342     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
6343     return priv->settings.fixedAsAbsolute;
6344 #else
6345     return false;
6346 #endif
6347 }
6348
6349 /**
6350  * Sets if fast path improvements should be used.
6351  *
6352  * @param ewkView view object to set
6353  * @param enable @c true if we want to use fast path modifications
6354  * @return @c true on success and @c false on failure.
6355  */
6356 Eina_Bool ewk_view_setting_css_fixed_fast_path_set(Evas_Object* ewkView, Eina_Bool enable)
6357 {
6358 #if ENABLE(TIZEN_CSS_FIXED_FAST_PATH)
6359     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
6360     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
6361     enable = !!enable;
6362     if (priv->settings.fixedFastPath != enable) {
6363         priv->pageSettings->setFixedFastPathImprovementsEnabled(enable);
6364         priv->settings.fixedFastPath = enable;
6365     }
6366     return true;
6367 #else
6368     return false;
6369 #endif
6370 }
6371
6372 /**
6373  * Gets if fast path modifications are enabled.
6374  *
6375  * @param ewkView view object to get
6376  *
6377  * @return @c true if encoding detector is enabled, @c false if not or on errors.
6378  */
6379 Eina_Bool ewk_view_setting_css_fixed_fast_path_get(Evas_Object* ewkView)
6380 {
6381 #if ENABLE(TIZEN_CSS_FIXED_FAST_PATH)
6382     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
6383     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
6384     return priv->settings.fixedFastPath;
6385 #else
6386     return false;
6387 #endif
6388 }
6389
6390 Eina_Bool ewk_view_setting_accelerated_compositing_enable_set(Evas_Object* ewkView, Eina_Bool enable)
6391 {
6392 #if USE(ACCELERATED_COMPOSITING)
6393     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
6394     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
6395
6396     WebCore::Settings* settings = priv->page->settings();
6397     if (!settings)
6398         return false;
6399
6400 #if ENABLE(TIZEN_CSS_FIXED_ACCELERATION)
6401     ewk_view_setting_css_fixed_as_absolute_set(ewkView, !enable);
6402     ewk_view_setting_css_fixed_fast_path_set(ewkView, !enable);
6403 #endif
6404
6405     if (enable == false) {
6406         settings->setAcceleratedCompositingEnabled(false);
6407         settings->setAcceleratedCompositingFor3DTransformsEnabled(false);
6408         settings->setAcceleratedCompositingForVideoEnabled(false);
6409         settings->setAcceleratedCompositingForPluginsEnabled(false);
6410         settings->setAcceleratedCompositingForCanvasEnabled(false);
6411         settings->setAcceleratedCompositingForAnimationEnabled(false);
6412 #if ENABLE(TIZEN_CSS_FIXED_ACCELERATION)
6413         settings->setAcceleratedCompositingForFixedPositionEnabled(false);
6414 #endif
6415         settings->setShowDebugBorders(false);
6416 #if ENABLE(WEBGL)
6417         settings->setWebGLEnabled(false);
6418 #endif
6419         return true;
6420     }
6421
6422     settings->setAcceleratedCompositingEnabled(true);
6423 #if ENABLE(WEBGL)
6424     settings->setWebGLEnabled(true);
6425     settings->setAcceleratedCompositingForCanvasEnabled(true);
6426 #endif
6427
6428 #if ENABLE(TIZEN_CSS_FIXED_ACCELERATION)
6429     settings->setAcceleratedCompositingForFixedPositionEnabled(true);
6430 #endif
6431
6432 #define ENV_VALUE (str.toInt()?true:false)
6433     String str = String(getenv("AC_3DTRANSFORMS"));
6434     if (str.isEmpty())
6435         settings->setAcceleratedCompositingFor3DTransformsEnabled(true); // default
6436     else
6437         settings->setAcceleratedCompositingFor3DTransformsEnabled(ENV_VALUE);
6438
6439     str = String(getenv("AC_PLUGINS"));
6440     if (str.isEmpty())
6441         settings->setAcceleratedCompositingForPluginsEnabled(false); // default
6442     else
6443         settings->setAcceleratedCompositingForPluginsEnabled(ENV_VALUE);
6444
6445     str = String(getenv("AC_ANIMATION"));
6446     if (str.isEmpty())
6447         settings->setAcceleratedCompositingForAnimationEnabled(false); // default
6448     else
6449         settings->setAcceleratedCompositingForAnimationEnabled(ENV_VALUE);
6450 #undef ENV_VALUE
6451
6452     return true;
6453 #else
6454     return false;
6455 #endif
6456 }
6457
6458 Eina_Bool ewk_view_setting_accelerated_compositing_enable_get(Evas_Object* ewkView)
6459 {
6460 #if USE(ACCELERATED_COMPOSITING)
6461     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
6462     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
6463     return (priv->pageSettings->acceleratedCompositingEnabled() ? true : false);
6464 #else
6465     return false;
6466 #endif
6467 }
6468
6469 Eina_Bool ewk_view_setting_html5video_external_player_enable_set(Evas_Object* ewkView, Eina_Bool enable)
6470 {
6471 #if USE(ACCELERATED_COMPOSITING)
6472     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
6473     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
6474
6475     WebCore::Settings* settings = priv->page->settings();
6476     if (!settings)
6477         return false;
6478
6479     if (!settings->acceleratedCompositingEnabled())
6480         return false;
6481
6482     settings->setAcceleratedCompositingForVideoEnabled((enable == false ? true : false));
6483     return true;
6484 #else
6485     return false;
6486 #endif
6487 }
6488
6489 Eina_Bool ewk_view_setting_html5video_external_player_enable_get(Evas_Object* ewkView)
6490 {
6491 #if USE(ACCELERATED_COMPOSITING)
6492     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
6493     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
6494     return (priv->pageSettings->acceleratedCompositingForVideoEnabled() ? false : true);
6495 #else
6496     return false;
6497 #endif
6498 }
6499
6500 EAPI Eina_Bool ewk_view_setting_layer_borders_enable_set(Evas_Object* o, Eina_Bool enable)
6501 {
6502 #if USE(ACCELERATED_COMPOSITING)
6503     EWK_VIEW_SD_GET_OR_RETURN(o, smartData, EINA_FALSE);
6504     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, EINA_FALSE);
6505
6506     WebCore::Settings* settings = priv->page->settings();
6507     if (!settings)
6508         return EINA_FALSE;
6509
6510     if (!settings->acceleratedCompositingEnabled())
6511         return EINA_FALSE;
6512
6513     settings->setShowDebugBorders((enable == EINA_TRUE ? true : false));
6514     return EINA_TRUE;
6515 #else
6516     return EINA_FALSE;
6517 #endif
6518 }
6519
6520 EAPI Eina_Bool ewk_view_setting_layer_borders_enable_get(Evas_Object* o)
6521 {
6522 #if USE(ACCELERATED_COMPOSITING)
6523     EWK_VIEW_SD_GET_OR_RETURN(o, smartData, EINA_FALSE);
6524     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, EINA_FALSE);
6525     return (priv->pageSettings->showDebugBorders() ? EINA_TRUE : EINA_FALSE);
6526 #else
6527     return EINA_FALSE;
6528 #endif
6529 }
6530
6531 /**
6532  * @internal
6533  * Asks if URI should be opened.
6534  *
6535  * @param ewkView View.
6536  * @param uri URI that will be opened.
6537  *
6538  * Emits signal: "should,allow,open" with Ewk_Should_Allow_Open_Uri_Return.
6539  */
6540 Eina_Bool ewk_should_allow_open_uri(Evas_Object* ewkView, const char* uri)
6541 {
6542 #if ENABLE(TIZEN_SHOULD_ALLOW_OPEN_URL)
6543     Ewk_Should_Allow_Open_Uri_Return callbackData;
6544     callbackData.uri = uri;
6545     callbackData.ret = true;
6546
6547     evas_object_smart_callback_call( ewkView, "should,allow,open", (void*)(&callbackData));
6548
6549     if (callbackData.ret)
6550         return true;
6551
6552     return false;
6553 #else
6554     return true;
6555 #endif
6556 }
6557
6558 /**
6559  * Returns current Ecore IMF context
6560  *
6561  * @param [in] webview a view object
6562  *
6563  * @return Ecore_IMF_Context on success and 0 otherwise
6564  */
6565 #if ENABLE(TIZEN_ISF_PORT)
6566 Ecore_IMF_Context* ewk_view_core_imContext_get(Evas_Object* webview)
6567 {
6568     EINA_SAFETY_ON_NULL_RETURN_VAL(webview, 0);
6569     EWK_VIEW_SD_GET_OR_RETURN(webview, smartData, 0);
6570     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
6571     return priv->imContext; /* 'priv' can not be 0 */
6572 }
6573
6574 Ecore_IMF_Context* ewk_view_imf_context_get(Evas_Object* webview)
6575 {
6576     EINA_SAFETY_ON_NULL_RETURN_VAL(webview, 0);
6577     EWK_VIEW_SD_GET_OR_RETURN(webview, smartData, 0);
6578     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
6579     return priv->imContext; /* 'priv' can not be 0 */
6580 }
6581 #endif
6582
6583 #if ENABLE(TIZEN_EFL_EXT_API)
6584 /**
6585  * Gathers images from the passed frame and puts them in a list.
6586  *
6587  * @param [in]  frame Frame to collect images from.
6588  * @param [in][out] data Eina_List where the image pointers will be stored.
6589  */ 
6590 void _collect_images_from_frame(WebCore::Frame* frame, void* data)
6591 {
6592     // getting the list containing list of images and list of urls
6593     Eina_List* listOfLists = (Eina_List*)data;
6594
6595     // getting specific lists
6596     Eina_List** listOfImages = (Eina_List**)eina_list_nth(listOfLists, 0);
6597     Eina_List** listOfUrls = (Eina_List**)eina_list_nth(listOfLists, 1);
6598
6599     // getting collection of all images in the frame
6600     RefPtr<WebCore::HTMLCollection> images = frame->document()->images();
6601
6602     for (unsigned i = 0; i < images->length(); ++i) {
6603          WebCore::HTMLImageElement* imageElement = (WebCore::HTMLImageElement*) images->item(i);
6604          if (!imageElement)
6605              continue;
6606
6607          WebCore::CachedImage* cachedImage = imageElement->cachedImage();
6608          if (!cachedImage)
6609              continue;
6610
6611          WebCore::Image* image = cachedImage->image();
6612          if (!image || image->isNull())
6613              continue;
6614
6615 #if USE(CAIRO)
6616          // getting native (cairo) representation of the image
6617          cairo_surface_t* cairoImage = image->nativeImageForCurrentFrame()->surface();
6618          if (!cairoImage)
6619              continue;
6620
6621          // appending image ptr & url to the lists
6622          *listOfImages = eina_list_append(*listOfImages, (void*)cairoImage);
6623          *listOfUrls = eina_list_append(*listOfUrls, (void*)strdup(WebCore::decodeURLEscapeSequences(imageElement->src().string()).utf8().data()));
6624 #endif
6625     }
6626 }
6627 #endif
6628
6629 Eina_Bool ewk_view_autofill_personal_data(Evas_Object* ewkView, const char* username, const char* password)
6630 {
6631 #if ENABLE(TIZEN_PASSWORD_MANAGER)
6632     EWK_VIEW_SD_GET_OR_RETURN(ewkView , smartData, false);
6633     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
6634     EINA_SAFETY_ON_NULL_RETURN_VAL(username, false);
6635     EINA_SAFETY_ON_NULL_RETURN_VAL(password, false);
6636
6637     // Getting all forms of the page
6638     RefPtr<WebCore::HTMLCollection> forms = priv->mainFrame->document()->forms();
6639     if (!forms)
6640         return false;
6641
6642     for (unsigned i = 0; i < forms->length(); i++) {
6643         WebCore::HTMLFormElement* formElement = static_cast<WebCore::HTMLFormElement*>(forms->item(i));
6644         if (!formElement)
6645             continue;
6646
6647         // Getting all elements of the form
6648         for (unsigned j = 0; j < formElement->associatedElements().size(); j++) {
6649              WebCore::FormAssociatedElement* associatedElement = formElement->associatedElements()[j];
6650              if (!associatedElement)
6651                  continue;
6652
6653              WebCore::HTMLElement* htmlElement = toHTMLElement(associatedElement);
6654              if (!htmlElement || !htmlElement->hasTagName(WebCore::HTMLNames::inputTag))
6655                  continue;
6656
6657              WebCore::HTMLInputElement* inputElement = static_cast<WebCore::HTMLInputElement*>(htmlElement);
6658              if (!inputElement || !inputElement->isEnabledFormControl())
6659                  continue;
6660
6661              if (inputElement->isPasswordField()) {
6662                  inputElement->setValue(password);
6663
6664                  // Then, search backwards for the username field
6665                  for (int index = j-1; index >= 0; index--) {
6666                      WebCore::FormAssociatedElement* associatedElement = formElement->associatedElements()[index];
6667                      if (!associatedElement)
6668                          continue;
6669
6670                      WebCore::HTMLElement* htmlElement = toHTMLElement(associatedElement);
6671                      if (!htmlElement || !htmlElement->hasTagName(WebCore::HTMLNames::inputTag))
6672                          continue;
6673
6674                      WebCore::HTMLInputElement* inputElement = static_cast<WebCore::HTMLInputElement*>(htmlElement);
6675                      if (!inputElement || !inputElement->isEnabledFormControl())
6676                          continue;
6677
6678                      if (inputElement->isTextField()) {
6679                          inputElement->setValue(username);
6680                          return true;
6681                      }
6682                 }
6683             } // End. if (inputElement->isPasswordField())
6684         } // End. for (unsigned j = 0; j < formElement->formElements.size(); j++) 
6685     }
6686
6687     return false;
6688 #else
6689     LOG_ERROR("TIZEN_PASSWORD_MANAGER is disabled. \n");
6690     return false;
6691 #endif
6692 }
6693
6694 Eina_Bool ewk_view_personal_data_fill(Evas_Object* ewkView, const char* username, const char* password)
6695 {
6696 #if ENABLE(TIZEN_PASSWORD_MANAGER)
6697     EWK_VIEW_SD_GET_OR_RETURN(ewkView , smartData, false);
6698     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
6699     EINA_SAFETY_ON_NULL_RETURN_VAL(username, false);
6700     EINA_SAFETY_ON_NULL_RETURN_VAL(password, false);
6701
6702     // Getting all forms of the page
6703     RefPtr<WebCore::HTMLCollection> forms = priv->mainFrame->document()->forms();
6704     if (!forms)
6705         return false;
6706
6707     for (unsigned i = 0; i < forms->length(); i++) {
6708         WebCore::HTMLFormElement* formElement = static_cast<WebCore::HTMLFormElement*>(forms->item(i));
6709         if (!formElement)
6710             continue;
6711
6712         // Getting all elements of the form
6713         for (unsigned j = 0; j < formElement->associatedElements().size(); j++) {
6714              WebCore::FormAssociatedElement* associatedElement = formElement->associatedElements()[j];
6715              if (!associatedElement)
6716                  continue;
6717
6718              WebCore::HTMLElement* htmlElement = toHTMLElement(associatedElement);
6719              if (!htmlElement || !htmlElement->hasTagName(WebCore::HTMLNames::inputTag))
6720                  continue;
6721
6722              WebCore::HTMLInputElement* inputElement = static_cast<WebCore::HTMLInputElement*>(htmlElement);
6723              if (!inputElement || !inputElement->isEnabledFormControl())
6724                  continue;
6725
6726              if (inputElement->isPasswordField()) {
6727                  inputElement->setValue(password);
6728
6729                  // Then, search backwards for the username field
6730                  for (int index = j-1; index >= 0; index--) {
6731                      WebCore::FormAssociatedElement* associatedElement = formElement->associatedElements()[index];
6732                      if (!associatedElement)
6733                          continue;
6734
6735                      WebCore::HTMLElement* htmlElement = toHTMLElement(associatedElement);
6736                      if (!htmlElement || !htmlElement->hasTagName(WebCore::HTMLNames::inputTag))
6737                          continue;
6738
6739                      WebCore::HTMLInputElement* inputElement = static_cast<WebCore::HTMLInputElement*>(htmlElement);
6740                      if (!inputElement || !inputElement->isEnabledFormControl())
6741                          continue;
6742
6743                      if (inputElement->isTextField()) {
6744                          inputElement->setValue(username);
6745                          return true;
6746                      }
6747                 }
6748             } // End. if (inputElement->isPasswordField())
6749         } // End. for (unsigned j = 0; j < formElement->formElements.size(); j++)
6750     }
6751
6752     return false;
6753 #else
6754     LOG_ERROR("TIZEN_PASSWORD_MANAGER is disabled. \n");
6755     return false;
6756 #endif
6757 }
6758
6759 EAPI void ewk_view_get_images_list(Evas_Object* view, Eina_List** listOfImages, Eina_List** listOfImageUrls)
6760 {
6761 #if ENABLE(TIZEN_EFL_EXT_API)
6762     EINA_SAFETY_ON_NULL_RETURN(view);
6763     EWK_VIEW_SD_GET_OR_RETURN(view, smartData);
6764     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
6765
6766     // creating a list containing both listOfImages and listOfImageUrls
6767     Eina_List* lisfOfLists = 0;
6768     lisfOfLists = eina_list_append(lisfOfLists, listOfImages);
6769     lisfOfLists = eina_list_append(lisfOfLists, listOfImageUrls);
6770
6771     // iterating all frames on the page and getting images inside 
6772     _iterate_frames(priv->mainFrame, _collect_images_from_frame, (void*)(lisfOfLists));
6773
6774     // freeing the list of lists, not needed anymore
6775     eina_list_free(lisfOfLists);
6776 #else
6777     LOG_ERROR("TIZEN_EFL_EXT_API is disabled. \n");
6778 #endif
6779 }
6780
6781 EAPI void ewk_view_image_list_get(Evas_Object* view, Eina_List** listOfImages, Eina_List** listOfImageUrls)
6782 {
6783 #if ENABLE(TIZEN_EFL_EXT_API)
6784     EINA_SAFETY_ON_NULL_RETURN(view);
6785     EWK_VIEW_SD_GET_OR_RETURN(view, smartData);
6786     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
6787
6788     // creating a list containing both listOfImages and listOfImageUrls
6789     Eina_List* lisfOfLists = 0;
6790     lisfOfLists = eina_list_append(lisfOfLists, listOfImages);
6791     lisfOfLists = eina_list_append(lisfOfLists, listOfImageUrls);
6792
6793     // iterating all frames on the page and getting images inside
6794     _iterate_frames(priv->mainFrame, _collect_images_from_frame, static_cast<void*>(lisfOfLists));
6795
6796     // freeing the list of lists, not needed anymore
6797     eina_list_free(lisfOfLists);
6798 #else
6799     LOG_ERROR("TIZEN_EFL_EXT_API is disabled. \n");
6800 #endif
6801 }
6802
6803 /* 
6804  * Samsung Modification from here 
6805  */
6806
6807 JSGlobalContextRef ewk_view_get_global_context(Evas_Object* obj)
6808 {
6809 #if ENABLE(TIZEN_JS_EXT_API)
6810     if (obj == 0)
6811         return 0;
6812
6813     Evas_Object* mainFrame = ewk_view_frame_main_get(obj);
6814     WebCore::Frame* frame = ewk_frame_core_get(mainFrame);
6815
6816     return reinterpret_cast<JSGlobalContextRef>(frame->script()->globalObject(WebCore::mainThreadNormalWorld())->globalExec());
6817 #else
6818     LOG_ERROR("TIZEN_JS_EXT_API is disabled. \n");
6819     return 0;
6820 #endif
6821 }
6822
6823 JSGlobalContextRef ewk_view_global_context_get(Evas_Object* ewkView)
6824 {
6825 #if ENABLE(TIZEN_JS_EXT_API)
6826     if (ewkView == 0)
6827         return 0;
6828
6829     Evas_Object* mainFrame = ewk_view_frame_main_get(ewkView);
6830     WebCore::Frame* frame = ewk_frame_core_get(mainFrame);
6831
6832     return reinterpret_cast<JSGlobalContextRef>(frame->script()->globalObject(WebCore::mainThreadNormalWorld())->globalExec());
6833 #else
6834     LOG_ERROR("TIZEN_JS_EXT_API is disabled. \n");
6835     return 0;
6836 #endif
6837 }
6838
6839 JSGlobalContextRef ewk_view_js_global_context_get(Evas_Object* ewkView)
6840 {
6841 #if ENABLE(TIZEN_JS_EXT_API)
6842     if (ewkView == 0)
6843         return 0;
6844
6845     Evas_Object* mainFrame = ewk_view_frame_main_get(ewkView);
6846     WebCore::Frame* frame = ewk_frame_core_get(mainFrame);
6847
6848     return reinterpret_cast<JSGlobalContextRef>(frame->script()->globalObject(WebCore::mainThreadNormalWorld())->globalExec());
6849 #else
6850     LOG_ERROR("TIZEN_JS_EXT_API is disabled. \n");
6851     return 0;
6852 #endif
6853 }
6854
6855 Eina_Bool ewk_view_is_jscript_running(Evas_Object* ewkView)
6856 {
6857     LOG_ERROR("This function is deprecated. So, this is will be removed soon.\n");
6858     return false;
6859 }
6860
6861 void ewk_view_javascript_suspend(Evas_Object* ewkView)
6862 {
6863 #if ENABLE(TIZEN_JS_PERMISSION_CHECKER)
6864     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
6865     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
6866     WebCore::Frame* mainFrame = priv->mainFrame;
6867     mainFrame->page()->suspendJavaScript();
6868 #endif
6869 }
6870
6871 void ewk_view_javascript_resume(Evas_Object* ewkView)
6872 {
6873 #if ENABLE(TIZEN_JS_PERMISSION_CHECKER)
6874     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
6875     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
6876     WebCore::Frame* mainFrame = priv->mainFrame;
6877     mainFrame->page()->resumeJavaScript();
6878 #endif
6879 }
6880
6881 Eina_Bool
6882 ewk_view_smart_selection_rect_get(Evas_Object* ewkView, int x, int y, Eina_Rectangle* rect)
6883 {
6884     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
6885     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
6886     EINA_SAFETY_ON_NULL_RETURN_VAL(rect, false);
6887
6888     return false;
6889 }
6890
6891 void ewk_view_screenshot_contents(const Evas_Object* ewkView, cairo_t* cr, const Eina_Rectangle* area)
6892 {
6893 #if ENABLE(TIZEN_EFL_EXT_API)
6894     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
6895     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
6896
6897     WebCore::FrameView* view = priv->mainFrame->view();
6898     EINA_SAFETY_ON_NULL_RETURN(view);
6899
6900     // Sometimes, mostly when the loading is stopped by user, the view needs to be relayouted.
6901     // Without this, the resulting screenshot would be black.
6902     // See check for needsLayout() in FrameView::paintContents()
6903     if (view->needsLayout())
6904         view->forceLayout();
6905
6906     ewk_view_paint_contents(priv, cr, area);
6907
6908 #if ENABLE(TIZEN_ACCELERATED_COMPOSITING)
6909     if (priv->compositingActive) {
6910         int width = 0, height= 0;
6911         evas_object_image_size_get(priv->compositingSurface, &width, &height);
6912         if (!width || !height)
6913             return;
6914
6915         float zoomLevel = ewk_view_zoom_get(ewkView);
6916
6917         cairo_matrix_t mat;
6918         cairo_get_matrix(cr, &mat);
6919
6920         if (zoomLevel == (float)mat.xx || zoomLevel == (float)mat.yy)
6921             return;
6922
6923         Eina_Rectangle imageArea;
6924
6925         imageArea.x = 0;
6926         imageArea.y = 0;
6927         imageArea.w = width;
6928         imageArea.h = height;
6929
6930         float zoomFactorX = mat.xx / zoomLevel;
6931         float zoomFactorY = mat.yy / zoomLevel;
6932
6933         unsigned int rowBytes = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, imageArea.w);
6934         unsigned int totalBytes = rowBytes * imageArea.h;
6935         unsigned char* pixels = new unsigned char[totalBytes];
6936         if (!pixels)
6937             return;
6938
6939         priv->compositor->readPixelData(imageArea.x, imageArea.y, imageArea.w, imageArea.h, pixels);
6940
6941         // Convert to BGRA
6942         for (int i = 0; i < totalBytes; i += 4)
6943             std::swap(pixels[i], pixels[i + 2]);
6944
6945         cairo_surface_t* fbCairoSurface = cairo_image_surface_create_for_data(pixels,
6946                                                                               CAIRO_FORMAT_ARGB32,
6947                                                                               imageArea.w,
6948                                                                               imageArea.h,
6949                                                                               rowBytes);
6950
6951         cairo_matrix_t resultMat;
6952         cairo_matrix_t t1Mat, t2Mat;
6953         cairo_matrix_t flipMat;
6954
6955         float offsetRateY = 2.0 / 3.0;
6956
6957         cairo_matrix_init_identity(&resultMat);
6958         cairo_matrix_init_translate(&t1Mat, imageArea.w * 0.5 , imageArea.h * 0.5);
6959         cairo_matrix_init(&flipMat, 1.0, 0.0, 0.0, -1.0, 0.0, 0.0);
6960         cairo_matrix_init_translate(&t2Mat, -imageArea.w * 0.5, -imageArea.h * 0.5);
6961
6962         cairo_matrix_multiply(&resultMat, &resultMat, &t2Mat);
6963         cairo_matrix_multiply(&resultMat, &resultMat, &flipMat);
6964         cairo_matrix_multiply(&resultMat, &resultMat, &t1Mat);
6965
6966         cairo_matrix_scale(&resultMat, zoomFactorX, zoomFactorY);
6967
6968         cairo_save(cr);
6969         cairo_set_matrix(cr, &resultMat);
6970
6971         cairo_translate(cr, 0, (float)imageArea.h * offsetRateY);
6972
6973         cairo_set_source_surface(cr, fbCairoSurface, 0, 0);
6974         cairo_paint(cr);
6975         cairo_restore(cr);
6976
6977         delete pixels;
6978     }
6979 #endif
6980 #else
6981     LOG_ERROR("TIZEN_EFL_EXT_API is disabled. \n");
6982 #endif
6983 }
6984
6985 void ewk_view_force_layout(const Evas_Object* ewkView)
6986 {
6987 #if ENABLE(TIZEN_EFL_EXT_API)
6988     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
6989     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
6990
6991     WebCore::FrameView* view = priv->mainFrame->view();
6992     EINA_SAFETY_ON_NULL_RETURN(view);
6993
6994     view->forceLayout();
6995 #else
6996     LOG_ERROR("TIZEN_EFL_EXT_API is disabled. \n");
6997 #endif
6998 }
6999
7000 Eina_Bool ewk_view_image_get(const Evas_Object* ewkView, Evas_Object* evasImage, int x, int y)
7001 {
7002 #if ENABLE(TIZEN_EFL_EXT_API)
7003     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
7004     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
7005     WebCore::Frame* frame = priv->mainFrame;
7006     EINA_SAFETY_ON_NULL_RETURN_VAL(frame, false);
7007     EINA_SAFETY_ON_NULL_RETURN_VAL(evasImage, false);
7008
7009     WebCore::DragImageRef dragImageRef = (WebCore::DragImageRef) evasImage;
7010     WebCore::IntPoint dragImageOrigin(0, 0); // not used currently
7011     WebCore::IntPoint eventPos(x, y);
7012
7013     WebCore::DragClientEfl dragClient; // in the future this should be static field or something
7014     dragClient.startDrag(dragImageRef, dragImageOrigin, eventPos, 0, frame);
7015
7016     return true;
7017 #else
7018     LOG_ERROR("TIZEN_EFL_EXT_API is disabled. \n");
7019     return false;
7020 #endif
7021 }
7022
7023 Eina_Bool ewk_page_dropdown_set_current_index(Evas_Object* ewkView, int newOptionIndex)
7024 {
7025 #if ENABLE(TIZEN_DROPDOWN_SUPPORT)
7026     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
7027     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
7028
7029     if (!priv->mainFrame->view())
7030         return false;
7031
7032     WebCore::Node* node = priv->currentSelectedNode;
7033     if (!node || node->nodeType() != WebCore::Node::ELEMENT_NODE
7034         || !equalIgnoringCase(node->nodeName(), "SELECT"))
7035         return false;
7036
7037     WebCore::HTMLSelectElement* selectElement = static_cast<WebCore::HTMLSelectElement*>(node);
7038     if (!selectElement)
7039         return false;
7040
7041     if (newOptionIndex < 0 || newOptionIndex >= selectElement->length())
7042         return false;
7043
7044     selectElement->optionSelectedByUser(newOptionIndex, true, true);
7045
7046 // Pure WebKit EFL supports tp show popup. However, TIZEN_ browser doesn't
7047 // use the popup APIs. The popup instance created by WebCore need to be
7048 // destroyed.
7049 #if ENABLE(TIZEN_POPUP_FIX)
7050     ewk_view_popup_destroy(ewkView);
7051 #endif
7052
7053     return true;
7054 #else
7055     LOG_ERROR("TIZEN_EFL_EXT_API is disabled. \n");
7056     return false;
7057 #endif
7058 }
7059
7060 #if ENABLE(TIZEN_DROPDOWN_SUPPORT)
7061 bool _ewk_view_get_select_rect(Evas_Object* ewkView, Eina_Rectangle* rect)
7062 {
7063     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
7064     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
7065
7066     WebCore::Node* node = priv->currentSelectedNode;
7067
7068     rect->x = node->getRect().x();
7069     rect->y = node->getRect().y();
7070     rect->w = node->getRect().width();
7071     rect->h = node->getRect().height();
7072     return TRUE;
7073 }
7074
7075 bool _ewk_view_dropdown_check_node_exist(Evas_Object* ewkView, bool* is_prev, bool* is_next)
7076 {
7077     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
7078     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
7079
7080     RefPtr<WebCore::KeyboardEvent> event = WebCore::KeyboardEvent::create();
7081     WebCore::KeyboardEvent* keyEvent = static_cast<WebCore::KeyboardEvent*>(event.get());
7082
7083     WebCore::Node* prevNode = priv->currentSelectedNode;
7084     WebCore::Node* nextNode = priv->currentSelectedNode;
7085     *is_prev = FALSE;
7086     *is_next = FALSE;
7087
7088     while (prevNode) {
7089         prevNode = priv->page->focusController()->previousFocusableNode(WebCore::FocusScope::focusScopeOf(prevNode), prevNode, keyEvent);
7090
7091         if ((prevNode) && (equalIgnoringCase(prevNode->nodeName(), "SELECT"))) {
7092             *is_prev = TRUE;
7093             break;
7094         }
7095     }
7096     while (nextNode) {
7097         nextNode = priv->page->focusController()->nextFocusableNode(WebCore::FocusScope::focusScopeOf(nextNode), nextNode, keyEvent);
7098
7099         if ((nextNode) && (equalIgnoringCase(nextNode->nodeName(), "SELECT"))) {
7100             *is_next = TRUE;
7101             break;
7102         }
7103     }
7104     return TRUE;
7105 }
7106 #endif
7107
7108 char** ewk_page_dropdown_get_options(Evas_Object* ewkView,  int x, int y, int* numberOfOptionsReturned, int* curentOptionIndex, Eina_Rectangle* rect, bool* is_prev, bool* is_next)
7109 {
7110 #if ENABLE(TIZEN_DROPDOWN_SUPPORT)
7111     EINA_SAFETY_ON_NULL_RETURN_VAL(numberOfOptionsReturned, 0);
7112     EINA_SAFETY_ON_NULL_RETURN_VAL(curentOptionIndex, 0);
7113
7114     *numberOfOptionsReturned = 0;
7115     *curentOptionIndex = -1;
7116     char** result;
7117
7118     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
7119     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
7120
7121     if (!priv->mainFrame->view())
7122         return 0;
7123
7124     WebCore::IntPoint pt = priv->mainFrame->view()->windowToContents(WebCore::IntPoint(x, y));
7125     WebCore::HitTestResult hitResult = priv->mainFrame->eventHandler()->hitTestResultAtPoint(pt, false);
7126     WebCore::Node* node = hitResult.innerNode()? hitResult.innerNode(): 0;
7127     if (!node || node->nodeType() != WebCore::Node::ELEMENT_NODE)
7128         return 0;
7129
7130     priv->currentSelectedNode = node;
7131
7132     WTF::AtomicString nodeName = node->nodeName();
7133     if (equalIgnoringCase(nodeName, "SELECT")) {
7134         WebCore::HTMLSelectElement* selectElem = (WebCore::HTMLSelectElement*)node;
7135         RefPtr<WebCore::HTMLOptionsCollection> availableOptions  = selectElem->options();
7136
7137         // no options, exit
7138         if (!availableOptions->length())
7139             return 0;
7140
7141         *numberOfOptionsReturned = availableOptions->length();
7142
7143         *curentOptionIndex = availableOptions->selectedIndex();
7144         // malloc'ing the table
7145         result = (char**)malloc((*numberOfOptionsReturned) * sizeof(char*));
7146         if (!result)
7147             return 0;
7148
7149         // iterating options
7150         for (int i = 0; i < *numberOfOptionsReturned; ++i) {
7151              WebCore::Node* node = availableOptions->item(i);
7152              WebCore::HTMLOptionElement* optionElement = (WebCore::HTMLOptionElement*)node;
7153
7154              WTF::String optionText = optionElement->text();
7155              result[i] = strdup(optionText.utf8().data());
7156         }
7157         _ewk_view_get_select_rect(ewkView, rect);
7158         _ewk_view_dropdown_check_node_exist(ewkView, is_prev, is_next);
7159
7160         return result;
7161     }
7162
7163     return 0;
7164 #else
7165     LOG_ERROR("TIZEN_DROPDOWN_SUPPORT is disabled. \n");
7166     return 0;
7167 #endif
7168 }
7169
7170 char** ewk_view_dropdown_get_next_options(Evas_Object* ewkView, int* numberOfOptionsReturned, int* curentOptionIndex, Eina_Rectangle* rect, bool* is_prev, bool* is_next)
7171 {
7172 #if ENABLE(TIZEN_DROPDOWN_SUPPORT)
7173     EINA_SAFETY_ON_NULL_RETURN_VAL(numberOfOptionsReturned, 0);
7174     EINA_SAFETY_ON_NULL_RETURN_VAL(curentOptionIndex, 0);
7175     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
7176     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
7177     
7178     char** result;
7179
7180     WebCore::Node* node = priv->currentSelectedNode;
7181
7182     RefPtr<WebCore::KeyboardEvent> event = WebCore::KeyboardEvent::create();
7183     WebCore::KeyboardEvent* keyEvent = static_cast<WebCore::KeyboardEvent*>(event.get());
7184
7185     while (node) {
7186         node = priv->page->focusController()->nextFocusableNode(WebCore::FocusScope::focusScopeOf(node), node, keyEvent);
7187
7188         if (!node)
7189             continue;
7190
7191         WTF::AtomicString nodeName = node->nodeName();
7192
7193         if (equalIgnoringCase(nodeName, "SELECT")) {
7194             WebCore::HTMLSelectElement* selectElem = (WebCore::HTMLSelectElement*)node;
7195             RefPtr<WebCore::HTMLOptionsCollection> availableOptions = selectElem->options();
7196
7197             // no options, exit
7198             if (!availableOptions->length())
7199                 return 0;
7200
7201             *numberOfOptionsReturned = availableOptions->length();
7202
7203             *curentOptionIndex = availableOptions->selectedIndex();
7204             // malloc'ing the table
7205             result = (char**)malloc((*numberOfOptionsReturned) * sizeof(char*));
7206             if (!result)
7207                 return 0;
7208
7209             // iterating options
7210             for (int i = 0; i < *numberOfOptionsReturned; ++i) {
7211                  WebCore::Node* node = availableOptions->item(i);
7212                  WebCore::HTMLOptionElement* optionElement = (WebCore::HTMLOptionElement*)node;
7213
7214                  WTF::String optionText = optionElement->text();
7215                  result[i] = strdup(optionText.utf8().data());
7216                  printf("<< next name = %s \n", result[i]);
7217             }
7218             priv->currentSelectedNode = node;
7219
7220             _ewk_view_get_select_rect(ewkView, rect);
7221             _ewk_view_dropdown_check_node_exist(ewkView, is_prev, is_next);
7222
7223 #if 0 // Implementing to move focus by gyuyoung 
7224             RefPtr<WebCore::KeyboardEvent> event = WebCore::KeyboardEvent::create();
7225             WebCore::KeyboardEvent* keyEvent = static_cast<WebCore::KeyboardEvent*>(event.get());
7226
7227             WebCore::FocusController* c = priv->mainFrame->page()->focusController();
7228             WebCore::FocusDirection focusDirection = WebCore::FocusDirectionForward;
7229
7230             c->advanceFocus(focusDirection, keyEvent);
7231             keyEvent->setDefaultHandled();
7232 #endif 
7233             return result;
7234         }
7235     }
7236
7237     return 0;
7238 #else
7239     LOG_ERROR("TIZEN_DROPDOWN_SUPPORT is disabled. \n");
7240     return 0;
7241 #endif
7242 }
7243
7244 char** ewk_view_dropdown_get_prev_options(Evas_Object* ewkView, int* numberOfOptionsReturned, int* curentOptionIndex, Eina_Rectangle* rect, bool* is_prev, bool* is_next)
7245 {
7246 #if ENABLE(TIZEN_DROPDOWN_SUPPORT)
7247     EINA_SAFETY_ON_NULL_RETURN_VAL(numberOfOptionsReturned, 0);
7248     EINA_SAFETY_ON_NULL_RETURN_VAL(curentOptionIndex, 0);
7249     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
7250     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
7251
7252     char** result;
7253
7254     WebCore::Node* node = priv->currentSelectedNode;
7255
7256     RefPtr<WebCore::KeyboardEvent> event = WebCore::KeyboardEvent::create();
7257     WebCore::KeyboardEvent* keyEvent = static_cast<WebCore::KeyboardEvent*>(event.get());
7258     
7259     while (node) {
7260         node = priv->page->focusController()->previousFocusableNode(WebCore::FocusScope::focusScopeOf(node), node, keyEvent);
7261
7262         if (!node)
7263             continue;
7264
7265         WTF::AtomicString nodeName = node->nodeName();
7266
7267         if (equalIgnoringCase(nodeName, "SELECT")) {
7268             WebCore::HTMLSelectElement* selectElem = (WebCore::HTMLSelectElement*)node;
7269             RefPtr<WebCore::HTMLOptionsCollection> availableOptions  = selectElem->options();
7270
7271             // no options, exit
7272             if (!availableOptions->length())
7273                 return 0;
7274
7275             *numberOfOptionsReturned = availableOptions->length();
7276
7277             *curentOptionIndex = availableOptions->selectedIndex();
7278             // malloc'ing the table
7279             result = (char**)malloc((*numberOfOptionsReturned) * sizeof(char*));
7280             if (!result)
7281                 return 0;
7282
7283             // iterating options
7284             for (int i = 0; i < *numberOfOptionsReturned; ++i) {
7285                  WebCore::Node* node = availableOptions->item(i);
7286                  WebCore::HTMLOptionElement* optionElement = (WebCore::HTMLOptionElement*)node;
7287
7288                  WTF::String optionText = optionElement->text();
7289                  result[i] = strdup(optionText.utf8().data());
7290                  printf("<< prev name = %s \n", result[i]);
7291             }
7292 #if 0 // Implementing to move focus by gyuyoung 
7293             RefPtr<WebCore::KeyboardEvent> event = WebCore::KeyboardEvent::create();
7294             WebCore::KeyboardEvent* keyEvent = static_cast<WebCore::KeyboardEvent*>(event.get());
7295
7296             WebCore::FocusController* c = priv->mainFrame->page()->focusController();
7297             WebCore::FocusDirection focusDirection = WebCore::FocusDirectionBackward;
7298
7299             c->advanceFocus(focusDirection, keyEvent);
7300             keyEvent->setDefaultHandled();
7301 #endif 
7302             priv->currentSelectedNode = node;
7303
7304             _ewk_view_get_select_rect(ewkView, rect);
7305             _ewk_view_dropdown_check_node_exist(ewkView, is_prev, is_next);
7306
7307             return result;
7308         }
7309     }
7310
7311     return 0;
7312 #else
7313     LOG_ERROR("TIZEN_DROPDOWN_SUPPORT is disabled. \n");
7314     return 0;
7315 #endif
7316 }
7317
7318 /**
7319  * Checking point for virtual keyboard enabling
7320  * Virtual keyboard is enabled for following html tags
7321  * input which type is not equal checkbox|radio|submit|reset|file|hidden|image|button,
7322  * because default and wrong types are text textarea
7323  *
7324  * @param[in]   obj             a Evas_Object webview
7325  * @param[in]   x               x coordinate of checking point
7326  * @param[in]   y               y coordinate of checking point
7327  * @return TRUE if element needs virtual keyboard or FALSE in other case
7328  *
7329  * Looks for a specified string inside #web_view.
7330  */
7331 char* ewk_page_check_point_for_keyboard(Evas_Object* ewkView, int x, int y, Eina_Bool* ret)
7332 {
7333 #if ENABLE(TIZEN_EFL_EXT_API)
7334     EINA_SAFETY_ON_NULL_RETURN_VAL(ret, 0);
7335     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
7336     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
7337
7338     WebCore::Document* doc = priv->mainFrame->documentAtPoint(WebCore::IntPoint(x, y));
7339     WebCore::Element* elem = doc->elementFromPoint(x, y);
7340
7341     WebCore::Frame* frame = EWKPrivate::corePage(ewkView)->focusController()->focusedOrMainFrame();
7342     *ret = frame->editor()->canEdit();
7343     if (*ret && elem) {
7344         WTF::String val = elem->getAttribute("value");
7345         if (val.isNull())
7346             return 0;
7347         return strdup(val.utf8().data());
7348     }
7349
7350     return 0;
7351 #else
7352     LOG_ERROR("TIZEN_EFL_EXT_API is disabled. \n");
7353     return 0;
7354 #endif
7355 }
7356
7357 Eina_Bool ewk_page_check_point(Evas_Object* ewkView, int x, int y, Evas_Event_Mouse_Down* event , Eina_Bool* haveLink, Eina_Bool* haveImg, Eina_Bool* haveFlash, char** linkURL, char** linkText, char** imgURL)
7358 {
7359 #if ENABLE(TIZEN_EFL_EXT_API)
7360     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
7361     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
7362
7363     WebCore::Document* doc = priv->mainFrame->documentAtPoint(WebCore::IntPoint(x, y));
7364     if (!doc)
7365         return false;
7366
7367     WebCore::HitTestRequest hitRequest(WebCore::HitTestRequest::ReadOnly);
7368     WebCore::IntPoint point(x, y);
7369     WebCore::PlatformMouseEvent platformEvent(event, point);
7370
7371     WebCore::MouseEventWithHitTestResults mouseWithHitResult = doc->prepareMouseEvent(hitRequest, point, platformEvent);
7372
7373     const WebCore::HitTestResult &hitResult = mouseWithHitResult.hitTestResult();
7374
7375     if (hitResult.absoluteLinkURL().isNull()) {
7376         *haveLink = false;
7377         linkURL = 0;
7378     } else {
7379         *haveLink = true;
7380         *linkURL = strdup(hitResult.absoluteLinkURL().string().utf8().data());
7381         *linkText = strdup(hitResult.textContent().utf8().data());
7382     }
7383
7384     if (hitResult.absoluteImageURL().isNull()) {
7385         *haveImg = false;
7386         imgURL = 0;
7387     } else {
7388         *haveImg = true;
7389         *imgURL = strdup(hitResult.absoluteImageURL().string().utf8().data());
7390         imgURL = linkURL;
7391     }
7392
7393     *haveFlash = false;
7394     // detect flash content
7395     WebCore::Node* node = hitResult.innerNonSharedNode();
7396     WebCore::Element* element = 0;
7397     if (node && node->isElementNode())
7398         element = static_cast<WebCore::Element*>(hitResult.innerNonSharedNode());
7399
7400     if (element && (element->hasTagName(WebCore::HTMLNames::objectTag) || element->hasTagName(WebCore::HTMLNames::embedTag))) {
7401         WebCore::HTMLPlugInElement* pluginElement = static_cast<WebCore::HTMLPlugInElement*>(element);
7402         if (_check_for_running_plugin(pluginElement))
7403             *haveFlash = true;
7404         else
7405             *haveFlash = false;
7406     }
7407
7408     return true; // fix prevent defect
7409 #else
7410     LOG_ERROR("TIZEN_EFL_EXT_API is disabled. \n");
7411     return false;
7412 #endif
7413 }
7414
7415 EAPI Eina_Bool ewk_view_reduce_plugins_frame_rate(Evas_Object* view, Eina_Bool reduceFPS)
7416 {
7417 #if ENABLE(TIZEN_PLUGIN_EXT) && ENABLE(NETSCAPE_PLUGIN_API) && ENABLE(TIZEN_NPAPI)
7418     EWK_VIEW_SD_GET_OR_RETURN(view, smartData, false);
7419     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
7420
7421     TNPEvent tnpevent;
7422     if (reduceFPS)
7423         tnpevent.type = TNPReduceFPS;
7424     else
7425         tnpevent.type = TNPRevertFPS;
7426
7427     _iterate_frames(priv->mainFrame, _send_event_to_all_plugins, &tnpevent);
7428     return true;
7429 #else
7430     LOG_ERROR("Tizen plugin extension, netscape api or tizen npapi are disabled.\n");
7431     return false;
7432 #endif
7433 }
7434
7435 Eina_Bool ewk_view_pause_or_resume_plugins(Evas_Object* view, Eina_Bool pausePlugin)
7436 {
7437 #if ENABLE(TIZEN_PLUGIN_EXT) && ENABLE(NETSCAPE_PLUGIN_API) && ENABLE(TIZEN_NPAPI)
7438     EWK_VIEW_SD_GET_OR_RETURN(view, smartData, false);
7439     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
7440
7441     TNPEvent tnpevent;
7442     if (pausePlugin)
7443         tnpevent.type = TNPPausePlugin;
7444     else
7445         tnpevent.type = TNPResumePlugin;
7446
7447     _iterate_frames(priv->mainFrame, _send_event_to_all_plugins, &tnpevent);
7448     return true;
7449 #else
7450     LOG_ERROR("Pause/resume plugins, netscape api or tizen npapi are disabled.\n");
7451     return false;
7452 #endif
7453 }
7454
7455 /**
7456  * Pausing/resuming html5 video and audio
7457  *
7458  * @param [in] view object
7459  * @param [in] true if pause media, false to resume
7460  */
7461 void ewk_view_pause_or_resume_video_audio(Evas_Object* view, Eina_Bool pauseMedia)
7462 {
7463 #if ENABLE(TIZEN_MM_PLAYER)
7464     bool pause = pauseMedia;
7465     evas_object_smart_callback_call(view, "html5video,pauseresume", &pause);
7466 #else
7467     LOG_ERROR("tizen mm-player is disabled. \n");
7468 #endif
7469 }
7470
7471 Eina_Bool ewk_view_suspend_request(Evas_Object* ewkView)
7472 {
7473     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
7474     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
7475
7476     WebCore::Frame* mainFrame = priv->mainFrame;
7477
7478 #if ENABLE(TIZEN_PAUSE_NETWORK)
7479     mainFrame->loader()->suspendAllLoaders();
7480 #endif
7481
7482 #if !ENABLE(TIZEN_MM_PLAYER)
7483 #if ENABLE(VIDEO)
7484     WebCore::Document* document = mainFrame->document();
7485     RefPtr<WebCore::NodeList> list = document->getElementsByTagName("video");
7486
7487     unsigned len = list->length();
7488     for (unsigned i = 0; i < len; i++) {
7489        if (list->item(i)->hasTagName(WebCore::HTMLNames::videoTag)) {
7490            WebCore::HTMLMediaElement* media = static_cast<WebCore::HTMLMediaElement*>(list->item(i));
7491            if (media->player()->hasVideo())
7492                media->player()->pause();
7493         }
7494     }
7495 #endif // ENABLE(VIDEO)
7496 #endif // !ENABLE(TIZEN_MM_PLAYER)
7497     return true;
7498 }
7499
7500 Eina_Bool ewk_view_resume_request(Evas_Object* ewkView)
7501 {
7502     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
7503     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
7504
7505     WebCore::Frame* mainFrame = priv->mainFrame;
7506
7507 #if ENABLE(TIZEN_PAUSE_NETWORK)
7508     mainFrame->loader()->resumeAllLoaders();
7509 #endif
7510
7511 #if !ENABLE(TIZEN_MM_PLAYER)
7512 #if ENABLE(VIDEO)
7513     // for playing video again
7514     WebCore::Document* document = mainFrame->document();
7515     RefPtr<WebCore::NodeList> list = document->getElementsByTagName("video");
7516
7517     unsigned len = list->length();
7518     for (unsigned i = 0; i < len; i++) {
7519         if (list->item(i)->hasTagName(WebCore::HTMLNames::videoTag)) {
7520             WebCore::HTMLMediaElement* media = static_cast<WebCore::HTMLMediaElement*>(list->item(i));
7521             if (media->player()->hasVideo())
7522                 media->player()->play();
7523         }
7524     }
7525 #endif // ENABLE(VIDEO)
7526 #endif // !ENABLE(TIZEN_MM_PLAYER)
7527     return true;
7528 }
7529
7530 Eina_Bool ewk_view_text_size_adjust(Evas_Object* ewkView)
7531 {
7532 #if ENABLE(TIZEN_TEXT_SIZE_ADJUST)
7533     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
7534     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
7535
7536     WebCore::Document* document = priv->mainFrame->document();
7537     if (!document)
7538         return false;
7539
7540     WebCore::Element* element = document->documentElement();
7541     if (!element)
7542         return false;
7543
7544     WebCore::RenderStyle* rootStyle = element->renderStyle();
7545     if (rootStyle)
7546         return rootStyle->textSizeAdjust();
7547
7548     return false;
7549 #else
7550     LOG_ERROR("TIZEN_TEXT_SIZE_ADJUST is disabled. \n");
7551     return false;
7552 #endif
7553 }
7554
7555 void ewk_view_set_text_size_adjust(Evas_Object* ewkView, Eina_Bool set)
7556 {
7557 #if ENABLE(TIZEN_TEXT_SIZE_ADJUST)
7558     if (ewk_view_text_size_adjust(ewkView) != set) {
7559         EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
7560         EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
7561
7562         WebCore::Document* document = priv->mainFrame->document();
7563         if (!document)
7564             return;
7565
7566         WebCore::Element* element = document->documentElement();
7567         if (!element)
7568             return;
7569
7570         WebCore::RenderStyle* rootStyle = element->renderStyle();
7571
7572         if (rootStyle)
7573             rootStyle->setTextSizeAdjust(set);
7574     }
7575 #else
7576     LOG_ERROR("TIZEN_TEXT_SIZE_ADJUST is disabled. \n");
7577 #endif
7578 }
7579
7580 void ewk_webcore_cache_clean()
7581 {
7582 #if ENABLE(TIZEN_EFL_EXT_API)
7583     (WebCore::memoryCache())->setDisabled(true);
7584     (WebCore::memoryCache())->setDisabled(false);
7585 #else
7586     LOG_ERROR("TIZEN_EFL_EXT_API is disabled. \n");
7587 #endif
7588 }
7589
7590 #if ENABLE(TIZEN_EFL_EXT_API)
7591 void _rescale_images_from_frame(WebCore::Frame* frame, void* data)
7592 {
7593     int width;
7594     if (data)
7595         width = *static_cast<int*>(data);
7596     else
7597         return;
7598
7599     RefPtr<WebCore::HTMLCollection> images = frame->document()->images();
7600
7601     for (unsigned i = 0 ; i < images->length() ; ++i) {
7602         WebCore::HTMLImageElement* htmlImageElement = static_cast<WebCore::HTMLImageElement*>(images->item(i));
7603         if (!htmlImageElement)
7604             continue;
7605
7606         int imageW = htmlImageElement->width();
7607         int imageH = htmlImageElement->height();
7608
7609         if (imageW > 0 && imageH > 0 && width > 0 && imageW > width) { // image extends webview and need to be rescaled
7610             int newImageW, newImageH;
7611             newImageW = width;
7612             newImageH = (newImageW * imageH) / imageW;
7613
7614             htmlImageElement->setWidth(newImageW);
7615             htmlImageElement->setHeight(newImageH);
7616         }
7617     }
7618 }
7619 #endif
7620
7621 void ewk_view_rescale_images_to_width(Evas_Object* ewkView, int w)
7622 {
7623 #if ENABLE(TIZEN_EFL_EXT_API)
7624     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
7625     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
7626
7627     if (priv->mainFrame) {
7628         WebCore::Document* document = priv->mainFrame->document();
7629         if (document) {
7630             int width = w;
7631             _iterate_frames(priv->mainFrame, _rescale_images_from_frame, (void*)&width);
7632         }
7633     }
7634 #else
7635     LOG_ERROR("TIZEN_EFL_EXT_API is disabled. \n");
7636     return;
7637 #endif
7638 }
7639
7640 #if ENABLE(TIZEN_EFL_EXT_API)
7641 // FIXME: NEED TO REMOVE
7642 static Eina_Bool (*g_navigation_policy_decision)(Ewk_View_Smart_Data* smartData, Ewk_Frame_Resource_Request* request);
7643
7644 // FIXME: NEED TO REMOVE
7645 EAPI void ewk_view_navigation_policy_decision_set(Eina_Bool (*navigation_policy_decision)(Ewk_View_Smart_Data*, Ewk_Frame_Resource_Request*))
7646 {
7647     g_navigation_policy_decision = navigation_policy_decision;
7648 }
7649 #endif
7650
7651 /**
7652  * This method returns allocated list containing rss links in the document which view object load.
7653  *
7654  * @param ewkView view object.
7655  *
7656  * @return eina_list containing Ewk_RSS_Items or 0. It should be freed via ewk_view_rss_items_free().
7657  *
7658  * @see ewk_view_rss_items_free()
7659  */
7660 EAPI Eina_List* ewk_view_rss_items_get(Evas_Object* ewkView)
7661 {
7662 #if ENABLE(TIZEN_SUPPORT_RSS_LINK_PARSING)
7663     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
7664     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
7665
7666     WebCore::Document* document = priv->mainFrame->document();
7667     RefPtr<WebCore::HTMLAllCollection>collection = document->all();
7668        
7669     WTF::String Rss("application/rss+xml");
7670     WTF::String Atom("application/atom+xml");
7671     WTF::String Alternate("alternate");
7672
7673     Eina_List* ret = 0;
7674     for (WebCore::Node* node = collection->firstItem(); node; node = collection->nextItem()) {
7675          WebCore::HTMLLinkElement* linkElement = static_cast<WebCore::HTMLLinkElement*>(node);
7676          if (linkElement->rel() == Alternate) {
7677              Ewk_Link_Type type;
7678              if (linkElement->type() == Rss)
7679                  type = EWK_LINK_TYPE_RSS;
7680              else if (linkElement->type() == Atom)
7681                  type = EWK_LINK_TYPE_ATOM;
7682              else
7683                  continue;
7684
7685              Ewk_RSS_Item* linkItem = static_cast<Ewk_RSS_Item*>(malloc(sizeof(Ewk_RSS_Item)));
7686              if (!linkItem)
7687                  return 0;
7688
7689              linkItem->type = type;
7690
7691              WTF::String href = linkElement->href();
7692              if (!href.isEmpty())
7693                  linkItem->href = strdup(href.utf8().data());
7694              else
7695                  linkItem->href = 0;
7696
7697              if (!linkElement->title().isEmpty())
7698                  linkItem->title = strdup(linkElement->title().utf8().data());
7699              else
7700                  linkItem->title = 0;
7701   
7702              ret = eina_list_append(ret, linkItem);
7703         }
7704     }
7705
7706     return ret;
7707 #else
7708     return 0;
7709 #endif  
7710 }
7711
7712 /**
7713  * This method clear list assigned by ewk_view_rss_items_get().
7714  * list can be 0.
7715  *
7716  * @param list list which assigned by ewk_view_rss_items_get().
7717  *
7718  * @see ewk_view_rss_items_get()
7719  */
7720 EAPI void ewk_view_rss_items_free(Eina_List* list)
7721 {
7722 #if ENABLE(TIZEN_SUPPORT_RSS_LINK_PARSING)
7723     if (!list)
7724         return;
7725     void* p;
7726     EINA_LIST_FREE(list, p) {
7727         Ewk_RSS_Item* item = static_cast<Ewk_RSS_Item*>(p);
7728         if (item->href)
7729             free(const_cast<char*>(item->href));
7730         if (item->title)
7731             free(const_cast<char*>(item->title));
7732         free(item);
7733     }
7734 #endif
7735 }
7736
7737 EAPI void ewk_view_get_rss_links(Evas_Object* ewkView, Ewk_RSS_Link** pRssLink, int* rssCount)
7738 {
7739 #if ENABLE(TIZEN_SUPPORT_RSS_LINK_PARSING)
7740     // This method is deprecated.
7741     *rssCount = 0;
7742 #endif
7743 }
7744
7745 #if USE(ACCELERATED_COMPOSITING) && ENABLE(TIZEN_ACCELERATED_COMPOSITING)
7746 static void _ewk_view_accelerated_compositing_pixels_cb(void* data, Evas_Object* obj)
7747 {
7748     Evas_Object* ewkView = static_cast<Evas_Object*>(data);
7749
7750     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
7751     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
7752
7753     if (priv->compositingActive) {
7754         priv->mainFrame->view()->updateLayoutAndStyleIfNeededRecursive();
7755         priv->compositor->syncLayers();
7756     }
7757 }
7758
7759 void ewk_view_compositor_create(Evas_Object* ewkView)
7760 {
7761     EWK_VIEW_SD_GET(ewkView, smartData);
7762     EWK_VIEW_PRIV_GET(smartData, priv);
7763
7764     if (priv->compositor)
7765         return;
7766     priv->compositor = WebCore::AcceleratedCompositor::create(priv->page->chrome());
7767 }
7768
7769 Evas_Object* ewk_view_evas_gl_object_create(Evas_Object* ewkView, Evas_Native_Surface* nativeSurface, int x, int y, int w, int h)
7770 {
7771     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
7772     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
7773
7774     if (!priv->compositingSurface) {
7775         Evas_Object* evas_gl_object = evas_object_image_add(smartData->base.evas);
7776
7777         evas_object_pass_events_set(evas_gl_object, true); // ignore events
7778         evas_object_image_alpha_set(evas_gl_object, true);
7779         evas_object_image_content_hint_set(evas_gl_object, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
7780
7781         evas_object_smart_member_add(evas_gl_object, ewkView);
7782
7783         priv->compositingSurface = evas_gl_object;
7784     }
7785
7786     evas_object_image_size_set(priv->compositingSurface, w, h);
7787     evas_object_image_fill_set(priv->compositingSurface, 0, 0, w, h);
7788
7789     evas_object_image_native_surface_set(priv->compositingSurface, nativeSurface);
7790
7791     evas_object_image_pixels_get_callback_set(priv->compositingSurface, _ewk_view_accelerated_compositing_pixels_cb, ewkView);
7792
7793     evas_object_move(priv->compositingSurface, x, y);
7794     evas_object_resize(priv->compositingSurface, w, h);
7795
7796     return priv->compositingSurface;
7797 }
7798
7799 void ewk_view_root_graphics_layer_set(Evas_Object* ewkView, WebCore::GraphicsLayer* rootLayer)
7800 {
7801     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
7802     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
7803
7804     bool active = rootLayer ? true : false;
7805
7806     if (priv->compositingActive == active)
7807         return;
7808
7809     priv->compositingActive = active;
7810
7811     if (priv->compositingActive) {
7812         ewk_view_compositor_create(ewkView);
7813
7814         if (priv->compositingSurface && priv->compositor) {
7815             evas_object_show(priv->compositingSurface);
7816
7817             priv->compositor->setRootLayer(rootLayer);
7818
7819             float zoom = ewk_view_zoom_get(ewkView);
7820             priv->compositor->setZoom(zoom);
7821         } else
7822             priv->compositingActive = false;
7823     }
7824
7825     if (!priv->compositingActive && priv->compositingSurface)
7826         evas_object_hide(priv->compositingSurface);
7827 }
7828
7829 void ewk_view_mark_for_sync(Evas_Object* ewkView, bool b)
7830 {
7831     EWK_VIEW_SD_GET(ewkView, smartData);
7832     EWK_VIEW_PRIV_GET(smartData, priv);
7833
7834     evas_object_image_pixels_dirty_set(priv->compositingSurface, true);
7835 }
7836
7837
7838 Evas_Object* ewk_view_evas_object_for_compositing_create(Evas_Object* ewkView)
7839 {
7840     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
7841     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
7842
7843     if (!priv->compositingSurface) {
7844         int x = 0, y = 0, w = 0, h = 0;
7845         evas_object_geometry_get(ewkView, &x, &y, &w, &h);
7846
7847         Evas_Object* evasObject = evas_object_image_add(smartData->base.evas);
7848
7849         evas_object_image_alpha_set(evasObject, true);
7850         evas_object_move(evasObject, x, y);
7851         evas_object_image_content_hint_set(evasObject, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
7852         evas_object_image_size_set(evasObject, w, h);
7853         evas_object_image_fill_set(evasObject, 0, 0, w, h);
7854         evas_object_resize(evasObject, w, h);
7855         evas_object_hide(evasObject);
7856         evas_object_pass_events_set(evasObject, true); // ignore events
7857         evas_object_smart_member_add(evasObject, ewkView);
7858
7859         priv->compositingSurface = evasObject;
7860     }
7861     return priv->compositingSurface;
7862 }
7863
7864 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
7865 void ewk_view_add_or_update_scrolling_layer(Evas_Object* ewkView, WebCore::PlatformLayer* scrollingLayer, WebCore::PlatformLayer* contentsLayer, const WebCore::IntSize& scrollSize)
7866 {
7867     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
7868     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
7869
7870     if (!priv->compositingActive || !priv->compositingSurface || !priv->compositor)
7871         return;
7872
7873     priv->compositor->addOrUpdateScrollingLayer(scrollingLayer, contentsLayer, scrollSize);
7874 }
7875
7876 void ewk_view_remove_scrolling_layer(Evas_Object* ewkView, WebCore::PlatformLayer* scrollingLayer, WebCore::PlatformLayer* contentsLayer)
7877 {
7878     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
7879     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
7880
7881     if (!priv->compositingActive || !priv->compositingSurface || !priv->compositor)
7882         return;
7883
7884     priv->compositor->removeScrollingLayer(scrollingLayer, contentsLayer);
7885 }
7886 #endif
7887 #endif // USE(ACCELERATED_COMPOSITING) && ENABLE(TIZEN_ACCELERATED_COMPOSITING)
7888
7889 /**
7890  * @fn Ewk_Dom_Input_Picker_Type ewk_view_cur_selected_element_type_check(Evas_Object* ewkView, int x, int y)
7891  * @brief Check DOM-element and attribute type for UI picker
7892  * @param [in] ewkView Webview.Evas_Object
7893  * @param [in] x X coordinate
7894  * @param [in] y Y coodinate
7895  * @return enum value of Ewk_Dom_Input_Picker_Type is a current selected element and attribute
7896  */
7897 Ewk_Dom_Input_Picker_Type ewk_view_cur_selected_element_type_check(Evas_Object* ewkView, int x, int y)
7898 {
7899 #if ENABLE(TIZEN_EFL_EXT_API)
7900     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, EWK_DOM_ELEMENT_NONE);
7901     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, EWK_DOM_ELEMENT_NONE);
7902     if (!priv->mainFrame->view())
7903          return EWK_DOM_ELEMENT_NONE;
7904
7905     WebCore::IntPoint pt = priv->mainFrame->view()->windowToContents(WebCore::IntPoint(x, y));
7906     WebCore::HitTestResult hitResult = priv->mainFrame->eventHandler()->hitTestResultAtPoint(pt, false);
7907     WebCore::Node* node = hitResult.innerNode() ? hitResult.innerNode() : 0;
7908
7909     if (!node || node->nodeType() != WebCore::Node::ELEMENT_NODE)
7910         return EWK_DOM_ELEMENT_NONE;
7911
7912     WTF::AtomicString nodeName = node->nodeName();
7913     if (equalIgnoringCase(nodeName, "SELECT"))
7914         return EWK_DOM_ELEMENT_SELECT;
7915     if (equalIgnoringCase(nodeName, "INPUT")) {
7916         if (!node->attributes())
7917             return EWK_DOM_ELEMENT_INPUT_ELSE;
7918         RefPtr<WebCore::Node> n = node->attributes()->getNamedItem("type");
7919         if (!n)
7920             return EWK_DOM_ELEMENT_INPUT_ELSE;
7921
7922         WTF::AtomicString nodeValue = n.get()->nodeValue();
7923
7924         if (equalIgnoringCase(nodeValue, "COLOR"))
7925             return EWK_DOM_ELEMENT_INPUT_COLOR;
7926         if (equalIgnoringCase(nodeValue, "TIME"))
7927             return EWK_DOM_ELEMENT_INPUT_TIME;
7928         if (equalIgnoringCase(nodeValue, "DATE"))
7929             return EWK_DOM_ELEMENT_INPUT_DATE;
7930
7931         return EWK_DOM_ELEMENT_INPUT_ELSE;
7932     }
7933
7934     return EWK_DOM_ELEMENT_ELSE;
7935 #else
7936     LOG_ERROR("TIZEN_EFL_EXT_API is disabled. \n");
7937     return EWK_DOM_ELEMENT_ERROR;
7938 #endif
7939 }
7940
7941 /**
7942  * @fn Eina_Bool ewk_view_cur_selected_input_element_value_set(Evas_Object* ewkView,  int x, int y, const char* value, Ewk_Dom_Input_Picker_Type type)
7943  * @brief Check DOM-element and attribute type for UI picker
7944  * @param [in] ewkView Webview.Evas_Object
7945  * @param [in] x X coordinate
7946  * @param [in] y Y coodinate
7947  * @param [in] value Setting value for current input element
7948  * @param [in] type Ewk_Dom_Input_Picker_Type for setting value validation checking
7949  * @return true if operation is success; false if not
7950  */
7951 Eina_Bool ewk_view_cur_selected_input_element_value_set(Evas_Object* ewkView,  int x, int y, const char* value, Ewk_Dom_Input_Picker_Type type)
7952 {
7953 #if ENABLE(TIZEN_EFL_EXT_API)
7954     if (!ewk_view_input_element_value_check(value, type))
7955         return false;
7956
7957     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
7958     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
7959
7960     if (!priv->mainFrame->view())
7961         return false;
7962
7963     WebCore::IntPoint pt = priv->mainFrame->view()->windowToContents(WebCore::IntPoint(x, y));
7964     WebCore::HitTestResult hitResult = priv->mainFrame->eventHandler()->hitTestResultAtPoint(pt, false);
7965     WebCore::Node* node = hitResult.innerNode()? hitResult.innerNode() : 0;
7966     if (!node || node->nodeType() != WebCore::Node::ELEMENT_NODE)
7967         return false;
7968
7969     if (equalIgnoringCase(node->nodeName(), "INPUT")) {
7970         WebCore::HTMLInputElement* htmlInputElement = (WebCore::HTMLInputElement*)node;
7971         htmlInputElement->setValue(value, WebCore::DispatchChangeEvent);
7972         return true;
7973     }
7974
7975     return false;
7976 #else
7977     LOG_ERROR("TIZEN_EFL_EXT_API is disabled. \n");
7978     return false;
7979 #endif
7980 }
7981
7982
7983 /**
7984  * @fn char* ewk_view_cur_selected_element_value_get(Evas_Object* ewkView,  int x, int y, Ewk_Dom_Input_Picker_Type type)
7985  * @brief Check DOM-element and attribute type for UI picker
7986  * @param [in] ewkView Webview.Evas_Object
7987  * @param [in] x X coordinate
7988  * @param [in] y Y coodinate
7989  * @param [in] type Ewk_Dom_Input_Picker_Type for getting value
7990  * @return String of current selected input element's value (Tis is had to be freed after use)
7991  */
7992 char* ewk_view_cur_selected_element_value_get(Evas_Object* ewkView,  int x, int y, Ewk_Dom_Input_Picker_Type type)
7993 {
7994 #if ENABLE(TIZEN_EFL_EXT_API)
7995     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
7996     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
7997
7998     if (!priv->mainFrame->view())
7999         return 0;
8000
8001     WebCore::IntPoint pt = priv->mainFrame->view()->windowToContents(WebCore::IntPoint(x, y));
8002     WebCore::HitTestResult hitResult = priv->mainFrame->eventHandler()->hitTestResultAtPoint(pt, false);
8003     WebCore::Node* node = hitResult.innerNode() ? hitResult.innerNode() : 0;
8004
8005     if (!node || node->nodeType() != WebCore::Node::ELEMENT_NODE)
8006         return 0;
8007
8008     if (equalIgnoringCase(node->nodeName(), "INPUT")) {
8009         WebCore::HTMLInputElement* htmlInputElement = (WebCore::HTMLInputElement*)node;
8010         if (!ewk_view_input_element_value_check(htmlInputElement->value().utf8().data(), type))
8011             return 0;
8012
8013         return strdup(htmlInputElement->value().utf8().data());
8014     }
8015
8016     return 0;
8017 #else
8018     LOG_ERROR("TIZEN_EFL_EXT_API is disabled. \n");
8019     return 0;
8020 #endif
8021 }
8022
8023
8024 /**
8025  * @fn Eina_Bool ewk_view_input_element_value_check(const char* value, Ewk_Dom_Input_Picker_Type type)
8026  * @brief Check DOM-element and attribute type for UI picker
8027  * @internal
8028  * @param [in] value A value for validation checking
8029  * @param [in] type For validation checking type of input element
8030  * @return true if value is valid; false if not
8031  */
8032 Eina_Bool ewk_view_input_element_value_check(const char* value, Ewk_Dom_Input_Picker_Type type)
8033 {
8034 #if ENABLE(TIZEN_EFL_EXT_API)
8035     String tempValue(value);
8036
8037     switch (type) {
8038     case EWK_DOM_ELEMENT_INPUT_TIME: {
8039         if (tempValue.length() !=5 || tempValue[2] != ':')
8040             return false;
8041
8042         int h = tempValue.substring(0, 2).toInt();
8043         int m = tempValue.substring(3, 2).toInt();
8044
8045         if ((h > 23 || h < 0) || (m > 59 || m < 0))
8046             return false;
8047         break;
8048     }
8049     case EWK_DOM_ELEMENT_INPUT_DATE: {
8050         if (tempValue.length() !=10 || tempValue[4] != '-' || tempValue[7] != '-')
8051              return false;
8052
8053          int y = tempValue.substring(0, 4).toInt();
8054          int m = tempValue.substring(5, 2).toInt();
8055          int d = tempValue.substring(8, 2).toInt();
8056
8057          if ((y > 9999 || y < 0) || (m > 12 || m < 1) || (d > 31 || d < 1))
8058              return false;
8059          break;
8060      }
8061      case EWK_DOM_ELEMENT_INPUT_COLOR: {
8062          if (tempValue.length() !=7 || tempValue[0] != '#')
8063              return false;
8064          break;
8065      }
8066      default:
8067          return false;
8068          break;
8069     }
8070     return true;
8071 #else
8072     LOG_ERROR("TIZEN_EFL_EXT_API is disabled. \n");
8073     return false;
8074 #endif
8075 }
8076
8077 Eina_Bool ewk_view_paste_image(Evas_Object* ewkView, const char* path)
8078 {
8079 #if ENABLE(TIZEN_IMAGE_PASTE)
8080     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
8081
8082     String filePath(path);
8083     filePath.remove(filePath.find("file://"), 7);
8084
8085     while (!filePath.find("//"))
8086         filePath.remove(0, 1);
8087
8088     FILE* file = fopen(filePath.utf8().data(), "r");
8089     if (!file) {
8090         LOG_ERROR("Could not open the file: %s\n", filePath.utf8().data());
8091         return false;
8092     }
8093
8094     if (fseek(file, 0, SEEK_END)) {
8095         LOG_ERROR("Reading error\n");
8096         fclose(file);
8097         return false;
8098     }
8099     unsigned long size = ftell(file);
8100     rewind(file);
8101
8102     char* buffer = (char*)malloc(sizeof(char)*size);
8103     if (!buffer) {
8104         LOG_ERROR("Memory error\n");
8105         fclose(file);
8106         return false;
8107     }
8108
8109     size_t result = fread(buffer, sizeof(char), size, file);
8110     fclose(file);
8111
8112     if (result != size) {
8113         LOG_ERROR("Reading error\n");
8114         free(buffer);
8115         return false;
8116     }
8117
8118     String stringToEncode(buffer, result);
8119     free(buffer);
8120
8121     Vector<char> in;
8122     in.append(stringToEncode.characters(), stringToEncode.length());
8123     Vector<char> out;
8124     WebCore::base64Encode(in, out);
8125
8126     size_t dotPos = filePath.reverseFind(".");
8127     if (dotPos == notFound) {
8128         LOG_ERROR("Unknown image extension");
8129         return false;
8130     }
8131
8132     String fileExtension = filePath.substring(dotPos + 1);
8133     if (equalIgnoringCase(fileExtension, "jpeg"))
8134         fileExtension = "jpg";
8135     else if (equalIgnoringCase(fileExtension, "jpg") && equalIgnoringCase(fileExtension, "png")) { // only png and jpg supported for now, got to test other images types
8136         LOG_ERROR("Unknown image extension");
8137         return false;
8138     }
8139
8140     String encodedString = String("data:image/");
8141     encodedString.append(fileExtension);
8142     encodedString.append(";base64,");
8143     encodedString.append(String(out.data(), out.size()));
8144
8145     return ewk_view_execute_editor_command(ewkView, EWK_EDITOR_COMMAND_INSERT_IMAGE, encodedString.utf8().data());
8146 #else
8147     LOG_ERROR("TIZEN_PASTE_IMAGE is disabled. \n");
8148     return false;
8149 #endif
8150 }
8151
8152 /**
8153  * This method allows to set value to the focused input element
8154  *
8155  * @param[in]   ewkView             a Evas_Object webview
8156  * @param[in]   value         value to set
8157  * @return true if it is succeeded or false in other case
8158  */
8159 Eina_Bool ewk_view_focused_input_element_value_set(Evas_Object* ewkView, const char* value)
8160 {
8161 #if ENABLE(TIZEN_INPUT_TAG_SUPPORT)
8162     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
8163     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
8164
8165     WebCore::Frame* focusedFrame = priv->page->focusController()->focusedOrMainFrame();
8166     if (focusedFrame
8167             && focusedFrame->document()
8168             && focusedFrame->document()->focusedNode()) {
8169         WebCore::Node* node = focusedFrame->document()->focusedNode();
8170         if (node->nodeType() == WebCore::Node::ELEMENT_NODE) {
8171             if (node->hasTagName(WebCore::HTMLNames::inputTag)) {
8172                 (static_cast<WebCore::HTMLInputElement*>(node))->setValue(value, WebCore::DispatchChangeEvent);
8173                 return true;
8174             }
8175         }
8176     }
8177     return false;
8178 #else
8179     LOG_ERROR("TIZEN_EFL_EXT_API is disabled.\n");
8180     return false;
8181 #endif
8182 }
8183
8184 /**
8185  * This method allows to get value from the focused input element
8186  *
8187  * @param[in]   ewkView             a Evas_Object webview
8188  * @return focused input element's value if it is succeeded or "" in other case
8189  */
8190 const char* ewk_view_focused_input_element_value_get(Evas_Object* ewkView)
8191 {
8192 #if ENABLE(TIZEN_EFL_EXT_API)
8193     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, "");
8194     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, "");
8195
8196     WebCore::Frame* focusedFrame = priv->page->focusController()->focusedOrMainFrame();
8197     if (focusedFrame
8198             && focusedFrame->document()
8199             && focusedFrame->document()->focusedNode()) {
8200         WebCore::Node* node = focusedFrame->document()->focusedNode();
8201         if (node->nodeType() == WebCore::Node::ELEMENT_NODE)
8202             if (node->hasTagName(WebCore::HTMLNames::inputTag))
8203                 return strdup((static_cast<WebCore::HTMLInputElement*>(node))->value().utf8().data());
8204     }
8205     return "";
8206 #else
8207     LOG_ERROR("TIZEN_EFL_EXT_API is disabled.\n");
8208     return "";
8209 #endif
8210 }
8211
8212 /**
8213  * Informs that this view is active.
8214  *
8215  * This can be used by the backing store to release resources or disable
8216  * updates on this view if necessary, being able to have many views without
8217  * all the implied cost associated. By default each created view is active.
8218  *
8219  * @param ewkView view to set as active.
8220  * @param value @c true if this view is active, @c false otherwise.
8221  *
8222  * @return @c true if view was set as active/inactive, @c false
8223  *         otherwise (errors, inactive set not supported).
8224  */
8225 Eina_Bool ewk_view_active_set(Evas_Object* ewkView, Eina_Bool value)
8226 {
8227 #if ENABLE(TIZEN_VIEW_ACTIVE_SET)
8228     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
8229     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
8230     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api->active_set, false);
8231
8232     if (priv->flags.active == value)
8233         return true;
8234
8235 #if ENABLE(TIZEN_PLUGIN_EXT) && ENABLE(TIZEN_NPAPI)
8236     ewk_view_pause_or_resume_plugins(ewkView, !value);
8237 #endif
8238
8239 #if ENABLE(NETSCAPE_PLUGIN_API) && ENABLE(TIZEN_SUPPORT_PLUGINS) && ENABLE(TIZEN_DONT_PAN_OVER_SOME_PLUGINS)
8240     if (!value && WebCore::PluginView::isPluginHandlingEvents())
8241         WebCore::PluginView::setPluginHandlingEvents(false);
8242 #endif
8243
8244     if (smartData->api->active_set(smartData, value)) {
8245         priv->flags.active = value;
8246         return true;
8247     }
8248
8249     return false;
8250 #else
8251     LOG_ERROR("TIZEN_VIEW_ACTIVE_SET is disabled.\n");
8252     return false;
8253 #endif
8254 }
8255
8256 /**
8257  * Returns if this view is set as active.
8258  *
8259  * @param ewkView view to fetch information from.
8260  *
8261  * @return @c true if the view is active, @c false otherwise.
8262  */
8263 Eina_Bool ewk_view_active_get(const Evas_Object* ewkView)
8264 {
8265 #if ENABLE(TIZEN_VIEW_ACTIVE_SET)
8266     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
8267     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
8268
8269     return priv->flags.active;
8270 #else
8271     LOG_ERROR("TIZEN_VIEW_ACTIVE_SET is disabled.\n");
8272     return false;
8273 #endif
8274 }
8275
8276 Eina_Bool ewk_view_dom_document_get(Evas_Object* ewkView, WebKitDOM_Document* ret)
8277 {
8278 #if ENABLE(CDOM_BINDINGS)
8279     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
8280     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
8281
8282     if (priv->mainFrame && ret) {
8283         _to_webkit_document(priv->mainFrame->document(), ret);
8284         return true;
8285     }
8286     return false;
8287 #else
8288     LOG_ERROR("CDOM_BINDINGS is disabled.\n");
8289     return false;
8290 #endif
8291 }
8292
8293 /* Code for painting performance profile for Cairo/Skia */
8294 #if ENABLE(TIZEN_RENDERING_PROFILE_TEST)
8295 #ifdef __cplusplus
8296 extern "C" {
8297 #endif
8298 EAPI unsigned int ewk_view_screenshot_test(const Evas_Object* ewkView, float zoom, int input_w, int input_h, int output_w, int output_h, unsigned char* pixels, const char* aImageFileName, void* fp_logfile, const char* info_logfile);
8299 #ifdef __cplusplus
8300 }
8301 #endif
8302 unsigned int ewk_view_screenshot_test(const Evas_Object* ewkView, float zoom, int input_w, int input_h, int output_w, int output_h, unsigned char* pixels, const char* aImageFileName, void* fp_logfile, const char* info_logfile)
8303 {
8304     unsigned long s = 0, e = 0;
8305     struct timeval currentTime;
8306
8307 #if ENABLE(TIZEN_EFL_EXT_API)
8308     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
8309     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
8310
8311     WebCore::FrameView* view = priv->mainFrame->view();
8312
8313     if (view->needsLayout())
8314         view->forceLayout();
8315 #if USE(CAIRO)
8316     cairo_surface_t* cairo_surface =  cairo_image_surface_create_for_data(pixels, CAIRO_FORMAT_ARGB32, output_w, output_h, output_w * 4);
8317     cairo_t* cr =  cairo_create(cairo_surface);
8318     WebCore::GraphicsContext gc(cr);
8319 #elif USE(SKIA)
8320     skia::PlatformCanvas canvas(output_w, output_h, 1, (uint8_t*)pixels);
8321     WebCore::PlatformContextSkia sContext(&canvas);
8322     WebCore::GraphicsContext gc(&sContext);
8323 #endif
8324     WebCore::IntRect rect(0, 0, input_w, input_h);
8325
8326 #if USE(CAIRO)
8327     cairo_save(cr);
8328 #endif
8329     gettimeofday(&currentTime, 0);
8330     s = currentTime.tv_sec * 1000000 + currentTime.tv_usec;
8331     gc.save();
8332     gc.scale(WebCore::FloatSize(zoom, zoom));
8333     gc.clip(rect);
8334     if (view->isTransparent())
8335         gc.clearRect(rect);
8336     view->paintContents(&gc, rect);
8337     gc.restore();
8338     gettimeofday(&currentTime, 0);
8339     e = currentTime.tv_sec * 1000000 + currentTime.tv_usec;
8340 #if USE(CAIRO)
8341     cairo_restore(cr);
8342 #endif
8343     if (fp_logfile)
8344         WebCore::TizenProfiler::printByFunctions(static_cast<FILE*>(fp_logfile));
8345     if (aImageFileName) {
8346 #if USE(CAIRO)
8347         cairo_surface_write_to_png(cairo_surface, aImageFileName);
8348 #elif USE(SKIA)
8349         SkBitmap dst_bitmap;
8350         dst_bitmap.setConfig(SkBitmap::kARGB_8888_Config, output_w, output_h);
8351         dst_bitmap.setPixels((uint8_t*)pixels);
8352         SkImageEncoder::EncodeFile(aImageFileName, dst_bitmap, SkImageEncoder::kPNG_Type, 100);
8353 #endif
8354     }
8355
8356 #if USE(CAIRO)
8357     cairo_destroy(cr);
8358     cairo_surface_destroy(cairo_surface);
8359 #elif USE(SKIA)
8360 #endif
8361
8362 #else
8363     LOG_ERROR("TIZEN_EFL_EXT_API is disabled. \n");
8364 #endif
8365     return e - s;
8366 }
8367 #endif // ENABLE(TIZEN_RENDERING_PROFILE_TEST)
8368
8369 void ewk_view_show_ime_on_autofocus_set(Evas_Object* ewkView, Eina_Bool enabled)
8370 {
8371 #if ENABLE(TIZEN_AUTOFOCUS_BLOCK)
8372     EWK_VIEW_SD_GET(ewkView, smartData);
8373     EWK_VIEW_PRIV_GET(smartData, priv);
8374
8375     priv->settings.showImeOnAutofocus = enabled;
8376 #endif
8377 }
8378
8379 Eina_Bool ewk_view_show_ime_on_autofocus_get(Evas_Object* ewkView)
8380 {
8381 #if ENABLE(TIZEN_AUTOFOCUS_BLOCK)
8382     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
8383     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
8384
8385     return priv->settings.showImeOnAutofocus;
8386 #else
8387     return true;
8388 #endif
8389 }
8390
8391 #if ENABLE(TIZEN_PAGE_CACHE)
8392 /**
8393  * @internal
8394  * Restore cached page contents size.
8395  *
8396  * This method must be called before cached page restored().
8397  *
8398  * @param ewkView view object to change cached page contents size.
8399  */
8400 void ewk_view_cached_page_restore(Evas_Object* ewkView)
8401 {
8402     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
8403     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
8404
8405     WebCore::HistoryItem* item = priv->mainFrame->loader()->history()->currentItem();
8406
8407     if (!item)
8408         return;
8409
8410     if (item->isInPageCache()) {
8411         ewk_view_viewport_attributes_set(ewkView, priv->viewportArguments);
8412         priv->mainFrame->view()->adjustViewSize();
8413         ewk_frame_load_firstlayout_nonempty_finished(smartData->main_frame);
8414         ewk_view_cached_page_data_save(ewkView, item->viewZoomFactor(), item->scrollPoint());
8415     }
8416 }
8417 /**
8418  * @internal
8419  * save cached page zoom level and scroll positoin in ewk_view.
8420  *
8421  * @param ewkView view object to change cached page zoom and scroll data.
8422  * @param zoom_level to restore cached page zoom level.
8423  * @param pos to restore cached page scroll position.
8424  */
8425 void ewk_view_cached_page_data_save(Evas_Object* ewkView, float zoom_level, WebCore::IntPoint pos)
8426 {
8427     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
8428     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
8429
8430     priv->cachedPageData.isRestored = true;
8431     priv->cachedPageData.zoomLevel = zoom_level;
8432     priv->cachedPageData.scrollPos = pos;
8433 }
8434 #endif
8435
8436 Eina_Bool ewk_view_setting_recording_surface_enable_set(Evas_Object* ewkView, Eina_Bool enable)
8437 {
8438 #if ENABLE(TIZEN_RECORDING_SURFACE)
8439     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
8440     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
8441
8442     if (enable == false) {
8443         if (priv->recordingSurfaceEnable) {
8444             priv->recordingSurfaceSetState = RECORDING_SURFACE_SET_STATE_INIT;
8445             priv->recordingSurfaceSetList = ewk_recording_surface_set_free(smartData->_priv->recordingSurfaceSetList);
8446             priv->recordingSurfaceSetScrollState = false;
8447         }
8448
8449         priv->recordingSurfaceEnable = false;
8450         return true;
8451     }
8452
8453     priv->recordingSurfaceEnable = true;
8454     return true;
8455 #else
8456     return false;
8457 #endif
8458 }
8459
8460 #if ENABLE(TIZEN_RECORDING_SURFACE)
8461 int ewk_view_recording_surface_set_status_get(Ewk_View_Private_Data* priv, int status)
8462 {
8463     switch (status) {
8464     case RECORDING_SURFACE_SET_ENABLE_CHECK:
8465         return priv->recordingSurfaceEnable;
8466     case RECORDING_SURFACE_SET_LOAD_FINISHED_CHECK:
8467         return priv->recordingSurfaceSetLoadFinished;
8468     case RECORDING_SURFACE_SET_RECORDING_STATE_CHECK:
8469         return priv->recordingSurfaceSetState;
8470     case RECORDING_SURFACE_SET_SCROLL_CHECK:
8471         return priv->recordingSurfaceSetScrollState;
8472     default:
8473         return 0;
8474     }
8475 }
8476
8477 Eina_Bool ewk_view_recording_surface_set_paint_contents(Ewk_View_Private_Data* priv, cairo_t* cr, const Eina_Rectangle* area)
8478 {
8479     EINA_SAFETY_ON_NULL_RETURN_VAL(priv, false);
8480     EINA_SAFETY_ON_NULL_RETURN_VAL(cr, false);
8481     EINA_SAFETY_ON_NULL_RETURN_VAL(area, false);
8482
8483     if (priv->recordingSurfaceSetState == RECORDING_SURFACE_SET_STATE_COMPLETE)
8484         return ewk_recording_surface_set_tiled_replay(priv->recordingSurfaceSetList, cr, area);
8485     
8486     return false;
8487 }
8488
8489 void ewk_view_recording_surface_set_base_if_needed(Evas_Object* ewkView)
8490 {
8491     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
8492     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
8493
8494     if (priv->callOnceAfterLoadFinished && !priv->recordingSurfaceSetLoadFinished) {
8495         float zoom = ewk_view_zoom_get(ewkView);
8496
8497         priv->recordingSurfaceSetState =  RECORDING_SURFACE_SET_STATE_INIT;
8498         priv->recordingSurfaceSetList = ewk_recording_surface_set_free(priv->recordingSurfaceSetList);
8499         priv->recordingSurfaceSetList = ewk_recording_surface_set_base_record(priv->recordingSurfaceSetList, ewkView, zoom);
8500         priv->recordingSurfaceSetState = RECORDING_SURFACE_SET_STATE_COMPLETE;
8501         priv->recordingSurfaceSetLoadFinished = true;
8502     }
8503     priv->callOnceAfterLoadFinished = false;
8504 }
8505 #endif
8506
8507 unsigned int ewk_view_inspector_server_start(unsigned int port)
8508 {
8509 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
8510     Eina_Bool ret = WebCore::InspectorServerEfl::server()->startServer(port);
8511     if (ret)
8512         return WebCore::InspectorServerEfl::server()->getServerPort();
8513     else
8514         return 0;
8515 #else
8516     LOG_ERROR("TIZEN_REMOTE_WEB_INSPECTOR is disabled.\n");
8517     return 0;
8518 #endif
8519 }
8520
8521 Eina_Bool ewk_view_inspector_server_stop()
8522 {
8523 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
8524     return WebCore::InspectorServerEfl::server()->stopServer();
8525 #else
8526     LOG_ERROR("TIZEN_REMOTE_WEB_INSPECTOR is disabled.\n");
8527     return false;
8528 #endif
8529 }
8530
8531 #if ENABLE(NOTIFICATIONS)
8532 #if ENABLE(TIZEN_NOTIFICATION)
8533 WebCore::NotificationClient* ewk_view_notification_presenter_get(const Evas_Object* ewkView)
8534 {
8535     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
8536     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
8537     return WebCore::NotificationController::from(priv->page.get())->client();
8538 }
8539
8540 void ewk_view_notification_show(Evas_Object* ewkView, WebCore::Notification* notification)
8541 {
8542     char* iconUrl = strdup(notification->iconURL().string().utf8().data());
8543     char* title = strdup(notification->title().utf8().data());
8544     char* body = strdup(notification->body().utf8().data());
8545     Ewk_Notification ewk_notification = { static_cast<void*>(notification), iconUrl, title, body, 0 };
8546
8547     evas_object_smart_callback_call(ewkView, "notification,contents,show", (void*)&ewk_notification);
8548
8549     free(iconUrl);
8550     free(title);
8551     free(body);
8552 }
8553
8554 void ewk_view_notification_html_show(Evas_Object* ewkView, WebCore::Notification* notification)
8555 {
8556     char* url = strdup(notification->url().string().utf8().data());
8557     Ewk_Notification ewk_notification = { static_cast<void*>(notification), 0, 0, 0, url };
8558
8559     evas_object_smart_callback_call(ewkView, "notification,contents,htmlshow", (void*)&ewk_notification);
8560
8561     free(url);
8562 }
8563
8564 void ewk_view_notification_cancel(Evas_Object* ewkView, WebCore::Notification* notification)
8565 {
8566     Ewk_Notification ewk_notification = { static_cast<void*>(notification), 0, 0, 0, 0 };
8567
8568     evas_object_smart_callback_call(ewkView, "notification,contents,cancel", (void*)&ewk_notification);
8569 }
8570
8571 void ewk_view_notification_request_permission(Evas_Object* ewkView, const char* domain)
8572 {
8573     evas_object_smart_callback_call(ewkView, "notification,contents,requestPermission", (void*)domain);
8574 }
8575 #endif
8576
8577 void ewk_view_notification_displayed(const Evas_Object* ewkView, const Ewk_Notification* ewkNotification)
8578 {
8579 #if ENABLE(TIZEN_NOTIFICATION)
8580     if (!ewkNotification)
8581         return;
8582     EWK_VIEW_SD_GET(ewkView, smartData);
8583     EWK_VIEW_PRIV_GET(smartData, priv);
8584     static_cast<WebCore::NotificationClientEfl*>(WebCore::NotificationController::from(priv->page.get())->client())->notificationDisplayed(static_cast<WebCore::Notification*>(ewkNotification->notification));
8585 #endif
8586 }
8587
8588 void ewk_view_notification_clicked(const Evas_Object* ewkView, const Ewk_Notification* ewkNotification)
8589 {
8590 #if ENABLE(TIZEN_NOTIFICATION)
8591     EWK_VIEW_SD_GET(ewkView, smartData);
8592     EWK_VIEW_PRIV_GET(smartData, priv);
8593     static_cast<WebCore::NotificationClientEfl*>(WebCore::NotificationController::from(priv->page.get())->client())->notificationClicked(static_cast<WebCore::Notification*>(ewkNotification->notification));
8594 #endif
8595 }
8596
8597 void ewk_view_notification_closed(const Evas_Object* ewkView, const Ewk_Notification* ewkNotification)
8598 {
8599 #if ENABLE(TIZEN_NOTIFICATION)
8600     EWK_VIEW_SD_GET(ewkView, smartData);
8601     EWK_VIEW_PRIV_GET(smartData, priv);
8602     static_cast<WebCore::NotificationClientEfl*>(WebCore::NotificationController::from(priv->page.get())->client())->notificationClosed(static_cast<WebCore::Notification*>(ewkNotification->notification));
8603 #endif
8604 }
8605
8606 void ewk_view_notification_error(const Evas_Object* ewkView, const Ewk_Notification* ewkNotification)
8607 {
8608 #if ENABLE(TIZEN_NOTIFICATION)
8609     EWK_VIEW_SD_GET(ewkView, smartData);
8610     EWK_VIEW_PRIV_GET(smartData, priv);
8611     static_cast<WebCore::NotificationClientEfl*>(WebCore::NotificationController::from(priv->page.get())->client())->notificationError(static_cast<WebCore::Notification*>(ewkNotification->notification));
8612 #endif
8613 }
8614
8615 void ewk_view_notification_permission_callback(const Evas_Object* ewkView, Eina_Bool permit, const char* domain)
8616 {
8617 #if ENABLE(TIZEN_NOTIFICATION)
8618     if (!permit)
8619         return;
8620
8621     EWK_VIEW_SD_GET(ewkView, smartData);
8622     EWK_VIEW_PRIV_GET(smartData, priv);
8623     static_cast<WebCore::NotificationClientEfl*>(WebCore::NotificationController::from(priv->page.get())->client())->permittedCallbackCall(domain);
8624 #endif
8625 }
8626
8627 void ewk_view_notification_allowed_set(const Evas_Object* ewkView, Eina_Bool permit, const char* domain)
8628 {
8629 #if ENABLE(TIZEN_NOTIFICATION)
8630     if (!permit || !domain)
8631         return;
8632
8633     EWK_VIEW_SD_GET(ewkView, smartData);
8634     EWK_VIEW_PRIV_GET(smartData, priv);
8635     static_cast<WebCore::NotificationClientEfl*>(WebCore::NotificationController::from(priv->page.get())->client())->permittedCallbackCall(domain);
8636 #endif
8637 }
8638
8639
8640 void ewk_view_notification_add_permitted_domains(const Evas_Object* ewkView, char** domains, int size)
8641 {
8642 #if ENABLE(TIZEN_NOTIFICATION)
8643     EWK_VIEW_SD_GET(ewkView, smartData);
8644     EWK_VIEW_PRIV_GET(smartData, priv);
8645     static_cast<WebCore::NotificationClientEfl*>(WebCore::NotificationController::from(priv->page.get())->client())->makePermissionCache(domains, size);
8646 #endif
8647 }
8648 #endif
8649
8650 void ewk_view_orientation_feed(Evas_Object* ewkView, Ewk_Screen_Orientation orientation)
8651 {
8652 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
8653     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
8654     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
8655
8656     if (priv->orientation == orientation)
8657         return;
8658
8659     priv->orientation = orientation;
8660
8661     //FIXME: This assume that default orientation of device is portrait.
8662     //       landscape device is also considered.
8663     int newOrientation = 0;
8664     switch (orientation) {
8665     case EWK_PORTRAIT_PRIMARY:
8666         newOrientation = 0;
8667         break;
8668     case EWK_PORTRAIT_SECONDARY:
8669         newOrientation = 180;
8670         break;
8671     case EWK_LANDSCAPE_PRIMARY:
8672         newOrientation = 90;
8673         break;
8674     case EWK_LANDSCAPE_SECONDARY:
8675         newOrientation = -90;
8676         break;
8677     }
8678     if (priv->mainFrame->orientation() == newOrientation)
8679         return;
8680
8681     priv->mainFrame->sendOrientationChangeEvent(newOrientation);
8682     for (WebCore::Frame* child = priv->mainFrame->tree()->firstChild(); child; child = child->tree()->nextSibling())
8683         child->sendOrientationChangeEvent(newOrientation);
8684 #endif
8685 }
8686
8687 Eina_Bool ewk_view_webapp_capable_get(const Evas_Object *ewkView)
8688 {
8689 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
8690     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
8691     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
8692
8693     if (!priv->mainFrame || !priv->mainFrame->document())
8694         return 0;
8695
8696     RefPtr<WebCore::NodeList> nodeList = priv->mainFrame->document()->getElementsByTagName("meta");
8697     for (unsigned i = 0; i < nodeList->length(); i++) {
8698         WebCore::HTMLMetaElement* metaElement = static_cast<WebCore::HTMLMetaElement*>(nodeList->item(i));
8699         if (metaElement->name() == "apple-mobile-web-app-capable")
8700             return metaElement->content() == "yes" ? true : false;
8701     }
8702 #endif
8703     return false;
8704 }
8705
8706 char* ewk_view_webapp_icon_get(const Evas_Object *ewkView)
8707 {
8708 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
8709     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
8710     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
8711
8712     if (!priv->mainFrame || !priv->mainFrame->document())
8713         return 0;
8714
8715     RefPtr<WebCore::NodeList> nodeList = priv->mainFrame->document()->getElementsByTagName("link");
8716     for (unsigned i = 0; i < nodeList->length(); i++) {
8717         WebCore::HTMLLinkElement* linkElement = static_cast<WebCore::HTMLLinkElement*>(nodeList->item(i));
8718         if (linkElement->rel() == "apple-touch-icon" || linkElement->rel() == "apple-touch-icon-precomposed")
8719             return strdup(linkElement->href().string().utf8().data());
8720     }
8721 #endif
8722     return 0;
8723 }
8724
8725 #if USE(ACCELERATED_COMPOSITING)
8726 bool ewk_view_accelerated_compositing_object_create(Evas_Object* ewkView, Evas_Native_Surface* nativeSurface, const WebCore::IntRect& rect)
8727 {
8728     notImplemented();
8729     return false;
8730 }
8731
8732 WebCore::GraphicsContext3D* ewk_view_accelerated_compositing_context_get(Evas_Object* ewkView)
8733 {
8734     EWK_VIEW_SD_GET(ewkView, smartData);
8735     EWK_VIEW_PRIV_GET(smartData, priv);
8736
8737     ewk_view_compositor_create(ewkView);
8738
8739     return (priv->compositor ? priv->compositor->context() : 0);
8740 }
8741 #endif
8742
8743 Eina_Bool ewk_view_setting_web_audio_get(const Evas_Object* ewkView)
8744 {
8745 #if ENABLE(WEB_AUDIO)
8746     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
8747     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
8748     return priv->settings.webAudio;
8749 #else
8750     return false;
8751 #endif
8752 }
8753
8754 Eina_Bool ewk_view_setting_web_audio_set(Evas_Object* ewkView, Eina_Bool enable)
8755 {
8756 #if ENABLE(WEB_AUDIO)
8757     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
8758     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
8759     if (priv->settings.webAudio != enable) {
8760         priv->pageSettings->setWebAudioEnabled(enable);
8761         priv->settings.webAudio = enable;
8762     }
8763     return true;
8764 #else
8765     return false;
8766 #endif
8767 }
8768
8769 void ewk_view_cursor_set(Evas_Object* ewkView, const WebCore::Cursor& cursor)
8770 {
8771     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
8772     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
8773
8774     const char* group = cursor.platformCursor();
8775     if (!group || group == priv->cursorGroup)
8776         return;
8777
8778     priv->cursorGroup = group;
8779
8780     if (priv->cursorObject)
8781         evas_object_del(priv->cursorObject);
8782     priv->cursorObject = edje_object_add(smartData->base.evas);
8783
8784     Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(smartData->base.evas);
8785     if (!priv->settings.theme || !edje_object_file_set(priv->cursorObject, priv->settings.theme, group)) {
8786         evas_object_del(priv->cursorObject);
8787         priv->cursorObject = 0;
8788
8789         ecore_evas_object_cursor_set(ecoreEvas, 0, 0, 0, 0);
8790 #ifdef HAVE_ECORE_X
8791         if (priv->isUsingEcoreX)
8792             WebCore::applyFallbackCursor(ecoreEvas, group);
8793 #endif
8794     } else {
8795         Evas_Coord width, height;
8796         edje_object_size_min_get(priv->cursorObject, &width, &height);
8797         if (width <= 0 || height <= 0)
8798             edje_object_size_min_calc(priv->cursorObject, &width, &height);
8799         if (width <= 0 || height <= 0) {
8800             width = 16;
8801             height = 16;
8802         }
8803         evas_object_resize(priv->cursorObject, width, height);
8804
8805         const char* data;
8806         int hotspotX = 0;
8807         data = edje_object_data_get(priv->cursorObject, "hot.x");
8808         if (data)
8809             hotspotX = atoi(data);
8810
8811         int hotspotY = 0;
8812         data = edje_object_data_get(priv->cursorObject, "hot.y");
8813         if (data)
8814             hotspotY = atoi(data);
8815
8816         ecore_evas_object_cursor_set(ecoreEvas, priv->cursorObject, EVAS_LAYER_MAX, hotspotX, hotspotY);
8817     }
8818 }
8819
8820 namespace EWKPrivate {
8821
8822 WebCore::Page* corePage(const Evas_Object* ewkView)
8823 {
8824     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
8825     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
8826     return priv->page.get();
8827 }
8828
8829 PlatformPageClient corePageClient(Evas_Object* ewkView)
8830 {
8831     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
8832     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
8833     return priv->pageClient.get();
8834 }
8835
8836 } // namespace EWKPrivate