Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ui/views/animation/ink_drop_host_view.h" | 5 #include "ui/views/animation/ink_drop_host_view.h" |
| 6 | 6 |
| 7 #include "ui/events/event.h" | 7 #include "ui/events/event.h" |
| 8 #include "ui/events/scoped_target_handler.h" | 8 #include "ui/events/scoped_target_handler.h" |
| 9 #include "ui/gfx/color_palette.h" | 9 #include "ui/gfx/color_palette.h" |
| 10 #include "ui/gfx/geometry/size_conversions.h" | 10 #include "ui/gfx/geometry/size_conversions.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 | 94 |
| 95 // An instance of ScopedTargetHandler allowing |this| to handle events. | 95 // An instance of ScopedTargetHandler allowing |this| to handle events. |
| 96 ui::ScopedTargetHandler target_handler_; | 96 ui::ScopedTargetHandler target_handler_; |
| 97 | 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(InkDropGestureHandler); | 98 DISALLOW_COPY_AND_ASSIGN(InkDropGestureHandler); |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 InkDropHostView::InkDropHostView() | 101 InkDropHostView::InkDropHostView() |
| 102 : ink_drop_(new InkDropStub()), | 102 : ink_drop_(new InkDropStub()), |
| 103 ink_drop_size_(kInkDropSize, kInkDropSize), | 103 ink_drop_size_(kInkDropSize, kInkDropSize), |
| 104 old_paint_to_layer_(false), | |
| 104 destroying_(false) {} | 105 destroying_(false) {} |
| 105 | 106 |
| 106 InkDropHostView::~InkDropHostView() { | 107 InkDropHostView::~InkDropHostView() { |
| 107 // TODO(bruthig): Improve InkDropImpl to be safer about calling back to | 108 // TODO(bruthig): Improve InkDropImpl to be safer about calling back to |
| 108 // potentially destroyed InkDropHosts and remove |destroying_|. | 109 // potentially destroyed InkDropHosts and remove |destroying_|. |
| 109 destroying_ = true; | 110 destroying_ = true; |
| 110 } | 111 } |
| 111 | 112 |
| 112 void InkDropHostView::AddInkDropLayer(ui::Layer* ink_drop_layer) { | 113 void InkDropHostView::AddInkDropLayer(ui::Layer* ink_drop_layer) { |
| 114 old_paint_to_layer_ = layer() != nullptr; | |
| 113 SetPaintToLayer(true); | 115 SetPaintToLayer(true); |
| 114 layer()->SetFillsBoundsOpaquely(false); | 116 layer()->SetFillsBoundsOpaquely(false); |
| 115 layer()->Add(ink_drop_layer); | 117 layer()->Add(ink_drop_layer); |
| 116 layer()->StackAtBottom(ink_drop_layer); | 118 layer()->StackAtBottom(ink_drop_layer); |
| 117 } | 119 } |
| 118 | 120 |
| 119 void InkDropHostView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { | 121 void InkDropHostView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { |
| 120 // No need to do anything when called during shutdown, and if a derived | 122 // No need to do anything when called during shutdown, and if a derived |
| 121 // class has overridden Add/RemoveInkDropLayer, running this implementation | 123 // class has overridden Add/RemoveInkDropLayer, running this implementation |
| 122 // would be wrong. | 124 // would be wrong. |
| 123 if (destroying_) | 125 if (destroying_) |
| 124 return; | 126 return; |
| 125 layer()->Remove(ink_drop_layer); | 127 layer()->Remove(ink_drop_layer); |
| 126 SetPaintToLayer(false); | 128 SetPaintToLayer(old_paint_to_layer_); |
|
bruthig
2016/06/09 03:26:00
What's the use case for this?
mohsen
2016/06/09 21:24:51
I think if a View had already been painting to lay
bruthig
2016/06/10 15:25:19
Hmm VERY good point! It seems that this SetPaintTo
| |
| 127 } | 129 } |
| 128 | 130 |
| 129 std::unique_ptr<InkDropRipple> InkDropHostView::CreateInkDropRipple() const { | 131 std::unique_ptr<InkDropRipple> InkDropHostView::CreateInkDropRipple() const { |
| 130 std::unique_ptr<InkDropRipple> ripple(new SquareInkDropRipple( | 132 std::unique_ptr<InkDropRipple> ripple(new SquareInkDropRipple( |
| 131 CalculateLargeInkDropSize(ink_drop_size_), kInkDropLargeCornerRadius, | 133 CalculateLargeInkDropSize(ink_drop_size_), kInkDropLargeCornerRadius, |
| 132 ink_drop_size_, kInkDropSmallCornerRadius, GetInkDropCenter(), | 134 ink_drop_size_, kInkDropSmallCornerRadius, GetInkDropCenter(), |
| 133 GetInkDropBaseColor())); | 135 GetInkDropBaseColor())); |
| 134 return ripple; | 136 return ripple; |
| 135 } | 137 } |
| 136 | 138 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 190 gesture_handler_.reset(); | 192 gesture_handler_.reset(); |
| 191 ink_drop_.reset(new InkDropStub()); | 193 ink_drop_.reset(new InkDropStub()); |
| 192 } | 194 } |
| 193 } | 195 } |
| 194 | 196 |
| 195 void InkDropHostView::AnimateInkDrop(InkDropState ink_drop_state) { | 197 void InkDropHostView::AnimateInkDrop(InkDropState ink_drop_state) { |
| 196 ink_drop_->AnimateToState(ink_drop_state); | 198 ink_drop_->AnimateToState(ink_drop_state); |
| 197 } | 199 } |
| 198 | 200 |
| 199 } // namespace views | 201 } // namespace views |
| OLD | NEW |