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 | |
michael@0 | 2 | /* |
michael@0 | 3 | * Copyright 2010 The Android Open Source Project |
michael@0 | 4 | * |
michael@0 | 5 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 6 | * found in the LICENSE file. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | |
michael@0 | 10 | #include "SkPDFFormXObject.h" |
michael@0 | 11 | |
michael@0 | 12 | #include "SkMatrix.h" |
michael@0 | 13 | #include "SkPDFCatalog.h" |
michael@0 | 14 | #include "SkPDFDevice.h" |
michael@0 | 15 | #include "SkPDFResourceDict.h" |
michael@0 | 16 | #include "SkPDFUtils.h" |
michael@0 | 17 | #include "SkStream.h" |
michael@0 | 18 | #include "SkTypes.h" |
michael@0 | 19 | |
michael@0 | 20 | SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device) { |
michael@0 | 21 | // We don't want to keep around device because we'd have two copies |
michael@0 | 22 | // of content, so reference or copy everything we need (content and |
michael@0 | 23 | // resources). |
michael@0 | 24 | SkTSet<SkPDFObject*> emptySet; |
michael@0 | 25 | SkPDFResourceDict* resourceDict = device->getResourceDict(); |
michael@0 | 26 | resourceDict->getReferencedResources(emptySet, &fResources, false); |
michael@0 | 27 | |
michael@0 | 28 | SkAutoTUnref<SkStream> content(device->content()); |
michael@0 | 29 | setData(content.get()); |
michael@0 | 30 | |
michael@0 | 31 | SkAutoTUnref<SkPDFArray> bboxArray(device->copyMediaBox()); |
michael@0 | 32 | init(NULL, resourceDict, bboxArray); |
michael@0 | 33 | |
michael@0 | 34 | // We invert the initial transform and apply that to the xobject so that |
michael@0 | 35 | // it doesn't get applied twice. We can't just undo it because it's |
michael@0 | 36 | // embedded in things like shaders and images. |
michael@0 | 37 | if (!device->initialTransform().isIdentity()) { |
michael@0 | 38 | SkMatrix inverse; |
michael@0 | 39 | if (!device->initialTransform().invert(&inverse)) { |
michael@0 | 40 | // The initial transform should be invertible. |
michael@0 | 41 | SkASSERT(false); |
michael@0 | 42 | inverse.reset(); |
michael@0 | 43 | } |
michael@0 | 44 | insert("Matrix", SkPDFUtils::MatrixToArray(inverse))->unref(); |
michael@0 | 45 | } |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | /** |
michael@0 | 49 | * Creates a FormXObject from a content stream and associated resources. |
michael@0 | 50 | */ |
michael@0 | 51 | SkPDFFormXObject::SkPDFFormXObject(SkStream* content, SkRect bbox, |
michael@0 | 52 | SkPDFResourceDict* resourceDict) { |
michael@0 | 53 | SkTSet<SkPDFObject*> emptySet; |
michael@0 | 54 | resourceDict->getReferencedResources(emptySet, &fResources, false); |
michael@0 | 55 | |
michael@0 | 56 | setData(content); |
michael@0 | 57 | |
michael@0 | 58 | SkAutoTUnref<SkPDFArray> bboxArray(SkPDFUtils::RectToArray(bbox)); |
michael@0 | 59 | init("DeviceRGB", resourceDict, bboxArray); |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | /** |
michael@0 | 63 | * Common initialization code. |
michael@0 | 64 | * Note that bbox is unreferenced here, so calling code does not need worry. |
michael@0 | 65 | */ |
michael@0 | 66 | void SkPDFFormXObject::init(const char* colorSpace, |
michael@0 | 67 | SkPDFDict* resourceDict, SkPDFArray* bbox) { |
michael@0 | 68 | insertName("Type", "XObject"); |
michael@0 | 69 | insertName("Subtype", "Form"); |
michael@0 | 70 | insert("Resources", resourceDict); |
michael@0 | 71 | insert("BBox", bbox); |
michael@0 | 72 | |
michael@0 | 73 | // Right now SkPDFFormXObject is only used for saveLayer, which implies |
michael@0 | 74 | // isolated blending. Do this conditionally if that changes. |
michael@0 | 75 | SkAutoTUnref<SkPDFDict> group(new SkPDFDict("Group")); |
michael@0 | 76 | group->insertName("S", "Transparency"); |
michael@0 | 77 | |
michael@0 | 78 | if (colorSpace != NULL) { |
michael@0 | 79 | group->insertName("CS", colorSpace); |
michael@0 | 80 | } |
michael@0 | 81 | group->insert("I", new SkPDFBool(true))->unref(); // Isolated. |
michael@0 | 82 | insert("Group", group.get()); |
michael@0 | 83 | } |
michael@0 | 84 | |
michael@0 | 85 | SkPDFFormXObject::~SkPDFFormXObject() { |
michael@0 | 86 | fResources.unrefAll(); |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | void SkPDFFormXObject::getResources( |
michael@0 | 90 | const SkTSet<SkPDFObject*>& knownResourceObjects, |
michael@0 | 91 | SkTSet<SkPDFObject*>* newResourceObjects) { |
michael@0 | 92 | GetResourcesHelper(&fResources.toArray(), |
michael@0 | 93 | knownResourceObjects, |
michael@0 | 94 | newResourceObjects); |
michael@0 | 95 | } |