#ifndef Page_h
#define Page_h
#include "core/dom/ViewportDescription.h"
#include "core/frame/SettingsDelegate.h"
#include "core/frame/UseCounter.h"
#include "core/page/HistoryController.h"
#include "core/page/PageAnimator.h"
#include "core/page/PageVisibilityState.h"
#include "platform/LifecycleContext.h"
#include "platform/Supplementable.h"
#include "platform/geometry/LayoutRect.h"
#include "platform/geometry/Region.h"
#include "wtf/Forward.h"
#include "wtf/HashSet.h"
#include "wtf/Noncopyable.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
class AutoscrollController;
class BackForwardClient;
class Chrome;
class ChromeClient;
class ClientRectList;
class ContextMenuClient;
class ContextMenuController;
class Document;
class DragCaretController;
class DragClient;
class DragController;
class EditorClient;
class FocusController;
class LocalFrame;
class FrameHost;
class FrameSelection;
class HaltablePlugin;
class HistoryItem;
class InspectorClient;
class InspectorController;
class Node;
class PageLifecycleNotifier;
class PlatformMouseEvent;
class PluginData;
class PointerLockController;
class Range;
class RenderBox;
class RenderObject;
class RenderTheme;
class StorageClient;
class VisibleSelection;
class ScrollableArea;
class ScrollingCoordinator;
class Settings;
class SpellCheckerClient;
class StorageNamespace;
class UndoStack;
class ValidationMessageClient;
typedef uint64_t LinkHash;
float deviceScaleFactor(LocalFrame*);
class Page FINAL : public Supplementable<Page>, public LifecycleContext<Page>, public SettingsDelegate {
WTF_MAKE_NONCOPYABLE(Page);
friend class Settings;
public:
static void scheduleForcedStyleRecalcForAllPages();
struct PageClients {
WTF_MAKE_NONCOPYABLE(PageClients); WTF_MAKE_FAST_ALLOCATED;
public:
PageClients();
~PageClients();
ChromeClient* chromeClient;
ContextMenuClient* contextMenuClient;
EditorClient* editorClient;
DragClient* dragClient;
InspectorClient* inspectorClient;
BackForwardClient* backForwardClient;
SpellCheckerClient* spellCheckerClient;
StorageClient* storageClient;
};
explicit Page(PageClients&);
virtual ~Page();
void makeOrdinary();
static HashSet<Page*>& allPages();
static HashSet<Page*>& ordinaryPages();
FrameHost& frameHost() { return *m_frameHost; }
void setNeedsRecalcStyleInAllFrames();
ViewportDescription viewportDescription() const;
static void refreshPlugins(bool reload);
PluginData* pluginData() const;
EditorClient& editorClient() const { return *m_editorClient; }
SpellCheckerClient& spellCheckerClient() const { return *m_spellCheckerClient; }
UndoStack& undoStack() const { return *m_undoStack; }
HistoryController& historyController() const { return *m_historyController; }
void setMainFrame(PassRefPtr<LocalFrame>);
LocalFrame* mainFrame() const { return m_mainFrame.get(); }
void documentDetached(Document*);
bool openedByDOM() const;
void setOpenedByDOM();
void incrementSubframeCount() { ++m_subframeCount; }
void decrementSubframeCount() { ASSERT(m_subframeCount); --m_subframeCount; }
int subframeCount() const { checkSubframeCountConsistency(); return m_subframeCount; }
PageAnimator& animator() { return m_animator; }
Chrome& chrome() const { return *m_chrome; }
AutoscrollController& autoscrollController() const { return *m_autoscrollController; }
DragCaretController& dragCaretController() const { return *m_dragCaretController; }
DragController& dragController() const { return *m_dragController; }
FocusController& focusController() const { return *m_focusController; }
ContextMenuController& contextMenuController() const { return *m_contextMenuController; }
InspectorController& inspectorController() const { return *m_inspectorController; }
PointerLockController& pointerLockController() const { return *m_pointerLockController; }
ValidationMessageClient* validationMessageClient() const { return m_validationMessageClient; }
void setValidationMessageClient(ValidationMessageClient* client) { m_validationMessageClient = client; }
ScrollingCoordinator* scrollingCoordinator();
String mainThreadScrollingReasonsAsText();
PassRefPtr<ClientRectList> nonFastScrollableRects(const LocalFrame*);
Settings& settings() const { return *m_settings; }
BackForwardClient& backForward() const { return *m_backForwardClient; }
UseCounter& useCounter() { return m_useCounter; }
void setTabKeyCyclesThroughElements(bool b) { m_tabKeyCyclesThroughElements = b; }
bool tabKeyCyclesThroughElements() const { return m_tabKeyCyclesThroughElements; }
void unmarkAllTextMatches();
void setDefersLoading(bool);
bool defersLoading() const { return m_defersLoading; }
void setPageScaleFactor(float scale, const IntPoint& origin);
float pageScaleFactor() const { return m_pageScaleFactor; }
float deviceScaleFactor() const { return m_deviceScaleFactor; }
void setDeviceScaleFactor(float);
static void allVisitedStateChanged();
static void visitedStateChanged(LinkHash visitedHash);
StorageNamespace* sessionStorage(bool optionalCreate = true);
StorageClient& storageClient() const { return *m_storageClient; }
static const int maxNumberOfFrames = 1000;
PageVisibilityState visibilityState() const;
void setVisibilityState(PageVisibilityState, bool);
bool isCursorVisible() const { return m_isCursorVisible; }
void setIsCursorVisible(bool isVisible) { m_isCursorVisible = isVisible; }
#ifndef NDEBUG
void setIsPainting(bool painting) { m_isPainting = painting; }
bool isPainting() const { return m_isPainting; }
#endif
double timerAlignmentInterval() const;
class MultisamplingChangedObserver {
public:
virtual void multisamplingChanged(bool) = 0;
};
void addMultisamplingChangedObserver(MultisamplingChangedObserver*);
void removeMultisamplingChangedObserver(MultisamplingChangedObserver*);
void didCommitLoad(LocalFrame*);
static void networkStateChanged(bool online);
PassOwnPtr<LifecycleNotifier<Page> > createLifecycleNotifier();
protected:
PageLifecycleNotifier& lifecycleNotifier();
private:
void initGroup();
#if ASSERT_DISABLED
void checkSubframeCountConsistency() const { }
#else
void checkSubframeCountConsistency() const;
#endif
void setTimerAlignmentInterval(double);
void setNeedsLayoutInAllFrames();
virtual void settingsChanged(SettingsDelegate::ChangeType) OVERRIDE;
PageAnimator m_animator;
const OwnPtr<AutoscrollController> m_autoscrollController;
const OwnPtr<Chrome> m_chrome;
const OwnPtr<DragCaretController> m_dragCaretController;
const OwnPtr<DragController> m_dragController;
const OwnPtr<FocusController> m_focusController;
const OwnPtr<ContextMenuController> m_contextMenuController;
const OwnPtr<InspectorController> m_inspectorController;
const OwnPtr<PointerLockController> m_pointerLockController;
OwnPtr<ScrollingCoordinator> m_scrollingCoordinator;
const OwnPtr<HistoryController> m_historyController;
const OwnPtr<UndoStack> m_undoStack;
RefPtr<LocalFrame> m_mainFrame;
mutable RefPtr<PluginData> m_pluginData;
BackForwardClient* m_backForwardClient;
EditorClient* const m_editorClient;
ValidationMessageClient* m_validationMessageClient;
SpellCheckerClient* const m_spellCheckerClient;
StorageClient* m_storageClient;
UseCounter m_useCounter;
int m_subframeCount;
bool m_openedByDOM;
bool m_tabKeyCyclesThroughElements;
bool m_defersLoading;
float m_pageScaleFactor;
float m_deviceScaleFactor;
OwnPtr<StorageNamespace> m_sessionStorage;
double m_timerAlignmentInterval;
PageVisibilityState m_visibilityState;
bool m_isCursorVisible;
#ifndef NDEBUG
bool m_isPainting;
#endif
HashSet<MultisamplingChangedObserver*> m_multisamplingChangedObservers;
OwnPtr<FrameHost> m_frameHost;
};
}
#endif