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 2346263003: Adjust positioning of bookmarks bubble for Harmony. (Closed)
Patch Set: Created 4 years, 3 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 "third_party/skia/include/core/SkDrawLooper.h" 10 #include "third_party/skia/include/core/SkDrawLooper.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 BubbleBorder::~BubbleBorder() {} 181 BubbleBorder::~BubbleBorder() {}
182 182
183 void BubbleBorder::set_paint_arrow(ArrowPaintType value) { 183 void BubbleBorder::set_paint_arrow(ArrowPaintType value) {
184 if (UseMd()) 184 if (UseMd())
185 return; 185 return;
186 arrow_paint_type_ = value; 186 arrow_paint_type_ = value;
187 } 187 }
188 188
189 gfx::Rect BubbleBorder::GetBounds(const gfx::Rect& anchor_rect, 189 gfx::Rect BubbleBorder::GetBounds(const gfx::Rect& anchor_rect,
190 const gfx::Size& contents_size) const { 190 const gfx::Size& contents_size) const {
191 if (UseMd()) {
192 // In MD, there are no arrows, so positioning logic is significantly
193 // simpler.
194 // TODO(estade): handle more anchor positions.
195 if (arrow_ == TOP_RIGHT) {
196 gfx::Rect contents_bounds(contents_size);
197 contents_bounds +=
198 anchor_rect.bottom_right() - contents_bounds.top_right();
199 contents_bounds.Inset(-GetInsets());
200 return contents_bounds;
201 }
202 }
203
191 int x = anchor_rect.x(); 204 int x = anchor_rect.x();
192 int y = anchor_rect.y(); 205 int y = anchor_rect.y();
193 int w = anchor_rect.width(); 206 int w = anchor_rect.width();
194 int h = anchor_rect.height(); 207 int h = anchor_rect.height();
195 const gfx::Size size(GetSizeForContentsSize(contents_size)); 208 const gfx::Size size(GetSizeForContentsSize(contents_size));
196 const int arrow_offset = GetArrowOffset(size); 209 const int arrow_offset = GetArrowOffset(size);
197 // |arrow_shift| is necessary to visually align the tip of the bubble arrow 210 // |arrow_shift| is necessary to visually align the tip of the bubble arrow
198 // with the anchor point. This shift is an inverse of the shadow thickness. 211 // with the anchor point. This shift is an inverse of the shadow thickness.
199 int arrow_shift = UseMd() ? 0 : 212 int arrow_shift = UseMd() ? 0 :
200 images_->arrow_interior_thickness + kStroke - images_->arrow_thickness; 213 images_->arrow_interior_thickness + kStroke - images_->arrow_thickness;
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 void BubbleBackground::Paint(gfx::Canvas* canvas, views::View* view) const { 497 void BubbleBackground::Paint(gfx::Canvas* canvas, views::View* view) const {
485 if (border_->shadow() == BubbleBorder::NO_SHADOW_OPAQUE_BORDER) 498 if (border_->shadow() == BubbleBorder::NO_SHADOW_OPAQUE_BORDER)
486 canvas->DrawColor(border_->background_color()); 499 canvas->DrawColor(border_->background_color());
487 500
488 // Fill the contents with a round-rect region to match the border images. 501 // Fill the contents with a round-rect region to match the border images.
489 SkPaint paint; 502 SkPaint paint;
490 paint.setAntiAlias(true); 503 paint.setAntiAlias(true);
491 paint.setStyle(SkPaint::kFill_Style); 504 paint.setStyle(SkPaint::kFill_Style);
492 paint.setColor(border_->background_color()); 505 paint.setColor(border_->background_color());
493 SkPath path; 506 SkPath path;
494 gfx::Rect bounds(view->GetLocalBounds()); 507 gfx::RectF bounds(view->GetLocalBounds());
495 bounds.Inset(border_->GetInsets()); 508 bounds.Inset(gfx::InsetsF(border_->GetInsets()));
509 if (UseMd()) {
510 // The border is 1px at all scale factors. Leave room for it.
511 const SkScalar one_pixel = SkFloatToScalar(1 / canvas->image_scale());
512 bounds.Inset(gfx::InsetsF(one_pixel));
513 }
496 514
497 canvas->DrawRoundRect(bounds, border_->GetBorderCornerRadius(), paint); 515 canvas->DrawRoundRect(bounds, border_->GetBorderCornerRadius(), paint);
498 } 516 }
499 517
500 } // namespace views 518 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698