2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2002-03-22 23:18:42 +03:00
|
|
|
|
2006-03-25 08:47:31 +03:00
|
|
|
/* DOM object returned from element.getComputedStyle() */
|
|
|
|
|
2002-03-22 23:18:42 +03:00
|
|
|
#ifndef nsComputedDOMStyle_h__
|
|
|
|
#define nsComputedDOMStyle_h__
|
|
|
|
|
2012-09-14 20:10:08 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2019-04-04 14:35:33 +03:00
|
|
|
#include "mozilla/StyleColorInlines.h"
|
2017-09-25 13:50:24 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2018-04-16 16:18:48 +03:00
|
|
|
#include "mozilla/dom/Element.h"
|
2002-03-22 23:18:42 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2018-03-28 04:25:47 +03:00
|
|
|
#include "nsContentUtils.h"
|
2013-03-03 04:31:48 +04:00
|
|
|
#include "nscore.h"
|
|
|
|
#include "nsDOMCSSDeclaration.h"
|
2018-03-22 21:20:41 +03:00
|
|
|
#include "mozilla/ComputedStyle.h"
|
2013-03-03 04:31:48 +04:00
|
|
|
#include "nsIWeakReferenceUtils.h"
|
2013-09-16 05:06:52 +04:00
|
|
|
#include "mozilla/gfx/Types.h"
|
|
|
|
#include "nsCoord.h"
|
|
|
|
#include "nsColor.h"
|
2016-01-28 08:24:00 +03:00
|
|
|
#include "nsStyleStruct.h"
|
2016-11-19 00:47:30 +03:00
|
|
|
#include "mozilla/WritingModes.h"
|
2013-03-03 04:31:48 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2017-11-27 11:10:27 +03:00
|
|
|
class DocGroup;
|
2013-03-03 04:31:48 +04:00
|
|
|
class Element;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
2019-04-16 10:25:10 +03:00
|
|
|
class PresShell;
|
2016-01-27 19:02:13 +03:00
|
|
|
struct ComputedGridTrackInfo;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace mozilla
|
2002-03-22 23:18:42 +03:00
|
|
|
|
2018-03-22 21:20:41 +03:00
|
|
|
struct ComputedStyleMap;
|
2018-04-29 14:17:26 +03:00
|
|
|
struct nsCSSKTableEntry;
|
2012-08-06 07:00:56 +04:00
|
|
|
class nsIFrame;
|
2012-10-01 20:49:41 +04:00
|
|
|
class nsDOMCSSValueList;
|
2014-06-19 04:57:51 +04:00
|
|
|
struct nsMargin;
|
2012-10-01 20:49:41 +04:00
|
|
|
class nsROCSSPrimitiveValue;
|
2013-09-16 05:06:52 +04:00
|
|
|
class nsStyleGradient;
|
2014-06-19 04:57:51 +04:00
|
|
|
struct nsStyleImage;
|
2010-04-11 00:09:38 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsComputedDOMStyle final : public nsDOMCSSDeclaration,
|
2015-09-17 05:08:21 +03:00
|
|
|
public nsStubMutationObserver {
|
2015-12-29 01:42:08 +03:00
|
|
|
private:
|
|
|
|
// Convenience typedefs:
|
2019-02-10 15:55:16 +03:00
|
|
|
using KTableEntry = nsCSSKTableEntry;
|
|
|
|
using CSSValue = mozilla::dom::CSSValue;
|
|
|
|
using StyleGeometryBox = mozilla::StyleGeometryBox;
|
|
|
|
using Element = mozilla::dom::Element;
|
|
|
|
using Document = mozilla::dom::Document;
|
|
|
|
using StyleFlexBasis = mozilla::StyleFlexBasis;
|
|
|
|
using StyleSize = mozilla::StyleSize;
|
|
|
|
using StyleMaxSize = mozilla::StyleMaxSize;
|
|
|
|
using LengthPercentage = mozilla::LengthPercentage;
|
|
|
|
using LengthPercentageOrAuto = mozilla::LengthPercentageOrAuto;
|
|
|
|
using StyleExtremumLength = mozilla::StyleExtremumLength;
|
|
|
|
using ComputedStyle = mozilla::ComputedStyle;
|
2014-02-05 15:10:44 +04:00
|
|
|
|
2015-12-29 01:42:08 +03:00
|
|
|
public:
|
2008-11-27 20:44:26 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2012-08-06 06:16:30 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(
|
|
|
|
nsComputedDOMStyle, nsICSSDeclaration)
|
2002-03-22 23:18:42 +03:00
|
|
|
|
2012-10-01 20:49:41 +04:00
|
|
|
NS_DECL_NSIDOMCSSSTYLEDECLARATION_HELPER
|
2018-01-30 22:48:26 +03:00
|
|
|
nsresult GetPropertyValue(const nsCSSPropertyID aPropID,
|
|
|
|
nsAString& aValue) override;
|
2018-01-30 22:48:26 +03:00
|
|
|
nsresult SetPropertyValue(const nsCSSPropertyID aPropID,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsIPrincipal* aSubjectPrincipal) override;
|
2018-03-14 16:13:29 +03:00
|
|
|
|
|
|
|
void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aPropName) final;
|
2002-03-22 23:18:42 +03:00
|
|
|
|
2017-05-19 07:57:35 +03:00
|
|
|
enum StyleType {
|
|
|
|
eDefaultOnly, // Only includes UA and user sheets
|
|
|
|
eAll // Includes all stylesheets
|
|
|
|
};
|
|
|
|
|
2019-02-10 15:55:16 +03:00
|
|
|
nsComputedDOMStyle(Element* aElement, const nsAString& aPseudoElt,
|
|
|
|
Document* aDocument, StyleType aStyleType);
|
2002-03-22 23:18:42 +03:00
|
|
|
|
2018-06-08 12:18:51 +03:00
|
|
|
nsINode* GetParentObject() override { return mElement; }
|
2009-07-13 15:14:57 +04:00
|
|
|
|
2019-02-10 15:55:16 +03:00
|
|
|
static already_AddRefed<ComputedStyle> GetComputedStyle(
|
|
|
|
Element* aElement, nsAtom* aPseudo, StyleType aStyleType = eAll);
|
2009-08-11 02:52:29 +04:00
|
|
|
|
2019-02-10 15:55:16 +03:00
|
|
|
static already_AddRefed<ComputedStyle> GetComputedStyleNoFlush(
|
|
|
|
Element* aElement, nsAtom* aPseudo, StyleType aStyleType = eAll) {
|
2018-03-22 21:20:41 +03:00
|
|
|
return DoGetComputedStyleNoFlush(
|
2018-03-28 04:25:47 +03:00
|
|
|
aElement, aPseudo, nsContentUtils::GetPresShellForContent(aElement),
|
2018-03-25 17:35:53 +03:00
|
|
|
aStyleType);
|
2017-04-03 10:49:09 +03:00
|
|
|
}
|
|
|
|
|
2019-02-10 15:55:16 +03:00
|
|
|
static already_AddRefed<ComputedStyle> GetUnanimatedComputedStyleNoFlush(
|
|
|
|
Element* aElement, nsAtom* aPseudo);
|
2009-08-21 01:52:47 +04:00
|
|
|
|
2010-04-03 05:58:25 +04:00
|
|
|
// Helper for nsDOMWindowUtils::GetVisitedDependentComputedStyle
|
2011-09-29 10:19:26 +04:00
|
|
|
void SetExposeVisitedStyle(bool aExpose) {
|
2010-04-03 05:58:25 +04:00
|
|
|
NS_ASSERTION(aExpose != mExposeVisitedStyle, "should always be changing");
|
|
|
|
mExposeVisitedStyle = aExpose;
|
|
|
|
}
|
|
|
|
|
2018-03-08 21:52:32 +03:00
|
|
|
void GetCSSImageURLs(const nsAString& aPropertyName,
|
|
|
|
nsTArray<nsString>& aImageURLs,
|
|
|
|
mozilla::ErrorResult& aRv) final;
|
|
|
|
|
2010-07-15 00:58:56 +04:00
|
|
|
// nsDOMCSSDeclaration abstract methods which should never be called
|
|
|
|
// on a nsComputedDOMStyle object, but must be defined to avoid
|
|
|
|
// compile errors.
|
Bug 1428246 - The attributeChangedCallback is fired twice for the *first* style attribute change, r=peterv
The idea with this patch is that style code will first call
InlineStyleDeclarationWillChange before style declaration has changed, and SetInlineStyleDeclaration once it has changed.
In order to be able to report old attribute value, InlineStyleDeclarationWillChange reads the value and also calls AttributeWillChange (so that DOMMutationObserser can grab the old value). Later SetInlineStyleDeclaration passes the old value to
SetAttrAndNotify so that mutation events and attributeChanged callbacks are handled correctly.
Because of performance, declaration can't be cloned for reading the old value. And that is why the recently-added callback is used to detect when declaration is about to change (bug 1466963 and followup bug 1468665).
To keep the expected existing behavior, even if declaration isn't changed, but just a new declaration was created (since there wasn't any), we need to still run all these
willchange/set calls. That is when the code has 'if (created)' checks.
Since there are several declaration implementation and only nsDOMCSSAttributeDeclaration needs the about-to-change callback, GetPropertyChangeClosure is the one to initialize the callback closure, and the struct which is then passes as data to the closure.
Apparently we lost mutation event testing on style attribute when the pref was added, so test_style_attr_listener.html is modified to test both pref values.
--HG--
extra : rebase_source : 9e605d43f22e650ac3912fbfb41abb8d5a2a0c8f
2018-06-26 12:54:00 +03:00
|
|
|
mozilla::DeclarationBlock* GetOrCreateCSSDeclaration(
|
|
|
|
Operation aOperation, mozilla::DeclarationBlock** aCreated) final;
|
|
|
|
virtual nsresult SetCSSDeclaration(mozilla::DeclarationBlock*,
|
|
|
|
mozilla::MutationClosureData*) override;
|
2019-01-02 16:05:23 +03:00
|
|
|
virtual mozilla::dom::Document* DocToUpdate() override;
|
2018-05-03 18:41:48 +03:00
|
|
|
|
2018-05-14 19:22:20 +03:00
|
|
|
nsDOMCSSDeclaration::ParsingEnvironment GetParsingEnvironment(
|
|
|
|
nsIPrincipal* aSubjectPrincipal) const final;
|
2010-07-15 00:58:56 +04:00
|
|
|
|
2015-12-29 01:42:08 +03:00
|
|
|
static already_AddRefed<nsROCSSPrimitiveValue> MatrixToCSSValue(
|
|
|
|
const mozilla::gfx::Matrix4x4& aMatrix);
|
2018-11-28 03:59:15 +03:00
|
|
|
static void SetToRGBAColor(nsROCSSPrimitiveValue* aValue, nscolor aColor);
|
2013-05-23 12:41:40 +04:00
|
|
|
|
2013-10-03 14:58:01 +04:00
|
|
|
static void RegisterPrefChangeCallbacks();
|
|
|
|
static void UnregisterPrefChangeCallbacks();
|
|
|
|
|
2015-09-17 05:08:21 +03:00
|
|
|
// nsIMutationObserver
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_PARENTCHAINCHANGED
|
|
|
|
|
2002-03-22 23:18:42 +03:00
|
|
|
private:
|
2014-06-26 20:29:06 +04:00
|
|
|
virtual ~nsComputedDOMStyle();
|
|
|
|
|
2009-02-25 03:14:45 +03:00
|
|
|
void AssertFlushedPendingReflows() {
|
|
|
|
NS_ASSERTION(mFlushedPendingReflows,
|
|
|
|
"property getter should have been marked layout-dependent");
|
|
|
|
}
|
2010-04-27 20:15:01 +04:00
|
|
|
|
2013-04-04 18:00:07 +04:00
|
|
|
nsMargin GetAdjustedValuesForBoxSizing();
|
|
|
|
|
2018-03-22 21:20:41 +03:00
|
|
|
// This indicates error by leaving mComputedStyle null.
|
2013-12-12 06:09:45 +04:00
|
|
|
void UpdateCurrentStyleSources(bool aNeedsLayoutFlush);
|
|
|
|
void ClearCurrentStyleSources();
|
2013-10-28 00:56:32 +04:00
|
|
|
|
2015-09-17 05:08:21 +03:00
|
|
|
// Helper functions called by UpdateCurrentStyleSources.
|
2018-03-22 21:20:41 +03:00
|
|
|
void ClearComputedStyle();
|
2019-02-10 15:55:16 +03:00
|
|
|
void SetResolvedComputedStyle(RefPtr<ComputedStyle>&& aContext,
|
2018-03-22 21:20:41 +03:00
|
|
|
uint64_t aGeneration);
|
2019-02-10 15:55:16 +03:00
|
|
|
void SetFrameComputedStyle(ComputedStyle* aStyle, uint64_t aGeneration);
|
2015-09-17 05:08:21 +03:00
|
|
|
|
2019-02-10 15:55:16 +03:00
|
|
|
static already_AddRefed<ComputedStyle> DoGetComputedStyleNoFlush(
|
2019-04-16 10:25:10 +03:00
|
|
|
Element* aElement, nsAtom* aPseudo, mozilla::PresShell* aPresShell,
|
2019-02-10 15:55:16 +03:00
|
|
|
StyleType aStyleType);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-03-26 12:09:17 +03:00
|
|
|
#define STYLE_STRUCT(name_) \
|
|
|
|
const nsStyle##name_* Style##name_() { \
|
|
|
|
return mComputedStyle->Style##name_(); \
|
2006-12-19 07:16:09 +03:00
|
|
|
}
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
#undef STYLE_STRUCT
|
|
|
|
|
2019-02-05 02:28:44 +03:00
|
|
|
/**
|
|
|
|
* 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&);
|
|
|
|
|
2019-02-24 21:47:53 +03:00
|
|
|
already_AddRefed<CSSValue> GetOffsetWidthFor(mozilla::Side);
|
2019-02-05 02:28:44 +03:00
|
|
|
already_AddRefed<CSSValue> GetAbsoluteOffset(mozilla::Side);
|
|
|
|
nscoord GetUsedAbsoluteOffset(mozilla::Side);
|
|
|
|
already_AddRefed<CSSValue> GetNonStaticPositionOffset(
|
|
|
|
mozilla::Side aSide, bool aResolveAuto, PercentageBaseGetter aWidthGetter,
|
|
|
|
PercentageBaseGetter aHeightGetter);
|
2013-08-16 04:31:32 +04:00
|
|
|
|
2016-11-18 11:28:38 +03:00
|
|
|
already_AddRefed<CSSValue> GetStaticOffset(mozilla::Side aSide);
|
2002-03-22 23:18:42 +03:00
|
|
|
|
2016-11-18 11:28:38 +03:00
|
|
|
already_AddRefed<CSSValue> GetPaddingWidthFor(mozilla::Side aSide);
|
2002-07-08 11:11:59 +04:00
|
|
|
|
2016-11-18 11:28:38 +03:00
|
|
|
already_AddRefed<CSSValue> GetBorderStyleFor(mozilla::Side aSide);
|
2002-03-22 23:18:42 +03:00
|
|
|
|
2016-11-18 11:28:38 +03:00
|
|
|
already_AddRefed<CSSValue> GetBorderWidthFor(mozilla::Side aSide);
|
2002-03-22 23:18:42 +03:00
|
|
|
|
2016-11-18 11:28:38 +03:00
|
|
|
already_AddRefed<CSSValue> GetBorderColorFor(mozilla::Side aSide);
|
2002-03-22 23:18:42 +03:00
|
|
|
|
2016-11-18 11:28:38 +03:00
|
|
|
already_AddRefed<CSSValue> GetMarginWidthFor(mozilla::Side aSide);
|
2011-03-04 20:28:57 +03:00
|
|
|
|
2019-05-17 02:25:10 +03:00
|
|
|
already_AddRefed<CSSValue> GetTransformValue(const mozilla::StyleTransform&);
|
2017-06-19 08:44:22 +03:00
|
|
|
|
2016-01-27 19:02:13 +03:00
|
|
|
// Appends all aLineNames (may be empty) space-separated to aResult.
|
2015-12-23 01:03:15 +03:00
|
|
|
void AppendGridLineNames(nsString& aResult,
|
2019-06-19 08:58:11 +03:00
|
|
|
const nsTArray<RefPtr<nsAtom>>& aLineNames);
|
2016-01-27 19:02:13 +03:00
|
|
|
// Appends aLineNames as a CSSValue* to aValueList. If aLineNames is empty
|
|
|
|
// a value ("[]") is only appended if aSuppressEmptyList is false.
|
2015-12-23 01:03:15 +03:00
|
|
|
void AppendGridLineNames(nsDOMCSSValueList* aValueList,
|
2019-06-19 08:58:11 +03:00
|
|
|
const nsTArray<RefPtr<nsAtom>>& aLineNames,
|
2016-01-27 19:02:13 +03:00
|
|
|
bool aSuppressEmptyList = true);
|
2015-12-23 01:03:15 +03:00
|
|
|
// Appends aLineNames1/2 (if non-empty) as a CSSValue* to aValueList.
|
|
|
|
void AppendGridLineNames(nsDOMCSSValueList* aValueList,
|
2019-06-19 08:58:11 +03:00
|
|
|
const nsTArray<RefPtr<nsAtom>>& aLineNames1,
|
|
|
|
const nsTArray<RefPtr<nsAtom>>& aLineNames2);
|
2019-07-16 10:33:44 +03:00
|
|
|
already_AddRefed<nsROCSSPrimitiveValue> GetGridTrackSize(
|
|
|
|
const mozilla::StyleTrackSize&);
|
|
|
|
already_AddRefed<nsROCSSPrimitiveValue> GetGridTrackBreadth(
|
|
|
|
const mozilla::StyleTrackBreadth&);
|
|
|
|
void SetValueToTrackBreadth(nsROCSSPrimitiveValue*,
|
|
|
|
const mozilla::StyleTrackBreadth&);
|
2015-12-29 01:42:09 +03:00
|
|
|
already_AddRefed<CSSValue> GetGridTemplateColumnsRows(
|
|
|
|
const nsStyleGridTemplate& aTrackList,
|
2016-01-27 19:02:13 +03:00
|
|
|
const mozilla::ComputedGridTrackInfo* aTrackInfo);
|
2014-03-11 02:54:13 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool GetLineHeightCoord(nscoord& aCoord);
|
2002-03-22 23:18:42 +03:00
|
|
|
|
2016-11-19 00:47:30 +03:00
|
|
|
bool ShouldHonorMinSizeAutoInAxis(mozilla::PhysicalAxis aAxis);
|
|
|
|
|
2010-07-15 00:58:55 +04:00
|
|
|
/* Properties queryable as CSSValues.
|
|
|
|
* To avoid a name conflict with nsIDOM*CSS2Properties, these are all
|
|
|
|
* DoGetXXX instead of GetXXX.
|
|
|
|
*/
|
2002-04-20 18:30:57 +04:00
|
|
|
|
|
|
|
/* Box properties */
|
2015-12-29 01:42:08 +03:00
|
|
|
|
|
|
|
already_AddRefed<CSSValue> DoGetWidth();
|
|
|
|
already_AddRefed<CSSValue> DoGetHeight();
|
|
|
|
already_AddRefed<CSSValue> DoGetMaxHeight();
|
|
|
|
already_AddRefed<CSSValue> DoGetMaxWidth();
|
|
|
|
already_AddRefed<CSSValue> DoGetMinHeight();
|
|
|
|
already_AddRefed<CSSValue> DoGetMinWidth();
|
|
|
|
already_AddRefed<CSSValue> DoGetLeft();
|
|
|
|
already_AddRefed<CSSValue> DoGetTop();
|
|
|
|
already_AddRefed<CSSValue> DoGetRight();
|
|
|
|
already_AddRefed<CSSValue> DoGetBottom();
|
2002-03-22 23:18:42 +03:00
|
|
|
|
2018-07-02 02:00:18 +03:00
|
|
|
/* Font properties */
|
2015-12-29 01:42:08 +03:00
|
|
|
already_AddRefed<CSSValue> DoGetOsxFontSmoothing();
|
2002-03-22 23:18:42 +03:00
|
|
|
|
2014-03-11 02:54:13 +04:00
|
|
|
/* Grid properties */
|
2015-12-29 01:42:08 +03:00
|
|
|
already_AddRefed<CSSValue> DoGetGridTemplateColumns();
|
|
|
|
already_AddRefed<CSSValue> DoGetGridTemplateRows();
|
2014-03-11 02:54:13 +04:00
|
|
|
|
2016-01-28 08:28:00 +03:00
|
|
|
/* StyleImageLayer properties */
|
|
|
|
already_AddRefed<CSSValue> DoGetImageLayerPosition(
|
|
|
|
const nsStyleImageLayers& aLayers);
|
|
|
|
|
|
|
|
/* Mask properties */
|
|
|
|
already_AddRefed<CSSValue> DoGetMask();
|
2017-09-21 12:36:57 +03:00
|
|
|
|
2002-03-22 23:18:42 +03:00
|
|
|
/* Padding properties */
|
2015-12-29 01:42:08 +03:00
|
|
|
already_AddRefed<CSSValue> DoGetPaddingTop();
|
|
|
|
already_AddRefed<CSSValue> DoGetPaddingBottom();
|
|
|
|
already_AddRefed<CSSValue> DoGetPaddingLeft();
|
|
|
|
already_AddRefed<CSSValue> DoGetPaddingRight();
|
2002-03-22 23:18:42 +03:00
|
|
|
|
|
|
|
/* Table Properties */
|
2015-12-29 01:42:08 +03:00
|
|
|
already_AddRefed<CSSValue> DoGetBorderSpacing();
|
2002-03-22 23:18:42 +03:00
|
|
|
|
|
|
|
/* Border Properties */
|
2015-12-29 01:42:08 +03:00
|
|
|
already_AddRefed<CSSValue> DoGetBorderTopWidth();
|
|
|
|
already_AddRefed<CSSValue> DoGetBorderBottomWidth();
|
|
|
|
already_AddRefed<CSSValue> DoGetBorderLeftWidth();
|
|
|
|
already_AddRefed<CSSValue> DoGetBorderRightWidth();
|
2011-12-23 03:34:45 +04:00
|
|
|
|
2002-03-22 23:18:42 +03:00
|
|
|
/* Margin Properties */
|
2015-12-29 01:42:08 +03:00
|
|
|
already_AddRefed<CSSValue> DoGetMarginTopWidth();
|
|
|
|
already_AddRefed<CSSValue> DoGetMarginBottomWidth();
|
|
|
|
already_AddRefed<CSSValue> DoGetMarginLeftWidth();
|
|
|
|
already_AddRefed<CSSValue> DoGetMarginRightWidth();
|
2002-03-22 23:18:42 +03:00
|
|
|
|
|
|
|
/* Text Properties */
|
2015-12-29 01:42:08 +03:00
|
|
|
already_AddRefed<CSSValue> DoGetLineHeight();
|
|
|
|
already_AddRefed<CSSValue> DoGetTextDecoration();
|
|
|
|
already_AddRefed<CSSValue> DoGetTextDecorationColor();
|
|
|
|
already_AddRefed<CSSValue> DoGetTextDecorationStyle();
|
2002-03-22 23:18:42 +03:00
|
|
|
|
|
|
|
/* Display properties */
|
2015-12-29 01:42:08 +03:00
|
|
|
already_AddRefed<CSSValue> DoGetTransform();
|
|
|
|
already_AddRefed<CSSValue> DoGetTransformOrigin();
|
|
|
|
already_AddRefed<CSSValue> DoGetPerspectiveOrigin();
|
2002-03-22 23:18:42 +03:00
|
|
|
|
2004-06-17 15:57:37 +04:00
|
|
|
/* Column properties */
|
2015-12-29 01:42:08 +03:00
|
|
|
already_AddRefed<CSSValue> DoGetColumnRuleWidth();
|
2004-06-17 15:57:37 +04:00
|
|
|
|
2018-06-27 08:34:29 +03:00
|
|
|
// For working around a MSVC bug. See related comment in
|
|
|
|
// GenerateComputedDOMStyleGenerated.py.
|
|
|
|
already_AddRefed<CSSValue> DummyGetter();
|
|
|
|
|
2014-09-09 22:40:17 +04:00
|
|
|
/* Helper functions */
|
2016-09-16 07:40:45 +03:00
|
|
|
void SetValueFromComplexColor(nsROCSSPrimitiveValue* aValue,
|
2019-04-04 14:35:33 +03:00
|
|
|
const mozilla::StyleColor& aColor);
|
2016-08-25 12:59:51 +03:00
|
|
|
void SetValueToPosition(const mozilla::Position& aPosition,
|
2014-09-09 22:40:17 +04:00
|
|
|
nsDOMCSSValueList* aValueList);
|
Bug 1552708 - Use cbindgen for URIs. r=heycam
This doesn't clean up as much as a whole, but it's a step in the right
direction. In particular, it allows us to start using simple bindings for:
* Filters
* Shapes and images, almost. Need to:
* Get rid of the complex -moz- gradient parsing (let
layout.css.simple-moz-gradient.enabled get to release).
* Counters, almost. Need to:
* Share the Attr representation with Gecko, by not using Option<>.
* Just another variant should be enough (ContentItem::{Attr,Prefixedattr},
maybe).
Which in turn allows us to remove a whole lot of bindings in followups to this.
The setup changes a bit. This also removes the double pointer I complained about
while reviewing the shared UA sheet patches. The old setup is:
```
SpecifiedUrl
* CssUrl
* Arc<CssUrlData>
* String
* UrlExtraData
* UrlValueSource
* Arc<CssUrlData>
* load id
* resolved uri
* CORS mode.
* ...
```
The new one removes the double reference to the url data via URLValue, and looks
like:
```
SpecifiedUrl
* CssUrl
* Arc<CssUrlData>
* String
* UrlExtraData
* CorsMode
* LoadData
* load id
* resolved URI
```
The LoadData is the only mutable bit that C++ can change, and is not used from
Rust. Ideally, in the future, we could just use rust-url to resolve the URL
after parsing or something, and make it all immutable. Maybe.
I've verified that this approach still works with the UA sheet patches (via the
LoadDataSource::Lazy).
The reordering of mWillChange is to avoid nsStyleDisplay from going over the
size limit. We want to split it up anyway in bug 1552587, but mBinding gains a
tag member, which means that we were having a bit of extra padding.
One thing I want to explore is to see if we can abuse rustc's non-zero
optimizations to predict the layout from C++, but that's something to explore at
some other point in time and with a lot of care and help from Michael (who sits
next to me and works on rustc ;)).
Differential Revision: https://phabricator.services.mozilla.com/D31742
2019-05-27 14:45:12 +03:00
|
|
|
void SetValueToURLValue(const mozilla::StyleComputedUrl* aURL,
|
2016-10-11 09:56:11 +03:00
|
|
|
nsROCSSPrimitiveValue* aValue);
|
2010-04-27 20:15:01 +04:00
|
|
|
|
2019-05-11 21:01:50 +03:00
|
|
|
void SetValueToSize(nsROCSSPrimitiveValue* aValue, const mozilla::StyleSize&);
|
2019-02-10 15:55:16 +03:00
|
|
|
|
|
|
|
void SetValueToLengthPercentageOrAuto(nsROCSSPrimitiveValue* aValue,
|
|
|
|
const LengthPercentageOrAuto&,
|
|
|
|
bool aClampNegativeCalc);
|
|
|
|
|
|
|
|
void SetValueToLengthPercentage(nsROCSSPrimitiveValue* aValue,
|
|
|
|
const LengthPercentage&,
|
2019-05-11 21:01:50 +03:00
|
|
|
bool aClampNegativeCalc);
|
2019-02-10 15:55:16 +03:00
|
|
|
|
|
|
|
void SetValueToMaxSize(nsROCSSPrimitiveValue* aValue, const StyleMaxSize&);
|
|
|
|
|
|
|
|
void SetValueToExtremumLength(nsROCSSPrimitiveValue* aValue,
|
|
|
|
StyleExtremumLength);
|
|
|
|
|
2007-02-20 21:43:16 +03:00
|
|
|
/**
|
|
|
|
* If aCoord is a eStyleUnit_Coord returns the nscoord. If it's
|
2007-04-23 11:04:33 +04:00
|
|
|
* eStyleUnit_Percent, attempts to resolve the percentage base and returns
|
2019-02-10 15:55:16 +03:00
|
|
|
* the resulting nscoord. If it's some other unit or a percentage base can't
|
2007-04-23 11:04:33 +04:00
|
|
|
* be determined, returns aDefaultValue.
|
2007-02-20 21:43:16 +03:00
|
|
|
*/
|
2019-02-10 15:55:16 +03:00
|
|
|
nscoord StyleCoordToNSCoord(const LengthPercentage& aCoord,
|
2007-04-23 11:04:33 +04:00
|
|
|
PercentageBaseGetter aPercentageBaseGetter,
|
2011-09-29 10:19:26 +04:00
|
|
|
nscoord aDefaultValue, bool aClampNegativeCalc);
|
2019-02-10 15:55:16 +03:00
|
|
|
template <typename LengthPercentageLike>
|
|
|
|
nscoord StyleCoordToNSCoord(const LengthPercentageLike& aCoord,
|
|
|
|
PercentageBaseGetter aPercentageBaseGetter,
|
|
|
|
nscoord aDefaultValue, bool aClampNegativeCalc) {
|
|
|
|
if (aCoord.IsLengthPercentage()) {
|
|
|
|
return StyleCoordToNSCoord(aCoord.AsLengthPercentage(),
|
|
|
|
aPercentageBaseGetter, aDefaultValue,
|
|
|
|
aClampNegativeCalc);
|
|
|
|
}
|
|
|
|
return aDefaultValue;
|
|
|
|
}
|
2007-02-20 21:43:16 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool GetCBContentWidth(nscoord& aWidth);
|
2019-02-05 02:28:44 +03:00
|
|
|
bool GetCBContentHeight(nscoord& aHeight);
|
|
|
|
bool GetCBPaddingRectWidth(nscoord& aWidth);
|
|
|
|
bool GetCBPaddingRectHeight(nscoord& aHeight);
|
2013-08-16 04:31:32 +04:00
|
|
|
bool GetScrollFrameContentWidth(nscoord& aWidth);
|
|
|
|
bool GetScrollFrameContentHeight(nscoord& aHeight);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool GetFrameBorderRectWidth(nscoord& aWidth);
|
|
|
|
bool GetFrameBorderRectHeight(nscoord& aHeight);
|
2002-03-22 23:18:42 +03:00
|
|
|
|
2019-04-12 13:04:33 +03:00
|
|
|
// Find out if we can safely skip flushing (i.e. pending restyles do not
|
|
|
|
// affect mElement).
|
|
|
|
bool NeedsToFlush() const;
|
2017-05-23 07:02:11 +03:00
|
|
|
|
2018-03-22 21:20:41 +03:00
|
|
|
static ComputedStyleMap* GetComputedStyleMap();
|
2002-10-08 05:53:31 +04:00
|
|
|
|
2005-06-03 05:51:15 +04:00
|
|
|
// We don't really have a good immutable representation of "presentation".
|
|
|
|
// Given the way GetComputedStyle is currently used, we should just grab the
|
2018-06-08 12:18:51 +03:00
|
|
|
// presshell, if any, from the document.
|
2005-06-03 05:51:15 +04:00
|
|
|
nsWeakPtr mDocumentWeak;
|
2019-02-10 15:55:16 +03:00
|
|
|
RefPtr<Element> mElement;
|
2002-03-22 23:18:42 +03:00
|
|
|
|
2015-09-17 05:08:20 +03:00
|
|
|
/**
|
2018-03-23 16:49:21 +03:00
|
|
|
* Strong reference to the ComputedStyle we access data from. This can be
|
|
|
|
* either a ComputedStyle we resolved ourselves or a ComputedStyle we got
|
2015-09-17 05:08:20 +03:00
|
|
|
* from our frame.
|
|
|
|
*
|
2018-03-23 16:49:21 +03:00
|
|
|
* If we got the ComputedStyle from the frame, we clear out mComputedStyle
|
2015-09-17 05:08:20 +03:00
|
|
|
* in ClearCurrentStyleSources. If we resolved one ourselves, then
|
2018-03-22 21:20:41 +03:00
|
|
|
* ClearCurrentStyleSources leaves it in mComputedStyle for use the next
|
2015-09-17 05:08:20 +03:00
|
|
|
* time this nsComputedDOMStyle object is queried. UpdateCurrentStyleSources
|
2018-03-23 16:49:21 +03:00
|
|
|
* in this case will check that the ComputedStyle is still valid to be used,
|
2015-09-17 05:08:20 +03:00
|
|
|
* by checking whether flush styles results in any restyles having been
|
|
|
|
* processed.
|
2002-03-22 23:18:42 +03:00
|
|
|
*/
|
2019-02-10 15:55:16 +03:00
|
|
|
RefPtr<ComputedStyle> mComputedStyle;
|
2017-10-03 01:05:19 +03:00
|
|
|
RefPtr<nsAtom> mPseudo;
|
2002-03-22 23:18:42 +03:00
|
|
|
|
2006-12-22 09:10:32 +03:00
|
|
|
/*
|
2008-01-30 00:53:09 +03:00
|
|
|
* While computing style data, the primary frame for mContent --- named
|
|
|
|
* "outer" because we should use it to compute positioning data. Null
|
2006-12-22 09:10:32 +03:00
|
|
|
* otherwise.
|
|
|
|
*/
|
2008-01-30 00:53:09 +03:00
|
|
|
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;
|
2007-05-05 09:30:10 +04:00
|
|
|
/*
|
|
|
|
* While computing style data, the presshell we're working with. Null
|
|
|
|
* otherwise.
|
|
|
|
*/
|
2019-04-16 10:25:10 +03:00
|
|
|
mozilla::PresShell* mPresShell;
|
2006-12-22 09:10:32 +03:00
|
|
|
|
2017-05-19 07:57:35 +03:00
|
|
|
/*
|
|
|
|
* The kind of styles we should be returning.
|
|
|
|
*/
|
|
|
|
StyleType mStyleType;
|
|
|
|
|
2015-09-17 05:08:20 +03:00
|
|
|
/**
|
|
|
|
* The nsComputedDOMStyle generation at the time we last resolved a style
|
2019-02-06 20:12:17 +03:00
|
|
|
* context and stored it in mComputedStyle, and the pres shell we got the
|
|
|
|
* style from. Should only be used together.
|
2015-09-17 05:08:20 +03:00
|
|
|
*/
|
2019-02-06 20:12:17 +03:00
|
|
|
uint64_t mComputedStyleGeneration = 0;
|
|
|
|
|
|
|
|
uint32_t mPresShellId = 0;
|
2015-09-17 05:08:20 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mExposeVisitedStyle;
|
2010-04-03 05:58:25 +04:00
|
|
|
|
2015-09-17 05:08:20 +03:00
|
|
|
/**
|
2018-03-23 16:49:21 +03:00
|
|
|
* Whether we resolved a ComputedStyle last time we called
|
2015-09-17 05:08:20 +03:00
|
|
|
* UpdateCurrentStyleSources. Initially false.
|
|
|
|
*/
|
2018-03-22 21:20:41 +03:00
|
|
|
bool mResolvedComputedStyle;
|
2015-09-17 05:08:20 +03:00
|
|
|
|
2009-02-25 03:14:45 +03:00
|
|
|
#ifdef DEBUG
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mFlushedPendingReflows;
|
2009-02-25 03:14:45 +03:00
|
|
|
#endif
|
2018-06-27 08:34:29 +03:00
|
|
|
|
|
|
|
friend struct ComputedStyleMap;
|
2002-03-22 23:18:42 +03:00
|
|
|
};
|
|
|
|
|
2012-07-06 16:28:33 +04:00
|
|
|
already_AddRefed<nsComputedDOMStyle> NS_NewComputedDOMStyle(
|
|
|
|
mozilla::dom::Element* aElement, const nsAString& aPseudoElt,
|
2019-01-02 16:05:23 +03:00
|
|
|
mozilla::dom::Document* aDocument,
|
2017-05-19 07:57:35 +03:00
|
|
|
nsComputedDOMStyle::StyleType aStyleType = nsComputedDOMStyle::eAll);
|
2009-07-13 15:14:57 +04:00
|
|
|
|
2002-03-22 23:18:42 +03:00
|
|
|
#endif /* nsComputedDOMStyle_h__ */
|