summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxji@chromium.org <xji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-15 17:45:57 +0000
committerxji@chromium.org <xji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-15 17:45:57 +0000
commitd9fa25b165cfbc788d30f44d0d450f804a791aec (patch)
tree53fe37cbf4b9f2d1466ee19fe78fdb34e3632a39
parentda50530a6140daab69ab1543d4bf92a41df02142 (diff)
downloadchromium_src-d9fa25b165cfbc788d30f44d0d450f804a791aec.zip
chromium_src-d9fa25b165cfbc788d30f44d0d450f804a791aec.tar.gz
chromium_src-d9fa25b165cfbc788d30f44d0d450f804a791aec.tar.bz2
This CL fixes issue 6223 (comment #10 and #15).
There are the following 3 issues: 1. the tab image in gray box is wrong in RTL locale. This is fixed by flipping canvas in RTL locale when draw those images. 2. dropped tab was not rendered in the correct position when gray box appears but the tab was not dropped inside the gray box. This is fixed by adjusting x coordinate of the dropped tab when there is dock information available in RTL in CompleteDrag(). 3. when chrome is maximized, drag/drop a tab to left/right window, then drag the tab through original main browser tabstrip and drop it anywhere else, dropped tab was not rendered in the right position. This is fixed by initialize window create point based on source_tabstrip_, not attached_tabstrip_, and move the initialization function from Attach() (since the position is no longer related to attached_tabstrip_) to CaptureDragInfo() where the mouse_offset_ is set. BUG=http://crbug.com/6223 TEST= 1. Open Hebrew Chrome, 2. drag a tab to the right of the screen till the gray box showed up, the tab image showed in the gray box should be similar to the tab image in Hebrew Chrome (not that in English Chrome), 3. drop the tab outside of the gray box while gray box is showing, the dropped tab should be rendered using the mouse click as the top-right corner (not top-left corner). 4. maximize chrome and open at least 2 tabs in it. 5. drag a tab out to left screen till the "left-half of screen" gray box showed up and drop it inside the gray box so that the tab was in the left-half of the screen and the original chrome browser is still maximized. 6. drag this tab back to the title of chrome (as if to re-insert it back to the maximized chrome's tabstrip) but do not release mouse, continue drag it back to somewhere on the screen and drop it. The dropped tab should be rendered using the mouse click as a point in its tabstrip (not rendered far away from the mouse click). Review URL: http://codereview.chromium.org/126006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18401 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/views/tabs/dragged_tab_controller.cc64
1 files changed, 54 insertions, 10 deletions
diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc
index 03722ff..b4fea1d 100644
--- a/chrome/browser/views/tabs/dragged_tab_controller.cc
+++ b/chrome/browser/views/tabs/dragged_tab_controller.cc
@@ -9,6 +9,7 @@
#include "app/animation.h"
#include "app/gfx/canvas.h"
+#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "chrome/browser/browser_window.h"
#include "chrome/browser/extensions/extension_function_dispatcher.h"
@@ -70,14 +71,31 @@ class DockView : public views::View {
SkBitmap* high_icon = rb.GetBitmapNamed(IDR_DOCK_HIGH);
SkBitmap* wide_icon = rb.GetBitmapNamed(IDR_DOCK_WIDE);
+ bool rtl_ui = l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT;
+ if (rtl_ui) {
+ // Flip canvas to draw the mirrored tab images for RTL UI.
+ canvas->save();
+ canvas->TranslateInt(width(), 0);
+ canvas->ScaleInt(-1, 1);
+ }
+ int x_of_active_tab = -1;
+ int x_of_inactive_tab = -1;
switch (type_) {
case DockInfo::LEFT_OF_WINDOW:
case DockInfo::LEFT_HALF:
- canvas->DrawBitmapInt(*high_icon,
- width() / 2 - high_icon->width() - kTabSpacing / 2,
- (height() - high_icon->height()) / 2);
+ if (!rtl_ui) {
+ x_of_active_tab = width() / 2 - high_icon->width() - kTabSpacing / 2;
+ x_of_inactive_tab = width() / 2 + kTabSpacing / 2;
+ } else {
+ // Adjust x axis for RTL UI after flippping canvas.
+ x_of_active_tab = width() / 2 + kTabSpacing / 2;
+ x_of_inactive_tab = width() / 2 - high_icon->width() -
+ kTabSpacing / 2;
+ }
+ canvas->DrawBitmapInt(*high_icon, x_of_active_tab,
+ (height() - high_icon->height()) / 2);
if (type_ == DockInfo::LEFT_OF_WINDOW) {
- DrawBitmapWithAlpha(canvas, *high_icon, width() / 2 + kTabSpacing / 2,
+ DrawBitmapWithAlpha(canvas, *high_icon, x_of_inactive_tab,
(height() - high_icon->height()) / 2);
}
break;
@@ -85,12 +103,20 @@ class DockView : public views::View {
case DockInfo::RIGHT_OF_WINDOW:
case DockInfo::RIGHT_HALF:
- canvas->DrawBitmapInt(*high_icon, width() / 2 + kTabSpacing / 2,
+ if (!rtl_ui) {
+ x_of_active_tab = width() / 2 + kTabSpacing / 2;
+ x_of_inactive_tab = width() / 2 - high_icon->width() -
+ kTabSpacing / 2;
+ } else {
+ // Adjust x axis for RTL UI after flippping canvas.
+ x_of_active_tab = width() / 2 - high_icon->width() - kTabSpacing / 2;
+ x_of_inactive_tab = width() / 2 + kTabSpacing / 2;
+ }
+ canvas->DrawBitmapInt(*high_icon, x_of_active_tab,
(height() - high_icon->height()) / 2);
if (type_ == DockInfo::RIGHT_OF_WINDOW) {
- DrawBitmapWithAlpha(canvas, *high_icon,
- width() / 2 - high_icon->width() - kTabSpacing / 2,
- (height() - high_icon->height()) / 2);
+ DrawBitmapWithAlpha(canvas, *high_icon, x_of_inactive_tab,
+ (height() - high_icon->height()) / 2);
}
break;
@@ -121,6 +147,8 @@ class DockView : public views::View {
NOTREACHED();
break;
}
+ if (rtl_ui)
+ canvas->restore();
}
private:
@@ -301,6 +329,7 @@ DraggedTabController::~DraggedTabController() {
void DraggedTabController::CaptureDragInfo(const gfx::Point& mouse_offset) {
start_screen_point_ = GetCursorScreenPoint();
mouse_offset_ = mouse_offset;
+ InitWindowCreatePoint();
}
void DraggedTabController::Drag() {
@@ -461,7 +490,14 @@ void DraggedTabController::DidProcessEvent(GdkEvent* event) {
void DraggedTabController::InitWindowCreatePoint() {
window_create_point_.SetPoint(mouse_offset_.x(), mouse_offset_.y());
- Tab* first_tab = attached_tabstrip_->GetTabAt(0);
+ // window_create_point_ is only used in CompleteDrag() (through
+ // GetWindowCreatePoint() to get the start point of the docked window) when
+ // the attached_tabstrip_ is NULL and all the window's related bound
+ // information are obtained from source_tabstrip_. So, we need to get the
+ // first_tab based on source_tabstrip_, not attached_tabstrip_. Otherwise,
+ // the window_create_point_ is not in the correct coordinate system. Please
+ // refer to http://crbug.com/6223 comment #15 for detailed information.
+ Tab* first_tab = source_tabstrip_->GetTabAt(0);
views::View::ConvertPointToWidget(first_tab, &window_create_point_);
}
@@ -688,7 +724,6 @@ TabStrip* DraggedTabController::GetTabStripIfItContains(
void DraggedTabController::Attach(TabStrip* attached_tabstrip,
const gfx::Point& screen_point) {
attached_tabstrip_ = attached_tabstrip;
- InitWindowCreatePoint();
attached_tabstrip_->GenerateIdealBounds();
// We don't need the photo-booth while we're attached.
@@ -1051,6 +1086,15 @@ bool DraggedTabController::CompleteDrag() {
gfx::Rect window_bounds(
GetWindowCreatePoint(),
gfx::Size(browser_rect.width(), browser_rect.height()));
+ // When modifying the following if statement, please make sure not to
+ // introduce issue listed in http://crbug.com/6223 comment #11.
+ bool rtl_ui = (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT);
+ bool has_dock_position = (dock_info_.type() != DockInfo::NONE);
+ if (rtl_ui && has_dock_position) {
+ // Mirror X axis so the docked tab is aligned using the mouse click as
+ // the top-right corner.
+ window_bounds.set_x(window_bounds.x() - window_bounds.width());
+ }
Browser* new_browser =
source_tabstrip_->model()->delegate()->CreateNewStripWithContents(
dragged_contents_, window_bounds, dock_info_);