Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : /* DOM object returned from element.getComputedStyle() */
7 :
8 : #ifndef nsComputedDOMStyle_h__
9 : #define nsComputedDOMStyle_h__
10 :
11 : #include "mozilla/ArenaRefPtr.h"
12 : #include "mozilla/ArenaRefPtrInlines.h"
13 : #include "mozilla/Attributes.h"
14 : #include "mozilla/StyleComplexColor.h"
15 : #include "nsCOMPtr.h"
16 : #include "nscore.h"
17 : #include "nsCSSProps.h"
18 : #include "nsDOMCSSDeclaration.h"
19 : #include "nsStyleContext.h"
20 : #include "nsIWeakReferenceUtils.h"
21 : #include "mozilla/gfx/Types.h"
22 : #include "nsCoord.h"
23 : #include "nsColor.h"
24 : #include "nsIContent.h"
25 : #include "nsStyleStruct.h"
26 : #include "mozilla/WritingModes.h"
27 :
28 : namespace mozilla {
29 : namespace dom {
30 : class Element;
31 : } // namespace dom
32 : struct ComputedGridTrackInfo;
33 : } // namespace mozilla
34 :
35 : struct nsComputedStyleMap;
36 : class nsIFrame;
37 : class nsIPresShell;
38 : class nsDOMCSSValueList;
39 : struct nsMargin;
40 : class nsROCSSPrimitiveValue;
41 : class nsStyleCoord;
42 : class nsStyleCorners;
43 : struct nsStyleFilter;
44 : class nsStyleGradient;
45 : struct nsStyleImage;
46 : class nsStyleSides;
47 : struct nsTimingFunction;
48 :
49 : class nsComputedDOMStyle final : public nsDOMCSSDeclaration
50 : , public nsStubMutationObserver
51 : {
52 : private:
53 : // Convenience typedefs:
54 : typedef nsCSSProps::KTableEntry KTableEntry;
55 : typedef mozilla::dom::CSSValue CSSValue;
56 : typedef mozilla::StyleGeometryBox StyleGeometryBox;
57 :
58 : public:
59 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
60 72 : NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsComputedDOMStyle,
61 : nsICSSDeclaration)
62 :
63 : NS_DECL_NSICSSDECLARATION
64 :
65 : NS_DECL_NSIDOMCSSSTYLEDECLARATION_HELPER
66 : virtual already_AddRefed<CSSValue>
67 : GetPropertyCSSValue(const nsAString& aProp, mozilla::ErrorResult& aRv)
68 : override;
69 : using nsICSSDeclaration::GetPropertyCSSValue;
70 : virtual void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aPropName) override;
71 :
72 : enum StyleType {
73 : eDefaultOnly, // Only includes UA and user sheets
74 : eAll // Includes all stylesheets
75 : };
76 :
77 : enum AnimationFlag {
78 : eWithAnimation,
79 : eWithoutAnimation,
80 : };
81 :
82 : nsComputedDOMStyle(mozilla::dom::Element* aElement,
83 : const nsAString& aPseudoElt,
84 : nsIPresShell* aPresShell,
85 : StyleType aStyleType,
86 : AnimationFlag aFlag = eWithAnimation);
87 :
88 4 : virtual nsINode *GetParentObject() override
89 : {
90 4 : return mContent;
91 : }
92 :
93 : static already_AddRefed<nsStyleContext>
94 : GetStyleContext(mozilla::dom::Element* aElement, nsIAtom* aPseudo,
95 : nsIPresShell* aPresShell,
96 : StyleType aStyleType = eAll);
97 :
98 : static already_AddRefed<nsStyleContext>
99 360 : GetStyleContextNoFlush(mozilla::dom::Element* aElement,
100 : nsIAtom* aPseudo,
101 : nsIPresShell* aPresShell,
102 : StyleType aStyleType = eAll)
103 : {
104 : return DoGetStyleContextNoFlush(aElement,
105 : aPseudo,
106 : aPresShell,
107 : aStyleType,
108 360 : eWithAnimation);
109 : }
110 :
111 : static already_AddRefed<nsStyleContext>
112 0 : GetUnanimatedStyleContextNoFlush(mozilla::dom::Element* aElement,
113 : nsIAtom* aPseudo,
114 : nsIPresShell* aPresShell,
115 : StyleType aStyleType = eAll)
116 : {
117 : return DoGetStyleContextNoFlush(aElement,
118 : aPseudo,
119 : aPresShell,
120 : aStyleType,
121 0 : eWithoutAnimation);
122 : }
123 :
124 : static nsIPresShell*
125 : GetPresShellForContent(const nsIContent* aContent);
126 :
127 : // Helper for nsDOMWindowUtils::GetVisitedDependentComputedStyle
128 0 : void SetExposeVisitedStyle(bool aExpose) {
129 0 : NS_ASSERTION(aExpose != mExposeVisitedStyle, "should always be changing");
130 0 : mExposeVisitedStyle = aExpose;
131 0 : }
132 :
133 : // nsDOMCSSDeclaration abstract methods which should never be called
134 : // on a nsComputedDOMStyle object, but must be defined to avoid
135 : // compile errors.
136 : virtual mozilla::DeclarationBlock* GetCSSDeclaration(Operation) override;
137 : virtual nsresult SetCSSDeclaration(mozilla::DeclarationBlock*) override;
138 : virtual nsIDocument* DocToUpdate() override;
139 : virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) override;
140 : nsDOMCSSDeclaration::ServoCSSParsingEnvironment GetServoCSSParsingEnvironment() const final;
141 :
142 : static already_AddRefed<nsROCSSPrimitiveValue>
143 : MatrixToCSSValue(const mozilla::gfx::Matrix4x4& aMatrix);
144 :
145 : static void RegisterPrefChangeCallbacks();
146 : static void UnregisterPrefChangeCallbacks();
147 :
148 : // nsIMutationObserver
149 : NS_DECL_NSIMUTATIONOBSERVER_PARENTCHAINCHANGED
150 :
151 : private:
152 : virtual ~nsComputedDOMStyle();
153 :
154 0 : void AssertFlushedPendingReflows() {
155 0 : NS_ASSERTION(mFlushedPendingReflows,
156 : "property getter should have been marked layout-dependent");
157 0 : }
158 :
159 : nsMargin GetAdjustedValuesForBoxSizing();
160 :
161 : // Helper method for DoGetTextAlign[Last].
162 : already_AddRefed<CSSValue> CreateTextAlignValue(uint8_t aAlign,
163 : bool aAlignTrue,
164 : const KTableEntry aTable[]);
165 : // This indicates error by leaving mStyleContext null.
166 : void UpdateCurrentStyleSources(bool aNeedsLayoutFlush);
167 : void ClearCurrentStyleSources();
168 :
169 : // Helper functions called by UpdateCurrentStyleSources.
170 : void ClearStyleContext();
171 : void SetResolvedStyleContext(RefPtr<nsStyleContext>&& aContext,
172 : uint64_t aGeneration);
173 : void SetFrameStyleContext(nsStyleContext* aContext, uint64_t aGeneration);
174 :
175 : static already_AddRefed<nsStyleContext>
176 : DoGetStyleContextNoFlush(mozilla::dom::Element* aElement,
177 : nsIAtom* aPseudo,
178 : nsIPresShell* aPresShell,
179 : StyleType aStyleType,
180 : AnimationFlag aAnimationFlag);
181 :
182 : #define STYLE_STRUCT(name_, checkdata_cb_) \
183 : const nsStyle##name_ * Style##name_() { \
184 : return mStyleContext->Style##name_(); \
185 : }
186 : #include "nsStyleStructList.h"
187 : #undef STYLE_STRUCT
188 :
189 : already_AddRefed<CSSValue> GetEllipseRadii(const nsStyleCorners& aRadius,
190 : mozilla::Corner aFullCorner);
191 :
192 : already_AddRefed<CSSValue> GetOffsetWidthFor(mozilla::Side aSide);
193 :
194 : already_AddRefed<CSSValue> GetAbsoluteOffset(mozilla::Side aSide);
195 :
196 : already_AddRefed<CSSValue> GetRelativeOffset(mozilla::Side aSide);
197 :
198 : already_AddRefed<CSSValue> GetStickyOffset(mozilla::Side aSide);
199 :
200 : already_AddRefed<CSSValue> GetStaticOffset(mozilla::Side aSide);
201 :
202 : already_AddRefed<CSSValue> GetPaddingWidthFor(mozilla::Side aSide);
203 :
204 : already_AddRefed<CSSValue> GetBorderColorsFor(mozilla::Side aSide);
205 :
206 : already_AddRefed<CSSValue> GetBorderStyleFor(mozilla::Side aSide);
207 :
208 : already_AddRefed<CSSValue> GetBorderWidthFor(mozilla::Side aSide);
209 :
210 : already_AddRefed<CSSValue> GetBorderColorFor(mozilla::Side aSide);
211 :
212 : already_AddRefed<CSSValue> GetMarginWidthFor(mozilla::Side aSide);
213 :
214 : already_AddRefed<CSSValue> GetFallbackValue(const nsStyleSVGPaint* aPaint);
215 :
216 : already_AddRefed<CSSValue> GetSVGPaintFor(bool aFill);
217 :
218 : already_AddRefed<CSSValue> GetTransformValue(nsCSSValueSharedList* aSpecifiedTransform);
219 :
220 : // Appends all aLineNames (may be empty) space-separated to aResult.
221 : void AppendGridLineNames(nsString& aResult,
222 : const nsTArray<nsString>& aLineNames);
223 : // Appends aLineNames as a CSSValue* to aValueList. If aLineNames is empty
224 : // a value ("[]") is only appended if aSuppressEmptyList is false.
225 : void AppendGridLineNames(nsDOMCSSValueList* aValueList,
226 : const nsTArray<nsString>& aLineNames,
227 : bool aSuppressEmptyList = true);
228 : // Appends aLineNames1/2 (if non-empty) as a CSSValue* to aValueList.
229 : void AppendGridLineNames(nsDOMCSSValueList* aValueList,
230 : const nsTArray<nsString>& aLineNames1,
231 : const nsTArray<nsString>& aLineNames2);
232 : already_AddRefed<CSSValue> GetGridTrackSize(const nsStyleCoord& aMinSize,
233 : const nsStyleCoord& aMaxSize);
234 : already_AddRefed<CSSValue> GetGridTemplateColumnsRows(
235 : const nsStyleGridTemplate& aTrackList,
236 : const mozilla::ComputedGridTrackInfo* aTrackInfo);
237 : already_AddRefed<CSSValue> GetGridLine(const nsStyleGridLine& aGridLine);
238 :
239 : bool GetLineHeightCoord(nscoord& aCoord);
240 :
241 : already_AddRefed<CSSValue> GetCSSShadowArray(nsCSSShadowArray* aArray,
242 : const nscolor& aDefaultColor,
243 : bool aIsBoxShadow);
244 :
245 : void GetCSSGradientString(const nsStyleGradient* aGradient,
246 : nsAString& aString);
247 : void GetImageRectString(nsIURI* aURI,
248 : const nsStyleSides& aCropRect,
249 : nsString& aString);
250 : already_AddRefed<CSSValue> GetScrollSnapPoints(const nsStyleCoord& aCoord);
251 : void AppendTimingFunction(nsDOMCSSValueList *aValueList,
252 : const nsTimingFunction& aTimingFunction);
253 :
254 : bool ShouldHonorMinSizeAutoInAxis(mozilla::PhysicalAxis aAxis);
255 :
256 : /* Properties queryable as CSSValues.
257 : * To avoid a name conflict with nsIDOM*CSS2Properties, these are all
258 : * DoGetXXX instead of GetXXX.
259 : */
260 :
261 : already_AddRefed<CSSValue> DoGetAppearance();
262 :
263 : /* Box properties */
264 : already_AddRefed<CSSValue> DoGetBoxAlign();
265 : already_AddRefed<CSSValue> DoGetBoxDecorationBreak();
266 : already_AddRefed<CSSValue> DoGetBoxDirection();
267 : already_AddRefed<CSSValue> DoGetBoxFlex();
268 : already_AddRefed<CSSValue> DoGetBoxOrdinalGroup();
269 : already_AddRefed<CSSValue> DoGetBoxOrient();
270 : already_AddRefed<CSSValue> DoGetBoxPack();
271 : already_AddRefed<CSSValue> DoGetBoxSizing();
272 :
273 : already_AddRefed<CSSValue> DoGetWidth();
274 : already_AddRefed<CSSValue> DoGetHeight();
275 : already_AddRefed<CSSValue> DoGetMaxHeight();
276 : already_AddRefed<CSSValue> DoGetMaxWidth();
277 : already_AddRefed<CSSValue> DoGetMinHeight();
278 : already_AddRefed<CSSValue> DoGetMinWidth();
279 : already_AddRefed<CSSValue> DoGetMixBlendMode();
280 : already_AddRefed<CSSValue> DoGetIsolation();
281 : already_AddRefed<CSSValue> DoGetObjectFit();
282 : already_AddRefed<CSSValue> DoGetObjectPosition();
283 : already_AddRefed<CSSValue> DoGetLeft();
284 : already_AddRefed<CSSValue> DoGetTop();
285 : already_AddRefed<CSSValue> DoGetRight();
286 : already_AddRefed<CSSValue> DoGetBottom();
287 : already_AddRefed<CSSValue> DoGetStackSizing();
288 :
289 : /* Font properties */
290 : already_AddRefed<CSSValue> DoGetColor();
291 : already_AddRefed<CSSValue> DoGetFontFamily();
292 : already_AddRefed<CSSValue> DoGetFontFeatureSettings();
293 : already_AddRefed<CSSValue> DoGetFontVariationSettings();
294 : already_AddRefed<CSSValue> DoGetFontKerning();
295 : already_AddRefed<CSSValue> DoGetFontLanguageOverride();
296 : already_AddRefed<CSSValue> DoGetFontSize();
297 : already_AddRefed<CSSValue> DoGetFontSizeAdjust();
298 : already_AddRefed<CSSValue> DoGetOsxFontSmoothing();
299 : already_AddRefed<CSSValue> DoGetFontStretch();
300 : already_AddRefed<CSSValue> DoGetFontStyle();
301 : already_AddRefed<CSSValue> DoGetFontSynthesis();
302 : already_AddRefed<CSSValue> DoGetFontVariant();
303 : already_AddRefed<CSSValue> DoGetFontVariantAlternates();
304 : already_AddRefed<CSSValue> DoGetFontVariantCaps();
305 : already_AddRefed<CSSValue> DoGetFontVariantEastAsian();
306 : already_AddRefed<CSSValue> DoGetFontVariantLigatures();
307 : already_AddRefed<CSSValue> DoGetFontVariantNumeric();
308 : already_AddRefed<CSSValue> DoGetFontVariantPosition();
309 : already_AddRefed<CSSValue> DoGetFontWeight();
310 :
311 : /* Grid properties */
312 : already_AddRefed<CSSValue> DoGetGridAutoFlow();
313 : already_AddRefed<CSSValue> DoGetGridAutoColumns();
314 : already_AddRefed<CSSValue> DoGetGridAutoRows();
315 : already_AddRefed<CSSValue> DoGetGridTemplateAreas();
316 : already_AddRefed<CSSValue> DoGetGridTemplateColumns();
317 : already_AddRefed<CSSValue> DoGetGridTemplateRows();
318 : already_AddRefed<CSSValue> DoGetGridColumnStart();
319 : already_AddRefed<CSSValue> DoGetGridColumnEnd();
320 : already_AddRefed<CSSValue> DoGetGridRowStart();
321 : already_AddRefed<CSSValue> DoGetGridRowEnd();
322 : already_AddRefed<CSSValue> DoGetGridColumnGap();
323 : already_AddRefed<CSSValue> DoGetGridRowGap();
324 :
325 : /* StyleImageLayer properties */
326 : already_AddRefed<CSSValue> DoGetImageLayerImage(const nsStyleImageLayers& aLayers);
327 : already_AddRefed<CSSValue> DoGetImageLayerPosition(const nsStyleImageLayers& aLayers);
328 : already_AddRefed<CSSValue> DoGetImageLayerPositionX(const nsStyleImageLayers& aLayers);
329 : already_AddRefed<CSSValue> DoGetImageLayerPositionY(const nsStyleImageLayers& aLayers);
330 : already_AddRefed<CSSValue> DoGetImageLayerRepeat(const nsStyleImageLayers& aLayers);
331 : already_AddRefed<CSSValue> DoGetImageLayerSize(const nsStyleImageLayers& aLayers);
332 :
333 : /* Background properties */
334 : already_AddRefed<CSSValue> DoGetBackgroundAttachment();
335 : already_AddRefed<CSSValue> DoGetBackgroundColor();
336 : already_AddRefed<CSSValue> DoGetBackgroundImage();
337 : already_AddRefed<CSSValue> DoGetBackgroundPosition();
338 : already_AddRefed<CSSValue> DoGetBackgroundPositionX();
339 : already_AddRefed<CSSValue> DoGetBackgroundPositionY();
340 : already_AddRefed<CSSValue> DoGetBackgroundRepeat();
341 : already_AddRefed<CSSValue> DoGetBackgroundClip();
342 : already_AddRefed<CSSValue> DoGetBackgroundBlendMode();
343 : already_AddRefed<CSSValue> DoGetBackgroundOrigin();
344 : already_AddRefed<CSSValue> DoGetBackgroundSize();
345 :
346 : /* Mask properties */
347 : already_AddRefed<CSSValue> DoGetMask();
348 : #ifdef MOZ_ENABLE_MASK_AS_SHORTHAND
349 : already_AddRefed<CSSValue> DoGetMaskImage();
350 : already_AddRefed<CSSValue> DoGetMaskPosition();
351 : already_AddRefed<CSSValue> DoGetMaskPositionX();
352 : already_AddRefed<CSSValue> DoGetMaskPositionY();
353 : already_AddRefed<CSSValue> DoGetMaskRepeat();
354 : already_AddRefed<CSSValue> DoGetMaskClip();
355 : already_AddRefed<CSSValue> DoGetMaskOrigin();
356 : already_AddRefed<CSSValue> DoGetMaskSize();
357 : already_AddRefed<CSSValue> DoGetMaskMode();
358 : already_AddRefed<CSSValue> DoGetMaskComposite();
359 : #endif
360 : /* Padding properties */
361 : already_AddRefed<CSSValue> DoGetPaddingTop();
362 : already_AddRefed<CSSValue> DoGetPaddingBottom();
363 : already_AddRefed<CSSValue> DoGetPaddingLeft();
364 : already_AddRefed<CSSValue> DoGetPaddingRight();
365 :
366 : /* Table Properties */
367 : already_AddRefed<CSSValue> DoGetBorderCollapse();
368 : already_AddRefed<CSSValue> DoGetBorderSpacing();
369 : already_AddRefed<CSSValue> DoGetCaptionSide();
370 : already_AddRefed<CSSValue> DoGetEmptyCells();
371 : already_AddRefed<CSSValue> DoGetTableLayout();
372 : already_AddRefed<CSSValue> DoGetVerticalAlign();
373 :
374 : /* Border Properties */
375 : already_AddRefed<CSSValue> DoGetBorderTopStyle();
376 : already_AddRefed<CSSValue> DoGetBorderBottomStyle();
377 : already_AddRefed<CSSValue> DoGetBorderLeftStyle();
378 : already_AddRefed<CSSValue> DoGetBorderRightStyle();
379 : already_AddRefed<CSSValue> DoGetBorderTopWidth();
380 : already_AddRefed<CSSValue> DoGetBorderBottomWidth();
381 : already_AddRefed<CSSValue> DoGetBorderLeftWidth();
382 : already_AddRefed<CSSValue> DoGetBorderRightWidth();
383 : already_AddRefed<CSSValue> DoGetBorderTopColor();
384 : already_AddRefed<CSSValue> DoGetBorderBottomColor();
385 : already_AddRefed<CSSValue> DoGetBorderLeftColor();
386 : already_AddRefed<CSSValue> DoGetBorderRightColor();
387 : already_AddRefed<CSSValue> DoGetBorderBottomColors();
388 : already_AddRefed<CSSValue> DoGetBorderLeftColors();
389 : already_AddRefed<CSSValue> DoGetBorderRightColors();
390 : already_AddRefed<CSSValue> DoGetBorderTopColors();
391 : already_AddRefed<CSSValue> DoGetBorderBottomLeftRadius();
392 : already_AddRefed<CSSValue> DoGetBorderBottomRightRadius();
393 : already_AddRefed<CSSValue> DoGetBorderTopLeftRadius();
394 : already_AddRefed<CSSValue> DoGetBorderTopRightRadius();
395 : already_AddRefed<CSSValue> DoGetFloatEdge();
396 :
397 : /* Border Image */
398 : already_AddRefed<CSSValue> DoGetBorderImageSource();
399 : already_AddRefed<CSSValue> DoGetBorderImageSlice();
400 : already_AddRefed<CSSValue> DoGetBorderImageWidth();
401 : already_AddRefed<CSSValue> DoGetBorderImageOutset();
402 : already_AddRefed<CSSValue> DoGetBorderImageRepeat();
403 :
404 : /* Box Shadow */
405 : already_AddRefed<CSSValue> DoGetBoxShadow();
406 :
407 : /* Window Shadow */
408 : already_AddRefed<CSSValue> DoGetWindowShadow();
409 :
410 : /* Margin Properties */
411 : already_AddRefed<CSSValue> DoGetMarginTopWidth();
412 : already_AddRefed<CSSValue> DoGetMarginBottomWidth();
413 : already_AddRefed<CSSValue> DoGetMarginLeftWidth();
414 : already_AddRefed<CSSValue> DoGetMarginRightWidth();
415 :
416 : /* Outline Properties */
417 : already_AddRefed<CSSValue> DoGetOutlineWidth();
418 : already_AddRefed<CSSValue> DoGetOutlineStyle();
419 : already_AddRefed<CSSValue> DoGetOutlineColor();
420 : already_AddRefed<CSSValue> DoGetOutlineOffset();
421 : already_AddRefed<CSSValue> DoGetOutlineRadiusBottomLeft();
422 : already_AddRefed<CSSValue> DoGetOutlineRadiusBottomRight();
423 : already_AddRefed<CSSValue> DoGetOutlineRadiusTopLeft();
424 : already_AddRefed<CSSValue> DoGetOutlineRadiusTopRight();
425 :
426 : /* Content Properties */
427 : already_AddRefed<CSSValue> DoGetContent();
428 : already_AddRefed<CSSValue> DoGetCounterIncrement();
429 : already_AddRefed<CSSValue> DoGetCounterReset();
430 :
431 : /* Quotes Properties */
432 : already_AddRefed<CSSValue> DoGetQuotes();
433 :
434 : /* z-index */
435 : already_AddRefed<CSSValue> DoGetZIndex();
436 :
437 : /* List properties */
438 : already_AddRefed<CSSValue> DoGetListStyleImage();
439 : already_AddRefed<CSSValue> DoGetListStylePosition();
440 : already_AddRefed<CSSValue> DoGetListStyleType();
441 : already_AddRefed<CSSValue> DoGetImageRegion();
442 :
443 : /* Text Properties */
444 : already_AddRefed<CSSValue> DoGetInitialLetter();
445 : already_AddRefed<CSSValue> DoGetLineHeight();
446 : already_AddRefed<CSSValue> DoGetRubyAlign();
447 : already_AddRefed<CSSValue> DoGetRubyPosition();
448 : already_AddRefed<CSSValue> DoGetTextAlign();
449 : already_AddRefed<CSSValue> DoGetTextAlignLast();
450 : already_AddRefed<CSSValue> DoGetTextCombineUpright();
451 : already_AddRefed<CSSValue> DoGetTextDecoration();
452 : already_AddRefed<CSSValue> DoGetTextDecorationColor();
453 : already_AddRefed<CSSValue> DoGetTextDecorationLine();
454 : already_AddRefed<CSSValue> DoGetTextDecorationStyle();
455 : already_AddRefed<CSSValue> DoGetTextEmphasisColor();
456 : already_AddRefed<CSSValue> DoGetTextEmphasisPosition();
457 : already_AddRefed<CSSValue> DoGetTextEmphasisStyle();
458 : already_AddRefed<CSSValue> DoGetTextIndent();
459 : already_AddRefed<CSSValue> DoGetTextJustify();
460 : already_AddRefed<CSSValue> DoGetTextOrientation();
461 : already_AddRefed<CSSValue> DoGetTextOverflow();
462 : already_AddRefed<CSSValue> DoGetTextShadow();
463 : already_AddRefed<CSSValue> DoGetTextSizeAdjust();
464 : already_AddRefed<CSSValue> DoGetTextTransform();
465 : already_AddRefed<CSSValue> DoGetLetterSpacing();
466 : already_AddRefed<CSSValue> DoGetWordSpacing();
467 : already_AddRefed<CSSValue> DoGetWhiteSpace();
468 : already_AddRefed<CSSValue> DoGetWordBreak();
469 : already_AddRefed<CSSValue> DoGetOverflowWrap();
470 : already_AddRefed<CSSValue> DoGetHyphens();
471 : already_AddRefed<CSSValue> DoGetTabSize();
472 : already_AddRefed<CSSValue> DoGetWebkitTextFillColor();
473 : already_AddRefed<CSSValue> DoGetWebkitTextStrokeColor();
474 : already_AddRefed<CSSValue> DoGetWebkitTextStrokeWidth();
475 :
476 : /* Visibility properties */
477 : already_AddRefed<CSSValue> DoGetColorAdjust();
478 : already_AddRefed<CSSValue> DoGetOpacity();
479 : already_AddRefed<CSSValue> DoGetPointerEvents();
480 : already_AddRefed<CSSValue> DoGetVisibility();
481 : already_AddRefed<CSSValue> DoGetWritingMode();
482 :
483 : /* Direction properties */
484 : already_AddRefed<CSSValue> DoGetDirection();
485 : already_AddRefed<CSSValue> DoGetUnicodeBidi();
486 :
487 : /* Display properties */
488 : already_AddRefed<CSSValue> DoGetBinding();
489 : already_AddRefed<CSSValue> DoGetClear();
490 : already_AddRefed<CSSValue> DoGetFloat();
491 : already_AddRefed<CSSValue> DoGetDisplay();
492 : already_AddRefed<CSSValue> DoGetContain();
493 : already_AddRefed<CSSValue> DoGetPosition();
494 : already_AddRefed<CSSValue> DoGetClip();
495 : already_AddRefed<CSSValue> DoGetImageOrientation();
496 : already_AddRefed<CSSValue> DoGetWillChange();
497 : already_AddRefed<CSSValue> DoGetOverflow();
498 : already_AddRefed<CSSValue> DoGetOverflowX();
499 : already_AddRefed<CSSValue> DoGetOverflowY();
500 : already_AddRefed<CSSValue> DoGetOverflowClipBox();
501 : already_AddRefed<CSSValue> DoGetResize();
502 : already_AddRefed<CSSValue> DoGetPageBreakAfter();
503 : already_AddRefed<CSSValue> DoGetPageBreakBefore();
504 : already_AddRefed<CSSValue> DoGetPageBreakInside();
505 : already_AddRefed<CSSValue> DoGetTouchAction();
506 : already_AddRefed<CSSValue> DoGetTransform();
507 : already_AddRefed<CSSValue> DoGetTransformBox();
508 : already_AddRefed<CSSValue> DoGetTransformOrigin();
509 : already_AddRefed<CSSValue> DoGetPerspective();
510 : already_AddRefed<CSSValue> DoGetBackfaceVisibility();
511 : already_AddRefed<CSSValue> DoGetPerspectiveOrigin();
512 : already_AddRefed<CSSValue> DoGetTransformStyle();
513 : already_AddRefed<CSSValue> DoGetOrient();
514 : already_AddRefed<CSSValue> DoGetScrollBehavior();
515 : already_AddRefed<CSSValue> DoGetScrollSnapType();
516 : already_AddRefed<CSSValue> DoGetScrollSnapTypeX();
517 : already_AddRefed<CSSValue> DoGetScrollSnapTypeY();
518 : already_AddRefed<CSSValue> DoGetScrollSnapPointsX();
519 : already_AddRefed<CSSValue> DoGetScrollSnapPointsY();
520 : already_AddRefed<CSSValue> DoGetScrollSnapDestination();
521 : already_AddRefed<CSSValue> DoGetScrollSnapCoordinate();
522 : already_AddRefed<CSSValue> DoGetShapeOutside();
523 :
524 : /* User interface properties */
525 : already_AddRefed<CSSValue> DoGetCaretColor();
526 : already_AddRefed<CSSValue> DoGetCursor();
527 : already_AddRefed<CSSValue> DoGetForceBrokenImageIcon();
528 : already_AddRefed<CSSValue> DoGetIMEMode();
529 : already_AddRefed<CSSValue> DoGetUserFocus();
530 : already_AddRefed<CSSValue> DoGetUserInput();
531 : already_AddRefed<CSSValue> DoGetUserModify();
532 : already_AddRefed<CSSValue> DoGetUserSelect();
533 : already_AddRefed<CSSValue> DoGetWindowDragging();
534 : already_AddRefed<CSSValue> DoGetWindowOpacity();
535 : already_AddRefed<CSSValue> DoGetWindowTransform();
536 : already_AddRefed<CSSValue> DoGetWindowTransformOrigin();
537 :
538 : /* Column properties */
539 : already_AddRefed<CSSValue> DoGetColumnCount();
540 : already_AddRefed<CSSValue> DoGetColumnFill();
541 : already_AddRefed<CSSValue> DoGetColumnSpan();
542 : already_AddRefed<CSSValue> DoGetColumnWidth();
543 : already_AddRefed<CSSValue> DoGetColumnGap();
544 : already_AddRefed<CSSValue> DoGetColumnRuleWidth();
545 : already_AddRefed<CSSValue> DoGetColumnRuleStyle();
546 : already_AddRefed<CSSValue> DoGetColumnRuleColor();
547 :
548 : /* CSS Transitions */
549 : already_AddRefed<CSSValue> DoGetTransitionProperty();
550 : already_AddRefed<CSSValue> DoGetTransitionDuration();
551 : already_AddRefed<CSSValue> DoGetTransitionDelay();
552 : already_AddRefed<CSSValue> DoGetTransitionTimingFunction();
553 :
554 : /* CSS Animations */
555 : already_AddRefed<CSSValue> DoGetAnimationName();
556 : already_AddRefed<CSSValue> DoGetAnimationDuration();
557 : already_AddRefed<CSSValue> DoGetAnimationDelay();
558 : already_AddRefed<CSSValue> DoGetAnimationTimingFunction();
559 : already_AddRefed<CSSValue> DoGetAnimationDirection();
560 : already_AddRefed<CSSValue> DoGetAnimationFillMode();
561 : already_AddRefed<CSSValue> DoGetAnimationIterationCount();
562 : already_AddRefed<CSSValue> DoGetAnimationPlayState();
563 :
564 : /* CSS Flexbox properties */
565 : already_AddRefed<CSSValue> DoGetFlexBasis();
566 : already_AddRefed<CSSValue> DoGetFlexDirection();
567 : already_AddRefed<CSSValue> DoGetFlexGrow();
568 : already_AddRefed<CSSValue> DoGetFlexShrink();
569 : already_AddRefed<CSSValue> DoGetFlexWrap();
570 :
571 : /* CSS Flexbox/Grid properties */
572 : already_AddRefed<CSSValue> DoGetOrder();
573 :
574 : /* CSS Box Alignment properties */
575 : already_AddRefed<CSSValue> DoGetAlignContent();
576 : already_AddRefed<CSSValue> DoGetAlignItems();
577 : already_AddRefed<CSSValue> DoGetAlignSelf();
578 : already_AddRefed<CSSValue> DoGetJustifyContent();
579 : already_AddRefed<CSSValue> DoGetJustifyItems();
580 : already_AddRefed<CSSValue> DoGetJustifySelf();
581 :
582 : /* SVG properties */
583 : already_AddRefed<CSSValue> DoGetFill();
584 : already_AddRefed<CSSValue> DoGetStroke();
585 : already_AddRefed<CSSValue> DoGetMarkerEnd();
586 : already_AddRefed<CSSValue> DoGetMarkerMid();
587 : already_AddRefed<CSSValue> DoGetMarkerStart();
588 : already_AddRefed<CSSValue> DoGetStrokeDasharray();
589 :
590 : already_AddRefed<CSSValue> DoGetStrokeDashoffset();
591 : already_AddRefed<CSSValue> DoGetStrokeWidth();
592 : already_AddRefed<CSSValue> DoGetVectorEffect();
593 :
594 : already_AddRefed<CSSValue> DoGetFillOpacity();
595 : already_AddRefed<CSSValue> DoGetFloodOpacity();
596 : already_AddRefed<CSSValue> DoGetStopOpacity();
597 : already_AddRefed<CSSValue> DoGetStrokeMiterlimit();
598 : already_AddRefed<CSSValue> DoGetStrokeOpacity();
599 :
600 : already_AddRefed<CSSValue> DoGetClipRule();
601 : already_AddRefed<CSSValue> DoGetFillRule();
602 : already_AddRefed<CSSValue> DoGetStrokeLinecap();
603 : already_AddRefed<CSSValue> DoGetStrokeLinejoin();
604 : already_AddRefed<CSSValue> DoGetTextAnchor();
605 :
606 : already_AddRefed<CSSValue> DoGetColorInterpolation();
607 : already_AddRefed<CSSValue> DoGetColorInterpolationFilters();
608 : already_AddRefed<CSSValue> DoGetDominantBaseline();
609 : already_AddRefed<CSSValue> DoGetImageRendering();
610 : already_AddRefed<CSSValue> DoGetShapeRendering();
611 : already_AddRefed<CSSValue> DoGetTextRendering();
612 :
613 : already_AddRefed<CSSValue> DoGetFloodColor();
614 : already_AddRefed<CSSValue> DoGetLightingColor();
615 : already_AddRefed<CSSValue> DoGetStopColor();
616 :
617 : already_AddRefed<CSSValue> DoGetClipPath();
618 : already_AddRefed<CSSValue> DoGetFilter();
619 : already_AddRefed<CSSValue> DoGetMaskType();
620 : already_AddRefed<CSSValue> DoGetPaintOrder();
621 :
622 : already_AddRefed<CSSValue> DoGetContextProperties();
623 :
624 : /* Custom properties */
625 : already_AddRefed<CSSValue> DoGetCustomProperty(const nsAString& aPropertyName);
626 :
627 : /* Helper functions */
628 : void SetToRGBAColor(nsROCSSPrimitiveValue* aValue, nscolor aColor);
629 : void SetValueFromComplexColor(nsROCSSPrimitiveValue* aValue,
630 : const mozilla::StyleComplexColor& aColor);
631 : void SetValueToStyleImage(const nsStyleImage& aStyleImage,
632 : nsROCSSPrimitiveValue* aValue);
633 : void SetValueToPositionCoord(const mozilla::Position::Coord& aCoord,
634 : nsROCSSPrimitiveValue* aValue);
635 : void SetValueToPosition(const mozilla::Position& aPosition,
636 : nsDOMCSSValueList* aValueList);
637 : void SetValueToURLValue(const mozilla::css::URLValueData* aURL,
638 : nsROCSSPrimitiveValue* aValue);
639 :
640 : /**
641 : * A method to get a percentage base for a percentage value. Returns true
642 : * if a percentage base value was determined, false otherwise.
643 : */
644 : typedef bool (nsComputedDOMStyle::*PercentageBaseGetter)(nscoord&);
645 :
646 : /**
647 : * Method to set aValue to aCoord. If aCoord is a percentage value and
648 : * aPercentageBaseGetter is not null, aPercentageBaseGetter is called. If it
649 : * returns true, the percentage base it outputs in its out param is used
650 : * to compute an nscoord value. If the getter is null or returns false,
651 : * the percent value of aCoord is set as a percent value on aValue. aTable,
652 : * if not null, is the keyword table to handle eStyleUnit_Enumerated. When
653 : * calling SetAppUnits on aValue (for coord or percent values), the value
654 : * passed in will be clamped to be no less than aMinAppUnits and no more than
655 : * aMaxAppUnits.
656 : *
657 : * XXXbz should caller pass in some sort of bitfield indicating which units
658 : * can be expected or something?
659 : */
660 : void SetValueToCoord(nsROCSSPrimitiveValue* aValue,
661 : const nsStyleCoord& aCoord,
662 : bool aClampNegativeCalc,
663 : PercentageBaseGetter aPercentageBaseGetter = nullptr,
664 : const KTableEntry aTable[] = nullptr,
665 : nscoord aMinAppUnits = nscoord_MIN,
666 : nscoord aMaxAppUnits = nscoord_MAX);
667 :
668 : /**
669 : * If aCoord is a eStyleUnit_Coord returns the nscoord. If it's
670 : * eStyleUnit_Percent, attempts to resolve the percentage base and returns
671 : * the resulting nscoord. If it's some other unit or a percentge base can't
672 : * be determined, returns aDefaultValue.
673 : */
674 : nscoord StyleCoordToNSCoord(const nsStyleCoord& aCoord,
675 : PercentageBaseGetter aPercentageBaseGetter,
676 : nscoord aDefaultValue,
677 : bool aClampNegativeCalc);
678 :
679 : /**
680 : * Append coord values from four sides. It omits values when possible.
681 : */
682 : void AppendFourSideCoordValues(nsDOMCSSValueList* aList,
683 : const nsStyleSides& aValues);
684 :
685 : bool GetCBContentWidth(nscoord& aWidth);
686 : bool GetCBContentHeight(nscoord& aWidth);
687 : bool GetScrollFrameContentWidth(nscoord& aWidth);
688 : bool GetScrollFrameContentHeight(nscoord& aHeight);
689 : bool GetFrameBoundsWidthForTransform(nscoord &aWidth);
690 : bool GetFrameBoundsHeightForTransform(nscoord &aHeight);
691 : bool GetFrameBorderRectWidth(nscoord& aWidth);
692 : bool GetFrameBorderRectHeight(nscoord& aHeight);
693 :
694 : /* Helper functions for computing the filter property style. */
695 : void SetCssTextToCoord(nsAString& aCssText, const nsStyleCoord& aCoord);
696 : already_AddRefed<CSSValue> CreatePrimitiveValueForStyleFilter(
697 : const nsStyleFilter& aStyleFilter);
698 :
699 : already_AddRefed<CSSValue>
700 : GetShapeSource(const mozilla::StyleShapeSource& aShapeSource,
701 : const KTableEntry aBoxKeywordTable[]);
702 :
703 : template<typename ReferenceBox>
704 : already_AddRefed<CSSValue>
705 : CreatePrimitiveValueForShapeSource(
706 : const mozilla::StyleBasicShape* aStyleBasicShape,
707 : ReferenceBox aReferenceBox,
708 : const KTableEntry aBoxKeywordTable[]);
709 :
710 : // Helper function for computing basic shape styles.
711 : already_AddRefed<CSSValue> CreatePrimitiveValueForBasicShape(
712 : const mozilla::StyleBasicShape* aStyleBasicShape);
713 : void BoxValuesToString(nsAString& aString,
714 : const nsTArray<nsStyleCoord>& aBoxValues);
715 : void BasicShapeRadiiToString(nsAString& aCssText,
716 : const nsStyleCorners& aCorners);
717 :
718 :
719 : static nsComputedStyleMap* GetComputedStyleMap();
720 :
721 : // We don't really have a good immutable representation of "presentation".
722 : // Given the way GetComputedStyle is currently used, we should just grab the
723 : // 0th presshell, if any, from the document.
724 : nsWeakPtr mDocumentWeak;
725 : nsCOMPtr<nsIContent> mContent;
726 :
727 : /**
728 : * Strong reference to the style context we access data from. This can be
729 : * either a style context we resolved ourselves or a style context we got
730 : * from our frame.
731 : *
732 : * If we got the style context from the frame, we clear out mStyleContext
733 : * in ClearCurrentStyleSources. If we resolved one ourselves, then
734 : * ClearCurrentStyleSources leaves it in mStyleContext for use the next
735 : * time this nsComputedDOMStyle object is queried. UpdateCurrentStyleSources
736 : * in this case will check that the style context is still valid to be used,
737 : * by checking whether flush styles results in any restyles having been
738 : * processed.
739 : *
740 : * Since an ArenaRefPtr is used to hold the style context, it will be cleared
741 : * if the pres arena from which it was allocated goes away.
742 : */
743 : mozilla::ArenaRefPtr<nsStyleContext> mStyleContext;
744 : nsCOMPtr<nsIAtom> mPseudo;
745 :
746 : /*
747 : * While computing style data, the primary frame for mContent --- named "outer"
748 : * because we should use it to compute positioning data. Null
749 : * otherwise.
750 : */
751 : nsIFrame* mOuterFrame;
752 : /*
753 : * While computing style data, the "inner frame" for mContent --- the frame
754 : * which we should use to compute margin, border, padding and content data. Null
755 : * otherwise.
756 : */
757 : nsIFrame* mInnerFrame;
758 : /*
759 : * While computing style data, the presshell we're working with. Null
760 : * otherwise.
761 : */
762 : nsIPresShell* mPresShell;
763 :
764 : /*
765 : * The kind of styles we should be returning.
766 : */
767 : StyleType mStyleType;
768 :
769 : /**
770 : * The nsComputedDOMStyle generation at the time we last resolved a style
771 : * context and stored it in mStyleContext.
772 : */
773 : uint64_t mStyleContextGeneration;
774 :
775 : bool mExposeVisitedStyle;
776 :
777 : /**
778 : * Whether we resolved a style context last time we called
779 : * UpdateCurrentStyleSources. Initially false.
780 : */
781 : bool mResolvedStyleContext;
782 :
783 : /**
784 : * Whether we include animation rules in the computed style.
785 : */
786 : AnimationFlag mAnimationFlag;
787 :
788 : #ifdef DEBUG
789 : bool mFlushedPendingReflows;
790 : #endif
791 : };
792 :
793 : already_AddRefed<nsComputedDOMStyle>
794 : NS_NewComputedDOMStyle(mozilla::dom::Element* aElement,
795 : const nsAString& aPseudoElt,
796 : nsIPresShell* aPresShell,
797 : nsComputedDOMStyle::StyleType aStyleType =
798 : nsComputedDOMStyle::eAll,
799 : nsComputedDOMStyle::AnimationFlag aFlag =
800 : nsComputedDOMStyle::eWithAnimation);
801 :
802 : #endif /* nsComputedDOMStyle_h__ */
|