Chromium Code Reviews| 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 | |
|
enne (OOO)
2013/11/14 22:59:01
This is pretty unfortunate. Can you file a bug to
wjmaclean
2013/12/24 21:03:49
Indeed, this hack was never meant to live ;-)
I'l
| |
| 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. | |
| 104 if (dict->GetBoolean("Scrollable", &scrollable)) | 119 if (dict->GetBoolean("Scrollable", &scrollable)) |
| 105 new_layer->SetScrollable(scrollable); | 120 new_layer->SetScrollable(scrollable ? new_layer.get() : NULL); |
| 106 | 121 |
| 107 bool wheel_handler; | 122 bool wheel_handler; |
| 108 if (dict->GetBoolean("WheelHandler", &wheel_handler)) | 123 if (dict->GetBoolean("WheelHandler", &wheel_handler)) |
| 109 new_layer->SetHaveWheelEventHandlers(wheel_handler); | 124 new_layer->SetHaveWheelEventHandlers(wheel_handler); |
| 110 | 125 |
| 111 if (dict->HasKey("TouchRegion")) { | 126 if (dict->HasKey("TouchRegion")) { |
| 112 success &= dict->GetList("TouchRegion", &list); | 127 success &= dict->GetList("TouchRegion", &list); |
| 113 cc::Region touch_region; | 128 cc::Region touch_region; |
| 114 for (size_t i = 0; i < list->GetSize(); ) { | 129 for (size_t i = 0; i < list->GetSize(); ) { |
| 115 int rect_x, rect_y, rect_width, rect_height; | 130 int rect_x, rect_y, rect_width, rect_height; |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 145 | 160 |
| 146 } // namespace | 161 } // namespace |
| 147 | 162 |
| 148 scoped_refptr<Layer> ParseTreeFromJson(std::string json, | 163 scoped_refptr<Layer> ParseTreeFromJson(std::string json, |
| 149 ContentLayerClient* content_client) { | 164 ContentLayerClient* content_client) { |
| 150 scoped_ptr<base::Value> val = base::test::ParseJson(json); | 165 scoped_ptr<base::Value> val = base::test::ParseJson(json); |
| 151 return ParseTreeFromValue(val.get(), content_client); | 166 return ParseTreeFromValue(val.get(), content_client); |
| 152 } | 167 } |
| 153 | 168 |
| 154 } // namespace cc | 169 } // namespace cc |
| OLD | NEW |