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 SkFontHost_DEFINED
11 #define SkFontHost_DEFINED
13 #include "SkTypeface.h"
15 class SkDescriptor;
16 class SkScalerContext;
17 struct SkScalerContextRec;
18 class SkStream;
19 class SkWStream;
21 /** \class SkFontHost
23 This class is ported to each environment. It is responsible for bridging
24 the gap between the (sort of) abstract class SkTypeface and the
25 platform-specific implementation that provides access to font files.
27 One basic task is for each create (subclass of) SkTypeface, the FontHost is
28 responsible for assigning a uniqueID. The ID should be unique for the
29 underlying font file/data, not unique per typeface instance. Thus it is
30 possible/common to request a typeface for the same font more than once
31 (e.g. asking for the same font by name several times). The FontHost may
32 return seperate typeface instances in that case, or it may choose to use a
33 cache and return the same instance (but calling typeface->ref(), since the
34 caller is always responsible for calling unref() on each instance that is
35 returned). Either way, the fontID for those instance(s) will be the same.
36 In addition, the fontID should never be set to 0. That value is used as a
37 sentinel to indicate no-font-id.
39 The major aspects are:
40 1) Given either a name/style, return a subclass of SkTypeface that
41 references the closest matching font available on the host system.
42 2) Given the data for a font (either in a stream or a file name), return
43 a typeface that allows access to that data.
44 3) Each typeface instance carries a 32bit ID for its corresponding font.
45 SkFontHost turns that ID into a stream to access the font's data.
46 4) Given a font ID, return a subclass of SkScalerContext, which connects a
47 font scaler (e.g. freetype or other) to the font's data.
48 5) Utilites to manage the font cache (budgeting) and gamma correction
49 */
50 class SK_API SkFontHost {
51 public:
52 /** LCDs either have their color elements arranged horizontally or
53 vertically. When rendering subpixel glyphs we need to know which way
54 round they are.
56 Note, if you change this after startup, you'll need to flush the glyph
57 cache because it'll have the wrong type of masks cached.
59 @deprecated use SkPixelGeometry instead.
60 */
61 enum LCDOrientation {
62 kHorizontal_LCDOrientation = 0, //!< this is the default
63 kVertical_LCDOrientation = 1
64 };
66 /** @deprecated set on Device creation. */
67 static void SetSubpixelOrientation(LCDOrientation orientation);
68 /** @deprecated get from Device. */
69 static LCDOrientation GetSubpixelOrientation();
71 /** LCD color elements can vary in order. For subpixel text we need to know
72 the order which the LCDs uses so that the color fringes are in the
73 correct place.
75 Note, if you change this after startup, you'll need to flush the glyph
76 cache because it'll have the wrong type of masks cached.
78 kNONE_LCDOrder means that the subpixel elements are not spatially
79 separated in any usable fashion.
81 @deprecated use SkPixelGeometry instead.
82 */
83 enum LCDOrder {
84 kRGB_LCDOrder = 0, //!< this is the default
85 kBGR_LCDOrder = 1,
86 kNONE_LCDOrder = 2
87 };
89 /** @deprecated set on Device creation. */
90 static void SetSubpixelOrder(LCDOrder order);
91 /** @deprecated get from Device. */
92 static LCDOrder GetSubpixelOrder();
94 private:
95 /** Return a new, closest matching typeface given either an existing family
96 (specified by a typeface in that family) or by a familyName and a
97 requested style.
98 1) If familyFace is null, use familyName.
99 2) If familyName is null, use data (UTF-16 to cover).
100 3) If all are null, return the default font that best matches style
101 */
102 static SkTypeface* CreateTypeface(const SkTypeface* familyFace,
103 const char familyName[],
104 SkTypeface::Style style);
106 /** Return a new typeface given the data buffer. If the data does not
107 represent a valid font, returns null.
109 If a typeface instance is returned, the caller is responsible for
110 calling unref() on the typeface when they are finished with it.
112 The returned typeface may or may not have called ref() on the stream
113 parameter. If the typeface has not called ref(), then it may have made
114 a copy of the releveant data. In either case, the caller is still
115 responsible for its refcnt ownership of the stream.
116 */
117 static SkTypeface* CreateTypefaceFromStream(SkStream*);
119 /** Return a new typeface from the specified file path. If the file does not
120 represent a valid font, this returns null. If a typeface is returned,
121 the caller is responsible for calling unref() when it is no longer used.
122 */
123 static SkTypeface* CreateTypefaceFromFile(const char path[]);
125 ///////////////////////////////////////////////////////////////////////////
127 friend class SkScalerContext;
128 friend class SkTypeface;
129 };
131 #endif