Commit 5299daa0 authored by sky's avatar sky Committed by Commit bot

Removes unnecessary calls to FocusManager

In general View::RequestFocus() and FocusManager::SetFocusedView() do
the same thing. The only exception to that is the SetFocusedView()
does not check if the view wants focus, where as View::RequestFocus()
does. For the cases I'm changing here RequestFocus() is fine.

BUG=none
TEST=none
R=msw@chromium.org

Review-Url: https://codereview.chromium.org/2738063007
Cr-Commit-Position: refs/heads/master@{#456118}
parent e86cff1a
...@@ -45,8 +45,7 @@ class TextInputView : public views::WidgetDelegateView { ...@@ -45,8 +45,7 @@ class TextInputView : public views::WidgetDelegateView {
return gfx::Size(kTextInputWindowWidth, kTextInputWindowHeight); return gfx::Size(kTextInputWindowWidth, kTextInputWindowHeight);
} }
// Overridden from views::WidgetDelegate: void FocusOnTextInput() { text_field_->RequestFocus(); }
void FocusOnTextInput() { GetFocusManager()->SetFocusedView(text_field_); }
private: private:
views::Textfield* text_field_; // owned by views hierarchy views::Textfield* text_field_; // owned by views hierarchy
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "ui/accessibility/ax_node_data.h" #include "ui/accessibility/ax_node_data.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/views/focus/focus_manager.h"
using content::DesktopMediaID; using content::DesktopMediaID;
...@@ -158,7 +157,7 @@ bool DesktopMediaListView::OnKeyPressed(const ui::KeyEvent& event) { ...@@ -158,7 +157,7 @@ bool DesktopMediaListView::OnKeyPressed(const ui::KeyEvent& event) {
} }
if (new_selected) if (new_selected)
GetFocusManager()->SetFocusedView(new_selected); new_selected->RequestFocus();
return true; return true;
} }
......
...@@ -103,8 +103,7 @@ void FirstRunBubbleTest::CreateAndCloseBubbleOnEventTest(ui::Event* event) { ...@@ -103,8 +103,7 @@ void FirstRunBubbleTest::CreateAndCloseBubbleOnEventTest(ui::Event* event) {
FirstRunBubble::ShowBubble(NULL, anchor_widget->GetContentsView()); FirstRunBubble::ShowBubble(NULL, anchor_widget->GetContentsView());
EXPECT_TRUE(delegate != NULL); EXPECT_TRUE(delegate != NULL);
anchor_widget->GetFocusManager()->SetFocusedView( anchor_widget->GetContentsView()->RequestFocus();
anchor_widget->GetContentsView());
std::unique_ptr<WidgetClosingObserver> widget_observer( std::unique_ptr<WidgetClosingObserver> widget_observer(
new WidgetClosingObserver(delegate->GetWidget())); new WidgetClosingObserver(delegate->GetWidget()));
......
...@@ -101,11 +101,6 @@ task_manager::TaskManagerTableModel* TaskManagerView::Show(Browser* browser) { ...@@ -101,11 +101,6 @@ task_manager::TaskManagerTableModel* TaskManagerView::Show(Browser* browser) {
g_task_manager_view->SelectTaskOfActiveTab(browser); g_task_manager_view->SelectTaskOfActiveTab(browser);
g_task_manager_view->GetWidget()->Show(); g_task_manager_view->GetWidget()->Show();
// Set the initial focus to the list of tasks.
views::FocusManager* focus_manager = g_task_manager_view->GetFocusManager();
if (focus_manager)
focus_manager->SetFocusedView(g_task_manager_view->tab_table_);
#if defined(USE_ASH) #if defined(USE_ASH)
aura::Window* window = g_task_manager_view->GetWidget()->GetNativeWindow(); aura::Window* window = g_task_manager_view->GetWidget()->GetNativeWindow();
window->SetProperty<int>(ash::kShelfItemTypeKey, ash::TYPE_DIALOG); window->SetProperty<int>(ash::kShelfItemTypeKey, ash::TYPE_DIALOG);
...@@ -166,6 +161,10 @@ bool TaskManagerView::AcceleratorPressed(const ui::Accelerator& accelerator) { ...@@ -166,6 +161,10 @@ bool TaskManagerView::AcceleratorPressed(const ui::Accelerator& accelerator) {
return true; return true;
} }
views::View* TaskManagerView::GetInitiallyFocusedView() {
return tab_table_;
}
bool TaskManagerView::CanResize() const { bool TaskManagerView::CanResize() const {
return true; return true;
} }
......
...@@ -54,6 +54,7 @@ class TaskManagerView : public TableViewDelegate, ...@@ -54,6 +54,7 @@ class TaskManagerView : public TableViewDelegate,
bool AcceleratorPressed(const ui::Accelerator& accelerator) override; bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
// views::DialogDelegateView: // views::DialogDelegateView:
views::View* GetInitiallyFocusedView() override;
bool CanResize() const override; bool CanResize() const override;
bool CanMaximize() const override; bool CanMaximize() const override;
bool CanMinimize() const override; bool CanMinimize() const override;
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "ui/views/border.h" #include "ui/views/border.h"
#include "ui/views/controls/button/image_button.h" #include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/textfield/textfield.h" #include "ui/views/controls/textfield/textfield.h"
#include "ui/views/focus/focus_manager.h"
#include "ui/views/painter.h" #include "ui/views/painter.h"
namespace app_list { namespace app_list {
...@@ -96,11 +95,7 @@ void FolderHeaderView::OnFolderItemRemoved() { ...@@ -96,11 +95,7 @@ void FolderHeaderView::OnFolderItemRemoved() {
} }
void FolderHeaderView::SetTextFocus() { void FolderHeaderView::SetTextFocus() {
if (!folder_name_view_->HasFocus()) { folder_name_view_->RequestFocus();
views::FocusManager* focus_manager = GetFocusManager();
if (focus_manager)
focus_manager->SetFocusedView(folder_name_view_);
}
} }
bool FolderHeaderView::HasTextFocus() const { bool FolderHeaderView::HasTextFocus() const {
......
...@@ -271,8 +271,7 @@ void WebView::RenderViewDeleted(content::RenderViewHost* render_view_host) { ...@@ -271,8 +271,7 @@ void WebView::RenderViewDeleted(content::RenderViewHost* render_view_host) {
void WebView::RenderViewHostChanged(content::RenderViewHost* old_host, void WebView::RenderViewHostChanged(content::RenderViewHost* old_host,
content::RenderViewHost* new_host) { content::RenderViewHost* new_host) {
FocusManager* const focus_manager = GetFocusManager(); if (HasFocus())
if (focus_manager && focus_manager->GetFocusedView() == this)
OnFocus(); OnFocus();
NotifyAccessibilityWebContentsChanged(); NotifyAccessibilityWebContentsChanged();
} }
...@@ -310,9 +309,7 @@ void WebView::DidDetachInterstitialPage() { ...@@ -310,9 +309,7 @@ void WebView::DidDetachInterstitialPage() {
} }
void WebView::OnWebContentsFocused() { void WebView::OnWebContentsFocused() {
FocusManager* focus_manager = GetFocusManager(); RequestFocus();
if (focus_manager)
focus_manager->SetFocusedView(this);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
...@@ -333,11 +330,9 @@ void WebView::AttachWebContents() { ...@@ -333,11 +330,9 @@ void WebView::AttachWebContents() {
holder_->Attach(view_to_attach); holder_->Attach(view_to_attach);
// The view will not be focused automatically when it is attached, so we need // The WebContents is not focused automatically when attached, so we need to
// to pass on focus to it if the FocusManager thinks the view is focused. Note // tell the WebContents it has focus if this has focus.
// that not every Widget has a focus manager. if (HasFocus())
FocusManager* const focus_manager = GetFocusManager();
if (focus_manager && focus_manager->GetFocusedView() == this)
OnFocus(); OnFocus();
OnWebContentsAttached(); OnWebContentsAttached();
......
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