зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1473742
- Fix printing fonts loaded with JS API. r=jfkthame
Copy over non-rule font faces to the static clone document that is used during printing. MozReview-Commit-ID: 8ggNrCcVpEK --HG-- extra : rebase_source : 27e270edd28c3ecf19a99f4df5398a89e6c53e6a
This commit is contained in:
Родитель
9fc855eec6
Коммит
6a890f9e34
|
@ -9578,6 +9578,13 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Font faces created with the JS API will not be reflected in the
|
||||
// stylesheets and need to be copied over to the cloned document.
|
||||
if (const FontFaceSet* set = GetFonts()) {
|
||||
set->CopyNonRuleFacesTo(clonedDoc->Fonts());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
mCreatingStaticClone = false;
|
||||
|
|
|
@ -13,6 +13,8 @@ support-files =
|
|||
printpreview_bug396024_helper.xul
|
||||
printpreview_bug482976_helper.xul
|
||||
printpreview_helper.xul
|
||||
printpreview_font_api.html
|
||||
printpreview_font_api_ref.html
|
||||
file_bug1018265.xul
|
||||
|
||||
[test_bug396367-1.html]
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -280,6 +280,32 @@ function runTest7() {
|
|||
exitprintpreview();
|
||||
ok(compareCanvases(), "Printing light DOM and shadow DOM should create same output");
|
||||
|
||||
requestAnimationFrame(function() { setTimeout(runTest8); } );
|
||||
}
|
||||
|
||||
async function runTest8() {
|
||||
// Test that fonts loaded with CSS and JS are printed the same.
|
||||
const iframeElement = document.getElementsByTagName("iframe")[0];
|
||||
|
||||
// First, snapshot the page with font defined in CSS.
|
||||
await new Promise((resolve) => {
|
||||
iframeElement.addEventListener("load", resolve, { capture: true, once: true });
|
||||
iframeElement.setAttribute("src", "printpreview_font_api_ref.html");
|
||||
});
|
||||
printpreview();
|
||||
ctx1.drawWindow(window.frames[1], 0, 0, 400, 400, "rgb(255,255,255)");
|
||||
exitprintpreview();
|
||||
|
||||
// Second, snapshot the page with font loaded in JS.
|
||||
await new Promise((resolve) => {
|
||||
iframeElement.addEventListener("message", resolve, { capture: true, once: true });
|
||||
iframeElement.setAttribute("src", "printpreview_font_api.html");
|
||||
});
|
||||
printpreview();
|
||||
ctx2.drawWindow(window.frames[1], 0, 0, 400, 400, "rgb(255,255,255)");
|
||||
exitprintpreview();
|
||||
ok(compareCanvases(), "Printing pages with fonts loaded from CSS and JS should be the same.");
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
|
|
|
@ -1936,6 +1936,17 @@ FontFaceSet::RefreshStandardFontLoadPrincipal()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
FontFaceSet::CopyNonRuleFacesTo(FontFaceSet* aFontFaceSet) const
|
||||
{
|
||||
for (const FontFaceRecord& rec : mNonRuleFaces) {
|
||||
ErrorResult rv;
|
||||
RefPtr<FontFace> f = rec.mFontFace;
|
||||
aFontFaceSet->Add(*f, rv);
|
||||
MOZ_ASSERT(!rv.Failed());
|
||||
}
|
||||
}
|
||||
|
||||
// -- FontFaceSet::UserFontSet ------------------------------------------------
|
||||
|
||||
/* virtual */ bool
|
||||
|
|
|
@ -177,6 +177,8 @@ public:
|
|||
|
||||
void RefreshStandardFontLoadPrincipal();
|
||||
|
||||
void CopyNonRuleFacesTo(FontFaceSet* aFontFaceSet) const;
|
||||
|
||||
nsIDocument* Document() const { return mDocument; }
|
||||
|
||||
// -- Web IDL --------------------------------------------------------------
|
||||
|
|
Загрузка…
Ссылка в новой задаче