Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / web / PageOverlay.h
blobf66f03dab0a0e56653a533462622ac8b24313093
1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
16 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. AND ITS CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC.
20 * OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #ifndef PageOverlay_h
30 #define PageOverlay_h
32 #include "platform/graphics/GraphicsLayer.h"
33 #include "platform/graphics/GraphicsLayerClient.h"
34 #include "platform/graphics/paint/DisplayItemClient.h"
35 #include "wtf/OwnPtr.h"
36 #include "wtf/PassOwnPtr.h"
37 #include "wtf/text/WTFString.h"
39 namespace blink {
41 class GraphicsContext;
42 class WebPageOverlay;
43 class WebViewImpl;
44 class WebGraphicsContext;
46 // Manages a layer that is overlaid on a WebView's content.
47 // Clients can paint by implementing WebPageOverlay.
49 // With Slimming Paint, internal clients can extract a GraphicsContext to add
50 // to the DisplayItemList owned by the GraphicsLayer
51 class PageOverlay : public GraphicsLayerClient {
52 public:
53 class Delegate : public GarbageCollectedFinalized<Delegate> {
54 public:
55 DEFINE_INLINE_VIRTUAL_TRACE() { }
57 // Paints page overlay contents.
58 virtual void paintPageOverlay(WebGraphicsContext*, const WebSize& webViewSize) = 0;
59 virtual ~Delegate() { }
62 static PassOwnPtr<PageOverlay> create(WebViewImpl*, PageOverlay::Delegate*);
64 ~PageOverlay();
66 void update();
68 GraphicsLayer* graphicsLayer() const { return m_layer.get(); }
69 DisplayItemClient displayItemClient() const { return toDisplayItemClient(this); }
70 String debugName() const { return "PageOverlay"; }
72 // GraphicsLayerClient implementation
73 void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& inClip) override;
74 String debugName(const GraphicsLayer*) override;
76 private:
77 PageOverlay(WebViewImpl*, PageOverlay::Delegate*);
79 WebViewImpl* m_viewImpl;
80 Persistent<PageOverlay::Delegate> m_delegate;
81 OwnPtr<GraphicsLayer> m_layer;
84 } // namespace blink
86 #endif // PageOverlay_h