2 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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 Computer, 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.
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.
29 #import <WebKit/WebView.h>
30 #import <WebKit/WebFramePrivate.h>
32 #if !defined(ENABLE_DASHBOARD_SUPPORT)
33 #define ENABLE_DASHBOARD_SUPPORT 1
36 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
37 #define WebNSInteger int
38 #define WebNSUInteger unsigned int
40 #define WebNSInteger NSInteger
41 #define WebNSUInteger NSUInteger
47 @class WebPreferences;
48 @class WebTextIterator;
50 @protocol WebFormDelegate;
52 extern NSString *_WebCanGoBackKey;
53 extern NSString *_WebCanGoForwardKey;
54 extern NSString *_WebEstimatedProgressKey;
55 extern NSString *_WebIsLoadingKey;
56 extern NSString *_WebMainFrameIconKey;
57 extern NSString *_WebMainFrameTitleKey;
58 extern NSString *_WebMainFrameURLKey;
59 extern NSString *_WebMainFrameDocumentKey;
61 // pending public WebElementDictionary keys
62 extern NSString *WebElementTitleKey; // NSString of the title of the element (used by Safari)
63 extern NSString *WebElementSpellingToolTipKey; // NSString of a tooltip representing misspelling or bad grammar (used internally)
64 extern NSString *WebElementIsContentEditableKey; // NSNumber indicating whether the inner non-shared node is content editable (used internally)
66 // other WebElementDictionary keys
67 extern NSString *WebElementLinkIsLiveKey; // NSNumber of BOOL indictating whether the link is live or not
69 #if ENABLE_DASHBOARD_SUPPORT
71 WebDashboardBehaviorAlwaysSendMouseEventsToAllWindows,
72 WebDashboardBehaviorAlwaysSendActiveNullEventsToPlugIns,
73 WebDashboardBehaviorAlwaysAcceptsFirstMouse,
74 WebDashboardBehaviorAllowWheelScrolling,
75 WebDashboardBehaviorUseBackwardCompatibilityMode
76 } WebDashboardBehavior;
79 @interface WebController : NSTreeController {
80 IBOutlet WebView *webView;
83 - (void)setWebView:(WebView *)newWebView;
86 @interface WebView (WebViewEditingActionsPendingPublic)
88 - (void)outdent:(id)sender;
92 @interface WebView (WebPendingPublic)
94 - (void)scheduleInRunLoop:(NSRunLoop *)runLoop forMode:(NSString *)mode;
95 - (void)unscheduleFromRunLoop:(NSRunLoop *)runLoop forMode:(NSString *)mode;
98 @method searchFor:direction:caseSensitive:wrap:startInSelection:
99 @abstract Searches a document view for a string and highlights the string if it is found.
100 Starts the search from the current selection. Will search across all frames.
101 @param string The string to search for.
102 @param forward YES to search forward, NO to seach backwards.
103 @param caseFlag YES to for case-sensitive search, NO for case-insensitive search.
104 @param wrapFlag YES to wrap around, NO to avoid wrapping.
105 @param startInSelection YES to begin search in the selected text (useful for incremental searching), NO to begin search after the selected text.
106 @result YES if found, NO if not found.
108 - (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag startInSelection:(BOOL)startInSelection;
110 - (void)setMainFrameDocumentReady:(BOOL)mainFrameDocumentReady;
112 - (void)setTabKeyCyclesThroughElements:(BOOL)cyclesElements;
113 - (BOOL)tabKeyCyclesThroughElements;
115 - (void)scrollDOMRangeToVisible:(DOMRange *)range;
117 // setHoverFeedbackSuspended: can be called by clients that want to temporarily prevent the webView
118 // from displaying feedback about mouse position. Each WebDocumentView class that displays feedback
119 // about mouse position should honor this setting.
120 - (void)setHoverFeedbackSuspended:(BOOL)newValue;
121 - (BOOL)isHoverFeedbackSuspended;
124 @method setScriptDebugDelegate:
125 @abstract Set the WebView's WebScriptDebugDelegate delegate.
126 @param delegate The WebScriptDebugDelegate to set as the delegate.
128 - (void)setScriptDebugDelegate:(id)delegate;
131 @method scriptDebugDelegate
132 @abstract Return the WebView's WebScriptDebugDelegate.
133 @result The WebView's WebScriptDebugDelegate.
135 - (id)scriptDebugDelegate;
140 @method aeDescByEvaluatingJavaScriptFromString:
141 @param script The text of the JavaScript.
142 @result The result of the script, converted to an NSAppleEventDescriptor, or nil for failure.
144 - (NSAppleEventDescriptor *)aeDescByEvaluatingJavaScriptFromString:(NSString *)script;
146 // Support for displaying multiple text matches.
147 // These methods might end up moving into a protocol, so different document types can specify
148 // whether or not they implement the protocol. For now we'll just deal with HTML.
149 // These methods are still in flux; don't rely on them yet.
150 - (BOOL)canMarkAllTextMatches;
151 - (WebNSUInteger)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight limit:(WebNSUInteger)limit;
152 - (void)unmarkAllTextMatches;
153 - (NSArray *)rectsForTextMatches;
155 // Support for disabling registration with the undo manager. This is equivalent to the methods with the same names on NSTextView.
157 - (void)setAllowsUndo:(BOOL)flag;
160 @method setPageSizeMultiplier:
161 @abstract Change the zoom factor of the page in views managed by this webView.
162 @param multiplier A fractional percentage value, 1.0 is 100%.
164 - (void)setPageSizeMultiplier:(float)multiplier;
167 @method pageSizeMultiplier
168 @result The page size multipler.
170 - (float)pageSizeMultiplier;
172 // Commands for doing page zoom. Will end up in WebView (WebIBActions) <NSUserInterfaceValidations>
173 - (BOOL)canZoomPageIn;
174 - (IBAction)zoomPageIn:(id)sender;
175 - (BOOL)canZoomPageOut;
176 - (IBAction)zoomPageOut:(id)sender;
177 - (BOOL)canResetPageZoom;
178 - (IBAction)resetPageZoom:(id)sender;
180 // Sets a master volume control for all media elements in the WebView. Valid values are 0..1.
181 - (void)setMediaVolume:(float)volume;
182 - (float)mediaVolume;
186 @interface WebView (WebPrivate)
188 - (WebInspector *)inspector;
191 @method setBackgroundColor:
192 @param backgroundColor Color to use as the default background.
193 @abstract Sets what color the receiver draws under transparent page background colors and images.
194 This color is also used when no page is loaded. A color with alpha should only be used when the receiver is
195 in a non-opaque window, since the color is drawn using NSCompositeCopy.
197 - (void)setBackgroundColor:(NSColor *)backgroundColor;
200 @method backgroundColor
201 @result Returns the background color drawn under transparent page background colors and images.
202 This color is also used when no page is loaded. A color with alpha should only be used when the receiver is
203 in a non-opaque window, since the color is drawn using NSCompositeCopy.
205 - (NSColor *)backgroundColor;
208 Could be worth adding to the API.
209 @method loadItemsFromOtherView:
210 @abstract Loads the view with the contents of the other view, including its backforward list.
211 @param otherView The WebView from which to copy contents.
213 - (void)_loadBackForwardListFromOtherView:(WebView *)otherView;
215 + (NSArray *)_supportedFileExtensions;
219 @abstract Checks if the WebKit can show the content of the file at the specified path.
220 @param path The path of the file to check
221 @result YES if the WebKit can show the content of the file at the specified path.
223 + (BOOL)canShowFile:(NSString *)path;
226 @method suggestedFileExtensionForMIMEType:
227 @param MIMEType The MIME type to check.
228 @result The extension based on the MIME type
230 + (NSString *)suggestedFileExtensionForMIMEType: (NSString *)MIMEType;
232 + (NSString *)_standardUserAgentWithApplicationName:(NSString *)applicationName;
234 // May well become public
235 - (void)_setFormDelegate:(id<WebFormDelegate>)delegate;
236 - (id<WebFormDelegate>)_formDelegate;
240 // _close is now replaced by public method -close. It remains here only for backward compatibility
241 // until callers can be weaned off of it.
245 @method _registerViewClass:representationClass:forURLScheme:
246 @discussion Register classes that implement WebDocumentView and WebDocumentRepresentation respectively.
247 @param viewClass The WebDocumentView class to use to render data for a given MIME type.
248 @param representationClass The WebDocumentRepresentation class to use to represent data of the given MIME type.
249 @param scheme The URL scheme to represent with an object of the given class.
251 + (void)_registerViewClass:(Class)viewClass representationClass:(Class)representationClass forURLScheme:(NSString *)URLScheme;
253 + (void)_unregisterViewClassAndRepresentationClassForMIMEType:(NSString *)MIMEType;
256 @method _canHandleRequest:
257 @abstract Performs a "preflight" operation that performs some
258 speculative checks to see if a request can be used to create
259 a WebDocumentView and WebDocumentRepresentation.
260 @discussion The result of this method is valid only as long as no
261 protocols or schemes are registered or unregistered, and as long as
262 the request is not mutated (if the request is mutable). Hence, clients
263 should be prepared to handle failures even if they have performed request
264 preflighting by caling this method.
265 @param request The request to preflight.
266 @result YES if it is likely that a WebDocumentView and WebDocumentRepresentation
267 can be created for the request, NO otherwise.
269 + (BOOL)_canHandleRequest:(NSURLRequest *)request;
271 + (NSString *)_decodeData:(NSData *)data;
273 + (void)_setAlwaysUsesComplexTextCodePath:(BOOL)f;
274 // This is the old name of the above method. Needed for Safari versions that call it.
275 + (void)_setAlwaysUseATSU:(BOOL)f;
277 - (NSCachedURLResponse *)_cachedResponseForURL:(NSURL *)URL;
279 #if ENABLE_DASHBOARD_SUPPORT
280 - (void)_addScrollerDashboardRegions:(NSMutableDictionary *)regions;
281 - (NSDictionary *)_dashboardRegions;
283 - (void)_setDashboardBehavior:(WebDashboardBehavior)behavior to:(BOOL)flag;
284 - (BOOL)_dashboardBehavior:(WebDashboardBehavior)behavior;
287 + (void)_setShouldUseFontSmoothing:(BOOL)f;
288 + (BOOL)_shouldUseFontSmoothing;
290 - (void)_setCatchesDelegateExceptions:(BOOL)f;
291 - (BOOL)_catchesDelegateExceptions;
293 // These two methods are useful for a test harness that needs a consistent appearance for the focus rings
294 // regardless of OS X version.
295 + (void)_setUsesTestModeFocusRingColor:(BOOL)f;
296 + (BOOL)_usesTestModeFocusRingColor;
298 + (NSString *)_minimumRequiredSafariBuildNumber;
301 @method setAlwaysShowVerticalScroller:
302 @result Forces the vertical scroller to be visible if flag is YES, otherwise
303 if flag is NO the scroller with automatically show and hide as needed.
305 - (void)setAlwaysShowVerticalScroller:(BOOL)flag;
308 @method alwaysShowVerticalScroller
309 @result YES if the vertical scroller is always shown
311 - (BOOL)alwaysShowVerticalScroller;
314 @method setAlwaysShowHorizontalScroller:
315 @result Forces the horizontal scroller to be visible if flag is YES, otherwise
316 if flag is NO the scroller with automatically show and hide as needed.
318 - (void)setAlwaysShowHorizontalScroller:(BOOL)flag;
321 @method alwaysShowHorizontalScroller
322 @result YES if the horizontal scroller is always shown
324 - (BOOL)alwaysShowHorizontalScroller;
327 @method setProhibitsMainFrameScrolling:
328 @abstract Prohibits scrolling in the WebView's main frame. Used to "lock" a WebView
329 to a specific scroll position.
331 - (void)setProhibitsMainFrameScrolling:(BOOL)prohibits;
334 @method _setAdditionalWebPlugInPaths:
335 @abstract Sets additional plugin search paths for a specific WebView.
337 - (void)_setAdditionalWebPlugInPaths:(NSArray *)newPaths;
340 @method _setInViewSourceMode:
341 @abstract Used to place a WebView into a special source-viewing mode.
343 - (void)_setInViewSourceMode:(BOOL)flag;
346 @method _inViewSourceMode;
347 @abstract Whether or not the WebView is in source-view mode for HTML.
349 - (BOOL)_inViewSourceMode;
352 @method _attachScriptDebuggerToAllFrames
353 @abstract Attaches a script debugger to all frames belonging to the receiver.
355 - (void)_attachScriptDebuggerToAllFrames;
358 @method _detachScriptDebuggerFromAllFrames
359 @abstract Detaches any script debuggers from all frames belonging to the receiver.
361 - (void)_detachScriptDebuggerFromAllFrames;
363 - (BOOL)defersCallbacks; // called by QuickTime plug-in
364 - (void)setDefersCallbacks:(BOOL)defer; // called by QuickTime plug-in
366 - (BOOL)usesPageCache;
367 - (void)setUsesPageCache:(BOOL)usesPageCache;
369 - (WebHistoryItem *)_globalHistoryItem;
372 @method textIteratorForRect:
373 @param rectangle from which we want the WebTextIterator to load text from
374 @result a WebtextIterator object.
376 - (WebTextIterator *)textIteratorForRect:(NSRect)rect;
378 #if ENABLE_DASHBOARD_SUPPORT
379 // <rdar://problem/5217124> Clients other than dashboard, don't use this.
380 // Do not remove until Dashboard has moved off it
381 - (void)handleAuthenticationForResource:(id)identifier challenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)dataSource;
384 - (void)_clearUndoRedoOperations;
386 /* Used to do fast (lower quality) scaling of images so that window resize can be quick. */
387 - (BOOL)_inFastImageScalingMode;
388 - (void)_setUseFastImageScalingMode:(BOOL)flag;
390 - (BOOL)_cookieEnabled;
391 - (void)_setCookieEnabled:(BOOL)enable;
393 // SPI for DumpRenderTree
394 - (void)_executeCoreCommandByName:(NSString *)name value:(NSString *)value;
395 - (void)_clearMainFrameName;
397 - (void)_setCustomHTMLTokenizerTimeDelay:(double)timeDelay;
398 - (void)_setCustomHTMLTokenizerChunkSize:(int)chunkSize;
400 - (id)_initWithFrame:(NSRect)f frameName:(NSString *)frameName groupName:(NSString *)groupName usesDocumentViews:(BOOL)usesDocumentViews;
401 - (BOOL)_usesDocumentViews;
403 - (void)setSelectTrailingWhitespaceEnabled:(BOOL)flag;
404 - (BOOL)isSelectTrailingWhitespaceEnabled;
406 - (void)setMemoryCacheDelegateCallsEnabled:(BOOL)suspend;
407 - (BOOL)areMemoryCacheDelegateCallsEnabled;
409 - (void)_setJavaScriptURLsAreAllowed:(BOOL)setJavaScriptURLsAreAllowed;
411 + (NSCursor *)_pointingHandCursor;
413 // SPI for DumpRenderTree
414 - (BOOL)_isUsingAcceleratedCompositing;
418 @interface WebView (WebViewPrintingPrivate)
420 @method _adjustPrintingMarginsForHeaderAndFooter:
421 @abstract Increase the top and bottom margins for the current print operation to
422 account for the header and footer height.
423 @discussion Called by <WebDocument> implementors once when a print job begins. If the
424 <WebDocument> implementor implements knowsPageRange:, this should be called from there.
425 Otherwise this should be called from beginDocument. The <WebDocument> implementors need
426 to also call _drawHeaderAndFooter.
428 - (void)_adjustPrintingMarginsForHeaderAndFooter;
431 @method _drawHeaderAndFooter
432 @abstract Gives the WebView's UIDelegate a chance to draw a header and footer on the
434 @discussion This should be called by <WebDocument> implementors from an override of
435 drawPageBorderWithSize:.
437 - (void)_drawHeaderAndFooter;
440 @interface WebView (WebViewGrammarChecking)
442 // FIXME: These two methods should be merged into WebViewEditing when we're not in API freeze
443 - (BOOL)isGrammarCheckingEnabled;
444 #ifndef BUILDING_ON_TIGER
445 - (void)setGrammarCheckingEnabled:(BOOL)flag;
447 // FIXME: This method should be merged into WebIBActions when we're not in API freeze
448 - (void)toggleGrammarChecking:(id)sender;
452 @interface WebView (WebViewEditingInMail)
453 - (void)_insertNewlineInQuotedContent;
454 - (void)_replaceSelectionWithNode:(DOMNode *)node matchStyle:(BOOL)matchStyle;
457 @interface NSObject (WebFrameLoadDelegatePrivate)
458 - (void)webView:(WebView *)sender didFirstLayoutInFrame:(WebFrame *)frame;
460 // didFinishDocumentLoadForFrame is sent when the document has finished loading, though not necessarily all
461 // of its subresources.
462 // FIXME 5259339: Currently this callback is not sent for (some?) pages loaded entirely from the cache.
463 - (void)webView:(WebView *)sender didFinishDocumentLoadForFrame:(WebFrame *)frame;
465 // Addresses 4192534. SPI for now.
466 - (void)webView:(WebView *)sender didHandleOnloadEventsForFrame:(WebFrame *)frame;
468 - (void)webView:(WebView *)sender didFirstVisuallyNonEmptyLayoutInFrame:(WebFrame *)frame;
472 @interface NSObject (WebResourceLoadDelegatePrivate)
473 // Addresses <rdar://problem/5008925> - SPI for now
474 - (NSCachedURLResponse *)webView:(WebView *)sender resource:(id)identifier willCacheResponse:(NSCachedURLResponse *)response fromDataSource:(WebDataSource *)dataSource;