#ifndef WebPage_p_h
#define WebPage_p_h
#include "ChromeClient.h"
#if USE(ACCELERATED_COMPOSITING)
#include "GLES2Context.h"
#include "LayerRenderer.h"
#endif
#include "KURL.h"
#include "PageClientBlackBerry.h"
#include "PlatformMouseEvent.h"
#include "ScriptSourceCode.h"
#include "Timer.h"
#include "ViewportArguments.h"
#include "WebPage.h"
#include "WebSettings.h"
#include <BlackBerryPlatformMessage.h>
namespace WebCore {
class DOMWrapperWorld;
class Document;
class Frame;
class GeolocationControllerClientBlackBerry;
class JavaScriptDebuggerBlackBerry;
class Node;
class Page;
class PluginView;
class RenderLayer;
class RenderObject;
class ScrollView;
class TransformationMatrix;
template<typename T> class Timer;
}
namespace BlackBerry {
namespace WebKit {
class BackingStore;
class BackingStoreClient;
class BackingStoreTile;
class DumpRenderTreeClient;
class InPageSearchManager;
class InputHandler;
class SelectionHandler;
class TouchEventHandler;
class WebPageClient;
#if USE(ACCELERATED_COMPOSITING)
class FrameLayers;
class WebPageCompositorPrivate;
#endif
class WebPagePrivate : public PageClientBlackBerry, public WebSettingsDelegate, public Platform::GuardedPointerBase {
public:
enum ViewMode { Mobile, Desktop, FixedDesktop };
enum LoadState { None , Provisional, Committed, Finished, Failed };
WebPagePrivate(WebPage*, WebPageClient*, const WebCore::IntRect&);
static WebCore::Page* core(const WebPage*);
WebPageClient* client() const { return m_client; }
void init(const WebString& pageGroupName);
bool handleMouseEvent(WebCore::PlatformMouseEvent&);
bool handleWheelEvent(WebCore::PlatformWheelEvent&);
void load(const char* url, const char* networkToken, const char* method, Platform::NetworkRequest::CachePolicy, const char* data, size_t dataLength, const char* const* headers, size_t headersLength, bool isInitial, bool mustHandleInternally = false, bool forceDownload = false, const char* overrideContentType = "");
void loadString(const char* string, const char* baseURL, const char* mimeType, const char* failingURL = 0);
bool executeJavaScript(const char* script, JavaScriptDataType& returnType, WebString& returnValue);
bool executeJavaScriptInIsolatedWorld(const WebCore::ScriptSourceCode&, JavaScriptDataType& returnType, WebString& returnValue);
void stopCurrentLoad();
void prepareToDestroy();
LoadState loadState() const { return m_loadState; }
bool isLoading() const { return m_loadState == WebPagePrivate::Provisional || m_loadState == WebPagePrivate::Committed; }
void setLoadState(LoadState);
double clampedScale(double scale) const;
bool shouldZoomAboutPoint(double scale, const WebCore::FloatPoint& anchor, bool enforeScaleClamping, double* clampedScale);
bool zoomAboutPoint(double scale, const WebCore::FloatPoint& anchor, bool enforceScaleClamping = true, bool forceRendering = false, bool isRestoringZoomLevel = false);
bool scheduleZoomAboutPoint(double scale, const WebCore::FloatPoint& anchor, bool enforceScaleClamping = true, bool forceRendering = false);
void unscheduleZoomAboutPoint();
WebCore::IntPoint calculateReflowedScrollPosition(const WebCore::FloatPoint& anchorOffset, double inverseScale);
void setTextReflowAnchorPoint(const Platform::IntPoint& focalPoint);
void schedulePinchZoomAboutPoint(double scale, const WebCore::IntPoint& anchor);
void zoomBlock();
void requestLayoutIfNeeded() const;
void setNeedsLayout();
WebCore::IntPoint scrollPosition() const;
WebCore::IntPoint maximumScrollPosition() const;
void setScrollPosition(const WebCore::IntPoint&);
bool scrollBy(int deltaX, int deltaY, bool scrollMainFrame = true);
void enqueueRenderingOfClippedContentOfScrollableNodeAfterInRegionScrolling(WebCore::Node*);
std::vector<Platform::ScrollViewBase> inRegionScrollableAreasForPoint(const Platform::IntPoint&);
void notifyInRegionScrollStatusChanged(bool status);
void setScrollOriginPoint(const Platform::IntPoint&);
void setHasInRegionScrollableAreas(bool);
WebCore::IntSize actualVisibleSize() const;
WebCore::IntSize viewportSize() const;
bool hasVirtualViewport() const;
bool isUserScalable() const { return m_userScalable; }
void setUserScalable(bool userScalable) { m_userScalable = userScalable; }
void setDefaultLayoutSize(const WebCore::IntSize&);
void updateViewportSize(bool setFixedReportedSize = true, bool sendResizeEvent = true);
WebCore::FloatPoint centerOfVisibleContentsRect() const;
WebCore::IntRect visibleContentsRect() const;
WebCore::IntSize contentsSize() const;
WebCore::IntSize absoluteVisibleOverflowSize() const;
virtual void setCursor(WebCore::PlatformCursor);
virtual Platform::NetworkStreamFactory* networkStreamFactory();
virtual Platform::Graphics::Window* platformWindow() const;
virtual void setPreventsScreenDimming(bool preventDimming);
virtual void showVirtualKeyboard(bool showKeyboard);
virtual void ensureContentVisible(bool centerInView = true);
virtual void zoomToContentRect(const WebCore::IntRect&);
virtual void registerPlugin(WebCore::PluginView*, bool);
virtual void notifyPageOnLoad();
virtual bool shouldPluginEnterFullScreen(WebCore::PluginView*, const char*);
virtual void didPluginEnterFullScreen(WebCore::PluginView*, const char*);
virtual void didPluginExitFullScreen(WebCore::PluginView*, const char*);
virtual void onPluginStartBackgroundPlay(WebCore::PluginView*, const char*);
virtual void onPluginStopBackgroundPlay(WebCore::PluginView*, const char*);
virtual bool lockOrientation(bool landscape);
virtual void unlockOrientation();
virtual int orientation() const;
virtual double currentZoomFactor() const;
virtual int showAlertDialog(WebPageClient::AlertType atype);
virtual bool isActive() const;
virtual bool isVisible() const { return m_visible; }
virtual WebCore::Credential authenticationChallenge(const WebCore::KURL&, const WebCore::ProtectionSpace&);
virtual SaveCredentialType notifyShouldSaveCredential(bool);
void enterFullscreenForNode(WebCore::Node*);
void exitFullscreenForNode(WebCore::Node*);
void contentsSizeChanged(const WebCore::IntSize&);
void overflowExceedsContentsSize() { m_overflowExceedsContentsSize = true; }
void layoutFinished();
void setNeedTouchEvents(bool);
void zoomToInitialScaleOnLoad();
double currentScale() const { return m_transformationMatrix->m11(); }
double zoomToFitScale() const;
double initialScale() const;
void setInitialScale(double scale) { m_initialScale = scale; }
double minimumScale() const
{
return (m_minimumScale > zoomToFitScale() && m_minimumScale <= maximumScale()) ? m_minimumScale : zoomToFitScale();
}
void setMinimumScale(double scale) { m_minimumScale = scale; }
double maximumScale() const;
void setMaximumScale(double scale) { m_maximumScale = scale; }
void resetScales();
int reflowWidth() const { return actualVisibleSize().width(); }
WebCore::IntPoint transformedScrollPosition() const;
WebCore::IntPoint transformedMaximumScrollPosition() const;
WebCore::IntSize transformedActualVisibleSize() const;
WebCore::IntSize transformedViewportSize() const;
WebCore::IntRect transformedVisibleContentsRect() const;
WebCore::IntSize transformedContentsSize() const;
WebCore::IntPoint mapFromContentsToViewport(const WebCore::IntPoint&) const;
WebCore::IntPoint mapFromViewportToContents(const WebCore::IntPoint&) const;
WebCore::IntRect mapFromContentsToViewport(const WebCore::IntRect&) const;
WebCore::IntRect mapFromViewportToContents(const WebCore::IntRect&) const;
WebCore::IntPoint mapFromTransformedContentsToTransformedViewport(const WebCore::IntPoint&) const;
WebCore::IntPoint mapFromTransformedViewportToTransformedContents(const WebCore::IntPoint&) const;
WebCore::IntRect mapFromTransformedContentsToTransformedViewport(const WebCore::IntRect&) const;
WebCore::IntRect mapFromTransformedViewportToTransformedContents(const WebCore::IntRect&) const;
WebCore::IntPoint mapToTransformed(const WebCore::IntPoint&) const;
WebCore::FloatPoint mapToTransformedFloatPoint(const WebCore::FloatPoint&) const;
WebCore::IntPoint mapFromTransformed(const WebCore::IntPoint&) const;
WebCore::FloatPoint mapFromTransformedFloatPoint(const WebCore::FloatPoint&) const;
WebCore::FloatRect mapFromTransformedFloatRect(const WebCore::FloatRect&) const;
WebCore::IntSize mapToTransformed(const WebCore::IntSize&) const;
WebCore::IntSize mapFromTransformed(const WebCore::IntSize&) const;
WebCore::IntRect mapToTransformed(const WebCore::IntRect&) const;
void clipToTransformedContentsRect(WebCore::IntRect&) const;
WebCore::IntRect mapFromTransformed(const WebCore::IntRect&) const;
bool transformedPointEqualsUntransformedPoint(const WebCore::IntPoint& transformedPoint, const WebCore::IntPoint& untransformedPoint);
void notifyTransformChanged();
void notifyTransformedContentsSizeChanged();
void notifyTransformedScrollChanged();
void assignFocus(Platform::FocusDirection);
Platform::IntRect focusNodeRect();
WebCore::IntRect getRecursiveVisibleWindowRect(WebCore::ScrollView*, bool noClipOfMainFrame = false);
WebCore::IntPoint frameOffset(const WebCore::Frame*) const;
WebCore::Node* bestNodeForZoomUnderPoint(const WebCore::IntPoint&);
WebCore::Node* bestChildNodeForClickRect(WebCore::Node* parentNode, const WebCore::IntRect& clickRect);
WebCore::Node* nodeForZoomUnderPoint(const WebCore::IntPoint&);
WebCore::Node* adjustedBlockZoomNodeForZoomLimits(WebCore::Node*);
WebCore::IntRect rectForNode(WebCore::Node*);
WebCore::IntRect blockZoomRectForNode(WebCore::Node*);
WebCore::IntRect adjustRectOffsetForFrameOffset(const WebCore::IntRect&, const WebCore::Node*);
bool compareNodesForBlockZoom(WebCore::Node* n1, WebCore::Node* n2);
double newScaleForBlockZoomRect(const WebCore::IntRect&, double oldScale, double margin);
double maxBlockZoomScale() const;
void notifyPluginRectChanged(int id, const WebCore::IntRect& rectChanged);
Platform::WebContext webContext(TargetDetectionStrategy);
PassRefPtr<WebCore::Node> contextNode(TargetDetectionStrategy);
#if ENABLE(VIEWPORT_REFLOW)
void toggleTextReflowIfEnabledForBlockZoomOnly(bool shouldEnableTextReflow = false);
#endif
void selectionChanged(WebCore::Frame*);
void updateDelegatedOverlays(bool dispatched = false);
void updateCursor();
void onInputLocaleChanged(bool isRTL);
ViewMode viewMode() const { return m_viewMode; }
bool setViewMode(ViewMode);
void setShouldUseFixedDesktopMode(bool b) { m_shouldUseFixedDesktopMode = b; }
bool useFixedLayout() const;
WebCore::IntSize fixedLayoutSize(bool snapToIncrement = false) const;
bool didLayoutExceedMaximumIterations() const { return m_nestedLayoutFinishedCount > 10; }
void clearFocusNode();
WebCore::Frame* focusedOrMainFrame() const;
WebCore::Frame* mainFrame() const { return m_mainFrame; }
bool scrollNodeRecursively(WebCore::Node* originalNode, const WebCore::IntSize& delta);
bool scrollRenderer(WebCore::RenderObject* renderer, const WebCore::IntSize& delta);
void adjustScrollDelta(const WebCore::IntPoint& maxOffset, const WebCore::IntPoint& currentOffset, WebCore::IntSize& delta) const;
bool canScrollRenderBox(WebCore::RenderBox*);
bool canScrollInnerFrame(WebCore::Frame*) const;
#if ENABLE(EVENT_MODE_METATAGS)
void didReceiveCursorEventMode(WebCore::CursorEventMode);
void didReceiveTouchEventMode(WebCore::TouchEventMode);
#endif
void dispatchViewportPropertiesDidChange(const WebCore::ViewportArguments&);
WebCore::IntSize recomputeVirtualViewportFromViewportArguments();
void resetBlockZoom();
void zoomAboutPointTimerFired(WebCore::Timer<WebPagePrivate>*);
bool shouldSendResizeEvent();
void scrollEventTimerFired(WebCore::Timer<WebPagePrivate>*);
void resizeEventTimerFired(WebCore::Timer<WebPagePrivate>*);
String findPatternStringForUrl(const WebCore::KURL&) const;
void suspendBackingStore();
void resumeBackingStore();
void setShouldResetTilesWhenShown(bool flag) { m_shouldResetTilesWhenShown = flag; }
bool shouldResetTilesWhenShown() const { return m_shouldResetTilesWhenShown; }
void setScreenOrientation(int);
void setViewportSize(const WebCore::IntSize& transformedActualVisibleSize, bool ensureFocusElementVisible);
void screenRotated();
void scheduleDeferrableTimer(WebCore::Timer<WebPagePrivate>*, double timeOut);
void unscheduleAllDeferrableTimers();
void willDeferLoading();
void didResumeLoading();
bool shouldZoomOnEscape() const;
WebCore::TransformationMatrix* transformationMatrix() const
{
return m_transformationMatrix;
}
bool compositorDrawsRootLayer() const; void setCompositorDrawsRootLayer(bool);
#if USE(ACCELERATED_COMPOSITING)
bool needsOneShotDrawingSynchronization();
void rootLayerCommitTimerFired(WebCore::Timer<WebPagePrivate>*);
bool commitRootLayerIfNeeded();
WebCore::LayerRenderingResults lastCompositingResults() const;
void setRootLayerWebKitThread(WebCore::Frame*, WebCore::LayerWebKitThread*);
void setNeedsOneShotDrawingSynchronization();
void scheduleRootLayerCommit();
void resetCompositingSurface();
void drawLayersOnCommit();
void setRootLayerCompositingThread(WebCore::LayerCompositingThread*);
void commitRootLayer(const WebCore::IntRect&, const WebCore::IntSize&, bool);
bool isAcceleratedCompositingActive() const { return m_compositor; }
WebPageCompositorPrivate* compositor() const { return m_compositor.get(); }
void setCompositor(PassRefPtr<WebPageCompositorPrivate>);
bool createCompositor();
void destroyCompositor();
void syncDestroyCompositorOnCompositingThread();
void destroyLayerResources();
void suspendRootLayerCommit();
void resumeRootLayerCommit();
void blitVisibleContents();
#endif
bool dispatchTouchEventToFullScreenPlugin(WebCore::PluginView*, const Platform::TouchEvent&);
bool dispatchTouchPointAsMouseEventToFullScreenPlugin(WebCore::PluginView*, const Platform::TouchPoint&);
bool dispatchMouseEventToFullScreenPlugin(WebCore::PluginView*, const Platform::MouseEvent&);
BackingStoreClient* backingStoreClientForFrame(const WebCore::Frame*) const;
void addBackingStoreClientForFrame(const WebCore::Frame*, BackingStoreClient*);
void removeBackingStoreClientForFrame(const WebCore::Frame*);
void clearDocumentData(const WebCore::Document*);
void frameUnloaded(const WebCore::Frame*);
static WebCore::RenderLayer* enclosingPositionedAncestorOrSelfIfPositioned(WebCore::RenderLayer*);
static WebCore::RenderLayer* enclosingFixedPositionedAncestorOrSelfIfFixedPositioned(WebCore::RenderLayer*);
static WebCore::IntSize defaultMaxLayoutSize();
static const String& defaultUserAgent();
void setVisible(bool);
#if ENABLE(PAGE_VISIBILITY_API)
void setPageVisibilityState();
#endif
void notifyAppActivationStateChange(ActivationStateType);
void deferredTasksTimerFired(WebCore::Timer<WebPagePrivate>*);
WebPage* m_webPage;
WebPageClient* m_client;
WebCore::Page* m_page;
WebCore::Frame* m_mainFrame;
RefPtr<WebCore::Node> m_currentContextNode;
WebSettings* m_webSettings;
#if ENABLE(JAVASCRIPT_DEBUGGER)
OwnPtr<WebCore::JavaScriptDebuggerBlackBerry> m_scriptDebugger;
#endif
bool m_visible;
ActivationStateType m_activationState;
bool m_shouldResetTilesWhenShown;
bool m_userScalable;
bool m_userPerformedManualZoom;
bool m_userPerformedManualScroll;
bool m_contentsSizeChanged;
bool m_overflowExceedsContentsSize;
bool m_resetVirtualViewportOnCommitted;
bool m_shouldUseFixedDesktopMode;
bool m_needTouchEvents;
int m_preventIdleDimmingCount;
#if ENABLE(TOUCH_EVENTS)
bool m_preventDefaultOnTouchStart;
#endif
unsigned m_nestedLayoutFinishedCount;
WebCore::IntSize m_previousContentsSize;
int m_actualVisibleWidth;
int m_actualVisibleHeight;
int m_virtualViewportWidth;
int m_virtualViewportHeight;
WebCore::IntSize m_defaultLayoutSize;
WebCore::ViewportArguments m_viewportArguments; WebCore::ViewportArguments m_userViewportArguments; bool m_didRestoreFromPageCache;
ViewMode m_viewMode;
LoadState m_loadState;
WebCore::TransformationMatrix* m_transformationMatrix;
BackingStore* m_backingStore;
BackingStoreClient* m_backingStoreClient;
InPageSearchManager* m_inPageSearchManager;
InputHandler* m_inputHandler;
SelectionHandler* m_selectionHandler;
TouchEventHandler* m_touchEventHandler;
#if ENABLE(EVENT_MODE_METATAGS)
WebCore::CursorEventMode m_cursorEventMode;
WebCore::TouchEventMode m_touchEventMode;
#endif
Platform::BlackBerryCursor m_currentCursor;
DumpRenderTreeClient* m_dumpRenderTree;
double m_initialScale;
double m_minimumScale;
double m_maximumScale;
WebCore::FloatPoint m_finalBlockPoint;
WebCore::FloatPoint m_finalBlockPointReflowOffset;
double m_blockZoomFinalScale;
RefPtr<WebCore::Node> m_currentPinchZoomNode;
WebCore::FloatPoint m_anchorInNodeRectRatio;
RefPtr<WebCore::Node> m_currentBlockZoomNode;
RefPtr<WebCore::Node> m_currentBlockZoomAdjustedNode;
bool m_shouldReflowBlock;
OwnPtr<WebCore::Timer<WebPagePrivate> > m_delayedZoomTimer;
struct {
double scale;
WebCore::FloatPoint anchor;
bool enforceScaleClamping;
bool forceRendering;
} m_delayedZoomArguments;
double m_lastUserEventTimestamp;
WebCore::PlatformMouseEvent m_lastMouseEvent;
bool m_pluginMouseButtonPressed; bool m_pluginMayOpenNewTab;
WebCore::GeolocationControllerClientBlackBerry* m_geolocationClient;
HashSet<WebCore::PluginView*> m_pluginViews;
RefPtr<WebCore::Node> m_inRegionScrollStartingNode;
#if USE(ACCELERATED_COMPOSITING)
bool m_isAcceleratedCompositingActive;
OwnPtr<FrameLayers> m_frameLayers;
OwnPtr<GLES2Context> m_ownedContext;
RefPtr<WebPageCompositorPrivate> m_compositor; OwnPtr<WebCore::Timer<WebPagePrivate> > m_rootLayerCommitTimer;
bool m_needsOneShotDrawingSynchronization;
bool m_needsCommit;
bool m_suspendRootLayerCommit;
#endif
int m_pendingOrientation;
RefPtr<WebCore::Node> m_fullscreenVideoNode;
RefPtr<WebCore::PluginView> m_fullScreenPluginView;
typedef HashMap<const WebCore::Frame*, BackingStoreClient*> BackingStoreClientForFrameMap;
BackingStoreClientForFrameMap m_backingStoreClientForFrameMap;
virtual void didChangeSettings(WebSettings*);
RefPtr<WebCore::DOMWrapperWorld> m_isolatedWorld;
bool m_hasInRegionScrollableAreas;
bool m_updateDelegatedOverlaysDispatched;
bool m_wouldPopupListSelectMultiple;
bool m_wouldPopupListSelectSingle;
bool m_wouldSetDateTimeInput;
bool m_wouldSetColorInput;
bool m_wouldCancelSelection;
bool m_wouldLoadManualScript;
bool m_wouldSetFocused;
bool m_wouldSetPageVisibilityState;
Vector<bool> m_cachedPopupListSelecteds;
int m_cachedPopupListSelectedIndex;
WebString m_cachedDateTimeInput;
WebString m_cachedColorInput;
WebCore::KURL m_cachedManualScript;
bool m_cachedFocused;
class DeferredTaskBase {
public:
void perform(WebPagePrivate* webPagePrivate)
{
if (!(webPagePrivate->*m_isActive))
return;
performInternal(webPagePrivate);
}
protected:
DeferredTaskBase(WebPagePrivate* webPagePrivate, bool WebPagePrivate::*isActive)
: m_isActive(isActive)
{
webPagePrivate->*m_isActive = true;
}
virtual void performInternal(WebPagePrivate*) = 0;
bool WebPagePrivate::*m_isActive;
};
Vector<OwnPtr<DeferredTaskBase> > m_deferredTasks;
WebCore::Timer<WebPagePrivate> m_deferredTasksTimer;
protected:
virtual ~WebPagePrivate();
};
}
}
#endif // WebPage_p_h