| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/renderer/render_widget.h" | 5 #include "chrome/renderer/render_widget.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/gfx/point.h" | 8 #include "base/gfx/point.h" |
| 9 #include "base/gfx/size.h" | 9 #include "base/gfx/size.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 closing_(false), | 60 closing_(false), |
| 61 ime_is_active_(false), | 61 ime_is_active_(false), |
| 62 ime_control_enable_ime_(true), | 62 ime_control_enable_ime_(true), |
| 63 ime_control_x_(-1), | 63 ime_control_x_(-1), |
| 64 ime_control_y_(-1), | 64 ime_control_y_(-1), |
| 65 ime_control_new_state_(false), | 65 ime_control_new_state_(false), |
| 66 ime_control_updated_(false), | 66 ime_control_updated_(false), |
| 67 ime_control_busy_(false), | 67 ime_control_busy_(false), |
| 68 activatable_(activatable), | 68 activatable_(activatable), |
| 69 pending_window_rect_count_(0), | 69 pending_window_rect_count_(0), |
| 70 suppress_next_char_events_(false) { | 70 suppress_next_char_events_(false), |
| 71 showing_popup_menu_(false), |
| 72 popup_menu_owner_widget_(NULL) { |
| 71 RenderProcess::current()->AddRefProcess(); | 73 RenderProcess::current()->AddRefProcess(); |
| 72 DCHECK(render_thread_); | 74 DCHECK(render_thread_); |
| 73 } | 75 } |
| 74 | 76 |
| 75 RenderWidget::~RenderWidget() { | 77 RenderWidget::~RenderWidget() { |
| 76 DCHECK(!webwidget_) << "Leaking our WebWidget!"; | 78 DCHECK(!webwidget_) << "Leaking our WebWidget!"; |
| 77 if (current_paint_buf_) { | 79 if (current_paint_buf_) { |
| 78 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); | 80 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); |
| 79 current_paint_buf_ = NULL; | 81 current_paint_buf_ = NULL; |
| 80 } | 82 } |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 DidHandleKeyEvent(); | 328 DidHandleKeyEvent(); |
| 327 } | 329 } |
| 328 | 330 |
| 329 void RenderWidget::OnMouseCaptureLost() { | 331 void RenderWidget::OnMouseCaptureLost() { |
| 330 if (webwidget_) | 332 if (webwidget_) |
| 331 webwidget_->mouseCaptureLost(); | 333 webwidget_->mouseCaptureLost(); |
| 332 } | 334 } |
| 333 | 335 |
| 334 void RenderWidget::OnSetFocus(bool enable) { | 336 void RenderWidget::OnSetFocus(bool enable) { |
| 335 has_focus_ = enable; | 337 has_focus_ = enable; |
| 336 if (webwidget_) | 338 if (webwidget_) { |
| 337 webwidget_->setFocus(enable); | 339 // Suppress focus / blur event if this RenderView creates a popup |
| 340 // menu and the popup menu is showing. |
| 341 // This is because the popup menu is a child of the RenderView and |
| 342 // when user clicks select control to show popup, we should not |
| 343 // consider this as focusing changes, so the focus / blur events |
| 344 // after popup menu is showing should be suppressed. The flag |
| 345 // will be reset once the popup menu is closed (see |
| 346 // RenderWidget::PopupMenuClosed). |
| 347 if (!showing_popup_menu_) |
| 348 webwidget_->setFocus(enable); |
| 349 } |
| 350 |
| 338 if (enable) { | 351 if (enable) { |
| 339 // Force to retrieve the state of the focused widget to determine if we | 352 // Force to retrieve the state of the focused widget to determine if we |
| 340 // should activate IMEs next time when this process calls the UpdateIME() | 353 // should activate IMEs next time when this process calls the UpdateIME() |
| 341 // function. | 354 // function. |
| 342 ime_control_updated_ = true; | 355 ime_control_updated_ = true; |
| 343 ime_control_new_state_ = true; | 356 ime_control_new_state_ = true; |
| 344 } | 357 } |
| 345 } | 358 } |
| 346 | 359 |
| 347 void RenderWidget::ClearFocus() { | 360 void RenderWidget::ClearFocus() { |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 MessageLoop::current()->PostTask(FROM_HERE, | 616 MessageLoop::current()->PostTask(FROM_HERE, |
| 604 NewRunnableMethod(this, &RenderWidget::ClearFocus)); | 617 NewRunnableMethod(this, &RenderWidget::ClearFocus)); |
| 605 } | 618 } |
| 606 } | 619 } |
| 607 | 620 |
| 608 void RenderWidget::didBlur() { | 621 void RenderWidget::didBlur() { |
| 609 Send(new ViewHostMsg_Blur(routing_id_)); | 622 Send(new ViewHostMsg_Blur(routing_id_)); |
| 610 } | 623 } |
| 611 | 624 |
| 612 void RenderWidget::DoDeferredClose() { | 625 void RenderWidget::DoDeferredClose() { |
| 626 if (popup_menu_owner_widget_.get()) { |
| 627 popup_menu_owner_widget_->PopupMenuClosed(); |
| 628 popup_menu_owner_widget_ = NULL; |
| 629 } |
| 630 |
| 613 Send(new ViewHostMsg_Close(routing_id_)); | 631 Send(new ViewHostMsg_Close(routing_id_)); |
| 614 } | 632 } |
| 615 | 633 |
| 616 void RenderWidget::closeWidgetSoon() { | 634 void RenderWidget::closeWidgetSoon() { |
| 617 // If a page calls window.close() twice, we'll end up here twice, but that's | 635 // If a page calls window.close() twice, we'll end up here twice, but that's |
| 618 // OK. It is safe to send multiple Close messages. | 636 // OK. It is safe to send multiple Close messages. |
| 619 | 637 |
| 620 // Ask the RenderWidgetHost to initiate close. We could be called from deep | 638 // Ask the RenderWidgetHost to initiate close. We could be called from deep |
| 621 // in Javascript. If we ask the RendwerWidgetHost to close now, the window | 639 // in Javascript. If we ask the RendwerWidgetHost to close now, the window |
| 622 // could be closed before the JS finishes executing. So instead, post a | 640 // could be closed before the JS finishes executing. So instead, post a |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 | 868 |
| 851 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { | 869 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { |
| 852 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); | 870 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); |
| 853 i != plugin_window_moves_.end(); ++i) { | 871 i != plugin_window_moves_.end(); ++i) { |
| 854 if (i->window == window) { | 872 if (i->window == window) { |
| 855 plugin_window_moves_.erase(i); | 873 plugin_window_moves_.erase(i); |
| 856 break; | 874 break; |
| 857 } | 875 } |
| 858 } | 876 } |
| 859 } | 877 } |
| 878 |
| 879 void RenderWidget::SetPopupMenuOwnerWidget(RenderWidget* widget) { |
| 880 popup_menu_owner_widget_ = widget; |
| 881 } |
| 882 |
| 883 void RenderWidget::PopupMenuClosed() { |
| 884 showing_popup_menu_ = false; |
| 885 } |
| OLD | NEW |