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