| Index: cc/blink/web_mutable_state_impl.cc | 
| diff --git a/cc/blink/web_mutable_state_impl.cc b/cc/blink/web_mutable_state_impl.cc | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..7104ee703ac6e42e26628a68cd1698f128f58a8c | 
| --- /dev/null | 
| +++ b/cc/blink/web_mutable_state_impl.cc | 
| @@ -0,0 +1,89 @@ | 
| +// Copyright 2015 The Chromium Authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| +#include "cc/blink/web_mutable_state_impl.h" | 
| + | 
| +#include "cc/animation/layer_tree_mutation.h" | 
| +#include "cc/layers/layer_impl.h" | 
| +#include "cc/trees/layer_tree_impl.h" | 
| + | 
| +namespace cc_blink { | 
| + | 
| +WebMutableStateImpl::WebMutableStateImpl(cc::LayerTreeMutation* mutation, | 
| +                                         cc::LayerImpl* main_layer, | 
| +                                         cc::LayerImpl* scroll_layer) | 
| +    : mutation_(mutation), | 
| +      main_layer_(main_layer), | 
| +      scroll_layer_(scroll_layer) {} | 
| + | 
| +WebMutableStateImpl::~WebMutableStateImpl() {} | 
| + | 
| +double WebMutableStateImpl::getOpacity() const { | 
| +  return main_layer_->opacity(); | 
| +} | 
| + | 
| +void WebMutableStateImpl::setOpacity(double opacity) { | 
| +  if (!main_layer_) | 
| +    return; | 
| +  main_layer_->OnOpacityAnimated(opacity); | 
| +  mutation_->SetOpacity(opacity); | 
| +} | 
| + | 
| +const SkMatrix44& WebMutableStateImpl::getTransform() const { | 
| +  static SkMatrix44 identity; | 
| +  return main_layer_ ? main_layer_->transform().matrix() : identity; | 
| +} | 
| + | 
| +void WebMutableStateImpl::setTransform(const SkMatrix44& matrix) { | 
| +  if (!main_layer_) | 
| +    return; | 
| +  main_layer_->OnTransformAnimated(gfx::Transform(matrix)); | 
| +  mutation_->SetTransform(matrix); | 
| +} | 
| + | 
| +double WebMutableStateImpl::getScrollLeft() const { | 
| +  return scroll_layer_ ? scroll_layer_->CurrentScrollOffset().x() : 0.0; | 
| +} | 
| + | 
| +void WebMutableStateImpl::setScrollLeft(double scroll_left) { | 
| +  if (!scroll_layer_) | 
| +    return; | 
| +  gfx::ScrollOffset offset = scroll_layer_->CurrentScrollOffset(); | 
| +  offset.set_x(scroll_left); | 
| +  scroll_layer_->OnScrollOffsetAnimated(offset); | 
| +  mutation_->SetScrollLeft(scroll_left); | 
| +} | 
| + | 
| +double WebMutableStateImpl::getScrollTop() const { | 
| +  return scroll_layer_ ? scroll_layer_->CurrentScrollOffset().y() : 0.0; | 
| +} | 
| + | 
| +void WebMutableStateImpl::setScrollTop(double scroll_top) { | 
| +  if (!scroll_layer_) | 
| +    return; | 
| +  gfx::ScrollOffset offset = scroll_layer_->CurrentScrollOffset(); | 
| +  offset.set_y(scroll_top); | 
| +  scroll_layer_->OnScrollOffsetAnimated(offset); | 
| +  mutation_->SetScrollTop(scroll_top); | 
| +} | 
| + | 
| +WebMutableStateProviderImpl::WebMutableStateProviderImpl( | 
| +    cc::LayerTreeImpl* state, | 
| +    cc::LayerTreeMutationMap* mutations) | 
| +    : state_(state), mutations_(mutations) {} | 
| + | 
| +WebMutableStateProviderImpl::~WebMutableStateProviderImpl() {} | 
| + | 
| +blink::WebMutableState* WebMutableStateProviderImpl::getMutableStateFor( | 
| +    uint64_t element_id) { | 
| +  cc::LayerImpl* main_layer = nullptr; | 
| +  cc::LayerImpl* scroll_layer = nullptr; | 
| +  if (!state_->GetMutableLayers(element_id, &main_layer, &scroll_layer)) | 
| +    return nullptr; | 
| + | 
| +  return new WebMutableStateImpl(&(*mutations_)[element_id], main_layer, | 
| +                                 scroll_layer); | 
| +} | 
| + | 
| +}  // namespace cc_blink | 
|  |