Use std::unique_ptr instead of OwnPtr in JSC - heap, jit, runtime, and parser directories
[WebKit-https.git] / Source / WebKit / mac / WebView / WebViewData.h
1 /*
2  * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All rights reserved.
3  * Copyright (C) 2010 Igalia S.L
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1.  Redistributions of source code must retain the above copyright
10  *     notice, this list of conditions and the following disclaimer. 
11  * 2.  Redistributions in binary form must reproduce the above copyright
12  *     notice, this list of conditions and the following disclaimer in the
13  *     documentation and/or other materials provided with the distribution. 
14  * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
15  *     its contributors may be used to endorse or promote products derived
16  *     from this software without specific prior written permission. 
17  *
18  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 #import "WebTypesInternal.h"
31 #import "WebDelegateImplementationCaching.h"
32 #import <WebCore/AlternativeTextClient.h>
33 #import <WebCore/LayerFlushScheduler.h>
34 #import <WebCore/LayerFlushSchedulerClient.h>
35 #import <WebCore/WebCoreKeyboardUIMode.h>
36 #import <wtf/HashMap.h>
37 #import <wtf/PassOwnPtr.h>
38 #import <wtf/RetainPtr.h>
39 #import <wtf/ThreadingPrimitives.h>
40 #import <wtf/text/WTFString.h>
41
42 #if PLATFORM(IOS)
43 #import "WebCaretChangeListener.h"
44 #endif
45
46 namespace WebCore {
47 class AlternativeTextUIController;
48 class HistoryItem;
49 class Page;
50 class TextIndicatorWindow;
51 }
52
53 @class WebActionMenuController;
54 @class WebInspector;
55 @class WebNodeHighlight;
56 @class WebPluginDatabase;
57 @class WebPreferences;
58 @class WebTextCompletionController;
59 @protocol WebFormDelegate;
60 @protocol WebDeviceOrientationProvider;
61 @protocol WebGeolocationProvider;
62 @protocol WebNotificationProvider;
63 #if ENABLE(VIDEO)
64 @class WebVideoFullscreenController;
65 #endif
66 #if ENABLE(FULLSCREEN_API)
67 @class WebFullScreenController;
68 #endif
69 #if ENABLE(MEDIA_STREAM)
70 @protocol WebUserMediaClient;
71 #endif
72 #if ENABLE(REMOTE_INSPECTOR) && PLATFORM(IOS)
73 @class WebIndicateLayer;
74 #endif
75
76 #if PLATFORM(IOS)
77 @class WAKWindow;
78 @class WebEvent;
79 @class WebFixedPositionContent;
80 #endif
81
82 extern BOOL applicationIsTerminating;
83 extern int pluginDatabaseClientCount;
84
85 class LayerFlushController;
86 class WebViewGroup;
87 class WebSelectionServiceController;
88
89 class WebViewLayerFlushScheduler : public WebCore::LayerFlushScheduler {
90 public:
91     WebViewLayerFlushScheduler(LayerFlushController*);
92     virtual ~WebViewLayerFlushScheduler() { }
93
94 private:
95     virtual void layerFlushCallback() override
96     {
97         RefPtr<LayerFlushController> protector = m_flushController;
98         WebCore::LayerFlushScheduler::layerFlushCallback();
99     }
100     
101     LayerFlushController* m_flushController;
102 };
103
104 class LayerFlushController : public RefCounted<LayerFlushController>, public WebCore::LayerFlushSchedulerClient {
105 public:
106     static PassRefPtr<LayerFlushController> create(WebView* webView)
107     {
108         return adoptRef(new LayerFlushController(webView));
109     }
110     
111     virtual bool flushLayers();
112     
113     void scheduleLayerFlush();
114     void invalidate();
115     
116 private:
117     LayerFlushController(WebView*);
118     
119     WebView* m_webView;
120     WebViewLayerFlushScheduler m_layerFlushScheduler;
121 };
122
123 // FIXME: This should be renamed to WebViewData.
124 @interface WebViewPrivate : NSObject {
125 @public
126     WebCore::Page* page;
127     RefPtr<WebViewGroup> group;
128
129     id UIDelegate;
130     id UIDelegateForwarder;
131     id resourceProgressDelegate;
132     id downloadDelegate;
133     id policyDelegate;
134     id policyDelegateForwarder;
135     id frameLoadDelegate;
136     id frameLoadDelegateForwarder;
137     id <WebFormDelegate> formDelegate;
138     id editingDelegate;
139     id editingDelegateForwarder;
140     id scriptDebugDelegate;
141     id historyDelegate;
142 #if PLATFORM(IOS)
143     id resourceProgressDelegateForwarder;
144     id formDelegateForwarder;
145 #endif
146
147     WebInspector *inspector;
148     WebNodeHighlight *currentNodeHighlight;
149
150 #if PLATFORM(MAC)
151 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
152     WebActionMenuController *actionMenuController;
153 #endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
154     std::unique_ptr<WebCore::TextIndicatorWindow> textIndicatorWindow;
155     BOOL hasInitializedLookupObserver;
156 #endif // PLATFORM(MAC)
157
158     BOOL allowsUndo;
159         
160     float zoomMultiplier;
161     BOOL zoomsTextOnly;
162
163     NSString *applicationNameForUserAgent;
164     WTF::String userAgent;
165     BOOL userAgentOverridden;
166     
167     WebPreferences *preferences;
168     BOOL useSiteSpecificSpoofing;
169 #if PLATFORM(IOS)
170     NSURL *userStyleSheetLocation;
171 #endif
172
173     NSWindow *hostWindow;
174
175     int programmaticFocusCount;
176     
177     WebResourceDelegateImplementationCache resourceLoadDelegateImplementations;
178     WebFrameLoadDelegateImplementationCache frameLoadDelegateImplementations;
179     WebScriptDebugDelegateImplementationCache scriptDebugDelegateImplementations;
180     WebHistoryDelegateImplementationCache historyDelegateImplementations;
181
182     void *observationInfo;
183     
184     BOOL closed;
185 #if PLATFORM(IOS)
186     BOOL closing;
187 #endif
188     BOOL shouldCloseWithWindow;
189     BOOL mainFrameDocumentReady;
190     BOOL drawsBackground;
191     BOOL tabKeyCyclesThroughElementsChanged;
192     BOOL becomingFirstResponder;
193     BOOL becomingFirstResponderFromOutside;
194     BOOL usesPageCache;
195
196 #if !PLATFORM(IOS)
197     NSColor *backgroundColor;
198 #else
199     CGColorRef backgroundColor;
200 #endif
201
202     NSString *mediaStyle;
203     
204     BOOL hasSpellCheckerDocumentTag;
205     NSInteger spellCheckerDocumentTag;
206
207 #if ENABLE(DASHBOARD_SUPPORT)
208     BOOL dashboardBehaviorAlwaysSendMouseEventsToAllWindows;
209     BOOL dashboardBehaviorAlwaysSendActiveNullEventsToPlugIns;
210     BOOL dashboardBehaviorAlwaysAcceptsFirstMouse;
211     BOOL dashboardBehaviorAllowWheelScrolling;
212 #endif
213     
214 #if PLATFORM(IOS)
215     BOOL isStopping;
216
217     id UIKitDelegate;
218     id UIKitDelegateForwarder;
219
220     id WebMailDelegate;
221
222     BOOL allowsMessaging;
223     NSMutableSet *_caretChangeListeners;
224     id <WebCaretChangeListener> _caretChangeListener;
225
226     CGSize fixedLayoutSize;
227     BOOL mainViewIsScrollingOrZooming;
228     int32_t didDrawTiles;
229     WTF::Mutex pendingFixedPositionLayoutRectMutex;
230     CGRect pendingFixedPositionLayoutRect;
231 #endif
232
233 #if !PLATFORM(IOS)
234     // WebKit has both a global plug-in database and a separate, per WebView plug-in database. Dashboard uses the per WebView database.
235     WebPluginDatabase *pluginDatabase;
236 #endif
237     
238     HashMap<unsigned long, RetainPtr<id>> identifierMap;
239
240     BOOL _keyboardUIModeAccessed;
241     WebCore::KeyboardUIMode _keyboardUIMode;
242
243     BOOL shouldUpdateWhileOffscreen;
244
245     BOOL includesFlattenedCompositingLayersWhenDrawingToBitmap;
246
247     // When this flag is set, next time a WebHTMLView draws, it needs to temporarily disable screen updates
248     // so that the NSView drawing is visually synchronized with CALayer updates.
249     BOOL needsOneShotDrawingSynchronization;
250     BOOL postsAcceleratedCompositingNotifications;
251     RefPtr<LayerFlushController> layerFlushController;
252
253 #if !PLATFORM(IOS)
254     NSPasteboard *insertionPasteboard;
255 #endif
256             
257     NSSize lastLayoutSize;
258
259 #if ENABLE(VIDEO)
260     WebVideoFullscreenController *fullscreenController;
261 #endif
262     
263 #if ENABLE(FULLSCREEN_API)
264     WebFullScreenController *newFullscreenController;
265 #endif
266
267 #if ENABLE(REMOTE_INSPECTOR)
268 #if PLATFORM(IOS)
269     WebIndicateLayer *indicateLayer;
270 #endif
271 #endif
272
273 #if USE(GLIB)
274     CFRunLoopObserverRef glibRunLoopObserver;
275 #endif
276     id<WebGeolocationProvider> _geolocationProvider;
277     id<WebDeviceOrientationProvider> m_deviceOrientationProvider;
278     id<WebNotificationProvider> _notificationProvider;
279
280 #if ENABLE(MEDIA_STREAM)
281     id<WebUserMediaClient> m_userMediaClient;
282 #endif
283
284 #if ENABLE(SERVICE_CONTROLS)
285     std::unique_ptr<WebSelectionServiceController> _selectionServiceController;
286 #endif
287
288     RefPtr<WebCore::HistoryItem> _globalHistoryItem;
289
290     BOOL interactiveFormValidationEnabled;
291     int validationMessageTimerMagnification;
292
293     float customDeviceScaleFactor;
294 #if PLATFORM(IOS)
295     WebFixedPositionContent* _fixedPositionContent;
296 #endif
297
298 #if USE(DICTATION_ALTERNATIVES)
299     OwnPtr<WebCore::AlternativeTextUIController> m_alternativeTextUIController;
300 #endif
301
302     RetainPtr<NSData> sourceApplicationAuditData;
303
304     BOOL _didPerformFirstNavigation;
305 }
306 @end