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