Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(474)

Side by Side Diff: chrome/browser/renderer_host/render_widget_host_view_views.cc

Issue 7206055: Add an option to run Chrome in the views desktop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
15 #include "base/task.h" 15 #include "base/task.h"
16 #include "base/time.h" 16 #include "base/time.h"
17 #include "chrome/common/render_messages.h" 17 #include "chrome/common/render_messages.h"
18 #include "content/browser/renderer_host/backing_store_skia.h" 18 #include "content/browser/renderer_host/backing_store_skia.h"
19 #include "content/browser/renderer_host/render_widget_host.h" 19 #include "content/browser/renderer_host/render_widget_host.h"
20 #include "content/common/native_web_keyboard_event.h" 20 #include "content/common/native_web_keyboard_event.h"
21 #include "content/common/result_codes.h" 21 #include "content/common/result_codes.h"
22 #include "content/common/view_messages.h" 22 #include "content/common/view_messages.h"
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
24 #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"
25 #include "ui/base/keycodes/keyboard_code_conversion_gtk.h"
26 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
27 #include "ui/base/x/x11_util.h"
28 #include "ui/gfx/canvas.h" 26 #include "ui/gfx/canvas.h"
29 #include "ui/gfx/canvas_skia.h" 27 #include "ui/gfx/canvas_skia.h"
30 #include "ui/gfx/gtk_native_view_id_manager.h"
31 #include "views/events/event.h" 28 #include "views/events/event.h"
32 #include "views/ime/input_method.h" 29 #include "views/ime/input_method.h"
30 #include "views/widget/widget.h"
31
32 #if defined(TOOLKIT_USES_GTK)
33 #include "ui/base/keycodes/keyboard_code_conversion_gtk.h"
34 #include "ui/base/x/x11_util.h"
35 #include "ui/gfx/gtk_native_view_id_manager.h"
33 #include "views/widget/native_widget_gtk.h" 36 #include "views/widget/native_widget_gtk.h"
34 #include "views/widget/widget.h" 37 #endif
35 38
36 static const int kMaxWindowWidth = 4000; 39 static const int kMaxWindowWidth = 4000;
37 static const int kMaxWindowHeight = 4000; 40 static const int kMaxWindowHeight = 4000;
38 static const char kRenderWidgetHostViewKey[] = "__RENDER_WIDGET_HOST_VIEW__"; 41 static const char kRenderWidgetHostViewKey[] = "__RENDER_WIDGET_HOST_VIEW__";
39 42
40 // Copied from third_party/WebKit/Source/WebCore/page/EventHandler.cpp 43 // Copied from third_party/WebKit/Source/WebCore/page/EventHandler.cpp
41 // 44 //
42 // Match key code of composition keydown event on windows. 45 // Match key code of composition keydown event on windows.
43 // IE sends VK_PROCESSKEY which has value 229; 46 // IE sends VK_PROCESSKEY which has value 229;
44 // 47 //
(...skipping 23 matching lines...) Expand all
68 if (event.IsControlDown()) 71 if (event.IsControlDown())
69 modifiers |= WebKit::WebInputEvent::ControlKey; 72 modifiers |= WebKit::WebInputEvent::ControlKey;
70 if (event.IsAltDown()) 73 if (event.IsAltDown())
71 modifiers |= WebKit::WebInputEvent::AltKey; 74 modifiers |= WebKit::WebInputEvent::AltKey;
72 if (event.IsCapsLockDown()) 75 if (event.IsCapsLockDown())
73 modifiers |= WebKit::WebInputEvent::CapsLockOn; 76 modifiers |= WebKit::WebInputEvent::CapsLockOn;
74 77
75 return modifiers; 78 return modifiers;
76 } 79 }
77 80
81 #if defined(TOUCH_UI)
sky 2011/06/21 21:52:11 oi, ifdef heaven. Any chance of making this code a
78 WebKit::WebTouchPoint::State TouchPointStateFromEvent( 82 WebKit::WebTouchPoint::State TouchPointStateFromEvent(
79 const views::TouchEvent* event) { 83 const views::TouchEvent* event) {
80 switch (event->type()) { 84 switch (event->type()) {
81 case ui::ET_TOUCH_PRESSED: 85 case ui::ET_TOUCH_PRESSED:
82 return WebKit::WebTouchPoint::StatePressed; 86 return WebKit::WebTouchPoint::StatePressed;
83 case ui::ET_TOUCH_RELEASED: 87 case ui::ET_TOUCH_RELEASED:
84 return WebKit::WebTouchPoint::StateReleased; 88 return WebKit::WebTouchPoint::StateReleased;
85 case ui::ET_TOUCH_MOVED: 89 case ui::ET_TOUCH_MOVED:
86 return WebKit::WebTouchPoint::StateMoved; 90 return WebKit::WebTouchPoint::StateMoved;
87 case ui::ET_TOUCH_CANCELLED: 91 case ui::ET_TOUCH_CANCELLED:
(...skipping 29 matching lines...) Expand all
117 121
118 void UpdateTouchPointPosition(const views::TouchEvent* event, 122 void UpdateTouchPointPosition(const views::TouchEvent* event,
119 const gfx::Point& origin, 123 const gfx::Point& origin,
120 WebKit::WebTouchPoint* tpoint) { 124 WebKit::WebTouchPoint* tpoint) {
121 tpoint->position.x = event->x(); 125 tpoint->position.x = event->x();
122 tpoint->position.y = event->y(); 126 tpoint->position.y = event->y();
123 127
124 tpoint->screenPosition.x = tpoint->position.x + origin.x(); 128 tpoint->screenPosition.x = tpoint->position.x + origin.x();
125 tpoint->screenPosition.y = tpoint->position.y + origin.y(); 129 tpoint->screenPosition.y = tpoint->position.y + origin.y();
126 } 130 }
131 #endif // TOUCH_UI
127 132
128 void InitializeWebMouseEventFromViewsEvent(const views::LocatedEvent& event, 133 void InitializeWebMouseEventFromViewsEvent(const views::LocatedEvent& event,
129 const gfx::Point& origin, 134 const gfx::Point& origin,
130 WebKit::WebMouseEvent* wmevent) { 135 WebKit::WebMouseEvent* wmevent) {
131 wmevent->timeStampSeconds = base::Time::Now().ToDoubleT(); 136 wmevent->timeStampSeconds = base::Time::Now().ToDoubleT();
132 wmevent->modifiers = WebInputEventFlagsFromViewsEvent(event); 137 wmevent->modifiers = WebInputEventFlagsFromViewsEvent(event);
133 138
134 wmevent->windowX = wmevent->x = event.x(); 139 wmevent->windowX = wmevent->x = event.x();
135 wmevent->windowY = wmevent->y = event.y(); 140 wmevent->windowY = wmevent->y = event.y();
136 wmevent->globalX = wmevent->x + origin.x(); 141 wmevent->globalX = wmevent->x + origin.x();
137 wmevent->globalY = wmevent->y + origin.y(); 142 wmevent->globalY = wmevent->y + origin.y();
138 } 143 }
139 144
140 } // namespace 145 } // namespace
141 146
147 #if defined(TOUCH_UI)
142 // static 148 // static
143 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( 149 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget(
144 RenderWidgetHost* widget) { 150 RenderWidgetHost* widget) {
145 return new RenderWidgetHostViewViews(widget); 151 return new RenderWidgetHostViewViews(widget);
146 } 152 }
153 #endif // TOUCH_UI
147 154
148 RenderWidgetHostViewViews::RenderWidgetHostViewViews(RenderWidgetHost* host) 155 RenderWidgetHostViewViews::RenderWidgetHostViewViews(RenderWidgetHost* host)
149 : host_(host), 156 : host_(host),
150 about_to_validate_and_paint_(false), 157 about_to_validate_and_paint_(false),
151 is_hidden_(false), 158 is_hidden_(false),
152 is_loading_(false), 159 is_loading_(false),
153 native_cursor_(NULL), 160 native_cursor_(NULL),
154 is_showing_popup_menu_(false), 161 is_showing_popup_menu_(false),
155 visually_deemphasized_(false), 162 visually_deemphasized_(false),
156 touch_event_(), 163 touch_event_(),
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 277
271 bool RenderWidgetHostViewViews::IsShowing() { 278 bool RenderWidgetHostViewViews::IsShowing() {
272 return IsVisible(); 279 return IsVisible();
273 } 280 }
274 281
275 gfx::Rect RenderWidgetHostViewViews::GetViewBounds() const { 282 gfx::Rect RenderWidgetHostViewViews::GetViewBounds() const {
276 return bounds(); 283 return bounds();
277 } 284 }
278 285
279 void RenderWidgetHostViewViews::UpdateCursor(const WebCursor& cursor) { 286 void RenderWidgetHostViewViews::UpdateCursor(const WebCursor& cursor) {
287 #if defined(TOOLKIT_USES_GTK)
280 // Optimize the common case, where the cursor hasn't changed. 288 // Optimize the common case, where the cursor hasn't changed.
281 // However, we can switch between different pixmaps, so only on the 289 // However, we can switch between different pixmaps, so only on the
282 // non-pixmap branch. 290 // non-pixmap branch.
283 if (current_cursor_.GetCursorType() != GDK_CURSOR_IS_PIXMAP && 291 if (current_cursor_.GetCursorType() != GDK_CURSOR_IS_PIXMAP &&
284 current_cursor_.GetCursorType() == cursor.GetCursorType()) { 292 current_cursor_.GetCursorType() == cursor.GetCursorType()) {
285 return; 293 return;
286 } 294 }
287 295
288 current_cursor_ = cursor; 296 current_cursor_ = cursor;
289 ShowCurrentCursor(); 297 ShowCurrentCursor();
298 #endif // TOOLKIT_USES_GTK
290 } 299 }
291 300
292 void RenderWidgetHostViewViews::SetIsLoading(bool is_loading) { 301 void RenderWidgetHostViewViews::SetIsLoading(bool is_loading) {
293 is_loading_ = is_loading; 302 is_loading_ = is_loading;
303 #if defined(TOOLKIT_USES_GTK)
294 // Only call ShowCurrentCursor() when it will actually change the cursor. 304 // Only call ShowCurrentCursor() when it will actually change the cursor.
295 if (current_cursor_.GetCursorType() == GDK_LAST_CURSOR) 305 if (current_cursor_.GetCursorType() == GDK_LAST_CURSOR)
296 ShowCurrentCursor(); 306 ShowCurrentCursor();
307 #endif // TOOLKIT_USES_GTK
297 } 308 }
298 309
299 void RenderWidgetHostViewViews::ImeUpdateTextInputState( 310 void RenderWidgetHostViewViews::ImeUpdateTextInputState(
300 ui::TextInputType type, 311 ui::TextInputType type,
301 bool can_compose_inline, 312 bool can_compose_inline,
302 const gfx::Rect& caret_rect) { 313 const gfx::Rect& caret_rect) {
303 // TODO(kinaba): currently, can_compose_inline is ignored and always treated 314 // TODO(kinaba): currently, can_compose_inline is ignored and always treated
304 // as true. We need to support "can_compose_inline=false" for PPAPI plugins 315 // as true. We need to support "can_compose_inline=false" for PPAPI plugins
305 // that may want to avoid drawing composition-text by themselves and pass 316 // that may want to avoid drawing composition-text by themselves and pass
306 // the responsibility to the browser. 317 // the responsibility to the browser.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 408
398 return new BackingStoreSkia(host_, size); 409 return new BackingStoreSkia(host_, size);
399 } 410 }
400 411
401 void RenderWidgetHostViewViews::SetBackground(const SkBitmap& background) { 412 void RenderWidgetHostViewViews::SetBackground(const SkBitmap& background) {
402 RenderWidgetHostView::SetBackground(background); 413 RenderWidgetHostView::SetBackground(background);
403 if (host_) 414 if (host_)
404 host_->Send(new ViewMsg_SetBackground(host_->routing_id(), background)); 415 host_->Send(new ViewMsg_SetBackground(host_->routing_id(), background));
405 } 416 }
406 417
418 #if defined(TOOLKIT_USES_GTK)
407 void RenderWidgetHostViewViews::CreatePluginContainer( 419 void RenderWidgetHostViewViews::CreatePluginContainer(
408 gfx::PluginWindowHandle id) { 420 gfx::PluginWindowHandle id) {
409 // TODO(anicolao): plugin_container_manager_.CreatePluginContainer(id); 421 // TODO(anicolao): plugin_container_manager_.CreatePluginContainer(id);
410 } 422 }
411 423
412 void RenderWidgetHostViewViews::DestroyPluginContainer( 424 void RenderWidgetHostViewViews::DestroyPluginContainer(
413 gfx::PluginWindowHandle id) { 425 gfx::PluginWindowHandle id) {
414 // TODO(anicolao): plugin_container_manager_.DestroyPluginContainer(id); 426 // TODO(anicolao): plugin_container_manager_.DestroyPluginContainer(id);
415 } 427 }
428 #endif // TOOLKIT_USES_GTK
416 429
417 void RenderWidgetHostViewViews::SetVisuallyDeemphasized( 430 void RenderWidgetHostViewViews::SetVisuallyDeemphasized(
418 const SkColor* color, bool animate) { 431 const SkColor* color, bool animate) {
419 // TODO(anicolao) 432 // TODO(anicolao)
420 } 433 }
421 434
422 bool RenderWidgetHostViewViews::ContainsNativeView( 435 bool RenderWidgetHostViewViews::ContainsNativeView(
423 gfx::NativeView native_view) const { 436 gfx::NativeView native_view) const {
424 // TODO(port) 437 // TODO(port)
425 NOTREACHED() << 438 NOTREACHED() <<
426 "RenderWidgetHostViewViews::ContainsNativeView not implemented."; 439 "RenderWidgetHostViewViews::ContainsNativeView not implemented.";
427 return false; 440 return false;
428 } 441 }
429 442
443 #if defined(TOOLKIT_USES_GTK)
430 void RenderWidgetHostViewViews::AcceleratedCompositingActivated( 444 void RenderWidgetHostViewViews::AcceleratedCompositingActivated(
431 bool activated) { 445 bool activated) {
432 // TODO(anicolao): figure out if we need something here 446 // TODO(anicolao): figure out if we need something here
433 if (activated) 447 if (activated)
434 NOTIMPLEMENTED(); 448 NOTIMPLEMENTED();
435 } 449 }
450 #endif // TOOLKIT_USES_GTK
451
452 #if defined(OS_WIN)
453 void RenderWidgetHostViewViews::WillWmDestroy() {
454 NOTIMPLEMENTED();
455 }
456
457 void RenderWidgetHostViewViews::ShowCompositorHostWindow(bool show) {
458 NOTIMPLEMENTED();
459 }
460 #endif // OS_WIN
436 461
437 gfx::PluginWindowHandle RenderWidgetHostViewViews::GetCompositingSurface() { 462 gfx::PluginWindowHandle RenderWidgetHostViewViews::GetCompositingSurface() {
463 #if defined(TOOLKIT_USES_GTK)
438 GtkNativeViewManager* manager = GtkNativeViewManager::GetInstance(); 464 GtkNativeViewManager* manager = GtkNativeViewManager::GetInstance();
439 gfx::PluginWindowHandle surface = gfx::kNullPluginWindow; 465 gfx::PluginWindowHandle surface = gfx::kNullPluginWindow;
440 gfx::NativeViewId view_id = gfx::IdFromNativeView(GetInnerNativeView()); 466 gfx::NativeViewId view_id = gfx::IdFromNativeView(GetInnerNativeView());
441 467
442 if (!manager->GetXIDForId(&surface, view_id)) { 468 if (!manager->GetXIDForId(&surface, view_id)) {
443 DLOG(ERROR) << "Can't find XID for view id " << view_id; 469 DLOG(ERROR) << "Can't find XID for view id " << view_id;
444 } 470 }
445 return surface; 471 return surface;
472 #else // TOOLKIT_USES_GTK
473 return NULL;
474 #endif
446 } 475 }
447 476
448 gfx::NativeView RenderWidgetHostViewViews::GetInnerNativeView() const { 477 gfx::NativeView RenderWidgetHostViewViews::GetInnerNativeView() const {
478 #if defined(TOOLKIT_USES_GTK)
449 // TODO(sad): Ideally this function should be equivalent to GetNativeView, and 479 // TODO(sad): Ideally this function should be equivalent to GetNativeView, and
450 // NativeWidgetGtk-specific function call should not be necessary. 480 // NativeWidgetGtk-specific function call should not be necessary.
451 const views::Widget* widget = GetWidget(); 481 const views::Widget* widget = GetWidget();
452 const views::NativeWidget* native = widget ? widget->native_widget() : NULL; 482 const views::NativeWidget* native = widget ? widget->native_widget() : NULL;
453 return native ? static_cast<const views::NativeWidgetGtk*>(native)-> 483 return native ? static_cast<const views::NativeWidgetGtk*>(native)->
454 window_contents() : NULL; 484 window_contents() : NULL;
485 #else // TOOLKIT_USES_GTK
486 // TODO(beng): Figure out what to do here for Windows/v.o.v.
487 return NULL;
488 #endif
455 } 489 }
456 490
457 std::string RenderWidgetHostViewViews::GetClassName() const { 491 std::string RenderWidgetHostViewViews::GetClassName() const {
458 return kViewClassName; 492 return kViewClassName;
459 } 493 }
460 494
461 gfx::NativeCursor RenderWidgetHostViewViews::GetCursor( 495 gfx::NativeCursor RenderWidgetHostViewViews::GetCursor(
462 const views::MouseEvent& event) { 496 const views::MouseEvent& event) {
463 return native_cursor_; 497 return native_cursor_;
464 } 498 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 } 544 }
511 545
512 void RenderWidgetHostViewViews::OnMouseEntered(const views::MouseEvent& event) { 546 void RenderWidgetHostViewViews::OnMouseEntered(const views::MouseEvent& event) {
513 // Already generated synthetically by webkit. 547 // Already generated synthetically by webkit.
514 } 548 }
515 549
516 void RenderWidgetHostViewViews::OnMouseExited(const views::MouseEvent& event) { 550 void RenderWidgetHostViewViews::OnMouseExited(const views::MouseEvent& event) {
517 // Already generated synthetically by webkit. 551 // Already generated synthetically by webkit.
518 } 552 }
519 553
554 #if defined(TOUCH_UI)
520 ui::TouchStatus RenderWidgetHostViewViews::OnTouchEvent( 555 ui::TouchStatus RenderWidgetHostViewViews::OnTouchEvent(
521 const views::TouchEvent& event) { 556 const views::TouchEvent& event) {
522 if (!host_) 557 if (!host_)
523 return ui::TOUCH_STATUS_UNKNOWN; 558 return ui::TOUCH_STATUS_UNKNOWN;
524 559
525 // Update the list of touch points first. 560 // Update the list of touch points first.
526 WebKit::WebTouchPoint* point = NULL; 561 WebKit::WebTouchPoint* point = NULL;
527 ui::TouchStatus status = ui::TOUCH_STATUS_UNKNOWN; 562 ui::TouchStatus status = ui::TOUCH_STATUS_UNKNOWN;
528 563
529 switch (event.type()) { 564 switch (event.type()) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 touch_event_.touchPoints[i] = touch_event_.touchPoints[i + 1]; 648 touch_event_.touchPoints[i] = touch_event_.touchPoints[i + 1];
614 } 649 }
615 if (touch_event_.touchPointsLength == 0) 650 if (touch_event_.touchPointsLength == 0)
616 status = ui::TOUCH_STATUS_END; 651 status = ui::TOUCH_STATUS_END;
617 } else if (event.type() == ui::ET_TOUCH_CANCELLED) { 652 } else if (event.type() == ui::ET_TOUCH_CANCELLED) {
618 status = ui::TOUCH_STATUS_CANCEL; 653 status = ui::TOUCH_STATUS_CANCEL;
619 } 654 }
620 655
621 return status; 656 return status;
622 } 657 }
658 #endif // TOUCH_UI
623 659
624 bool RenderWidgetHostViewViews::OnKeyPressed(const views::KeyEvent& event) { 660 bool RenderWidgetHostViewViews::OnKeyPressed(const views::KeyEvent& event) {
625 // TODO(suzhe): Support editor key bindings. 661 // TODO(suzhe): Support editor key bindings.
626 if (!host_) 662 if (!host_)
627 return false; 663 return false;
628 host_->ForwardKeyboardEvent(NativeWebKeyboardEvent(event)); 664 host_->ForwardKeyboardEvent(NativeWebKeyboardEvent(event));
629 return true; 665 return true;
630 } 666 }
631 667
632 bool RenderWidgetHostViewViews::OnKeyReleased(const views::KeyEvent& event) { 668 bool RenderWidgetHostViewViews::OnKeyReleased(const views::KeyEvent& event) {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 // Later views might still get to paint on top. 836 // Later views might still get to paint on top.
801 canvas->FillRectInt(SK_ColorBLACK, 0, 0, 837 canvas->FillRectInt(SK_ColorBLACK, 0, 0,
802 bounds().width(), bounds().height(), 838 bounds().width(), bounds().height(),
803 SkXfermode::kClear_Mode); 839 SkXfermode::kClear_Mode);
804 840
805 // Don't do any painting if the GPU process is rendering directly 841 // Don't do any painting if the GPU process is rendering directly
806 // into the View. 842 // into the View.
807 if (host_->is_accelerated_compositing_active()) 843 if (host_->is_accelerated_compositing_active())
808 return; 844 return;
809 845
846 #if defined(TOOLKIT_USES_GTK)
810 GdkWindow* window = GetInnerNativeView()->window; 847 GdkWindow* window = GetInnerNativeView()->window;
848 #endif
811 DCHECK(!about_to_validate_and_paint_); 849 DCHECK(!about_to_validate_and_paint_);
812 850
813 // TODO(anicolao): get the damage somehow 851 // TODO(anicolao): get the damage somehow
814 // invalid_rect_ = damage_rect; 852 // invalid_rect_ = damage_rect;
815 invalid_rect_ = bounds(); 853 invalid_rect_ = bounds();
816 gfx::Point origin; 854 gfx::Point origin;
817 ConvertPointToWidget(this, &origin); 855 ConvertPointToWidget(this, &origin);
818 856
819 about_to_validate_and_paint_ = true; 857 about_to_validate_and_paint_ = true;
820 BackingStore* backing_store = host_->GetBackingStore(true); 858 BackingStore* backing_store = host_->GetBackingStore(true);
821 // Calling GetBackingStore maybe have changed |invalid_rect_|... 859 // Calling GetBackingStore maybe have changed |invalid_rect_|...
822 about_to_validate_and_paint_ = false; 860 about_to_validate_and_paint_ = false;
823 861
824 gfx::Rect paint_rect = gfx::Rect(0, 0, kMaxWindowWidth, kMaxWindowHeight); 862 gfx::Rect paint_rect = gfx::Rect(0, 0, kMaxWindowWidth, kMaxWindowHeight);
825 paint_rect = paint_rect.Intersect(invalid_rect_); 863 paint_rect = paint_rect.Intersect(invalid_rect_);
826 864
827 if (backing_store) { 865 if (backing_store) {
866 #if defined(TOOLKIT_USES_GTK)
828 // Only render the widget if it is attached to a window; there's a short 867 // Only render the widget if it is attached to a window; there's a short
829 // period where this object isn't attached to a window but hasn't been 868 // period where this object isn't attached to a window but hasn't been
830 // Destroy()ed yet and it receives paint messages... 869 // Destroy()ed yet and it receives paint messages...
831 if (window) { 870 if (window) {
871 #endif
832 if (!visually_deemphasized_) { 872 if (!visually_deemphasized_) {
833 // In the common case, use XCopyArea. We don't draw more than once, so 873 // In the common case, use XCopyArea. We don't draw more than once, so
834 // we don't need to double buffer. 874 // we don't need to double buffer.
835 if (IsPopup()) { 875 if (IsPopup()) {
836 origin.SetPoint(origin.x() + paint_rect.x(), 876 origin.SetPoint(origin.x() + paint_rect.x(),
837 origin.y() + paint_rect.y()); 877 origin.y() + paint_rect.y());
838 paint_rect.SetRect(0, 0, paint_rect.width(), paint_rect.height()); 878 paint_rect.SetRect(0, 0, paint_rect.width(), paint_rect.height());
839 } 879 }
840 static_cast<BackingStoreSkia*>(backing_store)->SkiaShowRect( 880 static_cast<BackingStoreSkia*>(backing_store)->SkiaShowRect(
841 gfx::Point(paint_rect.x(), paint_rect.y()), canvas); 881 gfx::Point(paint_rect.x(), paint_rect.y()), canvas);
842 } else { 882 } else {
843 // TODO(sad) 883 // TODO(sad)
844 NOTIMPLEMENTED(); 884 NOTIMPLEMENTED();
845 } 885 }
886 #if defined(TOOLKIT_USES_GTK)
846 } 887 }
888 #endif
847 if (!whiteout_start_time_.is_null()) { 889 if (!whiteout_start_time_.is_null()) {
848 base::TimeDelta whiteout_duration = base::TimeTicks::Now() - 890 base::TimeDelta whiteout_duration = base::TimeTicks::Now() -
849 whiteout_start_time_; 891 whiteout_start_time_;
850 UMA_HISTOGRAM_TIMES("MPArch.RWHH_WhiteoutDuration", whiteout_duration); 892 UMA_HISTOGRAM_TIMES("MPArch.RWHH_WhiteoutDuration", whiteout_duration);
851 893
852 // Reset the start time to 0 so that we start recording again the next 894 // Reset the start time to 0 so that we start recording again the next
853 // time the backing store is NULL... 895 // time the backing store is NULL...
854 whiteout_start_time_ = base::TimeTicks(); 896 whiteout_start_time_ = base::TimeTicks();
855 } 897 }
856 if (!tab_switch_paint_time_.is_null()) { 898 if (!tab_switch_paint_time_.is_null()) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 return popup_type_ == WebKit::WebPopupTypeSelect; 947 return popup_type_ == WebKit::WebPopupTypeSelect;
906 } 948 }
907 949
908 bool RenderWidgetHostViewViews::IsPopup() { 950 bool RenderWidgetHostViewViews::IsPopup() {
909 return popup_type_ != WebKit::WebPopupTypeNone; 951 return popup_type_ != WebKit::WebPopupTypeNone;
910 } 952 }
911 953
912 void RenderWidgetHostViewViews::ShowCurrentCursor() { 954 void RenderWidgetHostViewViews::ShowCurrentCursor() {
913 // The widget may not have a window. If that's the case, abort mission. This 955 // The widget may not have a window. If that's the case, abort mission. This
914 // is the same issue as that explained above in Paint(). 956 // is the same issue as that explained above in Paint().
915 if (!GetInnerNativeView() || !GetInnerNativeView()->window) 957 if (!GetInnerNativeView()
958 #if defined(TOOLKIT_USES_GTK)
959 || !GetInnerNativeView()->window)
960 #else
961 )
962 #endif
916 return; 963 return;
917 964
918 native_cursor_ = current_cursor_.GetNativeCursor(); 965 native_cursor_ = current_cursor_.GetNativeCursor();
919 } 966 }
920 967
921 WebKit::WebMouseEvent RenderWidgetHostViewViews::WebMouseEventFromViewsEvent( 968 WebKit::WebMouseEvent RenderWidgetHostViewViews::WebMouseEventFromViewsEvent(
922 const views::MouseEvent& event) { 969 const views::MouseEvent& event) {
923 WebKit::WebMouseEvent wmevent; 970 WebKit::WebMouseEvent wmevent;
924 InitializeWebMouseEventFromViewsEvent(event, GetMirroredPosition(), &wmevent); 971 InitializeWebMouseEventFromViewsEvent(event, GetMirroredPosition(), &wmevent);
925 972
(...skipping 18 matching lines...) Expand all
944 void RenderWidgetHostViewViews::FinishImeCompositionSession() { 991 void RenderWidgetHostViewViews::FinishImeCompositionSession() {
945 if (!has_composition_text_) 992 if (!has_composition_text_)
946 return; 993 return;
947 if (host_) 994 if (host_)
948 host_->ImeConfirmComposition(); 995 host_->ImeConfirmComposition();
949 DCHECK(GetInputMethod()); 996 DCHECK(GetInputMethod());
950 GetInputMethod()->CancelComposition(this); 997 GetInputMethod()->CancelComposition(this);
951 has_composition_text_ = false; 998 has_composition_text_ = false;
952 } 999 }
953 1000
1001 #if defined(TOUCH_UI)
954 // static 1002 // static
955 RenderWidgetHostView* 1003 RenderWidgetHostView*
956 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( 1004 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView(
957 gfx::NativeView widget) { 1005 gfx::NativeView widget) {
1006 // TODO(beng): Figure out what to do here for Windows/v.o.v.
958 gpointer user_data = g_object_get_data(G_OBJECT(widget), 1007 gpointer user_data = g_object_get_data(G_OBJECT(widget),
959 kRenderWidgetHostViewKey); 1008 kRenderWidgetHostViewKey);
960 return reinterpret_cast<RenderWidgetHostView*>(user_data); 1009 return reinterpret_cast<RenderWidgetHostView*>(user_data);
961 } 1010 }
1011 #endif // TOUCH_UI
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698