• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2003, 2004, 2005 Apple Computer, 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 <Cocoa/Cocoa.h>
30 
31 @class NSError;
32 @class WebDataSource;
33 
34 /*!
35     @protocol WebDocumentView
36     @discussion Protocol implemented by the document view of WebFrameView
37 */
38 @protocol WebDocumentView <NSObject>
39 
40 /*!
41     @method setDataSource:
42     @abstract Called when the corresponding data source has been created.
43     @param dataSource The corresponding data source.
44 */
45 - (void)setDataSource:(WebDataSource *)dataSource;
46 
47 /*!
48     @method dataSourceUpdated:
49     @abstract Called when the corresponding data source has received data.
50     @param dataSource The corresponding data source.
51 */
52 - (void)dataSourceUpdated:(WebDataSource *)dataSource;
53 
54 /*!
55     @method setNeedsLayout:
56     @discussion Called when WebKit has determined that the document view needs to layout.
57     This method should simply set a flag and call layout from drawRect if the flag is YES.
58     @param flag YES to cause a layout, no to not cause a layout.
59 */
60 - (void)setNeedsLayout:(BOOL)flag;
61 
62 /*!
63     @method layout
64     @discussion Called when the document view must immediately layout. For simple views,
65     setting the frame is a sufficient implementation of this method.
66 */
67 - (void)layout;
68 
69 /*!
70     @method viewWillMoveToHostWindow:
71     @param hostWindow The host window for the document view.
72     @abstract Called before the host window is set on the parent web view.
73 */
74 - (void)viewWillMoveToHostWindow:(NSWindow *)hostWindow;
75 
76 /*!
77     @method viewDidMoveToHostWindow
78     @abstract Called after the host window is set on the parent web view.
79 */
80 - (void)viewDidMoveToHostWindow;
81 
82 @end
83 
84 
85 /*!
86     @protocol WebDocumentSearching
87     @discussion Optional protocol for searching document view of WebFrameView.
88 */
89 @protocol WebDocumentSearching <NSObject>
90 /*!
91     @method searchFor:direction:caseSensitive:wrap:
92     @abstract Searches a document view for a string and highlights the string if it is found.
93     @param string The string to search for.
94     @param forward YES to search forward, NO to seach backwards.
95     @param caseFlag YES to for case-sensitive search, NO for case-insensitive search.
96     @param wrapFlag YES to wrap around, NO to avoid wrapping.
97     @result YES if found, NO if not found.
98 */
99 - (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag;
100 @end
101 
102 
103 /*!
104     @protocol WebDocumentText
105     @discussion Optional protocol for supporting text operations.
106 */
107 @protocol WebDocumentText <NSObject>
108 
109 /*!
110     @method supportsTextEncoding
111     @result YES if the document view support text encoding, NO if it doesn't.
112 */
113 - (BOOL)supportsTextEncoding;
114 
115 /*!
116     @method string
117     @result String that represents the entire document.
118 */
119 - (NSString *)string;
120 
121 /*!
122     @method attributedString
123     @result Attributed string that represents the entire document.
124 */
125 - (NSAttributedString *)attributedString;
126 
127 /*!
128     @method selectedString
129     @result String that represents the current selection.
130 */
131 - (NSString *)selectedString;
132 
133 /*!
134     @method selectedAttributedString
135     @result Attributed string that represents the current selection.
136 */
137 - (NSAttributedString *)selectedAttributedString;
138 
139 
140 /*!
141     @method selectAll
142     @abstract Selects all the text in the document.
143 */
144 - (void)selectAll;
145 
146 /*!
147     @method deselectText
148     @abstract Causes a text selection to lose its selection.
149 */
150 - (void)deselectAll;
151 
152 @end
153 
154 
155 /*!
156     @protocol WebDocumentRepresentation
157     @discussion Protocol implemented by the document representation of a data source.
158 */
159 @protocol WebDocumentRepresentation <NSObject>
160 /*!
161     @method setDataSource:
162     @abstract Called soon after the document representation is created.
163     @param dataSource The data source that is set.
164 */
165 - (void)setDataSource:(WebDataSource *)dataSource;
166 
167 /*!
168     @method receivedData:withDataSource:
169     @abstract Called when the data source has received data.
170     @param data The data that the data source has received.
171     @param dataSource The data source that has received data.
172 */
173 - (void)receivedData:(NSData *)data withDataSource:(WebDataSource *)dataSource;
174 
175 /*!
176     @method receivedError:withDataSource:
177     @abstract Called when the data source has received an error.
178     @param error The error that the data source has received.
179     @param dataSource The data source that has received the error.
180 */
181 - (void)receivedError:(NSError *)error withDataSource:(WebDataSource *)dataSource;
182 
183 /*!
184     @method finishedLoadingWithDataSource:
185     @abstract Called when the data source has finished loading.
186     @param dataSource The datasource that has finished loading.
187 */
188 - (void)finishedLoadingWithDataSource:(WebDataSource *)dataSource;
189 
190 /*!
191     @method canProvideDocumentSource
192     @result Returns true if the representation can provide document source.
193 */
194 - (BOOL)canProvideDocumentSource;
195 
196 /*!
197     @method documentSource
198     @result Returns the textual source representation of the document.  For HTML documents
199     this is the original HTML source.
200 */
201 - (NSString *)documentSource;
202 
203 /*!
204     @method title
205     @result Return the title for the document.
206 */
207 - (NSString *)title;
208 
209 @end
210