#ifndef UI_BASE_INTERACTION_ELEMENT_TRACKER_MAC_H_
#define UI_BASE_INTERACTION_ELEMENT_TRACKER_MAC_H_
#import <Cocoa/Cocoa.h>
#include <map>
#include <memory>
#include <vector>
#include "base/component_export.h"
#include "base/no_destructor.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/base/interaction/element_tracker.h"
#include "ui/base/interaction/framework_specific_implementation.h"
#include "ui/gfx/geometry/rect.h"
namespace ui {
class COMPONENT_EXPORT(UI_BASE_INTERACTION) TrackedElementMac
: public TrackedElement {
public:
TrackedElementMac(ElementIdentifier identifier,
ElementContext context,
const gfx::Rect& screen_bounds);
~TrackedElementMac() override;
gfx::Rect GetScreenBounds() const override;
DECLARE_FRAMEWORK_SPECIFIC_METADATA()
private:
const gfx::Rect screen_bounds_;
};
class COMPONENT_EXPORT(UI_BASE_INTERACTION) ElementTrackerMac {
public:
ElementTrackerMac(const ElementTrackerMac& other) = delete;
void operator=(const ElementTrackerMac& other) = delete;
static ElementTrackerMac* GetInstance();
void NotifyMenuWillShow(NSMenu* menu, ElementContext context);
void NotifyMenuDoneShowing(NSMenu* menu);
void NotifyMenuItemShown(NSMenu* menu,
ElementIdentifier identifier,
const gfx::Rect& screen_bounds);
void NotifyMenuItemHidden(NSMenu* menu, ElementIdentifier identifier);
void NotifyMenuItemActivated(NSMenu* menu, ElementIdentifier identifier);
NSMenu* GetRootMenuForContext(ElementContext context);
protected:
ElementTrackerMac();
virtual ~ElementTrackerMac();
virtual NSMenu* GetRootMenu(NSMenu* menu) const;
bool is_tracking_any_menus() const { return !root_menu_to_data_.empty(); }
private:
friend class base::NoDestructor<ElementTrackerMac>;
class MenuData;
std::map<NSMenu*, MenuData> root_menu_to_data_;
};
}
#endif