Changeset 167560 in webkit


Ignore:
Timestamp:
Apr 19, 2014 7:32:48 PM (10 years ago)
Author:
Brent Fulgham
Message:

Latched scrolling may interact badly with custom programmatic scrolling
https://bugs.webkit.org/show_bug.cgi?id=131869
<rdar://problem/16249557>

Reviewed by Darin Adler.

  • dom/Element.cpp:

(WebCore::Element::setScrollLeft): Mark scrollable area as having
been scrolled programmatically.
(WebCore::Element::setScrollTop): Ditto.

  • page/EventHandler.cpp:

(WebCore::EventHandler::handleWheelEvent): Check for programmatic scroll, and
clear latched state if the handler manually scrolled. Clear programmatic
scroll state at the end of event handling.
(WebCore::EventHandler::clearLatchedState): Refactored code.

  • page/EventHandler.h:
  • page/mac/EventHandlerMac.mm:

(WebCore::EventHandler::platformPrepareForWheelEvents): Check
if scrollable area was scrolled programmatically. If it was, do
not honor latching behavior.

  • platform/ScrollableArea.cpp:

(WebCore::ScrollableArea::ScrollableArea): Initialize new member.

  • platform/ScrollableArea.h:

(WebCore::ScrollableArea::isScrolledProgrammatically): Added.
(WebCore::ScrollableArea::setScrolledProgrammatically): Added.

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r167559 r167560  
     12014-04-19  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Latched scrolling may interact badly with custom programmatic scrolling
     4        https://bugs.webkit.org/show_bug.cgi?id=131869
     5        <rdar://problem/16249557>
     6
     7        Reviewed by Darin Adler.
     8
     9        * dom/Element.cpp:
     10        (WebCore::Element::setScrollLeft): Mark scrollable area as having
     11        been scrolled programmatically.
     12        (WebCore::Element::setScrollTop): Ditto.
     13        * page/EventHandler.cpp:
     14        (WebCore::EventHandler::handleWheelEvent): Check for programmatic scroll, and
     15        clear latched state if the handler manually scrolled. Clear programmatic
     16        scroll state at the end of event handling.
     17        (WebCore::EventHandler::clearLatchedState): Refactored code.
     18        * page/EventHandler.h:
     19        * page/mac/EventHandlerMac.mm:
     20        (WebCore::EventHandler::platformPrepareForWheelEvents): Check
     21        if scrollable area was scrolled programmatically. If it was, do
     22        not honor latching behavior.
     23        * platform/ScrollableArea.cpp:
     24        (WebCore::ScrollableArea::ScrollableArea): Initialize new member.
     25        * platform/ScrollableArea.h:
     26        (WebCore::ScrollableArea::isScrolledProgrammatically): Added.
     27        (WebCore::ScrollableArea::setScrolledProgrammatically): Added.
     28
    1292014-04-19  Chris Fleizach  <cfleizach@apple.com>
    230
  • trunk/Source/WebCore/dom/Element.cpp

    r167545 r167560  
    6262#include "PlatformWheelEvent.h"
    6363#include "PointerLockController.h"
     64#include "RenderLayer.h"
    6465#include "RenderNamedFlowFragment.h"
    6566#include "RenderRegion.h"
     
    799800    document().updateLayoutIgnorePendingStylesheets();
    800801
    801     if (RenderBox* rend = renderBox())
    802         rend->setScrollLeft(static_cast<int>(newLeft * rend->style().effectiveZoom()));
     802    if (RenderBox* renderer = renderBox()) {
     803        renderer->setScrollLeft(static_cast<int>(newLeft * renderer->style().effectiveZoom()));
     804        if (auto* scrollableArea = renderer->layer())
     805            scrollableArea->setScrolledProgrammatically(true);
     806    }
    803807}
    804808
     
    807811    document().updateLayoutIgnorePendingStylesheets();
    808812
    809     if (RenderBox* rend = renderBox())
    810         rend->setScrollTop(static_cast<int>(newTop * rend->style().effectiveZoom()));
     813    if (RenderBox* renderer = renderBox()) {
     814        renderer->setScrollTop(static_cast<int>(newTop * renderer->style().effectiveZoom()));
     815        if (auto* scrollableArea = renderer->layer())
     816            scrollableArea->setScrolledProgrammatically(true);
     817    }
    811818}
    812819
  • trunk/Source/WebCore/page/EventHandler.cpp

    r167267 r167560  
    25942594            if (widget && passWheelEventToWidget(e, widget)) {
    25952595                m_isHandlingWheelEvent = false;
     2596                if (scrollableArea)
     2597                    scrollableArea->setScrolledProgrammatically(false);
    25962598                return true;
    25972599            }
     
    26002602        if (!element->dispatchWheelEvent(event)) {
    26012603            m_isHandlingWheelEvent = false;
     2604
     2605            if (scrollableArea && scrollableArea->isScrolledProgrammatically()) {
     2606                // Web developer is controlling scrolling. Don't attempt to latch ourselves:
     2607                clearLatchedState();
     2608                scrollableArea->setScrolledProgrammatically(false);
     2609            }
     2610
    26022611            return true;
    26032612        }
    26042613    }
    26052614
     2615    if (scrollableArea)
     2616        scrollableArea->setScrolledProgrammatically(false);
     2617
    26062618    return platformCompleteWheelEvent(e, scrollableContainer, scrollableArea);
     2619}
     2620
     2621void EventHandler::clearLatchedState()
     2622{
     2623    m_latchedWheelEventElement = nullptr;
     2624#if PLATFORM(COCOA)
     2625    m_latchedScrollableContainer = nullptr;
     2626#endif
     2627    m_widgetIsLatched = false;
     2628    m_previousWheelScrolledElement = nullptr;
    26072629}
    26082630
  • trunk/Source/WebCore/page/EventHandler.h

    r167267 r167560  
    437437#endif
    438438
     439    void clearLatchedState();
     440
    439441    Frame& m_frame;
    440442
  • trunk/Source/WebCore/page/mac/EventHandlerMac.mm

    r166965 r167560  
    800800        m_recentWheelEventDeltaTracker->beginTrackingDeltas();
    801801    } else if (wheelEvent.shouldResetLatching()) {
    802         m_latchedWheelEventElement = nullptr;
    803         m_latchedScrollableContainer = nullptr;
    804         m_widgetIsLatched = false;
    805         m_previousWheelScrolledElement = nullptr;
     802        clearLatchedState();
    806803        m_recentWheelEventDeltaTracker->endTrackingDeltas();
    807804    }
  • trunk/Source/WebCore/platform/ScrollableArea.cpp

    r165484 r167560  
    6060    , m_scrollbarOverlayStyle(ScrollbarOverlayStyleDefault)
    6161    , m_scrollOriginChanged(false)
     62    , m_scrolledProgrammatically(false)
    6263{
    6364}
  • trunk/Source/WebCore/platform/ScrollableArea.h

    r166630 r167560  
    157157    virtual bool scrolledToRight() const;
    158158
     159    bool isScrolledProgrammatically() const { return m_scrolledProgrammatically; }
     160    void setScrolledProgrammatically(bool state) { m_scrolledProgrammatically = state; }
     161
    159162    enum VisibleContentRectIncludesScrollbars { ExcludeScrollbars, IncludeScrollbars };
    160163    enum VisibleContentRectBehavior {
     
    293296
    294297    unsigned m_scrollOriginChanged : 1;
     298    unsigned m_scrolledProgrammatically : 1;
    295299};
    296300
  • trunk/WebKit.xcworkspace/xcshareddata/xcschemes/All Source (target WebProcess).xcscheme

    r166950 r167560  
    146146      launchStyle = "0"
    147147      useCustomWorkingDirectory = "NO"
    148       buildConfiguration = "Debug"
     148      buildConfiguration = "Release"
    149149      ignoresPersistentStateOnLaunch = "NO"
    150150      debugDocumentVersioning = "YES"
Note: See TracChangeset for help on using the changeset viewer.