| OLD | NEW |
| 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/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
| 14 #include "base/task.h" | 14 #include "base/task.h" |
| 15 #include "base/time.h" | 15 #include "base/time.h" |
| 16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 17 #include "chrome/common/native_web_keyboard_event_views.h" |
| 17 #include "chrome/common/render_messages.h" | 18 #include "chrome/common/render_messages.h" |
| 18 #include "content/browser/renderer_host/backing_store_skia.h" | 19 #include "content/browser/renderer_host/backing_store_skia.h" |
| 19 #include "content/browser/renderer_host/render_widget_host.h" | 20 #include "content/browser/renderer_host/render_widget_host.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 "third_party/WebKit/Source/WebKit/chromium/public/x11/WebScreenInfoFact
ory.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/x11/WebScreenInfoFact
ory.h" |
| 26 #include "ui/base/text/text_elider.h" | 26 #include "ui/base/text/text_elider.h" |
| 27 #include "ui/gfx/canvas.h" | 27 #include "ui/gfx/canvas.h" |
| 28 #include "ui/gfx/canvas_skia.h" | 28 #include "ui/gfx/canvas_skia.h" |
| 29 #include "views/events/event.h" | 29 #include "views/events/event.h" |
| 30 #include "views/ime/input_method.h" | 30 #include "views/ime/input_method.h" |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 } | 471 } |
| 472 | 472 |
| 473 void RenderWidgetHostViewViews::OnMouseExited(const views::MouseEvent& event) { | 473 void RenderWidgetHostViewViews::OnMouseExited(const views::MouseEvent& event) { |
| 474 // Already generated synthetically by webkit. | 474 // Already generated synthetically by webkit. |
| 475 } | 475 } |
| 476 | 476 |
| 477 bool RenderWidgetHostViewViews::OnKeyPressed(const views::KeyEvent& event) { | 477 bool RenderWidgetHostViewViews::OnKeyPressed(const views::KeyEvent& event) { |
| 478 // TODO(suzhe): Support editor key bindings. | 478 // TODO(suzhe): Support editor key bindings. |
| 479 if (!host_) | 479 if (!host_) |
| 480 return false; | 480 return false; |
| 481 host_->ForwardKeyboardEvent(NativeWebKeyboardEvent(event)); | 481 host_->ForwardKeyboardEvent(NativeWebKeyboardEventViews(event)); |
| 482 return true; | 482 return true; |
| 483 } | 483 } |
| 484 | 484 |
| 485 bool RenderWidgetHostViewViews::OnKeyReleased(const views::KeyEvent& event) { | 485 bool RenderWidgetHostViewViews::OnKeyReleased(const views::KeyEvent& event) { |
| 486 if (!host_) | 486 if (!host_) |
| 487 return false; | 487 return false; |
| 488 host_->ForwardKeyboardEvent(NativeWebKeyboardEvent(event)); | 488 host_->ForwardKeyboardEvent(NativeWebKeyboardEventViews(event)); |
| 489 return true; | 489 return true; |
| 490 } | 490 } |
| 491 | 491 |
| 492 bool RenderWidgetHostViewViews::OnMouseWheel( | 492 bool RenderWidgetHostViewViews::OnMouseWheel( |
| 493 const views::MouseWheelEvent& event) { | 493 const views::MouseWheelEvent& event) { |
| 494 if (!host_) | 494 if (!host_) |
| 495 return false; | 495 return false; |
| 496 | 496 |
| 497 WebMouseWheelEvent wmwe; | 497 WebMouseWheelEvent wmwe; |
| 498 InitializeWebMouseEventFromViewsEvent(event, GetMirroredPosition(), &wmwe); | 498 InitializeWebMouseEventFromViewsEvent(event, GetMirroredPosition(), &wmwe); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 | 561 |
| 562 void RenderWidgetHostViewViews::InsertText(const string16& text) { | 562 void RenderWidgetHostViewViews::InsertText(const string16& text) { |
| 563 DCHECK(text_input_type_ != ui::TEXT_INPUT_TYPE_NONE); | 563 DCHECK(text_input_type_ != ui::TEXT_INPUT_TYPE_NONE); |
| 564 if (host_) | 564 if (host_) |
| 565 host_->ImeConfirmComposition(text); | 565 host_->ImeConfirmComposition(text); |
| 566 has_composition_text_ = false; | 566 has_composition_text_ = false; |
| 567 } | 567 } |
| 568 | 568 |
| 569 void RenderWidgetHostViewViews::InsertChar(char16 ch, int flags) { | 569 void RenderWidgetHostViewViews::InsertChar(char16 ch, int flags) { |
| 570 if (host_) { | 570 if (host_) { |
| 571 NativeWebKeyboardEvent::FromViewsEvent from_views_event; | 571 NativeWebKeyboardEventViews::FromViewsEvent from_views_event; |
| 572 NativeWebKeyboardEvent wke(ch, flags, base::Time::Now().ToDoubleT(), | 572 NativeWebKeyboardEventViews wke(ch, flags, base::Time::Now().ToDoubleT(), |
| 573 from_views_event); | 573 from_views_event); |
| 574 host_->ForwardKeyboardEvent(wke); | 574 host_->ForwardKeyboardEvent(wke); |
| 575 } | 575 } |
| 576 } | 576 } |
| 577 | 577 |
| 578 ui::TextInputType RenderWidgetHostViewViews::GetTextInputType() { | 578 ui::TextInputType RenderWidgetHostViewViews::GetTextInputType() { |
| 579 return text_input_type_; | 579 return text_input_type_; |
| 580 } | 580 } |
| 581 | 581 |
| 582 gfx::Rect RenderWidgetHostViewViews::GetCaretBounds() { | 582 gfx::Rect RenderWidgetHostViewViews::GetCaretBounds() { |
| 583 return caret_bounds_; | 583 return caret_bounds_; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 | 793 |
| 794 void RenderWidgetHostViewViews::FinishImeCompositionSession() { | 794 void RenderWidgetHostViewViews::FinishImeCompositionSession() { |
| 795 if (!has_composition_text_) | 795 if (!has_composition_text_) |
| 796 return; | 796 return; |
| 797 if (host_) | 797 if (host_) |
| 798 host_->ImeConfirmComposition(); | 798 host_->ImeConfirmComposition(); |
| 799 DCHECK(GetInputMethod()); | 799 DCHECK(GetInputMethod()); |
| 800 GetInputMethod()->CancelComposition(this); | 800 GetInputMethod()->CancelComposition(this); |
| 801 has_composition_text_ = false; | 801 has_composition_text_ = false; |
| 802 } | 802 } |
| OLD | NEW |