OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/html_viewer/html_widget.h" | 5 #include "components/html_viewer/html_widget.h" |
6 | 6 |
7 #include "components/html_viewer/global_state.h" | 7 #include "components/html_viewer/global_state.h" |
8 #include "components/html_viewer/ime_controller.h" | 8 #include "components/html_viewer/ime_controller.h" |
9 #include "components/html_viewer/stats_collection_controller.h" | 9 #include "components/html_viewer/stats_collection_controller.h" |
10 #include "components/html_viewer/web_layer_tree_view_impl.h" | 10 #include "components/html_viewer/web_layer_tree_view_impl.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 scoped_ptr<WebLayerTreeViewImpl> CreateWebLayerTreeView( | 23 scoped_ptr<WebLayerTreeViewImpl> CreateWebLayerTreeView( |
24 GlobalState* global_state) { | 24 GlobalState* global_state) { |
25 return make_scoped_ptr(new WebLayerTreeViewImpl( | 25 return make_scoped_ptr(new WebLayerTreeViewImpl( |
26 global_state->compositor_thread(), | 26 global_state->compositor_thread(), |
27 global_state->gpu_memory_buffer_manager(), | 27 global_state->gpu_memory_buffer_manager(), |
28 global_state->raster_thread_helper()->task_graph_runner())); | 28 global_state->raster_thread_helper()->task_graph_runner())); |
29 } | 29 } |
30 | 30 |
31 void InitializeWebLayerTreeView(WebLayerTreeViewImpl* web_layer_tree_view, | 31 void InitializeWebLayerTreeView(WebLayerTreeViewImpl* web_layer_tree_view, |
32 mojo::ApplicationImpl* app, | 32 mojo::ApplicationImpl* app, |
33 mus::View* view, | 33 mojo::View* view, |
34 blink::WebWidget* widget) { | 34 blink::WebWidget* widget) { |
35 DCHECK(view); | 35 DCHECK(view); |
36 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 36 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
37 request->url = mojo::String::From("mojo:mus"); | 37 request->url = mojo::String::From("mojo:mus"); |
38 mojo::GpuPtr gpu_service; | 38 mojo::GpuPtr gpu_service; |
39 app->ConnectToService(request.Pass(), &gpu_service); | 39 app->ConnectToService(request.Pass(), &gpu_service); |
40 web_layer_tree_view->Initialize(gpu_service.Pass(), view, widget); | 40 web_layer_tree_view->Initialize(gpu_service.Pass(), view, widget); |
41 } | 41 } |
42 | 42 |
43 void UpdateWebViewSizeFromViewSize(mus::View* view, | 43 void UpdateWebViewSizeFromViewSize(mojo::View* view, |
44 blink::WebWidget* web_widget, | 44 blink::WebWidget* web_widget, |
45 WebLayerTreeViewImpl* web_layer_tree_view) { | 45 WebLayerTreeViewImpl* web_layer_tree_view) { |
46 const gfx::Size size_in_pixels(view->bounds().width, view->bounds().height); | 46 const gfx::Size size_in_pixels(view->bounds().width, view->bounds().height); |
47 const gfx::Size size_in_dips = gfx::ConvertSizeToDIP( | 47 const gfx::Size size_in_dips = gfx::ConvertSizeToDIP( |
48 view->viewport_metrics().device_pixel_ratio, size_in_pixels); | 48 view->viewport_metrics().device_pixel_ratio, size_in_pixels); |
49 web_widget->resize( | 49 web_widget->resize( |
50 blink::WebSize(size_in_dips.width(), size_in_dips.height())); | 50 blink::WebSize(size_in_dips.width(), size_in_dips.height())); |
51 web_layer_tree_view->setViewportSize(size_in_pixels); | 51 web_layer_tree_view->setViewportSize(size_in_pixels); |
52 } | 52 } |
53 | 53 |
(...skipping 13 matching lines...) Expand all Loading... |
67 : web_view_(blink::WebView::create(nullptr)) { | 67 : web_view_(blink::WebView::create(nullptr)) { |
68 ConfigureSettings(web_view_->settings()); | 68 ConfigureSettings(web_view_->settings()); |
69 } | 69 } |
70 | 70 |
71 HTMLWidgetRootRemote::~HTMLWidgetRootRemote() {} | 71 HTMLWidgetRootRemote::~HTMLWidgetRootRemote() {} |
72 | 72 |
73 blink::WebWidget* HTMLWidgetRootRemote::GetWidget() { | 73 blink::WebWidget* HTMLWidgetRootRemote::GetWidget() { |
74 return web_view_; | 74 return web_view_; |
75 } | 75 } |
76 | 76 |
77 void HTMLWidgetRootRemote::OnViewBoundsChanged(mus::View* view) {} | 77 void HTMLWidgetRootRemote::OnViewBoundsChanged(mojo::View* view) {} |
78 | 78 |
79 // HTMLWidgetRootLocal -------------------------------------------------------- | 79 // HTMLWidgetRootLocal -------------------------------------------------------- |
80 | 80 |
81 HTMLWidgetRootLocal::CreateParams::CreateParams(mojo::ApplicationImpl* app, | 81 HTMLWidgetRootLocal::CreateParams::CreateParams(mojo::ApplicationImpl* app, |
82 GlobalState* global_state, | 82 GlobalState* global_state, |
83 mus::View* view) | 83 mojo::View* view) |
84 : app(app), global_state(global_state), view(view) {} | 84 : app(app), global_state(global_state), view(view) {} |
85 | 85 |
86 HTMLWidgetRootLocal::CreateParams::~CreateParams() {} | 86 HTMLWidgetRootLocal::CreateParams::~CreateParams() {} |
87 | 87 |
88 HTMLWidgetRootLocal::HTMLWidgetRootLocal(CreateParams* create_params) | 88 HTMLWidgetRootLocal::HTMLWidgetRootLocal(CreateParams* create_params) |
89 : app_(create_params->app), | 89 : app_(create_params->app), |
90 global_state_(create_params->global_state), | 90 global_state_(create_params->global_state), |
91 view_(create_params->view), | 91 view_(create_params->view), |
92 web_view_(nullptr) { | 92 web_view_(nullptr) { |
93 web_view_ = blink::WebView::create(this); | 93 web_view_ = blink::WebView::create(this); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 } | 146 } |
147 | 147 |
148 void HTMLWidgetRootLocal::showImeIfNeeded() { | 148 void HTMLWidgetRootLocal::showImeIfNeeded() { |
149 ime_controller_->ShowImeIfNeeded(); | 149 ime_controller_->ShowImeIfNeeded(); |
150 } | 150 } |
151 | 151 |
152 blink::WebWidget* HTMLWidgetRootLocal::GetWidget() { | 152 blink::WebWidget* HTMLWidgetRootLocal::GetWidget() { |
153 return web_view_; | 153 return web_view_; |
154 } | 154 } |
155 | 155 |
156 void HTMLWidgetRootLocal::OnViewBoundsChanged(mus::View* view) { | 156 void HTMLWidgetRootLocal::OnViewBoundsChanged(mojo::View* view) { |
157 UpdateWebViewSizeFromViewSize(view, web_view_, | 157 UpdateWebViewSizeFromViewSize(view, web_view_, |
158 web_layer_tree_view_impl_.get()); | 158 web_layer_tree_view_impl_.get()); |
159 } | 159 } |
160 | 160 |
161 // HTMLWidgetLocalRoot -------------------------------------------------------- | 161 // HTMLWidgetLocalRoot -------------------------------------------------------- |
162 | 162 |
163 HTMLWidgetLocalRoot::HTMLWidgetLocalRoot(mojo::ApplicationImpl* app, | 163 HTMLWidgetLocalRoot::HTMLWidgetLocalRoot(mojo::ApplicationImpl* app, |
164 GlobalState* global_state, | 164 GlobalState* global_state, |
165 mus::View* view, | 165 mojo::View* view, |
166 blink::WebLocalFrame* web_local_frame) | 166 blink::WebLocalFrame* web_local_frame) |
167 : app_(app), global_state_(global_state), web_frame_widget_(nullptr) { | 167 : app_(app), global_state_(global_state), web_frame_widget_(nullptr) { |
168 web_frame_widget_ = blink::WebFrameWidget::create(this, web_local_frame); | 168 web_frame_widget_ = blink::WebFrameWidget::create(this, web_local_frame); |
169 ime_controller_.reset(new ImeController(view, web_frame_widget_)); | 169 ime_controller_.reset(new ImeController(view, web_frame_widget_)); |
170 // Creating the widget calls initializeLayerTreeView() to create the | 170 // Creating the widget calls initializeLayerTreeView() to create the |
171 // |web_layer_tree_view_impl_|. As we haven't yet assigned the | 171 // |web_layer_tree_view_impl_|. As we haven't yet assigned the |
172 // |web_frame_widget_| | 172 // |web_frame_widget_| |
173 // we have to set it here. | 173 // we have to set it here. |
174 if (web_layer_tree_view_impl_) { | 174 if (web_layer_tree_view_impl_) { |
175 InitializeWebLayerTreeView(web_layer_tree_view_impl_.get(), app_, view, | 175 InitializeWebLayerTreeView(web_layer_tree_view_impl_.get(), app_, view, |
176 web_frame_widget_); | 176 web_frame_widget_); |
177 UpdateWebViewSizeFromViewSize(view, web_frame_widget_, | 177 UpdateWebViewSizeFromViewSize(view, web_frame_widget_, |
178 web_layer_tree_view_impl_.get()); | 178 web_layer_tree_view_impl_.get()); |
179 } | 179 } |
180 } | 180 } |
181 | 181 |
182 HTMLWidgetLocalRoot::~HTMLWidgetLocalRoot() {} | 182 HTMLWidgetLocalRoot::~HTMLWidgetLocalRoot() {} |
183 | 183 |
184 blink::WebWidget* HTMLWidgetLocalRoot::GetWidget() { | 184 blink::WebWidget* HTMLWidgetLocalRoot::GetWidget() { |
185 return web_frame_widget_; | 185 return web_frame_widget_; |
186 } | 186 } |
187 | 187 |
188 void HTMLWidgetLocalRoot::OnViewBoundsChanged(mus::View* view) { | 188 void HTMLWidgetLocalRoot::OnViewBoundsChanged(mojo::View* view) { |
189 UpdateWebViewSizeFromViewSize(view, web_frame_widget_, | 189 UpdateWebViewSizeFromViewSize(view, web_frame_widget_, |
190 web_layer_tree_view_impl_.get()); | 190 web_layer_tree_view_impl_.get()); |
191 } | 191 } |
192 | 192 |
193 void HTMLWidgetLocalRoot::initializeLayerTreeView() { | 193 void HTMLWidgetLocalRoot::initializeLayerTreeView() { |
194 web_layer_tree_view_impl_ = CreateWebLayerTreeView(global_state_); | 194 web_layer_tree_view_impl_ = CreateWebLayerTreeView(global_state_); |
195 } | 195 } |
196 | 196 |
197 blink::WebLayerTreeView* HTMLWidgetLocalRoot::layerTreeView() { | 197 blink::WebLayerTreeView* HTMLWidgetLocalRoot::layerTreeView() { |
198 return web_layer_tree_view_impl_.get(); | 198 return web_layer_tree_view_impl_.get(); |
(...skipping 11 matching lines...) Expand all Loading... |
210 | 210 |
211 void HTMLWidgetLocalRoot::didUpdateTextOfFocusedElementByNonUserInput() { | 211 void HTMLWidgetLocalRoot::didUpdateTextOfFocusedElementByNonUserInput() { |
212 ime_controller_->DidUpdateTextOfFocusedElementByNonUserInput(); | 212 ime_controller_->DidUpdateTextOfFocusedElementByNonUserInput(); |
213 } | 213 } |
214 | 214 |
215 void HTMLWidgetLocalRoot::showImeIfNeeded() { | 215 void HTMLWidgetLocalRoot::showImeIfNeeded() { |
216 ime_controller_->ShowImeIfNeeded(); | 216 ime_controller_->ShowImeIfNeeded(); |
217 } | 217 } |
218 | 218 |
219 } // namespace html_viewer | 219 } // namespace html_viewer |
OLD | NEW |