summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/download_item_view.cc
diff options
context:
space:
mode:
authorxji@chromium.org <xji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-25 05:34:38 +0000
committerxji@chromium.org <xji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-25 05:34:38 +0000
commitf8d13fab476e5018fee5794e63bb64d6dee99bba (patch)
treed567bc02c1be91ec9d01b98082e1e16371edc76e /chrome/browser/views/download_item_view.cc
parente8361d4264211c6b47e0ae87606ea56c42da9952 (diff)
downloadchromium_src-f8d13fab476e5018fee5794e63bb64d6dee99bba.zip
chromium_src-f8d13fab476e5018fee5794e63bb64d6dee99bba.tar.gz
chromium_src-f8d13fab476e5018fee5794e63bb64d6dee99bba.tar.bz2
This CL fixes issue 14481 - RTL: Chrome is trying to open exe file directly after clicking down arrow on download shelf instead of drawing a context menu
After changing the download items in download shelf to be RTL in RTL UI, need to change the computation of x coordinate of drop down button. BUG=http://crbug.com/14481 TEST= 1. Run Hebrew Chrome 2. Download an exe file >> Dangerous file warning should show up now 3. Click "Save" button 4. Click the down arrow on the download shelf 5. Chrome should draw a context menu after clicking down arrow (not trying to open the exe file) Review URL: http://codereview.chromium.org/131091 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19232 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/download_item_view.cc')
-rw-r--r--chrome/browser/views/download_item_view.cc33
1 files changed, 24 insertions, 9 deletions
diff --git a/chrome/browser/views/download_item_view.cc b/chrome/browser/views/download_item_view.cc
index 95dc81b..fcf832b 100644
--- a/chrome/browser/views/download_item_view.cc
+++ b/chrome/browser/views/download_item_view.cc
@@ -245,7 +245,16 @@ DownloadItemView::DownloadItemView(DownloadItem* download,
box_y_ = kVerticalPadding;
gfx::Size size = GetPreferredSize();
- drop_down_x_ = size.width() - normal_drop_down_image_set_.top->width();
+ if (UILayoutIsRightToLeft()) {
+ // Drop down button is glued to the left of the download shelf.
+ drop_down_x_left_ = 0;
+ drop_down_x_right_ = normal_drop_down_image_set_.top->width();
+ } else {
+ // Drop down button is glued to the right of the download shelf.
+ drop_down_x_left_ =
+ size.width() - normal_drop_down_image_set_.top->width();
+ drop_down_x_right_ = size.width();
+ }
body_hover_animation_.reset(new SlideAnimation(this));
drop_hover_animation_.reset(new SlideAnimation(this));
@@ -762,7 +771,7 @@ bool DownloadItemView::OnMousePressed(const views::MouseEvent& event) {
if (event.IsOnlyLeftMouseButton()) {
gfx::Point point(event.location());
- if (event.x() < drop_down_x_) {
+ if (!InDropDownButtonXCoordinateRange(event.x())) {
SetState(PUSHED, NORMAL);
return true;
}
@@ -784,11 +793,10 @@ bool DownloadItemView::OnMousePressed(const views::MouseEvent& event) {
// DownloadShelfContextMenu will take care of setting the right anchor for
// the menu depending on the locale.
point.set_y(height());
- if (UILayoutIsRightToLeft()) {
- point.set_x(width());
- } else {
- point.set_x(drop_down_x_);
- }
+ if (UILayoutIsRightToLeft())
+ point.set_x(drop_down_x_right_);
+ else
+ point.set_x(drop_down_x_left_);
views::View::ConvertPointToScreen(this, &point);
DownloadShelfContextMenuWin menu(model_.get(),
@@ -806,7 +814,7 @@ void DownloadItemView::OnMouseMoved(const views::MouseEvent& event) {
if (IsDangerousMode())
return;
- bool on_body = event.x() < drop_down_x_;
+ bool on_body = !InDropDownButtonXCoordinateRange(event.x());
SetState(on_body ? HOT : NORMAL, on_body ? NORMAL : HOT);
if (on_body) {
body_hover_animation_->Show();
@@ -829,7 +837,8 @@ void DownloadItemView::OnMouseReleased(const views::MouseEvent& event,
starting_drag_ = false;
return;
}
- if (event.IsOnlyLeftMouseButton() && event.x() < drop_down_x_)
+ if (event.IsOnlyLeftMouseButton() &&
+ !InDropDownButtonXCoordinateRange(event.x()))
OpenDownload();
SetState(NORMAL, NORMAL);
@@ -964,3 +973,9 @@ void DownloadItemView::Reenable() {
disabled_while_opening_ = false;
SetEnabled(true); // Triggers a repaint.
}
+
+bool DownloadItemView::InDropDownButtonXCoordinateRange(int x) {
+ if (x > drop_down_x_left_ && x < drop_down_x_right_)
+ return true;
+ return false;
+}