| 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/test/layer_tree_json_parser.h" | 5 #include "cc/test/layer_tree_json_parser.h" |
| 6 | 6 |
| 7 #include "base/test/values_test_util.h" | 7 #include "base/test/values_test_util.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "cc/layers/content_layer.h" | 9 #include "cc/layers/content_layer.h" |
| 10 #include "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 94 |
| 95 double opacity; | 95 double opacity; |
| 96 if (dict->GetDouble("Opacity", &opacity)) | 96 if (dict->GetDouble("Opacity", &opacity)) |
| 97 new_layer->SetOpacity(opacity); | 97 new_layer->SetOpacity(opacity); |
| 98 | 98 |
| 99 bool contents_opaque; | 99 bool contents_opaque; |
| 100 if (dict->GetBoolean("ContentsOpaque", &contents_opaque)) | 100 if (dict->GetBoolean("ContentsOpaque", &contents_opaque)) |
| 101 new_layer->SetContentsOpaque(contents_opaque); | 101 new_layer->SetContentsOpaque(contents_opaque); |
| 102 | 102 |
| 103 bool scrollable; | 103 bool scrollable; |
| 104 // TODO(wjmaclean) At some time in the future we may wish to test that a | |
| 105 // reconstructed layer tree contains the correct linkage for the scroll | |
| 106 // clip layer. This is complicated by the fact that the json output doesn't | |
| 107 // (currently) re-construct the tree with the same layer IDs as the original. | |
| 108 // But, since a clip layer is always an ancestor of the scrollable layer, we | |
| 109 // can just count the number of upwards hops to the clip layer and write that | |
| 110 // into the json file (with 0 hops implying no clip layer, i.e. not | |
| 111 // scrollable). Reconstructing the tree can then be accomplished by passing | |
| 112 // the parent pointer to this function and traversing the same number of | |
| 113 // ancestors to determine the pointer to the clip layer. The LayerTreesMatch() | |
| 114 // function should then check that both original and reconstructed layers | |
| 115 // have the same positioning with respect to their clip layers. | |
| 116 // | |
| 117 // For now, we can safely indicate a layer is scrollable by giving it a | |
| 118 // pointer to itself, something not normally allowed in a working tree. | |
| 119 // | |
| 120 // https://code.google.com/p/chromium/issues/detail?id=330622 | |
| 121 // | |
| 122 if (dict->GetBoolean("Scrollable", &scrollable)) | 104 if (dict->GetBoolean("Scrollable", &scrollable)) |
| 123 new_layer->SetScrollClipLayer(scrollable ? new_layer.get() : NULL); | 105 new_layer->SetScrollable(scrollable); |
| 124 | 106 |
| 125 bool wheel_handler; | 107 bool wheel_handler; |
| 126 if (dict->GetBoolean("WheelHandler", &wheel_handler)) | 108 if (dict->GetBoolean("WheelHandler", &wheel_handler)) |
| 127 new_layer->SetHaveWheelEventHandlers(wheel_handler); | 109 new_layer->SetHaveWheelEventHandlers(wheel_handler); |
| 128 | 110 |
| 129 if (dict->HasKey("TouchRegion")) { | 111 if (dict->HasKey("TouchRegion")) { |
| 130 success &= dict->GetList("TouchRegion", &list); | 112 success &= dict->GetList("TouchRegion", &list); |
| 131 Region touch_region; | 113 Region touch_region; |
| 132 for (size_t i = 0; i < list->GetSize(); ) { | 114 for (size_t i = 0; i < list->GetSize(); ) { |
| 133 int rect_x, rect_y, rect_width, rect_height; | 115 int rect_x, rect_y, rect_width, rect_height; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 163 | 145 |
| 164 } // namespace | 146 } // namespace |
| 165 | 147 |
| 166 scoped_refptr<Layer> ParseTreeFromJson(std::string json, | 148 scoped_refptr<Layer> ParseTreeFromJson(std::string json, |
| 167 ContentLayerClient* content_client) { | 149 ContentLayerClient* content_client) { |
| 168 scoped_ptr<base::Value> val = base::test::ParseJson(json); | 150 scoped_ptr<base::Value> val = base::test::ParseJson(json); |
| 169 return ParseTreeFromValue(val.get(), content_client); | 151 return ParseTreeFromValue(val.get(), content_client); |
| 170 } | 152 } |
| 171 | 153 |
| 172 } // namespace cc | 154 } // namespace cc |
| OLD | NEW |