Unreviewed, roll out http://trac.webkit.org/changeset/187972.
[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/RetainPtr.h>
38 #import <wtf/ThreadingPrimitives.h>
39 #import <wtf/text/WTFString.h>
40
41 #if PLATFORM(IOS)
42 #import "WebCaretChangeListener.h"
43 #endif
44
45 namespace WebCore {
46 class AlternativeTextUIController;
47 class HistoryItem;
48 class Page;
49 class TextIndicatorWindow;
50 }
51
52 @class WebImmediateActionController;
53 @class WebInspector;
54 @class WebNodeHighlight;
55 @class WebPluginDatabase;
56 @class WebPreferences;
57 @class WebTextCompletionController;
58 @protocol WebFormDelegate;
59 @protocol WebDeviceOrientationProvider;
60 @protocol WebGeolocationProvider;
61 @protocol WebNotificationProvider;
62 #if ENABLE(VIDEO)
63 @class WebVideoFullscreenController;
64 #endif
65 #if ENABLE(FULLSCREEN_API)
66 @class WebFullScreenController;
67 #endif
68 #if ENABLE(MEDIA_STREAM)
69 @protocol WebUserMediaClient;
70 #endif
71 #if ENABLE(REMOTE_INSPECTOR) && PLATFORM(IOS)
72 @class WebIndicateLayer;
73 #endif
74
75 #if PLATFORM(IOS)
76 @class WAKWindow;
77 @class WebEvent;
78 @class WebFixedPositionContent;
79 #endif
80
81 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
82 class WebMediaPlaybackTargetPicker;
83 #endif
84
85 #if PLATFORM(MAC)
86 @class WebWindowVisibilityObserver;
87 #endif
88
89 extern BOOL applicationIsTerminating;
90 extern int pluginDatabaseClientCount;
91
92 class LayerFlushController;
93 class WebViewGroup;
94
95 #if ENABLE(SERVICE_CONTROLS)
96 class WebSelectionServiceController;
97 #endif
98
99 class WebViewLayerFlushScheduler : public WebCore::LayerFlushScheduler {
100 public:
101     WebViewLayerFlushScheduler(LayerFlushController*);
102     virtual ~WebViewLayerFlushScheduler() { }
103
104 private:
105     virtual void layerFlushCallback() override
106     {
107         RefPtr<LayerFlushController> protector = m_flushController;
108         WebCore::LayerFlushScheduler::layerFlushCallback();
109     }
110     
111     LayerFlushController* m_flushController;
112 };
113
114 class LayerFlushController : public RefCounted<LayerFlushController>, public WebCore::LayerFlushSchedulerClient {
115 public:
116     static PassRefPtr<LayerFlushController> create(WebView* webView)
117     {
118         return adoptRef(new LayerFlushController(webView));
119     }
120     
121     virtual bool flushLayers();
122     
123     void scheduleLayerFlush();
124     void invalidate();
125     
126 private:
127     LayerFlushController(WebView*);
128     
129     WebView* m_webView;
130     WebViewLayerFlushScheduler m_layerFlushScheduler;
131 };
132
133 @interface WebWindowVisibilityObserver : NSObject {
134     WebView *_view;
135 }
136
137 - (instancetype)initWithView:(WebView *)view;
138 - (void)startObserving:(NSWindow *)window;
139 - (void)stopObserving:(NSWindow *)window;
140 @end
141
142 // FIXME: This should be renamed to WebViewData.
143 @interface WebViewPrivate : NSObject {
144 @public
145     WebCore::Page* page;
146     RefPtr<WebViewGroup> group;
147
148     id UIDelegate;
149     id UIDelegateForwarder;
150     id resourceProgressDelegate;
151     id downloadDelegate;
152     id policyDelegate;
153     id policyDelegateForwarder;
154     id frameLoadDelegate;
155     id frameLoadDelegateForwarder;
156     id <WebFormDelegate> formDelegate;
157     id editingDelegate;
158     id editingDelegateForwarder;
159     id scriptDebugDelegate;
160     id historyDelegate;
161 #if PLATFORM(IOS)
162     id resourceProgressDelegateForwarder;
163     id formDelegateForwarder;
164 #endif
165
166     WebInspector *inspector;
167     WebNodeHighlight *currentNodeHighlight;
168
169 #if PLATFORM(MAC)
170 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
171     WebImmediateActionController *immediateActionController;
172 #endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
173     std::unique_ptr<WebCore::TextIndicatorWindow> textIndicatorWindow;
174     BOOL hasInitializedLookupObserver;
175     RetainPtr<WebWindowVisibilityObserver> windowVisibilityObserver;
176     RetainPtr<NSEvent> pressureEvent;
177 #endif // PLATFORM(MAC)
178
179     BOOL shouldMaintainInactiveSelection;
180
181     BOOL allowsUndo;
182         
183     float zoomMultiplier;
184     BOOL zoomsTextOnly;
185
186     NSString *applicationNameForUserAgent;
187     WTF::String userAgent;
188     BOOL userAgentOverridden;
189     
190     WebPreferences *preferences;
191     BOOL useSiteSpecificSpoofing;
192 #if PLATFORM(IOS)
193     NSURL *userStyleSheetLocation;
194 #endif
195
196     NSWindow *hostWindow;
197
198     int programmaticFocusCount;
199     
200     WebResourceDelegateImplementationCache resourceLoadDelegateImplementations;
201     WebFrameLoadDelegateImplementationCache frameLoadDelegateImplementations;
202     WebScriptDebugDelegateImplementationCache scriptDebugDelegateImplementations;
203     WebHistoryDelegateImplementationCache historyDelegateImplementations;
204
205     void *observationInfo;
206     
207     BOOL closed;
208 #if PLATFORM(IOS)
209     BOOL closing;
210 #endif
211     BOOL shouldCloseWithWindow;
212     BOOL mainFrameDocumentReady;
213     BOOL drawsBackground;
214     BOOL tabKeyCyclesThroughElementsChanged;
215     BOOL becomingFirstResponder;
216     BOOL becomingFirstResponderFromOutside;
217     BOOL usesPageCache;
218
219 #if !PLATFORM(IOS)
220     NSColor *backgroundColor;
221 #else
222     CGColorRef backgroundColor;
223 #endif
224
225     NSString *mediaStyle;
226     
227     BOOL hasSpellCheckerDocumentTag;
228     NSInteger spellCheckerDocumentTag;
229
230 #if ENABLE(DASHBOARD_SUPPORT)
231     BOOL dashboardBehaviorAlwaysSendMouseEventsToAllWindows;
232     BOOL dashboardBehaviorAlwaysSendActiveNullEventsToPlugIns;
233     BOOL dashboardBehaviorAlwaysAcceptsFirstMouse;
234     BOOL dashboardBehaviorAllowWheelScrolling;
235 #endif
236     
237 #if PLATFORM(IOS)
238     BOOL isStopping;
239
240     id UIKitDelegate;
241     id UIKitDelegateForwarder;
242
243     id WebMailDelegate;
244
245     BOOL allowsMessaging;
246     NSMutableSet *_caretChangeListeners;
247     id <WebCaretChangeListener> _caretChangeListener;
248
249     CGSize fixedLayoutSize;
250     BOOL mainViewIsScrollingOrZooming;
251     int32_t didDrawTiles;
252     WTF::Mutex pendingFixedPositionLayoutRectMutex;
253     CGRect pendingFixedPositionLayoutRect;
254 #endif
255
256 #if !PLATFORM(IOS)
257     // WebKit has both a global plug-in database and a separate, per WebView plug-in database. Dashboard uses the per WebView database.
258     WebPluginDatabase *pluginDatabase;
259 #endif
260     
261     HashMap<unsigned long, RetainPtr<id>> identifierMap;
262
263     BOOL _keyboardUIModeAccessed;
264     WebCore::KeyboardUIMode _keyboardUIMode;
265
266     BOOL shouldUpdateWhileOffscreen;
267
268     BOOL includesFlattenedCompositingLayersWhenDrawingToBitmap;
269
270     // When this flag is set, next time a WebHTMLView draws, it needs to temporarily disable screen updates
271     // so that the NSView drawing is visually synchronized with CALayer updates.
272     BOOL needsOneShotDrawingSynchronization;
273     BOOL postsAcceleratedCompositingNotifications;
274     RefPtr<LayerFlushController> layerFlushController;
275
276 #if !PLATFORM(IOS)
277     NSPasteboard *insertionPasteboard;
278 #endif
279             
280     NSSize lastLayoutSize;
281
282 #if ENABLE(VIDEO)
283     WebVideoFullscreenController *fullscreenController;
284 #endif
285     
286 #if ENABLE(FULLSCREEN_API)
287     WebFullScreenController *newFullscreenController;
288 #endif
289
290 #if ENABLE(REMOTE_INSPECTOR)
291 #if PLATFORM(IOS)
292     WebIndicateLayer *indicateLayer;
293 #endif
294 #endif
295
296     id<WebGeolocationProvider> _geolocationProvider;
297     id<WebDeviceOrientationProvider> m_deviceOrientationProvider;
298     id<WebNotificationProvider> _notificationProvider;
299
300 #if ENABLE(MEDIA_STREAM)
301     id<WebUserMediaClient> m_userMediaClient;
302 #endif
303
304 #if ENABLE(SERVICE_CONTROLS)
305     std::unique_ptr<WebSelectionServiceController> _selectionServiceController;
306 #endif
307
308     RefPtr<WebCore::HistoryItem> _globalHistoryItem;
309
310     BOOL interactiveFormValidationEnabled;
311     int validationMessageTimerMagnification;
312
313     float customDeviceScaleFactor;
314 #if PLATFORM(IOS)
315     WebFixedPositionContent* _fixedPositionContent;
316 #endif
317
318 #if USE(DICTATION_ALTERNATIVES)
319     std::unique_ptr<WebCore::AlternativeTextUIController> m_alternativeTextUIController;
320 #endif
321
322     RetainPtr<NSData> sourceApplicationAuditData;
323
324     BOOL _didPerformFirstNavigation;
325
326 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
327     std::unique_ptr<WebMediaPlaybackTargetPicker> m_playbackTargetPicker;
328 #endif
329 }
330 @end