WebCoreFrameBridge.h 12.1 KB
Newer Older
1
/*
darin@apple.com's avatar
darin@apple.com committed
2
 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */
25

darin's avatar
darin committed
26
#import <Cocoa/Cocoa.h>
rjw's avatar
rjw committed
27
#import <JavaVM/jni.h>
darin's avatar
darin committed
28
#import <WebCore/WebCoreKeyboardUIMode.h>
andersca's avatar
andersca committed
29
#import <WebCore/EditAction.h>
andersca's avatar
andersca committed
30
#import <WebCore/FrameLoaderTypes.h>
andersca's avatar
andersca committed
31
#import <WebCore/SelectionController.h>
ggaren's avatar
ggaren committed
32
#import <WebCore/TextAffinity.h>
andersca's avatar
andersca committed
33 34
#import <WebCore/TextGranularity.h>

thatcher's avatar
thatcher committed
35 36 37 38
#if USE(NPOBJECT)
#import <JavaScriptCore/npruntime.h>
#endif

darin's avatar
darin committed
39
namespace WebCore {
mjs's avatar
mjs committed
40
    class Frame;
darin's avatar
darin committed
41
    class HTMLFrameOwnerElement;
ggaren's avatar
ggaren committed
42
    class Page;
ggaren's avatar
ggaren committed
43
    class String;
darin's avatar
darin committed
44 45
}

kocienda's avatar
kocienda committed
46
@class DOMCSSStyleDeclaration;
kocienda's avatar
Tests:  
kocienda committed
47
@class DOMDocument;
cblu's avatar
cblu committed
48
@class DOMDocumentFragment;
kocienda's avatar
Tests:  
kocienda committed
49
@class DOMElement;
sullivan's avatar
sullivan committed
50
@class DOMHTMLInputElement;
darin's avatar
darin committed
51
@class DOMHTMLTextAreaElement;
cblu's avatar
Tests:  
cblu committed
52
@class DOMNode;
cblu's avatar
Tests:  
cblu committed
53
@class DOMRange;
adele's avatar
adele committed
54
@class NSMenu;
darin's avatar
darin committed
55

darin's avatar
darin committed
56
@protocol WebCoreRenderTreeCopier;
darin's avatar
darin committed
57

darin's avatar
darin committed
58
enum WebCoreDeviceType {
darin's avatar
darin committed
59 60
    WebCoreDeviceScreen,
    WebCoreDevicePrinter
darin's avatar
darin committed
61
};
darin's avatar
darin committed
62

darin's avatar
darin committed
63
enum WebScrollDirection {
cblu's avatar
cblu committed
64 65 66 67
    WebScrollUp,
    WebScrollDown,
    WebScrollLeft,
    WebScrollRight
darin's avatar
darin committed
68
};
cblu's avatar
cblu committed
69

darin's avatar
darin committed
70
enum WebScrollGranularity {
cblu's avatar
cblu committed
71 72 73 74
    WebScrollLine,
    WebScrollPage,
    WebScrollDocument,
    WebScrollWheel
darin's avatar
darin committed
75
};
kocienda's avatar
kocienda committed
76

mjs's avatar
mjs committed
77 78 79 80 81
@protocol WebCoreOpenPanelResultListener <NSObject>
- (void)chooseFilename:(NSString *)fileName;
- (void)cancel;
@end

mjs's avatar
mjs committed
82
// WebCoreFrameBridge objects are used by WebCore to abstract away operations that need
darin's avatar
darin committed
83 84 85
// to be implemented by library clients, for example WebKit. The objects are also
// used in the opposite direction, for simple access to WebCore functions without dealing
// directly with the KHTML C++ classes.
darin's avatar
darin committed
86

mjs's avatar
mjs committed
87
// A WebCoreFrameBridge creates and holds a reference to a Frame.
darin's avatar
darin committed
88

mjs's avatar
mjs committed
89
// The WebCoreFrameBridge interface contains methods for use by the non-WebCore side of the bridge.
darin's avatar
darin committed
90

mjs's avatar
mjs committed
91
@interface WebCoreFrameBridge : NSObject
92
{
mjs's avatar
mjs committed
93
@public
mjs's avatar
mjs committed
94
    WebCore::Frame* m_frame;
rjw's avatar
rjw committed
95
    BOOL _shouldCreateRenderers;
thatcher's avatar
thatcher committed
96
    BOOL _closed;
97
}
darin's avatar
darin committed
98

mjs's avatar
mjs committed
99
- (WebCore::Frame*)_frame; // underscore to prevent conflict with -[NSView frame]
darin's avatar
darin committed
100

mjs's avatar
mjs committed
101
+ (WebCoreFrameBridge *)bridgeForDOMDocument:(DOMDocument *)document;
cblu's avatar
Tests:  
cblu committed
102

ggaren's avatar
ggaren committed
103
- (id)init;
thatcher's avatar
thatcher committed
104 105
- (void)close;

darin's avatar
darin committed
106
- (void)addData:(NSData *)data;
darin's avatar
darin committed
107

mjs's avatar
mjs committed
108
- (void)clearFrame;
109

cblu's avatar
cblu committed
110
- (NSURL *)baseURL;
darin's avatar
darin committed
111

darin's avatar
darin committed
112 113
- (void)installInFrame:(NSView *)view;

cblu's avatar
cblu committed
114 115
- (BOOL)scrollOverflowInDirection:(WebScrollDirection)direction granularity:(WebScrollGranularity)granularity;

116
- (void)createFrameViewWithNSView:(NSView *)view marginWidth:(int)mw marginHeight:(int)mh;
darin's avatar
darin committed
117

darin's avatar
darin committed
118
- (void)reapplyStylesForDeviceType:(WebCoreDeviceType)deviceType;
sullivan's avatar
sullivan committed
119
- (void)forceLayoutAdjustingViewSize:(BOOL)adjustSizeFlag;
sullivan's avatar
sullivan committed
120
- (void)forceLayoutWithMinimumPageWidth:(float)minPageWidth maximumPageWidth:(float)maxPageWidth adjustingViewSize:(BOOL)adjustSizeFlag;
hyatt's avatar
hyatt committed
121
- (void)sendScrollEvent;
darin's avatar
darin committed
122
- (BOOL)needsLayout;
123
- (void)setNeedsLayout;
darin's avatar
darin committed
124
- (void)drawRect:(NSRect)rect;
trey's avatar
trey committed
125
- (void)adjustPageHeightNew:(float *)newBottom top:(float)oldTop bottom:(float)oldBottom limit:(float)bottomLimit;
126
- (NSArray*)computePageRectsWithPrintWidthScaleFactor:(float)printWidthScaleFactor printHeight:(float)printHeight;
darin's avatar
darin committed
127

darin's avatar
darin committed
128
- (NSObject *)copyRenderTree:(id <WebCoreRenderTreeCopier>)copier;
darin's avatar
darin committed
129
- (NSString *)renderTreeAsExternalRepresentation;
darin's avatar
darin committed
130

cblu's avatar
cblu committed
131
- (NSURL *)URLWithAttributeString:(NSString *)string;
cblu's avatar
cblu committed
132

kocienda's avatar
Tests:  
kocienda committed
133 134 135 136 137 138 139 140
- (DOMElement *)elementWithName:(NSString *)name inForm:(DOMElement *)form;
- (BOOL)elementDoesAutoComplete:(DOMElement *)element;
- (BOOL)elementIsPassword:(DOMElement *)element;
- (DOMElement *)formForElement:(DOMElement *)element;
- (DOMElement *)currentForm;
- (NSArray *)controlsInForm:(DOMElement *)form;
- (NSString *)searchForLabels:(NSArray *)labels beforeElement:(DOMElement *)element;
- (NSString *)matchLabels:(NSArray *)labels againstElement:(DOMElement *)element;
cblu's avatar
cblu committed
141

sullivan's avatar
sullivan committed
142
- (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag startInSelection:(BOOL)startInSelection;
sullivan's avatar
sullivan committed
143
- (unsigned)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag limit:(unsigned)limit;
sullivan's avatar
sullivan committed
144 145 146
- (BOOL)markedTextMatchesAreHighlighted;
- (void)setMarkedTextMatchesAreHighlighted:(BOOL)doHighlight;
- (void)unmarkAllTextMatches;
147
- (NSArray *)rectsForTextMatches;
darin's avatar
darin committed
148

darin's avatar
darin committed
149 150
- (void)setTextSizeMultiplier:(float)multiplier;

darin's avatar
darin committed
151
- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)string;
kdecker's avatar
kdecker committed
152
- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)string forceUserGesture:(BOOL)forceUserGesture;
153
- (NSAppleEventDescriptor *)aeDescByEvaluatingJavaScriptFromString:(NSString *)string;
darin's avatar
darin committed
154

cblu's avatar
Tests:  
cblu committed
155 156
- (NSString *)selectedString;

darin's avatar
darin committed
157 158
- (NSString *)stringForRange:(DOMRange *)range;

cblu's avatar
cblu committed
159 160
- (NSString *)markupStringFromNode:(DOMNode *)node nodes:(NSArray **)nodes;
- (NSString *)markupStringFromRange:(DOMRange *)range nodes:(NSArray **)nodes;
cblu's avatar
cblu committed
161

kocienda's avatar
kocienda committed
162
- (NSRect)caretRectAtNode:(DOMNode *)node offset:(int)offset affinity:(NSSelectionAffinity)affinity;
mjs's avatar
mjs committed
163
- (NSRect)firstRectForDOMRange:(DOMRange *)range;
164
- (void)scrollDOMRangeToVisible:(DOMRange *)range;
cblu's avatar
cblu committed
165

darin's avatar
darin committed
166 167 168
// Emacs-style-editing "mark"
- (DOMRange *)markDOMRange;

darin's avatar
darin committed
169
- (NSFont *)fontForSelection:(BOOL *)hasMultipleFonts;
kocienda's avatar
kocienda committed
170
- (NSWritingDirection)baseWritingDirectionForSelectionStart;
171

darin's avatar
darin committed
172 173
- (NSString *)stringWithData:(NSData *)data; // using the encoding of the frame's main resource
+ (NSString *)stringWithData:(NSData *)data textEncodingName:(NSString *)textEncodingName; // nil for textEncodingName means Latin-1
cblu's avatar
cblu committed
174

rjw's avatar
rjw committed
175 176 177
- (void)setShouldCreateRenderers:(BOOL)f;
- (BOOL)shouldCreateRenderers;

thatcher's avatar
thatcher committed
178
- (void)setBaseBackgroundColor:(NSColor *)backgroundColor;
darin's avatar
darin committed
179 180
- (void)setDrawsBackground:(BOOL)drawsBackround;

cblu's avatar
Tests:  
cblu committed
181
- (NSColor *)selectionColor;
rjw's avatar
WebKit:  
rjw committed
182

rjw's avatar
WebKit:  
rjw committed
183
- (id)accessibilityTree;
184

andersca's avatar
andersca committed
185 186 187
- (DOMRange *)rangeByAlteringCurrentSelection:(WebCore::SelectionController::EAlteration)alteration direction:(WebCore::SelectionController::EDirection)direction granularity:(WebCore::TextGranularity)granularity;
- (void)alterCurrentSelection:(WebCore::SelectionController::EAlteration)alteration verticalDistance:(float)distance;
- (WebCore::TextGranularity)selectionGranularity;
harrison's avatar
harrison committed
188 189
- (DOMRange *)smartDeleteRangeForProposedRange:(DOMRange *)proposedCharRange;
- (void)smartInsertForString:(NSString *)pasteString replacingRange:(DOMRange *)charRangeToReplace beforeString:(NSString **)beforeString afterString:(NSString **)afterString;
rjw's avatar
rjw committed
190 191 192
- (void)selectNSRange:(NSRange)range;
- (NSRange)selectedNSRange;
- (NSRange)markedTextNSRange;
eseidel's avatar
eseidel committed
193 194
- (DOMRange *)convertNSRangeToDOMRange:(NSRange)range;
- (NSRange)convertDOMRangeToNSRange:(DOMRange *)range;
cblu's avatar
cblu committed
195 196

- (DOMDocumentFragment *)documentFragmentWithMarkupString:(NSString *)markupString baseURLString:(NSString *)baseURLString;
darin's avatar
darin committed
197
- (DOMDocumentFragment *)documentFragmentWithText:(NSString *)text inContext:(DOMRange *)context;
eseidel's avatar
eseidel committed
198
- (DOMDocumentFragment *)documentFragmentWithNodesAsParagraphs:(NSArray *)nodes;
cblu's avatar
cblu committed
199

cblu's avatar
cblu committed
200
- (void)replaceSelectionWithFragment:(DOMDocumentFragment *)fragment selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace matchStyle:(BOOL)matchStyle;
harrison's avatar
harrison committed
201
- (void)replaceSelectionWithNode:(DOMNode *)node selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace matchStyle:(BOOL)matchStyle;
cblu's avatar
cblu committed
202 203
- (void)replaceSelectionWithMarkupString:(NSString *)markupString baseURLString:(NSString *)baseURLString selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace;
- (void)replaceSelectionWithText:(NSString *)text selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace;
cblu's avatar
cblu committed
204

kocienda's avatar
kocienda committed
205
- (void)insertParagraphSeparatorInQuotedContent;
cblu's avatar
cblu committed
206

cblu's avatar
cblu committed
207
- (void)setSelectionToDragCaret;
cblu's avatar
cblu committed
208
- (void)moveSelectionToDragCaret:(DOMDocumentFragment *)selectionFragment smartMove:(BOOL)smartMove;
cblu's avatar
cblu committed
209
- (DOMRange *)dragCaretDOMRange;
adele's avatar
adele committed
210
- (BOOL)isDragCaretRichlyEditable;
eseidel's avatar
eseidel committed
211
- (DOMRange *)characterRangeAtPoint:(NSPoint)point;
cblu's avatar
cblu committed
212

kocienda's avatar
kocienda committed
213
- (DOMCSSStyleDeclaration *)typingStyle;
andersca's avatar
andersca committed
214
- (void)setTypingStyle:(DOMCSSStyleDeclaration *)style withUndoAction:(WebCore::EditAction)undoAction;
darin's avatar
darin committed
215
- (NSCellStateValue)selectionHasStyle:(DOMCSSStyleDeclaration *)style;
darin's avatar
darin committed
216

trey's avatar
trey committed
217 218
- (void)dragSourceMovedTo:(NSPoint)windowLoc;
- (void)dragSourceEndedAt:(NSPoint)windowLoc operation:(NSDragOperation)operation;
trey's avatar
trey committed
219

220
- (BOOL)getData:(NSData **)data andResponse:(NSURLResponse **)response forURL:(NSString *)URL;
mjs's avatar
mjs committed
221 222
- (void)getAllResourceDatas:(NSArray **)datas andResponses:(NSArray **)responses;

andersca's avatar
andersca committed
223 224
- (BOOL)canProvideDocumentSource;
- (BOOL)canSaveAsWebArchive;
beidson's avatar
beidson committed
225

mjs's avatar
mjs committed
226 227
- (void)receivedData:(NSData *)data textEncodingName:(NSString *)textEncodingName;

darin's avatar
darin committed
228 229
@end

mjs's avatar
mjs committed
230
// The WebCoreFrameBridge protocol contains methods for use by the WebCore side of the bridge.
darin's avatar
darin committed
231

mjs's avatar
mjs committed
232
@protocol WebCoreFrameBridge
darin's avatar
darin committed
233

kocienda's avatar
kocienda committed
234
- (NSView *)documentView;
darin's avatar
darin committed
235

ggaren's avatar
ggaren committed
236
- (WebCore::Frame*)createChildFrameNamed:(NSString *)frameName withURL:(NSURL *)URL referrer:(const WebCore::String&)referrer
darin's avatar
darin committed
237
    ownerElement:(WebCore::HTMLFrameOwnerElement *)ownerElement allowsScrolling:(BOOL)allowsScrolling marginWidth:(int)width marginHeight:(int)height;
darin's avatar
darin committed
238

darin's avatar
darin committed
239 240
- (NSWindow *)window;

mjs's avatar
mjs committed
241
- (NSResponder *)firstResponder;
darin's avatar
darin committed
242
- (void)makeFirstResponder:(NSResponder *)responder;
mjs's avatar
mjs committed
243
- (void)willMakeFirstResponderForNodeFocus;
darin's avatar
darin committed
244

sullivan's avatar
sullivan committed
245
- (BOOL)textViewWasFirstResponderAtMouseDownTime:(NSTextView *)textView;
mjs's avatar
mjs committed
246

mjs's avatar
mjs committed
247
- (void)runOpenPanelForFileButtonWithResultListener:(id <WebCoreOpenPanelResultListener>)resultListener;
mjs's avatar
mjs committed
248

andersca's avatar
andersca committed
249 250 251 252 253 254 255
- (NSView *)viewForPluginWithFrame:(NSRect)frame
                               URL:(NSURL *)URL
                    attributeNames:(NSArray *)attributeNames
                   attributeValues:(NSArray *)attributeValues
                          MIMEType:(NSString *)MIMEType
                        DOMElement:(DOMElement *)element
                      loadManually:(BOOL)loadManually;
cblu's avatar
cblu committed
256
- (NSView *)viewForJavaAppletWithFrame:(NSRect)frame
cblu's avatar
cblu committed
257 258
                        attributeNames:(NSArray *)attributeNames
                       attributeValues:(NSArray *)attributeValues
tomernic's avatar
tomernic committed
259 260
                               baseURL:(NSURL *)baseURL
                            DOMElement:(DOMElement *)element;
andersca's avatar
andersca committed
261
- (void)redirectDataToPlugin:(NSView *)pluginView;
cblu's avatar
cblu committed
262

andersca's avatar
andersca committed
263
- (WebCore::ObjectContentType)determineObjectFromMIMEType:(NSString*)MIMEType URL:(NSURL*)URL;
cblu's avatar
cblu committed
264

rjw's avatar
WebKit:  
rjw committed
265 266 267
- (jobject)getAppletInView:(NSView *)view;

// Deprecated, use getAppletInView: instead.
rjw's avatar
WebKit:  
rjw committed
268
- (jobject)pollForAppletInView:(NSView *)view;
rjw's avatar
rjw committed
269

kocienda's avatar
kocienda committed
270
- (void)issuePasteCommand;
cblu's avatar
Tests:  
cblu committed
271 272
- (void)setIsSelected:(BOOL)isSelected forView:(NSView *)view;

rjw's avatar
WebKit:  
rjw committed
273 274
- (void)windowObjectCleared;

rjw's avatar
rjw committed
275
- (void)dashboardRegionsChanged:(NSMutableDictionary *)regions;
adele's avatar
adele committed
276
- (void)willPopupMenu:(NSMenu *)menu;
rjw's avatar
rjw committed
277

thatcher's avatar
thatcher committed
278 279
- (NSRect)customHighlightRect:(NSString*)type forLine:(NSRect)lineRect representedNode:(WebCore::Node *)node;
- (void)paintCustomHighlight:(NSString*)type forBox:(NSRect)boxRect onLine:(NSRect)lineRect behindText:(BOOL)text entireLine:(BOOL)line representedNode:(WebCore::Node *)node;
280

darin's avatar
darin committed
281
- (WebCore::KeyboardUIMode)keyboardUIMode;
mjs's avatar
mjs committed
282

andersca's avatar
andersca committed
283 284
- (NSString*)imageTitleForFilename:(NSString*)filename size:(NSSize)size;

darin's avatar
darin committed
285
@end
darin's avatar
darin committed
286

mjs's avatar
mjs committed
287 288 289
// This interface definition allows those who hold a WebCoreFrameBridge * to call all the methods
// in the WebCoreFrameBridge protocol without requiring the base implementation to supply the methods.
// This idiom is appropriate because WebCoreFrameBridge is an abstract class.
darin's avatar
darin committed
290

mjs's avatar
mjs committed
291
@interface WebCoreFrameBridge (SubclassResponsibility) <WebCoreFrameBridge>
darin's avatar
darin committed
292
@end
darin's avatar
darin committed
293

darin's avatar
darin committed
294
// Protocols that make up part of the interfaces above.
darin's avatar
darin committed
295

darin's avatar
darin committed
296
@protocol WebCoreRenderTreeCopier <NSObject>
297
- (NSObject *)nodeWithName:(NSString *)name position:(NSPoint)p rect:(NSRect)rect view:(NSView *)view children:(NSArray *)children;
darin's avatar
darin committed
298
@end