gfx/layers/client/ClientContainerLayer.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0 2 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef GFX_CLIENTCONTAINERLAYER_H
michael@0 7 #define GFX_CLIENTCONTAINERLAYER_H
michael@0 8
michael@0 9 #include <stdint.h> // for uint32_t
michael@0 10 #include "ClientLayerManager.h" // for ClientLayerManager, etc
michael@0 11 #include "Layers.h" // for Layer, ContainerLayer, etc
michael@0 12 #include "gfxPrefs.h" // for gfxPrefs
michael@0 13 #include "nsDebug.h" // for NS_ASSERTION
michael@0 14 #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
michael@0 15 #include "nsISupportsUtils.h" // for NS_ADDREF, NS_RELEASE
michael@0 16 #include "nsRegion.h" // for nsIntRegion
michael@0 17 #include "nsTArray.h" // for nsAutoTArray
michael@0 18
michael@0 19 namespace mozilla {
michael@0 20 namespace layers {
michael@0 21
michael@0 22 class ShadowableLayer;
michael@0 23
michael@0 24 class ClientContainerLayer : public ContainerLayer,
michael@0 25 public ClientLayer
michael@0 26 {
michael@0 27 public:
michael@0 28 ClientContainerLayer(ClientLayerManager* aManager) :
michael@0 29 ContainerLayer(aManager,
michael@0 30 static_cast<ClientLayer*>(MOZ_THIS_IN_INITIALIZER_LIST()))
michael@0 31 {
michael@0 32 MOZ_COUNT_CTOR(ClientContainerLayer);
michael@0 33 mSupportsComponentAlphaChildren = true;
michael@0 34 }
michael@0 35 virtual ~ClientContainerLayer()
michael@0 36 {
michael@0 37 while (mFirstChild) {
michael@0 38 ContainerLayer::RemoveChild(mFirstChild);
michael@0 39 }
michael@0 40
michael@0 41 MOZ_COUNT_DTOR(ClientContainerLayer);
michael@0 42 }
michael@0 43
michael@0 44 virtual void RenderLayer()
michael@0 45 {
michael@0 46 if (GetMaskLayer()) {
michael@0 47 ToClientLayer(GetMaskLayer())->RenderLayer();
michael@0 48 }
michael@0 49
michael@0 50 // Setup mSupportsComponentAlphaChildren in the same way
michael@0 51 // that ContainerLayerComposite will do.
michael@0 52 if (UseIntermediateSurface()) {
michael@0 53 if (GetEffectiveVisibleRegion().GetNumRects() != 1 ||
michael@0 54 !(GetContentFlags() & Layer::CONTENT_OPAQUE))
michael@0 55 {
michael@0 56 gfx::Matrix transform;
michael@0 57 if (HasOpaqueAncestorLayer(this) &&
michael@0 58 GetEffectiveTransform().Is2D(&transform) &&
michael@0 59 !gfx::ThebesMatrix(transform).HasNonIntegerTranslation()) {
michael@0 60 SetSupportsComponentAlphaChildren(
michael@0 61 gfxPrefs::ComponentAlphaEnabled());
michael@0 62 }
michael@0 63 }
michael@0 64 } else {
michael@0 65 SetSupportsComponentAlphaChildren(
michael@0 66 (GetContentFlags() & Layer::CONTENT_OPAQUE) ||
michael@0 67 (GetParent() && GetParent()->SupportsComponentAlphaChildren()));
michael@0 68 }
michael@0 69
michael@0 70 nsAutoTArray<Layer*, 12> children;
michael@0 71 SortChildrenBy3DZOrder(children);
michael@0 72
michael@0 73 for (uint32_t i = 0; i < children.Length(); i++) {
michael@0 74 Layer* child = children.ElementAt(i);
michael@0 75 if (child->GetEffectiveVisibleRegion().IsEmpty()) {
michael@0 76 continue;
michael@0 77 }
michael@0 78
michael@0 79 ToClientLayer(child)->RenderLayer();
michael@0 80
michael@0 81 if (!ClientManager()->GetRepeatTransaction() &&
michael@0 82 !child->GetInvalidRegion().IsEmpty()) {
michael@0 83 child->Mutated();
michael@0 84 }
michael@0 85 }
michael@0 86 }
michael@0 87
michael@0 88 virtual void SetVisibleRegion(const nsIntRegion& aRegion)
michael@0 89 {
michael@0 90 NS_ASSERTION(ClientManager()->InConstruction(),
michael@0 91 "Can only set properties in construction phase");
michael@0 92 ContainerLayer::SetVisibleRegion(aRegion);
michael@0 93 }
michael@0 94 virtual bool InsertAfter(Layer* aChild, Layer* aAfter) MOZ_OVERRIDE
michael@0 95 {
michael@0 96 if(!ClientManager()->InConstruction()) {
michael@0 97 NS_ERROR("Can only set properties in construction phase");
michael@0 98 return false;
michael@0 99 }
michael@0 100
michael@0 101 if (!ContainerLayer::InsertAfter(aChild, aAfter)) {
michael@0 102 return false;
michael@0 103 }
michael@0 104
michael@0 105 ClientManager()->AsShadowForwarder()->InsertAfter(ClientManager()->Hold(this),
michael@0 106 ClientManager()->Hold(aChild),
michael@0 107 aAfter ? ClientManager()->Hold(aAfter) : nullptr);
michael@0 108 return true;
michael@0 109 }
michael@0 110
michael@0 111 virtual bool RemoveChild(Layer* aChild) MOZ_OVERRIDE
michael@0 112 {
michael@0 113 if (!ClientManager()->InConstruction()) {
michael@0 114 NS_ERROR("Can only set properties in construction phase");
michael@0 115 return false;
michael@0 116 }
michael@0 117 // hold on to aChild before we remove it!
michael@0 118 ShadowableLayer *heldChild = ClientManager()->Hold(aChild);
michael@0 119 if (!ContainerLayer::RemoveChild(aChild)) {
michael@0 120 return false;
michael@0 121 }
michael@0 122 ClientManager()->AsShadowForwarder()->RemoveChild(ClientManager()->Hold(this), heldChild);
michael@0 123 return true;
michael@0 124 }
michael@0 125
michael@0 126 virtual bool RepositionChild(Layer* aChild, Layer* aAfter) MOZ_OVERRIDE
michael@0 127 {
michael@0 128 if (!ClientManager()->InConstruction()) {
michael@0 129 NS_ERROR("Can only set properties in construction phase");
michael@0 130 return false;
michael@0 131 }
michael@0 132 if (!ContainerLayer::RepositionChild(aChild, aAfter)) {
michael@0 133 return false;
michael@0 134 }
michael@0 135 ClientManager()->AsShadowForwarder()->RepositionChild(ClientManager()->Hold(this),
michael@0 136 ClientManager()->Hold(aChild),
michael@0 137 aAfter ? ClientManager()->Hold(aAfter) : nullptr);
michael@0 138 return true;
michael@0 139 }
michael@0 140
michael@0 141 virtual Layer* AsLayer() { return this; }
michael@0 142 virtual ShadowableLayer* AsShadowableLayer() { return this; }
michael@0 143
michael@0 144 virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface)
michael@0 145 {
michael@0 146 DefaultComputeEffectiveTransforms(aTransformToSurface);
michael@0 147 }
michael@0 148
michael@0 149 void ForceIntermediateSurface() { mUseIntermediateSurface = true; }
michael@0 150
michael@0 151 void SetSupportsComponentAlphaChildren(bool aSupports) { mSupportsComponentAlphaChildren = aSupports; }
michael@0 152
michael@0 153 protected:
michael@0 154 ClientLayerManager* ClientManager()
michael@0 155 {
michael@0 156 return static_cast<ClientLayerManager*>(mManager);
michael@0 157 }
michael@0 158 };
michael@0 159
michael@0 160 class ClientRefLayer : public RefLayer,
michael@0 161 public ClientLayer {
michael@0 162 public:
michael@0 163 ClientRefLayer(ClientLayerManager* aManager) :
michael@0 164 RefLayer(aManager,
michael@0 165 static_cast<ClientLayer*>(MOZ_THIS_IN_INITIALIZER_LIST()))
michael@0 166 {
michael@0 167 MOZ_COUNT_CTOR(ClientRefLayer);
michael@0 168 }
michael@0 169 virtual ~ClientRefLayer()
michael@0 170 {
michael@0 171 MOZ_COUNT_DTOR(ClientRefLayer);
michael@0 172 }
michael@0 173
michael@0 174 virtual Layer* AsLayer() { return this; }
michael@0 175 virtual ShadowableLayer* AsShadowableLayer() { return this; }
michael@0 176
michael@0 177 virtual void Disconnect()
michael@0 178 {
michael@0 179 ClientLayer::Disconnect();
michael@0 180 }
michael@0 181
michael@0 182 virtual void RenderLayer() { }
michael@0 183
michael@0 184 virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface)
michael@0 185 {
michael@0 186 DefaultComputeEffectiveTransforms(aTransformToSurface);
michael@0 187 }
michael@0 188
michael@0 189 private:
michael@0 190 ClientLayerManager* ClientManager()
michael@0 191 {
michael@0 192 return static_cast<ClientLayerManager*>(mManager);
michael@0 193 }
michael@0 194 };
michael@0 195
michael@0 196 }
michael@0 197 }
michael@0 198
michael@0 199 #endif

mercurial