Frame.h 25.6 KB
Newer Older
1
// -*- c-basic-offset: 2 -*-
mjs's avatar
mjs committed
2
 /* This file is part of the KDE project
kocienda's avatar
kocienda committed
3
4
 *
 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
5
6
7
8
 *                     1999-2001 Lars Knoll <knoll@kde.org>
 *                     1999-2001 Antti Koivisto <koivisto@kde.org>
 *                     2000-2001 Simon Hausmann <hausmann@kde.org>
 *                     2000-2001 Dirk Mueller <mueller@kde.org>
kocienda's avatar
kocienda committed
9
 *                     2000 Stefan Schimanski <1Stein@gmx.de>
10
 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
kocienda's avatar
kocienda committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

28
29
#ifndef Frame_H
#define Frame_H
darin's avatar
darin committed
30
31

#include "BrowserExtension.h"
darin's avatar
darin committed
32
#include "Color.h"
darin's avatar
darin committed
33
#include "DeprecatedStringList.h"
darin's avatar
darin committed
34
#include "EditAction.h"
darin's avatar
darin committed
35
#include "FrameView.h"
darin's avatar
darin committed
36
#include "Node.h"
weinig's avatar
weinig committed
37
#include "RenderObject.h"
thatcher's avatar
thatcher committed
38
#include "RenderLayer.h"
weinig's avatar
weinig committed
39
#include "ScrollBar.h"
darin's avatar
darin committed
40
41
#include "TextAffinity.h"
#include "TextGranularity.h"
mjs's avatar
mjs committed
42
#include <wtf/Vector.h>
kocienda's avatar
kocienda committed
43
44

namespace KJS {
darin's avatar
darin committed
45
46
47
48
    class JSValue;
    class PausedTimeouts;
    class SavedBuiltins;
    class SavedProperties;
49
50
51

    namespace Bindings {
        class Instance;
52
        class RootObject;
53
    }
darin's avatar
darin committed
54
}
kocienda's avatar
kocienda committed
55

darin's avatar
darin committed
56
57
namespace WebCore {

darin's avatar
darin committed
58
59
60
class CSSComputedStyleDeclaration;
class CSSMutableStyleDeclaration;
class CSSStyleDeclaration;
darin's avatar
darin committed
61
class DrawContentsEvent;
ggaren's avatar
ggaren committed
62
class DOMWindow;
darin's avatar
darin committed
63
class EditCommand;
darin's avatar
darin committed
64
65
class FramePrivate;
class FrameTree;
darin's avatar
darin committed
66
class KJSProxy;
darin's avatar
darin committed
67
68
class Page;
class Plugin;
darin's avatar
darin committed
69
class MouseEventWithHitTestResults;
darin's avatar
darin committed
70
class Range;
adele's avatar
adele committed
71
class RenderLayer;
darin's avatar
darin committed
72
73
class Selection;
class SelectionController;
darin's avatar
darin committed
74
class Settings;
darin's avatar
darin committed
75
class VisiblePosition;
darin's avatar
darin committed
76
77
78

template <typename T> class Timer;

mjs's avatar
mjs committed
79
struct MarkedTextUnderline {
darin's avatar
darin committed
80
81
    MarkedTextUnderline() 
        : startOffset(0), endOffset(0), thick(false) { }
darin's avatar
darin committed
82
83
84
85
86
87
    MarkedTextUnderline(unsigned s, unsigned e, const Color& c, bool t) 
        : startOffset(s), endOffset(e), color(c), thick(t) { }
    unsigned startOffset;
    unsigned endOffset;
    Color color;
    bool thick;
mjs's avatar
mjs committed
88
89
};

darin's avatar
darin committed
90
enum ObjectContentType {
mjs's avatar
mjs committed
91
92
93
    ObjectContentNone,
    ObjectContentImage,
    ObjectContentFrame,
weinig's avatar
weinig committed
94
    ObjectContentPlugin
mjs's avatar
mjs committed
95
96
};

ap's avatar
ap committed
97
class Frame : public Shared<Frame>, Noncopyable {
kocienda's avatar
kocienda committed
98
public:
kocienda's avatar
kocienda committed
99
  enum { NoXPosForVerticalArrowNavigation = INT_MIN };
kocienda's avatar
kocienda committed
100

andersca's avatar
andersca committed
101
  Frame(Page*, Element*);
mjs's avatar
mjs committed
102
  virtual ~Frame();
kocienda's avatar
kocienda committed
103

mjs's avatar
mjs committed
104
  virtual bool openURL(const KURL&);
darin's avatar
darin committed
105
  virtual bool closeURL();
kocienda's avatar
kocienda committed
106

mjs's avatar
mjs committed
107
108
  void didExplicitOpen();

beidson's avatar
beidson committed
109
  KURL iconURL();
beidson's avatar
beidson committed
110
  void commitIconURLToIconDatabase();
beidson's avatar
beidson committed
111
  
darin's avatar
darin committed
112
  Page* page() const;
113
114
  void pageDestroyed();
  
kocienda's avatar
kocienda committed
115
  /**
darin's avatar
darin committed
116
   * Stop loading the document and kill all data requests (for images, etc.)
kocienda's avatar
kocienda committed
117
   */
118
  void stopLoading(bool sendUnload = false);
kocienda's avatar
kocienda committed
119
120

  /**
darin's avatar
darin committed
121
   * Returns a pointer to the @ref BrowserExtension.
kocienda's avatar
kocienda committed
122
   */
123
  BrowserExtension* browserExtension() const;
kocienda's avatar
kocienda committed
124
125

  /**
126
   * Returns a pointer to the HTML document's view.
kocienda's avatar
kocienda committed
127
   */
128
  FrameView* view() const;
kocienda's avatar
kocienda committed
129

130
131
  virtual void setView(FrameView*);

kocienda's avatar
kocienda committed
132
  /**
ggaren's avatar
ggaren committed
133
   * Returns @p true if Javascript is enabled, @p false otherwise.
kocienda's avatar
kocienda committed
134
   */
ggaren's avatar
ggaren committed
135
  bool jScriptEnabled() const;
kocienda's avatar
kocienda committed
136
137

  /**
ggaren's avatar
ggaren committed
138
   * Returns true if Java is enabled, false otherwise.
kocienda's avatar
kocienda committed
139
   */
ggaren's avatar
ggaren committed
140
141
142
143
144
145
  bool javaEnabled() const;
  
  /**
   * Returns true if plugins are enabled, false otherwise.
   */
  bool pluginsEnabled() const;
kocienda's avatar
kocienda committed
146
147
148
149

  /**
   * Execute the specified snippet of JavaScript code.
   */
darin's avatar
darin committed
150
  KJS::JSValue* executeScript(Node*, const String& script, bool forceUserGesture = false);
kocienda's avatar
kocienda committed
151

trey's avatar
trey committed
152
  /**
153
   * Implementation of CSS property -webkit-user-drag == auto
trey's avatar
trey committed
154
   */
mjs's avatar
mjs committed
155
  virtual bool shouldDragAutoNode(Node*, const IntPoint&) const;
trey's avatar
trey committed
156
  
kocienda's avatar
kocienda committed
157
  /**
158
   * Specifies whether images contained in the document should be loaded
kocienda's avatar
kocienda committed
159
160
161
162
   * automatically or not.
   *
   * @note Request will be ignored if called before @ref begin().
   */
163
  void setAutoloadImages(bool enable);
kocienda's avatar
kocienda committed
164
  /**
165
   * Returns whether images contained in the document are loaded automatically
kocienda's avatar
kocienda committed
166
   * or not.
adele's avatar
adele committed
167
   * @note that the returned information is unreliable as long as no begin()
kocienda's avatar
kocienda committed
168
169
170
171
   * was called.
   */
  bool autoloadImages() const;

172
  KURL baseURL() const;
173
  String baseTarget() const;
174
175
176
177

  /**
   * Schedules a redirection after @p delay seconds.
   */
178
  void scheduleRedirection(double delay, const DeprecatedString& url, bool lockHistory = true);
179

darin's avatar
darin committed
180
  /**
darin's avatar
darin committed
181
182
   * Make a location change, or schedule one for later.
   * These are used for JavaScript-triggered location changes.
darin's avatar
darin committed
183
   */
darin's avatar
darin committed
184
185
  void changeLocation(const DeprecatedString& URL, const String& referrer, bool lockHistory = true, bool userGesture = false);
  void scheduleLocationChange(const DeprecatedString& url, const String& referrer, bool lockHistory = true, bool userGesture = false);
ap's avatar
ap committed
186
  void scheduleRefresh(bool userGesture = false);
darin's avatar
darin committed
187
  bool isScheduledLocationChangePending() const;
mjs's avatar
mjs committed
188

darin's avatar
darin committed
189
190
191
192
  /**
   * Schedules a history navigation operation (go forward, go back, etc.).
   * This is used for JavaScript-triggered location changes.
   */
193
  void scheduleHistoryNavigation(int steps);
darin's avatar
darin committed
194

195
196
  /**
   * Clears the widget and prepares it for new content.
kocienda's avatar
kocienda committed
197
198
199
200
   *
   * If you want @ref url() to return
   * for example "file:/tmp/test.html", you can use the following code:
   * <PRE>
201
   * view->begin(KURL("file:/tmp/test.html"));
kocienda's avatar
kocienda committed
202
203
204
205
   * </PRE>
   *
   * @param url is the url of the document to be displayed.  Even if you
   * are generating the HTML on the fly, it may be useful to specify
206
   * a directory so that any images are found.
kocienda's avatar
kocienda committed
207
208
209
210
   *
   * All child frames and the old document are removed if you call
   * this method.
   */
211
  virtual void begin(const KURL& url = KURL());
kocienda's avatar
kocienda committed
212
213

  /**
214
   * Writes another part of the HTML code to the widget.
kocienda's avatar
kocienda committed
215
216
217
218
219
   *
   * You may call
   * this function many times in sequence. But remember: The fewer calls
   * you make, the faster the widget will be.
   *
darin's avatar
darin committed
220
   * The HTML code is sent through a decoder which decodes the stream to
kocienda's avatar
kocienda committed
221
222
223
224
225
226
227
   * Unicode.
   *
   * The @p len parameter is needed for streams encoded in utf-16,
   * since these can have \0 chars in them. In case the encoding
   * you're using isn't utf-16, you can safely leave out the length
   * parameter.
   *
228
   * Attention: Don't mix calls to @ref write(const char*) with calls
darin's avatar
darin committed
229
   * to @ref write(const String&).
kocienda's avatar
kocienda committed
230
231
232
   *
   * The result might not be what you want.
   */
233
  virtual void write(const char* str, int len = -1);
kocienda's avatar
kocienda committed
234
235

  /**
236
   * Writes another part of the HTML code to the widget.
kocienda's avatar
kocienda committed
237
238
239
240
241
   *
   * You may call
   * this function many times in sequence. But remember: The fewer calls
   * you make, the faster the widget will be.
   */
darin's avatar
darin committed
242
  virtual void write(const String&);
kocienda's avatar
kocienda committed
243
244
245
246
247
248

  /**
   * Call this after your last call to @ref write().
   */
  virtual void end();

mjs's avatar
mjs committed
249
250
  void endIfNotLoading();

251
252
253
254
255
  /**
   * Similar to end, but called to abort a load rather than cleanly end.
   */
  void stop();

darin's avatar
darin committed
256
  void paint(GraphicsContext*, const IntRect&);
kocienda's avatar
kocienda committed
257

darin's avatar
darin committed
258
259
  void setEncoding(const String& encoding, bool userChosen);
  String encoding() const;
kocienda's avatar
kocienda committed
260
261

  /**
262
263
   * Sets a user defined style sheet to be used on top of the HTML4,
   * SVG and printing default style sheets.
kocienda's avatar
kocienda committed
264
   */
darin's avatar
darin committed
265
  void setUserStyleSheetLocation(const KURL&);
266
267
  void setUserStyleSheet(const String& styleSheetData);
  
kocienda's avatar
kocienda committed
268
  /**
269
   * Sets the standard font style.
kocienda's avatar
kocienda committed
270
271
272
   *
   * @param name The font name to use for standard text.
   */
273
  void setStandardFont(const String& name);
kocienda's avatar
kocienda committed
274
275

  /**
276
   * Sets the fixed font style.
kocienda's avatar
kocienda committed
277
278
279
280
   *
   * @param name The font name to use for fixed text, e.g.
   * the <tt>&lt;pre&gt;</tt> tag.
   */
281
  void setFixedFont(const String& name);
kocienda's avatar
kocienda committed
282
283

  /**
284
   * Finds the anchor named @p name.
kocienda's avatar
kocienda committed
285
286
287
288
289
   *
   * If the anchor is found, the widget
   * scrolls to the closest position. Returns @p if the anchor has
   * been found.
   */
290
  bool gotoAnchor(const String& name);
kocienda's avatar
kocienda committed
291

darin's avatar
darin committed
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
  /**
   * Sets the Zoom factor. The value is given in percent, larger values mean a
   * generally larger font and larger page contents. It is not guaranteed that
   * all parts of the page are scaled with the same factor though.
   *
   * The given value should be in the range of 20..300, values outside that
   * range are not guaranteed to work. A value of 100 will disable all zooming
   * and show the page with the sizes determined via the given lengths in the
   * stylesheets.
   */
  void setZoomFactor(int percent);

  /**
   * Returns the current zoom factor.
   */
  int zoomFactor() const;

darin's avatar
darin committed
309
  /**
310
   * Returns the text the user has marked.
kocienda's avatar
kocienda committed
311
   */
312
  virtual String selectedText() const;
justing's avatar
justing committed
313
314
  
  bool findString(const String&, bool, bool, bool);
kocienda's avatar
kocienda committed
315

darin's avatar
darin committed
316
317
318
  /**
   * Returns the granularity of the selection (character, word, line, paragraph).
   */
darin's avatar
darin committed
319
  TextGranularity selectionGranularity() const;
320
  
harrison's avatar
harrison committed
321
322
323
  /**
   * Sets the granularity of the selection (character, word, line, paragraph).
   */
darin's avatar
darin committed
324
  void setSelectionGranularity(TextGranularity granularity) const;
harrison's avatar
harrison committed
325

darin's avatar
darin committed
326
  // FIXME: Replace these with functions on the selection controller.
justing's avatar
justing committed
327
328
329
330
331
  bool shouldChangeSelection(const Selection&) const;
  virtual bool shouldDeleteSelection(const Selection&) const;
  void clearCaretRectIfNeeded();
  void setFocusNodeIfNeeded();
  void selectionLayoutChanged();
adele's avatar
adele committed
332
  void notifyRendererOfSelectionChange(bool userTriggered);
darin's avatar
darin committed
333

cblu's avatar
cblu committed
334
  /**
darin's avatar
darin committed
335
336
   * Returns a mark, to be used as emacs uses it.
   */
337
338
  const Selection& mark() const;
  void setMark(const Selection&);
cblu's avatar
cblu committed
339
  
harrison's avatar
harrison committed
340
341
342
343
344
  /**
   * Transposes characters either side of caret selection.
   */
  void transpose();
  
kocienda's avatar
kocienda committed
345
346
347
348
349
  /**
   * Invalidates the current selection.
   */
  void invalidateSelection();

darin's avatar
darin committed
350
351
352
  void setCaretVisible(bool flag = true);
  void paintCaret(GraphicsContext*, const IntRect&) const;  
  void paintDragCaret(GraphicsContext*, const IntRect&) const;
kocienda's avatar
kocienda committed
353

kocienda's avatar
kocienda committed
354
355
356
357
358
359
360
361
362
363
  /**
   * Set info for vertical arrow navigation.
   */
  void setXPosForVerticalArrowNavigation(int x);

  /**
   * Get info for vertical arrow navigation.
   */
  int xPosForVerticalArrowNavigation() const;

kocienda's avatar
kocienda committed
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
  /**
   * Has the user selected anything?
   *
   *  Call @ref selectedText() to
   * retrieve the selected text.
   *
   * @return @p true if there is text selected.
   */
  bool hasSelection() const;

  /**
   * Marks all text in the document as selected.
   */
  void selectAll();

adele's avatar
adele committed
379
380
381
382
  /**
   * Marks contents of node as selected.
   * Returns whether the selection changed.
   */
darin's avatar
darin committed
383
  bool selectContentsOfNode(Node*);
adele's avatar
adele committed
384
 
kocienda's avatar
kocienda committed
385
386
387
  /**
   * Returns whether editing should end in the given range
   */
388
  virtual bool shouldBeginEditing(const Range*) const;
kocienda's avatar
kocienda committed
389
390
391
392

  /**
   * Returns whether editing should end in the given range
   */
393
  virtual bool shouldEndEditing(const Range*) const;
kocienda's avatar
kocienda committed
394

395
396
397
398
399
400
401
402
403
404
  /**
   * Called when editing has begun.
   */
  virtual void didBeginEditing() const {};
   
  /**
   * Called when editing has ended.
   */
  virtual void didEndEditing() const {};
    
kocienda's avatar
Tests:    
kocienda committed
405
406
407
  /**
   * Returns the contentEditable "override" value for the part
   */
adele's avatar
adele committed
408
  virtual bool isContentEditable() const;
kocienda's avatar
Tests:    
kocienda committed
409

adele's avatar
adele committed
410
411
412
413
414
  virtual void textFieldDidBeginEditing(Element*);
  virtual void textFieldDidEndEditing(Element*);
  virtual void textDidChangeInTextField(Element*);
  virtual bool doTextFieldCommandFromEvent(Element*, const PlatformKeyboardEvent*);
  virtual void textWillBeDeletedInTextField(Element* input);
adele's avatar
adele committed
415
  virtual void textDidChangeInTextArea(Element*);
adele's avatar
adele committed
416

adele's avatar
adele committed
417
418
  virtual bool inputManagerHasMarkedText() const { return false; }
  
adele's avatar
adele committed
419
  virtual void setSecureKeyboardEntry(bool) {};
adele's avatar
adele committed
420
  virtual bool isSecureKeyboardEntry() { return false; }
adele's avatar
adele committed
421
  
adele's avatar
adele committed
422
423
  bool isSelectionInPasswordField();
  
kocienda's avatar
kocienda committed
424
  /**
kocienda's avatar
kocienda committed
425
   * Returns the most recent edit command applied.
kocienda's avatar
kocienda committed
426
   */
darin's avatar
darin committed
427
  EditCommand* lastEditCommand();
kocienda's avatar
kocienda committed
428
429

  /**
kocienda's avatar
kocienda committed
430
   * Called when editing has been applied.
kocienda's avatar
kocienda committed
431
   */
darin's avatar
darin committed
432
  void appliedEditing(PassRefPtr<EditCommand>);
kocienda's avatar
kocienda committed
433
434

  /**
kocienda's avatar
kocienda committed
435
   * Called when editing has been unapplied.
kocienda's avatar
kocienda committed
436
   */
darin's avatar
darin committed
437
  void unappliedEditing(PassRefPtr<EditCommand>);
kocienda's avatar
kocienda committed
438
439
440
441

  /**
   * Called when editing has been reapplied.
   */
darin's avatar
darin committed
442
  void reappliedEditing(PassRefPtr<EditCommand>);
kocienda's avatar
kocienda committed
443

kocienda's avatar
kocienda committed
444
445
446
  /**
   * Returns the typing style for the document.
   */
447
  CSSMutableStyleDeclaration* typingStyle() const;
kocienda's avatar
kocienda committed
448
449
450
451

  /**
   * Sets the typing style for the document.
   */
452
  void setTypingStyle(CSSMutableStyleDeclaration*);
kocienda's avatar
kocienda committed
453
454
455
456
457
458

  /**
   * Clears the typing style for the document.
   */
  void clearTypingStyle();

darin's avatar
darin committed
459
  virtual void tokenizerProcessedData() {}
460

461
462
463
  bool inViewSourceMode() const;
  void setInViewSourceMode(bool = true) const;

darin's avatar
darin committed
464
  const Settings* settings() const;
kocienda's avatar
kocienda committed
465

darin's avatar
darin committed
466
467
468
469
  void setJSStatusBarText(const String&);
  void setJSDefaultStatusBarText(const String&);
  String jsStatusBarText() const;
  String jsDefaultStatusBarText() const;
kocienda's avatar
kocienda committed
470

471
472
473
  /**
   * Referrer used for links in this page.
   */
darin's avatar
darin committed
474
  String referrer() const;
475
476
477
478

  /**
   * Last-modified date (in raw string format), if received in the [HTTP] headers.
   */
479
  String lastModified() const;
480

mjs's avatar
mjs committed
481
  bool isPointInsideSelection(const IntPoint&);
cblu's avatar
cblu committed
482

483
484
  virtual bool tabsToLinks() const;
  virtual bool tabsToAllControls() const;
485

darin's avatar
darin committed
486
487
488
489
490
  // Editing operations.
  enum TriState { falseTriState, trueTriState, mixedTriState };
  void copyToPasteboard();
  void cutToPasteboard();
  void pasteFromPasteboard();
cblu's avatar
cblu committed
491
  void pasteAndMatchStyle();
adele's avatar
adele committed
492
  bool mayCopy();
493
  virtual bool canPaste() const = 0;
darin's avatar
darin committed
494
495
  void redo();
  void undo();
496
497
  virtual bool canRedo() const = 0;
  virtual bool canUndo() const = 0;
498
499
500
501
502
  void computeAndSetTypingStyle(CSSStyleDeclaration* , EditAction editingAction=EditActionUnspecified);
  void applyStyle(CSSStyleDeclaration* , EditAction editingAction=EditActionUnspecified);
  void applyParagraphStyle(CSSStyleDeclaration* , EditAction editingAction=EditActionUnspecified);
  TriState selectionHasStyle(CSSStyleDeclaration*) const;
  bool selectionStartHasStyle(CSSStyleDeclaration*) const;
justing's avatar
justing committed
503
  TriState selectionListState() const;
darin's avatar
darin committed
504
  String selectionStartStylePropertyValue(int stylePropertyID) const;
kocienda's avatar
kocienda committed
505
506
  void applyEditingStyleToBodyElement() const;
  void removeEditingStyleFromBodyElement() const;
507
508
  void applyEditingStyleToElement(Element*) const;
  void removeEditingStyleFromElement(Element*) const;
509
  virtual void print() = 0;
darin's avatar
darin committed
510
  virtual bool isCharacterSmartReplaceExempt(UChar, bool);
darin's avatar
darin committed
511

darin's avatar
darin committed
512
513
514
  // Used to keep the part alive when running a script that might destroy it.
  void keepAlive();

mjs's avatar
mjs committed
515
516
  static void endAllLifeSupport();

kocienda's avatar
kocienda committed
517
  /**
518
519
   * returns a KURL object for the given url. Use when
   * you know what you're doing.
kocienda's avatar
kocienda committed
520
   */
521
  KURL completeURL(const DeprecatedString& url);
522

darin's avatar
darin committed
523
524
525
526
  virtual void handleMouseReleaseDoubleClickEvent(const MouseEventWithHitTestResults&);
  virtual void handleMousePressEvent(const MouseEventWithHitTestResults&);
  virtual void handleMouseMoveEvent(const MouseEventWithHitTestResults&);
  virtual void handleMouseReleaseEvent(const MouseEventWithHitTestResults&);
527
  
mjs's avatar
mjs committed
528
  void selectClosestWordFromMouseEvent(const PlatformMouseEvent&, Node* innerNode);
kocienda's avatar
kocienda committed
529

530
531
  virtual void urlSelected(const DeprecatedString& url, const String& target);
  virtual void urlSelected(const ResourceRequest&, const String& target);
532
533

  // Methods with platform-specific overrides (and no base class implementation).
534
  virtual void setTitle(const String&) = 0;
535
  virtual void handledOnloadEvents() = 0;
536
537
538
539
540
541
  virtual String userAgent() const = 0;
  virtual String incomingReferrer() const = 0;
  virtual String mimeTypeForFileName(const String&) const = 0;
  virtual KJS::Bindings::Instance* getEmbedInstanceForWidget(Widget*) = 0;
  virtual KJS::Bindings::Instance* getObjectInstanceForWidget(Widget*) = 0;
  virtual KJS::Bindings::Instance* getAppletInstanceForWidget(Widget*) = 0;
542
543
  virtual KJS::Bindings::RootObject* bindingRootObject() = 0;

544
  virtual void markMisspellingsInAdjacentWords(const VisiblePosition&) = 0;
justing's avatar
justing committed
545
  virtual void markMisspellings(const Selection&) = 0;
darin's avatar
darin committed
546
547
548
549
  virtual void addMessageToConsole(const String& message,  unsigned int lineNumber, const String& sourceID) = 0;
  virtual void runJavaScriptAlert(const String& message) = 0;
  virtual bool runJavaScriptConfirm(const String& message) = 0;
  virtual bool runJavaScriptPrompt(const String& message, const String& defaultValue, String& result) = 0;  
andersca's avatar
andersca committed
550
  virtual bool shouldInterruptJavaScript() = 0;
551
552
553
554
555
556
  virtual bool locationbarVisible() = 0;
  virtual bool menubarVisible() = 0;
  virtual bool personalbarVisible() = 0;
  virtual bool statusbarVisible() = 0;
  virtual bool toolbarVisible() = 0;
  virtual void scheduleClose() = 0;
hyatt's avatar
hyatt committed
557
  virtual void focusWindow() = 0;
558
559
  virtual void unfocusWindow() = 0;
  virtual void createEmptyDocument() = 0;
560
  virtual Range* markedTextRange() const = 0;
darin's avatar
darin committed
561
562
  virtual void registerCommandForUndo(PassRefPtr<EditCommand>) = 0;
  virtual void registerCommandForRedo(PassRefPtr<EditCommand>) = 0;
563
564
565
566
567
568
569
570
  virtual void clearUndoRedoOperations() = 0;
  virtual void issueUndoCommand() = 0;
  virtual void issueRedoCommand() = 0;
  virtual void issueCutCommand() = 0;
  virtual void issueCopyCommand() = 0;
  virtual void issuePasteCommand() = 0;
  virtual void issuePasteAndMatchStyleCommand() = 0;
  virtual void issueTransposeCommand() = 0;
justing's avatar
justing committed
571
572
573
  virtual void respondToChangedSelection(const Selection& oldSelection, bool closeTyping) = 0;
  virtual void respondToChangedContents(const Selection& endingSelection) = 0;
  virtual bool shouldChangeSelection(const Selection& oldSelection, const Selection& newSelection, EAffinity affinity, bool stillSelecting) const = 0;
574
575
576
577
  virtual void partClearedInBegin() = 0; 
  virtual void saveDocumentState() = 0;
  virtual void restoreDocumentState() = 0;
  virtual bool canGoBackOrForward(int distance) const = 0;
mjs's avatar
mjs committed
578
579
580
  virtual void openURLRequest(const ResourceRequest&) = 0;
  virtual void submitForm(const ResourceRequest&) = 0;
  virtual void urlSelected(const ResourceRequest&) = 0;
ap's avatar
ap committed
581
  virtual bool passSubframeEventToSubframe(MouseEventWithHitTestResults&, Frame* subframePart = 0) = 0;
582
  virtual bool passWheelEventToChildWidget(Node*) = 0;
583
  virtual bool lastEventIsMouseUp() const = 0;
584
  virtual String overrideMediaType() const = 0;
andersca's avatar
andersca committed
585
  virtual void redirectDataToPlugin(Widget* pluginWidget) { }
586
protected:
tomernic's avatar
tomernic committed
587
  virtual Plugin* createPlugin(Element* node, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType) = 0;
andersca's avatar
andersca committed
588
  virtual Frame* createFrame(const KURL& url, const String& name, Element* ownerElement, const String& referrer) = 0;
589
  virtual ObjectContentType objectContentType(const KURL& url, const String& mimeType) = 0;
kocienda's avatar
kocienda committed
590

andersca's avatar
andersca committed
591
  virtual void redirectionTimerFired(Timer<Frame>*);
beidson's avatar
beidson committed
592
593
  
  virtual bool isLoadTypeReload() = 0;
ggaren's avatar
ggaren committed
594
  virtual KURL originalRequestURL() const = 0;
darin's avatar
darin committed
595

darin's avatar
darin committed
596
597
598
599
600
601
602
public:
  void loadDone();

  void finishedParsing();

  void checkCompleted();

603
  void reparseConfiguration();
kocienda's avatar
kocienda committed
604

darin's avatar
darin committed
605
private:
trey's avatar
trey committed
606
607
  void childBegin();

kocienda's avatar
kocienda committed
608
609
  void submitFormAgain();

darin's avatar
darin committed
610
  void started();
611

darin's avatar
darin committed
612
613
614
  void completed(bool);
  void childCompleted(bool);
  void parentCompleted();
darin's avatar
darin committed
615

darin's avatar
darin committed
616
617
    void lifeSupportTimerFired(Timer<Frame>*);
    void endLifeSupport();
darin's avatar
darin committed
618

mjs's avatar
mjs committed
619
  virtual void clear(bool clearWindowProperties = true);
mjs's avatar
mjs committed
620

darin's avatar
darin committed
621
    void caretBlinkTimerFired(Timer<Frame>*);
622

623
624
  bool shouldUsePlugin(Node* element, const KURL& url, const String& mimeType, bool hasFallback, bool& useFallback);
  bool loadPlugin(RenderPart* renderer, const KURL& url, const String& mimeType, 
625
                  const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallback);
andersca's avatar
andersca committed
626
  Frame* loadSubframe(Element* ownerElement, const KURL& url, const String& name, const String& referrer);
kocienda's avatar
kocienda committed
627

darin's avatar
darin committed
628
public:
629
630
631
  void submitForm(const char* action, const String& url, const FormData& formData,
                  const String& target, const String& contentType = String(),
                  const String& boundary = String());
mjs's avatar
mjs committed
632
  
633
  bool requestObject(RenderPart* frame, const String& url, const AtomicString& frameName,
634
                     const String& serviceType, const Vector<String>& paramNames, const Vector<String>& paramValues);
andersca's avatar
andersca committed
635
  bool requestFrame(Element* ownerElement, const String& url, const AtomicString& frameName);
mjs's avatar
mjs committed
636

637
  Document* document() const;
darin's avatar
darin committed
638
  void setDocument(Document* newDoc);
darin's avatar
darin committed
639
640
641
642

  // Workaround for the fact that it's hard to delete a frame.
  // Call this after doing user-triggered selections to make it easy to delete the frame you entirely selected.
  void selectFrameElementInParentIfFullySelected();
rjw's avatar
rjw committed
643
  
644
645
  virtual bool mouseDownMayStartSelect() const { return true; }

646
647
  void handleFallbackContent();

darin's avatar
darin committed
648
private:
rjw's avatar
WebKit:    
rjw committed
649
  void cancelRedirection(bool newLoadInProgress = false);
kocienda's avatar
kocienda committed
650

mjs's avatar
mjs committed
651
 public:
darin's avatar
darin committed
652
  KJS::JSValue* executeScript(const String& filename, int baseLine, Node*, const String& script);
653
654
655
  KJSProxy* jScript();
  Frame* opener();
  void setOpener(Frame* _opener);
darin's avatar
darin committed
656
657
  bool openedByJS();
  void setOpenedByJS(bool _openedByJS);
mjs's avatar
mjs committed
658

darin's avatar
darin committed
659
  void setSettings(Settings*);
mjs's avatar
mjs committed
660
661
662

  void provisionalLoadStarted();
  bool userGestureHint();
663
664
665
666
  void didNotOpenURL(const KURL&);
  void addData(const char* bytes, int length);
  void addMetaData(const String& key, const String& value);
  void setMediaType(const String&);
mjs's avatar
mjs committed
667

mjs's avatar
mjs committed
668
669
670
  // root renderer for the document contained in this frame
  RenderObject* renderer() const;
  
darin's avatar
darin committed
671
  Element* ownerElement();
mjs's avatar
mjs committed
672
673
  // renderer for the element that contains this frame
  RenderPart* ownerRenderer();
mjs's avatar
mjs committed
674

675
  IntRect selectionRect() const;
676
  FloatRect visibleSelectionRect() const;
mjs's avatar
mjs committed
677
678
  bool isFrameSet() const;

679
  HTMLFormElement* currentForm() const;
mjs's avatar
mjs committed
680

681
  RenderStyle* styleForSelectionStart(Node* &nodeToRemove) const;
mjs's avatar
mjs committed
682

thatcher's avatar
thatcher committed
683
684
  void revealSelection(const RenderLayer::ScrollAlignment& alignment = RenderLayer::gAlignCenterIfNeeded) const;
  void revealCaret(const RenderLayer::ScrollAlignment& alignment = RenderLayer::gAlignCenterIfNeeded) const;
mjs's avatar
mjs committed
685
686
  void setSelectionFromNone();

darin's avatar
darin committed
687
  bool scrollOverflow(ScrollDirection direction, ScrollGranularity granularity);
mjs's avatar
mjs committed
688

689
  void adjustPageHeight(float* newBottom, float oldTop, float oldBottom, float bottomLimit);
mjs's avatar
mjs committed
690
691

  bool canCachePage();
692
693
694
695
696
697
698
699
  KJS::PausedTimeouts* pauseTimeouts();
  void resumeTimeouts(KJS::PausedTimeouts*);
  void saveWindowProperties(KJS::SavedProperties* windowProperties);
  void saveLocationProperties(KJS::SavedProperties* locationProperties);
  void restoreWindowProperties(KJS::SavedProperties* windowProperties);
  void restoreLocationProperties(KJS::SavedProperties* locationProperties);
  void saveInterpreterBuiltins(KJS::SavedBuiltins& interpreterBuiltins);
  void restoreInterpreterBuiltins(const KJS::SavedBuiltins& interpreterBuiltins);
mjs's avatar
mjs committed
700

701
702
703
  static Frame* frameForWidget(const Widget*);
  static Node* nodeForWidget(const Widget*);
  static Frame* frameForNode(Node*);
mjs's avatar
mjs committed
704

705
  static void clearDocumentFocus(Widget*);
mjs's avatar
mjs committed
706
707

  void updatePolicyBaseURL();
darin's avatar
darin committed
708
  void setPolicyBaseURL(const String&);
mjs's avatar
mjs committed
709
710
711
712
713
714
715

  void forceLayout();
  void forceLayoutWithPageWidthRange(float minPageWidth, float maxPageWidth);

  void sendResizeEvent();
  void sendScrollEvent();
  bool scrollbarsVisible();
716
  void scrollToAnchor(const KURL&);
darin's avatar
darin committed
717
  bool canMouseDownStartSelect(Node*);
darin's avatar
darin committed
718
719
720
  bool passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults&, bool isDoubleClick);
  bool passWidgetMouseDownEventToWidget(RenderWidget*);
  virtual bool passMouseDownEventToWidget(Widget*) = 0;
mjs's avatar
mjs committed
721
722

  void clearTimers();
723
  static void clearTimers(FrameView*);
mjs's avatar
mjs committed
724

hyatt's avatar
hyatt committed
725
726
  bool isActive() const;
  virtual void setIsActive(bool flag);
mjs's avatar
mjs committed
727
728
729
  void setWindowHasFocus(bool flag);
  // Convenience, to avoid repeating the code to dig down to get this.

darin's avatar
darin committed
730
  UChar backslashAsCurrencySymbol() const;
mjs's avatar
mjs committed
731

darin's avatar
darin committed
732
  const Vector<MarkedTextUnderline>& markedTextUnderlines() const;  
mjs's avatar
mjs committed
733
  bool markedTextUsesUnderlines() const;
sullivan's avatar
sullivan committed
734
  
sullivan's avatar
sullivan committed
735
  unsigned markAllMatchesForText(const String&, bool caseFlag, unsigned limit);
sullivan's avatar
sullivan committed
736
737
738
  bool markedTextMatchesAreHighlighted() const;
  void setMarkedTextMatchesAreHighlighted(bool flag);
  
mjs's avatar
mjs committed
739
740
741
  // Call this method before handling a new user action, like on a mouse down or key down.
  // Currently, all this does is clear the "don't submit form twice" data member.
  void prepareForUserAction();
742
  Node* mousePressNode();
743
744
745
  
  void clearRecordedFormValues();
  void recordFormValue(const String& name, const String& value, PassRefPtr<HTMLFormElement>);
mjs's avatar
mjs committed
746

ap's avatar
ap committed
747
748
  bool isComplete() const;
  bool isLoadingMainResource() const;
749
  
750
  void replaceContentsWithScriptResult(const KURL& url);
mjs's avatar
mjs committed
751

andersca's avatar
andersca committed
752
    void disconnectOwnerElement();
darin's avatar
darin committed
753

darin's avatar
darin committed
754
755
    void setNeedsReapplyStyles();

mjs's avatar
mjs committed
756
protected:
darin's avatar
darin committed
757
758
    virtual void startRedirectionTimer();
    virtual void stopRedirectionTimer();
759
    virtual void cleanupPluginObjects() { }
760
    void cancelAndClear();
adele's avatar
adele committed
761
762
763
764
    
    void handleAutoscroll(RenderLayer*);
    void startAutoscrollTimer();
    void stopAutoscrollTimer();
darin's avatar
darin committed
765

mjs's avatar
mjs committed
766
 private:
kocienda's avatar
kocienda committed
767
  void emitLoadEvent();
darin's avatar
darin committed
768
769
  
  void receivedFirstData();
kocienda's avatar
kocienda committed
770

darin's avatar
darin committed
771
772
773
774
775
  /**
   * @internal Extracts anchor and tries both encoded and decoded form.
   */
  void gotoAnchor();

darin's avatar
darin committed
776
777
778
  void handleMousePressEventSingleClick(const MouseEventWithHitTestResults&);
  void handleMousePressEventDoubleClick(const MouseEventWithHitTestResults&);
  void handleMousePressEventTripleClick(const MouseEventWithHitTestResults&);
kocienda's avatar
kocienda committed
779

780
  CSSComputedStyleDeclaration* selectionComputedStyle(Node* &nodeToRemove) const;
darin's avatar
darin committed
781

darin's avatar
darin committed
782
    virtual void setStatusBarText(const String&);
adele's avatar
adele committed
783
784
    
    void autoscrollTimerFired(Timer<Frame>*);
darin's avatar
darin committed
785

darin's avatar
darin committed
786
public:
darin's avatar
darin committed
787
  friend class FrameMac;
mjs's avatar
mjs committed
788
  friend class FrameWin;
ggaren's avatar
ggaren committed
789
790
791
#if PLATFORM(GDK)
  friend class FrameGdk;
#endif
792
793
794
#if PLATFORM(QT)
  friend class FrameQt;
#endif
795

mjs's avatar
mjs committed
796
797
  RenderObject::NodeInfo nodeInfoAtPoint(const IntPoint&, bool allowShadowContent);
  bool hasSelection();
ggaren's avatar
ggaren committed
798
  String documentTypeString() const;
mjs's avatar
mjs committed
799

mjs's avatar
mjs committed
800
  void checkEmitLoadEvent();
801
  bool didOpenURL(const KURL&);
cblu's avatar
cblu committed
802
  virtual void didFirstLayout() {}
darin's avatar
darin committed
803

mjs's avatar
mjs committed
804
805
806
  virtual void frameDetached();

  void updateBaseURLForEmptyDocument();
mjs's avatar
mjs committed
807

mjs's avatar
mjs committed
808
  KURL url() const;
beidson's avatar
beidson committed
809
  
mjs's avatar
mjs committed
810
811
  void setResourceRequest(const ResourceRequest& request);
  const ResourceRequest& resourceRequest() const;
mjs's avatar
mjs committed
812

andersca's avatar
andersca committed
813
814
  bool containsPlugins() const;
  
tomernic's avatar
tomernic committed
815
816
817
  bool prohibitsScrolling() const;
  void setProhibitsScrolling(const bool);
  
mjs's avatar
mjs committed
818
  // split out controller objects
mjs's avatar
mjs committed
819
  FrameTree* tree() const;
justing's avatar
justing committed
820
821
  SelectionController* selectionController() const;
  SelectionController* dragCaretController() const;
ggaren's avatar
ggaren committed
822
  DOMWindow* domWindow() const;
mjs's avatar
mjs committed
823
824
825
826

 private:
  friend class FramePrivate;
  FramePrivate* d;
darin's avatar
darin committed
827
};
kocienda's avatar
kocienda committed
828

weinig's avatar
weinig committed
829
} // namespace WebCore
darin's avatar
darin committed
830

weinig's avatar
weinig committed
831
#endif // Frame_H