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 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1595 } | 1584 } |
1596 | 1585 |
1597 void RenderWidget::OnSetTextDirection(WebTextDirection direction) { | 1586 void RenderWidget::OnSetTextDirection(WebTextDirection direction) { |
1598 if (!webwidget_) | 1587 if (!webwidget_) |
1599 return; | 1588 return; |
1600 webwidget_->setTextDirection(direction); | 1589 webwidget_->setTextDirection(direction); |
1601 } | 1590 } |
1602 | 1591 |
1603 void RenderWidget::OnScreenInfoChanged( | 1592 void RenderWidget::OnScreenInfoChanged( |
1604 const WebKit::WebScreenInfo& screen_info) { | 1593 const WebKit::WebScreenInfo& screen_info) { |
1605 screen_info_ = screen_info; | 1594 screen_info_ = screen_info; |
oshima
2012/11/14 16:52:35
can you add
// TODO(oshima): Update scale factor
| |
1606 } | 1595 } |
1607 | 1596 |
1608 void RenderWidget::OnUpdateScreenRects(const gfx::Rect& view_screen_rect, | 1597 void RenderWidget::OnUpdateScreenRects(const gfx::Rect& view_screen_rect, |
1609 const gfx::Rect& window_screen_rect) { | 1598 const gfx::Rect& window_screen_rect) { |
1610 view_screen_rect_ = view_screen_rect; | 1599 view_screen_rect_ = view_screen_rect; |
1611 window_screen_rect_ = window_screen_rect; | 1600 window_screen_rect_ = window_screen_rect; |
1612 Send(new ViewHostMsg_UpdateScreenRects_ACK(routing_id())); | 1601 Send(new ViewHostMsg_UpdateScreenRects_ACK(routing_id())); |
1613 } | 1602 } |
1614 | 1603 |
1615 webkit::ppapi::PluginInstance* RenderWidget::GetBitmapForOptimizedPluginPaint( | 1604 webkit::ppapi::PluginInstance* RenderWidget::GetBitmapForOptimizedPluginPaint( |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1922 bool RenderWidget::WillHandleGestureEvent( | 1911 bool RenderWidget::WillHandleGestureEvent( |
1923 const WebKit::WebGestureEvent& event) { | 1912 const WebKit::WebGestureEvent& event) { |
1924 return false; | 1913 return false; |
1925 } | 1914 } |
1926 | 1915 |
1927 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { | 1916 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { |
1928 return false; | 1917 return false; |
1929 } | 1918 } |
1930 | 1919 |
1931 } // namespace content | 1920 } // namespace content |
OLD | NEW |