diff options
author | Michael Bruning <michael.bruning@qt.io> | 2016-08-09 16:28:44 +0200 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@qt.io> | 2016-08-28 06:50:44 +0000 |
commit | 54b7425c356378018c511bd9087f06767d0bc708 (patch) | |
tree | 5c95c24e5c70d1a7ae9bf4d9cc6d55ae5788e5e9 /src/core | |
parent | 2609e257926c36e211a5aec9d6675e27dd447aad (diff) |
Add setting to enable printing of CSS backgrounds
[ChangeLog][Printing] Printing will now include the
CSS background of the printed elements by default. This restores
the default behavior from Qt WebKit. It can be controlled via the
PrintElementBackgrounds web setting.
Task-number: QTBUG-54918
Change-Id: I37c37456dfec6368f22c36c515ac3cad1bbf8006
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/print_view_manager_qt.cpp | 6 | ||||
-rw-r--r-- | src/core/web_engine_settings.cpp | 2 | ||||
-rw-r--r-- | src/core/web_engine_settings.h | 3 |
3 files changed, 9 insertions, 2 deletions
diff --git a/src/core/print_view_manager_qt.cpp b/src/core/print_view_manager_qt.cpp index bb01f531c..26a6c2682 100644 --- a/src/core/print_view_manager_qt.cpp +++ b/src/core/print_view_manager_qt.cpp @@ -50,7 +50,9 @@ #include "chrome/browser/printing/print_job_manager.h" #include "chrome/browser/printing/printer_query.h" #include "components/printing/common/print_messages.h" +#include "content/browser/renderer_host/render_view_host_impl.h" #include "content/public/browser/browser_thread.h" +#include "content/public/common/web_preferences.h" #include "printing/pdf_metafile_skia.h" #include "printing/print_job_constants.h" @@ -125,7 +127,7 @@ static base::DictionaryValue *createPrintSettings() printSettings->SetBoolean(printing::kSettingPreviewModifiable, false); printSettings->SetBoolean(printing::kSettingShouldPrintSelectionOnly, false); - printSettings->SetBoolean(printing::kSettingShouldPrintBackgrounds, false); + printSettings->SetBoolean(printing::kSettingShouldPrintBackgrounds, true); printSettings->SetBoolean(printing::kSettingHeaderFooterEnabled, false); printSettings->SetString(printing::kSettingDeviceName, ""); printSettings->SetInteger(printing::kPreviewUIID, 12345678); @@ -210,6 +212,8 @@ bool PrintViewManagerQt::PrintToPDFInternal(const QPageLayout &pageLayout, bool m_printSettings->SetInteger(printing::kSettingColor, printInColor ? printing::COLOR : printing::GRAYSCALE); applyQPageLayoutSettingsToDictionary(pageLayout, *m_printSettings); + m_printSettings->SetBoolean(printing::kSettingShouldPrintBackgrounds + , web_contents()->GetRenderViewHost()->GetWebkitPreferences().should_print_backgrounds); return Send(new PrintMsg_InitiatePrintPreview(routing_id(), false)); } diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp index a706b860e..754fa2f51 100644 --- a/src/core/web_engine_settings.cpp +++ b/src/core/web_engine_settings.cpp @@ -238,6 +238,7 @@ void WebEngineSettings::initDefaults(bool offTheRecord) s_defaultAttributes.insert(AutoLoadIconsForPage, true); s_defaultAttributes.insert(TouchIconsEnabled, false); s_defaultAttributes.insert(FocusOnNavigationEnabled, true); + s_defaultAttributes.insert(PrintElementBackgrounds, true); } if (offTheRecord) m_attributes.insert(LocalStorageEnabled, false); @@ -313,6 +314,7 @@ void WebEngineSettings::applySettingsToWebPreferences(content::WebPreferences *p prefs->fullscreen_supported = testAttribute(FullScreenSupportEnabled); prefs->accelerated_2d_canvas_enabled = testAttribute(Accelerated2dCanvasEnabled); prefs->experimental_webgl_enabled = testAttribute(WebGLEnabled); + prefs->should_print_backgrounds = testAttribute(PrintElementBackgrounds); // Fonts settings. prefs->standard_font_family_map[content::kCommonScript] = toString16(fontFamily(StandardFont)); diff --git a/src/core/web_engine_settings.h b/src/core/web_engine_settings.h index 55e659b53..31f2198b8 100644 --- a/src/core/web_engine_settings.h +++ b/src/core/web_engine_settings.h @@ -80,7 +80,8 @@ public: Accelerated2dCanvasEnabled, AutoLoadIconsForPage, TouchIconsEnabled, - FocusOnNavigationEnabled + FocusOnNavigationEnabled, + PrintElementBackgrounds }; // Must match the values from the public API in qwebenginesettings.h. |