/work/obj-fuzz/dist/include/mozilla/layout/RenderFrameParent.h
Line | Count | Source (jump to first uncovered line) |
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_layout_RenderFrameParent_h |
8 | | #define mozilla_layout_RenderFrameParent_h |
9 | | |
10 | | #include "mozilla/Attributes.h" |
11 | | #include <map> |
12 | | |
13 | | #include "mozilla/layers/APZUtils.h" |
14 | | #include "mozilla/layers/CompositorOptions.h" |
15 | | #include "mozilla/layers/LayersTypes.h" |
16 | | #include "mozilla/layout/PRenderFrameParent.h" |
17 | | #include "nsDisplayList.h" |
18 | | |
19 | | class nsFrameLoader; |
20 | | class nsSubDocumentFrame; |
21 | | |
22 | | namespace mozilla { |
23 | | |
24 | | class InputEvent; |
25 | | |
26 | | namespace layers { |
27 | | class AsyncDragMetrics; |
28 | | class TargetConfig; |
29 | | struct TextureFactoryIdentifier; |
30 | | struct ScrollableLayerGuid; |
31 | | } // namespace layers |
32 | | |
33 | | namespace layout { |
34 | | |
35 | | class RenderFrameParent final : public PRenderFrameParent |
36 | | { |
37 | | typedef mozilla::layers::AsyncDragMetrics AsyncDragMetrics; |
38 | | typedef mozilla::layers::FrameMetrics FrameMetrics; |
39 | | typedef mozilla::layers::CompositorOptions CompositorOptions; |
40 | | typedef mozilla::layers::ContainerLayer ContainerLayer; |
41 | | typedef mozilla::layers::Layer Layer; |
42 | | typedef mozilla::layers::LayerManager LayerManager; |
43 | | typedef mozilla::layers::LayersId LayersId; |
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 nsDisplayListSet& aLists); |
70 | | |
71 | | already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder, |
72 | | nsIFrame* aFrame, |
73 | | LayerManager* aManager, |
74 | | nsDisplayItem* aItem, |
75 | | const ContainerLayerParameters& aContainerParameters); |
76 | | |
77 | | void OwnerContentChanged(nsIContent* aContent); |
78 | | |
79 | | bool HitTest(const nsRect& aRect); |
80 | | |
81 | | void GetTextureFactoryIdentifier(TextureFactoryIdentifier* aTextureFactoryIdentifier); |
82 | | |
83 | 0 | inline LayersId GetLayersId() const { return mLayersId; } |
84 | 0 | inline bool IsLayersConnected() const { return mLayersConnected; } |
85 | 0 | inline CompositorOptions GetCompositorOptions() const { return mCompositorOptions; } |
86 | | |
87 | | void TakeFocusForClickFromTap(); |
88 | | |
89 | | void EnsureLayersConnected(CompositorOptions* aCompositorOptions); |
90 | | |
91 | | LayerManager* AttachLayerManager(); |
92 | | |
93 | | protected: |
94 | | void ActorDestroy(ActorDestroyReason why) override; |
95 | | |
96 | | virtual mozilla::ipc::IPCResult RecvNotifyCompositorTransaction() override; |
97 | | |
98 | | private: |
99 | | void TriggerRepaint(); |
100 | | void DispatchEventForPanZoomController(const InputEvent& aEvent); |
101 | | |
102 | | // When our child frame is pushing transactions directly to the |
103 | | // compositor, this is the ID of its layer tree in the compositor's |
104 | | // context. |
105 | | LayersId mLayersId; |
106 | | // A flag that indicates whether or not the compositor knows about the |
107 | | // layers id. In some cases this RenderFrameParent is not connected to the |
108 | | // compositor and so this flag is false. |
109 | | bool mLayersConnected; |
110 | | // The compositor options for this layers id. This is only meaningful if |
111 | | // the compositor actually knows about this layers id (i.e. when mLayersConnected |
112 | | // is true). |
113 | | CompositorOptions mCompositorOptions; |
114 | | |
115 | | RefPtr<nsFrameLoader> mFrameLoader; |
116 | | RefPtr<ContainerLayer> mContainer; |
117 | | RefPtr<LayerManager> mLayerManager; |
118 | | |
119 | | // True after Destroy() has been called, which is triggered |
120 | | // originally by nsFrameLoader::Destroy(). After this point, we can |
121 | | // no longer safely ask the frame loader to find its nearest layer |
122 | | // manager, because it may have been disconnected from the DOM. |
123 | | // It's still OK to *tell* the frame loader that we've painted after |
124 | | // it's destroyed; it'll just ignore us, and we won't be able to |
125 | | // find an nsIFrame to invalidate. See ShadowLayersUpdated(). |
126 | | // |
127 | | // Prefer the extra bit of state to null'ing out mFrameLoader in |
128 | | // Destroy() so that less code needs to be special-cased for after |
129 | | // Destroy(). |
130 | | // |
131 | | // It's possible for mFrameLoader==null and |
132 | | // mFrameLoaderDestroyed==false. |
133 | | bool mFrameLoaderDestroyed; |
134 | | |
135 | | bool mAsyncPanZoomEnabled; |
136 | | bool mInitted; |
137 | | }; |
138 | | |
139 | | } // namespace layout |
140 | | } // namespace mozilla |
141 | | |
142 | | /** |
143 | | * A DisplayRemote exists solely to graft a child process's shadow |
144 | | * layer tree (for a given RenderFrameParent) into its parent |
145 | | * process's layer tree. |
146 | | */ |
147 | | class nsDisplayRemote final : public nsDisplayItem |
148 | | { |
149 | | typedef mozilla::layout::RenderFrameParent RenderFrameParent; |
150 | | |
151 | | public: |
152 | | nsDisplayRemote(nsDisplayListBuilder* aBuilder, |
153 | | nsSubDocumentFrame* aFrame); |
154 | | |
155 | | bool HasDeletedFrame() const override; |
156 | | |
157 | | LayerState GetLayerState(nsDisplayListBuilder* aBuilder, |
158 | | LayerManager* aManager, |
159 | | const ContainerLayerParameters& aParameters) override |
160 | | { |
161 | | return mozilla::LAYER_ACTIVE_FORCE; |
162 | | } |
163 | | |
164 | | already_AddRefed<Layer> |
165 | | BuildLayer(nsDisplayListBuilder* aBuilder, LayerManager* aManager, |
166 | | const ContainerLayerParameters& aContainerParameters) override; |
167 | | |
168 | | bool CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder, |
169 | | mozilla::wr::IpcResourceUpdateQueue& aResources, |
170 | | const StackingContextHelper& aSc, |
171 | | mozilla::layers::WebRenderLayerManager* aManager, |
172 | | nsDisplayListBuilder* aDisplayListBuilder) override; |
173 | | bool UpdateScrollData(mozilla::layers::WebRenderScrollData* aData, |
174 | | mozilla::layers::WebRenderLayerScrollData* aLayerData) override; |
175 | | |
176 | | NS_DISPLAY_DECL_NAME("Remote", TYPE_REMOTE) |
177 | | |
178 | | private: |
179 | | mozilla::layers::LayersId GetRemoteLayersId() const; |
180 | | RenderFrameParent* GetRenderFrameParent() const; |
181 | | |
182 | | mozilla::LayoutDeviceIntPoint mOffset; |
183 | | mozilla::layers::EventRegionsOverride mEventRegionsOverride; |
184 | | }; |
185 | | |
186 | | |
187 | | #endif // mozilla_layout_RenderFrameParent_h |