Index: chrome/browser/renderer_host/render_widget_host_view_views.cc |
=================================================================== |
--- chrome/browser/renderer_host/render_widget_host_view_views.cc (revision 89828) |
+++ chrome/browser/renderer_host/render_widget_host_view_views.cc (working copy) |
@@ -22,17 +22,20 @@ |
#include "content/common/view_messages.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/gtk/WebInputEventFactory.h" |
-#include "ui/base/keycodes/keyboard_code_conversion_gtk.h" |
#include "ui/base/l10n/l10n_util.h" |
-#include "ui/base/x/x11_util.h" |
#include "ui/gfx/canvas.h" |
#include "ui/gfx/canvas_skia.h" |
-#include "ui/gfx/gtk_native_view_id_manager.h" |
#include "views/events/event.h" |
#include "views/ime/input_method.h" |
-#include "views/widget/native_widget_gtk.h" |
#include "views/widget/widget.h" |
+#if defined(TOOLKIT_USES_GTK) |
+#include "ui/base/keycodes/keyboard_code_conversion_gtk.h" |
+#include "ui/base/x/x11_util.h" |
+#include "ui/gfx/gtk_native_view_id_manager.h" |
+#include "views/widget/native_widget_gtk.h" |
+#endif |
+ |
static const int kMaxWindowWidth = 4000; |
static const int kMaxWindowHeight = 4000; |
static const char kRenderWidgetHostViewKey[] = "__RENDER_WIDGET_HOST_VIEW__"; |
@@ -75,6 +78,7 @@ |
return modifiers; |
} |
+#if defined(TOUCH_UI) |
sky
2011/06/21 21:52:11
oi, ifdef heaven. Any chance of making this code a
|
WebKit::WebTouchPoint::State TouchPointStateFromEvent( |
const views::TouchEvent* event) { |
switch (event->type()) { |
@@ -124,6 +128,7 @@ |
tpoint->screenPosition.x = tpoint->position.x + origin.x(); |
tpoint->screenPosition.y = tpoint->position.y + origin.y(); |
} |
+#endif // TOUCH_UI |
void InitializeWebMouseEventFromViewsEvent(const views::LocatedEvent& event, |
const gfx::Point& origin, |
@@ -139,11 +144,13 @@ |
} // namespace |
+#if defined(TOUCH_UI) |
// static |
RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( |
RenderWidgetHost* widget) { |
return new RenderWidgetHostViewViews(widget); |
} |
+#endif // TOUCH_UI |
RenderWidgetHostViewViews::RenderWidgetHostViewViews(RenderWidgetHost* host) |
: host_(host), |
@@ -277,6 +284,7 @@ |
} |
void RenderWidgetHostViewViews::UpdateCursor(const WebCursor& cursor) { |
+#if defined(TOOLKIT_USES_GTK) |
// Optimize the common case, where the cursor hasn't changed. |
// However, we can switch between different pixmaps, so only on the |
// non-pixmap branch. |
@@ -287,13 +295,16 @@ |
current_cursor_ = cursor; |
ShowCurrentCursor(); |
+#endif // TOOLKIT_USES_GTK |
} |
void RenderWidgetHostViewViews::SetIsLoading(bool is_loading) { |
is_loading_ = is_loading; |
+#if defined(TOOLKIT_USES_GTK) |
// Only call ShowCurrentCursor() when it will actually change the cursor. |
if (current_cursor_.GetCursorType() == GDK_LAST_CURSOR) |
ShowCurrentCursor(); |
+#endif // TOOLKIT_USES_GTK |
} |
void RenderWidgetHostViewViews::ImeUpdateTextInputState( |
@@ -404,6 +415,7 @@ |
host_->Send(new ViewMsg_SetBackground(host_->routing_id(), background)); |
} |
+#if defined(TOOLKIT_USES_GTK) |
void RenderWidgetHostViewViews::CreatePluginContainer( |
gfx::PluginWindowHandle id) { |
// TODO(anicolao): plugin_container_manager_.CreatePluginContainer(id); |
@@ -413,6 +425,7 @@ |
gfx::PluginWindowHandle id) { |
// TODO(anicolao): plugin_container_manager_.DestroyPluginContainer(id); |
} |
+#endif // TOOLKIT_USES_GTK |
void RenderWidgetHostViewViews::SetVisuallyDeemphasized( |
const SkColor* color, bool animate) { |
@@ -423,18 +436,31 @@ |
gfx::NativeView native_view) const { |
// TODO(port) |
NOTREACHED() << |
- "RenderWidgetHostViewViews::ContainsNativeView not implemented."; |
+ "RenderWidgetHostViewViews::ContainsNativeView not implemented."; |
return false; |
} |
+#if defined(TOOLKIT_USES_GTK) |
void RenderWidgetHostViewViews::AcceleratedCompositingActivated( |
bool activated) { |
// TODO(anicolao): figure out if we need something here |
if (activated) |
NOTIMPLEMENTED(); |
} |
+#endif // TOOLKIT_USES_GTK |
+#if defined(OS_WIN) |
+void RenderWidgetHostViewViews::WillWmDestroy() { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+void RenderWidgetHostViewViews::ShowCompositorHostWindow(bool show) { |
+ NOTIMPLEMENTED(); |
+} |
+#endif // OS_WIN |
+ |
gfx::PluginWindowHandle RenderWidgetHostViewViews::GetCompositingSurface() { |
+#if defined(TOOLKIT_USES_GTK) |
GtkNativeViewManager* manager = GtkNativeViewManager::GetInstance(); |
gfx::PluginWindowHandle surface = gfx::kNullPluginWindow; |
gfx::NativeViewId view_id = gfx::IdFromNativeView(GetInnerNativeView()); |
@@ -443,15 +469,23 @@ |
DLOG(ERROR) << "Can't find XID for view id " << view_id; |
} |
return surface; |
+#else // TOOLKIT_USES_GTK |
+ return NULL; |
+#endif |
} |
gfx::NativeView RenderWidgetHostViewViews::GetInnerNativeView() const { |
+#if defined(TOOLKIT_USES_GTK) |
// TODO(sad): Ideally this function should be equivalent to GetNativeView, and |
// NativeWidgetGtk-specific function call should not be necessary. |
const views::Widget* widget = GetWidget(); |
const views::NativeWidget* native = widget ? widget->native_widget() : NULL; |
return native ? static_cast<const views::NativeWidgetGtk*>(native)-> |
window_contents() : NULL; |
+#else // TOOLKIT_USES_GTK |
+ // TODO(beng): Figure out what to do here for Windows/v.o.v. |
+ return NULL; |
+#endif |
} |
std::string RenderWidgetHostViewViews::GetClassName() const { |
@@ -517,6 +551,7 @@ |
// Already generated synthetically by webkit. |
} |
+#if defined(TOUCH_UI) |
ui::TouchStatus RenderWidgetHostViewViews::OnTouchEvent( |
const views::TouchEvent& event) { |
if (!host_) |
@@ -620,6 +655,7 @@ |
return status; |
} |
+#endif // TOUCH_UI |
bool RenderWidgetHostViewViews::OnKeyPressed(const views::KeyEvent& event) { |
// TODO(suzhe): Support editor key bindings. |
@@ -807,7 +843,9 @@ |
if (host_->is_accelerated_compositing_active()) |
return; |
+#if defined(TOOLKIT_USES_GTK) |
GdkWindow* window = GetInnerNativeView()->window; |
+#endif |
DCHECK(!about_to_validate_and_paint_); |
// TODO(anicolao): get the damage somehow |
@@ -825,10 +863,12 @@ |
paint_rect = paint_rect.Intersect(invalid_rect_); |
if (backing_store) { |
+#if defined(TOOLKIT_USES_GTK) |
// Only render the widget if it is attached to a window; there's a short |
// period where this object isn't attached to a window but hasn't been |
// Destroy()ed yet and it receives paint messages... |
if (window) { |
+#endif |
if (!visually_deemphasized_) { |
// In the common case, use XCopyArea. We don't draw more than once, so |
// we don't need to double buffer. |
@@ -843,7 +883,9 @@ |
// TODO(sad) |
NOTIMPLEMENTED(); |
} |
+#if defined(TOOLKIT_USES_GTK) |
} |
+#endif |
if (!whiteout_start_time_.is_null()) { |
base::TimeDelta whiteout_duration = base::TimeTicks::Now() - |
whiteout_start_time_; |
@@ -912,7 +954,12 @@ |
void RenderWidgetHostViewViews::ShowCurrentCursor() { |
// The widget may not have a window. If that's the case, abort mission. This |
// is the same issue as that explained above in Paint(). |
- if (!GetInnerNativeView() || !GetInnerNativeView()->window) |
+ if (!GetInnerNativeView() |
+#if defined(TOOLKIT_USES_GTK) |
+ || !GetInnerNativeView()->window) |
+#else |
+ ) |
+#endif |
return; |
native_cursor_ = current_cursor_.GetNativeCursor(); |
@@ -951,11 +998,14 @@ |
has_composition_text_ = false; |
} |
+#if defined(TOUCH_UI) |
// static |
RenderWidgetHostView* |
RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( |
gfx::NativeView widget) { |
+ // TODO(beng): Figure out what to do here for Windows/v.o.v. |
gpointer user_data = g_object_get_data(G_OBJECT(widget), |
kRenderWidgetHostViewKey); |
return reinterpret_cast<RenderWidgetHostView*>(user_data); |
} |
+#endif // TOUCH_UI |