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

Side by Side Diff: Source/web/WebLocalFrameImpl.cpp

Issue 469833003: Cannot preview PDFs (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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
OLDNEW
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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_pageCount(0), m_printPa rams(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_pageCount = m_plugin->printBegin(m_printParams);
424 } 424 }
425 425
426 virtual int pageCount() const 426 virtual size_t pageCount() const OVERRIDE
427 { 427 {
428 return m_pageCount; 428 return m_pageCount;
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; 444 size_t m_pageCount;
445 WebPrintParams m_printParams; 445 WebPrintParams m_printParams;
446 446
447 }; 447 };
448 448
449 static WebDataSource* DataSourceForDocLoader(DocumentLoader* loader) 449 static WebDataSource* DataSourceForDocLoader(DocumentLoader* loader)
450 { 450 {
451 return loader ? WebDataSourceImpl::fromDocumentLoader(loader) : 0; 451 return loader ? WebDataSourceImpl::fromDocumentLoader(loader) : 0;
452 } 452 }
453 453
454 // WebFrame ------------------------------------------------------------------- 454 // WebFrame -------------------------------------------------------------------
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
1274 else 1274 else
1275 m_printContext = adoptPtrWillBeNoop(new ChromePrintContext(frame())); 1275 m_printContext = adoptPtrWillBeNoop(new ChromePrintContext(frame()));
1276 1276
1277 FloatRect rect(0, 0, static_cast<float>(printParams.printContentArea.width), static_cast<float>(printParams.printContentArea.height)); 1277 FloatRect rect(0, 0, static_cast<float>(printParams.printContentArea.width), static_cast<float>(printParams.printContentArea.height));
1278 m_printContext->begin(rect.width(), rect.height()); 1278 m_printContext->begin(rect.width(), rect.height());
1279 float pageHeight; 1279 float pageHeight;
1280 // We ignore the overlays calculation for now since they are generated in th e 1280 // We ignore the overlays calculation for now since they are generated in th e
1281 // browser. pageHeight is actually an output parameter. 1281 // browser. pageHeight is actually an output parameter.
1282 m_printContext->computePageRects(rect, 0, 0, 1.0, pageHeight); 1282 m_printContext->computePageRects(rect, 0, 0, 1.0, pageHeight);
1283 1283
1284 return m_printContext->pageCount(); 1284 return static_cast<int>(m_printContext->pageCount());
1285 } 1285 }
1286 1286
1287 float WebLocalFrameImpl::getPrintPageShrink(int page) 1287 float WebLocalFrameImpl::getPrintPageShrink(int page)
1288 { 1288 {
1289 ASSERT(m_printContext && page >= 0); 1289 ASSERT(m_printContext && page >= 0);
1290 return m_printContext->getPageShrink(page); 1290 return m_printContext->getPageShrink(page);
1291 } 1291 }
1292 1292
1293 float WebLocalFrameImpl::printPage(int page, WebCanvas* canvas) 1293 float WebLocalFrameImpl::printPage(int page, WebCanvas* canvas)
1294 { 1294 {
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
1870 1870
1871 void WebLocalFrameImpl::invalidateAll() const 1871 void WebLocalFrameImpl::invalidateAll() const
1872 { 1872 {
1873 ASSERT(frame() && frame()->view()); 1873 ASSERT(frame() && frame()->view());
1874 FrameView* view = frame()->view(); 1874 FrameView* view = frame()->view();
1875 view->invalidateRect(view->frameRect()); 1875 view->invalidateRect(view->frameRect());
1876 invalidateScrollbar(); 1876 invalidateScrollbar();
1877 } 1877 }
1878 1878
1879 } // namespace blink 1879 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698