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