source: trunk/ICeCoffEE/ICeCoffEE/WebCoreBridge.h@ 184

Last change on this file since 184 was 66, checked in by Nicholas Riley, 21 years ago

Initial import.

File size: 9.1 KB
Line 
1/*
2 * Copyright (C) 2002 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 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#import <Foundation/Foundation.h>
27
28#ifdef __cplusplus
29
30class KWQKHTMLPart;
31class KHTMLView;
32class RenderArena;
33
34namespace khtml {
35 class RenderPart;
36 class RenderObject;
37}
38
39typedef khtml::RenderPart KHTMLRenderPart;
40
41#else
42
43@class KWQKHTMLPart;
44@class KHTMLView;
45@class KHTMLRenderPart;
46@class RenderArena;
47
48#endif
49
50@class WebError;
51@class WebFrame;
52
53@protocol WebCoreDOMTreeCopier;
54@protocol WebCoreRenderTreeCopier;
55@protocol WebCoreResourceHandle;
56@protocol WebCoreResourceLoader;
57@protocol WebDOMDocument;
58@protocol WebDOMNode;
59
60extern NSString *WebCoreElementFrameKey;
61extern NSString *WebCoreElementImageAltStringKey;
62extern NSString *WebCoreElementImageKey;
63extern NSString *WebCoreElementImageLocationKey;
64extern NSString *WebCoreElementImageURLKey;
65extern NSString *WebCoreElementLinkURLKey;
66extern NSString *WebCoreElementLinkTargetFrameKey;
67extern NSString *WebCoreElementLinkLabelKey;
68extern NSString *WebCoreElementLinkTitleKey;
69extern NSString *WebCoreElementStringKey;
70
71// WebCoreBridge objects are used by WebCore to abstract away operations that need
72// to be implemented by library clients, for example WebKit. The objects are also
73// used in the opposite direction, for simple access to WebCore functions without dealing
74// directly with the KHTML C++ classes.
75
76// A WebCoreBridge creates and holds a reference to a KHTMLPart.
77
78// The WebCoreBridge interface contains methods for use by the non-WebCore side of the bridge.
79
80enum FrameBorderStyle {
81 NoFrameBorder = 1,
82 SunkenFrameBorder = 2,
83 PlainFrameBorder = 4
84};
85
86@interface WebCoreBridge : NSObject
87{
88 KWQKHTMLPart *_part;
89 KHTMLRenderPart *_renderPart;
90 RenderArena *_renderPartArena;
91}
92
93- (void)setRenderPart:(KHTMLRenderPart *)renderPart;
94- (KHTMLRenderPart *)renderPart;
95
96- (void)setName:(NSString *)name;
97- (NSString *)name;
98
99- (KWQKHTMLPart *)part;
100
101- (void)setParent:(WebCoreBridge *)parent;
102
103- (void)openURL:(NSString *)URL reload:(BOOL)reload headers:(NSDictionary *)headers lastModified:(NSDate *)lastModified pageCache:(NSDictionary *)pageCache;
104- (void)addData:(NSData *)data withEncoding:(NSString *)encoding;
105- (void)addData:(NSData *)data withOverrideEncoding:(NSString *)encoding;
106- (void)closeURL;
107- (void)saveDocumentState;
108- (void)restoreDocumentState;
109
110- (BOOL)canCachePage;
111- (BOOL)saveDocumentToPageCache;
112
113- (void)end;
114
115- (NSString *)URL;
116- (NSString *)referrer;
117
118- (void)installInFrame:(NSView *)view;
119- (void)removeFromFrame;
120
121- (void)scrollToAnchor:(NSString *)anchor;
122- (void)scrollToAnchorWithURL:(NSString *)URL;
123
124- (void)createKHTMLViewWithNSView:(NSView *)view marginWidth:(int)mw marginHeight:(int)mh;
125
126- (BOOL)isFrameSet;
127
128- (void)reapplyStyles;
129- (void)forceLayout;
130- (BOOL)needsLayout;
131- (void)adjustFrames:(NSRect)rect;
132- (void)drawRect:(NSRect)rect;
133
134- (void)mouseDown:(NSEvent *)event;
135- (void)mouseUp:(NSEvent *)event;
136- (void)mouseMoved:(NSEvent *)event;
137- (void)mouseDragged:(NSEvent *)event;
138
139- (NSView *)nextKeyView;
140- (NSView *)previousKeyView;
141
142- (NSView *)nextKeyViewInsideWebViews;
143- (NSView *)previousKeyViewInsideWebViews;
144
145- (NSObject *)copyDOMTree:(id <WebCoreDOMTreeCopier>)copier;
146- (NSObject *)copyRenderTree:(id <WebCoreRenderTreeCopier>)copier;
147
148- (NSDictionary *)elementAtPoint:(NSPoint)point;
149
150- (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag;
151- (void)jumpToSelection;
152
153- (void)setTextSizeMultiplier:(float)multiplier;
154
155- (CFStringEncoding)textEncoding;
156
157- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)string;
158
159- (id <WebDOMDocument>)DOMDocument;
160
161- (void)setSelectionFrom:(id <WebDOMNode>)start startOffset:(int)startOffset to:(id <WebDOMNode>)end endOffset:(int) endOffset;
162
163- (NSString *)selectedString;
164- (NSAttributedString *)selectedAttributedString;
165
166- (void)selectAll;
167- (void)deselectAll;
168
169- (id <WebDOMNode>)selectionStart;
170- (int)selectionStartOffset;
171- (id <WebDOMNode>)selectionEnd;
172- (int)selectionEndOffset;
173
174- (NSAttributedString *)attributedStringFrom:(id <WebDOMNode>)startNode startOffset:(int)startOffset to:(id <WebDOMNode>)endNode endOffset:(int)endOffset;
175
176- (int)frameBorderStyle;
177
178+ (NSString *)stringWithData:(NSData *)data textEncoding:(CFStringEncoding)textEncoding;
179+ (NSString *)stringWithData:(NSData *)data textEncodingName:(NSString *)textEncodingName;
180
181- (BOOL)interceptKeyEvent:(NSEvent *)event toView:(NSView *)view;
182
183@end
184
185// The WebCoreBridge protocol contains methods for use by the WebCore side of the bridge.
186
187@protocol WebCoreBridge
188
189- (NSArray *)childFrames; // WebCoreBridge objects
190- (WebCoreBridge *)mainFrame;
191- (WebCoreBridge *)findFramedNamed:(NSString *)name;
192- (WebCoreBridge *)findOrCreateFramedNamed:(NSString *)name;
193/* Creates a name for an frame unnamed in the HTML. It should produce repeatable results for loads of the same frameset. */
194- (NSString *)generateFrameName;
195
196- (void)loadURL:(NSString *)URL reload:(BOOL)reload triggeringEvent:(NSEvent *)event isFormSubmission:(BOOL)isFormSubmission;
197- (void)postWithURL:(NSString *)URL data:(NSData *)data contentType:(NSString *)contentType triggeringEvent:(NSEvent *)event;
198
199- (WebCoreBridge *)createWindowWithURL:(NSString *)URL frameName:(NSString *)name;
200- (void)showWindow;
201
202- (NSString *)userAgentForURL:(NSString *)URL;
203
204- (void)setTitle:(NSString *)title;
205- (void)setStatusText:(NSString *)status;
206
207- (void)setIconURL:(NSString *)URL;
208- (void)setIconURL:(NSString *)URL withType:(NSString *)string;
209
210- (WebCoreBridge *)createChildFrameNamed:(NSString *)frameName withURL:(NSString *)URL
211 renderPart:(KHTMLRenderPart *)renderPart
212 allowsScrolling:(BOOL)allowsScrolling marginWidth:(int)width marginHeight:(int)height;
213
214- (BOOL)areToolbarsVisible;
215- (void)setToolbarsVisible:(BOOL)visible;
216- (BOOL)isStatusBarVisible;
217- (void)setStatusBarVisible:(BOOL)visible;
218- (BOOL)areScrollbarsVisible;
219- (void)setScrollbarsVisible:(BOOL)visible;
220- (NSWindow *)window;
221- (void)setWindowFrame:(NSRect)frame;
222
223- (id <WebCoreResourceHandle>)startLoadingResource:(id <WebCoreResourceLoader>)loader withURL:(NSString *)URL;
224- (void)objectLoadedFromCacheWithURL:(NSString *)URL response:(id)response size:(unsigned)bytes;
225- (BOOL)isReloading;
226
227- (void)reportClientRedirectToURL:(NSString *)URL delay:(NSTimeInterval)seconds fireDate:(NSDate *)date lockHistory:(BOOL)lockHistory;
228- (void)reportClientRedirectCancelled;
229
230- (void)unfocusWindow;
231
232- (NSView *)nextKeyViewOutsideWebViews;
233- (NSView *)previousKeyViewOutsideWebViews;
234
235- (BOOL)defersLoading;
236- (void)setDefersLoading:(BOOL)loading;
237- (void)saveDocumentState:(NSArray *)documentState;
238- (NSArray *)documentState;
239
240- (void)setNeedsReapplyStyles;
241- (void)setNeedsLayout;
242
243- (NSString *)requestedURL;
244
245- (NSView *)viewForPluginWithURL:(NSString *)URL attributes:(NSArray *)attributesArray baseURL:(NSString *)baseURL MIMEType:(NSString *)MIMEType;
246- (NSView *)viewForJavaAppletWithFrame:(NSRect)frame attributes:(NSDictionary *)attributes baseURL:(NSString *)baseURL;
247
248- (BOOL)saveDocumentToPageCache:(id)documentInfo;
249
250- (int)getObjectCacheSize;
251
252- (void)loadEmptyDocumentSynchronously;
253
254- (NSString *)MIMETypeForPath:(NSString *)path;
255
256- (void)handleMouseDragged:(NSEvent *)event;
257- (void)handleAutoscrollForMouseDragged:(NSEvent *)event;
258- (BOOL)mayStartDragWithMouseDown:(NSEvent *)event;
259
260@end
261
262// This interface definition allows those who hold a WebCoreBridge * to call all the methods
263// in the WebCoreBridge protocol without requiring the base implementation to supply the methods.
264// This idiom is appropriate because WebCoreBridge is an abstract class.
265
266@interface WebCoreBridge (SubclassResponsibility) <WebCoreBridge>
267@end
268
269@protocol WebCoreDOMTreeCopier <NSObject>
270- (NSObject *)nodeWithName:(NSString *)name value:(NSString *)value source:(NSString *)source children:(NSArray *)children;
271@end
272
273@protocol WebCoreRenderTreeCopier <NSObject>
274- (NSObject *)nodeWithName:(NSString *)name position:(NSPoint)p rect:(NSRect)rect view:(NSView *)view children:(NSArray *)children;
275@end
Note: See TracBrowser for help on using the repository browser.