diff options
author | Feng Qian <> | 2009-04-10 18:11:29 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-04-10 18:11:29 -0700 |
commit | 8f72e70a9fd78eec56623b3a62e68f16b7b27e28 (patch) | |
tree | 181bf9a400c30a1bf34ea6d72560e8d00111d549 /WebCore/platform/gtk/ScrollbarGtk.cpp | |
parent | 7ed56f225e0ade046e1c2178977f72b2d896f196 (diff) | |
download | external_webkit-8f72e70a9fd78eec56623b3a62e68f16b7b27e28.zip external_webkit-8f72e70a9fd78eec56623b3a62e68f16b7b27e28.tar.gz external_webkit-8f72e70a9fd78eec56623b3a62e68f16b7b27e28.tar.bz2 |
AI 145796: Land the WebKit merge @r42026.
Automated import of CL 145796
Diffstat (limited to 'WebCore/platform/gtk/ScrollbarGtk.cpp')
-rw-r--r-- | WebCore/platform/gtk/ScrollbarGtk.cpp | 76 |
1 files changed, 58 insertions, 18 deletions
diff --git a/WebCore/platform/gtk/ScrollbarGtk.cpp b/WebCore/platform/gtk/ScrollbarGtk.cpp index df165e3..7543e23 100644 --- a/WebCore/platform/gtk/ScrollbarGtk.cpp +++ b/WebCore/platform/gtk/ScrollbarGtk.cpp @@ -44,19 +44,18 @@ static gboolean gtkScrollEventCallback(GtkWidget* widget, GdkEventScroll* event, } ScrollbarGtk::ScrollbarGtk(ScrollbarClient* client, ScrollbarOrientation orientation, - ScrollbarControlSize controlSize) + ScrollbarControlSize controlSize) : Scrollbar(client, orientation, controlSize) , m_adjustment(GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0))) { - GtkScrollbar* scrollBar = orientation == HorizontalScrollbar ? - GTK_SCROLLBAR(::gtk_hscrollbar_new(m_adjustment)) : - GTK_SCROLLBAR(::gtk_vscrollbar_new(m_adjustment)); - gtk_widget_show(GTK_WIDGET(scrollBar)); - g_object_ref(G_OBJECT(scrollBar)); - g_signal_connect(G_OBJECT(scrollBar), "value-changed", G_CALLBACK(ScrollbarGtk::gtkValueChanged), this); - g_signal_connect(G_OBJECT(scrollBar), "scroll-event", G_CALLBACK(gtkScrollEventCallback), this); + GtkWidget* scrollBar = orientation == HorizontalScrollbar ? + gtk_hscrollbar_new(m_adjustment): + gtk_vscrollbar_new(m_adjustment); + gtk_widget_show(scrollBar); + g_signal_connect(scrollBar, "value-changed", G_CALLBACK(ScrollbarGtk::gtkValueChanged), this); + g_signal_connect(scrollBar, "scroll-event", G_CALLBACK(gtkScrollEventCallback), this); - setPlatformWidget(GTK_WIDGET(scrollBar)); + setPlatformWidget(scrollBar); /* * assign a sane default width and height to the Scrollbar, otherwise @@ -66,22 +65,24 @@ ScrollbarGtk::ScrollbarGtk(ScrollbarClient* client, ScrollbarOrientation orienta ScrollbarTheme::nativeTheme()->scrollbarThickness()); } -ScrollbarGtk::~ScrollbarGtk() +IntPoint ScrollbarGtk::getLocationInParentWindow(const IntRect& rect) { - /* - * the Widget does not take over ownership. - */ - g_signal_handlers_disconnect_by_func(G_OBJECT(platformWidget()), (gpointer)ScrollbarGtk::gtkValueChanged, this); - g_signal_handlers_disconnect_by_func(G_OBJECT(platformWidget()), (gpointer)gtkScrollEventCallback, this); - g_object_unref(G_OBJECT(platformWidget())); + IntPoint loc; + + if (parent()->isScrollViewScrollbar(this)) + loc = parent()->convertToContainingWindow(rect.location()); + else + loc = parent()->contentsToWindow(rect.location()); + + return loc; } void ScrollbarGtk::frameRectsChanged() { - if (!parent() || !parent()->isScrollViewScrollbar(this)) + if (!parent()) return; - IntPoint loc = parent()->convertToContainingWindow(frameRect().location()); + IntPoint loc = getLocationInParentWindow(frameRect()); // Don't allow the allocation size to be negative IntSize sz = frameRect().size(); @@ -129,5 +130,44 @@ void ScrollbarGtk::setEnabled(bool shouldEnable) gtk_widget_set_sensitive(platformWidget(), shouldEnable); } +/* + * Strategy to painting a Widget: + * 1.) do not paint if there is no GtkWidget set + * 2.) We assume that GTK_NO_WINDOW is set and that frameRectsChanged positioned + * the widget correctly. ATM we do not honor the GraphicsContext translation. + */ +void ScrollbarGtk::paint(GraphicsContext* context, const IntRect& rect) +{ + if (!platformWidget()) + return; + + if (!context->gdkExposeEvent()) + return; + + GtkWidget* widget = platformWidget(); + ASSERT(GTK_WIDGET_NO_WINDOW(widget)); + GdkEvent* event = gdk_event_new(GDK_EXPOSE); + event->expose = *context->gdkExposeEvent(); + event->expose.area = static_cast<GdkRectangle>(rect); + IntPoint loc = getLocationInParentWindow(rect); + + event->expose.area.x = loc.x(); + event->expose.area.y = loc.y(); + + event->expose.region = gdk_region_rectangle(&event->expose.area); + + /* + * This will be unref'ed by gdk_event_free. + */ + g_object_ref(event->expose.window); + + /* + * If we are going to paint do the translation and GtkAllocation manipulation. + */ + if (!gdk_region_empty(event->expose.region)) + gtk_widget_send_expose(widget, event); + + gdk_event_free(event); +} |