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 2011 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 "SkNWayCanvas.h" |
michael@0 | 9 | |
michael@0 | 10 | SkNWayCanvas::SkNWayCanvas(int width, int height) |
michael@0 | 11 | : INHERITED(width, height) {} |
michael@0 | 12 | |
michael@0 | 13 | SkNWayCanvas::~SkNWayCanvas() { |
michael@0 | 14 | this->removeAll(); |
michael@0 | 15 | } |
michael@0 | 16 | |
michael@0 | 17 | void SkNWayCanvas::addCanvas(SkCanvas* canvas) { |
michael@0 | 18 | if (canvas) { |
michael@0 | 19 | canvas->ref(); |
michael@0 | 20 | *fList.append() = canvas; |
michael@0 | 21 | } |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | void SkNWayCanvas::removeCanvas(SkCanvas* canvas) { |
michael@0 | 25 | int index = fList.find(canvas); |
michael@0 | 26 | if (index >= 0) { |
michael@0 | 27 | canvas->unref(); |
michael@0 | 28 | fList.removeShuffle(index); |
michael@0 | 29 | } |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | void SkNWayCanvas::removeAll() { |
michael@0 | 33 | fList.unrefAll(); |
michael@0 | 34 | fList.reset(); |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | /////////////////////////////////////////////////////////////////////////// |
michael@0 | 38 | // These are forwarded to the N canvases we're referencing |
michael@0 | 39 | |
michael@0 | 40 | class SkNWayCanvas::Iter { |
michael@0 | 41 | public: |
michael@0 | 42 | Iter(const SkTDArray<SkCanvas*>& list) : fList(list) { |
michael@0 | 43 | fIndex = 0; |
michael@0 | 44 | } |
michael@0 | 45 | bool next() { |
michael@0 | 46 | if (fIndex < fList.count()) { |
michael@0 | 47 | fCanvas = fList[fIndex++]; |
michael@0 | 48 | return true; |
michael@0 | 49 | } |
michael@0 | 50 | return false; |
michael@0 | 51 | } |
michael@0 | 52 | SkCanvas* operator->() { return fCanvas; } |
michael@0 | 53 | |
michael@0 | 54 | private: |
michael@0 | 55 | const SkTDArray<SkCanvas*>& fList; |
michael@0 | 56 | int fIndex; |
michael@0 | 57 | SkCanvas* fCanvas; |
michael@0 | 58 | }; |
michael@0 | 59 | |
michael@0 | 60 | void SkNWayCanvas::willSave(SaveFlags flags) { |
michael@0 | 61 | Iter iter(fList); |
michael@0 | 62 | while (iter.next()) { |
michael@0 | 63 | iter->save(flags); |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | this->INHERITED::willSave(flags); |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | SkCanvas::SaveLayerStrategy SkNWayCanvas::willSaveLayer(const SkRect* bounds, const SkPaint* paint, |
michael@0 | 70 | SaveFlags flags) { |
michael@0 | 71 | Iter iter(fList); |
michael@0 | 72 | while (iter.next()) { |
michael@0 | 73 | iter->saveLayer(bounds, paint, flags); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | this->INHERITED::willSaveLayer(bounds, paint, flags); |
michael@0 | 77 | // No need for a layer. |
michael@0 | 78 | return kNoLayer_SaveLayerStrategy; |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | void SkNWayCanvas::willRestore() { |
michael@0 | 82 | Iter iter(fList); |
michael@0 | 83 | while (iter.next()) { |
michael@0 | 84 | iter->restore(); |
michael@0 | 85 | } |
michael@0 | 86 | this->INHERITED::willRestore(); |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | void SkNWayCanvas::didTranslate(SkScalar dx, SkScalar dy) { |
michael@0 | 90 | Iter iter(fList); |
michael@0 | 91 | while (iter.next()) { |
michael@0 | 92 | iter->translate(dx, dy); |
michael@0 | 93 | } |
michael@0 | 94 | this->INHERITED::didTranslate(dx, dy); |
michael@0 | 95 | } |
michael@0 | 96 | |
michael@0 | 97 | void SkNWayCanvas::didScale(SkScalar sx, SkScalar sy) { |
michael@0 | 98 | Iter iter(fList); |
michael@0 | 99 | while (iter.next()) { |
michael@0 | 100 | iter->scale(sx, sy); |
michael@0 | 101 | } |
michael@0 | 102 | this->INHERITED::didScale(sx, sy); |
michael@0 | 103 | } |
michael@0 | 104 | |
michael@0 | 105 | void SkNWayCanvas::didRotate(SkScalar degrees) { |
michael@0 | 106 | Iter iter(fList); |
michael@0 | 107 | while (iter.next()) { |
michael@0 | 108 | iter->rotate(degrees); |
michael@0 | 109 | } |
michael@0 | 110 | this->INHERITED::didRotate(degrees); |
michael@0 | 111 | } |
michael@0 | 112 | |
michael@0 | 113 | void SkNWayCanvas::didSkew(SkScalar sx, SkScalar sy) { |
michael@0 | 114 | Iter iter(fList); |
michael@0 | 115 | while (iter.next()) { |
michael@0 | 116 | iter->skew(sx, sy); |
michael@0 | 117 | } |
michael@0 | 118 | this->INHERITED::didSkew(sx, sy); |
michael@0 | 119 | } |
michael@0 | 120 | |
michael@0 | 121 | void SkNWayCanvas::didConcat(const SkMatrix& matrix) { |
michael@0 | 122 | Iter iter(fList); |
michael@0 | 123 | while (iter.next()) { |
michael@0 | 124 | iter->concat(matrix); |
michael@0 | 125 | } |
michael@0 | 126 | this->INHERITED::didConcat(matrix); |
michael@0 | 127 | } |
michael@0 | 128 | |
michael@0 | 129 | void SkNWayCanvas::didSetMatrix(const SkMatrix& matrix) { |
michael@0 | 130 | Iter iter(fList); |
michael@0 | 131 | while (iter.next()) { |
michael@0 | 132 | iter->setMatrix(matrix); |
michael@0 | 133 | } |
michael@0 | 134 | this->INHERITED::didSetMatrix(matrix); |
michael@0 | 135 | } |
michael@0 | 136 | |
michael@0 | 137 | void SkNWayCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { |
michael@0 | 138 | Iter iter(fList); |
michael@0 | 139 | while (iter.next()) { |
michael@0 | 140 | iter->clipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle); |
michael@0 | 141 | } |
michael@0 | 142 | this->INHERITED::onClipRect(rect, op, edgeStyle); |
michael@0 | 143 | } |
michael@0 | 144 | |
michael@0 | 145 | void SkNWayCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { |
michael@0 | 146 | Iter iter(fList); |
michael@0 | 147 | while (iter.next()) { |
michael@0 | 148 | iter->clipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle); |
michael@0 | 149 | } |
michael@0 | 150 | this->INHERITED::onClipRRect(rrect, op, edgeStyle); |
michael@0 | 151 | } |
michael@0 | 152 | |
michael@0 | 153 | void SkNWayCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) { |
michael@0 | 154 | Iter iter(fList); |
michael@0 | 155 | while (iter.next()) { |
michael@0 | 156 | iter->clipPath(path, op, kSoft_ClipEdgeStyle == edgeStyle); |
michael@0 | 157 | } |
michael@0 | 158 | this->INHERITED::onClipPath(path, op, edgeStyle); |
michael@0 | 159 | } |
michael@0 | 160 | |
michael@0 | 161 | void SkNWayCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { |
michael@0 | 162 | Iter iter(fList); |
michael@0 | 163 | while (iter.next()) { |
michael@0 | 164 | iter->clipRegion(deviceRgn, op); |
michael@0 | 165 | } |
michael@0 | 166 | this->INHERITED::onClipRegion(deviceRgn, op); |
michael@0 | 167 | } |
michael@0 | 168 | |
michael@0 | 169 | void SkNWayCanvas::clear(SkColor color) { |
michael@0 | 170 | Iter iter(fList); |
michael@0 | 171 | while (iter.next()) { |
michael@0 | 172 | iter->clear(color); |
michael@0 | 173 | } |
michael@0 | 174 | } |
michael@0 | 175 | |
michael@0 | 176 | void SkNWayCanvas::drawPaint(const SkPaint& paint) { |
michael@0 | 177 | Iter iter(fList); |
michael@0 | 178 | while (iter.next()) { |
michael@0 | 179 | iter->drawPaint(paint); |
michael@0 | 180 | } |
michael@0 | 181 | } |
michael@0 | 182 | |
michael@0 | 183 | void SkNWayCanvas::drawPoints(PointMode mode, size_t count, const SkPoint pts[], |
michael@0 | 184 | const SkPaint& paint) { |
michael@0 | 185 | Iter iter(fList); |
michael@0 | 186 | while (iter.next()) { |
michael@0 | 187 | iter->drawPoints(mode, count, pts, paint); |
michael@0 | 188 | } |
michael@0 | 189 | } |
michael@0 | 190 | |
michael@0 | 191 | void SkNWayCanvas::drawRect(const SkRect& rect, const SkPaint& paint) { |
michael@0 | 192 | Iter iter(fList); |
michael@0 | 193 | while (iter.next()) { |
michael@0 | 194 | iter->drawRect(rect, paint); |
michael@0 | 195 | } |
michael@0 | 196 | } |
michael@0 | 197 | |
michael@0 | 198 | void SkNWayCanvas::drawOval(const SkRect& rect, const SkPaint& paint) { |
michael@0 | 199 | Iter iter(fList); |
michael@0 | 200 | while (iter.next()) { |
michael@0 | 201 | iter->drawOval(rect, paint); |
michael@0 | 202 | } |
michael@0 | 203 | } |
michael@0 | 204 | |
michael@0 | 205 | void SkNWayCanvas::drawRRect(const SkRRect& rrect, const SkPaint& paint) { |
michael@0 | 206 | Iter iter(fList); |
michael@0 | 207 | while (iter.next()) { |
michael@0 | 208 | iter->drawRRect(rrect, paint); |
michael@0 | 209 | } |
michael@0 | 210 | } |
michael@0 | 211 | |
michael@0 | 212 | void SkNWayCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, |
michael@0 | 213 | const SkPaint& paint) { |
michael@0 | 214 | Iter iter(fList); |
michael@0 | 215 | while (iter.next()) { |
michael@0 | 216 | iter->drawDRRect(outer, inner, paint); |
michael@0 | 217 | } |
michael@0 | 218 | } |
michael@0 | 219 | |
michael@0 | 220 | void SkNWayCanvas::drawPath(const SkPath& path, const SkPaint& paint) { |
michael@0 | 221 | Iter iter(fList); |
michael@0 | 222 | while (iter.next()) { |
michael@0 | 223 | iter->drawPath(path, paint); |
michael@0 | 224 | } |
michael@0 | 225 | } |
michael@0 | 226 | |
michael@0 | 227 | void SkNWayCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, |
michael@0 | 228 | const SkPaint* paint) { |
michael@0 | 229 | Iter iter(fList); |
michael@0 | 230 | while (iter.next()) { |
michael@0 | 231 | iter->drawBitmap(bitmap, x, y, paint); |
michael@0 | 232 | } |
michael@0 | 233 | } |
michael@0 | 234 | |
michael@0 | 235 | void SkNWayCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, |
michael@0 | 236 | const SkRect& dst, const SkPaint* paint, |
michael@0 | 237 | DrawBitmapRectFlags flags) { |
michael@0 | 238 | Iter iter(fList); |
michael@0 | 239 | while (iter.next()) { |
michael@0 | 240 | iter->drawBitmapRectToRect(bitmap, src, dst, paint, flags); |
michael@0 | 241 | } |
michael@0 | 242 | } |
michael@0 | 243 | |
michael@0 | 244 | void SkNWayCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, |
michael@0 | 245 | const SkPaint* paint) { |
michael@0 | 246 | Iter iter(fList); |
michael@0 | 247 | while (iter.next()) { |
michael@0 | 248 | iter->drawBitmapMatrix(bitmap, m, paint); |
michael@0 | 249 | } |
michael@0 | 250 | } |
michael@0 | 251 | |
michael@0 | 252 | void SkNWayCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, |
michael@0 | 253 | const SkRect& dst, const SkPaint* paint) { |
michael@0 | 254 | Iter iter(fList); |
michael@0 | 255 | while (iter.next()) { |
michael@0 | 256 | iter->drawBitmapNine(bitmap, center, dst, paint); |
michael@0 | 257 | } |
michael@0 | 258 | } |
michael@0 | 259 | |
michael@0 | 260 | void SkNWayCanvas::drawSprite(const SkBitmap& bitmap, int x, int y, |
michael@0 | 261 | const SkPaint* paint) { |
michael@0 | 262 | Iter iter(fList); |
michael@0 | 263 | while (iter.next()) { |
michael@0 | 264 | iter->drawSprite(bitmap, x, y, paint); |
michael@0 | 265 | } |
michael@0 | 266 | } |
michael@0 | 267 | |
michael@0 | 268 | void SkNWayCanvas::drawText(const void* text, size_t byteLength, SkScalar x, |
michael@0 | 269 | SkScalar y, const SkPaint& paint) { |
michael@0 | 270 | Iter iter(fList); |
michael@0 | 271 | while (iter.next()) { |
michael@0 | 272 | iter->drawText(text, byteLength, x, y, paint); |
michael@0 | 273 | } |
michael@0 | 274 | } |
michael@0 | 275 | |
michael@0 | 276 | void SkNWayCanvas::drawPosText(const void* text, size_t byteLength, |
michael@0 | 277 | const SkPoint pos[], const SkPaint& paint) { |
michael@0 | 278 | Iter iter(fList); |
michael@0 | 279 | while (iter.next()) { |
michael@0 | 280 | iter->drawPosText(text, byteLength, pos, paint); |
michael@0 | 281 | } |
michael@0 | 282 | } |
michael@0 | 283 | |
michael@0 | 284 | void SkNWayCanvas::drawPosTextH(const void* text, size_t byteLength, |
michael@0 | 285 | const SkScalar xpos[], SkScalar constY, |
michael@0 | 286 | const SkPaint& paint) { |
michael@0 | 287 | Iter iter(fList); |
michael@0 | 288 | while (iter.next()) { |
michael@0 | 289 | iter->drawPosTextH(text, byteLength, xpos, constY, paint); |
michael@0 | 290 | } |
michael@0 | 291 | } |
michael@0 | 292 | |
michael@0 | 293 | void SkNWayCanvas::drawTextOnPath(const void* text, size_t byteLength, |
michael@0 | 294 | const SkPath& path, const SkMatrix* matrix, |
michael@0 | 295 | const SkPaint& paint) { |
michael@0 | 296 | Iter iter(fList); |
michael@0 | 297 | while (iter.next()) { |
michael@0 | 298 | iter->drawTextOnPath(text, byteLength, path, matrix, paint); |
michael@0 | 299 | } |
michael@0 | 300 | } |
michael@0 | 301 | |
michael@0 | 302 | void SkNWayCanvas::drawPicture(SkPicture& picture) { |
michael@0 | 303 | Iter iter(fList); |
michael@0 | 304 | while (iter.next()) { |
michael@0 | 305 | iter->drawPicture(picture); |
michael@0 | 306 | } |
michael@0 | 307 | } |
michael@0 | 308 | |
michael@0 | 309 | void SkNWayCanvas::drawVertices(VertexMode vmode, int vertexCount, |
michael@0 | 310 | const SkPoint vertices[], const SkPoint texs[], |
michael@0 | 311 | const SkColor colors[], SkXfermode* xmode, |
michael@0 | 312 | const uint16_t indices[], int indexCount, |
michael@0 | 313 | const SkPaint& paint) { |
michael@0 | 314 | Iter iter(fList); |
michael@0 | 315 | while (iter.next()) { |
michael@0 | 316 | iter->drawVertices(vmode, vertexCount, vertices, texs, colors, xmode, |
michael@0 | 317 | indices, indexCount, paint); |
michael@0 | 318 | } |
michael@0 | 319 | } |
michael@0 | 320 | |
michael@0 | 321 | void SkNWayCanvas::drawData(const void* data, size_t length) { |
michael@0 | 322 | Iter iter(fList); |
michael@0 | 323 | while (iter.next()) { |
michael@0 | 324 | iter->drawData(data, length); |
michael@0 | 325 | } |
michael@0 | 326 | } |
michael@0 | 327 | |
michael@0 | 328 | SkBounder* SkNWayCanvas::setBounder(SkBounder* bounder) { |
michael@0 | 329 | Iter iter(fList); |
michael@0 | 330 | while (iter.next()) { |
michael@0 | 331 | iter->setBounder(bounder); |
michael@0 | 332 | } |
michael@0 | 333 | return this->INHERITED::setBounder(bounder); |
michael@0 | 334 | } |
michael@0 | 335 | |
michael@0 | 336 | SkDrawFilter* SkNWayCanvas::setDrawFilter(SkDrawFilter* filter) { |
michael@0 | 337 | Iter iter(fList); |
michael@0 | 338 | while (iter.next()) { |
michael@0 | 339 | iter->setDrawFilter(filter); |
michael@0 | 340 | } |
michael@0 | 341 | return this->INHERITED::setDrawFilter(filter); |
michael@0 | 342 | } |
michael@0 | 343 | |
michael@0 | 344 | void SkNWayCanvas::beginCommentGroup(const char* description) { |
michael@0 | 345 | Iter iter(fList); |
michael@0 | 346 | while (iter.next()) { |
michael@0 | 347 | iter->beginCommentGroup(description); |
michael@0 | 348 | } |
michael@0 | 349 | } |
michael@0 | 350 | |
michael@0 | 351 | void SkNWayCanvas::addComment(const char* kywd, const char* value) { |
michael@0 | 352 | Iter iter(fList); |
michael@0 | 353 | while (iter.next()) { |
michael@0 | 354 | iter->addComment(kywd, value); |
michael@0 | 355 | } |
michael@0 | 356 | } |
michael@0 | 357 | |
michael@0 | 358 | void SkNWayCanvas::endCommentGroup() { |
michael@0 | 359 | Iter iter(fList); |
michael@0 | 360 | while (iter.next()) { |
michael@0 | 361 | iter->endCommentGroup(); |
michael@0 | 362 | } |
michael@0 | 363 | } |