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.
2 /*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8 #ifndef SkDumpCanvas_DEFINED
9 #define SkDumpCanvas_DEFINED
11 #include "SkCanvas.h"
13 #ifdef SK_DEVELOPER
15 /** This class overrides all the draw methods on SkCanvas, and formats them
16 as text, and then sends that to a Dumper helper object.
18 Typical use might be to dump a display list to a log file to see what is
19 being drawn.
20 */
21 class SkDumpCanvas : public SkCanvas {
22 public:
23 class Dumper;
25 explicit SkDumpCanvas(Dumper* = 0);
26 virtual ~SkDumpCanvas();
28 enum Verb {
29 kNULL_Verb,
31 kSave_Verb,
32 kRestore_Verb,
34 kMatrix_Verb,
36 kClip_Verb,
38 kDrawPaint_Verb,
39 kDrawPoints_Verb,
40 kDrawOval_Verb,
41 kDrawRect_Verb,
42 kDrawRRect_Verb,
43 kDrawDRRect_Verb,
44 kDrawPath_Verb,
45 kDrawBitmap_Verb,
46 kDrawText_Verb,
47 kDrawPicture_Verb,
48 kDrawVertices_Verb,
49 kDrawData_Verb,
51 kBeginCommentGroup_Verb,
52 kAddComment_Verb,
53 kEndCommentGroup_Verb,
55 kCull_Verb
56 };
58 /** Subclasses of this are installed on the DumpCanvas, and then called for
59 each drawing command.
60 */
61 class Dumper : public SkRefCnt {
62 public:
63 SK_DECLARE_INST_COUNT(Dumper)
65 virtual void dump(SkDumpCanvas*, SkDumpCanvas::Verb, const char str[],
66 const SkPaint*) = 0;
68 private:
69 typedef SkRefCnt INHERITED;
70 };
72 Dumper* getDumper() const { return fDumper; }
73 void setDumper(Dumper*);
75 int getNestLevel() const { return fNestLevel; }
77 virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE;
78 virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
79 const SkPaint& paint) SK_OVERRIDE;
80 virtual void drawOval(const SkRect&, const SkPaint& paint) SK_OVERRIDE;
81 virtual void drawRect(const SkRect&, const SkPaint& paint) SK_OVERRIDE;
82 virtual void drawRRect(const SkRRect&, const SkPaint& paint) SK_OVERRIDE;
83 virtual void drawPath(const SkPath& path, const SkPaint& paint) SK_OVERRIDE;
84 virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
85 const SkPaint* paint) SK_OVERRIDE;
86 virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
87 const SkRect& dst, const SkPaint* paint,
88 DrawBitmapRectFlags flags) SK_OVERRIDE;
89 virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
90 const SkPaint* paint) SK_OVERRIDE;
91 virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
92 const SkPaint* paint) SK_OVERRIDE;
93 virtual void drawText(const void* text, size_t byteLength, SkScalar x,
94 SkScalar y, const SkPaint& paint) SK_OVERRIDE;
95 virtual void drawPosText(const void* text, size_t byteLength,
96 const SkPoint pos[], const SkPaint& paint) SK_OVERRIDE;
97 virtual void drawPosTextH(const void* text, size_t byteLength,
98 const SkScalar xpos[], SkScalar constY,
99 const SkPaint& paint) SK_OVERRIDE;
100 virtual void drawTextOnPath(const void* text, size_t byteLength,
101 const SkPath& path, const SkMatrix* matrix,
102 const SkPaint& paint) SK_OVERRIDE;
103 virtual void drawPicture(SkPicture&) SK_OVERRIDE;
104 virtual void drawVertices(VertexMode vmode, int vertexCount,
105 const SkPoint vertices[], const SkPoint texs[],
106 const SkColor colors[], SkXfermode* xmode,
107 const uint16_t indices[], int indexCount,
108 const SkPaint& paint) SK_OVERRIDE;
109 virtual void drawData(const void*, size_t) SK_OVERRIDE;
110 virtual void beginCommentGroup(const char* description) SK_OVERRIDE;
111 virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE;
112 virtual void endCommentGroup() SK_OVERRIDE;
114 protected:
115 virtual void willSave(SaveFlags) SK_OVERRIDE;
116 virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE;
117 virtual void willRestore() SK_OVERRIDE;
119 virtual void didTranslate(SkScalar, SkScalar) SK_OVERRIDE;
120 virtual void didScale(SkScalar, SkScalar) SK_OVERRIDE;
121 virtual void didRotate(SkScalar) SK_OVERRIDE;
122 virtual void didSkew(SkScalar, SkScalar) SK_OVERRIDE;
123 virtual void didConcat(const SkMatrix&) SK_OVERRIDE;
124 virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE;
126 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
127 virtual void onPushCull(const SkRect& cullRect) SK_OVERRIDE;
128 virtual void onPopCull() SK_OVERRIDE;
130 virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
131 virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
132 virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
133 virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE;
135 static const char* EdgeStyleToAAString(ClipEdgeStyle edgeStyle);
137 private:
138 Dumper* fDumper;
139 int fNestLevel; // for nesting recursive elements like pictures
141 void dump(Verb, const SkPaint*, const char format[], ...);
143 typedef SkCanvas INHERITED;
144 };
146 /** Formats the draw commands, and send them to a function-pointer provided
147 by the caller.
148 */
149 class SkFormatDumper : public SkDumpCanvas::Dumper {
150 public:
151 SkFormatDumper(void (*)(const char text[], void* refcon), void* refcon);
153 // override from baseclass that does the formatting, and in turn calls
154 // the function pointer that was passed to the constructor
155 virtual void dump(SkDumpCanvas*, SkDumpCanvas::Verb, const char str[],
156 const SkPaint*) SK_OVERRIDE;
158 private:
159 void (*fProc)(const char*, void*);
160 void* fRefcon;
162 typedef SkDumpCanvas::Dumper INHERITED;
163 };
165 /** Subclass of Dumper that dumps the drawing command to SkDebugf
166 */
167 class SkDebugfDumper : public SkFormatDumper {
168 public:
169 SkDebugfDumper();
171 private:
172 typedef SkFormatDumper INHERITED;
173 };
175 #endif
177 #endif