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