Changeset 90629 in webkit


Ignore:
Timestamp:
Jul 8, 2011 7:42:27 AM (13 years ago)
Author:
benjamin.poulain@nokia.com
Message:

[WK2] Do not forward touch events to the web process when it does not need them
https://bugs.webkit.org/show_bug.cgi?id=64164

Reviewed by Kenneth Rohde Christiansen.

Source/JavaScriptCore:

Add a convenience function to obtain a reference to the last element of a Deque.

  • wtf/Deque.h:

(WTF::Deque::last):

Source/WebKit2:

The call to ChromeClient::needTouchEvent() is now forwarded to the WebPageProxy
to change the way events are delivered.

When the WebPage does not need touch events, and there is no queued touch events,
the incoming events just bounce back through PageClient::doneWithTouchEvent().

In the case when new events come to WebPageProxy and there are still touch events
incoming from the WebProcess, the new events are deferred with the corresponding
pending touch events.
Deferring the new events iafter the corresponding forwarded event ensure
the delivery is always done in order when PageClient::doneWithTouchEvent()
is called.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::handleTouchEvent):
(WebKit::WebPageProxy::needTouchEvents):
(WebKit::WebPageProxy::didReceiveEvent):
(WebKit::WebPageProxy::processDidCrash):

  • UIProcess/WebPageProxy.h:

(WebKit::QueuedTouchEvents:::forwardedEvent):

  • UIProcess/WebPageProxy.messages.in:
  • WebProcess/WebCoreSupport/WebChromeClient.cpp:

(WebKit::WebChromeClient::needTouchEvents):

Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r90602 r90629  
     12011-07-08  Benjamin Poulain  <benjamin@webkit.org>
     2
     3        [WK2] Do not forward touch events to the web process when it does not need them
     4        https://bugs.webkit.org/show_bug.cgi?id=64164
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        Add a convenience function to obtain a reference to the last element of a Deque.
     9
     10        * wtf/Deque.h:
     11        (WTF::Deque::last):
     12
    1132011-07-07  Filip Pizlo  <fpizlo@apple.com>
    214
  • trunk/Source/JavaScriptCore/wtf/Deque.h

    r86383 r90629  
    7979        PassType takeFirst();
    8080
     81        T& last() { ASSERT(m_start != m_end); return *(--end()); }
     82        const T& last() const { ASSERT(m_start != m_end); return *(--end()); }
     83
    8184        template<typename U> void append(const U&);
    8285        template<typename U> void prepend(const U&);
  • trunk/Source/WebKit2/ChangeLog

    r90618 r90629  
     12011-07-08  Benjamin Poulain  <benjamin@webkit.org>
     2
     3        [WK2] Do not forward touch events to the web process when it does not need them
     4        https://bugs.webkit.org/show_bug.cgi?id=64164
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        The call to ChromeClient::needTouchEvent() is now forwarded to the WebPageProxy
     9        to change the way events are delivered.
     10
     11        When the WebPage does not need touch events, and there is no queued touch events,
     12        the incoming events just bounce back through PageClient::doneWithTouchEvent().
     13
     14        In the case when new events come to WebPageProxy and there are still touch events
     15        incoming from the WebProcess, the new events are deferred with the corresponding
     16        pending touch events.
     17        Deferring the new events iafter the corresponding forwarded event ensure
     18        the delivery is always done in order when PageClient::doneWithTouchEvent()
     19        is called.
     20
     21        * UIProcess/WebPageProxy.cpp:
     22        (WebKit::WebPageProxy::WebPageProxy):
     23        (WebKit::WebPageProxy::handleTouchEvent):
     24        (WebKit::WebPageProxy::needTouchEvents):
     25        (WebKit::WebPageProxy::didReceiveEvent):
     26        (WebKit::WebPageProxy::processDidCrash):
     27        * UIProcess/WebPageProxy.h:
     28        (WebKit::QueuedTouchEvents:::forwardedEvent):
     29        * UIProcess/WebPageProxy.messages.in:
     30        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
     31        (WebKit::WebChromeClient::needTouchEvents):
     32
    1332011-07-08  Benjamin Poulain  <benjamin@webkit.org>
    234
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r90550 r90629  
    171171    , m_syncNavigationActionPolicyDownloadID(0)
    172172    , m_processingMouseMoveEvent(false)
     173#if ENABLE(TOUCH_EVENTS)
     174    , m_needTouchEvents(false)
     175#endif
    173176    , m_pageID(pageID)
    174177#if PLATFORM(MAC)
     
    978981        return;
    979982
    980     m_touchEventQueue.append(event);
    981     process()->responsivenessTimer()->start();
    982     process()->send(Messages::WebPage::TouchEvent(event), m_pageID);
     983    if (m_needTouchEvents) {
     984        m_touchEventQueue.append(event);
     985        process()->responsivenessTimer()->start();
     986        process()->send(Messages::WebPage::TouchEvent(event), m_pageID);
     987    } else {
     988        if (m_touchEventQueue.isEmpty()) {
     989            bool isEventHandled = false;
     990            m_pageClient->doneWithTouchEvent(event, isEventHandled);
     991        } else {
     992            // We attach the incoming events to the newest queued event so that all
     993            // the events are delivered in the correct order when the event is dequed.
     994            QueuedTouchEvents& lastEvent = m_touchEventQueue.last();
     995            lastEvent.deferredTouchEvents.append(event);
     996        }
     997    }
    983998}
    984999#endif
     
    21882203
    21892204    process()->send(Messages::WebPage::FindZoomableAreaForPoint(point), m_pageID);
     2205}
     2206#endif
     2207
     2208#if ENABLE(TOUCH_EVENTS)
     2209void WebPageProxy::needTouchEvents(bool needTouchEvents)
     2210{
     2211    m_needTouchEvents = needTouchEvents;
    21902212}
    21912213#endif
     
    27942816    case WebEvent::TouchEnd:
    27952817    case WebEvent::TouchCancel: {
    2796         NativeWebTouchEvent event = m_touchEventQueue.first();
    2797         MESSAGE_CHECK(type == event.type());
     2818        QueuedTouchEvents queuedEvents = m_touchEventQueue.first();
     2819        MESSAGE_CHECK(type == queuedEvents.forwardedEvent.type());
    27982820        m_touchEventQueue.removeFirst();
    27992821
    2800         m_pageClient->doneWithTouchEvent(event, handled);
     2822        m_pageClient->doneWithTouchEvent(queuedEvents.forwardedEvent, handled);
     2823        for (size_t i = 0; i < queuedEvents.deferredTouchEvents.size(); ++i) {
     2824            bool isEventHandled = false;
     2825            m_pageClient->doneWithTouchEvent(queuedEvents.deferredTouchEvents.at(i), isEventHandled);
     2826        }
    28012827        break;
    28022828    }
     
    30033029
    30043030    m_processingMouseMoveEvent = false;
     3031
     3032#if ENABLE(TOUCH_EVENTS)
     3033    m_needTouchEvents = false;
     3034    m_touchEventQueue.clear();
     3035#endif
    30053036
    30063037#if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD)
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r90550 r90629  
    6262#include <wtf/PassRefPtr.h>
    6363#include <wtf/RefPtr.h>
     64#include <wtf/Vector.h>
    6465#include <wtf/text/WTFString.h>
    6566#if PLATFORM(EFL)
     
    132133typedef GenericCallback<WKStringRef, StringImpl*> StringCallback;
    133134typedef GenericCallback<WKSerializedScriptValueRef, WebSerializedScriptValue*> ScriptValueCallback;
     135
     136#if ENABLE(TOUCH_EVENTS)
     137struct QueuedTouchEvents {
     138    QueuedTouchEvents(const NativeWebTouchEvent& event)
     139        : forwardedEvent(event)
     140    {
     141    }
     142    NativeWebTouchEvent forwardedEvent;
     143    Vector<NativeWebTouchEvent> deferredTouchEvents;
     144};
     145#endif
    134146
    135147// FIXME: Make a version of CallbackBase with three arguments, and define ValidateCommandCallback as a specialization.
     
    652664    void didFindZoomableArea(const WebCore::IntRect&);
    653665#endif
     666#if ENABLE(TOUCH_EVENTS)
     667    void needTouchEvents(bool);
     668#endif
    654669
    655670    void editorStateChanged(const EditorState&);
     
    870885
    871886    Deque<NativeWebKeyboardEvent> m_keyEventQueue;
    872 #if ENABLE(TOUCH_EVENTS)
    873     Deque<NativeWebTouchEvent> m_touchEventQueue;
    874 #endif
    875887    Deque<NativeWebWheelEvent> m_wheelEventQueue;
    876888    Vector<NativeWebWheelEvent> m_currentlyProcessedWheelEvents;
     
    879891    OwnPtr<NativeWebMouseEvent> m_nextMouseMoveEvent;
    880892    OwnPtr<NativeWebMouseEvent> m_currentlyProcessedMouseDownEvent;
     893
     894#if ENABLE(TOUCH_EVENTS)
     895    bool m_needTouchEvents;
     896    Deque<QueuedTouchEvents> m_touchEventQueue;
     897#endif
    881898
    882899    uint64_t m_pageID;
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in

    r89582 r90629  
    7474    DidFindZoomableArea(WebCore::IntRect area)
    7575#endif
     76#if ENABLE(TOUCH_EVENTS)
     77    NeedTouchEvents(bool needTouchEvents)
     78#endif
    7679
    7780    # Policy messages
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp

    r89430 r90629  
    730730
    731731#if ENABLE(TOUCH_EVENTS)
    732 void WebChromeClient::needTouchEvents(bool)
    733 {
     732void WebChromeClient::needTouchEvents(bool needTouchEvents)
     733{
     734    m_page->send(Messages::WebPageProxy::NeedTouchEvents(needTouchEvents));
    734735}
    735736#endif
Note: See TracChangeset for help on using the changeset viewer.