Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / cc / test / layer_tree_json_parser.cc
index e7f3e9b..1514d83 100644 (file)
@@ -69,8 +69,7 @@ scoped_refptr<Layer> ParseTreeFromValue(base::Value* val,
     scoped_refptr<NinePatchLayer> nine_patch_layer = NinePatchLayer::Create();
 
     SkBitmap bitmap;
-    bitmap.setConfig(SkBitmap::kARGB_8888_Config, image_width, image_height);
-    bitmap.allocPixels(NULL, NULL);
+    bitmap.allocN32Pixels(image_width, image_height);
     bitmap.setImmutable();
     nine_patch_layer->SetBitmap(bitmap);
     nine_patch_layer->SetAperture(
@@ -87,7 +86,6 @@ scoped_refptr<Layer> ParseTreeFromValue(base::Value* val,
   } else {  // Type "Layer" or "unknown"
     new_layer = Layer::Create();
   }
-  new_layer->SetAnchorPoint(gfx::Point());
   new_layer->SetPosition(gfx::PointF(position_x, position_y));
   new_layer->SetBounds(gfx::Size(width, height));
   new_layer->SetIsDrawable(draws_content);
@@ -101,13 +99,42 @@ scoped_refptr<Layer> ParseTreeFromValue(base::Value* val,
     new_layer->SetContentsOpaque(contents_opaque);
 
   bool scrollable;
+  // TODO(wjmaclean) At some time in the future we may wish to test that a
+  // reconstructed layer tree contains the correct linkage for the scroll
+  // clip layer. This is complicated by the fact that the json output doesn't
+  // (currently) re-construct the tree with the same layer IDs as the original.
+  // But, since a clip layer is always an ancestor of the scrollable layer, we
+  // can just count the number of upwards hops to the clip layer and write that
+  // into the json file (with 0 hops implying no clip layer, i.e. not
+  // scrollable). Reconstructing the tree can then be accomplished by passing
+  // the parent pointer to this function and traversing the same number of
+  // ancestors to determine the pointer to the clip layer. The LayerTreesMatch()
+  // function should then check that both original and reconstructed layers
+  // have the same positioning with respect to their clip layers.
+  //
+  // For now, we can safely indicate a layer is scrollable by giving it a
+  // pointer to itself, something not normally allowed in a working tree.
+  //
+  // https://code.google.com/p/chromium/issues/detail?id=330622
+  //
   if (dict->GetBoolean("Scrollable", &scrollable))
-    new_layer->SetScrollable(scrollable);
+    new_layer->SetScrollClipLayerId(scrollable ? new_layer->id()
+                                               : Layer::INVALID_ID);
 
   bool wheel_handler;
   if (dict->GetBoolean("WheelHandler", &wheel_handler))
     new_layer->SetHaveWheelEventHandlers(wheel_handler);
 
+  bool scroll_handler;
+  if (dict->GetBoolean("ScrollHandler", &scroll_handler))
+    new_layer->SetHaveScrollEventHandlers(scroll_handler);
+
+  bool is_3d_sorted;
+  if (dict->GetBoolean("Is3DSorted", &is_3d_sorted)) {
+    // A non-zero context ID will put the layer into a 3D sorting context
+    new_layer->Set3dSortingContextId(is_3d_sorted ? 1 : 0);
+  }
+
   if (dict->HasKey("TouchRegion")) {
     success &= dict->GetList("TouchRegion", &list);
     Region touch_region;