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

Unified Diff: sky/viewer/document_view.cc

Issue 880743002: Plumb ViewportMetrics change notifications around the world and back. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Fix typo Created 5 years, 11 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 | « sky/viewer/document_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/viewer/document_view.cc
diff --git a/sky/viewer/document_view.cc b/sky/viewer/document_view.cc
index 0c5f9a2a0cfdb55d0db8c28dc6cf1596c7b917a0..80ae7db9e6299609f8efc89072f23ae155cb1015 100644
--- a/sky/viewer/document_view.cc
+++ b/sky/viewer/document_view.cc
@@ -118,10 +118,7 @@ void DocumentView::OnEmbed(
Load(response_.Pass());
- auto& bounds = root_->bounds();
- float device_pixel_ratio = GetDevicePixelRatio();
- web_view_->resize(blink::WebSize(bounds.width / device_pixel_ratio,
- bounds.height / device_pixel_ratio));
+ UpdateRootSizeAndViewportMetrics(root_->bounds());
// TODO(abarth): We should ask the view whether it is focused instead of
// assuming that we're focused.
@@ -270,6 +267,20 @@ void DocumentView::OnViewBoundsChanged(mojo::View* view,
const mojo::Rect& old_bounds,
const mojo::Rect& new_bounds) {
DCHECK_EQ(view, root_);
+ UpdateRootSizeAndViewportMetrics(new_bounds);
+}
+
+void DocumentView::OnViewViewportMetricsChanged(
+ mojo::View* view,
+ const mojo::ViewportMetrics& old_metrics,
+ const mojo::ViewportMetrics& new_metrics) {
+ DCHECK_EQ(view, root_);
+ web_view_->setDeviceScaleFactor(GetDevicePixelRatio());
+ UpdateRootSizeAndViewportMetrics(root_->bounds());
+}
+
+void DocumentView::UpdateRootSizeAndViewportMetrics(
+ const mojo::Rect& new_bounds) {
float device_pixel_ratio = GetDevicePixelRatio();
web_view_->resize(blink::WebSize(new_bounds.width / device_pixel_ratio,
new_bounds.height / device_pixel_ratio));
« no previous file with comments | « sky/viewer/document_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698