Diff
Modified: trunk/Source/WebCore/ChangeLog (196631 => 196632)
--- trunk/Source/WebCore/ChangeLog 2016-02-16 09:45:41 UTC (rev 196631)
+++ trunk/Source/WebCore/ChangeLog 2016-02-16 09:50:26 UTC (rev 196632)
@@ -1,5 +1,46 @@
2016-02-16 Carlos Garcia Campos <[email protected]>
+ [GTK] clicking on the scrollbar trough steps rather than jumps to the clicked position
+ https://bugs.webkit.org/show_bug.cgi?id=115363
+
+ Reviewed by Michael Catanzaro.
+
+ Allow ScrollbarTheme to decide the behavior of a button press event,
+ instead of only deciding whether to center on thumb or not. This
+ way we can match the current GTK+ behavior in WebKit, without
+ affecting other ports.
+
+ * platform/ScrollTypes.h: Add ScrollbarButtonPressAction enum.
+ * platform/Scrollbar.cpp:
+ (WebCore::Scrollbar::mouseDown): Ask ScrollbarTheme to handle the
+ event for the pressed part and do the requested action.
+ * platform/ScrollbarTheme.cpp:
+ (WebCore::ScrollbarTheme::handleMousePressEvent): Add default
+ implementation. It's equivalent to the previous default implementation.
+ * platform/ScrollbarTheme.h:
+ * platform/gtk/ScrollbarThemeGtk.cpp:
+ (WebCore::ScrollbarThemeGtk::handleMousePressEvent): Match current
+ GTK+ behavior: left click centers on thumb and right click
+ scrolls. Dragging the thumb works for left and middle buttons.
+ * platform/gtk/ScrollbarThemeGtk.h:
+ * platform/ios/ScrollbarThemeIOS.h: Remove shouldCenterOnThumb,
+ and don't override handleMousePressEvent since iOS wants the
+ default behavior.
+ * platform/ios/ScrollbarThemeIOS.mm:
+ * platform/mac/ScrollbarThemeMac.h: Override handleMousePressEvent
+ and remove shouldCenterOnThumb.
+ * platform/mac/ScrollbarThemeMac.mm:
+ (WebCore::shouldCenterOnThumb): Same implementation just made it
+ static to be used as helper.
+ (WebCore::ScrollbarThemeMac::handleMousePressEvent): Return the
+ desired action keeping the same behavior.
+ * platform/win/ScrollbarThemeWin.cpp:
+ (WebCore::ScrollbarThemeWin::handleMousePressEvent): Ditto.
+ * platform/win/ScrollbarThemeWin.h:
+ * rendering/RenderScrollbarTheme.h:
+
+2016-02-16 Carlos Garcia Campos <[email protected]>
+
Mouse cursor doesn't change when entering scrollbars
https://bugs.webkit.org/show_bug.cgi?id=154243
Modified: trunk/Source/WebCore/platform/ScrollTypes.h (196631 => 196632)
--- trunk/Source/WebCore/platform/ScrollTypes.h 2016-02-16 09:45:41 UTC (rev 196631)
+++ trunk/Source/WebCore/platform/ScrollTypes.h 2016-02-16 09:50:26 UTC (rev 196632)
@@ -180,6 +180,13 @@
StickToViewportBounds
};
+enum class ScrollbarButtonPressAction {
+ None,
+ CenterOnThumb,
+ StartDrag,
+ Scroll
+};
+
}
#endif
Modified: trunk/Source/WebCore/platform/Scrollbar.cpp (196631 => 196632)
--- trunk/Source/WebCore/platform/Scrollbar.cpp 2016-02-16 09:45:41 UTC (rev 196631)
+++ trunk/Source/WebCore/platform/Scrollbar.cpp 2016-02-16 09:50:26 UTC (rev 196632)
@@ -391,31 +391,34 @@
bool Scrollbar::mouseDown(const PlatformMouseEvent& evt)
{
- // Early exit for right click
- if (evt.button() == RightButton)
- return true; // FIXME: Handled as context menu by Qt right now. Should just avoid even calling this method on a right click though.
+ ScrollbarPart pressedPart = theme().hitTest(*this, evt.position());
+ auto action = "" evt, pressedPart);
+ if (action == ScrollbarButtonPressAction::None)
+ return true;
m_scrollableArea.mouseIsDownInScrollbar(this, true);
- setPressedPart(theme().hitTest(*this, evt.position()));
- int pressedPos = (orientation() == HorizontalScrollbar ? convertFromContainingWindow(evt.position()).x() : convertFromContainingWindow(evt.position()).y());
-
- if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && theme().shouldCenterOnThumb(*this, evt)) {
+ setPressedPart(pressedPart);
+
+ int pressedPosition = (orientation() == HorizontalScrollbar ? convertFromContainingWindow(evt.position()).x() : convertFromContainingWindow(evt.position()).y());
+ if (action == ScrollbarButtonPressAction::CenterOnThumb) {
setHoveredPart(ThumbPart);
setPressedPart(ThumbPart);
m_dragOrigin = m_currentPos;
- int thumbLen = theme().thumbLength(*this);
- int desiredPos = pressedPos;
// Set the pressed position to the middle of the thumb so that when we do the move, the delta
// will be from the current pixel position of the thumb to the new desired position for the thumb.
- m_pressedPos = theme().trackPosition(*this) + theme().thumbPosition(*this) + thumbLen / 2;
- moveThumb(desiredPos);
+ m_pressedPos = theme().trackPosition(*this) + theme().thumbPosition(*this) + theme().thumbLength(*this) / 2;
+ moveThumb(pressedPosition);
return true;
- } else if (m_pressedPart == ThumbPart)
+ }
+
+ m_pressedPos = pressedPosition;
+
+ if (action == ScrollbarButtonPressAction::StartDrag)
m_dragOrigin = m_currentPos;
-
- m_pressedPos = pressedPos;
- autoscrollPressedPart(theme().initialAutoscrollTimerDelay());
+ if (action == ScrollbarButtonPressAction::Scroll)
+ autoscrollPressedPart(theme().initialAutoscrollTimerDelay());
+
return true;
}
Modified: trunk/Source/WebCore/platform/ScrollbarTheme.cpp (196631 => 196632)
--- trunk/Source/WebCore/platform/ScrollbarTheme.cpp 2016-02-16 09:45:41 UTC (rev 196631)
+++ trunk/Source/WebCore/platform/ScrollbarTheme.cpp 2016-02-16 09:50:26 UTC (rev 196632)
@@ -26,6 +26,7 @@
#include "config.h"
#include "ScrollbarTheme.h"
+#include "PlatformMouseEvent.h"
#include "ScrollbarThemeMock.h"
#include "Settings.h"
#include <wtf/NeverDestroyed.h>
@@ -41,4 +42,13 @@
return nativeTheme();
}
+ScrollbarButtonPressAction ScrollbarTheme::handleMousePressEvent(Scrollbar&, const PlatformMouseEvent& event, ScrollbarPart pressedPart)
+{
+ if (event.button() == RightButton)
+ return ScrollbarButtonPressAction::None;
+ if (pressedPart == ThumbPart)
+ return ScrollbarButtonPressAction::StartDrag;
+ return ScrollbarButtonPressAction::Scroll;
}
+
+}
Modified: trunk/Source/WebCore/platform/ScrollbarTheme.h (196631 => 196632)
--- trunk/Source/WebCore/platform/ScrollbarTheme.h 2016-02-16 09:45:41 UTC (rev 196631)
+++ trunk/Source/WebCore/platform/ScrollbarTheme.h 2016-02-16 09:50:26 UTC (rev 196632)
@@ -95,7 +95,7 @@
virtual void setUpContentShadowLayer(GraphicsLayer*) { }
#endif
- virtual bool shouldCenterOnThumb(Scrollbar&, const PlatformMouseEvent&) { return false; }
+ virtual ScrollbarButtonPressAction handleMousePressEvent(Scrollbar&, const PlatformMouseEvent&, ScrollbarPart);
virtual bool shouldSnapBackToDragOrigin(Scrollbar&, const PlatformMouseEvent&) { return false; }
virtual bool shouldDragDocumentInsteadOfThumb(Scrollbar&, const PlatformMouseEvent&) { return false; }
virtual int thumbPosition(Scrollbar&) { return 0; } // The position of the thumb relative to the track.
Modified: trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp (196631 => 196632)
--- trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp 2016-02-16 09:45:41 UTC (rev 196631)
+++ trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp 2016-02-16 09:50:26 UTC (rev 196632)
@@ -493,9 +493,25 @@
return true;
}
-bool ScrollbarThemeGtk::shouldCenterOnThumb(Scrollbar&, const PlatformMouseEvent& event)
+ScrollbarButtonPressAction ScrollbarThemeGtk::handleMousePressEvent(Scrollbar&, const PlatformMouseEvent& event, ScrollbarPart pressedPart)
{
- return (event.shiftKey() && event.button() == LeftButton) || (event.button() == MiddleButton);
+ switch (pressedPart) {
+ case BackTrackPart:
+ case ForwardTrackPart:
+ if (event.button() == LeftButton)
+ return ScrollbarButtonPressAction::CenterOnThumb;
+ if (event.button() == RightButton)
+ return ScrollbarButtonPressAction::Scroll;
+ break;
+ case ThumbPart:
+ if (event.button() != RightButton)
+ return ScrollbarButtonPressAction::StartDrag;
+ break;
+ default:
+ break;
+ }
+
+ return ScrollbarButtonPressAction::None;
}
int ScrollbarThemeGtk::scrollbarThickness(ScrollbarControlSize)
Modified: trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.h (196631 => 196632)
--- trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.h 2016-02-16 09:45:41 UTC (rev 196631)
+++ trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.h 2016-02-16 09:50:26 UTC (rev 196632)
@@ -53,7 +53,7 @@
virtual void paintTrackBackground(GraphicsContext&, Scrollbar&, const IntRect&) override;
virtual void paintThumb(GraphicsContext&, Scrollbar&, const IntRect&) override;
virtual void paintButton(GraphicsContext&, Scrollbar&, const IntRect&, ScrollbarPart) override;
- virtual bool shouldCenterOnThumb(Scrollbar&, const PlatformMouseEvent&) override;
+ virtual ScrollbarButtonPressAction handleMousePressEvent(Scrollbar&, const PlatformMouseEvent&, ScrollbarPart) override;
virtual int scrollbarThickness(ScrollbarControlSize) override;
virtual int minimumThumbLength(Scrollbar&) override;
Modified: trunk/Source/WebCore/platform/ios/ScrollbarThemeIOS.h (196631 => 196632)
--- trunk/Source/WebCore/platform/ios/ScrollbarThemeIOS.h 2016-02-16 09:45:41 UTC (rev 196631)
+++ trunk/Source/WebCore/platform/ios/ScrollbarThemeIOS.h 2016-02-16 09:50:26 UTC (rev 196632)
@@ -58,9 +58,7 @@
virtual IntRect trackRect(Scrollbar&, bool painting = false) override;
virtual int minimumThumbLength(Scrollbar&) override;
-
- virtual bool shouldCenterOnThumb(Scrollbar&, const PlatformMouseEvent&) override;
-
+
public:
void preferencesChanged();
};
Modified: trunk/Source/WebCore/platform/ios/ScrollbarThemeIOS.mm (196631 => 196632)
--- trunk/Source/WebCore/platform/ios/ScrollbarThemeIOS.mm 2016-02-16 09:45:41 UTC (rev 196631)
+++ trunk/Source/WebCore/platform/ios/ScrollbarThemeIOS.mm 2016-02-16 09:50:26 UTC (rev 196632)
@@ -111,11 +111,6 @@
return 0;
}
-bool ScrollbarThemeIOS::shouldCenterOnThumb(Scrollbar&, const PlatformMouseEvent&)
-{
- return false;
-}
-
bool ScrollbarThemeIOS::paint(Scrollbar&, GraphicsContext&, const IntRect& /*damageRect*/)
{
return true;
Modified: trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.h (196631 => 196632)
--- trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.h 2016-02-16 09:45:41 UTC (rev 196631)
+++ trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.h 2016-02-16 09:50:26 UTC (rev 196632)
@@ -84,7 +84,7 @@
virtual int minimumThumbLength(Scrollbar&) override;
- virtual bool shouldCenterOnThumb(Scrollbar&, const PlatformMouseEvent&) override;
+ virtual ScrollbarButtonPressAction handleMousePressEvent(Scrollbar&, const PlatformMouseEvent&, ScrollbarPart) override;
virtual bool shouldDragDocumentInsteadOfThumb(Scrollbar&, const PlatformMouseEvent&) override;
int scrollbarPartToHIPressedState(ScrollbarPart);
Modified: trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.mm (196631 => 196632)
--- trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.mm 2016-02-16 09:45:41 UTC (rev 196631)
+++ trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.mm 2016-02-16 09:50:26 UTC (rev 196632)
@@ -424,7 +424,7 @@
END_BLOCK_OBJC_EXCEPTIONS;
}
-bool ScrollbarThemeMac::shouldCenterOnThumb(Scrollbar&, const PlatformMouseEvent& evt)
+static bool shouldCenterOnThumb(const PlatformMouseEvent& evt)
{
if (evt.button() != LeftButton)
return false;
@@ -433,6 +433,26 @@
return evt.altKey();
}
+ScrollbarButtonPressAction ScrollbarThemeMac::handleMousePressEvent(Scrollbar&, const PlatformMouseEvent& event, ScrollbarPart pressedPart)
+{
+ if (event.button() == RightButton)
+ return ScrollbarButtonPressAction::None;
+
+ switch (pressedPart) {
+ case BackTrackPart:
+ case ForwardTrackPart:
+ if (shouldCenterOnThumb(event))
+ return ScrollbarButtonPressAction::CenterOnThumb;
+ break;
+ case ThumbPart:
+ return ScrollbarButtonPressAction::StartDrag;
+ default:
+ break;
+ }
+
+ return ScrollbarButtonPressAction::Scroll;
+}
+
bool ScrollbarThemeMac::shouldDragDocumentInsteadOfThumb(Scrollbar&, const PlatformMouseEvent& event)
{
return event.altKey();
Modified: trunk/Source/WebCore/platform/win/ScrollbarThemeWin.cpp (196631 => 196632)
--- trunk/Source/WebCore/platform/win/ScrollbarThemeWin.cpp 2016-02-16 09:45:41 UTC (rev 196631)
+++ trunk/Source/WebCore/platform/win/ScrollbarThemeWin.cpp 2016-02-16 09:50:26 UTC (rev 196632)
@@ -193,9 +193,24 @@
return IntRect(scrollbar.x(), scrollbar.y() + thickness, thickness, scrollbar.height() - 2 * thickness);
}
-bool ScrollbarThemeWin::shouldCenterOnThumb(Scrollbar&, const PlatformMouseEvent& evt)
+ScrollbarButtonPressAction ScrollbarThemeWin::handleMousePressEvent(Scrollbar&, const PlatformMouseEvent& event, ScrollbarPart pressedPart)
{
- return evt.shiftKey() && evt.button() == LeftButton;
+ if (event.button() == RightButton)
+ return ScrollbarButtonPressAction::None;
+
+ switch (pressedPart) {
+ case BackTrackPart:
+ case ForwardTrackPart:
+ if (event.shiftKey() && event.button() == LeftButton)
+ return ScrollbarButtonPressAction::CenterOnThumb;
+ break;
+ case ThumbPart:
+ return ScrollbarButtonPressAction::StartDrag;
+ default:
+ break;
+ }
+
+ return ScrollbarButtonPressAction::Scroll;
}
bool ScrollbarThemeWin::shouldSnapBackToDragOrigin(Scrollbar& scrollbar, const PlatformMouseEvent& evt)
Modified: trunk/Source/WebCore/platform/win/ScrollbarThemeWin.h (196631 => 196632)
--- trunk/Source/WebCore/platform/win/ScrollbarThemeWin.h 2016-02-16 09:45:41 UTC (rev 196631)
+++ trunk/Source/WebCore/platform/win/ScrollbarThemeWin.h 2016-02-16 09:50:26 UTC (rev 196632)
@@ -49,7 +49,7 @@
bool hasButtons(Scrollbar&) override { return true; }
bool hasThumb(Scrollbar&) override;
- bool shouldCenterOnThumb(Scrollbar&, const PlatformMouseEvent&) override;
+ virtual ScrollbarButtonPressAction handleMousePressEvent(Scrollbar&, const PlatformMouseEvent&, ScrollbarPart) override;
bool shouldSnapBackToDragOrigin(Scrollbar&, const PlatformMouseEvent&) override;
void paintTrackBackground(GraphicsContext&, Scrollbar&, const IntRect&) override;
Modified: trunk/Source/WebCore/rendering/RenderScrollbarTheme.h (196631 => 196632)
--- trunk/Source/WebCore/rendering/RenderScrollbarTheme.h 2016-02-16 09:45:41 UTC (rev 196631)
+++ trunk/Source/WebCore/rendering/RenderScrollbarTheme.h 2016-02-16 09:50:26 UTC (rev 196632)
@@ -46,8 +46,8 @@
virtual void paintScrollCorner(ScrollView*, GraphicsContext&, const IntRect& cornerRect) override;
- virtual bool shouldCenterOnThumb(Scrollbar& scrollbar, const PlatformMouseEvent& event) override { return ScrollbarTheme::theme().shouldCenterOnThumb(scrollbar, event); }
-
+ virtual ScrollbarButtonPressAction handleMousePressEvent(Scrollbar& scrollbar, const PlatformMouseEvent& event, ScrollbarPart pressedPart) override { return ScrollbarTheme::theme().handleMousePressEvent(scrollbar, event, pressedPart); }
+
virtual double initialAutoscrollTimerDelay() override { return ScrollbarTheme::theme().initialAutoscrollTimerDelay(); }
virtual double autoscrollTimerDelay() override { return ScrollbarTheme::theme().autoscrollTimerDelay(); }