Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(523)

Unified Diff: components/constrained_window/native_web_contents_modal_dialog_manager_views.cc

Issue 2172363002: Created min size for print preview dialog and modified to allow the Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge ConstrainedWebDialog functions Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/constrained_window/native_web_contents_modal_dialog_manager_views.cc
diff --git a/components/constrained_window/native_web_contents_modal_dialog_manager_views.cc b/components/constrained_window/native_web_contents_modal_dialog_manager_views.cc
index 45e3a43e49088650c3d330cc1b27303e6fcf5329..b5c050b43aba7ec160510fcd9b6c55cdf80de294 100644
--- a/components/constrained_window/native_web_contents_modal_dialog_manager_views.cc
+++ b/components/constrained_window/native_web_contents_modal_dialog_manager_views.cc
@@ -9,6 +9,7 @@
#include "components/constrained_window/constrained_window_views.h"
#include "components/web_modal/web_contents_modal_dialog_host.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
+#include "ui/base/accelerators/accelerator.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/size.h"
#include "ui/views/border.h"
@@ -19,11 +20,22 @@
#if defined(USE_AURA)
#include "ui/aura/client/aura_constants.h"
+#include "ui/aura/client/window_parenting_client.h"
#include "ui/aura/window.h"
+#include "ui/aura/window_observer.h"
+#include "ui/aura/window_tree_host.h"
+#include "ui/aura/window_tree_host_observer.h"
+#include "ui/wm/core/transient_window_manager.h"
#include "ui/wm/core/visibility_controller.h"
#include "ui/wm/core/window_animations.h"
#include "ui/wm/core/window_modality_controller.h"
-#endif
+#include "ui/wm/core/window_util.h"
+#endif // USE_AURA
+
+#if defined(OS_CHROMEOS)
+#include "ash/aura/wm_window_aura.h"
+#include "ash/common/wm/window_state.h"
+#endif // OS_CHROMEOS
using web_modal::SingleWebContentsDialogManager;
using web_modal::SingleWebContentsDialogManagerDelegate;
@@ -35,26 +47,56 @@ namespace constrained_window {
NativeWebContentsModalDialogManagerViews::
NativeWebContentsModalDialogManagerViews(
gfx::NativeWindow dialog,
- SingleWebContentsDialogManagerDelegate* native_delegate)
+ SingleWebContentsDialogManagerDelegate* native_delegate,
+ bool is_toplevel,
+ ui::AcceleratorTarget* target)
: native_delegate_(native_delegate),
dialog_(dialog),
host_(NULL),
- host_destroying_(false) {
- ManageDialog();
+ host_destroying_(false),
+ target_(target) {
+#if !defined(USE_AURA)
+ target_ = nullptr;
+#endif
+ ManageDialog(is_toplevel);
}
NativeWebContentsModalDialogManagerViews::
~NativeWebContentsModalDialogManagerViews() {
if (host_)
host_->RemoveObserver(this);
-
+#if defined(USE_AURA)
+ if (host_ && host_->GetHostView() && host_->GetHostView()->HasObserver(this))
+ host_->GetHostView()->RemoveObserver(this);
+ if (host_ && host_->GetHostView() && host_->GetHostView()->GetHost())
+ host_->GetHostView()->GetHost()->RemoveObserver(this);
+ if (host_ && host_->GetHostView() && GetWidget(host_->GetHostView()))
+ GetWidget(host_->GetHostView())->RemoveObserver(this);
+ bool toplevel = false;
+#endif
for (std::set<views::Widget*>::iterator it = observed_widgets_.begin();
it != observed_widgets_.end(); ++it) {
+#if defined(USE_AURA)
+ if (!!(*it)->GetNativeWindowProperty(wm::kAllowTransientParentEventsKey)) {
+ toplevel = true;
+ }
+#endif
(*it)->RemoveObserver(this);
}
+#if defined(USE_AURA)
+ if (host_ && toplevel) {
+ views::Widget * parent_widget = views::Widget::GetWidgetForNativeView(
+ host_->GetHostView());
+ if (parent_widget && parent_widget->GetFocusManager()) {
+ parent_widget->GetFocusManager()->UnregisterAccelerator(
+ ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE), target_);
+ }
+ }
+#endif
}
-void NativeWebContentsModalDialogManagerViews::ManageDialog() {
+void NativeWebContentsModalDialogManagerViews::ManageDialog(
+ bool is_toplevel) {
views::Widget* widget = GetWidget(dialog());
widget->AddObserver(this);
observed_widgets_.insert(widget);
@@ -68,17 +110,30 @@ void NativeWebContentsModalDialogManagerViews::ManageDialog() {
wm::SetWindowVisibilityAnimationType(
widget->GetNativeWindow(), wm::WINDOW_VISIBILITY_ANIMATION_TYPE_ROTATE);
- gfx::NativeView parent = widget->GetNativeView()->parent();
- wm::SetChildWindowVisibilityChangesAnimated(parent);
- // No animations should get performed on the window since that will re-order
- // the window stack which will then cause many problems.
- if (parent && parent->parent()) {
- parent->parent()->SetProperty(aura::client::kAnimationsDisabledKey, true);
+ if (is_toplevel) {
+ gfx::NativeView transient_parent =
+ wm::GetTransientParent(widget->GetNativeWindow());
+ wm::SetChildWindowVisibilityChangesAnimated(
+ widget->GetNativeView()->parent());
+ if (transient_parent) {
+ transient_parent->SetProperty(
+ aura::client::kAnimationsDisabledKey, true);
+ }
+ widget->SetNativeWindowProperty(wm::kAllowTransientParentEventsKey,
+ reinterpret_cast<void*>(true));
+ } else {
+ gfx::NativeView parent = widget->GetNativeView()->parent();
+ wm::SetChildWindowVisibilityChangesAnimated(parent);
+ // No animations should get performed on the window since that will re-order
+ // the window stack which will then cause many problems.
+ if (parent && parent->parent()) {
+ parent->parent()->SetProperty(aura::client::kAnimationsDisabledKey, true);
+ }
+ wm::SetModalParent(widget->GetNativeWindow(),
+ native_delegate_->GetWebContents()->GetNativeView());
}
-
- wm::SetModalParent(widget->GetNativeWindow(),
- native_delegate_->GetWebContents()->GetNativeView());
-#endif
+ called_internal_ = true;
+#endif // defined(USE_AURA)
}
// SingleWebContentsDialogManager:
@@ -89,23 +144,40 @@ void NativeWebContentsModalDialogManagerViews::Show() {
// services may not be present.
if (host_destroying_)
return;
+#if defined(OS_CHROMEOS)
+ if (!called_internal_ && window_minimized_) {
+ need_to_show_ = true;
+ return;
+ }
+#endif
views::Widget* widget = GetWidget(dialog());
#if defined(USE_AURA)
- std::unique_ptr<wm::SuspendChildWindowVisibilityAnimations> suspend;
- if (shown_widgets_.find(widget) != shown_widgets_.end()) {
- suspend.reset(new wm::SuspendChildWindowVisibilityAnimations(
+#if defined(OS_WIN)
+ bool suspend_animation =
+ !(widget->GetNativeWindowProperty(wm::kAllowTransientParentEventsKey));
+#else
+ bool suspend_animation = true;
+#endif
+ if (suspend_animation) {
+ std::unique_ptr<wm::SuspendChildWindowVisibilityAnimations> suspend;
+ if (shown_widgets_.find(widget) != shown_widgets_.end()) {
+ suspend.reset(new wm::SuspendChildWindowVisibilityAnimations(
widget->GetNativeWindow()->parent()));
+ }
}
+ if (parent_inactive_ && window_minimized_)
+ parent_inactive_ = false;
#endif
ShowWidget(widget);
- Focus();
+ FocusInternal(widget);
#if defined(USE_AURA)
// TODO(pkotwicz): Control the z-order of the constrained dialog via
// views::kHostViewKey. We will need to ensure that the parent window's
// shadows are below the constrained dialog in z-order when we do this.
shown_widgets_.insert(widget);
+ called_internal_ = false;
#endif
}
@@ -115,6 +187,9 @@ void NativeWebContentsModalDialogManagerViews::Hide() {
std::unique_ptr<wm::SuspendChildWindowVisibilityAnimations> suspend;
suspend.reset(new wm::SuspendChildWindowVisibilityAnimations(
widget->GetNativeWindow()->parent()));
+ if (parent_inactive_ &&
+ !!(widget->GetNativeWindowProperty(wm::kAllowTransientParentEventsKey)))
+ window_minimized_ = true;
#endif
HideWidget(widget);
}
@@ -125,14 +200,11 @@ void NativeWebContentsModalDialogManagerViews::Close() {
void NativeWebContentsModalDialogManagerViews::Focus() {
views::Widget* widget = GetWidget(dialog());
- if (widget->widget_delegate() &&
- widget->widget_delegate()->GetInitiallyFocusedView())
- widget->widget_delegate()->GetInitiallyFocusedView()->RequestFocus();
#if defined(USE_AURA)
- // We don't necessarily have a RootWindow yet.
- if (widget->GetNativeView()->GetRootWindow())
- widget->GetNativeView()->Focus();
+ if (!!widget->GetNativeWindowProperty(wm::kAllowTransientParentEventsKey))
+ return;
#endif
+ FocusInternal(widget);
}
void NativeWebContentsModalDialogManagerViews::Pulse() {}
@@ -148,8 +220,31 @@ void NativeWebContentsModalDialogManagerViews::OnPositionRequiresUpdate() {
}
}
+void NativeWebContentsModalDialogManagerViews::
+ OnNonClippedPositionRequiresUpdate() {
+ DCHECK(host_);
+#if defined(USE_AURA)
+ for (std::set<views::Widget*>::iterator it = observed_widgets_.begin();
+ it != observed_widgets_.end(); ++it) {
+ if (!!((*it)->GetNativeWindowProperty(wm::kAllowTransientParentEventsKey)))
+ constrained_window::UpdateWebContentsModalDialogPosition(*it, host_);
+ }
+#endif
+}
+
void NativeWebContentsModalDialogManagerViews::OnHostDestroying() {
host_->RemoveObserver(this);
+#if defined(USE_AURA)
+ if (host_->GetHostView())
+ GetWidget(host_->GetHostView())->RemoveObserver(this);
+ if (host_->GetHostView() && host_->GetHostView()->HasObserver(this))
+ host_->GetHostView()->RemoveObserver(this);
+ if (host_->GetHostView() && host_->GetHostView()->GetHost())
+ host_->GetHostView()->GetHost()->RemoveObserver(this);
+ if (host_->GetHostView() &&
+ views::Widget::GetWidgetForNativeView(host_->GetHostView()))
+ GetWidget(host_->GetHostView())->RemoveObserver(this);
+#endif
host_ = NULL;
host_destroying_ = true;
}
@@ -158,31 +253,211 @@ void NativeWebContentsModalDialogManagerViews::OnHostDestroying() {
void NativeWebContentsModalDialogManagerViews::OnWidgetClosing(
views::Widget* widget) {
- WidgetClosing(widget);
+#if defined(USE_AURA)
+ bool widget_is_host = host_ &&
+ widget == views::Widget::GetWidgetForNativeView(host_->GetHostView());
+#else
+ bool widget_is_host = false;
+#endif
+ if (!widget_is_host)
+ WidgetClosing(widget);
}
void NativeWebContentsModalDialogManagerViews::OnWidgetDestroying(
views::Widget* widget) {
- WidgetClosing(widget);
+#if defined(USE_AURA)
+ bool widget_is_host = host_ &&
+ widget == views::Widget::GetWidgetForNativeView(host_->GetHostView());
+#else
+ bool widget_is_host = false;
+#endif
+ if (!widget_is_host)
+ WidgetClosing(widget);
+}
+
+#if defined(USE_AURA)
+void NativeWebContentsModalDialogManagerViews::OnWidgetActivationChanged(
+ views::Widget* widget, bool active) {
+ if (!host_ || host_changing_)
+ return;
+#if !defined(OS_CHROMEOS)
+ if (active && widget != GetWidget(dialog())) {
+ for (std::set<views::Widget*>::iterator it = observed_widgets_.begin();
+ it != observed_widgets_.end(); ++it) {
+ if (!!((*it)->GetNativeWindowProperty(
+ wm::kAllowTransientParentEventsKey))) {
+ if ((*it)->IsVisible())
+ (*it)->StackAtTop();
+ }
+ }
+ }
+#else
+ // This prevents the widget from activating too early and ensures it does
+ // reappear after the parent is restored. Otherwise, a crash occurs due to
+ // trying to focus a non-child of the active dialog while activation change
+ // observers are still shifting the focus.
+
+ // If the widget is active but the parent has become inactive, note that
+ // parent is inactive in case the window is minimized.
+ if (widget == GetWidget(host_->GetHostView()) && !active) {
+ if (GetWidget(dialog())->IsActive())
+ parent_inactive_ = true;
+ }
+
+ // Set window minimized
+ if (!GetWidget(host_->GetHostView())->IsActive() &&
+ !GetWidget(dialog())->IsActive()) {
+ window_minimized_ |= ash::WmWindowAura::Get(
+ host_->GetHostView())->GetWindowState()->IsMinimized();
+ }
+
+ // Host view reactivated, widget deactivated. Update stacking if necessary
+ // and update booleans.
+ if (GetWidget(dialog()) == widget && !active &&
+ GetWidget(host_->GetHostView())->IsActive()) {
+ StackWidgetAtTop(GetWidget(dialog()));
+ if (window_minimized_ && !parent_inactive_) {
+ // If the window was minimized, we need to restore it, and add the dialog
+ // on the next restack.
+ show_on_next_stack_ = true;
+ } else if (window_minimized_) {
+ // if the host reactivated from the dialog and the parent was just
+ // inactive, the window isn't minimized.
+ window_minimized_ = false;
+ }
+ // Host is now active.
+ parent_inactive_ = false;
+ } else if (widget == GetWidget(host_->GetHostView()) && active) {
+ parent_inactive_ = false;
+ // If window was minimized, show the dialog on the next restack.
+ if (window_minimized_) {
+ show_on_next_stack_ = true;
+ }
+ }
+#endif
}
+#endif
void NativeWebContentsModalDialogManagerViews::HostChanged(
WebContentsModalDialogHost* new_host) {
+#if defined(USE_AURA)
+ host_changing_ = true;
+ if (new_host == host_ ||
+ (new_host && !new_host->GetHostView()->GetRootWindow()))
+ // This happens sometimes in testing and will cause a crash.
+ return;
+#endif
if (host_)
host_->RemoveObserver(this);
- host_ = new_host;
+ bool toplevel = false;
+ // Remove window observer
+#if defined(USE_AURA)
+ if (host_ && host_->GetHostView() && host_->GetHostView()->HasObserver(this))
+ host_->GetHostView()->RemoveObserver(this);
+ // Check if there are top level widgets.
+ if (host_ && host_->GetHostView() && host_->GetHostView()->parent()) {
+ for (std::set<views::Widget*>::iterator it = observed_widgets_.begin();
+ it != observed_widgets_.end(); ++it) {
+ if (!!((*it)->GetNativeWindowProperty(
+ wm::kAllowTransientParentEventsKey)))
+ toplevel = true;
+ }
+ }
+
+ if (host_ && host_->GetHostView() && toplevel) {
+ // Remove observers.
+ if (host_->GetHostView()->GetHost())
+ host_->GetHostView()->GetHost()->RemoveObserver(this);
+ views::Widget * parent_widget = views::Widget::GetWidgetForNativeView(
+ host_->GetHostView());
+ if (parent_widget)
+ parent_widget->RemoveObserver(this);
+
+ // Unregister the accelerator
+ if (parent_widget && parent_widget->GetFocusManager()) {
+ parent_widget->GetFocusManager()->UnregisterAccelerator(
+ ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE), target_);
+ }
+
+ // Clear animations disabled
+ if (host_->GetHostView()->parent())
+ host_->GetHostView()->parent()->ClearProperty(
+ aura::client::kAnimationsDisabledKey);
+ }
+#endif
+
+ host_ = new_host;
+ toplevel = false;
// |host_| may be null during WebContents destruction or Win32 tab dragging.
if (host_) {
host_->AddObserver(this);
for (std::set<views::Widget*>::iterator it = observed_widgets_.begin();
it != observed_widgets_.end(); ++it) {
- views::Widget::ReparentNativeView((*it)->GetNativeView(),
- host_->GetHostView());
+#if defined(USE_AURA)
+ bool widget_toplevel = !!((*it)->GetNativeWindowProperty(
+ wm::kAllowTransientParentEventsKey));
+#else
+ bool widget_toplevel = false;
+#endif
+ if (widget_toplevel) {
+#if defined(USE_AURA)
+ toplevel = true;
+#if !defined(OS_WIN)
+ if ((*it)->GetNativeView()->parent())
+ (*it)->GetNativeView()->parent()->RemoveChild((*it)->GetNativeView());
+ wm::AddTransientChild(host_->GetHostView()->parent(),
+ (*it)->GetNativeView());
+ aura::client::ParentWindowWithContext(
+ (*it)->GetNativeView(),
+ host_->GetHostView()->parent()->GetRootWindow(),
+ (*it)->GetNativeView()->bounds());
+ if (host_->GetHostView()->parent()) {
+ host_->GetHostView()->parent()->SetProperty(
+ aura::client::kAnimationsDisabledKey, true);
+ }
+#else
+ wm::AddTransientChild(host_->GetHostView(),
+ (*it)->GetNativeView());
+#endif
+#endif
+ } else {
+ views::Widget::ReparentNativeView((*it)->GetNativeView(),
+ host_->GetHostView());
+ }
}
-
+#if defined(USE_AURA)
+ // If there are top level widgets, need to register the accelerator and set
+ // the window observed_widgets_
+ if (toplevel) {
+ // Add window observer
+ host_->GetHostView()->AddObserver(this);
+ // Add host observer
+ if (host_->GetHostView()->GetHost())
+ host_->GetHostView()->GetHost()->AddObserver(this);
+ // Register accelerator
+ views::Widget * parent_widget = views::Widget::GetWidgetForNativeView(
+ host_->GetHostView());
+ if (parent_widget)
+ parent_widget->AddObserver(this);
+ parent_widget->GetFocusManager()->RegisterAccelerator(
+ ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE),
+ ui::AcceleratorManager::kNormalPriority, target_);
+ // Set animations disabled
+ if (host_->GetHostView()->parent()) {
+ host_->GetHostView()->parent()->SetProperty(
+ aura::client::kAnimationsDisabledKey, true);
+ }
+ parent_widget->StackAtTop();
+ }
+ // Reset all of these
+ window_minimized_ = false;
+ parent_inactive_ = false;
+ show_on_next_stack_ = false;
+ host_changing_ = false;
+#endif
OnPositionRequiresUpdate();
}
}
@@ -204,6 +479,18 @@ void NativeWebContentsModalDialogManagerViews::HideWidget(
widget->Hide();
}
+void NativeWebContentsModalDialogManagerViews::FocusInternal(
+ views::Widget* widget) {
+ if (widget->widget_delegate() &&
+ widget->widget_delegate()->GetInitiallyFocusedView())
+ widget->widget_delegate()->GetInitiallyFocusedView()->RequestFocus();
+#if defined(USE_AURA)
+ // We don't necessarily have a RootWindow yet.
+ if (widget->GetNativeView()->GetRootWindow())
+ widget->GetNativeView()->Focus();
+#endif
+}
+
views::Widget* NativeWebContentsModalDialogManagerViews::GetWidget(
gfx::NativeWindow dialog) {
views::Widget* widget = views::Widget::GetWidgetForNativeWindow(dialog);
@@ -214,20 +501,157 @@ views::Widget* NativeWebContentsModalDialogManagerViews::GetWidget(
void NativeWebContentsModalDialogManagerViews::WidgetClosing(
views::Widget* widget) {
#if defined(USE_AURA)
- gfx::NativeView view = widget->GetNativeView()->parent();
- // Allow the parent to animate again.
- if (view && view->parent())
- view->parent()->ClearProperty(aura::client::kAnimationsDisabledKey);
+ if (!!widget->GetNativeWindowProperty(wm::kAllowTransientParentEventsKey)) {
+ if (host_ && host_->GetHostView() && !host_destroying_) {
+ gfx::NativeWindow parent = host_->GetHostView()->parent();
+ if (parent)
+ parent->ClearProperty(aura::client::kAnimationsDisabledKey);
+ }
+ } else {
+ gfx::NativeView view = widget->GetNativeView()->parent();
+ // Allow the parent to animate again.
+ if (view && view->parent())
+ view->parent()->ClearProperty(aura::client::kAnimationsDisabledKey);
+ }
#endif
widget->RemoveObserver(this);
observed_widgets_.erase(widget);
#if defined(USE_AURA)
shown_widgets_.erase(widget);
+#if !defined(OS_WIN)
+ if (host_ && !!widget->GetNativeWindowProperty(
+ wm::kAllowTransientParentEventsKey))
+ wm::RemoveTransientChild(host_->GetHostView()->parent(),
+ widget->GetNativeView());
+#endif
#endif
// Will cause this object to be deleted.
native_delegate_->WillClose(widget->GetNativeWindow());
}
+#if defined(USE_AURA)
+void NativeWebContentsModalDialogManagerViews::OnWindowBoundsChanged(
+ aura::Window* window,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) {
+ if (window != host_->GetHostView())
+ return;
+ OnNonClippedPositionRequiresUpdate();
+ if (GetWidget(dialog())->IsVisible()){
+ GetWidget(dialog())->StackAtTop();
+ Show();
+ }
+}
+
+void NativeWebContentsModalDialogManagerViews::OnWindowDestroying(
+ aura::Window* window) {
+ window->RemoveObserver(this);
+}
+
+void NativeWebContentsModalDialogManagerViews::OnWindowStackingChanged(
+ aura::Window* window) {
+ // Can't stack if host is currently null or the wrong window was restacked
+ if (!host_ || window != host_->GetHostView())
+ return;
+ // Unless we are calling Show(), don't restack dialogs that are hidden.
+ if (!show_on_next_stack_ && !dialog()->TargetVisibility())
+ return;
+ // Can't stack if window has no parent.
+ if (!window->parent())
+ return;
+
+ for (std::set<views::Widget*>::iterator it = shown_widgets_.begin();
+ it != shown_widgets_.end(); ++it) {
+ if (views::Widget::GetWidgetForNativeView(window) &&
+ window->parent() == wm::GetTransientParent((*it)->GetNativeView()) &&
+ !!((*it)->GetNativeWindowProperty(wm::kAllowTransientParentEventsKey)))
+ {
+ if (window->parent()->children().empty() ||
+ (window->parent()->children().back() == (*it)->GetNativeView()))
+ // Already stacked correctly, continue.
+ continue;
+ StackWidgetAtTop((*it));
+ if (window_minimized_ && show_on_next_stack_ &&
+ GetWidget(host_->GetHostView())->IsVisible() && need_to_show_) {
+ // Call show here, as the web contents are done loading and
+ // there will not be a DCHECK crash from trying to focus the dialog.
+ called_internal_ = true;
+ Show();
+ window_minimized_ = false;
+ show_on_next_stack_ = false;
+ need_to_show_ = false;
+ } else if (window_minimized_ && show_on_next_stack_) {
+ called_internal_ = true;
+ }
+ }
+ }
+}
+
+void NativeWebContentsModalDialogManagerViews::OnWindowParentChanged(
+ aura::Window* window, aura::Window* parent) {
+ if (!host_ || !parent || window != host_->GetHostView())
+ return;
+
+ bool has_visibility = false;
+ for (std::set<views::Widget*>::iterator it = observed_widgets_.begin();
+ it != observed_widgets_.end(); ++it) {
+ if (!!((*it)->GetNativeWindowProperty(wm::kAllowTransientParentEventsKey)))
+ {
+ aura::Window * nativeView = (*it)->GetNativeView();
+ if (parent != wm::GetTransientParent(nativeView))
+ wm::AddTransientChild(host_->GetHostView()->parent(), nativeView);
+ has_visibility |= nativeView->TargetVisibility();
+ }
+ }
+ if (has_visibility) {
+ called_internal_ = true;
+#if !defined(OS_WIN)
+ Show();
+#endif
+ }
+}
+
+void NativeWebContentsModalDialogManagerViews::StackWidgetAtTop(
+ views::Widget* widget) {
+ aura::Window* transient_parent = wm::GetTransientParent(
+ widget->GetNativeView());
+ while (transient_parent) {
+ if (transient_parent->parent())
+ transient_parent->parent()->StackChildAtTop(transient_parent);
+ transient_parent = wm::GetTransientParent(transient_parent);
+ }
+ if (!host_ || !host_->GetHostView() || !widget->GetNativeView()->parent() ||
+ widget->GetNativeView() == host_->GetHostView())
+ return;
+ if (widget->GetNativeView()->parent() == host_->GetHostView()->parent()) {
+ widget->GetNativeView()->parent()->StackChildAbove(widget->GetNativeView(),
+ host_->GetHostView());
+ } else {
+ widget->GetNativeView()->parent()->StackChildAtTop(widget->GetNativeView());
+ }
+}
+
+void NativeWebContentsModalDialogManagerViews::OnHostMovedInPixels(
+ const aura::WindowTreeHost* host, const gfx::Point& new_origin_in_pixels) {
+ if (!host_ || host_changing_ || host != host_->GetHostView()->GetHost())
+ return;
+ views::Widget* parent_widget =
+ views::Widget::GetWidgetForNativeView(host_->GetHostView());
+ parent_widget->StackAtTop();
+
+ OnNonClippedPositionRequiresUpdate();
+ for (std::set<views::Widget*>::iterator it = observed_widgets_.begin();
+ it != observed_widgets_.end(); ++it) {
+ if (!!((*it)->GetNativeWindowProperty(wm::kAllowTransientParentEventsKey)))
+ {
+ if ((*it)->IsVisible()){
+ (*it)->StackAtTop();
+ Show();
+ }
+ }
+ }
+}
+#endif // defined(USE_AURA)
} // namespace constrained_window

Powered by Google App Engine
This is Rietveld 408576698