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 | * Copyright 2012 Google Inc. |
michael@0 | 3 | * |
michael@0 | 4 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 5 | * found in the LICENSE file. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | #include "SkStrokeRec.h" |
michael@0 | 9 | #include "SkPaintDefaults.h" |
michael@0 | 10 | |
michael@0 | 11 | // must be < 0, since ==0 means hairline, and >0 means normal stroke |
michael@0 | 12 | #define kStrokeRec_FillStyleWidth (-SK_Scalar1) |
michael@0 | 13 | |
michael@0 | 14 | SkStrokeRec::SkStrokeRec(InitStyle s) { |
michael@0 | 15 | fWidth = (kFill_InitStyle == s) ? kStrokeRec_FillStyleWidth : 0; |
michael@0 | 16 | fMiterLimit = SkPaintDefaults_MiterLimit; |
michael@0 | 17 | fCap = SkPaint::kDefault_Cap; |
michael@0 | 18 | fJoin = SkPaint::kDefault_Join; |
michael@0 | 19 | fStrokeAndFill = false; |
michael@0 | 20 | } |
michael@0 | 21 | |
michael@0 | 22 | SkStrokeRec::SkStrokeRec(const SkStrokeRec& src) { |
michael@0 | 23 | memcpy(this, &src, sizeof(src)); |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | SkStrokeRec::SkStrokeRec(const SkPaint& paint) { |
michael@0 | 27 | switch (paint.getStyle()) { |
michael@0 | 28 | case SkPaint::kFill_Style: |
michael@0 | 29 | fWidth = kStrokeRec_FillStyleWidth; |
michael@0 | 30 | fStrokeAndFill = false; |
michael@0 | 31 | break; |
michael@0 | 32 | case SkPaint::kStroke_Style: |
michael@0 | 33 | fWidth = paint.getStrokeWidth(); |
michael@0 | 34 | fStrokeAndFill = false; |
michael@0 | 35 | break; |
michael@0 | 36 | case SkPaint::kStrokeAndFill_Style: |
michael@0 | 37 | if (0 == paint.getStrokeWidth()) { |
michael@0 | 38 | // hairline+fill == fill |
michael@0 | 39 | fWidth = kStrokeRec_FillStyleWidth; |
michael@0 | 40 | fStrokeAndFill = false; |
michael@0 | 41 | } else { |
michael@0 | 42 | fWidth = paint.getStrokeWidth(); |
michael@0 | 43 | fStrokeAndFill = true; |
michael@0 | 44 | } |
michael@0 | 45 | break; |
michael@0 | 46 | default: |
michael@0 | 47 | SkDEBUGFAIL("unknown paint style"); |
michael@0 | 48 | // fall back on just fill |
michael@0 | 49 | fWidth = kStrokeRec_FillStyleWidth; |
michael@0 | 50 | fStrokeAndFill = false; |
michael@0 | 51 | break; |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | // copy these from the paint, regardless of our "style" |
michael@0 | 55 | fMiterLimit = paint.getStrokeMiter(); |
michael@0 | 56 | fCap = paint.getStrokeCap(); |
michael@0 | 57 | fJoin = paint.getStrokeJoin(); |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | SkStrokeRec::Style SkStrokeRec::getStyle() const { |
michael@0 | 61 | if (fWidth < 0) { |
michael@0 | 62 | return kFill_Style; |
michael@0 | 63 | } else if (0 == fWidth) { |
michael@0 | 64 | return kHairline_Style; |
michael@0 | 65 | } else { |
michael@0 | 66 | return fStrokeAndFill ? kStrokeAndFill_Style : kStroke_Style; |
michael@0 | 67 | } |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | void SkStrokeRec::setFillStyle() { |
michael@0 | 71 | fWidth = kStrokeRec_FillStyleWidth; |
michael@0 | 72 | fStrokeAndFill = false; |
michael@0 | 73 | } |
michael@0 | 74 | |
michael@0 | 75 | void SkStrokeRec::setHairlineStyle() { |
michael@0 | 76 | fWidth = 0; |
michael@0 | 77 | fStrokeAndFill = false; |
michael@0 | 78 | } |
michael@0 | 79 | |
michael@0 | 80 | void SkStrokeRec::setStrokeStyle(SkScalar width, bool strokeAndFill) { |
michael@0 | 81 | if (strokeAndFill && (0 == width)) { |
michael@0 | 82 | // hairline+fill == fill |
michael@0 | 83 | this->setFillStyle(); |
michael@0 | 84 | } else { |
michael@0 | 85 | fWidth = width; |
michael@0 | 86 | fStrokeAndFill = strokeAndFill; |
michael@0 | 87 | } |
michael@0 | 88 | } |
michael@0 | 89 | |
michael@0 | 90 | #include "SkStroke.h" |
michael@0 | 91 | |
michael@0 | 92 | bool SkStrokeRec::applyToPath(SkPath* dst, const SkPath& src) const { |
michael@0 | 93 | if (fWidth <= 0) { // hairline or fill |
michael@0 | 94 | return false; |
michael@0 | 95 | } |
michael@0 | 96 | |
michael@0 | 97 | SkStroke stroker; |
michael@0 | 98 | stroker.setCap(fCap); |
michael@0 | 99 | stroker.setJoin(fJoin); |
michael@0 | 100 | stroker.setMiterLimit(fMiterLimit); |
michael@0 | 101 | stroker.setWidth(fWidth); |
michael@0 | 102 | stroker.setDoFill(fStrokeAndFill); |
michael@0 | 103 | stroker.strokePath(src, dst); |
michael@0 | 104 | return true; |
michael@0 | 105 | } |