Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 3 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 3 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 public: | 300 public: |
| 301 ChromePrintContext(Frame* frame) | 301 ChromePrintContext(Frame* frame) |
| 302 : PrintContext(frame), | 302 : PrintContext(frame), |
| 303 printed_page_width_(0) { | 303 printed_page_width_(0) { |
| 304 } | 304 } |
| 305 void begin(float width) { | 305 void begin(float width) { |
| 306 DCHECK(!printed_page_width_); | 306 DCHECK(!printed_page_width_); |
| 307 printed_page_width_ = width; | 307 printed_page_width_ = width; |
| 308 WebCore::PrintContext::begin(printed_page_width_); | 308 WebCore::PrintContext::begin(printed_page_width_); |
| 309 } | 309 } |
| 310 float getPageShrink(int pageNumber) { | |
| 311 IntRect pageRect = m_pageRects[pageNumber]; | |
| 312 return printed_page_width_ / pageRect.width(); | |
| 313 } | |
| 310 // Spools the printed page, a subrect of m_frame. | 314 // Spools the printed page, a subrect of m_frame. |
| 311 // Skip the scale step. NativeTheme doesn't play well with scaling. Scaling | 315 // Skip the scale step. NativeTheme doesn't play well with scaling. Scaling |
| 312 // is done browser side instead. | 316 // is done browser side instead. |
| 313 // Returns the scale to be applied. | 317 // Returns the scale to be applied. |
| 314 float spoolPage(GraphicsContext& ctx, int pageNumber) { | 318 float spoolPage(GraphicsContext& ctx, int pageNumber) { |
| 315 IntRect pageRect = m_pageRects[pageNumber]; | 319 IntRect pageRect = m_pageRects[pageNumber]; |
| 316 float scale = printed_page_width_ / pageRect.width(); | 320 float scale = printed_page_width_ / pageRect.width(); |
| 317 | 321 |
| 318 ctx.save(); | 322 ctx.save(); |
| 319 ctx.translate(static_cast<float>(-pageRect.x()), | 323 ctx.translate(static_cast<float>(-pageRect.x()), |
| (...skipping 1557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1877 print_context_->begin(rect.width()); | 1881 print_context_->begin(rect.width()); |
| 1878 float page_height; | 1882 float page_height; |
| 1879 // We ignore the overlays calculation for now since they are generated in the | 1883 // We ignore the overlays calculation for now since they are generated in the |
| 1880 // browser. page_height is actually an output parameter. | 1884 // browser. page_height is actually an output parameter. |
| 1881 print_context_->computePageRects(rect, 0, 0, 1.0, page_height); | 1885 print_context_->computePageRects(rect, 0, 0, 1.0, page_height); |
| 1882 if (page_count) | 1886 if (page_count) |
| 1883 *page_count = print_context_->pageCount(); | 1887 *page_count = print_context_->pageCount(); |
| 1884 return true; | 1888 return true; |
| 1885 } | 1889 } |
| 1886 | 1890 |
| 1891 float WebFrameImpl::GetPrintPageShrink(int page) { | |
| 1892 // Ensure correct state. | |
| 1893 if (!print_context_.get() || page < 0 || !frame() || !frame()->document()) { | |
|
M-A Ruel
2009/04/27 18:41:13
I don't think it's worth looking at frame() or fra
| |
| 1894 NOTREACHED(); | |
| 1895 return 0; | |
| 1896 } | |
| 1897 | |
| 1898 return print_context_->getPageShrink(page); | |
| 1899 } | |
| 1900 | |
| 1887 float WebFrameImpl::PrintPage(int page, skia::PlatformCanvas* canvas) { | 1901 float WebFrameImpl::PrintPage(int page, skia::PlatformCanvas* canvas) { |
| 1888 // Ensure correct state. | 1902 // Ensure correct state. |
| 1889 if (!print_context_.get() || page < 0 || !frame() || !frame()->document()) { | 1903 if (!print_context_.get() || page < 0 || !frame() || !frame()->document()) { |
| 1890 NOTREACHED(); | 1904 NOTREACHED(); |
| 1891 return 0; | 1905 return 0; |
| 1892 } | 1906 } |
| 1893 | 1907 |
| 1894 #if defined(OS_WIN) || defined(OS_LINUX) | 1908 #if defined(OS_WIN) || defined(OS_LINUX) |
| 1895 PlatformContextSkia context(canvas); | 1909 PlatformContextSkia context(canvas); |
| 1896 GraphicsContext spool(&context); | 1910 GraphicsContext spool(&context); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1952 return password_listeners_.get(input_element); | 1966 return password_listeners_.get(input_element); |
| 1953 } | 1967 } |
| 1954 | 1968 |
| 1955 void WebFrameImpl::ClearPasswordListeners() { | 1969 void WebFrameImpl::ClearPasswordListeners() { |
| 1956 for (PasswordListenerMap::iterator iter = password_listeners_.begin(); | 1970 for (PasswordListenerMap::iterator iter = password_listeners_.begin(); |
| 1957 iter != password_listeners_.end(); ++iter) { | 1971 iter != password_listeners_.end(); ++iter) { |
| 1958 delete iter->second; | 1972 delete iter->second; |
| 1959 } | 1973 } |
| 1960 password_listeners_.clear(); | 1974 password_listeners_.clear(); |
| 1961 } | 1975 } |
| OLD | NEW |