Backed out changeset 80d28bc966b1 (bug 1691858) for causing failures on nsIFrame.cpp. CLOSED TREE

This commit is contained in:
Butkovits Atila
2021-02-12 00:10:31 +02:00
parent 205d9f1756
commit 7432bbf0e3
7 changed files with 71 additions and 57 deletions

View File

@@ -2691,9 +2691,12 @@ void nsCSSFrameConstructor::ConstructAnonymousContentForCanvas(
PrintedSheetFrame* nsCSSFrameConstructor::ConstructPrintedSheetFrame(
PresShell* aPresShell, nsContainerFrame* aParentFrame,
nsIFrame* aPrevSheetFrame) {
ComputedStyle* parentComputedStyle = aParentFrame->Style();
ServoStyleSet* styleSet = aPresShell->StyleSet();
RefPtr<ComputedStyle> printedSheetPseudoStyle =
aPresShell->StyleSet()->ResolveNonInheritingAnonymousBoxStyle(
PseudoStyleType::printedSheet);
styleSet->ResolveInheritingAnonymousBoxStyle(
PseudoStyleType::printedSheet, parentComputedStyle);
auto* printedSheetFrame =
NS_NewPrintedSheetFrame(aPresShell, printedSheetPseudoStyle);
@@ -2706,10 +2709,12 @@ PrintedSheetFrame* nsCSSFrameConstructor::ConstructPrintedSheetFrame(
nsContainerFrame* nsCSSFrameConstructor::ConstructPageFrame(
PresShell* aPresShell, nsContainerFrame* aParentFrame,
nsIFrame* aPrevPageFrame, nsContainerFrame*& aCanvasFrame) {
ComputedStyle* parentComputedStyle = aParentFrame->Style();
ServoStyleSet* styleSet = aPresShell->StyleSet();
RefPtr<ComputedStyle> pagePseudoStyle =
styleSet->ResolveNonInheritingAnonymousBoxStyle(PseudoStyleType::page);
styleSet->ResolveInheritingAnonymousBoxStyle(PseudoStyleType::page,
parentComputedStyle);
nsContainerFrame* pageFrame = NS_NewPageFrame(aPresShell, pagePseudoStyle);
@@ -2718,8 +2723,8 @@ nsContainerFrame* nsCSSFrameConstructor::ConstructPageFrame(
pageFrame->Init(nullptr, aParentFrame, aPrevPageFrame);
RefPtr<ComputedStyle> pageContentPseudoStyle;
pageContentPseudoStyle = styleSet->ResolveNonInheritingAnonymousBoxStyle(
PseudoStyleType::pageContent);
pageContentPseudoStyle = styleSet->ResolveInheritingAnonymousBoxStyle(
PseudoStyleType::pageContent, pagePseudoStyle);
nsContainerFrame* pageContentFrame =
NS_NewPageContentFrame(aPresShell, pageContentPseudoStyle);

View File

@@ -528,6 +528,12 @@ ServoStyleSet::ResolveInheritingAnonymousBoxStyle(PseudoStyleType aType,
already_AddRefed<ComputedStyle>
ServoStyleSet::ResolveNonInheritingAnonymousBoxStyle(PseudoStyleType aType) {
MOZ_ASSERT(PseudoStyle::IsNonInheritingAnonBox(aType));
MOZ_ASSERT(aType != PseudoStyleType::pageContent,
"If pageContent ends up non-inheriting, check "
"whether we need to do anything to move the "
"@page handling from ResolveInheritingAnonymousBoxStyle to "
"ResolveNonInheritingAnonymousBoxStyle");
nsCSSAnonBoxes::NonInheriting type =
nsCSSAnonBoxes::NonInheritingTypeForPseudoType(aType);
RefPtr<ComputedStyle>& cache = mNonInheritingComputedStyles[type];

View File

@@ -70,10 +70,7 @@ CSS_NON_INHERITING_ANON_BOX(framesetBlank, ":-moz-frameset-blank")
CSS_NON_INHERITING_ANON_BOX(tableColGroup, ":-moz-table-column-group")
CSS_NON_INHERITING_ANON_BOX(tableCol, ":-moz-table-column")
CSS_NON_INHERITING_ANON_BOX(page, ":-moz-page")
CSS_NON_INHERITING_ANON_BOX(pageBreak, ":-moz-page-break")
CSS_NON_INHERITING_ANON_BOX(pageContent, ":-moz-page-content")
CSS_NON_INHERITING_ANON_BOX(printedSheet, ":-moz-printed-sheet")
CSS_NON_INHERITING_ANON_BOX(pageBreak, ":-moz-pagebreak")
// Applies to blocks that wrap contiguous runs of "column-span: all"
// elements in multi-column subtrees, or the wrappers themselves, all the
@@ -111,7 +108,10 @@ CSS_WRAPPER_ANON_BOX(tableRowGroup, ":-moz-table-row-group")
CSS_WRAPPER_ANON_BOX(tableRow, ":-moz-table-row")
CSS_ANON_BOX(canvas, ":-moz-canvas")
CSS_ANON_BOX(page, ":-moz-page")
CSS_ANON_BOX(pageContent, ":-moz-pagecontent")
CSS_ANON_BOX(pageSequence, ":-moz-page-sequence")
CSS_ANON_BOX(printedSheet, ":-moz-printed-sheet")
CSS_ANON_BOX(scrolledContent, ":-moz-scrolled-content")
CSS_ANON_BOX(scrolledCanvas, ":-moz-scrolled-canvas")
CSS_ANON_BOX(scrolledPageSequence, ":-moz-scrolled-page-sequence")

View File

@@ -319,12 +319,12 @@
}
}
*|*::-moz-page-content {
*|*::-moz-pagecontent {
display: block;
margin: auto;
}
*|*::-moz-page-break {
*|*::-moz-pagebreak {
display: block;
}

View File

@@ -669,7 +669,7 @@ impl Stylist {
{
debug_assert!(pseudo.is_precomputed());
let rule_node = self.rule_node_for_precomputed_pseudo(guards, pseudo, vec![]);
let rule_node = self.rule_node_for_precomputed_pseudo(guards, pseudo, None);
self.precomputed_values_for_pseudo_with_rule_node::<E>(
guards,
@@ -709,40 +709,42 @@ impl Stylist {
)
}
/// Returns the rule node for a given precomputed pseudo-element.
/// Returns the rule node for given precomputed pseudo-element.
///
/// If we want to include extra declarations to this precomputed
/// pseudo-element, we can provide a vector of ApplicableDeclarationBlocks
/// to extra_declarations. This is useful for @page rules.
/// If we want to include extra declarations to this precomputed pseudo-element,
/// we can provide a vector of ApplicableDeclarationBlock to extra_declarations
/// argument. This is useful for providing extra @page rules.
pub fn rule_node_for_precomputed_pseudo(
&self,
guards: &StylesheetGuards,
pseudo: &PseudoElement,
mut extra_declarations: Vec<ApplicableDeclarationBlock>,
extra_declarations: Option<Vec<ApplicableDeclarationBlock>>,
) -> StrongRuleNode {
let mut declarations_with_extra;
let mut decl;
let declarations = match self
.cascade_data
.user_agent
.precomputed_pseudo_element_decls
.get(pseudo)
{
Some(declarations) => {
if !extra_declarations.is_empty() {
declarations_with_extra = declarations.clone();
declarations_with_extra.append(&mut extra_declarations);
&*declarations_with_extra
} else {
&**declarations
}
Some(declarations) => match extra_declarations {
Some(mut extra_decls) => {
decl = declarations.clone();
decl.append(&mut extra_decls);
Some(&decl)
},
None => &[],
None => Some(declarations),
},
None => extra_declarations.as_ref(),
};
self.rule_tree.insert_ordered_rules_with_important(
declarations.into_iter().map(|a| a.clone().for_rule_tree()),
match declarations {
Some(decls) => self.rule_tree.insert_ordered_rules_with_important(
decls.into_iter().map(|a| a.clone().for_rule_tree()),
guards,
)
),
None => self.rule_tree.root().clone(),
}
}
/// Returns the style for an anonymous box of the given type.

View File

@@ -3593,13 +3593,11 @@ pub unsafe extern "C" fn Servo_ComputedValues_GetForAnonymousBox(
let metrics = get_metrics_provider_for_product();
// If the pseudo element is PageContent, we should append @page rules to the
// precomputed pseudo.
//
// TODO(emilio): We'll need a separate code path or extra arguments for
// named pages, etc.
let mut extra_declarations = vec![];
if pseudo == PseudoElement::PageContent {
// If the pseudo element is PageContent, we should append the precomputed
// pseudo element declerations with specified page rules.
let page_decls = match pseudo {
PseudoElement::PageContent => {
let mut declarations = vec![];
let iter = data.stylist.iter_extra_data_origins_rev();
for (data, origin) in iter {
let level = match origin {
@@ -3608,17 +3606,20 @@ pub unsafe extern "C" fn Servo_ComputedValues_GetForAnonymousBox(
Origin::Author => CascadeLevel::same_tree_author_normal(),
};
for rule in data.pages.iter() {
extra_declarations.push(ApplicableDeclarationBlock::from_declarations(
declarations.push(ApplicableDeclarationBlock::from_declarations(
rule.read_with(level.guard(&guards)).block.clone(),
level,
));
}
}
}
Some(declarations)
},
_ => None,
};
let rule_node = data
.stylist
.rule_node_for_precomputed_pseudo(&guards, &pseudo, extra_declarations);
.rule_node_for_precomputed_pseudo(&guards, &pseudo, page_decls);
data.stylist
.precomputed_values_for_pseudo_with_rule_node::<GeckoElement>(

View File

@@ -2452,10 +2452,7 @@ STATIC_ATOMS = [
NonInheritingAnonBoxAtom("AnonBox_framesetBlank", ":-moz-frameset-blank"),
NonInheritingAnonBoxAtom("AnonBox_tableColGroup", ":-moz-table-column-group"),
NonInheritingAnonBoxAtom("AnonBox_tableCol", ":-moz-table-column"),
NonInheritingAnonBoxAtom("AnonBox_page", ":-moz-page"),
NonInheritingAnonBoxAtom("AnonBox_pageBreak", ":-moz-page-break"),
NonInheritingAnonBoxAtom("AnonBox_pageContent", ":-moz-page-content"),
NonInheritingAnonBoxAtom("AnonBox_printedSheet", ":-moz-printed-sheet"),
NonInheritingAnonBoxAtom("AnonBox_pageBreak", ":-moz-pagebreak"),
NonInheritingAnonBoxAtom("AnonBox_columnSpanWrapper", ":-moz-column-span-wrapper"),
InheritingAnonBoxAtom("AnonBox_mozText", ":-moz-text"),
InheritingAnonBoxAtom("AnonBox_firstLetterContinuation", ":-moz-first-letter-continuation"),
@@ -2476,7 +2473,10 @@ STATIC_ATOMS = [
InheritingAnonBoxAtom("AnonBox_tableRowGroup", ":-moz-table-row-group"),
InheritingAnonBoxAtom("AnonBox_tableRow", ":-moz-table-row"),
InheritingAnonBoxAtom("AnonBox_canvas", ":-moz-canvas"),
InheritingAnonBoxAtom("AnonBox_page", ":-moz-page"),
InheritingAnonBoxAtom("AnonBox_pageContent", ":-moz-pagecontent"),
InheritingAnonBoxAtom("AnonBox_pageSequence", ":-moz-page-sequence"),
InheritingAnonBoxAtom("AnonBox_printedSheet", ":-moz-printed-sheet"),
InheritingAnonBoxAtom("AnonBox_scrolledContent", ":-moz-scrolled-content"),
InheritingAnonBoxAtom("AnonBox_scrolledCanvas", ":-moz-scrolled-canvas"),
InheritingAnonBoxAtom("AnonBox_scrolledPageSequence", ":-moz-scrolled-page-sequence"),