/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /* DOM object returned from element.getComputedStyle() */ #ifndef nsComputedDOMStyle_h__ #define nsComputedDOMStyle_h__ #include "nsAutoPtr.h" #include "mozilla/ArenaRefPtr.h" #include "mozilla/ArenaRefPtrInlines.h" #include "mozilla/Attributes.h" #include "nsCOMPtr.h" #include "nscore.h" #include "nsCSSProps.h" #include "nsDOMCSSDeclaration.h" #include "nsStyleContext.h" #include "nsIWeakReferenceUtils.h" #include "mozilla/gfx/Types.h" #include "nsCoord.h" #include "nsColor.h" #include "nsIContent.h" #include "nsStyleStruct.h" namespace mozilla { namespace dom { class Element; } // namespace dom struct ComputedGridTrackInfo; } // namespace mozilla struct nsComputedStyleMap; class nsIFrame; class nsIPresShell; class nsDOMCSSValueList; struct nsMargin; class nsROCSSPrimitiveValue; class nsStyleCoord; class nsStyleCorners; struct nsStyleFilter; class nsStyleGradient; struct nsStyleImage; class nsStyleSides; struct nsTimingFunction; class nsComputedDOMStyle final : public nsDOMCSSDeclaration , public nsStubMutationObserver { private: // Convenience typedefs: typedef nsCSSProps::KTableEntry KTableEntry; typedef mozilla::dom::CSSValue CSSValue; public: NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsComputedDOMStyle, nsICSSDeclaration) NS_DECL_NSICSSDECLARATION NS_DECL_NSIDOMCSSSTYLEDECLARATION_HELPER virtual already_AddRefed GetPropertyCSSValue(const nsAString& aProp, mozilla::ErrorResult& aRv) override; using nsICSSDeclaration::GetPropertyCSSValue; virtual void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aPropName) override; enum StyleType { eDefaultOnly, // Only includes UA and user sheets eAll // Includes all stylesheets }; nsComputedDOMStyle(mozilla::dom::Element* aElement, const nsAString& aPseudoElt, nsIPresShell* aPresShell, StyleType aStyleType); virtual nsINode *GetParentObject() override { return mContent; } static already_AddRefed GetStyleContextForElement(mozilla::dom::Element* aElement, nsIAtom* aPseudo, nsIPresShell* aPresShell, StyleType aStyleType = eAll); static already_AddRefed GetStyleContextForElementNoFlush(mozilla::dom::Element* aElement, nsIAtom* aPseudo, nsIPresShell* aPresShell, StyleType aStyleType = eAll); static nsIPresShell* GetPresShellForContent(nsIContent* aContent); // Helper for nsDOMWindowUtils::GetVisitedDependentComputedStyle void SetExposeVisitedStyle(bool aExpose) { NS_ASSERTION(aExpose != mExposeVisitedStyle, "should always be changing"); mExposeVisitedStyle = aExpose; } // nsDOMCSSDeclaration abstract methods which should never be called // on a nsComputedDOMStyle object, but must be defined to avoid // compile errors. virtual mozilla::css::Declaration* GetCSSDeclaration(Operation) override; virtual nsresult SetCSSDeclaration(mozilla::css::Declaration*) override; virtual nsIDocument* DocToUpdate() override; virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) override; static already_AddRefed MatrixToCSSValue(const mozilla::gfx::Matrix4x4& aMatrix); static void RegisterPrefChangeCallbacks(); static void UnregisterPrefChangeCallbacks(); // nsIMutationObserver NS_DECL_NSIMUTATIONOBSERVER_PARENTCHAINCHANGED private: virtual ~nsComputedDOMStyle(); void AssertFlushedPendingReflows() { NS_ASSERTION(mFlushedPendingReflows, "property getter should have been marked layout-dependent"); } nsMargin GetAdjustedValuesForBoxSizing(); // Helper method for DoGetTextAlign[Last]. already_AddRefed CreateTextAlignValue(uint8_t aAlign, bool aAlignTrue, const KTableEntry aTable[]); // This indicates error by leaving mStyleContext null. void UpdateCurrentStyleSources(bool aNeedsLayoutFlush); void ClearCurrentStyleSources(); // Helper functions called by UpdateCurrentStyleSources. void ClearStyleContext(); void SetResolvedStyleContext(RefPtr&& aContext); void SetFrameStyleContext(nsStyleContext* aContext); #define STYLE_STRUCT(name_, checkdata_cb_) \ const nsStyle##name_ * Style##name_() { \ return mStyleContext->Style##name_(); \ } #include "nsStyleStructList.h" #undef STYLE_STRUCT already_AddRefed GetEllipseRadii(const nsStyleCorners& aRadius, uint8_t aFullCorner, bool aIsBorder); // else outline already_AddRefed GetOffsetWidthFor(mozilla::css::Side aSide); already_AddRefed GetAbsoluteOffset(mozilla::css::Side aSide); already_AddRefed GetRelativeOffset(mozilla::css::Side aSide); already_AddRefed GetStickyOffset(mozilla::css::Side aSide); already_AddRefed GetStaticOffset(mozilla::css::Side aSide); already_AddRefed GetPaddingWidthFor(mozilla::css::Side aSide); already_AddRefed GetBorderColorsFor(mozilla::css::Side aSide); already_AddRefed GetBorderStyleFor(mozilla::css::Side aSide); already_AddRefed GetBorderWidthFor(mozilla::css::Side aSide); already_AddRefed GetBorderColorFor(mozilla::css::Side aSide); already_AddRefed GetMarginWidthFor(mozilla::css::Side aSide); already_AddRefed GetSVGPaintFor(bool aFill); // Appends all aLineNames (may be empty) space-separated to aResult. void AppendGridLineNames(nsString& aResult, const nsTArray& aLineNames); // Appends aLineNames as a CSSValue* to aValueList. If aLineNames is empty // a value ("[]") is only appended if aSuppressEmptyList is false. void AppendGridLineNames(nsDOMCSSValueList* aValueList, const nsTArray& aLineNames, bool aSuppressEmptyList = true); // Appends aLineNames1/2 (if non-empty) as a CSSValue* to aValueList. void AppendGridLineNames(nsDOMCSSValueList* aValueList, const nsTArray& aLineNames1, const nsTArray& aLineNames2); already_AddRefed GetGridTrackSize(const nsStyleCoord& aMinSize, const nsStyleCoord& aMaxSize); already_AddRefed GetGridTemplateColumnsRows( const nsStyleGridTemplate& aTrackList, const mozilla::ComputedGridTrackInfo* aTrackInfo); already_AddRefed GetGridLine(const nsStyleGridLine& aGridLine); bool GetLineHeightCoord(nscoord& aCoord); already_AddRefed GetCSSShadowArray(nsCSSShadowArray* aArray, const nscolor& aDefaultColor, bool aIsBoxShadow); already_AddRefed GetBackgroundList( uint8_t nsStyleImageLayers::Layer::* aMember, uint32_t nsStyleImageLayers::* aCount, const nsStyleImageLayers& aLayers, const KTableEntry aTable[]); void GetCSSGradientString(const nsStyleGradient* aGradient, nsAString& aString); void GetImageRectString(nsIURI* aURI, const nsStyleSides& aCropRect, nsString& aString); already_AddRefed GetScrollSnapPoints(const nsStyleCoord& aCoord); void AppendTimingFunction(nsDOMCSSValueList *aValueList, const nsTimingFunction& aTimingFunction); /* Properties queryable as CSSValues. * To avoid a name conflict with nsIDOM*CSS2Properties, these are all * DoGetXXX instead of GetXXX. */ already_AddRefed DoGetAppearance(); /* Box properties */ already_AddRefed DoGetBoxAlign(); already_AddRefed DoGetBoxDecorationBreak(); already_AddRefed DoGetBoxDirection(); already_AddRefed DoGetBoxFlex(); already_AddRefed DoGetBoxOrdinalGroup(); already_AddRefed DoGetBoxOrient(); already_AddRefed DoGetBoxPack(); already_AddRefed DoGetBoxSizing(); already_AddRefed DoGetWidth(); already_AddRefed DoGetHeight(); already_AddRefed DoGetMaxHeight(); already_AddRefed DoGetMaxWidth(); already_AddRefed DoGetMinHeight(); already_AddRefed DoGetMinWidth(); already_AddRefed DoGetMixBlendMode(); already_AddRefed DoGetIsolation(); already_AddRefed DoGetObjectFit(); already_AddRefed DoGetObjectPosition(); already_AddRefed DoGetLeft(); already_AddRefed DoGetTop(); already_AddRefed DoGetRight(); already_AddRefed DoGetBottom(); already_AddRefed DoGetStackSizing(); /* Font properties */ already_AddRefed DoGetColor(); already_AddRefed DoGetFontFamily(); already_AddRefed DoGetFontFeatureSettings(); already_AddRefed DoGetFontKerning(); already_AddRefed DoGetFontLanguageOverride(); already_AddRefed DoGetFontSize(); already_AddRefed DoGetFontSizeAdjust(); already_AddRefed DoGetOsxFontSmoothing(); already_AddRefed DoGetFontStretch(); already_AddRefed DoGetFontStyle(); already_AddRefed DoGetFontSynthesis(); already_AddRefed DoGetFontVariant(); already_AddRefed DoGetFontVariantAlternates(); already_AddRefed DoGetFontVariantCaps(); already_AddRefed DoGetFontVariantEastAsian(); already_AddRefed DoGetFontVariantLigatures(); already_AddRefed DoGetFontVariantNumeric(); already_AddRefed DoGetFontVariantPosition(); already_AddRefed DoGetFontWeight(); /* Grid properties */ already_AddRefed DoGetGridAutoFlow(); already_AddRefed DoGetGridAutoColumns(); already_AddRefed DoGetGridAutoRows(); already_AddRefed DoGetGridTemplateAreas(); already_AddRefed DoGetGridTemplateColumns(); already_AddRefed DoGetGridTemplateRows(); already_AddRefed DoGetGridColumnStart(); already_AddRefed DoGetGridColumnEnd(); already_AddRefed DoGetGridRowStart(); already_AddRefed DoGetGridRowEnd(); already_AddRefed DoGetGridColumnGap(); already_AddRefed DoGetGridRowGap(); /* StyleImageLayer properties */ already_AddRefed DoGetImageLayerImage(const nsStyleImageLayers& aLayers); already_AddRefed DoGetImageLayerPosition(const nsStyleImageLayers& aLayers); already_AddRefed DoGetImageLayerRepeat(const nsStyleImageLayers& aLayers); already_AddRefed DoGetImageLayerSize(const nsStyleImageLayers& aLayers); /* Background properties */ already_AddRefed DoGetBackgroundAttachment(); already_AddRefed DoGetBackgroundColor(); already_AddRefed DoGetBackgroundImage(); already_AddRefed DoGetBackgroundPosition(); already_AddRefed DoGetBackgroundRepeat(); already_AddRefed DoGetBackgroundClip(); already_AddRefed DoGetBackgroundBlendMode(); already_AddRefed DoGetBackgroundOrigin(); already_AddRefed DoGetBackgroundSize(); /* Mask properties */ already_AddRefed DoGetMask(); #ifdef MOZ_ENABLE_MASK_AS_SHORTHAND already_AddRefed DoGetMaskImage(); already_AddRefed DoGetMaskPosition(); already_AddRefed DoGetMaskRepeat(); already_AddRefed DoGetMaskClip(); already_AddRefed DoGetMaskOrigin(); already_AddRefed DoGetMaskSize(); already_AddRefed DoGetMaskMode(); already_AddRefed DoGetMaskComposite(); #endif /* Padding properties */ already_AddRefed DoGetPaddingTop(); already_AddRefed DoGetPaddingBottom(); already_AddRefed DoGetPaddingLeft(); already_AddRefed DoGetPaddingRight(); /* Table Properties */ already_AddRefed DoGetBorderCollapse(); already_AddRefed DoGetBorderSpacing(); already_AddRefed DoGetCaptionSide(); already_AddRefed DoGetEmptyCells(); already_AddRefed DoGetTableLayout(); already_AddRefed DoGetVerticalAlign(); /* Border Properties */ already_AddRefed DoGetBorderTopStyle(); already_AddRefed DoGetBorderBottomStyle(); already_AddRefed DoGetBorderLeftStyle(); already_AddRefed DoGetBorderRightStyle(); already_AddRefed DoGetBorderTopWidth(); already_AddRefed DoGetBorderBottomWidth(); already_AddRefed DoGetBorderLeftWidth(); already_AddRefed DoGetBorderRightWidth(); already_AddRefed DoGetBorderTopColor(); already_AddRefed DoGetBorderBottomColor(); already_AddRefed DoGetBorderLeftColor(); already_AddRefed DoGetBorderRightColor(); already_AddRefed DoGetBorderBottomColors(); already_AddRefed DoGetBorderLeftColors(); already_AddRefed DoGetBorderRightColors(); already_AddRefed DoGetBorderTopColors(); already_AddRefed DoGetBorderBottomLeftRadius(); already_AddRefed DoGetBorderBottomRightRadius(); already_AddRefed DoGetBorderTopLeftRadius(); already_AddRefed DoGetBorderTopRightRadius(); already_AddRefed DoGetFloatEdge(); /* Border Image */ already_AddRefed DoGetBorderImageSource(); already_AddRefed DoGetBorderImageSlice(); already_AddRefed DoGetBorderImageWidth(); already_AddRefed DoGetBorderImageOutset(); already_AddRefed DoGetBorderImageRepeat(); /* Box Shadow */ already_AddRefed DoGetBoxShadow(); /* Window Shadow */ already_AddRefed DoGetWindowShadow(); /* Margin Properties */ already_AddRefed DoGetMarginTopWidth(); already_AddRefed DoGetMarginBottomWidth(); already_AddRefed DoGetMarginLeftWidth(); already_AddRefed DoGetMarginRightWidth(); /* Outline Properties */ already_AddRefed DoGetOutlineWidth(); already_AddRefed DoGetOutlineStyle(); already_AddRefed DoGetOutlineColor(); already_AddRefed DoGetOutlineOffset(); already_AddRefed DoGetOutlineRadiusBottomLeft(); already_AddRefed DoGetOutlineRadiusBottomRight(); already_AddRefed DoGetOutlineRadiusTopLeft(); already_AddRefed DoGetOutlineRadiusTopRight(); /* Content Properties */ already_AddRefed DoGetContent(); already_AddRefed DoGetCounterIncrement(); already_AddRefed DoGetCounterReset(); already_AddRefed DoGetMarkerOffset(); /* Quotes Properties */ already_AddRefed DoGetQuotes(); /* z-index */ already_AddRefed DoGetZIndex(); /* List properties */ already_AddRefed DoGetListStyleImage(); already_AddRefed DoGetListStylePosition(); already_AddRefed DoGetListStyleType(); already_AddRefed DoGetImageRegion(); /* Text Properties */ already_AddRefed DoGetLineHeight(); already_AddRefed DoGetRubyAlign(); already_AddRefed DoGetRubyPosition(); already_AddRefed DoGetTextAlign(); already_AddRefed DoGetTextAlignLast(); already_AddRefed DoGetTextCombineUpright(); already_AddRefed DoGetTextDecoration(); already_AddRefed DoGetTextDecorationColor(); already_AddRefed DoGetTextDecorationLine(); already_AddRefed DoGetTextDecorationStyle(); already_AddRefed DoGetTextEmphasisColor(); already_AddRefed DoGetTextEmphasisPosition(); already_AddRefed DoGetTextEmphasisStyle(); already_AddRefed DoGetTextIndent(); already_AddRefed DoGetTextOrientation(); already_AddRefed DoGetTextOverflow(); already_AddRefed DoGetTextTransform(); already_AddRefed DoGetTextShadow(); already_AddRefed DoGetLetterSpacing(); already_AddRefed DoGetWordSpacing(); already_AddRefed DoGetWhiteSpace(); already_AddRefed DoGetWordBreak(); already_AddRefed DoGetWordWrap(); already_AddRefed DoGetHyphens(); already_AddRefed DoGetTabSize(); already_AddRefed DoGetTextSizeAdjust(); /* Visibility properties */ already_AddRefed DoGetOpacity(); already_AddRefed DoGetPointerEvents(); already_AddRefed DoGetVisibility(); already_AddRefed DoGetWritingMode(); /* Direction properties */ already_AddRefed DoGetDirection(); already_AddRefed DoGetUnicodeBidi(); /* Display properties */ already_AddRefed DoGetBinding(); already_AddRefed DoGetClear(); already_AddRefed DoGetFloat(); already_AddRefed DoGetDisplay(); already_AddRefed DoGetContain(); already_AddRefed DoGetPosition(); already_AddRefed DoGetClip(); already_AddRefed DoGetImageOrientation(); already_AddRefed DoGetWillChange(); already_AddRefed DoGetOverflow(); already_AddRefed DoGetOverflowX(); already_AddRefed DoGetOverflowY(); already_AddRefed DoGetOverflowClipBox(); already_AddRefed DoGetResize(); already_AddRefed DoGetPageBreakAfter(); already_AddRefed DoGetPageBreakBefore(); already_AddRefed DoGetPageBreakInside(); already_AddRefed DoGetTouchAction(); already_AddRefed DoGetTransform(); already_AddRefed DoGetTransformBox(); already_AddRefed DoGetTransformOrigin(); already_AddRefed DoGetPerspective(); already_AddRefed DoGetBackfaceVisibility(); already_AddRefed DoGetPerspectiveOrigin(); already_AddRefed DoGetTransformStyle(); already_AddRefed DoGetOrient(); already_AddRefed DoGetScrollBehavior(); already_AddRefed DoGetScrollSnapType(); already_AddRefed DoGetScrollSnapTypeX(); already_AddRefed DoGetScrollSnapTypeY(); already_AddRefed DoGetScrollSnapPointsX(); already_AddRefed DoGetScrollSnapPointsY(); already_AddRefed DoGetScrollSnapDestination(); already_AddRefed DoGetScrollSnapCoordinate(); /* User interface properties */ already_AddRefed DoGetCursor(); already_AddRefed DoGetForceBrokenImageIcon(); already_AddRefed DoGetIMEMode(); already_AddRefed DoGetUserFocus(); already_AddRefed DoGetUserInput(); already_AddRefed DoGetUserModify(); already_AddRefed DoGetUserSelect(); already_AddRefed DoGetWindowDragging(); /* Column properties */ already_AddRefed DoGetColumnCount(); already_AddRefed DoGetColumnFill(); already_AddRefed DoGetColumnWidth(); already_AddRefed DoGetColumnGap(); already_AddRefed DoGetColumnRuleWidth(); already_AddRefed DoGetColumnRuleStyle(); already_AddRefed DoGetColumnRuleColor(); /* CSS Transitions */ already_AddRefed DoGetTransitionProperty(); already_AddRefed DoGetTransitionDuration(); already_AddRefed DoGetTransitionDelay(); already_AddRefed DoGetTransitionTimingFunction(); /* CSS Animations */ already_AddRefed DoGetAnimationName(); already_AddRefed DoGetAnimationDuration(); already_AddRefed DoGetAnimationDelay(); already_AddRefed DoGetAnimationTimingFunction(); already_AddRefed DoGetAnimationDirection(); already_AddRefed DoGetAnimationFillMode(); already_AddRefed DoGetAnimationIterationCount(); already_AddRefed DoGetAnimationPlayState(); /* CSS Flexbox properties */ already_AddRefed DoGetFlexBasis(); already_AddRefed DoGetFlexDirection(); already_AddRefed DoGetFlexGrow(); already_AddRefed DoGetFlexShrink(); already_AddRefed DoGetFlexWrap(); /* CSS Flexbox/Grid properties */ already_AddRefed DoGetOrder(); /* CSS Box Alignment properties */ already_AddRefed DoGetAlignContent(); already_AddRefed DoGetAlignItems(); already_AddRefed DoGetAlignSelf(); already_AddRefed DoGetJustifyContent(); already_AddRefed DoGetJustifyItems(); already_AddRefed DoGetJustifySelf(); /* SVG properties */ already_AddRefed DoGetFill(); already_AddRefed DoGetStroke(); already_AddRefed DoGetMarkerEnd(); already_AddRefed DoGetMarkerMid(); already_AddRefed DoGetMarkerStart(); already_AddRefed DoGetStrokeDasharray(); already_AddRefed DoGetStrokeDashoffset(); already_AddRefed DoGetStrokeWidth(); already_AddRefed DoGetVectorEffect(); already_AddRefed DoGetFillOpacity(); already_AddRefed DoGetFloodOpacity(); already_AddRefed DoGetStopOpacity(); already_AddRefed DoGetStrokeMiterlimit(); already_AddRefed DoGetStrokeOpacity(); already_AddRefed DoGetClipRule(); already_AddRefed DoGetFillRule(); already_AddRefed DoGetStrokeLinecap(); already_AddRefed DoGetStrokeLinejoin(); already_AddRefed DoGetTextAnchor(); already_AddRefed DoGetColorInterpolation(); already_AddRefed DoGetColorInterpolationFilters(); already_AddRefed DoGetDominantBaseline(); already_AddRefed DoGetImageRendering(); already_AddRefed DoGetShapeRendering(); already_AddRefed DoGetTextRendering(); already_AddRefed DoGetFloodColor(); already_AddRefed DoGetLightingColor(); already_AddRefed DoGetStopColor(); already_AddRefed DoGetClipPath(); already_AddRefed DoGetFilter(); already_AddRefed DoGetMaskType(); already_AddRefed DoGetPaintOrder(); /* Custom properties */ already_AddRefed DoGetCustomProperty(const nsAString& aPropertyName); nsDOMCSSValueList* GetROCSSValueList(bool aCommaDelimited); /* Helper functions */ void SetToRGBAColor(nsROCSSPrimitiveValue* aValue, nscolor aColor); void SetValueToStyleImage(const nsStyleImage& aStyleImage, nsROCSSPrimitiveValue* aValue); void SetValueToPositionCoord( const nsStyleImageLayers::Position::PositionCoord& aCoord, nsROCSSPrimitiveValue* aValue); void SetValueToPosition(const nsStyleImageLayers::Position& aPosition, nsDOMCSSValueList* aValueList); /** * A method to get a percentage base for a percentage value. Returns true * if a percentage base value was determined, false otherwise. */ typedef bool (nsComputedDOMStyle::*PercentageBaseGetter)(nscoord&); /** * Method to set aValue to aCoord. If aCoord is a percentage value and * aPercentageBaseGetter is not null, aPercentageBaseGetter is called. If it * returns true, the percentage base it outputs in its out param is used * to compute an nscoord value. If the getter is null or returns false, * the percent value of aCoord is set as a percent value on aValue. aTable, * if not null, is the keyword table to handle eStyleUnit_Enumerated. When * calling SetAppUnits on aValue (for coord or percent values), the value * passed in will be clamped to be no less than aMinAppUnits and no more than * aMaxAppUnits. * * XXXbz should caller pass in some sort of bitfield indicating which units * can be expected or something? */ void SetValueToCoord(nsROCSSPrimitiveValue* aValue, const nsStyleCoord& aCoord, bool aClampNegativeCalc, PercentageBaseGetter aPercentageBaseGetter = nullptr, const KTableEntry aTable[] = nullptr, nscoord aMinAppUnits = nscoord_MIN, nscoord aMaxAppUnits = nscoord_MAX); /** * If aCoord is a eStyleUnit_Coord returns the nscoord. If it's * eStyleUnit_Percent, attempts to resolve the percentage base and returns * the resulting nscoord. If it's some other unit or a percentge base can't * be determined, returns aDefaultValue. */ nscoord StyleCoordToNSCoord(const nsStyleCoord& aCoord, PercentageBaseGetter aPercentageBaseGetter, nscoord aDefaultValue, bool aClampNegativeCalc); bool GetCBContentWidth(nscoord& aWidth); bool GetCBContentHeight(nscoord& aWidth); bool GetScrollFrameContentWidth(nscoord& aWidth); bool GetScrollFrameContentHeight(nscoord& aHeight); bool GetFrameBoundsWidthForTransform(nscoord &aWidth); bool GetFrameBoundsHeightForTransform(nscoord &aHeight); bool GetFrameBorderRectWidth(nscoord& aWidth); bool GetFrameBorderRectHeight(nscoord& aHeight); /* Helper functions for computing the filter property style. */ void SetCssTextToCoord(nsAString& aCssText, const nsStyleCoord& aCoord); already_AddRefed CreatePrimitiveValueForStyleFilter( const nsStyleFilter& aStyleFilter); // Helper function for computing basic shape styles. already_AddRefed CreatePrimitiveValueForClipPath( const nsStyleBasicShape* aStyleBasicShape, uint8_t aSizingBox); void BoxValuesToString(nsAString& aString, const nsTArray& aBoxValues); void BasicShapeRadiiToString(nsAString& aCssText, const nsStyleCorners& aCorners); static nsComputedStyleMap* GetComputedStyleMap(); // We don't really have a good immutable representation of "presentation". // Given the way GetComputedStyle is currently used, we should just grab the // 0th presshell, if any, from the document. nsWeakPtr mDocumentWeak; nsCOMPtr mContent; /** * Strong reference to the style context we access data from. This can be * either a style context we resolved ourselves or a style context we got * from our frame. * * If we got the style context from the frame, we clear out mStyleContext * in ClearCurrentStyleSources. If we resolved one ourselves, then * ClearCurrentStyleSources leaves it in mStyleContext for use the next * time this nsComputedDOMStyle object is queried. UpdateCurrentStyleSources * in this case will check that the style context is still valid to be used, * by checking whether flush styles results in any restyles having been * processed. * * Since an ArenaRefPtr is used to hold the style context, it will be cleared * if the pres arena from which it was allocated goes away. */ mozilla::ArenaRefPtr mStyleContext; nsCOMPtr mPseudo; /* * While computing style data, the primary frame for mContent --- named "outer" * because we should use it to compute positioning data. Null * otherwise. */ nsIFrame* mOuterFrame; /* * While computing style data, the "inner frame" for mContent --- the frame * which we should use to compute margin, border, padding and content data. Null * otherwise. */ nsIFrame* mInnerFrame; /* * While computing style data, the presshell we're working with. Null * otherwise. */ nsIPresShell* mPresShell; /* * The kind of styles we should be returning. */ StyleType mStyleType; /** * The nsComputedDOMStyle generation at the time we last resolved a style * context and stored it in mStyleContext. */ uint64_t mStyleContextGeneration; bool mExposeVisitedStyle; /** * Whether we resolved a style context last time we called * UpdateCurrentStyleSources. Initially false. */ bool mResolvedStyleContext; #ifdef DEBUG bool mFlushedPendingReflows; #endif }; already_AddRefed NS_NewComputedDOMStyle(mozilla::dom::Element* aElement, const nsAString& aPseudoElt, nsIPresShell* aPresShell, nsComputedDOMStyle::StyleType aStyleType = nsComputedDOMStyle::eAll); #endif /* nsComputedDOMStyle_h__ */