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

Side by Side Diff: ui/views/border.cc

Issue 1513153002: Border::CreateBorderPainter now takes a unique_ptr, not a raw pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@border-unittest
Patch Set: Rebase (rest of border switched to unique_ptr). Created 4 years, 8 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/border.h ('k') | ui/views/controls/menu/menu_scroll_view_container.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/border.h" 5 #include "ui/views/border.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 gfx::Insets EmptyBorder::GetInsets() const { 132 gfx::Insets EmptyBorder::GetInsets() const {
133 return insets_; 133 return insets_;
134 } 134 }
135 135
136 gfx::Size EmptyBorder::GetMinimumSize() const { 136 gfx::Size EmptyBorder::GetMinimumSize() const {
137 return gfx::Size(); 137 return gfx::Size();
138 } 138 }
139 139
140 class BorderPainter : public Border { 140 class BorderPainter : public Border {
141 public: 141 public:
142 BorderPainter(Painter* painter, const gfx::Insets& insets); 142 BorderPainter(std::unique_ptr<Painter> painter, const gfx::Insets& insets);
143 143
144 // Overridden from Border: 144 // Overridden from Border:
145 void Paint(const View& view, gfx::Canvas* canvas) override; 145 void Paint(const View& view, gfx::Canvas* canvas) override;
146 gfx::Insets GetInsets() const override; 146 gfx::Insets GetInsets() const override;
147 gfx::Size GetMinimumSize() const override; 147 gfx::Size GetMinimumSize() const override;
148 148
149 private: 149 private:
150 std::unique_ptr<Painter> painter_; 150 std::unique_ptr<Painter> painter_;
151 const gfx::Insets insets_; 151 const gfx::Insets insets_;
152 152
153 DISALLOW_COPY_AND_ASSIGN(BorderPainter); 153 DISALLOW_COPY_AND_ASSIGN(BorderPainter);
154 }; 154 };
155 155
156 BorderPainter::BorderPainter(Painter* painter, const gfx::Insets& insets) 156 BorderPainter::BorderPainter(std::unique_ptr<Painter> painter,
157 : painter_(painter), 157 const gfx::Insets& insets)
158 insets_(insets) { 158 : painter_(std::move(painter)), insets_(insets) {
159 DCHECK(painter); 159 DCHECK(painter_);
160 } 160 }
161 161
162 void BorderPainter::Paint(const View& view, gfx::Canvas* canvas) { 162 void BorderPainter::Paint(const View& view, gfx::Canvas* canvas) {
163 Painter::PaintPainterAt(canvas, painter_.get(), view.GetLocalBounds()); 163 Painter::PaintPainterAt(canvas, painter_.get(), view.GetLocalBounds());
164 } 164 }
165 165
166 gfx::Insets BorderPainter::GetInsets() const { 166 gfx::Insets BorderPainter::GetInsets() const {
167 return insets_; 167 return insets_;
168 } 168 }
169 169
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 std::unique_ptr<Border> Border::CreateSolidSidedBorder(int top, 215 std::unique_ptr<Border> Border::CreateSolidSidedBorder(int top,
216 int left, 216 int left,
217 int bottom, 217 int bottom,
218 int right, 218 int right,
219 SkColor color) { 219 SkColor color) {
220 return base::WrapUnique( 220 return base::WrapUnique(
221 new SolidSidedBorder(gfx::Insets(top, left, bottom, right), color)); 221 new SolidSidedBorder(gfx::Insets(top, left, bottom, right), color));
222 } 222 }
223 223
224 // static 224 // static
225 std::unique_ptr<Border> Border::CreateBorderPainter(Painter* painter, 225 std::unique_ptr<Border> Border::CreateBorderPainter(
226 const gfx::Insets& insets) { 226 std::unique_ptr<Painter> painter,
227 return base::WrapUnique(new BorderPainter(painter, insets)); 227 const gfx::Insets& insets) {
228 return base::WrapUnique(new BorderPainter(std::move(painter), insets));
228 } 229 }
229 230
230 } // namespace views 231 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/border.h ('k') | ui/views/controls/menu/menu_scroll_view_container.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698