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

Side by Side Diff: ash/wm/frame_border_hit_test_controller.cc

Issue 189463013: [Refactor] Move code for painting the window header for browser windows out of ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/frame_border_hit_test_controller.h" 5 #include "ash/wm/frame_border_hit_test_controller.h"
6 6
7 #include "ash/ash_constants.h" 7 #include "ash/ash_constants.h"
8 #include "ash/wm/header_painter.h" 8 #include "ash/wm/caption_buttons/frame_caption_button_container_view.h"
9 #include "ash/wm/resize_handle_window_targeter.h" 9 #include "ash/wm/resize_handle_window_targeter.h"
10 #include "ash/wm/window_state_observer.h" 10 #include "ash/wm/window_state_observer.h"
11 #include "ui/aura/env.h" 11 #include "ui/aura/env.h"
12 #include "ui/aura/window.h" 12 #include "ui/aura/window.h"
13 #include "ui/aura/window_observer.h" 13 #include "ui/aura/window_observer.h"
14 #include "ui/aura/window_targeter.h" 14 #include "ui/aura/window_targeter.h"
15 #include "ui/base/hit_test.h" 15 #include "ui/base/hit_test.h"
16 #include "ui/views/widget/widget.h" 16 #include "ui/views/widget/widget.h"
17 #include "ui/views/widget/widget_delegate.h" 17 #include "ui/views/widget/widget_delegate.h"
18 #include "ui/views/window/non_client_view.h" 18 #include "ui/views/window/non_client_view.h"
19 19
20 namespace ash { 20 namespace ash {
21 21
22 FrameBorderHitTestController::FrameBorderHitTestController(views::Widget* frame) 22 FrameBorderHitTestController::FrameBorderHitTestController(views::Widget* frame)
23 : frame_window_(frame->GetNativeWindow()) { 23 : frame_window_(frame->GetNativeWindow()) {
24 frame_window_->SetEventTargeter(scoped_ptr<ui::EventTargeter>( 24 frame_window_->SetEventTargeter(scoped_ptr<ui::EventTargeter>(
25 new ResizeHandleWindowTargeter(frame_window_, NULL))); 25 new ResizeHandleWindowTargeter(frame_window_, NULL)));
26 } 26 }
27 27
28 FrameBorderHitTestController::~FrameBorderHitTestController() { 28 FrameBorderHitTestController::~FrameBorderHitTestController() {
29 } 29 }
30 30
31 // static 31 // static
32 int FrameBorderHitTestController::NonClientHitTest( 32 int FrameBorderHitTestController::NonClientHitTest(
33 views::NonClientFrameView* view, 33 views::NonClientFrameView* view,
34 HeaderPainter* header_painter, 34 FrameCaptionButtonContainerView* caption_button_container,
35 const gfx::Point& point) { 35 const gfx::Point& point) {
James Cook 2014/03/10 17:32:30 optional cleanup: maybe point_in_widget?
36 gfx::Rect expanded_bounds = view->bounds(); 36 gfx::Rect expanded_bounds = view->bounds();
37 int outside_bounds = kResizeOutsideBoundsSize; 37 int outside_bounds = kResizeOutsideBoundsSize;
38 38
39 if (aura::Env::GetInstance()->is_touch_down()) 39 if (aura::Env::GetInstance()->is_touch_down())
40 outside_bounds *= kResizeOutsideBoundsScaleForTouch; 40 outside_bounds *= kResizeOutsideBoundsScaleForTouch;
41 expanded_bounds.Inset(-outside_bounds, -outside_bounds); 41 expanded_bounds.Inset(-outside_bounds, -outside_bounds);
42 42
43 if (!expanded_bounds.Contains(point)) 43 if (!expanded_bounds.Contains(point))
44 return HTNOWHERE; 44 return HTNOWHERE;
45 45
(...skipping 12 matching lines...) Expand all
58 kResizeAreaCornerSize, 58 kResizeAreaCornerSize,
59 kResizeAreaCornerSize, 59 kResizeAreaCornerSize,
60 can_ever_resize); 60 can_ever_resize);
61 if (frame_component != HTNOWHERE) 61 if (frame_component != HTNOWHERE)
62 return frame_component; 62 return frame_component;
63 63
64 int client_component = frame->client_view()->NonClientHitTest(point); 64 int client_component = frame->client_view()->NonClientHitTest(point);
65 if (client_component != HTNOWHERE) 65 if (client_component != HTNOWHERE)
66 return client_component; 66 return client_component;
67 67
68 return header_painter->NonClientHitTest(point); 68 if (caption_button_container->visible()) {
69 gfx::Point point_in_caption_button_container(point);
70 views::View::ConvertPointFromWidget(caption_button_container,
71 &point_in_caption_button_container);
72 int component = caption_button_container->NonClientHitTest(
73 point_in_caption_button_container);
74 if (component != HTNOWHERE)
75 return component;
76 }
77
78 // Caption is a safe default.
79 return HTCAPTION;
69 } 80 }
70 81
71 } // namespace ash 82 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698