Home | History | Annotate | Download | only in WebView
      1 /*
      2  * Copyright (C) 2003, 2004, 2005, 2007 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 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.
     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 <Foundation/Foundation.h>
     30 #import <JavaScriptCore/JSBase.h>
     31 
     32 @class DOMDocument;
     33 @class DOMHTMLElement;
     34 @class NSURLRequest;
     35 @class WebArchive;
     36 @class WebDataSource;
     37 @class WebFramePrivate;
     38 @class WebFrameView;
     39 @class WebScriptObject;
     40 @class WebView;
     41 
     42 /*!
     43     @class WebFrame
     44     @discussion Every web page is represented by at least one WebFrame.  A WebFrame
     45     has a WebFrameView and a WebDataSource.
     46 */
     47 @interface WebFrame : NSObject
     48 {
     49 @private
     50     WebFramePrivate *_private;
     51 }
     52 
     53 /*!
     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.
     62 */
     63 - (id)initWithName:(NSString *)name webFrameView:(WebFrameView *)view webView:(WebView *)webView;
     64 
     65 /*!
     66     @method name
     67     @result The frame name.
     68 */
     69 - (NSString *)name;
     70 
     71 /*!
     72     @method webView
     73     @result Returns the WebView for the document that includes this frame.
     74 */
     75 - (WebView *)webView;
     76 
     77 /*!
     78     @method frameView
     79     @result The WebFrameView for this frame.
     80 */
     81 - (WebFrameView *)frameView;
     82 
     83 /*!
     84     @method DOMDocument
     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.
     87 */
     88 - (DOMDocument *)DOMDocument;
     89 
     90 /*!
     91     @method frameElement
     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.
     95 */
     96 - (DOMHTMLElement *)frameElement;
     97 
     98 /*!
     99     @method loadRequest:
    100     @param request The web request to load.
    101 */
    102 - (void)loadRequest:(NSURLRequest *)request;
    103 
    104 /*!
    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.
    110 */
    111 - (void)loadData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)encodingName baseURL:(NSURL *)URL;
    112 
    113 /*!
    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.
    117 */
    118 - (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)URL;
    119 
    120 /*!
    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.
    132 */
    133 - (void)loadAlternateHTMLString:(NSString *)string baseURL:(NSURL *)baseURL forUnreachableURL:(NSURL *)unreachableURL;
    134 
    135 /*!
    136     @method loadArchive:
    137     @abstract Causes WebFrame to load a WebArchive.
    138     @param archive The archive to be loaded.
    139 */
    140 - (void)loadArchive:(WebArchive *)archive;
    141 
    142 /*!
    143     @method dataSource
    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.
    147 */
    148 - (WebDataSource *)dataSource;
    149 
    150 /*!
    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.
    156 */
    157 - (WebDataSource *)provisionalDataSource;
    158 
    159 /*!
    160     @method stopLoading
    161     @discussion Stop any pending loads on the frame's data source,
    162     and its children.
    163 */
    164 - (void)stopLoading;
    165 
    166 /*!
    167     @method reload
    168     @discussion Performs HTTP/1.1 end-to-end revalidation using cache-validating conditionals if possible.
    169 */
    170 - (void)reload;
    171 
    172 /*!
    173     @method reloadFromOrigin
    174     @discussion Performs HTTP/1.1 end-to-end reload.
    175 */
    176 - (void)reloadFromOrigin;
    177 
    178 /*!
    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.
    188 */
    189 - (WebFrame *)findFrameNamed:(NSString *)name;
    190 
    191 /*!
    192     @method parentFrame
    193     @result The frame containing this frame, or nil if this is a top level frame.
    194 */
    195 - (WebFrame *)parentFrame;
    196 
    197 /*!
    198     @method childFrames
    199     @discussion The frames in the array are associated with a frame set or iframe.
    200     @result Returns an array of WebFrame.
    201 */
    202 - (NSArray *)childFrames;
    203 
    204 /*!
    205     @method windowObject
    206     @result The WebScriptObject representing the frame's JavaScript window object.
    207 */
    208 - (WebScriptObject *)windowObject;
    209 
    210 /*!
    211     @method globalContext
    212     @result The frame's global JavaScript execution context. Use this method to
    213     bridge between the WebKit and JavaScriptCore APIs.
    214 */
    215 - (JSGlobalContextRef)globalContext;
    216 @end
    217