Chromium Code Reviews| Index: mojo/services/html_viewer/html_document.cc |
| diff --git a/mojo/services/html_viewer/html_document.cc b/mojo/services/html_viewer/html_document.cc |
| index 0f35b8d7d94de8895b479d2d41d3ae1839d70cea..6ff9a7894ba1921556259d8ebed3b663647e41b0 100644 |
| --- a/mojo/services/html_viewer/html_document.cc |
| +++ b/mojo/services/html_viewer/html_document.cc |
| @@ -41,6 +41,7 @@ |
| #include "third_party/skia/include/core/SkCanvas.h" |
| #include "third_party/skia/include/core/SkColor.h" |
| #include "third_party/skia/include/core/SkDevice.h" |
| +#include "ui/gfx/geometry/size_conversions.h" |
| using mojo::AxProvider; |
| using mojo::Rect; |
| @@ -135,10 +136,7 @@ void HTMLDocument::OnEmbed( |
| root_ = root; |
| embedder_service_provider_ = exposed_services.Pass(); |
| navigator_host_.set_service_provider(embedder_service_provider_.get()); |
| - |
| - blink::WebSize root_size(root_->bounds().width, root_->bounds().height); |
| - web_view_->resize(root_size); |
| - web_layer_tree_view_impl_->setViewportSize(root_size); |
| + UpdateWebviewSizeFromViewSize(); |
| web_layer_tree_view_impl_->set_view(root_); |
| root_->AddObserver(this); |
| } |
| @@ -174,6 +172,17 @@ void HTMLDocument::Load(URLResponsePtr response) { |
| web_view_->mainFrame()->loadRequest(web_request); |
| } |
| +void HTMLDocument::UpdateWebviewSizeFromViewSize() { |
| + web_view_->setDeviceScaleFactor(root_->viewport_metrics().device_pixel_ratio); |
| + const gfx::Size size_in_pixels(root_->bounds().width, root_->bounds().height); |
| + // 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
|
| + const gfx::Size size_in_dips = gfx::ToCeiledSize(gfx::ScaleSize( |
| + size_in_pixels, 1 / root_->viewport_metrics().device_pixel_ratio)); |
| + web_view_->resize( |
| + blink::WebSize(size_in_dips.width(), size_in_dips.height())); |
| + web_layer_tree_view_impl_->setViewportSize(size_in_pixels); |
| +} |
| + |
| blink::WebStorageNamespace* HTMLDocument::createSessionStorageNamespace() { |
| return new WebStorageNamespaceImpl(); |
| } |
| @@ -301,8 +310,7 @@ void HTMLDocument::OnViewBoundsChanged(View* view, |
| const Rect& old_bounds, |
| const Rect& new_bounds) { |
| DCHECK_EQ(view, root_); |
| - web_view_->resize( |
| - blink::WebSize(view->bounds().width, view->bounds().height)); |
| + UpdateWebviewSizeFromViewSize(); |
| } |
| void HTMLDocument::OnViewDestroyed(View* view) { |