diff options
author | dbeam@chromium.org <dbeam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-17 12:57:04 +0000 |
---|---|---|
committer | dbeam@chromium.org <dbeam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-17 12:57:04 +0000 |
commit | 127c6a1a41fd69f173bcbcfec5feb7d6cf2c7009 (patch) | |
tree | 1b3f1665876f4347c9df42c1f1406029c1795cab /components/web_modal | |
parent | 77a8ca1352fbfb33367064a6a3065444bf21eaf9 (diff) | |
download | chromium_src-127c6a1a41fd69f173bcbcfec5feb7d6cf2c7009.zip chromium_src-127c6a1a41fd69f173bcbcfec5feb7d6cf2c7009.tar.gz chromium_src-127c6a1a41fd69f173bcbcfec5feb7d6cf2c7009.tar.bz2 |
Remove invisible views from tab order.
AutofillDialogViews::Layout() and AutofillDialogViews::GetPreferredSize()
short-circuit logic when either the loading shield or sign-in webview are
showing. Unfortunately this has the side-effect of keeping any focusable input
in the dialog in the tab order. Recently I made suggested buttons (down arrows)
focusable so this became more noticeable, but the problem has always been there
(if you currently change all sections to add mode and attempt to sign in you'll
have tons of invisible elements to focus).
This CL makes visually invisible nodes also !visible() to remove them from the
tab order (see: views::View::IsFocusable()).
R=isherman@chromium.org
BUG=306484
Review URL: https://codereview.chromium.org/27085002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229111 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/web_modal')
5 files changed, 161 insertions, 38 deletions
diff --git a/components/web_modal/test_web_contents_modal_dialog_host.cc b/components/web_modal/test_web_contents_modal_dialog_host.cc new file mode 100644 index 0000000..c5705fc --- /dev/null +++ b/components/web_modal/test_web_contents_modal_dialog_host.cc @@ -0,0 +1,36 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/web_modal/test_web_contents_modal_dialog_host.h" + +#include "ui/gfx/point.h" + +namespace web_modal { + +TestWebContentsModalDialogHost::TestWebContentsModalDialogHost( + gfx::NativeView host_view) + : host_view_(host_view) {} + +TestWebContentsModalDialogHost::~TestWebContentsModalDialogHost() {} + +gfx::Size TestWebContentsModalDialogHost::GetMaximumDialogSize() { + return max_dialog_size_; +} + +gfx::NativeView TestWebContentsModalDialogHost::GetHostView() const { + return host_view_; +} + +gfx::Point TestWebContentsModalDialogHost::GetDialogPosition( + const gfx::Size& size) { + return gfx::Point(); +} + +void TestWebContentsModalDialogHost::AddObserver( + ModalDialogHostObserver* observer) {} + +void TestWebContentsModalDialogHost::RemoveObserver( + ModalDialogHostObserver* observer) {} + +} // namespace web_modal diff --git a/components/web_modal/test_web_contents_modal_dialog_host.h b/components/web_modal/test_web_contents_modal_dialog_host.h new file mode 100644 index 0000000..89fb4b3 --- /dev/null +++ b/components/web_modal/test_web_contents_modal_dialog_host.h @@ -0,0 +1,42 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_WEB_MODAL_TEST_WEB_CONTENTS_MODAL_DIALOG_HOST_H_ +#define COMPONENTS_WEB_MODAL_TEST_WEB_CONTENTS_MODAL_DIALOG_HOST_H_ + +#include "components/web_modal/web_contents_modal_dialog_host.h" + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "ui/gfx/native_widget_types.h" +#include "ui/gfx/size.h" + +namespace web_modal { + +class TestWebContentsModalDialogHost : public WebContentsModalDialogHost { + public: + explicit TestWebContentsModalDialogHost(gfx::NativeView host_view); + virtual ~TestWebContentsModalDialogHost(); + + // WebContentsModalDialogHost: + virtual gfx::Size GetMaximumDialogSize() OVERRIDE; + virtual gfx::NativeView GetHostView() const OVERRIDE; + virtual gfx::Point GetDialogPosition(const gfx::Size& size) OVERRIDE; + virtual void AddObserver(ModalDialogHostObserver* observer) OVERRIDE; + virtual void RemoveObserver(ModalDialogHostObserver* observer) OVERRIDE; + + void set_max_dialog_size(const gfx::Size& max_dialog_size) { + max_dialog_size_ = max_dialog_size; + } + + private: + gfx::NativeView host_view_; + gfx::Size max_dialog_size_; + + DISALLOW_COPY_AND_ASSIGN(TestWebContentsModalDialogHost); +}; + +} // namespace web_modal + +#endif // COMPONENTS_WEB_MODAL_TEST_WEB_CONTENTS_MODAL_DIALOG_HOST_H_ diff --git a/components/web_modal/test_web_contents_modal_dialog_manager_delegate.cc b/components/web_modal/test_web_contents_modal_dialog_manager_delegate.cc new file mode 100644 index 0000000..53c94d2 --- /dev/null +++ b/components/web_modal/test_web_contents_modal_dialog_manager_delegate.cc @@ -0,0 +1,31 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/web_modal/test_web_contents_modal_dialog_manager_delegate.h" + +namespace web_modal { + +TestWebContentsModalDialogManagerDelegate:: + TestWebContentsModalDialogManagerDelegate() + : web_contents_visible_(true), + web_contents_blocked_(false), + web_contents_modal_dialog_host_(NULL) {} + +void TestWebContentsModalDialogManagerDelegate::SetWebContentsBlocked( + content::WebContents* web_contents, + bool blocked) { + web_contents_blocked_ = blocked; +} + +WebContentsModalDialogHost* TestWebContentsModalDialogManagerDelegate:: + GetWebContentsModalDialogHost() { + return web_contents_modal_dialog_host_; +} + +bool TestWebContentsModalDialogManagerDelegate::IsWebContentsVisible( + content::WebContents* web_contents) { + return web_contents_visible_; +} + +} // namespace web_modal diff --git a/components/web_modal/test_web_contents_modal_dialog_manager_delegate.h b/components/web_modal/test_web_contents_modal_dialog_manager_delegate.h new file mode 100644 index 0000000..3ca641a --- /dev/null +++ b/components/web_modal/test_web_contents_modal_dialog_manager_delegate.h @@ -0,0 +1,49 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_WEB_MODAL_TEST_WEB_CONTENTS_MODAL_DIALOG_MANAGER_DELEGATE_H_ +#define COMPONENTS_WEB_MODAL_TEST_WEB_CONTENTS_MODAL_DIALOG_MANAGER_DELEGATE_H_ + +#include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" + +#include "base/basictypes.h" +#include "base/compiler_specific.h" + +namespace web_modal { + +class TestWebContentsModalDialogManagerDelegate + : public WebContentsModalDialogManagerDelegate { + public: + TestWebContentsModalDialogManagerDelegate(); + + // WebContentsModalDialogManagerDelegate overrides: + virtual void SetWebContentsBlocked(content::WebContents* web_contents, + bool blocked) OVERRIDE; + + virtual WebContentsModalDialogHost* GetWebContentsModalDialogHost() OVERRIDE; + + virtual bool IsWebContentsVisible( + content::WebContents* web_contents) OVERRIDE; + + void set_web_contents_visible(bool visible) { + web_contents_visible_ = visible; + } + + void set_web_contents_modal_dialog_host(WebContentsModalDialogHost* host) { + web_contents_modal_dialog_host_ = host; + } + + bool web_contents_blocked() const { return web_contents_blocked_; } + + private: + bool web_contents_visible_; + bool web_contents_blocked_; + WebContentsModalDialogHost* web_contents_modal_dialog_host_; // Not owned. + + DISALLOW_COPY_AND_ASSIGN(TestWebContentsModalDialogManagerDelegate); +}; + +} // namespace web_modal + +#endif // COMPONENTS_WEB_MODAL_TEST_WEB_CONTENTS_MODAL_DIALOG_MANAGER_DELEGATE_H_ diff --git a/components/web_modal/web_contents_modal_dialog_manager_unittest.cc b/components/web_modal/web_contents_modal_dialog_manager_unittest.cc index 2da9124..7095498 100644 --- a/components/web_modal/web_contents_modal_dialog_manager_unittest.cc +++ b/components/web_modal/web_contents_modal_dialog_manager_unittest.cc @@ -2,12 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "components/web_modal/web_contents_modal_dialog_manager.h" + #include <map> #include "base/memory/scoped_ptr.h" #include "components/web_modal/native_web_contents_modal_dialog_manager.h" -#include "components/web_modal/web_contents_modal_dialog_manager.h" -#include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" +#include "components/web_modal/test_web_contents_modal_dialog_manager_delegate.h" #include "content/public/test/test_renderer_host.h" #include "testing/gtest/include/gtest/gtest.h" @@ -71,42 +72,6 @@ class TestNativeWebContentsModalDialogManager DISALLOW_COPY_AND_ASSIGN(TestNativeWebContentsModalDialogManager); }; -class TestWebContentsModalDialogManagerDelegate - : public WebContentsModalDialogManagerDelegate { - public: - TestWebContentsModalDialogManagerDelegate() - : web_contents_visible_(true), - web_contents_blocked_(false) { - } - - // WebContentsModalDialogManagerDelegate overrides - virtual void SetWebContentsBlocked(content::WebContents* web_contents, - bool blocked) OVERRIDE { - web_contents_blocked_ = blocked; - } - - virtual WebContentsModalDialogHost* GetWebContentsModalDialogHost() OVERRIDE { - return NULL; - } - - virtual bool IsWebContentsVisible( - content::WebContents* web_contents) OVERRIDE { - return web_contents_visible_; - } - - void set_web_contents_visible(bool visible) { - web_contents_visible_ = visible; - } - - bool web_contents_blocked() const { return web_contents_blocked_; } - - private: - bool web_contents_visible_; - bool web_contents_blocked_; - - DISALLOW_COPY_AND_ASSIGN(TestWebContentsModalDialogManagerDelegate); -}; - class WebContentsModalDialogManagerTest : public content::RenderViewHostTestHarness { public: |