2 * Copyright (C) 2005 Apple Computer, 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>
34 @class WebPreferences;
35 @class WebCoreSettings;
37 @protocol WebFormDelegate;
39 typedef struct _WebResourceDelegateImplementationCache {
40 uint delegateImplementsDidCancelAuthenticationChallenge:1;
41 uint delegateImplementsDidReceiveAuthenticationChallenge:1;
42 uint delegateImplementsDidReceiveResponse:1;
43 uint delegateImplementsDidReceiveContentLength:1;
44 uint delegateImplementsDidFinishLoadingFromDataSource:1;
45 uint delegateImplementsWillSendRequest:1;
46 uint delegateImplementsIdentifierForRequest:1;
47 } WebResourceDelegateImplementationCache;
49 extern NSString *_WebCanGoBackKey;
50 extern NSString *_WebCanGoForwardKey;
51 extern NSString *_WebEstimatedProgressKey;
52 extern NSString *_WebIsLoadingKey;
53 extern NSString *_WebMainFrameIconKey;
54 extern NSString *_WebMainFrameTitleKey;
55 extern NSString *_WebMainFrameURLKey;
56 extern NSString *_WebMainFrameDocumentKey;
58 extern NSString *WebElementTitleKey; // NSString of the title of the element (pending public, used by Safari)
61 WebDashboardBehaviorAlwaysSendMouseEventsToAllWindows,
62 WebDashboardBehaviorAlwaysSendActiveNullEventsToPlugIns,
63 WebDashboardBehaviorAlwaysAcceptsFirstMouse,
64 WebDashboardBehaviorAllowWheelScrolling
65 } WebDashboardBehavior;
67 @interface WebController : NSTreeController {
68 IBOutlet WebView *webView;
71 - (void)setWebView:(WebView *)newWebView;
74 @interface WebView (WebPendingPublic)
76 - (void)setMainFrameDocumentReady:(BOOL)mainFrameDocumentReady;
78 - (void)setTabKeyCyclesThroughElements:(BOOL)cyclesElements;
79 - (BOOL)tabKeyCyclesThroughElements;
82 @method setScriptDebugDelegate:
83 @abstract Set the WebView's WebScriptDebugDelegate delegate.
84 @param delegate The WebScriptDebugDelegate to set as the delegate.
86 - (void)setScriptDebugDelegate:(id)delegate;
89 @method scriptDebugDelegate
90 @abstract Return the WebView's WebScriptDebugDelegate.
91 @result The WebView's WebScriptDebugDelegate.
93 - (id)scriptDebugDelegate;
98 @method aeDescByEvaluatingJavaScriptFromString:
99 @param script The text of the JavaScript.
100 @result The result of the script, converted to an NSAppleEventDescriptor, or nil for failure.
102 - (NSAppleEventDescriptor *)aeDescByEvaluatingJavaScriptFromString:(NSString *)script;
104 // Support for displaying multiple text matches.
105 // These methods might end up moving into a protocol, so different document types can specify
106 // whether or not they implement the protocol. For now we'll just deal with HTML.
107 // These methods are still in flux; don't rely on them yet.
108 - (unsigned)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight limit:(unsigned)limit;
109 - (void)unmarkAllTextMatches;
110 - (NSArray *)rectsForTextMatches;
114 @interface WebView (WebPrivate)
116 + (BOOL)_developerExtrasEnabled;
117 + (BOOL)_scriptDebuggerEnabled;
120 @method setBackgroundColor:
121 @param backgroundColor Color to use as the default background.
122 @abstract Sets what color the receiver draws under transparent page background colors and images.
123 This color is also used when no page is loaded. A color with alpha should only be used when the receiver is
124 in a non-opaque window, since the color is drawn using NSCompositeCopy.
126 - (void)setBackgroundColor:(NSColor *)backgroundColor;
129 @method backgroundColor
130 @result Returns the background color drawn under transparent page background colors and images.
131 This color is also used when no page is loaded. A color with alpha should only be used when the receiver is
132 in a non-opaque window, since the color is drawn using NSCompositeCopy.
134 - (NSColor *)backgroundColor;
137 Could be worth adding to the API.
138 @method loadItemsFromOtherView:
139 @abstract Loads the view with the contents of the other view, including its backforward list.
140 @param otherView The WebView from which to copy contents.
142 - (void)_loadBackForwardListFromOtherView:(WebView *)otherView;
144 + (NSArray *)_supportedFileExtensions;
148 @abstract Checks if the WebKit can show the content of the file at the specified path.
149 @param path The path of the file to check
150 @result YES if the WebKit can show the content of the file at the specified path.
152 + (BOOL)canShowFile:(NSString *)path;
155 @method suggestedFileExtensionForMIMEType:
156 @param MIMEType The MIME type to check.
157 @result The extension based on the MIME type
159 + (NSString *)suggestedFileExtensionForMIMEType: (NSString *)MIMEType;
162 // May well become public
163 - (void)_setFormDelegate:(id<WebFormDelegate>)delegate;
164 - (id<WebFormDelegate>)_formDelegate;
169 @method _registerViewClass:representationClass:forURLScheme:
170 @discussion Register classes that implement WebDocumentView and WebDocumentRepresentation respectively.
171 @param viewClass The WebDocumentView class to use to render data for a given MIME type.
172 @param representationClass The WebDocumentRepresentation class to use to represent data of the given MIME type.
173 @param scheme The URL scheme to represent with an object of the given class.
175 + (void)_registerViewClass:(Class)viewClass representationClass:(Class)representationClass forURLScheme:(NSString *)URLScheme;
177 + (void)_unregisterViewClassAndRepresentationClassForMIMEType:(NSString *)MIMEType;
180 @method _canHandleRequest:
181 @abstract Performs a "preflight" operation that performs some
182 speculative checks to see if a request can be used to create
183 a WebDocumentView and WebDocumentRepresentation.
184 @discussion The result of this method is valid only as long as no
185 protocols or schemes are registered or unregistered, and as long as
186 the request is not mutated (if the request is mutable). Hence, clients
187 should be prepared to handle failures even if they have performed request
188 preflighting by caling this method.
189 @param request The request to preflight.
190 @result YES if it is likely that a WebDocumentView and WebDocumentRepresentation
191 can be created for the request, NO otherwise.
193 + (BOOL)_canHandleRequest:(NSURLRequest *)request;
195 + (NSString *)_decodeData:(NSData *)data;
197 + (void)_setAlwaysUseATSU:(BOOL)f;
199 - (NSCachedURLResponse *)_cachedResponseForURL:(NSURL *)URL;
201 - (void)_addScrollerDashboardRegions:(NSMutableDictionary *)regions;
202 - (NSDictionary *)_dashboardRegions;
204 - (void)_setDashboardBehavior:(WebDashboardBehavior)behavior to:(BOOL)flag;
205 - (void)handleAuthenticationForResource:(id)identifier challenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)dataSource;
206 - (BOOL)_dashboardBehavior:(WebDashboardBehavior)behavior;
208 + (void)_setShouldUseFontSmoothing:(BOOL)f;
209 + (BOOL)_shouldUseFontSmoothing;
211 + (NSString *)_minimumRequiredSafariBuildNumber;
214 @method setAlwaysShowVerticalScroller:
215 @result Forces the vertical scroller to be visible if flag is YES, otherwise
216 if flag is NO the scroller with automatically show and hide as needed.
218 - (void)setAlwaysShowVerticalScroller:(BOOL)flag;
221 @method alwaysShowVerticalScroller
222 @result YES if the vertical scroller is always shown
224 - (BOOL)alwaysShowVerticalScroller;
227 @method setAlwaysShowHorizontalScroller:
228 @result Forces the horizontal scroller to be visible if flag is YES, otherwise
229 if flag is NO the scroller with automatically show and hide as needed.
231 - (void)setAlwaysShowHorizontalScroller:(BOOL)flag;
234 @method alwaysShowHorizontalScroller
235 @result YES if the horizontal scroller is always shown
237 - (BOOL)alwaysShowHorizontalScroller;
240 @method setProhibitsMainFrameScrolling:
241 @abstract Prohibits scrolling in the WebView's main frame. Used to "lock" a WebView
242 to a specific scroll position.
244 - (void)setProhibitsMainFrameScrolling:(BOOL)prohibits;
247 @method _setAdditionalWebPlugInPaths:
248 @abstract Sets additional plugin search paths for a specific WebView.
250 - (void)_setAdditionalWebPlugInPaths:(NSArray *)newPaths;
253 @method _setInViewSourceMode:
254 @abstract Used to place a WebView into a special source-viewing mode.
256 - (void)_setInViewSourceMode:(BOOL)flag;
259 @method _inViewSourceMode;
260 @abstract Whether or not the WebView is in source-view mode for HTML.
262 - (BOOL)_inViewSourceMode;
265 @method _attachScriptDebuggerToAllFrames
266 @abstract Attaches a script debugger to all frames belonging to the receiver.
268 - (void)_attachScriptDebuggerToAllFrames;
271 @method _detachScriptDebuggerFromAllFrames
272 @abstract Detaches any script debuggers from all frames belonging to the receiver.
274 - (void)_detachScriptDebuggerFromAllFrames;
278 @interface WebView (WebViewPrintingPrivate)
280 @method _adjustPrintingMarginsForHeaderAndFooter:
281 @abstract Increase the top and bottom margins for the current print operation to
282 account for the header and footer height.
283 @discussion Called by <WebDocument> implementors once when a print job begins. If the
284 <WebDocument> implementor implements knowsPageRange:, this should be called from there.
285 Otherwise this should be called from beginDocument. The <WebDocument> implementors need
286 to also call _drawHeaderAndFooter.
288 - (void)_adjustPrintingMarginsForHeaderAndFooter;
291 @method _drawHeaderAndFooter
292 @abstract Gives the WebView's UIDelegate a chance to draw a header and footer on the
294 @discussion This should be called by <WebDocument> implementors from an override of
295 drawPageBorderWithSize:.
297 - (void)_drawHeaderAndFooter;
300 @interface WebView (WebViewEditingInMail)
301 - (void)_insertNewlineInQuotedContent;
302 - (BOOL)_selectWordBeforeMenuEvent;
303 - (void)_setSelectWordBeforeMenuEvent:(BOOL)flag;
304 - (void)_replaceSelectionWithNode:(DOMNode *)node matchStyle:(BOOL)matchStyle;
307 @interface _WebSafeForwarder : NSObject
309 id target; // Non-retained. Don't retain delegates.
313 - (id)initWithTarget:(id)t defaultTarget:(id)dt templateClass:(Class)aClass;
314 + (id)safeForwarderWithTarget:(id)t defaultTarget:(id)dt templateClass:(Class)aClass;
317 @interface NSObject (WebFrameLoadDelegatePrivate)
318 - (void)webView:(WebView *)sender didFirstLayoutInFrame:(WebFrame *)frame;
319 // Addresses 4192534. Private API for now.
320 - (void)webView:(WebView *)sender didHandleOnloadEventsForFrame:(WebFrame *)frame;