| Index: ui/compositor/layer_animator.cc
 | 
| diff --git a/ui/compositor/layer_animator.cc b/ui/compositor/layer_animator.cc
 | 
| index b3474964bcfeb46668c57344a8926907631d27b6..dd2ea4afaf7e5f52005b91bfe00aa0ca03ec3e1b 100644
 | 
| --- a/ui/compositor/layer_animator.cc
 | 
| +++ b/ui/compositor/layer_animator.cc
 | 
| @@ -139,9 +139,12 @@ void LayerAnimator::SwitchToLayer(scoped_refptr<cc::Layer> new_layer) {
 | 
|    element_animations_state_ = nullptr;
 | 
|  
 | 
|    if (delegate_)
 | 
| -    DetachLayerFromAnimationPlayer();
 | 
| -  if (new_layer)
 | 
| -    AttachLayerToAnimationPlayer(new_layer->id());
 | 
| +    DetachElementFromAnimationPlayer();
 | 
| +  if (new_layer) {
 | 
| +    if (!new_layer->element_id())
 | 
| +      new_layer->SetElementId(Layer::NextElementId());
 | 
| +    AttachElementToAnimationPlayer(new_layer->element_id());
 | 
| +  }
 | 
|  }
 | 
|  
 | 
|  void LayerAnimator::SetCompositor(Compositor* compositor) {
 | 
| @@ -157,14 +160,14 @@ void LayerAnimator::SetCompositor(Compositor* compositor) {
 | 
|    // AnimationHost::GetElementAnimationsForLayerId.
 | 
|    if (element_animations_state_) {
 | 
|      DCHECK_EQ(element_animations_state_->element_id(),
 | 
| -              delegate_->GetCcLayer()->id());
 | 
| +              delegate_->GetCcLayer()->element_id());
 | 
|      timeline->animation_host()->RegisterElementAnimations(
 | 
|          element_animations_state_.get());
 | 
|    }
 | 
|  
 | 
|    timeline->AttachPlayer(animation_player_);
 | 
|  
 | 
| -  AttachLayerToAnimationPlayer(delegate_->GetCcLayer()->id());
 | 
| +  AttachElementToAnimationPlayer(delegate_->GetCcLayer()->element_id());
 | 
|  
 | 
|    // Release ElementAnimations state.
 | 
|    element_animations_state_ = nullptr;
 | 
| @@ -176,30 +179,33 @@ void LayerAnimator::ResetCompositor(Compositor* compositor) {
 | 
|    cc::AnimationTimeline* timeline = compositor->GetAnimationTimeline();
 | 
|    DCHECK(timeline);
 | 
|  
 | 
| -  const int layer_id = animation_player_->element_id();
 | 
| +  const cc::ElementId element_id = animation_player_->element_id();
 | 
|  
 | 
|    // Store a reference to ElementAnimations (if any)
 | 
|    // so it may be picked up in LayerAnimator::SetCompositor.
 | 
| -  if (layer_id) {
 | 
| +  if (element_id) {
 | 
|      element_animations_state_ =
 | 
| -        timeline->animation_host()->GetElementAnimationsForElementId(layer_id);
 | 
| +        timeline->animation_host()->GetElementAnimationsForElementId(
 | 
| +            element_id);
 | 
|    }
 | 
|  
 | 
| -  DetachLayerFromAnimationPlayer();
 | 
| +  DetachElementFromAnimationPlayer();
 | 
|  
 | 
|    timeline->DetachPlayer(animation_player_);
 | 
|  }
 | 
|  
 | 
| -void LayerAnimator::AttachLayerToAnimationPlayer(int layer_id) {
 | 
| +void LayerAnimator::AttachElementToAnimationPlayer(cc::ElementId element_id) {
 | 
| +  DCHECK(element_id);
 | 
| +
 | 
|    if (!animation_player_->element_id())
 | 
| -    animation_player_->AttachElement(layer_id);
 | 
| +    animation_player_->AttachElement(element_id);
 | 
|    else
 | 
| -    DCHECK_EQ(animation_player_->element_id(), layer_id);
 | 
| +    DCHECK_EQ(animation_player_->element_id(), element_id);
 | 
|  
 | 
|    animation_player_->set_animation_delegate(this);
 | 
|  }
 | 
|  
 | 
| -void LayerAnimator::DetachLayerFromAnimationPlayer() {
 | 
| +void LayerAnimator::DetachElementFromAnimationPlayer() {
 | 
|    animation_player_->set_animation_delegate(nullptr);
 | 
|  
 | 
|    if (animation_player_->element_id())
 | 
| 
 |