Diff
Modified: trunk/Source/WebCore/ChangeLog (96560 => 96561)
--- trunk/Source/WebCore/ChangeLog 2011-10-04 00:23:56 UTC (rev 96560)
+++ trunk/Source/WebCore/ChangeLog 2011-10-04 00:29:13 UTC (rev 96561)
@@ -1,3 +1,55 @@
+2011-10-03 Anders Carlsson <[email protected]>
+
+ Work towards making PlatformWheelEvent immutable
+ https://bugs.webkit.org/show_bug.cgi?id=69306
+
+ Reviewed by Sam Weinig.
+
+ Currently, PlatformWheelEvent has an m_isAccepted flag that tracks whether
+ the event has been handled or not. For all other event types, that state is instead
+ tracked by the return value of the various event handlers.
+
+ As a first step, add return values to the various handleWheelEvent functions and
+ add an assertion in EventHandler::wheelEvent that the return value is the same as
+ the state of PlatformWheelEvent::isAccepted.
+
+ * Configurations/Base.xcconfig:
+ Don't warn when using C++11 extensions.
+
+ * page/mac/EventHandlerMac.mm:
+ (WebCore::EventHandler::wheelEvent):
+ Assert that isAccepted matches the return value.
+
+ * platform/ScrollAnimator.cpp:
+ (WebCore::ScrollAnimator::handleWheelEvent):
+ Return isAccepted.
+
+ * platform/ScrollAnimator.h:
+ HandleWheelEvent now returns a boolean.
+
+ * platform/ScrollView.cpp:
+ (WebCore::ScrollView::wheelEvent):
+ Return whether the event was handled or not.
+
+ * platform/ScrollView.h:
+ ScrollView::wheelEvent now returns a bool.
+
+ * platform/ScrollableArea.cpp:
+ (WebCore::ScrollableArea::handleWheelEvent):
+ * platform/ScrollableArea.h:
+ ScrollableArea::handleWheelEvent now returns a bool.
+
+ * platform/chromium/ScrollAnimatorChromiumMac.h:
+ * platform/chromium/ScrollAnimatorChromiumMac.mm:
+ (WebCore::ScrollAnimatorChromiumMac::handleWheelEvent):
+ Add return values, based on either the base class calls or the state of
+ PlatformWheelEvent::isAccepted().
+
+ * platform/mac/ScrollAnimatorMac.h:
+ * platform/mac/ScrollAnimatorMac.mm:
+ (WebCore::ScrollAnimatorMac::handleWheelEvent):
+ Ditto.
+
2011-10-03 Dan Bernstein <[email protected]>
<rdar://problem/9973489> REGRESSION (r66599): -[DOMNode boundingBox] returns the zero rect for SVG elements
Modified: trunk/Source/WebCore/Configurations/Base.xcconfig (96560 => 96561)
--- trunk/Source/WebCore/Configurations/Base.xcconfig 2011-10-04 00:23:56 UTC (rev 96560)
+++ trunk/Source/WebCore/Configurations/Base.xcconfig 2011-10-04 00:29:13 UTC (rev 96561)
@@ -23,6 +23,7 @@
#include "CompilerVersion.xcconfig"
+CLANG_WARN_CXX0X_EXTENSIONS = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DEBUGGING_SYMBOLS = default;
Modified: trunk/Source/WebCore/page/mac/EventHandlerMac.mm (96560 => 96561)
--- trunk/Source/WebCore/page/mac/EventHandlerMac.mm 2011-10-04 00:23:56 UTC (rev 96560)
+++ trunk/Source/WebCore/page/mac/EventHandlerMac.mm 2011-10-04 00:29:13 UTC (rev 96561)
@@ -106,8 +106,9 @@
CurrentEventScope scope(event);
PlatformWheelEvent wheelEvent(event, page->chrome()->platformPageClient());
- handleWheelEvent(wheelEvent);
+ bool handled = handleWheelEvent(wheelEvent);
+ ASSERT(handled == wheelEvent.isAccepted());
return wheelEvent.isAccepted();
}
Modified: trunk/Source/WebCore/platform/ScrollAnimator.cpp (96560 => 96561)
--- trunk/Source/WebCore/platform/ScrollAnimator.cpp 2011-10-04 00:23:56 UTC (rev 96560)
+++ trunk/Source/WebCore/platform/ScrollAnimator.cpp 2011-10-04 00:29:13 UTC (rev 96561)
@@ -81,7 +81,7 @@
}
}
-void ScrollAnimator::handleWheelEvent(PlatformWheelEvent& e)
+bool ScrollAnimator::handleWheelEvent(PlatformWheelEvent& e)
{
Scrollbar* horizontalScrollbar = m_scrollableArea->horizontalScrollbar();
Scrollbar* verticalScrollbar = m_scrollableArea->verticalScrollbar();
@@ -111,6 +111,8 @@
if (deltaX)
scroll(HorizontalScrollbar, ScrollByPixel, horizontalScrollbar->pixelStep(), -deltaX);
}
+
+ return e.isAccepted();
}
#if ENABLE(GESTURE_EVENTS)
Modified: trunk/Source/WebCore/platform/ScrollAnimator.h (96560 => 96561)
--- trunk/Source/WebCore/platform/ScrollAnimator.h 2011-10-04 00:23:56 UTC (rev 96560)
+++ trunk/Source/WebCore/platform/ScrollAnimator.h 2011-10-04 00:29:13 UTC (rev 96561)
@@ -63,7 +63,7 @@
virtual void setIsActive() { }
- virtual void handleWheelEvent(PlatformWheelEvent&);
+ virtual bool handleWheelEvent(PlatformWheelEvent&);
#if ENABLE(GESTURE_EVENTS)
virtual void handleGestureEvent(const PlatformGestureEvent&);
#endif
Modified: trunk/Source/WebCore/platform/ScrollView.cpp (96560 => 96561)
--- trunk/Source/WebCore/platform/ScrollView.cpp 2011-10-04 00:23:56 UTC (rev 96560)
+++ trunk/Source/WebCore/platform/ScrollView.cpp 2011-10-04 00:29:13 UTC (rev 96561)
@@ -797,7 +797,7 @@
platformSetScrollbarOverlayStyle(overlayStyle);
}
-void ScrollView::wheelEvent(PlatformWheelEvent& e)
+bool ScrollView::wheelEvent(PlatformWheelEvent& e)
{
// We don't allow mouse wheeling to happen in a ScrollView that has had its scrollbars explicitly disabled.
#if PLATFORM(WX)
@@ -805,10 +805,10 @@
#else
if (!canHaveScrollbars() || platformWidget()) {
#endif
- return;
+ return false;
}
- ScrollableArea::handleWheelEvent(e);
+ return ScrollableArea::handleWheelEvent(e);
}
#if ENABLE(GESTURE_EVENTS)
Modified: trunk/Source/WebCore/platform/ScrollView.h (96560 => 96561)
--- trunk/Source/WebCore/platform/ScrollView.h 2011-10-04 00:23:56 UTC (rev 96560)
+++ trunk/Source/WebCore/platform/ScrollView.h 2011-10-04 00:29:13 UTC (rev 96561)
@@ -234,7 +234,7 @@
// This function exists for scrollviews that need to handle wheel events manually.
// On Mac the underlying NSScrollView just does the scrolling, but on other platforms
// (like Windows), we need this function in order to do the scroll ourselves.
- void wheelEvent(PlatformWheelEvent&);
+ bool wheelEvent(PlatformWheelEvent&);
#if ENABLE(GESTURE_EVENTS)
void gestureEvent(const PlatformGestureEvent&);
#endif
Modified: trunk/Source/WebCore/platform/ScrollableArea.cpp (96560 => 96561)
--- trunk/Source/WebCore/platform/ScrollableArea.cpp 2011-10-04 00:23:56 UTC (rev 96560)
+++ trunk/Source/WebCore/platform/ScrollableArea.cpp 2011-10-04 00:29:13 UTC (rev 96561)
@@ -123,9 +123,9 @@
scrollToOffsetWithoutAnimation(FloatPoint(scrollAnimator()->currentPosition().x(), y));
}
-void ScrollableArea::handleWheelEvent(PlatformWheelEvent& wheelEvent)
+bool ScrollableArea::handleWheelEvent(PlatformWheelEvent& wheelEvent)
{
- scrollAnimator()->handleWheelEvent(wheelEvent);
+ return scrollAnimator()->handleWheelEvent(wheelEvent);
}
#if ENABLE(GESTURE_EVENTS)
Modified: trunk/Source/WebCore/platform/ScrollableArea.h (96560 => 96561)
--- trunk/Source/WebCore/platform/ScrollableArea.h 2011-10-04 00:23:56 UTC (rev 96560)
+++ trunk/Source/WebCore/platform/ScrollableArea.h 2011-10-04 00:29:13 UTC (rev 96561)
@@ -52,7 +52,7 @@
void scrollToXOffsetWithoutAnimation(float x);
void scrollToYOffsetWithoutAnimation(float x);
- void handleWheelEvent(PlatformWheelEvent&);
+ bool handleWheelEvent(PlatformWheelEvent&);
#if ENABLE(GESTURE_EVENTS)
void handleGestureEvent(const PlatformGestureEvent&);
#endif
Modified: trunk/Source/WebCore/platform/chromium/ScrollAnimatorChromiumMac.h (96560 => 96561)
--- trunk/Source/WebCore/platform/chromium/ScrollAnimatorChromiumMac.h 2011-10-04 00:23:56 UTC (rev 96560)
+++ trunk/Source/WebCore/platform/chromium/ScrollAnimatorChromiumMac.h 2011-10-04 00:29:13 UTC (rev 96561)
@@ -59,7 +59,7 @@
virtual void scrollToOffsetWithoutAnimation(const FloatPoint&);
#if ENABLE(RUBBER_BANDING)
- virtual void handleWheelEvent(PlatformWheelEvent&);
+ virtual bool handleWheelEvent(PlatformWheelEvent&) OVERRIDE;
#if ENABLE(GESTURE_EVENTS)
virtual void handleGestureEvent(const PlatformGestureEvent&);
#endif
Modified: trunk/Source/WebCore/platform/chromium/ScrollAnimatorChromiumMac.mm (96560 => 96561)
--- trunk/Source/WebCore/platform/chromium/ScrollAnimatorChromiumMac.mm 2011-10-04 00:23:56 UTC (rev 96560)
+++ trunk/Source/WebCore/platform/chromium/ScrollAnimatorChromiumMac.mm 2011-10-04 00:29:13 UTC (rev 96561)
@@ -781,29 +781,23 @@
return wheelEvent.deltaX() < 0 && !scrollableArea->shouldRubberBandInDirection(ScrollRight);
}
-void ScrollAnimatorChromiumMac::handleWheelEvent(PlatformWheelEvent& wheelEvent)
+bool ScrollAnimatorChromiumMac::handleWheelEvent(PlatformWheelEvent& wheelEvent)
{
m_haveScrolledSincePageLoad = true;
- if (!wheelEvent.hasPreciseScrollingDeltas()) {
- ScrollAnimator::handleWheelEvent(wheelEvent);
- return;
- }
+ if (!wheelEvent.hasPreciseScrollingDeltas())
+ return ScrollAnimator::handleWheelEvent(wheelEvent);
// FIXME: This is somewhat roundabout hack to allow forwarding wheel events
// up to the parent scrollable area. It takes advantage of the fact that
// the base class implemenatation of handleWheelEvent will not accept the
// wheel event if there is nowhere to scroll.
if (fabsf(wheelEvent.deltaY()) >= fabsf(wheelEvent.deltaX())) {
- if (!allowsVerticalStretching()) {
- ScrollAnimator::handleWheelEvent(wheelEvent);
- return;
- }
+ if (!allowsVerticalStretching())
+ return ScrollAnimator::handleWheelEvent(wheelEvent);
} else {
- if (!allowsHorizontalStretching()) {
- ScrollAnimator::handleWheelEvent(wheelEvent);
- return;
- }
+ if (!allowsHorizontalStretching())
+ return ScrollAnimator::handleWheelEvent(wheelEvent);
if (m_scrollableArea->horizontalScrollbar()) {
// If there is a scrollbar, we aggregate the wheel events to get an
@@ -829,8 +823,7 @@
(isScrollingRightAndShouldNotRubberBand(wheelEvent, m_scrollableArea) &&
m_scrollerInitiallyPinnedOnRight &&
m_scrollableArea->isHorizontalScrollerPinnedToMaximumPosition())) {
- ScrollAnimator::handleWheelEvent(wheelEvent);
- return;
+ return ScrollAnimator::handleWheelEvent(wheelEvent);
}
}
}
@@ -840,12 +833,14 @@
if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseEnded) {
m_ignoreMomentumScrolls = false;
wheelEvent.accept();
+ return true;
}
- return;
+ return false;
}
wheelEvent.accept();
smoothScrollWithEvent(wheelEvent);
+ return true;
}
void ScrollAnimatorChromiumMac::handleGestureEvent(const PlatformGestureEvent& gestureEvent)
Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h (96560 => 96561)
--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h 2011-10-04 00:23:56 UTC (rev 96560)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h 2011-10-04 00:29:13 UTC (rev 96561)
@@ -62,7 +62,7 @@
virtual void scrollToOffsetWithoutAnimation(const FloatPoint&);
#if ENABLE(RUBBER_BANDING)
- virtual void handleWheelEvent(PlatformWheelEvent&);
+ virtual bool handleWheelEvent(PlatformWheelEvent&) OVERRIDE;
#if ENABLE(GESTURE_EVENTS)
virtual void handleGestureEvent(const PlatformGestureEvent&);
#endif
Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm (96560 => 96561)
--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm 2011-10-04 00:23:56 UTC (rev 96560)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm 2011-10-04 00:29:13 UTC (rev 96561)
@@ -792,29 +792,24 @@
return wheelEvent.deltaX() < 0 && !scrollableArea->shouldRubberBandInDirection(ScrollRight);
}
-void ScrollAnimatorMac::handleWheelEvent(PlatformWheelEvent& wheelEvent)
+bool ScrollAnimatorMac::handleWheelEvent(PlatformWheelEvent& wheelEvent)
{
m_haveScrolledSincePageLoad = true;
if (!wheelEvent.hasPreciseScrollingDeltas()) {
- ScrollAnimator::handleWheelEvent(wheelEvent);
- return;
+ return ScrollAnimator::handleWheelEvent(wheelEvent);
}
// FIXME: This is somewhat roundabout hack to allow forwarding wheel events
// up to the parent scrollable area. It takes advantage of the fact that
- // the base class implemenatation of handleWheelEvent will not accept the
+ // the base class implementation of handleWheelEvent will not accept the
// wheel event if there is nowhere to scroll.
if (fabsf(wheelEvent.deltaY()) >= fabsf(wheelEvent.deltaX())) {
- if (!allowsVerticalStretching()) {
- ScrollAnimator::handleWheelEvent(wheelEvent);
- return;
- }
+ if (!allowsVerticalStretching())
+ return ScrollAnimator::handleWheelEvent(wheelEvent);
} else {
- if (!allowsHorizontalStretching()) {
- ScrollAnimator::handleWheelEvent(wheelEvent);
- return;
- }
+ if (!allowsHorizontalStretching())
+ return ScrollAnimator::handleWheelEvent(wheelEvent);
if (m_scrollableArea->horizontalScrollbar()) {
// If there is a scrollbar, we aggregate the wheel events to get an
@@ -840,8 +835,7 @@
(isScrollingRightAndShouldNotRubberBand(wheelEvent, m_scrollableArea) &&
m_scrollerInitiallyPinnedOnRight &&
m_scrollableArea->isHorizontalScrollerPinnedToMaximumPosition())) {
- ScrollAnimator::handleWheelEvent(wheelEvent);
- return;
+ return ScrollAnimator::handleWheelEvent(wheelEvent);
}
}
}
@@ -851,12 +845,14 @@
if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseEnded) {
m_ignoreMomentumScrolls = false;
wheelEvent.accept();
+ return true;
}
- return;
+ return false;
}
wheelEvent.accept();
smoothScrollWithEvent(wheelEvent);
+ return true;
}
void ScrollAnimatorMac::handleGestureEvent(const PlatformGestureEvent& gestureEvent)