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