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
+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.
#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;
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())
#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);
#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)
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);
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);
, 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)
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)
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);
m_postponeTextInputStateChanged = false;
- if (!wasEventHandled)
+ if (!wasEventHandled || !m_webView->hasFocus())
return;
const EditorState& editor = m_webPageProxy->editorState();
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;
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);
QQuickWebPage* m_webPage;
QQuickWebView* m_webView;
+private slots:
+ void inputPanelVisibleChanged();
+
private:
bool handleKeyPressEvent(QKeyEvent*);
bool handleKeyReleaseEvent(QKeyEvent*);
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)