Changeset 96105 in webkit


Ignore:
Timestamp:
Sep 27, 2011 7:09:00 AM (13 years ago)
Author:
caio.oliveira@openbossa.org
Message:

[Qt][WK2] Add support for hover API in Qt WebKit2
https://bugs.webkit.org/show_bug.cgi?id=68369

Reviewed by Andreas Kling.

Source/WebKit2:

Based on the patch from Igor Oliveira in the same bug.

Expose a linkHovered() signal in QDesktopWebView, that passes the QUrl and the
QString corresponding to the link title. I left textContent out because was
unsure of its use case.

In QDesktopWebView we store the last URL and title emitted to make sure we send
the signal only if either value changes. Tests were added to the QML element to
check: if values are correctly emitted and if we don't emit more signals than
necessary.

  • UIProcess/API/qt/qdesktopwebview.cpp:

(QDesktopWebViewPrivate::didMouseMoveOverElement):

  • UIProcess/API/qt/qdesktopwebview.h:
  • UIProcess/API/qt/qdesktopwebview_p.h:
  • UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_linkHovered.qml: Added.
  • UIProcess/API/qt/tests/qmltests/common/test2.html:
  • UIProcess/API/qt/tests/qmltests/qmltests.pro:
  • UIProcess/qt/ClientImpl.cpp:

(qt_wk_mouseDidMoveOverElement):

  • UIProcess/qt/ClientImpl.h:
  • UIProcess/qt/QtWebPageProxy.cpp:

(QtWebPageProxy::init):

  • UIProcess/qt/TouchViewInterface.h:

(WebKit::TouchViewInterface::didMouseMoveOverElement):

  • UIProcess/qt/ViewInterface.h:

Tools:

Change the statusbar to show the link URL when hovering links in
MiniBrowser using QDesktopWebView.

  • MiniBrowser/qt/BrowserWindow.cpp:

(BrowserWindow::BrowserWindow):
(BrowserWindow::onLinkHovered):

  • MiniBrowser/qt/BrowserWindow.h:
Location:
trunk
Files:
1 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r96101 r96105  
     12011-09-26  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
     2
     3        [Qt][WK2] Add support for hover API in Qt WebKit2
     4        https://bugs.webkit.org/show_bug.cgi?id=68369
     5
     6        Reviewed by Andreas Kling.
     7
     8        Based on the patch from Igor Oliveira in the same bug.
     9
     10        Expose a linkHovered() signal in QDesktopWebView, that passes the QUrl and the
     11        QString corresponding to the link title. I left textContent out because was
     12        unsure of its use case.
     13
     14        In QDesktopWebView we store the last URL and title emitted to make sure we send
     15        the signal only if either value changes. Tests were added to the QML element to
     16        check: if values are correctly emitted and if we don't emit more signals than
     17        necessary.
     18
     19        * UIProcess/API/qt/qdesktopwebview.cpp:
     20        (QDesktopWebViewPrivate::didMouseMoveOverElement):
     21        * UIProcess/API/qt/qdesktopwebview.h:
     22        * UIProcess/API/qt/qdesktopwebview_p.h:
     23        * UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_linkHovered.qml: Added.
     24        * UIProcess/API/qt/tests/qmltests/common/test2.html:
     25        * UIProcess/API/qt/tests/qmltests/qmltests.pro:
     26        * UIProcess/qt/ClientImpl.cpp:
     27        (qt_wk_mouseDidMoveOverElement):
     28        * UIProcess/qt/ClientImpl.h:
     29        * UIProcess/qt/QtWebPageProxy.cpp:
     30        (QtWebPageProxy::init):
     31        * UIProcess/qt/TouchViewInterface.h:
     32        (WebKit::TouchViewInterface::didMouseMoveOverElement):
     33        * UIProcess/qt/ViewInterface.h:
     34
    1352011-09-27  Alexis Menard  <alexis.menard@openbossa.org>
    236
  • trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp

    r95901 r96105  
    432432}
    433433
     434void QDesktopWebViewPrivate::didMouseMoveOverElement(const QUrl& linkURL, const QString& linkTitle)
     435{
     436    if (linkURL == lastHoveredURL && linkTitle == lastHoveredTitle)
     437        return;
     438    lastHoveredURL = linkURL;
     439    lastHoveredTitle = linkTitle;
     440    emit q->linkHovered(lastHoveredURL, lastHoveredTitle);
     441}
     442
    434443static PolicyInterface::PolicyAction toPolicyAction(QDesktopWebView::NavigationPolicy policy)
    435444{
  • trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.h

    r96101 r96105  
    8989    void loadProgressChanged(int progress);
    9090    void urlChanged(const QUrl& url);
     91    void linkHovered(const QUrl& url, const QString& title);
    9192
    9293protected:
  • trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview_p.h

    r95901 r96105  
    8585    virtual void chooseFiles(WKOpenPanelResultListenerRef, const QStringList& selectedFileNames, ViewInterface::FileChooserType);
    8686
     87    virtual void didMouseMoveOverElement(const QUrl&, const QString&);
     88
    8789    // PolicyInterface.
    8890    virtual PolicyInterface::PolicyAction navigationPolicyForURL(const QUrl&, Qt::MouseButton, Qt::KeyboardModifiers);
     
    9294    QFileDialog* fileDialog;
    9395    WKOpenPanelResultListenerRef openPanelResultListener;
     96
     97    QUrl lastHoveredURL;
     98    QString lastHoveredTitle;
    9499};
    95100
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test2.html

    r93427 r96105  
    22<head><title>Test page with huge link area</title></head>
    33<body>
    4 <a href="test1.html"><img width=200 height=200></a>
     4<a title="A title" href="test1.html"><img width=200 height=200></a>
    55</body>
    66</html>
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/qmltests.pro

    r95773 r96105  
    1414    DesktopWebView/tst_loadProgress.qml \
    1515    DesktopWebView/tst_loadProgressSignal.qml \
     16    DesktopWebView/tst_linkHovered.qml \
    1617    TouchWebView/tst_properties.qml \
    1718    TouchWebView/tst_load.qml \
  • trunk/Source/WebKit2/UIProcess/qt/ClientImpl.cpp

    r95901 r96105  
    3333#include <WKFrame.h>
    3434#include <WKFramePolicyListener.h>
     35#include <WKHitTestResult.h>
    3536#include <WKOpenPanelParameters.h>
    3637#include <WKOpenPanelResultListener.h>
     
    162163    ViewInterface::FileChooserType allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? ViewInterface::MultipleFilesSelection : ViewInterface::SingleFileSelection;
    163164    toViewInterface(clientInfo)->chooseFiles(listener, selectedFileNames, allowMultipleFiles);
     165}
     166
     167void qt_wk_mouseDidMoveOverElement(WKPageRef page, WKHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef userData, const void* clientInfo)
     168{
     169    const QUrl absoluteLinkUrl = WKURLCopyQUrl(WKHitTestResultCopyAbsoluteLinkURL(hitTestResult));
     170    const QString linkTitle = WKStringCopyQString(WKHitTestResultCopyLinkTitle(hitTestResult));
     171    toViewInterface(clientInfo)->didMouseMoveOverElement(absoluteLinkUrl, linkTitle);
    164172}
    165173
  • trunk/Source/WebKit2/UIProcess/qt/ClientImpl.h

    r95901 r96105  
    4242void qt_wk_setStatusText(WKPageRef page, WKStringRef text, const void *clientInfo);
    4343void qt_wk_runOpenPanel(WKPageRef, WKFrameRef, WKOpenPanelParametersRef, WKOpenPanelResultListenerRef, const void* clientInfo);
     44void qt_wk_mouseDidMoveOverElement(WKPageRef, WKHitTestResultRef, WKEventModifiers, WKTypeRef, const void* clientInfo);
    4445
    4546// Policy client.
  • trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp

    r95901 r96105  
    144144    uiClient.setStatusText = qt_wk_setStatusText;
    145145    uiClient.runOpenPanel = qt_wk_runOpenPanel;
     146    uiClient.mouseDidMoveOverElement = qt_wk_mouseDidMoveOverElement;
    146147    WKPageSetPageUIClient(toAPI(m_webPageProxy.get()), &uiClient);
    147148
  • trunk/Source/WebKit2/UIProcess/qt/TouchViewInterface.h

    r95901 r96105  
    8080    virtual void chooseFiles(WKOpenPanelResultListenerRef, const QStringList&, FileChooserType) { }
    8181
     82    virtual void didMouseMoveOverElement(const QUrl&, const QString&) { }
     83
    8284private:
    8385    QTouchWebView* const m_viewportView;
  • trunk/Source/WebKit2/UIProcess/qt/ViewInterface.h

    r95901 r96105  
    8989
    9090    virtual void chooseFiles(WKOpenPanelResultListenerRef, const QStringList& selectedFileNames, FileChooserType) = 0;
     91
     92    virtual void didMouseMoveOverElement(const QUrl&, const QString&) = 0;
    9193};
    9294
  • trunk/Tools/ChangeLog

    r96074 r96105  
     12011-09-26  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
     2
     3        [Qt][WK2] Add support for hover API in Qt WebKit2
     4        https://bugs.webkit.org/show_bug.cgi?id=68369
     5
     6        Reviewed by Andreas Kling.
     7
     8        Change the statusbar to show the link URL when hovering links in
     9        MiniBrowser using QDesktopWebView.
     10
     11        * MiniBrowser/qt/BrowserWindow.cpp:
     12        (BrowserWindow::BrowserWindow):
     13        (BrowserWindow::onLinkHovered):
     14        * MiniBrowser/qt/BrowserWindow.h:
     15
    1162011-09-26  Dimitri Glazkov  <dglazkov@chromium.org>
    217
  • trunk/Tools/MiniBrowser/qt/BrowserWindow.cpp

    r92276 r96105  
    6565        connect(webView(), SIGNAL(urlChanged(QUrl)), this, SLOT(printURL(QUrl)));
    6666
    67     if (QDesktopWebView* const desktopWebView = m_browser->desktopWebView())
     67    if (QDesktopWebView* const desktopWebView = m_browser->desktopWebView()) {
    6868        connect(desktopWebView, SIGNAL(statusBarMessageChanged(QString)), statusBar(), SLOT(showMessage(QString)));
     69        connect(desktopWebView, SIGNAL(linkHovered(QUrl, QString)), this, SLOT(onLinkHovered(QUrl, QString)));
     70    }
    6971
    7072    this->setCentralWidget(m_browser);
     
    288290}
    289291
     292void BrowserWindow::onLinkHovered(const QUrl& url, const QString&)
     293{
     294    statusBar()->showMessage(url.toString());
     295}
     296
    290297void BrowserWindow::updateUserAgentList()
    291298{
  • trunk/Tools/MiniBrowser/qt/BrowserWindow.h

    r92276 r96105  
    7070
    7171    void printURL(const QUrl&);
     72    void onLinkHovered(const QUrl&, const QString&);
    7273
    7374private:
Note: See TracChangeset for help on using the changeset viewer.