| 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" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 RenderWidgetHostViewViews::RenderWidgetHostViewViews(RenderWidgetHost* host) | 80 RenderWidgetHostViewViews::RenderWidgetHostViewViews(RenderWidgetHost* host) |
| 81 : host_(host), | 81 : host_(host), |
| 82 about_to_validate_and_paint_(false), | 82 about_to_validate_and_paint_(false), |
| 83 is_hidden_(false), | 83 is_hidden_(false), |
| 84 is_loading_(false), | 84 is_loading_(false), |
| 85 native_cursor_(NULL), | 85 native_cursor_(NULL), |
| 86 is_showing_context_menu_(false), | 86 is_showing_context_menu_(false), |
| 87 visually_deemphasized_(false), | 87 visually_deemphasized_(false), |
| 88 touch_event_(), | 88 touch_event_(), |
| 89 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 89 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| 90 has_composition_text_(false) { | 90 has_composition_text_(false), |
| 91 ALLOW_THIS_IN_INITIALIZER_LIST(touch_selection_controller_( |
| 92 views::TouchSelectionController::create(this))) { |
| 91 set_focusable(true); | 93 set_focusable(true); |
| 92 host_->SetView(this); | 94 host_->SetView(this); |
| 93 | 95 |
| 94 #if defined(TOUCH_UI) | 96 #if defined(TOUCH_UI) |
| 95 SetPaintToLayer(true); | 97 SetPaintToLayer(true); |
| 96 SetFillsBoundsOpaquely(true); | 98 SetFillsBoundsOpaquely(true); |
| 97 #endif | 99 #endif |
| 98 } | 100 } |
| 99 | 101 |
| 100 RenderWidgetHostViewViews::~RenderWidgetHostViewViews() { | 102 RenderWidgetHostViewViews::~RenderWidgetHostViewViews() { |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 const int kMaxTooltipLength = 8 << 10; | 299 const int kMaxTooltipLength = 8 << 10; |
| 298 // Clamp the tooltip length to kMaxTooltipLength so that we don't | 300 // Clamp the tooltip length to kMaxTooltipLength so that we don't |
| 299 // accidentally DOS the user with a mega tooltip. | 301 // accidentally DOS the user with a mega tooltip. |
| 300 tooltip_text_ = | 302 tooltip_text_ = |
| 301 l10n_util::TruncateString(WideToUTF16Hack(tip), kMaxTooltipLength); | 303 l10n_util::TruncateString(WideToUTF16Hack(tip), kMaxTooltipLength); |
| 302 if (GetWidget()) | 304 if (GetWidget()) |
| 303 GetWidget()->TooltipTextChanged(this); | 305 GetWidget()->TooltipTextChanged(this); |
| 304 } | 306 } |
| 305 | 307 |
| 306 void RenderWidgetHostViewViews::SelectionChanged(const std::string& text, | 308 void RenderWidgetHostViewViews::SelectionChanged(const std::string& text, |
| 307 const ui::Range& range) { | 309 const ui::Range& range, |
| 310 const gfx::Point& start, |
| 311 const gfx::Point& end) { |
| 308 // TODO(anicolao): deal with the clipboard without GTK | 312 // TODO(anicolao): deal with the clipboard without GTK |
| 309 NOTIMPLEMENTED(); | 313 NOTIMPLEMENTED(); |
| 314 if (touch_selection_controller_.get()) |
| 315 touch_selection_controller_->SelectionChanged(start, end); |
| 310 } | 316 } |
| 311 | 317 |
| 312 void RenderWidgetHostViewViews::ShowingContextMenu(bool showing) { | 318 void RenderWidgetHostViewViews::ShowingContextMenu(bool showing) { |
| 313 is_showing_context_menu_ = showing; | 319 is_showing_context_menu_ = showing; |
| 314 } | 320 } |
| 315 | 321 |
| 316 BackingStore* RenderWidgetHostViewViews::AllocBackingStore( | 322 BackingStore* RenderWidgetHostViewViews::AllocBackingStore( |
| 317 const gfx::Size& size) { | 323 const gfx::Size& size) { |
| 318 return new BackingStoreSkia(host_, size); | 324 return new BackingStoreSkia(host_, size); |
| 319 } | 325 } |
| 320 | 326 |
| 321 void RenderWidgetHostViewViews::SetBackground(const SkBitmap& background) { | 327 void RenderWidgetHostViewViews::SetBackground(const SkBitmap& background) { |
| 322 RenderWidgetHostView::SetBackground(background); | 328 RenderWidgetHostView::SetBackground(background); |
| 323 if (host_) | 329 if (host_) |
| 324 host_->Send(new ViewMsg_SetBackground(host_->routing_id(), background)); | 330 host_->Send(new ViewMsg_SetBackground(host_->routing_id(), background)); |
| 325 } | 331 } |
| 326 | 332 |
| 327 void RenderWidgetHostViewViews::SetVisuallyDeemphasized( | 333 void RenderWidgetHostViewViews::SetVisuallyDeemphasized( |
| 328 const SkColor* color, bool animate) { | 334 const SkColor* color, bool animate) { |
| 329 // TODO(anicolao) | 335 // TODO(anicolao) |
| 330 } | 336 } |
| 331 | 337 |
| 338 void RenderWidgetHostViewViews::SelectRect(const gfx::Point& start, |
| 339 const gfx::Point& end) { |
| 340 if (host_) |
| 341 host_->Send(new ViewMsg_SelectRect(host_->routing_id(), start, end)); |
| 342 } |
| 343 |
| 344 bool RenderWidgetHostViewViews::IsCommandIdChecked(int command_id) const { |
| 345 // TODO(varunjain): implement this and other menu delegate methods. |
| 346 NOTREACHED(); |
| 347 return true; |
| 348 } |
| 349 |
| 350 bool RenderWidgetHostViewViews::IsCommandIdEnabled(int command_id) const { |
| 351 NOTREACHED(); |
| 352 return true; |
| 353 } |
| 354 |
| 355 bool RenderWidgetHostViewViews::GetAcceleratorForCommandId( |
| 356 int command_id, |
| 357 ui::Accelerator* accelerator) { |
| 358 NOTREACHED(); |
| 359 return true; |
| 360 } |
| 361 |
| 362 void RenderWidgetHostViewViews::ExecuteCommand(int command_id) { |
| 363 NOTREACHED(); |
| 364 } |
| 365 |
| 332 std::string RenderWidgetHostViewViews::GetClassName() const { | 366 std::string RenderWidgetHostViewViews::GetClassName() const { |
| 333 return kViewClassName; | 367 return kViewClassName; |
| 334 } | 368 } |
| 335 | 369 |
| 336 gfx::NativeCursor RenderWidgetHostViewViews::GetCursor( | 370 gfx::NativeCursor RenderWidgetHostViewViews::GetCursor( |
| 337 const views::MouseEvent& event) { | 371 const views::MouseEvent& event) { |
| 338 return native_cursor_; | 372 return native_cursor_; |
| 339 } | 373 } |
| 340 | 374 |
| 341 bool RenderWidgetHostViewViews::OnMousePressed(const views::MouseEvent& event) { | 375 bool RenderWidgetHostViewViews::OnMousePressed(const views::MouseEvent& event) { |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 | 764 |
| 731 void RenderWidgetHostViewViews::FinishImeCompositionSession() { | 765 void RenderWidgetHostViewViews::FinishImeCompositionSession() { |
| 732 if (!has_composition_text_) | 766 if (!has_composition_text_) |
| 733 return; | 767 return; |
| 734 if (host_) | 768 if (host_) |
| 735 host_->ImeConfirmComposition(); | 769 host_->ImeConfirmComposition(); |
| 736 DCHECK(GetInputMethod()); | 770 DCHECK(GetInputMethod()); |
| 737 GetInputMethod()->CancelComposition(this); | 771 GetInputMethod()->CancelComposition(this); |
| 738 has_composition_text_ = false; | 772 has_composition_text_ = false; |
| 739 } | 773 } |
| OLD | NEW |