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 2006 The Android Open Source Project
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
10 #ifndef SkDOM_DEFINED
11 #define SkDOM_DEFINED
13 #include "SkChunkAlloc.h"
14 #include "SkScalar.h"
15 #include "SkTemplates.h"
17 struct SkDOMNode;
18 struct SkDOMAttr;
20 class SkDOM {
21 public:
22 SkDOM();
23 ~SkDOM();
25 typedef SkDOMNode Node;
26 typedef SkDOMAttr Attr;
28 /** Returns null on failure
29 */
30 const Node* build(const char doc[], size_t len);
31 const Node* copy(const SkDOM& dom, const Node* node);
33 const Node* getRootNode() const;
35 enum Type {
36 kElement_Type,
37 kText_Type
38 };
39 Type getType(const Node*) const;
41 const char* getName(const Node*) const;
42 const Node* getFirstChild(const Node*, const char elem[] = NULL) const;
43 const Node* getNextSibling(const Node*, const char elem[] = NULL) const;
45 const char* findAttr(const Node*, const char attrName[]) const;
46 const Attr* getFirstAttr(const Node*) const;
47 const Attr* getNextAttr(const Node*, const Attr*) const;
48 const char* getAttrName(const Node*, const Attr*) const;
49 const char* getAttrValue(const Node*, const Attr*) const;
51 // helpers for walking children
52 int countChildren(const Node* node, const char elem[] = NULL) const;
54 // helpers for calling SkParse
55 bool findS32(const Node*, const char name[], int32_t* value) const;
56 bool findScalars(const Node*, const char name[], SkScalar value[], int count) const;
57 bool findHex(const Node*, const char name[], uint32_t* value) const;
58 bool findBool(const Node*, const char name[], bool*) const;
59 int findList(const Node*, const char name[], const char list[]) const;
61 bool findScalar(const Node* node, const char name[], SkScalar value[]) const
62 {
63 return this->findScalars(node, name, value, 1);
64 }
66 bool hasAttr(const Node*, const char name[], const char value[]) const;
67 bool hasS32(const Node*, const char name[], int32_t value) const;
68 bool hasScalar(const Node*, const char name[], SkScalar value) const;
69 bool hasHex(const Node*, const char name[], uint32_t value) const;
70 bool hasBool(const Node*, const char name[], bool value) const;
72 class AttrIter {
73 public:
74 AttrIter(const class SkDOM&, const Node*);
75 const char* next(const char** value);
76 private:
77 const Attr* fAttr;
78 const Attr* fStop;
79 };
81 SkDEBUGCODE(void dump(const Node* node = NULL, int tabLevel = 0) const;)
82 SkDEBUGCODE(static void UnitTest();)
84 private:
85 SkChunkAlloc fAlloc;
86 Node* fRoot;
87 friend class AttrIter;
88 friend class SkDOMParser;
89 };
91 #endif