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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 return true; | 86 return true; |
87 default: | 87 default: |
88 break; | 88 break; |
89 } | 89 } |
90 return false; | 90 return false; |
91 } | 91 } |
92 | 92 |
93 } // namespace | 93 } // namespace |
94 | 94 |
95 RenderWidget::RenderWidget(WebKit::WebPopupType popup_type, | 95 RenderWidget::RenderWidget(WebKit::WebPopupType popup_type, |
96 const WebKit::WebScreenInfo& screen_info, | |
97 bool swapped_out) | 96 bool swapped_out) |
98 : routing_id_(MSG_ROUTING_NONE), | 97 : routing_id_(MSG_ROUTING_NONE), |
99 surface_id_(0), | 98 surface_id_(0), |
100 webwidget_(NULL), | 99 webwidget_(NULL), |
101 opener_id_(MSG_ROUTING_NONE), | 100 opener_id_(MSG_ROUTING_NONE), |
102 host_window_(0), | 101 host_window_(0), |
103 host_window_set_(false), | 102 host_window_set_(false), |
104 current_paint_buf_(NULL), | 103 current_paint_buf_(NULL), |
105 next_paint_flags_(0), | 104 next_paint_flags_(0), |
106 filtered_time_per_frame_(0.0f), | 105 filtered_time_per_frame_(0.0f), |
(...skipping 11 matching lines...) Expand all Loading... |
118 is_swapped_out_(swapped_out), | 117 is_swapped_out_(swapped_out), |
119 input_method_is_active_(false), | 118 input_method_is_active_(false), |
120 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 119 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
121 can_compose_inline_(true), | 120 can_compose_inline_(true), |
122 popup_type_(popup_type), | 121 popup_type_(popup_type), |
123 pending_window_rect_count_(0), | 122 pending_window_rect_count_(0), |
124 suppress_next_char_events_(false), | 123 suppress_next_char_events_(false), |
125 is_accelerated_compositing_active_(false), | 124 is_accelerated_compositing_active_(false), |
126 animation_update_pending_(false), | 125 animation_update_pending_(false), |
127 invalidation_task_posted_(false), | 126 invalidation_task_posted_(false), |
128 screen_info_(screen_info), | |
129 invert_(false) { | 127 invert_(false) { |
130 if (!swapped_out) | 128 if (!swapped_out) |
131 RenderProcess::current()->AddRefProcess(); | 129 RenderProcess::current()->AddRefProcess(); |
132 DCHECK(RenderThread::Get()); | 130 DCHECK(RenderThread::Get()); |
133 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( | 131 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( |
134 switches::kDisableGpuVsync); | 132 switches::kDisableGpuVsync); |
135 } | 133 } |
136 | 134 |
137 RenderWidget::~RenderWidget() { | 135 RenderWidget::~RenderWidget() { |
138 DCHECK(!webwidget_) << "Leaking our WebWidget!"; | 136 DCHECK(!webwidget_) << "Leaking our WebWidget!"; |
139 STLDeleteElements(&updates_pending_swap_); | 137 STLDeleteElements(&updates_pending_swap_); |
140 if (current_paint_buf_) { | 138 if (current_paint_buf_) { |
141 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); | 139 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); |
142 current_paint_buf_ = NULL; | 140 current_paint_buf_ = NULL; |
143 } | 141 } |
144 // If we are swapped out, we have released already. | 142 // If we are swapped out, we have released already. |
145 if (!is_swapped_out_) | 143 if (!is_swapped_out_) |
146 RenderProcess::current()->ReleaseProcess(); | 144 RenderProcess::current()->ReleaseProcess(); |
147 } | 145 } |
148 | 146 |
149 // static | 147 // static |
150 RenderWidget* RenderWidget::Create(int32 opener_id, | 148 RenderWidget* RenderWidget::Create(int32 opener_id, |
151 WebKit::WebPopupType popup_type, | 149 WebKit::WebPopupType popup_type) { |
152 const WebKit::WebScreenInfo& screen_info) { | |
153 DCHECK(opener_id != MSG_ROUTING_NONE); | 150 DCHECK(opener_id != MSG_ROUTING_NONE); |
154 scoped_refptr<RenderWidget> widget( | 151 scoped_refptr<RenderWidget> widget( |
155 new RenderWidget(popup_type, screen_info, false)); | 152 new RenderWidget(popup_type, false)); |
156 widget->Init(opener_id); // adds reference | 153 widget->Init(opener_id); // adds reference |
157 return widget; | 154 return widget; |
158 } | 155 } |
159 | 156 |
160 // static | 157 // static |
161 WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) { | 158 WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) { |
162 switch (render_widget->popup_type_) { | 159 switch (render_widget->popup_type_) { |
163 case WebKit::WebPopupTypeNone: // Nothing to create. | 160 case WebKit::WebPopupTypeNone: // Nothing to create. |
164 break; | 161 break; |
165 case WebKit::WebPopupTypeSelect: | 162 case WebKit::WebPopupTypeSelect: |
(...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1675 return static_cast<ui::TextInputType>(type); | 1672 return static_cast<ui::TextInputType>(type); |
1676 } | 1673 } |
1677 return ui::TEXT_INPUT_TYPE_NONE; | 1674 return ui::TEXT_INPUT_TYPE_NONE; |
1678 } | 1675 } |
1679 | 1676 |
1680 bool RenderWidget::CanComposeInline() { | 1677 bool RenderWidget::CanComposeInline() { |
1681 return true; | 1678 return true; |
1682 } | 1679 } |
1683 | 1680 |
1684 WebScreenInfo RenderWidget::screenInfo() { | 1681 WebScreenInfo RenderWidget::screenInfo() { |
1685 return screen_info_; | 1682 WebScreenInfo results; |
| 1683 if (host_window_set_) |
| 1684 Send(new ViewHostMsg_GetScreenInfo(routing_id_, host_window_, &results)); |
| 1685 else { |
| 1686 DLOG(WARNING) << "Unable to retrieve screen information, no host window"; |
| 1687 #if defined(USE_AURA) |
| 1688 // TODO(backer): Remove this a temporary workaround for crbug.com/111929 |
| 1689 // once we get a proper fix. |
| 1690 results.availableRect.width = 1000; |
| 1691 results.availableRect.height = 1000; |
| 1692 #endif |
| 1693 } |
| 1694 return results; |
1686 } | 1695 } |
1687 | 1696 |
1688 void RenderWidget::resetInputMethod() { | 1697 void RenderWidget::resetInputMethod() { |
1689 if (!input_method_is_active_) | 1698 if (!input_method_is_active_) |
1690 return; | 1699 return; |
1691 | 1700 |
1692 // If the last text input type is not None, then we should finish any | 1701 // If the last text input type is not None, then we should finish any |
1693 // ongoing composition regardless of the new text input type. | 1702 // ongoing composition regardless of the new text input type. |
1694 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE) { | 1703 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE) { |
1695 // If a composition text exists, then we need to let the browser process | 1704 // 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... |
1736 } | 1745 } |
1737 } | 1746 } |
1738 | 1747 |
1739 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 1748 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
1740 return false; | 1749 return false; |
1741 } | 1750 } |
1742 | 1751 |
1743 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { | 1752 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { |
1744 return false; | 1753 return false; |
1745 } | 1754 } |
OLD | NEW |