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

Unified Diff: cc/trees/property_tree_builder.cc

Issue 1021823006: Fix scroll position adjustment for fixed-position layers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased 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 | « cc/trees/property_tree.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/property_tree_builder.cc
diff --git a/cc/trees/property_tree_builder.cc b/cc/trees/property_tree_builder.cc
index 3da729e360d2c28134cae5cea83397d0df8af7b9..e95a9a63b9856c84a7e07e5eb39dc8a56722c426 100644
--- a/cc/trees/property_tree_builder.cc
+++ b/cc/trees/property_tree_builder.cc
@@ -11,6 +11,7 @@
#include "cc/layers/layer.h"
#include "cc/trees/layer_tree_host.h"
#include "ui/gfx/geometry/point_f.h"
+#include "ui/gfx/geometry/vector2d_conversions.h"
namespace cc {
@@ -33,6 +34,7 @@ struct DataForRecursion {
bool in_subtree_of_page_scale_application_layer;
bool should_flatten;
const gfx::Transform* device_transform;
+ gfx::Vector2dF scroll_compensation_adjustment;
};
static Layer* GetTransformParent(const DataForRecursion& data, Layer* layer) {
@@ -141,18 +143,21 @@ void AddTransformNodeIfNeeded(const DataForRecursion& data_from_ancestor,
parent_offset += to_parent.To2dTranslation();
} else if (!is_fixed) {
parent_offset = transform_parent->offset_to_transform_parent();
- } else if (data_from_ancestor.transform_tree_parent !=
- data_from_ancestor.transform_fixed_parent) {
- gfx::Vector2dF fixed_offset = data_from_ancestor.transform_tree_parent
- ->offset_to_transform_parent();
- gfx::Transform parent_to_parent;
- data_from_ancestor.transform_tree->ComputeTransform(
- data_from_ancestor.transform_tree_parent->transform_tree_index(),
- data_from_ancestor.transform_fixed_parent->transform_tree_index(),
- &parent_to_parent);
-
- fixed_offset += parent_to_parent.To2dTranslation();
- parent_offset += fixed_offset;
+ } else {
+ if (data_from_ancestor.transform_tree_parent !=
+ data_from_ancestor.transform_fixed_parent) {
+ gfx::Vector2dF fixed_offset = data_from_ancestor.transform_tree_parent
+ ->offset_to_transform_parent();
+ gfx::Transform parent_to_parent;
+ data_from_ancestor.transform_tree->ComputeTransform(
+ data_from_ancestor.transform_tree_parent->transform_tree_index(),
+ data_from_ancestor.transform_fixed_parent->transform_tree_index(),
+ &parent_to_parent);
+
+ fixed_offset += parent_to_parent.To2dTranslation();
+ parent_offset += fixed_offset;
+ }
+ parent_offset += data_from_ancestor.scroll_compensation_adjustment;
}
}
@@ -160,6 +165,9 @@ void AddTransformNodeIfNeeded(const DataForRecursion& data_from_ancestor,
data_for_children->transform_fixed_parent = layer;
data_for_children->transform_tree_parent = layer;
+ if (layer->IsContainerForFixedPositionLayers() || is_fixed)
+ data_for_children->scroll_compensation_adjustment = gfx::Vector2dF();
+
if (!requires_node) {
data_for_children->should_flatten |= layer->should_flatten_transform();
gfx::Vector2dF local_offset = layer->position().OffsetFromOrigin() +
@@ -232,6 +240,9 @@ void AddTransformNodeIfNeeded(const DataForRecursion& data_from_ancestor,
// Flattening (if needed) will be handled by |node|.
layer->set_should_flatten_transform_from_property_tree(false);
+
+ data_for_children->scroll_compensation_adjustment +=
+ layer->ScrollCompensationAdjustment() - node->data.scroll_snap;
}
void AddOpacityNodeIfNeeded(const DataForRecursion& data_from_ancestor,
« no previous file with comments | « cc/trees/property_tree.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698