From e212befa7e08201eef8182268a365c08d1bd1acc Mon Sep 17 00:00:00 2001 From: Brendan Abolivier Date: Thu, 10 Aug 2023 11:00:16 +0100 Subject: [PATCH] Bug 1843628 - Mutualise messageBody.css, and ignore CSS named pages when printing. r=mkmelin Differential Revision: https://phabricator.services.mozilla.com/D185798 --HG-- extra : amend_source : dc6edaa53bf90af5c345419e06139acb7ed78721 extra : histedit_source : 41a2746f7de09bd0647c86f1e0851fe9b0498bb3 --- .../message-reader/browser_printing.js | 33 +++ .../data/bug1843628_named_page.eml | 28 +++ mail/themes/linux/mail/messageBody.css | 193 +---------------- mail/themes/osx/mail/messageBody.css | 177 +-------------- mail/themes/shared/jar.inc.mn | 1 + mail/themes/shared/mail/messageBody.css | 201 ++++++++++++++++++ mail/themes/windows/mail/messageBody.css | 193 +---------------- 7 files changed, 266 insertions(+), 560 deletions(-) create mode 100644 mail/test/browser/message-reader/data/bug1843628_named_page.eml create mode 100644 mail/themes/shared/mail/messageBody.css diff --git a/mail/test/browser/message-reader/browser_printing.js b/mail/test/browser/message-reader/browser_printing.js index 57b422ebe9..0b80d031d2 100644 --- a/mail/test/browser/message-reader/browser_printing.js +++ b/mail/test/browser/message-reader/browser_printing.js @@ -19,10 +19,15 @@ var { create_message, mc, select_click_row, + open_message_from_file, } = ChromeUtils.import( "resource://testing-common/mozmill/FolderDisplayHelpers.jsm" ); +var { close_window } = ChromeUtils.import( + "resource://testing-common/mozmill/WindowHelpers.jsm" +); + var folder = null; const SUBJECT0 = "How is the printing?"; @@ -79,3 +84,31 @@ add_task(async function test_open_printpreview() { () => !mc.window.document.querySelector(".printPreviewBrowser") ); }); + +/** + * Test that the print preview generates correctly when the email use a CSS + * named page. + */ +add_task(async function test_named_page() { + const file = new FileUtils.File( + getTestFilePath(`data/bug1843628_named_page.eml`) + ); + const msgc = await open_message_from_file(file); + + EventUtils.synthesizeKey("P", { accelKey: true }, msgc.window); + + let preview; + // Ensure we're showing the preview... + await BrowserTestUtils.waitForCondition(() => { + preview = msgc.window.document.querySelector(".printPreviewBrowser"); + return preview && BrowserTestUtils.is_visible(preview); + }); + + Assert.equal( + preview.getAttribute("sheet-count"), + "1", + "preview should only include one page (and ignore the CSS named page)" + ); + + close_window(msgc); +}); diff --git a/mail/test/browser/message-reader/data/bug1843628_named_page.eml b/mail/test/browser/message-reader/data/bug1843628_named_page.eml new file mode 100644 index 0000000000..c1563b6343 --- /dev/null +++ b/mail/test/browser/message-reader/data/bug1843628_named_page.eml @@ -0,0 +1,28 @@ +X-Identity-Key: id1 +X-Account-Key: account2 +Date: Tue, 18 Dec 2012 13:42:01 +0100 +X-Mozilla-Draft-Info: internal/draft; vcard=0; receipt=0; DSN=0; uuencode=0 +User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20121217 Thunderbird/19.0a2 +MIME-Version: 1.0 +Subject: html test +X-Enigmail-Version: 1.5a1pre +Content-Type: text/html; charset=ISO-8859-2 +Content-Transfer-Encoding: quoted-printable + + + + + + + +
+

Hello there!

+
+ + diff --git a/mail/themes/linux/mail/messageBody.css b/mail/themes/linux/mail/messageBody.css index 1119a74f0f..a8c696fd37 100644 --- a/mail/themes/linux/mail/messageBody.css +++ b/mail/themes/linux/mail/messageBody.css @@ -2,200 +2,9 @@ * 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/. */ -/* ===== messageBody.css ================================================= - == Styles for the body of a mail message. - ======================================================================= */ -@import url(chrome://messenger/skin/messageQuotes.css); - -@namespace url("http://www.w3.org/1999/xhtml"); - -mailattachcount { - display: none; -} - -/* :::: message header ::::: */ - -@media screen { - .moz-main-header, - .moz-main-header + br, - .moz-print-only { - display: none; - } -} - -.moz-header-part1 { - background-color: #EFEFEF; -} - -.moz-header-part2, -.moz-header-part3 { - background-color: #DEDEDE; -} - -.moz-header-display-name { - display: inline; - font-weight: bold; - white-space: pre; -} - -/* ::::: message text, incl. quotes ::::: */ - -.moz-text-flowed blockquote, -.moz-text-plain blockquote { - margin: 0; -} - -.moz-text-plain pre { - margin: 0; - font-family: inherit; -} - -.moz-text-plain[wrap="true"] { - white-space: pre-wrap; -} - -.moz-text-plain[wrap="false"] { - white-space: pre; -} - -.moz-text-plain[wrap="flow"] .moz-txt-sig { - white-space: pre-wrap; -} - -.moz-text-plain[graphical-quote="false"] blockquote { - border-style: none; - padding: 0; -} - -.moz-text-plain[graphical-quote="true"] .moz-txt-citetags { - display: none; -} - -.moz-txt-underscore { - text-decoration: underline; -} +@import url("chrome://messenger/skin/shared/messageBody.css"); .moz-txt-formfeed { display: block; height: 100%; } - -/* ::::: images ::::: */ - -img[overflowing]:not([shrinktofit]) { - cursor: zoom-out; - width: auto !important; -} - -img[overflowing][shrinktofit] { - cursor: zoom-in; - max-width: 100% !important; - height: auto !important; -} - -@media print { - img[shrinktofit] { - max-width: 100% !important; - height: auto !important; - } -} - -.moz-attached-image-container { - text-align: center; -} - -/* ::::: vcard ::::: */ - -.moz-vcard-table { - margin-top: 10px; - border-radius: 3px; - box-shadow: 0 1px 3px hsla(0, 0%, 50%, 0.6); -} - -.moz-vcard-property { - font-size: 80%; - color: gray; -} - -.moz-vcard-badge { - margin-top: 2px; - height: 32px; - width: 32px; - background-image: url("chrome://messenger/skin/addressbook/icons/contact-generic.svg"); - background-size: 100% 100%; - background-color: transparent; - display: block; - opacity: .7; - cursor: pointer; -} - -.moz-vcard-badge:hover { - opacity: .8; -} - -.moz-vcard-badge:active { - opacity: 1; -} - -.moz-vcard-badge:focus { - outline: none; -} - -/* Old style feeds, pre Tb3.0 */ -#_mailrssiframe { - position: fixed; - display: block; - top: 0; - left: 0; - width: 100%; - height: 100%; - border: none; -} - -/* Attachment display styling (for inline attachments and printing) */ -.moz-mime-attachment-header { - border-style: none; - border-top: 1px solid GrayText; - padding-block-start: 0.625em; - padding-block-end: 0.2em; -} - -.moz-mime-attachment-header.moz-print-only { - margin-top: 1em; -} - -.moz-mime-attachment-header-name { - color: GrayText; - font-size: 80%; - font-family: Arial, sans-serif; -} - -.moz-mime-attachment-wrap { - padding: 0 1em; -} - -.moz-mime-attachment-table { - width: 100%; - border-collapse: collapse; - table-layout: fixed; -} - -.moz-mime-attachment-table tr + tr > td { - border-top: 1px solid GrayText; - padding-top: 0.25em; -} - -.moz-mime-attachment-file { - word-wrap: break-word; -} - -.moz-mime-attachment-size { - vertical-align: top; - width: 10ch; - text-align: right; -} - -.moz-mime-attachment-file, -.moz-mime-attachment-size { - padding: 0 0 0.25em; -} diff --git a/mail/themes/osx/mail/messageBody.css b/mail/themes/osx/mail/messageBody.css index f9f1cf59f8..3641de574b 100644 --- a/mail/themes/osx/mail/messageBody.css +++ b/mail/themes/osx/mail/messageBody.css @@ -2,66 +2,19 @@ * 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/. */ -/* ===== messageBody.css ================================================= - == Styles for the body of a mail message. - ======================================================================= */ -@import url(chrome://messenger/skin/messageQuotes.css); - -@namespace url("http://www.w3.org/1999/xhtml"); +@import url("chrome://messenger/skin/shared/messageBody.css"); mailattachcount { border: blue; } -/* :::: message header ::::: */ - -@media screen { - .moz-main-header, - .moz-main-header + br, - .moz-print-only { - display: none; - } -} - -.moz-header-part1 { - background-color: #EFEFEF; -} - -.moz-header-part2, -.moz-header-part3 { - background-color: #DEDEDE; -} - -.moz-header-display-name { - display: inline; - font-weight: bold; - white-space: pre; -} - /* ::::: message text, incl. quotes ::::: */ -.moz-text-flowed blockquote, -.moz-text-plain blockquote { - margin: 0; -} - .moz-text-plain pre { margin: inherit; font-family: inherit; } -.moz-text-plain[wrap="true"] { - white-space: pre-wrap; -} - -.moz-text-plain[wrap="false"] { - white-space: pre; -} - -.moz-text-plain[wrap="flow"] .moz-txt-sig { - white-space: pre-wrap; -} - .moz-text-plain[graphical-quote="false"] blockquote { margin: inherit; border-left: inherit; @@ -73,131 +26,3 @@ mailattachcount { border-width: 2px; border-color: gray; } - -.moz-text-plain[graphical-quote="true"] .moz-txt-citetags { - display: none; -} - -.moz-txt-underscore { - text-decoration: underline; -} - -/* ::::: images ::::: */ - -img[overflowing]:not([shrinktofit]) { - cursor: zoom-out; - width: auto !important; -} - -img[overflowing][shrinktofit] { - cursor: zoom-in; - max-width: 100% !important; - height: auto !important; -} - -@media print { - img[shrinktofit] { - max-width: 100% !important; - height: auto !important; - } -} - -.moz-attached-image-container { - text-align: center; -} - -/* ::::: vcard ::::: */ - -.moz-vcard-table { - margin-top: 10px; - border-radius: 3px; - box-shadow: 0 1px 3px hsla(0, 0%, 50%, 0.6); -} - -.moz-vcard-property { - font-size: 80%; - color: gray; -} - -.moz-vcard-badge { - margin-top: 2px; - height: 32px; - width: 32px; - background-image: url("chrome://messenger/skin/addressbook/icons/contact-generic.svg"); - background-size: 100% 100%; - background-color: transparent; - display: block; - opacity: .7; - cursor: pointer; -} - -.moz-vcard-badge:hover { - opacity: .8; -} - -.moz-vcard-badge:active { - opacity: 1; -} - -.moz-vcard-badge:focus { - outline: none; -} - -/* Old style feeds, pre Tb3.0 */ -#_mailrssiframe { - position: fixed; - display: block; - top: 0; - left: 0; - width: 100%; - height: 100%; - border: none; -} - -/* Attachment display styling (for inline attachments and printing) */ -.moz-mime-attachment-header { - border-style: none; - border-top: 1px solid GrayText; - padding-block-start: 0.625em; - padding-block-end: 0.2em; -} - -.moz-mime-attachment-header.moz-print-only { - margin-top: 1em; -} - -.moz-mime-attachment-header-name { - color: GrayText; - font-size: 80%; - font-family: Arial, sans-serif; -} - -.moz-mime-attachment-wrap { - padding: 0 1em; -} - -.moz-mime-attachment-table { - width: 100%; - border-collapse: collapse; - table-layout: fixed; -} - -.moz-mime-attachment-table tr + tr > td { - border-top: 1px solid GrayText; - padding-top: 0.25em; -} - -.moz-mime-attachment-file { - word-wrap: break-word; -} - -.moz-mime-attachment-size { - vertical-align: top; - width: 10ch; - text-align: right; -} - -.moz-mime-attachment-file, -.moz-mime-attachment-size { - padding: 0 0 0.25em; -} diff --git a/mail/themes/shared/jar.inc.mn b/mail/themes/shared/jar.inc.mn index d2738a60e6..4f4657b668 100644 --- a/mail/themes/shared/jar.inc.mn +++ b/mail/themes/shared/jar.inc.mn @@ -385,6 +385,7 @@ skin/classic/messenger/shared/mailWindow1.css (../shared/mail/mailWindow1.css) skin/classic/messenger/shared/menulist.css (../shared/mail/menulist.css) skin/classic/messenger/shared/message-bar.css (../shared/mail/message-bar.css) + skin/classic/messenger/shared/messageBody.css (../shared/mail/messageBody.css) skin/classic/messenger/shared/messageHeader.css (../shared/mail/messageHeader.css) skin/classic/messenger/shared/messageIcons.css (../shared/mail/messageIcons.css) skin/classic/messenger/shared/messenger.css (../shared/mail/messenger.css) diff --git a/mail/themes/shared/mail/messageBody.css b/mail/themes/shared/mail/messageBody.css new file mode 100644 index 0000000000..f38ee53fa9 --- /dev/null +++ b/mail/themes/shared/mail/messageBody.css @@ -0,0 +1,201 @@ +/* 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/. */ + +/* ===== messageBody.css ================================================= + == Styles for the body of a mail message. + ======================================================================= */ +@import url(chrome://messenger/skin/messageQuotes.css); + +@namespace url("http://www.w3.org/1999/xhtml"); + +mailattachcount { + display: none; +} + +/* :::: message header ::::: */ + +@media screen { + .moz-main-header, + .moz-main-header + br, + .moz-print-only { + display: none; + } +} + +.moz-header-part1 { + background-color: #EFEFEF; +} + +.moz-header-part2, +.moz-header-part3 { + background-color: #DEDEDE; +} + +.moz-header-display-name { + display: inline; + font-weight: bold; + white-space: pre; +} + +/* ::::: message text, incl. quotes ::::: */ + +.moz-text-flowed blockquote, +.moz-text-plain blockquote { + margin: 0; +} + +.moz-text-plain pre { + margin: 0; + font-family: inherit; +} + +.moz-text-plain[wrap="true"] { + white-space: pre-wrap; +} + +.moz-text-plain[wrap="false"] { + white-space: pre; +} + +.moz-text-plain[wrap="flow"] .moz-txt-sig { + white-space: pre-wrap; +} + +.moz-text-plain[graphical-quote="false"] blockquote { + border-style: none; + padding: 0; +} + +.moz-text-plain[graphical-quote="true"] .moz-txt-citetags { + display: none; +} + +.moz-txt-underscore { + text-decoration: underline; +} + +/* Ignore named pages when printing. */ +@media print { + * { page: auto !important; } +} + +/* ::::: images ::::: */ + +img[overflowing]:not([shrinktofit]) { + cursor: zoom-out; + width: auto !important; +} + +img[overflowing][shrinktofit] { + cursor: zoom-in; + max-width: 100% !important; + height: auto !important; +} + +@media print { + img[shrinktofit] { + max-width: 100% !important; + height: auto !important; + } +} + +.moz-attached-image-container { + text-align: center; +} + +/* ::::: vcard ::::: */ + +.moz-vcard-table { + margin-top: 10px; + border-radius: 3px; + box-shadow: 0 1px 3px hsla(0, 0%, 50%, 0.6); +} + +.moz-vcard-property { + font-size: 80%; + color: gray; +} + +.moz-vcard-badge { + margin-top: 2px; + height: 32px; + width: 32px; + background-image: url("chrome://messenger/skin/addressbook/icons/contact-generic.svg"); + background-size: 100% 100%; + background-color: transparent; + display: block; + opacity: .7; + cursor: pointer; +} + +.moz-vcard-badge:hover { + opacity: .8; +} + +.moz-vcard-badge:active { + opacity: 1; +} + +.moz-vcard-badge:focus { + outline: none; +} + +/* Old style feeds, pre Tb3.0 */ +#_mailrssiframe { + position: fixed; + display: block; + top: 0; + left: 0; + width: 100%; + height: 100%; + border: none; +} + +/* Attachment display styling (for inline attachments and printing) */ +.moz-mime-attachment-header { + border-style: none; + border-top: 1px solid GrayText; + padding-block-start: 0.625em; + padding-block-end: 0.2em; +} + +.moz-mime-attachment-header.moz-print-only { + margin-top: 1em; +} + +.moz-mime-attachment-header-name { + color: GrayText; + font-size: 80%; + font-family: Arial, sans-serif; +} + +.moz-mime-attachment-wrap { + padding: 0 1em; +} + +.moz-mime-attachment-table { + width: 100%; + border-collapse: collapse; + table-layout: fixed; +} + +.moz-mime-attachment-table tr + tr > td { + border-top: 1px solid GrayText; + padding-top: 0.25em; +} + +.moz-mime-attachment-file { + word-wrap: break-word; +} + +.moz-mime-attachment-size { + vertical-align: top; + width: 10ch; + text-align: right; +} + +.moz-mime-attachment-file, +.moz-mime-attachment-size { + padding: 0 0 0.25em; +} diff --git a/mail/themes/windows/mail/messageBody.css b/mail/themes/windows/mail/messageBody.css index 1119a74f0f..a8c696fd37 100644 --- a/mail/themes/windows/mail/messageBody.css +++ b/mail/themes/windows/mail/messageBody.css @@ -2,200 +2,9 @@ * 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/. */ -/* ===== messageBody.css ================================================= - == Styles for the body of a mail message. - ======================================================================= */ -@import url(chrome://messenger/skin/messageQuotes.css); - -@namespace url("http://www.w3.org/1999/xhtml"); - -mailattachcount { - display: none; -} - -/* :::: message header ::::: */ - -@media screen { - .moz-main-header, - .moz-main-header + br, - .moz-print-only { - display: none; - } -} - -.moz-header-part1 { - background-color: #EFEFEF; -} - -.moz-header-part2, -.moz-header-part3 { - background-color: #DEDEDE; -} - -.moz-header-display-name { - display: inline; - font-weight: bold; - white-space: pre; -} - -/* ::::: message text, incl. quotes ::::: */ - -.moz-text-flowed blockquote, -.moz-text-plain blockquote { - margin: 0; -} - -.moz-text-plain pre { - margin: 0; - font-family: inherit; -} - -.moz-text-plain[wrap="true"] { - white-space: pre-wrap; -} - -.moz-text-plain[wrap="false"] { - white-space: pre; -} - -.moz-text-plain[wrap="flow"] .moz-txt-sig { - white-space: pre-wrap; -} - -.moz-text-plain[graphical-quote="false"] blockquote { - border-style: none; - padding: 0; -} - -.moz-text-plain[graphical-quote="true"] .moz-txt-citetags { - display: none; -} - -.moz-txt-underscore { - text-decoration: underline; -} +@import url("chrome://messenger/skin/shared/messageBody.css"); .moz-txt-formfeed { display: block; height: 100%; } - -/* ::::: images ::::: */ - -img[overflowing]:not([shrinktofit]) { - cursor: zoom-out; - width: auto !important; -} - -img[overflowing][shrinktofit] { - cursor: zoom-in; - max-width: 100% !important; - height: auto !important; -} - -@media print { - img[shrinktofit] { - max-width: 100% !important; - height: auto !important; - } -} - -.moz-attached-image-container { - text-align: center; -} - -/* ::::: vcard ::::: */ - -.moz-vcard-table { - margin-top: 10px; - border-radius: 3px; - box-shadow: 0 1px 3px hsla(0, 0%, 50%, 0.6); -} - -.moz-vcard-property { - font-size: 80%; - color: gray; -} - -.moz-vcard-badge { - margin-top: 2px; - height: 32px; - width: 32px; - background-image: url("chrome://messenger/skin/addressbook/icons/contact-generic.svg"); - background-size: 100% 100%; - background-color: transparent; - display: block; - opacity: .7; - cursor: pointer; -} - -.moz-vcard-badge:hover { - opacity: .8; -} - -.moz-vcard-badge:active { - opacity: 1; -} - -.moz-vcard-badge:focus { - outline: none; -} - -/* Old style feeds, pre Tb3.0 */ -#_mailrssiframe { - position: fixed; - display: block; - top: 0; - left: 0; - width: 100%; - height: 100%; - border: none; -} - -/* Attachment display styling (for inline attachments and printing) */ -.moz-mime-attachment-header { - border-style: none; - border-top: 1px solid GrayText; - padding-block-start: 0.625em; - padding-block-end: 0.2em; -} - -.moz-mime-attachment-header.moz-print-only { - margin-top: 1em; -} - -.moz-mime-attachment-header-name { - color: GrayText; - font-size: 80%; - font-family: Arial, sans-serif; -} - -.moz-mime-attachment-wrap { - padding: 0 1em; -} - -.moz-mime-attachment-table { - width: 100%; - border-collapse: collapse; - table-layout: fixed; -} - -.moz-mime-attachment-table tr + tr > td { - border-top: 1px solid GrayText; - padding-top: 0.25em; -} - -.moz-mime-attachment-file { - word-wrap: break-word; -} - -.moz-mime-attachment-size { - vertical-align: top; - width: 10ch; - text-align: right; -} - -.moz-mime-attachment-file, -.moz-mime-attachment-size { - padding: 0 0 0.25em; -}