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