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