Sat, 03 Jan 2015 20:18:00 +0100
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.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef GFX_BASICLAYERS_H
7 #define GFX_BASICLAYERS_H
9 #include <stdint.h> // for INT32_MAX, int32_t
10 #include "Layers.h" // for Layer (ptr only), etc
11 #include "gfxTypes.h"
12 #include "gfxCachedTempSurface.h" // for gfxCachedTempSurface
13 #include "gfxContext.h" // for gfxContext
14 #include "mozilla/Attributes.h" // for MOZ_OVERRIDE
15 #include "mozilla/WidgetUtils.h" // for ScreenRotation
16 #include "mozilla/layers/LayersTypes.h" // for BufferMode, LayersBackend, etc
17 #include "nsAString.h"
18 #include "nsAutoPtr.h" // for nsRefPtr
19 #include "nsCOMPtr.h" // for already_AddRefed
20 #include "nsISupportsImpl.h" // for gfxContext::AddRef, etc
21 #include "nsRegion.h" // for nsIntRegion
22 #include "nscore.h" // for nsAString, etc
24 class gfxPattern;
25 class nsIWidget;
27 namespace mozilla {
28 namespace layers {
30 class BasicShadowableLayer;
31 class ImageFactory;
32 class ImageLayer;
33 class PaintLayerContext;
34 class ReadbackLayer;
35 class ReadbackProcessor;
37 /**
38 * This is a cairo/Thebes-only, main-thread-only implementation of layers.
39 *
40 * In each transaction, the client sets up the layer tree and then during
41 * the drawing phase, each ThebesLayer is painted directly into the target
42 * context (with appropriate clipping and Push/PopGroups performed
43 * between layers).
44 */
45 class BasicLayerManager :
46 public LayerManager
47 {
48 public:
49 /**
50 * Construct a BasicLayerManager which will have no default
51 * target context. SetDefaultTarget or BeginTransactionWithTarget
52 * must be called for any rendering to happen. ThebesLayers will not
53 * be retained.
54 */
55 BasicLayerManager();
56 /**
57 * Construct a BasicLayerManager which will have no default
58 * target context. SetDefaultTarget or BeginTransactionWithTarget
59 * must be called for any rendering to happen. ThebesLayers will be
60 * retained; that is, we will try to retain the visible contents of
61 * ThebesLayers as cairo surfaces. We create ThebesLayer buffers by
62 * creating similar surfaces to the default target context, or to
63 * aWidget's GetThebesSurface if there is no default target context, or
64 * to the passed-in context if there is no widget and no default
65 * target context.
66 *
67 * This does not keep a strong reference to the widget, so the caller
68 * must ensure that the widget outlives the layer manager or call
69 * ClearWidget before the widget dies.
70 */
71 BasicLayerManager(nsIWidget* aWidget);
72 virtual ~BasicLayerManager();
74 /**
75 * Set the default target context that will be used when BeginTransaction
76 * is called. This can only be called outside a transaction.
77 *
78 * aDoubleBuffering can request double-buffering for drawing to the
79 * default target. When BUFFERED, the layer manager avoids blitting
80 * temporary results to aContext and then overpainting them with final
81 * results, by using a temporary buffer when necessary. In BUFFERED
82 * mode we always completely overwrite the contents of aContext's
83 * destination surface (within the clip region) using OPERATOR_SOURCE.
84 */
85 void SetDefaultTarget(gfxContext* aContext);
86 virtual void SetDefaultTargetConfiguration(BufferMode aDoubleBuffering, ScreenRotation aRotation);
87 gfxContext* GetDefaultTarget() { return mDefaultTarget; }
89 nsIWidget* GetRetainerWidget() { return mWidget; }
90 void ClearRetainerWidget() { mWidget = nullptr; }
92 virtual bool IsWidgetLayerManager() { return mWidget != nullptr; }
94 virtual void BeginTransaction();
95 virtual void BeginTransactionWithTarget(gfxContext* aTarget);
96 virtual bool EndEmptyTransaction(EndTransactionFlags aFlags = END_DEFAULT);
97 virtual void EndTransaction(DrawThebesLayerCallback aCallback,
98 void* aCallbackData,
99 EndTransactionFlags aFlags = END_DEFAULT);
100 virtual bool AreComponentAlphaLayersEnabled() { return !IsWidgetLayerManager(); }
102 void AbortTransaction();
104 virtual void SetRoot(Layer* aLayer);
106 virtual already_AddRefed<ThebesLayer> CreateThebesLayer();
107 virtual already_AddRefed<ContainerLayer> CreateContainerLayer();
108 virtual already_AddRefed<ImageLayer> CreateImageLayer();
109 virtual already_AddRefed<CanvasLayer> CreateCanvasLayer();
110 virtual already_AddRefed<ColorLayer> CreateColorLayer();
111 virtual already_AddRefed<ReadbackLayer> CreateReadbackLayer();
112 virtual ImageFactory *GetImageFactory();
114 virtual LayersBackend GetBackendType() { return LayersBackend::LAYERS_BASIC; }
115 virtual void GetBackendName(nsAString& name) { name.AssignLiteral("Basic"); }
117 bool InConstruction() { return mPhase == PHASE_CONSTRUCTION; }
118 #ifdef DEBUG
119 bool InDrawing() { return mPhase == PHASE_DRAWING; }
120 bool InForward() { return mPhase == PHASE_FORWARD; }
121 #endif
122 bool InTransaction() { return mPhase != PHASE_NONE; }
124 gfxContext* GetTarget() { return mTarget; }
125 void SetTarget(gfxContext* aTarget) { mUsingDefaultTarget = false; mTarget = aTarget; }
126 bool IsRetained() { return mWidget != nullptr; }
128 virtual const char* Name() const { return "Basic"; }
130 // Clear the cached contents of this layer tree.
131 virtual void ClearCachedResources(Layer* aSubtree = nullptr) MOZ_OVERRIDE;
133 void SetTransactionIncomplete() { mTransactionIncomplete = true; }
134 bool IsTransactionIncomplete() { return mTransactionIncomplete; }
136 already_AddRefed<gfxContext> PushGroupForLayer(gfxContext* aContext, Layer* aLayer,
137 const nsIntRegion& aRegion,
138 bool* aNeedsClipToVisibleRegion);
139 already_AddRefed<gfxContext> PushGroupWithCachedSurface(gfxContext *aTarget,
140 gfxContentType aContent);
141 void PopGroupToSourceWithCachedSurface(gfxContext *aTarget, gfxContext *aPushed);
143 virtual bool IsCompositingCheap() { return false; }
144 virtual int32_t GetMaxTextureSize() const { return INT32_MAX; }
145 bool CompositorMightResample() { return mCompositorMightResample; }
147 protected:
148 enum TransactionPhase {
149 PHASE_NONE, PHASE_CONSTRUCTION, PHASE_DRAWING, PHASE_FORWARD
150 };
151 TransactionPhase mPhase;
153 // This is the main body of the PaintLayer routine which will if it has
154 // children, recurse into PaintLayer() otherwise it will paint using the
155 // underlying Paint() method of the Layer. It will not do both.
156 void PaintSelfOrChildren(PaintLayerContext& aPaintContext, gfxContext* aGroupTarget);
158 // Paint the group onto the underlying target. This is used by PaintLayer to
159 // flush the group to the underlying target.
160 void FlushGroup(PaintLayerContext& aPaintContext, bool aNeedsClipToVisibleRegion);
162 // Paints aLayer to mTarget.
163 void PaintLayer(gfxContext* aTarget,
164 Layer* aLayer,
165 DrawThebesLayerCallback aCallback,
166 void* aCallbackData,
167 ReadbackProcessor* aReadback);
169 // Clear the contents of a layer
170 void ClearLayer(Layer* aLayer);
172 bool EndTransactionInternal(DrawThebesLayerCallback aCallback,
173 void* aCallbackData,
174 EndTransactionFlags aFlags = END_DEFAULT);
176 void FlashWidgetUpdateArea(gfxContext* aContext);
178 void RenderDebugOverlay();
180 // Widget whose surface should be used as the basis for ThebesLayer
181 // buffers.
182 nsIWidget* mWidget;
183 // The default context for BeginTransaction.
184 nsRefPtr<gfxContext> mDefaultTarget;
185 // The context to draw into.
186 nsRefPtr<gfxContext> mTarget;
187 // Image factory we use.
188 nsRefPtr<ImageFactory> mFactory;
190 // Cached surface for double buffering
191 gfxCachedTempSurface mCachedSurface;
193 BufferMode mDoubleBuffering;
194 bool mUsingDefaultTarget;
195 bool mCachedSurfaceInUse;
196 bool mTransactionIncomplete;
197 bool mCompositorMightResample;
198 };
200 }
201 }
203 #endif /* GFX_BASICLAYERS_H */