Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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/. */
8 #include "ShadowLayerParent.h"
9 #include "Layers.h" // for Layer, ContainerLayer
10 #include "nsDebug.h" // for NS_RUNTIMEABORT
11 #include "nsISupportsImpl.h" // for Layer::AddRef, etc
13 #include "mozilla/layers/ThebesLayerComposite.h"
14 #include "mozilla/layers/CanvasLayerComposite.h"
15 #include "mozilla/layers/ColorLayerComposite.h"
16 #include "mozilla/layers/ImageLayerComposite.h"
17 #include "mozilla/layers/ContainerLayerComposite.h"
19 namespace mozilla {
20 namespace layers {
22 ShadowLayerParent::ShadowLayerParent() : mLayer(nullptr)
23 {
24 }
26 ShadowLayerParent::~ShadowLayerParent()
27 {
28 }
30 void
31 ShadowLayerParent::Bind(Layer* layer)
32 {
33 mLayer = layer;
34 }
36 void
37 ShadowLayerParent::Destroy()
38 {
39 // It's possible for Destroy() to come in just after this has been
40 // created, but just before the transaction in which Bind() would
41 // have been called. In that case, we'll ignore shadow-layers
42 // transactions from there on and never get a layer here.
43 if (mLayer) {
44 mLayer->Disconnect();
45 }
46 }
48 ContainerLayerComposite*
49 ShadowLayerParent::AsContainerLayerComposite() const
50 {
51 return mLayer && mLayer->GetType() == Layer::TYPE_CONTAINER
52 ? static_cast<ContainerLayerComposite*>(mLayer.get())
53 : nullptr;
54 }
56 CanvasLayerComposite*
57 ShadowLayerParent::AsCanvasLayerComposite() const
58 {
59 return mLayer && mLayer->GetType() == Layer::TYPE_CANVAS
60 ? static_cast<CanvasLayerComposite*>(mLayer.get())
61 : nullptr;
62 }
64 ColorLayerComposite*
65 ShadowLayerParent::AsColorLayerComposite() const
66 {
67 return mLayer && mLayer->GetType() == Layer::TYPE_COLOR
68 ? static_cast<ColorLayerComposite*>(mLayer.get())
69 : nullptr;
70 }
72 ImageLayerComposite*
73 ShadowLayerParent::AsImageLayerComposite() const
74 {
75 return mLayer && mLayer->GetType() == Layer::TYPE_IMAGE
76 ? static_cast<ImageLayerComposite*>(mLayer.get())
77 : nullptr;
78 }
80 RefLayerComposite*
81 ShadowLayerParent::AsRefLayerComposite() const
82 {
83 return mLayer && mLayer->GetType() == Layer::TYPE_REF
84 ? static_cast<RefLayerComposite*>(mLayer.get())
85 : nullptr;
86 }
88 ThebesLayerComposite*
89 ShadowLayerParent::AsThebesLayerComposite() const
90 {
91 return mLayer && mLayer->GetType() == Layer::TYPE_THEBES
92 ? static_cast<ThebesLayerComposite*>(mLayer.get())
93 : nullptr;
94 }
96 void
97 ShadowLayerParent::ActorDestroy(ActorDestroyReason why)
98 {
99 switch (why) {
100 case AncestorDeletion:
101 NS_RUNTIMEABORT("shadow layer deleted out of order!");
102 return; // unreached
104 case Deletion:
105 // See comment near Destroy() above.
106 if (mLayer) {
107 mLayer->Disconnect();
108 }
109 break;
111 case AbnormalShutdown:
112 if (mLayer) {
113 mLayer->Disconnect();
114 }
115 break;
117 case NormalShutdown:
118 // let IPDL-generated code automatically clean up Shmems and so
119 // forth; our channel is disconnected anyway
120 break;
122 case FailedConstructor:
123 NS_RUNTIMEABORT("FailedConstructor isn't possible in PLayerTransaction");
124 return; // unreached
125 }
127 mLayer = nullptr;
128 }
130 } // namespace layers
131 } // namespace mozilla