2 Copyright (C) 2011 Samsung Electronics
3 Copyright (C) 2012 Intel Corporation. All rights reserved.
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
23 #include "ewk_view_private.h"
26 #include "FindClientEfl.h"
27 #include "FormClientEfl.h"
28 #include "InputMethodContextEfl.h"
29 #include "PageLoadClientEfl.h"
30 #include "PagePolicyClientEfl.h"
31 #include "PageUIClientEfl.h"
32 #include "PageViewportController.h"
33 #include "PageViewportControllerClientEfl.h"
34 #include "ewk_back_forward_list_private.h"
35 #include "ewk_context.h"
36 #include "ewk_context_private.h"
37 #include "ewk_favicon_database_private.h"
38 #include "ewk_page_group.h"
39 #include "ewk_page_group_private.h"
40 #include "ewk_private.h"
41 #include "ewk_settings_private.h"
42 #include <Ecore_Evas.h>
43 #include <JavaScriptCore/JSRetainPtr.h>
44 #include <WebKit2/WKAPICast.h>
45 #include <WebKit2/WKData.h>
46 #include <WebKit2/WKEinaSharedString.h>
47 #include <WebKit2/WKFindOptions.h>
48 #include <WebKit2/WKInspector.h>
49 #include <WebKit2/WKPageGroup.h>
50 #include <WebKit2/WKRetainPtr.h>
51 #include <WebKit2/WKSerializedScriptValue.h>
52 #include <WebKit2/WKString.h>
53 #include <WebKit2/WKURL.h>
54 #include <WebKit2/WKView.h>
55 #include <wtf/text/CString.h>
58 #include "WebInspectorProxy.h"
61 using namespace WebKit;
63 static inline EwkView* toEwkViewChecked(const Evas_Object* evasObject)
65 EINA_SAFETY_ON_NULL_RETURN_VAL(evasObject, nullptr);
66 if (EINA_UNLIKELY(!isEwkViewEvasObject(evasObject)))
69 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(evasObject));
70 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData, nullptr);
72 return smartData->priv;
75 #define EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, ...) \
76 EwkView* impl = toEwkViewChecked(ewkView); \
78 if (EINA_UNLIKELY(!impl)) { \
79 EINA_LOG_CRIT("no private data for object %p", ewkView); \
85 Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
87 EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
89 return EwkView::initSmartClassInterface(*api);
92 Evas_Object* EWKViewCreate(WKContextRef context, WKPageGroupRef pageGroup, Evas* canvas, Evas_Smart* smart)
94 WKRetainPtr<WKViewRef> wkView = adoptWK(WKViewCreate(context, pageGroup));
95 if (EwkView* ewkView = EwkView::create(wkView.get(), canvas, smart))
96 return ewkView->evasObject();
101 WKViewRef EWKViewGetWKView(Evas_Object* ewkView)
103 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, nullptr);
105 return impl->wkView();
108 Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context, Ewk_Page_Group* pageGroup)
110 EwkContext* ewkContext = ewk_object_cast<EwkContext*>(context);
111 EwkPageGroup* ewkPageGroup = ewk_object_cast<EwkPageGroup*>(pageGroup);
113 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, nullptr);
114 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext->wkContext(), nullptr);
115 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkPageGroup, nullptr);
116 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkPageGroup->wkPageGroup(), nullptr);
118 return EWKViewCreate(ewkContext->wkContext(), ewkPageGroup->wkPageGroup(), canvas, smart);
121 Evas_Object* ewk_view_add(Evas* canvas)
123 return EWKViewCreate(adoptWK(WKContextCreate()).get(), 0, canvas, 0);
126 Evas_Object* ewk_view_add_with_context(Evas* canvas, Ewk_Context* context)
128 EwkContext* ewkContext = ewk_object_cast<EwkContext*>(context);
129 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, nullptr);
130 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext->wkContext(), nullptr);
132 return EWKViewCreate(ewkContext->wkContext(), 0, canvas, 0);
135 Ewk_Context* ewk_view_context_get(const Evas_Object* ewkView)
137 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, nullptr);
139 return impl->ewkContext();
142 Ewk_Page_Group* ewk_view_page_group_get(const Evas_Object* ewkView)
144 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, nullptr);
146 return impl->ewkPageGroup();
149 Eina_Bool ewk_view_url_set(Evas_Object* ewkView, const char* url)
151 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
152 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
154 WKRetainPtr<WKURLRef> wkUrl = adoptWK(WKURLCreateWithUTF8CString(url));
155 WKPageLoadURL(impl->wkPage(), wkUrl.get());
156 impl->informURLChange();
161 const char* ewk_view_url_get(const Evas_Object* ewkView)
163 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, nullptr);
168 Evas_Object* ewk_view_favicon_get(const Evas_Object* ewkView)
170 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, nullptr);
172 return impl->createFavicon();
175 Eina_Bool ewk_view_reload(Evas_Object* ewkView)
177 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
179 WKPageReload(impl->wkPage());
180 impl->informURLChange();
185 Eina_Bool ewk_view_reload_bypass_cache(Evas_Object* ewkView)
187 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
189 WKPageReloadFromOrigin(impl->wkPage());
190 impl->informURLChange();
195 Eina_Bool ewk_view_stop(Evas_Object* ewkView)
197 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
199 WKPageStopLoading(impl->wkPage());
204 Ewk_Settings* ewk_view_settings_get(const Evas_Object* ewkView)
206 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, nullptr);
208 return impl->settings();
211 const char* ewk_view_title_get(const Evas_Object* ewkView)
213 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, nullptr);
215 return impl->title();
218 double ewk_view_load_progress_get(const Evas_Object* ewkView)
220 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, -1.0);
222 return WKPageGetEstimatedProgress(impl->wkPage());
225 Eina_Bool ewk_view_scale_set(Evas_Object* ewkView, double scaleFactor, int x, int y)
227 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
229 WKPageSetScaleFactor(impl->wkPage(), scaleFactor, WKPointMake(x, y));
233 double ewk_view_scale_get(const Evas_Object* ewkView)
235 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, -1);
237 return WKPageGetScaleFactor(impl->wkPage());
240 Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object* ewkView, float ratio)
242 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
244 impl->setDeviceScaleFactor(ratio);
249 float ewk_view_device_pixel_ratio_get(const Evas_Object* ewkView)
251 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, -1.0);
253 return WKPageGetBackingScaleFactor(impl->wkPage());
256 void ewk_view_theme_set(Evas_Object* ewkView, const char* path)
258 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
260 impl->setThemePath(path);
263 const char* ewk_view_theme_get(const Evas_Object* ewkView)
265 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, nullptr);
267 return impl->themePath();
270 Eina_Bool ewk_view_back(Evas_Object* ewkView)
272 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
274 WKPageRef page = impl->wkPage();
275 if (WKPageCanGoBack(page)) {
283 Eina_Bool ewk_view_forward(Evas_Object* ewkView)
285 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
287 WKPageRef page = impl->wkPage();
288 if (WKPageCanGoForward(page)) {
289 WKPageGoForward(page);
296 Eina_Bool ewk_view_back_possible(Evas_Object* ewkView)
298 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
299 return WKPageCanGoBack(impl->wkPage());
302 Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView)
304 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
305 return WKPageCanGoForward(impl->wkPage());
308 Ewk_Back_Forward_List* ewk_view_back_forward_list_get(const Evas_Object* ewkView)
310 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, nullptr);
312 return impl->backForwardList();
315 Eina_Bool ewk_view_navigate_to(Evas_Object* ewkView, const Ewk_Back_Forward_List_Item* item)
317 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
318 EWK_OBJ_GET_IMPL_OR_RETURN(const EwkBackForwardListItem, item, itemImpl, false);
320 WKPageGoToBackForwardListItem(impl->wkPage(), itemImpl->wkItem());
325 Eina_Bool ewk_view_html_string_load(Evas_Object* ewkView, const char* html, const char* baseUrl, const char* unreachableUrl)
327 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
328 EINA_SAFETY_ON_NULL_RETURN_VAL(html, false);
330 WKRetainPtr<WKStringRef> wkHTMLString = adoptWK(WKStringCreateWithUTF8CString(html));
331 WKRetainPtr<WKURLRef> wkBaseURL = adoptWK(WKURLCreateWithUTF8CString(baseUrl));
333 if (unreachableUrl && *unreachableUrl) {
334 WKRetainPtr<WKURLRef> wkUnreachableURL = adoptWK(WKURLCreateWithUTF8CString(unreachableUrl));
335 WKPageLoadAlternateHTMLString(impl->wkPage(), wkHTMLString.get(), wkBaseURL.get(), wkUnreachableURL.get());
337 WKPageLoadHTMLString(impl->wkPage(), wkHTMLString.get(), wkBaseURL.get());
339 impl->informURLChange();
344 const char* ewk_view_custom_encoding_get(const Evas_Object* ewkView)
346 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, nullptr);
348 return impl->customTextEncodingName();
351 Eina_Bool ewk_view_custom_encoding_set(Evas_Object* ewkView, const char* encoding)
353 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
355 impl->setCustomTextEncodingName(encoding);
360 const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
362 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, nullptr);
364 return impl->userAgent();
367 Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* userAgent)
369 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
371 impl->setUserAgent(userAgent);
376 inline WKFindOptions toWKFindOptions(Ewk_Find_Options options)
378 unsigned wkFindOptions = 0;
380 if (options & EWK_FIND_OPTIONS_CASE_INSENSITIVE)
381 wkFindOptions |= kWKFindOptionsCaseInsensitive;
382 if (options & EWK_FIND_OPTIONS_AT_WORD_STARTS)
383 wkFindOptions |= kWKFindOptionsAtWordStarts;
384 if (options & EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START)
385 wkFindOptions |= kWKFindOptionsTreatMedialCapitalAsWordStart;
386 if (options & EWK_FIND_OPTIONS_BACKWARDS)
387 wkFindOptions |= kWKFindOptionsBackwards;
388 if (options & EWK_FIND_OPTIONS_WRAP_AROUND)
389 wkFindOptions |= kWKFindOptionsWrapAround;
390 if (options & EWK_FIND_OPTIONS_SHOW_OVERLAY)
391 wkFindOptions |= kWKFindOptionsShowOverlay;
392 if (options & EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR)
393 wkFindOptions |= kWKFindOptionsShowFindIndicator;
394 if (options & EWK_FIND_OPTIONS_SHOW_HIGHLIGHT)
395 wkFindOptions |= kWKFindOptionsShowHighlight;
397 return static_cast<WKFindOptions>(wkFindOptions);
400 Eina_Bool ewk_view_text_find(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount)
402 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
403 EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
405 WKRetainPtr<WKStringRef> wkText = adoptWK(WKStringCreateWithUTF8CString(text));
406 WKPageFindString(impl->wkPage(), wkText.get(), toWKFindOptions(options), maxMatchCount);
411 Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object* ewkView)
413 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
415 WKPageHideFindUI(impl->wkPage());
420 Eina_Bool ewk_view_text_matches_count(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount)
422 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
423 EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
425 WKRetainPtr<WKStringRef> wkText = adoptWK(WKStringCreateWithUTF8CString(text));
426 WKPageCountStringMatches(impl->wkPage(), wkText.get(), static_cast<WebKit::FindOptions>(options), maxMatchCount);
431 Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
433 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
435 impl->setMouseEventsEnabled(!!enabled);
440 Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object* ewkView)
442 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
444 return impl->mouseEventsEnabled();
447 Eina_Bool ewk_view_feed_touch_event(Evas_Object* ewkView, Ewk_Touch_Event_Type type, const Eina_List* points, const Evas_Modifier* modifiers)
449 #if ENABLE(TOUCH_EVENTS)
450 EINA_SAFETY_ON_NULL_RETURN_VAL(points, false);
451 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
453 impl->feedTouchEvent(type, points, modifiers);
457 UNUSED_PARAM(ewkView);
459 UNUSED_PARAM(points);
460 UNUSED_PARAM(modifiers);
465 Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
467 #if ENABLE(TOUCH_EVENTS)
468 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
470 impl->setTouchEventsEnabled(!!enabled);
474 UNUSED_PARAM(ewkView);
475 UNUSED_PARAM(enabled);
480 Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object* ewkView)
482 #if ENABLE(TOUCH_EVENTS)
483 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
485 return impl->touchEventsEnabled();
487 UNUSED_PARAM(ewkView);
492 Eina_Bool ewk_view_inspector_show(Evas_Object* ewkView)
494 #if ENABLE(INSPECTOR)
495 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
497 WKInspectorRef wkInspector = WKPageGetInspector(impl->wkPage());
499 WKInspectorShow(wkInspector);
503 UNUSED_PARAM(ewkView);
508 Eina_Bool ewk_view_inspector_close(Evas_Object* ewkView)
510 #if ENABLE(INSPECTOR)
511 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
513 WKInspectorRef wkInspector = WKPageGetInspector(impl->wkPage());
515 WKInspectorClose(wkInspector);
519 UNUSED_PARAM(ewkView);
524 inline WKPaginationMode toWKPaginationMode(Ewk_Pagination_Mode mode)
527 case EWK_PAGINATION_MODE_INVALID:
529 case EWK_PAGINATION_MODE_UNPAGINATED:
530 return kWKPaginationModeUnpaginated;
531 case EWK_PAGINATION_MODE_LEFT_TO_RIGHT:
532 return kWKPaginationModeLeftToRight;
533 case EWK_PAGINATION_MODE_RIGHT_TO_LEFT:
534 return kWKPaginationModeRightToLeft;
535 case EWK_PAGINATION_MODE_TOP_TO_BOTTOM:
536 return kWKPaginationModeTopToBottom;
537 case EWK_PAGINATION_MODE_BOTTOM_TO_TOP:
538 return kWKPaginationModeBottomToTop;
540 ASSERT_NOT_REACHED();
542 return kWKPaginationModeUnpaginated;
545 inline Ewk_Pagination_Mode toEwkPaginationMode(WKPaginationMode mode)
548 case kWKPaginationModeUnpaginated:
549 return EWK_PAGINATION_MODE_UNPAGINATED;
550 case kWKPaginationModeLeftToRight:
551 return EWK_PAGINATION_MODE_LEFT_TO_RIGHT;
552 case kWKPaginationModeRightToLeft:
553 return EWK_PAGINATION_MODE_RIGHT_TO_LEFT;
554 case kWKPaginationModeTopToBottom:
555 return EWK_PAGINATION_MODE_TOP_TO_BOTTOM;
556 case kWKPaginationModeBottomToTop:
557 return EWK_PAGINATION_MODE_BOTTOM_TO_TOP;
559 ASSERT_NOT_REACHED();
561 return EWK_PAGINATION_MODE_UNPAGINATED;
564 Eina_Bool ewk_view_pagination_mode_set(Evas_Object* ewkView, Ewk_Pagination_Mode mode)
566 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
568 WKPageSetPaginationMode(impl->wkPage(), toWKPaginationMode(mode));
573 Ewk_Pagination_Mode ewk_view_pagination_mode_get(const Evas_Object* ewkView)
575 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EWK_PAGINATION_MODE_INVALID);
577 return toEwkPaginationMode(WKPageGetPaginationMode(impl->wkPage()));
580 Eina_Bool ewk_view_fullscreen_exit(Evas_Object* ewkView)
582 #if ENABLE(FULLSCREEN_API)
583 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
585 return WKViewExitFullScreen(impl->wkView());
587 UNUSED_PARAM(ewkView);
592 void ewk_view_draws_page_background_set(Evas_Object *ewkView, Eina_Bool enabled)
594 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
596 WKViewSetDrawsBackground(impl->wkView(), enabled);
599 /// Creates a type name for Ewk_Page_Contents_Context.
600 typedef struct Ewk_Page_Contents_Context Ewk_Page_Contents_Context;
603 * @brief Structure containing page contents context used for ewk_view_page_contents_get() API.
605 struct Ewk_Page_Contents_Context {
606 Ewk_Page_Contents_Type type;
607 Ewk_Page_Contents_Cb callback;
613 * Callback function used for ewk_view_page_contents_get().
615 static void ewkViewPageContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
617 EINA_SAFETY_ON_NULL_RETURN(context);
619 auto contentsContext = std::unique_ptr<Ewk_Page_Contents_Context>(static_cast<Ewk_Page_Contents_Context*>(context));
620 contentsContext->callback(contentsContext->type, reinterpret_cast<const char*>(WKDataGetBytes(wkData)), contentsContext->userData);
625 * Callback function used for ewk_view_page_contents_get().
627 static void ewkViewPageContentsAsStringCallback(WKStringRef wkString, WKErrorRef, void* context)
629 EINA_SAFETY_ON_NULL_RETURN(context);
631 auto contentsContext = std::unique_ptr<Ewk_Page_Contents_Context>(static_cast<Ewk_Page_Contents_Context*>(context));
632 contentsContext->callback(contentsContext->type, WKEinaSharedString(wkString), contentsContext->userData);
635 Eina_Bool ewk_view_page_contents_get(const Evas_Object* ewkView, Ewk_Page_Contents_Type type, Ewk_Page_Contents_Cb callback, void* user_data)
637 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
638 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
640 Ewk_Page_Contents_Context* context = new Ewk_Page_Contents_Context;
641 context->type = type;
642 context->callback = callback;
643 context->userData = user_data;
645 switch (context->type) {
646 case EWK_PAGE_CONTENTS_TYPE_MHTML:
647 WKPageGetContentsAsMHTMLData(impl->wkPage(), false, context, ewkViewPageContentsAsMHTMLCallback);
649 case EWK_PAGE_CONTENTS_TYPE_STRING:
650 WKPageGetContentsAsString(impl->wkPage(), context, ewkViewPageContentsAsStringCallback);
654 ASSERT_NOT_REACHED();
661 struct Ewk_View_Script_Execute_Callback_Context {
662 Ewk_View_Script_Execute_Callback_Context(Ewk_View_Script_Execute_Cb callback, Evas_Object* ewkView, void* userData)
663 : m_callback(callback)
665 , m_userData(userData)
669 Ewk_View_Script_Execute_Cb m_callback;
674 static void runJavaScriptCallback(WKSerializedScriptValueRef scriptValue, WKErrorRef, void* context)
678 auto callbackContext = std::unique_ptr<Ewk_View_Script_Execute_Callback_Context>(static_cast<Ewk_View_Script_Execute_Callback_Context*>(context));
679 ASSERT(callbackContext->m_view);
681 if (!callbackContext->m_callback)
685 EWK_VIEW_IMPL_GET_OR_RETURN(callbackContext->m_view, impl);
686 JSGlobalContextRef jsGlobalContext = impl->ewkContext()->jsGlobalContext();
688 JSValueRef value = WKSerializedScriptValueDeserialize(scriptValue, jsGlobalContext, 0);
689 JSRetainPtr<JSStringRef> jsStringValue(Adopt, JSValueToStringCopy(jsGlobalContext, value, 0));
690 size_t length = JSStringGetMaximumUTF8CStringSize(jsStringValue.get());
691 auto buffer = std::make_unique<char[]>(length);
692 JSStringGetUTF8CString(jsStringValue.get(), buffer.get(), length);
693 callbackContext->m_callback(callbackContext->m_view, buffer.get(), callbackContext->m_userData);
695 callbackContext->m_callback(callbackContext->m_view, 0, callbackContext->m_userData);
698 Eina_Bool ewk_view_script_execute(Evas_Object* ewkView, const char* script, Ewk_View_Script_Execute_Cb callback, void* userData)
700 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
701 EINA_SAFETY_ON_NULL_RETURN_VAL(script, false);
703 Ewk_View_Script_Execute_Callback_Context* context = new Ewk_View_Script_Execute_Callback_Context(callback, ewkView, userData);
704 WKRetainPtr<WKStringRef> scriptString(AdoptWK, WKStringCreateWithUTF8CString(script));
705 WKPageRunJavaScriptInMainFrame(impl->wkPage(), scriptString.get(), context, runJavaScriptCallback);
709 Eina_Bool ewk_view_layout_fixed_set(Evas_Object* ewkView, Eina_Bool enabled)
711 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
713 WKPageSetUseFixedLayout(WKViewGetPage(impl->wkView()), enabled);
718 Eina_Bool ewk_view_layout_fixed_get(const Evas_Object* ewkView)
720 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
722 return WKPageUseFixedLayout(WKViewGetPage(impl->wkView()));