| 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 "chrome/browser/ui/views/status_bubble_views.h" | 5 #include "chrome/browser/ui/views/status_bubble_views.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 18 #include "chrome/browser/themes/theme_properties.h" | 18 #include "chrome/browser/themes/theme_properties.h" |
| 19 #include "components/url_formatter/elide_url.h" | 19 #include "components/url_formatter/elide_url.h" |
| 20 #include "components/url_formatter/url_formatter.h" | 20 #include "components/url_formatter/url_formatter.h" |
| 21 #include "skia/ext/cdl_paint.h" |
| 21 #include "third_party/skia/include/core/SkPaint.h" | 22 #include "third_party/skia/include/core/SkPaint.h" |
| 22 #include "third_party/skia/include/core/SkPath.h" | 23 #include "third_party/skia/include/core/SkPath.h" |
| 23 #include "third_party/skia/include/pathops/SkPathOps.h" | 24 #include "third_party/skia/include/pathops/SkPathOps.h" |
| 24 #include "ui/base/theme_provider.h" | 25 #include "ui/base/theme_provider.h" |
| 25 #include "ui/display/display.h" | 26 #include "ui/display/display.h" |
| 26 #include "ui/display/screen.h" | 27 #include "ui/display/screen.h" |
| 27 #include "ui/gfx/animation/animation_delegate.h" | 28 #include "ui/gfx/animation/animation_delegate.h" |
| 28 #include "ui/gfx/animation/linear_animation.h" | 29 #include "ui/gfx/animation/linear_animation.h" |
| 29 #include "ui/gfx/canvas.h" | 30 #include "ui/gfx/canvas.h" |
| 30 #include "ui/gfx/font_list.h" | 31 #include "ui/gfx/font_list.h" |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 // further and further outside the window as the scale increases. | 449 // further and further outside the window as the scale increases. |
| 449 const int inset = shadow_thickness_pixels - 1; | 450 const int inset = shadow_thickness_pixels - 1; |
| 450 bubble_rect.Inset(style_ == STYLE_STANDARD_RIGHT ? 0 : inset, 0, | 451 bubble_rect.Inset(style_ == STYLE_STANDARD_RIGHT ? 0 : inset, 0, |
| 451 style_ == STYLE_STANDARD_RIGHT ? inset : 0, inset); | 452 style_ == STYLE_STANDARD_RIGHT ? inset : 0, inset); |
| 452 // Align to pixel centers now that the layout is correct. | 453 // Align to pixel centers now that the layout is correct. |
| 453 bubble_rect.Inset(0.5, 0.5); | 454 bubble_rect.Inset(0.5, 0.5); |
| 454 | 455 |
| 455 SkPath path; | 456 SkPath path; |
| 456 path.addRoundRect(gfx::RectFToSkRect(bubble_rect), rad); | 457 path.addRoundRect(gfx::RectFToSkRect(bubble_rect), rad); |
| 457 | 458 |
| 458 SkPaint paint; | 459 CdlPaint paint; |
| 459 paint.setStyle(SkPaint::kStroke_Style); | 460 paint.setStyle(CdlPaint::kStroke_Style); |
| 460 paint.setStrokeWidth(1); | 461 paint.setStrokeWidth(1); |
| 461 paint.setAntiAlias(true); | 462 paint.setAntiAlias(true); |
| 462 | 463 |
| 463 SkPath stroke_path; | 464 SkPath stroke_path; |
| 464 paint.getFillPath(path, &stroke_path); | 465 ToSkPaint(paint).getFillPath(path, &stroke_path); |
| 465 | 466 |
| 466 // Get the fill path by subtracting the shadow so they align neatly. | 467 // Get the fill path by subtracting the shadow so they align neatly. |
| 467 SkPath fill_path; | 468 SkPath fill_path; |
| 468 Op(path, stroke_path, kDifference_SkPathOp, &fill_path); | 469 Op(path, stroke_path, kDifference_SkPathOp, &fill_path); |
| 469 paint.setStyle(SkPaint::kFill_Style); | 470 paint.setStyle(CdlPaint::kFill_Style); |
| 470 const SkColor bubble_color = | 471 const SkColor bubble_color = |
| 471 theme_provider_->GetColor(ThemeProperties::COLOR_TOOLBAR); | 472 theme_provider_->GetColor(ThemeProperties::COLOR_TOOLBAR); |
| 472 paint.setColor(bubble_color); | 473 paint.setColor(bubble_color); |
| 473 canvas->sk_canvas()->drawPath(fill_path, paint); | 474 canvas->sk_canvas()->drawPath(fill_path, paint); |
| 474 | 475 |
| 475 paint.setColor(kShadowColor); | 476 paint.setColor(kShadowColor); |
| 476 canvas->sk_canvas()->drawPath(stroke_path, paint); | 477 canvas->sk_canvas()->drawPath(stroke_path, paint); |
| 477 | 478 |
| 478 canvas->Restore(); | 479 canvas->Restore(); |
| 479 | 480 |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 void StatusBubbleViews::SetBubbleWidth(int width) { | 946 void StatusBubbleViews::SetBubbleWidth(int width) { |
| 946 size_.set_width(width); | 947 size_.set_width(width); |
| 947 SetBounds(original_position_.x(), original_position_.y(), | 948 SetBounds(original_position_.x(), original_position_.y(), |
| 948 size_.width(), size_.height()); | 949 size_.width(), size_.height()); |
| 949 } | 950 } |
| 950 | 951 |
| 951 void StatusBubbleViews::CancelExpandTimer() { | 952 void StatusBubbleViews::CancelExpandTimer() { |
| 952 if (expand_timer_factory_.HasWeakPtrs()) | 953 if (expand_timer_factory_.HasWeakPtrs()) |
| 953 expand_timer_factory_.InvalidateWeakPtrs(); | 954 expand_timer_factory_.InvalidateWeakPtrs(); |
| 954 } | 955 } |
| OLD | NEW |