From a90a5cba08fdf6c0ceb95101c275108a152a3aed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:35:37 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- layout/style/CSSKeyframeRule.cpp | 3 +- layout/style/CSSMarginRule.cpp | 183 ++++++++++++++++++++++++++++++++ layout/style/CSSMarginRule.h | 107 +++++++++++++++++++ layout/style/CSSPageRule.h | 1 - layout/style/CSSStyleRule.cpp | 14 ++- layout/style/CSSStyleRule.h | 2 +- layout/style/FontFaceSetWorkerImpl.cpp | 6 +- layout/style/GeckoBindings.cpp | 38 ------- layout/style/GeckoBindings.h | 21 ---- layout/style/Loader.cpp | 25 +++-- layout/style/PreferenceSheet.cpp | 1 - layout/style/Rule.cpp | 8 +- layout/style/ServoBindingTypes.h | 1 + layout/style/ServoBindings.h | 1 + layout/style/ServoBindings.toml | 5 +- layout/style/ServoCSSRuleList.cpp | 9 +- layout/style/ServoLockedArcTypeList.h | 1 + layout/style/ServoStyleConstsForwards.h | 1 + layout/style/ServoStyleConstsInlines.h | 1 + layout/style/ServoStyleSet.cpp | 7 +- layout/style/SheetLoadData.h | 8 +- layout/style/crashtests/crashtests.list | 22 ++-- layout/style/moz.build | 2 + layout/style/nsCSSValue.h | 18 ++-- layout/style/nsComputedDOMStyle.cpp | 6 +- layout/style/nsComputedDOMStyle.h | 2 +- layout/style/nsDOMCSSAttrDeclaration.h | 2 +- layout/style/nsDOMCSSDeclaration.h | 2 +- layout/style/nsMediaFeatures.cpp | 1 - layout/style/nsStyleStruct.cpp | 8 +- layout/style/nsStyleStruct.h | 69 ++++-------- layout/style/res/forms.css | 9 +- layout/style/res/html.css | 2 +- layout/style/res/quirk.css | 6 +- layout/style/test/property_database.js | 2 +- 35 files changed, 416 insertions(+), 178 deletions(-) create mode 100644 layout/style/CSSMarginRule.cpp create mode 100644 layout/style/CSSMarginRule.h (limited to 'layout/style') diff --git a/layout/style/CSSKeyframeRule.cpp b/layout/style/CSSKeyframeRule.cpp index e6ae2bada0..b70c6543b0 100644 --- a/layout/style/CSSKeyframeRule.cpp +++ b/layout/style/CSSKeyframeRule.cpp @@ -16,7 +16,7 @@ namespace mozilla::dom { // CSSKeyframeDeclaration // -class CSSKeyframeDeclaration : public nsDOMCSSDeclaration { +class CSSKeyframeDeclaration final : public nsDOMCSSDeclaration { public: explicit CSSKeyframeDeclaration(CSSKeyframeRule* aRule) : mRule(aRule) { mDecls = @@ -63,7 +63,6 @@ class CSSKeyframeDeclaration : public nsDOMCSSDeclaration { nsIPrincipal* aSubjectPrincipal) const final { return GetParsingEnvironmentForRule(mRule, StyleCssRuleType::Keyframe); } - Document* DocToUpdate() final { return nullptr; } nsINode* GetAssociatedNode() const final { return mRule ? mRule->GetAssociatedDocumentOrShadowRoot() : nullptr; diff --git a/layout/style/CSSMarginRule.cpp b/layout/style/CSSMarginRule.cpp new file mode 100644 index 0000000000..64a706666c --- /dev/null +++ b/layout/style/CSSMarginRule.cpp @@ -0,0 +1,183 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* 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/. */ + +#include "mozilla/dom/CSSMarginRule.h" +#include "mozilla/dom/CSSMarginRuleBinding.h" + +#include "mozilla/DeclarationBlock.h" +#include "mozilla/ServoBindings.h" + +namespace mozilla::dom { + +// -- CSSMarginRuleDeclaration --------------------------------------- + +CSSMarginRuleDeclaration::CSSMarginRuleDeclaration( + already_AddRefed aDecls) + : mDecls(new DeclarationBlock(std::move(aDecls))) { + mDecls->SetOwningRule(Rule()); +} + +CSSMarginRuleDeclaration::~CSSMarginRuleDeclaration() { + mDecls->SetOwningRule(nullptr); +} + +// QueryInterface implementation for CSSMarginRuleDeclaration +NS_INTERFACE_MAP_BEGIN(CSSMarginRuleDeclaration) + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY + // We forward the cycle collection interfaces to Rule(), which is + // never null (in fact, we're part of that object!) + if (aIID.Equals(NS_GET_IID(nsCycleCollectionISupports)) || + aIID.Equals(NS_GET_IID(nsXPCOMCycleCollectionParticipant))) { + return Rule()->QueryInterface(aIID, aInstancePtr); + } +NS_INTERFACE_MAP_END_INHERITING(nsDOMCSSDeclaration) + +NS_IMPL_ADDREF_USING_AGGREGATOR(CSSMarginRuleDeclaration, Rule()) +NS_IMPL_RELEASE_USING_AGGREGATOR(CSSMarginRuleDeclaration, Rule()) + +/* nsDOMCSSDeclaration implementation */ +css::Rule* CSSMarginRuleDeclaration::GetParentRule() { return Rule(); } + +nsINode* CSSMarginRuleDeclaration::GetAssociatedNode() const { + return Rule()->GetAssociatedDocumentOrShadowRoot(); +} + +nsISupports* CSSMarginRuleDeclaration::GetParentObject() const { + return Rule()->GetParentObject(); +} + +DeclarationBlock* CSSMarginRuleDeclaration::GetOrCreateCSSDeclaration( + Operation aOperation, DeclarationBlock** aCreated) { + if (aOperation != Operation::Read) { + if (StyleSheet* sheet = Rule()->GetStyleSheet()) { + sheet->WillDirty(); + } + } + return mDecls; +} + +void CSSMarginRuleDeclaration::SetRawAfterClone( + RefPtr aDeclarationBlock) { + mDecls->SetOwningRule(nullptr); + mDecls = new DeclarationBlock(aDeclarationBlock.forget()); + mDecls->SetOwningRule(Rule()); +} + +nsresult CSSMarginRuleDeclaration::SetCSSDeclaration( + DeclarationBlock* aDecl, MutationClosureData* aClosureData) { + MOZ_ASSERT(aDecl, "must be non-null"); + CSSMarginRule* rule = Rule(); + + if (aDecl != mDecls) { + mDecls->SetOwningRule(nullptr); + RefPtr decls = aDecl; + // TODO alaskanemily: bug 1890418 for implementing this and margin-rule + // style properties in general. + // Servo_MarginRule_SetStyle(rule->Raw(), decls->Raw()); + mDecls = std::move(decls); + mDecls->SetOwningRule(rule); + } + + return NS_OK; +} + +nsDOMCSSDeclaration::ParsingEnvironment +CSSMarginRuleDeclaration::GetParsingEnvironment( + nsIPrincipal* aSubjectPrincipal) const { + return GetParsingEnvironmentForRule(Rule(), StyleCssRuleType::Margin); +} + +// -- CSSMarginRule -------------------------------------------------- + +CSSMarginRule::CSSMarginRule(RefPtr aRawRule, + StyleSheet* aSheet, css::Rule* aParentRule, + uint32_t aLine, uint32_t aColumn) + : css::Rule(aSheet, aParentRule, aLine, aColumn), + mRawRule(std::move(aRawRule)), + mDecls(Servo_MarginRule_GetStyle(mRawRule).Consume()) {} + +NS_IMPL_ADDREF_INHERITED(CSSMarginRule, css::Rule) +NS_IMPL_RELEASE_INHERITED(CSSMarginRule, css::Rule) + +// QueryInterface implementation for MarginRule +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CSSMarginRule) +NS_INTERFACE_MAP_END_INHERITING(css::Rule) + +NS_IMPL_CYCLE_COLLECTION_CLASS(CSSMarginRule) + +NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(CSSMarginRule, css::Rule) + // Keep this in sync with IsCCLeaf. + + // Trace the wrapper for our declaration. This just expands out + // NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER which we can't use + // directly because the wrapper is on the declaration, not on us. + tmp->mDecls.TraceWrapper(aCallbacks, aClosure); +NS_IMPL_CYCLE_COLLECTION_TRACE_END + +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(CSSMarginRule) + // Keep this in sync with IsCCLeaf. + + // Unlink the wrapper for our declaration. + // + // Note that this has to happen before unlinking css::Rule. + tmp->UnlinkDeclarationWrapper(tmp->mDecls); + tmp->mDecls.mDecls->SetOwningRule(nullptr); +NS_IMPL_CYCLE_COLLECTION_UNLINK_END_INHERITED(css::Rule) + +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(CSSMarginRule, css::Rule) + // Keep this in sync with IsCCLeaf. +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END + +bool CSSMarginRule::IsCCLeaf() const { + if (!Rule::IsCCLeaf()) { + return false; + } + + return !mDecls.PreservingWrapper(); +} + +void CSSMarginRule::SetRawAfterClone(RefPtr aRaw) { + mRawRule = std::move(aRaw); + mDecls.SetRawAfterClone(Servo_MarginRule_GetStyle(mRawRule.get()).Consume()); +} + +// WebIDL interfaces +StyleCssRuleType CSSMarginRule::Type() const { + return StyleCssRuleType::Margin; +} + +// CSSRule implementation + +void CSSMarginRule::GetCssText(nsACString& aCssText) const { + Servo_MarginRule_GetCssText(mRawRule, &aCssText); +} + +void CSSMarginRule::GetName(nsACString& aRuleName) const { + Servo_MarginRule_GetName(mRawRule, &aRuleName); +} + +size_t CSSMarginRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { + // TODO Implement this! + return aMallocSizeOf(this); +} + +#ifdef DEBUG +void CSSMarginRule::List(FILE* out, int32_t aIndent) const { + nsAutoCString str; + for (int32_t i = 0; i < aIndent; i++) { + str.AppendLiteral(" "); + } + Servo_MarginRule_Debug(mRawRule, &str); + fprintf_stderr(out, "%s\n", str.get()); +} +#endif + +JSObject* CSSMarginRule::WrapObject(JSContext* aCx, + JS::Handle aGivenProto) { + return CSSMarginRule_Binding::Wrap(aCx, this, aGivenProto); +} + +} // namespace mozilla::dom diff --git a/layout/style/CSSMarginRule.h b/layout/style/CSSMarginRule.h new file mode 100644 index 0000000000..0ad5f60dbd --- /dev/null +++ b/layout/style/CSSMarginRule.h @@ -0,0 +1,107 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* 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/. */ + +#ifndef mozilla_dom_CSSMarginRule_h +#define mozilla_dom_CSSMarginRule_h + +#include "mozilla/css/Rule.h" +#include "mozilla/ServoBindingTypes.h" + +#include "nsDOMCSSDeclaration.h" +#include "nsICSSDeclaration.h" + +namespace mozilla { +class DeclarationBlock; + +namespace dom { +class CSSMarginRule; + +class CSSMarginRuleDeclaration final : public nsDOMCSSDeclaration { + public: + NS_DECL_ISUPPORTS_INHERITED + + css::Rule* GetParentRule() final; + nsINode* GetAssociatedNode() const final; + nsISupports* GetParentObject() const final; + + protected: + DeclarationBlock* GetOrCreateCSSDeclaration( + Operation aOperation, DeclarationBlock** aCreated) final; + nsresult SetCSSDeclaration(DeclarationBlock* aDecl, + MutationClosureData* aClosureData) final; + Document* DocToUpdate() final { return nullptr; } + nsDOMCSSDeclaration::ParsingEnvironment GetParsingEnvironment( + nsIPrincipal* aSubjectPrincipal) const final; + + private: + // For accessing the constructor. + friend class CSSMarginRule; + + explicit CSSMarginRuleDeclaration( + already_AddRefed aDecls); + void SetRawAfterClone(RefPtr); + + ~CSSMarginRuleDeclaration(); + + inline CSSMarginRule* Rule(); + inline const CSSMarginRule* Rule() const; + + RefPtr mDecls; +}; + +class CSSMarginRule final : public css::Rule { + public: + CSSMarginRule(RefPtr aRawRule, StyleSheet* aSheet, + css::Rule* aParentRule, uint32_t aLine, uint32_t aColumn); + + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(CSSMarginRule, + css::Rule) + + bool IsCCLeaf() const final; + + StyleMarginRule* Raw() const { return mRawRule; } + void SetRawAfterClone(RefPtr); + + // WebIDL interfaces + StyleCssRuleType Type() const final; + void GetCssText(nsACString& aCssText) const final; + nsICSSDeclaration* Style() { return &mDecls; } + + void GetName(nsACString& aRuleName) const; + + size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const final; + +#ifdef DEBUG + void List(FILE* out = stdout, int32_t aIndent = 0) const final; +#endif + + JSObject* WrapObject(JSContext* aCx, JS::Handle aGivenProto) final; + + private: + ~CSSMarginRule() = default; + + // For computing the offset of mDecls. + friend class CSSMarginRuleDeclaration; + + RefPtr mRawRule; + CSSMarginRuleDeclaration mDecls; +}; + +CSSMarginRule* CSSMarginRuleDeclaration::Rule() { + return reinterpret_cast(reinterpret_cast(this) - + offsetof(CSSMarginRule, mDecls)); +} + +const CSSMarginRule* CSSMarginRuleDeclaration::Rule() const { + return reinterpret_cast( + reinterpret_cast(this) - offsetof(CSSMarginRule, mDecls)); +} + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_CSSMarginRule_h diff --git a/layout/style/CSSPageRule.h b/layout/style/CSSPageRule.h index 904f94d2c0..b133111244 100644 --- a/layout/style/CSSPageRule.h +++ b/layout/style/CSSPageRule.h @@ -33,7 +33,6 @@ class CSSPageRuleDeclaration final : public nsDOMCSSDeclaration { Operation aOperation, DeclarationBlock** aCreated) final; nsresult SetCSSDeclaration(DeclarationBlock* aDecl, MutationClosureData* aClosureData) final; - Document* DocToUpdate() final { return nullptr; } nsDOMCSSDeclaration::ParsingEnvironment GetParsingEnvironment( nsIPrincipal* aSubjectPrincipal) const final; diff --git a/layout/style/CSSStyleRule.cpp b/layout/style/CSSStyleRule.cpp index 5cdb47fddb..5a3dbfad01 100644 --- a/layout/style/CSSStyleRule.cpp +++ b/layout/style/CSSStyleRule.cpp @@ -101,8 +101,6 @@ nsresult CSSStyleRuleDeclaration::SetCSSDeclaration( return NS_OK; } -Document* CSSStyleRuleDeclaration::DocToUpdate() { return nullptr; } - nsDOMCSSDeclaration::ParsingEnvironment CSSStyleRuleDeclaration::GetParsingEnvironment( nsIPrincipal* aSubjectPrincipal) const { @@ -314,6 +312,18 @@ void CSSStyleRule::GetSelectorWarnings( } } +already_AddRefed CSSStyleRule::QuerySelectorAll(nsINode& aRoot) { + AutoTArray rules; + CollectStyleRules(*this, /* aDesugared = */ true, rules); + StyleSelectorList* list = Servo_StyleRule_GetSelectorList(&rules); + + RefPtr contentList = new nsSimpleContentList(&aRoot); + Servo_SelectorList_QueryAll(&aRoot, list, contentList.get(), + /* useInvalidation */ false); + Servo_SelectorList_Drop(list); + return contentList.forget(); +} + /* virtual */ JSObject* CSSStyleRule::WrapObject(JSContext* aCx, JS::Handle aGivenProto) { diff --git a/layout/style/CSSStyleRule.h b/layout/style/CSSStyleRule.h index 05eaae5c10..9d8a1478e6 100644 --- a/layout/style/CSSStyleRule.h +++ b/layout/style/CSSStyleRule.h @@ -36,7 +36,6 @@ class CSSStyleRuleDeclaration final : public nsDOMCSSDeclaration { Operation aOperation, mozilla::DeclarationBlock** aCreated) final; nsresult SetCSSDeclaration(DeclarationBlock* aDecl, MutationClosureData* aClosureData) final; - Document* DocToUpdate() final; ParsingEnvironment GetParsingEnvironment( nsIPrincipal* aSubjectPrincipal) const final; @@ -76,6 +75,7 @@ class CSSStyleRule final : public css::GroupRule, public SupportsWeakPtr { bool aRelevantLinkVisited); NotNull GetDeclarationBlock() const; void GetSelectorWarnings(nsTArray& aResult) const; + already_AddRefed QuerySelectorAll(nsINode& aRoot); // WebIDL interface StyleCssRuleType Type() const final; diff --git a/layout/style/FontFaceSetWorkerImpl.cpp b/layout/style/FontFaceSetWorkerImpl.cpp index 7fbfbf0d95..cd11e1f584 100644 --- a/layout/style/FontFaceSetWorkerImpl.cpp +++ b/layout/style/FontFaceSetWorkerImpl.cpp @@ -177,11 +177,11 @@ void FontFaceSetWorkerImpl::DispatchToOwningThread( return; } - class FontFaceSetWorkerRunnable final : public WorkerRunnable { + class FontFaceSetWorkerRunnable final : public WorkerThreadRunnable { public: FontFaceSetWorkerRunnable(WorkerPrivate* aWorkerPrivate, std::function&& aFunc) - : WorkerRunnable(aWorkerPrivate, "FontFaceSetWorkerRunnable"), + : WorkerThreadRunnable("FontFaceSetWorkerRunnable"), mFunc(std::move(aFunc)) {} bool WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override { @@ -195,7 +195,7 @@ void FontFaceSetWorkerImpl::DispatchToOwningThread( RefPtr runnable = new FontFaceSetWorkerRunnable(workerPrivate, std::move(aFunc)); - runnable->Dispatch(); + runnable->Dispatch(workerPrivate); } uint64_t FontFaceSetWorkerImpl::GetInnerWindowID() { diff --git a/layout/style/GeckoBindings.cpp b/layout/style/GeckoBindings.cpp index dc43e9cf6a..17ba5c952e 100644 --- a/layout/style/GeckoBindings.cpp +++ b/layout/style/GeckoBindings.cpp @@ -988,34 +988,6 @@ const AnonymousCounterStyle* Gecko_CounterStyle_GetAnonymous( return aPtr->AsAnonymous(); } -void Gecko_EnsureTArrayCapacity(void* aArray, size_t aCapacity, - size_t aElemSize) { - auto base = - reinterpret_cast*>(aArray); - - base->EnsureCapacity(aCapacity, aElemSize); -} - -void Gecko_ClearPODTArray(void* aArray, size_t aElementSize, - size_t aElementAlign) { - auto base = - reinterpret_cast*>(aArray); - - base->template ShiftData( - 0, base->Length(), 0, aElementSize, aElementAlign); -} - -void Gecko_ResizeTArrayForStrings(nsTArray* aArray, - uint32_t aLength) { - aArray->SetLength(aLength); -} - -void Gecko_ResizeAtomArray(nsTArray>* aArray, uint32_t aLength) { - aArray->SetLength(aLength); -} - void Gecko_EnsureImageLayersLength(nsStyleImageLayers* aLayers, size_t aLen, nsStyleImageLayers::LayerType aLayerType) { size_t oldLength = aLayers->mLayers.Length(); @@ -1135,16 +1107,6 @@ Keyframe* Gecko_GetOrCreateFinalKeyframe( KeyframeInsertPosition::LastForOffset); } -PropertyValuePair* Gecko_AppendPropertyValuePair( - nsTArray* aProperties, - const mozilla::AnimatedPropertyID* aProperty) { - MOZ_ASSERT(aProperties); - MOZ_ASSERT( - aProperty->IsCustom() || - !nsCSSProps::PropHasFlags(aProperty->mID, CSSPropFlags::IsLogical)); - return aProperties->AppendElement(PropertyValuePair{*aProperty}); -} - void Gecko_GetComputedURLSpec(const StyleComputedUrl* aURL, nsCString* aOut) { MOZ_ASSERT(aURL); MOZ_ASSERT(aOut); diff --git a/layout/style/GeckoBindings.h b/layout/style/GeckoBindings.h index 7bb839ae18..8ba7fcc5c6 100644 --- a/layout/style/GeckoBindings.h +++ b/layout/style/GeckoBindings.h @@ -375,20 +375,6 @@ const mozilla::ServoElementSnapshot* Gecko_GetElementSnapshot( // Have we seen this pointer before? bool Gecko_HaveSeenPtr(mozilla::SeenPtrs* table, const void* ptr); -// `array` must be an nsTArray -// If changing this signature, please update the -// friend function declaration in nsTArray.h -void Gecko_EnsureTArrayCapacity(void* array, size_t capacity, size_t elem_size); - -// Same here, `array` must be an nsTArray, for some T. -// -// Important note: Only valid for POD types, since destructors won't be run -// otherwise. This is ensured with rust traits for the relevant structs. -void Gecko_ClearPODTArray(void* array, size_t elem_size, size_t elem_align); - -void Gecko_ResizeTArrayForStrings(nsTArray* array, uint32_t length); -void Gecko_ResizeAtomArray(nsTArray>* array, uint32_t length); - void Gecko_EnsureImageLayersLength(nsStyleImageLayers* layers, size_t len, nsStyleImageLayers::LayerType layer_type); @@ -438,13 +424,6 @@ mozilla::Keyframe* Gecko_GetOrCreateFinalKeyframe( const mozilla::StyleComputedTimingFunction* timingFunction, const mozilla::dom::CompositeOperationOrAuto composition); -// Appends and returns a new PropertyValuePair to |aProperties| initialized with -// its mProperty member set to |aProperty| and all other members initialized to -// their default values. -mozilla::PropertyValuePair* Gecko_AppendPropertyValuePair( - nsTArray*, - const mozilla::AnimatedPropertyID* aProperty); - void Gecko_ResetFilters(nsStyleEffects* effects, size_t new_len); void Gecko_CopyFiltersFrom(nsStyleEffects* aSrc, nsStyleEffects* aDest); diff --git a/layout/style/Loader.cpp b/layout/style/Loader.cpp index 1ea37b094f..3133dd8631 100644 --- a/layout/style/Loader.cpp +++ b/layout/style/Loader.cpp @@ -18,12 +18,11 @@ #include "mozilla/AutoRestore.h" #include "mozilla/LoadInfo.h" #include "mozilla/Logging.h" +#include "mozilla/glean/GleanMetrics.h" #include "mozilla/MemoryReporting.h" #include "mozilla/PreloadHashKey.h" #include "mozilla/ResultExtensions.h" -#include "mozilla/SchedulerGroup.h" #include "mozilla/URLPreloader.h" -#include "nsIChildChannel.h" #include "nsIPrincipal.h" #include "nsISupportsPriority.h" #include "nsITimedChannel.h" @@ -47,8 +46,6 @@ #include "nsMimeTypes.h" #include "nsICSSLoaderObserver.h" #include "nsThreadUtils.h" -#include "nsGkAtoms.h" -#include "nsIThreadInternal.h" #include "nsINetworkPredictor.h" #include "nsQueryActor.h" #include "nsStringStream.h" @@ -62,13 +59,10 @@ #include "mozilla/StyleSheet.h" #include "mozilla/StyleSheetInlines.h" #include "mozilla/ConsoleReportCollector.h" -#include "mozilla/ServoUtils.h" #include "mozilla/css/StreamLoader.h" #include "mozilla/SharedStyleSheetCache.h" #include "mozilla/StaticPrefs_layout.h" #include "mozilla/StaticPrefs_network.h" -#include "mozilla/StaticPrefs_dom.h" -#include "mozilla/StaticPrefs_network.h" #include "mozilla/Try.h" #include "ReferrerInfo.h" @@ -417,6 +411,23 @@ SheetLoadData::~SheetLoadData() { "dropping the load"); } +void SheetLoadData::StartLoading() { + MOZ_ASSERT(!mIsLoading, "Already loading? How?"); + mIsLoading = true; + mLoadStart = TimeStamp::Now(); +} + +void SheetLoadData::SetLoadCompleted() { + MOZ_ASSERT(mIsLoading, "Not loading?"); + MOZ_ASSERT(!mLoadStart.IsNull()); + mIsLoading = false; + // Belts and suspenders just in case. + if (MOZ_LIKELY(!mLoadStart.IsNull())) { + glean::performance_pageload::async_sheet_load.AccumulateRawDuration( + TimeStamp::Now() - mLoadStart); + } +} + RefPtr SheetLoadData::ValueForCache() const { // We need to clone the sheet on insertion to the cache because otherwise the // stylesheets can keep full windows alive via either their JS wrapper, or via diff --git a/layout/style/PreferenceSheet.cpp b/layout/style/PreferenceSheet.cpp index eb752b2789..8b0179a029 100644 --- a/layout/style/PreferenceSheet.cpp +++ b/layout/style/PreferenceSheet.cpp @@ -11,7 +11,6 @@ #include "mozilla/Encoding.h" #include "mozilla/Preferences.h" #include "mozilla/StaticPrefs_browser.h" -#include "mozilla/StaticPrefs_devtools.h" #include "mozilla/StaticPrefs_layout.h" #include "mozilla/StaticPrefs_widget.h" #include "mozilla/StaticPrefs_ui.h" diff --git a/layout/style/Rule.cpp b/layout/style/Rule.cpp index 4b0f783bd9..deaa46576c 100644 --- a/layout/style/Rule.cpp +++ b/layout/style/Rule.cpp @@ -95,9 +95,10 @@ Rule* Rule::GetParentRule() const { return mParentRule; } #ifdef DEBUG void Rule::AssertParentRuleType() { - // Would be nice to check that this->Type() is KEYFRAME_RULE when - // mParentRule->Tye() is KEYFRAMES_RULE, but we can't call + // Would be nice to check that this->Type() is StyleCssRuleType::Keyframe + // when mParentRule->Tye() is StyleCssRuleType::Keyframes, but we can't call // this->Type() here since it's virtual. + // Same for StyleCssRuleType::Margin and StyleCssRuleType::Page. if (mParentRule) { auto type = mParentRule->Type(); MOZ_ASSERT(type == StyleCssRuleType::Media || @@ -108,7 +109,8 @@ void Rule::AssertParentRuleType() { type == StyleCssRuleType::LayerBlock || type == StyleCssRuleType::Container || type == StyleCssRuleType::Scope || - type == StyleCssRuleType::StartingStyle); + type == StyleCssRuleType::StartingStyle || + type == StyleCssRuleType::Page); } } #endif diff --git a/layout/style/ServoBindingTypes.h b/layout/style/ServoBindingTypes.h index b081a4981b..e2443ef526 100644 --- a/layout/style/ServoBindingTypes.h +++ b/layout/style/ServoBindingTypes.h @@ -123,6 +123,7 @@ UNLOCKED_RULE_TYPE(Property) UNLOCKED_RULE_TYPE(LayerBlock) UNLOCKED_RULE_TYPE(LayerStatement) UNLOCKED_RULE_TYPE(Namespace) +UNLOCKED_RULE_TYPE(Margin) UNLOCKED_RULE_TYPE(Container) UNLOCKED_RULE_TYPE(Media) UNLOCKED_RULE_TYPE(Supports) diff --git a/layout/style/ServoBindings.h b/layout/style/ServoBindings.h index 52538cafb8..2c0abbe0db 100644 --- a/layout/style/ServoBindings.h +++ b/layout/style/ServoBindings.h @@ -77,6 +77,7 @@ BASIC_RULE_FUNCS_LOCKED(Keyframes) GROUP_RULE_FUNCS_UNLOCKED(Media) GROUP_RULE_FUNCS_UNLOCKED(Document) BASIC_RULE_FUNCS_UNLOCKED(Namespace) +BASIC_RULE_FUNCS_UNLOCKED(Margin) GROUP_RULE_FUNCS_LOCKED(Page) BASIC_RULE_FUNCS_UNLOCKED(Property) GROUP_RULE_FUNCS_UNLOCKED(Supports) diff --git a/layout/style/ServoBindings.toml b/layout/style/ServoBindings.toml index 67fd902e2b..833fbd0272 100644 --- a/layout/style/ServoBindings.toml +++ b/layout/style/ServoBindings.toml @@ -54,6 +54,7 @@ hide-types = [ "mozilla::StyleTimingFunction.*", # https://github.com/rust-lang/rust-bindgen/issues/1559 "mozilla::StyleGeneric.*", + "nsTArray_.*", ".*ErrorResult.*", ] bitfield-enums = [ @@ -290,7 +291,6 @@ allowlist-types = [ "nsStyleUI", "nsStyleVisibility", "nsStyleXUL", - "nsTArrayHeader", "mozilla::UniquePtr", "mozilla::DeclarationBlock", "mozilla::DefaultDelete", @@ -403,6 +403,7 @@ cbindgen-types = [ { gecko = "StyleOffsetRotate", servo = "crate::values::computed::motion::OffsetRotate" }, { gecko = "StylePathCommand", servo = "crate::values::specified::svg_path::PathCommand" }, { gecko = "StyleRayFunction", servo = "crate::values::computed::motion::RayFunction" }, + { gecko = "StyleParserState", servo = "cssparser::ParserState" }, { gecko = "StyleUnicodeRange", servo = "cssparser::UnicodeRange" }, { gecko = "StyleOverflowWrap", servo = "crate::values::computed::OverflowWrap" }, { gecko = "StyleWordBreak", servo = "crate::values::computed::WordBreak" }, @@ -631,6 +632,8 @@ mapped-generic-types = [ { generic = false, gecko = "nsAString", servo = "nsstring::nsAString" }, { generic = false, gecko = "nsCString", servo = "nsstring::nsCString" }, { generic = false, gecko = "nsString", servo = "nsstring::nsString" }, + { generic = true, gecko = "nsTArray", servo = "thin_vec::ThinVec" }, + { generic = true, gecko = "CopyableTArray", servo = "thin_vec::ThinVec" }, ] allowlist-functions = ["Servo_.*", "Gecko_.*"] diff --git a/layout/style/ServoCSSRuleList.cpp b/layout/style/ServoCSSRuleList.cpp index 133a962256..b7172879de 100644 --- a/layout/style/ServoCSSRuleList.cpp +++ b/layout/style/ServoCSSRuleList.cpp @@ -17,6 +17,7 @@ #include "mozilla/dom/CSSLayerStatementRule.h" #include "mozilla/dom/CSSKeyframesRule.h" #include "mozilla/dom/CSSContainerRule.h" +#include "mozilla/dom/CSSMarginRule.h" #include "mozilla/dom/CSSMediaRule.h" #include "mozilla/dom/CSSMozDocumentRule.h" #include "mozilla/dom/CSSNamespaceRule.h" @@ -88,6 +89,7 @@ css::Rule* ServoCSSRuleList::GetRule(uint32_t aIndex) { CASE_RULE_LOCKED(Keyframes, Keyframes) CASE_RULE_UNLOCKED(Media, Media) CASE_RULE_UNLOCKED(Namespace, Namespace) + CASE_RULE_UNLOCKED(Margin, Margin) CASE_RULE_LOCKED(Page, Page) CASE_RULE_UNLOCKED(Property, Property) CASE_RULE_UNLOCKED(Supports, Supports) @@ -108,9 +110,6 @@ css::Rule* ServoCSSRuleList::GetRule(uint32_t aIndex) { case StyleCssRuleType::Keyframe: MOZ_ASSERT_UNREACHABLE("keyframe rule cannot be here"); return nullptr; - case StyleCssRuleType::Margin: - // Margin rules not implemented yet, see bug 1864737 - return nullptr; } rule = CastToUint(ruleObj.forget().take()); mRules[aIndex] = rule; @@ -277,6 +276,7 @@ void ServoCSSRuleList::SetRawContents(RefPtr aNewRules, RULE_CASE_LOCKED(Keyframes, Keyframes) RULE_CASE_UNLOCKED(Media, Media) RULE_CASE_UNLOCKED(Namespace, Namespace) + RULE_CASE_UNLOCKED(Margin, Margin) RULE_CASE_LOCKED(Page, Page) RULE_CASE_UNLOCKED(Property, Property) RULE_CASE_UNLOCKED(Supports, Supports) @@ -294,9 +294,6 @@ void ServoCSSRuleList::SetRawContents(RefPtr aNewRules, case StyleCssRuleType::Keyframe: MOZ_ASSERT_UNREACHABLE("keyframe rule cannot be here"); break; - case StyleCssRuleType::Margin: - // Margin rules not implemented yet, see bug 1864737 - break; } #undef RULE_CASE_WITH_PREFIX #undef RULE_CASE_LOCKED diff --git a/layout/style/ServoLockedArcTypeList.h b/layout/style/ServoLockedArcTypeList.h index 2d356aabf9..70adc7bd8e 100644 --- a/layout/style/ServoLockedArcTypeList.h +++ b/layout/style/ServoLockedArcTypeList.h @@ -19,6 +19,7 @@ SERVO_LOCKED_ARC_TYPE(StyleRule) SERVO_LOCKED_ARC_TYPE(ImportRule) SERVO_LOCKED_ARC_TYPE(Keyframe) SERVO_LOCKED_ARC_TYPE(KeyframesRule) +SERVO_LOCKED_ARC_TYPE(MarginList) SERVO_LOCKED_ARC_TYPE(MediaList) SERVO_LOCKED_ARC_TYPE(PageRule) SERVO_LOCKED_ARC_TYPE(FontFaceRule) diff --git a/layout/style/ServoStyleConstsForwards.h b/layout/style/ServoStyleConstsForwards.h index 5bf87d8330..cd2958618f 100644 --- a/layout/style/ServoStyleConstsForwards.h +++ b/layout/style/ServoStyleConstsForwards.h @@ -89,6 +89,7 @@ class SharedFontList; class StyleSheet; class WritingMode; class ServoElementSnapshotTable; +class StyleParserState; template struct StyleForgottenArcSlicePtr; diff --git a/layout/style/ServoStyleConstsInlines.h b/layout/style/ServoStyleConstsInlines.h index 5a86e4ccd0..50893f5112 100644 --- a/layout/style/ServoStyleConstsInlines.h +++ b/layout/style/ServoStyleConstsInlines.h @@ -45,6 +45,7 @@ template struct StyleStrong; template struct StyleStrong; template struct StyleStrong; template struct StyleStrong; +template struct StyleStrong; template struct StyleStrong; template struct StyleStrong; template struct StyleStrong; diff --git a/layout/style/ServoStyleSet.cpp b/layout/style/ServoStyleSet.cpp index 91231af2b0..22359fa82d 100644 --- a/layout/style/ServoStyleSet.cpp +++ b/layout/style/ServoStyleSet.cpp @@ -34,6 +34,7 @@ #include "mozilla/dom/CSSContainerRule.h" #include "mozilla/dom/CSSLayerBlockRule.h" #include "mozilla/dom/CSSLayerStatementRule.h" +#include "mozilla/dom/CSSMarginRule.h" #include "mozilla/dom/CSSMediaRule.h" #include "mozilla/dom/CSSMozDocumentRule.h" #include "mozilla/dom/CSSKeyframesRule.h" @@ -766,7 +767,7 @@ bool ServoStyleSet::GeneratedContentPseudoExists( if (!aPseudoStyle.StyleContent()->mContent.IsItems()) { return false; } - MOZ_ASSERT(aPseudoStyle.StyleContent()->ContentCount() > 0, + MOZ_ASSERT(!aPseudoStyle.StyleContent()->NonAltContentItems().IsEmpty(), "IsItems() implies we have at least one item"); // display:none is equivalent to not having a pseudo at all. if (aPseudoStyle.StyleDisplay()->mDisplay == StyleDisplay::None) { @@ -994,6 +995,7 @@ void ServoStyleSet::RuleChangedInternal(StyleSheet& aSheet, css::Rule& aRule, CASE_FOR(Import, Import) CASE_FOR(Media, Media) CASE_FOR(Keyframes, Keyframes) + CASE_FOR(Margin, Margin) CASE_FOR(FontFeatureValues, FontFeatureValues) CASE_FOR(FontPaletteValues, FontPaletteValues) CASE_FOR(FontFace, FontFace) @@ -1014,9 +1016,6 @@ void ServoStyleSet::RuleChangedInternal(StyleSheet& aSheet, css::Rule& aRule, // FIXME: We should probably just forward to the parent @keyframes rule? I // think that'd do the right thing, but meanwhile... return MarkOriginsDirty(ToOriginFlags(aSheet.GetOrigin())); - case StyleCssRuleType::Margin: - // Margin rules not implemented yet, see bug 1864737 - break; } #undef CASE_FOR diff --git a/layout/style/SheetLoadData.h b/layout/style/SheetLoadData.h index 6621af35bd..2f829d746e 100644 --- a/layout/style/SheetLoadData.h +++ b/layout/style/SheetLoadData.h @@ -239,6 +239,9 @@ class SheetLoadData final // listening for the load. bool mIntentionallyDropped = false; + // The start timestamp for the load. + TimeStamp mLoadStart; + const bool mRecordErrors; bool ShouldDefer() const { return mWasAlternate || !mMediaMatched; } @@ -269,8 +272,9 @@ class SheetLoadData final bool IsLoading() const override { return mIsLoading; } bool IsCancelled() const override { return mIsCancelled; } - void StartLoading() override { mIsLoading = true; } - void SetLoadCompleted() override { mIsLoading = false; } + void StartLoading() override; + void SetLoadCompleted() override; + void Cancel() override { mIsCancelled = true; } private: diff --git a/layout/style/crashtests/crashtests.list b/layout/style/crashtests/crashtests.list index d54f053f1b..2568a6e036 100644 --- a/layout/style/crashtests/crashtests.list +++ b/layout/style/crashtests/crashtests.list @@ -166,7 +166,7 @@ load 1290994-4.html load 1314531.html load 1315889-1.html load 1315894-1.html -pref(widget.windows.window_occlusion_tracking.enabled,false) skip-if(wayland) load 1319072-1.html # Bug 1819154, wayland: bug 1856389 +load 1319072-1.html HTTP load 1320423-1.html load 1321357-1.html load 1328535-1.html @@ -174,8 +174,8 @@ load 1331272.html load 1332550.html HTTP load 1333001-1.html load 1340248.html -skip-if(wayland) load 1340344.html # wayland: bug 1856389 -skip-if(wayland) load 1342316-1.html # wayland: bug 1856389 +load 1340344.html +load 1342316-1.html load 1344210.html load 1353312.html load 1356601-1.html @@ -185,19 +185,19 @@ load 1374175-1.html load 1375812-1.html load 1377053-1.html load 1377256-1.html -skip-if(wayland) load 1378064-1.html # wayland: bug 1856389 +load 1378064-1.html load 1378814.html load 1380800.html load link-transition-before.html -skip-if(wayland) load 1381420-1.html # wayland: bug 1856389 +load 1381420-1.html load 1381682.html load 1382672.html load 1382710.html pref(dom.animations-api.compositing.enabled,true) load 1383493-1.html -skip-if(wayland) load 1383001.html # wayland: bug 1856389 +load 1383001.html load 1383001-2.html load 1383319.html -skip-if(wayland) load 1383589-1.html # wayland: bug 1856389 +load 1383589-1.html load 1383975.html load border-image-visited-link.html load content-only-on-link-before.html @@ -206,7 +206,7 @@ load font-face-truncated-src.html load large_border_image_width.html load link-transition-before.html load long-url-list-stack-overflow.html #Bug 1525117 -skip-if(wayland) load scale-on-block-continuation.html # wayland: bug 1856389 +load scale-on-block-continuation.html skip-if(AddressSanitizer) skip-if(ThreadSanitizer) load 1383981.html # Very sensitive to stack size. skip-if(AddressSanitizer) skip-if(ThreadSanitizer) load 1383981-2.html skip-if(AddressSanitizer) skip-if(ThreadSanitizer) load 1383981-3.html @@ -239,7 +239,7 @@ load 1400936-1.html load 1400936-2.html load 1401256.html load 1401706.html -skip-if(wayland) load 1401801.html # wayland: bug 1856389 +load 1401801.html load 1401825.html load 1402218-1.html load 1402366.html @@ -270,8 +270,8 @@ load 1413288.html load 1413361.html load 1413670.html load 1415353.html -skip-if(wayland) load 1418059.html # wayland: bug 1856389 -skip-if(wayland) load 1418867.html # wayland: bug 1856389 +load 1418059.html +load 1418867.html load 1419554.html load 1426312.html load 1439793.html diff --git a/layout/style/moz.build b/layout/style/moz.build index b77fa34983..ce9ee36cea 100644 --- a/layout/style/moz.build +++ b/layout/style/moz.build @@ -138,6 +138,7 @@ EXPORTS.mozilla.dom += [ "CSSKeyframesRule.h", "CSSLayerBlockRule.h", "CSSLayerStatementRule.h", + "CSSMarginRule.h", "CSSMediaRule.h", "CSSMozDocumentRule.h", "CSSNamespaceRule.h", @@ -191,6 +192,7 @@ UNIFIED_SOURCES += [ "CSSKeyframesRule.cpp", "CSSLayerBlockRule.cpp", "CSSLayerStatementRule.cpp", + "CSSMarginRule.cpp", "CSSMediaRule.cpp", "CSSMozDocumentRule.cpp", "CSSNamespaceRule.cpp", diff --git a/layout/style/nsCSSValue.h b/layout/style/nsCSSValue.h index bc8914bbc1..540ac91a49 100644 --- a/layout/style/nsCSSValue.h +++ b/layout/style/nsCSSValue.h @@ -55,14 +55,16 @@ enum nsCSSUnit : uint32_t { // different behavior than percent) // Font relative measure - eCSSUnit_EM = 800, // == current font size - eCSSUnit_XHeight = 801, // distance from top of lower case x to - // baseline - eCSSUnit_Char = 802, // number of characters, used for width with - // monospace font - eCSSUnit_RootEM = 803, // == root element font size - eCSSUnit_Ideographic = 804, // == CJK water ideograph width - eCSSUnit_CapHeight = 805, // == Capital letter height + eCSSUnit_EM = 800, // == current font size + eCSSUnit_XHeight = 801, // distance from top of lower case x to + // baseline + eCSSUnit_Char = 802, // number of characters, used for width with + // monospace font + eCSSUnit_RootEM = 803, // == root element font size + eCSSUnit_Ideographic = 804, // == CJK water ideograph width + eCSSUnit_CapHeight = 805, // == Capital letter height + eCSSUnit_LineHeight = 806, // == Line height + eCSSUnit_RootLineHeight = 807, // == Root line height // Screen relative measure eCSSUnit_Point = 900, // 4/3 of a CSS pixel diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 5b71ec54bf..876f32cd7a 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -1888,7 +1888,8 @@ already_AddRefed nsComputedDOMStyle::DoGetMinHeight() { RefPtr val = new nsROCSSPrimitiveValue; StyleSize minHeight = StylePosition()->mMinHeight; - if (minHeight.IsAuto() && !ShouldHonorMinSizeAutoInAxis(eAxisVertical)) { + if (minHeight.IsAuto() && + !ShouldHonorMinSizeAutoInAxis(PhysicalAxis::Vertical)) { minHeight = StyleSize::LengthPercentage(LengthPercentage::Zero()); } @@ -1901,7 +1902,8 @@ already_AddRefed nsComputedDOMStyle::DoGetMinWidth() { StyleSize minWidth = StylePosition()->mMinWidth; - if (minWidth.IsAuto() && !ShouldHonorMinSizeAutoInAxis(eAxisHorizontal)) { + if (minWidth.IsAuto() && + !ShouldHonorMinSizeAutoInAxis(PhysicalAxis::Horizontal)) { minWidth = StyleSize::LengthPercentage(LengthPercentage::Zero()); } diff --git a/layout/style/nsComputedDOMStyle.h b/layout/style/nsComputedDOMStyle.h index d1f3458030..14dc400418 100644 --- a/layout/style/nsComputedDOMStyle.h +++ b/layout/style/nsComputedDOMStyle.h @@ -133,7 +133,7 @@ class nsComputedDOMStyle final : public nsDOMCSSDeclaration, Operation aOperation, mozilla::DeclarationBlock** aCreated) final; virtual nsresult SetCSSDeclaration(mozilla::DeclarationBlock*, mozilla::MutationClosureData*) override; - virtual mozilla::dom::Document* DocToUpdate() override; + virtual mozilla::dom::Document* DocToUpdate() final; nsDOMCSSDeclaration::ParsingEnvironment GetParsingEnvironment( nsIPrincipal* aSubjectPrincipal) const final; diff --git a/layout/style/nsDOMCSSAttrDeclaration.h b/layout/style/nsDOMCSSAttrDeclaration.h index ebae280bf0..b2e9154a2d 100644 --- a/layout/style/nsDOMCSSAttrDeclaration.h +++ b/layout/style/nsDOMCSSAttrDeclaration.h @@ -83,7 +83,7 @@ class nsDOMCSSAttributeDeclaration final : public nsDOMCSSDeclaration { nsresult SetCSSDeclaration( mozilla::DeclarationBlock* aDecl, mozilla::MutationClosureData* aClosureData) override; - mozilla::dom::Document* DocToUpdate() override; + mozilla::dom::Document* DocToUpdate() final; RefPtr mElement; diff --git a/layout/style/nsDOMCSSDeclaration.h b/layout/style/nsDOMCSSDeclaration.h index 28810c280a..66134982a0 100644 --- a/layout/style/nsDOMCSSDeclaration.h +++ b/layout/style/nsDOMCSSDeclaration.h @@ -138,7 +138,7 @@ class nsDOMCSSDeclaration : public nsICSSDeclaration { // Document that we must call BeginUpdate/EndUpdate on around the // calls to SetCSSDeclaration and the style rule mutation that leads // to it. - virtual mozilla::dom::Document* DocToUpdate() = 0; + virtual mozilla::dom::Document* DocToUpdate() { return nullptr; } // mUrlExtraData returns URL data for parsing url values in // CSS. Returns nullptr on failure. If mUrlExtraData is nullptr, diff --git a/layout/style/nsMediaFeatures.cpp b/layout/style/nsMediaFeatures.cpp index fbdde4102d..cc86d1abf6 100644 --- a/layout/style/nsMediaFeatures.cpp +++ b/layout/style/nsMediaFeatures.cpp @@ -349,7 +349,6 @@ StyleDynamicRange Gecko_MediaFeatures_VideoDynamicRange( // with the device context claims to be HDR capable. if (nsDeviceContext* dx = GetDeviceContextFor(aDocument)) { if (dx->GetScreenIsHDR()) { - // bjw return StyleDynamicRange::High; } } diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index e46566d471..94d120e378 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -2237,6 +2237,7 @@ static bool AppearanceValueAffectsFrames(StyleAppearance aAppearance, // We need to reframe since this affects the spinbox creation in // nsNumber/SearchControlFrame::CreateAnonymousContent. return aDefaultAppearance == StyleAppearance::NumberInput || + aDefaultAppearance == StyleAppearance::PasswordInput || aDefaultAppearance == StyleAppearance::Searchfield; case StyleAppearance::Menulist: // This affects the menulist button creation. @@ -2697,12 +2698,11 @@ void nsStyleContent::TriggerImageLoads(Document& aDoc, } Span oldItems; - if (aOld && aOld->mContent.IsItems()) { - oldItems = aOld->mContent.AsItems().AsSpan(); + if (aOld) { + oldItems = aOld->NonAltContentItems(); } - auto items = mContent.AsItems().AsSpan(); - + auto items = NonAltContentItems(); for (size_t i = 0; i < items.Length(); ++i) { const auto& item = items[i]; if (!item.IsImage()) { diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index 8835934eaf..efca723852 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -1356,17 +1356,11 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay { return mDefaultAppearance; case mozilla::StyleAppearance::Textfield: // `appearance: textfield` should behave like `auto` on all elements - // except elements, which we identify using the - // internal -moz-default-appearance property. (In the browser chrome - // we have some other elements that set `-moz-default-appearance: - // searchfield`, but not in content documents.) - if (mDefaultAppearance == mozilla::StyleAppearance::Searchfield) { - return mAppearance; - } - // We also need to support `appearance: textfield` on , since that is the only way in Gecko to disable the - // spinners. - if (mDefaultAppearance == mozilla::StyleAppearance::NumberInput) { + // except elements, which we + // identify using the internal -moz-default-appearance property. + if (mDefaultAppearance == mozilla::StyleAppearance::Searchfield || + mDefaultAppearance == mozilla::StyleAppearance::NumberInput || + mDefaultAppearance == mozilla::StyleAppearance::PasswordInput) { return mAppearance; } return mDefaultAppearance; @@ -1533,8 +1527,10 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay { } } + // These two methods are deprecated since they do not differentiate paginated + // context and multi-column context. Use nsIFrame::ShouldBreakBefore() / + // nsIFrame::ShouldBreakAfter() instead. bool BreakBefore() const { return ShouldBreak(mBreakBefore); } - bool BreakAfter() const { return ShouldBreak(mBreakAfter); } // These are defined in nsStyleStructInlines.h. @@ -1607,12 +1603,22 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleContent { using CounterPair = mozilla::StyleGenericCounterPair; - size_t ContentCount() const { - return mContent.IsItems() ? mContent.AsItems().Length() : 0; + /// Returns the content items that aren't alternative content. + mozilla::Span NonAltContentItems() const { + if (!mContent.IsItems()) { + return {}; + } + const auto& items = mContent.AsItems(); + return mozilla::Span(items.items).To(items.alt_start); } - const mozilla::StyleContentItem& ContentAt(size_t aIndex) const { - return mContent.AsItems().AsSpan()[aIndex]; + /// Returns the content items that /are/ alternative content. + mozilla::Span AltContentItems() const { + if (!mContent.IsItems()) { + return {}; + } + const auto& items = mContent.AsItems(); + return mozilla::Span(items.items).From(items.alt_start); } mozilla::StyleContent mContent; @@ -2058,35 +2064,4 @@ struct UniquePtr_Simple { STATIC_ASSERT_TYPE_LAYOUTS_MATCH(mozilla::UniquePtr, UniquePtr_Simple); -/** - *
- */ -template -class nsTArray_Simple { - protected: - T* mBuffer; - - public: - ~nsTArray_Simple() { - // The existence of a user-provided, and therefore non-trivial, destructor - // here prevents bindgen from deriving the Clone trait via a simple memory - // copy. - } -}; - -/** - *
- */ -template -class CopyableTArray_Simple : public nsTArray_Simple {}; - -STATIC_ASSERT_TYPE_LAYOUTS_MATCH(nsTArray, - nsTArray_Simple); -STATIC_ASSERT_TYPE_LAYOUTS_MATCH(nsTArray, - nsTArray_Simple); -STATIC_ASSERT_TYPE_LAYOUTS_MATCH(nsTArray, - nsTArray_Simple); -STATIC_ASSERT_TYPE_LAYOUTS_MATCH(nsTArray, - nsTArray_Simple); - #endif /* nsStyleStruct_h___ */ diff --git a/layout/style/res/forms.css b/layout/style/res/forms.css index 044d460ad4..7a5c25fc6e 100644 --- a/layout/style/res/forms.css +++ b/layout/style/res/forms.css @@ -192,6 +192,10 @@ input::-moz-text-control-preview { line-height: -moz-block-height !important; } +input[type=password] { + -moz-default-appearance: password-input; +} + input[type=password]::-moz-text-control-editing-root, input[type=password]::-moz-text-control-preview { /* @@ -631,10 +635,6 @@ input[type=file] > label { text-align: match-parent; cursor: unset; - color: unset; - font-size: unset; - letter-spacing: unset; - user-select: none; unicode-bidi: plaintext; } @@ -842,7 +842,6 @@ input[type=range]::slider-thumb { } input[type=number] { - appearance: auto; -moz-default-appearance: number-input; } diff --git a/layout/style/res/html.css b/layout/style/res/html.css index 18dd1c4855..769ebece45 100644 --- a/layout/style/res/html.css +++ b/layout/style/res/html.css @@ -136,7 +136,7 @@ body { margin: 8px; } -p, dl, multicol { +p, dl { display: block; margin-block-start: 1em; margin-block-end: 1em; diff --git a/layout/style/res/quirk.css b/layout/style/res/quirk.css index 6e74839ee3..0379033515 100644 --- a/layout/style/res/quirk.css +++ b/layout/style/res/quirk.css @@ -59,7 +59,7 @@ table { * selectors will be hashed in the selector maps and things will be much more * efficient. */ -:is(body, td, th) > :is(p, dl, multicol, blockquote, h1, h2, h3, h4, h5, h6, listing, plaintext, xmp, pre, ul, menu, dir, ol):-moz-first-node { +:is(body, td, th) > :is(p, dl, blockquote, h1, h2, h3, h4, h5, h6, listing, plaintext, xmp, pre, ul, menu, dir, ol):-moz-first-node { margin-block-start: 0; } @@ -71,11 +71,11 @@ td > p:-moz-last-node, th > p:-moz-last-node { * collapse the bottom or top margins of empty elements * - see bug 97361 */ -:is(body, td, th) > :is(p, dl, multicol, blockquote, h1, h2, h3, h4, h5, h6, listing, plaintext, xmp, pre, ul, menu, dir, ol):-moz-only-whitespace:-moz-first-node { +:is(body, td, th) > :is(p, dl, blockquote, h1, h2, h3, h4, h5, h6, listing, plaintext, xmp, pre, ul, menu, dir, ol):-moz-only-whitespace:-moz-first-node { margin-block-end: 0; } -:is(td, th) > :is(p, dl, multicol, blockquote, h1, h2, h3, h4, h5, h6, listing, plaintext, xmp, pre, ul, menu, dir, ol):-moz-only-whitespace:-moz-last-node { +:is(td, th) > :is(p, dl, blockquote, h1, h2, h3, h4, h5, h6, listing, plaintext, xmp, pre, ul, menu, dir, ol):-moz-only-whitespace:-moz-last-node { margin-block-start: 0; } diff --git a/layout/style/test/property_database.js b/layout/style/test/property_database.js index c63d65926e..302bd48b42 100644 --- a/layout/style/test/property_database.js +++ b/layout/style/test/property_database.js @@ -5382,7 +5382,6 @@ var gCSSProperties = { "counter(\\()", "counters(a\\+b, '.')", "counter(\\}, upper-alpha)", - "-moz-alt-content", "counter(foo, symbols('*'))", "counter(foo, symbols(numeric '0' '1'))", "counters(foo, '.', symbols('*'))", @@ -5400,6 +5399,7 @@ var gCSSProperties = { "attr(-2)", "counter(2)", "counters(-2, '.')", + "-moz-alt-content", "-moz-alt-content 'foo'", "'foo' -moz-alt-content", "counter(one, two, three) 'foo'", -- cgit v1.2.3