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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/services/html_viewer/html_document.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« 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