Title: [105275] trunk/Source/WebKit2
Revision
105275
Author
kenn...@webkit.org
Date
2012-01-18 07:36:47 -0800 (Wed, 18 Jan 2012)

Log Message

[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):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (105274 => 105275)


--- trunk/Source/WebKit2/ChangeLog	2012-01-18 15:21:48 UTC (rev 105274)
+++ trunk/Source/WebKit2/ChangeLog	2012-01-18 15:36:47 UTC (rev 105275)
@@ -1,3 +1,31 @@
+2012-01-12  Kenneth Rohde Christiansen  <kenn...@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  <shin...@google.com>
 
         Move ShadowContentElement from dom/ to html/ and make ShadowContentElement subclass of HTMLElement.

Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (105274 => 105275)


--- trunk/Source/WebKit2/UIProcess/PageClient.h	2012-01-18 15:21:48 UTC (rev 105274)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h	2012-01-18 15:36:47 UTC (rev 105275)
@@ -106,7 +106,6 @@
 #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;

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (105274 => 105275)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2012-01-18 15:21:48 UTC (rev 105274)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2012-01-18 15:36:47 UTC (rev 105275)
@@ -2331,11 +2331,6 @@
     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())

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (105274 => 105275)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2012-01-18 15:21:48 UTC (rev 105274)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2012-01-18 15:36:47 UTC (rev 105275)
@@ -719,7 +719,6 @@
 #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);

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (105274 => 105275)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2012-01-18 15:21:48 UTC (rev 105274)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2012-01-18 15:36:47 UTC (rev 105275)
@@ -74,7 +74,6 @@
 #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)

Modified: trunk/Source/WebKit2/UIProcess/qt/QtPageClient.cpp (105274 => 105275)


--- trunk/Source/WebKit2/UIProcess/qt/QtPageClient.cpp	2012-01-18 15:21:48 UTC (rev 105274)
+++ trunk/Source/WebKit2/UIProcess/qt/QtPageClient.cpp	2012-01-18 15:36:47 UTC (rev 105275)
@@ -195,12 +195,6 @@
     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);

Modified: trunk/Source/WebKit2/UIProcess/qt/QtPageClient.h (105274 => 105275)


--- trunk/Source/WebKit2/UIProcess/qt/QtPageClient.h	2012-01-18 15:21:48 UTC (rev 105274)
+++ trunk/Source/WebKit2/UIProcess/qt/QtPageClient.h	2012-01-18 15:36:47 UTC (rev 105275)
@@ -93,7 +93,6 @@
     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);

Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp (105274 => 105275)


--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp	2012-01-18 15:21:48 UTC (rev 105274)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp	2012-01-18 15:36:47 UTC (rev 105275)
@@ -96,10 +96,12 @@
     , 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 @@
 
 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 @@
 
     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 @@
 
     m_postponeTextInputStateChanged = false;
 
-    if (!wasEventHandled)
+    if (!wasEventHandled || !m_webView->hasFocus())
         return;
 
     const EditorState& editor = m_webPageProxy->editorState();
@@ -521,14 +542,6 @@
     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;

Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.h (105274 => 105275)


--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.h	2012-01-18 15:21:48 UTC (rev 105274)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.h	2012-01-18 15:36:47 UTC (rev 105275)
@@ -51,7 +51,6 @@
     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 @@
     QQuickWebPage* m_webPage;
     QQuickWebView* m_webView;
 
+private slots:
+    void inputPanelVisibleChanged();
+
 private:
     bool handleKeyPressEvent(QKeyEvent*);
     bool handleKeyReleaseEvent(QKeyEvent*);

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp (105274 => 105275)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp	2012-01-18 15:21:48 UTC (rev 105274)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp	2012-01-18 15:36:47 UTC (rev 105275)
@@ -185,12 +185,6 @@
 
     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)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to