Merge "Cherry-pick "Dynamically enable spatial navigation based on events"" into klp-dev
diff --git a/cc/layers/picture_layer.cc b/cc/layers/picture_layer.cc
index 889e2fb..c84ade3 100644
--- a/cc/layers/picture_layer.cc
+++ b/cc/layers/picture_layer.cc
@@ -41,6 +41,18 @@
   // This should be first so others can use it.
   layer_impl->UpdateTwinLayer();
 
+  if (layer_impl->bounds().IsEmpty()) {
+    // Update may not get called for an empty layer, so resize here instead.
+    // Using layer_impl because either bounds() or paint_properties().bounds
+    // may disagree and either one could have been pushed to layer_impl.
+    pile_->Resize(layer_impl->bounds());
+    pile_->UpdateRecordedRegion();
+  }
+
+  if (DrawsContent()) {
+    DCHECK(paint_properties().bounds == pile_->size());
+  }
+
   layer_impl->SetIsMask(is_mask_);
   layer_impl->CreateTilingSetIfNeeded();
   // Unlike other properties, invalidation must always be set on layer_impl.