diff options
author | vitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-17 04:44:27 +0000 |
---|---|---|
committer | vitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-17 04:44:27 +0000 |
commit | b243667df1d41b22843a07e0ea7ef7917bf836ae (patch) | |
tree | 118e302aecf699d133c06f95326d8be80c7c2126 /printing | |
parent | 895769aec35ff50088fb677522b31a2c7c5dfdeb (diff) | |
download | chromium_src-b243667df1d41b22843a07e0ea7ef7917bf836ae.zip chromium_src-b243667df1d41b22843a07e0ea7ef7917bf836ae.tar.gz chromium_src-b243667df1d41b22843a07e0ea7ef7917bf836ae.tar.bz2 |
Merge 167311 - Print headers and footers with WebKit.
Old implementation with gfx::RenderText had issues with fallback fonts. Sandbox does not allow to read required information from registry.
Also WebKit inplementation is smaller and more readable.
BUG=152893, 108599, 133548
TEST=manual: make sure that main content with or without headers is in the same place (default margin is exception). Make sure that any custom margins and paper layout produce reasonable result. If margins are to small, header and footer should be hidden.
Review URL: https://chromiumcodereview.appspot.com/11359020
TBR=vitalybuka@chromium.org
Review URL: https://codereview.chromium.org/11316066
git-svn-id: svn://svn.chromium.org/chrome/branches/1312/src@168379 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing')
-rw-r--r-- | printing/print_job_constants.cc | 16 | ||||
-rw-r--r-- | printing/print_job_constants.h | 5 | ||||
-rw-r--r-- | printing/print_settings_initializer.cc | 25 | ||||
-rw-r--r-- | printing/units.cc | 9 | ||||
-rw-r--r-- | printing/units.h | 4 |
5 files changed, 3 insertions, 56 deletions
diff --git a/printing/print_job_constants.cc b/printing/print_job_constants.cc index a93da56..8cd6208 100644 --- a/printing/print_job_constants.cc +++ b/printing/print_job_constants.cc @@ -55,22 +55,6 @@ const char kSettingGenerateDraftData[] = "generateDraftData"; // Option to print headers and Footers: true if selected, false if not. const char kSettingHeaderFooterEnabled[] = "headerFooterEnabled"; -// Default character spacing for text while printing headers and footers. -// (For CoreGraphics only). -const int kSettingHeaderFooterCharacterSpacing = 0; - -// Default font family name for printing the headers and footers. -const char kSettingHeaderFooterFontFamilyName[] = "sans"; - -// Default font name for printing the headers and footers. -const char kSettingHeaderFooterFontName[] = "Helvetica"; - -// Default font size for printing the headers and footers. -const int kSettingHeaderFooterFontSize = 8; - -// Number of horizontal regions for headers and footers. -const float kSettingHeaderFooterHorizontalRegions = 3; - // Interstice or gap between different header footer components. Hardcoded to // about 0.5cm, match the value in PrintSettings::SetPrinterPrintableArea. const float kSettingHeaderFooterInterstice = 14.2f; diff --git a/printing/print_job_constants.h b/printing/print_job_constants.h index d9a6006..88bf125 100644 --- a/printing/print_job_constants.h +++ b/printing/print_job_constants.h @@ -26,11 +26,6 @@ PRINTING_EXPORT extern const char kSettingDuplexMode[]; PRINTING_EXPORT extern const char kSettingFitToPageEnabled[]; PRINTING_EXPORT extern const char kSettingGenerateDraftData[]; PRINTING_EXPORT extern const char kSettingHeaderFooterEnabled[]; -PRINTING_EXPORT extern const int kSettingHeaderFooterCharacterSpacing; -PRINTING_EXPORT extern const char kSettingHeaderFooterFontFamilyName[]; -PRINTING_EXPORT extern const char kSettingHeaderFooterFontName[]; -PRINTING_EXPORT extern const int kSettingHeaderFooterFontSize; -PRINTING_EXPORT extern const float kSettingHeaderFooterHorizontalRegions; PRINTING_EXPORT extern const float kSettingHeaderFooterInterstice; PRINTING_EXPORT extern const char kSettingHeaderFooterDate[]; PRINTING_EXPORT extern const char kSettingHeaderFooterTitle[]; diff --git a/printing/print_settings_initializer.cc b/printing/print_settings_initializer.cc index e82bbfc..c49a556 100644 --- a/printing/print_settings_initializer.cc +++ b/printing/print_settings_initializer.cc @@ -35,34 +35,15 @@ void PrintSettingsInitializer::InitHeaderFooterStrings( string16 date = base::TimeFormatShortDateNumeric(base::Time::Now()); string16 title; - std::string url; + string16 url; if (!job_settings.GetString(kSettingHeaderFooterTitle, &title) || !job_settings.GetString(kSettingHeaderFooterURL, &url)) { NOTREACHED(); } - gfx::Font font( - kSettingHeaderFooterFontName, - ceil(ConvertPointsToPixelDouble(kSettingHeaderFooterFontSize))); - double segment_width = GetHeaderFooterSegmentWidth(ConvertUnitDouble( - print_settings->page_setup_device_units().physical_size().width(), - print_settings->device_units_per_inch(), kPixelsPerInch)); - date = ui::ElideText(date, font, segment_width, ui::ELIDE_AT_END); print_settings->date = date; - - // Calculate the available title width. If the date string is not long - // enough, increase the available space for the title. - // Assumes there is no header text to RIGHT of title. - double date_width = font.GetStringWidth(date); - double max_title_width = std::min(2 * segment_width, - 2 * (segment_width - date_width) + - segment_width); - print_settings->title = - ui::ElideText(title, font, max_title_width, ui::ELIDE_AT_END); - - double max_url_width = 2 * segment_width; - GURL gurl(url); - print_settings->url = ui::ElideUrl(gurl, font, max_url_width, std::string()); + print_settings->title = title; + print_settings->url = ui::ElideUrl(GURL(url), gfx::Font(), 0, std::string()); } } // namespace printing diff --git a/printing/units.cc b/printing/units.cc index f1ec616..dcee9ea 100644 --- a/printing/units.cc +++ b/printing/units.cc @@ -52,13 +52,4 @@ double ConvertPointsToPixelDouble(double points) { return ConvertUnitDouble(points, kPointsPerInch, kPixelsPerInch); } -double GetHeaderFooterSegmentWidth(double page_width) { - // Interstice is left at both ends of the page as well as between - // each region, so 1 is added. - double total_interstice_width = (kSettingHeaderFooterHorizontalRegions + 1) * - kSettingHeaderFooterInterstice; - return (page_width - total_interstice_width) / - kSettingHeaderFooterHorizontalRegions; -} - } // namespace printing diff --git a/printing/units.h b/printing/units.h index 43f68ee..8f02832 100644 --- a/printing/units.h +++ b/printing/units.h @@ -42,10 +42,6 @@ PRINTING_EXPORT double ConvertPixelsToPointDouble(double pixels); // Converts from 1 point to 1 pixel using doubles. double ConvertPointsToPixelDouble(double points); -// Splits the horizontal width equally into segments with an interstice -// between each segment. Returns the width of a segment. -PRINTING_EXPORT double GetHeaderFooterSegmentWidth(double page_width); - } // namespace printing #endif // PRINTING_UNITS_H_ |