[GTK] Scrollbars do not respect the has-backward-stepper and has-forward-stepper properties

https://bugs.webkit.org/show_bug.cgi?id=76747

Patch by Martin Robinson <mrobinson@igalia.com> on 2012-01-23
Reviewed by Gustavo Noronha Silva.

No new tests. Regressions are covered by existing tests, but testing
different GTK+ theme configurations is not possible yet.

* platform/gtk/ScrollbarThemeGtk.cpp:
(WebCore::ScrollbarThemeGtk::backButtonRect): If there is no back stepper, return an empty rect.
(WebCore::ScrollbarThemeGtk::forwardButtonRect): If there is no forward stepper, return an empty rect.
(WebCore::ScrollbarThemeGtk::trackRect): Adjust track rect calculation to account for when there is
no steppers.
* platform/gtk/ScrollbarThemeGtk.h: New members describing whether there are primary steppers.
* platform/gtk/ScrollbarThemeGtk2.cpp:
(WebCore::ScrollbarThemeGtk::updateThemeProperties): Look at the theme to determine if there
are primary foward and back steppers.
* platform/gtk/ScrollbarThemeGtk3.cpp:
(WebCore::ScrollbarThemeGtk::updateThemeProperties): Ditto.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105660 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d22c03e2
2012-01-23 Martin Robinson <mrobinson@igalia.com>
[GTK] Scrollbars do not respect the has-backward-stepper and has-forward-stepper properties
https://bugs.webkit.org/show_bug.cgi?id=76747
Reviewed by Gustavo Noronha Silva.
No new tests. Regressions are covered by existing tests, but testing
different GTK+ theme configurations is not possible yet.
* platform/gtk/ScrollbarThemeGtk.cpp:
(WebCore::ScrollbarThemeGtk::backButtonRect): If there is no back stepper, return an empty rect.
(WebCore::ScrollbarThemeGtk::forwardButtonRect): If there is no forward stepper, return an empty rect.
(WebCore::ScrollbarThemeGtk::trackRect): Adjust track rect calculation to account for when there is
no steppers.
* platform/gtk/ScrollbarThemeGtk.h: New members describing whether there are primary steppers.
* platform/gtk/ScrollbarThemeGtk2.cpp:
(WebCore::ScrollbarThemeGtk::updateThemeProperties): Look at the theme to determine if there
are primary foward and back steppers.
* platform/gtk/ScrollbarThemeGtk3.cpp:
(WebCore::ScrollbarThemeGtk::updateThemeProperties): Ditto.
2012-01-23 Ryosuke Niwa <rniwa@webkit.org>
REGRESSION(r105396): drag state is not cleared after each drag
......@@ -97,6 +97,8 @@ IntRect ScrollbarThemeGtk::backButtonRect(Scrollbar* scrollbar, ScrollbarPart pa
{
if (part == BackButtonEndPart && !m_hasBackButtonEndPart)
return IntRect();
if (part == BackButtonStartPart && !m_hasBackButtonStartPart)
return IntRect();
int x = scrollbar->x() + m_troughBorderWidth;
int y = scrollbar->y() + m_troughBorderWidth;
......@@ -116,6 +118,8 @@ IntRect ScrollbarThemeGtk::forwardButtonRect(Scrollbar* scrollbar, ScrollbarPart
{
if (part == ForwardButtonStartPart && !m_hasForwardButtonStartPart)
return IntRect();
if (part == ForwardButtonEndPart && !m_hasForwardButtonEndPart)
return IntRect();
IntSize size = buttonSize(scrollbar);
if (scrollbar->orientation() == HorizontalScrollbar) {
......@@ -138,37 +142,42 @@ IntRect ScrollbarThemeGtk::forwardButtonRect(Scrollbar* scrollbar, ScrollbarPart
IntRect ScrollbarThemeGtk::trackRect(Scrollbar* scrollbar, bool)
{
// The padding along the thumb movement axis (from outside to in)
// is the size of trough border plus the size of the stepper (button)
// The padding along the thumb movement axis includes the trough border
// plus the size of stepper spacing (the space between the stepper and
// the place where the thumb stops). There is often no stepper spacing.
int movementAxisPadding = m_troughBorderWidth + m_stepperSize + m_stepperSpacing;
int movementAxisPadding = m_troughBorderWidth + m_stepperSpacing;
// The fatness of the scrollbar on the non-movement axis.
int thickness = scrollbarThickness(scrollbar->controlSize());
int alternateButtonOffset = 0;
int alternateButtonWidth = 0;
int startButtonsOffset = 0;
int buttonsWidth = 0;
if (m_hasForwardButtonStartPart) {
alternateButtonOffset += m_stepperSize;
alternateButtonWidth += m_stepperSize;
startButtonsOffset += m_stepperSize;
buttonsWidth += m_stepperSize;
}
if (m_hasBackButtonStartPart) {
startButtonsOffset += m_stepperSize;
buttonsWidth += m_stepperSize;
}
if (m_hasBackButtonEndPart)
alternateButtonWidth += m_stepperSize;
buttonsWidth += m_stepperSize;
if (m_hasForwardButtonEndPart)
buttonsWidth += m_stepperSize;
if (scrollbar->orientation() == HorizontalScrollbar) {
// Once the scrollbar becomes smaller than the natural size of the
// two buttons, the track disappears.
if (scrollbar->width() < 2 * thickness)
return IntRect();
return IntRect(scrollbar->x() + movementAxisPadding + alternateButtonOffset, scrollbar->y(),
scrollbar->width() - (2 * movementAxisPadding) - alternateButtonWidth, thickness);
return IntRect(scrollbar->x() + movementAxisPadding + startButtonsOffset, scrollbar->y(),
scrollbar->width() - (2 * movementAxisPadding) - buttonsWidth, thickness);
}
if (scrollbar->height() < 2 * thickness)
return IntRect();
return IntRect(scrollbar->x(), scrollbar->y() + movementAxisPadding + alternateButtonOffset,
thickness, scrollbar->height() - (2 * movementAxisPadding) - alternateButtonWidth);
return IntRect(scrollbar->x(), scrollbar->y() + movementAxisPadding + startButtonsOffset,
thickness, scrollbar->height() - (2 * movementAxisPadding) - buttonsWidth);
}
IntRect ScrollbarThemeGtk::thumbRect(Scrollbar* scrollbar, const IntRect& unconstrainedTrackRect)
......
......@@ -72,6 +72,8 @@ protected:
int m_minThumbLength;
gboolean m_troughUnderSteppers;
gboolean m_hasForwardButtonStartPart;
gboolean m_hasForwardButtonEndPart;
gboolean m_hasBackButtonStartPart;
gboolean m_hasBackButtonEndPart;
};
......
......@@ -58,6 +58,8 @@ void ScrollbarThemeGtk::updateThemeProperties()
"trough_border", &m_troughBorderWidth,
"stepper-size", &m_stepperSize,
"trough-under-steppers", &m_troughUnderSteppers,
"has-backward-stepper", &m_hasBackButtonStartPart,
"has-forward-stepper", &m_hasForwardButtonEndPart,
"has-secondary-forward-stepper", &m_hasForwardButtonStartPart,
"has-secondary-backward-stepper", &m_hasBackButtonEndPart, NULL);
m_minThumbLength = gtk_range_get_min_slider_size(GTK_RANGE(scrollbar));
......
......@@ -58,6 +58,8 @@ void ScrollbarThemeGtk::updateThemeProperties()
"stepper-size", &m_stepperSize,
"stepper-spacing", &m_stepperSpacing,
"trough-under-steppers", &m_troughUnderSteppers,
"has-backward-stepper", &m_hasBackButtonStartPart,
"has-forward-stepper", &m_hasForwardButtonEndPart,
"has-secondary-backward-stepper", &m_hasBackButtonEndPart,
"has-secondary-forward-stepper", &m_hasForwardButtonStartPart,
NULL);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment