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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 using WebKit::WebRange; | 63 using WebKit::WebRange; |
64 using WebKit::WebRect; | 64 using WebKit::WebRect; |
65 using WebKit::WebScreenInfo; | 65 using WebKit::WebScreenInfo; |
66 using WebKit::WebSize; | 66 using WebKit::WebSize; |
67 using WebKit::WebTextDirection; | 67 using WebKit::WebTextDirection; |
68 using WebKit::WebTouchEvent; | 68 using WebKit::WebTouchEvent; |
69 using WebKit::WebVector; | 69 using WebKit::WebVector; |
70 using WebKit::WebWidget; | 70 using WebKit::WebWidget; |
71 using content::RenderThread; | 71 using content::RenderThread; |
72 | 72 |
73 RenderWidget::RenderWidget(WebKit::WebPopupType popup_type) | 73 RenderWidget::RenderWidget(WebKit::WebPopupType popup_type, |
| 74 const WebKit::WebScreenInfo& screen_info) |
74 : routing_id_(MSG_ROUTING_NONE), | 75 : routing_id_(MSG_ROUTING_NONE), |
75 surface_id_(0), | 76 surface_id_(0), |
76 webwidget_(NULL), | 77 webwidget_(NULL), |
77 opener_id_(MSG_ROUTING_NONE), | 78 opener_id_(MSG_ROUTING_NONE), |
78 host_window_(0), | 79 host_window_(0), |
79 host_window_set_(false), | 80 host_window_set_(false), |
80 current_paint_buf_(NULL), | 81 current_paint_buf_(NULL), |
81 next_paint_flags_(0), | 82 next_paint_flags_(0), |
82 filtered_time_per_frame_(0.0f), | 83 filtered_time_per_frame_(0.0f), |
83 update_reply_pending_(false), | 84 update_reply_pending_(false), |
(...skipping 10 matching lines...) Expand all Loading... |
94 input_method_is_active_(false), | 95 input_method_is_active_(false), |
95 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 96 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
96 can_compose_inline_(true), | 97 can_compose_inline_(true), |
97 popup_type_(popup_type), | 98 popup_type_(popup_type), |
98 pending_window_rect_count_(0), | 99 pending_window_rect_count_(0), |
99 suppress_next_char_events_(false), | 100 suppress_next_char_events_(false), |
100 is_accelerated_compositing_active_(false), | 101 is_accelerated_compositing_active_(false), |
101 animation_update_pending_(false), | 102 animation_update_pending_(false), |
102 animation_task_posted_(false), | 103 animation_task_posted_(false), |
103 invalidation_task_posted_(false), | 104 invalidation_task_posted_(false), |
| 105 screen_info_(screen_info), |
104 invert_(false) { | 106 invert_(false) { |
105 RenderProcess::current()->AddRefProcess(); | 107 RenderProcess::current()->AddRefProcess(); |
106 DCHECK(RenderThread::Get()); | 108 DCHECK(RenderThread::Get()); |
107 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( | 109 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( |
108 switches::kDisableGpuVsync); | 110 switches::kDisableGpuVsync); |
109 } | 111 } |
110 | 112 |
111 RenderWidget::~RenderWidget() { | 113 RenderWidget::~RenderWidget() { |
112 DCHECK(!webwidget_) << "Leaking our WebWidget!"; | 114 DCHECK(!webwidget_) << "Leaking our WebWidget!"; |
113 STLDeleteElements(&updates_pending_swap_); | 115 STLDeleteElements(&updates_pending_swap_); |
114 if (current_paint_buf_) { | 116 if (current_paint_buf_) { |
115 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); | 117 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); |
116 current_paint_buf_ = NULL; | 118 current_paint_buf_ = NULL; |
117 } | 119 } |
118 // If we are swapped out, we have released already. | 120 // If we are swapped out, we have released already. |
119 if (!is_swapped_out_) | 121 if (!is_swapped_out_) |
120 RenderProcess::current()->ReleaseProcess(); | 122 RenderProcess::current()->ReleaseProcess(); |
121 } | 123 } |
122 | 124 |
123 // static | 125 // static |
124 RenderWidget* RenderWidget::Create(int32 opener_id, | 126 RenderWidget* RenderWidget::Create(int32 opener_id, |
125 WebKit::WebPopupType popup_type) { | 127 WebKit::WebPopupType popup_type, |
| 128 const WebKit::WebScreenInfo& screen_info) { |
126 DCHECK(opener_id != MSG_ROUTING_NONE); | 129 DCHECK(opener_id != MSG_ROUTING_NONE); |
127 scoped_refptr<RenderWidget> widget(new RenderWidget(popup_type)); | 130 scoped_refptr<RenderWidget> widget( |
| 131 new RenderWidget(popup_type, screen_info)); |
128 widget->Init(opener_id); // adds reference | 132 widget->Init(opener_id); // adds reference |
129 return widget; | 133 return widget; |
130 } | 134 } |
131 | 135 |
132 // static | 136 // static |
133 WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) { | 137 WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) { |
134 switch (render_widget->popup_type_) { | 138 switch (render_widget->popup_type_) { |
135 case WebKit::WebPopupTypeNone: // Nothing to create. | 139 case WebKit::WebPopupTypeNone: // Nothing to create. |
136 break; | 140 break; |
137 case WebKit::WebPopupTypeSelect: | 141 case WebKit::WebPopupTypeSelect: |
(...skipping 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1579 return static_cast<ui::TextInputType>(type); | 1583 return static_cast<ui::TextInputType>(type); |
1580 } | 1584 } |
1581 return ui::TEXT_INPUT_TYPE_NONE; | 1585 return ui::TEXT_INPUT_TYPE_NONE; |
1582 } | 1586 } |
1583 | 1587 |
1584 bool RenderWidget::CanComposeInline() { | 1588 bool RenderWidget::CanComposeInline() { |
1585 return true; | 1589 return true; |
1586 } | 1590 } |
1587 | 1591 |
1588 WebScreenInfo RenderWidget::screenInfo() { | 1592 WebScreenInfo RenderWidget::screenInfo() { |
1589 WebScreenInfo results; | 1593 return screen_info_; |
1590 if (host_window_set_) | |
1591 Send(new ViewHostMsg_GetScreenInfo(routing_id_, host_window_, &results)); | |
1592 else { | |
1593 DLOG(WARNING) << "Unable to retrieve screen information, no host window"; | |
1594 #if defined(USE_AURA) | |
1595 // TODO(backer): Remove this a temporary workaround for crbug.com/111929 | |
1596 // once we get a proper fix. | |
1597 results.availableRect.width = 1000; | |
1598 results.availableRect.height = 1000; | |
1599 #endif | |
1600 } | |
1601 return results; | |
1602 } | 1594 } |
1603 | 1595 |
1604 void RenderWidget::resetInputMethod() { | 1596 void RenderWidget::resetInputMethod() { |
1605 if (!input_method_is_active_) | 1597 if (!input_method_is_active_) |
1606 return; | 1598 return; |
1607 | 1599 |
1608 // If the last text input type is not None, then we should finish any | 1600 // If the last text input type is not None, then we should finish any |
1609 // ongoing composition regardless of the new text input type. | 1601 // ongoing composition regardless of the new text input type. |
1610 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE) { | 1602 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE) { |
1611 // If a composition text exists, then we need to let the browser process | 1603 // 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... |
1652 } | 1644 } |
1653 } | 1645 } |
1654 | 1646 |
1655 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 1647 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
1656 return false; | 1648 return false; |
1657 } | 1649 } |
1658 | 1650 |
1659 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { | 1651 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { |
1660 return false; | 1652 return false; |
1661 } | 1653 } |
OLD | NEW |