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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 destroying_(false) {} | 123 destroying_(false) {} |
124 | 124 |
125 InkDropHostView::~InkDropHostView() { | 125 InkDropHostView::~InkDropHostView() { |
126 // TODO(bruthig): Improve InkDropImpl to be safer about calling back to | 126 // TODO(bruthig): Improve InkDropImpl to be safer about calling back to |
127 // potentially destroyed InkDropHosts and remove |destroying_|. | 127 // potentially destroyed InkDropHosts and remove |destroying_|. |
128 destroying_ = true; | 128 destroying_ = true; |
129 } | 129 } |
130 | 130 |
131 void InkDropHostView::AddInkDropLayer(ui::Layer* ink_drop_layer) { | 131 void InkDropHostView::AddInkDropLayer(ui::Layer* ink_drop_layer) { |
132 old_paint_to_layer_ = layer() != nullptr; | 132 old_paint_to_layer_ = layer() != nullptr; |
133 SetPaintToLayer(true); | 133 SetPaintToLayer(); |
134 layer()->SetFillsBoundsOpaquely(false); | 134 layer()->SetFillsBoundsOpaquely(false); |
135 ink_drop_mask_ = CreateInkDropMask(); | 135 ink_drop_mask_ = CreateInkDropMask(); |
136 if (ink_drop_mask_) | 136 if (ink_drop_mask_) |
137 ink_drop_layer->SetMaskLayer(ink_drop_mask_->layer()); | 137 ink_drop_layer->SetMaskLayer(ink_drop_mask_->layer()); |
138 layer()->Add(ink_drop_layer); | 138 layer()->Add(ink_drop_layer); |
139 layer()->StackAtBottom(ink_drop_layer); | 139 layer()->StackAtBottom(ink_drop_layer); |
140 } | 140 } |
141 | 141 |
142 void InkDropHostView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { | 142 void InkDropHostView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { |
143 // No need to do anything when called during shutdown, and if a derived | 143 // No need to do anything when called during shutdown, and if a derived |
144 // class has overridden Add/RemoveInkDropLayer, running this implementation | 144 // class has overridden Add/RemoveInkDropLayer, running this implementation |
145 // would be wrong. | 145 // would be wrong. |
146 if (destroying_) | 146 if (destroying_) |
147 return; | 147 return; |
148 layer()->Remove(ink_drop_layer); | 148 layer()->Remove(ink_drop_layer); |
149 // Layers safely handle destroying a mask layer before the masked layer. | 149 // Layers safely handle destroying a mask layer before the masked layer. |
150 ink_drop_mask_.reset(); | 150 ink_drop_mask_.reset(); |
151 SetPaintToLayer(old_paint_to_layer_); | 151 if (old_paint_to_layer_) { |
152 SetPaintToLayer(); | |
bruthig
2017/01/23 16:25:02
nit: It's unnecessary to call SetPaintToLayer() he
yiyix
2017/01/23 16:49:48
Thanks, I didn't really read this code. The create
| |
153 } else { | |
154 DetachLayer(); | |
155 } | |
152 } | 156 } |
153 | 157 |
154 std::unique_ptr<InkDrop> InkDropHostView::CreateInkDrop() { | 158 std::unique_ptr<InkDrop> InkDropHostView::CreateInkDrop() { |
155 return CreateDefaultInkDropImpl(); | 159 return CreateDefaultInkDropImpl(); |
156 } | 160 } |
157 | 161 |
158 std::unique_ptr<InkDropRipple> InkDropHostView::CreateInkDropRipple() const { | 162 std::unique_ptr<InkDropRipple> InkDropHostView::CreateInkDropRipple() const { |
159 return CreateDefaultInkDropRipple(GetLocalBounds().CenterPoint()); | 163 return CreateDefaultInkDropRipple(GetLocalBounds().CenterPoint()); |
160 } | 164 } |
161 | 165 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
292 std::unique_ptr<InkDropImpl> | 296 std::unique_ptr<InkDropImpl> |
293 InkDropHostView::CreateDefaultFloodFillInkDropImpl() { | 297 InkDropHostView::CreateDefaultFloodFillInkDropImpl() { |
294 std::unique_ptr<views::InkDropImpl> ink_drop = | 298 std::unique_ptr<views::InkDropImpl> ink_drop = |
295 InkDropHostView::CreateDefaultInkDropImpl(); | 299 InkDropHostView::CreateDefaultInkDropImpl(); |
296 ink_drop->SetAutoHighlightMode( | 300 ink_drop->SetAutoHighlightMode( |
297 views::InkDropImpl::AutoHighlightMode::SHOW_ON_RIPPLE); | 301 views::InkDropImpl::AutoHighlightMode::SHOW_ON_RIPPLE); |
298 return ink_drop; | 302 return ink_drop; |
299 } | 303 } |
300 | 304 |
301 } // namespace views | 305 } // namespace views |
OLD | NEW |