opnsense-ports/www/waterfox/files/patch-bug1246883
Franco Fichtner 1684219aa3 */*: sync with upstream
Taken from: HardenedBSD
2018-01-13 11:05:42 +01:00

56 lines
2.3 KiB
Text

commit b175b27efefd
Author: Mantaroh Yoshinaga <mantaroh@gmail.com>
Date: Wed Dec 13 08:58:05 2017 +0900
Bug 1246883 - Load UA Stylesheet when printing the SVG document. r=jwatt, a=gchang
Currently, Gecko load only minimal-xul.css if the document is the SVG[1].
In the case of printing SVG document, gecko should load ua.css for using style
which related to print.
This patch will load ua.css when printing the SVG document.
[1] http://searchfox.org/mozilla-central/rev/67f38de2443e6b613d874fcf4d2cd1f2fc3d5e97/layout/base/nsDocumentViewer.cpp#2472
MozReview-Commit-ID: JtdaEvX8QTw
--HG--
extra : source : 727a90ad06e715b3a4457b2532e922d22a2469a2
---
layout/printing/nsPrintEngine.cpp | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git layout/printing/nsPrintEngine.cpp layout/printing/nsPrintEngine.cpp
index f8d8f1077ba5..3ac2211d159d 100644
--- layout/printing/nsPrintEngine.cpp
+++ layout/printing/nsPrintEngine.cpp
@@ -75,6 +75,7 @@ static const char kPrintingPromptService[] = "@mozilla.org/embedcomp/printingpro
#include "nsISupportsUtils.h"
#include "nsIScriptContext.h"
#include "nsIDOMDocument.h"
+#include "nsIDocumentObserver.h"
#include "nsISelectionListener.h"
#include "nsISelectionPrivate.h"
#include "nsIDOMRange.h"
@@ -82,6 +83,7 @@ static const char kPrintingPromptService[] = "@mozilla.org/embedcomp/printingpro
#include "nsLayoutCID.h"
#include "nsContentUtils.h"
#include "nsIPresShell.h"
+#include "nsLayoutStylesheetCache.h"
#include "nsLayoutUtils.h"
#include "mozilla/Preferences.h"
@@ -2267,6 +2269,13 @@ nsPrintEngine::ReflowPrintObject(const UniquePtr<nsPrintObject>& aPO)
StyleSetHandle styleSet = mDocViewerPrint->CreateStyleSet(aPO->mDocument);
+ if (aPO->mDocument->IsSVGDocument()) {
+ // The SVG document only loads minimal-xul.css, so it doesn't apply other
+ // styles. We should add ua.css for applying style which related to print.
+ auto cache = nsLayoutStylesheetCache::For(aPO->mDocument->GetStyleBackendType());
+ styleSet->PrependStyleSheet(SheetType::Agent, cache->UASheet());
+ }
+
aPO->mPresShell = aPO->mDocument->CreateShell(aPO->mPresContext,
aPO->mViewManager, styleSet);
if (!aPO->mPresShell) {