| 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(); | 135 InstallInkDropMask(ink_drop_layer); |
| 136 if (ink_drop_mask_) | |
| 137 ink_drop_layer->SetMaskLayer(ink_drop_mask_->layer()); | |
| 138 layer()->Add(ink_drop_layer); | 136 layer()->Add(ink_drop_layer); |
| 139 layer()->StackAtBottom(ink_drop_layer); | 137 layer()->StackAtBottom(ink_drop_layer); |
| 140 } | 138 } |
| 141 | 139 |
| 142 void InkDropHostView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { | 140 void InkDropHostView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { |
| 143 // No need to do anything when called during shutdown, and if a derived | 141 // No need to do anything when called during shutdown, and if a derived |
| 144 // class has overridden Add/RemoveInkDropLayer, running this implementation | 142 // class has overridden Add/RemoveInkDropLayer, running this implementation |
| 145 // would be wrong. | 143 // would be wrong. |
| 146 if (destroying_) | 144 if (destroying_) |
| 147 return; | 145 return; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 InkDrop* InkDropHostView::GetInkDrop() { | 271 InkDrop* InkDropHostView::GetInkDrop() { |
| 274 if (!ink_drop_) { | 272 if (!ink_drop_) { |
| 275 if (ink_drop_mode_ == InkDropMode::OFF || !PlatformStyle::kUseRipples) | 273 if (ink_drop_mode_ == InkDropMode::OFF || !PlatformStyle::kUseRipples) |
| 276 ink_drop_ = base::MakeUnique<InkDropStub>(); | 274 ink_drop_ = base::MakeUnique<InkDropStub>(); |
| 277 else | 275 else |
| 278 ink_drop_ = CreateInkDrop(); | 276 ink_drop_ = CreateInkDrop(); |
| 279 } | 277 } |
| 280 return ink_drop_.get(); | 278 return ink_drop_.get(); |
| 281 } | 279 } |
| 282 | 280 |
| 281 void InkDropHostView::InstallInkDropMask(ui::Layer* ink_drop_layer) { |
| 282 // Layer masks don't work on Windows. See crbug.com/713359 |
| 283 #if !defined(OS_WIN) |
| 284 ink_drop_mask_ = CreateInkDropMask(); |
| 285 if (ink_drop_mask_) |
| 286 ink_drop_layer->SetMaskLayer(ink_drop_mask_->layer()); |
| 287 #endif |
| 288 } |
| 289 |
| 290 void InkDropHostView::ResetInkDropMask() { |
| 291 ink_drop_mask_.reset(); |
| 292 } |
| 293 |
| 283 std::unique_ptr<InkDropImpl> InkDropHostView::CreateDefaultInkDropImpl() { | 294 std::unique_ptr<InkDropImpl> InkDropHostView::CreateDefaultInkDropImpl() { |
| 284 std::unique_ptr<InkDropImpl> ink_drop = | 295 std::unique_ptr<InkDropImpl> ink_drop = |
| 285 base::MakeUnique<InkDropImpl>(this, size()); | 296 base::MakeUnique<InkDropImpl>(this, size()); |
| 286 ink_drop->SetAutoHighlightMode( | 297 ink_drop->SetAutoHighlightMode( |
| 287 views::InkDropImpl::AutoHighlightMode::HIDE_ON_RIPPLE); | 298 views::InkDropImpl::AutoHighlightMode::HIDE_ON_RIPPLE); |
| 288 return ink_drop; | 299 return ink_drop; |
| 289 } | 300 } |
| 290 | 301 |
| 291 std::unique_ptr<InkDropImpl> | 302 std::unique_ptr<InkDropImpl> |
| 292 InkDropHostView::CreateDefaultFloodFillInkDropImpl() { | 303 InkDropHostView::CreateDefaultFloodFillInkDropImpl() { |
| 293 std::unique_ptr<views::InkDropImpl> ink_drop = | 304 std::unique_ptr<views::InkDropImpl> ink_drop = |
| 294 InkDropHostView::CreateDefaultInkDropImpl(); | 305 InkDropHostView::CreateDefaultInkDropImpl(); |
| 295 ink_drop->SetAutoHighlightMode( | 306 ink_drop->SetAutoHighlightMode( |
| 296 views::InkDropImpl::AutoHighlightMode::SHOW_ON_RIPPLE); | 307 views::InkDropImpl::AutoHighlightMode::SHOW_ON_RIPPLE); |
| 297 return ink_drop; | 308 return ink_drop; |
| 298 } | 309 } |
| 299 | 310 |
| 300 } // namespace views | 311 } // namespace views |
| OLD | NEW |