Bug 458861. Validate TrueType headers before activating downloaded font. r=roc, sr...
[wine-gecko.git] / layout / style / nsComputedDOMStyle.h
blobfed5742d0ea802bdbb216bf2eec4a786570e1263
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 * Christopher A. Aillon <christopher@aillon.com>
19 * Portions created by the Initial Developer are Copyright (C) 2002
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Christopher A. Aillon <christopher@aillon.com>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 /* DOM object returned from element.getComputedStyle() */
41 #ifndef nsComputedDOMStyle_h__
42 #define nsComputedDOMStyle_h__
44 #include "nsIComputedDOMStyle.h"
46 #include "nsROCSSPrimitiveValue.h"
47 #include "nsDOMCSSDeclaration.h"
48 #include "nsDOMCSSRGBColor.h"
49 #include "nsDOMCSSValueList.h"
50 #include "nsCSSProps.h"
52 #include "nsIPresShell.h"
53 #include "nsIContent.h"
54 #include "nsIFrame.h"
55 #include "nsCOMPtr.h"
56 #include "nsWeakReference.h"
57 #include "nsAutoPtr.h"
59 class nsComputedDOMStyle : public nsIComputedDOMStyle
61 public:
62 NS_DECL_ISUPPORTS
64 NS_IMETHOD Init(nsIDOMElement *aElement,
65 const nsAString& aPseudoElt,
66 nsIPresShell *aPresShell);
68 NS_DECL_NSICSSDECLARATION
70 NS_DECL_NSIDOMCSSSTYLEDECLARATION
72 nsComputedDOMStyle();
73 virtual ~nsComputedDOMStyle();
75 static void Shutdown();
77 private:
78 void FlushPendingReflows();
80 #define STYLE_STRUCT(name_, checkdata_cb_, ctor_args_) \
81 const nsStyle##name_ * GetStyle##name_() { \
82 return mStyleContextHolder->GetStyle##name_(); \
84 #include "nsStyleStructList.h"
85 #undef STYLE_STRUCT
87 nsresult GetEllipseRadii(const nsStyleCorners& aRadius,
88 PRUint8 aFullCorner,
89 nsIDOMCSSValue** aValue);
91 nsresult GetOffsetWidthFor(PRUint8 aSide, nsIDOMCSSValue** aValue);
93 nsresult GetAbsoluteOffset(PRUint8 aSide, nsIDOMCSSValue** aValue);
95 nsresult GetRelativeOffset(PRUint8 aSide, nsIDOMCSSValue** aValue);
97 nsresult GetStaticOffset(PRUint8 aSide, nsIDOMCSSValue** aValue);
99 nsresult GetPaddingWidthFor(PRUint8 aSide, nsIDOMCSSValue** aValue);
101 nsresult GetBorderColorsFor(PRUint8 aSide, nsIDOMCSSValue** aValue);
103 nsresult GetBorderStyleFor(PRUint8 aSide, nsIDOMCSSValue** aValue);
105 nsresult GetBorderWidthFor(PRUint8 aSide, nsIDOMCSSValue** aValue);
107 nsresult GetBorderColorFor(PRUint8 aSide, nsIDOMCSSValue** aValue);
109 nsresult GetMarginWidthFor(PRUint8 aSide, nsIDOMCSSValue** aValue);
111 PRBool GetLineHeightCoord(nscoord& aCoord);
113 nsresult GetCSSShadowArray(nsCSSShadowArray* aArray,
114 const nscolor& aDefaultColor,
115 PRBool aUsesSpread,
116 nsIDOMCSSValue** aValue);
118 /* Properties Queryable as CSSValues */
120 nsresult GetAppearance(nsIDOMCSSValue** aValue);
122 /* Box properties */
123 nsresult GetBoxAlign(nsIDOMCSSValue** aValue);
124 nsresult GetBoxDirection(nsIDOMCSSValue** aValue);
125 nsresult GetBoxFlex(nsIDOMCSSValue** aValue);
126 nsresult GetBoxOrdinalGroup(nsIDOMCSSValue** aValue);
127 nsresult GetBoxOrient(nsIDOMCSSValue** aValue);
128 nsresult GetBoxPack(nsIDOMCSSValue** aValue);
129 nsresult GetBoxSizing(nsIDOMCSSValue** aValue);
131 nsresult GetWidth(nsIDOMCSSValue** aValue);
132 nsresult GetHeight(nsIDOMCSSValue** aValue);
133 nsresult GetMaxHeight(nsIDOMCSSValue** aValue);
134 nsresult GetMaxWidth(nsIDOMCSSValue** aValue);
135 nsresult GetMinHeight(nsIDOMCSSValue** aValue);
136 nsresult GetMinWidth(nsIDOMCSSValue** aValue);
137 nsresult GetLeft(nsIDOMCSSValue** aValue);
138 nsresult GetTop(nsIDOMCSSValue** aValue);
139 nsresult GetRight(nsIDOMCSSValue** aValue);
140 nsresult GetBottom(nsIDOMCSSValue** aValue);
141 nsresult GetStackSizing(nsIDOMCSSValue** aValue);
143 /* Font properties */
144 nsresult GetColor(nsIDOMCSSValue** aValue);
145 nsresult GetFontFamily(nsIDOMCSSValue** aValue);
146 nsresult GetFontStyle(nsIDOMCSSValue** aValue);
147 nsresult GetFontSize(nsIDOMCSSValue** aValue);
148 nsresult GetFontSizeAdjust(nsIDOMCSSValue** aValue);
149 nsresult GetFontWeight(nsIDOMCSSValue** aValue);
150 nsresult GetFontVariant(nsIDOMCSSValue** aValue);
152 /* Background properties */
153 nsresult GetBackgroundAttachment(nsIDOMCSSValue** aValue);
154 nsresult GetBackgroundColor(nsIDOMCSSValue** aValue);
155 nsresult GetBackgroundImage(nsIDOMCSSValue** aValue);
156 nsresult GetBackgroundPosition(nsIDOMCSSValue** aValue);
157 nsresult GetBackgroundRepeat(nsIDOMCSSValue** aValue);
158 nsresult GetBackgroundClip(nsIDOMCSSValue** aValue);
159 nsresult GetBackgroundInlinePolicy(nsIDOMCSSValue** aValue);
160 nsresult GetBackgroundOrigin(nsIDOMCSSValue** aValue);
162 /* Padding properties */
163 nsresult GetPadding(nsIDOMCSSValue** aValue);
164 nsresult GetPaddingTop(nsIDOMCSSValue** aValue);
165 nsresult GetPaddingBottom(nsIDOMCSSValue** aValue);
166 nsresult GetPaddingLeft(nsIDOMCSSValue** aValue);
167 nsresult GetPaddingRight(nsIDOMCSSValue** aValue);
169 /* Table Properties */
170 nsresult GetBorderCollapse(nsIDOMCSSValue** aValue);
171 nsresult GetBorderSpacing(nsIDOMCSSValue** aValue);
172 nsresult GetCaptionSide(nsIDOMCSSValue** aValue);
173 nsresult GetEmptyCells(nsIDOMCSSValue** aValue);
174 nsresult GetTableLayout(nsIDOMCSSValue** aValue);
175 nsresult GetVerticalAlign(nsIDOMCSSValue** aValue);
177 /* Border Properties */
178 nsresult GetBorderStyle(nsIDOMCSSValue** aValue);
179 nsresult GetBorderWidth(nsIDOMCSSValue** aValue);
180 nsresult GetBorderTopStyle(nsIDOMCSSValue** aValue);
181 nsresult GetBorderBottomStyle(nsIDOMCSSValue** aValue);
182 nsresult GetBorderLeftStyle(nsIDOMCSSValue** aValue);
183 nsresult GetBorderRightStyle(nsIDOMCSSValue** aValue);
184 nsresult GetBorderTopWidth(nsIDOMCSSValue** aValue);
185 nsresult GetBorderBottomWidth(nsIDOMCSSValue** aValue);
186 nsresult GetBorderLeftWidth(nsIDOMCSSValue** aValue);
187 nsresult GetBorderRightWidth(nsIDOMCSSValue** aValue);
188 nsresult GetBorderTopColor(nsIDOMCSSValue** aValue);
189 nsresult GetBorderBottomColor(nsIDOMCSSValue** aValue);
190 nsresult GetBorderLeftColor(nsIDOMCSSValue** aValue);
191 nsresult GetBorderRightColor(nsIDOMCSSValue** aValue);
192 nsresult GetBorderBottomColors(nsIDOMCSSValue** aValue);
193 nsresult GetBorderLeftColors(nsIDOMCSSValue** aValue);
194 nsresult GetBorderRightColors(nsIDOMCSSValue** aValue);
195 nsresult GetBorderTopColors(nsIDOMCSSValue** aValue);
196 nsresult GetBorderRadiusBottomLeft(nsIDOMCSSValue** aValue);
197 nsresult GetBorderRadiusBottomRight(nsIDOMCSSValue** aValue);
198 nsresult GetBorderRadiusTopLeft(nsIDOMCSSValue** aValue);
199 nsresult GetBorderRadiusTopRight(nsIDOMCSSValue** aValue);
200 nsresult GetFloatEdge(nsIDOMCSSValue** aValue);
201 nsresult GetBorderImage(nsIDOMCSSValue** aValue);
203 /* Box Shadow */
204 nsresult GetBoxShadow(nsIDOMCSSValue** aValue);
206 /* Window Shadow */
207 nsresult GetWindowShadow(nsIDOMCSSValue** aValue);
209 /* Margin Properties */
210 nsresult GetMarginWidth(nsIDOMCSSValue** aValue);
211 nsresult GetMarginTopWidth(nsIDOMCSSValue** aValue);
212 nsresult GetMarginBottomWidth(nsIDOMCSSValue** aValue);
213 nsresult GetMarginLeftWidth(nsIDOMCSSValue** aValue);
214 nsresult GetMarginRightWidth(nsIDOMCSSValue** aValue);
216 /* Outline Properties */
217 nsresult GetOutline(nsIDOMCSSValue** aValue);
218 nsresult GetOutlineWidth(nsIDOMCSSValue** aValue);
219 nsresult GetOutlineStyle(nsIDOMCSSValue** aValue);
220 nsresult GetOutlineColor(nsIDOMCSSValue** aValue);
221 nsresult GetOutlineOffset(nsIDOMCSSValue** aValue);
222 nsresult GetOutlineRadiusBottomLeft(nsIDOMCSSValue** aValue);
223 nsresult GetOutlineRadiusBottomRight(nsIDOMCSSValue** aValue);
224 nsresult GetOutlineRadiusTopLeft(nsIDOMCSSValue** aValue);
225 nsresult GetOutlineRadiusTopRight(nsIDOMCSSValue** aValue);
227 /* Content Properties */
228 nsresult GetContent(nsIDOMCSSValue** aValue);
229 nsresult GetCounterIncrement(nsIDOMCSSValue** aValue);
230 nsresult GetCounterReset(nsIDOMCSSValue** aValue);
231 nsresult GetMarkerOffset(nsIDOMCSSValue** aValue);
233 /* Quotes Properties */
234 nsresult GetQuotes(nsIDOMCSSValue** aValue);
236 /* z-index */
237 nsresult GetZIndex(nsIDOMCSSValue** aValue);
239 /* List properties */
240 nsresult GetListStyleImage(nsIDOMCSSValue** aValue);
241 nsresult GetListStylePosition(nsIDOMCSSValue** aValue);
242 nsresult GetListStyleType(nsIDOMCSSValue** aValue);
243 nsresult GetImageRegion(nsIDOMCSSValue** aValue);
245 /* Text Properties */
246 nsresult GetLineHeight(nsIDOMCSSValue** aValue);
247 nsresult GetTextAlign(nsIDOMCSSValue** aValue);
248 nsresult GetTextDecoration(nsIDOMCSSValue** aValue);
249 nsresult GetTextIndent(nsIDOMCSSValue** aValue);
250 nsresult GetTextTransform(nsIDOMCSSValue** aValue);
251 nsresult GetTextShadow(nsIDOMCSSValue** aValue);
252 nsresult GetLetterSpacing(nsIDOMCSSValue** aValue);
253 nsresult GetWordSpacing(nsIDOMCSSValue** aValue);
254 nsresult GetWhiteSpace(nsIDOMCSSValue** aValue);
255 nsresult GetWordWrap(nsIDOMCSSValue** aValue);
257 /* Visibility properties */
258 nsresult GetOpacity(nsIDOMCSSValue** aValue);
259 nsresult GetVisibility(nsIDOMCSSValue** aValue);
261 /* Direction properties */
262 nsresult GetDirection(nsIDOMCSSValue** aValue);
263 nsresult GetUnicodeBidi(nsIDOMCSSValue** aValue);
265 /* Display properties */
266 nsresult GetBinding(nsIDOMCSSValue** aValue);
267 nsresult GetClear(nsIDOMCSSValue** aValue);
268 nsresult GetCssFloat(nsIDOMCSSValue** aValue);
269 nsresult GetDisplay(nsIDOMCSSValue** aValue);
270 nsresult GetPosition(nsIDOMCSSValue** aValue);
271 nsresult GetClip(nsIDOMCSSValue** aValue);
272 nsresult GetOverflow(nsIDOMCSSValue** aValue);
273 nsresult GetOverflowX(nsIDOMCSSValue** aValue);
274 nsresult GetOverflowY(nsIDOMCSSValue** aValue);
275 nsresult GetPageBreakAfter(nsIDOMCSSValue** aValue);
276 nsresult GetPageBreakBefore(nsIDOMCSSValue** aValue);
277 nsresult GetMozTransform(nsIDOMCSSValue** aValue);
278 nsresult GetMozTransformOrigin(nsIDOMCSSValue **aValue);
280 /* User interface properties */
281 nsresult GetCursor(nsIDOMCSSValue** aValue);
282 nsresult GetForceBrokenImageIcon(nsIDOMCSSValue** aValue);
283 nsresult GetIMEMode(nsIDOMCSSValue** aValue);
284 nsresult GetUserFocus(nsIDOMCSSValue** aValue);
285 nsresult GetUserInput(nsIDOMCSSValue** aValue);
286 nsresult GetUserModify(nsIDOMCSSValue** aValue);
287 nsresult GetUserSelect(nsIDOMCSSValue** aValue);
289 /* Column properties */
290 nsresult GetColumnCount(nsIDOMCSSValue** aValue);
291 nsresult GetColumnWidth(nsIDOMCSSValue** aValue);
292 nsresult GetColumnGap(nsIDOMCSSValue** aValue);
293 nsresult GetColumnRuleWidth(nsIDOMCSSValue** aValue);
294 nsresult GetColumnRuleStyle(nsIDOMCSSValue** aValue);
295 nsresult GetColumnRuleColor(nsIDOMCSSValue** aValue);
297 #ifdef MOZ_SVG
298 /* SVG properties */
299 nsresult GetSVGPaintFor(PRBool aFill, nsIDOMCSSValue** aValue);
301 nsresult GetFill(nsIDOMCSSValue** aValue);
302 nsresult GetStroke(nsIDOMCSSValue** aValue);
303 nsresult GetMarkerEnd(nsIDOMCSSValue** aValue);
304 nsresult GetMarkerMid(nsIDOMCSSValue** aValue);
305 nsresult GetMarkerStart(nsIDOMCSSValue** aValue);
306 nsresult GetStrokeDasharray(nsIDOMCSSValue** aValue);
308 nsresult GetStrokeDashoffset(nsIDOMCSSValue** aValue);
309 nsresult GetStrokeWidth(nsIDOMCSSValue** aValue);
311 nsresult GetFillOpacity(nsIDOMCSSValue** aValue);
312 nsresult GetFloodOpacity(nsIDOMCSSValue** aValue);
313 nsresult GetStopOpacity(nsIDOMCSSValue** aValue);
314 nsresult GetStrokeMiterlimit(nsIDOMCSSValue** aValue);
315 nsresult GetStrokeOpacity(nsIDOMCSSValue** aValue);
317 nsresult GetClipRule(nsIDOMCSSValue** aValue);
318 nsresult GetFillRule(nsIDOMCSSValue** aValue);
319 nsresult GetStrokeLinecap(nsIDOMCSSValue** aValue);
320 nsresult GetStrokeLinejoin(nsIDOMCSSValue** aValue);
321 nsresult GetTextAnchor(nsIDOMCSSValue** aValue);
323 nsresult GetColorInterpolation(nsIDOMCSSValue** aValue);
324 nsresult GetColorInterpolationFilters(nsIDOMCSSValue** aValue);
325 nsresult GetDominantBaseline(nsIDOMCSSValue** aValue);
326 nsresult GetPointerEvents(nsIDOMCSSValue** aValue);
327 nsresult GetShapeRendering(nsIDOMCSSValue** aValue);
328 nsresult GetTextRendering(nsIDOMCSSValue** aValue);
330 nsresult GetFloodColor(nsIDOMCSSValue** aValue);
331 nsresult GetLightingColor(nsIDOMCSSValue** aValue);
332 nsresult GetStopColor(nsIDOMCSSValue** aValue);
334 nsresult GetClipPath(nsIDOMCSSValue** aValue);
335 nsresult GetFilter(nsIDOMCSSValue** aValue);
336 nsresult GetMask(nsIDOMCSSValue** aValue);
337 #endif // MOZ_SVG
339 nsROCSSPrimitiveValue* GetROCSSPrimitiveValue();
340 nsDOMCSSValueList* GetROCSSValueList(PRBool aCommaDelimited);
341 nsresult SetToRGBAColor(nsROCSSPrimitiveValue* aValue, nscolor aColor);
344 * A method to get a percentage base for a percentage value. Returns PR_TRUE
345 * if a percentage base value was determined, PR_FALSE otherwise.
347 typedef PRBool (nsComputedDOMStyle::*PercentageBaseGetter)(nscoord&);
350 * Method to set aValue to aCoord. If aCoord is a percentage value and
351 * aPercentageBaseGetter is not null, aPercentageBaseGetter is called. If it
352 * returns PR_TRUE, the percentage base it outputs in its out param is used
353 * to compute an nscoord value. If the getter is null or returns PR_FALSE,
354 * the percent value of aCoord is set as a percent value on aValue. aTable,
355 * if not null, is the keyword table to handle eStyleUnit_Enumerated. When
356 * calling SetAppUnits on aValue (for coord or percent values), the value
357 * passed in will be PR_MAX of the value in aMinAppUnits and the PR_MIN of
358 * the actual value in aCoord and the value in aMaxAppUnits.
360 * XXXbz should caller pass in some sort of bitfield indicating which units
361 * can be expected or something?
363 void SetValueToCoord(nsROCSSPrimitiveValue* aValue,
364 const nsStyleCoord& aCoord,
365 PercentageBaseGetter aPercentageBaseGetter = nsnull,
366 const PRInt32 aTable[] = nsnull,
367 nscoord aMinAppUnits = nscoord_MIN,
368 nscoord aMaxAppUnits = nscoord_MAX);
371 * If aCoord is a eStyleUnit_Coord returns the nscoord. If it's
372 * eStyleUnit_Percent, attempts to resolve the percentage base and returns
373 * the resulting nscoord. If it's some other unit or a percentge base can't
374 * be determined, returns aDefaultValue.
376 nscoord StyleCoordToNSCoord(const nsStyleCoord& aCoord,
377 PercentageBaseGetter aPercentageBaseGetter,
378 nscoord aDefaultValue);
380 PRBool GetCBContentWidth(nscoord& aWidth);
381 PRBool GetCBContentHeight(nscoord& aWidth);
382 PRBool GetFrameBoundsWidthForTransform(nscoord &aWidth);
383 PRBool GetFrameBoundsHeightForTransform(nscoord &aHeight);
384 PRBool GetFrameBorderRectWidth(nscoord& aWidth);
386 struct ComputedStyleMapEntry
388 // Create a pointer-to-member-function type.
389 typedef nsresult (nsComputedDOMStyle::*ComputeMethod)(nsIDOMCSSValue**);
391 nsCSSProperty mProperty;
392 ComputeMethod mGetter;
395 static const ComputedStyleMapEntry* GetQueryablePropertyMap(PRUint32* aLength);
397 CSS2PropertiesTearoff mInner;
399 // We don't really have a good immutable representation of "presentation".
400 // Given the way GetComputedStyle is currently used, we should just grab the
401 // 0th presshell, if any, from the document.
402 nsWeakPtr mDocumentWeak;
403 nsCOMPtr<nsIContent> mContent;
406 * Strong reference to the style context while we're accessing the data from
407 * it. This can be either a style context we resolved ourselves or a style
408 * context we got from our frame.
410 nsRefPtr<nsStyleContext> mStyleContextHolder;
411 nsCOMPtr<nsIAtom> mPseudo;
414 * While computing style data, the primary frame for mContent --- named "outer"
415 * because we should use it to compute positioning data. Null
416 * otherwise.
418 nsIFrame* mOuterFrame;
420 * While computing style data, the "inner frame" for mContent --- the frame
421 * which we should use to compute margin, border, padding and content data. Null
422 * otherwise.
424 nsIFrame* mInnerFrame;
426 * While computing style data, the presshell we're working with. Null
427 * otherwise.
429 nsIPresShell* mPresShell;
431 PRInt32 mAppUnitsPerInch; /* For unit conversions */
434 #endif /* nsComputedDOMStyle_h__ */