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: 20; 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 | #include "mozilla/layers/TextureClientX11.h" |
michael@0 | 6 | #include "mozilla/layers/CompositableClient.h" |
michael@0 | 7 | #include "mozilla/layers/CompositableForwarder.h" |
michael@0 | 8 | #include "mozilla/layers/ISurfaceAllocator.h" |
michael@0 | 9 | #include "mozilla/layers/ShadowLayerUtilsX11.h" |
michael@0 | 10 | #include "mozilla/gfx/2D.h" |
michael@0 | 11 | #include "gfxXlibSurface.h" |
michael@0 | 12 | #include "gfx2DGlue.h" |
michael@0 | 13 | |
michael@0 | 14 | #include "mozilla/X11Util.h" |
michael@0 | 15 | #include <X11/Xlib.h> |
michael@0 | 16 | |
michael@0 | 17 | using namespace mozilla; |
michael@0 | 18 | using namespace mozilla::gfx; |
michael@0 | 19 | using namespace mozilla::layers; |
michael@0 | 20 | |
michael@0 | 21 | TextureClientX11::TextureClientX11(SurfaceFormat aFormat, TextureFlags aFlags) |
michael@0 | 22 | : TextureClient(aFlags), |
michael@0 | 23 | mFormat(aFormat), |
michael@0 | 24 | mLocked(false) |
michael@0 | 25 | { |
michael@0 | 26 | MOZ_COUNT_CTOR(TextureClientX11); |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | TextureClientX11::~TextureClientX11() |
michael@0 | 30 | { |
michael@0 | 31 | MOZ_COUNT_DTOR(TextureClientX11); |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | bool |
michael@0 | 35 | TextureClientX11::IsAllocated() const |
michael@0 | 36 | { |
michael@0 | 37 | return !!mSurface; |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | bool |
michael@0 | 41 | TextureClientX11::Lock(OpenMode aMode) |
michael@0 | 42 | { |
michael@0 | 43 | MOZ_ASSERT(!mLocked, "The TextureClient is already Locked!"); |
michael@0 | 44 | mLocked = IsValid() && IsAllocated(); |
michael@0 | 45 | return mLocked; |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | void |
michael@0 | 49 | TextureClientX11::Unlock() |
michael@0 | 50 | { |
michael@0 | 51 | MOZ_ASSERT(mLocked, "The TextureClient is already Unlocked!"); |
michael@0 | 52 | mLocked = false; |
michael@0 | 53 | |
michael@0 | 54 | if (mSurface) { |
michael@0 | 55 | FinishX(DefaultXDisplay()); |
michael@0 | 56 | } |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | bool |
michael@0 | 60 | TextureClientX11::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) |
michael@0 | 61 | { |
michael@0 | 62 | MOZ_ASSERT(IsValid()); |
michael@0 | 63 | if (!mSurface) { |
michael@0 | 64 | return false; |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | aOutDescriptor = SurfaceDescriptorX11(mSurface); |
michael@0 | 68 | return true; |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | TextureClientData* |
michael@0 | 72 | TextureClientX11::DropTextureData() |
michael@0 | 73 | { |
michael@0 | 74 | MOZ_ASSERT(!(mFlags & TEXTURE_DEALLOCATE_CLIENT)); |
michael@0 | 75 | return nullptr; |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | bool |
michael@0 | 79 | TextureClientX11::AllocateForSurface(IntSize aSize, TextureAllocationFlags aTextureFlags) |
michael@0 | 80 | { |
michael@0 | 81 | MOZ_ASSERT(IsValid()); |
michael@0 | 82 | //MOZ_ASSERT(mFormat != gfx::FORMAT_YUV, "This TextureClient cannot use YCbCr data"); |
michael@0 | 83 | |
michael@0 | 84 | gfxContentType contentType = ContentForFormat(mFormat); |
michael@0 | 85 | nsRefPtr<gfxASurface> surface = gfxPlatform::GetPlatform()->CreateOffscreenSurface(aSize, contentType); |
michael@0 | 86 | if (!surface || surface->GetType() != gfxSurfaceType::Xlib) { |
michael@0 | 87 | NS_ERROR("creating Xlib surface failed!"); |
michael@0 | 88 | return false; |
michael@0 | 89 | } |
michael@0 | 90 | |
michael@0 | 91 | mSize = aSize; |
michael@0 | 92 | mSurface = static_cast<gfxXlibSurface*>(surface.get()); |
michael@0 | 93 | |
michael@0 | 94 | // The host is always responsible for freeing the pixmap. |
michael@0 | 95 | mSurface->ReleasePixmap(); |
michael@0 | 96 | return true; |
michael@0 | 97 | } |
michael@0 | 98 | |
michael@0 | 99 | TemporaryRef<DrawTarget> |
michael@0 | 100 | TextureClientX11::GetAsDrawTarget() |
michael@0 | 101 | { |
michael@0 | 102 | MOZ_ASSERT(IsValid()); |
michael@0 | 103 | if (!mSurface) { |
michael@0 | 104 | return nullptr; |
michael@0 | 105 | } |
michael@0 | 106 | |
michael@0 | 107 | IntSize size = ToIntSize(mSurface->GetSize()); |
michael@0 | 108 | return Factory::CreateDrawTargetForCairoSurface(mSurface->CairoSurface(), size); |
michael@0 | 109 | } |