OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/renderer_host/render_widget_host_view_views.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_views.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
11 #include "app/x11_util.h" | |
12 #include "base/command_line.h" | 11 #include "base/command_line.h" |
13 #include "base/logging.h" | 12 #include "base/logging.h" |
14 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
15 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
16 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
17 #include "base/task.h" | 16 #include "base/task.h" |
18 #include "base/time.h" | 17 #include "base/time.h" |
19 #include "chrome/browser/renderer_host/backing_store_x.h" | 18 #include "chrome/browser/renderer_host/backing_store_x.h" |
20 #include "chrome/browser/renderer_host/render_widget_host.h" | 19 #include "chrome/browser/renderer_host/render_widget_host.h" |
21 #include "chrome/common/native_web_keyboard_event.h" | 20 #include "chrome/common/native_web_keyboard_event.h" |
22 #include "chrome/common/render_messages.h" | 21 #include "chrome/common/render_messages.h" |
23 #include "chrome/common/result_codes.h" | 22 #include "chrome/common/result_codes.h" |
24 #include "gfx/canvas.h" | 23 #include "gfx/canvas.h" |
25 #include "third_party/WebKit/Source/WebKit/chromium/public/gtk/WebInputEventFact
ory.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/gtk/WebInputEventFact
ory.h" |
26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
27 #include "ui/base/keycodes/keyboard_code_conversion_gtk.h" | 26 #include "ui/base/keycodes/keyboard_code_conversion_gtk.h" |
| 27 #include "ui/base/x/x11_util.h" |
28 #include "views/event.h" | 28 #include "views/event.h" |
29 #include "views/widget/widget.h" | 29 #include "views/widget/widget.h" |
30 #include "views/widget/widget_gtk.h" | 30 #include "views/widget/widget_gtk.h" |
31 | 31 |
32 static const int kMaxWindowWidth = 4000; | 32 static const int kMaxWindowWidth = 4000; |
33 static const int kMaxWindowHeight = 4000; | 33 static const int kMaxWindowHeight = 4000; |
34 static const char* kRenderWidgetHostViewKey = "__RENDER_WIDGET_HOST_VIEW__"; | 34 static const char* kRenderWidgetHostViewKey = "__RENDER_WIDGET_HOST_VIEW__"; |
35 | 35 |
36 using WebKit::WebInputEventFactory; | 36 using WebKit::WebInputEventFactory; |
37 using WebKit::WebMouseWheelEvent; | 37 using WebKit::WebMouseWheelEvent; |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 bool RenderWidgetHostViewViews::IsPopup() { | 319 bool RenderWidgetHostViewViews::IsPopup() { |
320 return popup_type_ != WebKit::WebPopupTypeNone; | 320 return popup_type_ != WebKit::WebPopupTypeNone; |
321 } | 321 } |
322 | 322 |
323 BackingStore* RenderWidgetHostViewViews::AllocBackingStore( | 323 BackingStore* RenderWidgetHostViewViews::AllocBackingStore( |
324 const gfx::Size& size) { | 324 const gfx::Size& size) { |
325 gfx::NativeView nview = GetInnerNativeView(); | 325 gfx::NativeView nview = GetInnerNativeView(); |
326 if (!nview) | 326 if (!nview) |
327 return NULL; | 327 return NULL; |
328 return new BackingStoreX(host_, size, | 328 return new BackingStoreX(host_, size, |
329 x11_util::GetVisualFromGtkWidget(nview), | 329 ui::GetVisualFromGtkWidget(nview), |
330 gtk_widget_get_visual(nview)->depth); | 330 gtk_widget_get_visual(nview)->depth); |
331 } | 331 } |
332 | 332 |
333 gfx::NativeView RenderWidgetHostViewViews::GetInnerNativeView() const { | 333 gfx::NativeView RenderWidgetHostViewViews::GetInnerNativeView() const { |
334 // TODO(sad): Ideally this function should be equivalent to GetNativeView, and | 334 // TODO(sad): Ideally this function should be equivalent to GetNativeView, and |
335 // WidgetGtk-specific function call should not be necessary. | 335 // WidgetGtk-specific function call should not be necessary. |
336 views::WidgetGtk* widget = static_cast<views::WidgetGtk*>(GetWidget()); | 336 views::WidgetGtk* widget = static_cast<views::WidgetGtk*>(GetWidget()); |
337 return widget ? widget->window_contents() : NULL; | 337 return widget ? widget->window_contents() : NULL; |
338 } | 338 } |
339 | 339 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 | 386 |
387 if (backing_store) { | 387 if (backing_store) { |
388 // Only render the widget if it is attached to a window; there's a short | 388 // Only render the widget if it is attached to a window; there's a short |
389 // period where this object isn't attached to a window but hasn't been | 389 // period where this object isn't attached to a window but hasn't been |
390 // Destroy()ed yet and it receives paint messages... | 390 // Destroy()ed yet and it receives paint messages... |
391 if (window) { | 391 if (window) { |
392 if (!visually_deemphasized_) { | 392 if (!visually_deemphasized_) { |
393 // In the common case, use XCopyArea. We don't draw more than once, so | 393 // In the common case, use XCopyArea. We don't draw more than once, so |
394 // we don't need to double buffer. | 394 // we don't need to double buffer. |
395 backing_store->XShowRect(origin, | 395 backing_store->XShowRect(origin, |
396 paint_rect, x11_util::GetX11WindowFromGdkWindow(window)); | 396 paint_rect, ui::GetX11WindowFromGdkWindow(window)); |
397 } else { | 397 } else { |
398 // If the grey blend is showing, we make two drawing calls. Use double | 398 // If the grey blend is showing, we make two drawing calls. Use double |
399 // buffering to prevent flicker. Use CairoShowRect because XShowRect | 399 // buffering to prevent flicker. Use CairoShowRect because XShowRect |
400 // shortcuts GDK's double buffering. | 400 // shortcuts GDK's double buffering. |
401 GdkRectangle rect = { paint_rect.x(), paint_rect.y(), | 401 GdkRectangle rect = { paint_rect.x(), paint_rect.y(), |
402 paint_rect.width(), paint_rect.height() }; | 402 paint_rect.width(), paint_rect.height() }; |
403 gdk_window_begin_paint_rect(window, &rect); | 403 gdk_window_begin_paint_rect(window, &rect); |
404 | 404 |
405 backing_store->CairoShowRect(paint_rect, GDK_DRAWABLE(window)); | 405 backing_store->CairoShowRect(paint_rect, GDK_DRAWABLE(window)); |
406 | 406 |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 } | 753 } |
754 | 754 |
755 // static | 755 // static |
756 RenderWidgetHostView* | 756 RenderWidgetHostView* |
757 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( | 757 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( |
758 gfx::NativeView widget) { | 758 gfx::NativeView widget) { |
759 gpointer user_data = g_object_get_data(G_OBJECT(widget), | 759 gpointer user_data = g_object_get_data(G_OBJECT(widget), |
760 kRenderWidgetHostViewKey); | 760 kRenderWidgetHostViewKey); |
761 return reinterpret_cast<RenderWidgetHostView*>(user_data); | 761 return reinterpret_cast<RenderWidgetHostView*>(user_data); |
762 } | 762 } |
OLD | NEW |