| Index: mojo/services/window_manager/view_target.h
|
| diff --git a/mojo/services/window_manager/view_target.h b/mojo/services/window_manager/view_target.h
|
| index 990a2715dafd84cbedad496edb53fd31e5c37578..67c9b7ee7c54ac62175aa27e2e948c48bc8add6a 100644
|
| --- a/mojo/services/window_manager/view_target.h
|
| +++ b/mojo/services/window_manager/view_target.h
|
| @@ -5,8 +5,15 @@
|
| #ifndef MOJO_SERVICES_WINDOW_MANAGER_VIEW_TARGET_H_
|
| #define MOJO_SERVICES_WINDOW_MANAGER_VIEW_TARGET_H_
|
|
|
| +#include "mojo/services/public/cpp/view_manager/view_observer.h"
|
| #include "ui/events/event_target.h"
|
|
|
| +namespace gfx {
|
| +class Point;
|
| +class Rect;
|
| +class Vector2d;
|
| +}
|
| +
|
| namespace ui {
|
| class EventTargeter;
|
| }
|
| @@ -17,21 +24,38 @@ class View;
|
| class ViewTargeter;
|
| class WindowManagerApp;
|
|
|
| -// A wrapper class around mojo::View. We maintain a shadow tree of ViewTargets,
|
| -// which mirrors the main View tree. The ViewTarget tree wraps mojo::View
|
| -// because we can't subclass View to implement the event targeting interfaces.
|
| -class ViewTarget : public ui::EventTarget {
|
| +// A wrapper class around mojo::View; we can't subclass View to implement the
|
| +// event targeting interfaces, so we create a separate object which observes
|
| +// the View and ties its lifetime to it.
|
| +//
|
| +// Instead of maintaining a shadow tree, we keep a static mapping between a
|
| +// View and all live ViewTarget objects. We observe the View and then delete
|
| +// and deregister ourselves when our View is deleted.
|
| +class ViewTarget : public ui::EventTarget,
|
| + public ViewObserver {
|
| public:
|
| - ViewTarget(WindowManagerApp* app, View* view_to_wrap);
|
| + ViewTarget(View* view_to_wrap);
|
| ~ViewTarget() override;
|
|
|
| + // Returns the ViewTarget for a View.
|
| + static ViewTarget* TargetFromView(View* view);
|
| +
|
| + // Converts |point| from |source|'s coordinates to |target|'s. If |source| is
|
| + // NULL, the function returns without modifying |point|. |target| cannot be
|
| + // NULL.
|
| + static void ConvertPointToTarget(const ViewTarget* source,
|
| + const ViewTarget* target,
|
| + gfx::Point* point);
|
| +
|
| View* view() { return view_; }
|
|
|
| + std::vector<ViewTarget*> GetChildren() const;
|
| + ViewTarget* GetParent() const;
|
| + gfx::Rect GetBounds() const;
|
| bool HasParent() const;
|
| bool IsVisible() const;
|
|
|
| - // We keep track of our children here.
|
| - void AddChild(ViewTarget* view);
|
| + const ViewTarget* GetRoot() const;
|
|
|
| // Sets a new ViewTargeter for the view, and returns the previous
|
| // ViewTargeter.
|
| @@ -45,15 +69,20 @@ class ViewTarget : public ui::EventTarget {
|
| void ConvertEventToTarget(ui::EventTarget* target,
|
| ui::LocatedEvent* event) override;
|
|
|
| + // Overridden from ViewObserver:
|
| + void OnViewDestroying(View* view) override;
|
| +
|
| private:
|
| - // The WindowManagerApp which owns us.
|
| - WindowManagerApp* app_;
|
| + bool ConvertPointForAncestor(const ViewTarget* ancestor,
|
| + gfx::Point* point) const;
|
| + bool ConvertPointFromAncestor(const ViewTarget* ancestor,
|
| + gfx::Point* point) const;
|
| + bool GetTargetOffsetRelativeTo(const ViewTarget* ancestor,
|
| + gfx::Vector2d* offset) const;
|
|
|
| // The mojo::View that we dispatch to.
|
| View* view_;
|
|
|
| - std::vector<ViewTarget*> children_;
|
| -
|
| scoped_ptr<ViewTargeter> targeter_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(ViewTarget);
|
|
|