Title: [109151] trunk/Source/WebCore
- Revision
- 109151
- Author
- [email protected]
- Date
- 2012-02-28 14:26:24 -0800 (Tue, 28 Feb 2012)
Log Message
Slow content causes choppy scrolling
https://bugs.webkit.org/show_bug.cgi?id=79403
Patch by Dave Moore <[email protected]> on 2012-02-28
Reviewed by James Robinson.
This code helps make scrolling (via wheel or pad) less choppy
when the content takes a long time to respond to the fake mouse moves
generated during scrolls.
* page/EventHandler.cpp:
(WebCore):
(MaximumDurationTracker):
(WebCore::MaximumDurationTracker::MaximumDurationTracker):
(WebCore::MaximumDurationTracker::~MaximumDurationTracker):
(WebCore::EventHandler::EventHandler):
(WebCore::EventHandler::clear):
(WebCore::EventHandler::mouseMoved):
(WebCore::EventHandler::dispatchFakeMouseMoveEventSoon):
(WebCore::EventHandler::dispatchFakeMouseMoveEventSoonInQuad):
* page/EventHandler.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (109150 => 109151)
--- trunk/Source/WebCore/ChangeLog 2012-02-28 22:23:13 UTC (rev 109150)
+++ trunk/Source/WebCore/ChangeLog 2012-02-28 22:26:24 UTC (rev 109151)
@@ -1,3 +1,27 @@
+2012-02-28 Dave Moore <[email protected]>
+
+ Slow content causes choppy scrolling
+ https://bugs.webkit.org/show_bug.cgi?id=79403
+
+ Reviewed by James Robinson.
+
+ This code helps make scrolling (via wheel or pad) less choppy
+ when the content takes a long time to respond to the fake mouse moves
+ generated during scrolls.
+
+
+ * page/EventHandler.cpp:
+ (WebCore):
+ (MaximumDurationTracker):
+ (WebCore::MaximumDurationTracker::MaximumDurationTracker):
+ (WebCore::MaximumDurationTracker::~MaximumDurationTracker):
+ (WebCore::EventHandler::EventHandler):
+ (WebCore::EventHandler::clear):
+ (WebCore::EventHandler::mouseMoved):
+ (WebCore::EventHandler::dispatchFakeMouseMoveEventSoon):
+ (WebCore::EventHandler::dispatchFakeMouseMoveEventSoonInQuad):
+ * page/EventHandler.h:
+
2012-02-28 Andreas Kling <[email protected]>
StyledElement::isPresentationAttribute() only needs the attribute name.
Modified: trunk/Source/WebCore/page/EventHandler.cpp (109150 => 109151)
--- trunk/Source/WebCore/page/EventHandler.cpp 2012-02-28 22:23:13 UTC (rev 109150)
+++ trunk/Source/WebCore/page/EventHandler.cpp 2012-02-28 22:26:24 UTC (rev 109151)
@@ -126,7 +126,11 @@
// When the autoscroll or the panScroll is triggered when do the scroll every 0.05s to make it smooth
const double autoscrollInterval = 0.05;
-const double fakeMouseMoveInterval = 0.1;
+// The amount of time to wait before sending a fake mouse event, triggered
+// during a scroll. The short interval is used if the content responds to the mouse events quickly enough,
+// otherwise the long interval is used.
+const double fakeMouseMoveShortInterval = 0.1;
+const double fakeMouseMoveLongInterval = 0.250;
enum NoCursorChangeType { NoCursorChange };
@@ -143,6 +147,24 @@
Cursor m_cursor;
};
+class MaximumDurationTracker {
+public:
+ explicit MaximumDurationTracker(double *maxDuration)
+ : m_maxDuration(maxDuration)
+ , m_start(monotonicallyIncreasingTime())
+ {
+ }
+
+ ~MaximumDurationTracker()
+ {
+ *m_maxDuration = max(*m_maxDuration, monotonicallyIncreasingTime() - m_start);
+ }
+
+private:
+ double* m_maxDuration;
+ double m_start;
+};
+
#if ENABLE(TOUCH_EVENTS)
class SyntheticTouchPoint : public PlatformTouchPoint {
public:
@@ -289,6 +311,7 @@
#if ENABLE(TOUCH_EVENTS)
, m_touchPressed(false)
#endif
+ , m_maxMouseMovedDuration(0)
{
}
@@ -335,6 +358,7 @@
#if ENABLE(TOUCH_EVENTS)
m_originatingTouchPointTargets.clear();
#endif
+ m_maxMouseMovedDuration = 0;
}
void EventHandler::nodeWillBeRemoved(Node* nodeToBeRemoved)
@@ -1635,8 +1659,10 @@
bool EventHandler::mouseMoved(const PlatformMouseEvent& event)
{
+ MaximumDurationTracker maxDurationTracker(&m_maxMouseMovedDuration);
RefPtr<FrameView> protector(m_frame->view());
+
#if ENABLE(TOUCH_EVENTS)
// FIXME: this should be moved elsewhere to also be able to dispatch touchcancel events.
bool defaultPrevented = dispatchSyntheticTouchEventIfEnabled(event);
@@ -2499,8 +2525,18 @@
if (m_mousePressed)
return;
- if (!m_fakeMouseMoveEventTimer.isActive())
- m_fakeMouseMoveEventTimer.startOneShot(fakeMouseMoveInterval);
+ // If the content has ever taken longer than fakeMouseMoveShortInterval we
+ // reschedule the timer and use a longer time. This will cause the content
+ // to receive these moves only after the user is done scrolling, reducing
+ // pauses during the scroll.
+ if (m_maxMouseMovedDuration > fakeMouseMoveShortInterval) {
+ if (m_fakeMouseMoveEventTimer.isActive())
+ m_fakeMouseMoveEventTimer.stop();
+ m_fakeMouseMoveEventTimer.startOneShot(fakeMouseMoveLongInterval);
+ } else {
+ if (!m_fakeMouseMoveEventTimer.isActive())
+ m_fakeMouseMoveEventTimer.startOneShot(fakeMouseMoveShortInterval);
+ }
}
void EventHandler::dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad& quad)
@@ -2509,11 +2545,10 @@
if (!view)
return;
- if (m_mousePressed || !quad.containsPoint(view->windowToContents(m_currentMousePosition)))
+ if (!quad.containsPoint(view->windowToContents(m_currentMousePosition)))
return;
- if (!m_fakeMouseMoveEventTimer.isActive())
- m_fakeMouseMoveEventTimer.startOneShot(fakeMouseMoveInterval);
+ dispatchFakeMouseMoveEventSoon();
}
void EventHandler::cancelFakeMouseMoveEvent()
Modified: trunk/Source/WebCore/page/EventHandler.h (109150 => 109151)
--- trunk/Source/WebCore/page/EventHandler.h 2012-02-28 22:23:13 UTC (rev 109150)
+++ trunk/Source/WebCore/page/EventHandler.h 2012-02-28 22:26:24 UTC (rev 109151)
@@ -431,6 +431,7 @@
TouchTargetMap m_originatingTouchPointTargets;
bool m_touchPressed;
#endif
+ double m_maxMouseMovedDuration;
};
} // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes