OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "printing/print_settings_initializer_win.h" | 5 #include "printing/print_settings_initializer_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "printing/print_settings.h" | 9 #include "printing/print_settings.h" |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 DCHECK_EQ(GetDeviceCaps(hdc, SCALINGFACTORY), 0); | 42 DCHECK_EQ(GetDeviceCaps(hdc, SCALINGFACTORY), 0); |
43 | 43 |
44 // Initialize page_setup_device_units_. | 44 // Initialize page_setup_device_units_. |
45 gfx::Size physical_size_device_units(GetDeviceCaps(hdc, PHYSICALWIDTH), | 45 gfx::Size physical_size_device_units(GetDeviceCaps(hdc, PHYSICALWIDTH), |
46 GetDeviceCaps(hdc, PHYSICALHEIGHT)); | 46 GetDeviceCaps(hdc, PHYSICALHEIGHT)); |
47 gfx::Rect printable_area_device_units(GetDeviceCaps(hdc, PHYSICALOFFSETX), | 47 gfx::Rect printable_area_device_units(GetDeviceCaps(hdc, PHYSICALOFFSETX), |
48 GetDeviceCaps(hdc, PHYSICALOFFSETY), | 48 GetDeviceCaps(hdc, PHYSICALOFFSETY), |
49 GetDeviceCaps(hdc, HORZRES), | 49 GetDeviceCaps(hdc, HORZRES), |
50 GetDeviceCaps(hdc, VERTRES)); | 50 GetDeviceCaps(hdc, VERTRES)); |
51 | 51 |
| 52 // Sanity check the printable_area: we've seen crashes caused by a printable |
| 53 // area rect of 0, 0, 0, 0, so it seems some drivers don't set it. |
| 54 if (printable_area_device_units.IsEmpty() || |
| 55 !gfx::Rect(physical_size_device_units).Contains( |
| 56 printable_area_device_units)) { |
| 57 printable_area_device_units = gfx::Rect(physical_size_device_units); |
| 58 } |
| 59 |
52 print_settings->SetPrinterPrintableArea(physical_size_device_units, | 60 print_settings->SetPrinterPrintableArea(physical_size_device_units, |
53 printable_area_device_units, | 61 printable_area_device_units, |
54 dpi); | 62 dpi); |
55 } | 63 } |
56 | 64 |
57 } // namespace printing | 65 } // namespace printing |
OLD | NEW |