| 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 | 6 |
| 7 #include "cc/layers/layer.h" |
| 8 |
| 7 namespace cc { | 9 namespace cc { |
| 8 | 10 |
| 9 LayerStickyPositionConstraint::LayerStickyPositionConstraint() | 11 LayerStickyPositionConstraint::LayerStickyPositionConstraint() |
| 10 : is_sticky(false), | 12 : is_sticky(false), |
| 11 is_anchored_left(false), | 13 is_anchored_left(false), |
| 12 is_anchored_right(false), | 14 is_anchored_right(false), |
| 13 is_anchored_top(false), | 15 is_anchored_top(false), |
| 14 is_anchored_bottom(false), | 16 is_anchored_bottom(false), |
| 15 left_offset(0.f), | 17 left_offset(0.f), |
| 16 right_offset(0.f), | 18 right_offset(0.f), |
| 17 top_offset(0.f), | 19 top_offset(0.f), |
| 18 bottom_offset(0.f) {} | 20 bottom_offset(0.f), |
| 21 nearest_layer_shifting_sticky_box(Layer::INVALID_ID), |
| 22 nearest_layer_shifting_containing_block(Layer::INVALID_ID) {} |
| 19 | 23 |
| 20 LayerStickyPositionConstraint::LayerStickyPositionConstraint( | 24 LayerStickyPositionConstraint::LayerStickyPositionConstraint( |
| 21 const LayerStickyPositionConstraint& other) | 25 const LayerStickyPositionConstraint& other) |
| 22 : is_sticky(other.is_sticky), | 26 : is_sticky(other.is_sticky), |
| 23 is_anchored_left(other.is_anchored_left), | 27 is_anchored_left(other.is_anchored_left), |
| 24 is_anchored_right(other.is_anchored_right), | 28 is_anchored_right(other.is_anchored_right), |
| 25 is_anchored_top(other.is_anchored_top), | 29 is_anchored_top(other.is_anchored_top), |
| 26 is_anchored_bottom(other.is_anchored_bottom), | 30 is_anchored_bottom(other.is_anchored_bottom), |
| 27 left_offset(other.left_offset), | 31 left_offset(other.left_offset), |
| 28 right_offset(other.right_offset), | 32 right_offset(other.right_offset), |
| 29 top_offset(other.top_offset), | 33 top_offset(other.top_offset), |
| 30 bottom_offset(other.bottom_offset), | 34 bottom_offset(other.bottom_offset), |
| 31 parent_relative_sticky_box_offset( | 35 parent_relative_sticky_box_offset( |
| 32 other.parent_relative_sticky_box_offset), | 36 other.parent_relative_sticky_box_offset), |
| 33 scroll_container_relative_sticky_box_rect( | 37 scroll_container_relative_sticky_box_rect( |
| 34 other.scroll_container_relative_sticky_box_rect), | 38 other.scroll_container_relative_sticky_box_rect), |
| 35 scroll_container_relative_containing_block_rect( | 39 scroll_container_relative_containing_block_rect( |
| 36 other.scroll_container_relative_containing_block_rect) {} | 40 other.scroll_container_relative_containing_block_rect), |
| 41 nearest_layer_shifting_sticky_box( |
| 42 other.nearest_layer_shifting_sticky_box), |
| 43 nearest_layer_shifting_containing_block( |
| 44 other.nearest_layer_shifting_containing_block) {} |
| 37 | 45 |
| 38 bool LayerStickyPositionConstraint::operator==( | 46 bool LayerStickyPositionConstraint::operator==( |
| 39 const LayerStickyPositionConstraint& other) const { | 47 const LayerStickyPositionConstraint& other) const { |
| 40 if (!is_sticky && !other.is_sticky) | 48 if (!is_sticky && !other.is_sticky) |
| 41 return true; | 49 return true; |
| 42 return is_sticky == other.is_sticky && | 50 return is_sticky == other.is_sticky && |
| 43 is_anchored_left == other.is_anchored_left && | 51 is_anchored_left == other.is_anchored_left && |
| 44 is_anchored_right == other.is_anchored_right && | 52 is_anchored_right == other.is_anchored_right && |
| 45 is_anchored_top == other.is_anchored_top && | 53 is_anchored_top == other.is_anchored_top && |
| 46 is_anchored_bottom == other.is_anchored_bottom && | 54 is_anchored_bottom == other.is_anchored_bottom && |
| 47 left_offset == other.left_offset && | 55 left_offset == other.left_offset && |
| 48 right_offset == other.right_offset && top_offset == other.top_offset && | 56 right_offset == other.right_offset && top_offset == other.top_offset && |
| 49 bottom_offset == other.bottom_offset && | 57 bottom_offset == other.bottom_offset && |
| 50 parent_relative_sticky_box_offset == | 58 parent_relative_sticky_box_offset == |
| 51 other.parent_relative_sticky_box_offset && | 59 other.parent_relative_sticky_box_offset && |
| 52 scroll_container_relative_sticky_box_rect == | 60 scroll_container_relative_sticky_box_rect == |
| 53 other.scroll_container_relative_sticky_box_rect && | 61 other.scroll_container_relative_sticky_box_rect && |
| 54 scroll_container_relative_containing_block_rect == | 62 scroll_container_relative_containing_block_rect == |
| 55 other.scroll_container_relative_containing_block_rect; | 63 other.scroll_container_relative_containing_block_rect && |
| 64 nearest_layer_shifting_sticky_box == |
| 65 other.nearest_layer_shifting_sticky_box && |
| 66 nearest_layer_shifting_containing_block == |
| 67 other.nearest_layer_shifting_containing_block; |
| 56 } | 68 } |
| 57 | 69 |
| 58 bool LayerStickyPositionConstraint::operator!=( | 70 bool LayerStickyPositionConstraint::operator!=( |
| 59 const LayerStickyPositionConstraint& other) const { | 71 const LayerStickyPositionConstraint& other) const { |
| 60 return !(*this == other); | 72 return !(*this == other); |
| 61 } | 73 } |
| 62 | 74 |
| 75 int LayerStickyPositionConstraint::NearestStickyAncestor() { |
| 76 return (nearest_layer_shifting_sticky_box != Layer::INVALID_ID) |
| 77 ? nearest_layer_shifting_sticky_box |
| 78 : nearest_layer_shifting_containing_block; |
| 79 } |
| 80 |
| 63 } // namespace cc | 81 } // namespace cc |
| OLD | NEW |