Bug 1246883 - Load UA Stylesheet when printing the SVG document. r?jwatt
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
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -71,23 +71,25 @@ static const char kPrintingPromptService
// Misc
#include "gfxContext.h"
#include "mozilla/gfx/DrawEventRecorder.h"
#include "mozilla/layout/RemotePrintJobChild.h"
#include "nsISupportsUtils.h"
#include "nsIScriptContext.h"
#include "nsIDOMDocument.h"
+#include "nsIDocumentObserver.h"
#include "nsISelectionListener.h"
#include "nsISelectionPrivate.h"
#include "nsIDOMRange.h"
#include "nsContentCID.h"
#include "nsLayoutCID.h"
#include "nsContentUtils.h"
#include "nsIPresShell.h"
+#include "nsLayoutStylesheetCache.h"
#include "nsLayoutUtils.h"
#include "mozilla/Preferences.h"
#include "Text.h"
#include "nsWidgetsCID.h"
#include "nsIDeviceContextSpec.h"
#include "nsDeviceContextSpecProxy.h"
#include "nsViewManager.h"
@@ -2274,16 +2276,23 @@ nsPrintEngine::ReflowPrintObject(const U
aPO->mViewManager = new nsViewManager();
rv = aPO->mViewManager->Init(printData->mPrintDC);
NS_ENSURE_SUCCESS(rv,rv);
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) {
styleSet->Delete();
return NS_ERROR_FAILURE;
}
// If we're printing selection then remove the unselected nodes from our