| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/gfx/point.h" | 9 #include "base/gfx/point.h" |
| 10 #include "base/gfx/size.h" | 10 #include "base/gfx/size.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 typedef std::queue< scoped_refptr<RenderWidget> > WidgetQueue; | 62 typedef std::queue< scoped_refptr<RenderWidget> > WidgetQueue; |
| 63 WidgetQueue queue_; | 63 WidgetQueue queue_; |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 DeferredCloses* DeferredCloses::current_ = NULL; | 66 DeferredCloses* DeferredCloses::current_ = NULL; |
| 67 | 67 |
| 68 } // namespace | 68 } // namespace |
| 69 | 69 |
| 70 /////////////////////////////////////////////////////////////////////////////// | 70 /////////////////////////////////////////////////////////////////////////////// |
| 71 | 71 |
| 72 RenderWidget::RenderWidget(RenderThreadBase* render_thread) | 72 RenderWidget::RenderWidget(RenderThreadBase* render_thread, |
| 73 bool focus_on_show) |
| 73 : routing_id_(MSG_ROUTING_NONE), | 74 : routing_id_(MSG_ROUTING_NONE), |
| 74 opener_id_(MSG_ROUTING_NONE), | 75 opener_id_(MSG_ROUTING_NONE), |
| 75 render_thread_(render_thread), | 76 render_thread_(render_thread), |
| 76 host_window_(NULL), | 77 host_window_(NULL), |
| 77 current_paint_buf_(NULL), | 78 current_paint_buf_(NULL), |
| 78 current_scroll_buf_(NULL), | 79 current_scroll_buf_(NULL), |
| 79 next_paint_flags_(0), | 80 next_paint_flags_(0), |
| 80 paint_reply_pending_(false), | 81 paint_reply_pending_(false), |
| 81 did_show_(false), | 82 did_show_(false), |
| 82 closing_(false), | 83 closing_(false), |
| 83 is_hidden_(false), | 84 is_hidden_(false), |
| 84 needs_repainting_on_restore_(false), | 85 needs_repainting_on_restore_(false), |
| 85 has_focus_(false), | 86 has_focus_(false), |
| 86 ime_is_active_(false), | 87 ime_is_active_(false), |
| 87 ime_control_enable_ime_(true), | 88 ime_control_enable_ime_(true), |
| 88 ime_control_x_(-1), | 89 ime_control_x_(-1), |
| 89 ime_control_y_(-1), | 90 ime_control_y_(-1), |
| 90 ime_control_new_state_(false), | 91 ime_control_new_state_(false), |
| 91 ime_control_updated_(false) { | 92 ime_control_updated_(false), |
| 93 focus_on_show_(focus_on_show) { |
| 92 RenderProcess::AddRefProcess(); | 94 RenderProcess::AddRefProcess(); |
| 93 DCHECK(render_thread_); | 95 DCHECK(render_thread_); |
| 94 } | 96 } |
| 95 | 97 |
| 96 RenderWidget::~RenderWidget() { | 98 RenderWidget::~RenderWidget() { |
| 97 if (current_paint_buf_) { | 99 if (current_paint_buf_) { |
| 98 RenderProcess::FreeSharedMemory(current_paint_buf_); | 100 RenderProcess::FreeSharedMemory(current_paint_buf_); |
| 99 current_paint_buf_ = NULL; | 101 current_paint_buf_ = NULL; |
| 100 } | 102 } |
| 101 if (current_scroll_buf_) { | 103 if (current_scroll_buf_) { |
| 102 RenderProcess::FreeSharedMemory(current_scroll_buf_); | 104 RenderProcess::FreeSharedMemory(current_scroll_buf_); |
| 103 current_scroll_buf_ = NULL; | 105 current_scroll_buf_ = NULL; |
| 104 } | 106 } |
| 105 RenderProcess::ReleaseProcess(); | 107 RenderProcess::ReleaseProcess(); |
| 106 } | 108 } |
| 107 | 109 |
| 108 /*static*/ | 110 /*static*/ |
| 109 RenderWidget* RenderWidget::Create(int32 opener_id, | 111 RenderWidget* RenderWidget::Create(int32 opener_id, |
| 110 RenderThreadBase* render_thread) { | 112 RenderThreadBase* render_thread, |
| 113 bool focus_on_show) { |
| 111 DCHECK(opener_id != MSG_ROUTING_NONE); | 114 DCHECK(opener_id != MSG_ROUTING_NONE); |
| 112 scoped_refptr<RenderWidget> widget = new RenderWidget(render_thread); | 115 scoped_refptr<RenderWidget> widget = new RenderWidget(render_thread, |
| 116 focus_on_show); |
| 113 widget->Init(opener_id); // adds reference | 117 widget->Init(opener_id); // adds reference |
| 114 return widget; | 118 return widget; |
| 115 } | 119 } |
| 116 | 120 |
| 117 void RenderWidget::Init(int32 opener_id) { | 121 void RenderWidget::Init(int32 opener_id) { |
| 118 DCHECK(!webwidget_); | 122 DCHECK(!webwidget_); |
| 119 | 123 |
| 120 if (opener_id != MSG_ROUTING_NONE) | 124 if (opener_id != MSG_ROUTING_NONE) |
| 121 opener_id_ = opener_id; | 125 opener_id_ = opener_id; |
| 122 | 126 |
| 123 // Avoid a leak here by not assigning, since WebWidget::Create addrefs for us. | 127 // Avoid a leak here by not assigning, since WebWidget::Create addrefs for us. |
| 124 WebWidget* webwidget = WebWidget::Create(this); | 128 WebWidget* webwidget = WebWidget::Create(this); |
| 125 webwidget_.swap(&webwidget); | 129 webwidget_.swap(&webwidget); |
| 126 | 130 |
| 127 bool result = render_thread_->Send( | 131 bool result = render_thread_->Send( |
| 128 new ViewHostMsg_CreateWidget(opener_id, &routing_id_)); | 132 new ViewHostMsg_CreateWidget(opener_id, focus_on_show_, &routing_id_)); |
| 129 if (result) { | 133 if (result) { |
| 130 render_thread_->AddRoute(routing_id_, this); | 134 render_thread_->AddRoute(routing_id_, this); |
| 131 // Take a reference on behalf of the RenderThread. This will be balanced | 135 // Take a reference on behalf of the RenderThread. This will be balanced |
| 132 // when we receive ViewMsg_Close. | 136 // when we receive ViewMsg_Close. |
| 133 AddRef(); | 137 AddRef(); |
| 134 } else { | 138 } else { |
| 135 DCHECK(false); | 139 DCHECK(false); |
| 136 } | 140 } |
| 137 } | 141 } |
| 138 | 142 |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 for (; i < plugin_window_moves_.size(); ++i) { | 754 for (; i < plugin_window_moves_.size(); ++i) { |
| 751 if (plugin_window_moves_[i].window == move.window) { | 755 if (plugin_window_moves_[i].window == move.window) { |
| 752 plugin_window_moves_[i] = move; | 756 plugin_window_moves_[i] = move; |
| 753 break; | 757 break; |
| 754 } | 758 } |
| 755 } | 759 } |
| 756 | 760 |
| 757 if (i == plugin_window_moves_.size()) | 761 if (i == plugin_window_moves_.size()) |
| 758 plugin_window_moves_.push_back(move); | 762 plugin_window_moves_.push_back(move); |
| 759 } | 763 } |
| OLD | NEW |