Bug 1833471 Part 2 - Export @page pseudo-class flags to Gecko style code r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D178869
This commit is contained in:
Emily McDonough 2023-06-21 19:02:23 +00:00
Родитель a18b6d735d
Коммит 332fa4dc43
4 изменённых файлов: 17 добавлений и 11 удалений

Просмотреть файл

@ -2910,7 +2910,8 @@ nsContainerFrame* nsCSSFrameConstructor::ConstructPageFrame(
"Page name from prev-in-flow should not have been null"); "Page name from prev-in-flow should not have been null");
} }
RefPtr<ComputedStyle> pageContentPseudoStyle = RefPtr<ComputedStyle> pageContentPseudoStyle =
styleSet->ResolvePageContentStyle(pageName); styleSet->ResolvePageContentStyle(pageName,
StylePagePseudoClassFlags::NONE);
nsContainerFrame* pageContentFrame = NS_NewPageContentFrame( nsContainerFrame* pageContentFrame = NS_NewPageContentFrame(
aPresShell, pageContentPseudoStyle, pageName.forget()); aPresShell, pageContentPseudoStyle, pageName.forget());

Просмотреть файл

@ -419,7 +419,8 @@ void nsPageContentFrame::EnsurePageName() {
return; return;
} }
RefPtr<ComputedStyle> pageContentPseudoStyle = RefPtr<ComputedStyle> pageContentPseudoStyle =
PresShell()->StyleSet()->ResolvePageContentStyle(mPageName); PresShell()->StyleSet()->ResolvePageContentStyle(
mPageName, StylePagePseudoClassFlags::FIRST);
SetComputedStyleWithoutNotification(pageContentPseudoStyle); SetComputedStyleWithoutNotification(pageContentPseudoStyle);
} }

Просмотреть файл

@ -572,7 +572,7 @@ ServoStyleSet::ResolveNonInheritingAnonymousBoxStyle(PseudoStyleType aType) {
} }
already_AddRefed<ComputedStyle> ServoStyleSet::ResolvePageContentStyle( already_AddRefed<ComputedStyle> ServoStyleSet::ResolvePageContentStyle(
const nsAtom* aPageName) { const nsAtom* aPageName, const StylePagePseudoClassFlags& aPseudo) {
// The empty atom is used to indicate no specified page name, and is not // The empty atom is used to indicate no specified page name, and is not
// usable as a page-rule selector. Changing this to null is a slight // usable as a page-rule selector. Changing this to null is a slight
// optimization to avoid the Servo code from doing an unnecessary hashtable // optimization to avoid the Servo code from doing an unnecessary hashtable
@ -580,10 +580,12 @@ already_AddRefed<ComputedStyle> ServoStyleSet::ResolvePageContentStyle(
if (aPageName == nsGkAtoms::_empty) { if (aPageName == nsGkAtoms::_empty) {
aPageName = nullptr; aPageName = nullptr;
} }
// Only use the cache if we are not doing a lookup for a named page style. // Only use the cache when we are doing a lookup for page styles without a
// page-name or any pseudo classes.
const bool useCache = !aPageName && !aPseudo;
RefPtr<ComputedStyle>& cache = RefPtr<ComputedStyle>& cache =
mNonInheritingComputedStyles[nsCSSAnonBoxes::NonInheriting::pageContent]; mNonInheritingComputedStyles[nsCSSAnonBoxes::NonInheriting::pageContent];
if (!aPageName && cache) { if (useCache && cache) {
RefPtr<ComputedStyle> retval = cache; RefPtr<ComputedStyle> retval = cache;
return retval.forget(); return retval.forget();
} }
@ -591,12 +593,11 @@ already_AddRefed<ComputedStyle> ServoStyleSet::ResolvePageContentStyle(
UpdateStylistIfNeeded(); UpdateStylistIfNeeded();
RefPtr<ComputedStyle> computedValues = RefPtr<ComputedStyle> computedValues =
Servo_ComputedValues_GetForPageContent(mRawData.get(), aPageName, Servo_ComputedValues_GetForPageContent(mRawData.get(), aPageName, aPseudo)
StylePagePseudoClassFlags::NONE)
.Consume(); .Consume();
MOZ_ASSERT(computedValues); MOZ_ASSERT(computedValues);
if (!aPageName) { if (useCache) {
cache = computedValues; cache = computedValues;
} }
return computedValues.forget(); return computedValues.forget();
@ -686,7 +687,8 @@ StyleSheet* ServoStyleSet::SheetAt(Origin aOrigin, size_t aIndex) const {
ServoStyleSet::FirstPageSizeAndOrientation ServoStyleSet::FirstPageSizeAndOrientation
ServoStyleSet::GetFirstPageSizeAndOrientation(const nsAtom* aFirstPageName) { ServoStyleSet::GetFirstPageSizeAndOrientation(const nsAtom* aFirstPageName) {
FirstPageSizeAndOrientation retval; FirstPageSizeAndOrientation retval;
const RefPtr<ComputedStyle> style = ResolvePageContentStyle(aFirstPageName); const RefPtr<ComputedStyle> style =
ResolvePageContentStyle(aFirstPageName, StylePagePseudoClassFlags::FIRST);
const StylePageSize& pageSize = style->StylePage()->mSize; const StylePageSize& pageSize = style->StylePage()->mSize;
if (pageSize.IsSize()) { if (pageSize.IsSize()) {

Просмотреть файл

@ -35,6 +35,7 @@ enum class StyleRuleChangeKind : uint32_t;
template <typename Integer, typename Number, typename LinearStops> template <typename Integer, typename Number, typename LinearStops>
struct StyleTimingFunction; struct StyleTimingFunction;
struct StylePagePseudoClassFlags;
struct StylePiecewiseLinearFunction; struct StylePiecewiseLinearFunction;
using StyleComputedTimingFunction = using StyleComputedTimingFunction =
StyleTimingFunction<int32_t, float, StylePiecewiseLinearFunction>; StyleTimingFunction<int32_t, float, StylePiecewiseLinearFunction>;
@ -254,9 +255,10 @@ class ServoStyleSet {
PseudoStyleType aType); PseudoStyleType aType);
// Get a ComputedStyle for a pageContent box with the specified page-name. // Get a ComputedStyle for a pageContent box with the specified page-name.
// A page name that is null or the empty atom gets the global page style. // A page name that is null or the empty atom and has no pseudo classes gets
// the global page style.
already_AddRefed<ComputedStyle> ResolvePageContentStyle( already_AddRefed<ComputedStyle> ResolvePageContentStyle(
const nsAtom* aPageName); const nsAtom* aPageName, const StylePagePseudoClassFlags& aPseudo);
already_AddRefed<ComputedStyle> ResolveXULTreePseudoStyle( already_AddRefed<ComputedStyle> ResolveXULTreePseudoStyle(
dom::Element* aParentElement, nsCSSAnonBoxPseudoStaticAtom* aPseudoTag, dom::Element* aParentElement, nsCSSAnonBoxPseudoStaticAtom* aPseudoTag,