| 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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 virtual void computePageRects(const FloatRect& printRect, float headerHeight
, float footerHeight, float userScaleFactor, float& outPageHeight) | 396 virtual void computePageRects(const FloatRect& printRect, float headerHeight
, float footerHeight, float userScaleFactor, float& outPageHeight) |
| 397 { | 397 { |
| 398 PrintContext::computePageRects(printRect, headerHeight, footerHeight, us
erScaleFactor, outPageHeight); | 398 PrintContext::computePageRects(printRect, headerHeight, footerHeight, us
erScaleFactor, outPageHeight); |
| 399 } | 399 } |
| 400 | 400 |
| 401 virtual int pageCount() const | 401 virtual int pageCount() const |
| 402 { | 402 { |
| 403 return PrintContext::pageCount(); | 403 return PrintContext::pageCount(); |
| 404 } | 404 } |
| 405 | 405 |
| 406 virtual bool shouldUseBrowserOverlays() const | |
| 407 { | |
| 408 return true; | |
| 409 } | |
| 410 | |
| 411 private: | 406 private: |
| 412 // Set when printing. | 407 // Set when printing. |
| 413 float m_printedPageWidth; | 408 float m_printedPageWidth; |
| 414 }; | 409 }; |
| 415 | 410 |
| 416 // Simple class to override some of PrintContext behavior. This is used when | 411 // Simple class to override some of PrintContext behavior. This is used when |
| 417 // the frame hosts a plugin that supports custom printing. In this case, we | 412 // the frame hosts a plugin that supports custom printing. In this case, we |
| 418 // want to delegate all printing related calls to the plugin. | 413 // want to delegate all printing related calls to the plugin. |
| 419 class ChromePluginPrintContext : public ChromePrintContext { | 414 class ChromePluginPrintContext : public ChromePrintContext { |
| 420 public: | 415 public: |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 | 448 |
| 454 // Spools the printed page, a subrect of frame(). Skip the scale step. | 449 // Spools the printed page, a subrect of frame(). Skip the scale step. |
| 455 // NativeTheme doesn't play well with scaling. Scaling is done browser side | 450 // NativeTheme doesn't play well with scaling. Scaling is done browser side |
| 456 // instead. Returns the scale to be applied. | 451 // instead. Returns the scale to be applied. |
| 457 virtual float spoolPage(GraphicsContext& context, int pageNumber) | 452 virtual float spoolPage(GraphicsContext& context, int pageNumber) |
| 458 { | 453 { |
| 459 m_plugin->printPage(pageNumber, &context); | 454 m_plugin->printPage(pageNumber, &context); |
| 460 return 1.0; | 455 return 1.0; |
| 461 } | 456 } |
| 462 | 457 |
| 463 virtual bool shouldUseBrowserOverlays() const | |
| 464 { | |
| 465 return false; | |
| 466 } | |
| 467 | |
| 468 private: | 458 private: |
| 469 // Set when printing. | 459 // Set when printing. |
| 470 WebPluginContainerImpl* m_plugin; | 460 WebPluginContainerImpl* m_plugin; |
| 471 int m_pageCount; | 461 int m_pageCount; |
| 472 WebPrintParams m_printParams; | 462 WebPrintParams m_printParams; |
| 473 | 463 |
| 474 }; | 464 }; |
| 475 | 465 |
| 476 static WebDataSource* DataSourceForDocLoader(DocumentLoader* loader) | 466 static WebDataSource* DataSourceForDocLoader(DocumentLoader* loader) |
| 477 { | 467 { |
| (...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1372 | 1362 |
| 1373 HitTestRequest request = HitTestRequest::Move | HitTestRequest::ReadOnly | H
itTestRequest::Active | HitTestRequest::IgnoreClipping | HitTestRequest::Disallo
wShadowContent; | 1363 HitTestRequest request = HitTestRequest::Move | HitTestRequest::ReadOnly | H
itTestRequest::Active | HitTestRequest::IgnoreClipping | HitTestRequest::Disallo
wShadowContent; |
| 1374 HitTestResult result(frame()->view()->windowToContents(roundedIntPoint(unsca
ledPoint))); | 1364 HitTestResult result(frame()->view()->windowToContents(roundedIntPoint(unsca
ledPoint))); |
| 1375 frame()->document()->renderView()->layer()->hitTest(request, result); | 1365 frame()->document()->renderView()->layer()->hitTest(request, result); |
| 1376 | 1366 |
| 1377 if (Node* node = result.targetNode()) | 1367 if (Node* node = result.targetNode()) |
| 1378 return frame()->selection().selection().visiblePositionRespectingEditing
Boundary(result.localPoint(), node); | 1368 return frame()->selection().selection().visiblePositionRespectingEditing
Boundary(result.localPoint(), node); |
| 1379 return VisiblePosition(); | 1369 return VisiblePosition(); |
| 1380 } | 1370 } |
| 1381 | 1371 |
| 1382 int WebFrameImpl::printBegin(const WebPrintParams& printParams, const WebNode& c
onstrainToNode, bool* useBrowserOverlays) | 1372 int WebFrameImpl::printBegin(const WebPrintParams& printParams, const WebNode& c
onstrainToNode) |
| 1383 { | 1373 { |
| 1384 ASSERT(!frame()->document()->isFrameSet()); | 1374 ASSERT(!frame()->document()->isFrameSet()); |
| 1385 WebPluginContainerImpl* pluginContainer = 0; | 1375 WebPluginContainerImpl* pluginContainer = 0; |
| 1386 if (constrainToNode.isNull()) { | 1376 if (constrainToNode.isNull()) { |
| 1387 // If this is a plugin document, check if the plugin supports its own | 1377 // If this is a plugin document, check if the plugin supports its own |
| 1388 // printing. If it does, we will delegate all printing to that. | 1378 // printing. If it does, we will delegate all printing to that. |
| 1389 pluginContainer = pluginContainerFromFrame(frame()); | 1379 pluginContainer = pluginContainerFromFrame(frame()); |
| 1390 } else { | 1380 } else { |
| 1391 // We only support printing plugin nodes for now. | 1381 // We only support printing plugin nodes for now. |
| 1392 pluginContainer = toPluginContainerImpl(constrainToNode.pluginContainer(
)); | 1382 pluginContainer = toPluginContainerImpl(constrainToNode.pluginContainer(
)); |
| 1393 } | 1383 } |
| 1394 | 1384 |
| 1395 if (pluginContainer && pluginContainer->supportsPaginatedPrint()) | 1385 if (pluginContainer && pluginContainer->supportsPaginatedPrint()) |
| 1396 m_printContext = adoptPtr(new ChromePluginPrintContext(frame(), pluginCo
ntainer, printParams)); | 1386 m_printContext = adoptPtr(new ChromePluginPrintContext(frame(), pluginCo
ntainer, printParams)); |
| 1397 else | 1387 else |
| 1398 m_printContext = adoptPtr(new ChromePrintContext(frame())); | 1388 m_printContext = adoptPtr(new ChromePrintContext(frame())); |
| 1399 | 1389 |
| 1400 FloatRect rect(0, 0, static_cast<float>(printParams.printContentArea.width),
static_cast<float>(printParams.printContentArea.height)); | 1390 FloatRect rect(0, 0, static_cast<float>(printParams.printContentArea.width),
static_cast<float>(printParams.printContentArea.height)); |
| 1401 m_printContext->begin(rect.width(), rect.height()); | 1391 m_printContext->begin(rect.width(), rect.height()); |
| 1402 float pageHeight; | 1392 float pageHeight; |
| 1403 // We ignore the overlays calculation for now since they are generated in th
e | 1393 // We ignore the overlays calculation for now since they are generated in th
e |
| 1404 // browser. pageHeight is actually an output parameter. | 1394 // browser. pageHeight is actually an output parameter. |
| 1405 m_printContext->computePageRects(rect, 0, 0, 1.0, pageHeight); | 1395 m_printContext->computePageRects(rect, 0, 0, 1.0, pageHeight); |
| 1406 if (useBrowserOverlays) | |
| 1407 *useBrowserOverlays = m_printContext->shouldUseBrowserOverlays(); | |
| 1408 | 1396 |
| 1409 return m_printContext->pageCount(); | 1397 return m_printContext->pageCount(); |
| 1410 } | 1398 } |
| 1411 | 1399 |
| 1412 float WebFrameImpl::getPrintPageShrink(int page) | 1400 float WebFrameImpl::getPrintPageShrink(int page) |
| 1413 { | 1401 { |
| 1414 ASSERT(m_printContext && page >= 0); | 1402 ASSERT(m_printContext && page >= 0); |
| 1415 return m_printContext->getPageShrink(page); | 1403 return m_printContext->getPageShrink(page); |
| 1416 } | 1404 } |
| 1417 | 1405 |
| (...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2476 | 2464 |
| 2477 // There is a possibility that the frame being detached was the only | 2465 // There is a possibility that the frame being detached was the only |
| 2478 // pending one. We need to make sure final replies can be sent. | 2466 // pending one. We need to make sure final replies can be sent. |
| 2479 flushCurrentScopingEffort(m_findRequestIdentifier); | 2467 flushCurrentScopingEffort(m_findRequestIdentifier); |
| 2480 | 2468 |
| 2481 cancelPendingScopingEffort(); | 2469 cancelPendingScopingEffort(); |
| 2482 } | 2470 } |
| 2483 } | 2471 } |
| 2484 | 2472 |
| 2485 } // namespace WebKit | 2473 } // namespace WebKit |
| OLD | NEW |