diff options
Diffstat (limited to 'Source/WebCore/inspector/InspectorOverlay.h')
-rw-r--r-- | Source/WebCore/inspector/InspectorOverlay.h | 84 |
1 files changed, 52 insertions, 32 deletions
diff --git a/Source/WebCore/inspector/InspectorOverlay.h b/Source/WebCore/inspector/InspectorOverlay.h index 7e3d017b2..a8af0d299 100644 --- a/Source/WebCore/inspector/InspectorOverlay.h +++ b/Source/WebCore/inspector/InspectorOverlay.h @@ -10,7 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -26,14 +26,15 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef InspectorOverlay_h -#define InspectorOverlay_h +#pragma once #include "Color.h" #include "FloatQuad.h" #include "LayoutRect.h" -#include <wtf/OwnPtr.h> -#include <wtf/PassOwnPtr.h> +#include "NodeList.h" +#include "Timer.h" +#include <inspector/InspectorProtocolObjects.h> +#include <wtf/Deque.h> #include <wtf/RefPtr.h> #include <wtf/Vector.h> #include <wtf/text/WTFString.h> @@ -41,6 +42,12 @@ namespace Inspector { class InspectorObject; class InspectorValue; + +namespace Protocol { +namespace OverlayTypes { +class NodeHighlightData; +} +} } namespace WebCore { @@ -61,21 +68,17 @@ public: Color border; Color margin; bool showInfo; - bool showRulers; bool usePageCoordinates; }; -enum HighlightType { - HighlightTypeNode, - HighlightTypeRects, +enum class HighlightType { + Node, // Provides 4 quads: margin, border, padding, content. + NodeList, // Provides a list of nodes. + Rects, // Provides a list of quads. }; struct Highlight { - Highlight() - : type(HighlightTypeNode) - , showRulers(false) - { - } + Highlight() { } void setDataFromConfig(const HighlightConfig& highlightConfig) { @@ -84,7 +87,6 @@ struct Highlight { paddingColor = highlightConfig.padding; borderColor = highlightConfig.border; marginColor = highlightConfig.margin; - showRulers = highlightConfig.showRulers; usePageCoordinates = highlightConfig.usePageCoordinates; } @@ -94,12 +96,9 @@ struct Highlight { Color borderColor; Color marginColor; - // When the type is Node, there are 4 quads (margin, border, padding, content). - // When the type is Rects, this is just a list of quads. - HighlightType type; + HighlightType type {HighlightType::Node}; Vector<FloatQuad> quads; - bool showRulers; - bool usePageCoordinates; + bool usePageCoordinates {true}; }; class InspectorOverlay { @@ -108,46 +107,67 @@ public: InspectorOverlay(Page&, InspectorClient*); ~InspectorOverlay(); + enum class CoordinateSystem { + View, // Adjusts for the main frame's scroll offset. + Document, // Does not adjust for the main frame's scroll offset. + }; + void update(); void paint(GraphicsContext&); - void drawOutline(GraphicsContext*, const LayoutRect&, const Color&); - void getHighlight(Highlight*) const; + void getHighlight(Highlight&, CoordinateSystem) const; void setPausedInDebuggerMessage(const String*); void hideHighlight(); + void highlightNodeList(RefPtr<NodeList>&&, const HighlightConfig&); void highlightNode(Node*, const HighlightConfig&); - void highlightQuad(PassOwnPtr<FloatQuad>, const HighlightConfig&); - + void highlightQuad(std::unique_ptr<FloatQuad>, const HighlightConfig&); + + void setShowingPaintRects(bool); + void showPaintRect(const FloatRect&); + Node* highlightedNode() const; void didSetSearchingForNode(bool enabled); - PassRefPtr<Inspector::InspectorObject> buildObjectForHighlightedNode() const; + void setIndicating(bool indicating); + + RefPtr<Inspector::Protocol::OverlayTypes::NodeHighlightData> buildHighlightObjectForNode(Node*, HighlightType) const; + Ref<Inspector::Protocol::Array<Inspector::Protocol::OverlayTypes::NodeHighlightData>> buildObjectForHighlightedNodes() const; void freePage(); private: + bool shouldShowOverlay() const; void drawGutter(); void drawNodeHighlight(); void drawQuadHighlight(); void drawPausedInDebuggerMessage(); + void drawPaintRects(); + void updatePaintRectsTimerFired(); + Page* overlayPage(); + + void forcePaint(); void reset(const IntSize& viewportSize, const IntSize& frameViewFullSize); + void evaluateInOverlay(const String& method); void evaluateInOverlay(const String& method, const String& argument); - void evaluateInOverlay(const String& method, PassRefPtr<Inspector::InspectorValue> argument); + void evaluateInOverlay(const String& method, RefPtr<Inspector::InspectorValue>&& argument); Page& m_page; InspectorClient* m_client; String m_pausedInDebuggerMessage; RefPtr<Node> m_highlightNode; + RefPtr<NodeList> m_highlightNodeList; HighlightConfig m_nodeHighlightConfig; - OwnPtr<FloatQuad> m_highlightQuad; - OwnPtr<Page> m_overlayPage; + std::unique_ptr<FloatQuad> m_highlightQuad; + std::unique_ptr<Page> m_overlayPage; HighlightConfig m_quadHighlightConfig; - IntSize m_size; + + typedef std::pair<std::chrono::steady_clock::time_point, FloatRect> TimeRectPair; + Deque<TimeRectPair> m_paintRects; + Timer m_paintRectUpdateTimer; + bool m_indicating {false}; + bool m_showingPaintRects {false}; }; } // namespace WebCore - - -#endif // InspectorOverlay_h |