InspectorOverlay.h [plain text]
#ifndef InspectorOverlay_h
#define InspectorOverlay_h
#include "Color.h"
#include "FloatQuad.h"
#include "LayoutRect.h"
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class Color;
class GraphicsContext;
class InspectorClient;
class InspectorValue;
class IntRect;
class Node;
class Page;
struct HighlightConfig {
WTF_MAKE_FAST_ALLOCATED;
public:
Color content;
Color contentOutline;
Color padding;
Color border;
Color margin;
bool showInfo;
bool showRulers;
bool usePageCoordinates;
};
enum HighlightType {
HighlightTypeNode,
HighlightTypeRects,
};
struct Highlight {
Highlight()
: type(HighlightTypeNode)
, showRulers(false)
{
}
void setDataFromConfig(const HighlightConfig& highlightConfig)
{
contentColor = highlightConfig.content;
contentOutlineColor = highlightConfig.contentOutline;
paddingColor = highlightConfig.padding;
borderColor = highlightConfig.border;
marginColor = highlightConfig.margin;
showRulers = highlightConfig.showRulers;
usePageCoordinates = highlightConfig.usePageCoordinates;
}
Color contentColor;
Color contentOutlineColor;
Color paddingColor;
Color borderColor;
Color marginColor;
HighlightType type;
Vector<FloatQuad> quads;
bool showRulers;
bool usePageCoordinates;
};
class InspectorOverlay {
WTF_MAKE_FAST_ALLOCATED;
public:
static PassOwnPtr<InspectorOverlay> create(Page* page, InspectorClient* client)
{
return adoptPtr(new InspectorOverlay(page, client));
}
~InspectorOverlay();
void update();
void paint(GraphicsContext&);
void drawOutline(GraphicsContext*, const LayoutRect&, const Color&);
void getHighlight(Highlight*) const;
void resize(const IntSize&);
void setPausedInDebuggerMessage(const String*);
void hideHighlight();
void highlightNode(Node*, const HighlightConfig&);
void highlightQuad(PassOwnPtr<FloatQuad>, const HighlightConfig&);
Node* highlightedNode() const;
void freePage();
private:
InspectorOverlay(Page*, InspectorClient*);
void drawGutter();
void drawNodeHighlight();
void drawQuadHighlight();
void drawPausedInDebuggerMessage();
Page* overlayPage();
void reset(const IntSize& viewportSize, const IntSize& frameViewFullSize);
void evaluateInOverlay(const String& method, const String& argument);
void evaluateInOverlay(const String& method, PassRefPtr<InspectorValue> argument);
Page* m_page;
InspectorClient* m_client;
String m_pausedInDebuggerMessage;
RefPtr<Node> m_highlightNode;
HighlightConfig m_nodeHighlightConfig;
OwnPtr<FloatQuad> m_highlightQuad;
OwnPtr<Page> m_overlayPage;
HighlightConfig m_quadHighlightConfig;
IntSize m_size;
};
}
#endif // InspectorOverlay_h