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

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 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
« no previous file with comments | « no previous file | components/html_viewer/web_layer_tree_view_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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())); 29 }
30
31 void InitializeWebLayerTreeView(WebLayerTreeViewImpl* web_layer_tree_view,
32 mojo::ApplicationImpl* app,
33 mojo::View* view,
34 blink::WebWidget* widget) {
35 DCHECK(view);
36 mojo::URLRequestPtr request(mojo::URLRequest::New());
37 request->url = mojo::String::From("mojo:view_manager");
38 mojo::GpuPtr gpu_service;
39 app->ConnectToService(request.Pass(), &gpu_service);
40 web_layer_tree_view->Initialize(gpu_service.Pass(), view, widget);
41 } 41 }
42 42
43 void UpdateWebViewSizeFromViewSize(mojo::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()));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
94 // Creating the widget calls initializeLayerTreeView() to create the 94 // Creating the widget calls initializeLayerTreeView() to create the
95 // |web_layer_tree_view_impl_|. As we haven't yet assigned the |web_view_| 95 // |web_layer_tree_view_impl_|. As we haven't yet assigned the |web_view_|
96 // we have to set it here. 96 // we have to set it here.
97 if (web_layer_tree_view_impl_) { 97 if (web_layer_tree_view_impl_) {
98 web_layer_tree_view_impl_->set_widget(web_view_); 98 InitializeWebLayerTreeView(web_layer_tree_view_impl_.get(), app_, view_,
99 web_layer_tree_view_impl_->set_view(create_params->view); 99 web_view_);
100 UpdateWebViewSizeFromViewSize(view_, web_view_, 100 UpdateWebViewSizeFromViewSize(view_, web_view_,
101 web_layer_tree_view_impl_.get()); 101 web_layer_tree_view_impl_.get());
102 } 102 }
103 ConfigureSettings(web_view_->settings()); 103 ConfigureSettings(web_view_->settings());
104 } 104 }
105 105
106 HTMLWidgetRootLocal::~HTMLWidgetRootLocal() {} 106 HTMLWidgetRootLocal::~HTMLWidgetRootLocal() {}
107 107
108 blink::WebStorageNamespace* 108 blink::WebStorageNamespace*
109 HTMLWidgetRootLocal::createSessionStorageNamespace() { 109 HTMLWidgetRootLocal::createSessionStorageNamespace() {
110 return new WebStorageNamespaceImpl(); 110 return new WebStorageNamespaceImpl();
111 } 111 }
112 112
113 void HTMLWidgetRootLocal::didCancelCompositionOnSelectionChange() { 113 void HTMLWidgetRootLocal::didCancelCompositionOnSelectionChange() {
114 // TODO(penghuang): Update text input state. 114 // TODO(penghuang): Update text input state.
115 } 115 }
116 116
117 void HTMLWidgetRootLocal::didChangeContents() { 117 void HTMLWidgetRootLocal::didChangeContents() {
118 // TODO(penghuang): Update text input state. 118 // TODO(penghuang): Update text input state.
119 } 119 }
120 120
121 void HTMLWidgetRootLocal::initializeLayerTreeView() { 121 void HTMLWidgetRootLocal::initializeLayerTreeView() {
122 web_layer_tree_view_impl_ = CreateWebLayerTreeView(app_, global_state_); 122 web_layer_tree_view_impl_ = CreateWebLayerTreeView(global_state_);
123 } 123 }
124 124
125 blink::WebLayerTreeView* HTMLWidgetRootLocal::layerTreeView() { 125 blink::WebLayerTreeView* HTMLWidgetRootLocal::layerTreeView() {
126 return web_layer_tree_view_impl_.get(); 126 return web_layer_tree_view_impl_.get();
127 } 127 }
128 128
129 void HTMLWidgetRootLocal::resetInputMethod() { 129 void HTMLWidgetRootLocal::resetInputMethod() {
130 // When this method gets called, WebWidgetClient implementation should 130 // When this method gets called, WebWidgetClient implementation should
131 // reset the input method by cancelling any ongoing composition. 131 // reset the input method by cancelling any ongoing composition.
132 // TODO(penghuang): Reset IME. 132 // TODO(penghuang): Reset IME.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 GlobalState* global_state, 198 GlobalState* global_state,
199 mojo::View* view, 199 mojo::View* view,
200 blink::WebLocalFrame* web_local_frame) 200 blink::WebLocalFrame* web_local_frame)
201 : app_(app), global_state_(global_state), web_frame_widget_(nullptr) { 201 : app_(app), global_state_(global_state), web_frame_widget_(nullptr) {
202 web_frame_widget_ = blink::WebFrameWidget::create(this, web_local_frame); 202 web_frame_widget_ = blink::WebFrameWidget::create(this, web_local_frame);
203 // Creating the widget calls initializeLayerTreeView() to create the 203 // Creating the widget calls initializeLayerTreeView() to create the
204 // |web_layer_tree_view_impl_|. As we haven't yet assigned the 204 // |web_layer_tree_view_impl_|. As we haven't yet assigned the
205 // |web_frame_widget_| 205 // |web_frame_widget_|
206 // we have to set it here. 206 // we have to set it here.
207 if (web_layer_tree_view_impl_) { 207 if (web_layer_tree_view_impl_) {
208 web_layer_tree_view_impl_->set_widget(web_frame_widget_); 208 InitializeWebLayerTreeView(web_layer_tree_view_impl_.get(), app_, view,
209 web_layer_tree_view_impl_->set_view(view); 209 web_frame_widget_);
210 UpdateWebViewSizeFromViewSize(view, web_frame_widget_, 210 UpdateWebViewSizeFromViewSize(view, web_frame_widget_,
211 web_layer_tree_view_impl_.get()); 211 web_layer_tree_view_impl_.get());
212 } 212 }
213 } 213 }
214 214
215 HTMLWidgetLocalRoot::~HTMLWidgetLocalRoot() {} 215 HTMLWidgetLocalRoot::~HTMLWidgetLocalRoot() {}
216 216
217 blink::WebWidget* HTMLWidgetLocalRoot::GetWidget() { 217 blink::WebWidget* HTMLWidgetLocalRoot::GetWidget() {
218 return web_frame_widget_; 218 return web_frame_widget_;
219 } 219 }
220 220
221 void HTMLWidgetLocalRoot::OnViewBoundsChanged(mojo::View* view) { 221 void HTMLWidgetLocalRoot::OnViewBoundsChanged(mojo::View* view) {
222 UpdateWebViewSizeFromViewSize(view, web_frame_widget_, 222 UpdateWebViewSizeFromViewSize(view, web_frame_widget_,
223 web_layer_tree_view_impl_.get()); 223 web_layer_tree_view_impl_.get());
224 } 224 }
225 225
226 void HTMLWidgetLocalRoot::initializeLayerTreeView() { 226 void HTMLWidgetLocalRoot::initializeLayerTreeView() {
227 web_layer_tree_view_impl_ = CreateWebLayerTreeView(app_, global_state_); 227 web_layer_tree_view_impl_ = CreateWebLayerTreeView(global_state_);
228 } 228 }
229 229
230 blink::WebLayerTreeView* HTMLWidgetLocalRoot::layerTreeView() { 230 blink::WebLayerTreeView* HTMLWidgetLocalRoot::layerTreeView() {
231 return web_layer_tree_view_impl_.get(); 231 return web_layer_tree_view_impl_.get();
232 } 232 }
233 233
234 } // namespace html_viewer 234 } // namespace html_viewer
OLDNEW
« no previous file with comments | « no previous file | components/html_viewer/web_layer_tree_view_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698