#ifndef DocumentMarkerController_h
#define DocumentMarkerController_h
#include "core/dom/DocumentMarker.h"
#include "platform/geometry/IntRect.h"
#include "wtf/HashMap.h"
#include "wtf/Vector.h"
namespace WebCore {
class ContainerNode;
class LayoutPoint;
class LayoutRect;
class Node;
class Range;
class RenderedDocumentMarker;
class DocumentMarkerController {
WTF_MAKE_NONCOPYABLE(DocumentMarkerController); WTF_MAKE_FAST_ALLOCATED;
public:
DocumentMarkerController();
~DocumentMarkerController();
void clear();
void addMarker(Range*, DocumentMarker::MarkerType);
void addMarker(Range*, DocumentMarker::MarkerType, const String& description);
void addMarker(Range*, DocumentMarker::MarkerType, const String& description, uint32_t hash);
void addMarkerToNode(Node*, unsigned startOffset, unsigned length, DocumentMarker::MarkerType);
void addMarkerToNode(Node*, unsigned startOffset, unsigned length, DocumentMarker::MarkerType, PassRefPtr<DocumentMarkerDetails>);
void addTextMatchMarker(const Range*, bool activeMatch);
void copyMarkers(Node* srcNode, unsigned startOffset, int length, Node* dstNode, int delta);
bool hasMarkers(Range*, DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers());
void prepareForDestruction();
enum RemovePartiallyOverlappingMarkerOrNot { DoNotRemovePartiallyOverlappingMarker, RemovePartiallyOverlappingMarker };
void removeMarkers(Range*, DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers(), RemovePartiallyOverlappingMarkerOrNot = DoNotRemovePartiallyOverlappingMarker);
void removeMarkers(Node*, unsigned startOffset, int length, DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers(), RemovePartiallyOverlappingMarkerOrNot = DoNotRemovePartiallyOverlappingMarker);
void removeMarkers(DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers());
void removeMarkers(Node*, DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers());
void repaintMarkers(DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers());
void invalidateRenderedRectsForMarkersInRect(const LayoutRect&);
void shiftMarkers(Node*, unsigned startOffset, int delta);
void setMarkersActive(Range*, bool);
void setMarkersActive(Node*, unsigned startOffset, unsigned endOffset, bool);
DocumentMarker* markerContainingPoint(const LayoutPoint&, DocumentMarker::MarkerType);
Vector<DocumentMarker*> markersFor(Node*, DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers());
Vector<DocumentMarker*> markersInRange(Range*, DocumentMarker::MarkerTypes);
Vector<DocumentMarker*> markers();
Vector<IntRect> renderedRectsForMarkers(DocumentMarker::MarkerType);
#ifndef NDEBUG
void showMarkers() const;
#endif
private:
void addMarker(Node*, const DocumentMarker&);
typedef Vector<RenderedDocumentMarker> MarkerList;
typedef Vector<OwnPtr<MarkerList>, DocumentMarker::MarkerTypeIndexesCount> MarkerLists;
typedef HashMap<const Node*, OwnPtr<MarkerLists> > MarkerMap;
void mergeOverlapping(MarkerList*, DocumentMarker&);
bool possiblyHasMarkers(DocumentMarker::MarkerTypes);
void removeMarkersFromList(MarkerMap::iterator, DocumentMarker::MarkerTypes);
MarkerMap m_markers;
DocumentMarker::MarkerTypes m_possiblyExistingMarkerTypes;
};
}
#ifndef NDEBUG
void showDocumentMarkers(const WebCore::DocumentMarkerController*);
#endif
#endif