1
// -*- c-basic-offset: 4 -*-
3
* Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
4
* 1999-2001 Lars Knoll <knoll@kde.org>
5
* 1999-2001 Antti Koivisto <koivisto@kde.org>
6
* 2000-2001 Simon Hausmann <hausmann@kde.org>
7
* 2000-2001 Dirk Mueller <mueller@kde.org>
8
* 2000 Stefan Schimanski <1Stein@gmx.de>
9
* Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
10
* Copyright (C) 2007 Trolltech ASA
12
* This library is free software; you can redistribute it and/or
13
* modify it under the terms of the GNU Library General Public
14
* License as published by the Free Software Foundation; either
15
* version 2 of the License, or (at your option) any later version.
17
* This library is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
* Library General Public License for more details.
22
* You should have received a copy of the GNU Library General Public License
23
* along with this library; see the file COPYING.LIB. If not, write to
24
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25
* Boston, MA 02111-1307, USA.
32
#include "EditAction.h"
33
#include "DragImage.h"
34
#include "RenderLayer.h"
35
#include "TextGranularity.h"
36
#include "VisiblePosition.h"
37
#include <wtf/unicode/Unicode.h>
38
#include <wtf/Forward.h>
39
#include <wtf/Vector.h>
57
@class NSMutableDictionary;
59
@class WebCoreFrameBridge;
60
@class WebScriptObject;
65
class NSMutableDictionary;
67
class WebCoreFrameBridge;
68
class WebScriptObject;
69
typedef int NSWritingDirection;
75
class CSSComputedStyleDeclaration;
76
class CSSMutableStyleDeclaration;
77
class CSSStyleDeclaration;
86
class FrameLoaderClient;
87
class HTMLFrameOwnerElement;
88
class HTMLTableCellElement;
92
class GraphicsContext;
93
class HTMLFormElement;
102
class SelectionController;
106
struct FrameLoadRequest;
108
template <typename T> class Timer;
110
struct MarkedTextUnderline {
111
MarkedTextUnderline()
112
: startOffset(0), endOffset(0), thick(false) { }
113
MarkedTextUnderline(unsigned s, unsigned e, const Color& c, bool t)
114
: startOffset(s), endOffset(e), color(c), thick(t) { }
115
unsigned startOffset;
121
class Frame : public Shared<Frame> {
123
static double currentPaintTimeStamp() { return s_currentPaintTimeStamp; } // returns 0 if not painting
125
Frame(Page*, HTMLFrameOwnerElement*, FrameLoaderClient*);
126
virtual void setView(FrameView*);
132
void setBridge(WebCoreFrameBridge*);
133
WebCoreFrameBridge* bridge() const;
137
HTMLFrameOwnerElement* ownerElement() const;
139
void pageDestroyed();
140
void disconnectOwnerElement();
142
Document* document() const;
143
FrameView* view() const;
145
CommandByName* command() const;
146
DOMWindow* domWindow() const;
147
Editor* editor() const;
148
EventHandler* eventHandler() const;
149
FrameLoader* loader() const;
150
SelectionController* selectionController() const;
151
FrameTree* tree() const;
153
RenderObject* renderer() const; // root renderer for the document contained in this frame
154
RenderPart* ownerRenderer(); // renderer for the element that contains this frame
156
friend class FramePrivate;
158
DragImageRef dragImageForSelection();
161
static double s_currentPaintTimeStamp; // used for detecting decoded resource thrash in the cache
165
// === undecided, may or may not belong here
168
static Frame* frameForWidget(const Widget*);
170
Settings* settings() const; // can be NULL
171
void reparseConfiguration();
173
// should move to FrameView
174
void paint(GraphicsContext*, const IntRect&);
175
void setPaintRestriction(PaintRestriction);
176
bool isPainting() const;
178
void setUserStyleSheetLocation(const KURL&);
179
void setUserStyleSheet(const String& styleSheetData);
181
void setZoomFactor(int percent);
182
int zoomFactor() const;
184
void setPrinting(bool printing, float minPageWidth, float maxPageWidth, bool adjustViewSize);
186
bool inViewSourceMode() const;
187
void setInViewSourceMode(bool = true) const;
189
void setJSStatusBarText(const String&);
190
void setJSDefaultStatusBarText(const String&);
191
String jsStatusBarText() const;
192
String jsDefaultStatusBarText() const;
194
void keepAlive(); // Used to keep the frame alive when running a script that might destroy it.
196
static void cancelAllKeepAlive();
199
KJS::Bindings::Instance* createScriptInstanceForWidget(Widget*);
200
KJS::Bindings::RootObject* bindingRootObject();
202
PassRefPtr<KJS::Bindings::RootObject> createRootObject(void* nativeHandle, PassRefPtr<KJS::Interpreter>);
205
WebScriptObject* windowScriptObject();
209
NPObject* windowScriptNPObject();
212
void setDocument(PassRefPtr<Document>);
214
KJSProxy* scriptProxy();
216
bool isFrameSet() const;
218
void adjustPageHeight(float* newBottom, float oldTop, float oldBottom, float bottomLimit);
220
void forceLayout(bool allowSubtree = false);
221
void forceLayoutWithPageWidthRange(float minPageWidth, float maxPageWidth, bool adjustViewSize);
223
void sendResizeEvent();
224
void sendScrollEvent();
227
static void clearTimers(FrameView*);
229
bool isActive() const;
230
void setIsActive(bool flag);
231
void setWindowHasFocus(bool flag);
233
// Convenience, to avoid repeating the code to dig down to get this.
234
UChar backslashAsCurrencySymbol() const;
236
void setNeedsReapplyStyles();
237
String documentTypeString() const;
239
bool prohibitsScrolling() const;
240
void setProhibitsScrolling(const bool);
242
void dashboardRegionsChanged();
244
void clearScriptProxy();
245
void clearDOMWindow();
247
void cleanupScriptObjects();
248
void cleanupScriptObjectsForPlugin(void*);
251
void cleanupPlatformScriptObjects();
253
void lifeSupportTimerFired(Timer<Frame>*);
255
// === to be moved into Chrome
259
void unfocusWindow();
261
void scheduleClose();
263
// === to be moved into Editor
266
String selectedText() const;
267
bool findString(const String&, bool forward, bool caseFlag, bool wrapFlag, bool startInSelection);
269
const Selection& mark() const; // Mark, to be used as emacs uses it.
270
void setMark(const Selection&);
274
void computeAndSetTypingStyle(CSSStyleDeclaration* , EditAction = EditActionUnspecified);
275
enum TriState { falseTriState, trueTriState, mixedTriState };
276
TriState selectionHasStyle(CSSStyleDeclaration*) const;
277
String selectionStartStylePropertyValue(int stylePropertyID) const;
278
void applyEditingStyleToBodyElement() const;
279
void removeEditingStyleFromBodyElement() const;
280
void applyEditingStyleToElement(Element*) const;
281
void removeEditingStyleFromElement(Element*) const;
283
Range* markedTextRange() const;
284
IntRect firstRectForRange(Range*) const;
287
void issuePasteCommand();
289
void issueTransposeCommand();
290
void respondToChangedSelection(const Selection& oldSelection, bool closeTyping);
291
bool shouldChangeSelection(const Selection& oldSelection, const Selection& newSelection, EAffinity, bool stillSelecting) const;
293
RenderStyle* styleForSelectionStart(Node*& nodeToRemove) const;
295
const Vector<MarkedTextUnderline>& markedTextUnderlines() const;
296
bool markedTextUsesUnderlines() const;
297
void setMarkedTextRange(Range* , Vector<MarkedTextUnderline>&);
298
void selectRangeInMarkedText(unsigned selOffset, unsigned selLength);
300
unsigned markAllMatchesForText(const String&, bool caseFlag, unsigned limit);
301
bool markedTextMatchesAreHighlighted() const;
302
void setMarkedTextMatchesAreHighlighted(bool flag);
304
CSSComputedStyleDeclaration* selectionComputedStyle(Node*& nodeToRemove) const;
306
void textFieldDidBeginEditing(Element*);
307
void textFieldDidEndEditing(Element*);
308
void textDidChangeInTextField(Element*);
309
bool doTextFieldCommandFromEvent(Element*, KeyboardEvent*);
310
void textWillBeDeletedInTextField(Element* input);
311
void textDidChangeInTextArea(Element*);
313
// === to be moved into SelectionController
316
TextGranularity selectionGranularity() const;
317
void setSelectionGranularity(TextGranularity) const;
319
bool shouldChangeSelection(const Selection&) const;
320
bool shouldDeleteSelection(const Selection&) const;
321
void clearCaretRectIfNeeded();
322
void setFocusedNodeIfNeeded();
323
void selectionLayoutChanged();
324
void notifyRendererOfSelectionChange(bool userTriggered);
326
void invalidateSelection();
328
void setCaretVisible(bool = true);
329
void paintCaret(GraphicsContext*, const IntRect&) const;
330
void paintDragCaret(GraphicsContext*, const IntRect&) const;
332
bool isContentEditable() const; // if true, everything in frame is editable
334
void updateSecureKeyboardEntryIfActive();
336
CSSMutableStyleDeclaration* typingStyle() const;
337
void setTypingStyle(CSSMutableStyleDeclaration*);
338
void clearTypingStyle();
340
FloatRect selectionRect(bool clipToVisibleContent = true) const;
341
void selectionTextRects(Vector<FloatRect>&, bool clipToVisibleContent = true) const;
343
HTMLFormElement* currentForm() const;
345
void revealSelection(const RenderLayer::ScrollAlignment& = RenderLayer::gAlignCenterIfNeeded) const;
346
void revealCaret(const RenderLayer::ScrollAlignment& = RenderLayer::gAlignCenterIfNeeded) const;
347
void setSelectionFromNone();
350
void caretBlinkTimerFired(Timer<Frame>*);
351
void setUseSecureKeyboardEntry(bool);
354
SelectionController* dragCaretController() const;
356
String searchForLabelsAboveCell(RegularExpression*, HTMLTableCellElement*);
357
String searchForLabelsBeforeElement(const Vector<String>& labels, Element*);
358
String matchLabelsAgainstElement(const Vector<String>& labels, Element*);
360
VisiblePosition visiblePositionForPoint(const IntPoint& framePoint);
361
Document* documentAtPoint(const IntPoint& windowPoint);
364
// === undecided, may or may not belong here
367
NSString* searchForNSLabelsAboveCell(RegularExpression*, HTMLTableCellElement*);
368
NSString* searchForLabelsBeforeElement(NSArray* labels, Element*);
369
NSString* matchLabelsAgainstElement(NSArray* labels, Element*);
371
NSMutableDictionary* dashboardRegionsDictionary();
373
void willPopupMenu(NSMenu*);
375
NSImage* selectionImage(bool forceBlackText = false) const;
376
NSImage* snapshotDragImage(Node*, NSRect* imageRect, NSRect* elementRect) const;
379
NSImage* imageFromRect(NSRect) const;
381
// === to be moved into Chrome
384
FloatRect customHighlightLineRect(const AtomicString& type, const FloatRect& lineRect, Node*);
385
void paintCustomHighlight(const AtomicString& type, const FloatRect& boxRect, const FloatRect& lineRect, bool text, bool line, Node*);
387
// === to be moved into Editor
390
NSDictionary* fontAttributesForSelectionStart() const;
391
NSWritingDirection baseWritingDirectionForSelectionStart() const;
393
void setMarkedTextRange(Range* , NSArray* attributes, NSArray* ranges);
399
} // namespace WebCore