#ifndef Frame_h
#define Frame_h
#include "AnimationController.h"
#include "DragImage.h"
#include "Editor.h"
#include "EventHandler.h"
#include "FrameLoader.h"
#include "FrameTree.h"
#include "ScriptController.h"
#include "ScrollBehavior.h"
#include "SelectionController.h"
#include "UserScriptTypes.h"
#include "ZoomMode.h"
#include "FloatSize.h"
#include "KURL.h"
#include "ViewportArguments.h"
#if PLATFORM(WIN)
#include "FrameWin.h"
#endif
#if ENABLE(TILED_BACKING_STORE)
#include "TiledBackingStoreClient.h"
#endif
#ifndef __OBJC__
class NSArray;
class NSDictionary;
class NSMutableDictionary;
class NSString;
typedef int NSWritingDirection;
#endif
#ifdef __OBJC__
@class DOMNode;
#else
class DOMNode;
#endif
#if PLATFORM(WIN)
typedef struct HBITMAP__* HBITMAP;
#endif
namespace WebCore {
class CSSMutableStyleDeclaration;
class HTMLTableCellElement;
class RegularExpression;
class RenderLayer;
class RenderPart;
class TiledBackingStore;
enum {
OverflowScrollNone = 0x0,
OverflowScrollLeft = 0x1,
OverflowScrollRight = 0x2,
OverflowScrollUp = 0x4,
OverflowScrollDown = 0x8
};
enum OverflowScrollAction { DoNotPerformOverflowScroll, PerformOverflowScroll };
typedef Node* (*NodeQualifier)(HitTestResult aHitTestResult, Node* terminationNode, IntRect* frame);
class Frame : public RefCounted<Frame>
#if ENABLE(TILED_BACKING_STORE)
, public TiledBackingStoreClient
#endif
{
public:
static PassRefPtr<Frame> create(Page* page, HTMLFrameOwnerElement* ownerElement, FrameLoaderClient* client)
{
return adoptRef(new Frame(page, ownerElement, client));
}
void setView(PassRefPtr<FrameView>);
~Frame();
void init();
void initWithSimpleHTMLDocument(const String& style, bool editable, const KURL& url);
Page* page() const;
void detachFromPage();
void transferChildFrameToNewDocument();
HTMLFrameOwnerElement* ownerElement() const;
void pageDestroyed();
void disconnectOwnerElement();
Document* document() const;
FrameView* view() const;
void setDOMWindow(DOMWindow*);
void clearFormerDOMWindow(DOMWindow*);
DOMWindow* domWindow() const;
DOMWindow* existingDOMWindow() { return m_domWindow.get(); }
Editor* editor() const;
EventHandler* eventHandler() const;
FrameLoader* loader() const;
RedirectScheduler* redirectScheduler() const;
SelectionController* selection() const;
FrameTree* tree() const;
AnimationController* animation() const;
ScriptController* script();
RenderView* contentRenderer() const; RenderPart* ownerRenderer() const;
bool isDisconnected() const;
void setIsDisconnected(bool);
bool excludeFromTextSearch() const;
void setExcludeFromTextSearch(bool);
void createView(const IntSize&, const Color&, bool, const IntSize &, bool,
ScrollbarMode = ScrollbarAuto, bool horizontalLock = false,
ScrollbarMode = ScrollbarAuto, bool verticalLock = false);
float documentScale() const;
float contentsScale() const; void documentScaleChanged();
void injectUserScripts(UserScriptInjectionTime);
String layerTreeAsText() const;
private:
void injectUserScriptsForWorld(DOMWrapperWorld*, const UserScriptVector&, UserScriptInjectionTime);
private:
Frame(Page*, HTMLFrameOwnerElement*, FrameLoaderClient*);
public:
static Frame* frameForWidget(const Widget*);
Settings* settings() const;
enum AdjustViewSizeOrNot { DoNotAdjustViewSize, AdjustViewSize };
void setPrinting(bool printing, const FloatSize& pageSize, float maximumShrinkRatio, AdjustViewSizeOrNot);
bool inViewSourceMode() const;
void setInViewSourceMode(bool = true);
void keepAlive(); #ifndef NDEBUG
static void cancelAllKeepAlive();
#endif
void setDocument(PassRefPtr<Document>);
void didParse(double);
void didLayout(bool, double);
void didForcedLayout();
void getPPTStats(unsigned& parseCount, unsigned& layoutCount, unsigned& forcedLayoutCount, CFTimeInterval& parseDuration, CFTimeInterval& layoutDuration);
void clearPPTStats();
const ViewportArguments& viewportArguments() const;
void setViewportArguments(const ViewportArguments&);
NSDictionary* dictionaryForViewportArguments(const ViewportArguments& arguments) const;
void betterApproximateNode(const IntPoint& testPoint, NodeQualifier aQualifer, Node*& best, Node* failedNode, IntPoint &bestPoint, IntRect &bestRect, const IntRect& testRect);
Node* qualifyingNodeAtViewportLocation(CGPoint* aViewportLocation, NodeQualifier aQualifer, bool shouldApproximate);
Node* nodeRespondingToClickEvents(CGPoint* aViewportLocation);
Node* nodeRespondingToScrollWheelEvents(CGPoint* aViewportLocation);
int indexCountOfWordPrecedingSelection(NSString *word);
NSArray *wordsInCurrentParagraph();
CGRect renderRectForPoint(CGPoint point, bool *isReplaced, float *fontSize);
void setEmbeddedEditingMode(bool b = true);
bool embeddedEditingMode() const;
#if ENABLE(ORIENTATION_EVENTS)
void sendOrientationChangeEvent(int orientation);
int orientation() const { return m_orientation; }
#endif
void clearTimers();
static void clearTimers(FrameView*, Document*);
void setNeedsReapplyStyles();
bool needsReapplyStyles() const;
void reapplyStyles();
String documentTypeString() const;
void clearDOMWindow();
String displayStringModifiedByEncoding(const String& str) const
{
return document() ? document()->displayStringModifiedByEncoding(str) : str;
}
#if ENABLE(TILED_BACKING_STORE)
TiledBackingStore* tiledBackingStore() const { return m_tiledBackingStore.get(); }
void setTiledBackingStoreEnabled(bool);
#endif
private:
void lifeSupportTimerFired(Timer<Frame>*);
public:
void setZoomFactor(float scale, ZoomMode);
float zoomFactor() const;
ZoomMode zoomMode() const;
bool shouldApplyTextZoom() const;
bool shouldApplyPageZoom() const;
float pageZoomFactor() const { return shouldApplyPageZoom() ? zoomFactor() : 1.0f; }
float textZoomFactor() const { return shouldApplyTextZoom() ? zoomFactor() : 1.0f; }
public:
void focusWindow();
void unfocusWindow();
bool shouldClose();
void scheduleClose();
void setJSStatusBarText(const String&);
void setJSDefaultStatusBarText(const String&);
String jsStatusBarText() const;
String jsDefaultStatusBarText() const;
public:
String selectedText() const;
bool findString(const String&, bool forward, bool caseFlag, bool wrapFlag, bool startInSelection);
const VisibleSelection& mark() const; void setMark(const VisibleSelection&);
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 VisibleSelection& oldSelection, bool closeTyping);
bool shouldChangeSelection(const VisibleSelection& oldSelection, const VisibleSelection& newSelection, EAffinity, bool stillSelecting) const;
RenderStyle* styleForSelectionStart(Node*& nodeToRemove) const;
unsigned countMatchesForText(const String&, bool caseFlag, unsigned limit, bool markMatches);
bool markedTextMatchesAreHighlighted() const;
void setMarkedTextMatchesAreHighlighted(bool flag);
PassRefPtr<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();
public:
TextGranularity selectionGranularity() const;
bool shouldChangeSelection(const VisibleSelection&) const;
bool shouldDeleteSelection(const VisibleSelection&) const;
void setFocusedNodeIfNeeded();
void notifyRendererOfSelectionChange(bool userTriggered);
void setSingleLineSelectionBehavior(bool b);
bool singleLineSelectionBehavior() const;
void paintDragCaret(GraphicsContext*, int tx, int ty, const IntRect& clipRect) const;
void scrollOverflowLayer(RenderLayer *, const IntRect &visibleRect, const IntRect &exposeRect);
bool isContentEditable() const;
CSSMutableStyleDeclaration* typingStyle() const;
void setTypingStyle(CSSMutableStyleDeclaration*);
void clearTypingStyle();
FloatRect selectionBounds(bool clipToVisibleContent = true) const;
enum SelectionRectRespectTransforms { RespectTransforms = true, IgnoreTransforms = false };
void selectionTextRects(Vector<FloatRect>&, SelectionRectRespectTransforms respectTransforms, bool clipToVisibleContent = true) const;
HTMLFormElement* currentForm() const;
void revealSelection(const ScrollAlignment& = ScrollAlignment::alignCenterIfNeeded, bool revealExtent = false);
void setSelectionFromNone();
private:
void overflowAutoScrollTimerFired(Timer<Frame>*);
void startOverflowAutoScroll(const IntPoint &);
void stopOverflowAutoScroll();
int checkOverflowScroll(OverflowScrollAction);
public:
SelectionController* dragCaretController() const;
String searchForLabelsAboveCell(RegularExpression*, HTMLTableCellElement*, size_t* resultDistanceFromStartOfCell);
String searchForLabelsBeforeElement(const Vector<String>& labels, Element*, size_t* resultDistance, bool* resultIsInCellAbove);
String matchLabelsAgainstElement(const Vector<String>& labels, Element*);
VisiblePosition visiblePositionForPoint(const IntPoint& framePoint);
Document* documentAtPoint(const IntPoint& windowPoint);
private:
#if ENABLE(TILED_BACKING_STORE)
virtual void tiledBackingStorePaintBegin();
virtual void tiledBackingStorePaint(GraphicsContext*, const IntRect&);
virtual void tiledBackingStorePaintEnd(const Vector<IntRect>& paintedArea);
virtual IntRect tiledBackingStoreContentsRect();
#endif
#if PLATFORM(MAC)
public:
NSString* searchForNSLabelsAboveCell(RegularExpression*, HTMLTableCellElement*, size_t* resultDistanceFromStartOfCell);
NSString* searchForLabelsBeforeElement(NSArray* labels, Element*, size_t* resultDistance, bool* resultIsInCellAbove);
NSString* matchLabelsAgainstElement(NSArray* labels, Element*);
#if ENABLE(DASHBOARD_SUPPORT)
NSMutableDictionary* dashboardRegionsDictionary();
#endif
CGImageRef selectionImage(bool forceBlackText = false) const;
private:
CGImageRef imageFromRect(NSRect) const;
public:
NSDictionary* fontAttributesForSelectionStart() const;
NSWritingDirection baseWritingDirectionForSelectionStart() const;
#endif
public:
void setVisibleSize(const FloatSize& size);
const FloatSize& visibleSize() const;
public:
int preferredHeight() const;
int innerLineHeight(DOMNode *node) const;
void updateLayout() const;
NSRect caretRect() const;
NSRect rectForScrollToVisible() const;
NSRect rectForSelection(VisibleSelection&) const;
void createDefaultFieldEditorDocumentStructure() const;
unsigned formElementsCharacterCount() const;
void setTimersPaused(bool);
bool timersPaused() const { return m_timersPausedCount; }
void dispatchPageHideEventBeforePause();
void dispatchPageShowEventBeforeResume();
void setRangedSelectionBaseToCurrentSelection();
void setRangedSelectionBaseToCurrentSelectionStart();
void setRangedSelectionBaseToCurrentSelectionEnd();
void clearRangedSelectionInitialExtent();
void setRangedSelectionInitialExtentToCurrentSelectionStart();
void setRangedSelectionInitialExtentToCurrentSelectionEnd();
VisibleSelection rangedSelectionBase() const;
VisibleSelection rangedSelectionInitialExtent() const;
void recursiveSetUpdateAppearanceEnabled(bool);
private:
void setTimersPausedInternal(bool);
#if PLATFORM(WIN)
public:
HBITMAP nodeImage(Node*) const;
#endif
private:
Page* m_page;
mutable FrameTree m_treeNode;
mutable FrameLoader m_loader;
mutable RedirectScheduler m_redirectScheduler;
mutable RefPtr<DOMWindow> m_domWindow;
HashSet<DOMWindow*> m_liveFormerWindows;
HTMLFrameOwnerElement* m_ownerElement;
RefPtr<FrameView> m_view;
RefPtr<Document> m_doc;
ScriptController m_script;
String m_kjsStatusBarText;
String m_kjsDefaultStatusBarText;
float m_zoomFactor;
mutable SelectionController m_selectionController;
mutable VisibleSelection m_mark;
mutable Editor m_editor;
mutable EventHandler m_eventHandler;
mutable AnimationController m_animationController;
RefPtr<CSSMutableStyleDeclaration> m_typingStyle;
Timer<Frame> m_overflowAutoScrollTimer;
float m_overflowAutoScrollDelta;
IntPoint m_overflowAutoScrollPos;
ViewportArguments m_viewportArguments;
bool m_embeddedEditingMode;
VisibleSelection m_rangedSelectionBase;
VisibleSelection m_rangedSelectionInitialExtent;
FloatSize m_visibleSize;
unsigned m_parseCount;
unsigned m_layoutCount;
unsigned m_forcedLayoutCount;
CFTimeInterval m_parseDuration;
CFTimeInterval m_layoutDuration;
Timer<Frame> m_lifeSupportTimer;
#if ENABLE(ORIENTATION_EVENTS)
int m_orientation;
#endif
bool m_highlightTextMatches;
bool m_inViewSourceMode;
bool m_needsReapplyStyles;
bool m_isDisconnected;
bool m_excludeFromTextSearch;
#if ENABLE(TILED_BACKING_STORE)
OwnPtr<TiledBackingStore> m_tiledBackingStore;
#endif
bool m_singleLineSelectionBehavior;
int m_timersPausedCount;
};
}
#endif // Frame_h