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

Unified Diff: cc/layer_tree_impl.cc

Issue 12082012: Implement desktop compatibility viewport (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@aelias
Patch Set: Created 7 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 | « cc/layer_tree_impl.h ('k') | cc/pinch_zoom_viewport.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layer_tree_impl.cc
diff --git a/cc/layer_tree_impl.cc b/cc/layer_tree_impl.cc
index 6b04f7a872644397958872894809f11af8171c91..eeff39a96233ba9a717b2e44d06c5d0b7467d678 100644
--- a/cc/layer_tree_impl.cc
+++ b/cc/layer_tree_impl.cc
@@ -120,6 +120,38 @@ void LayerTreeImpl::UpdateMaxScrollOffset() {
root_scroll_layer_->setMaxScrollOffset(gfx::ToFlooredVector2d(max_scroll));
}
+static gfx::Vector2dF toVector2dF(const gfx::Size& size) { return gfx::Vector2dF(size.width(), size.height()); }
+static gfx::Vector2dF toVector2dF(const gfx::SizeF& size) { return gfx::Vector2dF(size.width(), size.height()); }
+
+void LayerTreeImpl::UpdateFixedPositionViewport() {
+ if (!root_scroll_layer_)
+ return;
+
+ const gfx::Vector2dF total_scroll_offset = root_scroll_layer_->scrollOffset() + root_scroll_layer_->scrollDelta();
+ const gfx::Vector2dF layout_viewport_size = toVector2dF(pinch_zoom_viewport().layout_viewport_size());
+ const gfx::Vector2d desktop_compatibility_viewport_offset = root_scroll_layer_->desktopCompatibilityViewportOffsetFromScrollPosition();
+
+ gfx::Vector2dF desktop_compatibility_viewport_offset_delta = root_scroll_layer_->desktopCompatibilityViewportOffsetFromScrollPositionDelta();
+
+ // Make sure fixed position viewport contains the visible viewport
+ {
+ const gfx::Vector2dF offset_min = toVector2dF(pinch_zoom_viewport().LayoutSpaceViewportSize()) - layout_viewport_size;
+ desktop_compatibility_viewport_offset_delta.ClampToMin(offset_min - desktop_compatibility_viewport_offset);
+ const gfx::Vector2dF offset_max;
+ desktop_compatibility_viewport_offset_delta.ClampToMax(offset_max - desktop_compatibility_viewport_offset);
+ }
+
+ // Clamp the fixed position viewport within the document bounds.
+ {
+ const gfx::Vector2dF offset_max = toVector2dF(ScrollableSize()) - layout_viewport_size - total_scroll_offset;
+ desktop_compatibility_viewport_offset_delta.ClampToMax(offset_max - desktop_compatibility_viewport_offset);
+ const gfx::Vector2dF offset_min = -total_scroll_offset;
+ desktop_compatibility_viewport_offset_delta.ClampToMin(offset_min - desktop_compatibility_viewport_offset);
+ }
+
+ root_scroll_layer_->setDesktopCompatibilityViewportOffsetFromScrollPositionDelta(desktop_compatibility_viewport_offset_delta);
+}
+
void LayerTreeImpl::UpdateDrawProperties() {
render_surface_layer_list_.clear();
if (!RootLayer())
« no previous file with comments | « cc/layer_tree_impl.h ('k') | cc/pinch_zoom_viewport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698