diff --git a/gfx/src/thebes/nsThebesDeviceContext.cpp b/gfx/src/thebes/nsThebesDeviceContext.cpp index aec0fbb63e56..098042739c6b 100644 --- a/gfx/src/thebes/nsThebesDeviceContext.cpp +++ b/gfx/src/thebes/nsThebesDeviceContext.cpp @@ -237,6 +237,30 @@ nsThebesDeviceContext::Init(nsNativeWidget aWidget) } // XXX mDepth = 24; + + // Cache scrollbar sizes for GTK. + GtkRequisition req; + GtkWidget *sb; + + sb = gtk_vscrollbar_new(NULL); + gtk_widget_ref(sb); + gtk_object_sink(GTK_OBJECT(sb)); + gtk_widget_ensure_style(sb); + gtk_widget_queue_resize(sb); + gtk_widget_size_request(sb,&req); + mGTKScrollbarWidth = req.width; + gtk_widget_destroy(sb); + gtk_widget_unref(sb); + + sb = gtk_hscrollbar_new(NULL); + gtk_widget_ref(sb); + gtk_object_sink(GTK_OBJECT(sb)); + gtk_widget_ensure_style(sb); + gtk_widget_queue_resize(sb); + gtk_widget_size_request(sb,&req); + mGTKScrollbarHeight = req.height; + gtk_widget_destroy(sb); + gtk_widget_unref(sb); #endif #ifdef XP_WIN @@ -358,15 +382,16 @@ nsThebesDeviceContext::SupportsNativeWidgets(PRBool &aSupportsWidgets) NS_IMETHODIMP nsThebesDeviceContext::GetScrollBarDimensions(float &aWidth, float &aHeight) const { -#ifdef XP_WIN float scale; GetCanonicalPixelScale(scale); - +#ifdef MOZ_ENABLE_GTK2 + aWidth = mGTKScrollbarWidth * mDevUnitsToAppUnits * scale; + aHeight = mGTKScrollbarHeight * mDevUnitsToAppUnits * scale; +#elif XP_WIN aWidth = ::GetSystemMetrics(SM_CXVSCROLL) * mDevUnitsToAppUnits * scale; aHeight = ::GetSystemMetrics(SM_CXHSCROLL) * mDevUnitsToAppUnits * scale; - #else - + NS_WARNING("Couldn't get scrollbar size from system, so setting to 10px. FIX ME!"); aWidth = 10.0f * mPixelsToTwips; aHeight = 10.0f * mPixelsToTwips; #endif diff --git a/gfx/src/thebes/nsThebesDeviceContext.h b/gfx/src/thebes/nsThebesDeviceContext.h index e44ff5d72c64..285d41e16e9c 100644 --- a/gfx/src/thebes/nsThebesDeviceContext.h +++ b/gfx/src/thebes/nsThebesDeviceContext.h @@ -141,7 +141,10 @@ private: PRInt32 mWidth; PRInt32 mHeight; - +#ifdef MOZ_ENABLE_GTK2 + PRInt16 mGTKScrollbarHeight; + PRInt16 mGTKScrollbarWidth; +#endif PRBool mPrinter; nsRefPtrHashtable mWidgetSurfaceCache;