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