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