summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-18 15:34:18 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-18 15:34:18 +0000
commit1cf77cf6e159f144eef8aec04cadef2a39ec832b (patch)
treed0fb6d00f4a32b979fa3fd6f7355454408416876
parent583de937746e48390740cce200bb34c3b76fd649 (diff)
downloadchromium_src-1cf77cf6e159f144eef8aec04cadef2a39ec832b.zip
chromium_src-1cf77cf6e159f144eef8aec04cadef2a39ec832b.tar.gz
chromium_src-1cf77cf6e159f144eef8aec04cadef2a39ec832b.tar.bz2
views: Delete painter pointer using scoped_ptr.
R=sky@chromium.org Review URL: https://codereview.chromium.org/10909234 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157362 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ui/views/border.cc34
-rw-r--r--ui/views/border.h10
2 files changed, 27 insertions, 17 deletions
diff --git a/ui/views/border.cc b/ui/views/border.cc
index 1cfb037..064f04b 100644
--- a/ui/views/border.cc
+++ b/ui/views/border.cc
@@ -5,6 +5,7 @@
#include "ui/views/border.h"
#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
#include "ui/gfx/canvas.h"
#include "ui/views/painter.h"
@@ -22,15 +23,21 @@ class SidedSolidBorder : public Border {
virtual void GetInsets(gfx::Insets* insets) const OVERRIDE;
private:
- int top_, left_, bottom_, right_;
+ const int top_;
+ const int left_;
+ const int bottom_;
+ const int right_;
SkColor color_;
gfx::Insets insets_;
DISALLOW_COPY_AND_ASSIGN(SidedSolidBorder);
};
-SidedSolidBorder::SidedSolidBorder(int top, int left, int bottom, int right,
- SkColor color)
+SidedSolidBorder::SidedSolidBorder(int top,
+ int left,
+ int bottom,
+ int right,
+ SkColor color)
: top_(top),
left_(left),
bottom_(bottom),
@@ -97,14 +104,11 @@ class BorderPainter : public Border {
DCHECK(painter);
}
- virtual ~BorderPainter() {
- delete painter_;
- painter_ = NULL;
- }
+ virtual ~BorderPainter() {}
// Overridden from Border:
virtual void Paint(const View& view, gfx::Canvas* canvas) const OVERRIDE {
- Painter::PaintPainterAt(canvas, painter_, view.GetLocalBounds());
+ Painter::PaintPainterAt(canvas, painter_.get(), view.GetLocalBounds());
}
virtual void GetInsets(gfx::Insets* insets) const OVERRIDE {
@@ -113,12 +117,12 @@ class BorderPainter : public Border {
}
private:
- Painter* painter_;
+ scoped_ptr<Painter> painter_;
DISALLOW_COPY_AND_ASSIGN(BorderPainter);
};
-} // namespace
+} // namespace
Border::Border() {
}
@@ -137,13 +141,15 @@ Border* Border::CreateEmptyBorder(int top, int left, int bottom, int right) {
}
// static
-Border* Border::CreateSolidSidedBorder(int top, int left,
- int bottom, int right,
- SkColor color) {
+Border* Border::CreateSolidSidedBorder(int top,
+ int left,
+ int bottom,
+ int right,
+ SkColor color) {
return new SidedSolidBorder(top, left, bottom, right, color);
}
-//static
+// static
Border* Border::CreateBorderPainter(Painter* painter) {
return new BorderPainter(painter);
}
diff --git a/ui/views/border.h b/ui/views/border.h
index 8c6fd1c..ec3b122 100644
--- a/ui/views/border.h
+++ b/ui/views/border.h
@@ -5,9 +5,11 @@
#ifndef UI_VIEWS_BORDER_H_
#define UI_VIEWS_BORDER_H_
+#include "base/basictypes.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/insets.h"
#include "ui/views/view.h"
+#include "ui/views/views_export.h"
namespace gfx{
class Canvas;
@@ -49,9 +51,11 @@ class VIEWS_EXPORT Border {
// Creates a border of the specified color, and specified thickness on each
// side.
- static Border* CreateSolidSidedBorder(int top, int left,
- int bottom, int right,
- SkColor color);
+ static Border* CreateSolidSidedBorder(int top,
+ int left,
+ int bottom,
+ int right,
+ SkColor color);
// Creates a Border from the specified Painter. The border owns the painter,
// thus the painter is deleted when the Border is deleted.