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

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

Issue 178493003: aura: Make Window::HitTest() a private method. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 (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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 return false; 663 return false;
664 gfx::Point local_point(point_in_root); 664 gfx::Point local_point(point_in_root);
665 ConvertPointToTarget(root_window, this, &local_point); 665 ConvertPointToTarget(root_window, this, &local_point);
666 return gfx::Rect(GetTargetBounds().size()).Contains(local_point); 666 return gfx::Rect(GetTargetBounds().size()).Contains(local_point);
667 } 667 }
668 668
669 bool Window::ContainsPoint(const gfx::Point& local_point) const { 669 bool Window::ContainsPoint(const gfx::Point& local_point) const {
670 return gfx::Rect(bounds().size()).Contains(local_point); 670 return gfx::Rect(bounds().size()).Contains(local_point);
671 } 671 }
672 672
673 bool Window::HitTest(const gfx::Point& local_point) {
674 gfx::Rect local_bounds(bounds().size());
675 if (!delegate_ || !delegate_->HasHitTestMask())
676 return local_bounds.Contains(local_point);
677
678 gfx::Path mask;
679 delegate_->GetHitTestMask(&mask);
680
681 SkRegion clip_region;
682 clip_region.setRect(local_bounds.x(), local_bounds.y(),
683 local_bounds.width(), local_bounds.height());
684 SkRegion mask_region;
685 return mask_region.setPath(mask, clip_region) &&
686 mask_region.contains(local_point.x(), local_point.y());
687 }
688
689 Window* Window::GetEventHandlerForPoint(const gfx::Point& local_point) { 673 Window* Window::GetEventHandlerForPoint(const gfx::Point& local_point) {
690 return GetWindowForPoint(local_point, true, true); 674 return GetWindowForPoint(local_point, true, true);
691 } 675 }
692 676
693 Window* Window::GetTopWindowContainingPoint(const gfx::Point& local_point) { 677 Window* Window::GetTopWindowContainingPoint(const gfx::Point& local_point) {
694 return GetWindowForPoint(local_point, false, false); 678 return GetWindowForPoint(local_point, false, false);
695 } 679 }
696 680
697 Window* Window::GetToplevelWindow() { 681 Window* Window::GetToplevelWindow() {
698 Window* topmost_window_with_delegate = NULL; 682 Window* topmost_window_with_delegate = NULL;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 } 850 }
867 851
868 int64 Window::GetPropertyInternal(const void* key, 852 int64 Window::GetPropertyInternal(const void* key,
869 int64 default_value) const { 853 int64 default_value) const {
870 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); 854 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key);
871 if (iter == prop_map_.end()) 855 if (iter == prop_map_.end())
872 return default_value; 856 return default_value;
873 return iter->second.value; 857 return iter->second.value;
874 } 858 }
875 859
860 bool Window::HitTest(const gfx::Point& local_point) {
861 gfx::Rect local_bounds(bounds().size());
862 if (!delegate_ || !delegate_->HasHitTestMask())
863 return local_bounds.Contains(local_point);
864
865 gfx::Path mask;
866 delegate_->GetHitTestMask(&mask);
867
868 SkRegion clip_region;
869 clip_region.setRect(local_bounds.x(), local_bounds.y(),
870 local_bounds.width(), local_bounds.height());
871 SkRegion mask_region;
872 return mask_region.setPath(mask, clip_region) &&
873 mask_region.contains(local_point.x(), local_point.y());
874 }
875
876 void Window::SetBoundsInternal(const gfx::Rect& new_bounds) { 876 void Window::SetBoundsInternal(const gfx::Rect& new_bounds) {
877 gfx::Rect actual_new_bounds(new_bounds); 877 gfx::Rect actual_new_bounds(new_bounds);
878 878
879 // Ensure we don't go smaller than our minimum bounds. 879 // Ensure we don't go smaller than our minimum bounds.
880 if (delegate_) { 880 if (delegate_) {
881 const gfx::Size& min_size = delegate_->GetMinimumSize(); 881 const gfx::Size& min_size = delegate_->GetMinimumSize();
882 actual_new_bounds.set_width( 882 actual_new_bounds.set_width(
883 std::max(min_size.width(), actual_new_bounds.width())); 883 std::max(min_size.width(), actual_new_bounds.width()));
884 actual_new_bounds.set_height( 884 actual_new_bounds.set_height(
885 std::max(min_size.height(), actual_new_bounds.height())); 885 std::max(min_size.height(), actual_new_bounds.height()));
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 return window; 1438 return window;
1439 if (offset) 1439 if (offset)
1440 *offset += window->bounds().OffsetFromOrigin(); 1440 *offset += window->bounds().OffsetFromOrigin();
1441 } 1441 }
1442 if (offset) 1442 if (offset)
1443 *offset = gfx::Vector2d(); 1443 *offset = gfx::Vector2d();
1444 return NULL; 1444 return NULL;
1445 } 1445 }
1446 1446
1447 } // namespace aura 1447 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698