| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/layers/layer_sticky_position_constraint.h" | 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 | 6 |
| 9 namespace cc { | 7 namespace cc { |
| 10 | 8 |
| 11 LayerStickyPositionConstraint::LayerStickyPositionConstraint() | 9 LayerStickyPositionConstraint::LayerStickyPositionConstraint() |
| 12 : is_sticky(false), | 10 : is_sticky(false), |
| 13 is_anchored_left(false), | 11 is_anchored_left(false), |
| 14 is_anchored_right(false), | 12 is_anchored_right(false), |
| 15 is_anchored_top(false), | 13 is_anchored_top(false), |
| 16 is_anchored_bottom(false), | 14 is_anchored_bottom(false), |
| 17 left_offset(0.f), | 15 left_offset(0.f), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 30 right_offset(other.right_offset), | 28 right_offset(other.right_offset), |
| 31 top_offset(other.top_offset), | 29 top_offset(other.top_offset), |
| 32 bottom_offset(other.bottom_offset), | 30 bottom_offset(other.bottom_offset), |
| 33 parent_relative_sticky_box_offset( | 31 parent_relative_sticky_box_offset( |
| 34 other.parent_relative_sticky_box_offset), | 32 other.parent_relative_sticky_box_offset), |
| 35 scroll_container_relative_sticky_box_rect( | 33 scroll_container_relative_sticky_box_rect( |
| 36 other.scroll_container_relative_sticky_box_rect), | 34 other.scroll_container_relative_sticky_box_rect), |
| 37 scroll_container_relative_containing_block_rect( | 35 scroll_container_relative_containing_block_rect( |
| 38 other.scroll_container_relative_containing_block_rect) {} | 36 other.scroll_container_relative_containing_block_rect) {} |
| 39 | 37 |
| 40 void LayerStickyPositionConstraint::ToProtobuf( | |
| 41 proto::LayerStickyPositionConstraint* proto) const { | |
| 42 proto->set_is_sticky(is_sticky); | |
| 43 proto->set_is_anchored_left(is_anchored_left); | |
| 44 proto->set_is_anchored_right(is_anchored_right); | |
| 45 proto->set_is_anchored_top(is_anchored_top); | |
| 46 proto->set_is_anchored_bottom(is_anchored_bottom); | |
| 47 proto->set_left_offset(left_offset); | |
| 48 proto->set_right_offset(right_offset); | |
| 49 proto->set_top_offset(top_offset); | |
| 50 proto->set_bottom_offset(bottom_offset); | |
| 51 PointToProto(parent_relative_sticky_box_offset, | |
| 52 proto->mutable_parent_relative_sticky_box_offset()); | |
| 53 RectToProto(scroll_container_relative_sticky_box_rect, | |
| 54 proto->mutable_scroll_container_relative_sticky_box_rect()); | |
| 55 RectToProto(scroll_container_relative_containing_block_rect, | |
| 56 proto->mutable_scroll_container_relative_containing_block_rect()); | |
| 57 } | |
| 58 | |
| 59 void LayerStickyPositionConstraint::FromProtobuf( | |
| 60 const proto::LayerStickyPositionConstraint& proto) { | |
| 61 is_sticky = proto.is_sticky(); | |
| 62 is_anchored_left = proto.is_anchored_left(); | |
| 63 is_anchored_right = proto.is_anchored_right(); | |
| 64 is_anchored_top = proto.is_anchored_top(); | |
| 65 is_anchored_bottom = proto.is_anchored_bottom(); | |
| 66 left_offset = proto.left_offset(); | |
| 67 right_offset = proto.right_offset(); | |
| 68 top_offset = proto.top_offset(); | |
| 69 bottom_offset = proto.bottom_offset(); | |
| 70 parent_relative_sticky_box_offset = | |
| 71 ProtoToPoint(proto.parent_relative_sticky_box_offset()); | |
| 72 scroll_container_relative_sticky_box_rect = | |
| 73 ProtoToRect(proto.scroll_container_relative_sticky_box_rect()); | |
| 74 scroll_container_relative_containing_block_rect = | |
| 75 ProtoToRect(proto.scroll_container_relative_containing_block_rect()); | |
| 76 } | |
| 77 | |
| 78 bool LayerStickyPositionConstraint::operator==( | 38 bool LayerStickyPositionConstraint::operator==( |
| 79 const LayerStickyPositionConstraint& other) const { | 39 const LayerStickyPositionConstraint& other) const { |
| 80 if (!is_sticky && !other.is_sticky) | 40 if (!is_sticky && !other.is_sticky) |
| 81 return true; | 41 return true; |
| 82 return is_sticky == other.is_sticky && | 42 return is_sticky == other.is_sticky && |
| 83 is_anchored_left == other.is_anchored_left && | 43 is_anchored_left == other.is_anchored_left && |
| 84 is_anchored_right == other.is_anchored_right && | 44 is_anchored_right == other.is_anchored_right && |
| 85 is_anchored_top == other.is_anchored_top && | 45 is_anchored_top == other.is_anchored_top && |
| 86 is_anchored_bottom == other.is_anchored_bottom && | 46 is_anchored_bottom == other.is_anchored_bottom && |
| 87 left_offset == other.left_offset && | 47 left_offset == other.left_offset && |
| 88 right_offset == other.right_offset && top_offset == other.top_offset && | 48 right_offset == other.right_offset && top_offset == other.top_offset && |
| 89 bottom_offset == other.bottom_offset && | 49 bottom_offset == other.bottom_offset && |
| 90 parent_relative_sticky_box_offset == | 50 parent_relative_sticky_box_offset == |
| 91 other.parent_relative_sticky_box_offset && | 51 other.parent_relative_sticky_box_offset && |
| 92 scroll_container_relative_sticky_box_rect == | 52 scroll_container_relative_sticky_box_rect == |
| 93 other.scroll_container_relative_sticky_box_rect && | 53 other.scroll_container_relative_sticky_box_rect && |
| 94 scroll_container_relative_containing_block_rect == | 54 scroll_container_relative_containing_block_rect == |
| 95 other.scroll_container_relative_containing_block_rect; | 55 other.scroll_container_relative_containing_block_rect; |
| 96 } | 56 } |
| 97 | 57 |
| 98 bool LayerStickyPositionConstraint::operator!=( | 58 bool LayerStickyPositionConstraint::operator!=( |
| 99 const LayerStickyPositionConstraint& other) const { | 59 const LayerStickyPositionConstraint& other) const { |
| 100 return !(*this == other); | 60 return !(*this == other); |
| 101 } | 61 } |
| 102 | 62 |
| 103 } // namespace cc | 63 } // namespace cc |
| OLD | NEW |