#pragma once
#include "FloatQuad.h"
#include "FloatRect.h"
#include "HitTestLocation.h"
#include "HitTestRequest.h"
#include "LayoutRect.h"
#include "TextFlags.h"
#include <memory>
#include <wtf/Forward.h>
#include <wtf/ListHashSet.h>
#include <wtf/RefPtr.h>
namespace WebCore {
class Element;
class Frame;
class HTMLMediaElement;
class Image;
class Node;
class Scrollbar;
class URL;
class HitTestResult {
public:
typedef ListHashSet<RefPtr<Node>> NodeSet;
WEBCORE_EXPORT HitTestResult();
WEBCORE_EXPORT explicit HitTestResult(const LayoutPoint&);
WEBCORE_EXPORT HitTestResult(const LayoutPoint& centerPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding);
WEBCORE_EXPORT explicit HitTestResult(const HitTestLocation&);
WEBCORE_EXPORT HitTestResult(const HitTestResult&);
WEBCORE_EXPORT ~HitTestResult();
WEBCORE_EXPORT HitTestResult& operator=(const HitTestResult&);
Node* innerNode() const { return m_innerNode.get(); }
Node* innerNonSharedNode() const { return m_innerNonSharedNode.get(); }
WEBCORE_EXPORT Element* innerNonSharedElement() const;
Element* URLElement() const { return m_innerURLElement.get(); }
Scrollbar* scrollbar() const { return m_scrollbar.get(); }
bool isOverWidget() const { return m_isOverWidget; }
WEBCORE_EXPORT String linkSuggestedFilename() const;
bool isRectBasedTest() const { return m_hitTestLocation.isRectBasedTest(); }
const LayoutPoint& pointInMainFrame() const { return m_hitTestLocation.point(); }
IntPoint roundedPointInMainFrame() const { return roundedIntPoint(pointInMainFrame()); }
const LayoutPoint& pointInInnerNodeFrame() const { return m_pointInInnerNodeFrame; }
IntPoint roundedPointInInnerNodeFrame() const { return roundedIntPoint(pointInInnerNodeFrame()); }
WEBCORE_EXPORT Frame* innerNodeFrame() const;
const LayoutPoint& localPoint() const { return m_localPoint; }
void setLocalPoint(const LayoutPoint& p) { m_localPoint = p; }
void setToNonUserAgentShadowAncestor();
const HitTestLocation& hitTestLocation() const { return m_hitTestLocation; }
WEBCORE_EXPORT void setInnerNode(Node*);
void setInnerNonSharedNode(Node*);
void setURLElement(Element*);
void setScrollbar(Scrollbar*);
void setIsOverWidget(bool b) { m_isOverWidget = b; }
WEBCORE_EXPORT Frame* targetFrame() const;
WEBCORE_EXPORT bool isSelected() const;
WEBCORE_EXPORT String selectedText() const;
WEBCORE_EXPORT String spellingToolTip(TextDirection&) const;
String replacedString() const;
WEBCORE_EXPORT String title(TextDirection&) const;
String innerTextIfTruncated(TextDirection&) const;
WEBCORE_EXPORT String altDisplayString() const;
WEBCORE_EXPORT String titleDisplayString() const;
WEBCORE_EXPORT Image* image() const;
WEBCORE_EXPORT IntRect imageRect() const;
WEBCORE_EXPORT URL absoluteImageURL() const;
WEBCORE_EXPORT URL absolutePDFURL() const;
WEBCORE_EXPORT URL absoluteMediaURL() const;
WEBCORE_EXPORT URL absoluteLinkURL() const;
#if ENABLE(ATTACHMENT_ELEMENT)
WEBCORE_EXPORT URL absoluteAttachmentURL() const;
#endif
WEBCORE_EXPORT String textContent() const;
bool isOverLink() const;
WEBCORE_EXPORT bool isContentEditable() const;
void toggleMediaControlsDisplay() const;
void toggleMediaLoopPlayback() const;
WEBCORE_EXPORT bool mediaIsInFullscreen() const;
void toggleMediaFullscreenState() const;
void enterFullscreenForVideo() const;
bool mediaControlsEnabled() const;
bool mediaLoopEnabled() const;
bool mediaPlaying() const;
bool mediaSupportsFullscreen() const;
void toggleMediaPlayState() const;
WEBCORE_EXPORT bool mediaHasAudio() const;
WEBCORE_EXPORT bool mediaIsVideo() const;
bool mediaMuted() const;
void toggleMediaMuteState() const;
bool mediaSupportsEnhancedFullscreen() const;
bool mediaIsInEnhancedFullscreen() const;
void toggleEnhancedFullscreenForVideo() const;
WEBCORE_EXPORT bool isDownloadableMedia() const;
WEBCORE_EXPORT bool isOverTextInsideFormControlElement() const;
WEBCORE_EXPORT bool allowsCopy() const;
bool addNodeToRectBasedTestResult(Node*, const HitTestRequest&, const HitTestLocation& pointInContainer, const LayoutRect& = LayoutRect());
bool addNodeToRectBasedTestResult(Node*, const HitTestRequest&, const HitTestLocation& pointInContainer, const FloatRect&);
void append(const HitTestResult&);
WEBCORE_EXPORT const NodeSet& rectBasedTestResult() const;
Vector<String> dictationAlternatives() const;
Node* targetNode() const;
WEBCORE_EXPORT Element* targetElement() const;
private:
NodeSet& mutableRectBasedTestResult();
#if ENABLE(VIDEO)
HTMLMediaElement* mediaElement() const;
#endif
HitTestLocation m_hitTestLocation;
RefPtr<Node> m_innerNode;
RefPtr<Node> m_innerNonSharedNode;
LayoutPoint m_pointInInnerNodeFrame; LayoutPoint m_localPoint; RefPtr<Element> m_innerURLElement;
RefPtr<Scrollbar> m_scrollbar;
bool m_isOverWidget;
mutable std::unique_ptr<NodeSet> m_rectBasedTestResult;
};
WEBCORE_EXPORT String displayString(const String&, const Node*);
}