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, bool activatable) |
73 bool focus_on_show) | |
74 : routing_id_(MSG_ROUTING_NONE), | 73 : routing_id_(MSG_ROUTING_NONE), |
75 opener_id_(MSG_ROUTING_NONE), | 74 opener_id_(MSG_ROUTING_NONE), |
76 render_thread_(render_thread), | 75 render_thread_(render_thread), |
77 host_window_(NULL), | 76 host_window_(NULL), |
78 current_paint_buf_(NULL), | 77 current_paint_buf_(NULL), |
79 current_scroll_buf_(NULL), | 78 current_scroll_buf_(NULL), |
80 next_paint_flags_(0), | 79 next_paint_flags_(0), |
81 paint_reply_pending_(false), | 80 paint_reply_pending_(false), |
82 did_show_(false), | 81 did_show_(false), |
83 closing_(false), | 82 closing_(false), |
84 is_hidden_(false), | 83 is_hidden_(false), |
85 needs_repainting_on_restore_(false), | 84 needs_repainting_on_restore_(false), |
86 has_focus_(false), | 85 has_focus_(false), |
87 ime_is_active_(false), | 86 ime_is_active_(false), |
88 ime_control_enable_ime_(true), | 87 ime_control_enable_ime_(true), |
89 ime_control_x_(-1), | 88 ime_control_x_(-1), |
90 ime_control_y_(-1), | 89 ime_control_y_(-1), |
91 ime_control_new_state_(false), | 90 ime_control_new_state_(false), |
92 ime_control_updated_(false), | 91 ime_control_updated_(false), |
93 ime_control_busy_(false), | 92 ime_control_busy_(false), |
94 focus_on_show_(focus_on_show) { | 93 activatable_(activatable) { |
95 RenderProcess::AddRefProcess(); | 94 RenderProcess::AddRefProcess(); |
96 DCHECK(render_thread_); | 95 DCHECK(render_thread_); |
97 } | 96 } |
98 | 97 |
99 RenderWidget::~RenderWidget() { | 98 RenderWidget::~RenderWidget() { |
100 if (current_paint_buf_) { | 99 if (current_paint_buf_) { |
101 RenderProcess::FreeSharedMemory(current_paint_buf_); | 100 RenderProcess::FreeSharedMemory(current_paint_buf_); |
102 current_paint_buf_ = NULL; | 101 current_paint_buf_ = NULL; |
103 } | 102 } |
104 if (current_scroll_buf_) { | 103 if (current_scroll_buf_) { |
105 RenderProcess::FreeSharedMemory(current_scroll_buf_); | 104 RenderProcess::FreeSharedMemory(current_scroll_buf_); |
106 current_scroll_buf_ = NULL; | 105 current_scroll_buf_ = NULL; |
107 } | 106 } |
108 RenderProcess::ReleaseProcess(); | 107 RenderProcess::ReleaseProcess(); |
109 } | 108 } |
110 | 109 |
111 /*static*/ | 110 /*static*/ |
112 RenderWidget* RenderWidget::Create(int32 opener_id, | 111 RenderWidget* RenderWidget::Create(int32 opener_id, |
113 RenderThreadBase* render_thread, | 112 RenderThreadBase* render_thread, |
114 bool focus_on_show) { | 113 bool activatable) { |
115 DCHECK(opener_id != MSG_ROUTING_NONE); | 114 DCHECK(opener_id != MSG_ROUTING_NONE); |
116 scoped_refptr<RenderWidget> widget = new RenderWidget(render_thread, | 115 scoped_refptr<RenderWidget> widget = new RenderWidget(render_thread, |
117 focus_on_show); | 116 activatable); |
118 widget->Init(opener_id); // adds reference | 117 widget->Init(opener_id); // adds reference |
119 return widget; | 118 return widget; |
120 } | 119 } |
121 | 120 |
122 void RenderWidget::Init(int32 opener_id) { | 121 void RenderWidget::Init(int32 opener_id) { |
123 DCHECK(!webwidget_); | 122 DCHECK(!webwidget_); |
124 | 123 |
125 if (opener_id != MSG_ROUTING_NONE) | 124 if (opener_id != MSG_ROUTING_NONE) |
126 opener_id_ = opener_id; | 125 opener_id_ = opener_id; |
127 | 126 |
128 // 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. |
129 WebWidget* webwidget = WebWidget::Create(this); | 128 WebWidget* webwidget = WebWidget::Create(this); |
130 webwidget_.swap(&webwidget); | 129 webwidget_.swap(&webwidget); |
131 | 130 |
132 bool result = render_thread_->Send( | 131 bool result = render_thread_->Send( |
133 new ViewHostMsg_CreateWidget(opener_id, focus_on_show_, &routing_id_)); | 132 new ViewHostMsg_CreateWidget(opener_id, activatable_, &routing_id_)); |
134 if (result) { | 133 if (result) { |
135 render_thread_->AddRoute(routing_id_, this); | 134 render_thread_->AddRoute(routing_id_, this); |
136 // 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 |
137 // when we receive ViewMsg_Close. | 136 // when we receive ViewMsg_Close. |
138 AddRef(); | 137 AddRef(); |
139 } else { | 138 } else { |
140 DCHECK(false); | 139 DCHECK(false); |
141 } | 140 } |
142 } | 141 } |
143 | 142 |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 for (; i < plugin_window_moves_.size(); ++i) { | 769 for (; i < plugin_window_moves_.size(); ++i) { |
771 if (plugin_window_moves_[i].window == move.window) { | 770 if (plugin_window_moves_[i].window == move.window) { |
772 plugin_window_moves_[i] = move; | 771 plugin_window_moves_[i] = move; |
773 break; | 772 break; |
774 } | 773 } |
775 } | 774 } |
776 | 775 |
777 if (i == plugin_window_moves_.size()) | 776 if (i == plugin_window_moves_.size()) |
778 plugin_window_moves_.push_back(move); | 777 plugin_window_moves_.push_back(move); |
779 } | 778 } |
OLD | NEW |