- Revision
- 167560
- Author
- [email protected]
- Date
- 2014-04-19 19:32:48 -0700 (Sat, 19 Apr 2014)
Log 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.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (167559 => 167560)
--- trunk/Source/WebCore/ChangeLog 2014-04-20 01:38:48 UTC (rev 167559)
+++ trunk/Source/WebCore/ChangeLog 2014-04-20 02:32:48 UTC (rev 167560)
@@ -1,3 +1,31 @@
+2014-04-19 Brent Fulgham <[email protected]>
+
+ 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.
+
2014-04-19 Chris Fleizach <[email protected]>
AX: grid rows are not recognized do to lack of explicit role="row", role="gridcell"
Modified: trunk/Source/WebCore/dom/Element.cpp (167559 => 167560)
--- trunk/Source/WebCore/dom/Element.cpp 2014-04-20 01:38:48 UTC (rev 167559)
+++ trunk/Source/WebCore/dom/Element.cpp 2014-04-20 02:32:48 UTC (rev 167560)
@@ -61,6 +61,7 @@
#include "NodeRenderStyle.h"
#include "PlatformWheelEvent.h"
#include "PointerLockController.h"
+#include "RenderLayer.h"
#include "RenderNamedFlowFragment.h"
#include "RenderRegion.h"
#include "RenderTheme.h"
@@ -798,16 +799,22 @@
{
document().updateLayoutIgnorePendingStylesheets();
- if (RenderBox* rend = renderBox())
- rend->setScrollLeft(static_cast<int>(newLeft * rend->style().effectiveZoom()));
+ if (RenderBox* renderer = renderBox()) {
+ renderer->setScrollLeft(static_cast<int>(newLeft * renderer->style().effectiveZoom()));
+ if (auto* scrollableArea = renderer->layer())
+ scrollableArea->setScrolledProgrammatically(true);
+ }
}
void Element::setScrollTop(int newTop)
{
document().updateLayoutIgnorePendingStylesheets();
- if (RenderBox* rend = renderBox())
- rend->setScrollTop(static_cast<int>(newTop * rend->style().effectiveZoom()));
+ if (RenderBox* renderer = renderBox()) {
+ renderer->setScrollTop(static_cast<int>(newTop * renderer->style().effectiveZoom()));
+ if (auto* scrollableArea = renderer->layer())
+ scrollableArea->setScrolledProgrammatically(true);
+ }
}
int Element::scrollWidth()
Modified: trunk/Source/WebCore/page/EventHandler.cpp (167559 => 167560)
--- trunk/Source/WebCore/page/EventHandler.cpp 2014-04-20 01:38:48 UTC (rev 167559)
+++ trunk/Source/WebCore/page/EventHandler.cpp 2014-04-20 02:32:48 UTC (rev 167560)
@@ -2593,19 +2593,41 @@
Widget* widget = toRenderWidget(target)->widget();
if (widget && passWheelEventToWidget(e, widget)) {
m_isHandlingWheelEvent = false;
+ if (scrollableArea)
+ scrollableArea->setScrolledProgrammatically(false);
return true;
}
}
if (!element->dispatchWheelEvent(event)) {
m_isHandlingWheelEvent = false;
+
+ if (scrollableArea && scrollableArea->isScrolledProgrammatically()) {
+ // Web developer is controlling scrolling. Don't attempt to latch ourselves:
+ clearLatchedState();
+ scrollableArea->setScrolledProgrammatically(false);
+ }
+
return true;
}
}
+ if (scrollableArea)
+ scrollableArea->setScrolledProgrammatically(false);
+
return platformCompleteWheelEvent(e, scrollableContainer, scrollableArea);
}
+void EventHandler::clearLatchedState()
+{
+ m_latchedWheelEventElement = nullptr;
+#if PLATFORM(COCOA)
+ m_latchedScrollableContainer = nullptr;
+#endif
+ m_widgetIsLatched = false;
+ m_previousWheelScrolledElement = nullptr;
+}
+
void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEvent)
{
if (!startNode || !wheelEvent)
Modified: trunk/Source/WebCore/page/EventHandler.h (167559 => 167560)
--- trunk/Source/WebCore/page/EventHandler.h 2014-04-20 01:38:48 UTC (rev 167559)
+++ trunk/Source/WebCore/page/EventHandler.h 2014-04-20 02:32:48 UTC (rev 167560)
@@ -436,6 +436,8 @@
void autoHideCursorTimerFired(Timer<EventHandler>&);
#endif
+ void clearLatchedState();
+
Frame& m_frame;
bool m_mousePressed;
Modified: trunk/Source/WebCore/page/mac/EventHandlerMac.mm (167559 => 167560)
--- trunk/Source/WebCore/page/mac/EventHandlerMac.mm 2014-04-20 01:38:48 UTC (rev 167559)
+++ trunk/Source/WebCore/page/mac/EventHandlerMac.mm 2014-04-20 02:32:48 UTC (rev 167560)
@@ -799,10 +799,7 @@
isOverWidget = m_widgetIsLatched;
m_recentWheelEventDeltaTracker->beginTrackingDeltas();
} else if (wheelEvent.shouldResetLatching()) {
- m_latchedWheelEventElement = nullptr;
- m_latchedScrollableContainer = nullptr;
- m_widgetIsLatched = false;
- m_previousWheelScrolledElement = nullptr;
+ clearLatchedState();
m_recentWheelEventDeltaTracker->endTrackingDeltas();
}
Modified: trunk/Source/WebCore/platform/ScrollableArea.cpp (167559 => 167560)
--- trunk/Source/WebCore/platform/ScrollableArea.cpp 2014-04-20 01:38:48 UTC (rev 167559)
+++ trunk/Source/WebCore/platform/ScrollableArea.cpp 2014-04-20 02:32:48 UTC (rev 167560)
@@ -59,6 +59,7 @@
, m_horizontalScrollElasticity(ScrollElasticityNone)
, m_scrollbarOverlayStyle(ScrollbarOverlayStyleDefault)
, m_scrollOriginChanged(false)
+ , m_scrolledProgrammatically(false)
{
}
Modified: trunk/Source/WebCore/platform/ScrollableArea.h (167559 => 167560)
--- trunk/Source/WebCore/platform/ScrollableArea.h 2014-04-20 01:38:48 UTC (rev 167559)
+++ trunk/Source/WebCore/platform/ScrollableArea.h 2014-04-20 02:32:48 UTC (rev 167560)
@@ -156,6 +156,9 @@
virtual bool scrolledToLeft() const;
virtual bool scrolledToRight() const;
+ bool isScrolledProgrammatically() const { return m_scrolledProgrammatically; }
+ void setScrolledProgrammatically(bool state) { m_scrolledProgrammatically = state; }
+
enum VisibleContentRectIncludesScrollbars { ExcludeScrollbars, IncludeScrollbars };
enum VisibleContentRectBehavior {
ContentsVisibleRect,
@@ -292,6 +295,7 @@
unsigned m_scrollbarOverlayStyle : 2; // ScrollbarOverlayStyle
unsigned m_scrollOriginChanged : 1;
+ unsigned m_scrolledProgrammatically : 1;
};
} // namespace WebCore
Modified: trunk/WebKit.xcworkspace/xcshareddata/xcschemes/All Source (target WebProcess).xcscheme (167559 => 167560)
--- trunk/WebKit.xcworkspace/xcshareddata/xcschemes/All Source (target WebProcess).xcscheme 2014-04-20 01:38:48 UTC (rev 167559)
+++ trunk/WebKit.xcworkspace/xcshareddata/xcschemes/All Source (target WebProcess).xcscheme 2014-04-20 02:32:48 UTC (rev 167560)
@@ -145,7 +145,7 @@
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
- buildConfiguration = "Debug"
+ buildConfiguration = "Release"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">