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

Unified Diff: chrome/browser/ui/views/download/download_item_view.cc

Issue 2261593002: Use ScopedRTLFlipCanvas more pervasively for RTL flipping. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix namespace Created 4 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: chrome/browser/ui/views/download/download_item_view.cc
diff --git a/chrome/browser/ui/views/download/download_item_view.cc b/chrome/browser/ui/views/download/download_item_view.cc
index 2a5ab60a301075cda0cab10405c398b27cd6df71..103645aa7841575246a3ab671b79b0e30572991f 100644
--- a/chrome/browser/ui/views/download/download_item_view.cc
+++ b/chrome/browser/ui/views/download/download_item_view.cc
@@ -52,6 +52,7 @@
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/image/image.h"
+#include "ui/gfx/scoped_canvas.h"
#include "ui/gfx/text_elider.h"
#include "ui/gfx/text_utils.h"
#include "ui/views/controls/button/label_button.h"
@@ -703,85 +704,76 @@ void DownloadItemView::OnPaintBackground(gfx::Canvas* canvas) {
}
// Paint the background images.
- int x = kLeftPadding;
- canvas->Save();
- if (base::i18n::IsRTL()) {
- // Since we do not have the mirrored images for
- // (hot_)body_image_set->top_left, (hot_)body_image_set->left,
- // (hot_)body_image_set->bottom_left, and drop_down_image_set,
- // for RTL UI, we flip the canvas to draw those images mirrored.
- // Consequently, we do not need to mirror the x-axis of those images.
- canvas->Translate(gfx::Vector2d(width(), 0));
- canvas->Scale(-1, 1);
- }
- PaintImages(canvas,
- body_image_set->top_left, body_image_set->left,
- body_image_set->bottom_left,
- x, box_y_, box_height_, body_image_set->top_left->width());
- x += body_image_set->top_left->width();
- PaintImages(canvas,
- body_image_set->top, body_image_set->center,
- body_image_set->bottom,
- x, box_y_, box_height_, center_width);
- x += center_width;
- PaintImages(canvas,
- body_image_set->top_right, body_image_set->right,
- body_image_set->bottom_right,
- x, box_y_, box_height_, body_image_set->top_right->width());
-
- // Overlay our body hot state. Warning dialogs don't display body a hot state.
- if (!IsShowingWarningDialog() &&
- body_hover_animation_->GetCurrentValue() > 0) {
- canvas->SaveLayerAlpha(
- static_cast<int>(body_hover_animation_->GetCurrentValue() * 255));
+ {
+ gfx::ScopedRTLFlipCanvas scoped_canvas(canvas, width());
int x = kLeftPadding;
PaintImages(canvas,
- hot_body_image_set_.top_left, hot_body_image_set_.left,
- hot_body_image_set_.bottom_left,
- x, box_y_, box_height_, hot_body_image_set_.top_left->width());
+ body_image_set->top_left, body_image_set->left,
+ body_image_set->bottom_left,
+ x, box_y_, box_height_, body_image_set->top_left->width());
x += body_image_set->top_left->width();
PaintImages(canvas,
- hot_body_image_set_.top, hot_body_image_set_.center,
- hot_body_image_set_.bottom,
+ body_image_set->top, body_image_set->center,
+ body_image_set->bottom,
x, box_y_, box_height_, center_width);
x += center_width;
PaintImages(canvas,
- hot_body_image_set_.top_right, hot_body_image_set_.right,
- hot_body_image_set_.bottom_right,
- x, box_y_, box_height_,
- hot_body_image_set_.top_right->width());
- canvas->Restore();
- }
-
- x += body_image_set->top_right->width();
+ body_image_set->top_right, body_image_set->right,
+ body_image_set->bottom_right,
+ x, box_y_, box_height_, body_image_set->top_right->width());
+
+ // Overlay our body hot state. Warning dialogs don't display body a hot
+ // state.
+ if (!IsShowingWarningDialog() &&
+ body_hover_animation_->GetCurrentValue() > 0) {
+ canvas->SaveLayerAlpha(
+ static_cast<int>(body_hover_animation_->GetCurrentValue() * 255));
- // Paint the drop-down.
- if (drop_down_image_set) {
- PaintImages(canvas,
- drop_down_image_set->top, drop_down_image_set->center,
- drop_down_image_set->bottom,
- x, box_y_, box_height_, drop_down_image_set->top->width());
+ int x = kLeftPadding;
+ PaintImages(canvas,
+ hot_body_image_set_.top_left, hot_body_image_set_.left,
+ hot_body_image_set_.bottom_left,
+ x, box_y_, box_height_,
+ hot_body_image_set_.top_left->width());
+ x += body_image_set->top_left->width();
+ PaintImages(canvas,
+ hot_body_image_set_.top, hot_body_image_set_.center,
+ hot_body_image_set_.bottom,
+ x, box_y_, box_height_, center_width);
+ x += center_width;
+ PaintImages(canvas,
+ hot_body_image_set_.top_right, hot_body_image_set_.right,
+ hot_body_image_set_.bottom_right,
+ x, box_y_, box_height_,
+ hot_body_image_set_.top_right->width());
+ canvas->Restore();
+ }
- // Overlay our drop-down hot state.
- if (drop_hover_animation_->GetCurrentValue() > 0) {
- canvas->SaveLayerAlpha(
- static_cast<int>(drop_hover_animation_->GetCurrentValue() * 255));
+ x += body_image_set->top_right->width();
+ // Paint the drop-down.
+ if (drop_down_image_set) {
PaintImages(canvas,
drop_down_image_set->top, drop_down_image_set->center,
drop_down_image_set->bottom,
x, box_y_, box_height_, drop_down_image_set->top->width());
- canvas->Restore();
+ // Overlay our drop-down hot state.
+ if (drop_hover_animation_->GetCurrentValue() > 0) {
+ canvas->SaveLayerAlpha(
+ static_cast<int>(drop_hover_animation_->GetCurrentValue() * 255));
+
+ PaintImages(canvas,
+ drop_down_image_set->top, drop_down_image_set->center,
+ drop_down_image_set->bottom,
+ x, box_y_, box_height_, drop_down_image_set->top->width());
+
+ canvas->Restore();
+ }
}
}
- // Restore the canvas to avoid file name etc. text are drawn flipped.
- // Consequently, the x-axis of following canvas->DrawXXX() method should be
- // mirrored so the text and images are down in the right positions.
- canvas->Restore();
-
// Print the text, left aligned and always print the file extension.
// Last value of x was the end of the right image, just before the button.
// Note that in dangerous mode we use a label (as the text is multi-line).
« no previous file with comments | « ash/common/system/tray/tray_popup_label_button_border.cc ('k') | chrome/browser/ui/views/toolbar/app_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698