Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(760)

Side by Side Diff: ui/views/animation/ink_drop_host_view.cc

Issue 2639203007: Update SetPaintToLayer to accept LayerType (Closed)
Patch Set: fix comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/animation/ink_drop.cc ('k') | ui/views/bubble/tray_bubble_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 old_paint_to_layer_(false), 122 old_paint_to_layer_(false),
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;
varkha 2017/01/31 19:47:47 Drive-by after the fact. I think we should add a D
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 DestroyLayer();
152 } 153 }
153 154
154 std::unique_ptr<InkDrop> InkDropHostView::CreateInkDrop() { 155 std::unique_ptr<InkDrop> InkDropHostView::CreateInkDrop() {
155 return CreateDefaultInkDropImpl(); 156 return CreateDefaultInkDropImpl();
156 } 157 }
157 158
158 std::unique_ptr<InkDropRipple> InkDropHostView::CreateInkDropRipple() const { 159 std::unique_ptr<InkDropRipple> InkDropHostView::CreateInkDropRipple() const {
159 return CreateDefaultInkDropRipple(GetLocalBounds().CenterPoint()); 160 return CreateDefaultInkDropRipple(GetLocalBounds().CenterPoint());
160 } 161 }
161 162
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 std::unique_ptr<InkDropImpl> 293 std::unique_ptr<InkDropImpl>
293 InkDropHostView::CreateDefaultFloodFillInkDropImpl() { 294 InkDropHostView::CreateDefaultFloodFillInkDropImpl() {
294 std::unique_ptr<views::InkDropImpl> ink_drop = 295 std::unique_ptr<views::InkDropImpl> ink_drop =
295 InkDropHostView::CreateDefaultInkDropImpl(); 296 InkDropHostView::CreateDefaultInkDropImpl();
296 ink_drop->SetAutoHighlightMode( 297 ink_drop->SetAutoHighlightMode(
297 views::InkDropImpl::AutoHighlightMode::SHOW_ON_RIPPLE); 298 views::InkDropImpl::AutoHighlightMode::SHOW_ON_RIPPLE);
298 return ink_drop; 299 return ink_drop;
299 } 300 }
300 301
301 } // namespace views 302 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/animation/ink_drop.cc ('k') | ui/views/bubble/tray_bubble_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698