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

Unified Diff: ash/wm/workspace/workspace_window_resizer.cc

Issue 127053005: Cleanup: remove Details::window. Use GetTarget() when possible (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months 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: ash/wm/workspace/workspace_window_resizer.cc
diff --git a/ash/wm/workspace/workspace_window_resizer.cc b/ash/wm/workspace/workspace_window_resizer.cc
index eea0811e770c305a9491d64e994dbfb59fd1b994..56718e198b0d7497fe15dfa2ccff009cac0464c3 100644
--- a/ash/wm/workspace/workspace_window_resizer.cc
+++ b/ash/wm/workspace/workspace_window_resizer.cc
@@ -386,7 +386,7 @@ void WorkspaceWindowResizer::Drag(const gfx::Point& location_in_parent,
if (window_state()->IsNormalShowState())
AdjustBoundsForMainWindow(sticky_size, &bounds);
- if (bounds != window()->bounds()) {
+ if (bounds != GetTarget()->bounds()) {
if (!did_move_or_resize_) {
if (!details_.restore_bounds.IsEmpty())
window_state()->ClearRestoreBounds();
@@ -396,7 +396,7 @@ void WorkspaceWindowResizer::Drag(const gfx::Point& location_in_parent,
}
gfx::Point location_in_screen = location_in_parent;
- wm::ConvertPointToScreen(window()->parent(), &location_in_screen);
+ wm::ConvertPointToScreen(GetTarget()->parent(), &location_in_screen);
aura::Window* root = NULL;
gfx::Display display =
@@ -409,17 +409,17 @@ void WorkspaceWindowResizer::Drag(const gfx::Point& location_in_parent,
}
if (!attached_windows_.empty())
LayoutAttachedWindows(&bounds);
- if (bounds != window()->bounds()) {
+ if (bounds != GetTarget()->bounds()) {
// SetBounds needs to be called to update the layout which affects where the
// phantom window is drawn. Keep track if the window was destroyed during
// the drag and quit early if so.
base::WeakPtr<WorkspaceWindowResizer> resizer(
weak_ptr_factory_.GetWeakPtr());
- window()->SetBounds(bounds);
+ GetTarget()->SetBounds(bounds);
if (!resizer)
return;
}
- const bool in_original_root = !root || root == window()->GetRootWindow();
+ const bool in_original_root = !root || root == GetTarget()->GetRootWindow();
// Hide a phantom window for snapping if the cursor is in another root window.
if (in_original_root) {
UpdateSnapPhantomWindow(location_in_parent, bounds);
@@ -444,13 +444,13 @@ void WorkspaceWindowResizer::CompleteDrag() {
// out of a maximized window, it's already in the normal show state when this
// is called, so it does not matter.
if (window_state()->IsNormalShowState() &&
- (window()->type() != ui::wm::WINDOW_TYPE_PANEL ||
+ (GetTarget()->type() != ui::wm::WINDOW_TYPE_PANEL ||
!window_state()->panel_attached() ||
dock_layout_->is_dragged_window_docked()) &&
(snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT)) {
if (!window_state()->HasRestoreBounds()) {
gfx::Rect initial_bounds = ScreenAsh::ConvertRectToScreen(
- window()->parent(), details_.initial_bounds_in_parent);
+ GetTarget()->parent(), details_.initial_bounds_in_parent);
window_state()->SetRestoreBoundsInScreen(
details_.restore_bounds.IsEmpty() ?
initial_bounds :
@@ -474,7 +474,7 @@ void WorkspaceWindowResizer::RevertDrag() {
if (!did_move_or_resize_)
return;
- window()->SetBounds(details_.initial_bounds_in_parent);
+ GetTarget()->SetBounds(details_.initial_bounds_in_parent);
if (!details_.restore_bounds.IsEmpty()) {
window_state()->SetRestoreBoundsInScreen(details_.restore_bounds);
}
@@ -501,7 +501,7 @@ void WorkspaceWindowResizer::RevertDrag() {
}
aura::Window* WorkspaceWindowResizer::GetTarget() {
varkha 2014/01/08 23:46:56 Should this be const (and virtual OVERRIDE)?
- return details_.window;
+ return details_.window();
}
const gfx::Point& WorkspaceWindowResizer::GetInitialLocation() const {
@@ -534,7 +534,7 @@ WorkspaceWindowResizer::WorkspaceWindowResizer(
}
aura::Window* dock_container = Shell::GetContainer(
- window()->GetRootWindow(), kShellWindowId_DockedContainer);
+ GetTarget()->GetRootWindow(), kShellWindowId_DockedContainer);
dock_layout_ = static_cast<DockedWindowLayoutManager*>(
dock_container->layout_manager());
@@ -573,7 +573,7 @@ gfx::Rect WorkspaceWindowResizer::GetFinalBounds(
void WorkspaceWindowResizer::LayoutAttachedWindows(
gfx::Rect* bounds) {
- gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(window()));
+ gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(GetTarget()));
int initial_size = PrimaryAxisSize(details_.initial_bounds_in_parent.size());
int current_size = PrimaryAxisSize(bounds->size());
int start = PrimaryAxisCoordinate(bounds->right(), bounds->bottom());
@@ -713,11 +713,11 @@ void WorkspaceWindowResizer::CreateBucketsForAttached(
void WorkspaceWindowResizer::MagneticallySnapToOtherWindows(gfx::Rect* bounds) {
if (UpdateMagnetismWindow(*bounds, kAllMagnetismEdges)) {
gfx::Point point = OriginForMagneticAttach(
- ScreenAsh::ConvertRectToScreen(window()->parent(), *bounds),
+ ScreenAsh::ConvertRectToScreen(GetTarget()->parent(), *bounds),
magnetism_window_->GetBoundsInScreen(),
magnetism_edge_);
- aura::client::GetScreenPositionClient(window()->GetRootWindow())->
- ConvertPointFromScreen(window()->parent(), &point);
+ aura::client::GetScreenPositionClient(GetTarget()->GetRootWindow())->
+ ConvertPointFromScreen(GetTarget()->parent(), &point);
bounds->set_origin(point);
}
}
@@ -727,9 +727,9 @@ void WorkspaceWindowResizer::MagneticallySnapResizeToOtherWindows(
const uint32 edges = WindowComponentToMagneticEdge(details_.window_component);
if (UpdateMagnetismWindow(*bounds, edges)) {
*bounds = ScreenAsh::ConvertRectFromScreen(
- window()->parent(),
+ GetTarget()->parent(),
BoundsForMagneticResizeAttach(
- ScreenAsh::ConvertRectToScreen(window()->parent(), *bounds),
+ ScreenAsh::ConvertRectToScreen(GetTarget()->parent(), *bounds),
magnetism_window_->GetBoundsInScreen(),
magnetism_edge_));
}
@@ -739,7 +739,7 @@ bool WorkspaceWindowResizer::UpdateMagnetismWindow(const gfx::Rect& bounds,
uint32 edges) {
// |bounds| are in coordinates of original window's parent.
gfx::Rect bounds_in_screen =
- ScreenAsh::ConvertRectToScreen(window()->parent(), bounds);
+ ScreenAsh::ConvertRectToScreen(GetTarget()->parent(), bounds);
MagnetismMatcher matcher(bounds_in_screen, edges);
// If we snapped to a window then check it first. That way we don't bounce
@@ -769,7 +769,7 @@ bool WorkspaceWindowResizer::UpdateMagnetismWindow(const gfx::Rect& bounds,
for (aura::Window::Windows::const_reverse_iterator i = children.rbegin();
i != children.rend() && !matcher.AreEdgesObscured(); ++i) {
wm::WindowState* other_state = wm::GetWindowState(*i);
- if (other_state->window() == window() ||
+ if (other_state->window() == GetTarget() ||
!other_state->window()->IsVisible() ||
!other_state->IsNormalShowState() ||
!other_state->CanResize()) {
@@ -790,11 +790,12 @@ void WorkspaceWindowResizer::AdjustBoundsForMainWindow(
int sticky_size,
gfx::Rect* bounds) {
gfx::Point last_mouse_location_in_screen = last_mouse_location_;
- wm::ConvertPointToScreen(window()->parent(), &last_mouse_location_in_screen);
+ wm::ConvertPointToScreen(GetTarget()->parent(),
+ &last_mouse_location_in_screen);
gfx::Display display = Shell::GetScreen()->GetDisplayNearestPoint(
last_mouse_location_in_screen);
- gfx::Rect work_area =
- ScreenAsh::ConvertRectFromScreen(window()->parent(), display.work_area());
+ gfx::Rect work_area = ScreenAsh::ConvertRectFromScreen(GetTarget()->parent(),
+ display.work_area());
if (details_.window_component == HTCAPTION) {
// Adjust the bounds to the work area where the mouse cursor is located.
// Always keep kMinOnscreenHeight or the window height (whichever is less)
@@ -926,7 +927,7 @@ void WorkspaceWindowResizer::UpdateSnapPhantomWindow(const gfx::Point& location,
return;
}
}
- const bool can_dock = dock_layout_->CanDockWindow(window(), snap_type_);
+ const bool can_dock = dock_layout_->CanDockWindow(GetTarget(), snap_type_);
const bool can_snap = window_state()->CanSnap();
if (!can_snap && !can_dock) {
snap_type_ = SNAP_NONE;
@@ -952,7 +953,8 @@ void WorkspaceWindowResizer::UpdateSnapPhantomWindow(const gfx::Point& location,
gfx::Rect phantom_bounds;
if (can_snap &&
(!can_dock ||
- window()->bounds().width() > DockedWindowLayoutManager::kMaxDockWidth))
+ GetTarget()->bounds().width() >
+ DockedWindowLayoutManager::kMaxDockWidth))
phantom_bounds = snap_sizer_->target_bounds();
const bool should_dock = can_dock &&
(phantom_bounds.IsEmpty() ||
@@ -962,7 +964,7 @@ void WorkspaceWindowResizer::UpdateSnapPhantomWindow(const gfx::Point& location,
snap_type_ = GetSnapType(location);
if (dock_layout_->is_dragged_window_docked()) {
phantom_bounds = ScreenAsh::ConvertRectFromScreen(
- window()->parent(), dock_layout_->dragged_bounds());
+ GetTarget()->parent(), dock_layout_->dragged_bounds());
}
if (phantom_bounds.IsEmpty()) {
@@ -972,10 +974,10 @@ void WorkspaceWindowResizer::UpdateSnapPhantomWindow(const gfx::Point& location,
if (!snap_phantom_window_controller_) {
snap_phantom_window_controller_.reset(
- new PhantomWindowController(window()));
+ new PhantomWindowController(GetTarget()));
}
snap_phantom_window_controller_->Show(ScreenAsh::ConvertRectToScreen(
- window()->parent(), phantom_bounds));
+ GetTarget()->parent(), phantom_bounds));
}
void WorkspaceWindowResizer::RestackWindows() {
@@ -985,10 +987,10 @@ void WorkspaceWindowResizer::RestackWindows() {
// window with a different parent.
typedef std::map<size_t, aura::Window*> IndexToWindowMap;
IndexToWindowMap map;
- aura::Window* parent = window()->parent();
+ aura::Window* parent = GetTarget()->parent();
const aura::Window::Windows& windows(parent->children());
- map[std::find(windows.begin(), windows.end(), window()) -
- windows.begin()] = window();
+ map[std::find(windows.begin(), windows.end(), GetTarget()) -
+ windows.begin()] = GetTarget();
for (std::vector<aura::Window*>::const_iterator i =
attached_windows_.begin(); i != attached_windows_.end(); ++i) {
if ((*i)->parent() != parent)
@@ -1013,11 +1015,11 @@ SnapType WorkspaceWindowResizer::GetSnapType(
const gfx::Point& location) const {
// TODO: this likely only wants total display area, not the area of a single
// display.
- gfx::Rect area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(window()));
+ gfx::Rect area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(GetTarget()));
if (details_.source == aura::client::WINDOW_MOVE_SOURCE_TOUCH) {
// Increase tolerance for touch-snapping near the screen edges. This is only
// necessary when the work area left or right edge is same as screen edge.
- gfx::Rect display_bounds(ScreenAsh::GetDisplayBoundsInParent(window()));
+ gfx::Rect display_bounds(ScreenAsh::GetDisplayBoundsInParent(GetTarget()));
int inset_left = 0;
if (area.x() == display_bounds.x())
inset_left = kScreenEdgeInsetForTouchResize;
@@ -1035,10 +1037,11 @@ SnapType WorkspaceWindowResizer::GetSnapType(
void WorkspaceWindowResizer::SetDraggedWindowDocked(bool should_dock) {
if (should_dock &&
- dock_layout_->GetAlignmentOfWindow(window()) != DOCKED_ALIGNMENT_NONE) {
+ dock_layout_->GetAlignmentOfWindow(GetTarget()) !=
+ DOCKED_ALIGNMENT_NONE) {
if (!dock_layout_->is_dragged_window_docked()) {
window_state()->set_bounds_changed_by_user(false);
- dock_layout_->DockDraggedWindow(window());
+ dock_layout_->DockDraggedWindow(GetTarget());
}
} else {
if (dock_layout_->is_dragged_window_docked()) {
« ash/wm/workspace/workspace_window_resizer.h ('K') | « ash/wm/workspace/workspace_window_resizer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698