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

Side by Side Diff: ui/views/view.h

Issue 401933002: Move views event targeting into ViewTargeterDelegate::TargetForRect() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 #ifndef UI_VIEWS_VIEW_H_ 5 #ifndef UI_VIEWS_VIEW_H_
6 #define UI_VIEWS_VIEW_H_ 6 #define UI_VIEWS_VIEW_H_
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 // because their drawing logic stays the same and they can become agnostic to 544 // because their drawing logic stays the same and they can become agnostic to
545 // the UI directionality. 545 // the UI directionality.
546 void EnableCanvasFlippingForRTLUI(bool enable) { 546 void EnableCanvasFlippingForRTLUI(bool enable) {
547 flip_canvas_on_paint_for_rtl_ui_ = enable; 547 flip_canvas_on_paint_for_rtl_ui_ = enable;
548 } 548 }
549 549
550 // Input --------------------------------------------------------------------- 550 // Input ---------------------------------------------------------------------
551 // The points, rects, mouse locations, and touch locations in the following 551 // The points, rects, mouse locations, and touch locations in the following
552 // functions are in the view's coordinates, except for a RootView. 552 // functions are in the view's coordinates, except for a RootView.
553 553
554 // Convenience functions which calls into GetEventHandler() with 554 // A convenience function which calls into GetEventHandlerForRect() with
555 // a 1x1 rect centered at |point|. 555 // a 1x1 rect centered at |point|. |point| is in the local coordinate
556 // space of |this|.
556 View* GetEventHandlerForPoint(const gfx::Point& point); 557 View* GetEventHandlerForPoint(const gfx::Point& point);
557 558
558 // If point-based targeting should be used, return the deepest visible 559 // Returns the View that should be the target of an event having |rect| as
559 // descendant that contains the center point of |rect|. 560 // its location, or NULL if no such target exists. |rect| is in the local
560 // If rect-based targeting (i.e., fuzzing) should be used, return the 561 // coordinate space of |this|.
561 // closest visible descendant having at least kRectTargetOverlap of 562 // TODO(tdanderson): Make this function non-virtual.
562 // its area covered by |rect|. If no such descendant exists, return the
563 // deepest visible descendant that contains the center point of |rect|.
564 // See http://goo.gl/3Jp2BD for more information about rect-based targeting.
565 virtual View* GetEventHandlerForRect(const gfx::Rect& rect); 563 virtual View* GetEventHandlerForRect(const gfx::Rect& rect);
566 564
567 // Returns the deepest visible descendant that contains the specified point 565 // Returns the deepest visible descendant that contains the specified point
568 // and supports tooltips. If the view does not contain the point, returns 566 // and supports tooltips. If the view does not contain the point, returns
569 // NULL. 567 // NULL.
570 virtual View* GetTooltipHandlerForPoint(const gfx::Point& point); 568 virtual View* GetTooltipHandlerForPoint(const gfx::Point& point);
571 569
572 // Return the cursor that should be used for this view or the default cursor. 570 // Return the cursor that should be used for this view or the default cursor.
573 // The event location is in the receiver's coordinate system. The caller is 571 // The event location is in the receiver's coordinate system. The caller is
574 // responsible for managing the lifetime of the returned object, though that 572 // responsible for managing the lifetime of the returned object, though that
575 // lifetime may vary from platform to platform. On Windows and Aura, 573 // lifetime may vary from platform to platform. On Windows and Aura,
576 // the cursor is a shared resource. 574 // the cursor is a shared resource.
577 virtual gfx::NativeCursor GetCursor(const ui::MouseEvent& event); 575 virtual gfx::NativeCursor GetCursor(const ui::MouseEvent& event);
578 576
579 // A convenience function which calls HitTestRect() with a rect of size 577 // A convenience function which calls HitTestRect() with a rect of size
580 // 1x1 and an origin of |point|. 578 // 1x1 and an origin of |point|. |point| is in the local coordinate space
579 // of |this|.
581 bool HitTestPoint(const gfx::Point& point) const; 580 bool HitTestPoint(const gfx::Point& point) const;
582 581
583 // Tests whether |rect| intersects this view's bounds using the ViewTargeter 582 // Returns true if |rect| intersects this view's bounds. |rect| is in the
584 // installed on |this|. If there is no ViewTargeter installed on |this|, the 583 // local coordinate space of |this|.
585 // ViewTargeter installed on the root view is used instead.
586 bool HitTestRect(const gfx::Rect& rect) const; 584 bool HitTestRect(const gfx::Rect& rect) const;
587 585
588 // Returns true if this view or any of its descendants are permitted to 586 // Returns true if this view or any of its descendants are permitted to
589 // be the target of an event. 587 // be the target of an event.
590 virtual bool CanProcessEventsWithinSubtree() const; 588 virtual bool CanProcessEventsWithinSubtree() const;
591 589
592 // Returns true if the mouse cursor is over |view| and mouse events are 590 // Returns true if the mouse cursor is over |view| and mouse events are
593 // enabled. 591 // enabled.
594 bool IsMouseHovered(); 592 bool IsMouseHovered();
595 593
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 // Destroys the layer associated with this view, and reparents any descendants 1384 // Destroys the layer associated with this view, and reparents any descendants
1387 // to the destroyed layer's parent. 1385 // to the destroyed layer's parent.
1388 void DestroyLayer(); 1386 void DestroyLayer();
1389 1387
1390 // Input --------------------------------------------------------------------- 1388 // Input ---------------------------------------------------------------------
1391 1389
1392 bool ProcessMousePressed(const ui::MouseEvent& event); 1390 bool ProcessMousePressed(const ui::MouseEvent& event);
1393 bool ProcessMouseDragged(const ui::MouseEvent& event); 1391 bool ProcessMouseDragged(const ui::MouseEvent& event);
1394 void ProcessMouseReleased(const ui::MouseEvent& event); 1392 void ProcessMouseReleased(const ui::MouseEvent& event);
1395 1393
1394 // Returns the ViewTargeter installed on |this| if one exists,
1395 // otherwise returns the ViewTargeter installed on our root view.
1396 // The return value is guaranteed to be non-null.
1397 ViewTargeter* GetEffectiveViewTargeter() const;
1398
1396 // Accelerators -------------------------------------------------------------- 1399 // Accelerators --------------------------------------------------------------
1397 1400
1398 // Registers this view's keyboard accelerators that are not registered to 1401 // Registers this view's keyboard accelerators that are not registered to
1399 // FocusManager yet, if possible. 1402 // FocusManager yet, if possible.
1400 void RegisterPendingAccelerators(); 1403 void RegisterPendingAccelerators();
1401 1404
1402 // Unregisters all the keyboard accelerators associated with this view. 1405 // Unregisters all the keyboard accelerators associated with this view.
1403 // |leave_data_intact| if true does not remove data from accelerators_ array, 1406 // |leave_data_intact| if true does not remove data from accelerators_ array,
1404 // so it could be re-registered with other focus manager 1407 // so it could be re-registered with other focus manager
1405 void UnregisterAccelerators(bool leave_data_intact); 1408 void UnregisterAccelerators(bool leave_data_intact);
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 // Belongs to this view, but it's reference-counted on some platforms 1592 // Belongs to this view, but it's reference-counted on some platforms
1590 // so we can't use a scoped_ptr. It's dereferenced in the destructor. 1593 // so we can't use a scoped_ptr. It's dereferenced in the destructor.
1591 NativeViewAccessibility* native_view_accessibility_; 1594 NativeViewAccessibility* native_view_accessibility_;
1592 1595
1593 DISALLOW_COPY_AND_ASSIGN(View); 1596 DISALLOW_COPY_AND_ASSIGN(View);
1594 }; 1597 };
1595 1598
1596 } // namespace views 1599 } // namespace views
1597 1600
1598 #endif // UI_VIEWS_VIEW_H_ 1601 #endif // UI_VIEWS_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698