| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/trace_event/trace_event_argument.h" | 5 #include "base/trace_event/trace_event_argument.h" |
| 6 #include "cc/animation/element_id.h" | 6 #include "cc/animation/element_id.h" |
| 7 #include "cc/base/math_util.h" | 7 #include "cc/base/math_util.h" |
| 8 #include "cc/input/main_thread_scrolling_reason.h" | 8 #include "cc/input/main_thread_scrolling_reason.h" |
| 9 #include "cc/proto/gfx_conversions.h" | 9 #include "cc/proto/gfx_conversions.h" |
| 10 #include "cc/proto/property_tree.pb.h" | |
| 11 #include "cc/trees/scroll_node.h" | 10 #include "cc/trees/scroll_node.h" |
| 12 | 11 |
| 13 namespace cc { | 12 namespace cc { |
| 14 | 13 |
| 15 ScrollNode::ScrollNode() | 14 ScrollNode::ScrollNode() |
| 16 : id(-1), | 15 : id(-1), |
| 17 parent_id(-1), | 16 parent_id(-1), |
| 18 owner_id(-1), | 17 owner_id(-1), |
| 19 scrollable(false), | 18 scrollable(false), |
| 20 main_thread_scrolling_reasons( | 19 main_thread_scrolling_reasons( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 45 other.is_inner_viewport_scroll_layer && | 44 other.is_inner_viewport_scroll_layer && |
| 46 is_outer_viewport_scroll_layer == | 45 is_outer_viewport_scroll_layer == |
| 47 other.is_outer_viewport_scroll_layer && | 46 other.is_outer_viewport_scroll_layer && |
| 48 offset_to_transform_parent == other.offset_to_transform_parent && | 47 offset_to_transform_parent == other.offset_to_transform_parent && |
| 49 should_flatten == other.should_flatten && | 48 should_flatten == other.should_flatten && |
| 50 user_scrollable_horizontal == other.user_scrollable_horizontal && | 49 user_scrollable_horizontal == other.user_scrollable_horizontal && |
| 51 user_scrollable_vertical == other.user_scrollable_vertical && | 50 user_scrollable_vertical == other.user_scrollable_vertical && |
| 52 element_id == other.element_id && transform_id == other.transform_id; | 51 element_id == other.element_id && transform_id == other.transform_id; |
| 53 } | 52 } |
| 54 | 53 |
| 55 void ScrollNode::ToProtobuf(proto::TreeNode* proto) const { | |
| 56 proto->set_id(id); | |
| 57 proto->set_parent_id(parent_id); | |
| 58 proto->set_owner_id(owner_id); | |
| 59 | |
| 60 DCHECK(!proto->has_scroll_node_data()); | |
| 61 proto::ScrollNodeData* data = proto->mutable_scroll_node_data(); | |
| 62 data->set_scrollable(scrollable); | |
| 63 data->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons); | |
| 64 data->set_contains_non_fast_scrollable_region( | |
| 65 contains_non_fast_scrollable_region); | |
| 66 SizeToProto(scroll_clip_layer_bounds, | |
| 67 data->mutable_scroll_clip_layer_bounds()); | |
| 68 SizeToProto(bounds, data->mutable_bounds()); | |
| 69 data->set_max_scroll_offset_affected_by_page_scale( | |
| 70 max_scroll_offset_affected_by_page_scale); | |
| 71 data->set_is_inner_viewport_scroll_layer(is_inner_viewport_scroll_layer); | |
| 72 data->set_is_outer_viewport_scroll_layer(is_outer_viewport_scroll_layer); | |
| 73 Vector2dFToProto(offset_to_transform_parent, | |
| 74 data->mutable_offset_to_transform_parent()); | |
| 75 data->set_should_flatten(should_flatten); | |
| 76 data->set_user_scrollable_horizontal(user_scrollable_horizontal); | |
| 77 data->set_user_scrollable_vertical(user_scrollable_vertical); | |
| 78 element_id.ToProtobuf(data->mutable_element_id()); | |
| 79 data->set_transform_id(transform_id); | |
| 80 } | |
| 81 | |
| 82 void ScrollNode::FromProtobuf(const proto::TreeNode& proto) { | |
| 83 id = proto.id(); | |
| 84 parent_id = proto.parent_id(); | |
| 85 owner_id = proto.owner_id(); | |
| 86 | |
| 87 DCHECK(proto.has_scroll_node_data()); | |
| 88 const proto::ScrollNodeData& data = proto.scroll_node_data(); | |
| 89 | |
| 90 scrollable = data.scrollable(); | |
| 91 main_thread_scrolling_reasons = data.main_thread_scrolling_reasons(); | |
| 92 contains_non_fast_scrollable_region = | |
| 93 data.contains_non_fast_scrollable_region(); | |
| 94 scroll_clip_layer_bounds = ProtoToSize(data.scroll_clip_layer_bounds()); | |
| 95 bounds = ProtoToSize(data.bounds()); | |
| 96 max_scroll_offset_affected_by_page_scale = | |
| 97 data.max_scroll_offset_affected_by_page_scale(); | |
| 98 is_inner_viewport_scroll_layer = data.is_inner_viewport_scroll_layer(); | |
| 99 is_outer_viewport_scroll_layer = data.is_outer_viewport_scroll_layer(); | |
| 100 offset_to_transform_parent = | |
| 101 ProtoToVector2dF(data.offset_to_transform_parent()); | |
| 102 should_flatten = data.should_flatten(); | |
| 103 user_scrollable_horizontal = data.user_scrollable_horizontal(); | |
| 104 user_scrollable_vertical = data.user_scrollable_vertical(); | |
| 105 element_id.FromProtobuf(data.element_id()); | |
| 106 transform_id = data.transform_id(); | |
| 107 } | |
| 108 | |
| 109 void ScrollNode::AsValueInto(base::trace_event::TracedValue* value) const { | 54 void ScrollNode::AsValueInto(base::trace_event::TracedValue* value) const { |
| 110 value->SetInteger("id", id); | 55 value->SetInteger("id", id); |
| 111 value->SetInteger("parent_id", parent_id); | 56 value->SetInteger("parent_id", parent_id); |
| 112 value->SetInteger("owner_id", owner_id); | 57 value->SetInteger("owner_id", owner_id); |
| 113 value->SetBoolean("scrollable", scrollable); | 58 value->SetBoolean("scrollable", scrollable); |
| 114 MathUtil::AddToTracedValue("scroll_clip_layer_bounds", | 59 MathUtil::AddToTracedValue("scroll_clip_layer_bounds", |
| 115 scroll_clip_layer_bounds, value); | 60 scroll_clip_layer_bounds, value); |
| 116 MathUtil::AddToTracedValue("bounds", bounds, value); | 61 MathUtil::AddToTracedValue("bounds", bounds, value); |
| 117 MathUtil::AddToTracedValue("offset_to_transform_parent", | 62 MathUtil::AddToTracedValue("offset_to_transform_parent", |
| 118 offset_to_transform_parent, value); | 63 offset_to_transform_parent, value); |
| 119 value->SetBoolean("should_flatten", should_flatten); | 64 value->SetBoolean("should_flatten", should_flatten); |
| 120 value->SetBoolean("user_scrollable_horizontal", user_scrollable_horizontal); | 65 value->SetBoolean("user_scrollable_horizontal", user_scrollable_horizontal); |
| 121 value->SetBoolean("user_scrollable_vertical", user_scrollable_vertical); | 66 value->SetBoolean("user_scrollable_vertical", user_scrollable_vertical); |
| 122 | 67 |
| 123 element_id.AddToTracedValue(value); | 68 element_id.AddToTracedValue(value); |
| 124 value->SetInteger("transform_id", transform_id); | 69 value->SetInteger("transform_id", transform_id); |
| 125 } | 70 } |
| 126 | 71 |
| 127 } // namespace cc | 72 } // namespace cc |
| OLD | NEW |