Changeset 48154 in webkit


Ignore:
Timestamp:
Sep 8, 2009 7:43:08 AM (15 years ago)
Author:
Simon Hausmann
Message:

WebCore: [Qt] Make cursor set cleaner in QtWebKit Api: eliminate SetCursorEvent hack.
https://bugs.webkit.org/show_bug.cgi?id=28865

Patch by Kenneth Rohde Christiansen <kenneth@webkit.org> on 2009-09-08
Reviewed by Simon Hausmann.

Save the QCursor as a property in WidgetQt::setCursor
and actually change the cursor in QWebView::event() by making use
of the QEvent::DynamicPropertyChange event type.
When unsetCursor() is called on the QWidget we can fallback to
the cursor set by WebCore.

Patch by Kenneth Rohde Christiansen <kenneth@webkit.org> and

Antonio Gomes <antonio.gomes@openbossa.org> on 2009-09-07

  • platform/qt/WidgetQt.cpp:

(WebCore::Widget::setCursor):

WebKit/qt: [Qt] Make cursor set cleaner in QtWebKit Api: eliminate SetCursorEvent hack.
https://bugs.webkit.org/show_bug.cgi?id=28865

Patch by Kenneth Rohde Christiansen <kenneth@webkit.org> on 2009-09-08
Reviewed by Simon Hausmann.

Clean up the unserCursor hack to use the QCursor set
as a property of the QWidget by WebCore::WidgetQt.

Remove all code that are no longer necessary for getting
cursor change events.

Patch by Kenneth Rohde Christiansen <kenneth@webkit.org> and

Antonio Gomes <antonio.gomes@openbossa.org> on 2009-09-07

  • Api/qwebpage.cpp:
  • Api/qwebpage_p.h:
  • Api/qwebview.cpp:

(QWebViewPrivate::QWebViewPrivate):
(QWebView::event):

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r48153 r48154  
     12009-09-08  Kenneth Rohde Christiansen  <kenneth@webkit.org>
     2
     3        Reviewed by Simon Hausmann.
     4
     5        [Qt] Make cursor set cleaner in QtWebKit Api: eliminate SetCursorEvent hack.
     6        https://bugs.webkit.org/show_bug.cgi?id=28865
     7
     8        Save the QCursor as a property in WidgetQt::setCursor
     9        and actually change the cursor in QWebView::event() by making use
     10        of the QEvent::DynamicPropertyChange event type.
     11        When unsetCursor() is called on the QWidget we can fallback to
     12        the cursor set by WebCore.
     13
     14        Patch by Kenneth Rohde Christiansen <kenneth@webkit.org> and
     15                 Antonio Gomes <antonio.gomes@openbossa.org> on 2009-09-07
     16
     17        * platform/qt/WidgetQt.cpp:
     18        (WebCore::Widget::setCursor):
     19
    1202009-09-08  Andras Becsi  <becsi.andras@stud.u-szeged.hu>
    221
  • trunk/WebCore/platform/qt/WidgetQt.cpp

    r47004 r48154  
    9090        return;
    9191
    92     QCoreApplication::postEvent(widget, new SetCursorEvent(cursor.impl()));
     92    widget->setProperty("WebCoreCursor", cursor.impl());
    9393#endif
    9494}
  • trunk/WebKit/qt/Api/qwebpage.cpp

    r48151 r48154  
    225225    return 0;
    226226}
    227 
    228 #ifndef QT_NO_CURSOR
    229 SetCursorEvent::SetCursorEvent(const QCursor& cursor)
    230     : QEvent(static_cast<QEvent::Type>(EventType))
    231     , m_cursor(cursor)
    232 {}
    233 
    234 QCursor SetCursorEvent::cursor() const
    235 {
    236     return m_cursor;
    237 }
    238 #endif
    239227
    240228// If you change this make sure to also adjust the docs for QWebPage::userAgentForUrl
  • trunk/WebKit/qt/Api/qwebpage_p.h

    r46170 r48154  
    4646    class Page;
    4747    class Frame;
    48 
    49 #ifndef QT_NO_CURSOR
    50     class SetCursorEvent : public QEvent {
    51     public:
    52         static const int EventType = 724;
    53         SetCursorEvent(const QCursor&);
    54 
    55         QCursor cursor() const;
    56     private:
    57         QCursor m_cursor;
    58     };
    59 #endif
    6048}
    6149
  • trunk/WebKit/qt/Api/qwebview.cpp

    r48039 r48154  
    3737        , page(0)
    3838        , renderHints(QPainter::TextAntialiasing)
    39 #ifndef QT_NO_CURSOR
    40         , cursorSetByWebCore(false)
    41         , usesWebCoreCursor(true)
    42 #endif
    4339    {}
    4440
     
    4945
    5046    QPainter::RenderHints renderHints;
    51 
    52 #ifndef QT_NO_CURSOR
    53     /*
    54      * We keep track of if we have called setCursor and if the CursorChange
    55      * event is sent due our setCursor call and if we currently use the WebCore
    56      * Cursor and use it to decide if we can update to another WebCore Cursor.
    57      */
    58     bool cursorSetByWebCore;
    59     bool usesWebCoreCursor;
    60 
    61     void setCursor(const QCursor& newCursor)
    62     {
    63         webCoreCursor = newCursor;
    64 
    65         if (usesWebCoreCursor) {
    66             cursorSetByWebCore = true;
    67             view->setCursor(webCoreCursor);
    68         }
    69     }
    70 
    71     QCursor webCoreCursor;
    72 #endif
    7347};
    7448
     
    705679            d->page->event(e);
    706680#ifndef QT_NO_CURSOR
    707         } else if (e->type() == static_cast<QEvent::Type>(WebCore::SetCursorEvent::EventType)) {
    708             d->setCursor(static_cast<WebCore::SetCursorEvent*>(e)->cursor());
    709681#if QT_VERSION >= 0x040400
    710682        } else if (e->type() == QEvent::CursorChange) {
    711             // Okay we might use the WebCore Cursor now.
    712             d->usesWebCoreCursor = d->cursorSetByWebCore;
    713             d->cursorSetByWebCore = false;
    714 
    715             // Go back to the WebCore Cursor. QWidget::unsetCursor is appromixated with this
    716             if (!d->usesWebCoreCursor && cursor().shape() == Qt::ArrowCursor) {
    717                 d->usesWebCoreCursor = true;
    718                 d->setCursor(d->webCoreCursor);
     683            // might be a QWidget::unsetCursor()
     684            if (cursor().shape() == Qt::ArrowCursor) {
     685                QVariant prop = property("WebCoreCursor");
     686                if (prop.isValid()) {
     687                    QCursor webCoreCursor = qvariant_cast<QCursor>(prop);
     688                    if (webCoreCursor.shape() != Qt::ArrowCursor)
     689                        setCursor(webCoreCursor);
     690                }
     691            }
     692        } else if (e->type() == QEvent::DynamicPropertyChange) {
     693            const QByteArray& propName = static_cast<QDynamicPropertyChangeEvent *>(e)->propertyName();
     694            if (!qstrcmp(propName, "WebCoreCursor")) {
     695                QVariant prop = property("WebCoreCursor");
     696                if (prop.isValid()) {
     697                    QCursor webCoreCursor = qvariant_cast<QCursor>(prop);
     698                    setCursor(webCoreCursor);
     699                }
    719700            }
    720701#endif
  • trunk/WebKit/qt/ChangeLog

    r48151 r48154  
     12009-09-08  Kenneth Rohde Christiansen  <kenneth@webkit.org>
     2
     3        Reviewed by Simon Hausmann.
     4
     5        [Qt] Make cursor set cleaner in QtWebKit Api: eliminate SetCursorEvent hack.
     6        https://bugs.webkit.org/show_bug.cgi?id=28865
     7
     8        Clean up the unserCursor hack to use the QCursor set
     9        as a property of the QWidget by WebCore::WidgetQt.
     10
     11        Remove all code that are no longer necessary for getting
     12        cursor change events.
     13
     14        Patch by Kenneth Rohde Christiansen <kenneth@webkit.org> and
     15                 Antonio Gomes <antonio.gomes@openbossa.org> on 2009-09-07
     16
     17        * Api/qwebpage.cpp:
     18        * Api/qwebpage_p.h:
     19        * Api/qwebview.cpp:
     20        (QWebViewPrivate::QWebViewPrivate):
     21        (QWebView::event):
     22
    1232009-09-08  Laszlo Gombos  <laszlo.1.gombos@nokia.com>
    224
Note: See TracChangeset for help on using the changeset viewer.