RenderFrameParent.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2. * vim: sw=2 ts=8 et :
  3. */
  4. /* This Source Code Form is subject to the terms of the Mozilla Public
  5. * License, v. 2.0. If a copy of the MPL was not distributed with this
  6. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  7. #ifndef mozilla_layout_RenderFrameParent_h
  8. #define mozilla_layout_RenderFrameParent_h
  9. #include "mozilla/Attributes.h"
  10. #include <map>
  11. #include "mozilla/layers/APZUtils.h"
  12. #include "mozilla/layers/LayersTypes.h"
  13. #include "mozilla/layout/PRenderFrameParent.h"
  14. #include "nsDisplayList.h"
  15. class nsFrameLoader;
  16. class nsSubDocumentFrame;
  17. namespace mozilla {
  18. class InputEvent;
  19. namespace layers {
  20. class AsyncDragMetrics;
  21. class TargetConfig;
  22. struct TextureFactoryIdentifier;
  23. struct ScrollableLayerGuid;
  24. } // namespace layers
  25. namespace layout {
  26. class RenderFrameParent : public PRenderFrameParent
  27. {
  28. typedef mozilla::layers::AsyncDragMetrics AsyncDragMetrics;
  29. typedef mozilla::layers::FrameMetrics FrameMetrics;
  30. typedef mozilla::layers::ContainerLayer ContainerLayer;
  31. typedef mozilla::layers::Layer Layer;
  32. typedef mozilla::layers::LayerManager LayerManager;
  33. typedef mozilla::layers::TargetConfig TargetConfig;
  34. typedef mozilla::ContainerLayerParameters ContainerLayerParameters;
  35. typedef mozilla::layers::TextureFactoryIdentifier TextureFactoryIdentifier;
  36. typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid;
  37. typedef mozilla::layers::TouchBehaviorFlags TouchBehaviorFlags;
  38. typedef mozilla::layers::ZoomConstraints ZoomConstraints;
  39. typedef FrameMetrics::ViewID ViewID;
  40. public:
  41. /**
  42. * Select the desired scrolling behavior. If ASYNC_PAN_ZOOM is
  43. * chosen, then RenderFrameParent will watch input events and use
  44. * them to asynchronously pan and zoom.
  45. */
  46. RenderFrameParent(nsFrameLoader* aFrameLoader, bool* aSuccess);
  47. virtual ~RenderFrameParent();
  48. bool Init(nsFrameLoader* aFrameLoader);
  49. bool IsInitted();
  50. void Destroy();
  51. void BuildDisplayList(nsDisplayListBuilder* aBuilder,
  52. nsSubDocumentFrame* aFrame,
  53. const nsDisplayListSet& aLists);
  54. already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
  55. nsIFrame* aFrame,
  56. LayerManager* aManager,
  57. const nsIntRect& aVisibleRect,
  58. nsDisplayItem* aItem,
  59. const ContainerLayerParameters& aContainerParameters);
  60. void OwnerContentChanged(nsIContent* aContent);
  61. bool HitTest(const nsRect& aRect);
  62. void GetTextureFactoryIdentifier(TextureFactoryIdentifier* aTextureFactoryIdentifier);
  63. inline uint64_t GetLayersId() { return mLayersId; }
  64. void TakeFocusForClickFromTap();
  65. void EnsureLayersConnected();
  66. protected:
  67. void ActorDestroy(ActorDestroyReason why) override;
  68. virtual bool RecvNotifyCompositorTransaction() override;
  69. private:
  70. void TriggerRepaint();
  71. void DispatchEventForPanZoomController(const InputEvent& aEvent);
  72. uint64_t GetLayerTreeId() const;
  73. // When our child frame is pushing transactions directly to the
  74. // compositor, this is the ID of its layer tree in the compositor's
  75. // context.
  76. uint64_t mLayersId;
  77. RefPtr<nsFrameLoader> mFrameLoader;
  78. RefPtr<ContainerLayer> mContainer;
  79. // True after Destroy() has been called, which is triggered
  80. // originally by nsFrameLoader::Destroy(). After this point, we can
  81. // no longer safely ask the frame loader to find its nearest layer
  82. // manager, because it may have been disconnected from the DOM.
  83. // It's still OK to *tell* the frame loader that we've painted after
  84. // it's destroyed; it'll just ignore us, and we won't be able to
  85. // find an nsIFrame to invalidate. See ShadowLayersUpdated().
  86. //
  87. // Prefer the extra bit of state to null'ing out mFrameLoader in
  88. // Destroy() so that less code needs to be special-cased for after
  89. // Destroy().
  90. //
  91. // It's possible for mFrameLoader==null and
  92. // mFrameLoaderDestroyed==false.
  93. bool mFrameLoaderDestroyed;
  94. bool mAsyncPanZoomEnabled;
  95. bool mInitted;
  96. };
  97. } // namespace layout
  98. } // namespace mozilla
  99. /**
  100. * A DisplayRemote exists solely to graft a child process's shadow
  101. * layer tree (for a given RenderFrameParent) into its parent
  102. * process's layer tree.
  103. */
  104. class nsDisplayRemote : public nsDisplayItem
  105. {
  106. typedef mozilla::layout::RenderFrameParent RenderFrameParent;
  107. public:
  108. nsDisplayRemote(nsDisplayListBuilder* aBuilder, nsSubDocumentFrame* aFrame,
  109. RenderFrameParent* aRemoteFrame);
  110. virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
  111. LayerManager* aManager,
  112. const ContainerLayerParameters& aParameters) override
  113. { return mozilla::LAYER_ACTIVE_FORCE; }
  114. virtual already_AddRefed<Layer>
  115. BuildLayer(nsDisplayListBuilder* aBuilder, LayerManager* aManager,
  116. const ContainerLayerParameters& aContainerParameters) override;
  117. NS_DISPLAY_DECL_NAME("Remote", TYPE_REMOTE)
  118. private:
  119. RenderFrameParent* mRemoteFrame;
  120. mozilla::layers::EventRegionsOverride mEventRegionsOverride;
  121. };
  122. #endif // mozilla_layout_RenderFrameParent_h