forked from mirrors/gecko-dev
Bug 1869217. Don't use the @page rules that match the first page as the page defaults. r=emilio
page-rule-specificity-001-print.html is the only test that actually fails prior to this patch (it already passes in Chrome). Differential Revision: https://phabricator.services.mozilla.com/D196000
This commit is contained in:
parent
45dbc042f5
commit
473cc4095f
10 changed files with 135 additions and 25 deletions
|
|
@ -1374,18 +1374,8 @@ nsresult nsPrintJob::ReflowPrintObject(const UniquePtr<nsPrintObject>& aPO) {
|
||||||
|
|
||||||
RefPtr<PresShell> presShell = aPO->mPresShell;
|
RefPtr<PresShell> presShell = aPO->mPresShell;
|
||||||
{
|
{
|
||||||
// Get the initial page name. Even though we haven't done any page-name
|
const ServoStyleSet::PageSizeAndOrientation sizeAndOrientation =
|
||||||
// fragmentation (that happens during block reflow), this will still be
|
presShell->StyleSet()->GetDefaultPageSizeAndOrientation();
|
||||||
// valid to find the first page's name.
|
|
||||||
const nsAtom* firstPageName = nsGkAtoms::_empty;
|
|
||||||
if (const Element* const rootElement = aPO->mDocument->GetRootElement()) {
|
|
||||||
if (const nsIFrame* const rootFrame = rootElement->GetPrimaryFrame()) {
|
|
||||||
firstPageName = rootFrame->ComputePageValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const ServoStyleSet::FirstPageSizeAndOrientation sizeAndOrientation =
|
|
||||||
presShell->StyleSet()->GetFirstPageSizeAndOrientation(firstPageName);
|
|
||||||
// XXX Should we enable this for known save-to-PDF pseudo-printers once
|
// XXX Should we enable this for known save-to-PDF pseudo-printers once
|
||||||
// bug 1826301 is fixed?
|
// bug 1826301 is fixed?
|
||||||
if (mPrintSettings->GetOutputFormat() ==
|
if (mPrintSettings->GetOutputFormat() ==
|
||||||
|
|
|
||||||
|
|
@ -662,11 +662,11 @@ StyleSheet* ServoStyleSet::SheetAt(Origin aOrigin, size_t aIndex) const {
|
||||||
Servo_StyleSet_GetSheetAt(mRawData.get(), aOrigin, aIndex));
|
Servo_StyleSet_GetSheetAt(mRawData.get(), aOrigin, aIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
ServoStyleSet::FirstPageSizeAndOrientation
|
ServoStyleSet::PageSizeAndOrientation
|
||||||
ServoStyleSet::GetFirstPageSizeAndOrientation(const nsAtom* aFirstPageName) {
|
ServoStyleSet::GetDefaultPageSizeAndOrientation() {
|
||||||
FirstPageSizeAndOrientation retval;
|
PageSizeAndOrientation retval;
|
||||||
const RefPtr<ComputedStyle> style =
|
const RefPtr<ComputedStyle> style =
|
||||||
ResolvePageContentStyle(aFirstPageName, StylePagePseudoClassFlags::FIRST);
|
ResolvePageContentStyle(nullptr, StylePagePseudoClassFlags::NONE);
|
||||||
const StylePageSize& pageSize = style->StylePage()->mSize;
|
const StylePageSize& pageSize = style->StylePage()->mSize;
|
||||||
|
|
||||||
if (pageSize.IsSize()) {
|
if (pageSize.IsSize()) {
|
||||||
|
|
|
||||||
|
|
@ -260,12 +260,12 @@ class ServoStyleSet {
|
||||||
size_t SheetCount(Origin) const;
|
size_t SheetCount(Origin) const;
|
||||||
StyleSheet* SheetAt(Origin, size_t aIndex) const;
|
StyleSheet* SheetAt(Origin, size_t aIndex) const;
|
||||||
|
|
||||||
struct FirstPageSizeAndOrientation {
|
struct PageSizeAndOrientation {
|
||||||
Maybe<StylePageSizeOrientation> orientation;
|
Maybe<StylePageSizeOrientation> orientation;
|
||||||
Maybe<nsSize> size;
|
Maybe<nsSize> size;
|
||||||
};
|
};
|
||||||
// Gets the specified orientation and size used when the first page printed
|
// Gets the default page size and orientation (the size/orientation specified
|
||||||
// has the name |aFirstPageName|, based on the page-size property.
|
// by @page rules without a selector list), if any.
|
||||||
//
|
//
|
||||||
// If the specified size is just an orientation, then the size will be set to
|
// If the specified size is just an orientation, then the size will be set to
|
||||||
// nothing and the orientation will be set accordingly.
|
// nothing and the orientation will be set accordingly.
|
||||||
|
|
@ -273,8 +273,7 @@ class ServoStyleSet {
|
||||||
// to nothing.
|
// to nothing.
|
||||||
// Otherwise, the size will and orientation is determined by the specified
|
// Otherwise, the size will and orientation is determined by the specified
|
||||||
// page size.
|
// page size.
|
||||||
FirstPageSizeAndOrientation GetFirstPageSizeAndOrientation(
|
PageSizeAndOrientation GetDefaultPageSizeAndOrientation();
|
||||||
const nsAtom* aFirstPageName);
|
|
||||||
|
|
||||||
void AppendAllNonDocumentAuthorSheets(nsTArray<StyleSheet*>& aArray) const;
|
void AppendAllNonDocumentAuthorSheets(nsTArray<StyleSheet*>& aArray) const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>CSS Paged Media: @page without selector provides defaults</title>
|
||||||
|
<link rel="author" title="Jonathan Watt" href="mailto:jwatt@jwatt.org"/>
|
||||||
|
<link rel="help" href="https://drafts.csswg.org/css-page/#cascading-and-page-context"/>
|
||||||
|
<meta name="assert" content="@page with a selector should not apply to non-matched pages">
|
||||||
|
<link rel="match" href="page-rule-specificity-print-landscape-ref.html"/>
|
||||||
|
<meta name="reftest-pages" content="2">
|
||||||
|
<style>
|
||||||
|
|
||||||
|
/* WPT Print Reftest default size is 5x3in - this should only change that for the first page */
|
||||||
|
@page :first {
|
||||||
|
size: portrait;
|
||||||
|
}
|
||||||
|
div:first-of-type {
|
||||||
|
break-after: page;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
<body>
|
||||||
|
<div>Portrait</div>
|
||||||
|
<div>Landscape</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>CSS Paged Media: @page without selector provides defaults</title>
|
||||||
|
<link rel="author" title="Jonathan Watt" href="mailto:jwatt@jwatt.org"/>
|
||||||
|
<link rel="help" href="https://drafts.csswg.org/css-page/#cascading-and-page-context"/>
|
||||||
|
<meta name="assert" content="@page rule without a selector list should apply to pages not matched by rules with selectors">
|
||||||
|
<link rel="match" href="page-rule-specificity-print-landscape-ref.html"/>
|
||||||
|
<meta name="reftest-pages" content="2">
|
||||||
|
<style>
|
||||||
|
|
||||||
|
@page :first {
|
||||||
|
size: portrait;
|
||||||
|
}
|
||||||
|
@page {
|
||||||
|
size: landscape;
|
||||||
|
}
|
||||||
|
div:first-of-type {
|
||||||
|
break-after: page;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
<body>
|
||||||
|
<div>Portrait</div>
|
||||||
|
<div>Landscape</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>CSS Paged Media: @page without selector provides defaults</title>
|
||||||
|
<link rel="author" title="Jonathan Watt" href="mailto:jwatt@jwatt.org"/>
|
||||||
|
<link rel="help" href="https://drafts.csswg.org/css-page/#cascading-and-page-context"/>
|
||||||
|
<meta name="assert" content="@page rule without a selector list should apply to pages not matched by rules with selectors">
|
||||||
|
<link rel="match" href="page-rule-specificity-print-portrait-ref.html"/>
|
||||||
|
<meta name="reftest-pages" content="2">
|
||||||
|
<style>
|
||||||
|
|
||||||
|
@page :first {
|
||||||
|
size: landscape;
|
||||||
|
}
|
||||||
|
@page {
|
||||||
|
size: portrait;
|
||||||
|
}
|
||||||
|
div:first-of-type {
|
||||||
|
break-after: page;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
<body>
|
||||||
|
<div>Landscape</div>
|
||||||
|
<div>Portrait</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<link rel="author" title="Jonathan Watt" href="mailto:jwatt@jwatt.org"/>
|
||||||
|
<style>
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
<body>
|
||||||
|
<div>Landscape</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<link rel="author" title="Jonathan Watt" href="mailto:jwatt@jwatt.org"/>
|
||||||
|
<style>
|
||||||
|
|
||||||
|
@page :first {
|
||||||
|
size: portrait;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
<body>
|
||||||
|
<div>Portrait</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<style>
|
<style>
|
||||||
@page a { size: landscape; }
|
@page { size: landscape; }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div style="page: a">Test</div>
|
<div>Test</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<style>
|
<style>
|
||||||
@page a { size: portrait; }
|
@page { size: portrait; }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div style="page: a">Test</div>
|
<div>Test</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue