1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_dom_TabChild_h 8 #define mozilla_dom_TabChild_h 9 10 #include "mozilla/dom/PBrowserChild.h" 11 #include "nsIWebNavigation.h" 12 #include "nsCOMPtr.h" 13 #include "nsAutoPtr.h" 14 #include "nsIWebBrowserChrome2.h" 15 #include "nsIEmbeddingSiteWindow.h" 16 #include "nsIWebBrowserChromeFocus.h" 17 #include "nsIDOMEventListener.h" 18 #include "nsIInterfaceRequestor.h" 19 #include "nsIWindowProvider.h" 20 #include "nsIDOMWindow.h" 21 #include "nsIDocShell.h" 22 #include "nsIInterfaceRequestorUtils.h" 23 #include "nsFrameMessageManager.h" 24 #include "nsIPresShell.h" 25 #include "nsIScriptObjectPrincipal.h" 26 #include "nsWeakReference.h" 27 #include "nsITabChild.h" 28 #include "nsITooltipListener.h" 29 #include "mozilla/Attributes.h" 30 #include "mozilla/dom/TabContext.h" 31 #include "mozilla/DOMEventTargetHelper.h" 32 #include "mozilla/EventDispatcher.h" 33 #include "mozilla/EventForwards.h" 34 #include "mozilla/layers/CompositorTypes.h" 35 #include "mozilla/layers/APZCCallbackHelper.h" 36 #include "nsIWebBrowserChrome3.h" 37 #include "mozilla/dom/ipc/IdType.h" 38 #include "AudioChannelService.h" 39 #include "PuppetWidget.h" 40 #include "mozilla/layers/GeckoContentController.h" 41 #include "nsISHistoryListener.h" 42 #include "nsIPartialSHistoryListener.h" 43 44 class nsIDOMWindowUtils; 45 class nsIHttpChannel; 46 47 namespace mozilla { 48 namespace layout { 49 class RenderFrameChild; 50 } // namespace layout 51 52 namespace layers { 53 class APZChild; 54 class APZEventState; 55 class AsyncDragMetrics; 56 class IAPZCTreeManager; 57 class ImageCompositeNotification; 58 } // namespace layers 59 60 namespace widget { 61 struct AutoCacheNativeKeyCommands; 62 } // namespace widget 63 64 namespace plugins { 65 class PluginWidgetChild; 66 } // namespace plugins 67 68 namespace dom { 69 70 class TabChild; 71 class ClonedMessageData; 72 class TabChildBase; 73 74 class TabChildGlobal : public DOMEventTargetHelper, 75 public nsIContentFrameMessageManager, 76 public nsIScriptObjectPrincipal, 77 public nsIGlobalObject, 78 public nsSupportsWeakReference 79 { 80 public: 81 explicit TabChildGlobal(TabChildBase* aTabChild); 82 void Init(); 83 NS_DECL_ISUPPORTS_INHERITED NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TabChildGlobal,DOMEventTargetHelper)84 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TabChildGlobal, DOMEventTargetHelper) 85 NS_FORWARD_SAFE_NSIMESSAGELISTENERMANAGER(mMessageManager) 86 NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager) 87 NS_FORWARD_SAFE_NSIMESSAGEMANAGERGLOBAL(mMessageManager) 88 NS_IMETHOD SendSyncMessage(const nsAString& aMessageName, 89 JS::Handle<JS::Value> aObject, 90 JS::Handle<JS::Value> aRemote, 91 nsIPrincipal* aPrincipal, 92 JSContext* aCx, 93 uint8_t aArgc, 94 JS::MutableHandle<JS::Value> aRetval) override 95 { 96 return mMessageManager 97 ? mMessageManager->SendSyncMessage(aMessageName, aObject, aRemote, 98 aPrincipal, aCx, aArgc, aRetval) 99 : NS_ERROR_NULL_POINTER; 100 } SendRpcMessage(const nsAString & aMessageName,JS::Handle<JS::Value> aObject,JS::Handle<JS::Value> aRemote,nsIPrincipal * aPrincipal,JSContext * aCx,uint8_t aArgc,JS::MutableHandle<JS::Value> aRetval)101 NS_IMETHOD SendRpcMessage(const nsAString& aMessageName, 102 JS::Handle<JS::Value> aObject, 103 JS::Handle<JS::Value> aRemote, 104 nsIPrincipal* aPrincipal, 105 JSContext* aCx, 106 uint8_t aArgc, 107 JS::MutableHandle<JS::Value> aRetval) override 108 { 109 return mMessageManager 110 ? mMessageManager->SendRpcMessage(aMessageName, aObject, aRemote, 111 aPrincipal, aCx, aArgc, aRetval) 112 : NS_ERROR_NULL_POINTER; 113 } 114 NS_IMETHOD GetContent(mozIDOMWindowProxy** aContent) override; 115 NS_IMETHOD GetDocShell(nsIDocShell** aDocShell) override; 116 AddEventListener(const nsAString & aType,nsIDOMEventListener * aListener,bool aUseCapture)117 nsresult AddEventListener(const nsAString& aType, 118 nsIDOMEventListener* aListener, 119 bool aUseCapture) 120 { 121 // By default add listeners only for trusted events! 122 return DOMEventTargetHelper::AddEventListener(aType, aListener, 123 aUseCapture, false, 2); 124 } 125 using DOMEventTargetHelper::AddEventListener; AddEventListener(const nsAString & aType,nsIDOMEventListener * aListener,bool aUseCapture,bool aWantsUntrusted,uint8_t optional_argc)126 NS_IMETHOD AddEventListener(const nsAString& aType, 127 nsIDOMEventListener* aListener, 128 bool aUseCapture, bool aWantsUntrusted, 129 uint8_t optional_argc) override 130 { 131 return DOMEventTargetHelper::AddEventListener(aType, aListener, 132 aUseCapture, 133 aWantsUntrusted, 134 optional_argc); 135 } 136 137 nsresult PreHandleEvent(EventChainPreVisitor & aVisitor)138 PreHandleEvent(EventChainPreVisitor& aVisitor) override 139 { 140 aVisitor.mForceContentDispatch = true; 141 return NS_OK; 142 } 143 144 virtual nsIPrincipal* GetPrincipal() override; 145 virtual JSObject* GetGlobalJSObject() override; 146 WrapObject(JSContext * cx,JS::Handle<JSObject * > aGivenProto)147 virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override 148 { 149 MOZ_CRASH("TabChildGlobal doesn't use DOM bindings!"); 150 } 151 152 nsCOMPtr<nsIContentFrameMessageManager> mMessageManager; 153 RefPtr<TabChildBase> mTabChild; 154 155 protected: 156 ~TabChildGlobal(); 157 }; 158 159 class ContentListener final : public nsIDOMEventListener 160 { 161 public: ContentListener(TabChild * aTabChild)162 explicit ContentListener(TabChild* aTabChild) : mTabChild(aTabChild) {} 163 NS_DECL_ISUPPORTS 164 NS_DECL_NSIDOMEVENTLISTENER 165 protected: ~ContentListener()166 ~ContentListener() {} 167 TabChild* mTabChild; 168 }; 169 170 /** 171 * Listens on session history change, and sends NotifySessionHistoryChange to 172 * parent process. 173 */ 174 class TabChildSHistoryListener final : public nsISHistoryListener, 175 public nsIPartialSHistoryListener, 176 public nsSupportsWeakReference 177 { 178 public: TabChildSHistoryListener(TabChild * aTabChild)179 explicit TabChildSHistoryListener(TabChild* aTabChild) : mTabChild(aTabChild) {} ClearTabChild()180 void ClearTabChild() { mTabChild = nullptr; } 181 182 NS_DECL_ISUPPORTS 183 NS_DECL_NSISHISTORYLISTENER 184 NS_DECL_NSIPARTIALSHISTORYLISTENER 185 186 private: ~TabChildSHistoryListener()187 ~TabChildSHistoryListener() {} 188 TabChild* mTabChild; 189 }; 190 191 // This is base clase which helps to share Viewport and touch related 192 // functionality between b2g/android FF/embedlite clients implementation. 193 // It make sense to place in this class all helper functions, and functionality 194 // which could be shared between Cross-process/Cross-thread implmentations. 195 class TabChildBase : public nsISupports, 196 public nsMessageManagerScriptExecutor, 197 public ipc::MessageManagerCallback 198 { 199 protected: 200 typedef mozilla::widget::PuppetWidget PuppetWidget; 201 202 public: 203 TabChildBase(); 204 205 NS_DECL_CYCLE_COLLECTING_ISUPPORTS 206 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TabChildBase) 207 208 virtual nsIWebNavigation* WebNavigation() const = 0; 209 virtual PuppetWidget* WebWidget() = 0; GetPrincipal()210 nsIPrincipal* GetPrincipal() { return mPrincipal; } 211 virtual bool DoUpdateZoomConstraints(const uint32_t& aPresShellId, 212 const mozilla::layers::FrameMetrics::ViewID& aViewId, 213 const Maybe<mozilla::layers::ZoomConstraints>& aConstraints) = 0; 214 215 virtual ScreenIntSize GetInnerSize() = 0; 216 217 // Get the Document for the top-level window in this tab. 218 already_AddRefed<nsIDocument> GetDocument() const; 219 220 // Get the pres-shell of the document for the top-level window in this tab. 221 already_AddRefed<nsIPresShell> GetPresShell() const; 222 223 protected: 224 virtual ~TabChildBase(); 225 226 // Wraps up a JSON object as a structured clone and sends it to the browser 227 // chrome script. 228 // 229 // XXX/bug 780335: Do the work the browser chrome script does in C++ instead 230 // so we don't need things like this. 231 void DispatchMessageManagerMessage(const nsAString& aMessageName, 232 const nsAString& aJSONData); 233 234 void ProcessUpdateFrame(const mozilla::layers::FrameMetrics& aFrameMetrics); 235 236 bool UpdateFrameHandler(const mozilla::layers::FrameMetrics& aFrameMetrics); 237 238 protected: 239 RefPtr<TabChildGlobal> mTabChildGlobal; 240 nsCOMPtr<nsIWebBrowserChrome3> mWebBrowserChrome; 241 }; 242 243 class TabChild final : public TabChildBase, 244 public PBrowserChild, 245 public nsIWebBrowserChrome2, 246 public nsIEmbeddingSiteWindow, 247 public nsIWebBrowserChromeFocus, 248 public nsIInterfaceRequestor, 249 public nsIWindowProvider, 250 public nsSupportsWeakReference, 251 public nsITabChild, 252 public nsIObserver, 253 public TabContext, 254 public nsITooltipListener, 255 public mozilla::ipc::IShmemAllocator 256 { 257 typedef mozilla::dom::ClonedMessageData ClonedMessageData; 258 typedef mozilla::layout::RenderFrameChild RenderFrameChild; 259 typedef mozilla::layers::APZEventState APZEventState; 260 typedef mozilla::layers::SetAllowedTouchBehaviorCallback SetAllowedTouchBehaviorCallback; 261 262 public: 263 /** 264 * Find TabChild of aTabId in the same content process of the 265 * caller. 266 */ 267 static already_AddRefed<TabChild> FindTabChild(const TabId& aTabId); 268 269 // Return a list of all active TabChildren. 270 static nsTArray<RefPtr<TabChild>> GetAll(); 271 272 public: 273 /** 274 * Create a new TabChild object. 275 */ 276 TabChild(nsIContentChild* aManager, 277 const TabId& aTabId, 278 const TabContext& aContext, 279 uint32_t aChromeFlags); 280 281 nsresult Init(); 282 283 /** 284 * This is expected to be called off the critical path to content 285 * startup. This is an opportunity to load things that are slow 286 * on the critical path. 287 */ 288 static void PreloadSlowThings(); 289 290 /** Return a TabChild with the given attributes. */ 291 static already_AddRefed<TabChild> 292 Create(nsIContentChild* aManager, const TabId& aTabId, 293 const TabContext& aContext, uint32_t aChromeFlags); 294 295 // Let managees query if it is safe to send messages. IsDestroyed()296 bool IsDestroyed() const{ return mDestroyed; } 297 GetTabId()298 const TabId GetTabId() const 299 { 300 MOZ_ASSERT(mUniqueId != 0); 301 return mUniqueId; 302 } 303 304 NS_DECL_ISUPPORTS_INHERITED 305 NS_DECL_NSIWEBBROWSERCHROME 306 NS_DECL_NSIWEBBROWSERCHROME2 307 NS_DECL_NSIEMBEDDINGSITEWINDOW 308 NS_DECL_NSIWEBBROWSERCHROMEFOCUS 309 NS_DECL_NSIINTERFACEREQUESTOR 310 NS_DECL_NSIWINDOWPROVIDER 311 NS_DECL_NSITABCHILD 312 NS_DECL_NSIOBSERVER 313 NS_DECL_NSITOOLTIPLISTENER 314 315 FORWARD_SHMEM_ALLOCATOR_TO(PBrowserChild) 316 317 /** 318 * MessageManagerCallback methods that we override. 319 */ 320 virtual bool DoSendBlockingMessage(JSContext* aCx, 321 const nsAString& aMessage, 322 StructuredCloneData& aData, 323 JS::Handle<JSObject *> aCpows, 324 nsIPrincipal* aPrincipal, 325 nsTArray<StructuredCloneData>* aRetVal, 326 bool aIsSync) override; 327 328 virtual nsresult DoSendAsyncMessage(JSContext* aCx, 329 const nsAString& aMessage, 330 StructuredCloneData& aData, 331 JS::Handle<JSObject *> aCpows, 332 nsIPrincipal* aPrincipal) override; 333 334 virtual bool 335 DoUpdateZoomConstraints(const uint32_t& aPresShellId, 336 const ViewID& aViewId, 337 const Maybe<ZoomConstraints>& aConstraints) override; 338 339 virtual bool RecvLoadURL(const nsCString& aURI, 340 const ShowInfo& aInfo) override; 341 virtual bool 342 RecvShow(const ScreenIntSize& aSize, 343 const ShowInfo& aInfo, 344 const TextureFactoryIdentifier& aTextureFactoryIdentifier, 345 const uint64_t& aLayersId, 346 PRenderFrameChild* aRenderFrame, 347 const bool& aParentIsActive, 348 const nsSizeMode& aSizeMode) override; 349 350 virtual bool 351 RecvUpdateDimensions(const CSSRect& aRect, 352 const CSSSize& aSize, 353 const ScreenOrientationInternal& aOrientation, 354 const LayoutDeviceIntPoint& aClientOffset, 355 const LayoutDeviceIntPoint& aChromeDisp) override; 356 virtual bool 357 RecvSizeModeChanged(const nsSizeMode& aSizeMode) override; 358 359 virtual bool RecvActivate() override; 360 361 virtual bool RecvDeactivate() override; 362 363 virtual bool RecvMouseEvent(const nsString& aType, 364 const float& aX, 365 const float& aY, 366 const int32_t& aButton, 367 const int32_t& aClickCount, 368 const int32_t& aModifiers, 369 const bool& aIgnoreRootScrollFrame) override; 370 371 virtual bool RecvRealMouseMoveEvent(const mozilla::WidgetMouseEvent& aEvent, 372 const ScrollableLayerGuid& aGuid, 373 const uint64_t& aInputBlockId) override; 374 375 virtual bool RecvSynthMouseMoveEvent(const mozilla::WidgetMouseEvent& aEvent, 376 const ScrollableLayerGuid& aGuid, 377 const uint64_t& aInputBlockId) override; 378 379 virtual bool RecvRealMouseButtonEvent(const mozilla::WidgetMouseEvent& aEvent, 380 const ScrollableLayerGuid& aGuid, 381 const uint64_t& aInputBlockId) override; 382 383 virtual bool RecvRealDragEvent(const WidgetDragEvent& aEvent, 384 const uint32_t& aDragAction, 385 const uint32_t& aDropEffect) override; 386 387 virtual bool 388 RecvRealKeyEvent(const mozilla::WidgetKeyboardEvent& aEvent, 389 const MaybeNativeKeyBinding& aBindings) override; 390 391 virtual bool RecvMouseWheelEvent(const mozilla::WidgetWheelEvent& aEvent, 392 const ScrollableLayerGuid& aGuid, 393 const uint64_t& aInputBlockId) override; 394 395 virtual bool RecvRealTouchEvent(const WidgetTouchEvent& aEvent, 396 const ScrollableLayerGuid& aGuid, 397 const uint64_t& aInputBlockId, 398 const nsEventStatus& aApzResponse) override; 399 400 virtual bool 401 RecvRealTouchMoveEvent(const WidgetTouchEvent& aEvent, 402 const ScrollableLayerGuid& aGuid, 403 const uint64_t& aInputBlockId, 404 const nsEventStatus& aApzResponse) override; 405 406 virtual bool RecvKeyEvent(const nsString& aType, 407 const int32_t& aKeyCode, 408 const int32_t& aCharCode, 409 const int32_t& aModifiers, 410 const bool& aPreventDefault) override; 411 412 virtual bool RecvNativeSynthesisResponse(const uint64_t& aObserverId, 413 const nsCString& aResponse) override; 414 415 virtual bool RecvPluginEvent(const WidgetPluginEvent& aEvent) override; 416 417 virtual bool 418 RecvCompositionEvent(const mozilla::WidgetCompositionEvent& aEvent) override; 419 420 virtual bool 421 RecvSelectionEvent(const mozilla::WidgetSelectionEvent& aEvent) override; 422 423 virtual bool 424 RecvPasteTransferable(const IPCDataTransfer& aDataTransfer, 425 const bool& aIsPrivateData, 426 const IPC::Principal& aRequestingPrincipal) override; 427 428 virtual bool 429 RecvActivateFrameEvent(const nsString& aType, const bool& aCapture) override; 430 431 virtual bool RecvLoadRemoteScript(const nsString& aURL, 432 const bool& aRunInGlobalScope) override; 433 434 virtual bool RecvAsyncMessage(const nsString& aMessage, 435 InfallibleTArray<CpowEntry>&& aCpows, 436 const IPC::Principal& aPrincipal, 437 const ClonedMessageData& aData) override; 438 439 virtual bool 440 RecvSwappedWithOtherRemoteLoader(const IPCTabContext& aContext) override; 441 442 virtual PDocAccessibleChild* 443 AllocPDocAccessibleChild(PDocAccessibleChild*, const uint64_t&, 444 const uint32_t&, const IAccessibleHolder&) override; 445 446 virtual bool DeallocPDocAccessibleChild(PDocAccessibleChild*) override; 447 448 virtual PColorPickerChild* 449 AllocPColorPickerChild(const nsString& aTitle, 450 const nsString& aInitialColor) override; 451 452 virtual bool DeallocPColorPickerChild(PColorPickerChild* aActor) override; 453 454 virtual PDatePickerChild* 455 AllocPDatePickerChild(const nsString& title, const nsString& initialDate) override; 456 virtual bool DeallocPDatePickerChild(PDatePickerChild* actor) override; 457 458 virtual PFilePickerChild* 459 AllocPFilePickerChild(const nsString& aTitle, const int16_t& aMode) override; 460 461 virtual bool 462 DeallocPFilePickerChild(PFilePickerChild* aActor) override; 463 464 virtual PIndexedDBPermissionRequestChild* 465 AllocPIndexedDBPermissionRequestChild(const Principal& aPrincipal) override; 466 467 virtual bool 468 DeallocPIndexedDBPermissionRequestChild(PIndexedDBPermissionRequestChild* aActor) override; 469 WebNavigation()470 virtual nsIWebNavigation* WebNavigation() const override 471 { 472 return mWebNav; 473 } 474 WebWidget()475 virtual PuppetWidget* WebWidget() override { return mPuppetWidget; } 476 477 /** Return the DPI of the widget this TabChild draws to. */ 478 void GetDPI(float* aDPI); 479 480 void GetDefaultScale(double *aScale); 481 482 void GetWidgetRounding(int32_t* aRounding); 483 IsTransparent()484 bool IsTransparent() const { return mIsTransparent; } 485 486 void GetMaxTouchPoints(uint32_t* aTouchPoints); 487 GetOrientation()488 ScreenOrientationInternal GetOrientation() const { return mOrientation; } 489 490 void SetBackgroundColor(const nscolor& aColor); 491 492 void NotifyPainted(); 493 494 void RequestNativeKeyBindings(mozilla::widget::AutoCacheNativeKeyCommands* aAutoCache, 495 const WidgetKeyboardEvent* aEvent); 496 497 /** 498 * Signal to this TabChild that it should be made visible: 499 * activated widget, retained layer tree, etc. (Respectively, 500 * made not visible.) 501 */ 502 void MakeVisible(); 503 void MakeHidden(); 504 Manager()505 nsIContentChild* Manager() const { return mManager; } 506 507 static inline TabChild* GetFrom(nsIDocShell * aDocShell)508 GetFrom(nsIDocShell* aDocShell) 509 { 510 if (!aDocShell) { 511 return nullptr; 512 } 513 514 nsCOMPtr<nsITabChild> tc = aDocShell->GetTabChild(); 515 return static_cast<TabChild*>(tc.get()); 516 } 517 518 static inline TabChild* GetFrom(mozIDOMWindow * aWindow)519 GetFrom(mozIDOMWindow* aWindow) 520 { 521 nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow); 522 nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(webNav); 523 return GetFrom(docShell); 524 } 525 526 static inline TabChild* GetFrom(mozIDOMWindowProxy * aWindow)527 GetFrom(mozIDOMWindowProxy* aWindow) 528 { 529 nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow); 530 nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(webNav); 531 return GetFrom(docShell); 532 } 533 534 static TabChild* GetFrom(nsIPresShell* aPresShell); 535 static TabChild* GetFrom(uint64_t aLayersId); 536 LayersId()537 uint64_t LayersId() { return mLayersId; } 538 539 void DidComposite(uint64_t aTransactionId, 540 const TimeStamp& aCompositeStart, 541 const TimeStamp& aCompositeEnd); 542 543 void DidRequestComposite(const TimeStamp& aCompositeReqStart, 544 const TimeStamp& aCompositeReqEnd); 545 546 void ClearCachedResources(); 547 void InvalidateLayers(); 548 void ReinitRendering(); 549 void CompositorUpdated(const TextureFactoryIdentifier& aNewIdentifier); 550 GetFrom(nsIDOMWindow * aWindow)551 static inline TabChild* GetFrom(nsIDOMWindow* aWindow) 552 { 553 nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow); 554 nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(webNav); 555 return GetFrom(docShell); 556 } 557 558 virtual bool RecvUIResolutionChanged(const float& aDpi, 559 const int32_t& aRounding, 560 const double& aScale) override; 561 562 virtual bool 563 RecvThemeChanged(nsTArray<LookAndFeelInt>&& aLookAndFeelIntCache) override; 564 565 virtual bool RecvHandleAccessKey(const WidgetKeyboardEvent& aEvent, 566 nsTArray<uint32_t>&& aCharCodes, 567 const int32_t& aModifierMask) override; 568 569 virtual bool RecvAudioChannelChangeNotification(const uint32_t& aAudioChannel, 570 const float& aVolume, 571 const bool& aMuted) override; 572 573 virtual bool RecvSetUseGlobalHistory(const bool& aUse) override; 574 575 virtual bool RecvHandledWindowedPluginKeyEvent( 576 const mozilla::NativeEventData& aKeyEventData, 577 const bool& aIsConsumed) override; 578 579 virtual bool RecvPrint(const uint64_t& aOuterWindowID, 580 const PrintData& aPrintData) override; 581 582 virtual bool RecvUpdateNativeWindowHandle(const uintptr_t& aNewHandle) override; 583 584 /** 585 * Native widget remoting protocol for use with windowed plugins with e10s. 586 */ 587 PPluginWidgetChild* AllocPPluginWidgetChild() override; 588 589 bool DeallocPPluginWidgetChild(PPluginWidgetChild* aActor) override; 590 591 nsresult CreatePluginWidget(nsIWidget* aParent, nsIWidget** aOut); 592 GetClientOffset()593 LayoutDeviceIntPoint GetClientOffset() const { return mClientOffset; } GetChromeDisplacement()594 LayoutDeviceIntPoint GetChromeDisplacement() const { return mChromeDisp; }; 595 IPCOpen()596 bool IPCOpen() const { return mIPCOpen; } 597 ParentIsActive()598 bool ParentIsActive() const 599 { 600 return mParentIsActive; 601 } 602 AsyncPanZoomEnabled()603 bool AsyncPanZoomEnabled() const { return mAsyncPanZoomEnabled; } 604 605 virtual ScreenIntSize GetInnerSize() override; 606 607 // Call RecvShow(nsIntSize(0, 0)) and block future calls to RecvShow(). 608 void DoFakeShow(const TextureFactoryIdentifier& aTextureFactoryIdentifier, 609 const uint64_t& aLayersId, 610 PRenderFrameChild* aRenderFrame, 611 const ShowInfo& aShowInfo); 612 613 void ContentReceivedInputBlock(const ScrollableLayerGuid& aGuid, 614 uint64_t aInputBlockId, 615 bool aPreventDefault) const; 616 void SetTargetAPZC(uint64_t aInputBlockId, 617 const nsTArray<ScrollableLayerGuid>& aTargets) const; 618 bool RecvHandleTap(const layers::GeckoContentController::TapType& aType, 619 const LayoutDevicePoint& aPoint, 620 const Modifiers& aModifiers, 621 const ScrollableLayerGuid& aGuid, 622 const uint64_t& aInputBlockId) override; 623 void SetAllowedTouchBehavior(uint64_t aInputBlockId, 624 const nsTArray<TouchBehaviorFlags>& aFlags) const; 625 626 bool UpdateFrame(const FrameMetrics& aFrameMetrics); 627 bool NotifyAPZStateChange(const ViewID& aViewId, 628 const layers::GeckoContentController::APZStateChange& aChange, 629 const int& aArg); 630 void StartScrollbarDrag(const layers::AsyncDragMetrics& aDragMetrics); 631 void ZoomToRect(const uint32_t& aPresShellId, 632 const FrameMetrics::ViewID& aViewId, 633 const CSSRect& aRect, 634 const uint32_t& aFlags); 635 636 // Request that the docshell be marked as active. 637 void ForcePaint(uint64_t aLayerObserverEpoch); 638 639 #if defined(XP_WIN) && defined(ACCESSIBILITY) GetNativeWindowHandle()640 uintptr_t GetNativeWindowHandle() const { return mNativeWindowHandle; } 641 #endif 642 TakeIsFreshProcess()643 bool TakeIsFreshProcess() 644 { 645 bool wasFreshProcess = mIsFreshProcess; 646 mIsFreshProcess = false; 647 return wasFreshProcess; 648 } 649 650 protected: 651 virtual ~TabChild(); 652 653 virtual PRenderFrameChild* AllocPRenderFrameChild() override; 654 655 virtual bool DeallocPRenderFrameChild(PRenderFrameChild* aFrame) override; 656 657 virtual bool RecvDestroy() override; 658 659 virtual bool RecvSetDocShellIsActive(const bool& aIsActive, 660 const bool& aIsHidden, 661 const uint64_t& aLayerObserverEpoch) override; 662 663 virtual bool RecvNavigateByKey(const bool& aForward, 664 const bool& aForDocumentNavigation) override; 665 666 virtual bool RecvRequestNotifyAfterRemotePaint() override; 667 668 virtual bool RecvSuppressDisplayport(const bool& aEnabled) override; 669 670 virtual bool RecvParentActivated(const bool& aActivated) override; 671 672 virtual bool RecvSetKeyboardIndicators(const UIStateChangeType& aShowAccelerators, 673 const UIStateChangeType& aShowFocusRings) override; 674 675 virtual bool RecvStopIMEStateManagement() override; 676 677 virtual bool RecvMenuKeyboardListenerInstalled( 678 const bool& aInstalled) override; 679 680 virtual bool RecvNotifyAttachGroupedSessionHistory(const uint32_t& aOffset) override; 681 682 virtual bool RecvNotifyPartialSessionHistoryActive(const uint32_t& aGlobalLength, 683 const uint32_t& aTargetLocalIndex) override; 684 685 virtual bool RecvNotifyPartialSessionHistoryDeactive() override; 686 687 virtual bool RecvSetFreshProcess() override; 688 689 private: 690 void HandleDoubleTap(const CSSPoint& aPoint, const Modifiers& aModifiers, 691 const ScrollableLayerGuid& aGuid); 692 693 // Notify others that our TabContext has been updated. 694 // 695 // You should call this after calling TabContext::SetTabContext(). We also 696 // call this during Init(). 697 // 698 // @param aIsPreallocated true if this is called for Preallocated Tab. 699 void NotifyTabContextUpdated(bool aIsPreallocated); 700 701 // Update the frameType on our docshell. 702 void UpdateFrameType(); 703 704 void ActorDestroy(ActorDestroyReason why) override; 705 706 enum FrameScriptLoading { DONT_LOAD_SCRIPTS, DEFAULT_LOAD_SCRIPTS }; 707 708 bool InitTabChildGlobal(FrameScriptLoading aScriptLoading = DEFAULT_LOAD_SCRIPTS); 709 710 bool InitRenderingState(const TextureFactoryIdentifier& aTextureFactoryIdentifier, 711 const uint64_t& aLayersId, 712 PRenderFrameChild* aRenderFrame); 713 714 void DestroyWindow(); 715 716 void SetProcessNameToAppName(); 717 718 void ApplyShowInfo(const ShowInfo& aInfo); 719 720 bool HasValidInnerSize(); 721 722 void SetTabId(const TabId& aTabId); 723 724 ScreenIntRect GetOuterRect(); 725 SetUnscaledInnerSize(const CSSSize & aSize)726 void SetUnscaledInnerSize(const CSSSize& aSize) 727 { 728 mUnscaledInnerSize = aSize; 729 } 730 731 class DelayedDeleteRunnable; 732 733 TextureFactoryIdentifier mTextureFactoryIdentifier; 734 nsCOMPtr<nsIWebNavigation> mWebNav; 735 RefPtr<PuppetWidget> mPuppetWidget; 736 nsCOMPtr<nsIURI> mLastURI; 737 RenderFrameChild* mRemoteFrame; 738 RefPtr<nsIContentChild> mManager; 739 RefPtr<TabChildSHistoryListener> mHistoryListener; 740 uint32_t mChromeFlags; 741 int32_t mActiveSuppressDisplayport; 742 uint64_t mLayersId; 743 CSSRect mUnscaledOuterRect; 744 nscolor mLastBackgroundColor; 745 bool mDidFakeShow; 746 bool mNotified; 747 bool mTriedBrowserInit; 748 ScreenOrientationInternal mOrientation; 749 750 bool mIgnoreKeyPressEvent; 751 RefPtr<APZEventState> mAPZEventState; 752 SetAllowedTouchBehaviorCallback mSetAllowedTouchBehaviorCallback; 753 bool mHasValidInnerSize; 754 bool mDestroyed; 755 // Position of client area relative to the outer window 756 LayoutDeviceIntPoint mClientOffset; 757 // Position of tab, relative to parent widget (typically the window) 758 LayoutDeviceIntPoint mChromeDisp; 759 TabId mUniqueId; 760 761 friend class ContentChild; 762 float mDPI; 763 int32_t mRounding; 764 double mDefaultScale; 765 766 bool mIsTransparent; 767 768 bool mIPCOpen; 769 bool mParentIsActive; 770 bool mAsyncPanZoomEnabled; 771 CSSSize mUnscaledInnerSize; 772 bool mDidSetRealShowInfo; 773 bool mDidLoadURLInit; 774 bool mIsFreshProcess; 775 776 AutoTArray<bool, NUMBER_OF_AUDIO_CHANNELS> mAudioChannelsActive; 777 778 RefPtr<layers::IAPZCTreeManager> mApzcTreeManager; 779 // APZChild clears this pointer from its destructor, so it shouldn't be a 780 // dangling pointer. 781 layers::APZChild* mAPZChild; 782 783 // The most recently seen layer observer epoch in RecvSetDocShellIsActive. 784 uint64_t mLayerObserverEpoch; 785 786 #if defined(XP_WIN) && defined(ACCESSIBILITY) 787 // The handle associated with the native window that contains this tab 788 uintptr_t mNativeWindowHandle; 789 #endif // defined(XP_WIN) 790 791 DISALLOW_EVIL_CONSTRUCTORS(TabChild); 792 }; 793 794 } // namespace dom 795 } // namespace mozilla 796 797 #endif // mozilla_dom_TabChild_h 798