Commit 2213edcb authored by Mohamed Mansour's avatar Mohamed Mansour Committed by Commit Bot

TableView: Fix RTL Focusing

In RTL mode, this will render the focus ring in the right spot and
allow it to be traversable via keyboard shortcuts in the correct
direction.

AX-Relnotes: Focus ring does not appear distorted and left / right arrow keys behave correctly
in the Task Manager and other tables in Chromium's UI, when right-to-left languages are used.

Bug: 1030617, 1121715
Change-Id: I303a55486205c25580d6985462949dc0b79bf4d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2375736Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarNektarios Paisios <nektar@chromium.org>
Commit-Queue: Mohamed Mansour <mmansour@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#802286}
parent 434b2cad
......@@ -150,7 +150,9 @@ class TableView::HighlightPathGenerator : public views::HighlightPathGenerator {
return SkPath();
// Draw a focus indicator around the active cell.
return SkPath().addRect(gfx::RectToSkRect(table->GetActiveCellBounds()));
gfx::Rect bounds = table->GetActiveCellBounds();
bounds.set_x(table->GetMirroredXForRect(bounds));
return SkPath().addRect(gfx::RectToSkRect(bounds));
}
private:
......@@ -496,17 +498,17 @@ bool TableView::OnKeyPressed(const ui::KeyEvent& event) {
case ui::VKEY_LEFT:
if (PlatformStyle::kTableViewSupportsKeyboardNavigationByCell) {
const AdvanceDirection direction = base::i18n::IsRTL()
? AdvanceDirection::kIncrement
: AdvanceDirection::kDecrement;
if (IsCmdOrCtrl(event)) {
if (active_visible_column_index_ != -1 && header_) {
const AdvanceDirection direction =
base::i18n::IsRTL() ? AdvanceDirection::kIncrement
: AdvanceDirection::kDecrement;
header_->ResizeColumnViaKeyboard(active_visible_column_index_,
direction);
focus_ring_->SchedulePaint();
}
} else {
AdvanceActiveVisibleColumn(AdvanceDirection::kDecrement);
AdvanceActiveVisibleColumn(direction);
}
return true;
}
......@@ -514,17 +516,17 @@ bool TableView::OnKeyPressed(const ui::KeyEvent& event) {
case ui::VKEY_RIGHT:
if (PlatformStyle::kTableViewSupportsKeyboardNavigationByCell) {
const AdvanceDirection direction = base::i18n::IsRTL()
? AdvanceDirection::kDecrement
: AdvanceDirection::kIncrement;
if (IsCmdOrCtrl(event)) {
if (active_visible_column_index_ != -1 && header_) {
const AdvanceDirection direction =
base::i18n::IsRTL() ? AdvanceDirection::kDecrement
: AdvanceDirection::kIncrement;
header_->ResizeColumnViaKeyboard(active_visible_column_index_,
direction);
focus_ring_->SchedulePaint();
}
} else {
AdvanceActiveVisibleColumn(AdvanceDirection::kIncrement);
AdvanceActiveVisibleColumn(direction);
}
return true;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment