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

Side by Side Diff: cc/layers/layer_sticky_position_constraint.cc

Issue 2251303003: Implement position: sticky updates on compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with master and add comments to WebLayerStickyPositionConstraint members. Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « cc/layers/layer_sticky_position_constraint.h ('k') | cc/proto/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "cc/layers/layer_sticky_position_constraint.h"
6 #include "cc/proto/gfx_conversions.h"
7 #include "cc/proto/layer_sticky_position_constraint.pb.h"
8
9 namespace cc {
10
11 LayerStickyPositionConstraint::LayerStickyPositionConstraint()
12 : is_sticky(false),
13 is_anchored_left(false),
14 is_anchored_right(false),
15 is_anchored_top(false),
16 is_anchored_bottom(false),
17 left_offset(0.f),
18 right_offset(0.f),
19 top_offset(0.f),
20 bottom_offset(0.f) {}
21
22 LayerStickyPositionConstraint::LayerStickyPositionConstraint(
23 const LayerStickyPositionConstraint& other)
24 : is_sticky(other.is_sticky),
25 is_anchored_left(other.is_anchored_left),
26 is_anchored_right(other.is_anchored_right),
27 is_anchored_top(other.is_anchored_top),
28 is_anchored_bottom(other.is_anchored_bottom),
29 left_offset(other.left_offset),
30 right_offset(other.right_offset),
31 top_offset(other.top_offset),
32 bottom_offset(other.bottom_offset),
33 scroll_container_relative_sticky_box_rect(
34 other.scroll_container_relative_sticky_box_rect),
35 scroll_container_relative_containing_block_rect(
36 other.scroll_container_relative_containing_block_rect) {}
37
38 void LayerStickyPositionConstraint::ToProtobuf(
39 proto::LayerStickyPositionConstraint* proto) const {
40 proto->set_is_sticky(is_sticky);
41 proto->set_is_anchored_left(is_anchored_left);
42 proto->set_is_anchored_right(is_anchored_right);
43 proto->set_is_anchored_top(is_anchored_top);
44 proto->set_is_anchored_bottom(is_anchored_bottom);
45 proto->set_left_offset(left_offset);
46 proto->set_right_offset(right_offset);
47 proto->set_top_offset(top_offset);
48 proto->set_bottom_offset(bottom_offset);
49 RectToProto(scroll_container_relative_sticky_box_rect,
50 proto->mutable_scroll_container_relative_sticky_box_rect());
51 RectToProto(scroll_container_relative_containing_block_rect,
52 proto->mutable_scroll_container_relative_containing_block_rect());
53 }
54
55 void LayerStickyPositionConstraint::FromProtobuf(
56 const proto::LayerStickyPositionConstraint& proto) {
57 is_sticky = proto.is_sticky();
58 is_anchored_left = proto.is_anchored_left();
59 is_anchored_right = proto.is_anchored_right();
60 is_anchored_top = proto.is_anchored_top();
61 is_anchored_bottom = proto.is_anchored_bottom();
62 left_offset = proto.left_offset();
63 right_offset = proto.right_offset();
64 top_offset = proto.top_offset();
65 bottom_offset = proto.bottom_offset();
66 scroll_container_relative_sticky_box_rect =
67 ProtoToRect(proto.scroll_container_relative_sticky_box_rect());
68 scroll_container_relative_containing_block_rect =
69 ProtoToRect(proto.scroll_container_relative_containing_block_rect());
70 }
71
72 bool LayerStickyPositionConstraint::operator==(
73 const LayerStickyPositionConstraint& other) const {
74 if (!is_sticky && !other.is_sticky)
75 return true;
76 return is_sticky == other.is_sticky &&
77 is_anchored_left == other.is_anchored_left &&
78 is_anchored_right == other.is_anchored_right &&
79 is_anchored_top == other.is_anchored_top &&
80 is_anchored_bottom == other.is_anchored_bottom &&
81 left_offset == other.left_offset &&
82 right_offset == other.right_offset && top_offset == other.top_offset &&
83 bottom_offset == other.bottom_offset &&
84 scroll_container_relative_sticky_box_rect ==
85 other.scroll_container_relative_sticky_box_rect &&
86 scroll_container_relative_containing_block_rect ==
87 other.scroll_container_relative_containing_block_rect;
88 }
89
90 bool LayerStickyPositionConstraint::operator!=(
91 const LayerStickyPositionConstraint& other) const {
92 return !(*this == other);
93 }
94
95 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_sticky_position_constraint.h ('k') | cc/proto/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698