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

Side by Side 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: 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 unified diff | Download patch
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/bubble/bubble_border.h" 5 #include "ui/views/bubble/bubble_border.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 const gfx::Insets insets = GetInsets(); 271 const gfx::Insets insets = GetInsets();
272 size.Enlarge(insets.width(), insets.height()); 272 size.Enlarge(insets.width(), insets.height());
273 273
274 // Ensure the bubble is large enough to not overlap border and arrow images. 274 // Ensure the bubble is large enough to not overlap border and arrow images.
275 const int min = 2 * images_->border_thickness; 275 const int min = 2 * images_->border_thickness;
276 const int min_with_arrow_width = min + images_->top_arrow.width(); 276 const int min_with_arrow_width = min + images_->top_arrow.width();
277 const int min_with_arrow_thickness = images_->border_thickness + 277 const int min_with_arrow_thickness = images_->border_thickness +
278 std::max(images_->arrow_thickness + images_->border_interior_thickness, 278 std::max(images_->arrow_thickness + images_->border_interior_thickness,
279 images_->border_thickness); 279 images_->border_thickness);
280 // Only take arrow image sizes into account when the bubble tip is shown. 280 // Only take arrow image sizes into account when the bubble tip is shown.
281 if (arrow_paint_type_ == PAINT_TRANSPARENT || !has_arrow(arrow_)) 281 if (arrow_paint_type_ == PAINT_NONE || !has_arrow(arrow_))
msw 2014/08/11 22:26:32 Wow, nice catch!
282 size.SetToMax(gfx::Size(min, min)); 282 size.SetToMax(gfx::Size(min, min));
283 else if (is_arrow_on_horizontal(arrow_)) 283 else if (is_arrow_on_horizontal(arrow_))
284 size.SetToMax(gfx::Size(min_with_arrow_width, min_with_arrow_thickness)); 284 size.SetToMax(gfx::Size(min_with_arrow_width, min_with_arrow_thickness));
285 else 285 else
286 size.SetToMax(gfx::Size(min_with_arrow_thickness, min_with_arrow_width)); 286 size.SetToMax(gfx::Size(min_with_arrow_thickness, min_with_arrow_width));
287 return size; 287 return size;
288 } 288 }
289 289
290 gfx::ImageSkia* BubbleBorder::GetArrowImage() const { 290 gfx::ImageSkia* BubbleBorder::GetArrowImage() const {
291 if (!has_arrow(arrow_)) 291 if (!has_arrow(arrow_))
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 SkPath path; 372 SkPath path;
373 gfx::Rect bounds(view->GetLocalBounds()); 373 gfx::Rect bounds(view->GetLocalBounds());
374 bounds.Inset(border_->GetInsets()); 374 bounds.Inset(border_->GetInsets());
375 375
376 SkScalar radius = SkIntToScalar(border_->GetBorderCornerRadius()); 376 SkScalar radius = SkIntToScalar(border_->GetBorderCornerRadius());
377 path.addRoundRect(gfx::RectToSkRect(bounds), radius, radius); 377 path.addRoundRect(gfx::RectToSkRect(bounds), radius, radius);
378 canvas->DrawPath(path, paint); 378 canvas->DrawPath(path, paint);
379 } 379 }
380 380
381 } // namespace views 381 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/bubble/bubble_border_unittest.cc » ('j') | ui/views/bubble/bubble_border_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698