Merge "Fixed paste issue after selecting word in inputbox" into tizen_2.1
[framework/web/webkit-efl.git] / Source / WebKit2 / WebProcess / WebPage / DrawingArea.h
1 /*
2  * Copyright (C) 2010 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 #ifndef DrawingArea_h
27 #define DrawingArea_h
28
29 #include "DrawingAreaInfo.h"
30 #include <WebCore/FloatPoint.h>
31 #include <WebCore/IntRect.h>
32 #include <wtf/Forward.h>
33 #include <wtf/Noncopyable.h>
34 #include <wtf/PassOwnPtr.h>
35
36 #if ENABLE(TIZEN_RECORDING_SURFACE_PAINT_THREAD)
37 #include <wtf/Threading.h>
38 #endif
39
40 namespace CoreIPC {
41     class ArgumentDecoder;
42     class Connection;
43     class MessageID;
44 }
45
46 #if ENABLE(TIZEN_RECORDING_SURFACE_SET)
47 #include "PlatformContextCairo.h"
48 #include <cairo.h>
49 #endif
50
51 namespace WebCore {
52     class GraphicsLayer;
53 #if ENABLE(TIZEN_RECORDING_SURFACE_SET)
54     class GraphicsContext;
55     class PlatformContextCairo;
56 #endif
57 }
58
59 namespace WebKit {
60
61 struct ColorSpaceData;
62 class LayerTreeHost;
63 class WebPage;
64 struct WebPageCreationParameters;
65
66 #if PLATFORM(WIN)
67 struct WindowGeometry;
68 #endif
69
70 #if ENABLE(TIZEN_RECORDING_SURFACE_PAINT_THREAD)
71 class DrawingArea : public ThreadSafeRefCounted<DrawingArea> {
72 #else
73 class DrawingArea {
74 #endif
75     WTF_MAKE_NONCOPYABLE(DrawingArea);
76
77 public:
78     static PassOwnPtr<DrawingArea> create(WebPage*, const WebPageCreationParameters&);
79     virtual ~DrawingArea();
80     
81     void didReceiveDrawingAreaMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
82
83     virtual void setNeedsDisplay(const WebCore::IntRect&) = 0;
84     virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset) = 0;
85
86     // FIXME: These should be pure virtual.
87     virtual void pageBackgroundTransparencyChanged() { }
88     virtual void forceRepaint() { }
89     virtual bool forceRepaintAsync(uint64_t callbackID) { return false; }
90     virtual void setLayerTreeStateIsFrozen(bool) { }
91     virtual bool layerTreeStateIsFrozen() const { return false; }
92     virtual LayerTreeHost* layerTreeHost() const { return 0; }
93
94     virtual void didInstallPageOverlay() { }
95     virtual void didUninstallPageOverlay() { }
96     virtual void setPageOverlayNeedsDisplay(const WebCore::IntRect&) { }
97     virtual void setPageOverlayOpacity(float) { }
98     // If this function returns false, PageOverlay should apply opacity when painting.
99     virtual bool pageOverlayShouldApplyFadeWhenPainting() const { return true; }
100     virtual void pageCustomRepresentationChanged() { }
101
102     virtual void setPaintingEnabled(bool) { }
103     virtual void updatePreferences() { }
104
105 #if USE(ACCELERATED_COMPOSITING)
106     virtual void setRootCompositingLayer(WebCore::GraphicsLayer*) = 0;
107     virtual void scheduleCompositingLayerSync() = 0;
108
109 #if ENABLE(TIZEN_ONESHOT_DRAWING_SYNCHRONIZATION)
110     virtual void setNeedsOneShotDrawingSynchronization() = 0;
111 #endif
112
113 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
114     virtual void addOrUpdateScrollingLayer(WebCore::GraphicsLayer* scrollingLayer, WebCore::GraphicsLayer* contentsLayer, const WebCore::IntSize& scrollSize) = 0;
115     virtual void removeScrollingLayer(WebCore::GraphicsLayer* scrollingLayer, WebCore::GraphicsLayer* contentsLayer) = 0;
116 #endif
117 #endif
118
119 #if USE(UI_SIDE_COMPOSITING)
120     virtual void didReceiveLayerTreeCoordinatorMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*) = 0;
121 #endif
122
123 #if PLATFORM(WIN)
124     virtual void scheduleChildWindowGeometryUpdate(const WindowGeometry&) = 0;
125 #endif
126
127 #if ENABLE(TIZEN_RECORDING_SURFACE_SET)
128     virtual void recordingSurfaceSetLoadStartSet() { }
129     virtual void recordingSurfaceSetLoadFinishedSet(bool isFinishLoad) { }
130 #endif
131
132 #if ENABLE(TIZEN_LAYER_FLUSH_THROTTLING)
133     virtual void didStartProgress() {}
134     virtual void didFinishProgress() {}
135 #endif
136
137     virtual void dispatchAfterEnsuringUpdatedScrollPosition(const Function<void ()>&);
138
139 protected:
140     DrawingArea(DrawingAreaType, WebPage*);
141
142     DrawingAreaType m_type;
143     WebPage* m_webPage;
144
145 private:
146     // CoreIPC message handlers.
147     // FIXME: These should be pure virtual.
148     virtual void updateBackingStoreState(uint64_t backingStoreStateID, bool respondImmediately, float deviceScaleFactor, const WebCore::IntSize& size, const WebCore::IntSize& scrollOffset) { }
149     virtual void didUpdate() { }
150     virtual void suspendPainting() { }
151     virtual void resumePainting() { }
152     virtual void setLayerHostingMode(uint32_t) { }
153
154 #if PLATFORM(MAC)
155     // Used by TiledCoreAnimationDrawingArea.
156     virtual void updateGeometry(const WebCore::IntSize& viewSize) { }
157     virtual void setDeviceScaleFactor(float) { }
158     virtual void setColorSpace(const ColorSpaceData&) { }
159 #endif
160
161 #if USE(TILED_BACKING_STORE)
162     virtual void setSize(const WebCore::IntSize& viewSize) { }
163     virtual void setVisibleContentRectAndScale(const WebCore::IntRect&, float) { }
164     virtual void setVisibleContentRectTrajectoryVector(const WebCore::FloatPoint&) { }
165     virtual void setContentsScale(float scale) { }
166     virtual void renderNextFrame() { }
167     virtual void takeSnapshot(const WebCore::IntSize& targetSize, const WebCore::IntRect& contentsRect) { }
168 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
169     virtual void freePlatformSurface(int platformSurfaceId) { }
170 #endif
171 #endif
172 };
173
174 } // namespace WebKit
175
176 #endif // DrawingArea_h