OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 using WebKit::WebRange; | 61 using WebKit::WebRange; |
62 using WebKit::WebRect; | 62 using WebKit::WebRect; |
63 using WebKit::WebScreenInfo; | 63 using WebKit::WebScreenInfo; |
64 using WebKit::WebSize; | 64 using WebKit::WebSize; |
65 using WebKit::WebTextDirection; | 65 using WebKit::WebTextDirection; |
66 using WebKit::WebTouchEvent; | 66 using WebKit::WebTouchEvent; |
67 using WebKit::WebVector; | 67 using WebKit::WebVector; |
68 using WebKit::WebWidget; | 68 using WebKit::WebWidget; |
69 using content::RenderThread; | 69 using content::RenderThread; |
70 | 70 |
71 RenderWidget::RenderWidget(WebKit::WebPopupType popup_type) | 71 RenderWidget::RenderWidget(WebKit::WebPopupType popup_type, |
| 72 const WebKit::WebScreenInfo& screen_info) |
72 : routing_id_(MSG_ROUTING_NONE), | 73 : routing_id_(MSG_ROUTING_NONE), |
73 surface_id_(0), | 74 surface_id_(0), |
74 webwidget_(NULL), | 75 webwidget_(NULL), |
75 opener_id_(MSG_ROUTING_NONE), | 76 opener_id_(MSG_ROUTING_NONE), |
76 host_window_(0), | 77 host_window_(0), |
77 current_paint_buf_(NULL), | 78 current_paint_buf_(NULL), |
78 next_paint_flags_(0), | 79 next_paint_flags_(0), |
79 filtered_time_per_frame_(0.0f), | 80 filtered_time_per_frame_(0.0f), |
80 update_reply_pending_(false), | 81 update_reply_pending_(false), |
81 using_asynchronous_swapbuffers_(false), | 82 using_asynchronous_swapbuffers_(false), |
82 num_swapbuffers_complete_pending_(0), | 83 num_swapbuffers_complete_pending_(0), |
83 did_show_(false), | 84 did_show_(false), |
84 is_hidden_(false), | 85 is_hidden_(false), |
85 is_fullscreen_(false), | 86 is_fullscreen_(false), |
86 needs_repainting_on_restore_(false), | 87 needs_repainting_on_restore_(false), |
87 has_focus_(false), | 88 has_focus_(false), |
88 handling_input_event_(false), | 89 handling_input_event_(false), |
89 closing_(false), | 90 closing_(false), |
90 is_swapped_out_(false), | 91 is_swapped_out_(false), |
91 input_method_is_active_(false), | 92 input_method_is_active_(false), |
92 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 93 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
93 can_compose_inline_(true), | 94 can_compose_inline_(true), |
94 popup_type_(popup_type), | 95 popup_type_(popup_type), |
95 pending_window_rect_count_(0), | 96 pending_window_rect_count_(0), |
96 suppress_next_char_events_(false), | 97 suppress_next_char_events_(false), |
97 is_accelerated_compositing_active_(false), | 98 is_accelerated_compositing_active_(false), |
98 animation_update_pending_(false), | 99 animation_update_pending_(false), |
99 animation_task_posted_(false), | 100 animation_task_posted_(false), |
100 invalidation_task_posted_(false) { | 101 invalidation_task_posted_(false), |
| 102 screen_info_(screen_info) { |
101 RenderProcess::current()->AddRefProcess(); | 103 RenderProcess::current()->AddRefProcess(); |
102 DCHECK(RenderThread::Get()); | 104 DCHECK(RenderThread::Get()); |
103 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( | 105 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( |
104 switches::kDisableGpuVsync); | 106 switches::kDisableGpuVsync); |
105 } | 107 } |
106 | 108 |
107 RenderWidget::~RenderWidget() { | 109 RenderWidget::~RenderWidget() { |
108 DCHECK(!webwidget_) << "Leaking our WebWidget!"; | 110 DCHECK(!webwidget_) << "Leaking our WebWidget!"; |
109 STLDeleteElements(&updates_pending_swap_); | 111 STLDeleteElements(&updates_pending_swap_); |
110 if (current_paint_buf_) { | 112 if (current_paint_buf_) { |
111 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); | 113 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); |
112 current_paint_buf_ = NULL; | 114 current_paint_buf_ = NULL; |
113 } | 115 } |
114 // If we are swapped out, we have released already. | 116 // If we are swapped out, we have released already. |
115 if (!is_swapped_out_) | 117 if (!is_swapped_out_) |
116 RenderProcess::current()->ReleaseProcess(); | 118 RenderProcess::current()->ReleaseProcess(); |
117 } | 119 } |
118 | 120 |
119 // static | 121 // static |
120 RenderWidget* RenderWidget::Create(int32 opener_id, | 122 RenderWidget* RenderWidget::Create(int32 opener_id, |
121 WebKit::WebPopupType popup_type) { | 123 WebKit::WebPopupType popup_type, |
| 124 const WebKit::WebScreenInfo& screen_info) { |
122 DCHECK(opener_id != MSG_ROUTING_NONE); | 125 DCHECK(opener_id != MSG_ROUTING_NONE); |
123 scoped_refptr<RenderWidget> widget(new RenderWidget(popup_type)); | 126 scoped_refptr<RenderWidget> widget( |
| 127 new RenderWidget(popup_type, screen_info)); |
124 widget->Init(opener_id); // adds reference | 128 widget->Init(opener_id); // adds reference |
125 return widget; | 129 return widget; |
126 } | 130 } |
127 | 131 |
128 // static | 132 // static |
129 WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) { | 133 WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) { |
130 switch (render_widget->popup_type_) { | 134 switch (render_widget->popup_type_) { |
131 case WebKit::WebPopupTypeNone: // Nothing to create. | 135 case WebKit::WebPopupTypeNone: // Nothing to create. |
132 break; | 136 break; |
133 case WebKit::WebPopupTypeSelect: | 137 case WebKit::WebPopupTypeSelect: |
(...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1496 return static_cast<ui::TextInputType>(type); | 1500 return static_cast<ui::TextInputType>(type); |
1497 } | 1501 } |
1498 return ui::TEXT_INPUT_TYPE_NONE; | 1502 return ui::TEXT_INPUT_TYPE_NONE; |
1499 } | 1503 } |
1500 | 1504 |
1501 bool RenderWidget::CanComposeInline() { | 1505 bool RenderWidget::CanComposeInline() { |
1502 return true; | 1506 return true; |
1503 } | 1507 } |
1504 | 1508 |
1505 WebScreenInfo RenderWidget::screenInfo() { | 1509 WebScreenInfo RenderWidget::screenInfo() { |
1506 WebScreenInfo results; | 1510 return screen_info_; |
1507 Send(new ViewHostMsg_GetScreenInfo(routing_id_, host_window_, &results)); | |
1508 return results; | |
1509 } | 1511 } |
1510 | 1512 |
1511 void RenderWidget::resetInputMethod() { | 1513 void RenderWidget::resetInputMethod() { |
1512 if (!input_method_is_active_) | 1514 if (!input_method_is_active_) |
1513 return; | 1515 return; |
1514 | 1516 |
1515 // If the last text input type is not None, then we should finish any | 1517 // If the last text input type is not None, then we should finish any |
1516 // ongoing composition regardless of the new text input type. | 1518 // ongoing composition regardless of the new text input type. |
1517 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE) { | 1519 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE) { |
1518 // If a composition text exists, then we need to let the browser process | 1520 // If a composition text exists, then we need to let the browser process |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1559 } | 1561 } |
1560 } | 1562 } |
1561 | 1563 |
1562 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 1564 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
1563 return false; | 1565 return false; |
1564 } | 1566 } |
1565 | 1567 |
1566 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { | 1568 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { |
1567 return false; | 1569 return false; |
1568 } | 1570 } |
OLD | NEW |