2 * Copyright (C) 2003, 2004, 2005, 2007 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 <Foundation/Foundation.h>
30 #import <JavaScriptCore/JSBase.h>
33 @class DOMHTMLElement;
37 @class WebFramePrivate;
39 @class WebScriptObject;
44 @discussion Every web page is represented by at least one WebFrame. A WebFrame
45 has a WebFrameView and a WebDataSource.
47 @interface WebFrame : NSObject
50 WebFramePrivate *_private;
54 @method initWithName:webFrameView:webView:
55 @abstract The designated initializer of WebFrame.
56 @discussion WebFrames are normally created for you by the WebView. You should
57 not need to invoke this method directly.
58 @param name The name of the frame.
59 @param view The WebFrameView for the frame.
60 @param webView The WebView that manages the frame.
61 @result Returns an initialized WebFrame.
63 - (id)initWithName:(NSString *)name webFrameView:(WebFrameView *)view webView:(WebView *)webView;
67 @result The frame name.
73 @result Returns the WebView for the document that includes this frame.
79 @result The WebFrameView for this frame.
81 - (WebFrameView *)frameView;
85 @abstract Returns the DOM document of the frame.
86 @description Returns nil if the frame does not contain a DOM document such as a standalone image.
88 - (DOMDocument *)DOMDocument;
92 @abstract Returns the frame element of the frame.
93 @description The class of the result is either DOMHTMLFrameElement, DOMHTMLIFrameElement or DOMHTMLObjectElement.
94 Returns nil if the frame is the main frame since there is no frame element for the frame in this case.
96 - (DOMHTMLElement *)frameElement;
100 @param request The web request to load.
102 - (void)loadRequest:(NSURLRequest *)request;
105 @method loadData:MIMEType:textEncodingName:baseURL:
106 @param data The data to use for the main page of the document.
107 @param MIMEType The MIME type of the data.
108 @param encodingName The encoding of the data.
109 @param URL The base URL to apply to relative URLs within the document.
111 - (void)loadData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)encodingName baseURL:(NSURL *)URL;
114 @method loadHTMLString:baseURL:
115 @param string The string to use for the main page of the document.
116 @param URL The base URL to apply to relative URLs within the document.
118 - (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)URL;
121 @method loadAlternateHTMLString:baseURL:forUnreachableURL:
122 @abstract Loads a page to display as a substitute for a URL that could not be reached.
123 @discussion This allows clients to display page-loading errors in the webview itself.
124 This is typically called while processing the WebFrameLoadDelegate method
125 -webView:didFailProvisionalLoadWithError:forFrame: or one of the the WebPolicyDelegate methods
126 -webView:decidePolicyForMIMEType:request:frame:decisionListener: or
127 -webView:unableToImplementPolicyWithError:frame:. If it is called from within one of those
128 three delegate methods then the back/forward list will be maintained appropriately.
129 @param string The string to use for the main page of the document.
130 @param baseURL The baseURL to apply to relative URLs within the document.
131 @param unreachableURL The URL for which this page will serve as alternate content.
133 - (void)loadAlternateHTMLString:(NSString *)string baseURL:(NSURL *)baseURL forUnreachableURL:(NSURL *)unreachableURL;
137 @abstract Causes WebFrame to load a WebArchive.
138 @param archive The archive to be loaded.
140 - (void)loadArchive:(WebArchive *)archive;
144 @discussion Returns the committed data source. Will return nil if the
145 provisional data source hasn't yet been loaded.
146 @result The datasource for this frame.
148 - (WebDataSource *)dataSource;
151 @method provisionalDataSource
152 @discussion Will return the provisional data source. The provisional data source will
153 be nil if no data source has been set on the frame, or the data source
154 has successfully transitioned to the committed data source.
155 @result The provisional datasource of this frame.
157 - (WebDataSource *)provisionalDataSource;
161 @discussion Stop any pending loads on the frame's data source,
168 @discussion Performs HTTP/1.1 end-to-end revalidation using cache-validating conditionals if possible.
173 @method reloadFromOrigin
174 @discussion Performs HTTP/1.1 end-to-end reload.
176 - (void)reloadFromOrigin;
179 @method findFrameNamed:
180 @discussion This method returns a frame with the given name. findFrameNamed returns self
181 for _self and _current, the parent frame for _parent and the main frame for _top.
182 findFrameNamed returns self for _parent and _top if the receiver is the mainFrame.
183 findFrameNamed first searches from the current frame to all descending frames then the
184 rest of the frames in the WebView. If still not found, findFrameNamed searches the
185 frames of the other WebViews.
186 @param name The name of the frame to find.
187 @result The frame matching the provided name. nil if the frame is not found.
189 - (WebFrame *)findFrameNamed:(NSString *)name;
193 @result The frame containing this frame, or nil if this is a top level frame.
195 - (WebFrame *)parentFrame;
199 @discussion The frames in the array are associated with a frame set or iframe.
200 @result Returns an array of WebFrame.
202 - (NSArray *)childFrames;
206 @result The WebScriptObject representing the frame's JavaScript window object.
208 - (WebScriptObject *)windowObject;
211 @method globalContext
212 @result The frame's global JavaScript execution context. Use this method to
213 bridge between the WebKit and JavaScriptCore APIs.
215 - (JSGlobalContextRef)globalContext;