Commit 7aa2519f authored by yiyix's avatar yiyix Committed by Commit bot

Update window_parenting_utils to use aura::window instead of WmWindow.

BUG=687657

Review-Url: https://codereview.chromium.org/2737213002
Cr-Commit-Position: refs/heads/master@{#456080}
parent 6c77b2f4
......@@ -701,8 +701,9 @@ void DefaultState::UpdateBoundsFromState(WindowState* window_state,
WmWindow* docked_container =
window->GetRootWindow()->GetChildByShellWindowId(
kShellWindowId_DockedContainer);
ReparentChildWithTransientChildren(window, window->GetParent(),
docked_container);
ReparentChildWithTransientChildren(window->aura_window(),
window->aura_window()->parent(),
docked_container->aura_window());
}
// Return early because we don't want to update the bounds of the
// window below; as the bounds are managed by the dock layout.
......
......@@ -25,6 +25,7 @@
#include "base/auto_reset.h"
#include "base/metrics/histogram_macros.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/aura/window.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/display/display.h"
......@@ -181,11 +182,11 @@ bool IsWindowDocked(const WmWindow* window) {
void UndockWindow(WmWindow* window) {
gfx::Rect previous_bounds = window->GetBounds();
WmWindow* old_parent = window->GetParent();
aura::Window* old_parent = window->aura_window()->parent();
window->SetParentUsingContext(window, gfx::Rect());
if (window->GetParent() != old_parent) {
wm::ReparentTransientChildrenOfChild(window, old_parent,
window->GetParent());
if (window->aura_window()->parent() != old_parent) {
wm::ReparentTransientChildrenOfChild(window->aura_window(), old_parent,
window->aura_window()->parent());
}
// Start maximize or fullscreen (affecting packaged apps) animation from
// previous window bounds.
......
......@@ -188,8 +188,9 @@ void DockedWindowResizer::StartedDragging(
WmWindow* docked_container =
GetTarget()->GetRootWindow()->GetChildByShellWindowId(
kShellWindowId_DockedContainer);
wm::ReparentChildWithTransientChildren(
GetTarget(), GetTarget()->GetParent(), docked_container);
wm::ReparentChildWithTransientChildren(GetTarget()->aura_window(),
GetTarget()->aura_window()->parent(),
docked_container->aura_window());
if (!resizer)
return;
}
......@@ -266,8 +267,9 @@ DockedAction DockedWindowResizer::MaybeReparentWindowOnDragCompletion(
if ((is_resized || !is_attached_panel) &&
is_docked_ != (window->GetParent() == dock_container)) {
if (is_docked_) {
wm::ReparentChildWithTransientChildren(window, window->GetParent(),
dock_container);
wm::ReparentChildWithTransientChildren(window->aura_window(),
window->aura_window()->parent(),
dock_container->aura_window());
action = DOCKED_ACTION_DOCK;
} else if (window->GetParent()->GetShellWindowId() ==
kShellWindowId_DockedContainer) {
......@@ -279,11 +281,12 @@ DockedAction DockedWindowResizer::MaybeReparentWindowOnDragCompletion(
// mouse is).
gfx::Rect near_last_location(last_location_, gfx::Size());
// Reparenting will cause Relayout and possible dock shrinking.
WmWindow* previous_parent = window->GetParent();
aura::Window* previous_parent = window->aura_window()->parent();
window->SetParentUsingContext(window, near_last_location);
if (window->GetParent() != previous_parent) {
wm::ReparentTransientChildrenOfChild(window, previous_parent,
window->GetParent());
if (window->aura_window()->parent() != previous_parent) {
wm::ReparentTransientChildrenOfChild(window->aura_window(),
previous_parent,
window->aura_window()->parent());
}
action = was_docked_ ? DOCKED_ACTION_UNDOCK : DOCKED_ACTION_NONE;
}
......
......@@ -348,10 +348,11 @@ void PanelLayoutManager::OnWindowAddedToLayout(WmWindow* child) {
// back to appropriate container and ignore it.
// TODO(varkha): Updating bounds during a drag can cause problems and a more
// general solution is needed. See http://crbug.com/251813 .
WmWindow* old_parent = child->GetParent();
aura::Window* old_parent = child->aura_window()->parent();
child->SetParentUsingContext(child,
child->GetRootWindow()->GetBoundsInScreen());
wm::ReparentTransientChildrenOfChild(child, old_parent, child->GetParent());
wm::ReparentTransientChildrenOfChild(child->aura_window(), old_parent,
child->aura_window()->parent());
DCHECK(child->GetParent()->GetShellWindowId() !=
kShellWindowId_PanelContainer);
return;
......
......@@ -161,11 +161,11 @@ void PanelWindowResizer::StartedDragging() {
// We use root window coordinates to ensure that during the drag the panel
// is reparented to a container in the root window that has that window.
WmWindow* target_root = target->GetRootWindow();
WmWindow* old_parent = target->GetParent();
aura::Window* old_parent = target->aura_window()->parent();
target->SetParentUsingContext(target_root,
target_root->GetBoundsInScreen());
wm::ReparentTransientChildrenOfChild(target, old_parent,
target->GetParent());
wm::ReparentTransientChildrenOfChild(target->aura_window(), old_parent,
target->aura_window()->parent());
}
}
......@@ -180,11 +180,11 @@ void PanelWindowResizer::FinishDragging() {
// is reparented to a container in the root window that has that location.
WmWindow* target = GetTarget();
WmWindow* target_root = target->GetRootWindow();
WmWindow* old_parent = target->GetParent();
aura::Window* old_parent = target->aura_window()->parent();
target->SetParentUsingContext(target_root,
gfx::Rect(last_location_, gfx::Size()));
wm::ReparentTransientChildrenOfChild(target, old_parent,
target->GetParent());
target_root->GetBoundsInScreen());
wm::ReparentTransientChildrenOfChild(target->aura_window(), old_parent,
target->aura_window()->parent());
}
// If we started the drag in one root window and moved into another root
......
......@@ -4,23 +4,26 @@
#include "ash/common/wm/window_parenting_utils.h"
#include "ash/common/wm_window.h"
#include "ui/aura/window.h"
#include "ui/wm/core/window_util.h"
using aura::Window;
namespace ash {
namespace wm {
void ReparentChildWithTransientChildren(WmWindow* child,
WmWindow* old_parent,
WmWindow* new_parent) {
if (child->GetParent() == old_parent)
void ReparentChildWithTransientChildren(Window* child,
Window* old_parent,
Window* new_parent) {
if (child->parent() == old_parent)
new_parent->AddChild(child);
ReparentTransientChildrenOfChild(child, old_parent, new_parent);
}
void ReparentTransientChildrenOfChild(WmWindow* child,
WmWindow* old_parent,
WmWindow* new_parent) {
for (WmWindow* transient_child : child->GetTransientChildren())
void ReparentTransientChildrenOfChild(Window* child,
Window* old_parent,
Window* new_parent) {
for (Window* transient_child : ::wm::GetTransientChildren(child))
ReparentChildWithTransientChildren(transient_child, old_parent, new_parent);
}
......
......@@ -5,24 +5,26 @@
#ifndef ASH_COMMON_WM_WINDOW_PARENTING_UTILS_H_
#define ASH_COMMON_WM_WINDOW_PARENTING_UTILS_H_
namespace ash {
namespace aura {
class Window;
}
class WmWindow;
namespace ash {
namespace wm {
// Changes the parent of a |child| and all its transient children that are
// themselves children of |old_parent| to |new_parent|.
void ReparentChildWithTransientChildren(WmWindow* child,
WmWindow* old_parent,
WmWindow* new_parent);
void ReparentChildWithTransientChildren(aura::Window* child,
aura::Window* old_parent,
aura::Window* new_parent);
// Changes the parent of all transient children of a |child| to |new_parent|.
// Does not change parent of the transient children that are not themselves
// children of |old_parent|.
void ReparentTransientChildrenOfChild(WmWindow* child,
WmWindow* old_parent,
WmWindow* new_parent);
void ReparentTransientChildrenOfChild(aura::Window* child,
aura::Window* old_parent,
aura::Window* new_parent);
} // namespace wm
} // namespace ash
......
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