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 2012 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 SkPaintOptionsAndroid_DEFINED
11 #define SkPaintOptionsAndroid_DEFINED
13 #include "SkTypes.h"
14 #include "SkString.h"
16 class SkReadBuffer;
17 class SkWriteBuffer;
19 /** \class SkLanguage
21 The SkLanguage class represents a human written language, and is used by
22 text draw operations to determine which glyph to draw when drawing
23 characters with variants (ie Han-derived characters).
24 */
25 class SkLanguage {
26 public:
27 SkLanguage() { }
28 SkLanguage(const SkString& tag) : fTag(tag) { }
29 SkLanguage(const char* tag) : fTag(tag) { }
30 SkLanguage(const char* tag, size_t len) : fTag(tag, len) { }
31 SkLanguage(const SkLanguage& b) : fTag(b.fTag) { }
33 /** Gets a BCP 47 language identifier for this SkLanguage.
34 @return a BCP 47 language identifier representing this language
35 */
36 const SkString& getTag() const { return fTag; }
38 /** Performs BCP 47 fallback to return an SkLanguage one step more general.
39 @return an SkLanguage one step more general
40 */
41 SkLanguage getParent() const;
43 bool operator==(const SkLanguage& b) const {
44 return fTag == b.fTag;
45 }
46 bool operator!=(const SkLanguage& b) const {
47 return fTag != b.fTag;
48 }
49 SkLanguage& operator=(const SkLanguage& b) {
50 fTag = b.fTag;
51 return *this;
52 }
54 private:
55 //! BCP 47 language identifier
56 SkString fTag;
57 };
59 class SkPaintOptionsAndroid {
60 public:
61 SkPaintOptionsAndroid() {
62 fFontVariant = kDefault_Variant;
63 fUseFontFallbacks = false;
64 }
66 SkPaintOptionsAndroid& operator=(const SkPaintOptionsAndroid& b) {
67 fLanguage = b.fLanguage;
68 fFontVariant = b.fFontVariant;
69 fUseFontFallbacks = b.fUseFontFallbacks;
70 return *this;
71 }
73 bool operator==(const SkPaintOptionsAndroid& b) const {
74 return !(*this != b);
75 }
77 bool operator!=(const SkPaintOptionsAndroid& b) const {
78 return fLanguage != b.fLanguage ||
79 fFontVariant != b.fFontVariant ||
80 fUseFontFallbacks != b.fUseFontFallbacks;
81 }
83 void flatten(SkWriteBuffer&) const;
84 void unflatten(SkReadBuffer&);
86 /** Return the paint's language value used for drawing text.
87 @return the paint's language value used for drawing text.
88 */
89 const SkLanguage& getLanguage() const { return fLanguage; }
91 /** Set the paint's language value used for drawing text.
92 @param language set the paint's language value for drawing text.
93 */
94 void setLanguage(const SkLanguage& language) { fLanguage = language; }
95 void setLanguage(const char* languageTag) { fLanguage = SkLanguage(languageTag); }
98 enum FontVariant {
99 kDefault_Variant = 0x01,
100 kCompact_Variant = 0x02,
101 kElegant_Variant = 0x04,
102 kLast_Variant = kElegant_Variant,
103 };
105 /** Return the font variant
106 @return the font variant used by this paint object
107 */
108 FontVariant getFontVariant() const { return fFontVariant; }
110 /** Set the font variant
111 @param fontVariant set the paint's font variant for choosing fonts
112 */
113 void setFontVariant(FontVariant fontVariant) {
114 SkASSERT((unsigned)fontVariant <= kLast_Variant);
115 fFontVariant = fontVariant;
116 }
118 bool isUsingFontFallbacks() const { return fUseFontFallbacks; }
120 void setUseFontFallbacks(bool useFontFallbacks) {
121 fUseFontFallbacks = useFontFallbacks;
122 }
124 private:
125 SkLanguage fLanguage;
126 FontVariant fFontVariant;
127 bool fUseFontFallbacks;
128 };
130 #endif // #ifndef SkPaintOptionsAndroid_DEFINED