OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/web_contents/aura/gesture_nav_simple.h" | 5 #include "content/browser/web_contents/aura/gesture_nav_simple.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/macros.h" | 9 #include "base/macros.h" |
8 #include "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
9 #include "content/browser/frame_host/navigation_controller_impl.h" | 11 #include "content/browser/frame_host/navigation_controller_impl.h" |
10 #include "content/browser/renderer_host/overscroll_controller.h" | 12 #include "content/browser/renderer_host/overscroll_controller.h" |
11 #include "content/browser/web_contents/web_contents_impl.h" | 13 #include "content/browser/web_contents/web_contents_impl.h" |
12 #include "content/browser/web_contents/web_contents_view.h" | 14 #include "content/browser/web_contents/web_contents_view.h" |
13 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
14 #include "content/public/browser/overscroll_configuration.h" | 16 #include "content/public/browser/overscroll_configuration.h" |
15 #include "content/public/common/content_client.h" | 17 #include "content/public/common/content_client.h" |
16 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
(...skipping 26 matching lines...) Expand all Loading... |
43 return mode == (base::i18n::IsRTL() ? OVERSCROLL_WEST : OVERSCROLL_EAST) && | 45 return mode == (base::i18n::IsRTL() ? OVERSCROLL_WEST : OVERSCROLL_EAST) && |
44 controller.CanGoBack(); | 46 controller.CanGoBack(); |
45 } | 47 } |
46 | 48 |
47 // An animation observers that deletes itself and a pointer after the end of the | 49 // An animation observers that deletes itself and a pointer after the end of the |
48 // animation. | 50 // animation. |
49 template <class T> | 51 template <class T> |
50 class DeleteAfterAnimation : public ui::ImplicitAnimationObserver { | 52 class DeleteAfterAnimation : public ui::ImplicitAnimationObserver { |
51 public: | 53 public: |
52 explicit DeleteAfterAnimation(scoped_ptr<T> object) | 54 explicit DeleteAfterAnimation(scoped_ptr<T> object) |
53 : object_(object.Pass()) {} | 55 : object_(std::move(object)) {} |
54 | 56 |
55 private: | 57 private: |
56 friend class base::DeleteHelper<DeleteAfterAnimation<T> >; | 58 friend class base::DeleteHelper<DeleteAfterAnimation<T> >; |
57 | 59 |
58 ~DeleteAfterAnimation() override {} | 60 ~DeleteAfterAnimation() override {} |
59 | 61 |
60 // ui::ImplicitAnimationObserver: | 62 // ui::ImplicitAnimationObserver: |
61 void OnImplicitAnimationsCompleted() override { | 63 void OnImplicitAnimationsCompleted() override { |
62 // Deleting an observer when a ScopedLayerAnimationSettings is iterating | 64 // Deleting an observer when a ScopedLayerAnimationSettings is iterating |
63 // over them can cause a crash (which can happen during tests). So instead, | 65 // over them can cause a crash (which can happen during tests). So instead, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 : web_contents_(web_contents), | 124 : web_contents_(web_contents), |
123 completion_threshold_(0.f) {} | 125 completion_threshold_(0.f) {} |
124 | 126 |
125 GestureNavSimple::~GestureNavSimple() {} | 127 GestureNavSimple::~GestureNavSimple() {} |
126 | 128 |
127 void GestureNavSimple::ApplyEffectsAndDestroy(const gfx::Transform& transform, | 129 void GestureNavSimple::ApplyEffectsAndDestroy(const gfx::Transform& transform, |
128 float opacity) { | 130 float opacity) { |
129 ui::Layer* layer = arrow_.get(); | 131 ui::Layer* layer = arrow_.get(); |
130 ui::ScopedLayerAnimationSettings settings(arrow_->GetAnimator()); | 132 ui::ScopedLayerAnimationSettings settings(arrow_->GetAnimator()); |
131 settings.AddObserver( | 133 settings.AddObserver( |
132 new DeleteAfterAnimation<ArrowLayerDelegate>(arrow_delegate_.Pass())); | 134 new DeleteAfterAnimation<ArrowLayerDelegate>(std::move(arrow_delegate_))); |
133 settings.AddObserver(new DeleteAfterAnimation<ui::Layer>(arrow_.Pass())); | 135 settings.AddObserver(new DeleteAfterAnimation<ui::Layer>(std::move(arrow_))); |
134 settings.AddObserver(new DeleteAfterAnimation<ui::Layer>(clip_layer_.Pass())); | 136 settings.AddObserver( |
| 137 new DeleteAfterAnimation<ui::Layer>(std::move(clip_layer_))); |
135 layer->SetTransform(transform); | 138 layer->SetTransform(transform); |
136 layer->SetOpacity(opacity); | 139 layer->SetOpacity(opacity); |
137 } | 140 } |
138 | 141 |
139 void GestureNavSimple::AbortGestureAnimation() { | 142 void GestureNavSimple::AbortGestureAnimation() { |
140 if (!arrow_) | 143 if (!arrow_) |
141 return; | 144 return; |
142 gfx::Transform transform; | 145 gfx::Transform transform; |
143 transform.Translate(arrow_delegate_->left() ? -kArrowWidth : kArrowWidth, 0); | 146 transform.Translate(arrow_delegate_->left() ? -kArrowWidth : kArrowWidth, 0); |
144 ApplyEffectsAndDestroy(transform, kMinOpacity); | 147 ApplyEffectsAndDestroy(transform, kMinOpacity); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 clip_layer_->SetBounds(window->layer()->bounds()); | 234 clip_layer_->SetBounds(window->layer()->bounds()); |
232 clip_layer_->SetMasksToBounds(true); | 235 clip_layer_->SetMasksToBounds(true); |
233 clip_layer_->Add(arrow_.get()); | 236 clip_layer_->Add(arrow_.get()); |
234 | 237 |
235 ui::Layer* parent = window->layer()->parent(); | 238 ui::Layer* parent = window->layer()->parent(); |
236 parent->Add(clip_layer_.get()); | 239 parent->Add(clip_layer_.get()); |
237 parent->StackAtTop(clip_layer_.get()); | 240 parent->StackAtTop(clip_layer_.get()); |
238 } | 241 } |
239 | 242 |
240 } // namespace content | 243 } // namespace content |
OLD | NEW |