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"
|
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"
|
2020-11-23 19:21:38 +03:00
|
|
|
#include "nsStubMutationObserver.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
|
|
|
|
2020-11-23 19:21:38 +03:00
|
|
|
// XXX Avoid including this here by moving function bodies to the cpp file
|
|
|
|
#include "mozilla/dom/Element.h"
|
|
|
|
|
2013-03-03 04:31:48 +04:00
|
|
|
namespace mozilla {
|
2020-11-23 19:21:38 +03:00
|
|
|
enum class FlushType : uint8_t;
|
|
|
|
|
2013-03-03 04:31:48 +04:00
|
|
|
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;
|
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:
|
Bug 1519958 - Refactor grid types to preserve repeat() at computed value time and use cbindgen. r=mats,boris
I'm _really_ sorry for the size of the patch. I tried to do this in two steps
but it was a lot of work and pretty ugly.
This patch makes us use cbindgen for grid-template-{rows,columns}, in order to:
* Make us preserve repeat() at computed-value time. This is per spec since
interpolation needs to know about repeat(). Except for subgrid, which did the
repeat expansion at parse-time and was a bit more annoying (plus it doesn't
really animate yet so we don't need it to comply with the spec).
* Tweaks the WPT tests for interpolation to adopt the resolution at:
https://github.com/w3c/csswg-drafts/issues/3503.
Trade-off here, as this patch stands, is that this change makes us use less
long-living memory, since we expand repeat() during layout, but at the cost of a
bit of CPU time during layout (conditional on the property applying though,
which wasn't the case before). It should be very easy to store a cached version
of the template, should this be too hot (I expect it isn't), or to change the
representation in other ways to optimize grid layout code if it's worth it.
Another trade-off: I've used SmallPointerArray to handle line-name merging,
pointing to the individual arrays in the style data, rather than actually
heap-allocating the merged lists. This would also be pretty easy to change
should we measure and see that it's not worth it.
This patch also opens the gate to potentially improving memory usage in some
other ways, by reference-counting line-name lists for example, though I don't
have data that suggests it is worth it.
In general, this patch makes much easier to tweak the internal representation of
the grid style data structures. Overall, I think it's a win, the amount of magic
going on in that mako code was a bit huge; it took a bit to wrap my head around
it.
This patch comments out the style struct size assertions. They will be
uncommented in a follow-up patch which contains some improvements for this type,
which are worth getting reviewed separately.
Also, this patch doesn't remove as much code as I would've hoped for because of
I tried not to change most of the dom/grid code for inspector, but I think a
fair bit of the nsGridContainerFrame.cpp code that collects information for it
can be simplified / de-copy-pasted to some extent. But that was a pre-existing
problem and this patch is already quite massive.
Differential Revision: https://phabricator.services.mozilla.com/D36598
2019-06-28 14:27:19 +03:00
|
|
|
template <typename T>
|
|
|
|
using Span = mozilla::Span<T>;
|
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 LengthPercentage = mozilla::LengthPercentage;
|
|
|
|
using LengthPercentageOrAuto = mozilla::LengthPercentageOrAuto;
|
|
|
|
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,
|
2020-12-17 17:04:35 +03:00
|
|
|
nsACString& aValue) override;
|
2020-02-03 23:35:54 +03:00
|
|
|
void SetPropertyValue(const nsCSSPropertyID aPropID, const nsACString& aValue,
|
|
|
|
nsIPrincipal* aSubjectPrincipal,
|
|
|
|
mozilla::ErrorResult& aRv) override;
|
2018-03-14 16:13:29 +03:00
|
|
|
|
2020-01-04 13:36:49 +03:00
|
|
|
void IndexedGetter(uint32_t aIndex, bool& aFound,
|
|
|
|
nsACString& 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
|
|
|
|
2021-03-23 00:15:34 +03:00
|
|
|
nsINode* GetAssociatedNode() const override { return mElement; }
|
|
|
|
nsINode* GetParentObject() const 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(
|
2020-12-25 16:26:37 +03:00
|
|
|
const 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;
|
|
|
|
}
|
|
|
|
|
2020-01-04 13:36:49 +03:00
|
|
|
void GetCSSImageURLs(const nsACString& aPropertyName,
|
|
|
|
nsTArray<nsCString>& aImageURLs,
|
2018-03-08 21:52:32 +03:00
|
|
|
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:
|
2020-12-12 15:06:09 +03:00
|
|
|
nsresult GetPropertyValue(const nsCSSPropertyID aPropID,
|
|
|
|
const nsACString& aMaybeCustomPropertyNme,
|
2020-12-17 17:04:35 +03:00
|
|
|
nsACString& aValue);
|
2020-12-12 15:06:09 +03:00
|
|
|
|
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.
|
2019-07-31 20:31:21 +03:00
|
|
|
void UpdateCurrentStyleSources(nsCSSPropertyID);
|
2013-12-12 06:09:45 +04:00
|
|
|
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(
|
2020-12-25 16:26:37 +03:00
|
|
|
const 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> GetBorderWidthFor(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
|
|
|
|
Bug 1519958 - Refactor grid types to preserve repeat() at computed value time and use cbindgen. r=mats,boris
I'm _really_ sorry for the size of the patch. I tried to do this in two steps
but it was a lot of work and pretty ugly.
This patch makes us use cbindgen for grid-template-{rows,columns}, in order to:
* Make us preserve repeat() at computed-value time. This is per spec since
interpolation needs to know about repeat(). Except for subgrid, which did the
repeat expansion at parse-time and was a bit more annoying (plus it doesn't
really animate yet so we don't need it to comply with the spec).
* Tweaks the WPT tests for interpolation to adopt the resolution at:
https://github.com/w3c/csswg-drafts/issues/3503.
Trade-off here, as this patch stands, is that this change makes us use less
long-living memory, since we expand repeat() during layout, but at the cost of a
bit of CPU time during layout (conditional on the property applying though,
which wasn't the case before). It should be very easy to store a cached version
of the template, should this be too hot (I expect it isn't), or to change the
representation in other ways to optimize grid layout code if it's worth it.
Another trade-off: I've used SmallPointerArray to handle line-name merging,
pointing to the individual arrays in the style data, rather than actually
heap-allocating the merged lists. This would also be pretty easy to change
should we measure and see that it's not worth it.
This patch also opens the gate to potentially improving memory usage in some
other ways, by reference-counting line-name lists for example, though I don't
have data that suggests it is worth it.
In general, this patch makes much easier to tweak the internal representation of
the grid style data structures. Overall, I think it's a win, the amount of magic
going on in that mako code was a bit huge; it took a bit to wrap my head around
it.
This patch comments out the style struct size assertions. They will be
uncommented in a follow-up patch which contains some improvements for this type,
which are worth getting reviewed separately.
Also, this patch doesn't remove as much code as I would've hoped for because of
I tried not to change most of the dom/grid code for inspector, but I think a
fair bit of the nsGridContainerFrame.cpp code that collects information for it
can be simplified / de-copy-pasted to some extent. But that was a pre-existing
problem and this patch is already quite massive.
Differential Revision: https://phabricator.services.mozilla.com/D36598
2019-06-28 14:27:19 +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(
|
Bug 1519958 - Refactor grid types to preserve repeat() at computed value time and use cbindgen. r=mats,boris
I'm _really_ sorry for the size of the patch. I tried to do this in two steps
but it was a lot of work and pretty ugly.
This patch makes us use cbindgen for grid-template-{rows,columns}, in order to:
* Make us preserve repeat() at computed-value time. This is per spec since
interpolation needs to know about repeat(). Except for subgrid, which did the
repeat expansion at parse-time and was a bit more annoying (plus it doesn't
really animate yet so we don't need it to comply with the spec).
* Tweaks the WPT tests for interpolation to adopt the resolution at:
https://github.com/w3c/csswg-drafts/issues/3503.
Trade-off here, as this patch stands, is that this change makes us use less
long-living memory, since we expand repeat() during layout, but at the cost of a
bit of CPU time during layout (conditional on the property applying though,
which wasn't the case before). It should be very easy to store a cached version
of the template, should this be too hot (I expect it isn't), or to change the
representation in other ways to optimize grid layout code if it's worth it.
Another trade-off: I've used SmallPointerArray to handle line-name merging,
pointing to the individual arrays in the style data, rather than actually
heap-allocating the merged lists. This would also be pretty easy to change
should we measure and see that it's not worth it.
This patch also opens the gate to potentially improving memory usage in some
other ways, by reference-counting line-name lists for example, though I don't
have data that suggests it is worth it.
In general, this patch makes much easier to tweak the internal representation of
the grid style data structures. Overall, I think it's a win, the amount of magic
going on in that mako code was a bit huge; it took a bit to wrap my head around
it.
This patch comments out the style struct size assertions. They will be
uncommented in a follow-up patch which contains some improvements for this type,
which are worth getting reviewed separately.
Also, this patch doesn't remove as much code as I would've hoped for because of
I tried not to change most of the dom/grid code for inspector, but I think a
fair bit of the nsGridContainerFrame.cpp code that collects information for it
can be simplified / de-copy-pasted to some extent. But that was a pre-existing
problem and this patch is already quite massive.
Differential Revision: https://phabricator.services.mozilla.com/D36598
2019-06-28 14:27:19 +03:00
|
|
|
const mozilla::StyleGridTemplateComponent& aTrackList,
|
2019-10-12 20:15:43 +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();
|
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
|
|
|
|
2020-12-17 02:44:06 +03:00
|
|
|
void SetValueToMaxSize(nsROCSSPrimitiveValue* aValue,
|
|
|
|
const mozilla::StyleMaxSize&);
|
2019-02-10 15:55: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
|
2019-07-31 20:23:41 +03:00
|
|
|
// affect our element).
|
2019-10-07 02:30:23 +03:00
|
|
|
bool NeedsToFlushStyle(nsCSSPropertyID) const;
|
2019-07-31 20:31:21 +03:00
|
|
|
// Find out if we need to flush layout of the document, depending on the
|
|
|
|
// property that was requested.
|
|
|
|
bool NeedsToFlushLayout(nsCSSPropertyID) const;
|
|
|
|
// Flushes the given document, which must be our document, and potentially the
|
|
|
|
// mElement's document.
|
|
|
|
void Flush(Document&, mozilla::FlushType);
|
2019-07-31 20:26:32 +03:00
|
|
|
nsIFrame* GetOuterFrame() 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
|
2019-07-31 20:08:37 +03:00
|
|
|
bool mFlushedPendingReflows = false;
|
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__ */
|