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 2013 Google Inc. |
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 | #include "SkCanvasStack.h" |
michael@0 | 9 | |
michael@0 | 10 | SkCanvasStack::SkCanvasStack(int width, int height) |
michael@0 | 11 | : INHERITED(width, height) {} |
michael@0 | 12 | |
michael@0 | 13 | SkCanvasStack::~SkCanvasStack() { |
michael@0 | 14 | this->removeAll(); |
michael@0 | 15 | } |
michael@0 | 16 | |
michael@0 | 17 | void SkCanvasStack::pushCanvas(SkCanvas* canvas, const SkIPoint& origin) { |
michael@0 | 18 | if (canvas) { |
michael@0 | 19 | // compute the bounds of this canvas |
michael@0 | 20 | const SkIRect canvasBounds = SkIRect::MakeSize(canvas->getDeviceSize()); |
michael@0 | 21 | |
michael@0 | 22 | // push the canvas onto the stack |
michael@0 | 23 | this->INHERITED::addCanvas(canvas); |
michael@0 | 24 | |
michael@0 | 25 | // push the canvas data onto the stack |
michael@0 | 26 | CanvasData* data = &fCanvasData.push_back(); |
michael@0 | 27 | data->origin = origin; |
michael@0 | 28 | data->requiredClip.setRect(canvasBounds); |
michael@0 | 29 | |
michael@0 | 30 | // subtract this region from the canvas objects already on the stack. |
michael@0 | 31 | // This ensures they do not draw into the space occupied by the layers |
michael@0 | 32 | // above them. |
michael@0 | 33 | for (int i = fList.count() - 1; i > 0; --i) { |
michael@0 | 34 | SkIRect localBounds = canvasBounds; |
michael@0 | 35 | localBounds.offset(origin - fCanvasData[i-1].origin); |
michael@0 | 36 | |
michael@0 | 37 | fCanvasData[i-1].requiredClip.op(localBounds, SkRegion::kDifference_Op); |
michael@0 | 38 | fList[i-1]->clipRegion(fCanvasData[i-1].requiredClip); |
michael@0 | 39 | } |
michael@0 | 40 | } |
michael@0 | 41 | SkASSERT(fList.count() == fCanvasData.count()); |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | void SkCanvasStack::removeAll() { |
michael@0 | 45 | fCanvasData.reset(); |
michael@0 | 46 | this->INHERITED::removeAll(); |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | /** |
michael@0 | 50 | * Traverse all canvases (e.g. layers) the stack and ensure that they are clipped |
michael@0 | 51 | * to their bounds and that the area covered by any canvas higher in the stack is |
michael@0 | 52 | * also clipped out. |
michael@0 | 53 | */ |
michael@0 | 54 | void SkCanvasStack::clipToZOrderedBounds() { |
michael@0 | 55 | SkASSERT(fList.count() == fCanvasData.count()); |
michael@0 | 56 | for (int i = 0; i < fList.count(); ++i) { |
michael@0 | 57 | fList[i]->clipRegion(fCanvasData[i].requiredClip, SkRegion::kIntersect_Op); |
michael@0 | 58 | } |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 62 | |
michael@0 | 63 | /** |
michael@0 | 64 | * We need to handle setMatrix specially as it overwrites the matrix in each |
michael@0 | 65 | * canvas unlike all other matrix operations (i.e. translate, scale, etc) which |
michael@0 | 66 | * just pre-concatenate with the existing matrix. |
michael@0 | 67 | */ |
michael@0 | 68 | void SkCanvasStack::didSetMatrix(const SkMatrix& matrix) { |
michael@0 | 69 | SkASSERT(fList.count() == fCanvasData.count()); |
michael@0 | 70 | for (int i = 0; i < fList.count(); ++i) { |
michael@0 | 71 | |
michael@0 | 72 | SkMatrix tempMatrix = matrix; |
michael@0 | 73 | tempMatrix.postTranslate(SkIntToScalar(-fCanvasData[i].origin.x()), |
michael@0 | 74 | SkIntToScalar(-fCanvasData[i].origin.y())); |
michael@0 | 75 | fList[i]->setMatrix(tempMatrix); |
michael@0 | 76 | } |
michael@0 | 77 | this->SkCanvas::didSetMatrix(matrix); |
michael@0 | 78 | } |
michael@0 | 79 | |
michael@0 | 80 | void SkCanvasStack::onClipRect(const SkRect& r, SkRegion::Op op, ClipEdgeStyle edgeStyle) { |
michael@0 | 81 | this->INHERITED::onClipRect(r, op, edgeStyle); |
michael@0 | 82 | this->clipToZOrderedBounds(); |
michael@0 | 83 | } |
michael@0 | 84 | |
michael@0 | 85 | void SkCanvasStack::onClipRRect(const SkRRect& rr, SkRegion::Op op, ClipEdgeStyle edgeStyle) { |
michael@0 | 86 | this->INHERITED::onClipRRect(rr, op, edgeStyle); |
michael@0 | 87 | this->clipToZOrderedBounds(); |
michael@0 | 88 | } |
michael@0 | 89 | |
michael@0 | 90 | void SkCanvasStack::onClipPath(const SkPath& p, SkRegion::Op op, ClipEdgeStyle edgeStyle) { |
michael@0 | 91 | this->INHERITED::onClipPath(p, op, edgeStyle); |
michael@0 | 92 | this->clipToZOrderedBounds(); |
michael@0 | 93 | } |
michael@0 | 94 | |
michael@0 | 95 | void SkCanvasStack::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { |
michael@0 | 96 | SkASSERT(fList.count() == fCanvasData.count()); |
michael@0 | 97 | for (int i = 0; i < fList.count(); ++i) { |
michael@0 | 98 | SkRegion tempRegion; |
michael@0 | 99 | deviceRgn.translate(-fCanvasData[i].origin.x(), |
michael@0 | 100 | -fCanvasData[i].origin.y(), &tempRegion); |
michael@0 | 101 | tempRegion.op(fCanvasData[i].requiredClip, SkRegion::kIntersect_Op); |
michael@0 | 102 | fList[i]->clipRegion(tempRegion, op); |
michael@0 | 103 | } |
michael@0 | 104 | this->SkCanvas::onClipRegion(deviceRgn, op); |
michael@0 | 105 | } |