Commit fb08cc35 authored by Thomas Lukaszewicz's avatar Thomas Lukaszewicz Committed by Commit Bot

Moved TabbedPane Accelerators from ViewHierarchyChanged() to constructor

Moved the Accelerator initalizers for TabbedPane into the
constructor. This enables TabbedPane to be reparented without
redundantly adding accelerators.

Bug: 1083822
Change-Id: Iaa6483c6c6484a21c9ad17fa5b3948ca5118d94a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2208590
Commit-Queue: Thomas Lukaszewicz <tluk@chromium.org>
Reviewed-by: default avatarAllen Bauer <kylixrd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772258}
parent 34b4b8ad
...@@ -510,6 +510,11 @@ TabbedPane::TabbedPane(TabbedPane::Orientation orientation, ...@@ -510,6 +510,11 @@ TabbedPane::TabbedPane(TabbedPane::Orientation orientation,
views::FlexSpecification(views::MinimumFlexSizeRule::kScaleToZero, views::FlexSpecification(views::MinimumFlexSizeRule::kScaleToZero,
views::MaximumFlexSizeRule::kUnbounded)); views::MaximumFlexSizeRule::kUnbounded));
contents_->SetLayoutManager(std::make_unique<views::FillLayout>()); contents_->SetLayoutManager(std::make_unique<views::FillLayout>());
// Support navigating tabs by Ctrl+Tab and Ctrl+Shift+Tab.
AddAccelerator(
ui::Accelerator(ui::VKEY_TAB, ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN));
AddAccelerator(ui::Accelerator(ui::VKEY_TAB, ui::EF_CONTROL_DOWN));
} }
TabbedPane::~TabbedPane() = default; TabbedPane::~TabbedPane() = default;
...@@ -600,16 +605,6 @@ bool TabbedPane::MoveSelectionBy(int delta) { ...@@ -600,16 +605,6 @@ bool TabbedPane::MoveSelectionBy(int delta) {
return true; return true;
} }
void TabbedPane::ViewHierarchyChanged(
const ViewHierarchyChangedDetails& details) {
if (details.is_add) {
// Support navigating tabs by Ctrl+Tab and Ctrl+Shift+Tab.
AddAccelerator(
ui::Accelerator(ui::VKEY_TAB, ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN));
AddAccelerator(ui::Accelerator(ui::VKEY_TAB, ui::EF_CONTROL_DOWN));
}
}
bool TabbedPane::AcceleratorPressed(const ui::Accelerator& accelerator) { bool TabbedPane::AcceleratorPressed(const ui::Accelerator& accelerator) {
// Handle Ctrl+Tab and Ctrl+Shift+Tab navigation of pages. // Handle Ctrl+Tab and Ctrl+Shift+Tab navigation of pages.
DCHECK(accelerator.key_code() == ui::VKEY_TAB && accelerator.IsCtrlDown()); DCHECK(accelerator.key_code() == ui::VKEY_TAB && accelerator.IsCtrlDown());
......
...@@ -123,8 +123,6 @@ class VIEWS_EXPORT TabbedPane : public View { ...@@ -123,8 +123,6 @@ class VIEWS_EXPORT TabbedPane : public View {
bool MoveSelectionBy(int delta); bool MoveSelectionBy(int delta);
// Overridden from View: // Overridden from View:
void ViewHierarchyChanged(
const ViewHierarchyChangedDetails& details) override;
bool AcceleratorPressed(const ui::Accelerator& accelerator) override; bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
void GetAccessibleNodeData(ui::AXNodeData* node_data) override; void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
......
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