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 #include "SharedDIBSurface.h"
8 #include "cairo.h"
10 namespace mozilla {
11 namespace gfx {
13 static const cairo_user_data_key_t SHAREDDIB_KEY = {0};
15 static const long kBytesPerPixel = 4;
17 bool
18 SharedDIBSurface::Create(HDC adc, uint32_t aWidth, uint32_t aHeight,
19 bool aTransparent)
20 {
21 nsresult rv = mSharedDIB.Create(adc, aWidth, aHeight, aTransparent);
22 if (NS_FAILED(rv) || !mSharedDIB.IsValid())
23 return false;
25 InitSurface(aWidth, aHeight, aTransparent);
26 return true;
27 }
29 bool
30 SharedDIBSurface::Attach(Handle aHandle, uint32_t aWidth, uint32_t aHeight,
31 bool aTransparent)
32 {
33 nsresult rv = mSharedDIB.Attach(aHandle, aWidth, aHeight, aTransparent);
34 if (NS_FAILED(rv) || !mSharedDIB.IsValid())
35 return false;
37 InitSurface(aWidth, aHeight, aTransparent);
38 return true;
39 }
41 void
42 SharedDIBSurface::InitSurface(uint32_t aWidth, uint32_t aHeight,
43 bool aTransparent)
44 {
45 long stride = long(aWidth * kBytesPerPixel);
46 unsigned char* data = reinterpret_cast<unsigned char*>(mSharedDIB.GetBits());
48 gfxImageFormat format = aTransparent ? gfxImageFormat::ARGB32 : gfxImageFormat::RGB24;
50 gfxImageSurface::InitWithData(data, gfxIntSize(aWidth, aHeight),
51 stride, format);
53 cairo_surface_set_user_data(mSurface, &SHAREDDIB_KEY, this, nullptr);
54 }
56 bool
57 SharedDIBSurface::IsSharedDIBSurface(gfxASurface* aSurface)
58 {
59 return aSurface &&
60 aSurface->GetType() == gfxSurfaceType::Image &&
61 aSurface->GetData(&SHAREDDIB_KEY);
62 }
64 } // namespace gfx
65 } // namespace mozilla