1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
|
// -*- c-basic-offset: 4 -*-
/*
* Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
* 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>
* 2000 Stefan Schimanski <1Stein@gmx.de>
* Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2007 Trolltech ASA
*
* 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., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef Frame_h
#define Frame_h
#include "DragImage.h"
#include "EditAction.h"
#include "RenderLayer.h"
#include "TextGranularity.h"
struct NPObject;
namespace KJS {
class JSGlobalObject;
namespace Bindings {
class Instance;
class RootObject;
}
}
#if PLATFORM(MAC)
#ifdef __OBJC__
@class WebScriptObject;
#else
class NSArray;
class NSDictionary;
class NSMutableDictionary;
class NSString;
class WebScriptObject;
typedef int NSWritingDirection;
#endif
#endif
namespace WebCore {
class Editor;
class EventHandler;
class FrameLoader;
class FrameLoaderClient;
class FramePrivate;
class FrameTree;
class HTMLFrameOwnerElement;
class HTMLTableCellElement;
class ScriptController;
class RegularExpression;
class RenderPart;
class Selection;
class SelectionController;
class Widget;
template <typename T> class Timer;
class Frame : public RefCounted<Frame> {
public:
static PassRefPtr<Frame> create(Page* page, HTMLFrameOwnerElement* ownerElement, FrameLoaderClient* client)
{
return adoptRef(new Frame(page, ownerElement, client));
}
void setView(FrameView*);
~Frame();
void init();
Page* page() const;
HTMLFrameOwnerElement* ownerElement() const;
void pageDestroyed();
void disconnectOwnerElement();
Document* document() const;
FrameView* view() const;
DOMWindow* domWindow() const;
void clearFormerDOMWindow(DOMWindow*);
Editor* editor() const;
EventHandler* eventHandler() const;
FrameLoader* loader() const;
SelectionController* selectionController() const;
FrameTree* tree() const;
AnimationController* animationController() const;
ScriptController* scriptProxy();
RenderView* contentRenderer() const; // root renderer for the document contained in this frame
RenderPart* ownerRenderer() const; // renderer for the element that contains this frame
friend class FramePrivate;
private:
Frame(Page*, HTMLFrameOwnerElement*, FrameLoaderClient*);
FramePrivate* d;
// === undecided, would like to consider moving to another class
public:
static Frame* frameForWidget(const Widget*);
Settings* settings() const; // can be NULL
#if FRAME_LOADS_USER_STYLESHEET
void setUserStyleSheetLocation(const KURL&);
void setUserStyleSheet(const String& styleSheetData);
#endif
void setPrinting(bool printing, float minPageWidth, float maxPageWidth, bool adjustViewSize);
bool inViewSourceMode() const;
void setInViewSourceMode(bool = true) const;
void keepAlive(); // Used to keep the frame alive when running a script that might destroy it.
#ifndef NDEBUG
static void cancelAllKeepAlive();
#endif
void setDocument(PassRefPtr<Document>);
void clearTimers();
static void clearTimers(FrameView*, Document*);
// Convenience, to avoid repeating the code to dig down to get this.
UChar backslashAsCurrencySymbol() const;
void setNeedsReapplyStyles();
bool needsReapplyStyles() const;
void reapplyStyles();
String documentTypeString() const;
void clearScriptProxy();
void clearDOMWindow();
void clearScriptObjects();
void cleanupScriptObjectsForPlugin(void*);
private:
void clearPlatformScriptObjects();
void disconnectPlatformScriptObjects();
void lifeSupportTimerFired(Timer<Frame>*);
// === to be moved into ScriptController
public:
PassRefPtr<KJS::Bindings::Instance> createScriptInstanceForWidget(Widget*);
KJS::Bindings::RootObject* bindingRootObject();
PassRefPtr<KJS::Bindings::RootObject> createRootObject(void* nativeHandle, KJS::JSGlobalObject*);
#if PLATFORM(MAC)
#if ENABLE(MAC_JAVA_BRIDGE)
static void initJavaJSBindings();
#endif
WebScriptObject* windowScriptObject();
#endif
#if ENABLE(NETSCAPE_PLUGIN_API)
NPObject* windowScriptNPObject();
#endif
// === to be moved into Document
public:
bool isFrameSet() const;
// === to be moved into EventHandler
public:
void sendResizeEvent();
void sendScrollEvent();
// === to be moved into FrameView
public:
void paint(GraphicsContext*, const IntRect&);
void setPaintRestriction(PaintRestriction);
bool isPainting() const;
static double currentPaintTimeStamp() { return s_currentPaintTimeStamp; } // returns 0 if not painting
void forceLayout(bool allowSubtree = false);
void forceLayoutWithPageWidthRange(float minPageWidth, float maxPageWidth, bool adjustViewSize);
void adjustPageHeight(float* newBottom, float oldTop, float oldBottom, float bottomLimit);
void setZoomFactor(float scale, bool isTextOnly);
float zoomFactor() const;
bool isZoomFactorTextOnly() const;
bool shouldApplyTextZoom() const;
bool shouldApplyPageZoom() const;
float pageZoomFactor() const { return shouldApplyPageZoom() ? zoomFactor() : 1.0f; }
float textZoomFactor() const { return shouldApplyTextZoom() ? zoomFactor() : 1.0f; }
bool prohibitsScrolling() const;
void setProhibitsScrolling(const bool);
private:
static double s_currentPaintTimeStamp; // used for detecting decoded resource thrash in the cache
// === to be moved into Chrome
public:
void focusWindow();
void unfocusWindow();
bool shouldClose();
void scheduleClose();
void setJSStatusBarText(const String&);
void setJSDefaultStatusBarText(const String&);
String jsStatusBarText() const;
String jsDefaultStatusBarText() const;
// === to be moved into Editor
public:
String selectedText() const;
bool findString(const String&, bool forward, bool caseFlag, bool wrapFlag, bool startInSelection);
const Selection& mark() const; // Mark, to be used as emacs uses it.
void setMark(const Selection&);
void computeAndSetTypingStyle(CSSStyleDeclaration* , EditAction = EditActionUnspecified);
String selectionStartStylePropertyValue(int stylePropertyID) const;
void applyEditingStyleToBodyElement() const;
void removeEditingStyleFromBodyElement() const;
void applyEditingStyleToElement(Element*) const;
void removeEditingStyleFromElement(Element*) const;
IntRect firstRectForRange(Range*) const;
void respondToChangedSelection(const Selection& oldSelection, bool closeTyping);
bool shouldChangeSelection(const Selection& oldSelection, const Selection& newSelection, EAffinity, bool stillSelecting) const;
RenderStyle* styleForSelectionStart(Node*& nodeToRemove) const;
unsigned markAllMatchesForText(const String&, bool caseFlag, unsigned limit);
bool markedTextMatchesAreHighlighted() const;
void setMarkedTextMatchesAreHighlighted(bool flag);
CSSComputedStyleDeclaration* selectionComputedStyle(Node*& nodeToRemove) const;
void textFieldDidBeginEditing(Element*);
void textFieldDidEndEditing(Element*);
void textDidChangeInTextField(Element*);
bool doTextFieldCommandFromEvent(Element*, KeyboardEvent*);
void textWillBeDeletedInTextField(Element* input);
void textDidChangeInTextArea(Element*);
DragImageRef dragImageForSelection();
// === to be moved into SelectionController
public:
TextGranularity selectionGranularity() const;
void setSelectionGranularity(TextGranularity) const;
bool shouldChangeSelection(const Selection&) const;
bool shouldDeleteSelection(const Selection&) const;
void clearCaretRectIfNeeded();
void setFocusedNodeIfNeeded();
void selectionLayoutChanged();
void notifyRendererOfSelectionChange(bool userTriggered);
void invalidateSelection();
void setCaretVisible(bool = true);
void paintCaret(GraphicsContext*, const IntRect&) const;
void paintDragCaret(GraphicsContext*, const IntRect&) const;
bool isContentEditable() const; // if true, everything in frame is editable
void updateSecureKeyboardEntryIfActive();
CSSMutableStyleDeclaration* typingStyle() const;
void setTypingStyle(CSSMutableStyleDeclaration*);
void clearTypingStyle();
FloatRect selectionRect(bool clipToVisibleContent = true) const;
void selectionTextRects(Vector<FloatRect>&, bool clipToVisibleContent = true) const;
HTMLFormElement* currentForm() const;
void revealSelection(const RenderLayer::ScrollAlignment& = RenderLayer::gAlignCenterIfNeeded) const;
void revealCaret(const RenderLayer::ScrollAlignment& = RenderLayer::gAlignCenterIfNeeded) const;
void setSelectionFromNone();
void setUseSecureKeyboardEntry(bool);
private:
void caretBlinkTimerFired(Timer<Frame>*);
public:
SelectionController* dragCaretController() const;
String searchForLabelsAboveCell(RegularExpression*, HTMLTableCellElement*);
String searchForLabelsBeforeElement(const Vector<String>& labels, Element*);
String matchLabelsAgainstElement(const Vector<String>& labels, Element*);
VisiblePosition visiblePositionForPoint(const IntPoint& framePoint);
Document* documentAtPoint(const IntPoint& windowPoint);
#if PLATFORM(MAC)
// === undecided, would like to consider moving to another class
public:
NSString* searchForNSLabelsAboveCell(RegularExpression*, HTMLTableCellElement*);
NSString* searchForLabelsBeforeElement(NSArray* labels, Element*);
NSString* matchLabelsAgainstElement(NSArray* labels, Element*);
#if ENABLE(DASHBOARD_SUPPORT)
NSMutableDictionary* dashboardRegionsDictionary();
#endif
NSImage* selectionImage(bool forceBlackText = false) const;
NSImage* snapshotDragImage(Node*, NSRect* imageRect, NSRect* elementRect) const;
private:
NSImage* imageFromRect(NSRect) const;
// === to be moved into Editor
public:
NSDictionary* fontAttributesForSelectionStart() const;
NSWritingDirection baseWritingDirectionForSelectionStart() const;
#endif
};
} // namespace WebCore
#endif // Frame_h
|