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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 using WebKit::WebRect; | 67 using WebKit::WebRect; |
68 using WebKit::WebScreenInfo; | 68 using WebKit::WebScreenInfo; |
69 using WebKit::WebSize; | 69 using WebKit::WebSize; |
70 using WebKit::WebTextDirection; | 70 using WebKit::WebTextDirection; |
71 using WebKit::WebTouchEvent; | 71 using WebKit::WebTouchEvent; |
72 using WebKit::WebVector; | 72 using WebKit::WebVector; |
73 using WebKit::WebWidget; | 73 using WebKit::WebWidget; |
74 | 74 |
75 namespace content { | 75 namespace content { |
76 | 76 |
77 static const float kStandardDPI = 160; | |
78 | |
79 RenderWidget::RenderWidget(WebKit::WebPopupType popup_type, | 77 RenderWidget::RenderWidget(WebKit::WebPopupType popup_type, |
80 const WebKit::WebScreenInfo& screen_info, | 78 const WebKit::WebScreenInfo& screen_info, |
81 bool swapped_out) | 79 bool swapped_out) |
82 : routing_id_(MSG_ROUTING_NONE), | 80 : routing_id_(MSG_ROUTING_NONE), |
83 surface_id_(0), | 81 surface_id_(0), |
84 webwidget_(NULL), | 82 webwidget_(NULL), |
85 opener_id_(MSG_ROUTING_NONE), | 83 opener_id_(MSG_ROUTING_NONE), |
86 init_complete_(false), | 84 init_complete_(false), |
87 current_paint_buf_(NULL), | 85 current_paint_buf_(NULL), |
88 next_paint_flags_(0), | 86 next_paint_flags_(0), |
(...skipping 13 matching lines...) Expand all Loading... |
102 input_method_is_active_(false), | 100 input_method_is_active_(false), |
103 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 101 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
104 can_compose_inline_(true), | 102 can_compose_inline_(true), |
105 popup_type_(popup_type), | 103 popup_type_(popup_type), |
106 pending_window_rect_count_(0), | 104 pending_window_rect_count_(0), |
107 suppress_next_char_events_(false), | 105 suppress_next_char_events_(false), |
108 is_accelerated_compositing_active_(false), | 106 is_accelerated_compositing_active_(false), |
109 animation_update_pending_(false), | 107 animation_update_pending_(false), |
110 invalidation_task_posted_(false), | 108 invalidation_task_posted_(false), |
111 screen_info_(screen_info), | 109 screen_info_(screen_info), |
112 device_scale_factor_(1), | 110 device_scale_factor_(screen_info_.deviceScaleFactor), |
113 throttle_input_events_(true), | 111 throttle_input_events_(true), |
114 next_smooth_scroll_gesture_id_(0), | 112 next_smooth_scroll_gesture_id_(0), |
115 is_threaded_compositing_enabled_(false) { | 113 is_threaded_compositing_enabled_(false) { |
116 if (!swapped_out) | 114 if (!swapped_out) |
117 RenderProcess::current()->AddRefProcess(); | 115 RenderProcess::current()->AddRefProcess(); |
118 DCHECK(RenderThread::Get()); | 116 DCHECK(RenderThread::Get()); |
119 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( | 117 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( |
120 switches::kDisableGpuVsync); | 118 switches::kDisableGpuVsync); |
121 #if defined(OS_CHROMEOS) || defined(OS_MACOSX) | |
122 device_scale_factor_ = screen_info.verticalDPI / kStandardDPI; | |
123 // Unless an explicit scale factor was provided for testing, ensure the scale | |
124 // is integral. | |
125 if (!CommandLine::ForCurrentProcess()->HasSwitch( | |
126 switches::kForceDeviceScaleFactor)) | |
127 device_scale_factor_ = static_cast<int>(device_scale_factor_); | |
128 device_scale_factor_ = std::max(1.0f, device_scale_factor_); | |
129 #endif | |
130 is_threaded_compositing_enabled_ = | 119 is_threaded_compositing_enabled_ = |
131 CommandLine::ForCurrentProcess()->HasSwitch( | 120 CommandLine::ForCurrentProcess()->HasSwitch( |
132 switches::kEnableThreadedCompositing); | 121 switches::kEnableThreadedCompositing); |
133 } | 122 } |
134 | 123 |
135 RenderWidget::~RenderWidget() { | 124 RenderWidget::~RenderWidget() { |
136 DCHECK(!webwidget_) << "Leaking our WebWidget!"; | 125 DCHECK(!webwidget_) << "Leaking our WebWidget!"; |
137 STLDeleteElements(&updates_pending_swap_); | 126 STLDeleteElements(&updates_pending_swap_); |
138 if (current_paint_buf_) { | 127 if (current_paint_buf_) { |
139 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); | 128 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); |
(...skipping 1490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1630 } | 1619 } |
1631 | 1620 |
1632 void RenderWidget::OnSetTextDirection(WebTextDirection direction) { | 1621 void RenderWidget::OnSetTextDirection(WebTextDirection direction) { |
1633 if (!webwidget_) | 1622 if (!webwidget_) |
1634 return; | 1623 return; |
1635 webwidget_->setTextDirection(direction); | 1624 webwidget_->setTextDirection(direction); |
1636 } | 1625 } |
1637 | 1626 |
1638 void RenderWidget::OnScreenInfoChanged( | 1627 void RenderWidget::OnScreenInfoChanged( |
1639 const WebKit::WebScreenInfo& screen_info) { | 1628 const WebKit::WebScreenInfo& screen_info) { |
| 1629 // TODO(oshima): Update scale factor here and remove OnSetDeviceScaleFactor. |
1640 screen_info_ = screen_info; | 1630 screen_info_ = screen_info; |
1641 } | 1631 } |
1642 | 1632 |
1643 void RenderWidget::OnUpdateScreenRects(const gfx::Rect& view_screen_rect, | 1633 void RenderWidget::OnUpdateScreenRects(const gfx::Rect& view_screen_rect, |
1644 const gfx::Rect& window_screen_rect) { | 1634 const gfx::Rect& window_screen_rect) { |
1645 view_screen_rect_ = view_screen_rect; | 1635 view_screen_rect_ = view_screen_rect; |
1646 window_screen_rect_ = window_screen_rect; | 1636 window_screen_rect_ = window_screen_rect; |
1647 Send(new ViewHostMsg_UpdateScreenRects_ACK(routing_id())); | 1637 Send(new ViewHostMsg_UpdateScreenRects_ACK(routing_id())); |
1648 } | 1638 } |
1649 | 1639 |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1965 bool RenderWidget::WillHandleGestureEvent( | 1955 bool RenderWidget::WillHandleGestureEvent( |
1966 const WebKit::WebGestureEvent& event) { | 1956 const WebKit::WebGestureEvent& event) { |
1967 return false; | 1957 return false; |
1968 } | 1958 } |
1969 | 1959 |
1970 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { | 1960 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { |
1971 return false; | 1961 return false; |
1972 } | 1962 } |
1973 | 1963 |
1974 } // namespace content | 1964 } // namespace content |
OLD | NEW |