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

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

Issue 118260: Review request - fix issue 6103 and 13217 -- mirror download item in download shelf (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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
« no previous file with comments | « no previous file | views/view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/download_item_view.cc
===================================================================
--- chrome/browser/views/download_item_view.cc (revision 17253)
+++ chrome/browser/views/download_item_view.cc (working copy)
@@ -152,17 +152,6 @@
disabled_while_opening_(false),
creation_time_(base::Time::Now()),
ALLOW_THIS_IN_INITIALIZER_LIST(reenable_method_factory_(this)) {
- // TODO(idana) Bug# 1163334
- //
- // We currently do not mirror each download item on the download shelf (even
- // though the download shelf itself is mirrored and the items appear from
- // right to left on RTL UIs).
- //
- // We explicitly disable mirroring for the item because the code that draws
- // the download progress animation relies on the View's UI layout setting
- // when positioning the animation so we should make sure that code doesn't
- // treat our View as a mirrored View.
- EnableUIMirroringForRTLLanguages(false);
DCHECK(download_);
download_->AddObserver(this);
@@ -485,6 +474,17 @@
// Paint the background images.
int x = kLeftPadding;
+ bool rtl_ui = UILayoutIsRightToLeft();
+ if (rtl_ui) {
+ // 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->save();
+ canvas->TranslateInt(width(), 0);
+ canvas->ScaleInt(-1, 1);
+ }
PaintBitmaps(canvas,
body_image_set->top_left, body_image_set->left,
body_image_set->bottom_left,
@@ -524,6 +524,13 @@
x, box_y_, box_height_,
hot_body_image_set_.top_right->width());
canvas->restore();
+ if (rtl_ui) {
+ canvas->restore();
+ canvas->save();
+ // Flip it for drawing drop-down images for RTL locales.
+ canvas->TranslateInt(width(), 0);
+ canvas->ScaleInt(-1, 1);
+ }
}
x += body_image_set->top_right->width();
@@ -551,6 +558,13 @@
}
}
+ if (rtl_ui) {
+ // 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).
@@ -571,6 +585,8 @@
filename = gfx::ElideFilename(filepath, font_, kTextWidth);
}
+ int mirrored_x = MirroredXWithWidthInsideView(
+ download_util::kSmallProgressIconSize, kTextWidth);
if (show_status_text_) {
int y = box_y_ + kVerticalPadding;
@@ -578,13 +594,11 @@
canvas->DrawStringInt(filename, font_,
IsEnabled() ? kFileNameColor :
kFileNameDisabledColor,
- download_util::kSmallProgressIconSize, y,
- kTextWidth, font_.height());
+ mirrored_x, y, kTextWidth, font_.height());
y += font_.height() + kVerticalTextPadding;
- canvas->DrawStringInt(status_text_, font_, kStatusColor,
- download_util::kSmallProgressIconSize, y,
+ canvas->DrawStringInt(status_text_, font_, kStatusColor, mirrored_x, y,
kTextWidth, font_.height());
} else {
int y = box_y_ + (box_height_ - font_.height()) / 2;
@@ -593,8 +607,7 @@
canvas->DrawStringInt(filename, font_,
IsEnabled() ? kFileNameColor :
kFileNameDisabledColor,
- download_util::kSmallProgressIconSize, y,
- kTextWidth, font_.height());
+ mirrored_x, y, kTextWidth, font_.height());
}
}
@@ -625,18 +638,17 @@
}
// Draw the icon image.
+ int mirrored_x = MirroredXWithWidthInsideView(
+ download_util::kSmallProgressIconOffset, icon->width());
if (IsEnabled()) {
- canvas->DrawBitmapInt(*icon,
- download_util::kSmallProgressIconOffset,
+ canvas->DrawBitmapInt(*icon, mirrored_x,
download_util::kSmallProgressIconOffset);
} else {
// Use an alpha to make the image look disabled.
SkPaint paint;
paint.setAlpha(120);
- canvas->DrawBitmapInt(*icon,
- download_util::kSmallProgressIconOffset,
- download_util::kSmallProgressIconOffset,
- paint);
+ canvas->DrawBitmapInt(*icon, mirrored_x,
+ download_util::kSmallProgressIconOffset, paint);
}
}
}
@@ -771,11 +783,8 @@
// The menu's position is different depending on the UI layout.
// DownloadShelfContextMenu will take care of setting the right anchor for
// the menu depending on the locale.
- //
- // TODO(idana): when bug# 1163334 is fixed the following check should be
- // replaced with UILayoutIsRightToLeft().
point.set_y(height());
- if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) {
+ if (UILayoutIsRightToLeft()) {
point.set_x(width());
} else {
point.set_x(drop_down_x_);
« no previous file with comments | « no previous file | views/view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698