diff options
Diffstat (limited to 'Source/WebKit2')
108 files changed, 5083 insertions, 168 deletions
diff --git a/Source/WebKit2/CMakeLists.txt b/Source/WebKit2/CMakeLists.txt index 384d7e6de..104956641 100644 --- a/Source/WebKit2/CMakeLists.txt +++ b/Source/WebKit2/CMakeLists.txt @@ -45,6 +45,8 @@ SET(WebKit2_INCLUDE_DIRECTORIES "${WEBCORE_DIR}" "${WEBCORE_DIR}/Modules/battery" "${WEBCORE_DIR}/Modules/intents" + "${WEBCORE_DIR}/Modules/networkinfo" + "${WEBCORE_DIR}/Modules/vibration" "${WEBCORE_DIR}/accessibility" "${WEBCORE_DIR}/bindings/js" "${WEBCORE_DIR}/bindings" @@ -67,6 +69,8 @@ SET(WebKit2_INCLUDE_DIRECTORIES "${WEBCORE_DIR}/platform/animation" "${WEBCORE_DIR}/platform/graphics" "${WEBCORE_DIR}/platform/graphics/filters" + "${WEBCORE_DIR}/platform/graphics/harfbuzz" + "${WEBCORE_DIR}/platform/graphics/harfbuzz/ng" "${WEBCORE_DIR}/platform/graphics/transforms" "${WEBCORE_DIR}/platform/network" "${WEBCORE_DIR}/platform/sql" @@ -94,6 +98,7 @@ SET(WebKit2_INCLUDE_DIRECTORIES "${JAVASCRIPTCORE_DIR}/runtime" "${WTF_DIR}" "${DERIVED_SOURCES_DIR}" + "${DERIVED_SOURCES_DIR}/ForwardingHeaders" "${DERIVED_SOURCES_WEBCORE_DIR}" "${DERIVED_SOURCES_WEBKIT2_DIR}" "${DERIVED_SOURCES_WEBKIT2_DIR}/include" @@ -367,7 +372,9 @@ SET(WebKit2_SOURCES WebProcess/InjectedBundle/InjectedBundleClient.cpp WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.cpp WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp + WebProcess/InjectedBundle/InjectedBundleIntentRequest.cpp WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp + WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.cpp WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.cpp WebProcess/InjectedBundle/InjectedBundlePageEditorClient.cpp WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp @@ -385,6 +392,7 @@ SET(WebKit2_SOURCES WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp + WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.cpp WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp WebProcess/InjectedBundle/API/c/WKBundlePage.cpp @@ -540,8 +548,21 @@ SET(WebProcess_LIBRARIES ${WebKit2_LIBRARY_NAME} ) +SET(WebKit2_LIBRARIES + ${WebCore_LIBRARY_NAME} +) + +SET(WebKit2_FORWARDING_HEADERS_DIRECTORIES + Shared/API/c + UIProcess/API/C + UIProcess/API/cpp + WebProcess/InjectedBundle/API/c +) + WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS() +WEBKIT_CREATE_FORWARDING_HEADERS(WebKit2 DIRECTORIES ${WebKit2_FORWARDING_HEADERS_DIRECTORIES}) + # Create JavaScript C++ code given an IDL input FOREACH (_file ${WebKit2_MESSAGES_IN_FILES}) GET_FILENAME_COMPONENT (_name ${_file} NAME_WE) @@ -556,17 +577,11 @@ FOREACH (_file ${WebKit2_MESSAGES_IN_FILES}) LIST(APPEND WebKit2_SOURCES ${DERIVED_SOURCES_WEBKIT2_DIR}/${_name}MessageReceiver.cpp) ENDFOREACH () -SET(WebKit2_LIBRARIES - ${WebCore_LIBRARY_NAME} -) - ADD_DEFINITIONS(-DBUILDING_WEBKIT) INCLUDE_DIRECTORIES(${WebKit2_INCLUDE_DIRECTORIES}) ADD_LIBRARY(${WebKit2_LIBRARY_NAME} ${WebKit2_LIBRARY_TYPE} ${WebKit2_SOURCES}) ADD_DEPENDENCIES(${WebKit2_LIBRARY_NAME} ${WebCore_LIBRARY_NAME}) -ADD_DEPENDENCIES(${WebKit2_LIBRARY_NAME} ${ForwardingHeaders_NAME}) -ADD_DEPENDENCIES(${WebKit2_LIBRARY_NAME} ${ForwardingNetworkHeaders_NAME}) TARGET_LINK_LIBRARIES(${WebKit2_LIBRARY_NAME} ${WebKit2_LIBRARIES}) SET_TARGET_PROPERTIES(${WebKit2_LIBRARY_NAME} PROPERTIES FOLDER "WebKit") SET_TARGET_PROPERTIES(${WebKit2_LIBRARY_NAME} PROPERTIES LINK_INTERFACE_LIBRARIES "") diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog index 808b60f2b..b8fec0cf1 100644 --- a/Source/WebKit2/ChangeLog +++ b/Source/WebKit2/ChangeLog @@ -1,3 +1,1166 @@ +2012-07-29 Vsevolod Vlasov <vsevik@chromium.org> + + Web Inspector: Resource agent's reference to cached resources should be weak. + https://bugs.webkit.org/show_bug.cgi?id=92108 + + Reviewed by Pavel Feldman. + + * win/WebKit2.def: + * win/WebKit2CFLite.def: + +2012-07-29 YoungTaeck Song <youngtaeck.song@samsung.com> + + [WK2][EFL] TILED_BACKING_STORE support on Efl WebKit2 + https://bugs.webkit.org/show_bug.cgi?id=91582 + + Reviewed by Noam Rosenthal. + + This patch is a subset of Efl's UI_SIDE_COMPOSITING implementation. + Add a dummy function for fixing building error when enabling TILED_BACKING_STORE. + + * UIProcess/API/efl/PageClientImpl.cpp: + (WebKit): + (WebKit::PageClientImpl::pageDidRequestScroll): + * UIProcess/API/efl/PageClientImpl.h: + (PageClientImpl): + * WebProcess/WebCoreSupport/WebChromeClient.cpp: + (WebKit::WebChromeClient::contentsSizeChanged): + +2012-07-29 Patrick Gansterer <paroga@webkit.org> + + [CMake] Use WEBKIT_CREATE_FORWARDING_HEADERS to generate WK2 forwarding headers + https://bugs.webkit.org/show_bug.cgi?id=83579 + + Reviewed by Daniel Bates. + + Using a list of directories in combination with the WEBKIT_CREATE_FORWARDING_HEADERS + macro allows us to share the common generation of forwarding headers across ports. + + * CMakeLists.txt: + * PlatformEfl.cmake: + +2012-07-28 Sam Weinig <sam@webkit.org> + + Stop copying unnecessary files in WebKit2 build + https://bugs.webkit.org/show_bug.cgi?id=92587 + + Reviewed by Dan Bernstein. + + * WebKit2.xcodeproj/project.pbxproj: + We were accidentally copying ColorSpaceData.h and EventDispatcher.messages.in into the + build products. Stop this. + +2012-07-28 Ryuan Choi <ryuan.choi@samsung.com> + + [WK2][EFL] Add ewk_view_scale_{get|set} to EwkView. + https://bugs.webkit.org/show_bug.cgi?id=92446 + + Reviewed by Kenneth Rohde Christiansen. + + Add methods to Ewk_View to get or set the scale factor of page. + + * UIProcess/API/efl/ewk_view.cpp: + (ewk_view_scale_set): + (ewk_view_scale_get): + * UIProcess/API/efl/ewk_view.h: + +2012-07-28 Mario Sanchez Prada <msanchez@igalia.com> + + [WK2][GTK] Implement a new spell checker API for WebKit2GTK+ + https://bugs.webkit.org/show_bug.cgi?id=90268 + + Reviewed by Martin Robinson. + + Add a simple spell checking API to WK2, allowing to enable/disable + this feature and to define a list of languages associated to it. + + * GNUmakefile.am: Add flags to handle the SPELLCHECK feature. + * GNUmakefile.list.am: Added new files + + Added new internal class that will act both as the implementation + of TextCheckerClient and as the object WebKitWebContext will + depend on to implement the newly added API. + + * UIProcess/API/gtk/WebKitTextChecker.cpp: Added. + (toTextChecker): + (continuousSpellCheckingEnabledCallback): + (setContinuousSpellCheckingEnabledCallback): + (checkSpellingOfStringCallback): + (guessesForWordCallback): + (learnWordCallback): + (ignoreWordCallback): + (WebKitTextChecker::~WebKitTextChecker): + (WebKitTextChecker::create): + (WebKitTextChecker::WebKitTextChecker): + (WebKitTextChecker::checkSpellingOfString): + (WebKitTextChecker::getGuessesForWord): + (WebKitTextChecker::learnWord): + (WebKitTextChecker::ignoreWord): + (WebKitTextChecker::setSpellCheckingEnabled): + (WebKitTextChecker::setSpellCheckingLanguages): + * UIProcess/API/gtk/WebKitTextChecker.h: Added. + (WebKitTextChecker): + (WebKitTextChecker::isSpellCheckingEnabled): + (WebKitTextChecker::getSpellCheckingLanguages): + + Added WKTextChecker to WebKitPrivate.h, needed in WebKitTextChecker. + + * UIProcess/API/gtk/WebKitPrivate.h: + + Add new API to WebKitWebContext to allow enabling/disabling this + spell checking feature, and to set/get the list of languages used + to decide which dictionaries will be consulted. + + * UIProcess/API/gtk/WebKitWebContext.cpp: + (_WebKitWebContextPrivate): + (createDefaultWebContext): + (webkit_web_context_get_spell_checking_enabled): New API. + (webkit_web_context_set_spell_checking_enabled): Ditto. + (webkit_web_context_get_spell_checking_languages): Ditto. + (webkit_web_context_set_spell_checking_languages): Ditto. + * UIProcess/API/gtk/WebKitWebContext.h: + + New tests for checking the new API added to WebKitWebContext. + + * UIProcess/API/gtk/tests/TestWebKitWebContext.cpp: + (testWebContextSpellChecker): + (beforeAll): + + Update documentation with new sections and symbols. + + * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: + * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: + +2012-07-27 Christophe Dumez <christophe.dumez@intel.com> + + [EFL][WK2] Assertion hit in ewk_cookie_manager.cpp + https://bugs.webkit.org/show_bug.cgi?id=92544 + + Reviewed by Kenneth Rohde Christiansen. + + Removed wrong assertion in ewk_cookie_manager.cpp + and replace it by an if check. The assertion was + sometimes hit by our unit tests. + + * UIProcess/API/efl/ewk_cookie_manager.cpp: + (cookiesDidChange): + +2012-07-27 Anders Carlsson <andersca@apple.com> + + Don't use an NSUserDefault for disabling the web process sandbox + https://bugs.webkit.org/show_bug.cgi?id=92542 + <rdar://problem/11976060> + + Reviewed by Mark Rowe. + + The user default was really helpful during WebKit2 bringup, but we no longer need to pay the IPC cost of initializing NSUserDefaults at startup, + so get rid of the preference and use a good old #ifdef instead. + + * WebProcess/mac/WebProcessMac.mm: + (WebKit::initializeSandbox): + +2012-07-27 Christophe Dumez <christophe.dumez@intel.com> + + [WK2][WTR] LayoutTestController.deliverWebIntent() needs to be implemented + https://bugs.webkit.org/show_bug.cgi?id=92228 + + Reviewed by Anders Carlsson. + + Add C API to create a WKIntentData and to deliver + it to a frame. This is needed by WebKitTestRunner + to implement LayoutTestController.deliverWebIntent(). + + * UIProcess/API/C/WKIntentData.cpp: + (WKIntentDataCreate): + * UIProcess/API/C/WKIntentData.h: + * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp: + (WKBundlePageDeliverIntentToFrame): + * WebProcess/InjectedBundle/API/c/WKBundlePage.h: + * WebProcess/WebPage/WebPage.h: + (WebPage): Make deliverIntentToFrame() public so that it can + be used by WKBundlePage. + +2012-07-27 Anders Carlsson <andersca@apple.com> + + Show the unavailable plug-in indicator for Java applets as well + https://bugs.webkit.org/show_bug.cgi?id=92521 + + Reviewed by Sam Weinig. + + * WebProcess/WebCoreSupport/WebChromeClient.cpp: + (WebKit::WebChromeClient::unavailablePluginButtonClicked): + This can now be called on applet elements as well. + + * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: + (WebKit::WebFrameLoaderClient::createJavaAppletWidget): + Get the MIME type from the applet element. + +2012-07-27 Gyuyoung Kim <gyuyoung.kim@samsung.com> + + [WK2] Fix build warning in WebEventConversion.cpp + https://bugs.webkit.org/show_bug.cgi?id=92517 + + Reviewed by Darin Adler. + + There is a build warning related to comparison between signed and unsigned integer expressions. + + * Shared/WebEventConversion.cpp: + (WebKit::WebKit2PlatformTouchEvent::WebKit2PlatformTouchEvent): + +2012-07-27 Gyuyoung Kim <gyuyoung.kim@samsung.com> + + [WK2] Fix build warning in WebEventConversion.cpp + https://bugs.webkit.org/show_bug.cgi?id=92517 + + Reviewed by Darin Adler. + + There is a build warning related to comparison between signed and unsigned integer expressions. + + * Shared/WebEventConversion.cpp: + (WebKit::WebKit2PlatformTouchEvent::WebKit2PlatformTouchEvent): + +2012-07-27 Christophe Dumez <christophe.dumez@intel.com> + + [EFL][WK2] Add download client for Ewk_Context + https://bugs.webkit.org/show_bug.cgi?id=91345 + + Reviewed by Kenneth Rohde Christiansen. + + Add download client for Ewk_Context so that + information about downloads can be reported + to the client application via Ewk_View signals. + + The client application needs to listen for + "download,request" signal on the view and set + the download path for the download in the + callback in order to accept it. If the signal + is ignored or if the download path is not set + the download will fail. + + A new Ewk_Download_Job type is introduced to provide + information relative to a download to the client + and to allow the client to interact with it (e.g. + set its download path, cancel it, ...). + + * PlatformEfl.cmake: + * UIProcess/API/efl/EWebKit2.h: + * UIProcess/API/efl/PageClientImpl.cpp: + (WebKit::PageClientImpl::handleDownloadRequest): + (WebKit): + * UIProcess/API/efl/PageClientImpl.h: + (PageClientImpl): + * UIProcess/API/efl/ewk_context.cpp: + (_Ewk_Context): + (_Ewk_Context::_Ewk_Context): + (_Ewk_Context::~_Ewk_Context): + (ewk_context_download_job_add): + (ewk_context_download_job_get): + (ewk_context_download_job_remove): + * UIProcess/API/efl/ewk_context_download_client.cpp: Added. + (toEwkContext): + (decideDestinationWithSuggestedFilename): + (didReceiveResponse): + (didCreateDestination): + (didReceiveData): + (didFail): + (didCancel): + (didFinish): + (ewk_context_download_client_attach): + * UIProcess/API/efl/ewk_context_download_client_private.h: Added. + * UIProcess/API/efl/ewk_context_private.h: + * UIProcess/API/efl/ewk_download_job.cpp: Added. + (_Ewk_Download_Job): + (_Ewk_Download_Job::_Ewk_Download_Job): + (_Ewk_Download_Job::~_Ewk_Download_Job): + (ewk_download_job_ref): + (ewk_download_job_unref): + (ewk_download_job_id_get): + (ewk_download_job_view_get): + (ewk_download_job_state_get): + (ewk_download_job_request_get): + (ewk_download_job_response_get): + (ewk_download_job_destination_get): + (ewk_download_job_destination_set): + (ewk_download_job_suggested_filename_get): + (ewk_download_job_cancel): + (ewk_download_job_estimated_progress_get): + (ewk_download_job_elapsed_time_get): + (ewk_download_job_response_set): + (ewk_download_job_suggested_filename_set): + (ewk_download_job_received_data): + (ewk_download_job_state_set): + (ewk_download_job_new): + * UIProcess/API/efl/ewk_download_job.h: Added. + * UIProcess/API/efl/ewk_download_job_private.h: Added. + (WebKit): + * UIProcess/API/efl/ewk_url_response.cpp: + (ewk_url_response_content_length_get): Add a function to + retrieve the content length of a URL response. + * UIProcess/API/efl/ewk_url_response.h: + * UIProcess/API/efl/ewk_view.cpp: + (ewk_view_download_job_cancelled): + (ewk_view_download_job_requested): + (ewk_view_download_job_failed): + (ewk_view_download_job_finished): + * UIProcess/API/efl/ewk_view.h: + * UIProcess/API/efl/ewk_view_private.h: + * UIProcess/API/efl/tests/resources/test.pdf: Added. + * UIProcess/API/efl/tests/test_ewk2_download_job.cpp: Added. This tests + the download functionality. + (DownloadTestData): + (fileExists): + (serverCallback): + (on_download_requested): + (on_download_cancelled): + (on_download_failed): + (on_download_finished): + (TEST_F): + * UIProcess/PageClient.h: + (PageClient): + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::receivedPolicyDecision): + (WebKit): + (WebKit::WebPageProxy::handleDownloadRequest): + * UIProcess/WebPageProxy.h: + (WebPageProxy): + +2012-07-27 YoungTaeck Song <youngtaeck.song@samsung.com> + + [WK2][EFL] Add an ACCELERATED_COMPOSITING implementation for Efl WebKit2 + https://bugs.webkit.org/show_bug.cgi?id=91581 + + Reviewed by Noam Rosenthal. + + This patch is a subset of Efl's UI_SIDE_COMPOSITING implementation. + When enter accelerated compositing mode, create evas_gl, evas_gl_context, and evas_gl_surface. + + * PlatformEfl.cmake: + * Shared/LayerTreeContext.h: + (LayerTreeContext): + * UIProcess/API/efl/PageClientImpl.cpp: + (WebKit::PageClientImpl::viewSize): + (WebKit::PageClientImpl::enterAcceleratedCompositingMode): + (WebKit::PageClientImpl::exitAcceleratedCompositingMode): + * UIProcess/API/efl/ewk_view.cpp: + (_Ewk_View_Private_Data): + (_Ewk_View_Private_Data::_Ewk_View_Private_Data): + (ewk_view_size_get): + (ewk_view_create_gl_surface): + (ewk_view_enter_accelerated_compositing_mode): + (ewk_view_exit_accelerated_compositing_mode): + (_ewk_view_smart_calculate): + * UIProcess/API/efl/ewk_view_private.h: + +2012-07-27 Christophe Dumez <christophe.dumez@intel.com> + + [EFL][WK2] Add API to Ewk_Cookie_Manager to watch for cookie changes + https://bugs.webkit.org/show_bug.cgi?id=92484 + + Reviewed by Kenneth Rohde Christiansen. + + Add API tp Ewk_Cookie_Manager so that the client can watch + for cookie changes. + + * UIProcess/API/efl/ewk_cookie_manager.cpp: + * UIProcess/API/efl/ewk_cookie_manager.h: + * UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp: Add unit tests + for cookie changes watching. + +2012-07-27 Christophe Dumez <christophe.dumez@intel.com> + + [EFL][WK2] Stop using C API to interact with the page in Ewk_View + https://bugs.webkit.org/show_bug.cgi?id=92463 + + Reviewed by Simon Hausmann. + + Stop using C API to interact with the PageProxy in Ewk_View + and use the PageProxy object directly. This avoids useless + converting to WK type using toAPI() all the time. + + * UIProcess/API/efl/ewk_view.cpp: + (ewk_view_base_add): + (ewk_view_uri_update): + (ewk_view_uri_set): + (ewk_view_reload): + (ewk_view_reload_bypass_cache): + (ewk_view_stop): + (ewk_view_load_progress_get): + (ewk_view_device_pixel_ratio_set): + (ewk_view_theme_get): + (ewk_view_cursor_set): + (ewk_view_back): + (ewk_view_forward): + (ewk_view_intent_deliver): + (ewk_view_back_possible): + (ewk_view_forward_possible): + (ewk_view_setting_encoding_custom_get): + (ewk_view_setting_encoding_custom_set): + +2012-07-27 Dominik Röttsches <dominik.rottsches@intel.com> + + [Cairo] Add complex font drawing using HarfbuzzNG + https://bugs.webkit.org/show_bug.cgi?id=91864 + + Reviewed by Simon Hausmann and Martin Robinson. + + Adding includes for harfbuzz folders. + + * CMakeLists.txt: + +2012-07-27 Christophe Dumez <christophe.dumez@intel.com> + + [EFL][WK2] Add more Ewk_View unit tests + https://bugs.webkit.org/show_bug.cgi?id=92407 + + Reviewed by Kenneth Rohde Christiansen. + + Add more unit tests for WebKit2 Ewk_View API. + In particular, navigation, HTML loading and + device pixel ratio functions are now tested. + + * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp: + (EWK2UnitTest::EWK2UnitTestBase::SetUp): Call ewk_init() instead + of duplicating initialization code. + (EWK2UnitTest::EWK2UnitTestBase::TearDown): call ewk_shutdown(). + (TitleChangedData): + (EWK2UnitTest): + (EWK2UnitTest::onTitleChanged): + (EWK2UnitTest::EWK2UnitTestBase::waitUntilTitleChangedTo): Add convenience + method to wait until the view main frame title changes to a given value. + * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h: + (EWK2UnitTestBase): + * UIProcess/API/efl/tests/test_ewk2_view.cpp: + (TEST_F): + (serverCallbackNavigation): + +2012-07-27 Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com> + + [EFL][WK2] Keyboard events miss key location data. + https://bugs.webkit.org/show_bug.cgi?id=92235 + + Reviewed by Simon Hausmann. + + EFL WK2 did not initialize WebKeyboardEvent::m_isKeypad field. + This caused failure of fast/events/keydown-numpad-keys.html test. + + * Shared/efl/WebEventFactory.cpp: WebKeyboardEvent::m_isKeypad is initialized. + (WebKit::WebEventFactory::createWebKeyboardEvent): + +2012-07-27 Gyuyoung Kim <gyuyoung.kim@samsung.com> + + [EFL] Fix wrong return value in EWK_VIEW_XXX macro. + https://bugs.webkit.org/show_bug.cgi?id=92466 + + Reviewed by Simon Hausmann. + + There are wrong return values in EWK_VIEW_XXX macros. The wrong return values + should be fixed. In addition, API description is also modified according to returned + value change. + + * UIProcess/API/efl/ewk_view.cpp: + (ewk_view_uri_set): + (ewk_view_load_progress_get): + (ewk_view_device_pixel_ratio_get): + * UIProcess/API/efl/ewk_view.h: + +2012-07-27 Christophe Dumez <christophe.dumez@intel.com> + + [EFL][WK2] Add unit tests for Ewk_View form client + https://bugs.webkit.org/show_bug.cgi?id=92468 + + Reviewed by Simon Hausmann. + + Add unit test for form client functionality in + Ewk_View. + + * UIProcess/API/efl/tests/test_ewk2_view.cpp: + (onFormAboutToBeSubmitted): + (TEST_F): + +2012-07-26 Zeno Albisser <zeno@webkit.org> + + Unreviewed Qt buildfix after r123786. + + Qt-minimal builds with ENABLE_REQUEST_ANIMATION_FRAME=0. + Therefore adding #ifdefs to allow for that configuration. + + * WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp: + (WebKit): + * WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.h: + (LayerTreeCoordinator): + +2012-07-26 Zeno Albisser <zeno@webkit.org> + + [Qt] requestAnimationFrame should only trigger when a new frame can be displayed. + https://bugs.webkit.org/show_bug.cgi?id=88638 + + Disable REQUEST_ANIMATION_FRAME_TIMER for the Qt port and tie + the servicing of scripted animations to layer syncing for WK2. + For WK1 we rely on the RefreshAnimation that is based on QAbstractAnimation. + + Reviewed by Jocelyn Turcotte. + + * WebProcess/WebCoreSupport/WebChromeClient.cpp: + (WebKit): + (WebKit::WebChromeClient::scheduleAnimation): + * WebProcess/WebCoreSupport/WebChromeClient.h: + (WebChromeClient): + * WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp: + (WebKit::LayerTreeCoordinator::performScheduledLayerFlush): + (WebKit::LayerTreeCoordinator::scheduleAnimation): + (WebKit): + * WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.h: + (LayerTreeCoordinator): + * WebProcess/WebPage/LayerTreeHost.h: + (LayerTreeHost): + +2012-07-26 Jer Noble <jer.noble@apple.com> + + Add a ChromeClient method to send diagnostic logging messages from WebCore to the client. + https://bugs.webkit.org/show_bug.cgi?id=92340 + + Reviewed by Anders Carlsson. + + Pipe the ChromeClient logDiagnosticMessage() function through WebKit2 to a new bundle class + InjectedBundlePageDiagnosticLoggingClient, to be implemented by the client. + + * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp: + (WKBundlePageSetDiagnosticLoggingClient): Added. + * WebProcess/InjectedBundle/API/c/WKBundlePage.h: + * WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.cpp: Added. + (WebKit::InjectedBundlePageDiagnosticLoggingClient::logDiagnosticMessage): + * WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.h: Added. + (InjectedBundlePageDiagnosticLoggingClient): + * WebProcess/WebCoreSupport/WebChromeClient.cpp: + (WebKit::WebChromeClient::logDiagnosticMessage): + * WebProcess/WebCoreSupport/WebChromeClient.h: + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::initializeInjectedBundleDiagnosticLoggingClient): + * WebProcess/WebPage/WebPage.h: + (WebKit::WebPage::injectedBundleDiagnosticLoggingClient): + + Add a convenience class to retrieve the diagnostic message keys: + * WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.cpp: Added. + (WebKit::InjectedBundlePageDiagnosticLoggingClient::logDiagnosticMessage): + * WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.h: Added. + (InjectedBundlePageDiagnosticLoggingClient): + + Add the InjectedBundlePageDiagnosticLoggingClient.cpp,h files. + * CMakeLists.txt: + * GNUmakefile.list.am: + * Target.pri: + * win/WebKit2.vcproj: + * WebKit2.xcodeproj/project.pbxproj: + +2012-07-25 Jer Noble <jer.noble@apple.com> + + Add setting to enable and disable diagnostic logging. + https://bugs.webkit.org/show_bug.cgi?id=92337 + + Reviewed by Anders Carlsson. + + Add a WebKit2 WKPreferences API to set set the WebCore diagnosticLoggingEnabled setting. + + * Shared/WebPreferencesStore.h: + * UIProcess/API/C/WKPreferences.cpp: + (WKPreferencesSetDiagnosticLoggingEnabled): + (WKPreferencesGetDiagnosticLoggingEnabled): + * UIProcess/API/C/WKPreferencesPrivate.h: + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::updatePreferences): Ensure this preference is propagated to Settings + whenever the preferences change. + +2012-07-26 Thiago Marcos P. Santos <thiago.santos@intel.com> + + [EFL][WK2] Regression(r123731): Linking errors due to efreet functions + https://bugs.webkit.org/show_bug.cgi?id=92378 + + Unreviewed build fix. + + The library list created by PlatformEfl.cmake was being erased by a + SET called after including the platform specific file. Luckily the + dependencies were fulfilled by other targets until efreet was add. + + * CMakeLists.txt: + +2012-07-26 Christophe Dumez <christophe.dumez@intel.com> + + [EFL][WK2] Compilation warning in EWK2UnitTestServer.cpp + https://bugs.webkit.org/show_bug.cgi?id=92387 + + Reviewed by Kenneth Rohde Christiansen. + + Fix compilation warning in EWK2UnitTestServer.cpp. + + * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.cpp: + (EWK2UnitTestServer::EWK2UnitTestServer): + +2012-07-26 Christophe Dumez <christophe.dumez@intel.com> + + [EFL][WK2] Implement Network Information provider + https://bugs.webkit.org/show_bug.cgi?id=92343 + + Reviewed by Kenneth Rohde Christiansen. + + Add Network Information provider for WebKit2 EFL + by using NetworkInfoProviderEfl class from + WebCore. + + * CMakeLists.txt: + * PlatformEfl.cmake: + * UIProcess/API/efl/NetworkInfoProvider.cpp: Added. + (toNetworkInfoProvider): + (startUpdatingCallback): + (stopUpdatingCallback): + (getBandwidthCallback): + (isMeteredCallback): + (NetworkInfoProvider::create): + (NetworkInfoProvider::NetworkInfoProvider): + (NetworkInfoProvider::~NetworkInfoProvider): + (NetworkInfoProvider::bandwidth): + (NetworkInfoProvider::metered): + (NetworkInfoProvider::startUpdating): + (NetworkInfoProvider::stopUpdating): + * UIProcess/API/efl/NetworkInfoProvider.h: Added. + (NetworkInfoProvider): + +2012-07-26 Christophe Dumez <christophe.dumez@intel.com> + + [EFL][WK2] Compilation warning in EWK2UnitTestServer.cpp + https://bugs.webkit.org/show_bug.cgi?id=92387 + + Reviewed by Kenneth Rohde Christiansen. + + Fix compilation warning in EWK2UnitTestServer.cpp. + + * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.cpp: + (EWK2UnitTestServer::EWK2UnitTestServer): + +2012-07-26 Thiago Marcos P. Santos <thiago.santos@intel.com> + + [EFL][WK2] Regression(r123731): Linking errors due to efreet functions + https://bugs.webkit.org/show_bug.cgi?id=92378 + + Unreviewed build fix. + + The library list created by PlatformEfl.cmake was being erased by a + SET called after including the platform specific file. Luckily the + dependencies were fulfilled by other targets until efreet was add. + + * CMakeLists.txt: + +2012-07-26 Christophe Dumez <christophe.dumez@intel.com> + + [EFL][WK2] Compilation warning in EWK2UnitTestServer.cpp + https://bugs.webkit.org/show_bug.cgi?id=92387 + + Reviewed by Kenneth Rohde Christiansen. + + Fix compilation warning in EWK2UnitTestServer.cpp. + + * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.cpp: + (EWK2UnitTestServer::EWK2UnitTestServer): + +2012-07-26 Christophe Dumez <christophe.dumez@intel.com> + + [EFL][WK2] Implement Network Information provider + https://bugs.webkit.org/show_bug.cgi?id=92343 + + Reviewed by Kenneth Rohde Christiansen. + + Add Network Information provider for WebKit2 EFL + by using NetworkInfoProviderEfl class from + WebCore. + + * CMakeLists.txt: + * PlatformEfl.cmake: + * UIProcess/API/efl/NetworkInfoProvider.cpp: Added. + (toNetworkInfoProvider): + (startUpdatingCallback): + (stopUpdatingCallback): + (getBandwidthCallback): + (isMeteredCallback): + (NetworkInfoProvider::create): + (NetworkInfoProvider::NetworkInfoProvider): + (NetworkInfoProvider::~NetworkInfoProvider): + (NetworkInfoProvider::bandwidth): + (NetworkInfoProvider::metered): + (NetworkInfoProvider::startUpdating): + (NetworkInfoProvider::stopUpdating): + * UIProcess/API/efl/NetworkInfoProvider.h: Added. + (NetworkInfoProvider): + +2012-07-26 Christophe Dumez <christophe.dumez@intel.com> + + [EFL][WK2] Compilation warning in EWK2UnitTestServer.cpp + https://bugs.webkit.org/show_bug.cgi?id=92387 + + Reviewed by Kenneth Rohde Christiansen. + + Fix compilation warning in EWK2UnitTestServer.cpp. + + * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.cpp: + (EWK2UnitTestServer::EWK2UnitTestServer): + +2012-07-26 Christophe Dumez <christophe.dumez@intel.com> + + [EFL][WK2] Add unit tests for Ewk_Context + https://bugs.webkit.org/show_bug.cgi?id=92005 + + Reviewed by Antonio Gomes. + + Add unit tests for WebKit2 Ewk_Context. + + * PlatformEfl.cmake: + * UIProcess/API/efl/ewk_url_scheme_request.cpp: + (ewk_url_scheme_request_finish): + * UIProcess/API/efl/ewk_url_scheme_request.h: Mark content_data + argument as const. + * UIProcess/API/efl/tests/test_ewk2_context.cpp: Added. + (TEST_F): + (schemeRequestCallback): + +2012-07-26 Christophe Dumez <christophe.dumez@intel.com> + + [EFL][WK2] Add form client for Ewk_View + https://bugs.webkit.org/show_bug.cgi?id=92358 + + Reviewed by Kenneth Rohde Christiansen. + + Implement a form client for EFL port in order to + send a "form,request,new" signal on the Ewk_View + whenever a form will be submitted. + + The Ewk_Form_Submission_Request type is + introduced to provide the client with information + about the form (e.g. text fields contained in the + form) and to submit it. + + This is typically used to store login information + that can be used later to pre-fill the form. + + * PlatformEfl.cmake: + * UIProcess/API/efl/EWebKit2.h: + * UIProcess/API/efl/ewk_form_submission_request.cpp: Added. + (_Ewk_Form_Submission_Request): + (_Ewk_Form_Submission_Request::_Ewk_Form_Submission_Request): + (_Ewk_Form_Submission_Request::~_Ewk_Form_Submission_Request): + (ewk_form_submission_request_ref): + (ewk_form_submission_request_unref): + (ewk_form_submission_request_field_names_get): + (ewk_form_submission_request_field_value_get): + (ewk_form_submission_request_submit): + (ewk_form_submission_request_new): + * UIProcess/API/efl/ewk_form_submission_request.h: Added. + * UIProcess/API/efl/ewk_form_submission_request_private.h: Added. + * UIProcess/API/efl/ewk_view.cpp: + (ewk_view_base_add): + (ewk_view_form_submission_request_new): + * UIProcess/API/efl/ewk_view.h: + * UIProcess/API/efl/ewk_view_form_client.cpp: Added. + (willSubmitForm): + (ewk_view_form_client_attach): + * UIProcess/API/efl/ewk_view_form_client_private.h: Added. + * UIProcess/API/efl/ewk_view_private.h: + +2012-07-26 Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com> + + [WK2] WebPage::handleEditingKeyboardEvent does not check whether the node allows editing. + https://bugs.webkit.org/show_bug.cgi?id=92364 + + Reviewed by Kenneth Rohde Christiansen. + + Added a check whether the input node allows editing. If editing is not allowed + text input event will not be emitted. + + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::handleEditingKeyboardEvent): + +2012-07-26 Zoltan Nyul <zoltan.nyul@intel.com> + + [EFL] EFL port should use XDG paths + https://bugs.webkit.org/show_bug.cgi?id=91719 + + Reviewed by Kenneth Rohde Christiansen. + + Setting xdg paths for application cache, web-database and local-storage. + + * PlatformEfl.cmake: + * UIProcess/efl/WebContextEfl.cpp: + (WebKit::WebContext::applicationCacheDirectory): + (WebKit::WebContext::platformDefaultDatabaseDirectory): + (WebKit::WebContext::platformDefaultLocalStorageDirectory): + +2012-07-26 Sudarsana Nagineni <sudarsana.nagineni@linux.intel.com> + + [EFL] [WK2] Memory leak in ewk_view_resource_load_client.cpp + https://bugs.webkit.org/show_bug.cgi?id=92099 + + Reviewed by Kentaro Hara. + + Fix a memory leak by clearing the loadingResources HashMap on exit. + + * UIProcess/API/efl/ewk_view.cpp: + (_Ewk_View_Private_Data::~_Ewk_View_Private_Data): + (_ewk_view_priv_loading_resources_clear): + (ewk_view_load_provisional_started): + +2012-07-26 Gyuyoung Kim <gyuyoung.kim@samsung.com> + + [DRT] LTC:: pageNumberForElementById() could be moved to Internals + https://bugs.webkit.org/show_bug.cgi?id=92091 + + Reviewed by Kentaro Hara. + + Missing a symbol filter for Mac win port. + + * win/WebKit2.def: + * win/WebKit2CFLite.def: + +2012-07-25 Seokju Kwon <seokju.kwon@samsung.com> + + [EFL][WK2] Implement the inspector for WebKitTestRunner + https://bugs.webkit.org/show_bug.cgi?id=92213 + + Reviewed by Ryosuke Niwa. + + Partial Implementation of WebInspectorProxyEfl for WebkitTestRunner. + And Web Inspector resources installation. + + * PlatformEfl.cmake: + * UIProcess/WebInspectorProxy.cpp: + (WebKit::WebInspectorProxy::WebInspectorProxy): + * UIProcess/WebInspectorProxy.h: + (WebInspectorProxy): + * UIProcess/efl/WebInspectorProxyEfl.cpp: + (WebKit::WebInspectorProxy::platformCreateInspectorPage): + (WebKit::WebInspectorProxy::platformDidClose): + (WebKit::WebInspectorProxy::inspectorPageURL): + (WebKit::WebInspectorProxy::inspectorBaseURL): + +2012-07-25 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> + + Create a specialized struct for use in HashMap iterators + https://bugs.webkit.org/show_bug.cgi?id=92137 + + Reviewed by Ryosuke Niwa. + + * Platform/CoreIPC/ArgumentCoders.h: Add encode/decode for KeyValuePair. + +2012-07-25 Anders Carlsson <andersca@apple.com> + + Crash when calling PluginView::pluginFocusOrWindowFocusChanged when the web page is null + https://bugs.webkit.org/show_bug.cgi?id=92289 + <rdar://problem/11785352> + + Reviewed by Andreas Kling. + + Plug-in views that outlive their containing web page for various reasons (such as being protected from + destruction) need to null check the web page. + + * WebProcess/Plugins/PluginView.cpp: + (WebKit::PluginView::pluginFocusOrWindowFocusChanged): + (WebKit::PluginView::setComplexTextInputState): + +2012-07-25 Christophe Dumez <christophe.dumez@intel.com> + + [WK2][WTR] LayoutTestController.sendWebIntentResponse() needs to be implemented + https://bugs.webkit.org/show_bug.cgi?id=92227 + + Reviewed by Kenneth Rohde Christiansen. + + Add new InjectedBundleIntentRequest class to wrap WebCore's + IntentRequest and use it in InjectedBundle's + didReceiveIntentForFrame callback. The WebKitTestRunner needs + to be able to reply to a Web intent request in order to + implement LayoutTestController.sendWebIntentResponse(). As + a consequence, passing a WebIntentData type in not enough. + + * CMakeLists.txt: + * GNUmakefile.list.am: + * Shared/API/c/WKBase.h: + * Shared/APIObject.h: + * Shared/IntentData.cpp: + (WebKit::IntentData::IntentData): + (WebKit): + * Shared/IntentData.h: + (WebCore): + (WebKit::IntentData::IntentData): + (IntentData): + * Target.pri: + * WebProcess/InjectedBundle/API/c/WKBundleAPICast.h: + (WebKit): + * WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.cpp: Copied from Source/WebKit2/Shared/IntentData.cpp. + (WKBundleIntentRequestGetTypeID): + (WKBundleIntentRequestCopyIntent): + (WKBundleIntentRequestPostResult): + (WKBundleIntentRequestPostFailure): + * WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.h: Copied from Source/WebKit2/Shared/IntentData.h. + * WebProcess/InjectedBundle/API/c/WKBundlePage.h: + * WebProcess/InjectedBundle/InjectedBundleIntentRequest.cpp: Copied from Source/WebKit2/Shared/IntentData.cpp. + (WebKit): + (WebKit::InjectedBundleIntentRequest::create): + (WebKit::InjectedBundleIntentRequest::InjectedBundleIntentRequest): + (WebKit::InjectedBundleIntentRequest::postResult): + (WebKit::InjectedBundleIntentRequest::postFailure): + (WebKit::InjectedBundleIntentRequest::intent): + * WebProcess/InjectedBundle/InjectedBundleIntentRequest.h: Copied from Source/WebKit2/Shared/IntentData.h. + (WebCore): + (WebKit): + (InjectedBundleIntentRequest): + (WebKit::InjectedBundleIntentRequest::type): + * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp: + (WebKit::InjectedBundlePageLoaderClient::didReceiveIntentForFrame): + * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h: + (WebKit): + (InjectedBundlePageLoaderClient): + * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: + (WebKit::WebFrameLoaderClient::dispatchIntent): + +2012-07-25 Anders Carlsson <andersca@apple.com> + + Crash when a web page is closed with outstanding scrolling thread barriers + https://bugs.webkit.org/show_bug.cgi?id=92280 + <rdar://problem/11630200> + + Reviewed by Andreas Kling. + + There was a check in forceRepaintAsync to handle the drawing area going away before the block had + been invoked, but this check needs to be done earlier (as the FIXME suggested). + Move this check to dispatchAfterEnsuringUpdatedScrollPosition instead. + + * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm: + (WebKit::TiledCoreAnimationDrawingArea::forceRepaintAsync): + (WebKit::TiledCoreAnimationDrawingArea::dispatchAfterEnsuringUpdatedScrollPosition): + +2012-07-25 Alexey Proskuryakov <ap@apple.com> + + Chinese IM receives incorrect/duplicated key events in text fields in webpages in Safari. + https://bugs.webkit.org/show_bug.cgi?id=89048 + <rdar://problem/11786384> + + Reviewed by Andreas Kling. + + Cannot test text input from UI process side. + + Stop relying on IPC to handle key events in order. There are too many complications + where out of order delivery is performed. Instead, queue the events at UI process + side. + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::handleKeyboardEvent): + (WebKit::WebPageProxy::didReceiveEvent): + +2012-07-25 Gyuyoung Kim <gyuyoung.kim@samsung.com> + + [EFL] Use eina_stringshare_add instead of strdup. + https://bugs.webkit.org/show_bug.cgi?id=92072 + + Reviewed by Kentaro Hara. + + Eina of EFL libraries supports a string functionality that replaces strdup. So, EFL port needs + to replace strdup with eina_stringshare_add function. + + * UIProcess/API/efl/ewk_intent.cpp: + (ewk_intent_suggestions_get): + (ewk_intent_extra_get): + * UIProcess/API/efl/ewk_intent.h: + +2012-07-25 Ryuan Choi <ryuan.choi@samsung.com> + + [EFL][WK2] Add ewk_view_cursor_set to change cursor. + https://bugs.webkit.org/show_bug.cgi?id=89140 + + Reviewed by Hajime Morita. + + Implement ewk_view_cursor_set to support cursor changes. + + * UIProcess/API/efl/PageClientImpl.cpp: + (WebKit::PageClientImpl::setCursor): Called ewk_view_cursor_set. + * UIProcess/API/efl/ewk_view.cpp: + (_Ewk_View_Private_Data): + (_Ewk_View_Private_Data::_Ewk_View_Private_Data): + (_Ewk_View_Private_Data::~_Ewk_View_Private_Data): + (_ewk_view_priv_new): Check whether ecore_x can be used. + (_ewk_view_smart_add): + Change order of initialization to use base structure in _ewk_view_priv_new. + (ewk_view_cursor_set): Added to set cursor. + * UIProcess/API/efl/ewk_view_private.h: + +2012-07-25 Ryuan Choi <ryuan.choi@samsung.com> + + [EFL][WK2] Update uri when the active URI is changed while loading. + https://bugs.webkit.org/show_bug.cgi?id=92001 + + Reviewed by Hajime Morita. + + For now, ewk_view_uri_get just return the last uri of setter. + This patch updates the uri of ewk_view when it is changed while loading. + + * UIProcess/API/efl/ewk_view.cpp: + (ewk_view_uri_update): + Added to check whether current active URI has changed and send uri,changed + signal if it has changed. + (ewk_view_uri_set): + Called ewk_view_uri_update to make sure the active uri is updated when the + load operation is started. + (ewk_view_reload): Ditto. + (ewk_view_reload_bypass_cache): Ditto. + (ewk_view_load_finished): Ditto. + (ewk_view_load_provisional_redirect): Ditto. + (ewk_view_load_provisional_started): Ditto. + (ewk_view_html_string_load): Ditto. + * UIProcess/API/efl/ewk_view.h: Updated comment for uri,changed signal. + * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp: + (EWK2UnitTest::EWK2UnitTestEnvironment::urlForResource): + Added to get url of custom resource for test. + * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h: + * UIProcess/API/efl/tests/resources/redirect_uri_to_default.html: + Added to test ewk_view_uri_get when the page is redirected. + * UIProcess/API/efl/tests/test_ewk2_view.cpp: Ditto. + (onLoadFinishedForRedirection): + (TEST_F): Added new test case whether ewk_view_uri_get returns correct uri when + the page is redirected. + +2012-07-25 Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com> + + [EFL][WK2] Add ewk_main.{cpp,h} to EFL WK2 + https://bugs.webkit.org/show_bug.cgi?id=92101 + + Reviewed by Kenneth Rohde Christiansen. + + Added a centralized place for general initialization in UI process for EFL WK2. + + * PlatformEfl.cmake: + * UIProcess/API/efl/EWebKit2.h: + * UIProcess/API/efl/ewk_main.cpp: Added. + (ewk_init): General initialization. + (ewk_shutdown): General freeing. + (_ewk_init_body): An aux function. + * UIProcess/API/efl/ewk_main.h: Added. + +2012-07-24 Jae Hyun Park <jae.park@company100.net> + + WKContextGetGlobalStatistics() assigns wrong value to wkFrameCount in WKContextStatistics + https://bugs.webkit.org/show_bug.cgi?id=92173 + + Reviewed by John Sullivan. + + In WKContextGetGlobalStatistics(), wkViewCount in WebContext::Statistics + is assigned to wkFrameCount in WKContextStatistics. + wkFrameCount in WebContext:Statistics should be assigned to wkFrameCount in WKContextStatistics. + + * UIProcess/API/C/WKContext.cpp: + (WKContextGetGlobalStatistics): + +2012-07-24 Sudarsana Nagineni <sudarsana.nagineni@linux.intel.com> + + [EFL][WK2] Add unit tests for custom text encoding setting + https://bugs.webkit.org/show_bug.cgi?id=91983 + + Reviewed by Dirk Pranke. + + Add unit tests for get and set custom text encoding methods. Also, fix + a style nit for r123177. + + * UIProcess/API/efl/ewk_view.cpp: + (ewk_view_setting_encoding_custom_set): Fix a style nit - add newline + before return. + * UIProcess/API/efl/tests/test_ewk2_view.cpp: + (TEST_F): + +2012-07-24 Ryosuke Niwa <rniwa@webkit.org> + + WinCairo build fix attempt. + + * win/WebKit2CFLite.def: + +2012-07-24 Ryosuke Niwa <rniwa@webkit.org> + + Windows build fix attempt. + + * win/WebKit2.def: + +2012-07-24 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> + + [Qt] Make sure that an AC sync is triggered when the canvas contents is updated. + https://bugs.webkit.org/show_bug.cgi?id=92128 + + Reviewed by Kenneth Rohde Christiansen. + + This would cause missed frames when animating an accelerated 2D canvas without + touching the document. + + * WebProcess/WebPage/LayerTreeCoordinator/WebGraphicsLayer.cpp: + (WebCore::WebGraphicsLayer::setContentsNeedsDisplay): + +2012-07-24 Alexey Proskuryakov <ap@apple.com> + + [Mac WK2] Improve text input logging + https://bugs.webkit.org/show_bug.cgi?id=92147 + + Reviewed by Andreas Kling. + + * UIProcess/API/mac/WKView.mm: + (-[WKView insertText:replacementRange:]): + (-[WKView keyUp:]): + (-[WKView keyDown:]): + (-[WKView flagsChanged:]): + (-[WKView _executeSavedKeypressCommands]): + (-[WKView _notifyInputContextAboutDiscardedComposition]): + (-[WKView _interpretKeyEvent:savingCommandsTo:WebCore::]): + (-[WKView _updateSecureInputState]): + +2012-07-24 Christophe Dumez <christophe.dumez@intel.com> + + [EFL][WK2] Provide more useful output when an injected bundle cannot be loaded + https://bugs.webkit.org/show_bug.cgi?id=92136 + + Reviewed by Kenneth Rohde Christiansen. + + Call eina_error_get() in case an injected bundle cannot be + loaded in order to print more information about the error. + + * WebProcess/InjectedBundle/efl/InjectedBundleEfl.cpp: + (WebKit::InjectedBundle::load): + +2012-07-24 Sudarsana Nagineni <sudarsana.nagineni@linux.intel.com> + + [EFL][WK2] Add vibration client + https://bugs.webkit.org/show_bug.cgi?id=91371 + + Reviewed by Antonio Gomes. + + Implement Vibration provider for WebKit2 EFL and add an API to set + vibration client callbacks by application to handle the tactile + feedback in the application when the page content ask for vibration. + + * CMakeLists.txt: Add WebCore/Modules/vibration to include path. + * PlatformEfl.cmake: Add VibrationProvider.cpp file to the build + system. + * UIProcess/API/efl/VibrationProvider.cpp: Added. + (_Ewk_Vibration_Client): Structure contains the vibration client + callbacks. + (_Ewk_Vibration_Client::_Ewk_Vibration_Client): + (toVibrationProvider): Helper function to cast the clientinfo to + VibrationProvider. + (vibrateCallback): + (cancelVibrationCallback): + (VibrationProvider::create): + (VibrationProvider::VibrationProvider): + (VibrationProvider::~VibrationProvider): + (VibrationProvider::vibrate): + (VibrationProvider::cancelVibration): + (VibrationProvider::setVibrationClientCallbacks): + * UIProcess/API/efl/VibrationProvider.h: Added. + (VibrationProvider): + * UIProcess/API/efl/ewk_context.cpp: + (_Ewk_Context): + (createDefaultEwkContext): + (ewk_context_vibration_client_callbacks_set): API to set vibration + client callbacks. + * UIProcess/API/efl/ewk_context.h: + 2012-07-24 Simon Hausmann <simon.hausmann@nokia.com> [Qt] Fix compilation after QtQuick API changes diff --git a/Source/WebKit2/GNUmakefile.am b/Source/WebKit2/GNUmakefile.am index 9108bb4c9..eed029672 100644 --- a/Source/WebKit2/GNUmakefile.am +++ b/Source/WebKit2/GNUmakefile.am @@ -162,7 +162,6 @@ libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_LIB libWebCoreGtk.la \ $(CAIRO_LIBS) \ $(COVERAGE_LDFLAGS) \ - $(ENCHANT_LIBS) \ $(GAIL_LIBS) \ $(GAMEPAD_LIBS) \ $(GEOCLUE_LIBS) \ @@ -183,6 +182,16 @@ libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_LIB $(XT_LIBS) \ $(ZLIB_LIBS) +if ENABLE_SPELLCHECK +libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_CPPFLAGS += \ + -DENABLE_SPELLCHECK=1 \ + $(ENCHANT_CFLAGS) + +libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_LIBADD += \ + $(ENCHANT_LIBS) +endif + + if ENABLE_WEBKIT2 pkgconfig_DATA += Source/WebKit2/webkit2gtk-@WEBKITGTK_API_VERSION@.pc endif diff --git a/Source/WebKit2/GNUmakefile.list.am b/Source/WebKit2/GNUmakefile.list.am index ca81d4707..eb6927046 100644 --- a/Source/WebKit2/GNUmakefile.list.am +++ b/Source/WebKit2/GNUmakefile.list.am @@ -701,6 +701,8 @@ webkit2_sources += \ Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp \ Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h \ Source/WebKit2/UIProcess/API/gtk/WebKitSettingsPrivate.h \ + Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp \ + Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h \ Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp \ Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.h \ Source/WebKit2/UIProcess/API/gtk/WebKitURIRequest.cpp \ @@ -964,6 +966,8 @@ webkit2_sources += \ Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInitialize.h \ Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp \ Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.h \ + Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.cpp \ + Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.h \ Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp \ Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.h \ Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h \ @@ -996,10 +1000,14 @@ webkit2_sources += \ Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.h \ Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp \ Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.h \ + Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntentRequest.cpp \ + Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntentRequest.h \ Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp \ Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.h \ Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.cpp \ Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.h \ + Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.cpp \ + Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.h \ Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageEditorClient.cpp \ Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageEditorClient.h \ Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp \ diff --git a/Source/WebKit2/Platform/CoreIPC/ArgumentCoders.h b/Source/WebKit2/Platform/CoreIPC/ArgumentCoders.h index 070f45830..dd54dfeef 100644 --- a/Source/WebKit2/Platform/CoreIPC/ArgumentCoders.h +++ b/Source/WebKit2/Platform/CoreIPC/ArgumentCoders.h @@ -72,6 +72,29 @@ template<typename T, typename U> struct ArgumentCoder<std::pair<T, U> > { } }; +template<typename KeyType, typename ValueType> struct ArgumentCoder<WTF::KeyValuePair<KeyType, ValueType> > { + static void encode(ArgumentEncoder* encoder, const WTF::KeyValuePair<KeyType, ValueType>& pair) + { + encoder->encode(pair.first); + encoder->encode(pair.second); + } + + static bool decode(ArgumentDecoder* decoder, WTF::KeyValuePair<KeyType, ValueType>& pair) + { + KeyType key; + if (!decoder->decode(key)) + return false; + + ValueType value; + if (!decoder->decode(value)) + return false; + + pair.first = key; + pair.second = value; + return true; + } +}; + template<bool fixedSizeElements, typename T> struct VectorArgumentCoder; template<typename T> struct VectorArgumentCoder<false, T> { diff --git a/Source/WebKit2/PlatformEfl.cmake b/Source/WebKit2/PlatformEfl.cmake index 316006e15..0a02c2bf6 100644 --- a/Source/WebKit2/PlatformEfl.cmake +++ b/Source/WebKit2/PlatformEfl.cmake @@ -3,6 +3,7 @@ LIST(APPEND WebKit2_LINK_FLAGS ${ECORE_X_LDFLAGS} ${EDJE_LDFLAGS} ${EFLDEPS_LDFLAGS} + ${EFREET_LDFLAGS} ${EVAS_LDFLAGS} ${LIBSOUP24_LDFLAGS} ) @@ -19,9 +20,9 @@ LIST(APPEND WebKit2_SOURCES Shared/API/c/gtk/WKGraphicsContextGtk.cpp - Shared/cairo/LayerTreeContextCairo.cpp Shared/cairo/ShareableBitmapCairo.cpp + Shared/efl/LayerTreeContextEfl.cpp Shared/efl/NativeWebKeyboardEventEfl.cpp Shared/efl/NativeWebWheelEventEfl.cpp Shared/efl/NativeWebMouseEventEfl.cpp @@ -37,17 +38,24 @@ LIST(APPEND WebKit2_SOURCES UIProcess/API/C/soup/WKSoupRequestManager.cpp UIProcess/API/efl/BatteryProvider.cpp + UIProcess/API/efl/NetworkInfoProvider.cpp UIProcess/API/efl/PageClientImpl.cpp + UIProcess/API/efl/VibrationProvider.cpp UIProcess/API/efl/ewk_context.cpp + UIProcess/API/efl/ewk_context_download_client.cpp UIProcess/API/efl/ewk_context_request_manager_client.cpp UIProcess/API/efl/ewk_cookie_manager.cpp + UIProcess/API/efl/ewk_download_job.cpp + UIProcess/API/efl/ewk_form_submission_request.cpp UIProcess/API/efl/ewk_intent.cpp UIProcess/API/efl/ewk_intent_service.cpp + UIProcess/API/efl/ewk_main.cpp UIProcess/API/efl/ewk_navigation_policy_decision.cpp UIProcess/API/efl/ewk_url_request.cpp UIProcess/API/efl/ewk_url_response.cpp UIProcess/API/efl/ewk_url_scheme_request.cpp UIProcess/API/efl/ewk_view.cpp + UIProcess/API/efl/ewk_view_form_client.cpp UIProcess/API/efl/ewk_view_loader_client.cpp UIProcess/API/efl/ewk_view_policy_client.cpp UIProcess/API/efl/ewk_view_resource_load_client.cpp @@ -122,6 +130,7 @@ LIST(APPEND WebKit2_INCLUDE_DIRECTORIES ${ECORE_X_INCLUDE_DIRS} ${EDJE_INCLUDE_DIRS} ${EFLDEPS_INCLUDE_DIRS} + ${EFREET_INCLUDE_DIRS} ${EVAS_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIR} ${LIBXSLT_INCLUDE_DIRS} @@ -135,6 +144,7 @@ LIST(APPEND WebKit2_LIBRARIES ${CAIRO_LIBRARIES} ${ECORE_X_LIBRARIES} ${EFLDEPS_LIBRARIES} + ${EFREET_LIBRARIES} ${Freetype_LIBRARIES} ${LIBXML2_LIBRARIES} ${SQLITE_LIBRARIES} @@ -146,6 +156,13 @@ LIST(APPEND WebKit2_LIBRARIES ${LIBSOUP24_LIBRARIES} ) +LIST (APPEND WebKit2_FORWARDING_HEADERS_DIRECTORIES + Shared/API/c/efl + Shared/API/c/soup + UIProcess/API/C/efl + UIProcess/API/C/soup +) + LIST (APPEND WebProcess_SOURCES efl/MainEfl.cpp ) @@ -163,23 +180,16 @@ LIST (APPEND WebProcess_LIBRARIES ADD_DEFINITIONS(-DDEFAULT_THEME_PATH=\"${CMAKE_INSTALL_PREFIX}/${DATA_INSTALL_DIR}/themes\") -ADD_CUSTOM_TARGET(forwarding-headerEfl - COMMAND ${PERL_EXECUTABLE} ${WEBKIT2_DIR}/Scripts/generate-forwarding-headers.pl ${WEBKIT2_DIR} ${DERIVED_SOURCES_WEBKIT2_DIR}/include efl -) -SET(ForwardingHeaders_NAME forwarding-headerEfl) - -ADD_CUSTOM_TARGET(forwarding-headerSoup - COMMAND ${PERL_EXECUTABLE} ${WEBKIT2_DIR}/Scripts/generate-forwarding-headers.pl ${WEBKIT2_DIR} ${DERIVED_SOURCES_WEBKIT2_DIR}/include soup -) -SET(ForwardingNetworkHeaders_NAME forwarding-headerSoup) - CONFIGURE_FILE(efl/ewebkit2.pc.in ${CMAKE_BINARY_DIR}/WebKit2/efl/ewebkit2.pc @ONLY) SET (EWebKit2_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/EWebKit2.h" "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_context.h" "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_cookie_manager.h" + "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_download_job.h" + "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_form_submission_request.h" "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_intent.h" "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_intent_service.h" + "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_main.h" "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_navigation_policy_decision.h" "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_url_request.h" "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_url_response.h" @@ -237,7 +247,9 @@ TARGET_LINK_LIBRARIES(ewk2UnitTestUtils ${EWK2UnitTests_LIBRARIES}) # The "ewk" on the test name needs to be suffixed with "2", otherwise it # will clash with tests from the WebKit 1 test suite. SET(EWK2UnitTests_BINARIES + test_ewk2_context test_ewk2_cookie_manager + test_ewk2_download_job test_ewk2_view ) @@ -249,3 +261,24 @@ IF (ENABLE_API_TESTS) TARGET_LINK_LIBRARIES(${testName} ${EWK2UnitTests_LIBRARIES} ewk2UnitTestUtils) ENDFOREACH () ENDIF () + +IF (ENABLE_INSPECTOR) + SET(WK2_WEB_INSPECTOR_DIR ${CMAKE_BINARY_DIR}/WebKit2/efl/webinspector) + SET(WK2_WEB_INSPECTOR_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${WebKit2_LIBRARY_NAME}-${PROJECT_VERSION_MAJOR}) + ADD_DEFINITIONS(-DWK2_WEB_INSPECTOR_DIR="${WK2_WEB_INSPECTOR_DIR}") + ADD_DEFINITIONS(-DWK2_WEB_INSPECTOR_INSTALL_DIR="${WK2_WEB_INSPECTOR_INSTALL_DIR}/webinspector") + ADD_CUSTOM_TARGET( + wk2-web-inspector-resources ALL + COMMAND ${CMAKE_COMMAND} -E copy_directory ${WEBCORE_DIR}/inspector/front-end ${WK2_WEB_INSPECTOR_DIR} + COMMAND ${CMAKE_COMMAND} -E copy ${WEBCORE_DIR}/English.lproj/localizedStrings.js ${WK2_WEB_INSPECTOR_DIR} + COMMAND ${CMAKE_COMMAND} -E copy ${DERIVED_SOURCES_WEBCORE_DIR}/InspectorBackendCommands.js ${WK2_WEB_INSPECTOR_DIR}/InspectorBackendCommands.js + DEPENDS ${WebCore_LIBRARY_NAME} + ) + INSTALL(DIRECTORY ${WK2_WEB_INSPECTOR_DIR} + DESTINATION ${WK2_WEB_INSPECTOR_INSTALL_DIR} + FILES_MATCHING PATTERN "*.js" + PATTERN "*.html" + PATTERN "*.css" + PATTERN "*.gif" + PATTERN "*.png") +ENDIF () diff --git a/Source/WebKit2/Shared/API/c/WKBase.h b/Source/WebKit2/Shared/API/c/WKBase.h index 3f707bace..6854ecc27 100644 --- a/Source/WebKit2/Shared/API/c/WKBase.h +++ b/Source/WebKit2/Shared/API/c/WKBase.h @@ -135,6 +135,7 @@ typedef const struct OpaqueWKBundleDOMWindowExtension* WKBundleDOMWindowExtensio typedef const struct OpaqueWKBundleFrame* WKBundleFrameRef; typedef const struct OpaqueWKBundleHitTestResult* WKBundleHitTestResultRef; typedef const struct OpaqueWKBundleInspector* WKBundleInspectorRef; +typedef const struct OpaqueWKBundleIntentRequest* WKBundleIntentRequestRef; typedef const struct OpaqueWKBundleNavigationAction* WKBundleNavigationActionRef; typedef const struct OpaqueWKBundleNodeHandle* WKBundleNodeHandleRef; typedef const struct OpaqueWKBundlePage* WKBundlePageRef; diff --git a/Source/WebKit2/Shared/APIObject.h b/Source/WebKit2/Shared/APIObject.h index 6e9c1d6f6..8e4d29342 100644 --- a/Source/WebKit2/Shared/APIObject.h +++ b/Source/WebKit2/Shared/APIObject.h @@ -117,6 +117,7 @@ public: TypeBundleFrame, TypeBundleHitTestResult, TypeBundleInspector, + TypeBundleIntentRequest, TypeBundleNavigationAction, TypeBundleNodeHandle, TypeBundlePage, diff --git a/Source/WebKit2/Shared/IntentData.cpp b/Source/WebKit2/Shared/IntentData.cpp index 388a3a567..4995b2ef5 100644 --- a/Source/WebKit2/Shared/IntentData.cpp +++ b/Source/WebKit2/Shared/IntentData.cpp @@ -31,11 +31,22 @@ #include "APIObject.h" #include "DataReference.h" #include "WebCoreArgumentCoders.h" +#include <WebCore/Intent.h> using namespace WebCore; namespace WebKit { +IntentData::IntentData(Intent* coreIntent) + : action(coreIntent->action()) + , type(coreIntent->type()) + , service(coreIntent->service()) + , data(coreIntent->data()->data()) + , extras(coreIntent->extras()) + , suggestions(coreIntent->suggestions()) +{ +} + void IntentData::encode(CoreIPC::ArgumentEncoder* encoder) const { encoder->encode(action); diff --git a/Source/WebKit2/Shared/IntentData.h b/Source/WebKit2/Shared/IntentData.h index 293577633..96e2d9f99 100644 --- a/Source/WebKit2/Shared/IntentData.h +++ b/Source/WebKit2/Shared/IntentData.h @@ -37,9 +37,16 @@ class ArgumentDecoder; class ArgumentEncoder; } +namespace WebCore { +class Intent; +} + namespace WebKit { struct IntentData { + IntentData() { } + explicit IntentData(WebCore::Intent*); + void encode(CoreIPC::ArgumentEncoder*) const; static bool decode(CoreIPC::ArgumentDecoder*, IntentData&); diff --git a/Source/WebKit2/Shared/LayerTreeContext.h b/Source/WebKit2/Shared/LayerTreeContext.h index 710d9da81..388514db0 100644 --- a/Source/WebKit2/Shared/LayerTreeContext.h +++ b/Source/WebKit2/Shared/LayerTreeContext.h @@ -58,6 +58,8 @@ public: uint32_t webLayerID; #elif PLATFORM(GTK) uint64_t windowHandle; +#elif PLATFORM(EFL) + uint32_t webLayerID; #endif }; diff --git a/Source/WebKit2/Shared/WebEventConversion.cpp b/Source/WebKit2/Shared/WebEventConversion.cpp index 8b61e27b2..0fad683e6 100644 --- a/Source/WebKit2/Shared/WebEventConversion.cpp +++ b/Source/WebKit2/Shared/WebEventConversion.cpp @@ -319,7 +319,7 @@ public: m_timestamp = webEvent.timestamp(); // PlatformTouchEvent - for (int i = 0; i < webEvent.touchPoints().size(); ++i) + for (size_t i = 0; i < webEvent.touchPoints().size(); ++i) m_touchPoints.append(WebKit2PlatformTouchPoint(webEvent.touchPoints().at(i))); } }; diff --git a/Source/WebKit2/Shared/WebPreferencesStore.h b/Source/WebKit2/Shared/WebPreferencesStore.h index 0a84cdbf8..83e0596f2 100644 --- a/Source/WebKit2/Shared/WebPreferencesStore.h +++ b/Source/WebKit2/Shared/WebPreferencesStore.h @@ -113,6 +113,7 @@ namespace WebKit { macro(ShouldRespectImageOrientation, shouldRespectImageOrientation, Bool, bool, false) \ macro(WantsBalancedSetDefersLoadingBehavior, wantsBalancedSetDefersLoadingBehavior, Bool, bool, false) \ macro(RequestAnimationFrameEnabled, requestAnimationFrameEnabled, Bool, bool, true) \ + macro(DiagnosticLoggingEnabled, diagnosticLoggingEnabled, Bool, bool, false) \ \ #define FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \ diff --git a/Source/WebKit2/Shared/efl/LayerTreeContextEfl.cpp b/Source/WebKit2/Shared/efl/LayerTreeContextEfl.cpp new file mode 100644 index 000000000..881d78782 --- /dev/null +++ b/Source/WebKit2/Shared/efl/LayerTreeContextEfl.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2012 Samsung Electronics. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "LayerTreeContext.h" + +#include "ArgumentDecoder.h" +#include "ArgumentEncoder.h" + +namespace WebKit { + +LayerTreeContext::LayerTreeContext() + : webLayerID(0) +{ +} + +LayerTreeContext::~LayerTreeContext() +{ +} + +void LayerTreeContext::encode(CoreIPC::ArgumentEncoder* encoder) const +{ + encoder->encode(webLayerID); +} + +bool LayerTreeContext::decode(CoreIPC::ArgumentDecoder* decoder, LayerTreeContext& context) +{ + return decoder->decode(context.webLayerID); +} + +bool LayerTreeContext::isEmpty() const +{ + return !webLayerID; +} + +bool operator==(const LayerTreeContext& a, const LayerTreeContext& b) +{ + return a.webLayerID == b.webLayerID; +} + +} // namespace WebKit diff --git a/Source/WebKit2/Shared/efl/WebEventFactory.cpp b/Source/WebKit2/Shared/efl/WebEventFactory.cpp index ffe2cb5a9..74a0530a3 100644 --- a/Source/WebKit2/Shared/efl/WebEventFactory.cpp +++ b/Source/WebKit2/Shared/efl/WebEventFactory.cpp @@ -44,6 +44,8 @@ enum { RightButton = 3 }; +static const char keyPadPrefix[] = "KP_"; + static inline WebEvent::Modifiers modifiersForEvent(const Evas_Modifier* modifiers) { unsigned result = 0; @@ -158,7 +160,7 @@ WebWheelEvent WebEventFactory::createWebWheelEvent(const Evas_Event_Mouse_Wheel* WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const Evas_Event_Key_Down* event) { - String keyName = String(event->key); + const String keyName(event->key); return WebKeyboardEvent(WebEvent::KeyDown, String::fromUTF8(event->string), String::fromUTF8(event->string), @@ -167,7 +169,7 @@ WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const Evas_Event_Key_Do 0 /* FIXME: nativeVirtualKeyCode */, 0 /* macCharCode */, false /* FIXME: isAutoRepeat */, - false /* FIXME: isKeypad */, + keyName.startsWith(keyPadPrefix), false /* isSystemKey */, modifiersForEvent(event->modifiers), event->timestamp); @@ -175,7 +177,7 @@ WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const Evas_Event_Key_Do WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const Evas_Event_Key_Up* event) { - String keyName = String(event->key); + const String keyName(event->key); return WebKeyboardEvent(WebEvent::KeyUp, String::fromUTF8(event->string), String::fromUTF8(event->string), @@ -184,7 +186,7 @@ WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const Evas_Event_Key_Up 0 /* FIXME: nativeVirtualKeyCode */, 0 /* macCharCode */, false /* FIXME: isAutoRepeat */, - false /* FIXME: isKeypad */, + keyName.startsWith(keyPadPrefix), false /* isSystemKey */, modifiersForEvent(event->modifiers), event->timestamp); diff --git a/Source/WebKit2/Target.pri b/Source/WebKit2/Target.pri index e80967278..f9fc48791 100644 --- a/Source/WebKit2/Target.pri +++ b/Source/WebKit2/Target.pri @@ -319,6 +319,7 @@ HEADERS += \ WebProcess/InjectedBundle/API/c/WKBundleBackForwardList.h \ WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.h \ WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h \ + WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.h \ WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.h \ WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.h \ WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h \ @@ -331,8 +332,10 @@ HEADERS += \ WebProcess/InjectedBundle/InjectedBundleClient.h \ WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.h \ WebProcess/InjectedBundle/InjectedBundleHitTestResult.h \ + WebProcess/InjectedBundle/InjectedBundleIntentRequest.h \ WebProcess/InjectedBundle/InjectedBundleNavigationAction.h \ WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.h \ + WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.h \ WebProcess/InjectedBundle/InjectedBundlePageFormClient.h \ WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.h \ WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.h \ @@ -700,6 +703,7 @@ SOURCES += \ WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp \ WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp \ WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp \ + WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.cpp \ WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp \ WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp \ WebProcess/InjectedBundle/API/c/WKBundlePage.cpp \ @@ -714,8 +718,10 @@ SOURCES += \ WebProcess/InjectedBundle/InjectedBundleClient.cpp \ WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.cpp \ WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp \ + WebProcess/InjectedBundle/InjectedBundleIntentRequest.cpp \ WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp \ WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.cpp \ + WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.cpp \ WebProcess/InjectedBundle/InjectedBundlePageEditorClient.cpp \ WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp \ WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.cpp \ diff --git a/Source/WebKit2/UIProcess/API/C/WKContext.cpp b/Source/WebKit2/UIProcess/API/C/WKContext.cpp index 7fadf3087..e90d1129a 100644 --- a/Source/WebKit2/UIProcess/API/C/WKContext.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKContext.cpp @@ -112,7 +112,7 @@ void WKContextGetGlobalStatistics(WKContextStatistics* statistics) statistics->wkViewCount = webContextStatistics.wkViewCount; statistics->wkPageCount = webContextStatistics.wkPageCount; - statistics->wkFrameCount = webContextStatistics.wkViewCount; + statistics->wkFrameCount = webContextStatistics.wkFrameCount; } void WKContextAddVisitedLink(WKContextRef contextRef, WKStringRef visitedURL) diff --git a/Source/WebKit2/UIProcess/API/C/WKIntentData.cpp b/Source/WebKit2/UIProcess/API/C/WKIntentData.cpp index a42f530ac..7a92db54c 100644 --- a/Source/WebKit2/UIProcess/API/C/WKIntentData.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKIntentData.cpp @@ -29,6 +29,8 @@ #include "ImmutableArray.h" #include "ImmutableDictionary.h" #include "WKAPICast.h" +#include "WKDictionary.h" +#include "WKString.h" #if ENABLE(WEB_INTENTS) #include "WebIntentData.h" @@ -45,6 +47,27 @@ WKTypeID WKIntentDataGetTypeID() #endif } +WKIntentDataRef WKIntentDataCreate(WKDictionaryRef initDictionaryRef) +{ +#if ENABLE(WEB_INTENTS) + IntentData intentData; + WKStringRef action = static_cast<WKStringRef>(WKDictionaryGetItemForKey(initDictionaryRef, WKStringCreateWithUTF8CString("action"))); + ASSERT(action); + intentData.action = toImpl(action)->string(); + WKStringRef type = static_cast<WKStringRef>(WKDictionaryGetItemForKey(initDictionaryRef, WKStringCreateWithUTF8CString("type"))); + ASSERT(type); + intentData.type = toImpl(type)->string(); + WKSerializedScriptValueRef data = static_cast<WKSerializedScriptValueRef>(WKDictionaryGetItemForKey(initDictionaryRef, WKStringCreateWithUTF8CString("data"))); + if (data) + intentData.data = toImpl(data)->dataReference().vector(); + + RefPtr<WebIntentData> webIntentData = WebIntentData::create(intentData); + return toAPI(webIntentData.release().leakRef()); +#else + return 0; +#endif +} + WKStringRef WKIntentDataCopyAction(WKIntentDataRef intentRef) { #if ENABLE(WEB_INTENTS) diff --git a/Source/WebKit2/UIProcess/API/C/WKIntentData.h b/Source/WebKit2/UIProcess/API/C/WKIntentData.h index 030555b4b..1f809ec8d 100644 --- a/Source/WebKit2/UIProcess/API/C/WKIntentData.h +++ b/Source/WebKit2/UIProcess/API/C/WKIntentData.h @@ -33,6 +33,9 @@ extern "C" { #endif WK_EXPORT WKTypeID WKIntentDataGetTypeID(); + +WK_EXPORT WKIntentDataRef WKIntentDataCreate(WKDictionaryRef initDictionary); + WK_EXPORT WKStringRef WKIntentDataCopyAction(WKIntentDataRef intentRef); WK_EXPORT WKStringRef WKIntentDataCopyType(WKIntentDataRef intentRef); WK_EXPORT WKURLRef WKIntentDataCopyService(WKIntentDataRef intentRef); diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp index 727781f01..243a17369 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp @@ -823,3 +823,13 @@ void WKPreferencesResetTestRunnerOverrides(WKPreferencesRef preferencesRef) // are usually always the same (in the UI process), they are not sent to web process, not triggering the reset. toImpl(preferencesRef)->forceUpdate(); } + +void WKPreferencesSetDiagnosticLoggingEnabled(WKPreferencesRef preferencesRef, bool enabled) +{ + toImpl(preferencesRef)->setDiagnosticLoggingEnabled(enabled); +} + +bool WKPreferencesGetDiagnosticLoggingEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->diagnosticLoggingEnabled(); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h b/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h index 6dbc47310..371c539a1 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h +++ b/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h @@ -187,6 +187,10 @@ WK_EXPORT bool WKPreferencesGetJavaEnabledForLocalFiles(WKPreferencesRef prefere WK_EXPORT void WKPreferencesSetRequestAnimationFrameEnabled(WKPreferencesRef, bool); WK_EXPORT bool WKPreferencesGetRequestAnimationFrameEnabled(WKPreferencesRef); +// Defaults to false +WK_EXPORT void WKPreferencesSetDiagnosticLoggingEnabled(WKPreferencesRef preferencesRef, bool enabled); +WK_EXPORT bool WKPreferencesGetDiagnosticLoggingEnabled(WKPreferencesRef preferencesRef); + WK_EXPORT void WKPreferencesResetTestRunnerOverrides(WKPreferencesRef preferencesRef); #ifdef __cplusplus diff --git a/Source/WebKit2/UIProcess/API/efl/EWebKit2.h b/Source/WebKit2/UIProcess/API/efl/EWebKit2.h index 597cf24cb..9a052da4b 100644 --- a/Source/WebKit2/UIProcess/API/efl/EWebKit2.h +++ b/Source/WebKit2/UIProcess/API/efl/EWebKit2.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2012 Samsung Electronics + * Copyright (C) 2012 Intel Corporation. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -29,8 +30,11 @@ #include "ewk_context.h" #include "ewk_cookie_manager.h" +#include "ewk_download_job.h" +#include "ewk_form_submission_request.h" #include "ewk_intent.h" #include "ewk_intent_service.h" +#include "ewk_main.h" #include "ewk_navigation_policy_decision.h" #include "ewk_url_request.h" #include "ewk_url_response.h" diff --git a/Source/WebKit2/UIProcess/API/efl/NetworkInfoProvider.cpp b/Source/WebKit2/UIProcess/API/efl/NetworkInfoProvider.cpp new file mode 100644 index 000000000..54a6921da --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/NetworkInfoProvider.cpp @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "NetworkInfoProvider.h" + +#if ENABLE(NETWORK_INFO) + +#include "WKNetworkInfoManager.h" +#include <NotImplemented.h> + +static inline NetworkInfoProvider* toNetworkInfoProvider(const void* clientInfo) +{ + return static_cast<NetworkInfoProvider*>(const_cast<void*>(clientInfo)); +} + +static void startUpdatingCallback(WKNetworkInfoManagerRef, const void* clientInfo) +{ + toNetworkInfoProvider(clientInfo)->startUpdating(); +} + +static void stopUpdatingCallback(WKNetworkInfoManagerRef, const void* clientInfo) +{ + toNetworkInfoProvider(clientInfo)->stopUpdating(); +} + +static double getBandwidthCallback(WKNetworkInfoManagerRef, const void* clientInfo) +{ + return toNetworkInfoProvider(clientInfo)->bandwidth(); +} + +static bool isMeteredCallback(WKNetworkInfoManagerRef, const void* clientInfo) +{ + return toNetworkInfoProvider(clientInfo)->metered(); +} + +PassRefPtr<NetworkInfoProvider> NetworkInfoProvider::create(WKNetworkInfoManagerRef wkManager) +{ + return adoptRef(new NetworkInfoProvider(wkManager)); +} + +NetworkInfoProvider::NetworkInfoProvider(WKNetworkInfoManagerRef wkManager) + : m_wkNetworkInfoManager(wkManager) +{ + ASSERT(wkManager); + + WKNetworkInfoProvider wkNetworkInfoProvider = { + kWKNetworkInfoProviderCurrentVersion, + this, // clientInfo + startUpdatingCallback, + stopUpdatingCallback, + getBandwidthCallback, + isMeteredCallback + }; + WKNetworkInfoManagerSetProvider(m_wkNetworkInfoManager.get(), &wkNetworkInfoProvider); +} + +NetworkInfoProvider::~NetworkInfoProvider() +{ +} + +double NetworkInfoProvider::bandwidth() const +{ + return m_provider.bandwidth(); +} + +bool NetworkInfoProvider::metered() const +{ + notImplemented(); + + return false; +} + +void NetworkInfoProvider::startUpdating() +{ + m_provider.startUpdating(); +} + +void NetworkInfoProvider::stopUpdating() +{ + m_provider.stopUpdating(); +} + +#endif // ENABLE(NETWORK_INFO) diff --git a/Source/WebKit2/UIProcess/API/efl/NetworkInfoProvider.h b/Source/WebKit2/UIProcess/API/efl/NetworkInfoProvider.h new file mode 100644 index 000000000..b9f86e6e5 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/NetworkInfoProvider.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef NetworkInfoProvider_h +#define NetworkInfoProvider_h + +#if ENABLE(NETWORK_INFO) + +#include <NetworkInfoClient.h> +#include <NetworkInfoProviderEfl.h> +#include <WebKit2/WKBase.h> +#include <WebKit2/WKRetainPtr.h> +#include <wtf/PassRefPtr.h> + +class NetworkInfoProvider : public RefCounted<NetworkInfoProvider>, public WebCore::NetworkInfoClient { +public: + virtual ~NetworkInfoProvider(); + static PassRefPtr<NetworkInfoProvider> create(WKNetworkInfoManagerRef); + + // NetworkInfoClient interface. + virtual double bandwidth() const; + virtual bool metered() const; + + virtual void startUpdating(); + virtual void stopUpdating(); + +private: + NetworkInfoProvider(WKNetworkInfoManagerRef); + + WKRetainPtr<WKNetworkInfoManagerRef> m_wkNetworkInfoManager; + WebCore::NetworkInfoProviderEfl m_provider; +}; + +#endif // ENABLE(NETWORK_INFO) + +#endif // NetworkInfoProvider_h diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp index e69f87d28..79d20a17d 100644 --- a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp +++ b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp @@ -32,6 +32,10 @@ #include "WebContext.h" #include "WebContextMenuProxy.h" #include "WebPageProxy.h" +#include "ewk_context.h" +#include "ewk_context_private.h" +#include "ewk_download_job.h" +#include "ewk_download_job_private.h" #include "ewk_view_private.h" using namespace WebCore; @@ -72,9 +76,7 @@ void PageClientImpl::scrollView(const WebCore::IntRect& scrollRect, const WebCor WebCore::IntSize PageClientImpl::viewSize() { - int width, height; - evas_object_geometry_get(m_viewWidget, 0, 0, &width, &height); - return IntSize(width, height); + return ewk_view_size_get(m_viewWidget); } bool PageClientImpl::isViewWindowActive() @@ -121,9 +123,9 @@ void PageClientImpl::toolTipChanged(const String&, const String&) notImplemented(); } -void PageClientImpl::setCursor(const Cursor&) +void PageClientImpl::setCursor(const Cursor& cursor) { - notImplemented(); + ewk_view_cursor_set(m_viewWidget, cursor); } void PageClientImpl::setCursorHiddenUntilMouseMoves(bool) @@ -221,12 +223,12 @@ void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator>, bool, bool) #if USE(ACCELERATED_COMPOSITING) void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext&) { - notImplemented(); + ewk_view_accelerated_compositing_mode_enter(m_viewWidget); } void PageClientImpl::exitAcceleratedCompositingMode() { - notImplemented(); + ewk_view_accelerated_compositing_mode_exit(m_viewWidget); } void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&) @@ -276,4 +278,21 @@ void PageClientImpl::countStringMatchesInCustomRepresentation(const String&, Fin notImplemented(); } +void PageClientImpl::handleDownloadRequest(DownloadProxy* download) +{ + Ewk_Download_Job* ewkDownload = ewk_download_job_new(download, m_viewWidget); + // For now we only support one default context, but once we support + // multiple contexts, we will need to retrieve the context from the + // view. + ewk_context_download_job_add(ewk_context_default_get(), ewkDownload); + ewk_download_job_unref(ewkDownload); +} + +#if USE(TILED_BACKING_STORE) +void PageClientImpl::pageDidRequestScroll(const IntPoint&) +{ + notImplemented(); +} +#endif + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h index 427ef5297..1bd22934a 100644 --- a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h +++ b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h @@ -76,6 +76,8 @@ private: virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&); virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&); + virtual void handleDownloadRequest(DownloadProxy*); + virtual void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool); #if ENABLE(TOUCH_EVENTS) virtual void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled); @@ -106,6 +108,10 @@ private: virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned); virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned); +#if USE(TILED_BACKING_STORE) + virtual void pageDidRequestScroll(const WebCore::IntPoint&); +#endif + private: RefPtr<WebPageProxy> m_page; Evas_Object* m_viewWidget; diff --git a/Source/WebKit2/UIProcess/API/efl/VibrationProvider.cpp b/Source/WebKit2/UIProcess/API/efl/VibrationProvider.cpp new file mode 100644 index 000000000..a96910638 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/VibrationProvider.cpp @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "VibrationProvider.h" + +#if ENABLE(VIBRATION) + +#include "WKAPICast.h" +#include "WKVibration.h" +#include <Evas.h> + +using namespace WebCore; + +/** + * \struct _Ewk_Vibration_Client + * @brief Contains the vibration client callbacks. + */ +struct _Ewk_Vibration_Client { + Ewk_Vibration_Client_Vibrate_Cb vibrate; + Ewk_Vibration_Client_Vibration_Cancel_Cb cancelVibration; + void* userData; + + _Ewk_Vibration_Client(Ewk_Vibration_Client_Vibrate_Cb vibrate, Ewk_Vibration_Client_Vibration_Cancel_Cb cancelVibration, void* userData) + : vibrate(vibrate) + , cancelVibration(cancelVibration) + , userData(userData) + { } +}; + +static inline VibrationProvider* toVibrationProvider(const void* clientInfo) +{ + return static_cast<VibrationProvider*>(const_cast<void*>(clientInfo)); +} + +static void vibrateCallback(WKVibrationRef vibrationRef, uint64_t vibrationTime, const void* clientInfo) +{ + toVibrationProvider(clientInfo)->vibrate(vibrationTime); +} + +static void cancelVibrationCallback(WKVibrationRef vibrationRef, const void* clientInfo) +{ + toVibrationProvider(clientInfo)->cancelVibration(); +} + +PassRefPtr<VibrationProvider> VibrationProvider::create(WKVibrationRef wkVibrationRef) +{ + return adoptRef(new VibrationProvider(wkVibrationRef)); +} + +VibrationProvider::VibrationProvider(WKVibrationRef wkVibrationRef) + : m_wkVibrationRef(wkVibrationRef) +{ + ASSERT(wkVibrationRef); + + WKVibrationProvider wkVibrationProvider = { + kWKVibrationProviderCurrentVersion, + this, // clientInfo + vibrateCallback, + cancelVibrationCallback + }; + WKVibrationSetProvider(m_wkVibrationRef.get(), &wkVibrationProvider); +} + +VibrationProvider::~VibrationProvider() +{ +} + +void VibrationProvider::vibrate(uint64_t vibrationTime) +{ + if (m_vibrationClient && m_vibrationClient->vibrate) + m_vibrationClient->vibrate(vibrationTime, m_vibrationClient->userData); +} + +void VibrationProvider::cancelVibration() +{ + if (m_vibrationClient && m_vibrationClient->cancelVibration) + m_vibrationClient->cancelVibration(m_vibrationClient->userData); +} + +void VibrationProvider::setVibrationClientCallbacks(Ewk_Vibration_Client_Vibrate_Cb vibrate, Ewk_Vibration_Client_Vibration_Cancel_Cb cancelVibration, void* data) +{ + m_vibrationClient = adoptPtr(new Ewk_Vibration_Client(vibrate, cancelVibration, data)); +} + +#endif // ENABLE(VIBRATION) diff --git a/Source/WebKit2/UIProcess/API/efl/VibrationProvider.h b/Source/WebKit2/UIProcess/API/efl/VibrationProvider.h new file mode 100644 index 000000000..c2643b638 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/VibrationProvider.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef VibrationProvider_h +#define VibrationProvider_h + +#if ENABLE(VIBRATION) + +#include "WKRetainPtr.h" +#include "ewk_context.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> + +typedef struct _Ewk_Vibration_Client Ewk_Vibration_Client; + +class VibrationProvider : public RefCounted<VibrationProvider> { +public: + static PassRefPtr<VibrationProvider> create(WKVibrationRef); + virtual ~VibrationProvider(); + + void vibrate(uint64_t vibrationTime); + void cancelVibration(); + void setVibrationClientCallbacks(Ewk_Vibration_Client_Vibrate_Cb, Ewk_Vibration_Client_Vibration_Cancel_Cb, void*); + +private: + explicit VibrationProvider(WKVibrationRef); + + WKRetainPtr<WKVibrationRef> m_wkVibrationRef; + OwnPtr<Ewk_Vibration_Client> m_vibrationClient; +}; + +#endif // ENABLE(VIBRATION) + +#endif // VibrationProvider_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp index b8607e584..f2ed417fc 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp @@ -22,13 +22,17 @@ #include "ewk_context.h" #include "BatteryProvider.h" +#include "VibrationProvider.h" #include "WKAPICast.h" #include "WKContextSoup.h" #include "WKRetainPtr.h" #include "WKString.h" +#include "ewk_context_download_client_private.h" #include "ewk_context_private.h" #include "ewk_context_request_manager_client_private.h" #include "ewk_cookie_manager_private.h" +#include "ewk_download_job.h" +#include "ewk_download_job_private.h" #include <wtf/HashMap.h> #include <wtf/text/WTFString.h> @@ -58,6 +62,10 @@ struct _Ewk_Context { #if ENABLE(BATTERY_STATUS) RefPtr<BatteryProvider> batteryProvider; #endif +#if ENABLE(VIBRATION) + RefPtr<VibrationProvider> vibrationProvider; +#endif + HashMap<uint64_t, Ewk_Download_Job*> downloadJobs; WKRetainPtr<WKSoupRequestManagerRef> requestManager; URLSchemeHandlerMap urlSchemeHandlers; @@ -72,13 +80,24 @@ struct _Ewk_Context { batteryProvider = BatteryProvider::create(wkBatteryManager); #endif +#if ENABLE(VIBRATION) + WKVibrationRef wkVibrationRef = WKContextGetVibration(contextRef); + vibrationProvider = VibrationProvider::create(wkVibrationRef); +#endif + ewk_context_request_manager_client_attach(this); + ewk_context_download_client_attach(this); } ~_Ewk_Context() { if (cookieManager) ewk_cookie_manager_free(cookieManager); + + HashMap<uint64_t, Ewk_Download_Job*>::iterator it = downloadJobs.begin(); + HashMap<uint64_t, Ewk_Download_Job*>::iterator end = downloadJobs.end(); + for ( ; it != end; ++it) + ewk_download_job_unref(it->second); } }; @@ -99,6 +118,47 @@ WKContextRef ewk_context_WKContext_get(const Ewk_Context* ewkContext) /** * @internal + * Registers that a new download has been requested. + */ +void ewk_context_download_job_add(Ewk_Context* ewkContext, Ewk_Download_Job* ewkDownload) +{ + EINA_SAFETY_ON_NULL_RETURN(ewkContext); + EINA_SAFETY_ON_NULL_RETURN(ewkDownload); + + uint64_t downloadId = ewk_download_job_id_get(ewkDownload); + if (ewkContext->downloadJobs.contains(downloadId)) + return; + + ewk_download_job_ref(ewkDownload); + ewkContext->downloadJobs.add(downloadId, ewkDownload); +} + +/** + * @internal + * Returns the #Ewk_Download_Job with the given @a downloadId, or + * @c 0 in case of failure. + */ +Ewk_Download_Job* ewk_context_download_job_get(const Ewk_Context* ewkContext, uint64_t downloadId) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0); + + return ewkContext->downloadJobs.get(downloadId); +} + +/** + * @internal + * Removes the #Ewk_Download_Job with the given @a downloadId from the internal + * HashMap. + */ +void ewk_context_download_job_remove(Ewk_Context* ewkContext, uint64_t downloadId) +{ + EINA_SAFETY_ON_NULL_RETURN(ewkContext); + Ewk_Download_Job* download = ewkContext->downloadJobs.take(downloadId); + if (download) + ewk_download_job_unref(download); +} + +/** * Retrieve the request manager for @a ewkContext. * * @param ewkContext a #Ewk_Context object. @@ -151,3 +211,12 @@ Eina_Bool ewk_context_uri_scheme_register(Ewk_Context* ewkContext, const char* s return true; } + +void ewk_context_vibration_client_callbacks_set(Ewk_Context* ewkContext, Ewk_Vibration_Client_Vibrate_Cb vibrate, Ewk_Vibration_Client_Vibration_Cancel_Cb cancel, void* data) +{ + EINA_SAFETY_ON_NULL_RETURN(ewkContext); + +#if ENABLE(VIBRATION) + ewkContext->vibrationProvider->setVibrationClientCallbacks(vibrate, cancel, data); +#endif +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context.h b/Source/WebKit2/UIProcess/API/efl/ewk_context.h index 3df362f6f..5e4d34262 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context.h @@ -47,6 +47,20 @@ typedef struct _Ewk_Context Ewk_Context; typedef void (*Ewk_Url_Scheme_Request_Cb) (Ewk_Url_Scheme_Request *request, void *user_data); /** + * @typedef Ewk_Vibration_Client_Vibrate_Cb Ewk_Vibration_Client_Vibrate_Cb + * @brief Type definition for a function that will be called back when vibrate + * request receiveed from the vibration controller. + */ +typedef void (*Ewk_Vibration_Client_Vibrate_Cb)(uint64_t vibration_time, void *user_data); + +/** + * @typedef Ewk_Vibration_Client_Vibration_Cancel_Cb Ewk_Vibration_Client_Vibration_Cancel_Cb + * @brief Type definition for a function that will be called back when cancel + * vibration request receiveed from the vibration controller. + */ +typedef void (*Ewk_Vibration_Client_Vibration_Cancel_Cb)(void *user_data); + +/** * Gets default Ewk_Context instance. * * @return Ewk_Context object. @@ -105,6 +119,22 @@ EAPI Ewk_Cookie_Manager *ewk_context_cookie_manager_get(const Ewk_Context *conte */ EAPI Eina_Bool ewk_context_uri_scheme_register(Ewk_Context *context, const char *scheme, Ewk_Url_Scheme_Request_Cb callback, void *user_data); +/** + * Sets vibration client callbacks to handle the tactile feedback in the form of + * vibration in the client application when the content asks for vibration. + * + * To stop listening for vibration events, you may call this function with @c + * NULL for the callbacks. + * + * @param context context object to set vibration client callbacks. + * @param vibrate The function to call when the vibrate request received from the + * controller (may be @c NULL). + * @param cancel The function to call when the cancel vibration request received + * from the controller (may be @c NULL). + * @param data User data (may be @c NULL). + */ +EAPI void ewk_context_vibration_client_callbacks_set(Ewk_Context *context, Ewk_Vibration_Client_Vibrate_Cb vibrate, Ewk_Vibration_Client_Vibration_Cancel_Cb cancel, void *data); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context_download_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_context_download_client.cpp new file mode 100644 index 000000000..1cb7e17f2 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context_download_client.cpp @@ -0,0 +1,145 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "DownloadProxy.h" +#include "WKAPICast.h" +#include "WKContext.h" +#include "WKString.h" +#include "ewk_context_download_client_private.h" +#include "ewk_context_private.h" +#include "ewk_download_job.h" +#include "ewk_download_job_private.h" +#include "ewk_url_response.h" +#include "ewk_url_response_private.h" +#include "ewk_view_private.h" +#include "ewk_web_error.h" +#include "ewk_web_error_private.h" +#include <string.h> +#include <wtf/text/CString.h> + +using namespace WebKit; + +static inline Ewk_Context* toEwkContext(const void* clientInfo) +{ + return static_cast<Ewk_Context*>(const_cast<void*>(clientInfo)); +} + +static WKStringRef decideDestinationWithSuggestedFilename(WKContextRef, WKDownloadRef wkDownload, WKStringRef filename, bool* allowOverwrite, const void* clientInfo) +{ + Ewk_Download_Job* download = ewk_context_download_job_get(toEwkContext(clientInfo), toImpl(wkDownload)->downloadID()); + ASSERT(download); + + ewk_download_job_suggested_filename_set(download, toImpl(filename)->string().utf8().data()); + + // We send the new download signal on the Ewk_View only once we have received the response + // and the suggested file name. + ewk_view_download_job_requested(ewk_download_job_view_get(download), download); + + // DownloadSoup expects the destination to be a URI. + String destination = String("file://") + String::fromUTF8(ewk_download_job_destination_get(download)); + + return WKStringCreateWithUTF8CString(destination.utf8().data()); +} + +static void didReceiveResponse(WKContextRef, WKDownloadRef wkDownload, WKURLResponseRef wkResponse, const void* clientInfo) +{ + Ewk_Download_Job* download = ewk_context_download_job_get(toEwkContext(clientInfo), toImpl(wkDownload)->downloadID()); + ASSERT(download); + Ewk_Url_Response* response = ewk_url_response_new(toImpl(wkResponse)->resourceResponse()); + ewk_download_job_response_set(download, response); + ewk_url_response_unref(response); +} + +static void didCreateDestination(WKContextRef, WKDownloadRef wkDownload, WKStringRef path, const void* clientInfo) +{ + Ewk_Download_Job* download = ewk_context_download_job_get(toEwkContext(clientInfo), toImpl(wkDownload)->downloadID()); + ASSERT(download); + + ewk_download_job_state_set(download, EWK_DOWNLOAD_JOB_STATE_DOWNLOADING); +} + +static void didReceiveData(WKContextRef, WKDownloadRef wkDownload, uint64_t length, const void* clientInfo) +{ + Ewk_Download_Job* download = ewk_context_download_job_get(toEwkContext(clientInfo), toImpl(wkDownload)->downloadID()); + ASSERT(download); + ewk_download_job_received_data(download, length); +} + +static void didFail(WKContextRef, WKDownloadRef wkDownload, WKErrorRef error, const void *clientInfo) +{ + uint64_t downloadId = toImpl(wkDownload)->downloadID(); + Ewk_Download_Job* download = ewk_context_download_job_get(toEwkContext(clientInfo), downloadId); + ASSERT(download); + + Ewk_Web_Error* ewkError = ewk_web_error_new(error); + ewk_download_job_state_set(download, EWK_DOWNLOAD_JOB_STATE_FAILED); + ewk_view_download_job_failed(ewk_download_job_view_get(download), download, ewkError); + ewk_web_error_free(ewkError); + ewk_context_download_job_remove(toEwkContext(clientInfo), downloadId); +} + +static void didCancel(WKContextRef, WKDownloadRef wkDownload, const void *clientInfo) +{ + uint64_t downloadId = toImpl(wkDownload)->downloadID(); + Ewk_Download_Job* download = ewk_context_download_job_get(toEwkContext(clientInfo), downloadId); + ASSERT(download); + + ewk_download_job_state_set(download, EWK_DOWNLOAD_JOB_STATE_CANCELLED); + ewk_view_download_job_cancelled(ewk_download_job_view_get(download), download); + ewk_context_download_job_remove(toEwkContext(clientInfo), downloadId); +} + +static void didFinish(WKContextRef, WKDownloadRef wkDownload, const void *clientInfo) +{ + uint64_t downloadId = toImpl(wkDownload)->downloadID(); + Ewk_Download_Job* download = ewk_context_download_job_get(toEwkContext(clientInfo), downloadId); + ASSERT(download); + + ewk_download_job_state_set(download, EWK_DOWNLOAD_JOB_STATE_FINISHED); + ewk_view_download_job_finished(ewk_download_job_view_get(download), download); + ewk_context_download_job_remove(toEwkContext(clientInfo), downloadId); +} + +void ewk_context_download_client_attach(Ewk_Context* ewkContext) +{ + WKContextDownloadClient wkDownloadClient; + memset(&wkDownloadClient, 0, sizeof(WKContextDownloadClient)); + + wkDownloadClient.version = kWKContextDownloadClientCurrentVersion; + wkDownloadClient.clientInfo = ewkContext; + wkDownloadClient.didCancel = didCancel; + wkDownloadClient.decideDestinationWithSuggestedFilename = decideDestinationWithSuggestedFilename; + wkDownloadClient.didCreateDestination = didCreateDestination; + wkDownloadClient.didReceiveResponse = didReceiveResponse; + wkDownloadClient.didReceiveData = didReceiveData; + wkDownloadClient.didFail = didFail; + wkDownloadClient.didFinish = didFinish; + + WKContextSetDownloadClient(ewk_context_WKContext_get(ewkContext), &wkDownloadClient); +} + + diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context_download_client_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_context_download_client_private.h new file mode 100644 index 000000000..f7017a863 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context_download_client_private.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ewk_context_download_client_private_h +#define ewk_context_download_client_private_h + +typedef struct _Ewk_Context Ewk_Context; + +void ewk_context_download_client_attach(Ewk_Context*); + +#endif // ewk_context_download_client_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h index d78e1e961..db9e911d2 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h @@ -23,10 +23,15 @@ #include <WebKit2/WKBase.h> typedef struct _Ewk_Context Ewk_Context; +typedef struct _Ewk_Download_Job Ewk_Download_Job; typedef struct _Ewk_Url_Scheme_Request Ewk_Url_Scheme_Request; WKContextRef ewk_context_WKContext_get(const Ewk_Context*); WKSoupRequestManagerRef ewk_context_request_manager_get(const Ewk_Context*); void ewk_context_url_scheme_request_received(Ewk_Context*, Ewk_Url_Scheme_Request*); +void ewk_context_download_job_add(Ewk_Context*, Ewk_Download_Job*); +Ewk_Download_Job* ewk_context_download_job_get(const Ewk_Context*, uint64_t downloadId); +void ewk_context_download_job_remove(Ewk_Context*, uint64_t downloadId); + #endif // ewk_context_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.cpp index 02f1fbd76..45dd75e63 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.cpp @@ -40,16 +40,47 @@ using namespace WebKit; +struct Cookie_Change_Handler { + Ewk_Cookie_Manager_Changes_Watch_Cb callback; + void* userData; + + Cookie_Change_Handler() + : callback(0) + , userData(0) + { } + + Cookie_Change_Handler(Ewk_Cookie_Manager_Changes_Watch_Cb _callback, void* _userData) + : callback(_callback) + , userData(_userData) + { } +}; + +static void cookiesDidChange(WKCookieManagerRef, const void* clientInfo); + /** * \struct _Ewk_Cookie_Manager * @brief Contains the cookie manager data. */ struct _Ewk_Cookie_Manager { WKRetainPtr<WKCookieManagerRef> wkCookieManager; + Cookie_Change_Handler changeHandler; _Ewk_Cookie_Manager(WKCookieManagerRef cookieManagerRef) : wkCookieManager(cookieManagerRef) - { } + { + WKCookieManagerClient wkCookieManagerClient = { + kWKCookieManagerClientCurrentVersion, + this, // clientInfo + cookiesDidChange + }; + WKCookieManagerSetClient(wkCookieManager.get(), &wkCookieManagerClient); + } + + ~_Ewk_Cookie_Manager() + { + if (changeHandler.callback) + WKCookieManagerStopObservingCookieChanges(wkCookieManager.get()); + } }; #define EWK_COOKIE_MANAGER_WK_GET_OR_RETURN(manager, wkManager_, ...) \ @@ -72,12 +103,28 @@ COMPILE_ASSERT_MATCHING_ENUM(EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY, kWKHTTPCoo COMPILE_ASSERT_MATCHING_ENUM(EWK_COOKIE_PERSISTENT_STORAGE_TEXT, SoupCookiePersistentStorageText); COMPILE_ASSERT_MATCHING_ENUM(EWK_COOKIE_PERSISTENT_STORAGE_SQLITE, SoupCookiePersistentStorageSQLite); +static void cookiesDidChange(WKCookieManagerRef, const void* clientInfo) +{ + Ewk_Cookie_Manager* manager = static_cast<Ewk_Cookie_Manager*>(const_cast<void*>(clientInfo)); + + if (!manager->changeHandler.callback) + return; + + manager->changeHandler.callback(manager->changeHandler.userData); +} + void ewk_cookie_manager_persistent_storage_set(Ewk_Cookie_Manager* manager, const char* filename, Ewk_Cookie_Persistent_Storage storage) { EWK_COOKIE_MANAGER_WK_GET_OR_RETURN(manager, wkManager); EINA_SAFETY_ON_NULL_RETURN(filename); + if (manager->changeHandler.callback) + WKCookieManagerStopObservingCookieChanges(wkManager); + toImpl(wkManager)->setCookiePersistentStorage(String::fromUTF8(filename), storage); + + if (manager->changeHandler.callback) + WKCookieManagerStartObservingCookieChanges(wkManager); } void ewk_cookie_manager_accept_policy_set(Ewk_Cookie_Manager* manager, Ewk_Cookie_Accept_Policy policy) @@ -174,6 +221,18 @@ void ewk_cookie_manager_cookies_clear(Ewk_Cookie_Manager* manager) WKCookieManagerDeleteAllCookies(wkManager); } +void ewk_cookie_manager_changes_watch(Ewk_Cookie_Manager* manager, Ewk_Cookie_Manager_Changes_Watch_Cb callback, void* data) +{ + EWK_COOKIE_MANAGER_WK_GET_OR_RETURN(manager, wkManager); + + manager->changeHandler = Cookie_Change_Handler(callback, data); + + if (callback) + WKCookieManagerStartObservingCookieChanges(wkManager); + else + WKCookieManagerStopObservingCookieChanges(wkManager); +} + /** * @internal * Frees a Ewk_Cookie_Manager object. diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.h b/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.h index e93ed8ed8..e37780864 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.h @@ -90,6 +90,12 @@ typedef void (*Ewk_Cookie_Manager_Async_Policy_Get_Cb)(Ewk_Cookie_Accept_Policy typedef void (*Ewk_Cookie_Manager_Async_Hostnames_Get_Cb)(Eina_List* hostnames, Ewk_Web_Error *error, void *event_info); /** + * @typedef Ewk_Cookie_Manager_Changes_Watch_Cb Ewk_Cookie_Manager_Changes_Watch_Cb + * @brief Callback type for use with ewk_cookie_manager_changes_watch() + */ +typedef void (*Ewk_Cookie_Manager_Changes_Watch_Cb)(void *event_info); + +/** * Set the @a filename where non-session cookies are stored persistently using @a storage as the format to read/write the cookies. * * Cookies are initially read from @filename to create an initial set of cookies. @@ -144,6 +150,17 @@ EAPI void ewk_cookie_manager_async_hostnames_with_cookies_get(const Ewk_Cookie_M EAPI void ewk_cookie_manager_hostname_cookies_clear(Ewk_Cookie_Manager *manager, const char *hostname); /** + * Watch for cookies changes in @a manager. + * + * Pass @c NULL as value for @a callback to stop watching for changes. + * + * @param manager The cookie manager to watch. + * @param callback function that will be called every time cookies are added, removed or modified. + * @param data User data (may be @c NULL). + */ +EAPI void ewk_cookie_manager_changes_watch(Ewk_Cookie_Manager *manager, Ewk_Cookie_Manager_Changes_Watch_Cb callback, void *data); + +/** * Delete all cookies of @a manager. * * @param manager The cookie manager to update. diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_download_job.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_download_job.cpp new file mode 100644 index 000000000..c41681071 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_download_job.cpp @@ -0,0 +1,282 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ewk_download_job.h" + +#include "DownloadProxy.h" +#include "WKAPICast.h" +#include "WKRetainPtr.h" +#include "WebURLRequest.h" +#include "ewk_download_job_private.h" +#include "ewk_url_request_private.h" +#include <Ecore.h> + +using namespace WebKit; + +/** + * \struct _Ewk_Download_Job + * @brief Contains the download data. + */ +struct _Ewk_Download_Job { + unsigned int __ref; /**< the reference count of the object */ + DownloadProxy* downloadProxy; + Evas_Object* view; + Ewk_Download_Job_State state; + Ewk_Url_Request* request; + Ewk_Url_Response* response; + double startTime; + double endTime; + uint64_t downloaded; /**< length already downloaded */ + const char* destination; + const char* suggestedFilename; + + _Ewk_Download_Job(DownloadProxy* download, Evas_Object* ewkView) + : __ref(1) + , downloadProxy(download) + , view(ewkView) + , state(EWK_DOWNLOAD_JOB_STATE_NOT_STARTED) + , request(0) + , response(0) + , startTime(-1) + , endTime(-1) + , downloaded(0) + , destination(0) + , suggestedFilename(0) + { } + + ~_Ewk_Download_Job() + { + ASSERT(!__ref); + if (request) + ewk_url_request_unref(request); + if (response) + ewk_url_response_unref(response); + eina_stringshare_del(destination); + eina_stringshare_del(suggestedFilename); + } +}; + +void ewk_download_job_ref(Ewk_Download_Job* download) +{ + EINA_SAFETY_ON_NULL_RETURN(download); + + ++download->__ref; +} + +void ewk_download_job_unref(Ewk_Download_Job* download) +{ + EINA_SAFETY_ON_NULL_RETURN(download); + + if (--download->__ref) + return; + + delete download; +} + +/** + * @internal + * Queries the identifier for this download + */ +uint64_t ewk_download_job_id_get(const Ewk_Download_Job* download) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(download, 0); + EINA_SAFETY_ON_NULL_RETURN_VAL(download->downloadProxy, 0); + + return download->downloadProxy->downloadID(); +} + +/** + * @internal + * Returns the view this download is attached to. + * The view is needed to send notification signals. + */ +Evas_Object* ewk_download_job_view_get(const Ewk_Download_Job* download) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(download, 0); + + return download->view; +} + +Ewk_Download_Job_State ewk_download_job_state_get(const Ewk_Download_Job* download) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(download, EWK_DOWNLOAD_JOB_STATE_UNKNOWN); + + return download->state; +} + +Ewk_Url_Request* ewk_download_job_request_get(const Ewk_Download_Job* download) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(download, 0); + + if (!download->request) { + EINA_SAFETY_ON_NULL_RETURN_VAL(download->downloadProxy, 0); + WKRetainPtr<WKURLRequestRef> wkURLRequest(AdoptWK, toAPI(WebURLRequest::create(download->downloadProxy->request()).leakRef())); + const_cast<Ewk_Download_Job*>(download)->request = ewk_url_request_new(wkURLRequest.get()); + } + + return download->request; +} + +Ewk_Url_Response* ewk_download_job_response_get(const Ewk_Download_Job* download) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(download, 0); + + return download->response; +} + +const char* ewk_download_job_destination_get(const Ewk_Download_Job* download) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(download, 0); + + return download->destination; +} + +Eina_Bool ewk_download_job_destination_set(Ewk_Download_Job* download, const char* destination) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(download, false); + EINA_SAFETY_ON_NULL_RETURN_VAL(destination, false); + + eina_stringshare_replace(&download->destination, destination); + + return true; +} + +const char *ewk_download_job_suggested_filename_get(const Ewk_Download_Job* download) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(download, 0); + + return download->suggestedFilename; +} + +Eina_Bool ewk_download_job_cancel(Ewk_Download_Job* download) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(download, false); + EINA_SAFETY_ON_NULL_RETURN_VAL(download->downloadProxy, false); + + if (download->state != EWK_DOWNLOAD_JOB_STATE_DOWNLOADING) + return false; + + download->state = EWK_DOWNLOAD_JOB_STATE_CANCELLING; + download->downloadProxy->cancel(); + return true; +} + +double ewk_download_job_estimated_progress_get(const Ewk_Download_Job* download) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(download, 0); + + if (!download->response) + return 0; + + const unsigned long contentLength = ewk_url_response_content_length_get(download->response); + if (!contentLength) + return 0; + + return static_cast<double>(download->downloaded) / contentLength; +} + +double ewk_download_job_elapsed_time_get(const Ewk_Download_Job* download) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(download, 0); + + // Download has not started yet. + if (download->startTime < 0) + return 0; + + // Download had ended, return the time elapsed between the + // download start and the end event. + if (download->endTime >= 0) + return download->endTime - download->startTime; + + // Download is still going. + return ecore_time_get() - download->startTime; +} + +/** + * @internal + * Sets the URL @a response for this @a download. + */ +void ewk_download_job_response_set(Ewk_Download_Job* download, Ewk_Url_Response* response) +{ + EINA_SAFETY_ON_NULL_RETURN(download); + EINA_SAFETY_ON_NULL_RETURN(response); + + ewk_url_response_ref(response); + download->response = response; +} + +/** + * @internal + * Sets the suggested file name for this @a download. + */ +void ewk_download_job_suggested_filename_set(Ewk_Download_Job* download, const char* suggestedFilename) +{ + EINA_SAFETY_ON_NULL_RETURN(download); + + eina_stringshare_replace(&download->suggestedFilename, suggestedFilename); +} + +/** + * @internal + * Report a given amount of data was received. + */ +void ewk_download_job_received_data(Ewk_Download_Job* download, uint64_t length) +{ + EINA_SAFETY_ON_NULL_RETURN(download); + + download->downloaded += length; +} + +/** + * @internal + * Sets the state of the download. + */ +void ewk_download_job_state_set(Ewk_Download_Job* download, Ewk_Download_Job_State state) +{ + download->state = state; + + // Update start time if the download has started + if (state == EWK_DOWNLOAD_JOB_STATE_DOWNLOADING) + download->startTime = ecore_time_get(); + + // Update end time if the download has finished (successfully or not) + if (state == EWK_DOWNLOAD_JOB_STATE_FAILED + || state == EWK_DOWNLOAD_JOB_STATE_CANCELLED + || state == EWK_DOWNLOAD_JOB_STATE_FINISHED) + download->endTime = ecore_time_get(); +} + +/** + * @internal + * Constructs a Ewk_Download_Job from a DownloadProxy. + */ +Ewk_Download_Job* ewk_download_job_new(DownloadProxy* download, Evas_Object* ewkView) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(download, 0); + EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0); + + return new _Ewk_Download_Job(download, ewkView); +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_download_job.h b/Source/WebKit2/UIProcess/API/efl/ewk_download_job.h new file mode 100644 index 000000000..68f03fc7e --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_download_job.h @@ -0,0 +1,202 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file ewk_download_job.h + * @brief Describes the Download Job API. + * + * @note Ewk_Download_Job encapsulates a WebKit download job in order to provide + * information about it and interact with it (e.g. set the destination + * path, cancel the download, ...). + */ + +#ifndef ewk_download_job_h +#define ewk_download_job_h + +#include "ewk_url_request.h" +#include "ewk_url_response.h" +#include <Eina.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** Creates a type name for _Ewk_Download_Job_Job */ +typedef struct _Ewk_Download_Job Ewk_Download_Job; + +/// Defines the possible states of a download. +enum _Ewk_Download_Job_State { + /// The download state is unknown + EWK_DOWNLOAD_JOB_STATE_UNKNOWN = -1, + /// The download has not started yet + EWK_DOWNLOAD_JOB_STATE_NOT_STARTED, + /// The download has started + EWK_DOWNLOAD_JOB_STATE_DOWNLOADING, + /// The download stopped because of a failure + EWK_DOWNLOAD_JOB_STATE_FAILED, + /// The download is being cancelled + EWK_DOWNLOAD_JOB_STATE_CANCELLING, + /// The download stopped because it was cancelled + EWK_DOWNLOAD_JOB_STATE_CANCELLED, + /// The download completed successfully. + EWK_DOWNLOAD_JOB_STATE_FINISHED +}; +/// Creates a type name for @a _Ewk_Download_Job_State. +typedef enum _Ewk_Download_Job_State Ewk_Download_Job_State; + +/** + * Increases the reference count of the given object. + * + * @param download the download object to increase the reference count + */ +EAPI void ewk_download_job_ref(Ewk_Download_Job *download); + +/** + * Decreases the reference count of the given object, possibly freeing it. + * + * When the reference count reaches 0, the download is freed. + * + * @param download the download object to decrease the reference count + */ +EAPI void ewk_download_job_unref(Ewk_Download_Job *download); + +/** + * Query the state for this download. + * + * @param download a #Ewk_Download_Job to query. + * + * @return the download state. + */ +EAPI Ewk_Download_Job_State ewk_download_job_state_get(const Ewk_Download_Job *download); + +/** + * Query the URL request for this download. + * + * @param download a #Ewk_Download_Job to query. + * + * @return the #Ewk_Url_Request for this download. + */ +EAPI Ewk_Url_Request *ewk_download_job_request_get(const Ewk_Download_Job *download); + +/** + * Query the URL response for this download. + * + * @param download a #Ewk_Download_Job to query. + * + * @return the #Ewk_Url_Response for this download or @c NULL if it was not received yet. + */ +EAPI Ewk_Url_Response *ewk_download_job_response_get(const Ewk_Download_Job *download); + +/** + * Query the URI to which the downloaded file will be written. + * + * @param download a #Ewk_Download_Job to query. + * + * @return the destination pointer, that may be @c NULL. This pointer is + * guaranteed to be eina_stringshare, so whenever possible + * save yourself some cpu cycles and use + * eina_stringshare_ref() instead of eina_stringshare_add() or + * strdup(). + */ +EAPI const char *ewk_download_job_destination_get(const Ewk_Download_Job *download); + +/** + * Sets the destination path for this download. + * + * Sets the path to which the downloaded file will be written. + * + * This method needs to be called before the download transfer + * starts, by connecting to the "download,new" signal on the + * Ewk_View and setting the destination in the callback. To set + * the destination using the filename suggested by the server + * use ewk_download_job_suggested_filename_get(). + * + * @param download #Ewk_Download_Job to update. + * @param destination the destination path. + * + * @return @c EINA_TRUE if successful, @c EINA_FALSE otherwise. + * + * @see ewk_download_job_suggested_filename_get + */ +EAPI Eina_Bool ewk_download_job_destination_set(Ewk_Download_Job *download, const char *destination); + +/** + * Queries the suggested file name for this download. + * + * It can be useful to use the value returned by this function to construct + * the destination path to pass to ewk_download_job_destination_set(). + * + * @param download #Ewk_Download_Job to query. + * + * @return The suggested file name for this download. This pointer is + * guaranteed to be eina_stringshare, so whenever possible + * save yourself some cpu cycles and use + * eina_stringshare_ref() instead of eina_stringshare_add() or + * strdup(). + * + * @see ewk_download_job_destination_set + */ +EAPI const char *ewk_download_job_suggested_filename_get(const Ewk_Download_Job *download); + +/** + * Cancels the download asynchronously. + * + * When the ongoing download operation is effectively cancelled a "download,cancelled" + * signal will be emitted on the view. + * + * @param download a #Ewk_Download_Job to cancel. + * + * @return @c EINA_TRUE if the cancellation request was taken into account, or + * @c EINA_FALSE otherwise. + */ +EAPI Eina_Bool ewk_download_job_cancel(Ewk_Download_Job *download); + +/** + * Query the estimated progress for this download. + * + * @param download a #Ewk_Download_Job to query. + * + * @return an estimate of the of the percent complete for a download + * as a range from 0.0 to 1.0. + */ +EAPI double ewk_download_job_estimated_progress_get(const Ewk_Download_Job *download); + +/** + * Gets the elapsed time in seconds, including any fractional part. + * + * If the download finished, had an error or was cancelled this is + * the time between its start and the event. + * + * @param download a #Ewk_Download_Job + * + * @return seconds since the download was started or 0.0 in case of failure. + */ +EAPI double ewk_download_job_elapsed_time_get(const Ewk_Download_Job *download); + +#ifdef __cplusplus +} +#endif + +#endif // ewk_download_job_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_download_job_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_download_job_private.h new file mode 100644 index 000000000..d043494c3 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_download_job_private.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ewk_download_job_private_h +#define ewk_download_job_private_h + +#include "WKBase.h" +#include <Evas.h> + +typedef struct _Ewk_Download_Job Ewk_Download_Job; +typedef struct _Ewk_Url_Response Ewk_Url_Response; +typedef struct _Ewk_Web_Error Ewk_Web_Error; + +namespace WebKit { +class DownloadProxy; +} + +Ewk_Download_Job* ewk_download_job_new(WebKit::DownloadProxy*, Evas_Object* ewkView); +uint64_t ewk_download_job_id_get(const Ewk_Download_Job*); +Evas_Object* ewk_download_job_view_get(const Ewk_Download_Job*); + +void ewk_download_job_state_set(Ewk_Download_Job*, Ewk_Download_Job_State); +void ewk_download_job_cancelled(Ewk_Download_Job*); +void ewk_download_job_failed(Ewk_Download_Job*); +void ewk_download_job_finished(Ewk_Download_Job*); +void ewk_download_job_started(Ewk_Download_Job*); + +void ewk_download_job_received_data(Ewk_Download_Job*, uint64_t length); +void ewk_download_job_response_set(Ewk_Download_Job*, Ewk_Url_Response*); +void ewk_download_job_suggested_filename_set(Ewk_Download_Job*, const char* suggestedFilename); + +#endif // ewk_download_job_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request.cpp new file mode 100644 index 000000000..70721735b --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request.cpp @@ -0,0 +1,131 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ewk_form_submission_request.h" + +#include "WKAPICast.h" +#include "WKArray.h" +#include "WKBase.h" +#include "WKDictionary.h" +#include "WKFormSubmissionListener.h" +#include "WKRetainPtr.h" +#include "WKString.h" +#include "ewk_form_submission_request_private.h" +#include <wtf/text/CString.h> + +using namespace WebKit; + +/** + * \struct _Ewk_Form_Submission_Request + * @brief Contains the form submission request data. + */ +struct _Ewk_Form_Submission_Request { + unsigned int __ref; /**< the reference count of the object */ + WKRetainPtr<WKDictionaryRef> wkValues; + WKRetainPtr<WKFormSubmissionListenerRef> wkListener; + bool handledRequest; + + _Ewk_Form_Submission_Request(WKDictionaryRef values, WKFormSubmissionListenerRef listener) + : __ref(1) + , wkValues(values) + , wkListener(listener) + , handledRequest(false) + { } + + ~_Ewk_Form_Submission_Request() + { + ASSERT(!__ref); + + // Make sure the request is always handled before destroying. + if (!handledRequest) + WKFormSubmissionListenerContinue(wkListener.get()); + } +}; + +void ewk_form_submission_request_ref(Ewk_Form_Submission_Request* request) +{ + EINA_SAFETY_ON_NULL_RETURN(request); + ++request->__ref; +} + +void ewk_form_submission_request_unref(Ewk_Form_Submission_Request* request) +{ + EINA_SAFETY_ON_NULL_RETURN(request); + + if (--request->__ref) + return; + + delete request; +} + +Eina_List* ewk_form_submission_request_field_names_get(Ewk_Form_Submission_Request* request) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0); + + Eina_List* names = 0; + + WKRetainPtr<WKArrayRef> wkKeys(AdoptWK, WKDictionaryCopyKeys(request->wkValues.get())); + const size_t numKeys = WKArrayGetSize(wkKeys.get()); + for (size_t i = 0; i < numKeys; ++i) { + WKStringRef wkKey = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkKeys.get(), i)); + names = eina_list_append(names, eina_stringshare_add(toImpl(wkKey)->string().utf8().data())); + } + + return names; +} + +const char* ewk_form_submission_request_field_value_get(Ewk_Form_Submission_Request* request, const char* name) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0); + EINA_SAFETY_ON_NULL_RETURN_VAL(name, 0); + + WKRetainPtr<WKStringRef> wkKey(AdoptWK, WKStringCreateWithUTF8CString(name)); + WKStringRef wkValue = static_cast<WKStringRef>(WKDictionaryGetItemForKey(request->wkValues.get(), wkKey.get())); + + return wkValue ? eina_stringshare_add(toImpl(wkValue)->string().utf8().data()) : 0; +} + +Eina_Bool ewk_form_submission_request_submit(Ewk_Form_Submission_Request* request) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(request, false); + + WKFormSubmissionListenerContinue(request->wkListener.get()); + request->handledRequest = true; + + return true; +} + +/** + * @internal ewk_form_submission_request_new + * Creates a Ewk_Form_Submission_Request from a dictionary and a WKFormSubmissionListenerRef. + */ +Ewk_Form_Submission_Request* ewk_form_submission_request_new(WKDictionaryRef values, WKFormSubmissionListenerRef listener) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(values, 0); + EINA_SAFETY_ON_NULL_RETURN_VAL(listener, 0); + + return new Ewk_Form_Submission_Request(values, listener); +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request.h b/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request.h new file mode 100644 index 000000000..fa67e9360 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request.h @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file ewk_form_submission_request.h + * @brief Describes the Ewk Form Submission Request API. + * + * @note Ewk_Form_Submission_Request provides information regarding + * a form about the be submitted, in particular its text fields. + */ + +#ifndef ewk_form_submission_request_h +#define ewk_form_submission_request_h + +#include <Eina.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** Creates a type name for _Ewk_Form_Submission_Request */ +typedef struct _Ewk_Form_Submission_Request Ewk_Form_Submission_Request; + +/** + * Increases the reference count of the given object. + * + * @param request the request object to increase the reference count + */ +EAPI void ewk_form_submission_request_ref(Ewk_Form_Submission_Request *request); + +/** + * Decreases the reference count of the given object, possibly freeing it. + * + * When the reference count reaches 0, the request is freed. + * + * If the reference count reaches 0 and the form request has not be submitted yet, + * ewk_form_submission_request_submit() will be called automatically before + * destruction. + * + * @param request the request object to decrease the reference count + */ +EAPI void ewk_form_submission_request_unref(Ewk_Form_Submission_Request *request); + +/** + * Returns the list of field names contained in the form associated to @a request. + * + * @param request the request object to query. + * + * @return a #Eina_List with the form text fields names, or @c NULL in case of error. + * The items of the list are guaranteed to be stringshared so use eina_stringshare_add() + * instead of strdup() to copy them and free them using eina_stringshare_del(). + * + * @see ewk_form_submission_request_field_value_get() + */ +EAPI Eina_List *ewk_form_submission_request_field_names_get(Ewk_Form_Submission_Request *request); + +/** + * Returns the value of specific field contained in the form associated to @a request. + * + * @param request the request object to query. + * @param name name of the field to query the value for. + * + * @return a #Eina_List with the form text fields names, or @c NULL in case of error. + * The string returned is guaranteed to be stringshared. You need to call + * eina_stringshare_del() on the returned value once you are done with it. + * + * @see ewk_form_submission_request_field_names_get() + */ +EAPI const char *ewk_form_submission_request_field_value_get(Ewk_Form_Submission_Request *request, const char *name); + +/** + * Continues the form request submission. + * + * If you don't call this function explicitly, the form request will be submitted + * upon @a request object destruction. + * + * @param request the request object to submit. + * + * @return @c EINA_TRUE is if successful, @c EINA_FALSE otherwise. + */ +EAPI Eina_Bool ewk_form_submission_request_submit(Ewk_Form_Submission_Request *request); + +#ifdef __cplusplus +} +#endif + +#endif // ewk_form_submission_request_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request_private.h new file mode 100644 index 000000000..feb3d606b --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request_private.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ewk_form_submission_request_private_h +#define ewk_form_submission_request_private_h + +typedef struct _Ewk_Form_Submission_Request Ewk_Form_Submission_Request; + +Ewk_Form_Submission_Request* ewk_form_submission_request_new(WKDictionaryRef values, WKFormSubmissionListenerRef); + +#endif // ewk_form_submission_request_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_intent.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_intent.cpp index 7322108be..856179346 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_intent.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_intent.cpp @@ -156,7 +156,7 @@ Eina_List* ewk_intent_suggestions_get(const Ewk_Intent* intent) const size_t numSuggestions = WKArrayGetSize(wkSuggestions.get()); for (size_t i = 0; i < numSuggestions; ++i) { WKURLRef wkSuggestion = static_cast<WKURLRef>(WKArrayGetItemAtIndex(wkSuggestions.get(), i)); - listOfSuggestions = eina_list_append(listOfSuggestions, strdup(toImpl(wkSuggestion)->string().utf8().data())); + listOfSuggestions = eina_list_append(listOfSuggestions, eina_stringshare_add(toImpl(wkSuggestion)->string().utf8().data())); } return listOfSuggestions; @@ -165,7 +165,7 @@ Eina_List* ewk_intent_suggestions_get(const Ewk_Intent* intent) #endif } -char* ewk_intent_extra_get(const Ewk_Intent* intent, const char* key) +const char* ewk_intent_extra_get(const Ewk_Intent* intent, const char* key) { #if ENABLE(WEB_INTENTS) EWK_INTENT_WK_GET_OR_RETURN(intent, wkIntent, 0); @@ -176,7 +176,7 @@ char* ewk_intent_extra_get(const Ewk_Intent* intent, const char* key) if (value.isEmpty()) return 0; - return strdup(value.utf8().data()); + return eina_stringshare_add(value.utf8().data()); #else return 0; #endif @@ -193,7 +193,7 @@ Eina_List* ewk_intent_extra_names_get(const Ewk_Intent* intent) const size_t numKeys = WKArrayGetSize(wkKeys.get()); for (size_t i = 0; i < numKeys; ++i) { WKStringRef wkKey = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkKeys.get(), i)); - listOfKeys = eina_list_append(listOfKeys, strdup(toImpl(wkKey)->string().utf8().data())); + listOfKeys = eina_list_append(listOfKeys, eina_stringshare_add(toImpl(wkKey)->string().utf8().data())); } return listOfKeys; diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_intent.h b/Source/WebKit2/UIProcess/API/efl/ewk_intent.h index ae73c6ce5..abcffa59f 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_intent.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_intent.h @@ -104,29 +104,33 @@ EAPI const char *ewk_intent_service_get(const Ewk_Intent *intent); * @param intent intent item to query. * * @return @c Eina_List with suggested service URLs on success, or @c NULL on failure, - * the Eina_List and its items should be freed after use. Use free() to free the - * items. + * the Eina_List and its items should be freed after use. Use eina_stringshare_del() + * to free the items. */ EAPI Eina_List *ewk_intent_suggestions_get(const Ewk_Intent *intent); /** * Retrieves the value (if any) from the extra data dictionary this intent was constructed with. * + * The returned string should be freed by eina_stringshare_del() after use. + * * @param intent intent item to query. * @param key key to query in the dictionary. * * @return a newly allocated string or @c NULL in case of error or if the key does not exist. */ -EAPI char *ewk_intent_extra_get(const Ewk_Intent *intent, const char *key); +EAPI const char *ewk_intent_extra_get(const Ewk_Intent *intent, const char *key); /** * Retrieve a list of the names of extra metadata associated with the intent. * + * The item of a returned list should be freed by eina_stringshare_del() after use. + * * @param intent intent item to query. * * @return @c Eina_List with names of extra metadata on success, or @c NULL on failure, - * the Eina_List and its items should be freed after use. Use free() to free the - * items. + * the Eina_List and its items should be freed after use. Use eina_stringshare_del() + * to free the items. */ EAPI Eina_List *ewk_intent_extra_names_get(const Ewk_Intent *intent); diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_main.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_main.cpp new file mode 100644 index 000000000..0d01924bc --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_main.cpp @@ -0,0 +1,105 @@ +/* + Copyright (C) 2009-2010 ProFUSION embedded systems + Copyright (C) 2009-2011 Samsung Electronics + Copyright (C) 2012 Intel Corporation + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "config.h" +#include "ewk_main.h" + +#include <Ecore.h> +#include <Ecore_Evas.h> +#include <Edje.h> +#include <Eina.h> +#include <Evas.h> +#include <glib-object.h> +#include <glib.h> + +static int _ewkInitCount = 0; + +/** + * \var _ewk_log_dom + * @brief the log domain identifier that is used with EINA's macros + */ +int _ewk_log_dom = -1; + +int ewk_init(void) +{ + if (_ewkInitCount) + return ++_ewkInitCount; + + if (!eina_init()) + goto error_eina; + + _ewk_log_dom = eina_log_domain_register("ewebkit2", EINA_COLOR_ORANGE); + if (_ewk_log_dom < 0) { + EINA_LOG_CRIT("could not register log domain 'ewebkit2'"); + goto error_log_domain; + } + + if (!evas_init()) { + EINA_LOG_DOM_CRIT(_ewk_log_dom, "could not init evas."); + goto error_evas; + } + + if (!ecore_init()) { + EINA_LOG_DOM_CRIT(_ewk_log_dom, "could not init ecore."); + goto error_ecore; + } + + if (!ecore_evas_init()) { + EINA_LOG_DOM_CRIT(_ewk_log_dom, "could not init ecore_evas."); + goto error_ecore_evas; + } + + g_type_init(); + + if (!ecore_main_loop_glib_integrate()) { + EINA_LOG_DOM_WARN(_ewk_log_dom, "Ecore was not compiled with GLib support, some plugins will not " + "work (ie: Adobe Flash)"); + } + + return ++_ewkInitCount; + +error_ecore_evas: + ecore_shutdown(); +error_ecore: + evas_shutdown(); +error_evas: + eina_log_domain_unregister(_ewk_log_dom); + _ewk_log_dom = -1; +error_log_domain: + eina_shutdown(); +error_eina: + return 0; +} + +int ewk_shutdown(void) +{ + if (--_ewkInitCount) + return _ewkInitCount; + + ecore_evas_shutdown(); + ecore_shutdown(); + evas_shutdown(); + eina_log_domain_unregister(_ewk_log_dom); + _ewk_log_dom = -1; + eina_shutdown(); + + return 0; +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_main.h b/Source/WebKit2/UIProcess/API/efl/ewk_main.h new file mode 100644 index 000000000..28e93fe23 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_main.h @@ -0,0 +1,58 @@ +/* + Copyright (C) 2009-2010 ProFUSION embedded systems + Copyright (C) 2009-2010 Samsung Electronics + Copyright (C) 2012 Intel Corporation + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +/** + * @file ewk_main.h + * @brief The general initialization of WebKit2-EFL, not tied to any view object. + */ + +#ifndef ewk_main_h +#define ewk_main_h + +#include <Eina.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Initializes WebKit's instance. + * + * - initializes components needed by EFL, + * - increases a reference count of WebKit's instance. + * + * @return a reference count of WebKit's instance on success or 0 on failure + */ +EAPI int ewk_init(void); + +/** + * Decreases a reference count of WebKit's instance, possibly destroying it. + * + * If the reference count reaches 0 WebKit's instance is destroyed. + * + * @return a reference count of WebKit's instance + */ +EAPI int ewk_shutdown(void); + +#ifdef __cplusplus +} +#endif +#endif // ewk_main_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_url_response.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_url_response.cpp index 137753d60..8f9f5366a 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_url_response.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_url_response.cpp @@ -98,6 +98,13 @@ const char* ewk_url_response_mime_type_get(const Ewk_Url_Response* response) return response->mimeType; } +unsigned long ewk_url_response_content_length_get(const Ewk_Url_Response* response) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(response, 0); + + return response->coreResponse.expectedContentLength(); +} + /** * @internal * Constructs a Ewk_Url_Response from a WebCore::ResourceResponse. diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_url_response.h b/Source/WebKit2/UIProcess/API/efl/ewk_url_response.h index c02622dd7..35631ebef 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_url_response.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_url_response.h @@ -94,6 +94,17 @@ EAPI int ewk_url_response_status_code_get(const Ewk_Url_Response *response); */ EAPI const char *ewk_url_response_mime_type_get(const Ewk_Url_Response *response); +/** + * Get the expected content length of the #Ewk_Url_Response. + * + * It can be 0 if the server provided an incorrect or missing Content-Length. + * + * @param response a #Ewk_Url_Response. + * + * @return the expected content length of @a response or 0 in case of failure. + */ +EAPI unsigned long ewk_url_response_content_length_get(const Ewk_Url_Response *response); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.cpp index 693ff3df6..32c3281f9 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.cpp @@ -115,7 +115,7 @@ uint64_t ewk_url_scheme_request_id_get(const Ewk_Url_Scheme_Request* request) return request->requestID; } -Eina_Bool ewk_url_scheme_request_finish(const Ewk_Url_Scheme_Request* request, void* contentData, unsigned int contentLength, const char* mimeType) +Eina_Bool ewk_url_scheme_request_finish(const Ewk_Url_Scheme_Request* request, const void* contentData, unsigned int contentLength, const char* mimeType) { EINA_SAFETY_ON_NULL_RETURN_VAL(request, false); diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.h b/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.h index 034cbd474..deaaf1892 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.h @@ -103,7 +103,7 @@ EAPI const char *ewk_url_scheme_request_path_get(const Ewk_Url_Scheme_Request *r * @param content_length the length of the @a content_data. * @param mime_type the content type of the stream or %c NULL if not known */ -EAPI Eina_Bool ewk_url_scheme_request_finish(const Ewk_Url_Scheme_Request *request, void *content_data, unsigned int content_length, const char *mime_type); +EAPI Eina_Bool ewk_url_scheme_request_finish(const Ewk_Url_Scheme_Request *request, const void *content_data, unsigned int content_length, const char *mime_type); #ifdef __cplusplus } diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp index 3f80aa11d..b1b1bcc08 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp @@ -32,19 +32,31 @@ #include "ewk_context.h" #include "ewk_context_private.h" #include "ewk_intent_private.h" +#include "ewk_view_form_client_private.h" #include "ewk_view_loader_client_private.h" #include "ewk_view_policy_client_private.h" #include "ewk_view_private.h" #include "ewk_view_resource_load_client_private.h" #include "ewk_web_resource.h" +#include <Ecore_Evas.h> +#include <Edje.h> +#include <WebCore/Cursor.h> +#include <WebCore/EflScreenUtilities.h> #include <wtf/text/CString.h> +#if USE(ACCELERATED_COMPOSITING) +#include <Evas_GL.h> +#endif + using namespace WebKit; using namespace WebCore; static const char EWK_VIEW_TYPE_STR[] = "EWK2_View"; +static const int defaultCursorSize = 16; + typedef HashMap<uint64_t, Ewk_Web_Resource*> LoadingResourcesMap; +static void _ewk_view_priv_loading_resources_clear(LoadingResourcesMap& loadingResourcesMap); struct _Ewk_View_Private_Data { OwnPtr<PageClientImpl> pageClient; @@ -52,13 +64,35 @@ struct _Ewk_View_Private_Data { const char* title; const char* theme; const char* customEncoding; + const char* cursorGroup; + Evas_Object* cursorObject; LoadingResourcesMap loadingResourcesMap; +#ifdef HAVE_ECORE_X + bool isUsingEcoreX; +#endif + +#if USE(ACCELERATED_COMPOSITING) + Evas_GL* evasGl; + Evas_GL_Context* evasGlContext; + Evas_GL_Surface* evasGlSurface; +#endif + _Ewk_View_Private_Data() : uri(0) , title(0) , theme(0) , customEncoding(0) + , cursorGroup(0) + , cursorObject(0) +#ifdef HAVE_ECORE_X + , isUsingEcoreX(false) +#endif +#if USE(ACCELERATED_COMPOSITING) + , evasGl(0) + , evasGlContext(0) + , evasGlSurface(0) +#endif { } ~_Ewk_View_Private_Data() @@ -67,6 +101,10 @@ struct _Ewk_View_Private_Data { eina_stringshare_del(title); eina_stringshare_del(theme); eina_stringshare_del(customEncoding); + _ewk_view_priv_loading_resources_clear(loadingResourcesMap); + + if (cursorObject) + evas_object_del(cursorObject); } }; @@ -284,9 +322,24 @@ static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData) return 0; } +#ifdef HAVE_ECORE_X + priv->isUsingEcoreX = WebCore::isUsingEcoreX(smartData->base.evas); +#endif + return priv; } +static void _ewk_view_priv_loading_resources_clear(LoadingResourcesMap& loadingResourcesMap) +{ + // Clear the loadingResources HashMap. + LoadingResourcesMap::iterator it = loadingResourcesMap.begin(); + LoadingResourcesMap::iterator end = loadingResourcesMap.end(); + for ( ; it != end; ++it) + ewk_web_resource_unref(it->second); + + loadingResourcesMap.clear(); +} + static void _ewk_view_priv_del(Ewk_View_Private_Data* priv) { delete priv; @@ -309,9 +362,11 @@ static void _ewk_view_smart_add(Evas_Object* ewkView) } smartData->self = ewkView; - smartData->priv = _ewk_view_priv_new(smartData); smartData->api = api; + g_parentSmartClass.add(ewkView); + + smartData->priv = _ewk_view_priv_new(smartData); if (!smartData->priv) { EINA_LOG_CRIT("could not allocate _Ewk_View_Private_Data"); evas_object_smart_data_set(ewkView, 0); @@ -319,8 +374,6 @@ static void _ewk_view_smart_add(Evas_Object* ewkView) return; } - g_parentSmartClass.add(ewkView); - // Create evas_object_image to draw web contents. smartData->image = evas_object_image_add(smartData->base.evas); evas_object_image_alpha_set(smartData->image, false); @@ -369,6 +422,94 @@ static void _ewk_view_smart_move(Evas_Object* ewkView, Evas_Coord x, Evas_Coord _ewk_view_smart_changed(smartData); } +IntSize ewk_view_size_get(const Evas_Object* ewkView) +{ + int width, height; + evas_object_geometry_get(ewkView, 0, 0, &width, &height); + return IntSize(width, height); +} + +#if USE(ACCELERATED_COMPOSITING) +static bool ewk_view_create_gl_surface(const Evas_Object* ewkView, const IntSize& viewSize) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + + Evas_GL_Config evasGlConfig = { + EVAS_GL_RGBA_8888, + EVAS_GL_DEPTH_BIT_8, + EVAS_GL_STENCIL_NONE, + EVAS_GL_OPTIONS_NONE, + EVAS_GL_MULTISAMPLE_NONE + }; + + ASSERT(!priv->evasGlSurface); + priv->evasGlSurface = evas_gl_surface_create(priv->evasGl, &evasGlConfig, viewSize.width(), viewSize.height()); + if (!priv->evasGlSurface) + return false; + + Evas_Native_Surface nativeSurface; + evas_gl_native_surface_get(priv->evasGl, priv->evasGlSurface, &nativeSurface); + evas_object_image_native_surface_set(smartData->image, &nativeSurface); + + return true; +} + +bool ewk_view_accelerated_compositing_mode_enter(const Evas_Object* ewkView) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + + EINA_SAFETY_ON_NULL_RETURN_VAL(!priv->evasGl, false); + + Evas* evas = evas_object_evas_get(ewkView); + priv->evasGl = evas_gl_new(evas); + if (!priv->evasGl) + return false; + + priv->evasGlContext = evas_gl_context_create(priv->evasGl, 0); + if (!priv->evasGlContext) { + evas_gl_free(priv->evasGl); + priv->evasGl = 0; + return false; + } + + if (!ewk_view_create_gl_surface(ewkView, ewk_view_size_get(ewkView))) { + evas_gl_context_destroy(priv->evasGl, priv->evasGlContext); + priv->evasGlContext = 0; + + evas_gl_free(priv->evasGl); + priv->evasGl = 0; + return false; + } + + return true; +} + +bool ewk_view_accelerated_compositing_mode_exit(const Evas_Object* ewkView) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + + EINA_SAFETY_ON_NULL_RETURN_VAL(priv->evasGl, false); + + if (priv->evasGlSurface) { + evas_gl_surface_destroy(priv->evasGl, priv->evasGlSurface); + priv->evasGlSurface = 0; + } + + if (priv->evasGlContext) { + evas_gl_context_destroy(priv->evasGl, priv->evasGlContext); + priv->evasGlContext = 0; + } + + evas_gl_free(priv->evasGl); + priv->evasGl = 0; + + return true; +} +#endif + static void _ewk_view_smart_calculate(Evas_Object* ewkView) { EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); @@ -382,6 +523,16 @@ static void _ewk_view_smart_calculate(Evas_Object* ewkView) if (smartData->changed.size) { if (priv->pageClient->page()->drawingArea()) priv->pageClient->page()->drawingArea()->setSize(IntSize(width, height), IntSize()); + +#if USE(ACCELERATED_COMPOSITING) + if (!priv->evasGlSurface) + return; + evas_gl_surface_destroy(priv->evasGl, priv->evasGlSurface); + priv->evasGlSurface = 0; + ewk_view_create_gl_surface(ewkView, IntSize(width, height)); + ewk_view_display(ewkView, IntRect(IntPoint(), IntSize(width, height))); +#endif + smartData->view.w = width; smartData->view.h = height; smartData->changed.size = false; @@ -510,9 +661,12 @@ Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGrou } priv->pageClient = PageClientImpl::create(toImpl(contextRef), toImpl(pageGroupRef), ewkView); - ewk_view_loader_client_attach(toAPI(priv->pageClient->page()), ewkView); - ewk_view_policy_client_attach(toAPI(priv->pageClient->page()), ewkView); - ewk_view_resource_load_client_attach(toAPI(priv->pageClient->page()), ewkView); + + WKPageRef wkPage = toAPI(priv->pageClient->page()); + ewk_view_form_client_attach(wkPage, ewkView); + ewk_view_loader_client_attach(wkPage, ewkView); + ewk_view_policy_client_attach(wkPage, ewkView); + ewk_view_resource_load_client_attach(wkPage, ewkView); ewk_view_theme_set(ewkView, DEFAULT_THEME_PATH"/default.edj"); @@ -529,15 +683,35 @@ Evas_Object* ewk_view_add(Evas* canvas) return ewk_view_add_with_context(canvas, ewk_context_default_get()); } -Eina_Bool ewk_view_uri_set(Evas_Object* ewkView, const char* uri) +/** + * @internal + * The uri of view was changed by the frame loader. + * + * Emits signal: "uri,changed" with pointer to new uri string. + */ +void ewk_view_uri_update(Evas_Object* ewkView) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); + + String activeURL = priv->pageClient->page()->activeURL(); + if (activeURL.isEmpty()) + return; + + if (!eina_stringshare_replace(&priv->uri, activeURL.utf8().data())) + return; - WKRetainPtr<WKURLRef> url(AdoptWK, WKURLCreateWithUTF8CString(uri)); - WKPageLoadURL(toAPI(priv->pageClient->page()), url.get()); + evas_object_smart_callback_call(ewkView, "uri,changed", static_cast<void*>(const_cast<char*>(priv->uri))); +} - eina_stringshare_replace(&priv->uri, uri); +Eina_Bool ewk_view_uri_set(Evas_Object* ewkView, const char* uri) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EINA_SAFETY_ON_NULL_RETURN_VAL(uri, false); + + priv->pageClient->page()->loadURL(uri); + ewk_view_uri_update(ewkView); return true; } @@ -555,7 +729,9 @@ Eina_Bool ewk_view_reload(Evas_Object* ewkView) EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - WKPageReload(toAPI(priv->pageClient->page())); + priv->pageClient->page()->reload(/*reloadFromOrigin*/ false); + ewk_view_uri_update(ewkView); + return true; } @@ -564,7 +740,8 @@ Eina_Bool ewk_view_reload_bypass_cache(Evas_Object* ewkView) EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - WKPageReloadFromOrigin(toAPI(priv->pageClient->page())); + priv->pageClient->page()->reload(/*reloadFromOrigin*/ true); + ewk_view_uri_update(ewkView); return true; } @@ -574,7 +751,8 @@ Eina_Bool ewk_view_stop(Evas_Object* ewkView) EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - WKPageStopLoading(toAPI(priv->pageClient->page())); + priv->pageClient->page()->stopLoading(); + return true; } @@ -700,10 +878,27 @@ void ewk_view_title_changed(Evas_Object* ewkView, const char* title) double ewk_view_load_progress_get(const Evas_Object* ewkView) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1.0); + + return priv->pageClient->page()->estimatedProgress(); +} + +Eina_Bool ewk_view_scale_set(Evas_Object* ewkView, double scaleFactor, int x, int y) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + + priv->pageClient->page()->scalePage(scaleFactor, IntPoint(x, y)); + return true; +} + +double ewk_view_scale_get(const Evas_Object* ewkView) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1); - return WKPageGetEstimatedProgress(toAPI(priv->pageClient->page())); + return priv->pageClient->page()->pageScaleFactor(); } Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object* ewkView, float ratio) @@ -712,13 +907,14 @@ Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object* ewkView, float ratio) EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); priv->pageClient->page()->setCustomDeviceScaleFactor(ratio); + return true; } float ewk_view_device_pixel_ratio_get(const Evas_Object* ewkView) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 1); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 1); + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1.0); return priv->pageClient->page()->deviceScaleFactor(); } @@ -762,9 +958,62 @@ const char* ewk_view_theme_get(const Evas_Object* ewkView) { EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); + return priv->theme; } +void ewk_view_cursor_set(Evas_Object* ewkView, const Cursor& cursor) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); + + const char* group = cursor.platformCursor(); + if (!group || group == priv->cursorGroup) + return; + + priv->cursorGroup = group; + + if (priv->cursorObject) + evas_object_del(priv->cursorObject); + priv->cursorObject = edje_object_add(smartData->base.evas); + + Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(smartData->base.evas); + if (!priv->theme || !edje_object_file_set(priv->cursorObject, priv->theme, group)) { + evas_object_del(priv->cursorObject); + priv->cursorObject = 0; + + ecore_evas_object_cursor_set(ecoreEvas, 0, 0, 0, 0); +#ifdef HAVE_ECORE_X + if (priv->isUsingEcoreX) + WebCore::applyFallbackCursor(ecoreEvas, group); +#endif + return; + } + + Evas_Coord width, height; + edje_object_size_min_get(priv->cursorObject, &width, &height); + if (width <= 0 || height <= 0) + edje_object_size_min_calc(priv->cursorObject, &width, &height); + if (width <= 0 || height <= 0) { + width = defaultCursorSize; + height = defaultCursorSize; + } + evas_object_resize(priv->cursorObject, width, height); + + const char* data; + int hotspotX = 0; + data = edje_object_data_get(priv->cursorObject, "hot.x"); + if (data) + hotspotX = atoi(data); + + int hotspotY = 0; + data = edje_object_data_get(priv->cursorObject, "hot.y"); + if (data) + hotspotY = atoi(data); + + ecore_evas_object_cursor_set(ecoreEvas, priv->cursorObject, EVAS_LAYER_MAX, hotspotX, hotspotY); +} + void ewk_view_display(Evas_Object* ewkView, const IntRect& rect) { EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); @@ -774,16 +1023,62 @@ void ewk_view_display(Evas_Object* ewkView, const IntRect& rect) evas_object_image_data_update_add(smartData->image, rect.x(), rect.y(), rect.width(), rect.height()); } +/** + * @internal + * A download for that view was cancelled. + * + * Emits signal: "download,cancelled" with pointer to a Ewk_Download_Job. + */ +void ewk_view_download_job_cancelled(Evas_Object* ewkView, Ewk_Download_Job* download) +{ + evas_object_smart_callback_call(ewkView, "download,cancelled", download); +} + +/** + * @internal + * A new download has been requested for that view. + * + * Emits signal: "download,request" with pointer to a Ewk_Download_Job. + */ +void ewk_view_download_job_requested(Evas_Object* ewkView, Ewk_Download_Job* download) +{ + evas_object_smart_callback_call(ewkView, "download,request", download); +} + +/** + * @internal + * A download for that view has failed. + * + * Emits signal: "download,failed" with pointer to a Ewk_Download_Job_Error. + */ +void ewk_view_download_job_failed(Evas_Object* ewkView, Ewk_Download_Job* download, Ewk_Web_Error* error) +{ + Ewk_Download_Job_Error downloadError = { download, error }; + evas_object_smart_callback_call(ewkView, "download,failed", &downloadError); +} + +/** + * @internal + * A download for that view finished successfully. + * + * Emits signal: "download,finished" with pointer to a Ewk_Download_Job. + */ +void ewk_view_download_job_finished(Evas_Object* ewkView, Ewk_Download_Job* download) +{ + evas_object_smart_callback_call(ewkView, "download,finished", download); +} + Eina_Bool ewk_view_back(Evas_Object* ewkView) { EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - WKPageRef pageRef = toAPI(priv->pageClient->page()); - if (WKPageCanGoBack(pageRef)) { - WKPageGoBack(pageRef); + WebPageProxy* page = priv->pageClient->page(); + if (page->canGoBack()) { + page->goBack(); return true; } + return false; } @@ -792,11 +1087,12 @@ Eina_Bool ewk_view_forward(Evas_Object* ewkView) EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - WKPageRef pageRef = toAPI(priv->pageClient->page()); - if (WKPageCanGoForward(pageRef)) { - WKPageGoForward(pageRef); + WebPageProxy* page = priv->pageClient->page(); + if (page->canGoForward()) { + page->goForward(); return true; } + return false; } @@ -807,8 +1103,9 @@ Eina_Bool ewk_view_intent_deliver(Evas_Object* ewkView, Ewk_Intent* intent) EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); EINA_SAFETY_ON_NULL_RETURN_VAL(intent, false); - WKPageRef wkPage = toAPI(priv->pageClient->page()); - WKPageDeliverIntentToFrame(wkPage, WKPageGetMainFrame(wkPage), ewk_intent_WKIntentDataRef_get(intent)); + WebPageProxy* page = priv->pageClient->page(); + page->deliverIntentToFrame(page->mainFrame(), toImpl(ewk_intent_WKIntentDataRef_get(intent))); + return true; #else return false; @@ -820,7 +1117,7 @@ Eina_Bool ewk_view_back_possible(Evas_Object* ewkView) EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - return WKPageCanGoBack(toAPI(priv->pageClient->page())); + return priv->pageClient->page()->canGoBack(); } Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView) @@ -828,7 +1125,7 @@ Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView) EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - return WKPageCanGoForward(toAPI(priv->pageClient->page())); + return priv->pageClient->page()->canGoForward(); } void ewk_view_image_data_set(Evas_Object* ewkView, void* imageData, const IntSize& size) @@ -844,6 +1141,17 @@ void ewk_view_image_data_set(Evas_Object* ewkView, void* imageData, const IntSiz /** * @internal + * Reports that a form request is about to be submitted. + * + * Emits signal: "form,submission,request" with pointer to Ewk_Form_Submission_Request. + */ +void ewk_view_form_submission_request_new(Evas_Object* ewkView, Ewk_Form_Submission_Request* request) +{ + evas_object_smart_callback_call(ewkView, "form,submission,request", request); +} + +/** + * @internal * Reports load failed with error information. * * Emits signal: "load,error" with pointer to Ewk_Web_Error. @@ -861,6 +1169,7 @@ void ewk_view_load_error(Evas_Object* ewkView, const Ewk_Web_Error* error) */ void ewk_view_load_finished(Evas_Object* ewkView) { + ewk_view_uri_update(ewkView); evas_object_smart_callback_call(ewkView, "load,finished", 0); } @@ -883,6 +1192,7 @@ void ewk_view_load_provisional_failed(Evas_Object* ewkView, const Ewk_Web_Error* */ void ewk_view_load_provisional_redirect(Evas_Object* ewkView) { + ewk_view_uri_update(ewkView); evas_object_smart_callback_call(ewkView, "load,provisional,redirect", 0); } @@ -899,12 +1209,9 @@ void ewk_view_load_provisional_started(Evas_Object* ewkView) // The main frame started provisional load, we should clear // the loadingResources HashMap to start clean. - LoadingResourcesMap::iterator it = priv->loadingResourcesMap.begin(); - LoadingResourcesMap::iterator end = priv->loadingResourcesMap.end(); - for ( ; it != end; ++it) - ewk_web_resource_unref(it->second); - priv->loadingResourcesMap.clear(); + _ewk_view_priv_loading_resources_clear(priv->loadingResourcesMap); + ewk_view_uri_update(ewkView); evas_object_smart_callback_call(ewkView, "load,provisional,started", 0); } @@ -940,6 +1247,7 @@ Eina_Bool ewk_view_html_string_load(Evas_Object* ewkView, const char* html, cons priv->pageClient->page()->loadAlternateHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "", String::fromUTF8(unreachableUrl)); else priv->pageClient->page()->loadHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : ""); + ewk_view_uri_update(ewkView); return true; } @@ -970,11 +1278,12 @@ const char* ewk_view_setting_encoding_custom_get(const Evas_Object* ewkView) EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); - WKRetainPtr<WKStringRef> wkEncodingName(AdoptWK, WKPageCopyCustomTextEncodingName(toAPI(priv->pageClient->page()))); - if (WKStringIsEmpty(wkEncodingName.get())) + String customEncoding = priv->pageClient->page()->customTextEncodingName(); + if (customEncoding.isEmpty()) return 0; - eina_stringshare_replace(&priv->customEncoding, toImpl(wkEncodingName.get())->string().utf8().data()); + eina_stringshare_replace(&priv->customEncoding, customEncoding.utf8().data()); + return priv->customEncoding; } @@ -983,8 +1292,8 @@ Eina_Bool ewk_view_setting_encoding_custom_set(Evas_Object* ewkView, const char* EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - WKRetainPtr<WKStringRef> wkEncodingName = encoding ? adoptWK(WKStringCreateWithUTF8CString(encoding)) : 0; if (eina_stringshare_replace(&priv->customEncoding, encoding)) - WKPageSetCustomTextEncodingName(toAPI(priv->pageClient->page()), wkEncodingName.get()); + priv->pageClient->page()->setCustomTextEncodingName(encoding ? encoding : String()); + return true; } diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.h b/Source/WebKit2/UIProcess/API/efl/ewk_view.h index 924dbcf67..057f725bd 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.h @@ -26,6 +26,20 @@ * * The following signals (see evas_object_smart_callback_add()) are emitted: * + * - "download,cancelled", Ewk_Download_Job*: reports that a download was effectively cancelled. + * - "download,failed", Ewk_Download_Job_Error*: reports that a download failed with the given error. + * - "download,finished", Ewk_Download_Job*: reports that a download completed successfully. + * - "download,request", Ewk_Download_Job*: reports that a new download has been requested. The client should set the + * destination path by calling ewk_download_job_destination_set() or the download will fail. + * - "form,submission,request", Ewk_Form_Submission_Request*: Reports that a form request is about to be submitted. + * The Ewk_Form_Submission_Request passed contains information about the text fields of the form. This + * is typically used to store login information that can be used later to pre-fill the form. + * The form will not be submitted until ewk_form_submission_request_submit() is called. + * It is possible to handle the form submission request asynchronously, by simply calling + * ewk_form_submission_request_ref() on the request and calling ewk_form_submission_request_submit() + * when done to continue with the form submission. If the last reference is removed on a + * #Ewk_Form_Submission_Request and the form has not been submitted yet, + * ewk_form_submission_request_submit() will be called automatically. * - "intent,request,new", Ewk_Intent_Request*: reports new Web intent request. * - "intent,service,register", Ewk_Intent_Service*: reports new Web intent service registration. * - "load,error", const Ewk_Web_Error*: reports main frame load failed. @@ -46,12 +60,14 @@ * - "resource,request,response", Ewk_Web_Resource_Load_Response*: a response to a resource request was received. * - "resource,request,sent", const Ewk_Web_Resource_Request*: a resource request was sent. * - "title,changed", const char*: title of the main frame was changed. + * - "uri,changed", const char*: uri of the main frame was changed. */ #ifndef ewk_view_h #define ewk_view_h #include "ewk_context.h" +#include "ewk_download_job.h" #include "ewk_intent.h" #include "ewk_url_request.h" #include "ewk_url_response.h" @@ -188,6 +204,17 @@ struct _Ewk_Web_Resource_Load_Error { Ewk_Web_Error *error; /**< load error */ }; +/// Creates a type name for _Ewk_Download_Job_Error. +typedef struct _Ewk_Download_Job_Error Ewk_Download_Job_Error; + +/** + * @brief Structure containing details about a download failure. + */ +struct _Ewk_Download_Job_Error { + Ewk_Download_Job *download_job; /**< download that failed */ + Ewk_Web_Error *error; /**< download error */ +}; + /** * Creates a new EFL WebKit view object. * @@ -213,7 +240,8 @@ EAPI Evas_Object *ewk_view_add_with_context(Evas *e, Ewk_Context *context); * @param o view object to load @a URI * @param uri uniform resource identifier to load * - * @return @c EINA_TRUE is returned if @a o is valid, irrespective of load. + * @return @c EINA_TRUE is returned if @a o is valid, irrespective of load, + * or @c EINA_FALSE on failure */ EAPI Eina_Bool ewk_view_uri_set(Evas_Object *o, const char *uri); @@ -326,7 +354,8 @@ EAPI const char *ewk_view_title_get(const Evas_Object *o); * * @param o view object to get the current progress * - * @return the load progres of page, value from 0.0 to 1.0. + * @return the load progress of page, value from 0.0 to 1.0, + * or @c -1.0 on failure */ EAPI double ewk_view_load_progress_get(const Evas_Object *o); @@ -350,6 +379,30 @@ EAPI double ewk_view_load_progress_get(const Evas_Object *o); EAPI Eina_Bool ewk_view_html_string_load(Evas_Object *o, const char *html, const char *baseUrl, const char *unreachableUrl); /** + * Scales the current page, centered at the given point. + * + * @param o view object to set the zoom level + * @param scale_factor a new level to set + * @param cx x of center coordinate + * @param cy y of center coordinate + * + * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise + */ +Eina_Bool ewk_view_scale_set(Evas_Object *o, double scaleFactor, int x, int y); + +/** + * Queries the current scale factor of the page. + * + * It returns previous scale factor after ewk_view_scale_set is called immediately + * until scale factor of page is really changed. + * + * @param o view object to get the scale factor + * + * @return current scale factor in use on success or @c -1.0 on failure + */ +double ewk_view_scale_get(const Evas_Object *o); + +/** * Queries the ratio between the CSS units and device pixels when the content is unscaled. * * When designing touch-friendly contents, knowing the approximated target size on a device @@ -382,7 +435,8 @@ EAPI Eina_Bool ewk_view_html_string_load(Evas_Object *o, const char *html, const * * @param o view object to get device pixel ratio * - * @return the ratio between the CSS units and device pixels. + * @return the ratio between the CSS units and device pixels, + * or @c -1.0 on failure */ EAPI float ewk_view_device_pixel_ratio_get(const Evas_Object *o); diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_form_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view_form_client.cpp new file mode 100644 index 000000000..264ac5e47 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_form_client.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "WKPage.h" +#include "ewk_form_submission_request.h" +#include "ewk_form_submission_request_private.h" +#include "ewk_view_form_client_private.h" +#include "ewk_view_private.h" + +static void willSubmitForm(WKPageRef page, WKFrameRef frame, WKFrameRef sourceFrame, WKDictionaryRef values, WKTypeRef userData, WKFormSubmissionListenerRef listener, const void* clientInfo) +{ + Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); + + Ewk_Form_Submission_Request* request = ewk_form_submission_request_new(values, listener); + ewk_view_form_submission_request_new(ewkView, request); + ewk_form_submission_request_unref(request); +} + +void ewk_view_form_client_attach(WKPageRef pageRef, Evas_Object* ewkView) +{ + WKPageFormClient formClient; + memset(&formClient, 0, sizeof(WKPageFormClient)); + formClient.version = kWKPageFormClientCurrentVersion; + formClient.clientInfo = ewkView; + formClient.willSubmitForm = willSubmitForm; + WKPageSetPageFormClient(pageRef, &formClient); +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_form_client_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_view_form_client_private.h new file mode 100644 index 000000000..9feb4a138 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_form_client_private.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ewk_view_form_client_private_h +#define ewk_view_form_client_private_h + +#include <Evas.h> +#include <WebKit2/WKBase.h> + +void ewk_view_form_client_attach(WKPageRef pageRef, Evas_Object* ewkView); + +#endif // ewk_view_form_client_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h index 3c9ce94a7..3b57a7618 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h @@ -26,10 +26,13 @@ #include <WebKit2/WKBase.h> namespace WebCore { +class Cursor; class IntRect; class IntSize; } +typedef struct _Ewk_Download_Job Ewk_Download_Job; +typedef struct _Ewk_Form_Submission_Request Ewk_Form_Submission_Request; typedef struct _Ewk_Url_Request Ewk_Url_Request; typedef struct _Ewk_Url_Response Ewk_Url_Response; typedef struct _Ewk_Web_Error Ewk_Web_Error; @@ -42,7 +45,13 @@ typedef struct _Ewk_Intent Ewk_Intent; typedef struct _Ewk_Intent_Service Ewk_Intent_Service; #endif +void ewk_view_cursor_set(Evas_Object* ewkView, const WebCore::Cursor& cursor); void ewk_view_display(Evas_Object* ewkView, const WebCore::IntRect& rect); +void ewk_view_download_job_cancelled(Evas_Object* ewkView, Ewk_Download_Job*); +void ewk_view_download_job_failed(Evas_Object* ewkView, Ewk_Download_Job*, Ewk_Web_Error*); +void ewk_view_download_job_finished(Evas_Object* ewkView, Ewk_Download_Job*); +void ewk_view_download_job_requested(Evas_Object* ewkView, Ewk_Download_Job*); +void ewk_view_form_submission_request_new(Evas_Object* ewkView, Ewk_Form_Submission_Request*); void ewk_view_image_data_set(Evas_Object* ewkView, void* imageData, const WebCore::IntSize& size); void ewk_view_load_error(Evas_Object* ewkView, const Ewk_Web_Error* error); void ewk_view_load_finished(Evas_Object* ewkView); @@ -69,5 +78,11 @@ void ewk_view_intent_service_register(Evas_Object* ewkView, const Ewk_Intent_Ser #endif WebKit::WebPageProxy* ewk_view_page_get(const Evas_Object* ewkView); +WebCore::IntSize ewk_view_size_get(const Evas_Object* ewkView); + +#if USE(ACCELERATED_COMPOSITING) +bool ewk_view_accelerated_compositing_mode_enter(const Evas_Object* ewkView); +bool ewk_view_accelerated_compositing_mode_exit(const Evas_Object* ewkView); +#endif #endif // ewk_view_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp index b8da86dce..4069e25fa 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp @@ -47,12 +47,7 @@ EWK2UnitTestBase::EWK2UnitTestBase() void EWK2UnitTestBase::SetUp() { - ASSERT_GT(ecore_evas_init(), 0); - - // glib support (for libsoup). - g_type_init(); - if (!ecore_main_loop_glib_integrate()) - fprintf(stderr, "WARNING: Glib main loop integration is not working. Some tests may fail."); + ewk_init(); unsigned int width = environment->defaultWidth(); unsigned int height = environment->defaultHeight(); @@ -77,7 +72,7 @@ void EWK2UnitTestBase::TearDown() { evas_object_del(m_webView); ecore_evas_free(m_ecoreEvas); - ecore_evas_shutdown(); + ewk_shutdown(); } void EWK2UnitTestBase::loadUrlSync(const char* url) @@ -93,4 +88,28 @@ void EWK2UnitTestBase::loadUrlSync(const char* url) evas_object_smart_callback_del(m_webView, "load,finished", onLoadFinished); } +struct TitleChangedData { + CString expectedTitle; + bool done; +}; + +static void onTitleChanged(void* userData, Evas_Object* webView, void* eventInfo) +{ + TitleChangedData* data = static_cast<TitleChangedData*>(userData); + + if (!strcmp(ewk_view_title_get(webView), data->expectedTitle.data())) + data->done = true; +} + +void EWK2UnitTestBase::waitUntilTitleChangedTo(const char* expectedTitle) +{ + TitleChangedData data = { expectedTitle, false }; + evas_object_smart_callback_add(m_webView, "title,changed", onTitleChanged, &data); + + while (!data.done) + ecore_main_loop_iterate(); + + evas_object_smart_callback_del(m_webView, "title,changed", onTitleChanged); +} + } // namespace EWK2UnitTest diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h index 8fa1b5021..64b9bce60 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h +++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h @@ -37,6 +37,7 @@ protected: virtual void TearDown(); void loadUrlSync(const char* url); + void waitUntilTitleChangedTo(const char* expectedTitle); private: Evas_Object* m_webView; diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp index e7bc0d621..fae77242f 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp @@ -20,6 +20,8 @@ #include "config.h" #include "EWK2UnitTestEnvironment.h" +#include <wtf/text/StringConcatenate.h> + namespace EWK2UnitTest { EWK2UnitTestEnvironment::EWK2UnitTestEnvironment(bool useX11Window) @@ -39,4 +41,9 @@ const char* EWK2UnitTestEnvironment::defaultTheme() const return TEST_THEME_DIR"/default.edj"; } +CString EWK2UnitTestEnvironment::urlForResource(const char* resource) +{ + return makeString("file://"TEST_RESOURCES_DIR"/", resource).utf8(); +} + } // namespace EWK2UnitTest diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h index fac0f5988..d010b6237 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h +++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h @@ -19,7 +19,9 @@ #ifndef EWK2UnitTestEnvironment_h #define EWK2UnitTestEnvironment_h +#include <Eina.h> #include <gtest/gtest.h> +#include <wtf/text/CString.h> namespace EWK2UnitTest { @@ -30,6 +32,7 @@ public: bool useX11Window() const { return m_useX11Window; } const char* defaultTestPageUrl() const; const char* defaultTheme() const; + CString urlForResource(const char* resource); virtual unsigned int defaultWidth() const { return m_defaultWidth; } virtual unsigned int defaultHeight() const { return m_defaultHeight; } diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.cpp b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.cpp index 13e577984..52e6af46e 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.cpp @@ -26,7 +26,7 @@ EWK2UnitTestServer::EWK2UnitTestServer() SoupAddress* address = soup_address_new("127.0.0.1", SOUP_ADDRESS_ANY_PORT); soup_address_resolve_sync(address, 0); - m_soupServer = soup_server_new(SOUP_SERVER_INTERFACE, address, 0); + m_soupServer = soup_server_new(SOUP_SERVER_INTERFACE, address, static_cast<char*>(0)); m_baseURI = soup_uri_new("http://127.0.0.1/"); soup_uri_set_port(m_baseURI, soup_server_get_port(m_soupServer)); g_object_unref(address); diff --git a/Source/WebKit2/UIProcess/API/efl/tests/resources/redirect_uri_to_default.html b/Source/WebKit2/UIProcess/API/efl/tests/resources/redirect_uri_to_default.html new file mode 100644 index 000000000..846fd1113 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/resources/redirect_uri_to_default.html @@ -0,0 +1,6 @@ +<!doctype html> +<body> +<script> +location.href="./default_test_page.html"; +</script> +</body> diff --git a/Source/WebKit2/UIProcess/API/efl/tests/resources/test.pdf b/Source/WebKit2/UIProcess/API/efl/tests/resources/test.pdf Binary files differnew file mode 100644 index 000000000..2424c19d9 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/resources/test.pdf diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_context.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_context.cpp new file mode 100644 index 000000000..034f87140 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_context.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "UnitTestUtils/EWK2UnitTestBase.h" +#include "UnitTestUtils/EWK2UnitTestEnvironment.h" +#include <EWebKit2.h> +#include <gtest/gtest.h> + +using namespace EWK2UnitTest; + +extern EWK2UnitTestEnvironment* environment; + +static const char htmlReply[] = "<html><head><title>Foo</title></head><body>Bar</body></html>"; + +TEST_F(EWK2UnitTestBase, ewk_context_default_get) +{ + Ewk_Context* defaultContext = ewk_context_default_get(); + ASSERT_TRUE(defaultContext); + ASSERT_EQ(defaultContext, ewk_context_default_get()); +} + +TEST_F(EWK2UnitTestBase, ewk_context_cookie_manager_get) +{ + Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_context_default_get()); + ASSERT_TRUE(cookieManager); + ASSERT_EQ(cookieManager, ewk_context_cookie_manager_get(ewk_context_default_get())); +} + +static void schemeRequestCallback(Ewk_Url_Scheme_Request* request, void* userData) +{ + const char* scheme = ewk_url_scheme_request_scheme_get(request); + ASSERT_STREQ(scheme, "fooscheme"); + const char* url = ewk_url_scheme_request_url_get(request); + ASSERT_STREQ(url, "fooscheme:MyPath"); + const char* path = ewk_url_scheme_request_path_get(request); + ASSERT_STREQ(path, "MyPath"); + ASSERT_TRUE(ewk_url_scheme_request_finish(request, htmlReply, strlen(htmlReply), "text/html")); +} + +TEST_F(EWK2UnitTestBase, ewk_context_uri_scheme_register) +{ + ewk_context_uri_scheme_register(ewk_context_default_get(), "fooscheme", schemeRequestCallback, 0); + loadUrlSync("fooscheme:MyPath"); + ASSERT_STREQ(ewk_view_title_get(webView()), "Foo"); +} diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp index 86815b42c..7dbd496bd 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp @@ -153,6 +153,75 @@ TEST_F(EWK2UnitTestBase, ewk_cookie_manager_accept_policy) ASSERT_EQ(countHostnamesWithCookies(cookieManager), 0); } +void onCookiesChanged(void *eventInfo) +{ + bool* cookiesChanged = static_cast<bool*>(eventInfo); + *cookiesChanged = true; +} + +TEST_F(EWK2UnitTestBase, ewk_cookie_manager_changes_watch) +{ + OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer); + httpServer->run(serverCallback); + + Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_context_default_get()); + ASSERT_TRUE(cookieManager); + + ewk_cookie_manager_accept_policy_set(cookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS); + ASSERT_EQ(getAcceptPolicy(cookieManager), EWK_COOKIE_ACCEPT_POLICY_ALWAYS); + + // Watch for changes + bool cookiesChanged = false; + ewk_cookie_manager_changes_watch(cookieManager, onCookiesChanged, &cookiesChanged); + + // Check for cookie changes notifications + loadUrlSync(httpServer->getURIForPath("/index.html").data()); + + while (!cookiesChanged) + ecore_main_loop_iterate(); + ASSERT_TRUE(cookiesChanged); + + cookiesChanged = false; + ewk_cookie_manager_cookies_clear(cookieManager); + while (!cookiesChanged) + ecore_main_loop_iterate(); + ASSERT_TRUE(cookiesChanged); + + // Stop watching for notifications + ewk_cookie_manager_changes_watch(cookieManager, 0, 0); + cookiesChanged = false; + loadUrlSync(httpServer->getURIForPath("/index.html").data()); + ASSERT_EQ(countHostnamesWithCookies(cookieManager), 2); + ASSERT_FALSE(cookiesChanged); + + // Watch again for notifications + ewk_cookie_manager_changes_watch(cookieManager, onCookiesChanged, &cookiesChanged); + + // Make sure we don't get notifications when loading setting an existing persistent storage + char textStorage1[] = "/tmp/txt-cookie.XXXXXX"; + ASSERT_TRUE(mktemp(textStorage1)); + char textStorage2[] = "/tmp/txt-cookie.XXXXXX"; + ASSERT_TRUE(mktemp(textStorage2)); + + ewk_cookie_manager_persistent_storage_set(cookieManager, textStorage1, EWK_COOKIE_PERSISTENT_STORAGE_TEXT); + loadUrlSync(httpServer->getURIForPath("/index.html").data()); + ASSERT_EQ(countHostnamesWithCookies(cookieManager), 2); + + cookiesChanged = false; + ewk_cookie_manager_persistent_storage_set(cookieManager, textStorage2, EWK_COOKIE_PERSISTENT_STORAGE_TEXT); + ASSERT_EQ(countHostnamesWithCookies(cookieManager), 0); + + ewk_cookie_manager_persistent_storage_set(cookieManager, textStorage1, EWK_COOKIE_PERSISTENT_STORAGE_TEXT); + ASSERT_EQ(countHostnamesWithCookies(cookieManager), 2); + + ASSERT_FALSE(cookiesChanged); + + // Final clean up. + ewk_cookie_manager_changes_watch(cookieManager, 0, 0); + unlink(textStorage1); + unlink(textStorage2); +} + TEST_F(EWK2UnitTestBase, ewk_cookie_manager_cookies_delete) { OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer); diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_download_job.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_download_job.cpp new file mode 100644 index 000000000..22c97aad8 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_download_job.cpp @@ -0,0 +1,178 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "UnitTestUtils/EWK2UnitTestBase.h" +#include "UnitTestUtils/EWK2UnitTestEnvironment.h" +#include "UnitTestUtils/EWK2UnitTestServer.h" +#include <EWebKit2.h> +#include <Ecore.h> +#include <gtest/gtest.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <unistd.h> +#include <wtf/OwnPtr.h> +#include <wtf/PassOwnPtr.h> + +using namespace EWK2UnitTest; +using namespace WTF; + +extern EWK2UnitTestEnvironment* environment; + +static const char serverSuggestedFilename[] = "webkit-downloaded-file"; +static const char testFilePath[] = "/test.pdf"; + +struct DownloadTestData { + const char* fileUrl; + const char* destinationPath; +}; + +static inline bool fileExists(const char* path) +{ + struct stat buf; + return !stat(path, &buf); +} + +static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, void*) +{ + if (message->method != SOUP_METHOD_GET) { + soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED); + return; + } + + Eina_Strbuf* filePath = eina_strbuf_new(); + eina_strbuf_append(filePath, TEST_RESOURCES_DIR); + eina_strbuf_append(filePath, path); + + Eina_File* f = eina_file_open(eina_strbuf_string_get(filePath), false); + eina_strbuf_free(filePath); + if (!f) { + soup_message_set_status(message, SOUP_STATUS_NOT_FOUND); + soup_message_body_complete(message->response_body); + return; + } + + size_t fileSize = eina_file_size_get(f); + + void* contents = eina_file_map_all(f, EINA_FILE_POPULATE); + if (!contents) { + soup_message_set_status(message, SOUP_STATUS_NOT_FOUND); + soup_message_body_complete(message->response_body); + return; + } + + soup_message_set_status(message, SOUP_STATUS_OK); + + Eina_Strbuf* contentDisposition = eina_strbuf_new(); + eina_strbuf_append_printf(contentDisposition, "filename=%s", serverSuggestedFilename); + soup_message_headers_append(message->response_headers, "Content-Disposition", eina_strbuf_string_get(contentDisposition)); + eina_strbuf_free(contentDisposition); + + soup_message_body_append(message->response_body, SOUP_MEMORY_COPY, contents, fileSize); + soup_message_body_complete(message->response_body); + + eina_file_map_free(f, contents); + eina_file_close(f); +} + +static void on_download_requested(void* userData, Evas_Object* webview, void* eventInfo) +{ + DownloadTestData* testData = static_cast<DownloadTestData*>(userData); + Ewk_Download_Job* download = static_cast<Ewk_Download_Job*>(eventInfo); + ASSERT_EQ(ewk_download_job_state_get(download), EWK_DOWNLOAD_JOB_STATE_NOT_STARTED); + ASSERT_EQ(ewk_download_job_estimated_progress_get(download), 0); + ASSERT_EQ(ewk_download_job_elapsed_time_get(download), 0); + + Ewk_Url_Request* request = ewk_download_job_request_get(download); + ASSERT_TRUE(request); + EXPECT_STREQ(ewk_url_request_url_get(request), testData->fileUrl); + + Ewk_Url_Response* response = ewk_download_job_response_get(download); + ASSERT_TRUE(response); + EXPECT_STREQ(ewk_url_response_mime_type_get(response), "application/pdf"); + + EXPECT_STREQ(ewk_download_job_suggested_filename_get(download), serverSuggestedFilename); + + ASSERT_FALSE(fileExists(testData->destinationPath)); + ewk_download_job_destination_set(download, testData->destinationPath); + EXPECT_STREQ(ewk_download_job_destination_get(download), testData->destinationPath); +} + +static void on_download_cancelled(void* userData, Evas_Object* webview, void* eventInfo) +{ + fprintf(stderr, "Download was cancelled.\n"); + ecore_main_loop_quit(); + FAIL(); +} + +static void on_download_failed(void* userData, Evas_Object* webview, void* eventInfo) +{ + Ewk_Download_Job_Error* downloadError = static_cast<Ewk_Download_Job_Error*>(eventInfo); + fprintf(stderr, "Download error: %s\n", ewk_web_error_description_get(downloadError->error)); + ecore_main_loop_quit(); + FAIL(); +} + +static void on_download_finished(void* userData, Evas_Object* webview, void* eventInfo) +{ + DownloadTestData* testData = static_cast<DownloadTestData*>(userData); + Ewk_Download_Job* download = static_cast<Ewk_Download_Job*>(eventInfo); + + ASSERT_EQ(ewk_download_job_estimated_progress_get(download), 1); + ASSERT_EQ(ewk_download_job_state_get(download), EWK_DOWNLOAD_JOB_STATE_FINISHED); + ASSERT_GT(ewk_download_job_elapsed_time_get(download), 0); + + ASSERT_TRUE(fileExists(testData->destinationPath)); + + ecore_main_loop_quit(); +} + +TEST_F(EWK2UnitTestBase, ewk_download) +{ + OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer); + httpServer->run(serverCallback); + + // Generate unique name for destination file. + char destinationPath[] = "/tmp/pdf-file.XXXXXX"; + ASSERT_TRUE(mktemp(destinationPath)); + + CString fileUrl = httpServer->getURIForPath(testFilePath); + + DownloadTestData userData = { fileUrl.data(), destinationPath }; + ASSERT_FALSE(fileExists(destinationPath)); + + evas_object_smart_callback_add(webView(), "download,request", on_download_requested, &userData); + evas_object_smart_callback_add(webView(), "download,cancel", on_download_cancelled, &userData); + evas_object_smart_callback_add(webView(), "download,failed", on_download_failed, &userData); + evas_object_smart_callback_add(webView(), "download,finished", on_download_finished, &userData); + + // Download test pdf + ewk_view_uri_set(webView(), fileUrl.data()); + ecore_main_loop_begin(); + + // Clean up + unlink(destinationPath); +} diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp index 8ee134d35..5edb04379 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp @@ -21,15 +21,170 @@ #include "UnitTestUtils/EWK2UnitTestBase.h" #include "UnitTestUtils/EWK2UnitTestEnvironment.h" +#include "UnitTestUtils/EWK2UnitTestServer.h" #include <EWebKit2.h> +#include <Ecore.h> #include <gtest/gtest.h> +#include <wtf/OwnPtr.h> +#include <wtf/PassOwnPtr.h> +#include <wtf/UnusedParam.h> +#include <wtf/text/CString.h> using namespace EWK2UnitTest; extern EWK2UnitTestEnvironment* environment; +static void onLoadFinishedForRedirection(void* userData, Evas_Object*, void*) +{ + int* countLoadFinished = static_cast<int*>(userData); + (*countLoadFinished)--; +} + TEST_F(EWK2UnitTestBase, ewk_view_uri_get) { loadUrlSync(environment->defaultTestPageUrl()); EXPECT_STREQ(ewk_view_uri_get(webView()), environment->defaultTestPageUrl()); + + int countLoadFinished = 2; + evas_object_smart_callback_add(webView(), "load,finished", onLoadFinishedForRedirection, &countLoadFinished); + ewk_view_uri_set(webView(), environment->urlForResource("redirect_uri_to_default.html").data()); + while (countLoadFinished) + ecore_main_loop_iterate(); + evas_object_smart_callback_del(webView(), "load,finished", onLoadFinishedForRedirection); + EXPECT_STREQ(ewk_view_uri_get(webView()), environment->defaultTestPageUrl()); +} + +TEST_F(EWK2UnitTestBase, ewk_view_device_pixel_ratio) +{ + loadUrlSync(environment->defaultTestPageUrl()); + + // Default pixel ratio is 1.0 + ASSERT_FLOAT_EQ(ewk_view_device_pixel_ratio_get(webView()), 1); + + ASSERT_TRUE(ewk_view_device_pixel_ratio_set(webView(), 1.2)); + ASSERT_FLOAT_EQ(ewk_view_device_pixel_ratio_get(webView()), 1.2); + + ASSERT_TRUE(ewk_view_device_pixel_ratio_set(webView(), 1)); + ASSERT_FLOAT_EQ(ewk_view_device_pixel_ratio_get(webView()), 1); +} + +TEST_F(EWK2UnitTestBase, ewk_view_html_string_load) +{ + ewk_view_html_string_load(webView(), "<html><head><title>Foo</title></head><body>Bar</body></html>", 0, 0); + waitUntilTitleChangedTo("Foo"); + ASSERT_STREQ(ewk_view_title_get(webView()), "Foo"); + ewk_view_html_string_load(webView(), "<html><head><title>Bar</title></head><body>Foo</body></html>", 0, 0); + waitUntilTitleChangedTo("Bar"); + ASSERT_STREQ(ewk_view_title_get(webView()), "Bar"); +} + +static void serverCallbackNavigation(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer) +{ + if (message->method != SOUP_METHOD_GET) { + soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED); + return; + } + + soup_message_set_status(message, SOUP_STATUS_OK); + + Eina_Strbuf* body = eina_strbuf_new(); + eina_strbuf_append_printf(body, "<html><title>%s</title><body>%s</body></html>", path + 1, path + 1); + const size_t bodyLength = eina_strbuf_length_get(body); + soup_message_body_append(message->response_body, SOUP_MEMORY_TAKE, eina_strbuf_string_steal(body), bodyLength); + eina_strbuf_free(body); + + soup_message_body_complete(message->response_body); +} + +TEST_F(EWK2UnitTestBase, ewk_view_navigation) +{ + OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer); + httpServer->run(serverCallbackNavigation); + + // Visit Page1 + loadUrlSync(httpServer->getURIForPath("/Page1").data()); + ASSERT_STREQ(ewk_view_title_get(webView()), "Page1"); + ASSERT_FALSE(ewk_view_back_possible(webView())); + ASSERT_FALSE(ewk_view_forward_possible(webView())); + + // Visit Page2 + loadUrlSync(httpServer->getURIForPath("/Page2").data()); + ASSERT_STREQ(ewk_view_title_get(webView()), "Page2"); + ASSERT_TRUE(ewk_view_back_possible(webView())); + ASSERT_FALSE(ewk_view_forward_possible(webView())); + + // Go back to Page1 + ewk_view_back(webView()); + waitUntilTitleChangedTo("Page1"); + ASSERT_STREQ(ewk_view_title_get(webView()), "Page1"); + ASSERT_FALSE(ewk_view_back_possible(webView())); + ASSERT_TRUE(ewk_view_forward_possible(webView())); + + // Go forward to Page2 + ewk_view_forward(webView()); + waitUntilTitleChangedTo("Page2"); + ASSERT_STREQ(ewk_view_title_get(webView()), "Page2"); + ASSERT_TRUE(ewk_view_back_possible(webView())); + ASSERT_FALSE(ewk_view_forward_possible(webView())); +} + +TEST_F(EWK2UnitTestBase, ewk_view_setting_encoding_custom) +{ + ASSERT_FALSE(ewk_view_setting_encoding_custom_get(webView())); + ASSERT_TRUE(ewk_view_setting_encoding_custom_set(webView(), "UTF-8")); + ASSERT_STREQ(ewk_view_setting_encoding_custom_get(webView()), "UTF-8"); + // Set the default charset. + ASSERT_TRUE(ewk_view_setting_encoding_custom_set(webView(), 0)); + ASSERT_FALSE(ewk_view_setting_encoding_custom_get(webView())); +} + +static void onFormAboutToBeSubmitted(void* userData, Evas_Object*, void* eventInfo) +{ + Ewk_Form_Submission_Request* request = static_cast<Ewk_Form_Submission_Request*>(eventInfo); + bool* handled = static_cast<bool*>(userData); + + ASSERT_TRUE(request); + + Eina_List* fieldNames = ewk_form_submission_request_field_names_get(request); + ASSERT_TRUE(fieldNames); + ASSERT_EQ(eina_list_count(fieldNames), 3); + void* data; + EINA_LIST_FREE(fieldNames, data) + eina_stringshare_del(static_cast<char*>(data)); + + const char* value1 = ewk_form_submission_request_field_value_get(request, "text1"); + ASSERT_STREQ(value1, "value1"); + eina_stringshare_del(value1); + const char* value2 = ewk_form_submission_request_field_value_get(request, "text2"); + ASSERT_STREQ(value2, "value2"); + eina_stringshare_del(value2); + const char* password = ewk_form_submission_request_field_value_get(request, "password"); + ASSERT_STREQ(password, "secret"); + eina_stringshare_del(password); + + *handled = true; +} + +TEST_F(EWK2UnitTestBase, ewk_view_form_submission_request) +{ + const char* formHTML = + "<html><head><script type='text/javascript'>function submitForm() { document.getElementById('myform').submit(); }</script></head>" + "<body onload='submitForm()'>" + " <form id='myform' action='#'>" + " <input type='text' name='text1' value='value1'>" + " <input type='text' name='text2' value='value2'>" + " <input type='password' name='password' value='secret'>" + " <textarea cols='5' rows='5' name='textarea'>Text</textarea>" + " <input type='hidden' name='hidden1' value='hidden1'>" + " <input type='submit' value='Submit'>" + " </form>" + "</body></html>"; + + ewk_view_html_string_load(webView(), formHTML, "file:///", 0); + bool handled = false; + evas_object_smart_callback_add(webView(), "form,submission,request", onFormAboutToBeSubmitted, &handled); + while (!handled) + ecore_main_loop_iterate(); + ASSERT_TRUE(handled); + evas_object_smart_callback_del(webView(), "form,submission,request", onFormAboutToBeSubmitted); } diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h index 7fd5d7861..aa8a71bf9 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h @@ -40,6 +40,7 @@ #include <WebKit2/WKSerializedScriptValue.h> #include <WebKit2/WKSoupRequestManager.h> #include <WebKit2/WKString.h> +#include <WebKit2/WKTextChecker.h> #include <WebKit2/WebKit2.h> #include <glib.h> #include <wtf/Assertions.h> diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp new file mode 100644 index 000000000..5676bb6d7 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp @@ -0,0 +1,152 @@ +/* + * Copyright (C) 2012 Igalia S.L. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebKitTextChecker.h" + +#if ENABLE(SPELLCHECK) + +#include "WebKitPrivate.h" +#include <wtf/Vector.h> +#include <wtf/text/CString.h> + +using namespace WebKit; + +static inline WebKitTextChecker* toTextChecker(const void* clientInfo) +{ + return static_cast<WebKitTextChecker*>(const_cast<void*>(clientInfo)); +} + +static bool continuousSpellCheckingEnabledCallback(const void* clientInfo) +{ + return toTextChecker(clientInfo)->isSpellCheckingEnabled(); +} + +static void setContinuousSpellCheckingEnabledCallback(bool enabled, const void* clientInfo) +{ + toTextChecker(clientInfo)->setSpellCheckingEnabled(enabled); +} + +static void checkSpellingOfStringCallback(uint64_t tag, WKStringRef text, int32_t* misspellingLocation, int32_t* misspellingLength, const void* clientInfo) +{ + toTextChecker(clientInfo)->checkSpellingOfString(toImpl(text)->string(), *misspellingLocation, *misspellingLength); +} + +static WKArrayRef guessesForWordCallback(uint64_t tag, WKStringRef word, const void* clientInfo) +{ + Vector<String> guesses = toTextChecker(clientInfo)->getGuessesForWord(toImpl(word)->string()); + if (guesses.isEmpty()) + return 0; + + WKMutableArrayRef wkSuggestions = WKMutableArrayCreate(); + for (Vector<String>::const_iterator iter = guesses.begin(); iter != guesses.end(); ++iter) { + WKRetainPtr<WKStringRef> wkSuggestion(AdoptWK, WKStringCreateWithUTF8CString(iter->utf8().data())); + WKArrayAppendItem(wkSuggestions, wkSuggestion.get()); + } + + return wkSuggestions; +} + +static void learnWordCallback(uint64_t tag, WKStringRef word, const void* clientInfo) +{ + toTextChecker(clientInfo)->learnWord(toImpl(word)->string()); +} + +static void ignoreWordCallback(uint64_t tag, WKStringRef word, const void* clientInfo) +{ + toTextChecker(clientInfo)->ignoreWord(toImpl(word)->string()); +} + +WebKitTextChecker::~WebKitTextChecker() +{ +} + +WebKitTextChecker::WebKitTextChecker() + : m_textChecker(WebCore::TextCheckerEnchant::create()) + , m_spellCheckingEnabled(false) +{ + WKTextCheckerClient wkTextCheckerClient = { + kWKTextCheckerClientCurrentVersion, + this, // clientInfo + 0, // continuousSpellCheckingAllowed + continuousSpellCheckingEnabledCallback, + setContinuousSpellCheckingEnabledCallback, + 0, // grammarCheckingEnabled + 0, // setGrammarCheckingEnabled + 0, // uniqueSpellDocumentTag + 0, // closeSpellDocumentWithTag + checkSpellingOfStringCallback, + 0, // checkGrammarOfString + 0, // spellingUIIsShowing + 0, // toggleSpellingUIIsShowing + 0, // updateSpellingUIWithMisspelledWord + 0, // updateSpellingUIWithGrammarString + guessesForWordCallback, + learnWordCallback, + ignoreWordCallback, + }; + WKTextCheckerSetClient(&wkTextCheckerClient); +} + +void WebKitTextChecker::checkSpellingOfString(const String& string, int& misspellingLocation, int& misspellingLength) +{ + m_textChecker->checkSpellingOfString(string, misspellingLocation, misspellingLength); +} + +Vector<String> WebKitTextChecker::getGuessesForWord(const String& word) +{ + return m_textChecker->getGuessesForWord(word); +} + +void WebKitTextChecker::learnWord(const String& word) +{ + m_textChecker->learnWord(word); +} + +void WebKitTextChecker::ignoreWord(const String& word) +{ + m_textChecker->ignoreWord(word); +} + +void WebKitTextChecker::setSpellCheckingEnabled(bool enabled) +{ + if (m_spellCheckingEnabled == enabled) + return; + m_spellCheckingEnabled = enabled; + + // We need to notify the Web process that this has changed. + WKTextCheckerContinuousSpellCheckingEnabledStateChanged(enabled); +} + +void WebKitTextChecker::setSpellCheckingLanguages(const String& languages) +{ + if (m_spellCheckingLanguages == languages) + return; + m_spellCheckingLanguages = languages; + + // We need to update the languages in the enchant-based checker too. + m_textChecker->updateSpellCheckingLanguages(languages); +} +#endif // ENABLE(SPELLCHECK) diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h b/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h new file mode 100644 index 000000000..dd7583a3a --- /dev/null +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2012 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef WebKitTextChecker_h +#define WebKitTextChecker_h + +#if ENABLE(SPELLCHECK) + +#include <WebCore/TextCheckerEnchant.h> +#include <wtf/FastAllocBase.h> +#include <wtf/PassOwnPtr.h> +#include <wtf/Vector.h> + +class WebKitTextChecker { + WTF_MAKE_FAST_ALLOCATED; + +public: + static PassOwnPtr<WebKitTextChecker> create() { return adoptPtr(new WebKitTextChecker()); } + virtual ~WebKitTextChecker(); + + // For implementing TextCheckerClient. + bool isSpellCheckingEnabled() { return m_spellCheckingEnabled; } + void setSpellCheckingEnabled(bool enabled); + void checkSpellingOfString(const String& string, int& misspellingLocation, int& misspellingLength); + Vector<String> getGuessesForWord(const String& word); + void learnWord(const String& word); + void ignoreWord(const String& word); + + // To be called from WebKitWebContext only. + const String getSpellCheckingLanguages() { return m_spellCheckingLanguages; } + void setSpellCheckingLanguages(const String& spellCheckingLanguages); + +private: + WebKitTextChecker(); + + OwnPtr<WebCore::TextCheckerEnchant> m_textChecker; + String m_spellCheckingLanguages; + bool m_spellCheckingEnabled; +}; + +#endif // ENABLE(SPELLCHECK) + +#endif // WebKitTextChecker_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp index 8a0625c07..4008e865f 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp @@ -28,10 +28,13 @@ #include "WebKitPluginPrivate.h" #include "WebKitPrivate.h" #include "WebKitRequestManagerClient.h" +#include "WebKitTextChecker.h" #include "WebKitURISchemeRequestPrivate.h" #include "WebKitWebContextPrivate.h" #include <WebCore/FileSystem.h> #include <wtf/HashMap.h> +#include <wtf/OwnPtr.h> +#include <wtf/gobject/GOwnPtr.h> #include <wtf/gobject/GRefPtr.h> #include <wtf/text/CString.h> @@ -72,6 +75,10 @@ struct _WebKitWebContextPrivate { #if ENABLE(GEOLOCATION) RefPtr<WebKitGeolocationProvider> geolocationProvider; #endif +#if ENABLE(SPELLCHECK) + OwnPtr<WebKitTextChecker> textChecker; + GOwnPtr<gchar> spellCheckingLanguages; +#endif }; static guint signals[LAST_SIGNAL] = { 0, }; @@ -127,6 +134,9 @@ static gpointer createDefaultWebContext(gpointer) WKGeolocationManagerRef wkGeolocationManager = WKContextGetGeolocationManager(webContext->priv->context.get()); webContext->priv->geolocationProvider = WebKitGeolocationProvider::create(wkGeolocationManager); #endif +#if ENABLE(SPELLCHECK) + webContext->priv->textChecker = WebKitTextChecker::create(); +#endif return webContext.get(); } @@ -418,6 +428,88 @@ void webkit_web_context_register_uri_scheme(WebKitWebContext* context, const cha WKSoupRequestManagerRegisterURIScheme(context->priv->requestManager.get(), wkScheme.get()); } +/** + * webkit_web_context_get_spell_checking_enabled: + * @context: a #WebKitWebContext + * + * Get the current status of the spell checking feature. + * + * Returns: %TRUE If spell checking is enabled, or %FALSE otherwise. + */ +gboolean webkit_web_context_get_spell_checking_enabled(WebKitWebContext* context) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), FALSE); + +#if ENABLE(SPELLCHECK) + return context->priv->textChecker->isSpellCheckingEnabled(); +#else + return false; +#endif +} + +/** + * webkit_web_context_set_spell_checking_enabled: + * @context: a #WebKitWebContext + * @enabled: Value to be set + * + * Enable or disable the spell checking feature. + */ +void webkit_web_context_set_spell_checking_enabled(WebKitWebContext* context, gboolean enabled) +{ + g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); + +#if ENABLE(SPELLCHECK) + context->priv->textChecker->setSpellCheckingEnabled(enabled); +#endif +} + +/** + * webkit_web_context_get_spell_checking_languages: + * @context: a #WebKitWebContext + * + * Get the the list of spell checking languages associated with + * @context, separated by commas. See + * webkit_web_context_set_spell_checking_languages() for more details + * on the format of the languages in the list. + * + * Returns: (transfer none): A comma separated list of languages. + */ +const gchar* webkit_web_context_get_spell_checking_languages(WebKitWebContext* context) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0); + +#if ENABLE(SPELLCHECK) + return context->priv->spellCheckingLanguages.get(); +#else + return 0; +#endif +} + +/** + * webkit_web_context_set_spell_checking_languages: + * @context: a #WebKitWebContext + * @languages: (allow-none): new list of spell checking + * languages separated by commas, or %NULL + * + * Set the list of spell checking languages to be used for spell + * checking, separated by commas. In case %NULL is passed, the default + * value as returned by gtk_get_default_language() will be used. + * + * The locale string typically is in the form lang_COUNTRY, where lang + * is an ISO-639 language code, and COUNTRY is an ISO-3166 country code. + * For instance, sv_FI for Swedish as written in Finland or pt_BR + * for Portuguese as written in Brazil. + */ +void webkit_web_context_set_spell_checking_languages(WebKitWebContext* context, const gchar* languages) +{ + g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); + +#if ENABLE(SPELLCHECK) + context->priv->textChecker->setSpellCheckingLanguages(String(languages)); + context->priv->spellCheckingLanguages.set(g_strdup(languages)); +#endif +} + WebKitDownload* webkitWebContextGetOrCreateDownload(WKDownloadRef wkDownload) { GRefPtr<WebKitDownload> download = downloadsMap().get(wkDownload); diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h index 83b601a38..0d32ba5bb 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h @@ -132,6 +132,20 @@ webkit_web_context_register_uri_scheme (WebKitWebContext const gchar *scheme, WebKitURISchemeRequestCallback callback, gpointer user_data); + +WEBKIT_API gboolean +webkit_web_context_get_spell_checking_enabled (WebKitWebContext *context); + +WEBKIT_API void +webkit_web_context_set_spell_checking_enabled (WebKitWebContext *context, + gboolean enabled); +WEBKIT_API const gchar * +webkit_web_context_get_spell_checking_languages (WebKitWebContext *context); + +WEBKIT_API void +webkit_web_context_set_spell_checking_languages (WebKitWebContext *context, + const gchar *languages); + G_END_DECLS #endif diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt index 3164177cc..73f09d5d3 100644 --- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt +++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt @@ -33,6 +33,10 @@ webkit_web_context_get_cookie_manager webkit_web_context_set_additional_plugins_directory webkit_web_context_get_plugins webkit_web_context_get_plugins_finish +webkit_web_context_get_spell_checking_enabled +webkit_web_context_set_spell_checking_enabled +webkit_web_context_get_spell_checking_languages +webkit_web_context_set_spell_checking_languages <SUBSECTION URI Scheme> WebKitURISchemeRequestCallback diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp index e7d43a13d..f42feafb7 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp @@ -231,11 +231,38 @@ static void testWebContextURIScheme(URISchemeTest* test, gconstpointer) g_assert(!test->m_loadEvents.contains(LoadTrackingTest::LoadFailed)); } +static void testWebContextSpellChecker(Test* test, gconstpointer) +{ + GRefPtr<WebKitWebContext> webContext(webkit_web_context_get_default()); + + // Set the language to a specific one, an empty one and a list of them. + webkit_web_context_set_spell_checking_languages(webContext.get(), "en_US"); + const gchar* currentLanguage(webkit_web_context_get_spell_checking_languages(webContext.get())); + g_assert_cmpstr(currentLanguage, ==, "en_US"); + + webkit_web_context_set_spell_checking_languages(webContext.get(), 0); + currentLanguage = webkit_web_context_get_spell_checking_languages(webContext.get()); + g_assert_cmpstr(currentLanguage, ==, 0); + + webkit_web_context_set_spell_checking_languages(webContext.get(), "es_ES,en_US"); + currentLanguage = webkit_web_context_get_spell_checking_languages(webContext.get()); + g_assert_cmpstr(currentLanguage, ==, "es_ES,en_US"); + + // Check disabling and re-enabling spell checking. + webkit_web_context_set_spell_checking_enabled(webContext.get(), FALSE); + gboolean isSpellCheckingEnabled = webkit_web_context_get_spell_checking_enabled(webContext.get()); + g_assert(!isSpellCheckingEnabled); + webkit_web_context_set_spell_checking_enabled(webContext.get(), TRUE); + isSpellCheckingEnabled = webkit_web_context_get_spell_checking_enabled(webContext.get()); + g_assert(isSpellCheckingEnabled); +} + void beforeAll() { Test::add("WebKitWebContext", "default-context", testWebContextDefault); PluginsTest::add("WebKitWebContext", "get-plugins", testWebContextGetPlugins); URISchemeTest::add("WebKitWebContext", "uri-scheme", testWebContextURIScheme); + Test::add("WebKitWebContext", "spell-checker", testWebContextSpellChecker); } void afterAll() diff --git a/Source/WebKit2/UIProcess/API/mac/WKView.mm b/Source/WebKit2/UIProcess/API/mac/WKView.mm index 27f233b69..a11ef65d0 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKView.mm +++ b/Source/WebKit2/UIProcess/API/mac/WKView.mm @@ -1201,6 +1201,7 @@ static const short kIOHIDEventTypeScroll = 6; // - If it's sent outside of keyboard event processing (e.g. from Character Viewer, or when confirming an inline input area with a mouse), // then we also execute it immediately, as there will be no other chance. if (parameters && !isFromInputMethod) { + // FIXME: Handle replacementRange in this case, too. It's known to occur in practice when canceling Press and Hold (see <rdar://11940670>). ASSERT(replacementRange.location == NSNotFound); KeypressCommand command("insertText:", text); parameters->commands->append(command); @@ -1272,6 +1273,7 @@ static const short kIOHIDEventTypeScroll = 6; - (void)keyUp:(NSEvent *)theEvent { + LOG(TextInput, "keyUp:%p %@", theEvent, theEvent); _data->_page->handleKeyboardEvent(NativeWebKeyboardEvent(theEvent, self)); } @@ -1326,13 +1328,17 @@ static const short kIOHIDEventTypeScroll = 6; - (void)keyDown:(NSEvent *)theEvent { + LOG(TextInput, "keyDown:%p %@%s", theEvent, theEvent, (theEvent == _data->_keyDownEventBeingResent) ? " (re-sent)" : ""); + // There's a chance that responding to this event will run a nested event loop, and // fetching a new event might release the old one. Retaining and then autoreleasing // the current event prevents that from causing a problem inside WebKit or AppKit code. [[theEvent retain] autorelease]; - if ([self _tryHandlePluginComplexTextInputKeyDown:theEvent]) + if ([self _tryHandlePluginComplexTextInputKeyDown:theEvent]) { + LOG(TextInput, "...handled by plug-in"); return; + } // We could be receiving a key down from AppKit if we have re-sent an event // that maps to an action that is currently unavailable (for example a copy when @@ -1347,6 +1353,8 @@ static const short kIOHIDEventTypeScroll = 6; - (void)flagsChanged:(NSEvent *)theEvent { + LOG(TextInput, "flagsChanged:%p %@", theEvent, theEvent); + // There's a chance that responding to this event will run a nested event loop, and // fetching a new event might release the old one. Retaining and then autoreleasing // the current event prevents that from causing a problem inside WebKit or AppKit code. @@ -1372,10 +1380,14 @@ static const short kIOHIDEventTypeScroll = 6; if (parameters->executingSavedKeypressCommands) return; + LOG(TextInput, "Executing %u saved keypress commands...", parameters->commands->size()); + parameters->executingSavedKeypressCommands = true; parameters->eventInterpretationHadSideEffects |= _data->_page->executeKeypressCommands(*parameters->commands); parameters->commands->clear(); parameters->executingSavedKeypressCommands = false; + + LOG(TextInput, "...done executing saved keypress commands."); } - (void)_notifyInputContextAboutDiscardedComposition @@ -1386,6 +1398,7 @@ static const short kIOHIDEventTypeScroll = 6; if (![[self window] isKeyWindow] || self != [[self window] firstResponder]) return; + LOG(TextInput, "-> discardMarkedText"); [[super inputContext] discardMarkedText]; // Inform the input method that we won't have an inline input area despite having been asked to. } @@ -2371,14 +2384,19 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I parameters.commands = &commands; _data->_interpretKeyEventsParameters = ¶meters; + LOG(TextInput, "-> interpretKeyEvents:%p %@", event, event); [self interpretKeyEvents:[NSArray arrayWithObject:event]]; _data->_interpretKeyEventsParameters = 0; // An input method may consume an event and not tell us (e.g. when displaying a candidate window), // in which case we should not bubble the event up the DOM. - if (parameters.consumedByIM) + if (parameters.consumedByIM) { + LOG(TextInput, "...event %p was consumed by an input method", event); return YES; + } + + LOG(TextInput, "...interpretKeyEvents for event %p done, returns %d", event, parameters.eventInterpretationHadSideEffects); // If we have already executed all or some of the commands, the event is "handled". Note that there are additional checks on web process side. return parameters.eventInterpretationHadSideEffects; @@ -2827,10 +2845,12 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path) if (!_data->_inSecureInputState) EnableSecureEventInput(); static NSArray *romanInputSources = [[NSArray alloc] initWithObjects:&NSAllRomanInputSourcesLocaleIdentifier count:1]; + LOG(TextInput, "-> setAllowedInputSourceLocales:romanInputSources"); [context setAllowedInputSourceLocales:romanInputSources]; } else { if (_data->_inSecureInputState) DisableSecureEventInput(); + LOG(TextInput, "-> setAllowedInputSourceLocales:nil"); [context setAllowedInputSourceLocales:nil]; } _data->_inSecureInputState = isInPasswordField; diff --git a/Source/WebKit2/UIProcess/PageClient.h b/Source/WebKit2/UIProcess/PageClient.h index fc5d747c5..518db8e1c 100644 --- a/Source/WebKit2/UIProcess/PageClient.h +++ b/Source/WebKit2/UIProcess/PageClient.h @@ -121,13 +121,16 @@ public: virtual void didChangeContentsSize(const WebCore::IntSize&) = 0; virtual void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&) = 0; virtual void didReceiveMessageFromNavigatorQtObject(const String&) = 0; - virtual void handleDownloadRequest(DownloadProxy*) = 0; virtual void updateTextInputState() = 0; virtual void handleAuthenticationRequiredRequest(const String& hostname, const String& realm, const String& prefilledUsername, String& username, String& password) = 0; virtual void handleCertificateVerificationRequest(const String& hostname, bool& ignoreErrors) = 0; virtual void handleProxyAuthenticationRequiredRequest(const String& hostname, uint16_t port, const String& prefilledUsername, String& username, String& password) = 0; #endif // PLATFORM(QT). +#if PLATFORM(QT) || PLATFORM(EFL) + virtual void handleDownloadRequest(DownloadProxy*) = 0; +#endif // PLATFORM(QT) || PLATFORM(EFL) + #if PLATFORM(QT) || PLATFORM(GTK) virtual void startDrag(const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage) = 0; #endif diff --git a/Source/WebKit2/UIProcess/WebInspectorProxy.cpp b/Source/WebKit2/UIProcess/WebInspectorProxy.cpp index ab19d5d14..3c5c38005 100644 --- a/Source/WebKit2/UIProcess/WebInspectorProxy.cpp +++ b/Source/WebKit2/UIProcess/WebInspectorProxy.cpp @@ -80,7 +80,7 @@ WebInspectorProxy::WebInspectorProxy(WebPageProxy* page) , m_isProfilingPage(false) #if PLATFORM(WIN) , m_inspectorWindow(0) -#elif PLATFORM(GTK) +#elif PLATFORM(GTK) || PLATFORM(EFL) , m_inspectorView(0) , m_inspectorWindow(0) #endif diff --git a/Source/WebKit2/UIProcess/WebInspectorProxy.h b/Source/WebKit2/UIProcess/WebInspectorProxy.h index 0958472e8..5a73a5e8c 100644 --- a/Source/WebKit2/UIProcess/WebInspectorProxy.h +++ b/Source/WebKit2/UIProcess/WebInspectorProxy.h @@ -52,6 +52,11 @@ OBJC_CLASS WKWebInspectorWKView; #include "WebInspectorClientGtk.h" #endif +#if PLATFORM(EFL) +#include <Ecore_Evas.h> +#include <Evas.h> +#endif + namespace WebKit { class WebFrameProxy; @@ -217,6 +222,9 @@ private: WebInspectorClientGtk m_client; GtkWidget* m_inspectorView; GtkWidget* m_inspectorWindow; +#elif PLATFORM(EFL) + Evas_Object* m_inspectorView; + Ecore_Evas* m_inspectorWindow; #endif #if ENABLE(INSPECTOR_SERVER) int m_remoteInspectionPageId; diff --git a/Source/WebKit2/UIProcess/WebPageProxy.cpp b/Source/WebKit2/UIProcess/WebPageProxy.cpp index 344ed9846..6cf260a36 100644 --- a/Source/WebKit2/UIProcess/WebPageProxy.cpp +++ b/Source/WebKit2/UIProcess/WebPageProxy.cpp @@ -1136,7 +1136,7 @@ void WebPageProxy::handleKeyboardEvent(const NativeWebKeyboardEvent& event) bool handled = false; process()->sendSync(Messages::WebPage::KeyEventSyncForTesting(event), Messages::WebPage::KeyEventSyncForTesting::Reply(handled), m_pageID); didReceiveEvent(event.type(), handled); - } else + } else if (m_keyEventQueue.size() == 1) // Otherwise, sent from DidReceiveEvent message handler. process()->send(Messages::WebPage::KeyEvent(event), m_pageID); } @@ -1221,7 +1221,7 @@ void WebPageProxy::receivedPolicyDecision(PolicyAction action, WebFrameProxy* fr // Create a download proxy. DownloadProxy* download = m_process->context()->createDownloadProxy(); downloadID = download->downloadID(); -#if PLATFORM(QT) +#if PLATFORM(QT) || PLATFORM(EFL) // Our design does not suppport downloads without a WebPage. handleDownloadRequest(download); #endif @@ -2642,11 +2642,6 @@ void WebPageProxy::didReceiveMessageFromNavigatorQtObject(const String& contents m_pageClient->didReceiveMessageFromNavigatorQtObject(contents); } -void WebPageProxy::handleDownloadRequest(DownloadProxy* download) -{ - m_pageClient->handleDownloadRequest(download); -} - void WebPageProxy::authenticationRequiredRequest(const String& hostname, const String& realm, const String& prefilledUsername, String& username, String& password) { m_pageClient->handleAuthenticationRequiredRequest(hostname, realm, prefilledUsername, username, password); @@ -2663,6 +2658,13 @@ void WebPageProxy::certificateVerificationRequest(const String& hostname, bool& } #endif // PLATFORM(QT). +#if PLATFORM(QT) || PLATFORM(EFL) +void WebPageProxy::handleDownloadRequest(DownloadProxy* download) +{ + m_pageClient->handleDownloadRequest(download); +} +#endif // PLATFORM(QT) || PLATFORM(EFL) + #if ENABLE(TOUCH_EVENTS) void WebPageProxy::needTouchEvents(bool needTouchEvents) { @@ -3253,8 +3255,10 @@ void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled) m_keyEventQueue.removeFirst(); - m_pageClient->doneWithKeyEvent(event, handled); + if (!m_keyEventQueue.isEmpty()) + process()->send(Messages::WebPage::KeyEvent(m_keyEventQueue.first()), m_pageID); + m_pageClient->doneWithKeyEvent(event, handled); if (handled) break; diff --git a/Source/WebKit2/UIProcess/WebPageProxy.h b/Source/WebKit2/UIProcess/WebPageProxy.h index 33c49a3ca..5633ce750 100644 --- a/Source/WebKit2/UIProcess/WebPageProxy.h +++ b/Source/WebKit2/UIProcess/WebPageProxy.h @@ -635,6 +635,9 @@ public: #if PLATFORM(QT) void findZoomableAreaForPoint(const WebCore::IntPoint&, const WebCore::IntSize&); void didReceiveMessageFromNavigatorQtObject(const String&); +#endif + +#if PLATFORM(QT) || PLATFORM(EFL) void handleDownloadRequest(DownloadProxy*); #endif diff --git a/Source/WebKit2/UIProcess/efl/WebContextEfl.cpp b/Source/WebKit2/UIProcess/efl/WebContextEfl.cpp index ac77ef3f2..8a479d29e 100644 --- a/Source/WebKit2/UIProcess/efl/WebContextEfl.cpp +++ b/Source/WebKit2/UIProcess/efl/WebContextEfl.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "WebContext.h" +#include <Efreet.h> #include <WebCore/ApplicationCacheStorage.h> #include <WebCore/NotImplemented.h> @@ -33,7 +34,7 @@ namespace WebKit { String WebContext::applicationCacheDirectory() { - return WebCore::cacheStorage().cacheDirectory(); + return String::fromUTF8(efreet_cache_home_get()) + "/WebKitEfl/Applications"; } void WebContext::platformInitializeWebProcess(WebProcessCreationParameters&) @@ -48,8 +49,7 @@ void WebContext::platformInvalidateContext() String WebContext::platformDefaultDatabaseDirectory() const { - notImplemented(); - return ""; + return String::fromUTF8(efreet_data_home_get()) + "/WebKitEfl/Databases"; } String WebContext::platformDefaultIconDatabasePath() const @@ -60,8 +60,7 @@ String WebContext::platformDefaultIconDatabasePath() const String WebContext::platformDefaultLocalStorageDirectory() const { - notImplemented(); - return ""; + return String::fromUTF8(efreet_data_home_get()) + "/WebKitEfl/LocalStorage"; } } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/efl/WebInspectorProxyEfl.cpp b/Source/WebKit2/UIProcess/efl/WebInspectorProxyEfl.cpp index b2b68bccc..2b1537e1b 100644 --- a/Source/WebKit2/UIProcess/efl/WebInspectorProxyEfl.cpp +++ b/Source/WebKit2/UIProcess/efl/WebInspectorProxyEfl.cpp @@ -28,15 +28,25 @@ #if ENABLE(INSPECTOR) +#include "WebProcessProxy.h" +#include "ewk_view_private.h" #include <WebCore/NotImplemented.h> +#include <unistd.h> +#include <wtf/text/CString.h> #include <wtf/text/WTFString.h> namespace WebKit { WebPageProxy* WebInspectorProxy::platformCreateInspectorPage() { - notImplemented(); - return 0; + ASSERT(m_page); + + m_inspectorWindow = ecore_evas_buffer_new(initialWindowWidth, initialWindowHeight); + if (!m_inspectorWindow) + return 0; + + m_inspectorView = ewk_view_base_add(ecore_evas_get(m_inspectorWindow), toAPI(page()->process()->context()), toAPI(inspectorPageGroup())); + return ewk_view_page_get(m_inspectorView); } void WebInspectorProxy::platformOpen() @@ -46,7 +56,15 @@ void WebInspectorProxy::platformOpen() void WebInspectorProxy::platformDidClose() { - notImplemented(); + if (m_inspectorView) { + evas_object_del(m_inspectorView); + m_inspectorView = 0; + } + + if (m_inspectorWindow) { + ecore_evas_free(m_inspectorWindow); + m_inspectorWindow = 0; + } } void WebInspectorProxy::platformBringToFront() @@ -67,14 +85,16 @@ void WebInspectorProxy::platformInspectedURLChanged(const String&) String WebInspectorProxy::inspectorPageURL() const { - notImplemented(); - return String(); + return makeString(inspectorBaseURL(), "/inspector.html"); } String WebInspectorProxy::inspectorBaseURL() const { - notImplemented(); - return String(); + String inspectorFilesPath = makeString("file://", WK2_WEB_INSPECTOR_INSTALL_DIR); + if (access(inspectorFilesPath.utf8().data(), R_OK)) + inspectorFilesPath = makeString("file://", WK2_WEB_INSPECTOR_DIR); + + return inspectorFilesPath; } unsigned WebInspectorProxy::platformInspectedWindowHeight() diff --git a/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj b/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj index 6077f6d3e..cf12343df 100644 --- a/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj +++ b/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj @@ -77,7 +77,6 @@ 1A24B5F311F531E800C38269 /* MachUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A24B5F111F531E800C38269 /* MachUtilities.h */; }; 1A24BED5120894D100FBB059 /* SharedMemory.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A24BED3120894D100FBB059 /* SharedMemory.h */; }; 1A24BF3A120896A600FBB059 /* SharedMemoryMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A24BF39120896A600FBB059 /* SharedMemoryMac.cpp */; }; - 1A2A4B00158693920090C9E9 /* ColorSpaceData.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1A2A4AFE158693920090C9E9 /* ColorSpaceData.h */; }; 1A2A4B0E1586A2240090C9E9 /* ColorSpaceData.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A2A4AFD158693920090C9E9 /* ColorSpaceData.mm */; }; 1A2BB6D014117B4D000F35D4 /* PluginProcessConnectionMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2BB6CE14117B4D000F35D4 /* PluginProcessConnectionMessageReceiver.cpp */; }; 1A2BB6D114117B4D000F35D4 /* PluginProcessConnectionMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2BB6CF14117B4D000F35D4 /* PluginProcessConnectionMessages.h */; }; @@ -189,7 +188,6 @@ 1AA56F2911E92BC80061B882 /* PluginController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA56F2811E92BC80061B882 /* PluginController.h */; }; 1AA575FA1496B52600A4EE06 /* EventDispatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AA575F81496B52600A4EE06 /* EventDispatcher.cpp */; }; 1AA575FB1496B52600A4EE06 /* EventDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA575F91496B52600A4EE06 /* EventDispatcher.h */; }; - 1AA575FE1496B6F300A4EE06 /* EventDispatcher.messages.in in Resources */ = {isa = PBXBuildFile; fileRef = 1AA575FD1496B6F300A4EE06 /* EventDispatcher.messages.in */; }; 1AA576021496B97900A4EE06 /* EventDispatcherMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AA575FF1496B7C000A4EE06 /* EventDispatcherMessageReceiver.cpp */; }; 1AA5889211EE70400061B882 /* NetscapePluginStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA5889011EE70400061B882 /* NetscapePluginStream.h */; }; 1AA5889311EE70400061B882 /* NetscapePluginStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AA5889111EE70400061B882 /* NetscapePluginStream.cpp */; }; @@ -874,6 +872,7 @@ C574A58212E66681002DFE98 /* PasteboardTypes.mm in Sources */ = {isa = PBXBuildFile; fileRef = C574A58012E66681002DFE98 /* PasteboardTypes.mm */; }; CD5C66A0134B9D38004FE2A8 /* InjectedBundlePageFullScreenClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD5C669E134B9D36004FE2A8 /* InjectedBundlePageFullScreenClient.cpp */; }; CD5C66A1134B9D38004FE2A8 /* InjectedBundlePageFullScreenClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CD5C669F134B9D37004FE2A8 /* InjectedBundlePageFullScreenClient.h */; }; + CD67D30E15C08F9A00843ADF /* InjectedBundlePageDiagnosticLoggingClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD67D30815C07BE000843ADF /* InjectedBundlePageDiagnosticLoggingClient.cpp */; }; CD6F75F4131B66D000D6B21E /* WebFullScreenManagerProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD73BA3E131A2E8A00EEDED2 /* WebFullScreenManagerProxy.cpp */; }; CD73BA47131ACC9A00EEDED2 /* WebFullScreenManagerProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD73BA45131ACC8800EEDED2 /* WebFullScreenManagerProxyMessageReceiver.cpp */; }; CD73BA4E131ACDB700EEDED2 /* WebFullScreenManagerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD73BA48131ACD8E00EEDED2 /* WebFullScreenManagerMessageReceiver.cpp */; }; @@ -993,7 +992,6 @@ files = ( BCDE0ABF13272708001259FB /* PluginProcess.app in CopyFiles */, 1A50DB66110A3D57000D3FE5 /* WebProcess.app in CopyFiles */, - 1A2A4B00158693920090C9E9 /* ColorSpaceData.h in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1935,6 +1933,8 @@ C574A58012E66681002DFE98 /* PasteboardTypes.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PasteboardTypes.mm; sourceTree = "<group>"; }; CD5C669E134B9D36004FE2A8 /* InjectedBundlePageFullScreenClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundlePageFullScreenClient.cpp; sourceTree = "<group>"; }; CD5C669F134B9D37004FE2A8 /* InjectedBundlePageFullScreenClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundlePageFullScreenClient.h; sourceTree = "<group>"; }; + CD67D30815C07BE000843ADF /* InjectedBundlePageDiagnosticLoggingClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundlePageDiagnosticLoggingClient.cpp; sourceTree = "<group>"; }; + CD67D30915C07BE000843ADF /* InjectedBundlePageDiagnosticLoggingClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundlePageDiagnosticLoggingClient.h; sourceTree = "<group>"; }; CD73BA37131A29FE00EEDED2 /* WebFullScreenManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebFullScreenManager.cpp; path = FullScreen/WebFullScreenManager.cpp; sourceTree = "<group>"; }; CD73BA38131A29FE00EEDED2 /* WebFullScreenManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebFullScreenManager.h; path = FullScreen/WebFullScreenManager.h; sourceTree = "<group>"; }; CD73BA39131A29FE00EEDED2 /* WebFullScreenManager.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebFullScreenManager.messages.in; path = FullScreen/WebFullScreenManager.messages.in; sourceTree = "<group>"; }; @@ -3243,6 +3243,8 @@ BC498616124D10E200D834E1 /* InjectedBundleHitTestResult.h */, BC8147D412F66D31007B2C32 /* InjectedBundleNavigationAction.cpp */, BC8147D312F66D31007B2C32 /* InjectedBundleNavigationAction.h */, + CD67D30815C07BE000843ADF /* InjectedBundlePageDiagnosticLoggingClient.cpp */, + CD67D30915C07BE000843ADF /* InjectedBundlePageDiagnosticLoggingClient.h */, 512935E11288D97800A4B695 /* InjectedBundlePageContextMenuClient.cpp */, 512935E21288D97800A4B695 /* InjectedBundlePageContextMenuClient.h */, E1EE53E611F8CFFB00CCBEE4 /* InjectedBundlePageEditorClient.cpp */, @@ -4346,7 +4348,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 1AA575FE1496B6F300A4EE06 /* EventDispatcher.messages.in in Resources */, E133FD8A1423DD7F00FC7BFB /* WebKit.icns in Resources */, E1967E38150AB5E200C73169 /* com.apple.WebProcess.sb in Resources */, ); @@ -4951,6 +4952,7 @@ 51FA2D7715212E2600C1BA0B /* WKBundleDOMWindowExtension.cpp in Sources */, 1A2A4B0E1586A2240090C9E9 /* ColorSpaceData.mm in Sources */, 3F87B9BD158940120090FF62 /* WebColorChooser.cpp in Sources */, + CD67D30E15C08F9A00843ADF /* InjectedBundlePageDiagnosticLoggingClient.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h index e40c898c7..3355d086d 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h @@ -46,6 +46,7 @@ class InjectedBundleBackForwardList; class InjectedBundleBackForwardListItem; class InjectedBundleDOMWindowExtension; class InjectedBundleHitTestResult; +class InjectedBundleIntentRequest; class InjectedBundleNavigationAction; class InjectedBundleNodeHandle; class InjectedBundleRangeHandle; @@ -63,6 +64,7 @@ WK_ADD_API_MAPPING(WKBundleDOMWindowExtensionRef, InjectedBundleDOMWindowExtensi WK_ADD_API_MAPPING(WKBundleFrameRef, WebFrame) WK_ADD_API_MAPPING(WKBundleHitTestResultRef, InjectedBundleHitTestResult) WK_ADD_API_MAPPING(WKBundleInspectorRef, WebInspector) +WK_ADD_API_MAPPING(WKBundleIntentRequestRef, InjectedBundleIntentRequest) WK_ADD_API_MAPPING(WKBundleNavigationActionRef, InjectedBundleNavigationAction) WK_ADD_API_MAPPING(WKBundleNodeHandleRef, InjectedBundleNodeHandle) WK_ADD_API_MAPPING(WKBundlePageGroupRef, WebPageGroupProxy) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.cpp new file mode 100644 index 000000000..81c95c6c5 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WKBundleIntentRequest.h" + +#if ENABLE(WEB_INTENTS) +#include "InjectedBundleIntentRequest.h" +#include "WKAPICast.h" +#include "WKBundleAPICast.h" +#include "WebIntentData.h" + +using namespace WebKit; +#endif + +WKTypeID WKBundleIntentRequestGetTypeID() +{ +#if ENABLE(WEB_INTENTS) + return toAPI(InjectedBundleIntentRequest::APIType); +#else + return 0; +#endif +} + +WKIntentDataRef WKBundleIntentRequestCopyIntentData(WKBundleIntentRequestRef requestRef) +{ +#if ENABLE(WEB_INTENTS) + RefPtr<WebIntentData> webIntentData = toImpl(requestRef)->intent(); + return toAPI(webIntentData.release().leakRef()); +#else + return 0; +#endif +} + +void WKBundleIntentRequestPostResult(WKBundleIntentRequestRef requestRef, WKSerializedScriptValueRef serializedDataRef) +{ +#if ENABLE(WEB_INTENTS) + return toImpl(requestRef)->postResult(toImpl(serializedDataRef)); +#endif +} + +void WKBundleIntentRequestPostFailure(WKBundleIntentRequestRef requestRef, WKSerializedScriptValueRef serializedDataRef) +{ +#if ENABLE(WEB_INTENTS) + return toImpl(requestRef)->postFailure(toImpl(serializedDataRef)); +#endif +} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.h new file mode 100644 index 000000000..b18136d13 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKBundleIntentRequest_h +#define WKBundleIntentRequest_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKBundleIntentRequestGetTypeID(); + +WK_EXPORT WKIntentDataRef WKBundleIntentRequestCopyIntentData(WKBundleIntentRequestRef request); + +WK_EXPORT void WKBundleIntentRequestPostResult(WKBundleIntentRequestRef request, WKSerializedScriptValueRef serializedData); +WK_EXPORT void WKBundleIntentRequestPostFailure(WKBundleIntentRequestRef request, WKSerializedScriptValueRef serializedData); + +#ifdef __cplusplus +} +#endif + +#endif /* WKBundleIntentRequest_h */ diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp index 07841d7cc..2ae22371d 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp @@ -31,6 +31,7 @@ #include "InjectedBundleNodeHandle.h" #include "WKAPICast.h" #include "WKBundleAPICast.h" +#include "WebFrame.h" #include "WebFullScreenManager.h" #include "WebImage.h" #include "WebPage.h" @@ -45,6 +46,10 @@ #include <WebCore/KURL.h> #include <WebCore/Page.h> +#if ENABLE(WEB_INTENTS) +#include "WebIntentData.h" +#endif + using namespace WebKit; WKTypeID WKBundlePageGetTypeID() @@ -124,6 +129,11 @@ void WKBundlePageDidExitFullScreen(WKBundlePageRef pageRef) #endif } +void WKBundlePageSetDiagnosticLoggingClient(WKBundlePageRef pageRef, WKBundlePageDiagnosticLoggingClient* client) +{ + toImpl(pageRef)->initializeInjectedBundleDiagnosticLoggingClient(client); +} + WKBundlePageGroupRef WKBundlePageGetPageGroup(WKBundlePageRef pageRef) { return toAPI(toImpl(pageRef)->pageGroup()); @@ -300,6 +310,13 @@ double WKBundlePageGetBackingScaleFactor(WKBundlePageRef pageRef) return toImpl(pageRef)->deviceScaleFactor(); } +void WKBundlePageDeliverIntentToFrame(WKBundlePageRef pageRef, WKBundleFrameRef frameRef, WKIntentDataRef intentRef) +{ +#if ENABLE(WEB_INTENTS) + toImpl(pageRef)->deliverIntentToFrame(toImpl(frameRef)->frameID(), toImpl(intentRef)->store()); +#endif +} + #if defined(ENABLE_INSPECTOR) && ENABLE_INSPECTOR WKBundleInspectorRef WKBundlePageGetInspector(WKBundlePageRef pageRef) { diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h index f70d5b36b..aa8609244 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h @@ -109,7 +109,7 @@ typedef void (*WKBundlePageWillDisconnectDOMWindowExtensionFromGlobalObjectCallb typedef void (*WKBundlePageDidReconnectDOMWindowExtensionToGlobalObjectCallback)(WKBundlePageRef page, WKBundleDOMWindowExtensionRef, const void* clientInfo); typedef void (*WKBundlePageWillDestroyGlobalObjectForDOMWindowExtensionCallback)(WKBundlePageRef page, WKBundleDOMWindowExtensionRef, const void* clientInfo); typedef bool (*WKBundlePageShouldForceUniversalAccessFromLocalURLCallback)(WKBundlePageRef, WKStringRef url, const void* clientInfo); -typedef void (*WKBundlePageDidReceiveIntentForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKIntentDataRef intent, WKTypeRef* userData, const void* clientInfo); +typedef void (*WKBundlePageDidReceiveIntentForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleIntentRequestRef intentRequest, WKTypeRef* userData, const void* clientInfo); typedef void (*WKBundlePageRegisterIntentServiceForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKIntentServiceInfoRef serviceInfo, WKTypeRef* userData, const void* clientInfo); struct WKBundlePageLoaderClient { @@ -354,6 +354,18 @@ typedef struct WKBundlePageFullScreenClient WKBundlePageFullScreenClient; enum { kWKBundlePageFullScreenClientCurrentVersion = 1 }; +// MessageTrace client +typedef void (*WKBundlePageDiagnosticLoggingCallback)(WKBundlePageRef page, WKStringRef message, WKStringRef description, WKStringRef success, const void* clientInfo); + +struct WKBundlePageDiagnosticLoggingClient { + int version; + const void * clientInfo; + WKBundlePageDiagnosticLoggingCallback logDiagnosticMessage; +}; +typedef struct WKBundlePageDiagnosticLoggingClient WKBundlePageDiagnosticLoggingClient; + +enum { kWKBundlePageDiagnosticLoggingClientCurrentVersion = 0 }; + WK_EXPORT void WKBundlePageWillEnterFullScreen(WKBundlePageRef page); WK_EXPORT void WKBundlePageDidEnterFullScreen(WKBundlePageRef page); WK_EXPORT void WKBundlePageWillExitFullScreen(WKBundlePageRef page); @@ -368,8 +380,8 @@ WK_EXPORT void WKBundlePageSetPageLoaderClient(WKBundlePageRef page, WKBundlePag WK_EXPORT void WKBundlePageSetResourceLoadClient(WKBundlePageRef page, WKBundlePageResourceLoadClient* client); WK_EXPORT void WKBundlePageSetPolicyClient(WKBundlePageRef page, WKBundlePagePolicyClient* client); WK_EXPORT void WKBundlePageSetUIClient(WKBundlePageRef page, WKBundlePageUIClient* client); - WK_EXPORT void WKBundlePageSetFullScreenClient(WKBundlePageRef page, WKBundlePageFullScreenClient* client); +WK_EXPORT void WKBundlePageSetDiagnosticLoggingClient(WKBundlePageRef page, WKBundlePageDiagnosticLoggingClient* client); WK_EXPORT WKBundlePageGroupRef WKBundlePageGetPageGroup(WKBundlePageRef page); WK_EXPORT WKBundleFrameRef WKBundlePageGetMainFrame(WKBundlePageRef page); @@ -392,6 +404,8 @@ WK_EXPORT WKImageRef WKBundlePageCreateScaledSnapshotInDocumentCoordinates(WKBun WK_EXPORT double WKBundlePageGetBackingScaleFactor(WKBundlePageRef page); +WK_EXPORT void WKBundlePageDeliverIntentToFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKIntentDataRef intent); + #if defined(ENABLE_INSPECTOR) && ENABLE_INSPECTOR WK_EXPORT WKBundleInspectorRef WKBundlePageGetInspector(WKBundlePageRef page); #endif diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntentRequest.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntentRequest.cpp new file mode 100644 index 000000000..5ccb19cad --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntentRequest.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "InjectedBundleIntentRequest.h" + +#if ENABLE(WEB_INTENTS) +#include <WebCore/IntentRequest.h> +#include <WebSerializedScriptValue.h> + +using namespace WebCore; + +namespace WebKit { + +PassRefPtr<InjectedBundleIntentRequest> InjectedBundleIntentRequest::create(IntentRequest* request) +{ + return adoptRef(new InjectedBundleIntentRequest(request)); +} + +InjectedBundleIntentRequest::InjectedBundleIntentRequest(IntentRequest* request) + : m_intentRequest(request) +{ +} + +void InjectedBundleIntentRequest::postResult(WebSerializedScriptValue* data) +{ + m_intentRequest->postResult(static_cast<SerializedScriptValue*>(data->internalRepresentation())); +} + +void InjectedBundleIntentRequest::postFailure(WebSerializedScriptValue* data) +{ + m_intentRequest->postFailure(static_cast<SerializedScriptValue*>(data->internalRepresentation())); +} + +PassRefPtr<WebIntentData> InjectedBundleIntentRequest::intent() const +{ + return WebIntentData::create(IntentData(m_intentRequest->intent())); +} + +} // namespace WebKit + +#endif // ENABLE(WEB_INTENTS) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntentRequest.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntentRequest.h new file mode 100644 index 000000000..b5870d9a2 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntentRequest.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef InjectedBundleIntentRequest_h +#define InjectedBundleIntentRequest_h + +#if ENABLE(WEB_INTENTS) + +#include "APIObject.h" +#include "WebIntentData.h" +#include <wtf/Forward.h> +#include <wtf/PassRefPtr.h> +#include <wtf/RefPtr.h> + +namespace WebCore { +class IntentRequest; +} + +namespace WebKit { + +class WebSerializedScriptValue; + +class InjectedBundleIntentRequest : public APIObject { +public: + static const Type APIType = TypeBundleIntentRequest; + + static PassRefPtr<InjectedBundleIntentRequest> create(WebCore::IntentRequest*); + + void postResult(WebSerializedScriptValue*); + void postFailure(WebSerializedScriptValue*); + + PassRefPtr<WebIntentData> intent() const; + +private: + explicit InjectedBundleIntentRequest(WebCore::IntentRequest*); + + virtual Type type() const { return APIType; } + + RefPtr<WebCore::IntentRequest> m_intentRequest; +}; + +} // namespace WebKit + +#endif // ENABLE(WEB_INTENTS) + +#endif // InjectedBundleIntentRequest_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.cpp new file mode 100644 index 000000000..6f264cb62 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2012 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "InjectedBundlePageDiagnosticLoggingClient.h" + +#include "WKAPICast.h" +#include "WKBundleAPICast.h" + +namespace WebKit { + +void InjectedBundlePageDiagnosticLoggingClient::logDiagnosticMessage(WebPage* page, const String& message, const String& description, const String& success) +{ + if (!m_client.logDiagnosticMessage) + return; + m_client.logDiagnosticMessage(toAPI(page), toCopiedAPI(message), toCopiedAPI(description), toCopiedAPI(success), m_client.clientInfo); +} + +} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.h new file mode 100644 index 000000000..e79e81a03 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2012 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef InjectedBundlePageDiagnosticLoggingClient_h +#define InjectedBundlePageDiagnosticLoggingClient_h + +#include "APIClient.h" +#include "WKBundlePage.h" +#include <JavaScriptCore/JSBase.h> +#include <wtf/Forward.h> + +namespace WebKit { + +class APIObject; +class InjectedBundleHitTestResult; +class WebContextMenuItemData; +class WebPage; + +class InjectedBundlePageDiagnosticLoggingClient : public APIClient<WKBundlePageDiagnosticLoggingClient, kWKBundlePageDiagnosticLoggingClientCurrentVersion> { +public: + void logDiagnosticMessage(WebPage*, const String& message, const String& description, const String& success); +}; + +} // namespace WebKit + +#endif // InjectedBundlePageDiagnosticLoggingClient_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp index 74f8efb1d..a6a06123f 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp @@ -34,7 +34,7 @@ #include <wtf/text/WTFString.h> #if ENABLE(WEB_INTENTS) -#include "WebIntentData.h" +#include "InjectedBundleIntentRequest.h" #endif #if ENABLE(WEB_INTENTS_TAG) #include "WebIntentServiceInfo.h" @@ -195,13 +195,13 @@ void InjectedBundlePageLoaderClient::didDetectXSSForFrame(WebPage* page, WebFram } #if ENABLE(WEB_INTENTS) -void InjectedBundlePageLoaderClient::didReceiveIntentForFrame(WebPage* page, WebFrame* frame, WebIntentData* intent, RefPtr<APIObject>& userData) +void InjectedBundlePageLoaderClient::didReceiveIntentForFrame(WebPage* page, WebFrame* frame, InjectedBundleIntentRequest* intentRequest, RefPtr<APIObject>& userData) { if (!m_client.didReceiveIntentForFrame) return; WKTypeRef userDataToPass = 0; - m_client.didReceiveIntentForFrame(toAPI(page), toAPI(frame), toAPI(intent), &userDataToPass, m_client.clientInfo); + m_client.didReceiveIntentForFrame(toAPI(page), toAPI(frame), toAPI(intentRequest), &userDataToPass, m_client.clientInfo); userData = adoptRef(toImpl(userDataToPass)); } #endif diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h index 403037e12..81d9be44d 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h @@ -47,7 +47,7 @@ class InjectedBundleBackForwardListItem; class WebPage; class WebFrame; #if ENABLE(WEB_INTENTS) -class WebIntentData; +class InjectedBundleIntentRequest; #endif #if ENABLE(WEB_INTENTS_TAG) class WebIntentServiceInfo; @@ -72,7 +72,7 @@ public: void didDetectXSSForFrame(WebPage*, WebFrame*, RefPtr<APIObject>& userData); #if ENABLE(WEB_INTENTS) - void didReceiveIntentForFrame(WebPage*, WebFrame*, WebIntentData*, RefPtr<APIObject>& userData); + void didReceiveIntentForFrame(WebPage*, WebFrame*, InjectedBundleIntentRequest*, RefPtr<APIObject>& userData); #endif #if ENABLE(WEB_INTENTS_TAG) void registerIntentServiceForFrame(WebPage*, WebFrame*, WebIntentServiceInfo*, RefPtr<APIObject>& userData); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/efl/InjectedBundleEfl.cpp b/Source/WebKit2/WebProcess/InjectedBundle/efl/InjectedBundleEfl.cpp index a2a61d47d..9cc8c06a7 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/efl/InjectedBundleEfl.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/efl/InjectedBundleEfl.cpp @@ -42,7 +42,7 @@ bool InjectedBundle::load(APIObject* initializationUserData) return false; } if (!eina_module_load(m_platformBundle)) { - EINA_LOG_CRIT("Error loading the injected bundle: %s", m_path.utf8().data()); + EINA_LOG_CRIT("Error loading the injected bundle from %s: %s", m_path.utf8().data(), eina_error_msg_get(eina_error_get())); eina_module_free(m_platformBundle); m_platformBundle = 0; return false; diff --git a/Source/WebKit2/WebProcess/Plugins/PluginView.cpp b/Source/WebKit2/WebProcess/Plugins/PluginView.cpp index 470c162bb..072a69c9c 100644 --- a/Source/WebKit2/WebProcess/Plugins/PluginView.cpp +++ b/Source/WebKit2/WebProcess/Plugins/PluginView.cpp @@ -1180,12 +1180,14 @@ void PluginView::scheduleWindowedPluginGeometryUpdate(const WindowGeometry& geom #if PLATFORM(MAC) void PluginView::pluginFocusOrWindowFocusChanged(bool pluginHasFocusAndWindowHasFocus) { - m_webPage->send(Messages::WebPageProxy::PluginFocusOrWindowFocusChanged(m_plugin->pluginComplexTextInputIdentifier(), pluginHasFocusAndWindowHasFocus)); + if (m_webPage) + m_webPage->send(Messages::WebPageProxy::PluginFocusOrWindowFocusChanged(m_plugin->pluginComplexTextInputIdentifier(), pluginHasFocusAndWindowHasFocus)); } void PluginView::setComplexTextInputState(PluginComplexTextInputState pluginComplexTextInputState) { - m_webPage->send(Messages::WebPageProxy::SetPluginComplexTextInputState(m_plugin->pluginComplexTextInputIdentifier(), pluginComplexTextInputState)); + if (m_webPage) + m_webPage->send(Messages::WebPageProxy::SetPluginComplexTextInputState(m_plugin->pluginComplexTextInputIdentifier(), pluginComplexTextInputState)); } mach_port_t PluginView::compositingRenderServerPort() diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp index 33370bdef..3af596626 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp @@ -440,7 +440,7 @@ void WebChromeClient::contentsSizeChanged(Frame* frame, const IntSize& size) con if (frame->page()->mainFrame() != frame) return; -#if PLATFORM(QT) +#if PLATFORM(QT) || (PLATFORM(EFL) && USE(TILED_BACKING_STORE)) if (m_page->useFixedLayout()) { // The below method updates the size(). m_page->resizeToContentsIfNeeded(); @@ -483,7 +483,7 @@ bool WebChromeClient::shouldUnavailablePluginMessageBeButton(RenderEmbeddedObjec void WebChromeClient::unavailablePluginButtonClicked(Element* element, RenderEmbeddedObject::PluginUnavailabilityReason pluginUnavailabilityReason) const { - ASSERT(element->hasTagName(objectTag) || element->hasTagName(embedTag)); + ASSERT(element->hasTagName(objectTag) || element->hasTagName(embedTag) || element->hasTagName(appletTag)); ASSERT(pluginUnavailabilityReason == RenderEmbeddedObject::PluginMissing || pluginUnavailabilityReason == RenderEmbeddedObject::InsecurePluginVersion); HTMLPlugInImageElement* pluginElement = static_cast<HTMLPlugInImageElement*>(element); @@ -635,6 +635,15 @@ void WebChromeClient::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves) m_page->send(Messages::WebPageProxy::SetCursorHiddenUntilMouseMoves(hiddenUntilMouseMoves)); } +#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER) +void WebChromeClient::scheduleAnimation() +{ +#if USE(UI_SIDE_COMPOSITING) + m_page->drawingArea()->layerTreeHost()->scheduleAnimation(); +#endif +} +#endif + void WebChromeClient::formStateDidChange(const Node*) { notImplemented(); @@ -773,4 +782,12 @@ void WebChromeClient::numWheelEventHandlersChanged(unsigned count) m_page->numWheelEventHandlersChanged(count); } +void WebChromeClient::logDiagnosticMessage(const String& message, const String& description, const String& success) +{ + if (!m_page->corePage()->settings()->diagnosticLoggingEnabled()) + return; + + m_page->injectedBundleDiagnosticLoggingClient().logDiagnosticMessage(m_page, message, description, success); +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h index 383eeac3e..f40d4b174 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h @@ -162,6 +162,9 @@ private: virtual void setCursor(const WebCore::Cursor&) OVERRIDE; virtual void setCursorHiddenUntilMouseMoves(bool) OVERRIDE; +#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER) + virtual void scheduleAnimation() OVERRIDE; +#endif // Notification that the given form element has changed. This function // will be called frequently, so handling should be very fast. @@ -219,6 +222,8 @@ private: virtual void numWheelEventHandlersChanged(unsigned) OVERRIDE; + virtual void logDiagnosticMessage(const String& message, const String& description, const String& success) OVERRIDE; + String m_cachedToolTip; mutable RefPtr<WebFrame> m_cachedFrameSetLargestFrame; mutable bool m_cachedMainFrameHasHorizontalScrollbar; diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp index 918e74acd..fbb824974 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp @@ -74,8 +74,8 @@ #include <WebCore/WindowFeatures.h> #if ENABLE(WEB_INTENTS) +#include "InjectedBundleIntentRequest.h" #include "IntentData.h" -#include "WebIntentData.h" #include <WebCore/IntentRequest.h> #endif @@ -1364,11 +1364,10 @@ void WebFrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget) PassRefPtr<Widget> WebFrameLoaderClient::createJavaAppletWidget(const IntSize& pluginSize, HTMLAppletElement* appletElement, const KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues) { - const String mimeType = "application/x-java-applet"; - RefPtr<Widget> plugin = createPlugin(pluginSize, appletElement, KURL(), paramNames, paramValues, mimeType, false); + RefPtr<Widget> plugin = createPlugin(pluginSize, appletElement, KURL(), paramNames, paramValues, appletElement->serviceType(), false); if (!plugin) { if (WebPage* webPage = m_frame->page()) - webPage->send(Messages::WebPageProxy::DidFailToInitializePlugin(mimeType)); + webPage->send(Messages::WebPageProxy::DidFailToInitializePlugin(appletElement->serviceType())); } return plugin.release(); } @@ -1562,20 +1561,11 @@ void WebFrameLoaderClient::dispatchIntent(PassRefPtr<IntentRequest> request) if (!webPage) return; - IntentData intentData; - Intent* coreIntent = request->intent(); - ASSERT(coreIntent); - intentData.action = coreIntent->action(); - intentData.type = coreIntent->type(); - intentData.service = coreIntent->service(); - intentData.data = coreIntent->data()->data(); - intentData.extras = coreIntent->extras(); - intentData.suggestions = coreIntent->suggestions(); - RefPtr<APIObject> userData; - RefPtr<WebIntentData> webIntent = WebIntentData::create(intentData); - webPage->injectedBundleLoaderClient().didReceiveIntentForFrame(webPage, m_frame, webIntent.get(), userData); + RefPtr<InjectedBundleIntentRequest> bundleIntentRequest = InjectedBundleIntentRequest::create(request.get()); + webPage->injectedBundleLoaderClient().didReceiveIntentForFrame(webPage, m_frame, bundleIntentRequest.get(), userData); + IntentData intentData(request->intent()); webPage->send(Messages::WebPageProxy::DidReceiveIntentForFrame(m_frame->frameID(), intentData, InjectedBundleUserMessageEncoder(userData.get()))); } #endif diff --git a/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp b/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp index a3b9a1391..ae3994422 100644 --- a/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp +++ b/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp @@ -356,6 +356,10 @@ void LayerTreeCoordinator::performScheduledLayerFlush() { if (m_isSuspended || m_waitingForUIProcess) return; +#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER) && !USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) + // Make sure that any previously registered animation callbacks are being executed before we flush the layers. + m_webPage->corePage()->mainFrame()->view()->serviceScriptedAnimations(convertSecondsToDOMTimeStamp(currentTime())); +#endif m_webPage->layoutIfNeeded(); @@ -544,6 +548,13 @@ void LayerTreeCoordinator::setVisibleContentsRect(const IntRect& rect, float sca m_shouldSendScrollPositionUpdate = true; } +#if USE(UI_SIDE_COMPOSITING) +void LayerTreeCoordinator::scheduleAnimation() +{ + scheduleLayerFlush(); +} +#endif + void LayerTreeCoordinator::renderNextFrame() { m_waitingForUIProcess = false; diff --git a/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.h b/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.h index 9b5154c36..7f6038005 100644 --- a/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.h +++ b/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.h @@ -86,6 +86,9 @@ public: virtual void syncFixedLayers(); virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, ShareableBitmap::Flags, ShareableSurface::Handle&, WebCore::IntPoint&); +#if USE(UI_SIDE_COMPOSITING) + virtual void scheduleAnimation() OVERRIDE; +#endif protected: explicit LayerTreeCoordinator(WebPage*); diff --git a/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/WebGraphicsLayer.cpp b/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/WebGraphicsLayer.cpp index 581491245..19ce4d031 100644 --- a/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/WebGraphicsLayer.cpp +++ b/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/WebGraphicsLayer.cpp @@ -320,6 +320,8 @@ void WebGraphicsLayer::setContentsNeedsDisplay() setContentsToImage(0); setContentsToImage(image.get()); m_canvasNeedsDisplay = true; + if (client()) + client()->notifySyncRequired(this); } void WebGraphicsLayer::setContentsToCanvas(PlatformLayer* platformLayer) diff --git a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h index 368230cc9..1372f2a29 100644 --- a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h +++ b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h @@ -105,6 +105,10 @@ public: virtual WebCore::GraphicsDeviceAdapter* graphicsDeviceAdapter() const { return 0; } #endif +#if USE(UI_SIDE_COMPOSITING) + virtual void scheduleAnimation() = 0; +#endif + protected: explicit LayerTreeHost(WebPage*); diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp index 9571ffbaa..59d3bc5cb 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp @@ -419,6 +419,11 @@ void WebPage::initializeInjectedBundleFullScreenClient(WKBundlePageFullScreenCli } #endif +void WebPage::initializeInjectedBundleDiagnosticLoggingClient(WKBundlePageDiagnosticLoggingClient* client) +{ + m_logDiagnosticMessageClient.initialize(client); +} + PassRefPtr<Plugin> WebPage::createPlugin(WebFrame* frame, HTMLPlugInElement* pluginElement, const Plugin::Parameters& parameters) { String pluginPath; @@ -2086,6 +2091,8 @@ void WebPage::updatePreferences(const WebPreferencesStore& store) settings->setShouldRespectImageOrientation(store.getBoolValueForKey(WebPreferencesKey::shouldRespectImageOrientationKey())); + settings->setDiagnosticLoggingEnabled(store.getBoolValueForKey(WebPreferencesKey::diagnosticLoggingEnabledKey())); + platformPreferencesDidChange(store); if (m_drawingArea) @@ -2145,6 +2152,10 @@ bool WebPage::handleEditingKeyboardEvent(KeyboardEvent* evt) if (command.execute(evt)) return true; + // Don't allow text insertion for nodes that cannot edit. + if (!frame->editor()->canEdit()) + return false; + // Don't insert null or control characters as they can result in unexpected behaviour if (evt->charCode() < ' ') return false; diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.h b/Source/WebKit2/WebProcess/WebPage/WebPage.h index 1b7708a4c..e3257a33a 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.h +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.h @@ -35,6 +35,7 @@ #if ENABLE(CONTEXT_MENUS) #include "InjectedBundlePageContextMenuClient.h" #endif +#include "InjectedBundlePageDiagnosticLoggingClient.h" #include "InjectedBundlePageEditorClient.h" #include "InjectedBundlePageFormClient.h" #include "InjectedBundlePageFullScreenClient.h" @@ -248,6 +249,7 @@ public: #if ENABLE(FULLSCREEN_API) void initializeInjectedBundleFullScreenClient(WKBundlePageFullScreenClient*); #endif + void initializeInjectedBundleDiagnosticLoggingClient(WKBundlePageDiagnosticLoggingClient*); #if ENABLE(CONTEXT_MENUS) InjectedBundlePageContextMenuClient& injectedBundleContextMenuClient() { return m_contextMenuClient; } @@ -258,6 +260,7 @@ public: InjectedBundlePagePolicyClient& injectedBundlePolicyClient() { return m_policyClient; } InjectedBundlePageResourceLoadClient& injectedBundleResourceLoadClient() { return m_resourceLoadClient; } InjectedBundlePageUIClient& injectedBundleUIClient() { return m_uiClient; } + InjectedBundlePageDiagnosticLoggingClient& injectedBundleDiagnosticLoggingClient() { return m_logDiagnosticMessageClient; } #if ENABLE(FULLSCREEN_API) InjectedBundlePageFullScreenClient& injectedBundleFullScreenClient() { return m_fullScreenClient; } #endif @@ -474,6 +477,10 @@ public: bool isSmartInsertDeleteEnabled() const { return m_isSmartInsertDeleteEnabled; } #endif +#if ENABLE(WEB_INTENTS) + void deliverIntentToFrame(uint64_t frameID, const IntentData&); +#endif + void replaceSelectionWithText(WebCore::Frame*, const String&); void clearSelection(); @@ -652,10 +659,6 @@ private: void runJavaScriptInMainFrame(const String&, uint64_t callbackID); void forceRepaint(uint64_t callbackID); -#if ENABLE(WEB_INTENTS) - void deliverIntentToFrame(uint64_t frameID, const IntentData&); -#endif - void preferencesDidChange(const WebPreferencesStore&); void platformPreferencesDidChange(const WebPreferencesStore&); void updatePreferences(const WebPreferencesStore&); @@ -811,6 +814,7 @@ private: #if ENABLE(FULLSCREEN_API) InjectedBundlePageFullScreenClient m_fullScreenClient; #endif + InjectedBundlePageDiagnosticLoggingClient m_logDiagnosticMessageClient; #if USE(TILED_BACKING_STORE) WebCore::IntSize m_viewportSize; diff --git a/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm b/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm index 2254152ca..4dffb6edd 100644 --- a/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm +++ b/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm @@ -144,15 +144,9 @@ bool TiledCoreAnimationDrawingArea::forceRepaintAsync(uint64_t callbackID) if (m_layerTreeStateIsFrozen) return false; - // FIXME: It is possible for the drawing area to be destroyed before the bound block - // is invoked, so grab a reference to the web page here so we can access the drawing area through it. - // (The web page is already kept alive by dispatchAfterEnsuringUpdatedScrollPosition). - // A better fix would be to make sure that we keep the drawing area alive if there are outstanding calls. - WebPage* webPage = m_webPage; dispatchAfterEnsuringUpdatedScrollPosition(bind(^{ - if (DrawingArea* drawingArea = webPage->drawingArea()) - drawingArea->forceRepaint(); - webPage->send(Messages::WebPageProxy::VoidCallback(callbackID)); + m_webPage->drawingArea()->forceRepaint(); + m_webPage->send(Messages::WebPageProxy::VoidCallback(callbackID)); })); return true; } @@ -230,13 +224,23 @@ void TiledCoreAnimationDrawingArea::dispatchAfterEnsuringUpdatedScrollPosition(c m_layerFlushScheduler.suspend(); Function<void ()> function = functionRef; + + // It is possible for the drawing area to be destroyed before the bound block + // is invoked, so grab a reference to the web page here so we can access the drawing area through it. + // (The web page is already kept alive by dispatchAfterEnsuringUpdatedScrollPosition). + WebPage* webPage = m_webPage; + ScrollingThread::dispatchBarrier(bind(^{ + DrawingArea* drawingArea = webPage->drawingArea(); + if (!drawingArea) + return; + function(); if (!m_layerTreeStateIsFrozen) m_layerFlushScheduler.resume(); - m_webPage->deref(); + webPage->deref(); })); } diff --git a/Source/WebKit2/WebProcess/mac/WebProcessMac.mm b/Source/WebKit2/WebProcess/mac/WebProcessMac.mm index 0a8c0a489..18765047b 100644 --- a/Source/WebKit2/WebProcess/mac/WebProcessMac.mm +++ b/Source/WebKit2/WebProcess/mac/WebProcessMac.mm @@ -62,6 +62,9 @@ #define SANDBOX_NAMED_EXTERNAL 0x0003 extern "C" int sandbox_init_with_parameters(const char *profile, uint64_t flags, const char *const parameters[], char **errorbuf); +// Define this to 1 to bypass the sandbox for debugging purposes. +#define DEBUG_BYPASS_SANDBOX 0 + #endif using namespace WebCore; @@ -180,10 +183,11 @@ static void appendReadwriteSandboxDirectory(Vector<const char*>& vector, const c static void initializeSandbox(const WebProcessCreationParameters& parameters) { #if ENABLE(WEB_PROCESS_SANDBOX) - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DisableSandbox"]) { - WTFLogAlways("Bypassing sandbox due to DisableSandbox user default.\n"); - return; - } + +#if DEBUG_BYPASS_SANDBOX + WTFLogAlways("Bypassing web process sandbox.\n"); + return; +#endif #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Use private temporary and cache directories. diff --git a/Source/WebKit2/win/WebKit2.def b/Source/WebKit2/win/WebKit2.def index 563758064..dea36ed90 100644 --- a/Source/WebKit2/win/WebKit2.def +++ b/Source/WebKit2/win/WebKit2.def @@ -113,6 +113,7 @@ EXPORTS ??1Mutex@WTF@@QAE@XZ ??1StringImpl@WTF@@QAE@XZ ??1ThreadCondition@WTF@@QAE@XZ + ?addTextMatchMarker@DocumentMarkerController@WebCore@@QAEXPBVRange@2@_N@Z ?broadcast@ThreadCondition@WTF@@QAEXXZ ?callOnMainThread@WTF@@YAXP6AXPAX@Z0@Z ?consoleMessageArgumentCounts@InspectorConsoleAgent@WebCore@@QAE?AV?$Vector@I$0A@@WTF@@XZ @@ -174,6 +175,7 @@ EXPORTS ?find@StringImpl@WTF@@QAEIPAV12@@Z ?absoluteCaretBounds@FrameSelection@WebCore@@QAE?AVIntRect@2@XZ ?fromUTF8WithLatin1Fallback@String@WTF@@SA?AV12@PBEI@Z + ?garbageCollectDocumentResources@CachedResourceLoader@WebCore@@QAEXXZ ?getCachedDOMStructure@WebCore@@YAPAVStructure@JSC@@PAVJSDOMGlobalObject@1@PBUClassInfo@3@@Z ?getData16SlowCase@StringImpl@WTF@@ABEPB_WXZ ?getElementById@TreeScope@WebCore@@QBEPAVElement@2@ABVAtomicString@WTF@@@Z @@ -197,6 +199,7 @@ EXPORTS ?overrideUserPreferredLanguages@WebCore@@YAXABV?$Vector@VString@WTF@@$0A@@WTF@@@Z ?numberOfScopedHTMLStyleChildren@Node@WebCore@@QBEIXZ ?page@Document@WebCore@@QBEPAVPage@2@XZ + ?pageNumberForElement@PrintContext@WebCore@@SAHPAVElement@2@ABVFloatSize@2@@Z ?paintControlTints@FrameView@WebCore@@AAEXXZ ?placeholderShouldBeVisible@HTMLTextFormControlElement@WebCore@@QBE_NXZ ?rangeFromLocationAndLength@TextIterator@WebCore@@SA?AV?$PassRefPtr@VRange@WebCore@@@WTF@@PAVContainerNode@2@HH_N@Z @@ -273,4 +276,4 @@ EXPORTS ?jsStringSlowCase@WebCore@@YA?AVJSValue@JSC@@PAVExecState@3@AAV?$HashMap@PAVStringImpl@WTF@@V?$Weak@VJSString@JSC@@@JSC@@U?$PtrHash@PAVStringImpl@WTF@@@2@U?$HashTraits@PAVStringImpl@WTF@@@2@U?$HashTraits@V?$Weak@VJSString@JSC@@@JSC@@@2@@WTF@@PAVStringImpl@6@@Z ?registerURLSchemeAsBypassingContentSecurityPolicy@SchemeRegistry@WebCore@@SAXABVString@WTF@@@Z ?removeURLSchemeRegisteredAsBypassingContentSecurityPolicy@SchemeRegistry@WebCore@@SAXABVString@WTF@@@Z - ?iconURLs@Document@WebCore@@QAEABV?$Vector@UIconURL@WebCore@@$0A@@WTF@@XZ
\ No newline at end of file + ?iconURLs@Document@WebCore@@QAEABV?$Vector@UIconURL@WebCore@@$0A@@WTF@@XZ diff --git a/Source/WebKit2/win/WebKit2.vcproj b/Source/WebKit2/win/WebKit2.vcproj index 0a38c4b82..a362b046d 100755 --- a/Source/WebKit2/win/WebKit2.vcproj +++ b/Source/WebKit2/win/WebKit2.vcproj @@ -2394,6 +2394,14 @@ > </File> <File + RelativePath="..\WebProcess\InjectedBundle\InjectedBundlePageDiagnosticLoggingClient.cpp" + > + </File> + <File + RelativePath="..\WebProcess\InjectedBundle\InjectedBundlePageDiagnosticLoggingClient.h" + > + </File> + <File RelativePath="..\WebProcess\InjectedBundle\InjectedBundlePageEditorClient.cpp" > </File> diff --git a/Source/WebKit2/win/WebKit2CFLite.def b/Source/WebKit2/win/WebKit2CFLite.def index 0e5d1b2c7..1a47d2f3a 100644 --- a/Source/WebKit2/win/WebKit2CFLite.def +++ b/Source/WebKit2/win/WebKit2CFLite.def @@ -106,6 +106,7 @@ EXPORTS ??1Mutex@WTF@@QAE@XZ ??1StringImpl@WTF@@QAE@XZ ??1ThreadCondition@WTF@@QAE@XZ + ?addTextMatchMarker@DocumentMarkerController@WebCore@@QAEXPBVRange@2@_N@Z ?broadcast@ThreadCondition@WTF@@QAEXXZ ?callOnMainThread@WTF@@YAXP6AXPAX@Z0@Z ?consoleMessageArgumentCounts@InspectorConsoleAgent@WebCore@@QAE?AV?$Vector@I$0A@@WTF@@XZ @@ -117,6 +118,7 @@ EXPORTS ?detachThread@WTF@@YAXI@Z ?didBeginFrameImpl@InspectorInstrumentation@WebCore@@CAXPAVInstrumentingAgents@2@@Z ?didCancelFrameImpl@InspectorInstrumentation@WebCore@@CAXPAVInstrumentingAgents@2@@Z + ?iconURLs@Document@WebCore@@QAEABV?$Vector@UIconURL@WebCore@@$0A@@WTF@@XZ ?initializeMainThread@WTF@@YAXXZ ?initializeThreading@WTF@@YAXXZ ?instrumentationForPage@WebCore@@YAPAVInstrumentingAgents@1@PAVPage@1@@Z @@ -170,6 +172,7 @@ EXPORTS ?find@StringImpl@WTF@@QAEIPAV12@@Z ?absoluteCaretBounds@FrameSelection@WebCore@@QAE?AVIntRect@2@XZ ?fromUTF8WithLatin1Fallback@String@WTF@@SA?AV12@PBEI@Z + ?garbageCollectDocumentResources@CachedResourceLoader@WebCore@@QAEXXZ ?getCachedDOMStructure@WebCore@@YAPAVStructure@JSC@@PAVJSDOMGlobalObject@1@PBUClassInfo@3@@Z ?getData16SlowCase@StringImpl@WTF@@ABEPB_WXZ ?getElementById@TreeScope@WebCore@@QBEPAVElement@2@ABVAtomicString@WTF@@@Z @@ -193,6 +196,7 @@ EXPORTS ?overrideUserPreferredLanguages@WebCore@@YAXABV?$Vector@VString@WTF@@$0A@@WTF@@@Z ?numberOfScopedHTMLStyleChildren@Node@WebCore@@QBEIXZ ?page@Document@WebCore@@QBEPAVPage@2@XZ + ?pageNumberForElement@PrintContext@WebCore@@SAHPAVElement@2@ABVFloatSize@2@@Z ?paintControlTints@FrameView@WebCore@@AAEXXZ ?placeholderShouldBeVisible@HTMLTextFormControlElement@WebCore@@QBE_NXZ ?rangeFromLocationAndLength@TextIterator@WebCore@@SA?AV?$PassRefPtr@VRange@WebCore@@@WTF@@PAVContainerNode@2@HH_N@Z |
