/src/mozilla-central/layout/style/nsComputedDOMStyle.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | /* DOM object returned from element.getComputedStyle() */ |
8 | | |
9 | | #ifndef nsComputedDOMStyle_h__ |
10 | | #define nsComputedDOMStyle_h__ |
11 | | |
12 | | #include "mozilla/ArenaRefPtr.h" |
13 | | #include "mozilla/ArenaRefPtrInlines.h" |
14 | | #include "mozilla/Attributes.h" |
15 | | #include "mozilla/StyleComplexColor.h" |
16 | | #include "mozilla/UniquePtr.h" |
17 | | #include "mozilla/dom/Element.h" |
18 | | #include "nsCOMPtr.h" |
19 | | #include "nsContentUtils.h" |
20 | | #include "nscore.h" |
21 | | #include "nsDOMCSSDeclaration.h" |
22 | | #include "mozilla/ComputedStyle.h" |
23 | | #include "nsIWeakReferenceUtils.h" |
24 | | #include "mozilla/gfx/Types.h" |
25 | | #include "nsCoord.h" |
26 | | #include "nsColor.h" |
27 | | #include "nsStyleStruct.h" |
28 | | #include "mozilla/WritingModes.h" |
29 | | |
30 | | namespace mozilla { |
31 | | namespace dom { |
32 | | class DocGroup; |
33 | | class Element; |
34 | | } // namespace dom |
35 | | struct ComputedGridTrackInfo; |
36 | | } // namespace mozilla |
37 | | |
38 | | struct ComputedStyleMap; |
39 | | struct nsCSSKTableEntry; |
40 | | class nsIFrame; |
41 | | class nsIPresShell; |
42 | | class nsDOMCSSValueList; |
43 | | struct nsMargin; |
44 | | class nsROCSSPrimitiveValue; |
45 | | class nsStyleCoord; |
46 | | class nsStyleCorners; |
47 | | struct nsStyleFilter; |
48 | | class nsStyleGradient; |
49 | | struct nsStyleImage; |
50 | | class nsStyleSides; |
51 | | struct nsTimingFunction; |
52 | | |
53 | | class nsComputedDOMStyle final : public nsDOMCSSDeclaration |
54 | | , public nsStubMutationObserver |
55 | | { |
56 | | private: |
57 | | // Convenience typedefs: |
58 | | typedef nsCSSKTableEntry KTableEntry; |
59 | | typedef mozilla::dom::CSSValue CSSValue; |
60 | | typedef mozilla::StyleGeometryBox StyleGeometryBox; |
61 | | |
62 | | public: |
63 | | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
64 | | NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsComputedDOMStyle, |
65 | | nsICSSDeclaration) |
66 | | |
67 | | NS_DECL_NSIDOMCSSSTYLEDECLARATION_HELPER |
68 | | nsresult GetPropertyValue(const nsCSSPropertyID aPropID, |
69 | | nsAString& aValue) override; |
70 | | nsresult SetPropertyValue(const nsCSSPropertyID aPropID, |
71 | | const nsAString& aValue, |
72 | | nsIPrincipal* aSubjectPrincipal) override; |
73 | | |
74 | | void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aPropName) final; |
75 | | |
76 | | enum StyleType { |
77 | | eDefaultOnly, // Only includes UA and user sheets |
78 | | eAll // Includes all stylesheets |
79 | | }; |
80 | | |
81 | | nsComputedDOMStyle(mozilla::dom::Element* aElement, |
82 | | const nsAString& aPseudoElt, |
83 | | nsIDocument* aDocument, |
84 | | StyleType aStyleType); |
85 | | |
86 | | nsINode* GetParentObject() override |
87 | 0 | { |
88 | 0 | return mElement; |
89 | 0 | } |
90 | | |
91 | | static already_AddRefed<mozilla::ComputedStyle> |
92 | | GetComputedStyle(mozilla::dom::Element* aElement, nsAtom* aPseudo, |
93 | | StyleType aStyleType = eAll); |
94 | | |
95 | | static already_AddRefed<mozilla::ComputedStyle> |
96 | | GetComputedStyleNoFlush(mozilla::dom::Element* aElement, |
97 | | nsAtom* aPseudo, |
98 | | StyleType aStyleType = eAll) |
99 | 0 | { |
100 | 0 | return DoGetComputedStyleNoFlush(aElement, |
101 | 0 | aPseudo, |
102 | 0 | nsContentUtils::GetPresShellForContent(aElement), |
103 | 0 | aStyleType); |
104 | 0 | } |
105 | | |
106 | | static already_AddRefed<mozilla::ComputedStyle> |
107 | | GetUnanimatedComputedStyleNoFlush(mozilla::dom::Element* aElement, |
108 | | nsAtom* aPseudo); |
109 | | |
110 | | // Helper for nsDOMWindowUtils::GetVisitedDependentComputedStyle |
111 | 0 | void SetExposeVisitedStyle(bool aExpose) { |
112 | 0 | NS_ASSERTION(aExpose != mExposeVisitedStyle, "should always be changing"); |
113 | 0 | mExposeVisitedStyle = aExpose; |
114 | 0 | } |
115 | | |
116 | | |
117 | | void GetCSSImageURLs(const nsAString& aPropertyName, |
118 | | nsTArray<nsString>& aImageURLs, |
119 | | mozilla::ErrorResult& aRv) final; |
120 | | |
121 | | // nsDOMCSSDeclaration abstract methods which should never be called |
122 | | // on a nsComputedDOMStyle object, but must be defined to avoid |
123 | | // compile errors. |
124 | | mozilla::DeclarationBlock* GetOrCreateCSSDeclaration( |
125 | | Operation aOperation, mozilla::DeclarationBlock** aCreated) final; |
126 | | virtual nsresult SetCSSDeclaration(mozilla::DeclarationBlock*, |
127 | | mozilla::MutationClosureData*) override; |
128 | | virtual nsIDocument* DocToUpdate() override; |
129 | | |
130 | | nsDOMCSSDeclaration::ParsingEnvironment |
131 | | GetParsingEnvironment(nsIPrincipal* aSubjectPrincipal) const final; |
132 | | |
133 | | static already_AddRefed<nsROCSSPrimitiveValue> |
134 | | MatrixToCSSValue(const mozilla::gfx::Matrix4x4& aMatrix); |
135 | | |
136 | | static void RegisterPrefChangeCallbacks(); |
137 | | static void UnregisterPrefChangeCallbacks(); |
138 | | |
139 | | // nsIMutationObserver |
140 | | NS_DECL_NSIMUTATIONOBSERVER_PARENTCHAINCHANGED |
141 | | |
142 | | private: |
143 | | virtual ~nsComputedDOMStyle(); |
144 | | |
145 | 0 | void AssertFlushedPendingReflows() { |
146 | 0 | NS_ASSERTION(mFlushedPendingReflows, |
147 | 0 | "property getter should have been marked layout-dependent"); |
148 | 0 | } |
149 | | |
150 | | nsMargin GetAdjustedValuesForBoxSizing(); |
151 | | |
152 | | // Helper method for DoGetTextAlign[Last]. |
153 | | already_AddRefed<CSSValue> CreateTextAlignValue(uint8_t aAlign, |
154 | | bool aAlignTrue, |
155 | | const KTableEntry aTable[]); |
156 | | // This indicates error by leaving mComputedStyle null. |
157 | | void UpdateCurrentStyleSources(bool aNeedsLayoutFlush); |
158 | | void ClearCurrentStyleSources(); |
159 | | |
160 | | // Helper functions called by UpdateCurrentStyleSources. |
161 | | void ClearComputedStyle(); |
162 | | void SetResolvedComputedStyle(RefPtr<mozilla::ComputedStyle>&& aContext, |
163 | | uint64_t aGeneration); |
164 | | void SetFrameComputedStyle(mozilla::ComputedStyle* aStyle, uint64_t aGeneration); |
165 | | |
166 | | static already_AddRefed<mozilla::ComputedStyle> |
167 | | DoGetComputedStyleNoFlush(mozilla::dom::Element* aElement, |
168 | | nsAtom* aPseudo, |
169 | | nsIPresShell* aPresShell, |
170 | | StyleType aStyleType); |
171 | | |
172 | | #define STYLE_STRUCT(name_) \ |
173 | 0 | const nsStyle##name_ * Style##name_() { \ |
174 | 0 | return mComputedStyle->Style##name_(); \ |
175 | 0 | } Unexecuted instantiation: nsComputedDOMStyle::StyleFont() Unexecuted instantiation: nsComputedDOMStyle::StyleColor() Unexecuted instantiation: nsComputedDOMStyle::StyleList() Unexecuted instantiation: nsComputedDOMStyle::StyleText() Unexecuted instantiation: nsComputedDOMStyle::StyleVisibility() Unexecuted instantiation: nsComputedDOMStyle::StyleUI() Unexecuted instantiation: nsComputedDOMStyle::StyleTableBorder() Unexecuted instantiation: nsComputedDOMStyle::StyleSVG() Unexecuted instantiation: nsComputedDOMStyle::StyleBackground() Unexecuted instantiation: nsComputedDOMStyle::StylePosition() Unexecuted instantiation: nsComputedDOMStyle::StyleTextReset() Unexecuted instantiation: nsComputedDOMStyle::StyleDisplay() Unexecuted instantiation: nsComputedDOMStyle::StyleContent() Unexecuted instantiation: nsComputedDOMStyle::StyleUIReset() Unexecuted instantiation: nsComputedDOMStyle::StyleTable() Unexecuted instantiation: nsComputedDOMStyle::StyleMargin() Unexecuted instantiation: nsComputedDOMStyle::StylePadding() Unexecuted instantiation: nsComputedDOMStyle::StyleBorder() Unexecuted instantiation: nsComputedDOMStyle::StyleOutline() Unexecuted instantiation: nsComputedDOMStyle::StyleXUL() Unexecuted instantiation: nsComputedDOMStyle::StyleSVGReset() Unexecuted instantiation: nsComputedDOMStyle::StyleColumn() Unexecuted instantiation: nsComputedDOMStyle::StyleEffects() |
176 | | #include "nsStyleStructList.h" |
177 | | #undef STYLE_STRUCT |
178 | | |
179 | | already_AddRefed<CSSValue> GetEllipseRadii(const nsStyleCorners& aRadius, |
180 | | mozilla::Corner aFullCorner); |
181 | | |
182 | | already_AddRefed<CSSValue> GetOffsetWidthFor(mozilla::Side aSide); |
183 | | |
184 | | already_AddRefed<CSSValue> GetAbsoluteOffset(mozilla::Side aSide); |
185 | | |
186 | | already_AddRefed<CSSValue> GetRelativeOffset(mozilla::Side aSide); |
187 | | |
188 | | already_AddRefed<CSSValue> GetStickyOffset(mozilla::Side aSide); |
189 | | |
190 | | already_AddRefed<CSSValue> GetStaticOffset(mozilla::Side aSide); |
191 | | |
192 | | already_AddRefed<CSSValue> GetPaddingWidthFor(mozilla::Side aSide); |
193 | | |
194 | | already_AddRefed<CSSValue> GetBorderStyleFor(mozilla::Side aSide); |
195 | | |
196 | | already_AddRefed<CSSValue> GetBorderWidthFor(mozilla::Side aSide); |
197 | | |
198 | | already_AddRefed<CSSValue> GetBorderColorFor(mozilla::Side aSide); |
199 | | |
200 | | already_AddRefed<CSSValue> GetMarginWidthFor(mozilla::Side aSide); |
201 | | |
202 | | already_AddRefed<CSSValue> GetFallbackValue(const nsStyleSVGPaint* aPaint); |
203 | | |
204 | | already_AddRefed<CSSValue> GetSVGPaintFor(bool aFill); |
205 | | |
206 | | already_AddRefed<CSSValue> GetTransformValue(nsCSSValueSharedList* aSpecifiedTransform); |
207 | | |
208 | | // Appends all aLineNames (may be empty) space-separated to aResult. |
209 | | void AppendGridLineNames(nsString& aResult, |
210 | | const nsTArray<nsString>& aLineNames); |
211 | | // Appends aLineNames as a CSSValue* to aValueList. If aLineNames is empty |
212 | | // a value ("[]") is only appended if aSuppressEmptyList is false. |
213 | | void AppendGridLineNames(nsDOMCSSValueList* aValueList, |
214 | | const nsTArray<nsString>& aLineNames, |
215 | | bool aSuppressEmptyList = true); |
216 | | // Appends aLineNames1/2 (if non-empty) as a CSSValue* to aValueList. |
217 | | void AppendGridLineNames(nsDOMCSSValueList* aValueList, |
218 | | const nsTArray<nsString>& aLineNames1, |
219 | | const nsTArray<nsString>& aLineNames2); |
220 | | already_AddRefed<CSSValue> GetGridTrackSize(const nsStyleCoord& aMinSize, |
221 | | const nsStyleCoord& aMaxSize); |
222 | | already_AddRefed<CSSValue> GetGridTemplateColumnsRows( |
223 | | const nsStyleGridTemplate& aTrackList, |
224 | | const mozilla::ComputedGridTrackInfo* aTrackInfo); |
225 | | already_AddRefed<CSSValue> GetGridLine(const nsStyleGridLine& aGridLine); |
226 | | |
227 | | bool GetLineHeightCoord(nscoord& aCoord); |
228 | | |
229 | | already_AddRefed<CSSValue> GetCSSShadowArray(nsCSSShadowArray* aArray, |
230 | | bool aIsBoxShadow); |
231 | | |
232 | | void GetCSSGradientString(const nsStyleGradient* aGradient, |
233 | | nsAString& aString); |
234 | | void GetImageRectString(nsIURI* aURI, |
235 | | const nsStyleSides& aCropRect, |
236 | | nsString& aString); |
237 | | already_AddRefed<CSSValue> GetScrollSnapPoints(const nsStyleCoord& aCoord); |
238 | | void AppendTimingFunction(nsDOMCSSValueList *aValueList, |
239 | | const nsTimingFunction& aTimingFunction); |
240 | | |
241 | | bool ShouldHonorMinSizeAutoInAxis(mozilla::PhysicalAxis aAxis); |
242 | | |
243 | | /* Properties queryable as CSSValues. |
244 | | * To avoid a name conflict with nsIDOM*CSS2Properties, these are all |
245 | | * DoGetXXX instead of GetXXX. |
246 | | */ |
247 | | |
248 | | |
249 | | /* Box properties */ |
250 | | already_AddRefed<CSSValue> DoGetBoxFlex(); |
251 | | |
252 | | already_AddRefed<CSSValue> DoGetWidth(); |
253 | | already_AddRefed<CSSValue> DoGetHeight(); |
254 | | already_AddRefed<CSSValue> DoGetMaxHeight(); |
255 | | already_AddRefed<CSSValue> DoGetMaxWidth(); |
256 | | already_AddRefed<CSSValue> DoGetMinHeight(); |
257 | | already_AddRefed<CSSValue> DoGetMinWidth(); |
258 | | already_AddRefed<CSSValue> DoGetObjectPosition(); |
259 | | already_AddRefed<CSSValue> DoGetLeft(); |
260 | | already_AddRefed<CSSValue> DoGetTop(); |
261 | | already_AddRefed<CSSValue> DoGetRight(); |
262 | | already_AddRefed<CSSValue> DoGetBottom(); |
263 | | |
264 | | /* Color */ |
265 | | already_AddRefed<CSSValue> DoGetColor(); |
266 | | |
267 | | /* Font properties */ |
268 | | already_AddRefed<CSSValue> DoGetOsxFontSmoothing(); |
269 | | already_AddRefed<CSSValue> DoGetFontVariant(); |
270 | | |
271 | | /* Grid properties */ |
272 | | already_AddRefed<CSSValue> DoGetGridAutoFlow(); |
273 | | already_AddRefed<CSSValue> DoGetGridAutoColumns(); |
274 | | already_AddRefed<CSSValue> DoGetGridAutoRows(); |
275 | | already_AddRefed<CSSValue> DoGetGridTemplateAreas(); |
276 | | already_AddRefed<CSSValue> DoGetGridTemplateColumns(); |
277 | | already_AddRefed<CSSValue> DoGetGridTemplateRows(); |
278 | | already_AddRefed<CSSValue> DoGetGridColumnStart(); |
279 | | already_AddRefed<CSSValue> DoGetGridColumnEnd(); |
280 | | already_AddRefed<CSSValue> DoGetGridRowStart(); |
281 | | already_AddRefed<CSSValue> DoGetGridRowEnd(); |
282 | | |
283 | | /* StyleImageLayer properties */ |
284 | | already_AddRefed<CSSValue> DoGetImageLayerImage(const nsStyleImageLayers& aLayers); |
285 | | already_AddRefed<CSSValue> DoGetImageLayerPosition(const nsStyleImageLayers& aLayers); |
286 | | already_AddRefed<CSSValue> DoGetImageLayerPositionX(const nsStyleImageLayers& aLayers); |
287 | | already_AddRefed<CSSValue> DoGetImageLayerPositionY(const nsStyleImageLayers& aLayers); |
288 | | already_AddRefed<CSSValue> DoGetImageLayerRepeat(const nsStyleImageLayers& aLayers); |
289 | | already_AddRefed<CSSValue> DoGetImageLayerSize(const nsStyleImageLayers& aLayers); |
290 | | |
291 | | /* Background properties */ |
292 | | already_AddRefed<CSSValue> DoGetBackgroundImage(); |
293 | | already_AddRefed<CSSValue> DoGetBackgroundPosition(); |
294 | | already_AddRefed<CSSValue> DoGetBackgroundPositionX(); |
295 | | already_AddRefed<CSSValue> DoGetBackgroundPositionY(); |
296 | | already_AddRefed<CSSValue> DoGetBackgroundRepeat(); |
297 | | already_AddRefed<CSSValue> DoGetBackgroundSize(); |
298 | | |
299 | | /* Mask properties */ |
300 | | already_AddRefed<CSSValue> DoGetMask(); |
301 | | already_AddRefed<CSSValue> DoGetMaskImage(); |
302 | | already_AddRefed<CSSValue> DoGetMaskPosition(); |
303 | | already_AddRefed<CSSValue> DoGetMaskPositionX(); |
304 | | already_AddRefed<CSSValue> DoGetMaskPositionY(); |
305 | | already_AddRefed<CSSValue> DoGetMaskRepeat(); |
306 | | already_AddRefed<CSSValue> DoGetMaskSize(); |
307 | | |
308 | | /* Padding properties */ |
309 | | already_AddRefed<CSSValue> DoGetPaddingTop(); |
310 | | already_AddRefed<CSSValue> DoGetPaddingBottom(); |
311 | | already_AddRefed<CSSValue> DoGetPaddingLeft(); |
312 | | already_AddRefed<CSSValue> DoGetPaddingRight(); |
313 | | |
314 | | /* Table Properties */ |
315 | | already_AddRefed<CSSValue> DoGetBorderSpacing(); |
316 | | already_AddRefed<CSSValue> DoGetVerticalAlign(); |
317 | | |
318 | | /* Border Properties */ |
319 | | already_AddRefed<CSSValue> DoGetBorderTopStyle(); |
320 | | already_AddRefed<CSSValue> DoGetBorderBottomStyle(); |
321 | | already_AddRefed<CSSValue> DoGetBorderLeftStyle(); |
322 | | already_AddRefed<CSSValue> DoGetBorderRightStyle(); |
323 | | already_AddRefed<CSSValue> DoGetBorderTopWidth(); |
324 | | already_AddRefed<CSSValue> DoGetBorderBottomWidth(); |
325 | | already_AddRefed<CSSValue> DoGetBorderLeftWidth(); |
326 | | already_AddRefed<CSSValue> DoGetBorderRightWidth(); |
327 | | already_AddRefed<CSSValue> DoGetBorderBottomLeftRadius(); |
328 | | already_AddRefed<CSSValue> DoGetBorderBottomRightRadius(); |
329 | | already_AddRefed<CSSValue> DoGetBorderTopLeftRadius(); |
330 | | already_AddRefed<CSSValue> DoGetBorderTopRightRadius(); |
331 | | |
332 | | /* Border Image */ |
333 | | already_AddRefed<CSSValue> DoGetBorderImageSource(); |
334 | | already_AddRefed<CSSValue> DoGetBorderImageSlice(); |
335 | | already_AddRefed<CSSValue> DoGetBorderImageWidth(); |
336 | | already_AddRefed<CSSValue> DoGetBorderImageOutset(); |
337 | | already_AddRefed<CSSValue> DoGetBorderImageRepeat(); |
338 | | |
339 | | /* Box Shadow */ |
340 | | already_AddRefed<CSSValue> DoGetBoxShadow(); |
341 | | |
342 | | /* Window Shadow */ |
343 | | |
344 | | /* Margin Properties */ |
345 | | already_AddRefed<CSSValue> DoGetMarginTopWidth(); |
346 | | already_AddRefed<CSSValue> DoGetMarginBottomWidth(); |
347 | | already_AddRefed<CSSValue> DoGetMarginLeftWidth(); |
348 | | already_AddRefed<CSSValue> DoGetMarginRightWidth(); |
349 | | |
350 | | /* Outline Properties */ |
351 | | already_AddRefed<CSSValue> DoGetOutlineWidth(); |
352 | | already_AddRefed<CSSValue> DoGetOutlineStyle(); |
353 | | already_AddRefed<CSSValue> DoGetOutlineRadiusBottomLeft(); |
354 | | already_AddRefed<CSSValue> DoGetOutlineRadiusBottomRight(); |
355 | | already_AddRefed<CSSValue> DoGetOutlineRadiusTopLeft(); |
356 | | already_AddRefed<CSSValue> DoGetOutlineRadiusTopRight(); |
357 | | |
358 | | /* Quotes Properties */ |
359 | | already_AddRefed<CSSValue> DoGetQuotes(); |
360 | | |
361 | | /* z-index */ |
362 | | already_AddRefed<CSSValue> DoGetZIndex(); |
363 | | |
364 | | /* List properties */ |
365 | | already_AddRefed<CSSValue> DoGetImageRegion(); |
366 | | |
367 | | /* Text Properties */ |
368 | | already_AddRefed<CSSValue> DoGetInitialLetter(); |
369 | | already_AddRefed<CSSValue> DoGetLineHeight(); |
370 | | already_AddRefed<CSSValue> DoGetTextAlign(); |
371 | | already_AddRefed<CSSValue> DoGetTextDecoration(); |
372 | | already_AddRefed<CSSValue> DoGetTextDecorationColor(); |
373 | | already_AddRefed<CSSValue> DoGetTextDecorationLine(); |
374 | | already_AddRefed<CSSValue> DoGetTextDecorationStyle(); |
375 | | already_AddRefed<CSSValue> DoGetTextEmphasisPosition(); |
376 | | already_AddRefed<CSSValue> DoGetTextEmphasisStyle(); |
377 | | already_AddRefed<CSSValue> DoGetTextOverflow(); |
378 | | already_AddRefed<CSSValue> DoGetTextShadow(); |
379 | | already_AddRefed<CSSValue> DoGetLetterSpacing(); |
380 | | already_AddRefed<CSSValue> DoGetWordSpacing(); |
381 | | already_AddRefed<CSSValue> DoGetTabSize(); |
382 | | already_AddRefed<CSSValue> DoGetWebkitTextStrokeWidth(); |
383 | | |
384 | | /* Visibility properties */ |
385 | | |
386 | | /* Direction properties */ |
387 | | |
388 | | /* Display properties */ |
389 | | already_AddRefed<CSSValue> DoGetBinding(); |
390 | | already_AddRefed<CSSValue> DoGetDisplay(); |
391 | | already_AddRefed<CSSValue> DoGetContain(); |
392 | | already_AddRefed<CSSValue> DoGetClip(); |
393 | | already_AddRefed<CSSValue> DoGetWillChange(); |
394 | | already_AddRefed<CSSValue> DoGetOverflow(); |
395 | | already_AddRefed<CSSValue> DoGetOverflowY(); |
396 | | already_AddRefed<CSSValue> DoGetOverflowClipBoxBlock(); |
397 | | already_AddRefed<CSSValue> DoGetOverflowClipBoxInline(); |
398 | | already_AddRefed<CSSValue> DoGetTouchAction(); |
399 | | already_AddRefed<CSSValue> DoGetTransform(); |
400 | | already_AddRefed<CSSValue> DoGetTranslate(); |
401 | | already_AddRefed<CSSValue> DoGetRotate(); |
402 | | already_AddRefed<CSSValue> DoGetScale(); |
403 | | already_AddRefed<CSSValue> DoGetTransformOrigin(); |
404 | | already_AddRefed<CSSValue> DoGetPerspective(); |
405 | | already_AddRefed<CSSValue> DoGetPerspectiveOrigin(); |
406 | | already_AddRefed<CSSValue> DoGetTransformStyle(); |
407 | | already_AddRefed<CSSValue> DoGetOverscrollBehaviorX(); |
408 | | already_AddRefed<CSSValue> DoGetOverscrollBehaviorY(); |
409 | | already_AddRefed<CSSValue> DoGetScrollSnapTypeX(); |
410 | | already_AddRefed<CSSValue> DoGetScrollSnapTypeY(); |
411 | | already_AddRefed<CSSValue> DoGetScrollSnapPointsX(); |
412 | | already_AddRefed<CSSValue> DoGetScrollSnapPointsY(); |
413 | | already_AddRefed<CSSValue> DoGetScrollSnapDestination(); |
414 | | already_AddRefed<CSSValue> DoGetScrollSnapCoordinate(); |
415 | | already_AddRefed<CSSValue> DoGetScrollbarColor(); |
416 | | |
417 | | /* User interface properties */ |
418 | | already_AddRefed<CSSValue> DoGetCaretColor(); |
419 | | already_AddRefed<CSSValue> DoGetCursor(); |
420 | | already_AddRefed<CSSValue> DoGetForceBrokenImageIcon(); |
421 | | |
422 | | /* Column properties */ |
423 | | already_AddRefed<CSSValue> DoGetColumnCount(); |
424 | | already_AddRefed<CSSValue> DoGetColumnWidth(); |
425 | | already_AddRefed<CSSValue> DoGetColumnRuleWidth(); |
426 | | |
427 | | /* CSS Transitions */ |
428 | | already_AddRefed<CSSValue> DoGetTransitionProperty(); |
429 | | already_AddRefed<CSSValue> DoGetTransitionDuration(); |
430 | | already_AddRefed<CSSValue> DoGetTransitionDelay(); |
431 | | already_AddRefed<CSSValue> DoGetTransitionTimingFunction(); |
432 | | |
433 | | /* CSS Animations */ |
434 | | already_AddRefed<CSSValue> DoGetAnimationName(); |
435 | | already_AddRefed<CSSValue> DoGetAnimationDuration(); |
436 | | already_AddRefed<CSSValue> DoGetAnimationDelay(); |
437 | | already_AddRefed<CSSValue> DoGetAnimationTimingFunction(); |
438 | | already_AddRefed<CSSValue> DoGetAnimationIterationCount(); |
439 | | |
440 | | /* CSS Flexbox properties */ |
441 | | already_AddRefed<CSSValue> DoGetFlexBasis(); |
442 | | already_AddRefed<CSSValue> DoGetFlexGrow(); |
443 | | already_AddRefed<CSSValue> DoGetFlexShrink(); |
444 | | |
445 | | /* CSS Flexbox/Grid properties */ |
446 | | |
447 | | /* CSS Box Alignment properties */ |
448 | | already_AddRefed<CSSValue> DoGetAlignContent(); |
449 | | already_AddRefed<CSSValue> DoGetAlignItems(); |
450 | | already_AddRefed<CSSValue> DoGetAlignSelf(); |
451 | | already_AddRefed<CSSValue> DoGetJustifyContent(); |
452 | | already_AddRefed<CSSValue> DoGetJustifyItems(); |
453 | | already_AddRefed<CSSValue> DoGetJustifySelf(); |
454 | | already_AddRefed<CSSValue> DoGetColumnGap(); |
455 | | already_AddRefed<CSSValue> DoGetRowGap(); |
456 | | |
457 | | /* SVG properties */ |
458 | | already_AddRefed<CSSValue> DoGetFill(); |
459 | | already_AddRefed<CSSValue> DoGetStroke(); |
460 | | already_AddRefed<CSSValue> DoGetMarkerEnd(); |
461 | | already_AddRefed<CSSValue> DoGetMarkerMid(); |
462 | | already_AddRefed<CSSValue> DoGetMarkerStart(); |
463 | | already_AddRefed<CSSValue> DoGetStrokeDasharray(); |
464 | | |
465 | | already_AddRefed<CSSValue> DoGetStrokeDashoffset(); |
466 | | already_AddRefed<CSSValue> DoGetStrokeWidth(); |
467 | | |
468 | | already_AddRefed<CSSValue> DoGetFillOpacity(); |
469 | | already_AddRefed<CSSValue> DoGetStrokeMiterlimit(); |
470 | | already_AddRefed<CSSValue> DoGetStrokeOpacity(); |
471 | | |
472 | | |
473 | | |
474 | | |
475 | | already_AddRefed<CSSValue> DoGetFilter(); |
476 | | already_AddRefed<CSSValue> DoGetPaintOrder(); |
477 | | |
478 | | |
479 | | // For working around a MSVC bug. See related comment in |
480 | | // GenerateComputedDOMStyleGenerated.py. |
481 | | already_AddRefed<CSSValue> DummyGetter(); |
482 | | |
483 | | /* Helper functions */ |
484 | | void SetToRGBAColor(nsROCSSPrimitiveValue* aValue, nscolor aColor); |
485 | | void SetValueFromComplexColor(nsROCSSPrimitiveValue* aValue, |
486 | | const mozilla::StyleComplexColor& aColor); |
487 | | void SetValueForWidgetColor(nsROCSSPrimitiveValue* aValue, |
488 | | const mozilla::StyleComplexColor& aColor, |
489 | | mozilla::StyleAppearance aWidgetType); |
490 | | void SetValueToStyleImage(const nsStyleImage& aStyleImage, |
491 | | nsROCSSPrimitiveValue* aValue); |
492 | | void SetValueToPositionCoord(const mozilla::Position::Coord& aCoord, |
493 | | nsROCSSPrimitiveValue* aValue); |
494 | | void SetValueToPosition(const mozilla::Position& aPosition, |
495 | | nsDOMCSSValueList* aValueList); |
496 | | void SetValueToURLValue(const mozilla::css::URLValueData* aURL, |
497 | | nsROCSSPrimitiveValue* aValue); |
498 | | |
499 | | /** |
500 | | * A method to get a percentage base for a percentage value. Returns true |
501 | | * if a percentage base value was determined, false otherwise. |
502 | | */ |
503 | | typedef bool (nsComputedDOMStyle::*PercentageBaseGetter)(nscoord&); |
504 | | |
505 | | /** |
506 | | * Method to set aValue to aCoord. If aCoord is a percentage value and |
507 | | * aPercentageBaseGetter is not null, aPercentageBaseGetter is called. If it |
508 | | * returns true, the percentage base it outputs in its out param is used |
509 | | * to compute an nscoord value. If the getter is null or returns false, |
510 | | * the percent value of aCoord is set as a percent value on aValue. aTable, |
511 | | * if not null, is the keyword table to handle eStyleUnit_Enumerated. When |
512 | | * calling SetAppUnits on aValue (for coord or percent values), the value |
513 | | * passed in will be clamped to be no less than aMinAppUnits and no more than |
514 | | * aMaxAppUnits. |
515 | | * |
516 | | * XXXbz should caller pass in some sort of bitfield indicating which units |
517 | | * can be expected or something? |
518 | | */ |
519 | | void SetValueToCoord(nsROCSSPrimitiveValue* aValue, |
520 | | const nsStyleCoord& aCoord, |
521 | | bool aClampNegativeCalc, |
522 | | PercentageBaseGetter aPercentageBaseGetter = nullptr, |
523 | | const KTableEntry aTable[] = nullptr, |
524 | | nscoord aMinAppUnits = nscoord_MIN, |
525 | | nscoord aMaxAppUnits = nscoord_MAX); |
526 | | |
527 | | /** |
528 | | * If aCoord is a eStyleUnit_Coord returns the nscoord. If it's |
529 | | * eStyleUnit_Percent, attempts to resolve the percentage base and returns |
530 | | * the resulting nscoord. If it's some other unit or a percentge base can't |
531 | | * be determined, returns aDefaultValue. |
532 | | */ |
533 | | nscoord StyleCoordToNSCoord(const nsStyleCoord& aCoord, |
534 | | PercentageBaseGetter aPercentageBaseGetter, |
535 | | nscoord aDefaultValue, |
536 | | bool aClampNegativeCalc); |
537 | | |
538 | | /** |
539 | | * Append coord values from four sides. It omits values when possible. |
540 | | */ |
541 | | void AppendFourSideCoordValues(nsDOMCSSValueList* aList, |
542 | | const nsStyleSides& aValues); |
543 | | |
544 | | bool GetCBContentWidth(nscoord& aWidth); |
545 | | bool GetCBContentHeight(nscoord& aWidth); |
546 | | bool GetScrollFrameContentWidth(nscoord& aWidth); |
547 | | bool GetScrollFrameContentHeight(nscoord& aHeight); |
548 | | bool GetFrameBoundsWidthForTransform(nscoord &aWidth); |
549 | | bool GetFrameBoundsHeightForTransform(nscoord &aHeight); |
550 | | bool GetFrameBorderRectWidth(nscoord& aWidth); |
551 | | bool GetFrameBorderRectHeight(nscoord& aHeight); |
552 | | |
553 | | /* Helper functions for computing and serializing a nsStyleCoord. */ |
554 | | void SetCssTextToCoord(nsAString& aCssText, const nsStyleCoord& aCoord, |
555 | | bool aClampNegativeCalc); |
556 | | already_AddRefed<CSSValue> CreatePrimitiveValueForStyleFilter( |
557 | | const nsStyleFilter& aStyleFilter); |
558 | | |
559 | | template<typename ReferenceBox> |
560 | | already_AddRefed<CSSValue> |
561 | | CreatePrimitiveValueForShapeSource( |
562 | | const mozilla::UniquePtr<mozilla::StyleBasicShape>& aStyleBasicShape, |
563 | | ReferenceBox aReferenceBox, |
564 | | const KTableEntry aBoxKeywordTable[]); |
565 | | |
566 | | // Helper function for computing basic shape styles. |
567 | | already_AddRefed<CSSValue> CreatePrimitiveValueForBasicShape( |
568 | | const mozilla::UniquePtr<mozilla::StyleBasicShape>& aStyleBasicShape); |
569 | | void BoxValuesToString(nsAString& aString, |
570 | | const nsTArray<nsStyleCoord>& aBoxValues, |
571 | | bool aClampNegativeCalc); |
572 | | void BasicShapeRadiiToString(nsAString& aCssText, |
573 | | const nsStyleCorners& aCorners); |
574 | | |
575 | | // Find out if we can safely skip flushing for aDocument (i.e. pending |
576 | | // restyles does not affect mContent). |
577 | | bool NeedsToFlush(nsIDocument* aDocument) const; |
578 | | |
579 | | |
580 | | static ComputedStyleMap* GetComputedStyleMap(); |
581 | | |
582 | | // We don't really have a good immutable representation of "presentation". |
583 | | // Given the way GetComputedStyle is currently used, we should just grab the |
584 | | // presshell, if any, from the document. |
585 | | nsWeakPtr mDocumentWeak; |
586 | | RefPtr<mozilla::dom::Element> mElement; |
587 | | |
588 | | /** |
589 | | * Strong reference to the ComputedStyle we access data from. This can be |
590 | | * either a ComputedStyle we resolved ourselves or a ComputedStyle we got |
591 | | * from our frame. |
592 | | * |
593 | | * If we got the ComputedStyle from the frame, we clear out mComputedStyle |
594 | | * in ClearCurrentStyleSources. If we resolved one ourselves, then |
595 | | * ClearCurrentStyleSources leaves it in mComputedStyle for use the next |
596 | | * time this nsComputedDOMStyle object is queried. UpdateCurrentStyleSources |
597 | | * in this case will check that the ComputedStyle is still valid to be used, |
598 | | * by checking whether flush styles results in any restyles having been |
599 | | * processed. |
600 | | * |
601 | | * Since an ArenaRefPtr is used to hold the ComputedStyle, it will be cleared |
602 | | * if the pres arena from which it was allocated goes away. |
603 | | */ |
604 | | mozilla::ArenaRefPtr<mozilla::ComputedStyle> mComputedStyle; |
605 | | RefPtr<nsAtom> mPseudo; |
606 | | |
607 | | /* |
608 | | * While computing style data, the primary frame for mContent --- named "outer" |
609 | | * because we should use it to compute positioning data. Null |
610 | | * otherwise. |
611 | | */ |
612 | | nsIFrame* mOuterFrame; |
613 | | /* |
614 | | * While computing style data, the "inner frame" for mContent --- the frame |
615 | | * which we should use to compute margin, border, padding and content data. Null |
616 | | * otherwise. |
617 | | */ |
618 | | nsIFrame* mInnerFrame; |
619 | | /* |
620 | | * While computing style data, the presshell we're working with. Null |
621 | | * otherwise. |
622 | | */ |
623 | | nsIPresShell* mPresShell; |
624 | | |
625 | | /* |
626 | | * The kind of styles we should be returning. |
627 | | */ |
628 | | StyleType mStyleType; |
629 | | |
630 | | /** |
631 | | * The nsComputedDOMStyle generation at the time we last resolved a style |
632 | | * context and stored it in mComputedStyle. |
633 | | */ |
634 | | uint64_t mComputedStyleGeneration; |
635 | | |
636 | | bool mExposeVisitedStyle; |
637 | | |
638 | | /** |
639 | | * Whether we resolved a ComputedStyle last time we called |
640 | | * UpdateCurrentStyleSources. Initially false. |
641 | | */ |
642 | | bool mResolvedComputedStyle; |
643 | | |
644 | | #ifdef DEBUG |
645 | | bool mFlushedPendingReflows; |
646 | | #endif |
647 | | |
648 | | friend struct ComputedStyleMap; |
649 | | }; |
650 | | |
651 | | already_AddRefed<nsComputedDOMStyle> |
652 | | NS_NewComputedDOMStyle(mozilla::dom::Element* aElement, |
653 | | const nsAString& aPseudoElt, |
654 | | nsIDocument* aDocument, |
655 | | nsComputedDOMStyle::StyleType aStyleType = |
656 | | nsComputedDOMStyle::eAll); |
657 | | |
658 | | #endif /* nsComputedDOMStyle_h__ */ |