Line data Source code
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 :
8 : #ifndef mozilla_layout_RenderFrameParent_h
9 : #define mozilla_layout_RenderFrameParent_h
10 :
11 : #include "mozilla/Attributes.h"
12 : #include <map>
13 :
14 : #include "mozilla/layers/APZUtils.h"
15 : #include "mozilla/layers/CompositorOptions.h"
16 : #include "mozilla/layers/LayersTypes.h"
17 : #include "mozilla/layout/PRenderFrameParent.h"
18 : #include "nsDisplayList.h"
19 :
20 : class nsFrameLoader;
21 : class nsSubDocumentFrame;
22 :
23 : namespace mozilla {
24 :
25 : class InputEvent;
26 :
27 : namespace layers {
28 : class AsyncDragMetrics;
29 : class TargetConfig;
30 : struct TextureFactoryIdentifier;
31 : struct ScrollableLayerGuid;
32 : } // namespace layers
33 :
34 : namespace layout {
35 :
36 : class RenderFrameParent : public PRenderFrameParent
37 : {
38 : typedef mozilla::layers::AsyncDragMetrics AsyncDragMetrics;
39 : typedef mozilla::layers::FrameMetrics FrameMetrics;
40 : typedef mozilla::layers::CompositorOptions CompositorOptions;
41 : typedef mozilla::layers::ContainerLayer ContainerLayer;
42 : typedef mozilla::layers::Layer Layer;
43 : typedef mozilla::layers::LayerManager LayerManager;
44 : typedef mozilla::layers::TargetConfig TargetConfig;
45 : typedef mozilla::ContainerLayerParameters ContainerLayerParameters;
46 : typedef mozilla::layers::TextureFactoryIdentifier TextureFactoryIdentifier;
47 : typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid;
48 : typedef mozilla::layers::TouchBehaviorFlags TouchBehaviorFlags;
49 : typedef mozilla::layers::ZoomConstraints ZoomConstraints;
50 : typedef FrameMetrics::ViewID ViewID;
51 :
52 : public:
53 :
54 :
55 : /**
56 : * Select the desired scrolling behavior. If ASYNC_PAN_ZOOM is
57 : * chosen, then RenderFrameParent will watch input events and use
58 : * them to asynchronously pan and zoom.
59 : */
60 : explicit RenderFrameParent(nsFrameLoader* aFrameLoader);
61 : virtual ~RenderFrameParent();
62 :
63 : bool Init(nsFrameLoader* aFrameLoader);
64 : bool IsInitted();
65 : void Destroy();
66 :
67 : void BuildDisplayList(nsDisplayListBuilder* aBuilder,
68 : nsSubDocumentFrame* aFrame,
69 : const nsRect& aDirtyRect,
70 : const nsDisplayListSet& aLists);
71 :
72 : already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
73 : nsIFrame* aFrame,
74 : LayerManager* aManager,
75 : const nsIntRect& aVisibleRect,
76 : nsDisplayItem* aItem,
77 : const ContainerLayerParameters& aContainerParameters);
78 :
79 : void OwnerContentChanged(nsIContent* aContent);
80 :
81 : bool HitTest(const nsRect& aRect);
82 :
83 : void GetTextureFactoryIdentifier(TextureFactoryIdentifier* aTextureFactoryIdentifier);
84 :
85 13 : inline uint64_t GetLayersId() const { return mLayersId; }
86 1 : inline bool IsLayersConnected() const { return mLayersConnected; }
87 1 : inline CompositorOptions GetCompositorOptions() const { return mCompositorOptions; }
88 :
89 : void TakeFocusForClickFromTap();
90 :
91 : void EnsureLayersConnected(CompositorOptions* aCompositorOptions);
92 :
93 : LayerManager* AttachLayerManager();
94 :
95 : protected:
96 : void ActorDestroy(ActorDestroyReason why) override;
97 :
98 : virtual mozilla::ipc::IPCResult RecvNotifyCompositorTransaction() override;
99 :
100 : private:
101 : void TriggerRepaint();
102 : void DispatchEventForPanZoomController(const InputEvent& aEvent);
103 :
104 : // When our child frame is pushing transactions directly to the
105 : // compositor, this is the ID of its layer tree in the compositor's
106 : // context.
107 : uint64_t mLayersId;
108 : // A flag that indicates whether or not the compositor knows about the
109 : // layers id. In some cases this RenderFrameParent is not connected to the
110 : // compositor and so this flag is false.
111 : bool mLayersConnected;
112 : // The compositor options for this layers id. This is only meaningful if
113 : // the compositor actually knows about this layers id (i.e. when mLayersConnected
114 : // is true).
115 : CompositorOptions mCompositorOptions;
116 :
117 : RefPtr<nsFrameLoader> mFrameLoader;
118 : RefPtr<ContainerLayer> mContainer;
119 : RefPtr<LayerManager> mLayerManager;
120 :
121 : // True after Destroy() has been called, which is triggered
122 : // originally by nsFrameLoader::Destroy(). After this point, we can
123 : // no longer safely ask the frame loader to find its nearest layer
124 : // manager, because it may have been disconnected from the DOM.
125 : // It's still OK to *tell* the frame loader that we've painted after
126 : // it's destroyed; it'll just ignore us, and we won't be able to
127 : // find an nsIFrame to invalidate. See ShadowLayersUpdated().
128 : //
129 : // Prefer the extra bit of state to null'ing out mFrameLoader in
130 : // Destroy() so that less code needs to be special-cased for after
131 : // Destroy().
132 : //
133 : // It's possible for mFrameLoader==null and
134 : // mFrameLoaderDestroyed==false.
135 : bool mFrameLoaderDestroyed;
136 :
137 : bool mAsyncPanZoomEnabled;
138 : bool mInitted;
139 : };
140 :
141 : } // namespace layout
142 : } // namespace mozilla
143 :
144 : /**
145 : * A DisplayRemote exists solely to graft a child process's shadow
146 : * layer tree (for a given RenderFrameParent) into its parent
147 : * process's layer tree.
148 : */
149 33 : class nsDisplayRemote : public nsDisplayItem
150 : {
151 : typedef mozilla::layout::RenderFrameParent RenderFrameParent;
152 :
153 : public:
154 : nsDisplayRemote(nsDisplayListBuilder* aBuilder, nsSubDocumentFrame* aFrame,
155 : RenderFrameParent* aRemoteFrame);
156 :
157 24 : virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
158 : LayerManager* aManager,
159 : const ContainerLayerParameters& aParameters) override
160 24 : { return mozilla::LAYER_ACTIVE_FORCE; }
161 :
162 : virtual already_AddRefed<Layer>
163 : BuildLayer(nsDisplayListBuilder* aBuilder, LayerManager* aManager,
164 : const ContainerLayerParameters& aContainerParameters) override;
165 :
166 233 : NS_DISPLAY_DECL_NAME("Remote", TYPE_REMOTE)
167 :
168 : private:
169 : RenderFrameParent* mRemoteFrame;
170 : mozilla::layers::EventRegionsOverride mEventRegionsOverride;
171 : };
172 :
173 :
174 : #endif // mozilla_layout_RenderFrameParent_h
|