Implement Focus UI
[framework/web/webkit-efl.git] / Source / WebKit2 / UIProcess / efl / WebPageProxyEfl.cpp
index 138695f..3d7b14d 100755 (executable)
@@ -79,7 +79,7 @@ Evas_Object* WebPageProxy::viewWidget()
 String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent)
 {
 #if OS(TIZEN)
-    return String::fromUTF8("Mozilla/5.0 (Linux; U; Tizen 2.0; en-us) AppleWebKit/537.1 (KHTML, like Gecko) Mobile TizenBrowser/2.0");
+    return String::fromUTF8("Mozilla/5.0 (Linux; Tizen 2.2; sdk) AppleWebKit/537.3 (KHTML, like Gecko) Version/2.2 Mobile Safari/537.3");
 #endif
 
     WTF::String platform;
@@ -238,15 +238,12 @@ void WebPageProxy::textChangeInTextField(const String& name, const String& value
 #endif
 
 #if ENABLE(TIZEN_ISF_PORT)
-void WebPageProxy::setInputMethodState(bool active)
+void WebPageProxy::prepareKeyDownEvent()
 {
-    InputMethodContextEfl* inputMethodContext = static_cast<PageClientImpl*>(m_pageClient)->viewImpl()->inputMethodContext();
-    if (!active)
+    if (!isValid())
         return;
 
-    inputMethodContext->setTryToShow(true);
-    inputMethodContext->updateTextInputState();
-    inputMethodContext->setTryToShow(false);
+    process()->send(Messages::WebPage::PrepareKeyDownEvent(), m_pageID);
 }
 
 int WebPageProxy::getCursorOffset()
@@ -290,7 +287,16 @@ void WebPageProxy::didCancelComposition()
         inputMethodContext->resetIMFContext();
     m_didCancelCompositionFromWebProcess = false;
 }
-#endif
+
+void WebPageProxy::removeInputMethodContext(uintptr_t id)
+{
+    InputMethodContextEfl* inputMethodContext = static_cast<PageClientImpl*>(m_pageClient)->viewImpl()->inputMethodContext();
+    if (!inputMethodContext)
+        return;
+
+    inputMethodContext->removeIMFContext(id);
+}
+#endif // #if ENABLE(TIZEN_ISF_PORT)
 
 void WebPageProxy::requestUpdateFormNavigation()
 {
@@ -404,26 +410,25 @@ void WebPageProxy::initializeTizenClient(const WKPageTizenClient* client)
 }
 
 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
+#if ENABLE(TOUCH_ADJUSTMENT)
+WebHitTestResult::Data WebPageProxy::hitTestResultAtPoint(const IntPoint& point, int hitTestMode, const IntSize& area)
+#else
 WebHitTestResult::Data WebPageProxy::hitTestResultAtPoint(const IntPoint& point, int hitTestMode)
+#endif
 {
     WebHitTestResult::Data hitTestResultData;
     if (!isValid())
         return hitTestResultData;
 
+#if ENABLE(TOUCH_ADJUSTMENT)
+    process()->sendSync(Messages::WebPage::HitTestResultAtPoint(point, hitTestMode, area),
+                        Messages::WebPage::HitTestResultAtPoint::Reply(hitTestResultData), m_pageID);
+#else
     process()->sendSync(Messages::WebPage::HitTestResultAtPoint(point, hitTestMode),
                         Messages::WebPage::HitTestResultAtPoint::Reply(hitTestResultData), m_pageID);
-
-    return hitTestResultData;
-}
 #endif
 
-#if ENABLE(TIZEN_RECORDING_SURFACE_SET)
-void WebPageProxy::recordingSurfaceSetEnableSet(bool enable)
-{
-    if (!isValid())
-        return;
-
-    process()->send(Messages::WebPage::RecordingSurfaceSetEnableSet(enable), m_pageID, 0);
+    return hitTestResultData;
 }
 #endif
 
@@ -500,7 +505,7 @@ void WebPageProxy::clipboardContextMenuSelected()
 }
 #endif
 
-#if ENABLE(TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR)
+#if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
 uint32_t WebPageProxy::startInspectorServer(uint32_t port)
 {
     if (!isValid())
@@ -611,16 +616,6 @@ void WebPageProxy::suspendPainting()
     process()->send(Messages::DrawingArea::SuspendPainting(), m_pageID);
 }
 
-#if ENABLE(TIZEN_WEBKIT2_TILED_AC)
-void WebPageProxy::suspendPaintingOfInactiveView()
-{
-    if (!isValid() || isViewVisible())
-        return;
-
-    process()->send(Messages::DrawingArea::SuspendPainting(), m_pageID);
-}
-#endif
-
 void WebPageProxy::resumePainting()
 {
     if (!isValid())
@@ -645,6 +640,22 @@ void WebPageProxy::resumeJavaScriptAndResource()
     process()->send(Messages::WebPage::ResumeJavaScriptAndResources(), m_pageID);
 }
 
+void WebPageProxy::suspendAnimations()
+{
+    if (!isValid())
+        return;
+
+    process()->send(Messages::WebPage::SuspendAnimations(), m_pageID);
+}
+
+void WebPageProxy::resumeAnimations()
+{
+    if (!isValid())
+        return;
+
+    process()->send(Messages::WebPage::ResumeAnimations(), m_pageID);
+}
+
 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
 void WebPageProxy::suspendPlugin()
 {
@@ -663,6 +674,16 @@ void WebPageProxy::resumePlugin()
 }
 #endif
 
+#if ENABLE(TIZEN_WEBKIT2_TILED_AC)
+void WebPageProxy::purgeBackingStoresOfInactiveView()
+{
+    if (!isValid() || isViewVisible())
+        return;
+
+    process()->send(Messages::LayerTreeCoordinator::PurgeBackingStores(), m_pageID);
+}
+#endif
+
 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
 bool WebPageProxy::scrollOverflow(const FloatPoint& offset)
 {
@@ -718,6 +739,9 @@ void WebPageProxy::replyJavaScriptAlert()
 
     m_alertReply->send();
     m_alertReply = nullptr;
+#if ENABLE(TIZEN_WEBKIT2_NOTIFY_POPUP_REPLY_STATUS)
+    m_uiClient.notifyPopupReplyWaitingState(this, false);
+#endif
 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
     process()->connection()->setForcelySetAllAsyncMessagesToDispatchEvenWhenWaitingForSyncReply(false);
 #endif
@@ -730,6 +754,9 @@ void WebPageProxy::replyJavaScriptConfirm(bool result)
 
     m_confirmReply->send(result);
     m_confirmReply = nullptr;
+#if ENABLE(TIZEN_WEBKIT2_NOTIFY_POPUP_REPLY_STATUS)
+    m_uiClient.notifyPopupReplyWaitingState(this, false);
+#endif
 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
     process()->connection()->setForcelySetAllAsyncMessagesToDispatchEvenWhenWaitingForSyncReply(false);
 #endif
@@ -742,6 +769,9 @@ void WebPageProxy::replyJavaScriptPrompt(const String& result)
 
     m_promptReply->send(result);
     m_promptReply = nullptr;
+#if ENABLE(TIZEN_WEBKIT2_NOTIFY_POPUP_REPLY_STATUS)
+    m_uiClient.notifyPopupReplyWaitingState(this, false);
+#endif
 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
     process()->connection()->setForcelySetAllAsyncMessagesToDispatchEvenWhenWaitingForSyncReply(false);
 #endif
@@ -761,6 +791,17 @@ void WebPageProxy::replyBeforeUnloadConfirmPanel(bool result)
 }
 #endif
 
+#if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED)
+void WebPageProxy::replyReceiveAuthenticationChallengeInFrame(bool result)
+{
+    if (!m_AuthReply)
+        return;
+
+    m_AuthReply->send(result);
+    m_AuthReply = nullptr;
+}
+#endif
+
 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
 void WebPageProxy::replyPolicyForCertificateError(bool result)
 {
@@ -801,18 +842,6 @@ bool WebPageProxy::makeContextCurrent()
 }
 #endif
 
-#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
-void WebPageProxy::getTextStyleStateForSelection()
-{
-    process()->send(Messages::WebPage::GetTextStyleStateForSelection(), m_pageID, 0);
-}
-
-void WebPageProxy::didGetTextStyleStateForSelection(int underlineState, int italicState, int boldState)
-{
-    static_cast<PageClientImpl*>(m_pageClient)->didGetTextStyleStateForSelection(underlineState, italicState, boldState);
-}
-#endif
-
 #if ENABLE(TIZEN_ICON_DATABASE)
 void WebPageProxy::didReceiveIcon()
 {
@@ -855,33 +884,33 @@ void WebPageProxy::startOfflinePageSave(String subresourceFolderName)
 #endif
 
 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
-bool WebPageProxy::selectClosestWord(const IntPoint& point, bool isStartedTextSelectionFromOutside)
+bool WebPageProxy::selectClosestWord(const IntPoint& point)
 {
     if (!isValid())
         return false;
 
     bool result = false;
-    process()->sendSync(Messages::WebPage::SelectClosestWord(point, isStartedTextSelectionFromOutside), Messages::WebPage::SelectClosestWord::Reply(result), m_pageID);
+    process()->sendSync(Messages::WebPage::SelectClosestWord(point), Messages::WebPage::SelectClosestWord::Reply(result), m_pageID);
     return result;
 }
 
-bool WebPageProxy::setLeftSelection(const IntPoint& point)
+int WebPageProxy::setLeftSelection(const IntPoint& point, const int direction)
 {
     if (!isValid())
-        return false;
+        return 0;
 
-    bool result = false;
-    process()->sendSync(Messages::WebPage::SetLeftSelection(point), Messages::WebPage::SetLeftSelection::Reply(result), m_pageID);
+    int result = 0;
+    process()->sendSync(Messages::WebPage::SetLeftSelection(point, direction), Messages::WebPage::SetLeftSelection::Reply(result), m_pageID);
     return result;
 }
 
-bool WebPageProxy::setRightSelection(const IntPoint& point)
+int WebPageProxy::setRightSelection(const IntPoint& point, const int direction)
 {
     if (!isValid())
-        return false;
+        return 0;
 
-    bool result;
-    process()->sendSync(Messages::WebPage::SetRightSelection(point), Messages::WebPage::SetRightSelection::Reply(result), m_pageID);
+    int result = 0;
+    process()->sendSync(Messages::WebPage::SetRightSelection(point, direction), Messages::WebPage::SetRightSelection::Reply(result), m_pageID);
     return result;
 }
 
@@ -927,6 +956,16 @@ bool WebPageProxy::scrollContentByCharacter(const IntPoint& point, SelectionDire
     process()->sendSync(Messages::WebPage::ScrollContentByCharacter(point, direction), Messages::WebPage::ScrollContentByCharacter::Reply(result), m_pageID);
     return result;
 }
+
+bool WebPageProxy::scrollContentByLine(const IntPoint& point, SelectionDirection direction)
+{
+    if (!isValid())
+        return false;
+
+    bool result = false;
+    process()->sendSync(Messages::WebPage::ScrollContentByLine(point, direction), Messages::WebPage::ScrollContentByLine::Reply(result), m_pageID);
+    return result;
+}
 #endif
 
 #if ENABLE(TIZEN_LINK_MAGNIFIER)
@@ -946,7 +985,7 @@ void WebPageProxy::didGetLinkMagnifierRect(const IntPoint& position, const IntRe
 void WebPageProxy::openLink(const IntPoint& position)
 {
 #if ENABLE(GESTURE_EVENTS)
-    IntPoint globalPosition(EwkViewImpl::fromEvasObject(viewWidget())->transformToScreen().mapPoint(position));
+    IntPoint globalPosition(static_cast<PageClientImpl*>(m_pageClient)->viewImpl()->transformToScreen().mapPoint(position));
     WebGestureEvent gesture(WebEvent::GestureSingleTap, position, globalPosition, WebEvent::Modifiers(0), ecore_time_get());
     handleGestureEvent(gesture);
 #endif
@@ -954,16 +993,6 @@ void WebPageProxy::openLink(const IntPoint& position)
 #endif
 
 #if ENABLE(TIZEN_SCREEN_READER)
-void WebPageProxy::raiseTapEvent(const IntPoint& position)
-{
-#if ENABLE(GESTURE_EVENTS)
-    IntPoint globalPosition = EwkViewImpl::fromEvasObject(viewWidget())->transformToScreen().mapPoint(position);
-    process()->send(Messages::WebPage::RaiseTapEvent(position, globalPosition), m_pageID);
-#else
-    UNUSED_PARAM(position);
-#endif
-}
-
 bool WebPageProxy::moveScreenReaderFocus(bool forward)
 {
     bool result;
@@ -976,9 +1005,28 @@ void WebPageProxy::moveScreenReaderFocusByPoint(const IntPoint& point)
     process()->send(Messages::WebPage::MoveScreenReaderFocusByPoint(point), m_pageID);
 }
 
+void WebPageProxy::clearScreenReaderFocus()
+{
+    process()->send(Messages::WebPage::ClearScreenReaderFocus(), m_pageID);
+}
+
+bool WebPageProxy::raiseTapEvent(const IntPoint& position)
+{
+    IntPoint globalPosition = static_cast<PageClientImpl*>(m_pageClient)->viewImpl()->transformToScreen().mapPoint(position);
+    bool result;
+    process()->sendSync(Messages::WebPage::RaiseTapEvent(position, globalPosition), Messages::WebPage::RaiseTapEvent::Reply(result), m_pageID);
+
+    return result;
+}
+
+void WebPageProxy::adjustScreenReaderFocusedObjectValue(bool up)
+{
+    process()->send(Messages::WebPage::AdjustScreenReaderFocusedObjectValue(up), m_pageID);
+}
+
 void WebPageProxy::recalcScreenReaderFocusRect()
 {
-    if (!ScreenReaderProxy::screenReader().isEnabled())
+    if (!ScreenReaderProxy::screenReader().isActive(static_cast<PageClientImpl*>(m_pageClient)->viewImpl()))
         return;
 
     process()->send(Messages::WebPage::RecalcScreenReaderFocusRect(), m_pageID);
@@ -989,7 +1037,14 @@ void WebPageProxy::clearScreenReader()
     process()->send(Messages::WebPage::ClearScreenReader(), m_pageID);
 }
 
-void WebPageProxy::didScreenReaderFocusRectChanged(const IntRect& rect)
+void WebPageProxy::didScreenReaderTextChanged(const String& text)
+{
+    ScreenReaderProxy::screenReader().setText(text);
+}
+#endif
+
+#if ENABLE(TIZEN_SCREEN_READER) || ENABLE(TIZEN_FOCUS_UI)
+void WebPageProxy::didChangeFocusedRect(const IntRect& rect)
 {
 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
     FocusRing* focusRing = ewkViewGetFocusRing(viewWidget());
@@ -1003,11 +1058,7 @@ void WebPageProxy::didScreenReaderFocusRectChanged(const IntRect& rect)
 #else
     UNUSED_PARAM(rect);
 #endif
-}
 
-void WebPageProxy::didScreenReaderTextChanged(const String& text)
-{
-    ScreenReaderProxy::screenReader().setText(text);
 }
 #endif
 
@@ -1083,6 +1134,54 @@ void WebPageProxy::replyExceededIndexedDatabaseQuota(bool allow)
 }
 #endif
 
+#if ENABLE(TIZEN_SQL_DATABASE)
+void WebPageProxy::replyExceededDatabaseQuota(bool allow)
+{
+    if (!m_exceededDatabaseQuotaReply) {
+        TIZEN_LOGE("m_exceededDatabaseQuotaReply does not exist");
+        return;
+    }
+
+    m_exceededDatabaseQuotaReply->send(allow);
+    m_exceededDatabaseQuotaReply = nullptr;
+#if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
+    process()->connection()->setForcelySetAllAsyncMessagesToDispatchEvenWhenWaitingForSyncReply(false);
+#endif
+}
+#endif
+
+#if ENABLE(TIZEN_FILE_SYSTEM)
+void WebPageProxy::exceededLocalFileSystemQuota(uint64_t frameID, const String& originIdentifier, int64_t currentUsage, PassRefPtr<Messages::WebPageProxy::ExceededLocalFileSystemQuota::DelayedReply> reply)
+{
+    WebFrameProxy* frame = process()->webFrame(frameID);
+    MESSAGE_CHECK(frame);
+
+    // Since exceededLocalFileSystemQuota() can spin a nested run loop we need to turn off the responsiveness timer.
+    process()->responsivenessTimer()->stop();
+    m_exceededLocalFileSystemQuotaReply = reply;
+#if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
+    process()->connection()->setForcelySetAllAsyncMessagesToDispatchEvenWhenWaitingForSyncReply(true);
+#endif
+
+    RefPtr<WebSecurityOrigin> origin = WebSecurityOrigin::createFromDatabaseIdentifier(originIdentifier);
+
+    if (!m_tizenClient.exceededLocalFileSystemQuota(this, origin.get(), currentUsage, frame))
+        replyExceededLocalFileSystemQuota(false);
+}
+
+void WebPageProxy::replyExceededLocalFileSystemQuota(bool allow)
+{
+    if (!m_exceededLocalFileSystemQuotaReply)
+        return;
+
+    m_exceededLocalFileSystemQuotaReply->send(allow);
+    m_exceededLocalFileSystemQuotaReply = nullptr;
+#if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
+    process()->connection()->setForcelySetAllAsyncMessagesToDispatchEvenWhenWaitingForSyncReply(false);
+#endif
+}
+#endif
+
 #endif // #if OS(TIZEN)
 
 void WebPageProxy::handleInputMethodKeydown(bool& handled)
@@ -1131,4 +1230,34 @@ void WebPageProxy::cancelComposition()
     process()->send(Messages::WebPage::CancelComposition(), m_pageID, 0);
 }
 
+#if ENABLE(TIZEN_USE_SETTINGS_FONT)
+void WebPageProxy::useSettingsFont()
+{
+    process()->send(Messages::WebPage::UseSettingsFont(), m_pageID, 0);
+}
+#endif
+
+#if ENABLE(TIZEN_WEBKIT2_NOTIFY_SUSPEND_BY_REMOTE_WEB_INSPECTOR)
+void WebPageProxy::setContentSuspendedByInspector(bool isSuspended)
+{
+    m_contentSuspendedByInspector = isSuspended;
+}
+#endif
+
+#if ENABLE(TIZEN_FOCUS_UI)
+void WebPageProxy::setSpatialNavigationEnabled(bool enabled)
+{
+    if (m_spatialNavigationEnabled == enabled)
+        return;
+
+    m_spatialNavigationEnabled = enabled;
+
+    if (enabled)
+        static_cast<PageClientImpl*>(m_pageClient)->viewImpl()->focusRing->setImage(FOCUS_UI_FOCUS_RING_IMAGE_PATH, 4, 2);
+    else
+        static_cast<PageClientImpl*>(m_pageClient)->viewImpl()->focusRing->setImage(String(), 0, 0);
+
+    process()->send(Messages::WebPage::SetSpatialNavigationEnabled(enabled), m_pageID);
+}
+#endif
 } // namespace WebKit