Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 2; -*- */ |
michael@0 | 2 | /* vim: set sw=4 ts=8 et tw=80 : */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef mozilla_dom_TabChild_h |
michael@0 | 8 | #define mozilla_dom_TabChild_h |
michael@0 | 9 | |
michael@0 | 10 | #include "mozilla/dom/PBrowserChild.h" |
michael@0 | 11 | #include "nsIWebNavigation.h" |
michael@0 | 12 | #include "nsCOMPtr.h" |
michael@0 | 13 | #include "nsAutoPtr.h" |
michael@0 | 14 | #include "nsIWebBrowserChrome2.h" |
michael@0 | 15 | #include "nsIEmbeddingSiteWindow.h" |
michael@0 | 16 | #include "nsIWebBrowserChromeFocus.h" |
michael@0 | 17 | #include "nsIDOMEventListener.h" |
michael@0 | 18 | #include "nsIInterfaceRequestor.h" |
michael@0 | 19 | #include "nsIWindowProvider.h" |
michael@0 | 20 | #include "nsIDOMWindow.h" |
michael@0 | 21 | #include "nsIDocShell.h" |
michael@0 | 22 | #include "nsIInterfaceRequestorUtils.h" |
michael@0 | 23 | #include "nsFrameMessageManager.h" |
michael@0 | 24 | #include "nsIWebProgressListener.h" |
michael@0 | 25 | #include "nsIPresShell.h" |
michael@0 | 26 | #include "nsIScriptObjectPrincipal.h" |
michael@0 | 27 | #include "nsWeakReference.h" |
michael@0 | 28 | #include "nsITabChild.h" |
michael@0 | 29 | #include "nsITooltipListener.h" |
michael@0 | 30 | #include "mozilla/Attributes.h" |
michael@0 | 31 | #include "mozilla/dom/TabContext.h" |
michael@0 | 32 | #include "mozilla/DOMEventTargetHelper.h" |
michael@0 | 33 | #include "mozilla/EventDispatcher.h" |
michael@0 | 34 | #include "mozilla/EventForwards.h" |
michael@0 | 35 | #include "mozilla/layers/CompositorTypes.h" |
michael@0 | 36 | |
michael@0 | 37 | class nsICachedFileDescriptorListener; |
michael@0 | 38 | class nsIDOMWindowUtils; |
michael@0 | 39 | |
michael@0 | 40 | namespace mozilla { |
michael@0 | 41 | namespace layout { |
michael@0 | 42 | class RenderFrameChild; |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | namespace layers { |
michael@0 | 46 | class ActiveElementManager; |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | namespace widget { |
michael@0 | 50 | struct AutoCacheNativeKeyCommands; |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | namespace dom { |
michael@0 | 54 | |
michael@0 | 55 | class TabChild; |
michael@0 | 56 | class ClonedMessageData; |
michael@0 | 57 | class TabChildBase; |
michael@0 | 58 | |
michael@0 | 59 | class TabChildGlobal : public DOMEventTargetHelper, |
michael@0 | 60 | public nsIContentFrameMessageManager, |
michael@0 | 61 | public nsIScriptObjectPrincipal, |
michael@0 | 62 | public nsIGlobalObject |
michael@0 | 63 | { |
michael@0 | 64 | public: |
michael@0 | 65 | TabChildGlobal(TabChildBase* aTabChild); |
michael@0 | 66 | void Init(); |
michael@0 | 67 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 68 | NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TabChildGlobal, DOMEventTargetHelper) |
michael@0 | 69 | NS_FORWARD_SAFE_NSIMESSAGELISTENERMANAGER(mMessageManager) |
michael@0 | 70 | NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager) |
michael@0 | 71 | NS_IMETHOD SendSyncMessage(const nsAString& aMessageName, |
michael@0 | 72 | JS::Handle<JS::Value> aObject, |
michael@0 | 73 | JS::Handle<JS::Value> aRemote, |
michael@0 | 74 | nsIPrincipal* aPrincipal, |
michael@0 | 75 | JSContext* aCx, |
michael@0 | 76 | uint8_t aArgc, |
michael@0 | 77 | JS::MutableHandle<JS::Value> aRetval) |
michael@0 | 78 | { |
michael@0 | 79 | return mMessageManager |
michael@0 | 80 | ? mMessageManager->SendSyncMessage(aMessageName, aObject, aRemote, |
michael@0 | 81 | aPrincipal, aCx, aArgc, aRetval) |
michael@0 | 82 | : NS_ERROR_NULL_POINTER; |
michael@0 | 83 | } |
michael@0 | 84 | NS_IMETHOD SendRpcMessage(const nsAString& aMessageName, |
michael@0 | 85 | JS::Handle<JS::Value> aObject, |
michael@0 | 86 | JS::Handle<JS::Value> aRemote, |
michael@0 | 87 | nsIPrincipal* aPrincipal, |
michael@0 | 88 | JSContext* aCx, |
michael@0 | 89 | uint8_t aArgc, |
michael@0 | 90 | JS::MutableHandle<JS::Value> aRetval) |
michael@0 | 91 | { |
michael@0 | 92 | return mMessageManager |
michael@0 | 93 | ? mMessageManager->SendRpcMessage(aMessageName, aObject, aRemote, |
michael@0 | 94 | aPrincipal, aCx, aArgc, aRetval) |
michael@0 | 95 | : NS_ERROR_NULL_POINTER; |
michael@0 | 96 | } |
michael@0 | 97 | NS_IMETHOD GetContent(nsIDOMWindow** aContent) MOZ_OVERRIDE; |
michael@0 | 98 | NS_IMETHOD GetDocShell(nsIDocShell** aDocShell) MOZ_OVERRIDE; |
michael@0 | 99 | NS_IMETHOD Dump(const nsAString& aStr) MOZ_OVERRIDE |
michael@0 | 100 | { |
michael@0 | 101 | return mMessageManager ? mMessageManager->Dump(aStr) : NS_OK; |
michael@0 | 102 | } |
michael@0 | 103 | NS_IMETHOD PrivateNoteIntentionalCrash() MOZ_OVERRIDE; |
michael@0 | 104 | NS_IMETHOD Btoa(const nsAString& aBinaryData, |
michael@0 | 105 | nsAString& aAsciiBase64String) MOZ_OVERRIDE; |
michael@0 | 106 | NS_IMETHOD Atob(const nsAString& aAsciiString, |
michael@0 | 107 | nsAString& aBinaryData) MOZ_OVERRIDE; |
michael@0 | 108 | |
michael@0 | 109 | NS_IMETHOD AddEventListener(const nsAString& aType, |
michael@0 | 110 | nsIDOMEventListener* aListener, |
michael@0 | 111 | bool aUseCapture) |
michael@0 | 112 | { |
michael@0 | 113 | // By default add listeners only for trusted events! |
michael@0 | 114 | return DOMEventTargetHelper::AddEventListener(aType, aListener, |
michael@0 | 115 | aUseCapture, false, 2); |
michael@0 | 116 | } |
michael@0 | 117 | using DOMEventTargetHelper::AddEventListener; |
michael@0 | 118 | NS_IMETHOD AddEventListener(const nsAString& aType, |
michael@0 | 119 | nsIDOMEventListener* aListener, |
michael@0 | 120 | bool aUseCapture, bool aWantsUntrusted, |
michael@0 | 121 | uint8_t optional_argc) MOZ_OVERRIDE |
michael@0 | 122 | { |
michael@0 | 123 | return DOMEventTargetHelper::AddEventListener(aType, aListener, |
michael@0 | 124 | aUseCapture, |
michael@0 | 125 | aWantsUntrusted, |
michael@0 | 126 | optional_argc); |
michael@0 | 127 | } |
michael@0 | 128 | |
michael@0 | 129 | nsresult |
michael@0 | 130 | PreHandleEvent(EventChainPreVisitor& aVisitor) |
michael@0 | 131 | { |
michael@0 | 132 | aVisitor.mForceContentDispatch = true; |
michael@0 | 133 | return NS_OK; |
michael@0 | 134 | } |
michael@0 | 135 | |
michael@0 | 136 | virtual JSContext* GetJSContextForEventHandlers() MOZ_OVERRIDE; |
michael@0 | 137 | virtual nsIPrincipal* GetPrincipal() MOZ_OVERRIDE; |
michael@0 | 138 | virtual JSObject* GetGlobalJSObject() MOZ_OVERRIDE; |
michael@0 | 139 | |
michael@0 | 140 | nsCOMPtr<nsIContentFrameMessageManager> mMessageManager; |
michael@0 | 141 | nsRefPtr<TabChildBase> mTabChild; |
michael@0 | 142 | }; |
michael@0 | 143 | |
michael@0 | 144 | class ContentListener MOZ_FINAL : public nsIDOMEventListener |
michael@0 | 145 | { |
michael@0 | 146 | public: |
michael@0 | 147 | ContentListener(TabChild* aTabChild) : mTabChild(aTabChild) {} |
michael@0 | 148 | NS_DECL_ISUPPORTS |
michael@0 | 149 | NS_DECL_NSIDOMEVENTLISTENER |
michael@0 | 150 | protected: |
michael@0 | 151 | TabChild* mTabChild; |
michael@0 | 152 | }; |
michael@0 | 153 | |
michael@0 | 154 | // This is base clase which helps to share Viewport and touch related functionality |
michael@0 | 155 | // between b2g/android FF/embedlite clients implementation. |
michael@0 | 156 | // It make sense to place in this class all helper functions, and functionality which could be shared between |
michael@0 | 157 | // Cross-process/Cross-thread implmentations. |
michael@0 | 158 | class TabChildBase : public nsISupports, |
michael@0 | 159 | public nsFrameScriptExecutor, |
michael@0 | 160 | public ipc::MessageManagerCallback |
michael@0 | 161 | { |
michael@0 | 162 | public: |
michael@0 | 163 | TabChildBase(); |
michael@0 | 164 | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
michael@0 | 165 | NS_DECL_CYCLE_COLLECTION_CLASS(TabChildBase) |
michael@0 | 166 | |
michael@0 | 167 | virtual nsIWebNavigation* WebNavigation() = 0; |
michael@0 | 168 | virtual nsIWidget* WebWidget() = 0; |
michael@0 | 169 | nsIPrincipal* GetPrincipal() { return mPrincipal; } |
michael@0 | 170 | bool IsAsyncPanZoomEnabled(); |
michael@0 | 171 | // Recalculates the display state, including the CSS |
michael@0 | 172 | // viewport. This should be called whenever we believe the |
michael@0 | 173 | // viewport data on a document may have changed. If it didn't |
michael@0 | 174 | // change, this function doesn't do anything. However, it should |
michael@0 | 175 | // not be called all the time as it is fairly expensive. |
michael@0 | 176 | bool HandlePossibleViewportChange(); |
michael@0 | 177 | virtual bool DoUpdateZoomConstraints(const uint32_t& aPresShellId, |
michael@0 | 178 | const mozilla::layers::FrameMetrics::ViewID& aViewId, |
michael@0 | 179 | const bool& aIsRoot, |
michael@0 | 180 | const mozilla::layers::ZoomConstraints& aConstraints) = 0; |
michael@0 | 181 | |
michael@0 | 182 | nsEventStatus DispatchSynthesizedMouseEvent(uint32_t aMsg, uint64_t aTime, |
michael@0 | 183 | const LayoutDevicePoint& aRefPoint, |
michael@0 | 184 | nsIWidget* aWidget); |
michael@0 | 185 | |
michael@0 | 186 | protected: |
michael@0 | 187 | CSSSize GetPageSize(nsCOMPtr<nsIDocument> aDocument, const CSSSize& aViewport); |
michael@0 | 188 | |
michael@0 | 189 | // Get the DOMWindowUtils for the top-level window in this tab. |
michael@0 | 190 | already_AddRefed<nsIDOMWindowUtils> GetDOMWindowUtils(); |
michael@0 | 191 | // Get the Document for the top-level window in this tab. |
michael@0 | 192 | already_AddRefed<nsIDocument> GetDocument(); |
michael@0 | 193 | |
michael@0 | 194 | // Wrapper for nsIDOMWindowUtils.setCSSViewport(). This updates some state |
michael@0 | 195 | // variables local to this class before setting it. |
michael@0 | 196 | void SetCSSViewport(const CSSSize& aSize); |
michael@0 | 197 | |
michael@0 | 198 | // Wraps up a JSON object as a structured clone and sends it to the browser |
michael@0 | 199 | // chrome script. |
michael@0 | 200 | // |
michael@0 | 201 | // XXX/bug 780335: Do the work the browser chrome script does in C++ instead |
michael@0 | 202 | // so we don't need things like this. |
michael@0 | 203 | void DispatchMessageManagerMessage(const nsAString& aMessageName, |
michael@0 | 204 | const nsAString& aJSONData); |
michael@0 | 205 | |
michael@0 | 206 | nsEventStatus DispatchWidgetEvent(WidgetGUIEvent& event); |
michael@0 | 207 | |
michael@0 | 208 | bool HasValidInnerSize(); |
michael@0 | 209 | void InitializeRootMetrics(); |
michael@0 | 210 | |
michael@0 | 211 | mozilla::layers::FrameMetrics ProcessUpdateFrame(const mozilla::layers::FrameMetrics& aFrameMetrics); |
michael@0 | 212 | |
michael@0 | 213 | bool UpdateFrameHandler(const mozilla::layers::FrameMetrics& aFrameMetrics); |
michael@0 | 214 | |
michael@0 | 215 | protected: |
michael@0 | 216 | float mOldViewportWidth; |
michael@0 | 217 | bool mContentDocumentIsDisplayed; |
michael@0 | 218 | nsRefPtr<TabChildGlobal> mTabChildGlobal; |
michael@0 | 219 | ScreenIntSize mInnerSize; |
michael@0 | 220 | mozilla::layers::FrameMetrics mLastRootMetrics; |
michael@0 | 221 | mozilla::layout::ScrollingBehavior mScrolling; |
michael@0 | 222 | }; |
michael@0 | 223 | |
michael@0 | 224 | class TabChild : public TabChildBase, |
michael@0 | 225 | public PBrowserChild, |
michael@0 | 226 | public nsIWebBrowserChrome2, |
michael@0 | 227 | public nsIEmbeddingSiteWindow, |
michael@0 | 228 | public nsIWebBrowserChromeFocus, |
michael@0 | 229 | public nsIInterfaceRequestor, |
michael@0 | 230 | public nsIWindowProvider, |
michael@0 | 231 | public nsIDOMEventListener, |
michael@0 | 232 | public nsIWebProgressListener, |
michael@0 | 233 | public nsSupportsWeakReference, |
michael@0 | 234 | public nsITabChild, |
michael@0 | 235 | public nsIObserver, |
michael@0 | 236 | public TabContext, |
michael@0 | 237 | public nsITooltipListener |
michael@0 | 238 | { |
michael@0 | 239 | typedef mozilla::dom::ClonedMessageData ClonedMessageData; |
michael@0 | 240 | typedef mozilla::layout::RenderFrameChild RenderFrameChild; |
michael@0 | 241 | typedef mozilla::layout::ScrollingBehavior ScrollingBehavior; |
michael@0 | 242 | typedef mozilla::layers::ActiveElementManager ActiveElementManager; |
michael@0 | 243 | |
michael@0 | 244 | public: |
michael@0 | 245 | /** |
michael@0 | 246 | * This is expected to be called off the critical path to content |
michael@0 | 247 | * startup. This is an opportunity to load things that are slow |
michael@0 | 248 | * on the critical path. |
michael@0 | 249 | */ |
michael@0 | 250 | static void PreloadSlowThings(); |
michael@0 | 251 | |
michael@0 | 252 | /** Return a TabChild with the given attributes. */ |
michael@0 | 253 | static already_AddRefed<TabChild> |
michael@0 | 254 | Create(ContentChild* aManager, const TabContext& aContext, uint32_t aChromeFlags); |
michael@0 | 255 | |
michael@0 | 256 | virtual ~TabChild(); |
michael@0 | 257 | |
michael@0 | 258 | bool IsRootContentDocument(); |
michael@0 | 259 | |
michael@0 | 260 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 261 | NS_DECL_NSIWEBBROWSERCHROME |
michael@0 | 262 | NS_DECL_NSIWEBBROWSERCHROME2 |
michael@0 | 263 | NS_DECL_NSIEMBEDDINGSITEWINDOW |
michael@0 | 264 | NS_DECL_NSIWEBBROWSERCHROMEFOCUS |
michael@0 | 265 | NS_DECL_NSIINTERFACEREQUESTOR |
michael@0 | 266 | NS_DECL_NSIWINDOWPROVIDER |
michael@0 | 267 | NS_DECL_NSIDOMEVENTLISTENER |
michael@0 | 268 | NS_DECL_NSIWEBPROGRESSLISTENER |
michael@0 | 269 | NS_DECL_NSITABCHILD |
michael@0 | 270 | NS_DECL_NSIOBSERVER |
michael@0 | 271 | NS_DECL_NSITOOLTIPLISTENER |
michael@0 | 272 | |
michael@0 | 273 | /** |
michael@0 | 274 | * MessageManagerCallback methods that we override. |
michael@0 | 275 | */ |
michael@0 | 276 | virtual bool DoSendBlockingMessage(JSContext* aCx, |
michael@0 | 277 | const nsAString& aMessage, |
michael@0 | 278 | const mozilla::dom::StructuredCloneData& aData, |
michael@0 | 279 | JS::Handle<JSObject *> aCpows, |
michael@0 | 280 | nsIPrincipal* aPrincipal, |
michael@0 | 281 | InfallibleTArray<nsString>* aJSONRetVal, |
michael@0 | 282 | bool aIsSync) MOZ_OVERRIDE; |
michael@0 | 283 | virtual bool DoSendAsyncMessage(JSContext* aCx, |
michael@0 | 284 | const nsAString& aMessage, |
michael@0 | 285 | const mozilla::dom::StructuredCloneData& aData, |
michael@0 | 286 | JS::Handle<JSObject *> aCpows, |
michael@0 | 287 | nsIPrincipal* aPrincipal) MOZ_OVERRIDE; |
michael@0 | 288 | virtual bool DoUpdateZoomConstraints(const uint32_t& aPresShellId, |
michael@0 | 289 | const ViewID& aViewId, |
michael@0 | 290 | const bool& aIsRoot, |
michael@0 | 291 | const ZoomConstraints& aConstraints) MOZ_OVERRIDE; |
michael@0 | 292 | virtual bool RecvLoadURL(const nsCString& uri) MOZ_OVERRIDE; |
michael@0 | 293 | virtual bool RecvCacheFileDescriptor(const nsString& aPath, |
michael@0 | 294 | const FileDescriptor& aFileDescriptor) |
michael@0 | 295 | MOZ_OVERRIDE; |
michael@0 | 296 | virtual bool RecvShow(const nsIntSize& size) MOZ_OVERRIDE; |
michael@0 | 297 | virtual bool RecvUpdateDimensions(const nsRect& rect, |
michael@0 | 298 | const nsIntSize& size, |
michael@0 | 299 | const ScreenOrientation& orientation) MOZ_OVERRIDE; |
michael@0 | 300 | virtual bool RecvUpdateFrame(const mozilla::layers::FrameMetrics& aFrameMetrics) MOZ_OVERRIDE; |
michael@0 | 301 | virtual bool RecvAcknowledgeScrollUpdate(const ViewID& aScrollId, |
michael@0 | 302 | const uint32_t& aScrollGeneration) MOZ_OVERRIDE; |
michael@0 | 303 | virtual bool RecvHandleDoubleTap(const CSSPoint& aPoint, |
michael@0 | 304 | const mozilla::layers::ScrollableLayerGuid& aGuid) MOZ_OVERRIDE; |
michael@0 | 305 | virtual bool RecvHandleSingleTap(const CSSPoint& aPoint, |
michael@0 | 306 | const mozilla::layers::ScrollableLayerGuid& aGuid) MOZ_OVERRIDE; |
michael@0 | 307 | virtual bool RecvHandleLongTap(const CSSPoint& aPoint, |
michael@0 | 308 | const mozilla::layers::ScrollableLayerGuid& aGuid) MOZ_OVERRIDE; |
michael@0 | 309 | virtual bool RecvHandleLongTapUp(const CSSPoint& aPoint, |
michael@0 | 310 | const mozilla::layers::ScrollableLayerGuid& aGuid) MOZ_OVERRIDE; |
michael@0 | 311 | virtual bool RecvNotifyAPZStateChange(const ViewID& aViewId, |
michael@0 | 312 | const APZStateChange& aChange, |
michael@0 | 313 | const int& aArg) MOZ_OVERRIDE; |
michael@0 | 314 | virtual bool RecvActivate() MOZ_OVERRIDE; |
michael@0 | 315 | virtual bool RecvDeactivate() MOZ_OVERRIDE; |
michael@0 | 316 | virtual bool RecvMouseEvent(const nsString& aType, |
michael@0 | 317 | const float& aX, |
michael@0 | 318 | const float& aY, |
michael@0 | 319 | const int32_t& aButton, |
michael@0 | 320 | const int32_t& aClickCount, |
michael@0 | 321 | const int32_t& aModifiers, |
michael@0 | 322 | const bool& aIgnoreRootScrollFrame) MOZ_OVERRIDE; |
michael@0 | 323 | virtual bool RecvRealMouseEvent(const mozilla::WidgetMouseEvent& event) MOZ_OVERRIDE; |
michael@0 | 324 | virtual bool RecvRealKeyEvent(const mozilla::WidgetKeyboardEvent& event, |
michael@0 | 325 | const MaybeNativeKeyBinding& aBindings) MOZ_OVERRIDE; |
michael@0 | 326 | virtual bool RecvMouseWheelEvent(const mozilla::WidgetWheelEvent& event) MOZ_OVERRIDE; |
michael@0 | 327 | virtual bool RecvRealTouchEvent(const WidgetTouchEvent& aEvent, |
michael@0 | 328 | const ScrollableLayerGuid& aGuid) MOZ_OVERRIDE; |
michael@0 | 329 | virtual bool RecvRealTouchMoveEvent(const WidgetTouchEvent& aEvent, |
michael@0 | 330 | const ScrollableLayerGuid& aGuid) MOZ_OVERRIDE; |
michael@0 | 331 | virtual bool RecvKeyEvent(const nsString& aType, |
michael@0 | 332 | const int32_t& aKeyCode, |
michael@0 | 333 | const int32_t& aCharCode, |
michael@0 | 334 | const int32_t& aModifiers, |
michael@0 | 335 | const bool& aPreventDefault) MOZ_OVERRIDE; |
michael@0 | 336 | virtual bool RecvCompositionEvent(const mozilla::WidgetCompositionEvent& event) MOZ_OVERRIDE; |
michael@0 | 337 | virtual bool RecvTextEvent(const mozilla::WidgetTextEvent& event) MOZ_OVERRIDE; |
michael@0 | 338 | virtual bool RecvSelectionEvent(const mozilla::WidgetSelectionEvent& event) MOZ_OVERRIDE; |
michael@0 | 339 | virtual bool RecvActivateFrameEvent(const nsString& aType, const bool& capture) MOZ_OVERRIDE; |
michael@0 | 340 | virtual bool RecvLoadRemoteScript(const nsString& aURL, |
michael@0 | 341 | const bool& aRunInGlobalScope) MOZ_OVERRIDE; |
michael@0 | 342 | virtual bool RecvAsyncMessage(const nsString& aMessage, |
michael@0 | 343 | const ClonedMessageData& aData, |
michael@0 | 344 | const InfallibleTArray<CpowEntry>& aCpows, |
michael@0 | 345 | const IPC::Principal& aPrincipal) MOZ_OVERRIDE; |
michael@0 | 346 | |
michael@0 | 347 | virtual PDocumentRendererChild* |
michael@0 | 348 | AllocPDocumentRendererChild(const nsRect& documentRect, const gfx::Matrix& transform, |
michael@0 | 349 | const nsString& bgcolor, |
michael@0 | 350 | const uint32_t& renderFlags, const bool& flushLayout, |
michael@0 | 351 | const nsIntSize& renderSize) MOZ_OVERRIDE; |
michael@0 | 352 | virtual bool DeallocPDocumentRendererChild(PDocumentRendererChild* actor) MOZ_OVERRIDE; |
michael@0 | 353 | virtual bool RecvPDocumentRendererConstructor(PDocumentRendererChild* actor, |
michael@0 | 354 | const nsRect& documentRect, |
michael@0 | 355 | const gfx::Matrix& transform, |
michael@0 | 356 | const nsString& bgcolor, |
michael@0 | 357 | const uint32_t& renderFlags, |
michael@0 | 358 | const bool& flushLayout, |
michael@0 | 359 | const nsIntSize& renderSize) MOZ_OVERRIDE; |
michael@0 | 360 | |
michael@0 | 361 | virtual PColorPickerChild* |
michael@0 | 362 | AllocPColorPickerChild(const nsString& title, const nsString& initialColor) MOZ_OVERRIDE; |
michael@0 | 363 | virtual bool DeallocPColorPickerChild(PColorPickerChild* actor) MOZ_OVERRIDE; |
michael@0 | 364 | |
michael@0 | 365 | #ifdef DEBUG |
michael@0 | 366 | virtual PContentPermissionRequestChild* |
michael@0 | 367 | SendPContentPermissionRequestConstructor(PContentPermissionRequestChild* aActor, |
michael@0 | 368 | const InfallibleTArray<PermissionRequest>& aRequests, |
michael@0 | 369 | const IPC::Principal& aPrincipal); |
michael@0 | 370 | #endif /* DEBUG */ |
michael@0 | 371 | |
michael@0 | 372 | virtual PContentPermissionRequestChild* |
michael@0 | 373 | AllocPContentPermissionRequestChild(const InfallibleTArray<PermissionRequest>& aRequests, |
michael@0 | 374 | const IPC::Principal& aPrincipal) MOZ_OVERRIDE; |
michael@0 | 375 | virtual bool |
michael@0 | 376 | DeallocPContentPermissionRequestChild(PContentPermissionRequestChild* actor) MOZ_OVERRIDE; |
michael@0 | 377 | |
michael@0 | 378 | virtual PFilePickerChild* |
michael@0 | 379 | AllocPFilePickerChild(const nsString& aTitle, const int16_t& aMode) MOZ_OVERRIDE; |
michael@0 | 380 | virtual bool |
michael@0 | 381 | DeallocPFilePickerChild(PFilePickerChild* actor) MOZ_OVERRIDE; |
michael@0 | 382 | |
michael@0 | 383 | virtual POfflineCacheUpdateChild* AllocPOfflineCacheUpdateChild( |
michael@0 | 384 | const URIParams& manifestURI, |
michael@0 | 385 | const URIParams& documentURI, |
michael@0 | 386 | const bool& stickDocument) MOZ_OVERRIDE; |
michael@0 | 387 | virtual bool |
michael@0 | 388 | DeallocPOfflineCacheUpdateChild(POfflineCacheUpdateChild* offlineCacheUpdate) MOZ_OVERRIDE; |
michael@0 | 389 | |
michael@0 | 390 | virtual nsIWebNavigation* WebNavigation() MOZ_OVERRIDE { return mWebNav; } |
michael@0 | 391 | virtual nsIWidget* WebWidget() MOZ_OVERRIDE { return mWidget; } |
michael@0 | 392 | |
michael@0 | 393 | /** Return the DPI of the widget this TabChild draws to. */ |
michael@0 | 394 | void GetDPI(float* aDPI); |
michael@0 | 395 | void GetDefaultScale(double *aScale); |
michael@0 | 396 | |
michael@0 | 397 | ScreenOrientation GetOrientation() { return mOrientation; } |
michael@0 | 398 | |
michael@0 | 399 | void SetBackgroundColor(const nscolor& aColor); |
michael@0 | 400 | |
michael@0 | 401 | void NotifyPainted(); |
michael@0 | 402 | |
michael@0 | 403 | void RequestNativeKeyBindings(mozilla::widget::AutoCacheNativeKeyCommands* aAutoCache, |
michael@0 | 404 | WidgetKeyboardEvent* aEvent); |
michael@0 | 405 | |
michael@0 | 406 | /** Return a boolean indicating if the page has called preventDefault on |
michael@0 | 407 | * the event. |
michael@0 | 408 | */ |
michael@0 | 409 | bool DispatchMouseEvent(const nsString& aType, |
michael@0 | 410 | const CSSPoint& aPoint, |
michael@0 | 411 | const int32_t& aButton, |
michael@0 | 412 | const int32_t& aClickCount, |
michael@0 | 413 | const int32_t& aModifiers, |
michael@0 | 414 | const bool& aIgnoreRootScrollFrame, |
michael@0 | 415 | const unsigned short& aInputSourceArg); |
michael@0 | 416 | |
michael@0 | 417 | /** |
michael@0 | 418 | * Signal to this TabChild that it should be made visible: |
michael@0 | 419 | * activated widget, retained layer tree, etc. (Respectively, |
michael@0 | 420 | * made not visible.) |
michael@0 | 421 | */ |
michael@0 | 422 | void MakeVisible(); |
michael@0 | 423 | void MakeHidden(); |
michael@0 | 424 | |
michael@0 | 425 | // Returns true if the file descriptor was found in the cache, false |
michael@0 | 426 | // otherwise. |
michael@0 | 427 | bool GetCachedFileDescriptor(const nsAString& aPath, |
michael@0 | 428 | nsICachedFileDescriptorListener* aCallback); |
michael@0 | 429 | |
michael@0 | 430 | void CancelCachedFileDescriptorCallback( |
michael@0 | 431 | const nsAString& aPath, |
michael@0 | 432 | nsICachedFileDescriptorListener* aCallback); |
michael@0 | 433 | |
michael@0 | 434 | ContentChild* Manager() { return mManager; } |
michael@0 | 435 | |
michael@0 | 436 | bool GetUpdateHitRegion() { return mUpdateHitRegion; } |
michael@0 | 437 | |
michael@0 | 438 | void UpdateHitRegion(const nsRegion& aRegion); |
michael@0 | 439 | |
michael@0 | 440 | static inline TabChild* |
michael@0 | 441 | GetFrom(nsIDocShell* aDocShell) |
michael@0 | 442 | { |
michael@0 | 443 | nsCOMPtr<nsITabChild> tc = do_GetInterface(aDocShell); |
michael@0 | 444 | return static_cast<TabChild*>(tc.get()); |
michael@0 | 445 | } |
michael@0 | 446 | |
michael@0 | 447 | static TabChild* GetFrom(nsIPresShell* aPresShell); |
michael@0 | 448 | static TabChild* GetFrom(uint64_t aLayersId); |
michael@0 | 449 | |
michael@0 | 450 | void DidComposite(); |
michael@0 | 451 | |
michael@0 | 452 | static inline TabChild* |
michael@0 | 453 | GetFrom(nsIDOMWindow* aWindow) |
michael@0 | 454 | { |
michael@0 | 455 | nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow); |
michael@0 | 456 | nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(webNav); |
michael@0 | 457 | return GetFrom(docShell); |
michael@0 | 458 | } |
michael@0 | 459 | |
michael@0 | 460 | protected: |
michael@0 | 461 | virtual PRenderFrameChild* AllocPRenderFrameChild() MOZ_OVERRIDE; |
michael@0 | 462 | virtual bool DeallocPRenderFrameChild(PRenderFrameChild* aFrame) MOZ_OVERRIDE; |
michael@0 | 463 | virtual bool RecvDestroy() MOZ_OVERRIDE; |
michael@0 | 464 | virtual bool RecvSetUpdateHitRegion(const bool& aEnabled) MOZ_OVERRIDE; |
michael@0 | 465 | virtual bool RecvSetIsDocShellActive(const bool& aIsActive) MOZ_OVERRIDE; |
michael@0 | 466 | |
michael@0 | 467 | virtual PIndexedDBChild* AllocPIndexedDBChild(const nsCString& aGroup, |
michael@0 | 468 | const nsCString& aASCIIOrigin, |
michael@0 | 469 | bool* /* aAllowed */) MOZ_OVERRIDE; |
michael@0 | 470 | |
michael@0 | 471 | virtual bool DeallocPIndexedDBChild(PIndexedDBChild* aActor) MOZ_OVERRIDE; |
michael@0 | 472 | |
michael@0 | 473 | private: |
michael@0 | 474 | /** |
michael@0 | 475 | * Create a new TabChild object. |
michael@0 | 476 | * |
michael@0 | 477 | * |aOwnOrContainingAppId| is the app-id of our frame or of the closest app |
michael@0 | 478 | * frame in the hierarchy which contains us. |
michael@0 | 479 | * |
michael@0 | 480 | * |aIsBrowserElement| indicates whether we're a browser (but not an app). |
michael@0 | 481 | */ |
michael@0 | 482 | TabChild(ContentChild* aManager, const TabContext& aContext, uint32_t aChromeFlags); |
michael@0 | 483 | |
michael@0 | 484 | nsresult Init(); |
michael@0 | 485 | |
michael@0 | 486 | |
michael@0 | 487 | // Notify others that our TabContext has been updated. (At the moment, this |
michael@0 | 488 | // sets the appropriate app-id and is-browser flags on our docshell.) |
michael@0 | 489 | // |
michael@0 | 490 | // You should call this after calling TabContext::SetTabContext(). We also |
michael@0 | 491 | // call this during Init(). |
michael@0 | 492 | void NotifyTabContextUpdated(); |
michael@0 | 493 | |
michael@0 | 494 | bool UseDirectCompositor(); |
michael@0 | 495 | |
michael@0 | 496 | void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; |
michael@0 | 497 | |
michael@0 | 498 | enum FrameScriptLoading { DONT_LOAD_SCRIPTS, DEFAULT_LOAD_SCRIPTS }; |
michael@0 | 499 | bool InitTabChildGlobal(FrameScriptLoading aScriptLoading = DEFAULT_LOAD_SCRIPTS); |
michael@0 | 500 | bool InitRenderingState(); |
michael@0 | 501 | void DestroyWindow(); |
michael@0 | 502 | void SetProcessNameToAppName(); |
michael@0 | 503 | |
michael@0 | 504 | // Call RecvShow(nsIntSize(0, 0)) and block future calls to RecvShow(). |
michael@0 | 505 | void DoFakeShow(); |
michael@0 | 506 | |
michael@0 | 507 | // These methods are used for tracking synthetic mouse events |
michael@0 | 508 | // dispatched for compatibility. On each touch event, we |
michael@0 | 509 | // UpdateTapState(). If we've detected that the current gesture |
michael@0 | 510 | // isn't a tap, then we CancelTapTracking(). In the meantime, we |
michael@0 | 511 | // may detect a context-menu event, and if so we |
michael@0 | 512 | // FireContextMenuEvent(). |
michael@0 | 513 | void FireContextMenuEvent(); |
michael@0 | 514 | void CancelTapTracking(); |
michael@0 | 515 | void UpdateTapState(const WidgetTouchEvent& aEvent, nsEventStatus aStatus); |
michael@0 | 516 | |
michael@0 | 517 | nsresult |
michael@0 | 518 | BrowserFrameProvideWindow(nsIDOMWindow* aOpener, |
michael@0 | 519 | nsIURI* aURI, |
michael@0 | 520 | const nsAString& aName, |
michael@0 | 521 | const nsACString& aFeatures, |
michael@0 | 522 | bool* aWindowIsNew, |
michael@0 | 523 | nsIDOMWindow** aReturn); |
michael@0 | 524 | |
michael@0 | 525 | class CachedFileDescriptorInfo; |
michael@0 | 526 | class CachedFileDescriptorCallbackRunnable; |
michael@0 | 527 | |
michael@0 | 528 | TextureFactoryIdentifier mTextureFactoryIdentifier; |
michael@0 | 529 | nsCOMPtr<nsIWebNavigation> mWebNav; |
michael@0 | 530 | nsCOMPtr<nsIWidget> mWidget; |
michael@0 | 531 | nsCOMPtr<nsIURI> mLastURI; |
michael@0 | 532 | RenderFrameChild* mRemoteFrame; |
michael@0 | 533 | nsRefPtr<ContentChild> mManager; |
michael@0 | 534 | uint32_t mChromeFlags; |
michael@0 | 535 | uint64_t mLayersId; |
michael@0 | 536 | nsIntRect mOuterRect; |
michael@0 | 537 | // When we're tracking a possible tap gesture, this is the "down" |
michael@0 | 538 | // point of the touchstart. |
michael@0 | 539 | LayoutDevicePoint mGestureDownPoint; |
michael@0 | 540 | // The touch identifier of the active gesture. |
michael@0 | 541 | int32_t mActivePointerId; |
michael@0 | 542 | // A timer task that fires if the tap-hold timeout is exceeded by |
michael@0 | 543 | // the touch we're tracking. That is, if touchend or a touchmove |
michael@0 | 544 | // that exceeds the gesture threshold doesn't happen. |
michael@0 | 545 | CancelableTask* mTapHoldTimer; |
michael@0 | 546 | // Whether we have already received a FileDescriptor for the app package. |
michael@0 | 547 | bool mAppPackageFileDescriptorRecved; |
michael@0 | 548 | // At present only 1 of these is really expected. |
michael@0 | 549 | nsAutoTArray<nsAutoPtr<CachedFileDescriptorInfo>, 1> |
michael@0 | 550 | mCachedFileDescriptorInfos; |
michael@0 | 551 | nscolor mLastBackgroundColor; |
michael@0 | 552 | bool mDidFakeShow; |
michael@0 | 553 | bool mNotified; |
michael@0 | 554 | bool mTriedBrowserInit; |
michael@0 | 555 | ScreenOrientation mOrientation; |
michael@0 | 556 | bool mUpdateHitRegion; |
michael@0 | 557 | bool mContextMenuHandled; |
michael@0 | 558 | bool mWaitingTouchListeners; |
michael@0 | 559 | void FireSingleTapEvent(LayoutDevicePoint aPoint); |
michael@0 | 560 | |
michael@0 | 561 | bool mIgnoreKeyPressEvent; |
michael@0 | 562 | nsRefPtr<ActiveElementManager> mActiveElementManager; |
michael@0 | 563 | |
michael@0 | 564 | DISALLOW_EVIL_CONSTRUCTORS(TabChild); |
michael@0 | 565 | }; |
michael@0 | 566 | |
michael@0 | 567 | } |
michael@0 | 568 | } |
michael@0 | 569 | |
michael@0 | 570 | #endif // mozilla_dom_TabChild_h |