[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
mrobinson at webkit.org
mrobinson at webkit.org
Wed Dec 22 12:52:13 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit b80718ceaa1444ea1092899ed98f4cd440639944
Author: mrobinson at webkit.org <mrobinson at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Aug 31 21:47:47 2010 +0000
2010-08-31 Martin Robinson <mrobinson at igalia.com>
Reviewed by Gustavo Noronha Silva.
[GTK] ScrollbarThemeGtk should respond to theme changes
https://bugs.webkit.org/show_bug.cgi?id=44782
Scrollbar is currently written with the assumption that scrollbars never change
thickness. In GTK+ changing the current theme can alter scrollbar thickness. This
change manually resizes interior frame scrollbar widgets when the GTK+ theme changes.
Since we are now tracking style changes, we may also cache theme properties to avoid
having to call moz_gtk_get_scrollbar_metrics repeatedly during rendering.
* platform/gtk/RenderThemeGtk.cpp:
(WebCore::RenderThemeGtk::gtkScrollbar): Added accessor for the Mozilla theming code's
scrollbar widget. We access it here, because RenderThemGtk takes care of initializing
the Mozilla code.
* platform/gtk/RenderThemeGtk.h: Added accessor declaration.
* platform/gtk/ScrollbarThemeGtk.cpp:
(WebCore::ScrollbarThemeGtk::ScrollbarThemeGtk): Update the style property cache during construction.
(WebCore::ScrollbarThemeGtk::registerScrollbar): Track all interior frame scrollbars.
(WebCore::ScrollbarThemeGtk::unregisterScrollbar): Ditto.
(WebCore::ScrollbarThemeGtk::updateThemeProperties): Added this method which updates the style cache.
(WebCore::gtkStyleSetCallback): Added this signal handler for when the style changes.
(WebCore::ScrollbarThemeGtk::backButtonRect): Use the style cache instead of calling moz_gtk_get_scrollbar_metrics.
(WebCore::ScrollbarThemeGtk::forwardButtonRect): Ditto.
(WebCore::ScrollbarThemeGtk::trackRect): Ditto.
(WebCore::ScrollbarThemeGtk::paintTrackBackground): Ditto.
(WebCore::ScrollbarThemeGtk::thumbRect): Ditto.
(WebCore::ScrollbarThemeGtk::paint): Ditto.
(WebCore::ScrollbarThemeGtk::scrollbarThickness): Ditto.
(WebCore::ScrollbarThemeGtk::buttonSize): Ditto.
(WebCore::ScrollbarThemeGtk::minimumThumbLength): Ditto.
* platform/gtk/ScrollbarThemeGtk.h: Added new method declarations.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66540 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index ab888e4..1232018 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,38 @@
+2010-08-31 Martin Robinson <mrobinson at igalia.com>
+
+ Reviewed by Gustavo Noronha Silva.
+
+ [GTK] ScrollbarThemeGtk should respond to theme changes
+ https://bugs.webkit.org/show_bug.cgi?id=44782
+
+ Scrollbar is currently written with the assumption that scrollbars never change
+ thickness. In GTK+ changing the current theme can alter scrollbar thickness. This
+ change manually resizes interior frame scrollbar widgets when the GTK+ theme changes.
+ Since we are now tracking style changes, we may also cache theme properties to avoid
+ having to call moz_gtk_get_scrollbar_metrics repeatedly during rendering.
+
+ * platform/gtk/RenderThemeGtk.cpp:
+ (WebCore::RenderThemeGtk::gtkScrollbar): Added accessor for the Mozilla theming code's
+ scrollbar widget. We access it here, because RenderThemGtk takes care of initializing
+ the Mozilla code.
+ * platform/gtk/RenderThemeGtk.h: Added accessor declaration.
+ * platform/gtk/ScrollbarThemeGtk.cpp:
+ (WebCore::ScrollbarThemeGtk::ScrollbarThemeGtk): Update the style property cache during construction.
+ (WebCore::ScrollbarThemeGtk::registerScrollbar): Track all interior frame scrollbars.
+ (WebCore::ScrollbarThemeGtk::unregisterScrollbar): Ditto.
+ (WebCore::ScrollbarThemeGtk::updateThemeProperties): Added this method which updates the style cache.
+ (WebCore::gtkStyleSetCallback): Added this signal handler for when the style changes.
+ (WebCore::ScrollbarThemeGtk::backButtonRect): Use the style cache instead of calling moz_gtk_get_scrollbar_metrics.
+ (WebCore::ScrollbarThemeGtk::forwardButtonRect): Ditto.
+ (WebCore::ScrollbarThemeGtk::trackRect): Ditto.
+ (WebCore::ScrollbarThemeGtk::paintTrackBackground): Ditto.
+ (WebCore::ScrollbarThemeGtk::thumbRect): Ditto.
+ (WebCore::ScrollbarThemeGtk::paint): Ditto.
+ (WebCore::ScrollbarThemeGtk::scrollbarThickness): Ditto.
+ (WebCore::ScrollbarThemeGtk::buttonSize): Ditto.
+ (WebCore::ScrollbarThemeGtk::minimumThumbLength): Ditto.
+ * platform/gtk/ScrollbarThemeGtk.h: Added new method declarations.
+
2010-08-31 Darin Adler <darin at apple.com>
Reviewed by Anders Carlsson.
diff --git a/WebCore/platform/gtk/RenderThemeGtk.cpp b/WebCore/platform/gtk/RenderThemeGtk.cpp
index 92431c7..9329179 100644
--- a/WebCore/platform/gtk/RenderThemeGtk.cpp
+++ b/WebCore/platform/gtk/RenderThemeGtk.cpp
@@ -732,6 +732,11 @@ GtkWidget* RenderThemeGtk::gtkTreeView() const
return m_gtkTreeView;
}
+GtkWidget* RenderThemeGtk::gtkScrollbar()
+{
+ return moz_gtk_get_scrollbar_widget();
+}
+
void RenderThemeGtk::platformColorsDidChange()
{
#if ENABLE(VIDEO)
diff --git a/WebCore/platform/gtk/RenderThemeGtk.h b/WebCore/platform/gtk/RenderThemeGtk.h
index bdaa208..4e24c97 100644
--- a/WebCore/platform/gtk/RenderThemeGtk.h
+++ b/WebCore/platform/gtk/RenderThemeGtk.h
@@ -85,6 +85,8 @@ public:
bool paintMozillaGtkWidget(GtkThemeWidgetType, GraphicsContext*, const IntRect&, GtkWidgetState*, int flags, GtkTextDirection = GTK_TEXT_DIR_NONE);
+ GtkWidget* gtkScrollbar();
+
protected:
virtual bool paintCheckbox(RenderObject* o, const PaintInfo& i, const IntRect& r);
virtual void setCheckboxSize(RenderStyle* style) const;
diff --git a/WebCore/platform/gtk/ScrollbarThemeGtk.cpp b/WebCore/platform/gtk/ScrollbarThemeGtk.cpp
index ee6fb38..b6efe54 100644
--- a/WebCore/platform/gtk/ScrollbarThemeGtk.cpp
+++ b/WebCore/platform/gtk/ScrollbarThemeGtk.cpp
@@ -28,22 +28,89 @@
#include "PlatformMouseEvent.h"
#include "RenderThemeGtk.h"
+#include "ScrollView.h"
#include "Scrollbar.h"
#include "gtkdrawing.h"
#include <gtk/gtk.h>
namespace WebCore {
+static HashSet<Scrollbar*>* gScrollbars;
+static void gtkStyleSetCallback(GtkWidget*, GtkStyle*, ScrollbarThemeGtk*);
+
ScrollbarTheme* ScrollbarTheme::nativeTheme()
{
static ScrollbarThemeGtk theme;
return &theme;
}
+ScrollbarThemeGtk::ScrollbarThemeGtk()
+{
+ updateThemeProperties();
+ g_signal_connect(static_cast<RenderThemeGtk*>(RenderTheme::defaultTheme().get())->gtkScrollbar(),
+ "style-set", G_CALLBACK(gtkStyleSetCallback), this);
+}
+
ScrollbarThemeGtk::~ScrollbarThemeGtk()
{
}
+void ScrollbarThemeGtk::registerScrollbar(Scrollbar* scrollbar)
+{
+ if (!gScrollbars)
+ gScrollbars = new HashSet<Scrollbar*>;
+ gScrollbars->add(scrollbar);
+}
+
+void ScrollbarThemeGtk::unregisterScrollbar(Scrollbar* scrollbar)
+{
+ gScrollbars->remove(scrollbar);
+ if (gScrollbars->isEmpty()) {
+ delete gScrollbars;
+ gScrollbars = 0;
+ }
+}
+
+void ScrollbarThemeGtk::updateThemeProperties()
+{
+ MozGtkScrollbarMetrics metrics;
+ moz_gtk_get_scrollbar_metrics(&metrics);
+
+ m_thumbFatness = metrics.slider_width;
+ m_troughBorderWidth = metrics.trough_border;
+ m_stepperSize = metrics.stepper_size;
+ m_stepperSpacing = metrics.stepper_spacing;
+ m_minThumbLength = metrics.min_slider_size;
+ m_troughUnderSteppers = metrics.trough_under_steppers;
+
+ if (!gScrollbars)
+ return;
+
+ // Update the thickness of every interior frame scrollbar widget. The
+ // platform-independent scrollbar them code isn't yet smart enough to get
+ // this information when it paints.
+ HashSet<Scrollbar*>::iterator end = gScrollbars->end();
+ for (HashSet<Scrollbar*>::iterator it = gScrollbars->begin(); it != end; ++it) {
+ Scrollbar* scrollbar = (*it);
+
+ // Top-level scrollbar i.e. scrollbars who have a parent ScrollView
+ // with no parent are native, and thus do not need to be resized.
+ if (!scrollbar->parent() || !scrollbar->parent()->parent())
+ return;
+
+ int thickness = scrollbarThickness(scrollbar->controlSize());
+ if (scrollbar->orientation() == HorizontalScrollbar)
+ scrollbar->setFrameRect(IntRect(0, scrollbar->parent()->height() - thickness, scrollbar->width(), thickness));
+ else
+ scrollbar->setFrameRect(IntRect(scrollbar->parent()->width() - thickness, 0, thickness, scrollbar->height()));
+ }
+}
+
+static void gtkStyleSetCallback(GtkWidget* widget, GtkStyle* previous, ScrollbarThemeGtk* scrollbarTheme)
+{
+ scrollbarTheme->updateThemeProperties();
+}
+
bool ScrollbarThemeGtk::hasThumb(Scrollbar* scrollbar)
{
// This method is just called as a paint-time optimization to see if
@@ -57,10 +124,8 @@ IntRect ScrollbarThemeGtk::backButtonRect(Scrollbar* scrollbar, ScrollbarPart pa
if (part == BackButtonEndPart)
return IntRect();
- MozGtkScrollbarMetrics metrics;
- moz_gtk_get_scrollbar_metrics(&metrics);
IntSize size = buttonSize(scrollbar);
- return IntRect(scrollbar->x() + metrics.trough_border, scrollbar->y() + metrics.trough_border, size.width(), size.height());
+ return IntRect(scrollbar->x() + m_troughBorderWidth, scrollbar->y() + m_troughBorderWidth, size.width(), size.height());
}
IntRect ScrollbarThemeGtk::forwardButtonRect(Scrollbar* scrollbar, ScrollbarPart part, bool)
@@ -69,17 +134,14 @@ IntRect ScrollbarThemeGtk::forwardButtonRect(Scrollbar* scrollbar, ScrollbarPart
if (part == ForwardButtonStartPart)
return IntRect();
- MozGtkScrollbarMetrics metrics;
- moz_gtk_get_scrollbar_metrics(&metrics);
-
IntSize size = buttonSize(scrollbar);
int x, y;
if (scrollbar->orientation() == HorizontalScrollbar) {
- x = scrollbar->x() + scrollbar->width() - size.width() - metrics.trough_border;
- y = scrollbar->y() + metrics.trough_border;
+ x = scrollbar->x() + scrollbar->width() - size.width() - m_troughBorderWidth;
+ y = scrollbar->y() + m_troughBorderWidth;
} else {
- x = scrollbar->x() + metrics.trough_border;
- y = scrollbar->y() + scrollbar->height() - size.height() - metrics.trough_border;
+ x = scrollbar->x() + m_troughBorderWidth;
+ y = scrollbar->y() + scrollbar->height() - size.height() - m_troughBorderWidth;
}
return IntRect(x, y, size.width(), size.height());
}
@@ -90,14 +152,10 @@ IntRect ScrollbarThemeGtk::trackRect(Scrollbar* scrollbar, bool)
// is the size of trough border plus the size of the stepper (button)
// plus the size of stepper spacing (the space between the stepper and
// the place where the thumb stops). There is often no stepper spacing.
- MozGtkScrollbarMetrics metrics;
- moz_gtk_get_scrollbar_metrics(&metrics);
- int movementAxisPadding = metrics.trough_border + metrics.stepper_size + metrics.stepper_spacing;
+ int movementAxisPadding = m_troughBorderWidth + m_stepperSize + m_stepperSpacing;
- // The thickness (of the long part) of the scrollbar. We could also
- // use scrollbarThickness here, but that would mean one more call to
- // moz_gtk_get_scrollbar_metrics.
- int thickness = metrics.slider_width + (metrics.trough_border * 2);
+ // The fatness of the scrollbar on the non-movement axis.
+ int thickness = scrollbarThickness(scrollbar->controlSize());
if (scrollbar->orientation() == HorizontalScrollbar) {
// Once the scrollbar becomes smaller than the natural size of the
@@ -125,11 +183,8 @@ void ScrollbarThemeGtk::paintTrackBackground(GraphicsContext* context, Scrollbar
// Paint the track background. If the trough-under-steppers property is true, this
// should be the full size of the scrollbar, but if is false, it should only be the
// track rect.
- MozGtkScrollbarMetrics metrics;
- moz_gtk_get_scrollbar_metrics(&metrics);
-
IntRect fullScrollbarRect = rect;
- if (metrics.trough_under_steppers)
+ if (m_troughUnderSteppers)
fullScrollbarRect = IntRect(scrollbar->x(), scrollbar->y(), scrollbar->width(), scrollbar->height());
GtkThemeWidgetType type = scrollbar->orientation() == VerticalScrollbar ? MOZ_GTK_SCROLLBAR_TRACK_VERTICAL : MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL;
@@ -168,17 +223,13 @@ void ScrollbarThemeGtk::paintThumb(GraphicsContext* context, Scrollbar* scrollba
IntRect ScrollbarThemeGtk::thumbRect(Scrollbar* scrollbar, const IntRect& unconstrainedTrackRect)
{
- MozGtkScrollbarMetrics metrics;
- moz_gtk_get_scrollbar_metrics(&metrics);
-
IntRect trackRect = constrainTrackRectToTrackPieces(scrollbar, unconstrainedTrackRect);
- int thickness = metrics.slider_width;
int thumbPos = thumbPosition(scrollbar);
if (scrollbar->orientation() == HorizontalScrollbar)
- return IntRect(trackRect.x() + thumbPos, trackRect.y() + (trackRect.height() - thickness) / 2, thumbLength(scrollbar), thickness);
+ return IntRect(trackRect.x() + thumbPos, trackRect.y() + (trackRect.height() - m_thumbFatness) / 2, thumbLength(scrollbar), m_thumbFatness);
// VerticalScrollbar
- return IntRect(trackRect.x() + (trackRect.width() - thickness) / 2, trackRect.y() + thumbPos, thickness, thumbLength(scrollbar));
+ return IntRect(trackRect.x() + (trackRect.width() - m_thumbFatness) / 2, trackRect.y() + thumbPos, m_thumbFatness, thumbLength(scrollbar));
}
bool ScrollbarThemeGtk::paint(Scrollbar* scrollbar, GraphicsContext* graphicsContext, const IntRect& damageRect)
@@ -209,10 +260,7 @@ bool ScrollbarThemeGtk::paint(Scrollbar* scrollbar, GraphicsContext* graphicsCon
if (damageRect.intersects(trackPaintRect))
scrollMask |= TrackBGPart;
- MozGtkScrollbarMetrics metrics;
- moz_gtk_get_scrollbar_metrics(&metrics);
- if (metrics.trough_under_steppers
- && (scrollMask & BackButtonStartPart
+ if (m_troughUnderSteppers && (scrollMask & BackButtonStartPart
|| scrollMask & BackButtonEndPart
|| scrollMask & ForwardButtonStartPart
|| scrollMask & ForwardButtonEndPart))
@@ -296,28 +344,21 @@ bool ScrollbarThemeGtk::shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent
int ScrollbarThemeGtk::scrollbarThickness(ScrollbarControlSize)
{
- MozGtkScrollbarMetrics metrics;
- moz_gtk_get_scrollbar_metrics(&metrics);
- return metrics.slider_width + (metrics.trough_border * 2);
+ return m_thumbFatness + (m_troughBorderWidth * 2);
}
IntSize ScrollbarThemeGtk::buttonSize(Scrollbar* scrollbar)
{
- MozGtkScrollbarMetrics metrics;
- moz_gtk_get_scrollbar_metrics(&metrics);
-
if (scrollbar->orientation() == VerticalScrollbar)
- return IntSize(metrics.slider_width, metrics.stepper_size);
+ return IntSize(m_thumbFatness, m_stepperSize);
// HorizontalScrollbar
- return IntSize(metrics.stepper_size, metrics.slider_width);
+ return IntSize(m_stepperSize, m_thumbFatness);
}
int ScrollbarThemeGtk::minimumThumbLength(Scrollbar* scrollbar)
{
- MozGtkScrollbarMetrics metrics;
- moz_gtk_get_scrollbar_metrics(&metrics);
- return metrics.min_slider_size;
+ return m_minThumbLength;
}
}
diff --git a/WebCore/platform/gtk/ScrollbarThemeGtk.h b/WebCore/platform/gtk/ScrollbarThemeGtk.h
index 4080b77..eff2fee 100644
--- a/WebCore/platform/gtk/ScrollbarThemeGtk.h
+++ b/WebCore/platform/gtk/ScrollbarThemeGtk.h
@@ -34,6 +34,7 @@ class Scrollbar;
class ScrollbarThemeGtk : public ScrollbarThemeComposite {
public:
+ ScrollbarThemeGtk();
virtual ~ScrollbarThemeGtk();
virtual bool hasButtons(Scrollbar*) { return true; }
@@ -56,7 +57,17 @@ public:
// TODO: These are the default GTK+ values. At some point we should pull these from the theme itself.
virtual double initialAutoscrollTimerDelay() { return 0.20; }
virtual double autoscrollTimerDelay() { return 0.02; }
+ void updateThemeProperties();
+ void registerScrollbar(Scrollbar*);
+ void unregisterScrollbar(Scrollbar*);
+protected:
+ int m_thumbFatness;
+ int m_troughBorderWidth;
+ int m_stepperSize;
+ int m_stepperSpacing;
+ int m_minThumbLength;
+ bool m_troughUnderSteppers;
};
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list