Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: chrome/renderer/print_web_view_helper.cc

Issue 10837080: Work-around Windows 8 bug causing print footers and headers to have incorrect size. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/print_web_view_helper.h" 5 #include "chrome/renderer/print_web_view_helper.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 printing::VerticalHeaderFooterPosition vertical_position, 436 printing::VerticalHeaderFooterPosition vertical_position,
437 double offset_to_baseline) { 437 double offset_to_baseline) {
438 #if defined(USE_RENDER_TEXT) 438 #if defined(USE_RENDER_TEXT)
439 paint->SetText(text); 439 paint->SetText(text);
440 paint->SetFontSize(printing::kSettingHeaderFooterFontSize); 440 paint->SetFontSize(printing::kSettingHeaderFooterFontSize);
441 double text_width_in_points = paint->GetStringSize().width(); 441 double text_width_in_points = paint->GetStringSize().width();
442 SkPoint point = GetHeaderFooterPosition(webkit_scale_factor, page_layout, 442 SkPoint point = GetHeaderFooterPosition(webkit_scale_factor, page_layout,
443 horizontal_position, 443 horizontal_position,
444 vertical_position, offset_to_baseline, 444 vertical_position, offset_to_baseline,
445 text_width_in_points); 445 text_width_in_points);
446 paint->SetFontSize(printing::kSettingHeaderFooterFontSize / 446 // Set the scaled font size before drawing the text.
447 webkit_scale_factor); 447 // This creates a new font instead of calling |paint->SetFontSize()| to work
448 // around a Windows 8 bug. See: http://crbug.com/139206
449 gfx::FontList font_list(
450 gfx::Font(printing::kSettingHeaderFooterFontFamilyName,
451 printing::kSettingHeaderFooterFontSize / webkit_scale_factor));
452 paint->SetFontList(font_list);
448 gfx::Size size(paint->GetStringSize()); 453 gfx::Size size(paint->GetStringSize());
449 gfx::Rect rect(point.x(), point.y() - paint->GetBaseline(), 454 gfx::Rect rect(point.x(), point.y() - paint->GetBaseline(),
450 size.width(), size.height()); 455 size.width(), size.height());
451 paint->SetDisplayRect(rect); 456 paint->SetDisplayRect(rect);
452 { 457 {
453 SkMatrix m = canvas->getTotalMatrix(); 458 SkMatrix m = canvas->getTotalMatrix();
454 ui::ScaleFactor device_scale_factor = ui::GetScaleFactorFromScale( 459 ui::ScaleFactor device_scale_factor = ui::GetScaleFactorFromScale(
455 SkScalarAbs(m.getScaleX())); 460 SkScalarAbs(m.getScaleX()));
456 scoped_ptr<gfx::Canvas> gfx_canvas(gfx::Canvas::CreateCanvasWithoutScaling( 461 scoped_ptr<gfx::Canvas> gfx_canvas(gfx::Canvas::CreateCanvasWithoutScaling(
457 canvas, device_scale_factor)); 462 canvas, device_scale_factor));
(...skipping 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1875 DCHECK(IsRendering()); 1880 DCHECK(IsRendering());
1876 return prep_frame_view_->GetPrintCanvasSize(); 1881 return prep_frame_view_->GetPrintCanvasSize();
1877 } 1882 }
1878 1883
1879 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { 1884 void PrintWebViewHelper::PrintPreviewContext::ClearContext() {
1880 prep_frame_view_.reset(); 1885 prep_frame_view_.reset();
1881 metafile_.reset(); 1886 metafile_.reset();
1882 pages_to_render_.clear(); 1887 pages_to_render_.clear();
1883 error_ = PREVIEW_ERROR_NONE; 1888 error_ = PREVIEW_ERROR_NONE;
1884 } 1889 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698