| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 // Set when printing. | 389 // Set when printing. |
| 390 float m_printedPageWidth; | 390 float m_printedPageWidth; |
| 391 }; | 391 }; |
| 392 | 392 |
| 393 // Simple class to override some of PrintContext behavior. This is used when | 393 // Simple class to override some of PrintContext behavior. This is used when |
| 394 // the frame hosts a plugin that supports custom printing. In this case, we | 394 // the frame hosts a plugin that supports custom printing. In this case, we |
| 395 // want to delegate all printing related calls to the plugin. | 395 // want to delegate all printing related calls to the plugin. |
| 396 class ChromePluginPrintContext FINAL : public ChromePrintContext { | 396 class ChromePluginPrintContext FINAL : public ChromePrintContext { |
| 397 public: | 397 public: |
| 398 ChromePluginPrintContext(LocalFrame* frame, WebPluginContainerImpl* plugin,
const WebPrintParams& printParams) | 398 ChromePluginPrintContext(LocalFrame* frame, WebPluginContainerImpl* plugin,
const WebPrintParams& printParams) |
| 399 : ChromePrintContext(frame), m_plugin(plugin), m_pageCount(0), m_printPa
rams(printParams) | 399 : ChromePrintContext(frame), m_plugin(plugin), m_printParams(printParams
) |
| 400 { | 400 { |
| 401 } | 401 } |
| 402 | 402 |
| 403 virtual ~ChromePluginPrintContext() { } | 403 virtual ~ChromePluginPrintContext() { } |
| 404 | 404 |
| 405 virtual void begin(float width, float height) | 405 virtual void begin(float width, float height) OVERRIDE |
| 406 { | 406 { |
| 407 } | 407 } |
| 408 | 408 |
| 409 virtual void end() | 409 virtual void end() OVERRIDE |
| 410 { | 410 { |
| 411 m_plugin->printEnd(); | 411 m_plugin->printEnd(); |
| 412 } | 412 } |
| 413 | 413 |
| 414 virtual float getPageShrink(int pageNumber) const | 414 virtual float getPageShrink(int pageNumber) const OVERRIDE |
| 415 { | 415 { |
| 416 // We don't shrink the page (maybe we should ask the widget ??) | 416 // We don't shrink the page (maybe we should ask the widget ??) |
| 417 return 1.0; | 417 return 1.0; |
| 418 } | 418 } |
| 419 | 419 |
| 420 virtual void computePageRects(const FloatRect& printRect, float headerHeight
, float footerHeight, float userScaleFactor, float& outPageHeight) | 420 virtual void computePageRects(const FloatRect& printRect, float headerHeight
, float footerHeight, float userScaleFactor, float& outPageHeight) OVERRIDE |
| 421 { | 421 { |
| 422 m_printParams.printContentArea = IntRect(printRect); | 422 m_printParams.printContentArea = IntRect(printRect); |
| 423 m_pageCount = m_plugin->printBegin(m_printParams); | 423 m_pageRects.fill(IntRect(printRect), m_plugin->printBegin(m_printParams)
); |
| 424 } | 424 } |
| 425 | 425 |
| 426 virtual int pageCount() const | 426 virtual void computePageRectsWithPageSize(const FloatSize& pageSizeInPixels,
bool allowHorizontalTiling) OVERRIDE |
| 427 { | 427 { |
| 428 return m_pageCount; | 428 ASSERT_NOT_REACHED(); |
| 429 } | 429 } |
| 430 | 430 |
| 431 protected: | 431 protected: |
| 432 // Spools the printed page, a subrect of frame(). Skip the scale step. | 432 // Spools the printed page, a subrect of frame(). Skip the scale step. |
| 433 // NativeTheme doesn't play well with scaling. Scaling is done browser side | 433 // NativeTheme doesn't play well with scaling. Scaling is done browser side |
| 434 // instead. Returns the scale to be applied. | 434 // instead. Returns the scale to be applied. |
| 435 virtual float spoolPage(GraphicsContext& context, int pageNumber) | 435 virtual float spoolPage(GraphicsContext& context, int pageNumber) OVERRIDE |
| 436 { | 436 { |
| 437 m_plugin->printPage(pageNumber, &context); | 437 m_plugin->printPage(pageNumber, &context); |
| 438 return 1.0; | 438 return 1.0; |
| 439 } | 439 } |
| 440 | 440 |
| 441 private: | 441 private: |
| 442 // Set when printing. | 442 // Set when printing. |
| 443 WebPluginContainerImpl* m_plugin; | 443 WebPluginContainerImpl* m_plugin; |
| 444 int m_pageCount; | |
| 445 WebPrintParams m_printParams; | 444 WebPrintParams m_printParams; |
| 446 | |
| 447 }; | 445 }; |
| 448 | 446 |
| 449 static WebDataSource* DataSourceForDocLoader(DocumentLoader* loader) | 447 static WebDataSource* DataSourceForDocLoader(DocumentLoader* loader) |
| 450 { | 448 { |
| 451 return loader ? WebDataSourceImpl::fromDocumentLoader(loader) : 0; | 449 return loader ? WebDataSourceImpl::fromDocumentLoader(loader) : 0; |
| 452 } | 450 } |
| 453 | 451 |
| 454 // WebFrame ------------------------------------------------------------------- | 452 // WebFrame ------------------------------------------------------------------- |
| 455 | 453 |
| 456 int WebFrame::instanceCount() | 454 int WebFrame::instanceCount() |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1274 else | 1272 else |
| 1275 m_printContext = adoptPtrWillBeNoop(new ChromePrintContext(frame())); | 1273 m_printContext = adoptPtrWillBeNoop(new ChromePrintContext(frame())); |
| 1276 | 1274 |
| 1277 FloatRect rect(0, 0, static_cast<float>(printParams.printContentArea.width),
static_cast<float>(printParams.printContentArea.height)); | 1275 FloatRect rect(0, 0, static_cast<float>(printParams.printContentArea.width),
static_cast<float>(printParams.printContentArea.height)); |
| 1278 m_printContext->begin(rect.width(), rect.height()); | 1276 m_printContext->begin(rect.width(), rect.height()); |
| 1279 float pageHeight; | 1277 float pageHeight; |
| 1280 // We ignore the overlays calculation for now since they are generated in th
e | 1278 // We ignore the overlays calculation for now since they are generated in th
e |
| 1281 // browser. pageHeight is actually an output parameter. | 1279 // browser. pageHeight is actually an output parameter. |
| 1282 m_printContext->computePageRects(rect, 0, 0, 1.0, pageHeight); | 1280 m_printContext->computePageRects(rect, 0, 0, 1.0, pageHeight); |
| 1283 | 1281 |
| 1284 return m_printContext->pageCount(); | 1282 return static_cast<int>(m_printContext->pageCount()); |
| 1285 } | 1283 } |
| 1286 | 1284 |
| 1287 float WebLocalFrameImpl::getPrintPageShrink(int page) | 1285 float WebLocalFrameImpl::getPrintPageShrink(int page) |
| 1288 { | 1286 { |
| 1289 ASSERT(m_printContext && page >= 0); | 1287 ASSERT(m_printContext && page >= 0); |
| 1290 return m_printContext->getPageShrink(page); | 1288 return m_printContext->getPageShrink(page); |
| 1291 } | 1289 } |
| 1292 | 1290 |
| 1293 float WebLocalFrameImpl::printPage(int page, WebCanvas* canvas) | 1291 float WebLocalFrameImpl::printPage(int page, WebCanvas* canvas) |
| 1294 { | 1292 { |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1870 | 1868 |
| 1871 void WebLocalFrameImpl::invalidateAll() const | 1869 void WebLocalFrameImpl::invalidateAll() const |
| 1872 { | 1870 { |
| 1873 ASSERT(frame() && frame()->view()); | 1871 ASSERT(frame() && frame()->view()); |
| 1874 FrameView* view = frame()->view(); | 1872 FrameView* view = frame()->view(); |
| 1875 view->invalidateRect(view->frameRect()); | 1873 view->invalidateRect(view->frameRect()); |
| 1876 invalidateScrollbar(); | 1874 invalidateScrollbar(); |
| 1877 } | 1875 } |
| 1878 | 1876 |
| 1879 } // namespace blink | 1877 } // namespace blink |
| OLD | NEW |