dom/ipc/TabChild.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/ipc/TabChild.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,570 @@
     1.4 +/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 2; -*- */
     1.5 +/* vim: set sw=4 ts=8 et tw=80 : */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef mozilla_dom_TabChild_h
    1.11 +#define mozilla_dom_TabChild_h
    1.12 +
    1.13 +#include "mozilla/dom/PBrowserChild.h"
    1.14 +#include "nsIWebNavigation.h"
    1.15 +#include "nsCOMPtr.h"
    1.16 +#include "nsAutoPtr.h"
    1.17 +#include "nsIWebBrowserChrome2.h"
    1.18 +#include "nsIEmbeddingSiteWindow.h"
    1.19 +#include "nsIWebBrowserChromeFocus.h"
    1.20 +#include "nsIDOMEventListener.h"
    1.21 +#include "nsIInterfaceRequestor.h"
    1.22 +#include "nsIWindowProvider.h"
    1.23 +#include "nsIDOMWindow.h"
    1.24 +#include "nsIDocShell.h"
    1.25 +#include "nsIInterfaceRequestorUtils.h"
    1.26 +#include "nsFrameMessageManager.h"
    1.27 +#include "nsIWebProgressListener.h"
    1.28 +#include "nsIPresShell.h"
    1.29 +#include "nsIScriptObjectPrincipal.h"
    1.30 +#include "nsWeakReference.h"
    1.31 +#include "nsITabChild.h"
    1.32 +#include "nsITooltipListener.h"
    1.33 +#include "mozilla/Attributes.h"
    1.34 +#include "mozilla/dom/TabContext.h"
    1.35 +#include "mozilla/DOMEventTargetHelper.h"
    1.36 +#include "mozilla/EventDispatcher.h"
    1.37 +#include "mozilla/EventForwards.h"
    1.38 +#include "mozilla/layers/CompositorTypes.h"
    1.39 +
    1.40 +class nsICachedFileDescriptorListener;
    1.41 +class nsIDOMWindowUtils;
    1.42 +
    1.43 +namespace mozilla {
    1.44 +namespace layout {
    1.45 +class RenderFrameChild;
    1.46 +}
    1.47 +
    1.48 +namespace layers {
    1.49 +class ActiveElementManager;
    1.50 +}
    1.51 +
    1.52 +namespace widget {
    1.53 +struct AutoCacheNativeKeyCommands;
    1.54 +}
    1.55 +
    1.56 +namespace dom {
    1.57 +
    1.58 +class TabChild;
    1.59 +class ClonedMessageData;
    1.60 +class TabChildBase;
    1.61 +
    1.62 +class TabChildGlobal : public DOMEventTargetHelper,
    1.63 +                       public nsIContentFrameMessageManager,
    1.64 +                       public nsIScriptObjectPrincipal,
    1.65 +                       public nsIGlobalObject
    1.66 +{
    1.67 +public:
    1.68 +  TabChildGlobal(TabChildBase* aTabChild);
    1.69 +  void Init();
    1.70 +  NS_DECL_ISUPPORTS_INHERITED
    1.71 +  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TabChildGlobal, DOMEventTargetHelper)
    1.72 +  NS_FORWARD_SAFE_NSIMESSAGELISTENERMANAGER(mMessageManager)
    1.73 +  NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
    1.74 +  NS_IMETHOD SendSyncMessage(const nsAString& aMessageName,
    1.75 +                             JS::Handle<JS::Value> aObject,
    1.76 +                             JS::Handle<JS::Value> aRemote,
    1.77 +                             nsIPrincipal* aPrincipal,
    1.78 +                             JSContext* aCx,
    1.79 +                             uint8_t aArgc,
    1.80 +                             JS::MutableHandle<JS::Value> aRetval)
    1.81 +  {
    1.82 +    return mMessageManager
    1.83 +      ? mMessageManager->SendSyncMessage(aMessageName, aObject, aRemote,
    1.84 +                                         aPrincipal, aCx, aArgc, aRetval)
    1.85 +      : NS_ERROR_NULL_POINTER;
    1.86 +  }
    1.87 +  NS_IMETHOD SendRpcMessage(const nsAString& aMessageName,
    1.88 +                            JS::Handle<JS::Value> aObject,
    1.89 +                            JS::Handle<JS::Value> aRemote,
    1.90 +                            nsIPrincipal* aPrincipal,
    1.91 +                            JSContext* aCx,
    1.92 +                            uint8_t aArgc,
    1.93 +                            JS::MutableHandle<JS::Value> aRetval)
    1.94 +  {
    1.95 +    return mMessageManager
    1.96 +      ? mMessageManager->SendRpcMessage(aMessageName, aObject, aRemote,
    1.97 +                                        aPrincipal, aCx, aArgc, aRetval)
    1.98 +      : NS_ERROR_NULL_POINTER;
    1.99 +  }
   1.100 +  NS_IMETHOD GetContent(nsIDOMWindow** aContent) MOZ_OVERRIDE;
   1.101 +  NS_IMETHOD GetDocShell(nsIDocShell** aDocShell) MOZ_OVERRIDE;
   1.102 +  NS_IMETHOD Dump(const nsAString& aStr) MOZ_OVERRIDE
   1.103 +  {
   1.104 +    return mMessageManager ? mMessageManager->Dump(aStr) : NS_OK;
   1.105 +  }
   1.106 +  NS_IMETHOD PrivateNoteIntentionalCrash() MOZ_OVERRIDE;
   1.107 +  NS_IMETHOD Btoa(const nsAString& aBinaryData,
   1.108 +                  nsAString& aAsciiBase64String) MOZ_OVERRIDE;
   1.109 +  NS_IMETHOD Atob(const nsAString& aAsciiString,
   1.110 +                  nsAString& aBinaryData) MOZ_OVERRIDE;
   1.111 +
   1.112 +  NS_IMETHOD AddEventListener(const nsAString& aType,
   1.113 +                              nsIDOMEventListener* aListener,
   1.114 +                              bool aUseCapture)
   1.115 +  {
   1.116 +    // By default add listeners only for trusted events!
   1.117 +    return DOMEventTargetHelper::AddEventListener(aType, aListener,
   1.118 +                                                  aUseCapture, false, 2);
   1.119 +  }
   1.120 +  using DOMEventTargetHelper::AddEventListener;
   1.121 +  NS_IMETHOD AddEventListener(const nsAString& aType,
   1.122 +                              nsIDOMEventListener* aListener,
   1.123 +                              bool aUseCapture, bool aWantsUntrusted,
   1.124 +                              uint8_t optional_argc) MOZ_OVERRIDE
   1.125 +  {
   1.126 +    return DOMEventTargetHelper::AddEventListener(aType, aListener,
   1.127 +                                                  aUseCapture,
   1.128 +                                                  aWantsUntrusted,
   1.129 +                                                  optional_argc);
   1.130 +  }
   1.131 +
   1.132 +  nsresult
   1.133 +  PreHandleEvent(EventChainPreVisitor& aVisitor)
   1.134 +  {
   1.135 +    aVisitor.mForceContentDispatch = true;
   1.136 +    return NS_OK;
   1.137 +  }
   1.138 +
   1.139 +  virtual JSContext* GetJSContextForEventHandlers() MOZ_OVERRIDE;
   1.140 +  virtual nsIPrincipal* GetPrincipal() MOZ_OVERRIDE;
   1.141 +  virtual JSObject* GetGlobalJSObject() MOZ_OVERRIDE;
   1.142 +
   1.143 +  nsCOMPtr<nsIContentFrameMessageManager> mMessageManager;
   1.144 +  nsRefPtr<TabChildBase> mTabChild;
   1.145 +};
   1.146 +
   1.147 +class ContentListener MOZ_FINAL : public nsIDOMEventListener
   1.148 +{
   1.149 +public:
   1.150 +  ContentListener(TabChild* aTabChild) : mTabChild(aTabChild) {}
   1.151 +  NS_DECL_ISUPPORTS
   1.152 +  NS_DECL_NSIDOMEVENTLISTENER
   1.153 +protected:
   1.154 +  TabChild* mTabChild;
   1.155 +};
   1.156 +
   1.157 +// This is base clase which helps to share Viewport and touch related functionality
   1.158 +// between b2g/android FF/embedlite clients implementation.
   1.159 +// It make sense to place in this class all helper functions, and functionality which could be shared between
   1.160 +// Cross-process/Cross-thread implmentations.
   1.161 +class TabChildBase : public nsISupports,
   1.162 +                     public nsFrameScriptExecutor,
   1.163 +                     public ipc::MessageManagerCallback
   1.164 +{
   1.165 +public:
   1.166 +    TabChildBase();
   1.167 +    NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   1.168 +    NS_DECL_CYCLE_COLLECTION_CLASS(TabChildBase)
   1.169 +
   1.170 +    virtual nsIWebNavigation* WebNavigation() = 0;
   1.171 +    virtual nsIWidget* WebWidget() = 0;
   1.172 +    nsIPrincipal* GetPrincipal() { return mPrincipal; }
   1.173 +    bool IsAsyncPanZoomEnabled();
   1.174 +    // Recalculates the display state, including the CSS
   1.175 +    // viewport. This should be called whenever we believe the
   1.176 +    // viewport data on a document may have changed. If it didn't
   1.177 +    // change, this function doesn't do anything.  However, it should
   1.178 +    // not be called all the time as it is fairly expensive.
   1.179 +    bool HandlePossibleViewportChange();
   1.180 +    virtual bool DoUpdateZoomConstraints(const uint32_t& aPresShellId,
   1.181 +                                         const mozilla::layers::FrameMetrics::ViewID& aViewId,
   1.182 +                                         const bool& aIsRoot,
   1.183 +                                         const mozilla::layers::ZoomConstraints& aConstraints) = 0;
   1.184 +
   1.185 +    nsEventStatus DispatchSynthesizedMouseEvent(uint32_t aMsg, uint64_t aTime,
   1.186 +                                                const LayoutDevicePoint& aRefPoint,
   1.187 +                                                nsIWidget* aWidget);
   1.188 +
   1.189 +protected:
   1.190 +    CSSSize GetPageSize(nsCOMPtr<nsIDocument> aDocument, const CSSSize& aViewport);
   1.191 +
   1.192 +    // Get the DOMWindowUtils for the top-level window in this tab.
   1.193 +    already_AddRefed<nsIDOMWindowUtils> GetDOMWindowUtils();
   1.194 +    // Get the Document for the top-level window in this tab.
   1.195 +    already_AddRefed<nsIDocument> GetDocument();
   1.196 +
   1.197 +    // Wrapper for nsIDOMWindowUtils.setCSSViewport(). This updates some state
   1.198 +    // variables local to this class before setting it.
   1.199 +    void SetCSSViewport(const CSSSize& aSize);
   1.200 +
   1.201 +    // Wraps up a JSON object as a structured clone and sends it to the browser
   1.202 +    // chrome script.
   1.203 +    //
   1.204 +    // XXX/bug 780335: Do the work the browser chrome script does in C++ instead
   1.205 +    // so we don't need things like this.
   1.206 +    void DispatchMessageManagerMessage(const nsAString& aMessageName,
   1.207 +                                       const nsAString& aJSONData);
   1.208 +
   1.209 +    nsEventStatus DispatchWidgetEvent(WidgetGUIEvent& event);
   1.210 +
   1.211 +    bool HasValidInnerSize();
   1.212 +    void InitializeRootMetrics();
   1.213 +
   1.214 +    mozilla::layers::FrameMetrics ProcessUpdateFrame(const mozilla::layers::FrameMetrics& aFrameMetrics);
   1.215 +
   1.216 +    bool UpdateFrameHandler(const mozilla::layers::FrameMetrics& aFrameMetrics);
   1.217 +
   1.218 +protected:
   1.219 +    float mOldViewportWidth;
   1.220 +    bool mContentDocumentIsDisplayed;
   1.221 +    nsRefPtr<TabChildGlobal> mTabChildGlobal;
   1.222 +    ScreenIntSize mInnerSize;
   1.223 +    mozilla::layers::FrameMetrics mLastRootMetrics;
   1.224 +    mozilla::layout::ScrollingBehavior mScrolling;
   1.225 +};
   1.226 +
   1.227 +class TabChild : public TabChildBase,
   1.228 +                 public PBrowserChild,
   1.229 +                 public nsIWebBrowserChrome2,
   1.230 +                 public nsIEmbeddingSiteWindow,
   1.231 +                 public nsIWebBrowserChromeFocus,
   1.232 +                 public nsIInterfaceRequestor,
   1.233 +                 public nsIWindowProvider,
   1.234 +                 public nsIDOMEventListener,
   1.235 +                 public nsIWebProgressListener,
   1.236 +                 public nsSupportsWeakReference,
   1.237 +                 public nsITabChild,
   1.238 +                 public nsIObserver,
   1.239 +                 public TabContext,
   1.240 +                 public nsITooltipListener
   1.241 +{
   1.242 +    typedef mozilla::dom::ClonedMessageData ClonedMessageData;
   1.243 +    typedef mozilla::layout::RenderFrameChild RenderFrameChild;
   1.244 +    typedef mozilla::layout::ScrollingBehavior ScrollingBehavior;
   1.245 +    typedef mozilla::layers::ActiveElementManager ActiveElementManager;
   1.246 +
   1.247 +public:
   1.248 +    /** 
   1.249 +     * This is expected to be called off the critical path to content
   1.250 +     * startup.  This is an opportunity to load things that are slow
   1.251 +     * on the critical path.
   1.252 +     */
   1.253 +    static void PreloadSlowThings();
   1.254 +
   1.255 +    /** Return a TabChild with the given attributes. */
   1.256 +    static already_AddRefed<TabChild>
   1.257 +    Create(ContentChild* aManager, const TabContext& aContext, uint32_t aChromeFlags);
   1.258 +
   1.259 +    virtual ~TabChild();
   1.260 +
   1.261 +    bool IsRootContentDocument();
   1.262 +
   1.263 +    NS_DECL_ISUPPORTS_INHERITED
   1.264 +    NS_DECL_NSIWEBBROWSERCHROME
   1.265 +    NS_DECL_NSIWEBBROWSERCHROME2
   1.266 +    NS_DECL_NSIEMBEDDINGSITEWINDOW
   1.267 +    NS_DECL_NSIWEBBROWSERCHROMEFOCUS
   1.268 +    NS_DECL_NSIINTERFACEREQUESTOR
   1.269 +    NS_DECL_NSIWINDOWPROVIDER
   1.270 +    NS_DECL_NSIDOMEVENTLISTENER
   1.271 +    NS_DECL_NSIWEBPROGRESSLISTENER
   1.272 +    NS_DECL_NSITABCHILD
   1.273 +    NS_DECL_NSIOBSERVER
   1.274 +    NS_DECL_NSITOOLTIPLISTENER
   1.275 +
   1.276 +    /**
   1.277 +     * MessageManagerCallback methods that we override.
   1.278 +     */
   1.279 +    virtual bool DoSendBlockingMessage(JSContext* aCx,
   1.280 +                                       const nsAString& aMessage,
   1.281 +                                       const mozilla::dom::StructuredCloneData& aData,
   1.282 +                                       JS::Handle<JSObject *> aCpows,
   1.283 +                                       nsIPrincipal* aPrincipal,
   1.284 +                                       InfallibleTArray<nsString>* aJSONRetVal,
   1.285 +                                       bool aIsSync) MOZ_OVERRIDE;
   1.286 +    virtual bool DoSendAsyncMessage(JSContext* aCx,
   1.287 +                                    const nsAString& aMessage,
   1.288 +                                    const mozilla::dom::StructuredCloneData& aData,
   1.289 +                                    JS::Handle<JSObject *> aCpows,
   1.290 +                                    nsIPrincipal* aPrincipal) MOZ_OVERRIDE;
   1.291 +    virtual bool DoUpdateZoomConstraints(const uint32_t& aPresShellId,
   1.292 +                                         const ViewID& aViewId,
   1.293 +                                         const bool& aIsRoot,
   1.294 +                                         const ZoomConstraints& aConstraints) MOZ_OVERRIDE;
   1.295 +    virtual bool RecvLoadURL(const nsCString& uri) MOZ_OVERRIDE;
   1.296 +    virtual bool RecvCacheFileDescriptor(const nsString& aPath,
   1.297 +                                         const FileDescriptor& aFileDescriptor)
   1.298 +                                         MOZ_OVERRIDE;
   1.299 +    virtual bool RecvShow(const nsIntSize& size) MOZ_OVERRIDE;
   1.300 +    virtual bool RecvUpdateDimensions(const nsRect& rect,
   1.301 +                                      const nsIntSize& size,
   1.302 +                                      const ScreenOrientation& orientation) MOZ_OVERRIDE;
   1.303 +    virtual bool RecvUpdateFrame(const mozilla::layers::FrameMetrics& aFrameMetrics) MOZ_OVERRIDE;
   1.304 +    virtual bool RecvAcknowledgeScrollUpdate(const ViewID& aScrollId,
   1.305 +                                             const uint32_t& aScrollGeneration) MOZ_OVERRIDE;
   1.306 +    virtual bool RecvHandleDoubleTap(const CSSPoint& aPoint,
   1.307 +                                     const mozilla::layers::ScrollableLayerGuid& aGuid) MOZ_OVERRIDE;
   1.308 +    virtual bool RecvHandleSingleTap(const CSSPoint& aPoint,
   1.309 +                                     const mozilla::layers::ScrollableLayerGuid& aGuid) MOZ_OVERRIDE;
   1.310 +    virtual bool RecvHandleLongTap(const CSSPoint& aPoint,
   1.311 +                                   const mozilla::layers::ScrollableLayerGuid& aGuid) MOZ_OVERRIDE;
   1.312 +    virtual bool RecvHandleLongTapUp(const CSSPoint& aPoint,
   1.313 +                                     const mozilla::layers::ScrollableLayerGuid& aGuid) MOZ_OVERRIDE;
   1.314 +    virtual bool RecvNotifyAPZStateChange(const ViewID& aViewId,
   1.315 +                                          const APZStateChange& aChange,
   1.316 +                                          const int& aArg) MOZ_OVERRIDE;
   1.317 +    virtual bool RecvActivate() MOZ_OVERRIDE;
   1.318 +    virtual bool RecvDeactivate() MOZ_OVERRIDE;
   1.319 +    virtual bool RecvMouseEvent(const nsString& aType,
   1.320 +                                const float&    aX,
   1.321 +                                const float&    aY,
   1.322 +                                const int32_t&  aButton,
   1.323 +                                const int32_t&  aClickCount,
   1.324 +                                const int32_t&  aModifiers,
   1.325 +                                const bool&     aIgnoreRootScrollFrame) MOZ_OVERRIDE;
   1.326 +    virtual bool RecvRealMouseEvent(const mozilla::WidgetMouseEvent& event) MOZ_OVERRIDE;
   1.327 +    virtual bool RecvRealKeyEvent(const mozilla::WidgetKeyboardEvent& event,
   1.328 +                                  const MaybeNativeKeyBinding& aBindings) MOZ_OVERRIDE;
   1.329 +    virtual bool RecvMouseWheelEvent(const mozilla::WidgetWheelEvent& event) MOZ_OVERRIDE;
   1.330 +    virtual bool RecvRealTouchEvent(const WidgetTouchEvent& aEvent,
   1.331 +                                    const ScrollableLayerGuid& aGuid) MOZ_OVERRIDE;
   1.332 +    virtual bool RecvRealTouchMoveEvent(const WidgetTouchEvent& aEvent,
   1.333 +                                        const ScrollableLayerGuid& aGuid) MOZ_OVERRIDE;
   1.334 +    virtual bool RecvKeyEvent(const nsString& aType,
   1.335 +                              const int32_t&  aKeyCode,
   1.336 +                              const int32_t&  aCharCode,
   1.337 +                              const int32_t&  aModifiers,
   1.338 +                              const bool&     aPreventDefault) MOZ_OVERRIDE;
   1.339 +    virtual bool RecvCompositionEvent(const mozilla::WidgetCompositionEvent& event) MOZ_OVERRIDE;
   1.340 +    virtual bool RecvTextEvent(const mozilla::WidgetTextEvent& event) MOZ_OVERRIDE;
   1.341 +    virtual bool RecvSelectionEvent(const mozilla::WidgetSelectionEvent& event) MOZ_OVERRIDE;
   1.342 +    virtual bool RecvActivateFrameEvent(const nsString& aType, const bool& capture) MOZ_OVERRIDE;
   1.343 +    virtual bool RecvLoadRemoteScript(const nsString& aURL,
   1.344 +                                      const bool& aRunInGlobalScope) MOZ_OVERRIDE;
   1.345 +    virtual bool RecvAsyncMessage(const nsString& aMessage,
   1.346 +                                  const ClonedMessageData& aData,
   1.347 +                                  const InfallibleTArray<CpowEntry>& aCpows,
   1.348 +                                  const IPC::Principal& aPrincipal) MOZ_OVERRIDE;
   1.349 +
   1.350 +    virtual PDocumentRendererChild*
   1.351 +    AllocPDocumentRendererChild(const nsRect& documentRect, const gfx::Matrix& transform,
   1.352 +                                const nsString& bgcolor,
   1.353 +                                const uint32_t& renderFlags, const bool& flushLayout,
   1.354 +                                const nsIntSize& renderSize) MOZ_OVERRIDE;
   1.355 +    virtual bool DeallocPDocumentRendererChild(PDocumentRendererChild* actor) MOZ_OVERRIDE;
   1.356 +    virtual bool RecvPDocumentRendererConstructor(PDocumentRendererChild* actor,
   1.357 +                                                  const nsRect& documentRect,
   1.358 +                                                  const gfx::Matrix& transform,
   1.359 +                                                  const nsString& bgcolor,
   1.360 +                                                  const uint32_t& renderFlags,
   1.361 +                                                  const bool& flushLayout,
   1.362 +                                                  const nsIntSize& renderSize) MOZ_OVERRIDE;
   1.363 +
   1.364 +    virtual PColorPickerChild*
   1.365 +    AllocPColorPickerChild(const nsString& title, const nsString& initialColor) MOZ_OVERRIDE;
   1.366 +    virtual bool DeallocPColorPickerChild(PColorPickerChild* actor) MOZ_OVERRIDE;
   1.367 +
   1.368 +#ifdef DEBUG
   1.369 +    virtual PContentPermissionRequestChild*
   1.370 +    SendPContentPermissionRequestConstructor(PContentPermissionRequestChild* aActor,
   1.371 +                                             const InfallibleTArray<PermissionRequest>& aRequests,
   1.372 +                                             const IPC::Principal& aPrincipal);
   1.373 +#endif /* DEBUG */
   1.374 +
   1.375 +    virtual PContentPermissionRequestChild*
   1.376 +    AllocPContentPermissionRequestChild(const InfallibleTArray<PermissionRequest>& aRequests,
   1.377 +                                        const IPC::Principal& aPrincipal) MOZ_OVERRIDE;
   1.378 +    virtual bool
   1.379 +    DeallocPContentPermissionRequestChild(PContentPermissionRequestChild* actor) MOZ_OVERRIDE;
   1.380 +
   1.381 +    virtual PFilePickerChild*
   1.382 +    AllocPFilePickerChild(const nsString& aTitle, const int16_t& aMode) MOZ_OVERRIDE;
   1.383 +    virtual bool
   1.384 +    DeallocPFilePickerChild(PFilePickerChild* actor) MOZ_OVERRIDE;
   1.385 +
   1.386 +    virtual POfflineCacheUpdateChild* AllocPOfflineCacheUpdateChild(
   1.387 +            const URIParams& manifestURI,
   1.388 +            const URIParams& documentURI,
   1.389 +            const bool& stickDocument) MOZ_OVERRIDE;
   1.390 +    virtual bool
   1.391 +    DeallocPOfflineCacheUpdateChild(POfflineCacheUpdateChild* offlineCacheUpdate) MOZ_OVERRIDE;
   1.392 +
   1.393 +    virtual nsIWebNavigation* WebNavigation() MOZ_OVERRIDE { return mWebNav; }
   1.394 +    virtual nsIWidget* WebWidget() MOZ_OVERRIDE { return mWidget; }
   1.395 +
   1.396 +    /** Return the DPI of the widget this TabChild draws to. */
   1.397 +    void GetDPI(float* aDPI);
   1.398 +    void GetDefaultScale(double *aScale);
   1.399 +
   1.400 +    ScreenOrientation GetOrientation() { return mOrientation; }
   1.401 +
   1.402 +    void SetBackgroundColor(const nscolor& aColor);
   1.403 +
   1.404 +    void NotifyPainted();
   1.405 +
   1.406 +    void RequestNativeKeyBindings(mozilla::widget::AutoCacheNativeKeyCommands* aAutoCache,
   1.407 +                                  WidgetKeyboardEvent* aEvent);
   1.408 +
   1.409 +    /** Return a boolean indicating if the page has called preventDefault on
   1.410 +     *  the event.
   1.411 +     */
   1.412 +    bool DispatchMouseEvent(const nsString&       aType,
   1.413 +                            const CSSPoint&       aPoint,
   1.414 +                            const int32_t&        aButton,
   1.415 +                            const int32_t&        aClickCount,
   1.416 +                            const int32_t&        aModifiers,
   1.417 +                            const bool&           aIgnoreRootScrollFrame,
   1.418 +                            const unsigned short& aInputSourceArg);
   1.419 +
   1.420 +    /**
   1.421 +     * Signal to this TabChild that it should be made visible:
   1.422 +     * activated widget, retained layer tree, etc.  (Respectively,
   1.423 +     * made not visible.)
   1.424 +     */
   1.425 +    void MakeVisible();
   1.426 +    void MakeHidden();
   1.427 +
   1.428 +    // Returns true if the file descriptor was found in the cache, false
   1.429 +    // otherwise.
   1.430 +    bool GetCachedFileDescriptor(const nsAString& aPath,
   1.431 +                                 nsICachedFileDescriptorListener* aCallback);
   1.432 +
   1.433 +    void CancelCachedFileDescriptorCallback(
   1.434 +                                    const nsAString& aPath,
   1.435 +                                    nsICachedFileDescriptorListener* aCallback);
   1.436 +
   1.437 +    ContentChild* Manager() { return mManager; }
   1.438 +
   1.439 +    bool GetUpdateHitRegion() { return mUpdateHitRegion; }
   1.440 +
   1.441 +    void UpdateHitRegion(const nsRegion& aRegion);
   1.442 +
   1.443 +    static inline TabChild*
   1.444 +    GetFrom(nsIDocShell* aDocShell)
   1.445 +    {
   1.446 +      nsCOMPtr<nsITabChild> tc = do_GetInterface(aDocShell);
   1.447 +      return static_cast<TabChild*>(tc.get());
   1.448 +    }
   1.449 +
   1.450 +    static TabChild* GetFrom(nsIPresShell* aPresShell);
   1.451 +    static TabChild* GetFrom(uint64_t aLayersId);
   1.452 +
   1.453 +    void DidComposite();
   1.454 +
   1.455 +    static inline TabChild*
   1.456 +    GetFrom(nsIDOMWindow* aWindow)
   1.457 +    {
   1.458 +      nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow);
   1.459 +      nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(webNav);
   1.460 +      return GetFrom(docShell);
   1.461 +    }
   1.462 +
   1.463 +protected:
   1.464 +    virtual PRenderFrameChild* AllocPRenderFrameChild() MOZ_OVERRIDE;
   1.465 +    virtual bool DeallocPRenderFrameChild(PRenderFrameChild* aFrame) MOZ_OVERRIDE;
   1.466 +    virtual bool RecvDestroy() MOZ_OVERRIDE;
   1.467 +    virtual bool RecvSetUpdateHitRegion(const bool& aEnabled) MOZ_OVERRIDE;
   1.468 +    virtual bool RecvSetIsDocShellActive(const bool& aIsActive) MOZ_OVERRIDE;
   1.469 +
   1.470 +    virtual PIndexedDBChild* AllocPIndexedDBChild(const nsCString& aGroup,
   1.471 +                                                  const nsCString& aASCIIOrigin,
   1.472 +                                                  bool* /* aAllowed */) MOZ_OVERRIDE;
   1.473 +
   1.474 +    virtual bool DeallocPIndexedDBChild(PIndexedDBChild* aActor) MOZ_OVERRIDE;
   1.475 +
   1.476 +private:
   1.477 +    /**
   1.478 +     * Create a new TabChild object.
   1.479 +     *
   1.480 +     * |aOwnOrContainingAppId| is the app-id of our frame or of the closest app
   1.481 +     * frame in the hierarchy which contains us.
   1.482 +     *
   1.483 +     * |aIsBrowserElement| indicates whether we're a browser (but not an app).
   1.484 +     */
   1.485 +    TabChild(ContentChild* aManager, const TabContext& aContext, uint32_t aChromeFlags);
   1.486 +
   1.487 +    nsresult Init();
   1.488 +
   1.489 +
   1.490 +    // Notify others that our TabContext has been updated.  (At the moment, this
   1.491 +    // sets the appropriate app-id and is-browser flags on our docshell.)
   1.492 +    //
   1.493 +    // You should call this after calling TabContext::SetTabContext().  We also
   1.494 +    // call this during Init().
   1.495 +    void NotifyTabContextUpdated();
   1.496 +
   1.497 +    bool UseDirectCompositor();
   1.498 +
   1.499 +    void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
   1.500 +
   1.501 +    enum FrameScriptLoading { DONT_LOAD_SCRIPTS, DEFAULT_LOAD_SCRIPTS };
   1.502 +    bool InitTabChildGlobal(FrameScriptLoading aScriptLoading = DEFAULT_LOAD_SCRIPTS);
   1.503 +    bool InitRenderingState();
   1.504 +    void DestroyWindow();
   1.505 +    void SetProcessNameToAppName();
   1.506 +
   1.507 +    // Call RecvShow(nsIntSize(0, 0)) and block future calls to RecvShow().
   1.508 +    void DoFakeShow();
   1.509 +
   1.510 +    // These methods are used for tracking synthetic mouse events
   1.511 +    // dispatched for compatibility.  On each touch event, we
   1.512 +    // UpdateTapState().  If we've detected that the current gesture
   1.513 +    // isn't a tap, then we CancelTapTracking().  In the meantime, we
   1.514 +    // may detect a context-menu event, and if so we
   1.515 +    // FireContextMenuEvent().
   1.516 +    void FireContextMenuEvent();
   1.517 +    void CancelTapTracking();
   1.518 +    void UpdateTapState(const WidgetTouchEvent& aEvent, nsEventStatus aStatus);
   1.519 +
   1.520 +    nsresult
   1.521 +    BrowserFrameProvideWindow(nsIDOMWindow* aOpener,
   1.522 +                              nsIURI* aURI,
   1.523 +                              const nsAString& aName,
   1.524 +                              const nsACString& aFeatures,
   1.525 +                              bool* aWindowIsNew,
   1.526 +                              nsIDOMWindow** aReturn);
   1.527 +
   1.528 +    class CachedFileDescriptorInfo;
   1.529 +    class CachedFileDescriptorCallbackRunnable;
   1.530 +
   1.531 +    TextureFactoryIdentifier mTextureFactoryIdentifier;
   1.532 +    nsCOMPtr<nsIWebNavigation> mWebNav;
   1.533 +    nsCOMPtr<nsIWidget> mWidget;
   1.534 +    nsCOMPtr<nsIURI> mLastURI;
   1.535 +    RenderFrameChild* mRemoteFrame;
   1.536 +    nsRefPtr<ContentChild> mManager;
   1.537 +    uint32_t mChromeFlags;
   1.538 +    uint64_t mLayersId;
   1.539 +    nsIntRect mOuterRect;
   1.540 +    // When we're tracking a possible tap gesture, this is the "down"
   1.541 +    // point of the touchstart.
   1.542 +    LayoutDevicePoint mGestureDownPoint;
   1.543 +    // The touch identifier of the active gesture.
   1.544 +    int32_t mActivePointerId;
   1.545 +    // A timer task that fires if the tap-hold timeout is exceeded by
   1.546 +    // the touch we're tracking.  That is, if touchend or a touchmove
   1.547 +    // that exceeds the gesture threshold doesn't happen.
   1.548 +    CancelableTask* mTapHoldTimer;
   1.549 +    // Whether we have already received a FileDescriptor for the app package.
   1.550 +    bool mAppPackageFileDescriptorRecved;
   1.551 +    // At present only 1 of these is really expected.
   1.552 +    nsAutoTArray<nsAutoPtr<CachedFileDescriptorInfo>, 1>
   1.553 +        mCachedFileDescriptorInfos;
   1.554 +    nscolor mLastBackgroundColor;
   1.555 +    bool mDidFakeShow;
   1.556 +    bool mNotified;
   1.557 +    bool mTriedBrowserInit;
   1.558 +    ScreenOrientation mOrientation;
   1.559 +    bool mUpdateHitRegion;
   1.560 +    bool mContextMenuHandled;
   1.561 +    bool mWaitingTouchListeners;
   1.562 +    void FireSingleTapEvent(LayoutDevicePoint aPoint);
   1.563 +
   1.564 +    bool mIgnoreKeyPressEvent;
   1.565 +    nsRefPtr<ActiveElementManager> mActiveElementManager;
   1.566 +
   1.567 +    DISALLOW_EVIL_CONSTRUCTORS(TabChild);
   1.568 +};
   1.569 +
   1.570 +}
   1.571 +}
   1.572 +
   1.573 +#endif // mozilla_dom_TabChild_h

mercurial