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

Side by Side Diff: mojo/services/html_viewer/html_document.cc

Issue 1018543002: Wires through scale factor and bounds in html_viewer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 | « mojo/services/html_viewer/html_document.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "mojo/services/html_viewer/html_document.h" 5 #include "mojo/services/html_viewer/html_document.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 23 matching lines...) Expand all
34 #include "third_party/WebKit/public/web/WebSettings.h" 34 #include "third_party/WebKit/public/web/WebSettings.h"
35 #include "third_party/WebKit/public/web/WebView.h" 35 #include "third_party/WebKit/public/web/WebView.h"
36 #include "third_party/mojo/src/mojo/public/cpp/application/connect.h" 36 #include "third_party/mojo/src/mojo/public/cpp/application/connect.h"
37 #include "third_party/mojo/src/mojo/public/cpp/system/data_pipe.h" 37 #include "third_party/mojo/src/mojo/public/cpp/system/data_pipe.h"
38 #include "third_party/mojo/src/mojo/public/interfaces/application/shell.mojom.h" 38 #include "third_party/mojo/src/mojo/public/interfaces/application/shell.mojom.h"
39 #include "third_party/mojo_services/src/surfaces/public/interfaces/surfaces.mojo m.h" 39 #include "third_party/mojo_services/src/surfaces/public/interfaces/surfaces.mojo m.h"
40 #include "third_party/mojo_services/src/view_manager/public/cpp/view.h" 40 #include "third_party/mojo_services/src/view_manager/public/cpp/view.h"
41 #include "third_party/skia/include/core/SkCanvas.h" 41 #include "third_party/skia/include/core/SkCanvas.h"
42 #include "third_party/skia/include/core/SkColor.h" 42 #include "third_party/skia/include/core/SkColor.h"
43 #include "third_party/skia/include/core/SkDevice.h" 43 #include "third_party/skia/include/core/SkDevice.h"
44 #include "ui/gfx/geometry/size_conversions.h"
44 45
45 using mojo::AxProvider; 46 using mojo::AxProvider;
46 using mojo::Rect; 47 using mojo::Rect;
47 using mojo::ServiceProviderPtr; 48 using mojo::ServiceProviderPtr;
48 using mojo::URLResponsePtr; 49 using mojo::URLResponsePtr;
49 using mojo::View; 50 using mojo::View;
50 using mojo::ViewManager; 51 using mojo::ViewManager;
51 using mojo::WeakBindToRequest; 52 using mojo::WeakBindToRequest;
52 53
53 namespace html_viewer { 54 namespace html_viewer {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 129 }
129 130
130 void HTMLDocument::OnEmbed( 131 void HTMLDocument::OnEmbed(
131 View* root, 132 View* root,
132 mojo::InterfaceRequest<mojo::ServiceProvider> services, 133 mojo::InterfaceRequest<mojo::ServiceProvider> services,
133 mojo::ServiceProviderPtr exposed_services) { 134 mojo::ServiceProviderPtr exposed_services) {
134 DCHECK(!is_headless_); 135 DCHECK(!is_headless_);
135 root_ = root; 136 root_ = root;
136 embedder_service_provider_ = exposed_services.Pass(); 137 embedder_service_provider_ = exposed_services.Pass();
137 navigator_host_.set_service_provider(embedder_service_provider_.get()); 138 navigator_host_.set_service_provider(embedder_service_provider_.get());
138 139 UpdateWebviewSizeFromViewSize();
139 blink::WebSize root_size(root_->bounds().width, root_->bounds().height);
140 web_view_->resize(root_size);
141 web_layer_tree_view_impl_->setViewportSize(root_size);
142 web_layer_tree_view_impl_->set_view(root_); 140 web_layer_tree_view_impl_->set_view(root_);
143 root_->AddObserver(this); 141 root_->AddObserver(this);
144 } 142 }
145 143
146 void HTMLDocument::Create(mojo::ApplicationConnection* connection, 144 void HTMLDocument::Create(mojo::ApplicationConnection* connection,
147 mojo::InterfaceRequest<AxProvider> request) { 145 mojo::InterfaceRequest<AxProvider> request) {
148 if (!web_view_) 146 if (!web_view_)
149 return; 147 return;
150 ax_provider_impls_.insert( 148 ax_provider_impls_.insert(
151 WeakBindToRequest(new AxProviderImpl(web_view_), &request)); 149 WeakBindToRequest(new AxProviderImpl(web_view_), &request));
(...skipping 15 matching lines...) Expand all
167 extra_data->synthetic_response = response.Pass(); 165 extra_data->synthetic_response = response.Pass();
168 166
169 blink::WebURLRequest web_request; 167 blink::WebURLRequest web_request;
170 web_request.initialize(); 168 web_request.initialize();
171 web_request.setURL(url); 169 web_request.setURL(url);
172 web_request.setExtraData(extra_data); 170 web_request.setExtraData(extra_data);
173 171
174 web_view_->mainFrame()->loadRequest(web_request); 172 web_view_->mainFrame()->loadRequest(web_request);
175 } 173 }
176 174
175 void HTMLDocument::UpdateWebviewSizeFromViewSize() {
176 web_view_->setDeviceScaleFactor(root_->viewport_metrics().device_pixel_ratio);
177 const gfx::Size size_in_pixels(root_->bounds().width, root_->bounds().height);
178 // TODO: WebView should really take pixels (or float) so it has the real size.
jamesr 2015/03/16 23:26:45 you're picking the real size here. Blink operates
sky 2015/03/16 23:33:00 But if I do 6, then we're not rendering the last p
179 const gfx::Size size_in_dips = gfx::ToCeiledSize(gfx::ScaleSize(
180 size_in_pixels, 1 / root_->viewport_metrics().device_pixel_ratio));
181 web_view_->resize(
182 blink::WebSize(size_in_dips.width(), size_in_dips.height()));
183 web_layer_tree_view_impl_->setViewportSize(size_in_pixels);
184 }
185
177 blink::WebStorageNamespace* HTMLDocument::createSessionStorageNamespace() { 186 blink::WebStorageNamespace* HTMLDocument::createSessionStorageNamespace() {
178 return new WebStorageNamespaceImpl(); 187 return new WebStorageNamespaceImpl();
179 } 188 }
180 189
181 void HTMLDocument::initializeLayerTreeView() { 190 void HTMLDocument::initializeLayerTreeView() {
182 if (is_headless_) { 191 if (is_headless_) {
183 web_layer_tree_view_impl_.reset( 192 web_layer_tree_view_impl_.reset(
184 new WebLayerTreeViewImpl(compositor_thread_, nullptr, nullptr)); 193 new WebLayerTreeViewImpl(compositor_thread_, nullptr, nullptr));
185 return; 194 return;
186 } 195 }
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 make_scoped_ptr(new media::DefaultCdmFactory()), 303 make_scoped_ptr(new media::DefaultCdmFactory()),
295 media_permission_.get())); 304 media_permission_.get()));
296 } 305 }
297 return web_encrypted_media_client_.get(); 306 return web_encrypted_media_client_.get();
298 } 307 }
299 308
300 void HTMLDocument::OnViewBoundsChanged(View* view, 309 void HTMLDocument::OnViewBoundsChanged(View* view,
301 const Rect& old_bounds, 310 const Rect& old_bounds,
302 const Rect& new_bounds) { 311 const Rect& new_bounds) {
303 DCHECK_EQ(view, root_); 312 DCHECK_EQ(view, root_);
304 web_view_->resize( 313 UpdateWebviewSizeFromViewSize();
305 blink::WebSize(view->bounds().width, view->bounds().height));
306 } 314 }
307 315
308 void HTMLDocument::OnViewDestroyed(View* view) { 316 void HTMLDocument::OnViewDestroyed(View* view) {
309 DCHECK_EQ(view, root_); 317 DCHECK_EQ(view, root_);
310 root_ = nullptr; 318 root_ = nullptr;
311 } 319 }
312 320
313 void HTMLDocument::OnViewInputEvent(View* view, const mojo::EventPtr& event) { 321 void HTMLDocument::OnViewInputEvent(View* view, const mojo::EventPtr& event) {
314 scoped_ptr<blink::WebInputEvent> web_event = 322 scoped_ptr<blink::WebInputEvent> web_event =
315 event.To<scoped_ptr<blink::WebInputEvent>>(); 323 event.To<scoped_ptr<blink::WebInputEvent>>();
316 if (web_event) 324 if (web_event)
317 web_view_->handleInputEvent(*web_event); 325 web_view_->handleInputEvent(*web_event);
318 } 326 }
319 327
320 } // namespace html_viewer 328 } // namespace html_viewer
OLDNEW
« no previous file with comments | « mojo/services/html_viewer/html_document.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698