Reviewed by Niko.
FrameView, PlatformScrollbar and changes to the way we draw
Fix the lifetime of PlatformScrollbar, use a default width and
height and fix drawing of the PlatformScrollbar and other widgets
the following way: FrameGdk handles the expose events of the Frame
and will make the frame redraw and now it will draw the childrent of
the FrameView as well. This approach has the issue of honoring the
z-order of elements inside the RenderTree. Honoring the z-order will
be a bit more work
Widget can now handle Widget::setGtkWidget call where the GtkWidget
has not yet a GdkWindow allocated. We will lazily set the GdkDrawable.
In preparation of honoring the z-order of the RenderTree for RenderWidgets
it is started to store native objects inside the GraphicsContext. Doing this
nicely eliminates the need of RenderThemeGdk to do any drawing to a temporary
GdkPixmap. This should fix themes with rounded buttons.
ScrollView implement add- and removeChild to get a working PlatformScrollbar
* platform/Widget.h:
* platform/gdk/FrameGdk.cpp:
(frame_gdk_expose_child): Will send the expose to all children
(WebCore::FrameGdk::handleGdkEvent): Painting changes, move to mouseMoved
* platform/gdk/PlatformScreenGdk.cpp:
(WebCore::screenDepth): gdkDrawable
* platform/gdk/PlatformScrollBarGdk.cpp:
(PlatformScrollbar::PlatformScrollbar): Fix ownership
(PlatformScrollbar::~PlatformScrollbar): Fix ownership
(PlatformScrollbar::paint): Widget::paint will do the right thing soon
* platform/gdk/RenderThemeGdk.cpp: No need for using a GdkPixmap, draw directly
(WebCore::RenderThemeGdk::paintCheckbox): No need for using a GdkPixmap, draw directly
(WebCore::RenderThemeGdk::paintRadio): No need for using a GdkPixmap, draw directly
(WebCore::RenderThemeGdk::paintButton): No need for using a GdkPixmap, draw directly
* platform/gdk/RenderThemeGdk.h: remove the copyContext call
* platform/gdk/ScrollViewGdk.cpp: gdkDrawable
(WebCore::ScrollView::updateView): gdkDrawable
(WebCore::ScrollView::update): clear the area to fix repainting issues
(WebCore::ScrollView::setGtkWidget): gdkDrawable
(WebCore::ScrollView::addChild): implement
(WebCore::ScrollView::removeChild): implement
* platform/gdk/TemporaryLinkStubs.cpp: Not needed header removed
* platform/gdk/WidgetGdk.cpp:
(WebCore::Widget::gdkDrawable): Renamed from drawable
(WebCore::Widget::setGtkWidget): use gdkDrawable
(WebCore::Widget::setCursor): gdkDrawable
(WebCore::Widget::show): gdkDrawable
(WebCore::Widget::hide): gdkDrawable
* platform/graphics/GraphicsContext.h: Allow to set the GdkDrawable, e.g. used inside a expose event
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate):
(WebCore::GraphicsContext::setGdkDrawable):
(WebCore::GraphicsContext::gdkDrawable):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@24322
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2007-07-16 Holger Hans Peter Freyther <zecke@selfish.org>
+
+ Reviewed by Niko.
+
+ FrameView, PlatformScrollbar and changes to the way we draw
+
+ Fix the lifetime of PlatformScrollbar, use a default width and
+ height and fix drawing of the PlatformScrollbar and other widgets
+ the following way: FrameGdk handles the expose events of the Frame
+ and will make the frame redraw and now it will draw the childrent of
+ the FrameView as well. This approach has the issue of honoring the
+ z-order of elements inside the RenderTree. Honoring the z-order will
+ be a bit more work
+
+ Widget can now handle Widget::setGtkWidget call where the GtkWidget
+ has not yet a GdkWindow allocated. We will lazily set the GdkDrawable.
+
+ In preparation of honoring the z-order of the RenderTree for RenderWidgets
+ it is started to store native objects inside the GraphicsContext. Doing this
+ nicely eliminates the need of RenderThemeGdk to do any drawing to a temporary
+ GdkPixmap. This should fix themes with rounded buttons.
+
+ ScrollView implement add- and removeChild to get a working PlatformScrollbar
+
+
+ * platform/Widget.h:
+ * platform/gdk/FrameGdk.cpp:
+ (frame_gdk_expose_child): Will send the expose to all children
+ (WebCore::FrameGdk::handleGdkEvent): Painting changes, move to mouseMoved
+ * platform/gdk/PlatformScreenGdk.cpp:
+ (WebCore::screenDepth): gdkDrawable
+ * platform/gdk/PlatformScrollBarGdk.cpp:
+ (PlatformScrollbar::PlatformScrollbar): Fix ownership
+ (PlatformScrollbar::~PlatformScrollbar): Fix ownership
+ (PlatformScrollbar::paint): Widget::paint will do the right thing soon
+ * platform/gdk/RenderThemeGdk.cpp: No need for using a GdkPixmap, draw directly
+ (WebCore::RenderThemeGdk::paintCheckbox): No need for using a GdkPixmap, draw directly
+ (WebCore::RenderThemeGdk::paintRadio): No need for using a GdkPixmap, draw directly
+ (WebCore::RenderThemeGdk::paintButton): No need for using a GdkPixmap, draw directly
+ * platform/gdk/RenderThemeGdk.h: remove the copyContext call
+ * platform/gdk/ScrollViewGdk.cpp: gdkDrawable
+ (WebCore::ScrollView::updateView): gdkDrawable
+ (WebCore::ScrollView::update): clear the area to fix repainting issues
+ (WebCore::ScrollView::setGtkWidget): gdkDrawable
+ (WebCore::ScrollView::addChild): implement
+ (WebCore::ScrollView::removeChild): implement
+ * platform/gdk/TemporaryLinkStubs.cpp: Not needed header removed
+ * platform/gdk/WidgetGdk.cpp:
+ (WebCore::Widget::gdkDrawable): Renamed from drawable
+ (WebCore::Widget::setGtkWidget): use gdkDrawable
+ (WebCore::Widget::setCursor): gdkDrawable
+ (WebCore::Widget::show): gdkDrawable
+ (WebCore::Widget::hide): gdkDrawable
+ * platform/graphics/GraphicsContext.h: Allow to set the GdkDrawable, e.g. used inside a expose event
+ * platform/graphics/cairo/GraphicsContextCairo.cpp:
+ (WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate):
+ (WebCore::GraphicsContext::setGdkDrawable):
+ (WebCore::GraphicsContext::gdkDrawable):
+
2007-07-16 Holger Hans Peter Freyther <zecke@selfish.org>
Reviewed by Maciej.
#if PLATFORM(GDK)
Widget(GtkWidget*);
virtual void setGtkWidget(GtkWidget*);
- GdkDrawable* drawable() const;
+ GdkDrawable* gdkDrawable() const;
GtkWidget* gtkWidget() const;
#endif
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
+ * Copyright (C) 2007 Holger Hans Peter Freyther
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
return resource;
}
+struct FrameGdkExposeData {
+ GtkContainer *container;
+ GdkEventExpose *expose;
+};
+
+static void frame_gdk_expose_child(GtkWidget *widget, gpointer _data)
+{
+ FrameGdkExposeData* data = (FrameGdkExposeData*)_data;
+ int width, height;
+ gtk_container_propagate_expose(data->container, widget, data->expose);
+}
+
namespace WebCore {
FrameGdk::FrameGdk(Page* page, HTMLFrameOwnerElement* ownerElement, FrameLoaderClientGdk* frameLoader)
gdk_window_begin_paint_region(event->any.window, event->expose.region);
cairo_t* cr = gdk_cairo_create(event->any.window);
GraphicsContext ctx(cr);
+ ctx.setGdkDrawable(event->any.window);
if (renderer()) {
if (view()->needsLayout())
view()->layout();
paint(&ctx, rect);
}
cairo_destroy(cr);
+
+ /*
+ * Make sure children of the view get redrawn
+ */
+ FrameGdkExposeData data = { GTK_CONTAINER(view()->gtkWidget()), &event->expose };
+ gtk_container_forall(GTK_CONTAINER(view()->gtkWidget()), frame_gdk_expose_child, &data);
gdk_window_end_paint(event->any.window);
+
break;
}
break;
}
case GDK_MOTION_NOTIFY:
- eventHandler()->handleMouseMoveEvent(PlatformMouseEvent(event));
+ eventHandler()->mouseMoved(PlatformMouseEvent(event));
break;
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
int screenDepth(Widget* widget)
{
- ASSERT(widget->drawable());
+ ASSERT(widget->gdkDrawable());
gint dummy, depth;
- gdk_window_get_geometry(widget->drawable(), &dummy, &dummy, &dummy, &dummy, &depth);
+ gdk_window_get_geometry(widget->gdkDrawable(), &dummy, &dummy, &dummy, &dummy, &depth);
return depth;
}
#include "config.h"
#include "PlatformScrollBar.h"
+#include "IntRect.h"
+#include "GraphicsContext.h"
#include "NotImplemented.h"
#include <gtk/gtk.h>
+#include <cairo/cairo.h>
#include <stdio.h>
using namespace WebCore;
GtkScrollbar* scrollBar = orientation == HorizontalScrollbar ?
GTK_SCROLLBAR(::gtk_hscrollbar_new(NULL)) :
GTK_SCROLLBAR(::gtk_vscrollbar_new(NULL));
+ gtk_widget_show(GTK_WIDGET(scrollBar));
setGtkWidget(GTK_WIDGET(scrollBar));
+
+ /*
+ * assign a sane default width and height to the ScrollBar, otherwise
+ * we will end up with a 0 width scrollbar.
+ */
+ resize(PlatformScrollbar::horizontalScrollbarHeight(),
+ PlatformScrollbar::verticalScrollbarWidth());
+
+ g_object_ref(G_OBJECT(scrollBar));
+ gtk_object_sink(GTK_OBJECT(scrollBar));
}
+
PlatformScrollbar::~PlatformScrollbar()
{
/*
* the Widget does not take over ownership.
*/
- gtk_object_unref(GTK_OBJECT(gtkWidget()));
+ gtk_widget_destroy(gtkWidget());
+ g_object_unref(G_OBJECT(gtkWidget()));
}
int PlatformScrollbar::width() const
Widget::setEnabled(enabled);
}
-void PlatformScrollbar::paint(GraphicsContext*, const IntRect&)
+void PlatformScrollbar::paint(GraphicsContext* graphicsContext, const IntRect& damageRect)
{
- notImplemented();
+ Widget::paint(graphicsContext, damageRect);
}
void PlatformScrollbar::updateThumbPosition()
{
// FIXME: is it the right thing to do?
GtkWidget *checkbox = gtkCheckbox();
- GdkPixmap *pixmap = gdk_pixmap_new(GDK_DRAWABLE(checkbox->window), rect.width(), rect.height(), -1);
- gtk_paint_box(checkbox->style, GDK_DRAWABLE(pixmap),
+ gtk_paint_box(checkbox->style, i.context->gdkDrawable(),
GTK_STATE_NORMAL, GTK_SHADOW_OUT,
NULL, checkbox, "checkbutton",
- 0, 0, rect.width(), rect.height());
- copyToContext(pixmap, i.context->platformContext(), rect);
+ rect.x(), rect.y(), rect.width(), rect.height());
return false;
}
{
// FIXME: is it the right thing to do?
GtkWidget *radio = gtkRadioButton();
- GdkPixmap *pixmap = gdk_pixmap_new(GDK_DRAWABLE(radio->window), rect.width(), rect.height(), -1);
- gtk_paint_box(radio->style, GDK_DRAWABLE(pixmap),
+ gtk_paint_box(radio->style, i.context->gdkDrawable(),
GTK_STATE_NORMAL, GTK_SHADOW_OUT,
NULL, radio, "radiobutton",
- 0, 0, rect.width(), rect.height());
- copyToContext(pixmap, i.context->platformContext(), rect);
+ rect.x(), rect.y(), rect.width(), rect.height());
return false;
}
{
// FIXME: should use theme-aware drawing. This should honor the state as well
GtkWidget *button = gtkButton();
- GdkPixmap *pixmap = gdk_pixmap_new(GDK_DRAWABLE(button->window), rect.width(), rect.height(), -1);
- gtk_paint_box(button->style, GDK_DRAWABLE(pixmap),
+ gtk_paint_box(button->style, i.context->gdkDrawable(),
GTK_STATE_NORMAL, GTK_SHADOW_OUT,
NULL, button, "button",
- 0, 0, rect.width(), rect.height());
- copyToContext(pixmap, i.context->platformContext(), rect);
+ rect.x(), rect.y(), rect.width(), rect.height());
return false;
}
{
}
-/*
- * copy the src surface to the current context at position (rect.x,rect.y) and invalidate
- * GdkPixmap
- */
-void RenderThemeGdk::copyToContext(GdkPixmap *src, cairo_t* cr, const IntRect& rect)
-{
- gdk_cairo_set_source_pixmap(cr, src, rect.x(), rect.y());
- cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
- cairo_paint(cr);
- g_object_unref(src);
-}
-
GtkWidget* RenderThemeGdk::gtkButton() const
{
if (!m_gtkButton) {
*/
GtkWidget* gtkWindowContainer() const;
- void copyToContext(GdkPixmap *src, PlatformGraphicsContext*, const IntRect&);
-
private:
mutable GtkWidget *m_gtkButton;
mutable GtkWidget *m_gtkCheckbox;
void ScrollView::updateView(const IntRect& updateRect, bool now)
{
GdkRectangle rect = { updateRect.x(), updateRect.y(), updateRect.width(), updateRect.height() };
- GdkDrawable* gdkdrawable = Widget::drawable();
+ GdkDrawable* gdkdrawable = Widget::gdkDrawable();
if (GDK_IS_WINDOW(gdkdrawable)) {
GdkWindow* window = GDK_WINDOW(gdkdrawable);
gdk_window_invalidate_rect(window, &rect, true);
m_data->verticalAdjustment = gtk_layout_get_vadjustment(layout);
Widget::setGtkWidget(GTK_WIDGET(layout));
- if (!GDK_IS_WINDOW(drawable())) {
+ if (!GDK_IS_WINDOW(gdkDrawable())) {
LOG_ERROR("image scrollview not supported");
return;
}
}
-void ScrollView::addChild(Widget*)
+void ScrollView::addChild(Widget* w)
{
- notImplemented();
+ ASSERT(w->gtkWidget());
+ ASSERT(m_data->layout);
+
+ gtk_layout_put(m_data->layout, w->gtkWidget(), 0, 0);
}
-void ScrollView::removeChild(Widget*)
+void ScrollView::removeChild(Widget* w)
{
- notImplemented();
+ ASSERT(w->gtkWidget());
+ ASSERT(m_data->layout);
+
+ gtk_container_remove(GTK_CONTAINER(m_data->layout), w->gtkWidget());
}
void ScrollView::scrollRectIntoViewRecursively(const IntRect&)
#include "NotImplemented.h"
#include "Pasteboard.h"
#include "PlatformMouseEvent.h"
-#include "PlatformScrollBar.h"
#include "PlugInInfoStore.h"
#include "ResourceError.h"
#include "ResourceHandle.h"
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
+ * Copyright (C) 2007 Holger Hans Peter Freyther
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
setGtkWidget(widget);
}
-GdkDrawable* Widget::drawable() const
+GdkDrawable* Widget::gdkDrawable() const
{
+ if (!data->drawable && data->widget)
+ data->drawable = GTK_IS_LAYOUT(data->widget) ? GTK_LAYOUT(data->widget)->bin_window : data->widget->window;
return data->drawable;
}
void Widget::setGtkWidget(GtkWidget* widget)
{
- data->drawable = GTK_IS_LAYOUT(widget) ? GTK_LAYOUT(widget)->bin_window : widget->window;
+ data->drawable = 0;
data->widget = widget;
}
if (!pcur)
return;
- GdkDrawable* drawable = data->drawable;
+ GdkDrawable* drawable = gdkDrawable();
if (!drawable || !GDK_IS_WINDOW(drawable))
return;
GdkWindow* window = GDK_WINDOW(drawable);
void Widget::show()
{
- GdkDrawable* drawable = data->drawable;
+ GdkDrawable* drawable = gdkDrawable();
if (!drawable || !GDK_IS_WINDOW(drawable))
return;
GdkWindow* window = GDK_WINDOW(drawable);
void Widget::hide()
{
- GdkDrawable* drawable = data->drawable;
+ GdkDrawable* drawable = gdkDrawable();
if (!drawable || !GDK_IS_WINDOW(drawable))
return;
GdkWindow* window = GDK_WINDOW(drawable);
typedef void PlatformGraphicsContext;
#endif
+#if PLATFORM(GDK)
+typedef struct _GdkDrawable GdkDrawable;
+#endif
+
#if PLATFORM(WIN)
typedef struct HDC__* HDC;
#endif
PlatformPath* currentPath();
#endif
+#if PLATFORM(GDK)
+ void setGdkDrawable(GdkDrawable*);
+ GdkDrawable *gdkDrawable() const;
+#endif
+
private:
void savePlatformState();
void restorePlatformState();
#include <cairo-win32.h>
#endif
+#if PLATFORM(GDK)
+#include <gdk/gdk.h>
+#endif
+
#ifndef M_PI
#define M_PI 3.14159265358979323846
cairo_t* cr;
Vector<float> layers;
+
+#if PLATFORM(GDK)
+ GdkDrawable *drawable;
+#endif
};
static inline void setColor(cairo_t* cr, const Color& col)
GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate()
: cr(0)
+#if PLATFORM(GDK)
+ , drawable(0)
+#endif
{
}
notImplemented();
}
+#if PLATFORM(GDK)
+void GraphicsContext::setGdkDrawable(GdkDrawable* drawable)
+{
+ m_data->drawable = drawable;
+}
+
+GdkDrawable* GraphicsContext::gdkDrawable() const
+{
+ return m_data->drawable;
+}
+#endif
+
} // namespace WebCore
#endif // PLATFORM(CAIRO)