OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/web_contents/aura/overscroll_layer_wrapper.h" |
| 6 |
| 7 #include "content/browser/web_contents/aura/shadow_layer_delegate.h" |
| 8 #include "ui/aura/window.h" |
| 9 #include "ui/compositor/layer.h" |
| 10 |
| 11 namespace content { |
| 12 |
| 13 OverscrollLayerWrapper::OverscrollLayerWrapper() |
| 14 : layer_(nullptr), |
| 15 window_(nullptr), |
| 16 shadow_(nullptr) { |
| 17 } |
| 18 |
| 19 OverscrollLayerWrapper::~OverscrollLayerWrapper() { |
| 20 } |
| 21 |
| 22 void OverscrollLayerWrapper::WrapWindow(aura::Window* window) { |
| 23 DCHECK(!window_); |
| 24 DCHECK(!layer_); |
| 25 window_ = window; |
| 26 shadow_.reset(new ShadowLayerDelegate(window_->layer())); |
| 27 } |
| 28 |
| 29 void OverscrollLayerWrapper::WrapLayer(ui::Layer* layer) { |
| 30 DCHECK(!window_); |
| 31 DCHECK(!layer_); |
| 32 layer_ = layer; |
| 33 shadow_.reset(new ShadowLayerDelegate(layer)); |
| 34 } |
| 35 |
| 36 void OverscrollLayerWrapper::SetTransform(const gfx::Transform& transform) { |
| 37 if (layer_) { |
| 38 layer_->SetTransform(transform); |
| 39 return; |
| 40 } |
| 41 DCHECK(window_); |
| 42 window_->SetTransform(transform); |
| 43 } |
| 44 |
| 45 void OverscrollLayerWrapper::SetBounds(const gfx::Rect& bounds) { |
| 46 if (layer_) { |
| 47 layer_->SetBounds(bounds); |
| 48 return; |
| 49 } |
| 50 DCHECK(window_); |
| 51 window_->SetBounds(bounds); |
| 52 } |
| 53 |
| 54 ui::LayerAnimator* OverscrollLayerWrapper::GetAnimator() { |
| 55 if (layer_) |
| 56 return layer_->GetAnimator(); |
| 57 DCHECK(window_); |
| 58 return window_->layer()->GetAnimator(); |
| 59 } |
| 60 |
| 61 gfx::Rect OverscrollLayerWrapper::GetBounds() { |
| 62 if (layer_) |
| 63 return layer_->bounds(); |
| 64 DCHECK(window_); |
| 65 return window_->bounds(); |
| 66 } |
| 67 |
| 68 } // namespace content |
OLD | NEW |