Frame.h 25 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 "KWQScrollBar.h"
darin's avatar
darin committed
37 38 39
#include "Node.h"
#include "TextAffinity.h"
#include "TextGranularity.h"
darin's avatar
darin committed
40
#include "TransferJobClient.h"
mjs's avatar
mjs committed
41
#include <wtf/Vector.h>
mjs's avatar
mjs committed
42
#include "RenderObject.h"
kocienda's avatar
kocienda committed
43 44 45 46

class KHTMLSettings;

namespace KJS {
darin's avatar
darin committed
47 48 49 50
    class JSValue;
    class PausedTimeouts;
    class SavedBuiltins;
    class SavedProperties;
51 52 53 54

    namespace Bindings {
        class Instance;
    }
darin's avatar
darin committed
55
}
kocienda's avatar
kocienda committed
56

darin's avatar
darin committed
57 58
namespace WebCore {

darin's avatar
darin committed
59 60 61
class CSSComputedStyleDeclaration;
class CSSMutableStyleDeclaration;
class CSSStyleDeclaration;
darin's avatar
darin committed
62
class DrawContentsEvent;
ggaren's avatar
ggaren committed
63
class DOMWindow;
darin's avatar
darin committed
64 65 66
class EditCommandPtr;
class FramePrivate;
class FrameTree;
darin's avatar
darin committed
67
class KJSProxy;
darin's avatar
darin committed
68 69
class Page;
class Plugin;
darin's avatar
darin committed
70
class MouseEventWithHitTestResults;
darin's avatar
darin committed
71
class Range;
adele's avatar
adele committed
72
class RenderLayer;
darin's avatar
darin committed
73 74 75
class Selection;
class SelectionController;
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 82 83 84 85
    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
86 87
};

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

darin's avatar
darin committed
95
class Frame : public Shared<Frame>, Noncopyable, TransferJobClient {
96

kocienda's avatar
kocienda committed
97
public:
kocienda's avatar
kocienda committed
98
  enum { NoXPosForVerticalArrowNavigation = INT_MIN };
kocienda's avatar
kocienda committed
99

darin's avatar
darin committed
100
  Frame(Page*, RenderPart*);
mjs's avatar
mjs committed
101
  virtual ~Frame();
kocienda's avatar
kocienda committed
102

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

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

darin's avatar
darin committed
108 109
  Page* page() const;

kocienda's avatar
kocienda committed
110
  /**
darin's avatar
darin committed
111
   * Stop loading the document and kill all data requests (for images, etc.)
kocienda's avatar
kocienda committed
112
   */
113
  void stopLoading(bool sendUnload = false);
kocienda's avatar
kocienda committed
114 115

  /**
darin's avatar
darin committed
116
   * Returns a pointer to the @ref BrowserExtension.
kocienda's avatar
kocienda committed
117
   */
118
  BrowserExtension* browserExtension() const;
kocienda's avatar
kocienda committed
119 120

  /**
121
   * Returns a pointer to the HTML document's view.
kocienda's avatar
kocienda committed
122
   */
123
  FrameView* view() const;
kocienda's avatar
kocienda committed
124

125 126
  virtual void setView(FrameView*);

kocienda's avatar
kocienda committed
127
  /**
ggaren's avatar
ggaren committed
128
   * Returns @p true if Javascript is enabled, @p false otherwise.
kocienda's avatar
kocienda committed
129
   */
ggaren's avatar
ggaren committed
130
  bool jScriptEnabled() const;
kocienda's avatar
kocienda committed
131 132

  /**
ggaren's avatar
ggaren committed
133
   * Returns true if Java is enabled, false otherwise.
kocienda's avatar
kocienda committed
134
   */
ggaren's avatar
ggaren committed
135 136 137 138 139 140
  bool javaEnabled() const;
  
  /**
   * Returns true if plugins are enabled, false otherwise.
   */
  bool pluginsEnabled() const;
kocienda's avatar
kocienda committed
141 142 143 144

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

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

167
  KURL baseURL() const;
168
  String baseTarget() const;
169 170 171 172

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

darin's avatar
darin committed
175
  /**
darin's avatar
darin committed
176 177
   * Make a location change, or schedule one for later.
   * These are used for JavaScript-triggered location changes.
darin's avatar
darin committed
178
   */
179 180
  void changeLocation(const DeprecatedString& URL, const DeprecatedString& referrer, bool lockHistory = true, bool userGesture = false);
  void scheduleLocationChange(const DeprecatedString& url, const DeprecatedString& referrer, bool lockHistory = true, bool userGesture = false);
darin's avatar
darin committed
181
  bool isScheduledLocationChangePending() const;
mjs's avatar
mjs committed
182

darin's avatar
darin committed
183 184 185 186
  /**
   * Schedules a history navigation operation (go forward, go back, etc.).
   * This is used for JavaScript-triggered location changes.
   */
187
  void scheduleHistoryNavigation(int steps);
darin's avatar
darin committed
188

189 190
  /**
   * Clears the widget and prepares it for new content.
kocienda's avatar
kocienda committed
191 192 193 194
   *
   * If you want @ref url() to return
   * for example "file:/tmp/test.html", you can use the following code:
   * <PRE>
195
   * view->begin(KURL("file:/tmp/test.html"));
kocienda's avatar
kocienda committed
196 197 198 199
   * </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
200
   * a directory so that any images are found.
kocienda's avatar
kocienda committed
201 202 203 204
   *
   * All child frames and the old document are removed if you call
   * this method.
   */
205
  virtual void begin(const KURL& url = KURL());
kocienda's avatar
kocienda committed
206 207

  /**
208
   * Writes another part of the HTML code to the widget.
kocienda's avatar
kocienda committed
209 210 211 212 213 214 215 216 217 218 219 220 221
   *
   * You may call
   * this function many times in sequence. But remember: The fewer calls
   * you make, the faster the widget will be.
   *
   * The HTML code is send through a decoder which decodes the stream to
   * 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.
   *
222 223
   * Attention: Don't mix calls to @ref write(const char*) with calls
   * to @ref write(const DeprecatedString&  ).
kocienda's avatar
kocienda committed
224 225 226
   *
   * The result might not be what you want.
   */
227
  virtual void write(const char* str, int len = -1);
kocienda's avatar
kocienda committed
228 229

  /**
230
   * Writes another part of the HTML code to the widget.
kocienda's avatar
kocienda committed
231 232 233 234 235
   *
   * You may call
   * this function many times in sequence. But remember: The fewer calls
   * you make, the faster the widget will be.
   */
236
  virtual void write(const DeprecatedString& str);
kocienda's avatar
kocienda committed
237 238 239 240 241 242

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

mjs's avatar
mjs committed
243 244
  void endIfNotLoading();

245 246 247 248 249
  /**
   * Similar to end, but called to abort a load rather than cleanly end.
   */
  void stop();

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

252
  void setEncoding(const DeprecatedString& encoding, bool userChosen);
kocienda's avatar
kocienda committed
253 254

  /**
255
   * Returns the encoding the page currently uses.
kocienda's avatar
kocienda committed
256 257 258
   *
   * Note that the encoding might be different from the charset.
   */
darin's avatar
darin committed
259
  DeprecatedString 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;
kocienda's avatar
kocienda committed
313

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

darin's avatar
darin committed
324
  // FIXME: Replace these with functions on the selection controller.
325 326
  void setSelection(const SelectionController&, bool closeTyping = true, bool keepTypingStyle = false);
  bool shouldChangeSelection(const SelectionController&) const;
darin's avatar
darin committed
327

cblu's avatar
cblu committed
328
  /**
darin's avatar
darin committed
329 330
   * Returns a mark, to be used as emacs uses it.
   */
331 332
  const Selection& mark() const;
  void setMark(const Selection&);
darin's avatar
darin committed
333

darin's avatar
darin committed
334
  // FIXME: Replace this with a function on the selection controller or change it to Selection instead?
335
  void setDragCaret(const SelectionController&);
cblu's avatar
cblu committed
336
  
harrison's avatar
harrison committed
337 338 339 340 341
  /**
   * Transposes characters either side of caret selection.
   */
  void transpose();
  
kocienda's avatar
kocienda committed
342 343 344 345 346
  /**
   * Invalidates the current selection.
   */
  void invalidateSelection();

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

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

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

kocienda's avatar
kocienda committed
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375
  /**
   * 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
376 377 378 379
  /**
   * Marks contents of node as selected.
   * Returns whether the selection changed.
   */
darin's avatar
darin committed
380
  bool selectContentsOfNode(Node*);
adele's avatar
adele committed
381
 
kocienda's avatar
kocienda committed
382 383 384
  /**
   * Returns whether editing should end in the given range
   */
385
  virtual bool shouldBeginEditing(const Range*) const;
kocienda's avatar
kocienda committed
386 387 388 389

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

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

adele's avatar
adele committed
407 408 409 410 411
  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
412
  virtual void textDidChangeInTextArea(Element*);
adele's avatar
adele committed
413

kocienda's avatar
kocienda committed
414
  /**
kocienda's avatar
kocienda committed
415
   * Returns the most recent edit command applied.
kocienda's avatar
kocienda committed
416
   */
darin's avatar
darin committed
417
  EditCommandPtr lastEditCommand();
kocienda's avatar
kocienda committed
418 419

  /**
kocienda's avatar
kocienda committed
420
   * Called when editing has been applied.
kocienda's avatar
kocienda committed
421
   */
422
  void appliedEditing(EditCommandPtr&);
kocienda's avatar
kocienda committed
423 424

  /**
kocienda's avatar
kocienda committed
425
   * Called when editing has been unapplied.
kocienda's avatar
kocienda committed
426
   */
427
  void unappliedEditing(EditCommandPtr&);
kocienda's avatar
kocienda committed
428 429 430 431

  /**
   * Called when editing has been reapplied.
   */
432
  void reappliedEditing(EditCommandPtr&);
kocienda's avatar
kocienda committed
433

kocienda's avatar
kocienda committed
434 435 436
  /**
   * Returns the typing style for the document.
   */
437
  CSSMutableStyleDeclaration* typingStyle() const;
kocienda's avatar
kocienda committed
438 439 440 441

  /**
   * Sets the typing style for the document.
   */
442
  void setTypingStyle(CSSMutableStyleDeclaration*);
kocienda's avatar
kocienda committed
443 444 445 446 447 448

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

darin's avatar
darin committed
449
  virtual void tokenizerProcessedData() {}
450

darin's avatar
darin committed
451
  const KHTMLSettings* settings() const;
kocienda's avatar
kocienda committed
452

darin's avatar
darin committed
453 454 455 456
  void setJSStatusBarText(const String&);
  void setJSDefaultStatusBarText(const String&);
  String jsStatusBarText() const;
  String jsDefaultStatusBarText() const;
kocienda's avatar
kocienda committed
457

458 459 460
  /**
   * Referrer used for links in this page.
   */
darin's avatar
darin committed
461
  DeprecatedString referrer() const;
462 463 464 465

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

mjs's avatar
mjs committed
468
  bool isPointInsideSelection(const IntPoint&);
cblu's avatar
cblu committed
469

470 471
  virtual bool tabsToLinks() const;
  virtual bool tabsToAllControls() const;
472

darin's avatar
darin committed
473 474 475 476 477
  // Editing operations.
  enum TriState { falseTriState, trueTriState, mixedTriState };
  void copyToPasteboard();
  void cutToPasteboard();
  void pasteFromPasteboard();
cblu's avatar
cblu committed
478
  void pasteAndMatchStyle();
479
  virtual bool canPaste() const = 0;
darin's avatar
darin committed
480 481
  void redo();
  void undo();
482 483
  virtual bool canRedo() const = 0;
  virtual bool canUndo() const = 0;
484 485 486 487 488
  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;
darin's avatar
darin committed
489
  String selectionStartStylePropertyValue(int stylePropertyID) const;
kocienda's avatar
kocienda committed
490 491
  void applyEditingStyleToBodyElement() const;
  void removeEditingStyleFromBodyElement() const;
492 493
  void applyEditingStyleToElement(Element*) const;
  void removeEditingStyleFromElement(Element*) const;
494
  virtual void print() = 0;
495
  virtual bool isCharacterSmartReplaceExempt(const QChar&, bool);
darin's avatar
darin committed
496

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

mjs's avatar
mjs committed
500 501
  static void endAllLifeSupport();

kocienda's avatar
kocienda committed
502
  /**
503 504
   * returns a KURL object for the given url. Use when
   * you know what you're doing.
kocienda's avatar
kocienda committed
505
   */
506
  KURL completeURL(const DeprecatedString& url);
507

darin's avatar
darin committed
508 509 510 511
  virtual void handleMouseReleaseDoubleClickEvent(const MouseEventWithHitTestResults&);
  virtual void handleMousePressEvent(const MouseEventWithHitTestResults&);
  virtual void handleMouseMoveEvent(const MouseEventWithHitTestResults&);
  virtual void handleMouseReleaseEvent(const MouseEventWithHitTestResults&);
512
  
mjs's avatar
mjs committed
513
  void selectClosestWordFromMouseEvent(const PlatformMouseEvent&, Node* innerNode);
kocienda's avatar
kocienda committed
514

515 516
  virtual void urlSelected(const DeprecatedString& url, const String& target);
  virtual void urlSelected(const ResourceRequest&, const String& target);
517 518 519


  // Methods with platform-specific overrides (and no base class implementation).
520
  virtual void setTitle(const String&) = 0;
521
  virtual void handledOnloadEvents() = 0;
522 523 524 525 526 527 528 529
  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;
  virtual void markMisspellingsInAdjacentWords(const VisiblePosition&) = 0;
  virtual void markMisspellings(const SelectionController&) = 0;
darin's avatar
darin committed
530 531 532 533
  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;  
534 535 536 537 538 539
  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
540
  virtual void focusWindow() = 0;
541 542
  virtual void unfocusWindow() = 0;
  virtual void createEmptyDocument() = 0;
543 544 545
  virtual Range* markedTextRange() const = 0;
  virtual void registerCommandForUndo(const EditCommandPtr&) = 0;
  virtual void registerCommandForRedo(const EditCommandPtr&) = 0;
546 547 548 549 550 551 552 553
  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;
554
  virtual void respondToChangedSelection(const SelectionController& oldSelection, bool closeTyping) = 0;
555
  virtual void respondToChangedContents() = 0;
556
  virtual bool shouldChangeSelection(const SelectionController& oldSelection, const SelectionController& newSelection, EAffinity affinity, bool stillSelecting) const = 0;
557 558 559 560
  virtual void partClearedInBegin() = 0; 
  virtual void saveDocumentState() = 0;
  virtual void restoreDocumentState() = 0;
  virtual bool canGoBackOrForward(int distance) const = 0;
mjs's avatar
mjs committed
561 562 563
  virtual void openURLRequest(const ResourceRequest&) = 0;
  virtual void submitForm(const ResourceRequest&) = 0;
  virtual void urlSelected(const ResourceRequest&) = 0;
ap's avatar
ap committed
564
  virtual bool passSubframeEventToSubframe(MouseEventWithHitTestResults&, Frame* subframePart = 0) = 0;
565
  virtual bool passWheelEventToChildWidget(Node*) = 0;
566
  virtual bool lastEventIsMouseUp() const = 0;
567
  virtual String overrideMediaType() const = 0;
568
protected:
tomernic's avatar
tomernic committed
569
  virtual Plugin* createPlugin(Element* node, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType) = 0;
570 571
  virtual Frame* createFrame(const KURL& url, const String& name, RenderPart* renderer, const String& referrer) = 0;
  virtual ObjectContentType objectContentType(const KURL& url, const String& mimeType) = 0;
kocienda's avatar
kocienda committed
572

darin's avatar
darin committed
573 574
    virtual void redirectionTimerFired(Timer<Frame>*);

darin's avatar
darin committed
575 576 577 578 579 580 581
public:
  void loadDone();

  void finishedParsing();

  void checkCompleted();

582
  void reparseConfiguration();
kocienda's avatar
kocienda committed
583

darin's avatar
darin committed
584
private:
darin's avatar
darin committed
585 586 587
    virtual void receivedRedirect(TransferJob*, const KURL&);
    virtual void receivedAllData(TransferJob*);

trey's avatar
trey committed
588 589
  void childBegin();

kocienda's avatar
kocienda committed
590 591
  void submitFormAgain();

darin's avatar
darin committed
592
  void started();
593

darin's avatar
darin committed
594 595 596
  void completed(bool);
  void childCompleted(bool);
  void parentCompleted();
darin's avatar
darin committed
597

darin's avatar
darin committed
598 599
    void lifeSupportTimerFired(Timer<Frame>*);
    void endLifeSupport();
darin's avatar
darin committed
600

mjs's avatar
mjs committed
601
  virtual void clear(bool clearWindowProperties = true);
mjs's avatar
mjs committed
602

kocienda's avatar
kocienda committed
603
  void clearCaretRectIfNeeded();
cblu's avatar
cblu committed
604
  void setFocusNodeIfNeeded();
kocienda's avatar
kocienda committed
605
  void selectionLayoutChanged();
darin's avatar
darin committed
606
    void caretBlinkTimerFired(Timer<Frame>*);
607

608 609
  bool shouldUsePlugin(Node* element, const KURL& url, const String& mimeType, bool hasFallback, bool& useFallback);
  bool loadPlugin(RenderPart* renderer, const KURL& url, const String& mimeType, 
610
                  const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallback);
611
  Frame* loadSubframe(RenderPart* renderer, const KURL& url, const String& name, const String& referrer);
kocienda's avatar
kocienda committed
612

darin's avatar
darin committed
613
public:
614 615 616
  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
617
  
618
  bool requestObject(RenderPart* frame, const String& url, const AtomicString& frameName,
619
                     const String& serviceType, const Vector<String>& paramNames, const Vector<String>& paramValues);
620
  bool requestFrame(RenderPart* frame, const String& url, const AtomicString& frameName);
mjs's avatar
mjs committed
621

622
  Document* document() const;
darin's avatar
darin committed
623
  void setDocument(Document* newDoc);
darin's avatar
darin committed
624 625 626 627

  // 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
628
  
629 630
  virtual bool mouseDownMayStartSelect() const { return true; }

631 632
  void handleFallbackContent();

darin's avatar
darin committed
633
private:
rjw's avatar
WebKit:  
rjw committed
634
  void cancelRedirection(bool newLoadInProgress = false);
kocienda's avatar
kocienda committed
635

mjs's avatar
mjs committed
636
 public:
637 638 639 640
  KJS::JSValue* executeScript(const String& filename, int baseLine, Node*, const DeprecatedString& script);
  KJSProxy* jScript();
  Frame* opener();
  void setOpener(Frame* _opener);
darin's avatar
darin committed
641 642
  bool openedByJS();
  void setOpenedByJS(bool _openedByJS);
mjs's avatar
mjs committed
643

644
  void setSettings(KHTMLSettings*);
mjs's avatar
mjs committed
645 646 647

  void provisionalLoadStarted();
  bool userGestureHint();
648 649 650 651
  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
652

mjs's avatar
mjs committed
653 654 655
  // root renderer for the document contained in this frame
  RenderObject* renderer() const;
  
darin's avatar
darin committed
656
  Element* ownerElement();
mjs's avatar
mjs committed
657 658
  // renderer for the element that contains this frame
  RenderPart* ownerRenderer();
mjs's avatar
mjs committed
659

660
  IntRect selectionRect() const;
661
  FloatRect visibleSelectionRect() const;
mjs's avatar
mjs committed
662 663
  bool isFrameSet() const;

664
  HTMLFormElement* currentForm() const;
mjs's avatar
mjs committed
665

666
  RenderStyle* styleForSelectionStart(Node* &nodeToRemove) const;
mjs's avatar
mjs committed
667

mjs's avatar
mjs committed
668 669 670 671 672 673 674 675
  // Scrolls as necessary to reveal the selection
  void revealSelection();
  // Centers the selection regardless of whether it was already visible
  void centerSelectionInVisibleArea() const;
  void setSelectionFromNone();

  bool scrollOverflow(KWQScrollDirection direction, KWQScrollGranularity granularity);

676
  void adjustPageHeight(float* newBottom, float oldTop, float oldBottom, float bottomLimit);
mjs's avatar
mjs committed
677 678

  bool canCachePage();
679 680 681 682 683 684 685 686
  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
687

688 689 690
  static Frame* frameForWidget(const Widget*);
  static Node* nodeForWidget(const Widget*);
  static Frame* frameForNode(Node*);
mjs's avatar
mjs committed
691

692
  static void clearDocumentFocus(Widget*);
mjs's avatar
mjs committed
693 694

  void updatePolicyBaseURL();
darin's avatar
darin committed
695
  void setPolicyBaseURL(const String&);
mjs's avatar
mjs committed
696 697 698 699 700 701 702

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

  void sendResizeEvent();
  void sendScrollEvent();
  bool scrollbarsVisible();
703
  void scrollToAnchor(const KURL&);
darin's avatar
darin committed
704
  bool canMouseDownStartSelect(Node*);
darin's avatar
darin committed
705 706 707
  bool passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults&, bool isDoubleClick);
  bool passWidgetMouseDownEventToWidget(RenderWidget*);
  virtual bool passMouseDownEventToWidget(Widget*) = 0;
mjs's avatar
mjs committed
708 709

  void clearTimers();
710
  static void clearTimers(FrameView*);
mjs's avatar
mjs committed
711 712

  bool displaysWithFocusAttributes() const;
713
  virtual void setDisplaysWithFocusAttributes(bool flag);
mjs's avatar
mjs committed
714 715 716
  void setWindowHasFocus(bool flag);
  // Convenience, to avoid repeating the code to dig down to get this.

darin's avatar
darin committed
717
  UChar backslashAsCurrencySymbol() const;
mjs's avatar
mjs committed
718

darin's avatar
darin committed
719
  DeprecatedValueList<MarkedTextUnderline> markedTextUnderlines() const;  
mjs's avatar
mjs committed
720
  bool markedTextUsesUnderlines() const;
sullivan's avatar
sullivan committed
721 722 723 724 725
  
  unsigned markAllMatchesForText(const String&, bool caseFlag);
  bool markedTextMatchesAreHighlighted() const;
  void setMarkedTextMatchesAreHighlighted(bool flag);
  
mjs's avatar
mjs committed
726 727 728
  // 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();
729
  Node* mousePressNode();
730 731 732
  
  void clearRecordedFormValues();
  void recordFormValue(const String& name, const String& value, PassRefPtr<HTMLFormElement>);
mjs's avatar
mjs committed
733

ap's avatar
ap committed
734 735
  bool isComplete() const;
  bool isLoadingMainResource() const;
736
  
737
  void replaceContentsWithScriptResult(const KURL& url);
mjs's avatar
mjs committed
738

darin's avatar
darin committed
739 740
    void disconnectOwnerRenderer();

darin's avatar
darin committed
741 742
    void setNeedsReapplyStyles();

mjs's avatar
mjs committed
743
protected:
darin's avatar
darin committed
744 745
    virtual void startRedirectionTimer();
    virtual void stopRedirectionTimer();
adele's avatar
adele committed
746 747 748 749
    
    void handleAutoscroll(RenderLayer*);
    void startAutoscrollTimer();
    void stopAutoscrollTimer();
darin's avatar
darin committed
750

mjs's avatar
mjs committed
751
 private:
kocienda's avatar
kocienda committed
752
  void emitLoadEvent();
darin's avatar
darin committed
753 754
  
  void receivedFirstData();
kocienda's avatar
kocienda committed
755

darin's avatar
darin committed
756 757 758 759 760
  /**
   * @internal Extracts anchor and tries both encoded and decoded form.
   */
  void gotoAnchor();

darin's avatar
darin committed
761 762 763
  void handleMousePressEventSingleClick(const MouseEventWithHitTestResults&);
  void handleMousePressEventDoubleClick(const MouseEventWithHitTestResults&);
  void handleMousePressEventTripleClick(const MouseEventWithHitTestResults&);
kocienda's avatar
kocienda committed
764

765
  CSSComputedStyleDeclaration* selectionComputedStyle(Node* &nodeToRemove) const;
darin's avatar
darin committed
766

darin's avatar
darin committed
767
    virtual void setStatusBarText(const String&);
adele's avatar
adele committed
768 769
    
    void autoscrollTimerFired(Timer<Frame>*);
darin's avatar
darin committed
770

darin's avatar
darin committed
771
public:
darin's avatar
darin committed
772
  friend class FrameMac;
mjs's avatar
mjs committed
773
  friend class FrameWin;
774

mjs's avatar
mjs committed
775 776 777 778
  RenderObject::NodeInfo nodeInfoAtPoint(const IntPoint&, bool allowShadowContent);
  bool hasSelection();
  String Frame::documentTypeString() const;

mjs's avatar
mjs committed
779
  void checkEmitLoadEvent();
780
  bool didOpenURL(const KURL&);
cblu's avatar
cblu committed
781
  virtual void didFirstLayout() {}
darin's avatar
darin committed
782

mjs's avatar
mjs committed
783 784 785
  virtual void frameDetached();

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

mjs's avatar
mjs committed
787
  KURL url() const;
mjs's avatar
mjs committed
788 789
  void setResourceRequest(const ResourceRequest& request);
  const ResourceRequest& resourceRequest() const;
mjs's avatar
mjs committed
790

andersca's avatar
andersca committed
791 792
  bool containsPlugins() const;
  
mjs's avatar
mjs committed
793
  // split out controller objects
mjs's avatar
mjs committed
794
  FrameTree* tree() const;
darin's avatar
darin committed
795 796
  SelectionController& selection() const; // FIXME: Change to pointer?
  SelectionController& dragCaret() const; // FIXME: Change to pointer?
ggaren's avatar
ggaren committed
797
  DOMWindow* domWindow() const;
mjs's avatar
mjs committed
798 799 800 801

 private:
  friend class FramePrivate;
  FramePrivate* d;
darin's avatar
darin committed
802
};
kocienda's avatar
kocienda committed
803

darin's avatar
darin committed
804 805
}

806
#endif