Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(443)

Side by Side Diff: components/html_viewer/html_widget.cc

Issue 1281663002: Mandoline: Allow submitting CompositorFrames directly to mojo::Views (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased + added uip::Surface Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/blink_input_events_type_converters.h" 7 #include "components/html_viewer/blink_input_events_type_converters.h"
8 #include "components/html_viewer/blink_text_input_type_converters.h" 8 #include "components/html_viewer/blink_text_input_type_converters.h"
9 #include "components/html_viewer/global_state.h" 9 #include "components/html_viewer/global_state.h"
10 #include "components/html_viewer/web_layer_tree_view_impl.h" 10 #include "components/html_viewer/web_layer_tree_view_impl.h"
11 #include "components/html_viewer/web_storage_namespace_impl.h" 11 #include "components/html_viewer/web_storage_namespace_impl.h"
12 #include "components/view_manager/public/cpp/view.h" 12 #include "components/view_manager/public/cpp/view.h"
13 #include "components/view_manager/public/interfaces/surfaces.mojom.h"
14 #include "mojo/application/public/cpp/application_impl.h" 13 #include "mojo/application/public/cpp/application_impl.h"
15 #include "third_party/WebKit/public/web/WebFrameWidget.h" 14 #include "third_party/WebKit/public/web/WebFrameWidget.h"
16 #include "third_party/WebKit/public/web/WebInputEvent.h" 15 #include "third_party/WebKit/public/web/WebInputEvent.h"
17 #include "third_party/WebKit/public/web/WebSettings.h" 16 #include "third_party/WebKit/public/web/WebSettings.h"
18 #include "third_party/WebKit/public/web/WebView.h" 17 #include "third_party/WebKit/public/web/WebView.h"
19 #include "ui/gfx/geometry/dip_util.h" 18 #include "ui/gfx/geometry/dip_util.h"
20 19
21 namespace html_viewer { 20 namespace html_viewer {
22 namespace { 21 namespace {
23 22
24 scoped_ptr<WebLayerTreeViewImpl> CreateWebLayerTreeView( 23 scoped_ptr<WebLayerTreeViewImpl> CreateWebLayerTreeView(
25 mojo::ApplicationImpl* app,
26 GlobalState* global_state) { 24 GlobalState* global_state) {
27 mojo::URLRequestPtr request(mojo::URLRequest::New());
28 request->url = mojo::String::From("mojo:view_manager");
29 mojo::SurfacePtr surface;
30 app->ConnectToService(request.Pass(), &surface);
31
32 mojo::URLRequestPtr request2(mojo::URLRequest::New());
33 request2->url = mojo::String::From("mojo:view_manager");
34 mojo::GpuPtr gpu_service;
35 app->ConnectToService(request2.Pass(), &gpu_service);
36 return make_scoped_ptr(new WebLayerTreeViewImpl( 25 return make_scoped_ptr(new WebLayerTreeViewImpl(
37 global_state->compositor_thread(), 26 global_state->compositor_thread(),
38 global_state->gpu_memory_buffer_manager(), 27 global_state->gpu_memory_buffer_manager(),
39 global_state->raster_thread_helper()->task_graph_runner(), surface.Pass(), 28 global_state->raster_thread_helper()->task_graph_runner()));
40 gpu_service.Pass()));
41 } 29 }
42 30
43 void UpdateWebViewSizeFromViewSize(mojo::View* view, 31 void UpdateWebViewSizeFromViewSize(mojo::View* view,
44 blink::WebWidget* web_widget, 32 blink::WebWidget* web_widget,
45 WebLayerTreeViewImpl* web_layer_tree_view) { 33 WebLayerTreeViewImpl* web_layer_tree_view) {
46 const gfx::Size size_in_pixels(view->bounds().width, view->bounds().height); 34 const gfx::Size size_in_pixels(view->bounds().width, view->bounds().height);
47 const gfx::Size size_in_dips = gfx::ConvertSizeToDIP( 35 const gfx::Size size_in_dips = gfx::ConvertSizeToDIP(
48 view->viewport_metrics().device_pixel_ratio, size_in_pixels); 36 view->viewport_metrics().device_pixel_ratio, size_in_pixels);
49 web_widget->resize( 37 web_widget->resize(
50 blink::WebSize(size_in_dips.width(), size_in_dips.height())); 38 blink::WebSize(size_in_dips.width(), size_in_dips.height()));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 75
88 HTMLWidgetRootLocal::HTMLWidgetRootLocal(CreateParams* create_params) 76 HTMLWidgetRootLocal::HTMLWidgetRootLocal(CreateParams* create_params)
89 : app_(create_params->app), 77 : app_(create_params->app),
90 global_state_(create_params->global_state), 78 global_state_(create_params->global_state),
91 view_(create_params->view), 79 view_(create_params->view),
92 web_view_(nullptr) { 80 web_view_(nullptr) {
93 web_view_ = blink::WebView::create(this); 81 web_view_ = blink::WebView::create(this);
94 // Creating the widget calls initializeLayerTreeView() to create the 82 // Creating the widget calls initializeLayerTreeView() to create the
95 // |web_layer_tree_view_impl_|. As we haven't yet assigned the |web_view_| 83 // |web_layer_tree_view_impl_|. As we haven't yet assigned the |web_view_|
96 // we have to set it here. 84 // we have to set it here.
85 DCHECK(view_);
86 mojo::URLRequestPtr request(mojo::URLRequest::New());
87 request->url = mojo::String::From("mojo:view_manager");
88 mojo::GpuPtr gpu_service;
89 app_->ConnectToService(request.Pass(), &gpu_service);
90
97 if (web_layer_tree_view_impl_) { 91 if (web_layer_tree_view_impl_) {
98 web_layer_tree_view_impl_->set_widget(web_view_); 92 web_layer_tree_view_impl_->Initialize(gpu_service.Pass(),
99 web_layer_tree_view_impl_->set_view(create_params->view); 93 view_,
94 web_view_);
100 UpdateWebViewSizeFromViewSize(view_, web_view_, 95 UpdateWebViewSizeFromViewSize(view_, web_view_,
101 web_layer_tree_view_impl_.get()); 96 web_layer_tree_view_impl_.get());
102 } 97 }
103 ConfigureSettings(web_view_->settings()); 98 ConfigureSettings(web_view_->settings());
104 } 99 }
105 100
106 HTMLWidgetRootLocal::~HTMLWidgetRootLocal() {} 101 HTMLWidgetRootLocal::~HTMLWidgetRootLocal() {}
107 102
108 blink::WebStorageNamespace* 103 blink::WebStorageNamespace*
109 HTMLWidgetRootLocal::createSessionStorageNamespace() { 104 HTMLWidgetRootLocal::createSessionStorageNamespace() {
110 return new WebStorageNamespaceImpl(); 105 return new WebStorageNamespaceImpl();
111 } 106 }
112 107
113 void HTMLWidgetRootLocal::didCancelCompositionOnSelectionChange() { 108 void HTMLWidgetRootLocal::didCancelCompositionOnSelectionChange() {
114 // TODO(penghuang): Update text input state. 109 // TODO(penghuang): Update text input state.
115 } 110 }
116 111
117 void HTMLWidgetRootLocal::didChangeContents() { 112 void HTMLWidgetRootLocal::didChangeContents() {
118 // TODO(penghuang): Update text input state. 113 // TODO(penghuang): Update text input state.
119 } 114 }
120 115
121 void HTMLWidgetRootLocal::initializeLayerTreeView() { 116 void HTMLWidgetRootLocal::initializeLayerTreeView() {
122 web_layer_tree_view_impl_ = CreateWebLayerTreeView(app_, global_state_); 117 web_layer_tree_view_impl_ = CreateWebLayerTreeView(global_state_);
123 } 118 }
124 119
125 blink::WebLayerTreeView* HTMLWidgetRootLocal::layerTreeView() { 120 blink::WebLayerTreeView* HTMLWidgetRootLocal::layerTreeView() {
126 return web_layer_tree_view_impl_.get(); 121 return web_layer_tree_view_impl_.get();
127 } 122 }
128 123
129 void HTMLWidgetRootLocal::resetInputMethod() { 124 void HTMLWidgetRootLocal::resetInputMethod() {
130 // When this method gets called, WebWidgetClient implementation should 125 // When this method gets called, WebWidgetClient implementation should
131 // reset the input method by cancelling any ongoing composition. 126 // reset the input method by cancelling any ongoing composition.
132 // TODO(penghuang): Reset IME. 127 // TODO(penghuang): Reset IME.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 GlobalState* global_state, 193 GlobalState* global_state,
199 mojo::View* view, 194 mojo::View* view,
200 blink::WebLocalFrame* web_local_frame) 195 blink::WebLocalFrame* web_local_frame)
201 : app_(app), global_state_(global_state), web_frame_widget_(nullptr) { 196 : app_(app), global_state_(global_state), web_frame_widget_(nullptr) {
202 web_frame_widget_ = blink::WebFrameWidget::create(this, web_local_frame); 197 web_frame_widget_ = blink::WebFrameWidget::create(this, web_local_frame);
203 // Creating the widget calls initializeLayerTreeView() to create the 198 // Creating the widget calls initializeLayerTreeView() to create the
204 // |web_layer_tree_view_impl_|. As we haven't yet assigned the 199 // |web_layer_tree_view_impl_|. As we haven't yet assigned the
205 // |web_frame_widget_| 200 // |web_frame_widget_|
206 // we have to set it here. 201 // we have to set it here.
207 if (web_layer_tree_view_impl_) { 202 if (web_layer_tree_view_impl_) {
208 web_layer_tree_view_impl_->set_widget(web_frame_widget_); 203 DCHECK(view);
sky 2015/08/26 22:58:03 Isn't this and 85-94 about the same? It seems like
Fady Samuel 2015/08/26 23:51:00 Done.
209 web_layer_tree_view_impl_->set_view(view); 204 mojo::URLRequestPtr request(mojo::URLRequest::New());
205 request->url = mojo::String::From("mojo:view_manager");
206 mojo::GpuPtr gpu_service;
207 app_->ConnectToService(request.Pass(), &gpu_service);
208 web_layer_tree_view_impl_->Initialize(gpu_service.Pass(),
209 view,
210 web_frame_widget_);
210 UpdateWebViewSizeFromViewSize(view, web_frame_widget_, 211 UpdateWebViewSizeFromViewSize(view, web_frame_widget_,
211 web_layer_tree_view_impl_.get()); 212 web_layer_tree_view_impl_.get());
212 } 213 }
213 } 214 }
214 215
215 HTMLWidgetLocalRoot::~HTMLWidgetLocalRoot() {} 216 HTMLWidgetLocalRoot::~HTMLWidgetLocalRoot() {}
216 217
217 blink::WebWidget* HTMLWidgetLocalRoot::GetWidget() { 218 blink::WebWidget* HTMLWidgetLocalRoot::GetWidget() {
218 return web_frame_widget_; 219 return web_frame_widget_;
219 } 220 }
220 221
221 void HTMLWidgetLocalRoot::OnViewBoundsChanged(mojo::View* view) { 222 void HTMLWidgetLocalRoot::OnViewBoundsChanged(mojo::View* view) {
222 UpdateWebViewSizeFromViewSize(view, web_frame_widget_, 223 UpdateWebViewSizeFromViewSize(view, web_frame_widget_,
223 web_layer_tree_view_impl_.get()); 224 web_layer_tree_view_impl_.get());
224 } 225 }
225 226
226 void HTMLWidgetLocalRoot::initializeLayerTreeView() { 227 void HTMLWidgetLocalRoot::initializeLayerTreeView() {
227 web_layer_tree_view_impl_ = CreateWebLayerTreeView(app_, global_state_); 228 web_layer_tree_view_impl_ = CreateWebLayerTreeView(global_state_);
228 } 229 }
229 230
230 blink::WebLayerTreeView* HTMLWidgetLocalRoot::layerTreeView() { 231 blink::WebLayerTreeView* HTMLWidgetLocalRoot::layerTreeView() {
231 return web_layer_tree_view_impl_.get(); 232 return web_layer_tree_view_impl_.get();
232 } 233 }
233 234
234 } // namespace html_viewer 235 } // namespace html_viewer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698