579c8d8850729db793c669d7497993ecf63f77ea
[WebKit-https.git] / Source / WebKitLegacy / mac / WebView / WebViewInternal.h
1 /*
2  * Copyright (C) 2005, 2006, 2007, 2008, 2009 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 // This header contains WebView declarations that can be used anywhere in WebKit, but are neither SPI nor API.
31
32 #import "WebPreferences.h"
33 #import "WebViewPrivate.h"
34 #import "WebTypesInternal.h"
35
36 #ifdef __cplusplus
37 #import <WebCore/AlternativeTextClient.h>
38 #import <WebCore/FindOptions.h>
39 #import <WebCore/FloatRect.h>
40 #import <WebCore/HTMLMediaElementEnums.h>
41 #import <WebCore/LayoutMilestone.h>
42 #import <WebCore/TextAlternativeWithRange.h>
43 #import <WebCore/TextIndicator.h>
44 #import <WebCore/TextIndicatorWindow.h>
45 #import <WebCore/WebCoreKeyboardUIMode.h>
46 #import <functional>
47 #import <wtf/Forward.h>
48 #import <wtf/RetainPtr.h>
49
50 namespace WebCore {
51 class Element;
52 class Event;
53 class Frame;
54 class HTMLMediaElement;
55 class HTMLVideoElement;
56 class KeyboardEvent;
57 class Page;
58 class RenderBox;
59 class TextIndicator;
60 struct DictationAlternative;
61 struct DictionaryPopupInfo;
62 }
63
64 #if PLATFORM(IOS_FAMILY) && ENABLE(DRAG_SUPPORT)
65 namespace WebCore {
66 struct DragItem;
67 }
68 #endif
69
70 class WebMediaPlaybackTargetPicker;
71 class WebSelectionServiceController;
72
73 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS_FAMILY)
74 #import <WebCore/MediaPlaybackTargetContext.h>
75 #import <WebCore/MediaProducer.h>
76 #endif
77
78 #endif
79
80 @class NSCandidateListTouchBarItem;
81 @class WebBasePluginPackage;
82 @class WebDownload;
83 @class WebImmediateActionController;
84 @class WebNodeHighlight;
85
86 #ifdef __cplusplus
87
88 WebCore::FindOptions coreOptions(WebFindOptions options);
89
90 OptionSet<WebCore::LayoutMilestone> coreLayoutMilestones(WebLayoutMilestones);
91 WebLayoutMilestones kitLayoutMilestones(OptionSet<WebCore::LayoutMilestone>);
92
93 #if USE(DICTATION_ALTERNATIVES)
94 OBJC_CLASS NSTextAlternatives;
95 #endif
96
97 #if ENABLE(DATA_INTERACTION) && defined(__cplusplus)
98 @interface WebUITextIndicatorData (WebUITextIndicatorInternal)
99 - (WebUITextIndicatorData *)initWithImage:(CGImageRef)image textIndicatorData:(const WebCore::TextIndicatorData&)indicatorData scale:(CGFloat)scale;
100 - (WebUITextIndicatorData *)initWithImage:(CGImageRef)image scale:(CGFloat)scale;
101 @end
102 #endif
103
104 @interface WebView (WebViewEditingExtras)
105 - (BOOL)_shouldChangeSelectedDOMRange:(DOMRange *)currentRange toDOMRange:(DOMRange *)proposedRange affinity:(NSSelectionAffinity)selectionAffinity stillSelecting:(BOOL)flag;
106 @end
107
108 @interface WebView (AllWebViews)
109 + (void)_makeAllWebViewsPerformSelector:(SEL)selector;
110 - (void)_removeFromAllWebViewsSet;
111 - (void)_addToAllWebViewsSet;
112 @end
113
114 @interface WebView (WebViewInternal)
115
116 + (BOOL)shouldIncludeInWebKitStatistics;
117
118 - (WebCore::Frame*)_mainCoreFrame;
119 - (WebFrame *)_selectedOrMainFrame;
120
121 - (void)_clearCredentials;
122
123 - (WebCore::KeyboardUIMode)_keyboardUIMode;
124
125 - (BOOL)_becomingFirstResponderFromOutside;
126
127 - (BOOL)_needsOneShotDrawingSynchronization;
128 - (void)_setNeedsOneShotDrawingSynchronization:(BOOL)needsSynchronization;
129 - (void)_scheduleCompositingLayerFlush;
130 - (BOOL)_flushCompositingChanges;
131
132 #if USE(AUTOCORRECTION_PANEL)
133 - (void)handleAcceptedAlternativeText:(NSString*)text;
134 #endif
135
136 #if USE(DICTATION_ALTERNATIVES)
137 - (void)_getWebCoreDictationAlternatives:(Vector<WebCore::DictationAlternative>&)alternatives fromTextAlternatives:(const Vector<WebCore::TextAlternativeWithRange>&)alternativesWithRange;
138 - (void)_showDictationAlternativeUI:(const WebCore::FloatRect&)boundingBoxOfDictatedText forDictationContext:(uint64_t)dictationContext;
139 - (void)_removeDictationAlternatives:(uint64_t)dictationContext;
140 - (Vector<String>)_dictationAlternatives:(uint64_t)dictationContext;
141 #endif
142
143 #if ENABLE(SERVICE_CONTROLS)
144 - (WebSelectionServiceController&)_selectionServiceController;
145 #endif
146
147 - (void)_windowVisibilityChanged:(NSNotification *)notification;
148
149 - (void)_closeWindow;
150
151 @end
152
153 #endif
154
155 #if PLATFORM(IOS_FAMILY)
156 @interface NSObject (WebSafeForwarder)
157 - (id)asyncForwarder;
158 @end
159 #endif
160
161 // FIXME: Temporary way to expose methods that are in the wrong category inside WebView.
162 @interface WebView (WebViewOtherInternal)
163
164 + (void)_setCacheModel:(WebCacheModel)cacheModel;
165 + (WebCacheModel)_cacheModel;
166
167 #ifdef __cplusplus
168 - (WebCore::Page*)page;
169 - (WTF::String)_userAgentString;
170 #endif
171
172 #if !PLATFORM(IOS_FAMILY)
173 - (NSMenu *)_menuForElement:(NSDictionary *)element defaultItems:(NSArray *)items;
174 #endif
175 - (id)_UIDelegateForwarder;
176 #if PLATFORM(IOS_FAMILY)
177 - (id)_UIDelegateForSelector:(SEL)selector;
178 #endif
179 - (id)_editingDelegateForwarder;
180 - (id)_policyDelegateForwarder;
181 #if PLATFORM(IOS_FAMILY)
182 - (id)_frameLoadDelegateForwarder;
183 - (id)_resourceLoadDelegateForwarder;
184 - (id)_UIKitDelegateForwarder;
185 #endif
186 - (void)_pushPerformingProgrammaticFocus;
187 - (void)_popPerformingProgrammaticFocus;
188 #if !PLATFORM(IOS_FAMILY)
189 - (void)_didStartProvisionalLoadForFrame:(WebFrame *)frame;
190 #endif
191 + (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType allowingPlugins:(BOOL)allowPlugins;
192 - (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType;
193 + (void)_registerPluginMIMEType:(NSString *)MIMEType;
194 + (void)_unregisterPluginMIMEType:(NSString *)MIMEType;
195 + (BOOL)_canShowMIMEType:(NSString *)MIMEType allowingPlugins:(BOOL)allowPlugins;
196 - (BOOL)_canShowMIMEType:(NSString *)MIMEType;
197 + (NSString *)_MIMETypeForFile:(NSString *)path;
198 - (WebDownload *)_downloadURL:(NSURL *)URL;
199 + (NSString *)_generatedMIMETypeForURLScheme:(NSString *)URLScheme;
200 + (BOOL)_representationExistsForURLScheme:(NSString *)URLScheme;
201 - (BOOL)_isPerformingProgrammaticFocus;
202 - (void)_mouseDidMoveOverElement:(NSDictionary *)dictionary modifierFlags:(NSUInteger)modifierFlags;
203 - (WebView *)_openNewWindowWithRequest:(NSURLRequest *)request;
204 #if !PLATFORM(IOS_FAMILY)
205 - (void)_writeImageForElement:(NSDictionary *)element withPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard;
206 - (void)_writeLinkElement:(NSDictionary *)element withPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard;
207 - (void)_openFrameInNewWindowFromMenu:(NSMenuItem *)sender;
208 - (void)_searchWithGoogleFromMenu:(id)sender;
209 - (void)_searchWithSpotlightFromMenu:(id)sender;
210 #endif
211 - (void)_progressCompleted:(WebFrame *)frame;
212 - (void)_didCommitLoadForFrame:(WebFrame *)frame;
213 #if !PLATFORM(IOS_FAMILY)
214 - (void)_didFinishLoadForFrame:(WebFrame *)frame;
215 - (void)_didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame;
216 - (void)_didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame;
217 #endif
218 - (void)_willChangeValueForKey:(NSString *)key;
219 - (void)_didChangeValueForKey:(NSString *)key;
220 - (WebBasePluginPackage *)_pluginForMIMEType:(NSString *)MIMEType;
221 - (WebBasePluginPackage *)_pluginForExtension:(NSString *)extension;
222
223 - (void)setCurrentNodeHighlight:(WebNodeHighlight *)nodeHighlight;
224 - (WebNodeHighlight *)currentNodeHighlight;
225
226 #if !PLATFORM(IOS_FAMILY)
227 - (void)addPluginInstanceView:(NSView *)view;
228 - (void)removePluginInstanceView:(NSView *)view;
229 - (void)removePluginInstanceViewsFor:(WebFrame*)webFrame;
230 #endif
231
232 - (void)_addObject:(id)object forIdentifier:(unsigned long)identifier;
233 - (id)_objectForIdentifier:(unsigned long)identifier;
234 - (void)_removeObjectForIdentifier:(unsigned long)identifier;
235
236 - (void)_setZoomMultiplier:(float)multiplier isTextOnly:(BOOL)isTextOnly;
237 - (float)_zoomMultiplier:(BOOL)isTextOnly;
238 - (float)_realZoomMultiplier;
239 - (BOOL)_realZoomMultiplierIsTextOnly;
240 - (BOOL)_canZoomOut:(BOOL)isTextOnly;
241 - (BOOL)_canZoomIn:(BOOL)isTextOnly;
242 - (IBAction)_zoomOut:(id)sender isTextOnly:(BOOL)isTextOnly;
243 - (IBAction)_zoomIn:(id)sender isTextOnly:(BOOL)isTextOnly;
244 - (BOOL)_canResetZoom:(BOOL)isTextOnly;
245 - (IBAction)_resetZoom:(id)sender isTextOnly:(BOOL)isTextOnly;
246
247 + (BOOL)_canHandleRequest:(NSURLRequest *)request forMainFrame:(BOOL)forMainFrame;
248
249 #if !PLATFORM(IOS_FAMILY)
250 - (void)_setInsertionPasteboard:(NSPasteboard *)pasteboard;
251 #endif
252
253 #if PLATFORM(IOS_FAMILY)
254 - (BOOL)_isStopping;
255 - (BOOL)_isClosing;
256
257 - (void)_documentScaleChanged;
258 - (BOOL)_fetchCustomFixedPositionLayoutRect:(NSRect*)rect;
259 #if ENABLE(ORIENTATION_EVENTS)
260 - (void)_setDeviceOrientation:(NSUInteger)orientation;
261 - (NSUInteger)_deviceOrientation;
262 #endif
263 #endif
264
265 #if ENABLE(DATA_INTERACTION) && defined(__cplusplus)
266 - (void)_startDrag:(const WebCore::DragItem&)dragItem;
267 - (void)_didConcludeEditDataInteraction;
268 #endif
269
270 - (void)_preferencesChanged:(WebPreferences *)preferences;
271 - (void)_invalidateUserAgentCache;
272
273 #if ENABLE(VIDEO) && defined(__cplusplus)
274 - (void)_enterVideoFullscreenForVideoElement:(WebCore::HTMLVideoElement*)videoElement mode:(WebCore::HTMLMediaElementEnums::VideoFullscreenMode)mode;
275 - (void)_exitVideoFullscreen;
276 #if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
277 - (BOOL)_hasActiveVideoForControlsInterface;
278 - (void)_setUpPlaybackControlsManagerForMediaElement:(WebCore::HTMLMediaElement&)mediaElement;
279 - (void)_clearPlaybackControlsManager;
280 #endif
281 #endif
282
283 #if ENABLE(FULLSCREEN_API) && !PLATFORM(IOS_FAMILY) && defined(__cplusplus)
284 - (BOOL)_supportsFullScreenForElement:(WebCore::Element*)element withKeyboard:(BOOL)withKeyboard;
285 - (void)_enterFullScreenForElement:(WebCore::Element*)element;
286 - (void)_exitFullScreenForElement:(WebCore::Element*)element;
287 #endif
288
289 // Conversion functions between WebCore root view coordinates and web view coordinates.
290 - (NSPoint)_convertPointFromRootView:(NSPoint)point;
291 - (NSRect)_convertRectFromRootView:(NSRect)rect;
292
293 - (void)_setMaintainsInactiveSelection:(BOOL)shouldMaintainInactiveSelection;
294
295 #if PLATFORM(MAC) && defined(__cplusplus)
296 - (void)_setTextIndicator:(WebCore::TextIndicator&)textIndicator;
297 - (void)_setTextIndicator:(WebCore::TextIndicator&)textIndicator withLifetime:(WebCore::TextIndicatorWindowLifetime)lifetime;
298 - (void)_clearTextIndicatorWithAnimation:(WebCore::TextIndicatorWindowDismissalAnimation)animation;
299 - (void)_setTextIndicatorAnimationProgress:(float)progress;
300 - (void)_showDictionaryLookupPopup:(const WebCore::DictionaryPopupInfo&)dictionaryPopupInfo;
301 - (id)_animationControllerForDictionaryLookupPopupInfo:(const WebCore::DictionaryPopupInfo&)dictionaryPopupInfo;
302 - (WebImmediateActionController *)_immediateActionController;
303 - (NSEvent *)_pressureEvent;
304 - (void)_setPressureEvent:(NSEvent *)event;
305 #endif
306
307 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS_FAMILY) && defined(__cplusplus)
308 - (WebMediaPlaybackTargetPicker *) _devicePicker;
309 - (void)_addPlaybackTargetPickerClient:(uint64_t)clientId;
310 - (void)_removePlaybackTargetPickerClient:(uint64_t)contextId;
311 - (void)_showPlaybackTargetPicker:(uint64_t)contextId location:(const WebCore::IntPoint&)location hasVideo:(BOOL)hasVideo;
312 - (void)_playbackTargetPickerClientStateDidChange:(uint64_t)contextId state:(WebCore::MediaProducer::MediaStateFlags)state;
313 - (void)_setMockMediaPlaybackTargetPickerEnabled:(bool)enabled;
314 - (void)_setMockMediaPlaybackTargetPickerName:(NSString *)name state:(WebCore::MediaPlaybackTargetContext::State)state;
315 #endif
316
317 - (void)prepareForMouseUp;
318 - (void)prepareForMouseDown;
319 - (void)updateTouchBar;
320 - (void)_dismissTextTouchBarPopoverItemWithIdentifier:(NSString *)identifier;
321 - (NSCandidateListTouchBarItem *)candidateList;
322
323 - (void)showFormValidationMessage:(NSString *)message withAnchorRect:(NSRect)anchorRect;
324 - (void)hideFormValidationMessage;
325
326 #if !PLATFORM(IOS_FAMILY)
327 - (void)_setMainFrameIcon:(NSImage *)icon;
328 #endif
329 @end