Bug 458861. Validate TrueType headers before activating downloaded font. r=roc, sr...
[wine-gecko.git] / gfx / src / nsRenderingContextImpl.h
blob686d8282b6c4721f1cbef4c408c475216ef3c2f2
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef nsRenderingContextImpl_h___
39 #define nsRenderingContextImpl_h___
41 #include "gfxCore.h"
42 #include "nsIRenderingContext.h"
43 #include "nsPoint.h"
44 #include "nsSize.h"
46 class gfxContext;
48 class nsRenderingContextImpl : public nsIRenderingContext
51 // CLASS MEMBERS
53 public:
54 nsRenderingContextImpl();
57 // CLASS METHODS
59 /**
60 * Return the maximum length of a string that can be handled by the platform
61 * using the current font metrics.
62 * The implementation here is just a stub; classes that don't override
63 * the safe string methods need to implement this.
65 virtual PRInt32 GetMaxStringLength() = 0;
67 /**
68 * Let the device context know whether we want text reordered with
69 * right-to-left base direction
71 NS_IMETHOD GetRightToLeftText(PRBool* aIsRTL);
73 // Safe string method variants: by default, these defer to the more
74 // elaborate methods below
75 NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth,
76 PRInt32 *aFontID = nsnull);
77 NS_IMETHOD GetWidth(const char* aString, nscoord& aWidth);
78 NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY,
79 PRInt32 aFontID = -1,
80 const nscoord* aSpacing = nsnull);
82 // Safe string methods
83 NS_IMETHOD GetWidth(const char* aString, PRUint32 aLength,
84 nscoord& aWidth);
85 NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength,
86 nscoord &aWidth, PRInt32 *aFontID = nsnull);
88 NS_IMETHOD GetTextDimensions(const char* aString, PRUint32 aLength,
89 nsTextDimensions& aDimensions);
90 NS_IMETHOD GetTextDimensions(const PRUnichar* aString, PRUint32 aLength,
91 nsTextDimensions& aDimensions, PRInt32* aFontID = nsnull);
93 #if defined(_WIN32) || defined(XP_OS2) || defined(MOZ_X11) || defined(XP_BEOS)
94 NS_IMETHOD GetTextDimensions(const char* aString,
95 PRInt32 aLength,
96 PRInt32 aAvailWidth,
97 PRInt32* aBreaks,
98 PRInt32 aNumBreaks,
99 nsTextDimensions& aDimensions,
100 PRInt32& aNumCharsFit,
101 nsTextDimensions& aLastWordDimensions,
102 PRInt32* aFontID = nsnull);
104 NS_IMETHOD GetTextDimensions(const PRUnichar* aString,
105 PRInt32 aLength,
106 PRInt32 aAvailWidth,
107 PRInt32* aBreaks,
108 PRInt32 aNumBreaks,
109 nsTextDimensions& aDimensions,
110 PRInt32& aNumCharsFit,
111 nsTextDimensions& aLastWordDimensions,
112 PRInt32* aFontID = nsnull);
113 #endif
114 #ifdef MOZ_MATHML
115 NS_IMETHOD
116 GetBoundingMetrics(const char* aString,
117 PRUint32 aLength,
118 nsBoundingMetrics& aBoundingMetrics);
119 NS_IMETHOD
120 GetBoundingMetrics(const PRUnichar* aString,
121 PRUint32 aLength,
122 nsBoundingMetrics& aBoundingMetrics,
123 PRInt32* aFontID = nsnull);
124 #endif
125 NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,
126 nscoord aX, nscoord aY,
127 const nscoord* aSpacing = nsnull);
128 NS_IMETHOD DrawString(const PRUnichar *aString, PRUint32 aLength,
129 nscoord aX, nscoord aY,
130 PRInt32 aFontID = -1,
131 const nscoord* aSpacing = nsnull);
133 // Unsafe platform-specific implementations
134 NS_IMETHOD GetWidthInternal(const char* aString, PRUint32 aLength,
135 nscoord& aWidth)
136 { return NS_ERROR_NOT_IMPLEMENTED; }
137 NS_IMETHOD GetWidthInternal(const PRUnichar *aString, PRUint32 aLength,
138 nscoord &aWidth, PRInt32 *aFontID = nsnull)
139 { return NS_ERROR_NOT_IMPLEMENTED; }
141 NS_IMETHOD GetTextDimensionsInternal(const char* aString, PRUint32 aLength,
142 nsTextDimensions& aDimensions)
143 { return NS_ERROR_NOT_IMPLEMENTED; }
144 NS_IMETHOD GetTextDimensionsInternal(const PRUnichar* aString, PRUint32 aLength,
145 nsTextDimensions& aDimensions, PRInt32* aFontID = nsnull)
146 { return NS_ERROR_NOT_IMPLEMENTED; }
148 #if defined(_WIN32) || defined(XP_OS2) || defined(MOZ_X11) || defined(XP_BEOS)
149 NS_IMETHOD GetTextDimensionsInternal(const char* aString,
150 PRInt32 aLength,
151 PRInt32 aAvailWidth,
152 PRInt32* aBreaks,
153 PRInt32 aNumBreaks,
154 nsTextDimensions& aDimensions,
155 PRInt32& aNumCharsFit,
156 nsTextDimensions& aLastWordDimensions,
157 PRInt32* aFontID = nsnull)
158 { return NS_ERROR_NOT_IMPLEMENTED; }
160 NS_IMETHOD GetTextDimensionsInternal(const PRUnichar* aString,
161 PRInt32 aLength,
162 PRInt32 aAvailWidth,
163 PRInt32* aBreaks,
164 PRInt32 aNumBreaks,
165 nsTextDimensions& aDimensions,
166 PRInt32& aNumCharsFit,
167 nsTextDimensions& aLastWordDimensions,
168 PRInt32* aFontID = nsnull)
169 { return NS_ERROR_NOT_IMPLEMENTED; }
170 #endif
171 #ifdef MOZ_MATHML
172 NS_IMETHOD
173 GetBoundingMetricsInternal(const char* aString,
174 PRUint32 aLength,
175 nsBoundingMetrics& aBoundingMetrics)
176 { return NS_ERROR_NOT_IMPLEMENTED; }
177 NS_IMETHOD
178 GetBoundingMetricsInternal(const PRUnichar* aString,
179 PRUint32 aLength,
180 nsBoundingMetrics& aBoundingMetrics,
181 PRInt32* aFontID = nsnull)
182 { return NS_ERROR_NOT_IMPLEMENTED; }
183 #endif
184 NS_IMETHOD DrawStringInternal(const char *aString, PRUint32 aLength,
185 nscoord aX, nscoord aY,
186 const nscoord* aSpacing = nsnull)
187 { return NS_ERROR_NOT_IMPLEMENTED; }
188 NS_IMETHOD DrawStringInternal(const PRUnichar *aString, PRUint32 aLength,
189 nscoord aX, nscoord aY,
190 PRInt32 aFontID = -1,
191 const nscoord* aSpacing = nsnull)
192 { return NS_ERROR_NOT_IMPLEMENTED; }
194 gfxContext *ThebesContext() { return nsnull; }
196 protected:
197 virtual ~nsRenderingContextImpl();
201 #endif /* nsRenderingContextImpl */