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

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

Issue 7227007: [Mac] Show correct cursor after context menu is closed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 76 }
77 77
78 } // namespace 78 } // namespace
79 79
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_popup_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 set_focusable(true); 91 set_focusable(true);
92 host_->SetView(this); 92 host_->SetView(this);
93 } 93 }
94 94
95 RenderWidgetHostViewViews::~RenderWidgetHostViewViews() { 95 RenderWidgetHostViewViews::~RenderWidgetHostViewViews() {
96 } 96 }
97 97
98 void RenderWidgetHostViewViews::InitAsChild() { 98 void RenderWidgetHostViewViews::InitAsChild() {
99 Show(); 99 Show();
100 } 100 }
101 101
102 void RenderWidgetHostViewViews::InitAsPopup( 102 void RenderWidgetHostViewViews::InitAsPopup(
103 RenderWidgetHostView* parent_host_view, 103 RenderWidgetHostView* parent_host_view,
104 const gfx::Rect& pos) { 104 const gfx::Rect& pos) {
105 RenderWidgetHostViewViews* parent = 105 RenderWidgetHostViewViews* parent =
106 static_cast<RenderWidgetHostViewViews*>(parent_host_view); 106 static_cast<RenderWidgetHostViewViews*>(parent_host_view);
107 parent->AddChildView(this); 107 parent->AddChildView(this);
108 // If the parent loses focus then the popup will close. So we need 108 // If the parent loses focus then the popup will close. So we need
109 // to tell the parent it's showing a popup so that it doesn't respond to 109 // to tell the parent it's showing a popup so that it doesn't respond to
110 // blurs. 110 // blurs.
111 parent->is_showing_popup_menu_ = true; 111 parent->is_showing_context_menu_ = true;
112 views::View* root_view = GetWidget()->GetRootView(); 112 views::View* root_view = GetWidget()->GetRootView();
113 // TODO(fsamuel): WebKit is computing the screen coordinates incorrectly. 113 // TODO(fsamuel): WebKit is computing the screen coordinates incorrectly.
114 // Fixing this is a long and involved process, because WebKit needs to know 114 // Fixing this is a long and involved process, because WebKit needs to know
115 // how to direct an IPC at a particular View. For now, we simply convert 115 // how to direct an IPC at a particular View. For now, we simply convert
116 // the broken screen coordinates into relative coordinates. 116 // the broken screen coordinates into relative coordinates.
117 gfx::Point p(pos.x() - root_view->GetScreenBounds().x(), 117 gfx::Point p(pos.x() - root_view->GetScreenBounds().x(),
118 pos.y() - root_view->GetScreenBounds().y()); 118 pos.y() - root_view->GetScreenBounds().y());
119 views::View::SetBounds(p.x(), p.y(), pos.width(), pos.height()); 119 views::View::SetBounds(p.x(), p.y(), pos.width(), pos.height());
120 Show(); 120 Show();
121 121
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 host_->ViewDestroyed(); 277 host_->ViewDestroyed();
278 Destroy(); 278 Destroy();
279 } 279 }
280 280
281 void RenderWidgetHostViewViews::Destroy() { 281 void RenderWidgetHostViewViews::Destroy() {
282 // host_'s destruction brought us here, null it out so we don't use it 282 // host_'s destruction brought us here, null it out so we don't use it
283 host_ = NULL; 283 host_ = NULL;
284 if (parent()) { 284 if (parent()) {
285 if (IsPopup()) { 285 if (IsPopup()) {
286 static_cast<RenderWidgetHostViewViews*> 286 static_cast<RenderWidgetHostViewViews*>
287 (parent())->is_showing_popup_menu_ = false; 287 (parent())->is_showing_context_menu_ = false;
288 // We're hiding the popup so we need to make sure we repaint 288 // We're hiding the popup so we need to make sure we repaint
289 // what's underneath. 289 // what's underneath.
290 parent()->SchedulePaintInRect(bounds()); 290 parent()->SchedulePaintInRect(bounds());
291 } 291 }
292 parent()->RemoveChildView(this); 292 parent()->RemoveChildView(this);
293 } 293 }
294 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 294 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
295 } 295 }
296 296
297 void RenderWidgetHostViewViews::SetTooltipText(const std::wstring& tip) { 297 void RenderWidgetHostViewViews::SetTooltipText(const std::wstring& tip) {
298 const int kMaxTooltipLength = 8 << 10; 298 const int kMaxTooltipLength = 8 << 10;
299 // Clamp the tooltip length to kMaxTooltipLength so that we don't 299 // Clamp the tooltip length to kMaxTooltipLength so that we don't
300 // accidentally DOS the user with a mega tooltip. 300 // accidentally DOS the user with a mega tooltip.
301 tooltip_text_ = 301 tooltip_text_ =
302 l10n_util::TruncateString(WideToUTF16Hack(tip), kMaxTooltipLength); 302 l10n_util::TruncateString(WideToUTF16Hack(tip), kMaxTooltipLength);
303 if (GetWidget()) 303 if (GetWidget())
304 GetWidget()->TooltipTextChanged(this); 304 GetWidget()->TooltipTextChanged(this);
305 } 305 }
306 306
307 void RenderWidgetHostViewViews::SelectionChanged(const std::string& text, 307 void RenderWidgetHostViewViews::SelectionChanged(const std::string& text,
308 const ui::Range& range) { 308 const ui::Range& range) {
309 // TODO(anicolao): deal with the clipboard without GTK 309 // TODO(anicolao): deal with the clipboard without GTK
310 NOTIMPLEMENTED(); 310 NOTIMPLEMENTED();
311 } 311 }
312 312
313 void RenderWidgetHostViewViews::ShowingContextMenu(bool showing) { 313 void RenderWidgetHostViewViews::ShowingContextMenu(bool showing) {
314 is_showing_popup_menu_ = showing; 314 is_showing_context_menu_ = showing;
315 } 315 }
316 316
317 BackingStore* RenderWidgetHostViewViews::AllocBackingStore( 317 BackingStore* RenderWidgetHostViewViews::AllocBackingStore(
318 const gfx::Size& size) { 318 const gfx::Size& size) {
319 return new BackingStoreSkia(host_, size); 319 return new BackingStoreSkia(host_, size);
320 } 320 }
321 321
322 void RenderWidgetHostViewViews::SetBackground(const SkBitmap& background) { 322 void RenderWidgetHostViewViews::SetBackground(const SkBitmap& background) {
323 RenderWidgetHostView::SetBackground(background); 323 RenderWidgetHostView::SetBackground(background);
324 if (host_) 324 if (host_)
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 host_->GotFocus(); 678 host_->GotFocus();
679 host_->SetInputMethodActive(GetInputMethod()->IsActive()); 679 host_->SetInputMethodActive(GetInputMethod()->IsActive());
680 } 680 }
681 681
682 void RenderWidgetHostViewViews::OnBlur() { 682 void RenderWidgetHostViewViews::OnBlur() {
683 if (!host_) 683 if (!host_)
684 return; 684 return;
685 View::OnBlur(); 685 View::OnBlur();
686 // If we are showing a context menu, maintain the illusion that webkit has 686 // If we are showing a context menu, maintain the illusion that webkit has
687 // focus. 687 // focus.
688 if (!is_showing_popup_menu_ && !is_hidden_) 688 if (!is_showing_context_menu_ && !is_hidden_)
689 host_->Blur(); 689 host_->Blur();
690 host_->SetInputMethodActive(false); 690 host_->SetInputMethodActive(false);
691 } 691 }
692 692
693 bool RenderWidgetHostViewViews::NeedsInputGrab() { 693 bool RenderWidgetHostViewViews::NeedsInputGrab() {
694 return popup_type_ == WebKit::WebPopupTypeSelect; 694 return popup_type_ == WebKit::WebPopupTypeSelect;
695 } 695 }
696 696
697 bool RenderWidgetHostViewViews::IsPopup() { 697 bool RenderWidgetHostViewViews::IsPopup() {
698 return popup_type_ != WebKit::WebPopupTypeNone; 698 return popup_type_ != WebKit::WebPopupTypeNone;
(...skipping 24 matching lines...) Expand all
723 723
724 void RenderWidgetHostViewViews::FinishImeCompositionSession() { 724 void RenderWidgetHostViewViews::FinishImeCompositionSession() {
725 if (!has_composition_text_) 725 if (!has_composition_text_)
726 return; 726 return;
727 if (host_) 727 if (host_)
728 host_->ImeConfirmComposition(); 728 host_->ImeConfirmComposition();
729 DCHECK(GetInputMethod()); 729 DCHECK(GetInputMethod());
730 GetInputMethod()->CancelComposition(this); 730 GetInputMethod()->CancelComposition(this);
731 has_composition_text_ = false; 731 has_composition_text_ = false;
732 } 732 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698