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

Side by Side Diff: ui/aura/window.cc

Issue 2852653004: Remove aura::Window::hit_test_bounds_override_inner_ (Closed)
Patch Set: . Created 3 years, 7 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
« no previous file with comments | « ui/aura/window.h ('k') | ui/aura/window_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/aura/window.h" 5 #include "ui/aura/window.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 721
722 void Window::Paint(const ui::PaintContext& context) { 722 void Window::Paint(const ui::PaintContext& context) {
723 if (delegate_) 723 if (delegate_)
724 delegate_->OnPaint(context); 724 delegate_->OnPaint(context);
725 } 725 }
726 726
727 Window* Window::GetWindowForPoint(const gfx::Point& local_point, 727 Window* Window::GetWindowForPoint(const gfx::Point& local_point,
728 bool return_tightest, 728 bool return_tightest,
729 bool for_event_handling) { 729 bool for_event_handling) {
730 if (!IsVisible()) 730 if (!IsVisible())
731 return NULL; 731 return nullptr;
732 732
733 if ((for_event_handling && !HitTest(local_point)) || 733 if ((for_event_handling && !HitTest(local_point)) ||
734 (!for_event_handling && !ContainsPoint(local_point))) 734 (!for_event_handling && !ContainsPoint(local_point))) {
735 return NULL; 735 return nullptr;
736
737 // Check if I should claim this event and not pass it to my children because
738 // the location is inside my hit test override area. For details, see
739 // set_hit_test_bounds_override_inner().
740 if (for_event_handling && !hit_test_bounds_override_inner_.IsEmpty()) {
741 gfx::Rect inset_local_bounds(gfx::Point(), bounds().size());
742 inset_local_bounds.Inset(hit_test_bounds_override_inner_);
743 // We know we're inside the normal local bounds, so if we're outside the
744 // inset bounds we must be in the special hit test override area.
745 DCHECK(HitTest(local_point));
746 if (!inset_local_bounds.Contains(local_point))
747 return delegate_ ? this : NULL;
748 } 736 }
749 737
750 if (!return_tightest && delegate_) 738 if (!return_tightest && delegate_)
751 return this; 739 return this;
752 740
753 for (Windows::const_reverse_iterator it = children_.rbegin(), 741 for (Windows::const_reverse_iterator it = children_.rbegin(),
754 rend = children_.rend(); 742 rend = children_.rend();
755 it != rend; ++it) { 743 it != rend; ++it) {
756 Window* child = *it; 744 Window* child = *it;
757 745
758 if (for_event_handling) { 746 if (for_event_handling) {
759 if (child->ignore_events_) 747 if (child->ignore_events_)
760 continue; 748 continue;
749
761 // The client may not allow events to be processed by certain subtrees. 750 // The client may not allow events to be processed by certain subtrees.
762 client::EventClient* client = client::GetEventClient(GetRootWindow()); 751 client::EventClient* client = client::GetEventClient(GetRootWindow());
763 if (client && !client->CanProcessEventsWithinSubtree(child)) 752 if (client && !client->CanProcessEventsWithinSubtree(child))
764 continue; 753 continue;
754
765 if (delegate_ && !delegate_->ShouldDescendIntoChildForEventHandling( 755 if (delegate_ && !delegate_->ShouldDescendIntoChildForEventHandling(
766 child, local_point)) 756 child, local_point)) {
767 continue; 757 continue;
758 }
768 } 759 }
769 760
770 gfx::Point point_in_child_coords(local_point); 761 gfx::Point point_in_child_coords(local_point);
771 ConvertPointToTarget(this, child, &point_in_child_coords); 762 ConvertPointToTarget(this, child, &point_in_child_coords);
772 Window* match = child->GetWindowForPoint(point_in_child_coords, 763 Window* match = child->GetWindowForPoint(point_in_child_coords,
773 return_tightest, 764 return_tightest,
774 for_event_handling); 765 for_event_handling);
775 if (match) 766 if (match)
776 return match; 767 return match;
777 } 768 }
778 769
779 return delegate_ ? this : NULL; 770 return delegate_ ? this : nullptr;
780 } 771 }
781 772
782 void Window::RemoveChildImpl(Window* child, Window* new_parent) { 773 void Window::RemoveChildImpl(Window* child, Window* new_parent) {
783 if (layout_manager_) 774 if (layout_manager_)
784 layout_manager_->OnWillRemoveWindowFromLayout(child); 775 layout_manager_->OnWillRemoveWindowFromLayout(child);
785 for (WindowObserver& observer : observers_) 776 for (WindowObserver& observer : observers_)
786 observer.OnWillRemoveWindow(child); 777 observer.OnWillRemoveWindow(child);
787 Window* root_window = child->GetRootWindow(); 778 Window* root_window = child->GetRootWindow();
788 Window* new_root_window = new_parent ? new_parent->GetRootWindow() : NULL; 779 Window* new_root_window = new_parent ? new_parent->GetRootWindow() : NULL;
789 if (root_window && root_window != new_root_window) 780 if (root_window && root_window != new_root_window)
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 layer_name = "Unnamed Window"; 1072 layer_name = "Unnamed Window";
1082 1073
1083 if (id_ != -1) 1074 if (id_ != -1)
1084 layer_name += " " + base::IntToString(id_); 1075 layer_name += " " + base::IntToString(id_);
1085 1076
1086 layer()->set_name(layer_name); 1077 layer()->set_name(layer_name);
1087 #endif 1078 #endif
1088 } 1079 }
1089 1080
1090 } // namespace aura 1081 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window.h ('k') | ui/aura/window_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698