summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-05 21:08:31 +0000
committeragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-05 21:08:31 +0000
commit1e91483c7fa063dfd1b4ee7dd96c250659fc1bdb (patch)
treef2a5c0416b5fe2701ef6917bf3bc055ae7866ac5
parent7d886d12386ee44f2afd10ec47304135d0c4192b (diff)
downloadchromium_src-1e91483c7fa063dfd1b4ee7dd96c250659fc1bdb.zip
chromium_src-1e91483c7fa063dfd1b4ee7dd96c250659fc1bdb.tar.gz
chromium_src-1e91483c7fa063dfd1b4ee7dd96c250659fc1bdb.tar.bz2
Linux: add a big, stubby RenderWidgetHostView
This implementation is a lot of NOTIMPLEMENTEDs with a little bit of drawing code. It provides a skeleton for future implementation efforts and does, at least, build. Review URL: http://codereview.chromium.org/21091 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9253 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser.scons1
-rw-r--r--chrome/browser/renderer_host/backing_store.h2
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_gtk.cc224
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_gtk.h60
4 files changed, 287 insertions, 0 deletions
diff --git a/chrome/browser/browser.scons b/chrome/browser/browser.scons
index 653d211..b11d554 100644
--- a/chrome/browser/browser.scons
+++ b/chrome/browser/browser.scons
@@ -815,6 +815,7 @@ if not env.Bit('windows'):
if env.Bit('linux'):
input_files.Extend([
'browser_main_gtk.cc',
+ 'renderer_host/render_widget_host_view_gtk.cc',
])
if env.Bit('mac'):
diff --git a/chrome/browser/renderer_host/backing_store.h b/chrome/browser/renderer_host/backing_store.h
index ce15c88..903c6f3 100644
--- a/chrome/browser/renderer_host/backing_store.h
+++ b/chrome/browser/renderer_host/backing_store.h
@@ -33,6 +33,8 @@ class BackingStore {
#if defined(OS_WIN)
HDC hdc() { return hdc_; }
+#else
+ skia::PlatformCanvas* canvas() { return &canvas_; }
#endif
// Paints the bitmap from the renderer onto the backing store.
diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc
new file mode 100644
index 0000000..35d64b6
--- /dev/null
+++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc
@@ -0,0 +1,224 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/renderer_host/render_widget_host_view_gtk.h"
+
+#include <gtk/gtk.h>
+#include <gdk/gdk.h>
+#include <cairo/cairo.h>
+
+#include "base/logging.h"
+#include "chrome/browser/renderer_host/backing_store.h"
+#include "chrome/browser/renderer_host/render_widget_host.h"
+#include "skia/ext/bitmap_platform_device_linux.h"
+#include "skia/ext/platform_device_linux.h"
+
+namespace {
+
+// -----------------------------------------------------------------------------
+// Callback functions to proxy to RenderWidgetHostViewGtk...
+
+gboolean ConfigureEvent(GtkWidget* widget, GdkEventConfigure* config,
+ RenderWidgetHostViewGtk* host) {
+ NOTIMPLEMENTED();
+ return FALSE;
+}
+
+gboolean ExposeEvent(GtkWidget* widget, GdkEventExpose* expose,
+ RenderWidgetHostViewGtk* host) {
+ const gfx::Rect damage_rect(expose->area);
+ host->Paint(damage_rect);
+ return FALSE;
+}
+
+gboolean KeyPressReleaseEvent(GtkWidget* widget, GdkEventKey* event,
+ RenderWidgetHostViewGtk* host) {
+ NOTIMPLEMENTED();
+ return FALSE;
+}
+
+gboolean FocusIn(GtkWidget* widget, GdkEventFocus* focus,
+ RenderWidgetHostViewGtk* host) {
+ NOTIMPLEMENTED();
+ return FALSE;
+}
+
+gboolean FocusOut(GtkWidget* widget, GdkEventFocus* focus,
+ RenderWidgetHostViewGtk* host) {
+ NOTIMPLEMENTED();
+ return FALSE;
+}
+
+gboolean ButtonPressReleaseEvent(GtkWidget* widget, GdkEventButton* event,
+ RenderWidgetHostViewGtk* host) {
+ NOTIMPLEMENTED();
+ return FALSE;
+}
+
+gboolean MouseMoveEvent(GtkWidget* widget, GdkEventMotion* event,
+ RenderWidgetHostViewGtk* host) {
+ NOTIMPLEMENTED();
+ return FALSE;
+}
+
+gboolean MouseScrollEvent(GtkWidget* widget, GdkEventScroll* event,
+ RenderWidgetHostViewGtk* host) {
+ NOTIMPLEMENTED();
+ return FALSE;
+}
+
+} // anonymous namespace
+
+// static
+RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget(
+ RenderWidgetHost* widget) {
+ return new RenderWidgetHostViewGtk(widget);
+}
+
+RenderWidgetHostViewGtk::RenderWidgetHostViewGtk(RenderWidgetHost* widget)
+ : widget_(widget) {
+ view_ = gtk_drawing_area_new();
+
+ gtk_widget_add_events(view_, GDK_EXPOSURE_MASK |
+ GDK_POINTER_MOTION_MASK |
+ GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_KEY_PRESS_MASK |
+ GDK_KEY_RELEASE_MASK);
+ GTK_WIDGET_SET_FLAGS(view_, GTK_CAN_FOCUS);
+ g_signal_connect(view_, "configure-event", G_CALLBACK(ConfigureEvent), this);
+ g_signal_connect(view_, "expose-event", G_CALLBACK(ExposeEvent), this);
+ g_signal_connect(view_, "key-press-event", G_CALLBACK(KeyPressReleaseEvent),
+ this);
+ g_signal_connect(view_, "key-release-event",
+ G_CALLBACK(KeyPressReleaseEvent), this);
+ g_signal_connect(view_, "focus-in-event", G_CALLBACK(FocusIn), this);
+ g_signal_connect(view_, "focus-out-event", G_CALLBACK(FocusOut), this);
+ g_signal_connect(view_, "button-press-event",
+ G_CALLBACK(ButtonPressReleaseEvent), this);
+ g_signal_connect(view_, "button-release-event",
+ G_CALLBACK(ButtonPressReleaseEvent), this);
+ g_signal_connect(view_, "motion-notify-event", G_CALLBACK(MouseMoveEvent),
+ this);
+ g_signal_connect(view_, "scroll-event", G_CALLBACK(MouseScrollEvent),
+ this);
+}
+
+RenderWidgetHostViewGtk::~RenderWidgetHostViewGtk() {
+ gtk_widget_destroy(view_);
+}
+
+void RenderWidgetHostViewGtk::DidBecomeSelected() {
+ NOTIMPLEMENTED();
+}
+
+void RenderWidgetHostViewGtk::WasHidden() {
+ NOTIMPLEMENTED();
+}
+
+void RenderWidgetHostViewGtk::SetSize(const gfx::Size& size) {
+ NOTIMPLEMENTED();
+}
+
+gfx::NativeView RenderWidgetHostViewGtk::GetPluginNativeView() {
+ NOTIMPLEMENTED();
+ return NULL;
+}
+
+void RenderWidgetHostViewGtk::MovePluginWindows(
+ const std::vector<WebPluginGeometry>& plugin_window_moves) {
+ NOTIMPLEMENTED();
+}
+
+void RenderWidgetHostViewGtk::Focus() {
+ NOTIMPLEMENTED();
+}
+
+void RenderWidgetHostViewGtk::Blur() {
+ NOTIMPLEMENTED();
+}
+
+bool RenderWidgetHostViewGtk::HasFocus() {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+void RenderWidgetHostViewGtk::Show() {
+ NOTIMPLEMENTED();
+}
+
+void RenderWidgetHostViewGtk::Hide() {
+ NOTIMPLEMENTED();
+}
+
+gfx::Rect RenderWidgetHostViewGtk::GetViewBounds() const {
+ NOTIMPLEMENTED();
+ return gfx::Rect();
+}
+
+void RenderWidgetHostViewGtk::UpdateCursor(const WebCursor& cursor) {
+ NOTIMPLEMENTED();
+}
+
+void RenderWidgetHostViewGtk::UpdateCursorIfOverSelf() {
+ NOTIMPLEMENTED();
+}
+
+void RenderWidgetHostViewGtk::SetIsLoading(bool is_loading) {
+ NOTIMPLEMENTED();
+}
+
+void RenderWidgetHostViewGtk::IMEUpdateStatus(int control,
+ const gfx::Rect& caret_rect) {
+ NOTIMPLEMENTED();
+}
+
+void RenderWidgetHostViewGtk::DidPaintRect(const gfx::Rect& rect) {
+ NOTIMPLEMENTED();
+}
+
+void RenderWidgetHostViewGtk::DidScrollRect(const gfx::Rect& rect, int dx,
+ int dy) {
+ NOTIMPLEMENTED();
+}
+
+void RenderWidgetHostViewGtk::RendererGone() {
+ NOTIMPLEMENTED();
+}
+
+void RenderWidgetHostViewGtk::Destroy() {
+ NOTIMPLEMENTED();
+}
+
+void RenderWidgetHostViewGtk::SetTooltipText(const std::wstring& tooltip_text) {
+ NOTIMPLEMENTED();
+}
+
+void RenderWidgetHostViewGtk::Paint(const gfx::Rect& damage_rect) {
+ BackingStore* backing_store = widget_->GetBackingStore();
+
+ if (backing_store) {
+ GdkRectangle grect = {
+ damage_rect.x(),
+ damage_rect.y(),
+ damage_rect.width(),
+ damage_rect.height()
+ };
+ GdkWindow* window = view_->window;
+ gdk_window_begin_paint_rect(window, &grect);
+
+ skia::PlatformDeviceLinux &platdev =
+ backing_store->canvas()->getTopPlatformDevice();
+ skia::BitmapPlatformDeviceLinux* const bitdev =
+ static_cast<skia::BitmapPlatformDeviceLinux* >(&platdev);
+ cairo_t* cairo_drawable = gdk_cairo_create(window);
+ cairo_set_source_surface(cairo_drawable, bitdev->surface(), 0, 0);
+ cairo_paint(cairo_drawable);
+ cairo_destroy(cairo_drawable);
+
+ gdk_window_end_paint(window);
+ } else {
+ NOTIMPLEMENTED();
+ }
+}
diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.h b/chrome/browser/renderer_host/render_widget_host_view_gtk.h
new file mode 100644
index 0000000..600225d
--- /dev/null
+++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.h
@@ -0,0 +1,60 @@
+// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_
+#define CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_
+
+#include <vector>
+
+#include "base/gfx/native_widget_types.h"
+#include "chrome/browser/renderer_host/render_widget_host_view.h"
+
+class RenderWidgetHost;
+
+// -----------------------------------------------------------------------------
+// See comments in render_widget_host_view.h about this class and its members.
+// -----------------------------------------------------------------------------
+class RenderWidgetHostViewGtk : public RenderWidgetHostView {
+ public:
+ RenderWidgetHostViewGtk(RenderWidgetHost* widget);
+ ~RenderWidgetHostViewGtk();
+
+ // ---------------------------------------------------------------------------
+ // Implementation of RenderWidgetHostView...
+
+ RenderWidgetHost* GetRenderWidgetHost() const { return widget_; }
+ void DidBecomeSelected();
+ void WasHidden();
+ void SetSize(const gfx::Size& size);
+ gfx::NativeView GetPluginNativeView();
+ void MovePluginWindows(
+ const std::vector<WebPluginGeometry>& plugin_window_moves);
+ void Focus();
+ void Blur();
+ bool HasFocus();
+ void Show();
+ void Hide();
+ gfx::Rect GetViewBounds() const;
+ void UpdateCursor(const WebCursor& cursor);
+ void UpdateCursorIfOverSelf();
+ void SetIsLoading(bool is_loading);
+ void IMEUpdateStatus(int control, const gfx::Rect& caret_rect);
+ void DidPaintRect(const gfx::Rect& rect);
+ void DidScrollRect(
+ const gfx::Rect& rect, int dx, int dy);
+ void RendererGone();
+ void Destroy();
+ void SetTooltipText(const std::wstring& tooltip_text);
+ // ---------------------------------------------------------------------------
+
+ gfx::NativeView native_view() const { return view_; }
+
+ void Paint(const gfx::Rect&);
+
+ private:
+ RenderWidgetHost *const widget_;
+ gfx::NativeView view_;
+};
+
+#endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_