1/*
2 * Copyright (C) 2005-2014 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1.  Redistributions of source code must retain the above copyright
9 *     notice, this list of conditions and the following disclaimer.
10 * 2.  Redistributions in binary form must reproduce the above copyright
11 *     notice, this list of conditions and the following disclaimer in the
12 *     documentation and/or other materials provided with the distribution.
13 * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
14 *     its contributors may be used to endorse or promote products derived
15 *     from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#import <WebKitLegacy/WebView.h>
30#import <WebKitLegacy/WebFramePrivate.h>
31#import <JavaScriptCore/JSBase.h>
32
33#if TARGET_OS_IPHONE
34#import <CoreGraphics/CGColor.h>
35#endif
36
37#if !defined(ENABLE_DASHBOARD_SUPPORT)
38#if TARGET_OS_IPHONE
39#define ENABLE_DASHBOARD_SUPPORT 0
40#else
41#define ENABLE_DASHBOARD_SUPPORT 1
42#endif
43#endif
44
45#if !defined(ENABLE_REMOTE_INSPECTOR)
46// FIXME: Should we just remove this ENABLE flag everywhere?
47#define ENABLE_REMOTE_INSPECTOR 1
48#endif
49
50@class NSError;
51@class WebFrame;
52@class WebDeviceOrientation;
53@class WebGeolocationPosition;
54@class WebInspector;
55@class WebNotification;
56@class WebPreferences;
57@class WebScriptWorld;
58@class WebSecurityOrigin;
59@class WebTextIterator;
60#if TARGET_OS_IPHONE
61@class CALayer;
62@class WebFixedPositionContent;
63
64@protocol WebCaretChangeListener;
65#endif
66@protocol WebDeviceOrientationProvider;
67@protocol WebFormDelegate;
68@protocol WebUserMediaClient;
69
70#if !TARGET_OS_IPHONE
71extern NSString *_WebCanGoBackKey;
72extern NSString *_WebCanGoForwardKey;
73extern NSString *_WebEstimatedProgressKey;
74extern NSString *_WebIsLoadingKey;
75extern NSString *_WebMainFrameIconKey;
76extern NSString *_WebMainFrameTitleKey;
77extern NSString *_WebMainFrameURLKey;
78extern NSString *_WebMainFrameDocumentKey;
79#endif
80
81#if TARGET_OS_IPHONE
82extern NSString * const WebViewProgressEstimatedProgressKey;
83extern NSString * const WebViewProgressBackgroundColorKey;
84#endif
85
86// pending public WebElementDictionary keys
87extern NSString *WebElementTitleKey;             // NSString of the title of the element (used by Safari)
88extern NSString *WebElementSpellingToolTipKey;   // NSString of a tooltip representing misspelling or bad grammar (used internally)
89extern NSString *WebElementIsContentEditableKey; // NSNumber indicating whether the inner non-shared node is content editable (used internally)
90extern NSString *WebElementMediaURLKey;          // NSURL of the media element
91
92// other WebElementDictionary keys
93extern NSString *WebElementLinkIsLiveKey;        // NSNumber of BOOL indicating whether the link is live or not
94extern NSString *WebElementIsInScrollBarKey;
95
96// One of the subviews of the WebView entered compositing mode.
97extern NSString *_WebViewDidStartAcceleratedCompositingNotification;
98
99#if ENABLE_REMOTE_INSPECTOR
100// FIXME: Legacy, remove this, switch to something from JavaScriptCore Inspector::RemoteInspectorServer.
101// Notification when the number of inspector sessions becomes non-zero or returns to 0.
102// Check the current state via -[WebView _hasRemoteInspectorSession].
103extern NSString *_WebViewRemoteInspectorHasSessionChangedNotification;
104#endif
105
106#if TARGET_OS_IPHONE
107extern NSString *WebQuickLookFileNameKey;
108extern NSString *WebQuickLookUTIKey;
109#endif
110
111extern NSString * const WebViewWillCloseNotification;
112
113#if ENABLE_DASHBOARD_SUPPORT
114typedef enum {
115    WebDashboardBehaviorAlwaysSendMouseEventsToAllWindows,
116    WebDashboardBehaviorAlwaysSendActiveNullEventsToPlugIns,
117    WebDashboardBehaviorAlwaysAcceptsFirstMouse,
118    WebDashboardBehaviorAllowWheelScrolling,
119    WebDashboardBehaviorUseBackwardCompatibilityMode
120} WebDashboardBehavior;
121#endif
122
123typedef enum {
124    WebInjectAtDocumentStart,
125    WebInjectAtDocumentEnd,
126} WebUserScriptInjectionTime;
127
128typedef enum {
129    WebInjectInAllFrames,
130    WebInjectInTopFrameOnly
131} WebUserContentInjectedFrames;
132
133enum {
134    WebFindOptionsCaseInsensitive = 1 << 0,
135    WebFindOptionsAtWordStarts = 1 << 1,
136    WebFindOptionsTreatMedialCapitalAsWordStart = 1 << 2,
137    WebFindOptionsBackwards = 1 << 3,
138    WebFindOptionsWrapAround = 1 << 4,
139    WebFindOptionsStartInSelection = 1 << 5
140};
141typedef NSUInteger WebFindOptions;
142
143typedef enum {
144    WebPaginationModeUnpaginated,
145    WebPaginationModeLeftToRight,
146    WebPaginationModeRightToLeft,
147    WebPaginationModeTopToBottom,
148    WebPaginationModeBottomToTop,
149#if TARGET_OS_IPHONE
150    // FIXME: Remove these once UIKit has switched to the above.
151    WebPaginationModeHorizontal = WebPaginationModeLeftToRight,
152    WebPaginationModeVertical = WebPaginationModeTopToBottom,
153#endif
154} WebPaginationMode;
155
156enum {
157    WebDidFirstLayout = 1 << 0,
158    WebDidFirstVisuallyNonEmptyLayout = 1 << 1,
159    WebDidHitRelevantRepaintedObjectsAreaThreshold = 1 << 2
160};
161typedef NSUInteger WebLayoutMilestones;
162
163typedef enum {
164    WebPageVisibilityStateVisible,
165    WebPageVisibilityStateHidden,
166    WebPageVisibilityStatePrerender
167} WebPageVisibilityState;
168
169typedef enum {
170    WebNotificationPermissionAllowed,
171    WebNotificationPermissionNotAllowed,
172    WebNotificationPermissionDenied
173} WebNotificationPermission;
174
175#if !TARGET_OS_IPHONE
176@interface WebController : NSTreeController {
177    IBOutlet WebView *webView;
178}
179- (WebView *)webView;
180- (void)setWebView:(WebView *)newWebView;
181@end
182#endif
183
184@interface WebView (WebViewEditingActionsPendingPublic)
185
186- (void)outdent:(id)sender;
187- (NSDictionary *)typingAttributes;
188
189@end
190
191@interface WebView (WebPendingPublic)
192
193#if !TARGET_OS_IPHONE
194- (void)scheduleInRunLoop:(NSRunLoop *)runLoop forMode:(NSString *)mode;
195- (void)unscheduleFromRunLoop:(NSRunLoop *)runLoop forMode:(NSString *)mode;
196#endif
197
198- (BOOL)findString:(NSString *)string options:(WebFindOptions)options;
199- (DOMRange *)DOMRangeOfString:(NSString *)string relativeTo:(DOMRange *)previousRange options:(WebFindOptions)options;
200
201- (void)setMainFrameDocumentReady:(BOOL)mainFrameDocumentReady;
202
203- (void)setTabKeyCyclesThroughElements:(BOOL)cyclesElements;
204- (BOOL)tabKeyCyclesThroughElements;
205
206- (void)scrollDOMRangeToVisible:(DOMRange *)range;
207#if TARGET_OS_IPHONE
208- (void)scrollDOMRangeToVisible:(DOMRange *)range withInset:(CGFloat)inset;
209#endif
210
211/*!
212@method setScriptDebugDelegate:
213@abstract Set the WebView's WebScriptDebugDelegate delegate.
214@param delegate The WebScriptDebugDelegate to set as the delegate.
215*/
216- (void)setScriptDebugDelegate:(id)delegate;
217
218/*!
219@method scriptDebugDelegate
220@abstract Return the WebView's WebScriptDebugDelegate.
221@result The WebView's WebScriptDebugDelegate.
222*/
223- (id)scriptDebugDelegate;
224
225/*!
226    @method setHistoryDelegate:
227    @abstract Set the WebView's WebHistoryDelegate delegate.
228    @param delegate The WebHistoryDelegate to set as the delegate.
229*/
230- (void)setHistoryDelegate:(id)delegate;
231
232/*!
233    @method historyDelegate
234    @abstract Return the WebView's WebHistoryDelegate delegate.
235    @result The WebView's WebHistoryDelegate delegate.
236*/
237- (id)historyDelegate;
238
239- (BOOL)shouldClose;
240
241#if !TARGET_OS_IPHONE
242/*!
243    @method aeDescByEvaluatingJavaScriptFromString:
244    @param script The text of the JavaScript.
245    @result The result of the script, converted to an NSAppleEventDescriptor, or nil for failure.
246*/
247- (NSAppleEventDescriptor *)aeDescByEvaluatingJavaScriptFromString:(NSString *)script;
248#endif
249
250// Support for displaying multiple text matches.
251// These methods might end up moving into a protocol, so different document types can specify
252// whether or not they implement the protocol. For now we'll just deal with HTML.
253// These methods are still in flux; don't rely on them yet.
254- (BOOL)canMarkAllTextMatches;
255- (NSUInteger)countMatchesForText:(NSString *)string options:(WebFindOptions)options highlight:(BOOL)highlight limit:(NSUInteger)limit markMatches:(BOOL)markMatches;
256- (NSUInteger)countMatchesForText:(NSString *)string inDOMRange:(DOMRange *)range options:(WebFindOptions)options highlight:(BOOL)highlight limit:(NSUInteger)limit markMatches:(BOOL)markMatches;
257- (void)unmarkAllTextMatches;
258- (NSArray *)rectsForTextMatches;
259
260// Support for disabling registration with the undo manager. This is equivalent to the methods with the same names on NSTextView.
261- (BOOL)allowsUndo;
262- (void)setAllowsUndo:(BOOL)flag;
263
264/*!
265    @method setPageSizeMultiplier:
266    @abstract Change the zoom factor of the page in views managed by this webView.
267    @param multiplier A fractional percentage value, 1.0 is 100%.
268*/
269- (void)setPageSizeMultiplier:(float)multiplier;
270
271/*!
272    @method pageSizeMultiplier
273    @result The page size multipler.
274*/
275- (float)pageSizeMultiplier;
276
277// Commands for doing page zoom.  Will end up in WebView (WebIBActions) <NSUserInterfaceValidations>
278- (BOOL)canZoomPageIn;
279- (IBAction)zoomPageIn:(id)sender;
280- (BOOL)canZoomPageOut;
281- (IBAction)zoomPageOut:(id)sender;
282- (BOOL)canResetPageZoom;
283- (IBAction)resetPageZoom:(id)sender;
284
285// Sets a master volume control for all media elements in the WebView. Valid values are 0..1.
286- (void)setMediaVolume:(float)volume;
287- (float)mediaVolume;
288
289// Add visited links
290- (void)addVisitedLinks:(NSArray *)visitedLinks;
291#if TARGET_OS_IPHONE
292- (void)removeVisitedLink:(NSURL *)url;
293#endif
294@end
295
296@interface WebView (WebPrivate)
297
298- (WebInspector *)inspector;
299
300#if ENABLE_REMOTE_INSPECTOR
301+ (void)_enableRemoteInspector;
302+ (void)_disableRemoteInspector;
303+ (void)_disableAutoStartRemoteInspector;
304+ (BOOL)_isRemoteInspectorEnabled;
305+ (BOOL)_hasRemoteInspectorSession;
306
307/*!
308    @method allowsRemoteInspection
309    @result Returns whether or not this WebView will allow a Remote Web Inspector
310    to attach to it.
311*/
312- (BOOL)allowsRemoteInspection;
313
314/*!
315    @method setAllowsRemoteInspection:
316    @param allow The new permission for this WebView.
317    @abstract Sets the permission of this WebView to either allow or disallow
318    a Remote Web Inspector to attach to it.
319*/
320- (void)setAllowsRemoteInspection:(BOOL)allow;
321
322/*!
323    @method setShowingInspectorIndication
324    @param enabled Show the indication when true, hide when false.
325    @abstract indicate this WebView on screen for a remote inspector.
326*/
327- (void)setShowingInspectorIndication:(BOOL)enabled;
328
329#if TARGET_OS_IPHONE
330- (void)_setHostApplicationProcessIdentifier:(pid_t)pid auditToken:(audit_token_t)auditToken;
331#endif
332
333#endif // ENABLE_REMOTE_INSPECTOR
334
335#if !TARGET_OS_IPHONE
336/*!
337    @method setBackgroundColor:
338    @param backgroundColor Color to use as the default background.
339    @abstract Sets what color the receiver draws under transparent page background colors and images.
340    This color is also used when no page is loaded. A color with alpha should only be used when the receiver is
341    in a non-opaque window, since the color is drawn using NSCompositeCopy.
342*/
343- (void)setBackgroundColor:(NSColor *)backgroundColor;
344
345/*!
346    @method backgroundColor
347    @result Returns the background color drawn under transparent page background colors and images.
348    This color is also used when no page is loaded. A color with alpha should only be used when the receiver is
349    in a non-opaque window, since the color is drawn using NSCompositeCopy.
350*/
351- (NSColor *)backgroundColor;
352#else
353- (void)setBackgroundColor:(CGColorRef)backgroundColor;
354- (CGColorRef)backgroundColor;
355#endif
356
357/*!
358Could be worth adding to the API.
359 @method _loadBackForwardListFromOtherView:
360 @abstract Loads the view with the contents of the other view, including its backforward list.
361 @param otherView   The WebView from which to copy contents.
362 */
363- (void)_loadBackForwardListFromOtherView:(WebView *)otherView;
364
365/*
366 @method _reportException:inContext:
367 @abstract Logs the exception to the Web Inspector. This only needs called for exceptions that
368 occur while using the JavaScriptCore APIs with a context owned by a WebKit.
369 @param exception The exception value to log.
370 @param context   The context the exception occured in.
371*/
372+ (void)_reportException:(JSValueRef)exception inContext:(JSContextRef)context;
373
374/*!
375 @method _dispatchPendingLoadRequests:
376 @abstract Dispatches any pending load requests that have been scheduled because of recent DOM additions or style changes.
377 @discussion You only need to call this method if you require synchronous notification of loads through the resource load delegate.
378 Otherwise the resource load delegate will be notified about loads during a future run loop iteration.
379 */
380- (void)_dispatchPendingLoadRequests;
381
382#if !TARGET_OS_IPHONE
383+ (NSArray *)_supportedFileExtensions;
384#endif
385
386/*!
387    @method canShowFile:
388    @abstract Checks if the WebKit can show the content of the file at the specified path.
389    @param path The path of the file to check
390    @result YES if the WebKit can show the content of the file at the specified path.
391*/
392+ (BOOL)canShowFile:(NSString *)path;
393
394#if !TARGET_OS_IPHONE
395/*!
396    @method suggestedFileExtensionForMIMEType:
397    @param MIMEType The MIME type to check.
398    @result The extension based on the MIME type
399*/
400+ (NSString *)suggestedFileExtensionForMIMEType: (NSString *)MIMEType;
401#endif
402
403+ (NSString *)_standardUserAgentWithApplicationName:(NSString *)applicationName;
404#if TARGET_OS_IPHONE
405- (void)_setBrowserUserAgentProductVersion:(NSString *)productVersion buildVersion:(NSString *)buildVersion bundleVersion:(NSString *)bundleVersion;
406- (void)_setUIWebViewUserAgentWithBuildVersion:(NSString *)buildVersion;
407#endif
408
409/*!
410    @method canCloseAllWebViews
411    @abstract Checks if all the open WebViews can be closed (by dispatching the beforeUnload event to the pages).
412    @result YES if all the WebViews can be closed.
413*/
414+ (BOOL)canCloseAllWebViews;
415
416#if TARGET_OS_IPHONE
417- (id)initSimpleHTMLDocumentWithStyle:(NSString *)style frame:(CGRect)frame preferences:(WebPreferences *)preferences groupName:(NSString *)groupName;
418- (id)_formDelegateForwarder;
419- (id)_formDelegateForSelector:(SEL)selector;
420- (id)_webMailDelegate;
421- (void)setWebMailDelegate:(id)delegate;
422- (id <WebCaretChangeListener>)caretChangeListener;
423- (void)setCaretChangeListener:(id <WebCaretChangeListener>)listener;
424
425- (NSSet *)caretChangeListeners;
426- (void)addCaretChangeListener:(id <WebCaretChangeListener>)listener;
427- (void)removeCaretChangeListener:(id <WebCaretChangeListener>)listener;
428- (void)removeAllCaretChangeListeners;
429
430- (void)caretChanged;
431
432- (void)_dispatchUnloadEvent;
433
434- (DOMCSSStyleDeclaration *)styleAtSelectionStart;
435
436- (NSUInteger)_renderTreeSize;
437
438/*!
439 * @method _handleMemoryWarning
440 * @discussion Try to release memory since we got a memory warning from the system. This method is
441 * also used by other internal clients. See <rdar://9582500>.
442 */
443+ (void)_handleMemoryWarning;
444
445- (void)_setResourceLoadSchedulerSuspended:(BOOL)suspend;
446+ (void)_setTileCacheLayerPoolCapacity:(unsigned)capacity;
447
448+ (void)_setAllowCookies:(BOOL)allow;
449+ (BOOL)_allowCookies;
450+ (BOOL)_isUnderMemoryPressure;
451+ (void)_clearMemoryPressure;
452+ (BOOL)_shouldWaitForMemoryClearMessage;
453+ (void)_releaseMemoryNow;
454+ (void)_clearPrivateBrowsingSessionCookieStorage;
455
456- (void)_replaceCurrentHistoryItem:(WebHistoryItem *)item;
457#endif // PLATFORM(IOS)
458
459#if TARGET_OS_IPHONE
460- (NSDictionary *)quickLookContentForURL:(NSURL *)url;
461#endif
462
463// May well become public
464- (void)_setFormDelegate:(id<WebFormDelegate>)delegate;
465- (id<WebFormDelegate>)_formDelegate;
466
467- (BOOL)_isClosed;
468
469// _close is now replaced by public method -close. It remains here only for backward compatibility
470// until callers can be weaned off of it.
471- (void)_close;
472
473// Indicates if the WebView is in the midst of a user gesture.
474- (BOOL)_isProcessingUserGesture;
475
476// Determining and updating page visibility state.
477- (BOOL)_isViewVisible;
478- (void)_updateVisibilityState;
479
480// SPI for DumpRenderTree
481- (void)_updateActiveState;
482
483/*!
484    @method _registerViewClass:representationClass:forURLScheme:
485    @discussion Register classes that implement WebDocumentView and WebDocumentRepresentation respectively.
486    @param viewClass The WebDocumentView class to use to render data for a given MIME type.
487    @param representationClass The WebDocumentRepresentation class to use to represent data of the given MIME type.
488    @param scheme The URL scheme to represent with an object of the given class.
489*/
490+ (void)_registerViewClass:(Class)viewClass representationClass:(Class)representationClass forURLScheme:(NSString *)URLScheme;
491
492+ (void)_unregisterViewClassAndRepresentationClassForMIMEType:(NSString *)MIMEType;
493
494/*!
495     @method _canHandleRequest:
496     @abstract Performs a "preflight" operation that performs some
497     speculative checks to see if a request can be used to create
498     a WebDocumentView and WebDocumentRepresentation.
499     @discussion The result of this method is valid only as long as no
500     protocols or schemes are registered or unregistered, and as long as
501     the request is not mutated (if the request is mutable). Hence, clients
502     should be prepared to handle failures even if they have performed request
503     preflighting by caling this method.
504     @param request The request to preflight.
505     @result YES if it is likely that a WebDocumentView and WebDocumentRepresentation
506     can be created for the request, NO otherwise.
507*/
508+ (BOOL)_canHandleRequest:(NSURLRequest *)request;
509
510+ (NSString *)_decodeData:(NSData *)data;
511
512+ (void)_setAlwaysUsesComplexTextCodePath:(BOOL)f;
513
514+ (void)_setAllowsRoundingHacks:(BOOL)allowsRoundingHacks;
515+ (BOOL)_allowsRoundingHacks;
516
517#if !TARGET_OS_IPHONE
518- (NSCachedURLResponse *)_cachedResponseForURL:(NSURL *)URL;
519#endif
520
521#if ENABLE_DASHBOARD_SUPPORT
522- (void)_addScrollerDashboardRegions:(NSMutableDictionary *)regions;
523- (NSDictionary *)_dashboardRegions;
524
525- (void)_setDashboardBehavior:(WebDashboardBehavior)behavior to:(BOOL)flag;
526- (BOOL)_dashboardBehavior:(WebDashboardBehavior)behavior;
527#endif
528
529+ (void)_setShouldUseFontSmoothing:(BOOL)f;
530+ (BOOL)_shouldUseFontSmoothing;
531
532#if !TARGET_OS_IPHONE
533// These two methods are useful for a test harness that needs a consistent appearance for the focus rings
534// regardless of OS X version.
535+ (void)_setUsesTestModeFocusRingColor:(BOOL)f;
536+ (BOOL)_usesTestModeFocusRingColor;
537#endif
538
539#if TARGET_OS_IPHONE
540- (void)_setUIKitDelegate:(id)delegate;
541- (id)_UIKitDelegate;
542- (void)_clearDelegates;
543
544- (NSURL *)_displayURL;
545
546+ (NSArray *)_productivityDocumentMIMETypes;
547
548- (void)_setAllowsMessaging:(BOOL)aFlag;
549- (BOOL)_allowsMessaging;
550
551- (void)_setCustomFixedPositionLayoutRectInWebThread:(CGRect)rect synchronize:(BOOL)synchronize;
552- (void)_setCustomFixedPositionLayoutRect:(CGRect)rect;
553
554- (WebFixedPositionContent*)_fixedPositionContent;
555
556- (void)_viewGeometryDidChange;
557- (void)_overflowScrollPositionChangedTo:(CGPoint)offset forNode:(DOMNode *)node isUserScroll:(BOOL)userScroll;
558
559- (NSArray *)_touchEventRegions;
560
561/*!
562    @method _doNotStartObservingNetworkReachability
563    @abstract Does not start observation of network reachability in any WebView.
564    @discussion To take effect, this method must be called before the first WebView is created.
565 */
566+ (void)_doNotStartObservingNetworkReachability;
567#endif
568
569#if !TARGET_OS_IPHONE
570/*!
571    @method setAlwaysShowVerticalScroller:
572    @result Forces the vertical scroller to be visible if flag is YES, otherwise
573    if flag is NO the scroller with automatically show and hide as needed.
574 */
575- (void)setAlwaysShowVerticalScroller:(BOOL)flag;
576
577/*!
578    @method alwaysShowVerticalScroller
579    @result YES if the vertical scroller is always shown
580 */
581- (BOOL)alwaysShowVerticalScroller;
582
583/*!
584    @method setAlwaysShowHorizontalScroller:
585    @result Forces the horizontal scroller to be visible if flag is YES, otherwise
586    if flag is NO the scroller with automatically show and hide as needed.
587 */
588- (void)setAlwaysShowHorizontalScroller:(BOOL)flag;
589
590/*!
591    @method alwaysShowHorizontalScroller
592    @result YES if the horizontal scroller is always shown
593 */
594- (BOOL)alwaysShowHorizontalScroller;
595
596/*!
597    @method setProhibitsMainFrameScrolling:
598    @abstract Prohibits scrolling in the WebView's main frame.  Used to "lock" a WebView
599    to a specific scroll position.
600  */
601- (void)setProhibitsMainFrameScrolling:(BOOL)prohibits;
602
603/*!
604    @method _setAdditionalWebPlugInPaths:
605    @abstract Sets additional plugin search paths for a specific WebView.
606 */
607- (void)_setAdditionalWebPlugInPaths:(NSArray *)newPaths;
608#endif /* !TARGET_OS_IPHONE */
609
610#if TARGET_OS_IPHONE
611/*!
612    @method _pluginsAreRunning
613    @result Returns YES if any plug-ins in the WebView are running.
614 */
615- (BOOL)_pluginsAreRunning;
616/*!
617    @method _destroyAllPlugIns
618    @abstract Destroys all plug-ins in all of the WebView's frames.
619 */
620- (void)_destroyAllPlugIns;
621/*!
622    @method _startAllPlugIns
623    @abstract Starts all plug-ins in all of the WebView's frames.
624 */
625- (void)_startAllPlugIns;
626/*!
627    @method _stopAllPlugIns
628    @abstract Stops all plug-ins in all of the WebView's frames.
629 */
630- (void)_stopAllPlugIns;
631/*!
632    @method _stopAllPlugInsForPageCache
633    @abstract Stops all plug-ins in all of the WebView's frames.
634    Called when the page is entering the PageCache and lets the
635    plug-in know this by sending -webPlugInStopForPageCache.
636*/
637- (void)_stopAllPlugInsForPageCache;
638/*!
639    @method _restorePlugInsFromCache
640    @abstract Reconnects plug-ins from all of the WebView's frames to the
641    WebView and performs any other necessary reinitialization.
642 */
643- (void)_restorePlugInsFromCache;
644
645/*!
646    @method _setMediaLayer:forPluginView:
647    @abstract Set the layer that renders plug-in content for the given pluginView.
648    If layer is NULL, removes any existing layer. Returns YES if the set or
649    remove was successful.
650 */
651- (BOOL)_setMediaLayer:(CALayer*)layer forPluginView:(NSView*)pluginView;
652
653/*!
654    @method _clearBackForwardCache
655    @abstract Clear's this WebView's back/forward cache on the WebThread.
656 */
657- (void)_clearBackForwardCache;
658
659/*!
660 @method _wantsTelephoneNumberParsing
661 @abstract Does this WebView want phone number parsing? (This could ultimately be disallowed by the document itself).
662 */
663
664- (BOOL)_wantsTelephoneNumberParsing;
665
666/*!
667 @method _setWantsTelephoneNumberParsing
668 @abstract Explicitly disable WebKit phone number parsing on this WebView, or say that you want it enabled if possible.
669 */
670
671- (void)_setWantsTelephoneNumberParsing:(BOOL)flag;
672
673/*!
674    @method _setNeedsUnrestrictedGetMatchedCSSRules
675    @abstract Explicitly enables/disables cross origin CSS rules matching.
676 */
677- (void)_setNeedsUnrestrictedGetMatchedCSSRules:(BOOL)flag;
678#endif /* TARGET_OS_IPHONE */
679
680/*!
681    @method _attachScriptDebuggerToAllFrames
682    @abstract Attaches a script debugger to all frames belonging to the receiver.
683 */
684- (void)_attachScriptDebuggerToAllFrames;
685
686/*!
687    @method _detachScriptDebuggerFromAllFrames
688    @abstract Detaches any script debuggers from all frames belonging to the receiver.
689 */
690- (void)_detachScriptDebuggerFromAllFrames;
691
692- (BOOL)defersCallbacks; // called by QuickTime plug-in
693- (void)setDefersCallbacks:(BOOL)defer; // called by QuickTime plug-in
694
695- (BOOL)usesPageCache;
696- (void)setUsesPageCache:(BOOL)usesPageCache;
697
698- (WebHistoryItem *)_globalHistoryItem;
699
700/*!
701    @method textIteratorForRect:
702    @param rect The rectangle of the document that we're interested in text from.
703    @result WebTextIterator object, initialized with a range that corresponds to
704    the passed-in rectangle.
705    @abstract This method gives the text for the approximate range of the document
706    corresponding to the rectangle. The range is determined by using hit testing at
707    the top left and bottom right of the rectangle. Because of that, there can be
708    text visible in the rectangle that is not included in the iterator. If you need
709    a guarantee of iterating all text that is visible, then you need to instead make
710    a WebTextIterator with a DOMRange that covers the entire document.
711 */
712- (WebTextIterator *)textIteratorForRect:(NSRect)rect;
713
714#if ENABLE_DASHBOARD_SUPPORT
715// <rdar://problem/5217124> Clients other than Dashboard, don't use this.
716// As of this writing, Dashboard uses this on Tiger, but not on Leopard or newer.
717- (void)handleAuthenticationForResource:(id)identifier challenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)dataSource;
718#endif
719
720#if !TARGET_OS_IPHONE
721- (void)_clearUndoRedoOperations;
722#endif
723
724/* Used to do fast (lower quality) scaling of images so that window resize can be quick. */
725- (BOOL)_inFastImageScalingMode;
726- (void)_setUseFastImageScalingMode:(BOOL)flag;
727
728- (BOOL)_cookieEnabled;
729- (void)_setCookieEnabled:(BOOL)enable;
730
731// SPI for DumpRenderTree
732- (void)_executeCoreCommandByName:(NSString *)name value:(NSString *)value;
733- (void)_clearMainFrameName;
734
735- (void)setSelectTrailingWhitespaceEnabled:(BOOL)flag;
736- (BOOL)isSelectTrailingWhitespaceEnabled;
737
738- (void)setMemoryCacheDelegateCallsEnabled:(BOOL)suspend;
739- (BOOL)areMemoryCacheDelegateCallsEnabled;
740
741#if !TARGET_OS_IPHONE
742+ (NSCursor *)_pointingHandCursor;
743#endif
744
745// SPI for DumpRenderTree
746- (BOOL)_postsAcceleratedCompositingNotifications;
747- (void)_setPostsAcceleratedCompositingNotifications:(BOOL)flag;
748- (BOOL)_isUsingAcceleratedCompositing;
749- (void)_setBaseCTM:(CGAffineTransform)transform forContext:(CGContextRef)context;
750
751// For DumpRenderTree
752- (BOOL)interactiveFormValidationEnabled;
753- (void)setInteractiveFormValidationEnabled:(BOOL)enabled;
754- (int)validationMessageTimerMagnification;
755- (void)setValidationMessageTimerMagnification:(int)newValue;
756
757// Returns YES if NSView -displayRectIgnoringOpacity:inContext: will produce a faithful representation of the content.
758- (BOOL)_isSoftwareRenderable;
759// When drawing into a bitmap context, we normally flatten compositing layers (and distort 3D transforms).
760// Clients who are able to capture their own copy of the compositing layers need to be able to disable this.
761- (void)_setIncludesFlattenedCompositingLayersWhenDrawingToBitmap:(BOOL)flag;
762- (BOOL)_includesFlattenedCompositingLayersWhenDrawingToBitmap;
763
764- (void)setTracksRepaints:(BOOL)flag;
765- (BOOL)isTrackingRepaints;
766- (void)resetTrackedRepaints;
767- (NSArray*)trackedRepaintRects; // Returned array contains rectValue NSValues.
768
769#if !TARGET_OS_IPHONE
770// Which pasteboard text is coming from in editing delegate methods such as shouldInsertNode.
771- (NSPasteboard *)_insertionPasteboard;
772#endif
773
774// Whitelists access from an origin (sourceOrigin) to a set of one or more origins described by the parameters:
775// - destinationProtocol: The protocol to grant access to.
776// - destinationHost: The host to grant access to.
777// - allowDestinationSubdomains: If host is a domain, setting this to YES will whitelist host and all its subdomains, recursively.
778+ (void)_addOriginAccessWhitelistEntryWithSourceOrigin:(NSString *)sourceOrigin destinationProtocol:(NSString *)destinationProtocol destinationHost:(NSString *)destinationHost allowDestinationSubdomains:(BOOL)allowDestinationSubdomains;
779+ (void)_removeOriginAccessWhitelistEntryWithSourceOrigin:(NSString *)sourceOrigin destinationProtocol:(NSString *)destinationProtocol destinationHost:(NSString *)destinationHost allowDestinationSubdomains:(BOOL)allowDestinationSubdomains;
780
781// Removes all white list entries created with _addOriginAccessWhitelistEntryWithSourceOrigin.
782+ (void)_resetOriginAccessWhitelists;
783
784// FIXME: The following two methods are deprecated in favor of the overloads below that take the WebUserContentInjectedFrames argument. https://bugs.webkit.org/show_bug.cgi?id=41800.
785+ (void)_addUserScriptToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist injectionTime:(WebUserScriptInjectionTime)injectionTime;
786+ (void)_addUserStyleSheetToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist;
787
788+ (void)_addUserScriptToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist injectionTime:(WebUserScriptInjectionTime)injectionTime injectedFrames:(WebUserContentInjectedFrames)injectedFrames;
789+ (void)_addUserStyleSheetToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist injectedFrames:(WebUserContentInjectedFrames)injectedFrames;
790+ (void)_removeUserScriptFromGroup:(NSString *)groupName world:(WebScriptWorld *)world url:(NSURL *)url;
791+ (void)_removeUserStyleSheetFromGroup:(NSString *)groupName world:(WebScriptWorld *)world url:(NSURL *)url;
792+ (void)_removeUserScriptsFromGroup:(NSString *)groupName world:(WebScriptWorld *)world;
793+ (void)_removeUserStyleSheetsFromGroup:(NSString *)groupName world:(WebScriptWorld *)world;
794+ (void)_removeAllUserContentFromGroup:(NSString *)groupName;
795
796// SPI for DumpRenderTree
797+ (void)_setLoadResourcesSerially:(BOOL)serialize;
798
799/*!
800    @method cssAnimationsSuspended
801    @abstract Returns whether or not CSS Animations are suspended.
802    @result YES if CSS Animations are suspended.
803*/
804- (BOOL)cssAnimationsSuspended;
805
806/*!
807    @method setCSSAnimationsSuspended
808    @param paused YES to suspend animations, NO to resume animations.
809    @discussion Suspends or resumes all running animations and transitions in the page.
810*/
811- (void)setCSSAnimationsSuspended:(BOOL)suspended;
812
813/*
814    SPI to revert back to buggy behavior that would allow new transitions
815    and animations to run even when the view is suspended (e.g. loading a
816    new document).
817*/
818- (BOOL)allowsNewCSSAnimationsWhileSuspended;
819- (void)setAllowsNewCSSAnimationsWhileSuspended:(BOOL)allowed;
820
821+ (void)_setDomainRelaxationForbidden:(BOOL)forbidden forURLScheme:(NSString *)scheme;
822+ (void)_registerURLSchemeAsSecure:(NSString *)scheme;
823+ (void)_registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing:(NSString *)scheme;
824+ (void)_registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing:(NSString *)scheme;
825
826- (void)_scaleWebView:(float)scale atOrigin:(NSPoint)origin;
827- (float)_viewScaleFactor;
828
829- (void)_setUseFixedLayout:(BOOL)fixed;
830- (void)_setFixedLayoutSize:(NSSize)size;
831
832- (BOOL)_useFixedLayout;
833- (NSSize)_fixedLayoutSize;
834
835- (void)_setPaginationMode:(WebPaginationMode)paginationMode;
836- (WebPaginationMode)_paginationMode;
837
838- (void)_listenForLayoutMilestones:(WebLayoutMilestones)layoutMilestones;
839- (WebLayoutMilestones)_layoutMilestones;
840
841- (WebPageVisibilityState)_visibilityState;
842- (void)_setVisibilityState:(WebPageVisibilityState)visibilityState isInitialState:(BOOL)isInitialState;
843
844// Whether the column-break-{before,after} properties are respected instead of the
845// page-break-{before,after} properties.
846- (void)_setPaginationBehavesLikeColumns:(BOOL)behavesLikeColumns;
847- (BOOL)_paginationBehavesLikeColumns;
848
849// Set to 0 to have the page length equal the view length.
850- (void)_setPageLength:(CGFloat)pageLength;
851- (CGFloat)_pageLength;
852- (void)_setGapBetweenPages:(CGFloat)pageGap;
853- (CGFloat)_gapBetweenPages;
854- (NSUInteger)_pageCount;
855
856#if !TARGET_OS_IPHONE
857- (void)_setCustomBackingScaleFactor:(CGFloat)overrideScaleFactor;
858- (CGFloat)_backingScaleFactor;
859#endif
860
861// Deprecated. Use the methods in pending public above instead.
862- (NSUInteger)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight limit:(NSUInteger)limit;
863- (NSUInteger)countMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight limit:(NSUInteger)limit markMatches:(BOOL)markMatches;
864
865/*!
866 @method searchFor:direction:caseSensitive:wrap:startInSelection:
867 @abstract Searches a document view for a string and highlights the string if it is found.
868 Starts the search from the current selection.  Will search across all frames.
869 @param string The string to search for.
870 @param forward YES to search forward, NO to seach backwards.
871 @param caseFlag YES to for case-sensitive search, NO for case-insensitive search.
872 @param wrapFlag YES to wrap around, NO to avoid wrapping.
873 @param startInSelection YES to begin search in the selected text (useful for incremental searching), NO to begin search after the selected text.
874 @result YES if found, NO if not found.
875 */
876// Deprecated. Use findString.
877- (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag startInSelection:(BOOL)startInSelection;
878
879/*!
880    @method _HTTPPipeliningEnabled
881    @abstract Checks the HTTP pipelining status.
882    @discussion Defaults to NO.
883    @result YES if HTTP pipelining is enabled, NO if not enabled.
884 */
885+ (BOOL)_HTTPPipeliningEnabled;
886
887/*!
888    @method _setHTTPPipeliningEnabled:
889    @abstract Set the HTTP pipelining status.
890    @discussion Defaults to NO.
891    @param enabled The new HTTP pipelining status.
892 */
893+ (void)_setHTTPPipeliningEnabled:(BOOL)enabled;
894
895@property (nonatomic, copy, getter=_sourceApplicationAuditData, setter=_setSourceApplicationAuditData:) NSData *sourceApplicationAuditData;
896
897- (void)_setFontFallbackPrefersPictographs:(BOOL)flag;
898
899@end
900
901#if !TARGET_OS_IPHONE
902@interface WebView (WebViewPrintingPrivate)
903/*!
904    @method _adjustPrintingMarginsForHeaderAndFooter:
905    @abstract Increase the top and bottom margins for the current print operation to
906    account for the header and footer height.
907    @discussion Called by <WebDocument> implementors once when a print job begins. If the
908    <WebDocument> implementor implements knowsPageRange:, this should be called from there.
909    Otherwise this should be called from beginDocument. The <WebDocument> implementors need
910    to also call _drawHeaderAndFooter.
911*/
912- (void)_adjustPrintingMarginsForHeaderAndFooter;
913
914/*!
915    @method _drawHeaderAndFooter
916    @abstract Gives the WebView's UIDelegate a chance to draw a header and footer on the
917    printed page.
918    @discussion This should be called by <WebDocument> implementors from an override of
919    drawPageBorderWithSize:.
920*/
921- (void)_drawHeaderAndFooter;
922@end
923
924@interface WebView (WebViewGrammarChecking)
925
926// FIXME: These two methods should be merged into WebViewEditing when we're not in API freeze
927- (BOOL)isGrammarCheckingEnabled;
928- (void)setGrammarCheckingEnabled:(BOOL)flag;
929
930// FIXME: This method should be merged into WebIBActions when we're not in API freeze
931- (void)toggleGrammarChecking:(id)sender;
932
933@end
934
935@interface WebView (WebViewTextChecking)
936
937- (BOOL)isAutomaticQuoteSubstitutionEnabled;
938- (BOOL)isAutomaticLinkDetectionEnabled;
939- (BOOL)isAutomaticDashSubstitutionEnabled;
940- (BOOL)isAutomaticTextReplacementEnabled;
941- (BOOL)isAutomaticSpellingCorrectionEnabled;
942- (void)setAutomaticQuoteSubstitutionEnabled:(BOOL)flag;
943- (void)toggleAutomaticQuoteSubstitution:(id)sender;
944- (void)setAutomaticLinkDetectionEnabled:(BOOL)flag;
945- (void)toggleAutomaticLinkDetection:(id)sender;
946- (void)setAutomaticDashSubstitutionEnabled:(BOOL)flag;
947- (void)toggleAutomaticDashSubstitution:(id)sender;
948- (void)setAutomaticTextReplacementEnabled:(BOOL)flag;
949- (void)toggleAutomaticTextReplacement:(id)sender;
950- (void)setAutomaticSpellingCorrectionEnabled:(BOOL)flag;
951- (void)toggleAutomaticSpellingCorrection:(id)sender;
952@end
953#endif /* !TARGET_OS_IPHONE */
954
955@interface WebView (WebViewEditingInMail)
956- (void)_insertNewlineInQuotedContent;
957- (void)_replaceSelectionWithNode:(DOMNode *)node matchStyle:(BOOL)matchStyle;
958- (BOOL)_selectionIsCaret;
959- (BOOL)_selectionIsAll;
960- (void)_simplifyMarkup:(DOMNode *)startNode endNode:(DOMNode *)endNode;
961
962@end
963
964@interface WebView (WebViewDeviceOrientation)
965- (void)_setDeviceOrientationProvider:(id<WebDeviceOrientationProvider>)deviceOrientationProvider;
966- (id<WebDeviceOrientationProvider>)_deviceOrientationProvider;
967@end
968
969#if TARGET_OS_IPHONE
970@protocol WebGeolocationProvider;
971
972@protocol WebGeolocationProviderInitializationListener <NSObject>
973- (void)initializationAllowedWebView:(WebView *)webView;
974- (void)initializationDeniedWebView:(WebView *)webView;
975@end
976
977#endif
978
979@interface WebView (WebViewUserMedia)
980- (void)_setUserMediaClient:(id<WebUserMediaClient>)userMediaClient;
981- (id<WebUserMediaClient>)_userMediaClient;
982@end
983
984@protocol WebGeolocationProvider <NSObject>
985- (void)registerWebView:(WebView *)webView;
986- (void)unregisterWebView:(WebView *)webView;
987- (WebGeolocationPosition *)lastPosition;
988#if TARGET_OS_IPHONE
989- (void)setEnableHighAccuracy:(BOOL)enableHighAccuracy;
990- (void)initializeGeolocationForWebView:(WebView *)webView listener:(id<WebGeolocationProviderInitializationListener>)listener;
991- (void)stopTrackingWebView:(WebView *)webView;
992#endif
993@end
994
995@protocol WebNotificationProvider
996- (void)registerWebView:(WebView *)webView;
997- (void)unregisterWebView:(WebView *)webView;
998
999- (void)showNotification:(WebNotification *)notification fromWebView:(WebView *)webView;
1000- (void)cancelNotification:(WebNotification *)notification;
1001- (void)notificationDestroyed:(WebNotification *)notification;
1002- (void)clearNotifications:(NSArray *)notificationIDs;
1003- (WebNotificationPermission)policyForOrigin:(WebSecurityOrigin *)origin;
1004
1005- (void)webView:(WebView *)webView didShowNotification:(uint64_t)notificationID;
1006- (void)webView:(WebView *)webView didClickNotification:(uint64_t)notificationID;
1007- (void)webView:(WebView *)webView didCloseNotifications:(NSArray *)notificationIDs;
1008@end
1009
1010@interface WebView (WebViewGeolocation)
1011- (void)_setGeolocationProvider:(id<WebGeolocationProvider>)locationProvider;
1012- (id<WebGeolocationProvider>)_geolocationProvider;
1013
1014- (void)_geolocationDidChangePosition:(WebGeolocationPosition *)position;
1015- (void)_geolocationDidFailWithMessage:(NSString *)errorMessage;
1016#if TARGET_OS_IPHONE
1017- (void)_resetAllGeolocationPermission;
1018#endif
1019@end
1020
1021@interface WebView (WebViewNotification)
1022- (void)_setNotificationProvider:(id<WebNotificationProvider>)notificationProvider;
1023- (id<WebNotificationProvider>)_notificationProvider;
1024
1025- (void)_notificationDidShow:(uint64_t)notificationID;
1026- (void)_notificationDidClick:(uint64_t)notificationID;
1027- (void)_notificationsDidClose:(NSArray *)notificationIDs;
1028
1029- (uint64_t)_notificationIDForTesting:(JSValueRef)jsNotification;
1030@end
1031
1032#if TARGET_OS_IPHONE
1033@interface WebView (WebViewIOSPDF)
1034+ (Class)_getPDFRepresentationClass;
1035+ (void)_setPDFRepresentationClass:(Class)pdfRepresentationClass;
1036
1037+ (Class)_getPDFViewClass;
1038+ (void)_setPDFViewClass:(Class)pdfViewClass;
1039@end
1040#endif
1041
1042@interface NSObject (WebViewFrameLoadDelegatePrivate)
1043- (void)webView:(WebView *)sender didFirstLayoutInFrame:(WebFrame *)frame;
1044
1045// didFinishDocumentLoadForFrame is sent when the document has finished loading, though not necessarily all
1046// of its subresources.
1047// FIXME 5259339: Currently this callback is not sent for (some?) pages loaded entirely from the cache.
1048- (void)webView:(WebView *)sender didFinishDocumentLoadForFrame:(WebFrame *)frame;
1049
1050// Addresses 4192534.  SPI for now.
1051- (void)webView:(WebView *)sender didHandleOnloadEventsForFrame:(WebFrame *)frame;
1052
1053- (void)webView:(WebView *)sender didFirstVisuallyNonEmptyLayoutInFrame:(WebFrame *)frame;
1054
1055- (void)webView:(WebView *)sender didLayout:(WebLayoutMilestones)milestones;
1056
1057// For implementing the WebInspector's test harness
1058- (void)webView:(WebView *)webView didClearInspectorWindowObject:(WebScriptObject *)windowObject forFrame:(WebFrame *)frame;
1059
1060@end
1061
1062@interface NSObject (WebViewResourceLoadDelegatePrivate)
1063// Addresses <rdar://problem/5008925> - SPI for now
1064- (NSCachedURLResponse *)webView:(WebView *)sender resource:(id)identifier willCacheResponse:(NSCachedURLResponse *)response fromDataSource:(WebDataSource *)dataSource;
1065@end
1066
1067#ifdef __cplusplus
1068extern "C" {
1069#endif
1070
1071// This is a C function to avoid calling +[WebView initialize].
1072void WebInstallMemoryPressureHandler(void);
1073
1074#ifdef __cplusplus
1075}
1076#endif
1077