| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |