0
|
1 |
/*
|
|
2 |
* Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
|
|
3 |
* 1999-2001 Lars Knoll <knoll@kde.org>
|
|
4 |
* 1999-2001 Antti Koivisto <koivisto@kde.org>
|
|
5 |
* 2000-2001 Simon Hausmann <hausmann@kde.org>
|
|
6 |
* 2000-2001 Dirk Mueller <mueller@kde.org>
|
|
7 |
* 2000 Stefan Schimanski <1Stein@gmx.de>
|
|
8 |
* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
|
|
9 |
* Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
|
|
10 |
* Copyright (C) 2008 Eric Seidel <eric@webkit.org>
|
|
11 |
*
|
|
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.
|
|
16 |
*
|
|
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.
|
|
21 |
*
|
|
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., 51 Franklin Street, Fifth Floor,
|
|
25 |
* Boston, MA 02110-1301, USA.
|
|
26 |
*/
|
|
27 |
|
|
28 |
#ifndef Frame_h
|
|
29 |
#define Frame_h
|
|
30 |
|
|
31 |
#include "AnimationController.h"
|
|
32 |
#include "Document.h"
|
|
33 |
#include "DragImage.h"
|
|
34 |
#include "EditAction.h"
|
|
35 |
#include "Editor.h"
|
|
36 |
#include "EventHandler.h"
|
|
37 |
#include "FrameLoader.h"
|
|
38 |
#include "FrameTree.h"
|
|
39 |
#include "Range.h"
|
|
40 |
#include "ScriptController.h"
|
|
41 |
#include "ScrollBehavior.h"
|
|
42 |
#include "SelectionController.h"
|
|
43 |
#include "TextGranularity.h"
|
|
44 |
#include "UserScriptTypes.h"
|
|
45 |
|
|
46 |
#if PLATFORM(WIN)
|
|
47 |
#include "FrameWin.h"
|
|
48 |
#endif
|
|
49 |
|
|
50 |
#if PLATFORM(MAC)
|
|
51 |
#ifndef __OBJC__
|
|
52 |
class NSArray;
|
|
53 |
class NSDictionary;
|
|
54 |
class NSMutableDictionary;
|
|
55 |
class NSString;
|
|
56 |
typedef int NSWritingDirection;
|
|
57 |
#endif
|
|
58 |
#endif
|
|
59 |
|
|
60 |
#if PLATFORM(WIN)
|
|
61 |
typedef struct HBITMAP__* HBITMAP;
|
|
62 |
#endif
|
|
63 |
|
|
64 |
namespace WebCore {
|
|
65 |
|
|
66 |
class CSSMutableStyleDeclaration;
|
|
67 |
class Editor;
|
|
68 |
class EventHandler;
|
|
69 |
class FrameLoader;
|
|
70 |
class RedirectScheduler;
|
|
71 |
class FrameLoaderClient;
|
|
72 |
class FrameTree;
|
|
73 |
class FrameView;
|
|
74 |
class HTMLFrameOwnerElement;
|
|
75 |
class HTMLTableCellElement;
|
|
76 |
class RegularExpression;
|
|
77 |
class RenderPart;
|
|
78 |
class ScriptController;
|
|
79 |
class SelectionController;
|
|
80 |
class Settings;
|
|
81 |
class VisibleSelection;
|
|
82 |
class Widget;
|
|
83 |
|
|
84 |
template <typename T> class Timer;
|
|
85 |
|
|
86 |
class Frame : public RefCounted<Frame> {
|
|
87 |
public:
|
|
88 |
static PassRefPtr<Frame> create(Page* page, HTMLFrameOwnerElement* ownerElement, FrameLoaderClient* client)
|
|
89 |
{
|
|
90 |
return adoptRef(new Frame(page, ownerElement, client));
|
|
91 |
}
|
|
92 |
void setView(PassRefPtr<FrameView>);
|
|
93 |
~Frame();
|
|
94 |
|
|
95 |
void init();
|
|
96 |
|
|
97 |
Page* page() const;
|
|
98 |
void detachFromPage();
|
|
99 |
HTMLFrameOwnerElement* ownerElement() const;
|
|
100 |
|
|
101 |
void pageDestroyed();
|
|
102 |
void disconnectOwnerElement();
|
|
103 |
|
|
104 |
Document* document() const;
|
|
105 |
FrameView* view() const;
|
|
106 |
|
|
107 |
void setDOMWindow(DOMWindow*);
|
|
108 |
DOMWindow* domWindow() const;
|
|
109 |
void clearFormerDOMWindow(DOMWindow*);
|
|
110 |
|
|
111 |
Editor* editor() const;
|
|
112 |
EventHandler* eventHandler() const;
|
|
113 |
FrameLoader* loader() const;
|
|
114 |
RedirectScheduler* redirectScheduler() const;
|
|
115 |
SelectionController* selection() const;
|
|
116 |
FrameTree* tree() const;
|
|
117 |
AnimationController* animation() const;
|
|
118 |
ScriptController* script();
|
|
119 |
|
|
120 |
RenderView* contentRenderer() const; // root renderer for the document contained in this frame
|
|
121 |
RenderPart* ownerRenderer() const; // renderer for the element that contains this frame
|
|
122 |
|
|
123 |
bool isDisconnected() const;
|
|
124 |
void setIsDisconnected(bool);
|
|
125 |
bool excludeFromTextSearch() const;
|
|
126 |
void setExcludeFromTextSearch(bool);
|
|
127 |
|
|
128 |
void createView(const IntSize&, const Color&, bool, const IntSize &, bool,
|
|
129 |
ScrollbarMode = ScrollbarAuto, ScrollbarMode = ScrollbarAuto);
|
|
130 |
|
|
131 |
void injectUserScripts(UserScriptInjectionTime);
|
|
132 |
|
|
133 |
private:
|
|
134 |
void injectUserScriptsForWorld(unsigned worldID, const UserScriptVector&, UserScriptInjectionTime);
|
|
135 |
|
|
136 |
private:
|
|
137 |
Frame(Page*, HTMLFrameOwnerElement*, FrameLoaderClient*);
|
|
138 |
|
|
139 |
// === undecided, would like to consider moving to another class
|
|
140 |
|
|
141 |
public:
|
|
142 |
static Frame* frameForWidget(const Widget*);
|
|
143 |
|
|
144 |
Settings* settings() const; // can be NULL
|
|
145 |
|
|
146 |
void setPrinting(bool printing, float minPageWidth, float maxPageWidth, bool adjustViewSize);
|
|
147 |
|
|
148 |
bool inViewSourceMode() const;
|
|
149 |
void setInViewSourceMode(bool = true);
|
|
150 |
|
|
151 |
void keepAlive(); // Used to keep the frame alive when running a script that might destroy it.
|
|
152 |
#ifndef NDEBUG
|
|
153 |
static void cancelAllKeepAlive();
|
|
154 |
#endif
|
|
155 |
|
|
156 |
void setDocument(PassRefPtr<Document>);
|
|
157 |
|
|
158 |
#if ENABLE(ORIENTATION_EVENTS)
|
|
159 |
// Orientation is the interface orientation in degrees. Some examples are:
|
|
160 |
// 0 is straight up; -90 is when the device is rotated 90 clockwise;
|
|
161 |
// 90 is when rotated counter clockwise.
|
|
162 |
void sendOrientationChangeEvent(int orientation);
|
|
163 |
int orientation() const { return m_orientation; }
|
|
164 |
#endif
|
|
165 |
|
|
166 |
void clearTimers();
|
|
167 |
static void clearTimers(FrameView*, Document*);
|
|
168 |
|
|
169 |
void setNeedsReapplyStyles();
|
|
170 |
bool needsReapplyStyles() const;
|
|
171 |
void reapplyStyles();
|
|
172 |
|
|
173 |
String documentTypeString() const;
|
|
174 |
|
|
175 |
// This method -- and the corresponding list of former DOM windows --
|
|
176 |
// should move onto ScriptController
|
|
177 |
void clearDOMWindow();
|
|
178 |
|
|
179 |
String displayStringModifiedByEncoding(const String& str) const
|
|
180 |
{
|
|
181 |
return document() ? document()->displayStringModifiedByEncoding(str) : str;
|
|
182 |
}
|
|
183 |
|
|
184 |
private:
|
|
185 |
void lifeSupportTimerFired(Timer<Frame>*);
|
|
186 |
|
|
187 |
// === to be moved into FrameView
|
|
188 |
|
|
189 |
public:
|
|
190 |
void setZoomFactor(float scale, bool isTextOnly);
|
|
191 |
float zoomFactor() const;
|
|
192 |
bool isZoomFactorTextOnly() const;
|
|
193 |
bool shouldApplyTextZoom() const;
|
|
194 |
bool shouldApplyPageZoom() const;
|
|
195 |
float pageZoomFactor() const { return shouldApplyPageZoom() ? zoomFactor() : 1.0f; }
|
|
196 |
float textZoomFactor() const { return shouldApplyTextZoom() ? zoomFactor() : 1.0f; }
|
|
197 |
|
|
198 |
// === to be moved into Chrome
|
|
199 |
|
|
200 |
public:
|
|
201 |
void focusWindow();
|
|
202 |
void unfocusWindow();
|
|
203 |
bool shouldClose();
|
|
204 |
void scheduleClose();
|
|
205 |
|
|
206 |
void setJSStatusBarText(const String&);
|
|
207 |
void setJSDefaultStatusBarText(const String&);
|
|
208 |
String jsStatusBarText() const;
|
|
209 |
String jsDefaultStatusBarText() const;
|
|
210 |
|
|
211 |
// === to be moved into Editor
|
|
212 |
|
|
213 |
public:
|
|
214 |
String selectedText() const;
|
|
215 |
bool findString(const String&, bool forward, bool caseFlag, bool wrapFlag, bool startInSelection);
|
|
216 |
|
|
217 |
const VisibleSelection& mark() const; // Mark, to be used as emacs uses it.
|
|
218 |
void setMark(const VisibleSelection&);
|
|
219 |
|
|
220 |
void computeAndSetTypingStyle(CSSStyleDeclaration* , EditAction = EditActionUnspecified);
|
|
221 |
String selectionStartStylePropertyValue(int stylePropertyID) const;
|
|
222 |
void applyEditingStyleToBodyElement() const;
|
|
223 |
void removeEditingStyleFromBodyElement() const;
|
|
224 |
void applyEditingStyleToElement(Element*) const;
|
|
225 |
void removeEditingStyleFromElement(Element*) const;
|
|
226 |
|
|
227 |
IntRect firstRectForRange(Range*) const;
|
|
228 |
|
|
229 |
void respondToChangedSelection(const VisibleSelection& oldSelection, bool closeTyping);
|
|
230 |
bool shouldChangeSelection(const VisibleSelection& oldSelection, const VisibleSelection& newSelection, EAffinity, bool stillSelecting) const;
|
|
231 |
|
|
232 |
RenderStyle* styleForSelectionStart(Node*& nodeToRemove) const;
|
|
233 |
|
|
234 |
unsigned markAllMatchesForText(const String&, bool caseFlag, unsigned limit);
|
|
235 |
bool markedTextMatchesAreHighlighted() const;
|
|
236 |
void setMarkedTextMatchesAreHighlighted(bool flag);
|
|
237 |
|
|
238 |
PassRefPtr<CSSComputedStyleDeclaration> selectionComputedStyle(Node*& nodeToRemove) const;
|
|
239 |
|
|
240 |
void textFieldDidBeginEditing(Element*);
|
|
241 |
void textFieldDidEndEditing(Element*);
|
|
242 |
void textDidChangeInTextField(Element*);
|
|
243 |
bool doTextFieldCommandFromEvent(Element*, KeyboardEvent*);
|
|
244 |
void textWillBeDeletedInTextField(Element* input);
|
|
245 |
void textDidChangeInTextArea(Element*);
|
|
246 |
|
|
247 |
DragImageRef dragImageForSelection();
|
|
248 |
|
|
249 |
// === to be moved into SelectionController
|
|
250 |
|
|
251 |
public:
|
|
252 |
TextGranularity selectionGranularity() const;
|
|
253 |
void setSelectionGranularity(TextGranularity);
|
|
254 |
|
|
255 |
bool shouldChangeSelection(const VisibleSelection&) const;
|
|
256 |
bool shouldDeleteSelection(const VisibleSelection&) const;
|
|
257 |
void clearCaretRectIfNeeded();
|
|
258 |
void setFocusedNodeIfNeeded();
|
|
259 |
void selectionLayoutChanged();
|
|
260 |
void notifyRendererOfSelectionChange(bool userTriggered);
|
|
261 |
|
|
262 |
void invalidateSelection();
|
|
263 |
|
|
264 |
void setCaretVisible(bool = true);
|
|
265 |
void paintCaret(GraphicsContext*, int tx, int ty, const IntRect& clipRect) const;
|
|
266 |
void paintDragCaret(GraphicsContext*, int tx, int ty, const IntRect& clipRect) const;
|
|
267 |
|
|
268 |
bool isContentEditable() const; // if true, everything in frame is editable
|
|
269 |
|
|
270 |
void updateSecureKeyboardEntryIfActive();
|
|
271 |
|
|
272 |
CSSMutableStyleDeclaration* typingStyle() const;
|
|
273 |
void setTypingStyle(CSSMutableStyleDeclaration*);
|
|
274 |
void clearTypingStyle();
|
|
275 |
|
|
276 |
FloatRect selectionBounds(bool clipToVisibleContent = true) const;
|
|
277 |
void selectionTextRects(Vector<FloatRect>&, bool clipToVisibleContent = true) const;
|
|
278 |
|
|
279 |
HTMLFormElement* currentForm() const;
|
|
280 |
|
|
281 |
void revealSelection(const ScrollAlignment& = ScrollAlignment::alignCenterIfNeeded, bool revealExtent = false);
|
|
282 |
void setSelectionFromNone();
|
|
283 |
|
|
284 |
void setUseSecureKeyboardEntry(bool);
|
|
285 |
|
|
286 |
private:
|
|
287 |
void caretBlinkTimerFired(Timer<Frame>*);
|
|
288 |
|
|
289 |
public:
|
|
290 |
SelectionController* dragCaretController() const;
|
|
291 |
|
|
292 |
String searchForLabelsAboveCell(RegularExpression*, HTMLTableCellElement*);
|
|
293 |
String searchForLabelsBeforeElement(const Vector<String>& labels, Element*);
|
|
294 |
String matchLabelsAgainstElement(const Vector<String>& labels, Element*);
|
|
295 |
|
|
296 |
VisiblePosition visiblePositionForPoint(const IntPoint& framePoint);
|
|
297 |
Document* documentAtPoint(const IntPoint& windowPoint);
|
|
298 |
|
|
299 |
#if PLATFORM(MAC)
|
|
300 |
|
|
301 |
// === undecided, would like to consider moving to another class
|
|
302 |
|
|
303 |
public:
|
|
304 |
NSString* searchForNSLabelsAboveCell(RegularExpression*, HTMLTableCellElement*);
|
|
305 |
NSString* searchForLabelsBeforeElement(NSArray* labels, Element*);
|
|
306 |
NSString* matchLabelsAgainstElement(NSArray* labels, Element*);
|
|
307 |
|
|
308 |
#if ENABLE(DASHBOARD_SUPPORT)
|
|
309 |
NSMutableDictionary* dashboardRegionsDictionary();
|
|
310 |
#endif
|
|
311 |
|
|
312 |
NSImage* selectionImage(bool forceBlackText = false) const;
|
|
313 |
NSImage* snapshotDragImage(Node*, NSRect* imageRect, NSRect* elementRect) const;
|
|
314 |
NSImage* nodeImage(Node*) const;
|
|
315 |
|
|
316 |
private:
|
|
317 |
NSImage* imageFromRect(NSRect) const;
|
|
318 |
|
|
319 |
// === to be moved into Editor
|
|
320 |
|
|
321 |
public:
|
|
322 |
NSDictionary* fontAttributesForSelectionStart() const;
|
|
323 |
NSWritingDirection baseWritingDirectionForSelectionStart() const;
|
|
324 |
|
|
325 |
#endif
|
|
326 |
|
|
327 |
#if PLATFORM(WIN)
|
|
328 |
|
|
329 |
public:
|
|
330 |
// FIXME - We should have a single version of nodeImage instead of using platform types.
|
|
331 |
HBITMAP nodeImage(Node*) const;
|
|
332 |
|
|
333 |
#endif
|
|
334 |
|
|
335 |
private:
|
|
336 |
Page* m_page;
|
|
337 |
mutable FrameTree m_treeNode;
|
|
338 |
mutable FrameLoader m_loader;
|
|
339 |
mutable RedirectScheduler m_redirectScheduler;
|
|
340 |
|
|
341 |
mutable RefPtr<DOMWindow> m_domWindow;
|
|
342 |
HashSet<DOMWindow*> m_liveFormerWindows;
|
|
343 |
|
|
344 |
HTMLFrameOwnerElement* m_ownerElement;
|
|
345 |
RefPtr<FrameView> m_view;
|
|
346 |
RefPtr<Document> m_doc;
|
|
347 |
|
|
348 |
ScriptController m_script;
|
|
349 |
|
|
350 |
String m_kjsStatusBarText;
|
|
351 |
String m_kjsDefaultStatusBarText;
|
|
352 |
|
|
353 |
float m_zoomFactor;
|
|
354 |
|
|
355 |
TextGranularity m_selectionGranularity;
|
|
356 |
|
|
357 |
mutable SelectionController m_selectionController;
|
|
358 |
mutable VisibleSelection m_mark;
|
|
359 |
Timer<Frame> m_caretBlinkTimer;
|
|
360 |
mutable Editor m_editor;
|
|
361 |
mutable EventHandler m_eventHandler;
|
|
362 |
mutable AnimationController m_animationController;
|
|
363 |
|
|
364 |
RefPtr<CSSMutableStyleDeclaration> m_typingStyle;
|
|
365 |
|
|
366 |
Timer<Frame> m_lifeSupportTimer;
|
|
367 |
|
|
368 |
#if ENABLE(ORIENTATION_EVENTS)
|
|
369 |
int m_orientation;
|
|
370 |
#endif
|
|
371 |
|
|
372 |
bool m_caretVisible;
|
|
373 |
bool m_caretPaint;
|
|
374 |
|
|
375 |
bool m_highlightTextMatches;
|
|
376 |
bool m_inViewSourceMode;
|
|
377 |
bool m_needsReapplyStyles;
|
|
378 |
bool m_isDisconnected;
|
|
379 |
bool m_excludeFromTextSearch;
|
|
380 |
};
|
|
381 |
|
|
382 |
} // namespace WebCore
|
|
383 |
|
|
384 |
#endif // Frame_h
|