[Qt] Zoom in to the focused node only when vkb starts becoming visible https://bugs...
authorkenneth@webkit.org <kenneth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jan 2012 15:36:47 +0000 (15:36 +0000)
committerkenneth@webkit.org <kenneth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jan 2012 15:36:47 +0000 (15:36 +0000)
Reviewed by Simon Hausmann.

Remove the old code which always zoomed in when something got focus,
even via JavaScript, and replaced it with code checking the state of
the Qt input panel.

Also make sure that we do not zoom in or request the input panel if
the item is not focused.

* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/qt/QtPageClient.cpp:
* UIProcess/qt/QtPageClient.h:
* UIProcess/qt/QtWebPageEventHandler.cpp:
(QtWebPageEventHandler::QtWebPageEventHandler):
(QtWebPageEventHandler::~QtWebPageEventHandler):
(QtWebPageEventHandler::inputPanelVisibleChanged):
* UIProcess/qt/QtWebPageEventHandler.h:
* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::respondToChangedSelection):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105275 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/UIProcess/qt/QtPageClient.cpp
Source/WebKit2/UIProcess/qt/QtPageClient.h
Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp
Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.h
Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp

index ae7bcf6..2374f9e 100644 (file)
@@ -1,3 +1,31 @@
+2012-01-12  Kenneth Rohde Christiansen  <kenneth@webkit.org>
+
+        [Qt] Zoom in to the focused node only when vkb starts becoming visible
+        https://bugs.webkit.org/show_bug.cgi?id=76174
+
+        Reviewed by Simon Hausmann.
+
+        Remove the old code which always zoomed in when something got focus,
+        even via JavaScript, and replaced it with code checking the state of
+        the Qt input panel.
+
+        Also make sure that we do not zoom in or request the input panel if
+        the item is not focused.
+
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.cpp:
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/qt/QtPageClient.cpp:
+        * UIProcess/qt/QtPageClient.h:
+        * UIProcess/qt/QtWebPageEventHandler.cpp:
+        (QtWebPageEventHandler::QtWebPageEventHandler):
+        (QtWebPageEventHandler::~QtWebPageEventHandler):
+        (QtWebPageEventHandler::inputPanelVisibleChanged):
+        * UIProcess/qt/QtWebPageEventHandler.h:
+        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+        (WebKit::WebEditorClient::respondToChangedSelection):
+
 2012-01-18  Shinya Kawanaka  <shinyak@google.com>
 
         Move ShadowContentElement from dom/ to html/ and make ShadowContentElement subclass of HTMLElement.
index deabbd0..1c9714b 100644 (file)
@@ -106,7 +106,6 @@ public:
 #if PLATFORM(QT)
     virtual void didChangeContentsSize(const WebCore::IntSize&) = 0;
     virtual void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&) = 0;
-    virtual void focusEditableArea(const WebCore::IntRect&, const WebCore::IntRect&) = 0;
     virtual void didReceiveMessageFromNavigatorQtObject(const String&) = 0;
     virtual void handleDownloadRequest(DownloadProxy*) = 0;
     virtual void updateTextInputState() = 0;
index b253daa..1218232 100644 (file)
@@ -2331,11 +2331,6 @@ void WebPageProxy::didFindZoomableArea(const IntPoint& target, const IntRect& ar
     m_pageClient->didFindZoomableArea(target, area);
 }
 
-void WebPageProxy::focusEditableArea(const WebCore::IntRect& caret, const WebCore::IntRect& area)
-{
-    m_pageClient->focusEditableArea(caret, area);
-}
-
 void WebPageProxy::findZoomableAreaForPoint(const IntPoint& point)
 {
     if (!isValid())
index 926502f..2b45785 100644 (file)
@@ -719,7 +719,6 @@ private:
 #if PLATFORM(QT)
     void didChangeContentsSize(const WebCore::IntSize&);
     void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&);
-    void focusEditableArea(const WebCore::IntRect& caret, const WebCore::IntRect&);
 #endif
 #if ENABLE(TOUCH_EVENTS)
     void needTouchEvents(bool);
index 875f5b9..848e3a6 100644 (file)
@@ -74,7 +74,6 @@ messages -> WebPageProxy {
 #if PLATFORM(QT)
     DidChangeContentsSize(WebCore::IntSize newSize)
     DidFindZoomableArea(WebCore::IntPoint target, WebCore::IntRect area)
-    FocusEditableArea(WebCore::IntRect caret, WebCore::IntRect area)
     AuthenticationRequiredRequest(WTF::String hostname, WTF::String realm, WTF::String prefilledUsername) -> (WTF::String username, WTF::String password)
 #endif
 #if ENABLE(TOUCH_EVENTS)
index a1063b9..0ad152d 100644 (file)
@@ -195,12 +195,6 @@ void QtPageClient::didFindZoomableArea(const IntPoint& target, const IntRect& ar
     m_eventHandler->didFindZoomableArea(target, area);
 }
 
-void QtPageClient::focusEditableArea(const IntRect& caret, const IntRect& area)
-{
-    ASSERT(m_eventHandler);
-    m_eventHandler->focusEditableArea(caret, area);
-}
-
 void QtPageClient::didReceiveMessageFromNavigatorQtObject(const String& message)
 {
     QQuickWebViewPrivate::get(m_webView)->didReceiveMessageFromNavigatorQtObject(message);
index 81dfddf..157518a 100644 (file)
@@ -93,7 +93,6 @@ public:
     virtual void findStringInCustomRepresentation(const String&, WebKit::FindOptions, unsigned maxMatchCount) { }
     virtual void countStringMatchesInCustomRepresentation(const String&, WebKit::FindOptions, unsigned maxMatchCount) { }
     virtual void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&);
-    virtual void focusEditableArea(const WebCore::IntRect&, const WebCore::IntRect&);
     virtual void updateTextInputState();
     virtual void doneWithGestureEvent(const WebGestureEvent&, bool wasEventHandled);
     virtual void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled);
index 0e3f450..f7249fa 100644 (file)
@@ -96,10 +96,12 @@ QtWebPageEventHandler::QtWebPageEventHandler(WKPageRef pageRef, QQuickWebPage* q
     , m_clickCount(0)
     , m_postponeTextInputStateChanged(false)
 {
+    connect(qApp->inputPanel(), SIGNAL(visibleChanged()), this, SLOT(inputPanelVisibleChanged()));
 }
 
 QtWebPageEventHandler::~QtWebPageEventHandler()
 {
+    disconnect(qApp->inputPanel(), SIGNAL(visibleChanged()), this, SLOT(inputPanelVisibleChanged()));
 }
 
 bool QtWebPageEventHandler::handleEvent(QEvent* ev)
@@ -425,12 +427,28 @@ void QtWebPageEventHandler::resetGestureRecognizers()
 
 static void setInputPanelVisible(bool visible)
 {
+    Q_ASSERT(m_webView->hasFocus());
+
     if (qApp->inputPanel()->visible() == visible)
         return;
 
     qApp->inputPanel()->setVisible(visible);
 }
 
+void QtWebPageEventHandler::inputPanelVisibleChanged()
+{
+    if (!m_interactionEngine)
+        return;
+
+    // We only respond to the input panel becoming visible.
+    if (!m_webView->hasFocus() || !qApp->inputPanel()->visible())
+        return;
+
+    const EditorState& editor = m_webPageProxy->editorState();
+    if (editor.isContentEditable)
+        m_interactionEngine->focusEditableArea(QRectF(editor.cursorRect), QRectF(editor.editorRect));
+}
+
 void QtWebPageEventHandler::updateTextInputState()
 {
     if (m_postponeTextInputStateChanged)
@@ -440,6 +458,9 @@ void QtWebPageEventHandler::updateTextInputState()
 
     m_webView->setInputMethodHints(Qt::InputMethodHints(editor.inputMethodHints));
 
+    if (!m_webView->hasFocus())
+        return;
+
     // Ignore input method requests not due to a tap gesture.
     if (!editor.isContentEditable)
         setInputPanelVisible(false);
@@ -452,7 +473,7 @@ void QtWebPageEventHandler::doneWithGestureEvent(const WebGestureEvent& event, b
 
     m_postponeTextInputStateChanged = false;
 
-    if (!wasEventHandled)
+    if (!wasEventHandled || !m_webView->hasFocus())
         return;
 
     const EditorState& editor = m_webPageProxy->editorState();
@@ -521,14 +542,6 @@ void QtWebPageEventHandler::didFindZoomableArea(const IntPoint& target, const In
     m_interactionEngine->zoomToAreaGestureEnded(QPointF(target), QRectF(area));
 }
 
-void QtWebPageEventHandler::focusEditableArea(const IntRect& caret, const IntRect& area)
-{
-    if (!m_interactionEngine)
-        return;
-
-    m_interactionEngine->focusEditableArea(QRectF(caret), QRectF(area));
-}
-
 void QtWebPageEventHandler::startDrag(const WebCore::DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
 {
     QImage dragQImage;
index b1878f6..fd4aa0c 100644 (file)
@@ -51,7 +51,6 @@ public:
     void handleDoubleTapEvent(const QTouchEvent::TouchPoint&);
 
     void didFindZoomableArea(const WebCore::IntPoint& target, const WebCore::IntRect& area);
-    void focusEditableArea(const WebCore::IntRect& caret, const WebCore::IntRect& area);
     void updateTextInputState();
     void doneWithGestureEvent(const WebGestureEvent& event, bool wasEventHandled);
     void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled);
@@ -70,6 +69,9 @@ protected:
     QQuickWebPage* m_webPage;
     QQuickWebView* m_webView;
 
+private slots:
+    void inputPanelVisibleChanged();
+
 private:
     bool handleKeyPressEvent(QKeyEvent*);
     bool handleKeyReleaseEvent(QKeyEvent*);
index 8b243a3..efb75be 100644 (file)
@@ -185,12 +185,6 @@ void WebEditorClient::respondToChangedSelection(Frame* frame)
 
     EditorState state = m_page->editorState();
 
-#if PLATFORM(QT)
-    // FIXME: Move this to act on the vkb visibility change.
-    if (state.isContentEditable)
-        m_page->send(Messages::WebPageProxy::FocusEditableArea(state.cursorRect, state.editorRect));
-#endif
-
     m_page->send(Messages::WebPageProxy::EditorStateChanged(state));
 
 #if PLATFORM(WIN)