| 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))) { | |
| 93 set_focusable(true); | 91 set_focusable(true); |
| 94 host_->SetView(this); | 92 host_->SetView(this); |
| 95 | 93 |
| 96 #if defined(TOUCH_UI) | 94 #if defined(TOUCH_UI) |
| 97 SetPaintToLayer(true); | 95 SetPaintToLayer(true); |
| 98 SetFillsBoundsOpaquely(true); | 96 SetFillsBoundsOpaquely(true); |
| 99 #endif | 97 #endif |
| 100 } | 98 } |
| 101 | 99 |
| 102 RenderWidgetHostViewViews::~RenderWidgetHostViewViews() { | 100 RenderWidgetHostViewViews::~RenderWidgetHostViewViews() { |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 const int kMaxTooltipLength = 8 << 10; | 297 const int kMaxTooltipLength = 8 << 10; |
| 300 // Clamp the tooltip length to kMaxTooltipLength so that we don't | 298 // Clamp the tooltip length to kMaxTooltipLength so that we don't |
| 301 // accidentally DOS the user with a mega tooltip. | 299 // accidentally DOS the user with a mega tooltip. |
| 302 tooltip_text_ = | 300 tooltip_text_ = |
| 303 l10n_util::TruncateString(WideToUTF16Hack(tip), kMaxTooltipLength); | 301 l10n_util::TruncateString(WideToUTF16Hack(tip), kMaxTooltipLength); |
| 304 if (GetWidget()) | 302 if (GetWidget()) |
| 305 GetWidget()->TooltipTextChanged(this); | 303 GetWidget()->TooltipTextChanged(this); |
| 306 } | 304 } |
| 307 | 305 |
| 308 void RenderWidgetHostViewViews::SelectionChanged(const std::string& text, | 306 void RenderWidgetHostViewViews::SelectionChanged(const std::string& text, |
| 309 const ui::Range& range, | 307 const ui::Range& range) { |
| 310 const gfx::Point& start, | |
| 311 const gfx::Point& end) { | |
| 312 // TODO(anicolao): deal with the clipboard without GTK | 308 // TODO(anicolao): deal with the clipboard without GTK |
| 313 NOTIMPLEMENTED(); | 309 NOTIMPLEMENTED(); |
| 314 if (touch_selection_controller_.get()) | |
| 315 touch_selection_controller_->SelectionChanged(start, end); | |
| 316 } | 310 } |
| 317 | 311 |
| 318 void RenderWidgetHostViewViews::ShowingContextMenu(bool showing) { | 312 void RenderWidgetHostViewViews::ShowingContextMenu(bool showing) { |
| 319 is_showing_context_menu_ = showing; | 313 is_showing_context_menu_ = showing; |
| 320 } | 314 } |
| 321 | 315 |
| 322 BackingStore* RenderWidgetHostViewViews::AllocBackingStore( | 316 BackingStore* RenderWidgetHostViewViews::AllocBackingStore( |
| 323 const gfx::Size& size) { | 317 const gfx::Size& size) { |
| 324 return new BackingStoreSkia(host_, size); | 318 return new BackingStoreSkia(host_, size); |
| 325 } | 319 } |
| 326 | 320 |
| 327 void RenderWidgetHostViewViews::SetBackground(const SkBitmap& background) { | 321 void RenderWidgetHostViewViews::SetBackground(const SkBitmap& background) { |
| 328 RenderWidgetHostView::SetBackground(background); | 322 RenderWidgetHostView::SetBackground(background); |
| 329 if (host_) | 323 if (host_) |
| 330 host_->Send(new ViewMsg_SetBackground(host_->routing_id(), background)); | 324 host_->Send(new ViewMsg_SetBackground(host_->routing_id(), background)); |
| 331 } | 325 } |
| 332 | 326 |
| 333 void RenderWidgetHostViewViews::SetVisuallyDeemphasized( | 327 void RenderWidgetHostViewViews::SetVisuallyDeemphasized( |
| 334 const SkColor* color, bool animate) { | 328 const SkColor* color, bool animate) { |
| 335 // TODO(anicolao) | 329 // TODO(anicolao) |
| 336 } | 330 } |
| 337 | 331 |
| 338 void RenderWidgetHostViewViews::SelectRect(const gfx::Point& start, | |
| 339 const gfx::Point& end) { | |
| 340 if (host_) | |
| 341 host_->Send(new ViewMsg_SelectRange(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 | |
| 366 std::string RenderWidgetHostViewViews::GetClassName() const { | 332 std::string RenderWidgetHostViewViews::GetClassName() const { |
| 367 return kViewClassName; | 333 return kViewClassName; |
| 368 } | 334 } |
| 369 | 335 |
| 370 gfx::NativeCursor RenderWidgetHostViewViews::GetCursor( | 336 gfx::NativeCursor RenderWidgetHostViewViews::GetCursor( |
| 371 const views::MouseEvent& event) { | 337 const views::MouseEvent& event) { |
| 372 return native_cursor_; | 338 return native_cursor_; |
| 373 } | 339 } |
| 374 | 340 |
| 375 bool RenderWidgetHostViewViews::OnMousePressed(const views::MouseEvent& event) { | 341 bool RenderWidgetHostViewViews::OnMousePressed(const views::MouseEvent& event) { |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 | 730 |
| 765 void RenderWidgetHostViewViews::FinishImeCompositionSession() { | 731 void RenderWidgetHostViewViews::FinishImeCompositionSession() { |
| 766 if (!has_composition_text_) | 732 if (!has_composition_text_) |
| 767 return; | 733 return; |
| 768 if (host_) | 734 if (host_) |
| 769 host_->ImeConfirmComposition(); | 735 host_->ImeConfirmComposition(); |
| 770 DCHECK(GetInputMethod()); | 736 DCHECK(GetInputMethod()); |
| 771 GetInputMethod()->CancelComposition(this); | 737 GetInputMethod()->CancelComposition(this); |
| 772 has_composition_text_ = false; | 738 has_composition_text_ = false; |
| 773 } | 739 } |
| OLD | NEW |