| 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 "content/renderer/render_widget.h" | 5 #include "content/renderer/render_widget.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 using WebKit::WebMouseEvent; | 51 using WebKit::WebMouseEvent; |
| 52 using WebKit::WebNavigationPolicy; | 52 using WebKit::WebNavigationPolicy; |
| 53 using WebKit::WebPopupMenu; | 53 using WebKit::WebPopupMenu; |
| 54 using WebKit::WebPopupMenuInfo; | 54 using WebKit::WebPopupMenuInfo; |
| 55 using WebKit::WebPopupType; | 55 using WebKit::WebPopupType; |
| 56 using WebKit::WebRange; | 56 using WebKit::WebRange; |
| 57 using WebKit::WebRect; | 57 using WebKit::WebRect; |
| 58 using WebKit::WebScreenInfo; | 58 using WebKit::WebScreenInfo; |
| 59 using WebKit::WebSize; | 59 using WebKit::WebSize; |
| 60 using WebKit::WebTextDirection; | 60 using WebKit::WebTextDirection; |
| 61 using WebKit::WebTextInputType; | |
| 62 using WebKit::WebVector; | 61 using WebKit::WebVector; |
| 63 using WebKit::WebWidget; | 62 using WebKit::WebWidget; |
| 64 | 63 |
| 65 RenderWidget::RenderWidget(RenderThreadBase* render_thread, | 64 RenderWidget::RenderWidget(RenderThreadBase* render_thread, |
| 66 WebKit::WebPopupType popup_type) | 65 WebKit::WebPopupType popup_type) |
| 67 : routing_id_(MSG_ROUTING_NONE), | 66 : routing_id_(MSG_ROUTING_NONE), |
| 68 webwidget_(NULL), | 67 webwidget_(NULL), |
| 69 opener_id_(MSG_ROUTING_NONE), | 68 opener_id_(MSG_ROUTING_NONE), |
| 70 render_thread_(render_thread), | 69 render_thread_(render_thread), |
| 71 host_window_(0), | 70 host_window_(0), |
| 72 current_paint_buf_(NULL), | 71 current_paint_buf_(NULL), |
| 73 next_paint_flags_(0), | 72 next_paint_flags_(0), |
| 74 filtered_time_per_frame_(1.0f/60.0f), | 73 filtered_time_per_frame_(1.0f/60.0f), |
| 75 update_reply_pending_(false), | 74 update_reply_pending_(false), |
| 76 using_asynchronous_swapbuffers_(false), | 75 using_asynchronous_swapbuffers_(false), |
| 77 num_swapbuffers_complete_pending_(0), | 76 num_swapbuffers_complete_pending_(0), |
| 78 did_show_(false), | 77 did_show_(false), |
| 79 is_hidden_(false), | 78 is_hidden_(false), |
| 80 needs_repainting_on_restore_(false), | 79 needs_repainting_on_restore_(false), |
| 81 has_focus_(false), | 80 has_focus_(false), |
| 82 handling_input_event_(false), | 81 handling_input_event_(false), |
| 83 closing_(false), | 82 closing_(false), |
| 84 is_swapped_out_(false), | 83 is_swapped_out_(false), |
| 85 input_method_is_active_(false), | 84 input_method_is_active_(false), |
| 86 text_input_type_(WebKit::WebTextInputTypeNone), | 85 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| 86 can_compose_inline_(true), |
| 87 popup_type_(popup_type), | 87 popup_type_(popup_type), |
| 88 pending_window_rect_count_(0), | 88 pending_window_rect_count_(0), |
| 89 suppress_next_char_events_(false), | 89 suppress_next_char_events_(false), |
| 90 is_accelerated_compositing_active_(false), | 90 is_accelerated_compositing_active_(false), |
| 91 animation_update_pending_(false), | 91 animation_update_pending_(false), |
| 92 animation_task_posted_(false), | 92 animation_task_posted_(false), |
| 93 invalidation_task_posted_(false) { | 93 invalidation_task_posted_(false) { |
| 94 RenderProcess::current()->AddRefProcess(); | 94 RenderProcess::current()->AddRefProcess(); |
| 95 DCHECK(render_thread_); | 95 DCHECK(render_thread_); |
| 96 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( | 96 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( |
| (...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1271 } | 1271 } |
| 1272 | 1272 |
| 1273 void RenderWidget::set_next_paint_is_repaint_ack() { | 1273 void RenderWidget::set_next_paint_is_repaint_ack() { |
| 1274 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK; | 1274 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK; |
| 1275 } | 1275 } |
| 1276 | 1276 |
| 1277 void RenderWidget::UpdateInputMethod() { | 1277 void RenderWidget::UpdateInputMethod() { |
| 1278 if (!input_method_is_active_) | 1278 if (!input_method_is_active_) |
| 1279 return; | 1279 return; |
| 1280 | 1280 |
| 1281 WebTextInputType new_type = GetTextInputType(); | 1281 ui::TextInputType new_type = GetTextInputType(); |
| 1282 bool new_can_compose_inline = CanComposeInline(); |
| 1282 WebRect new_caret_bounds; | 1283 WebRect new_caret_bounds; |
| 1283 | 1284 |
| 1284 if (webwidget_) | 1285 if (webwidget_) |
| 1285 new_caret_bounds = webwidget_->caretOrSelectionBounds(); | 1286 new_caret_bounds = webwidget_->caretOrSelectionBounds(); |
| 1286 | 1287 |
| 1287 // Only sends text input type and caret bounds to the browser process if they | 1288 // Only sends text input type and caret bounds to the browser process if they |
| 1288 // are changed. | 1289 // are changed. |
| 1289 if (text_input_type_ != new_type || caret_bounds_ != new_caret_bounds) { | 1290 if (text_input_type_ != new_type || caret_bounds_ != new_caret_bounds || |
| 1291 can_compose_inline_ != new_can_compose_inline) { |
| 1290 text_input_type_ = new_type; | 1292 text_input_type_ = new_type; |
| 1293 can_compose_inline_ = new_can_compose_inline; |
| 1291 caret_bounds_ = new_caret_bounds; | 1294 caret_bounds_ = new_caret_bounds; |
| 1292 Send(new ViewHostMsg_ImeUpdateTextInputState( | 1295 Send(new ViewHostMsg_ImeUpdateTextInputState( |
| 1293 routing_id(), new_type, new_caret_bounds)); | 1296 routing_id(), new_type, new_can_compose_inline, new_caret_bounds)); |
| 1294 } | 1297 } |
| 1295 } | 1298 } |
| 1296 | 1299 |
| 1297 WebKit::WebTextInputType RenderWidget::GetTextInputType() { | 1300 ui::TextInputType RenderWidget::GetTextInputType() { |
| 1298 if (webwidget_) | 1301 if (webwidget_) |
| 1299 return webwidget_->textInputType(); | 1302 return static_cast<ui::TextInputType>(webwidget_->textInputType()); |
| 1300 return WebKit::WebTextInputTypeNone; | 1303 return ui::TEXT_INPUT_TYPE_NONE; |
| 1304 } |
| 1305 |
| 1306 bool RenderWidget::CanComposeInline() { |
| 1307 return true; |
| 1301 } | 1308 } |
| 1302 | 1309 |
| 1303 WebScreenInfo RenderWidget::screenInfo() { | 1310 WebScreenInfo RenderWidget::screenInfo() { |
| 1304 WebScreenInfo results; | 1311 WebScreenInfo results; |
| 1305 Send(new ViewHostMsg_GetScreenInfo(routing_id_, host_window_, &results)); | 1312 Send(new ViewHostMsg_GetScreenInfo(routing_id_, host_window_, &results)); |
| 1306 return results; | 1313 return results; |
| 1307 } | 1314 } |
| 1308 | 1315 |
| 1309 void RenderWidget::resetInputMethod() { | 1316 void RenderWidget::resetInputMethod() { |
| 1310 if (!input_method_is_active_) | 1317 if (!input_method_is_active_) |
| 1311 return; | 1318 return; |
| 1312 | 1319 |
| 1313 // If the last text input type is not None, then we should finish any | 1320 // If the last text input type is not None, then we should finish any |
| 1314 // ongoing composition regardless of the new text input type. | 1321 // ongoing composition regardless of the new text input type. |
| 1315 if (text_input_type_ != WebKit::WebTextInputTypeNone) { | 1322 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE) { |
| 1316 // If a composition text exists, then we need to let the browser process | 1323 // If a composition text exists, then we need to let the browser process |
| 1317 // to cancel the input method's ongoing composition session. | 1324 // to cancel the input method's ongoing composition session. |
| 1318 if (webwidget_->confirmComposition()) | 1325 if (webwidget_->confirmComposition()) |
| 1319 Send(new ViewHostMsg_ImeCancelComposition(routing_id())); | 1326 Send(new ViewHostMsg_ImeCancelComposition(routing_id())); |
| 1320 } | 1327 } |
| 1321 | 1328 |
| 1322 // Send an updated IME range with the current caret rect. | 1329 // Send an updated IME range with the current caret rect. |
| 1323 ui::Range range(ui::Range::InvalidRange()); | 1330 ui::Range range(ui::Range::InvalidRange()); |
| 1324 size_t location, length; | 1331 size_t location, length; |
| 1325 if (webwidget_->caretOrSelectionRange(&location, &length)) { | 1332 if (webwidget_->caretOrSelectionRange(&location, &length)) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1349 | 1356 |
| 1350 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { | 1357 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { |
| 1351 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); | 1358 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); |
| 1352 i != plugin_window_moves_.end(); ++i) { | 1359 i != plugin_window_moves_.end(); ++i) { |
| 1353 if (i->window == window) { | 1360 if (i->window == window) { |
| 1354 plugin_window_moves_.erase(i); | 1361 plugin_window_moves_.erase(i); |
| 1355 break; | 1362 break; |
| 1356 } | 1363 } |
| 1357 } | 1364 } |
| 1358 } | 1365 } |
| OLD | NEW |