Commit 714a98f9 authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

views: split BubbleDialogDelegateView

This change moves most of the logic from BubbleDialogDelegateView into a
new class, BubbleDialogDelegate. BubbleDialogDelegate implements the
anchoring logic for bubbles, as well as some ancillary functionality
around widget activity, anchor view highlighting, and so on.

BubbleDialogDelegateView is now mostly a stub class that subclasses both
BubbleDialogDelegate and View, and overrides some behavior of View.

BDDV = BubbleDialogDelegateView
BDD = BubbleDialogDelegate (doesn't yet exist)
DDV = DialogDelegateView
DD = DialogDelegate
WD = WidgetDelegate
V = View

This CL is the second step in this process:

1. BDDV inherits from DD & V (landed in r770128)
2. Break BDDV into BDD (which inherits from DD) and BDDV (which
   inherits from both), like the current DD/DDV split
3. For each client class that subclasses BDDV, move that class to
   subclassing View and containing a BDD member, which is used when
   a BDD, DD, or WD is needed.
4. Delete BDDV itself
5. Repeat (3) for DDV instead of BDDV
6. Delete DDV itself
7. Remove any remaining subclasses of BDD or DD

Change-Id: Ie300eebdeab59709e2bb437ed8c26ee29d0c2835
Bug: 1075649, 1011446
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2209374
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771905}
parent d5561af9
...@@ -18,7 +18,7 @@ namespace { ...@@ -18,7 +18,7 @@ namespace {
// Returns the BubbleDialogDelegateView corresponding to |maybe_bubble| if // Returns the BubbleDialogDelegateView corresponding to |maybe_bubble| if
// |maybe_bubble| is a bubble. // |maybe_bubble| is a bubble.
views::BubbleDialogDelegateView* AsBubbleDialogDelegate( views::BubbleDialogDelegate* AsBubbleDialogDelegate(
aura::Window* maybe_bubble) { aura::Window* maybe_bubble) {
if (!maybe_bubble) if (!maybe_bubble)
return nullptr; return nullptr;
...@@ -29,7 +29,7 @@ views::BubbleDialogDelegateView* AsBubbleDialogDelegate( ...@@ -29,7 +29,7 @@ views::BubbleDialogDelegateView* AsBubbleDialogDelegate(
} }
views::View* GetAnchorView(aura::Window* maybe_bubble) { views::View* GetAnchorView(aura::Window* maybe_bubble) {
views::BubbleDialogDelegateView* bubble_dialog = views::BubbleDialogDelegate* bubble_dialog =
AsBubbleDialogDelegate(maybe_bubble); AsBubbleDialogDelegate(maybe_bubble);
return bubble_dialog ? bubble_dialog->GetAnchorView() : nullptr; return bubble_dialog ? bubble_dialog->GetAnchorView() : nullptr;
} }
......
...@@ -138,7 +138,7 @@ void ApplyAnimationSettings( ...@@ -138,7 +138,7 @@ void ApplyAnimationSettings(
} }
// Returns BubbleDialogDelegateView if |transient_window| is a bubble dialog. // Returns BubbleDialogDelegateView if |transient_window| is a bubble dialog.
views::BubbleDialogDelegateView* AsBubbleDialogDelegate( views::BubbleDialogDelegate* AsBubbleDialogDelegate(
aura::Window* transient_window) { aura::Window* transient_window) {
views::Widget* widget = views::Widget* widget =
views::Widget::GetWidgetForNativeWindow(transient_window); views::Widget::GetWidgetForNativeWindow(transient_window);
...@@ -173,7 +173,7 @@ void WindowTransformAnimationObserver::OnImplicitAnimationsCompleted() { ...@@ -173,7 +173,7 @@ void WindowTransformAnimationObserver::OnImplicitAnimationsCompleted() {
::wm::TransientWindowManager::GetOrCreate(window_) ::wm::TransientWindowManager::GetOrCreate(window_)
->transient_children()) { ->transient_children()) {
// For now we only care about bubble dialog type transient children. // For now we only care about bubble dialog type transient children.
views::BubbleDialogDelegateView* bubble_delegate_view = views::BubbleDialogDelegate* bubble_delegate_view =
AsBubbleDialogDelegate(transient_window); AsBubbleDialogDelegate(transient_window);
if (bubble_delegate_view) if (bubble_delegate_view)
bubble_delegate_view->OnAnchorBoundsChanged(); bubble_delegate_view->OnAnchorBoundsChanged();
......
...@@ -446,7 +446,7 @@ void CaptionBubble::AddedToWidget() { ...@@ -446,7 +446,7 @@ void CaptionBubble::AddedToWidget() {
anchor_widget()->GetFocusTraversable()); anchor_widget()->GetFocusTraversable());
GetWidget()->SetFocusTraversableParentView(GetAnchorView()); GetWidget()->SetFocusTraversableParentView(GetAnchorView());
GetAnchorView()->SetProperty(views::kAnchoredDialogKey, GetAnchorView()->SetProperty(views::kAnchoredDialogKey,
static_cast<BubbleDialogDelegateView*>(this)); static_cast<BubbleDialogDelegate*>(this));
} }
void CaptionBubble::ButtonPressed(views::Button* sender, void CaptionBubble::ButtonPressed(views::Button* sender,
......
...@@ -148,7 +148,7 @@ class ExtensionsMenuViewBrowserTest : public ExtensionsToolbarBrowserTest { ...@@ -148,7 +148,7 @@ class ExtensionsMenuViewBrowserTest : public ExtensionsToolbarBrowserTest {
if (ui_test_name_ == "InstallDialog") { if (ui_test_name_ == "InstallDialog") {
ExtensionsToolbarContainer* const container = ExtensionsToolbarContainer* const container =
GetExtensionsToolbarContainer(); GetExtensionsToolbarContainer();
views::BubbleDialogDelegateView* const install_bubble = views::BubbleDialogDelegate* const install_bubble =
container->GetViewForId(extensions()[0]->id()) container->GetViewForId(extensions()[0]->id())
->GetProperty(views::kAnchoredDialogKey); ->GetProperty(views::kAnchoredDialogKey);
ASSERT_TRUE(install_bubble); ASSERT_TRUE(install_bubble);
...@@ -164,7 +164,7 @@ class ExtensionsMenuViewBrowserTest : public ExtensionsToolbarBrowserTest { ...@@ -164,7 +164,7 @@ class ExtensionsMenuViewBrowserTest : public ExtensionsToolbarBrowserTest {
ExtensionsToolbarContainer* const container = ExtensionsToolbarContainer* const container =
GetExtensionsToolbarContainer(); GetExtensionsToolbarContainer();
// Accept or cancel the dialog. // Accept or cancel the dialog.
views::BubbleDialogDelegateView* const uninstall_bubble = views::BubbleDialogDelegate* const uninstall_bubble =
container->GetViewForId(extensions()[0]->id()) container->GetViewForId(extensions()[0]->id())
->GetProperty(views::kAnchoredDialogKey); ->GetProperty(views::kAnchoredDialogKey);
ASSERT_TRUE(uninstall_bubble); ASSERT_TRUE(uninstall_bubble);
......
...@@ -1475,7 +1475,7 @@ bool BrowserView::ActivateFirstInactiveBubbleForAccessibility() { ...@@ -1475,7 +1475,7 @@ bool BrowserView::ActivateFirstInactiveBubbleForAccessibility() {
// general solution should be desirable to find any bubbles anchored in the // general solution should be desirable to find any bubbles anchored in the
// views hierarchy. // views hierarchy.
if (toolbar_ && toolbar_->app_menu_button()) { if (toolbar_ && toolbar_->app_menu_button()) {
views::BubbleDialogDelegateView* bubble = views::BubbleDialogDelegate* bubble =
toolbar_->app_menu_button()->GetProperty(views::kAnchoredDialogKey); toolbar_->app_menu_button()->GetProperty(views::kAnchoredDialogKey);
if (!bubble && GetLocationBarView()) if (!bubble && GetLocationBarView())
bubble = GetLocationBarView()->GetProperty(views::kAnchoredDialogKey); bubble = GetLocationBarView()->GetProperty(views::kAnchoredDialogKey);
......
...@@ -581,7 +581,7 @@ gfx::Rect BubbleFrameView::GetAvailableScreenBounds( ...@@ -581,7 +581,7 @@ gfx::Rect BubbleFrameView::GetAvailableScreenBounds(
} }
gfx::Rect BubbleFrameView::GetAvailableAnchorWindowBounds() const { gfx::Rect BubbleFrameView::GetAvailableAnchorWindowBounds() const {
views::BubbleDialogDelegateView* bubble_delegate_view = views::BubbleDialogDelegate* bubble_delegate_view =
GetWidget()->widget_delegate()->AsBubbleDialogDelegate(); GetWidget()->widget_delegate()->AsBubbleDialogDelegate();
if (bubble_delegate_view) { if (bubble_delegate_view) {
views::View* const anchor_view = bubble_delegate_view->GetAnchorView(); views::View* const anchor_view = bubble_delegate_view->GetAnchorView();
......
...@@ -617,7 +617,7 @@ bool FocusManager::RedirectAcceleratorToBubbleAnchorWidget( ...@@ -617,7 +617,7 @@ bool FocusManager::RedirectAcceleratorToBubbleAnchorWidget(
} }
Widget* FocusManager::GetBubbleAnchorWidget() { Widget* FocusManager::GetBubbleAnchorWidget() {
BubbleDialogDelegateView* widget_delegate = BubbleDialogDelegate* widget_delegate =
widget_->widget_delegate()->AsBubbleDialogDelegate(); widget_->widget_delegate()->AsBubbleDialogDelegate();
return widget_delegate ? widget_delegate->anchor_widget() : nullptr; return widget_delegate ? widget_delegate->anchor_widget() : nullptr;
} }
......
...@@ -203,7 +203,7 @@ View* FocusSearch::FindNextFocusableViewImpl( ...@@ -203,7 +203,7 @@ View* FocusSearch::FindNextFocusableViewImpl(
// Check to see if we should navigate into a dialog anchored at this view. // Check to see if we should navigate into a dialog anchored at this view.
if (can_go_into_anchored_dialog == if (can_go_into_anchored_dialog ==
AnchoredDialogPolicy::kCanGoIntoAnchoredDialog) { AnchoredDialogPolicy::kCanGoIntoAnchoredDialog) {
BubbleDialogDelegateView* bubble = BubbleDialogDelegate* bubble =
starting_view->GetProperty(kAnchoredDialogKey); starting_view->GetProperty(kAnchoredDialogKey);
if (bubble) { if (bubble) {
*focus_traversable = bubble->GetWidget()->GetFocusTraversable(); *focus_traversable = bubble->GetWidget()->GetFocusTraversable();
...@@ -230,8 +230,7 @@ View* FocusSearch::FindNextFocusableViewImpl( ...@@ -230,8 +230,7 @@ View* FocusSearch::FindNextFocusableViewImpl(
while (parent && parent != root_) { while (parent && parent != root_) {
if (can_go_into_anchored_dialog == if (can_go_into_anchored_dialog ==
AnchoredDialogPolicy::kCanGoIntoAnchoredDialog) { AnchoredDialogPolicy::kCanGoIntoAnchoredDialog) {
BubbleDialogDelegateView* bubble = BubbleDialogDelegate* bubble = parent->GetProperty(kAnchoredDialogKey);
parent->GetProperty(kAnchoredDialogKey);
if (bubble) { if (bubble) {
*focus_traversable = bubble->GetWidget()->GetFocusTraversable(); *focus_traversable = bubble->GetWidget()->GetFocusTraversable();
*focus_traversable_view = starting_view; *focus_traversable_view = starting_view;
...@@ -302,7 +301,7 @@ View* FocusSearch::FindPreviousFocusableViewImpl( ...@@ -302,7 +301,7 @@ View* FocusSearch::FindPreviousFocusableViewImpl(
// Check to see if we should navigate into a dialog anchored at this view. // Check to see if we should navigate into a dialog anchored at this view.
if (can_go_into_anchored_dialog == if (can_go_into_anchored_dialog ==
AnchoredDialogPolicy::kCanGoIntoAnchoredDialog) { AnchoredDialogPolicy::kCanGoIntoAnchoredDialog) {
BubbleDialogDelegateView* bubble = BubbleDialogDelegate* bubble =
starting_view->GetProperty(kAnchoredDialogKey); starting_view->GetProperty(kAnchoredDialogKey);
if (bubble) { if (bubble) {
*focus_traversable = bubble->GetWidget()->GetFocusTraversable(); *focus_traversable = bubble->GetWidget()->GetFocusTraversable();
......
...@@ -20,7 +20,7 @@ DEFINE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT, int) ...@@ -20,7 +20,7 @@ DEFINE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT, int)
DEFINE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT, gfx::Insets*) DEFINE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT, gfx::Insets*)
DEFINE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT, DEFINE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT,
views::BubbleDialogDelegateView*) views::BubbleDialogDelegate*)
DEFINE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT, DEFINE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT,
views::HighlightPathGenerator*) views::HighlightPathGenerator*)
...@@ -31,7 +31,7 @@ namespace views { ...@@ -31,7 +31,7 @@ namespace views {
DEFINE_UI_CLASS_PROPERTY_KEY(int, kHitTestComponentKey, HTNOWHERE) DEFINE_UI_CLASS_PROPERTY_KEY(int, kHitTestComponentKey, HTNOWHERE)
DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(gfx::Insets, kMarginsKey, nullptr) DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(gfx::Insets, kMarginsKey, nullptr)
DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(gfx::Insets, kInternalPaddingKey, nullptr) DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(gfx::Insets, kInternalPaddingKey, nullptr)
DEFINE_UI_CLASS_PROPERTY_KEY(views::BubbleDialogDelegateView*, DEFINE_UI_CLASS_PROPERTY_KEY(views::BubbleDialogDelegate*,
kAnchoredDialogKey, kAnchoredDialogKey,
nullptr) nullptr)
DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(views::HighlightPathGenerator, DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(views::HighlightPathGenerator,
......
...@@ -14,7 +14,7 @@ class Insets; ...@@ -14,7 +14,7 @@ class Insets;
namespace views { namespace views {
class BubbleDialogDelegateView; class BubbleDialogDelegate;
class FlexSpecification; class FlexSpecification;
class HighlightPathGenerator; class HighlightPathGenerator;
...@@ -41,7 +41,7 @@ VIEWS_EXPORT extern const ui::ClassProperty<gfx::Insets*>* const ...@@ -41,7 +41,7 @@ VIEWS_EXPORT extern const ui::ClassProperty<gfx::Insets*>* const
// A property to store the bubble dialog anchored to this view, to // A property to store the bubble dialog anchored to this view, to
// enable the bubble's contents to be included in the focus order. // enable the bubble's contents to be included in the focus order.
VIEWS_EXPORT extern const ui::ClassProperty<BubbleDialogDelegateView*>* const VIEWS_EXPORT extern const ui::ClassProperty<BubbleDialogDelegate*>* const
kAnchoredDialogKey; kAnchoredDialogKey;
// A property to store a highlight-path generator. This generator is used to // A property to store a highlight-path generator. This generator is used to
...@@ -63,7 +63,7 @@ VIEWS_EXPORT extern const ui::ClassProperty<FlexSpecification*>* const ...@@ -63,7 +63,7 @@ VIEWS_EXPORT extern const ui::ClassProperty<FlexSpecification*>* const
// translation unit is a C++ error. // translation unit is a C++ error.
DECLARE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT, gfx::Insets*) DECLARE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT, gfx::Insets*)
DECLARE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT, DECLARE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT,
views::BubbleDialogDelegateView*) views::BubbleDialogDelegate*)
DECLARE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT, DECLARE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT,
views::HighlightPathGenerator*) views::HighlightPathGenerator*)
DECLARE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT, views::FlexSpecification*) DECLARE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT, views::FlexSpecification*)
......
...@@ -46,7 +46,7 @@ View* WidgetDelegate::GetInitiallyFocusedView() { ...@@ -46,7 +46,7 @@ View* WidgetDelegate::GetInitiallyFocusedView() {
return nullptr; return nullptr;
} }
BubbleDialogDelegateView* WidgetDelegate::AsBubbleDialogDelegate() { BubbleDialogDelegate* WidgetDelegate::AsBubbleDialogDelegate() {
return nullptr; return nullptr;
} }
......
...@@ -20,7 +20,7 @@ class Rect; ...@@ -20,7 +20,7 @@ class Rect;
} // namespace gfx } // namespace gfx
namespace views { namespace views {
class BubbleDialogDelegateView; class BubbleDialogDelegate;
class ClientView; class ClientView;
class DialogDelegate; class DialogDelegate;
class NonClientFrameView; class NonClientFrameView;
...@@ -98,7 +98,7 @@ class VIEWS_EXPORT WidgetDelegate { ...@@ -98,7 +98,7 @@ class VIEWS_EXPORT WidgetDelegate {
// NULL no view is focused. // NULL no view is focused.
virtual View* GetInitiallyFocusedView(); virtual View* GetInitiallyFocusedView();
virtual BubbleDialogDelegateView* AsBubbleDialogDelegate(); virtual BubbleDialogDelegate* AsBubbleDialogDelegate();
virtual DialogDelegate* AsDialogDelegate(); virtual DialogDelegate* AsDialogDelegate();
// Returns true if the window can be resized. // Returns true if the window can be resized.
......
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