1 | /* |
2 | * Copyright (C) 2015 Apple Inc. All rights reserved. |
3 | * |
4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions |
6 | * are met: |
7 | * 1. Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. |
9 | * 2. Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. |
12 | * |
13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
23 | * THE POSSIBILITY OF SUCH DAMAGE. |
24 | */ |
25 | |
26 | #pragma once |
27 | |
28 | #if ENABLE(RESOURCE_USAGE) |
29 | |
30 | #include "FloatRect.h" |
31 | #include "GraphicsLayer.h" |
32 | #include "IntRect.h" |
33 | #include "PageOverlay.h" |
34 | #include <wtf/Noncopyable.h> |
35 | #include <wtf/RetainPtr.h> |
36 | |
37 | #if PLATFORM(COCOA) |
38 | #include "PlatformCALayer.h" |
39 | #endif |
40 | |
41 | namespace WebCore { |
42 | |
43 | class FloatRect; |
44 | class IntPoint; |
45 | class IntRect; |
46 | |
47 | class ResourceUsageOverlay final : public PageOverlay::Client { |
48 | WTF_MAKE_FAST_ALLOCATED; |
49 | WTF_MAKE_NONCOPYABLE(ResourceUsageOverlay); |
50 | public: |
51 | explicit ResourceUsageOverlay(Page&); |
52 | ~ResourceUsageOverlay(); |
53 | |
54 | PageOverlay& overlay() { return *m_overlay; } |
55 | |
56 | #if PLATFORM(COCOA) |
57 | void platformDraw(CGContextRef); |
58 | #endif |
59 | |
60 | static const int normalWidth = 570; |
61 | static const int normalHeight = 160; |
62 | |
63 | private: |
64 | void willMoveToPage(PageOverlay&, Page*) override { } |
65 | void didMoveToPage(PageOverlay&, Page*) override { } |
66 | void drawRect(PageOverlay&, GraphicsContext&, const IntRect&) override { } |
67 | bool mouseEvent(PageOverlay&, const PlatformMouseEvent&) override; |
68 | void didScrollFrame(PageOverlay&, Frame&) override { } |
69 | |
70 | void initialize(); |
71 | |
72 | void platformInitialize(); |
73 | void platformDestroy(); |
74 | |
75 | Page& m_page; |
76 | RefPtr<PageOverlay> m_overlay; |
77 | bool m_dragging { false }; |
78 | IntPoint m_dragPoint; |
79 | |
80 | #if PLATFORM(COCOA) |
81 | RetainPtr<CALayer> m_layer; |
82 | RetainPtr<CALayer> m_containerLayer; |
83 | #endif |
84 | |
85 | #if OS(LINUX) |
86 | RefPtr<GraphicsLayer> m_paintLayer; |
87 | std::unique_ptr<GraphicsLayerClient> m_overlayPainter; |
88 | #endif |
89 | }; |
90 | |
91 | } // namespace WebCore |
92 | |
93 | #endif // ENABLE(RESOURCE_USAGE) |
94 | |