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

Unified Diff: ui/views/bubble/bubble_border.cc

Issue 454173002: Fixed BubbleBorder sizing problems & added unit tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed construction order of the TrayBubbleView/TrayBubbleWrapper in WebNotificationBubbleWrapper co… Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/bubble/bubble_border.cc
diff --git a/ui/views/bubble/bubble_border.cc b/ui/views/bubble/bubble_border.cc
index 1e97f610536c6091e3e6527febc7d7ab1f5d62eb..d7adfb6573033016bf9b140d09c01aebb5e7db3d 100644
--- a/ui/views/bubble/bubble_border.cc
+++ b/ui/views/bubble/bubble_border.cc
@@ -7,10 +7,8 @@
#include <algorithm>
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
-#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/skia_util.h"
#include "ui/resources/grit/ui_resources.h"
@@ -21,31 +19,6 @@ namespace views {
namespace internal {
-// A helper that combines each border image-set painter with arrows and metrics.
-struct BorderImages {
- BorderImages(const int border_image_ids[],
- const int arrow_image_ids[],
- int border_interior_thickness,
- int arrow_interior_thickness,
- int corner_radius);
-
- scoped_ptr<Painter> border_painter;
- gfx::ImageSkia left_arrow;
- gfx::ImageSkia top_arrow;
- gfx::ImageSkia right_arrow;
- gfx::ImageSkia bottom_arrow;
-
- // The thickness of border and arrow images and their interior areas.
- // Thickness is the width of left/right and the height of top/bottom images.
- // The interior is measured without including stroke or shadow pixels.
- int border_thickness;
- int border_interior_thickness;
- int arrow_thickness;
- int arrow_interior_thickness;
- // The corner radius of the bubble's rounded-rect interior area.
- int corner_radius;
-};
-
BorderImages::BorderImages(const int border_image_ids[],
const int arrow_image_ids[],
int border_interior_thickness,
@@ -68,13 +41,12 @@ BorderImages::BorderImages(const int border_image_ids[],
}
}
+BorderImages::~BorderImages() {}
+
} // namespace internal
namespace {
-// The border and arrow stroke size used in image assets, in pixels.
-const int kStroke = 1;
-
// Bubble border and arrow image resource ids. They don't use the IMAGE_GRID
// macro because there is no center image.
const int kNoShadowImages[] = {
@@ -150,6 +122,8 @@ BorderImages* GetBorderImages(BubbleBorder::Shadow shadow) {
} // namespace
+const int BubbleBorder::kStroke = 1;
+
BubbleBorder::BubbleBorder(Arrow arrow, Shadow shadow, SkColor color)
: arrow_(arrow),
arrow_offset_(0),
@@ -278,7 +252,7 @@ gfx::Size BubbleBorder::GetSizeForContentsSize(
std::max(images_->arrow_thickness + images_->border_interior_thickness,
images_->border_thickness);
// Only take arrow image sizes into account when the bubble tip is shown.
- if (arrow_paint_type_ == PAINT_TRANSPARENT || !has_arrow(arrow_))
+ if (arrow_paint_type_ == PAINT_NONE || !has_arrow(arrow_))
size.SetToMax(gfx::Size(min, min));
else if (is_arrow_on_horizontal(arrow_))
size.SetToMax(gfx::Size(min_with_arrow_width, min_with_arrow_thickness));
@@ -360,6 +334,10 @@ void BubbleBorder::DrawArrow(gfx::Canvas* canvas,
canvas->DrawPath(path, paint);
}
+internal::BorderImages* BubbleBorder::GetImagesForTest() const {
+ return images_;
+}
+
void BubbleBackground::Paint(gfx::Canvas* canvas, views::View* view) const {
if (border_->shadow() == BubbleBorder::NO_SHADOW_OPAQUE_BORDER)
canvas->DrawColor(border_->background_color());

Powered by Google App Engine
This is Rietveld 408576698