<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [GTK] Add kinetic scrolling"
   href="https://bugs.webkit.org/show_bug.cgi?id=155750#c11">Comment # 11</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [GTK] Add kinetic scrolling"
   href="https://bugs.webkit.org/show_bug.cgi?id=155750">bug 155750</a>
              from <span class="vcard"><a class="email" href="mailto:cgarcia&#64;igalia.com" title="Carlos Garcia Campos &lt;cgarcia&#64;igalia.com&gt;"> <span class="fn">Carlos Garcia Campos</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=277468&amp;action=diff" name="attach_277468" title="WIP patch">attachment 277468</a> <a href="attachment.cgi?id=277468&amp;action=edit" title="WIP patch">[details]</a></span>
WIP patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=277468&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=277468&amp;action=review</a>

Some more general comments

<span class="quote">&gt; Source/WebCore/platform/PlatformWheelEvent.h:32
&gt; +#if PLATFORM(GTK)
&gt; +#include &quot;FloatPoint.h&quot;
&gt; +#endif</span >

Don't use platform ifdefs to include cross-platform headers, just include the header if it's really needed.

<span class="quote">&gt; Source/WebCore/platform/PlatformWheelEvent.h:73
&gt; +    enum PlatformWheelEventPhase {
&gt; +        PlatformWheelEventPhaseNone        = 0,
&gt; +        PlatformWheelEventPhaseStop        = 1 &lt;&lt; 0,
&gt; +        PlatformWheelEventPhaseSwipe       = 1 &lt;&lt; 1,</span >

Do not line up this enum with the previous one. I wonder if we could reuse the cocoa enum even if we don't use all the flags, or are they too different?

<span class="quote">&gt; Source/WebCore/platform/PlatformWheelEvent.h:95
&gt; +            , m_phase(PlatformWheelEventPhaseNone)</span >

Initialize this below when the member is delcared and you don't need to do this in every constructor.

<span class="quote">&gt; Source/WebCore/platform/PlatformWheelEvent.h:96
&gt; +            , m_swipeVelocity(FloatPoint())</span >

This is not needed

<span class="quote">&gt; Source/WebCore/platform/PlatformWheelEvent.h:120
&gt; +            , m_phase(PlatformWheelEventPhaseNone)
&gt; +            , m_swipeVelocity(FloatPoint())</span >

Ditto.

<span class="quote">&gt; Source/WebCore/platform/PlatformWheelEvent.h:182
&gt; +        FloatPoint swipeVelocity() const { return m_swipeVelocity; }</span >

This should return a const reference instead of a copy.

<span class="quote">&gt; Source/WebCore/platform/ScrollAnimationKinetic.cpp:112
&gt; +    , m_horizontalData(0, 0, 0, 0)
&gt; +    , m_verticalData(0, 0, 0, 0)</span >

These are not needed.

<span class="quote">&gt; Source/WebCore/platform/ScrollAnimationKinetic.cpp:123
&gt; +    return true;</span >

Why is this empty now?

<span class="quote">&gt; Source/WebCore/platform/ScrollAnimationKinetic.cpp:142
&gt; +    if (velocity == FloatPoint())</span >

I would do if (!velocity.x() &amp;&amp; !velocity.y()) instead of creating a zero FloatPoint just to compare it.

<span class="quote">&gt; Source/WebCore/platform/gtk/ScrollAnimatorGtk.cpp:53
&gt; +    // FIXME Should this be moved to the initializer list even if it's a bit complex?</span >

I think it's fine here in the body.

<span class="quote">&gt; Source/WebCore/platform/gtk/ScrollAnimatorGtk.cpp:55
&gt; +        updatePosition(FloatPoint(position));</span >

You should move the position, updatePosition(WTFMove(position));

<span class="quote">&gt; Source/WebCore/platform/gtk/ScrollAnimatorGtk.cpp:59
&gt; +#if ENABLE(SMOOTH_SCROLLING)
&gt; +        if (m_smoothAnimation)
&gt; +            m_smoothAnimation-&gt;setCurrentPosition(position);
&gt; +#endif</span >

Maybe updatePosition() should set the current position on both animations to keep everything in sync whenever the position is updated?

<span class="quote">&gt; Source/WebCore/platform/gtk/ScrollAnimatorGtk.cpp:111
&gt; +const FloatPoint ScrollAnimatorGtk::computeVelocity()</span >

Since we are returning a new FloatPoint, why making it const?

<span class="quote">&gt; Source/WebCore/platform/gtk/ScrollAnimatorGtk.cpp:131
&gt; +bool ScrollAnimatorGtk::handleWheelEvent(const PlatformWheelEvent&amp; e)</span >

e -&gt; event

<span class="quote">&gt; Source/WebCore/platform/gtk/ScrollAnimatorGtk.cpp:136
&gt; +        return e.timestamp() - event.timestamp() &gt; 150;</span >

Use a global static const for this 150 instead of magic number.

<span class="quote">&gt; Source/WebCore/platform/gtk/ScrollAnimatorGtk.h:58
&gt; +
&gt; +#if ENABLE(SMOOTH_SCROLLING)
&gt; +    void ensureSmoothScrollingAnimation();
&gt;  #endif
&gt; +    const FloatPoint computeVelocity();
&gt; +
&gt; +    void updatePosition(FloatPoint&amp;&amp;);</span >

Move this below after the virtual methods

<span class="quote">&gt; Source/WebCore/platform/gtk/ScrollAnimatorGtk.h:93
&gt; +    std::function&lt;void(FloatPoint&amp;&amp;)&gt; m_positionChangedCallback;</span >

What is this?

<span class="quote">&gt; Source/WebKit2/Shared/WebEvent.h:223
&gt; +    WebCore::FloatPoint swipeVelocity() const { return m_swipeVelocity; }</span >

This should return a const reference.

<span class="quote">&gt; Source/WebKit2/Shared/WebEventConversion.cpp:162
&gt; +        m_phase = static_cast&lt;WebCore::PlatformWheelEventPhase&gt;(webEvent.phase());</span >

We normally try to avoid casts to convert from/to enums, because it's very fragile in case any of the enum changes. Better use to/from conversion functions.

<span class="quote">&gt; Source/WebKit2/Shared/gtk/WebEventFactory.cpp:195
&gt; +#if GTK_CHECK_VERSION(3, 19, 7)</span >

Since 3.20 was already released, let's check for 3, 20, 0 better instead of using an unstable release number.

<span class="quote">&gt; Source/WebKit2/Shared/gtk/WebEventFactory.cpp:199
&gt; +#elif GTK_CHECK_VERSION(3, 3, 18)</span >

I think 3.6 is the minimum GTK+ version we support, so we don't need to check for 3.3 version.

<span class="quote">&gt; Source/WebKit2/UIProcess/WebPageProxy.cpp:1835
&gt; +#if PLATFORM(GTK)
&gt; +#if GTK_CHECK_VERSION(3, 19, 7)
&gt; +        bool isScrollStopEvent = gdk_event_is_scroll_stop_event(event.nativeEvent());
&gt; +#else
&gt; +        const GdkEventScroll&amp; scroll = event.nativeEvent()-&gt;scroll;
&gt; +        bool isScrollStopEvent = scroll.direction == GDK_SCROLL_SMOOTH &amp;&amp; scroll.delta_x &amp;&amp; scroll.delta_y;
&gt; +#endif
&gt; +        if (m_wheelEventQueue.size() &lt; wheelEventQueueSizeThreshold &amp;&amp; !isScrollStopEvent)
&gt; +            return;
&gt; +#else
&gt;          if (m_wheelEventQueue.size() &lt; wheelEventQueueSizeThreshold)
&gt;              return;
&gt; +#endif</span >

We need a better way to handle this than this ifdef mess here :-) We could have a method in the page client, for example, to check if a given wheel event should never be discarded, with this implementation in the GTK+ page client and returning false for all other ports.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>