Fixed sometimes foucs ring disappear late and is not shown.
[framework/web/webkit-efl.git] / Source / WebKit2 / UIProcess / WebPageProxy.cpp
index 44d5a3d..cf2c174 100755 (executable)
 #include "ArgumentCodersGtk.h"
 #endif
 
+#if USE(SOUP)
+#include "WebSoupRequestManagerProxy.h"
+#endif
+
 #if ENABLE(TIZEN_DRAG_SUPPORT)
 #include "ArgumentCodersTizen.h"
 #endif
 #endif
 
 #if ENABLE(TIZEN_ISF_PORT) || ENABLE(TIZEN_GESTURE)
-#include "ewk_view_private.h"
+#include "EwkViewImpl.h"
+#include "InputMethodContextEfl.h"
+#endif
+
+#if ENABLE(TIZEN_VIEWPORT_META_TAG)
+#include <WebCore/EflScreenUtilities.h>
 #endif
 
 // This controls what strategy we use for mouse wheel coalescing.
@@ -185,7 +194,7 @@ WebPageProxy::WebPageProxy(PageClient* pageClient, PassRefPtr<WebProcessProxy> p
     , m_textZoomFactor(1)
     , m_pageZoomFactor(1)
     , m_pageScaleFactor(1)
-    , m_intrinsicDeviceScaleFactor(1)
+    , m_intrinsicDeviceScaleFactor(getMobileDPI() / 160)
     , m_customDeviceScaleFactor(0)
 #if HAVE(LAYER_HOSTING_IN_WINDOW_SERVER)
     , m_layerHostingMode(LayerHostingModeInWindowServer)
@@ -248,6 +257,9 @@ WebPageProxy::WebPageProxy(PageClient* pageClient, PassRefPtr<WebProcessProxy> p
 #if ENABLE(TIZEN_ISF_PORT)
     , m_didCancelCompositionFromWebProcess(false)
 #endif
+#if ENABLE(TIZEN_WEBKIT2_NOTIFY_SUSPEND_BY_REMOTE_WEB_INSPECTOR)
+    , m_contentSuspendedByInspector(false)
+#endif
 {
 #ifndef NDEBUG
     webPageProxyCounter.increment();
@@ -608,6 +620,12 @@ void WebPageProxy::loadContentsbyMimeType(const WebData* contents, const String&
         reattachToWebProcess();
 
     process()->assumeReadAccessToBaseURL(baseURL);
+#if ENABLE(TIZEN_UNIVERSAL_FILE_READ_ACCESS)
+    SandboxExtension::Handle sandboxExtensionHandleEmail;
+    bool createdExtension = maybeInitializeSandboxExtensionHandle(KURL(KURL(), baseURL), sandboxExtensionHandleEmail);
+    if (createdExtension)
+        process()->willAcquireUniversalFileReadSandboxExtension();
+#endif
     process()->send(Messages::WebPage::LoadContentsbyMimeType(contents->dataReference(), mimeType, encoding, baseURL), m_pageID);
     process()->responsivenessTimer()->start();
 }
@@ -1241,9 +1259,22 @@ void WebPageProxy::handleGestureEvent(const WebGestureEvent& event)
     if (!isValid())
         return;
 
+#if ENABLE(TIZEN_ISF_PORT) || ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
+    if (event.type() == WebEvent::GestureSingleTap) {
+#if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
+        FocusRing* focusRing = ewkViewGetFocusRing(viewWidget());
+        if (focusRing) {
+            IntPoint tapPosition = EwkViewImpl::fromEvasObject(viewWidget())->transformToScene().mapPoint(event.position());
+            focusRing->requestToShow(tapPosition, true);
+        }
+#endif
+
 #if ENABLE(TIZEN_ISF_PORT)
-    if (event.type() == WebEvent::GestureSingleTap)
-        ewk_view_imf_context_reset(viewWidget());
+        InputMethodContextEfl* inputMethodContext = static_cast<PageClientImpl*>(m_pageClient)->viewImpl()->inputMethodContext();
+        if (inputMethodContext)
+            inputMethodContext->resetIMFContext();
+#endif
+    }
 #endif
 
 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
@@ -1280,7 +1311,11 @@ void WebPageProxy::handlePotentialActivation(const IntPoint& touchPoint, const I
 
 void WebPageProxy::handleTouchEvent(const NativeWebTouchEvent& event)
 {
+#if ENABLE(TIZEN_WEBKIT2_NOTIFY_SUSPEND_BY_REMOTE_WEB_INSPECTOR)
+    if (!isValid() || isContentSuspendedByInspector())
+#else
     if (!isValid())
+#endif
         return;
 
     // If the page is suspended, which should be the case during panning, pinching
@@ -2639,6 +2674,9 @@ void WebPageProxy::runJavaScriptAlert(uint64_t frameID, const String& message, P
     process()->responsivenessTimer()->stop();
 
     m_alertReply = reply;
+#if ENABLE(TIZEN_WEBKIT2_NOTIFY_POPUP_REPLY_STATUS)
+    m_uiClient.notifyPopupReplyWaitingState(this, true);
+#endif
 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
     process()->connection()->setForcelySetAllAsyncMessagesToDispatchEvenWhenWaitingForSyncReply(true);
 #endif
@@ -2655,6 +2693,9 @@ void WebPageProxy::runJavaScriptConfirm(uint64_t frameID, const String& message,
     process()->responsivenessTimer()->stop();
 
     m_confirmReply = reply;
+#if ENABLE(TIZEN_WEBKIT2_NOTIFY_POPUP_REPLY_STATUS)
+    m_uiClient.notifyPopupReplyWaitingState(this, true);
+#endif
 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
     process()->connection()->setForcelySetAllAsyncMessagesToDispatchEvenWhenWaitingForSyncReply(true);
 #endif
@@ -2671,6 +2712,9 @@ void WebPageProxy::runJavaScriptPrompt(uint64_t frameID, const String& message,
     process()->responsivenessTimer()->stop();
 
     m_promptReply = reply;
+#if ENABLE(TIZEN_WEBKIT2_NOTIFY_POPUP_REPLY_STATUS)
+    m_uiClient.notifyPopupReplyWaitingState(this, true);
+#endif
 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
     process()->connection()->setForcelySetAllAsyncMessagesToDispatchEvenWhenWaitingForSyncReply(true);
 #endif
@@ -3256,7 +3300,7 @@ void WebPageProxy::editorStateChanged(const EditorState& editorState)
 
 #if PLATFORM(MAC)
     m_pageClient->updateTextInputState(couldChangeSecureInputState);
-#elif PLATFORM(QT) || ENABLE(TIZEN_ISF_PORT)
+#elif PLATFORM(QT) || PLATFORM(EFL)
     m_pageClient->updateTextInputState();
 #endif
 }
@@ -3444,11 +3488,6 @@ void WebPageProxy::contextMenuItemSelected(const WebContextMenuItemData& item)
         return;
     }
 
-#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
-    if (item.action() == ContextMenuItemTagPaste)
-        m_pageClient->setIsTextSelectionMode(false);
-#endif
-
 #if PLATFORM(MAC)
     if (item.action() == ContextMenuItemTagSmartCopyPaste) {
         setSmartInsertDeleteEnabled(!isSmartInsertDeleteEnabled());
@@ -3778,6 +3817,23 @@ void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)
         m_gestureEventQueue.removeFirst();
         m_pageClient->doneWithGestureEvent(event, handled);
 #endif
+#if ENABLE(TIZEN_ISF_PORT)
+        if (m_isVisible && type == WebEvent::GestureSingleTap && m_editorState.isContentEditable) {
+#if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
+            if (m_editorState.inputMethodHints == "date"
+                || m_editorState.inputMethodHints == "datetime"
+                || m_editorState.inputMethodHints == "datetime-local"
+                || m_editorState.inputMethodHints == "month"
+                || m_editorState.inputMethodHints == "time"
+                || m_editorState.inputMethodHints == "week") {
+                InputMethodContextEfl* inputMethodContext = static_cast<PageClientImpl*>(m_pageClient)->viewImpl()->inputMethodContext();
+                if (inputMethodContext->inputPickerType() == -1)
+                    break;
+            }
+#endif
+            evas_object_focus_set(viewWidget(), true);
+        }
+#endif
         break;
     }
 #endif
@@ -3807,20 +3863,11 @@ void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)
 
 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
         QueuedUIEvents<NativeWebKeyboardEvent> queuedEvents = m_keyEventQueue.first();
-        MESSAGE_CHECK(type == queuedEvents.forwardedEvent.type());
+        NativeWebKeyboardEvent event = queuedEvents.forwardedEvent;
+        MESSAGE_CHECK(type == event.type());
         m_keyEventQueue.removeFirst();
 
-        m_pageClient->doneWithKeyEvent(queuedEvents.forwardedEvent, handled);
-
-        if (!handled) {
-            if (m_uiClient.implementsDidNotHandleKeyEvent())
-                m_uiClient.didNotHandleKeyEvent(this, queuedEvents.forwardedEvent);
-#if PLATFORM(WIN)
-            else
-                ::TranslateMessage(queuedEvents.forwardedEvent.nativeEvent());
-#endif
-        }
-
+        m_pageClient->doneWithKeyEvent(event, handled);
         for (size_t i = 0; i < queuedEvents.deferredEvents.size(); ++i) {
             bool isEventHandled = false;
             m_pageClient->doneWithKeyEvent(queuedEvents.deferredEvents.at(i), isEventHandled);
@@ -3835,16 +3882,23 @@ void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)
             process()->send(Messages::WebPage::KeyEvent(m_keyEventQueue.first()), m_pageID);
 
         m_pageClient->doneWithKeyEvent(event, handled);
+#endif // #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
+
         if (handled)
             break;
 
+#if ENABLE(TIZEN_ISF_PORT)
+        InputMethodContextEfl* inputMethodContext = static_cast<PageClientImpl*>(m_pageClient)->viewImpl()->inputMethodContext();
+        if (event.type() == WebEvent::KeyDown && event.keyIdentifier() == "Enter" && inputMethodContext && inputMethodContext->autoCapitalType() == ECORE_IMF_AUTOCAPITAL_TYPE_NONE)
+            inputMethodContext->hideIMFContext();
+#endif
+
         if (m_uiClient.implementsDidNotHandleKeyEvent())
             m_uiClient.didNotHandleKeyEvent(this, event);
 #if PLATFORM(WIN)
         else
             ::TranslateMessage(event.nativeEvent());
 #endif
-#endif // #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
         break;
     }
 #if ENABLE(TOUCH_EVENTS)
@@ -4226,20 +4280,47 @@ void WebPageProxy::canAuthenticateAgainstProtectionSpaceInFrame(uint64_t frameID
     canAuthenticate = m_loaderClient.canAuthenticateAgainstProtectionSpaceInFrame(this, frame, protectionSpace.get());
 }
 
+#if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED)
+void WebPageProxy::didReceiveAuthenticationChallenge(uint64_t frameID, const AuthenticationChallenge& coreChallenge, uint64_t challengeID, PassRefPtr<Messages::WebPageProxy::DidReceiveAuthenticationChallenge::DelayedReply> reply)
+#else
 void WebPageProxy::didReceiveAuthenticationChallenge(uint64_t frameID, const AuthenticationChallenge& coreChallenge, uint64_t challengeID)
+#endif
 {
     WebFrameProxy* frame = process()->webFrame(frameID);
     MESSAGE_CHECK(frame);
 
 #if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED)
     RefPtr<AuthenticationChallengeProxy> authenticationChallenge = frame->setUpAuthenticationChallengeProxy(coreChallenge, challengeID, process());
+    m_AuthReply = reply;
+
+    if (!m_loaderClient.didReceiveAuthenticationChallengeInFrame(this, frame, authenticationChallenge.get()))
+        replyReceiveAuthenticationChallengeInFrame(true);
 #else
     RefPtr<AuthenticationChallengeProxy> authenticationChallenge = AuthenticationChallengeProxy::create(coreChallenge, challengeID, process());
-#endif
 
     m_loaderClient.didReceiveAuthenticationChallengeInFrame(this, frame, authenticationChallenge.get());
+#endif
 }
 
+#if ENABLE(TIZEN_SQL_DATABASE)
+void WebPageProxy::exceededDatabaseQuota(uint64_t frameID, const String& originIdentifier, const String& displayName, uint64_t expectedUsage, PassRefPtr<Messages::WebPageProxy::ExceededDatabaseQuota::DelayedReply> allowExceed)
+{
+    WebFrameProxy* frame = process()->webFrame(frameID);
+    MESSAGE_CHECK(frame);
+
+    // Since exceededDatabaseQuota() can spin a nested run loop we need to turn off the responsiveness timer.
+    process()->responsivenessTimer()->stop();
+
+    m_exceededDatabaseQuotaReply = allowExceed;
+    RefPtr<WebSecurityOrigin> origin = WebSecurityOrigin::createFromDatabaseIdentifier(originIdentifier);
+#if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
+    process()->connection()->setForcelySetAllAsyncMessagesToDispatchEvenWhenWaitingForSyncReply(true);
+#endif
+
+    if (!m_uiClient.exceededDatabaseQuota(this, frame, origin.get(), displayName, expectedUsage))
+        replyExceededDatabaseQuota(true);
+}
+#else
 void WebPageProxy::exceededDatabaseQuota(uint64_t frameID, const String& originIdentifier, const String& databaseName, const String& displayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage, uint64_t& newQuota)
 {
     WebFrameProxy* frame = process()->webFrame(frameID);
@@ -4249,6 +4330,7 @@ void WebPageProxy::exceededDatabaseQuota(uint64_t frameID, const String& originI
 
     newQuota = m_uiClient.exceededDatabaseQuota(this, frame, origin.get(), databaseName, displayName, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage);
 }
+#endif
 
 void WebPageProxy::requestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, String originIdentifier)
 {
@@ -4590,6 +4672,13 @@ void WebPageProxy::dictationAlternatives(uint64_t dictationContext, Vector<Strin
 
 #endif // PLATFORM(MAC)
 
+#if USE(SOUP)
+void WebPageProxy::didReceiveURIRequest(String uriString, uint64_t requestID)
+{
+    m_process->context()->soupRequestManagerProxy()->didReceiveURIRequest(uriString, this, requestID);
+}
+#endif
+
 #if ENABLE(TIZEN_PAGE_VISIBILITY_API)
 void WebPageProxy::setPageVisibility(WebCore::PageVisibilityState pageVisibilityState, bool isInitialState)
 {