| 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 "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "ui/events/event.h" | 8 #include "ui/events/event.h" |
| 9 #include "ui/events/scoped_target_handler.h" | 9 #include "ui/events/scoped_target_handler.h" |
| 10 #include "ui/gfx/color_palette.h" | 10 #include "ui/gfx/color_palette.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // potentially destroyed InkDropHosts and remove |destroying_|. | 125 // potentially destroyed InkDropHosts and remove |destroying_|. |
| 126 destroying_ = true; | 126 destroying_ = true; |
| 127 } | 127 } |
| 128 | 128 |
| 129 void InkDropHostView::AddInkDropLayer(ui::Layer* ink_drop_layer) { | 129 void InkDropHostView::AddInkDropLayer(ui::Layer* ink_drop_layer) { |
| 130 old_paint_to_layer_ = layer() != nullptr; | 130 old_paint_to_layer_ = layer() != nullptr; |
| 131 if (!old_paint_to_layer_) | 131 if (!old_paint_to_layer_) |
| 132 SetPaintToLayer(); | 132 SetPaintToLayer(); |
| 133 | 133 |
| 134 layer()->SetFillsBoundsOpaquely(false); | 134 layer()->SetFillsBoundsOpaquely(false); |
| 135 ink_drop_mask_ = CreateInkDropMask(); | |
| 136 if (ink_drop_mask_) | |
| 137 ink_drop_layer->SetMaskLayer(ink_drop_mask_->layer()); | |
| 138 layer()->Add(ink_drop_layer); | 135 layer()->Add(ink_drop_layer); |
| 139 layer()->StackAtBottom(ink_drop_layer); | 136 layer()->StackAtBottom(ink_drop_layer); |
| 140 } | 137 } |
| 141 | 138 |
| 142 void InkDropHostView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { | 139 void InkDropHostView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { |
| 143 // No need to do anything when called during shutdown, and if a derived | 140 // No need to do anything when called during shutdown, and if a derived |
| 144 // class has overridden Add/RemoveInkDropLayer, running this implementation | 141 // class has overridden Add/RemoveInkDropLayer, running this implementation |
| 145 // would be wrong. | 142 // would be wrong. |
| 146 if (destroying_) | 143 if (destroying_) |
| 147 return; | 144 return; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 InkDrop* InkDropHostView::GetInkDrop() { | 270 InkDrop* InkDropHostView::GetInkDrop() { |
| 274 if (!ink_drop_) { | 271 if (!ink_drop_) { |
| 275 if (ink_drop_mode_ == InkDropMode::OFF || !PlatformStyle::kUseRipples) | 272 if (ink_drop_mode_ == InkDropMode::OFF || !PlatformStyle::kUseRipples) |
| 276 ink_drop_ = base::MakeUnique<InkDropStub>(); | 273 ink_drop_ = base::MakeUnique<InkDropStub>(); |
| 277 else | 274 else |
| 278 ink_drop_ = CreateInkDrop(); | 275 ink_drop_ = CreateInkDrop(); |
| 279 } | 276 } |
| 280 return ink_drop_.get(); | 277 return ink_drop_.get(); |
| 281 } | 278 } |
| 282 | 279 |
| 280 void InkDropHostView::InstallInkDropMask(ui::Layer* ink_drop_layer) { |
| 281 ink_drop_mask_ = CreateInkDropMask(); |
| 282 if (ink_drop_mask_) |
| 283 ink_drop_layer->SetMaskLayer(ink_drop_mask_->layer()); |
| 284 } |
| 285 |
| 286 void InkDropHostView::ResetInkDropMask() { |
| 287 ink_drop_mask_.reset(); |
| 288 } |
| 289 |
| 283 std::unique_ptr<InkDropImpl> InkDropHostView::CreateDefaultInkDropImpl() { | 290 std::unique_ptr<InkDropImpl> InkDropHostView::CreateDefaultInkDropImpl() { |
| 284 std::unique_ptr<InkDropImpl> ink_drop = | 291 std::unique_ptr<InkDropImpl> ink_drop = |
| 285 base::MakeUnique<InkDropImpl>(this, size()); | 292 base::MakeUnique<InkDropImpl>(this, size()); |
| 286 ink_drop->SetAutoHighlightMode( | 293 ink_drop->SetAutoHighlightMode( |
| 287 views::InkDropImpl::AutoHighlightMode::HIDE_ON_RIPPLE); | 294 views::InkDropImpl::AutoHighlightMode::HIDE_ON_RIPPLE); |
| 288 return ink_drop; | 295 return ink_drop; |
| 289 } | 296 } |
| 290 | 297 |
| 291 std::unique_ptr<InkDropImpl> | 298 std::unique_ptr<InkDropImpl> |
| 292 InkDropHostView::CreateDefaultFloodFillInkDropImpl() { | 299 InkDropHostView::CreateDefaultFloodFillInkDropImpl() { |
| 293 std::unique_ptr<views::InkDropImpl> ink_drop = | 300 std::unique_ptr<views::InkDropImpl> ink_drop = |
| 294 InkDropHostView::CreateDefaultInkDropImpl(); | 301 InkDropHostView::CreateDefaultInkDropImpl(); |
| 295 ink_drop->SetAutoHighlightMode( | 302 ink_drop->SetAutoHighlightMode( |
| 296 views::InkDropImpl::AutoHighlightMode::SHOW_ON_RIPPLE); | 303 views::InkDropImpl::AutoHighlightMode::SHOW_ON_RIPPLE); |
| 297 return ink_drop; | 304 return ink_drop; |
| 298 } | 305 } |
| 299 | 306 |
| 300 } // namespace views | 307 } // namespace views |
| OLD | NEW |