| 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 #include "public/web/WebInputElement.h" | 201 #include "public/web/WebInputElement.h" |
| 202 #include "public/web/WebNode.h" | 202 #include "public/web/WebNode.h" |
| 203 #include "public/web/WebPerformance.h" | 203 #include "public/web/WebPerformance.h" |
| 204 #include "public/web/WebPlugin.h" | 204 #include "public/web/WebPlugin.h" |
| 205 #include "public/web/WebPrintParams.h" | 205 #include "public/web/WebPrintParams.h" |
| 206 #include "public/web/WebPrintPresetOptions.h" | 206 #include "public/web/WebPrintPresetOptions.h" |
| 207 #include "public/web/WebRange.h" | 207 #include "public/web/WebRange.h" |
| 208 #include "public/web/WebScriptSource.h" | 208 #include "public/web/WebScriptSource.h" |
| 209 #include "public/web/WebSerializedScriptValue.h" | 209 #include "public/web/WebSerializedScriptValue.h" |
| 210 #include "public/web/WebTreeScopeType.h" | 210 #include "public/web/WebTreeScopeType.h" |
| 211 #include "skia/ext/platform_device.h" |
| 211 #include "web/AssociatedURLLoader.h" | 212 #include "web/AssociatedURLLoader.h" |
| 212 #include "web/CompositionUnderlineVectorBuilder.h" | 213 #include "web/CompositionUnderlineVectorBuilder.h" |
| 213 #include "web/FindInPageCoordinates.h" | 214 #include "web/FindInPageCoordinates.h" |
| 214 #include "web/GeolocationClientProxy.h" | 215 #include "web/GeolocationClientProxy.h" |
| 215 #include "web/InspectorOverlayImpl.h" | 216 #include "web/InspectorOverlayImpl.h" |
| 216 #include "web/LocalFileSystemClient.h" | 217 #include "web/LocalFileSystemClient.h" |
| 217 #include "web/MIDIClientProxy.h" | 218 #include "web/MIDIClientProxy.h" |
| 218 #include "web/NotificationPermissionClientImpl.h" | 219 #include "web/NotificationPermissionClientImpl.h" |
| 219 #include "web/PageOverlay.h" | 220 #include "web/PageOverlay.h" |
| 220 #include "web/RemoteBridgeFrameOwner.h" | 221 #include "web/RemoteBridgeFrameOwner.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 { | 354 { |
| 354 dispatchEventsForPrintingOnAllFrames(); | 355 dispatchEventsForPrintingOnAllFrames(); |
| 355 if (!frame()->document() || !frame()->document()->layoutView()) | 356 if (!frame()->document() || !frame()->document()->layoutView()) |
| 356 return 0; | 357 return 0; |
| 357 | 358 |
| 358 frame()->view()->updateLayoutAndStyleForPainting(); | 359 frame()->view()->updateLayoutAndStyleForPainting(); |
| 359 if (!frame()->document() || !frame()->document()->layoutView()) | 360 if (!frame()->document() || !frame()->document()->layoutView()) |
| 360 return 0; | 361 return 0; |
| 361 | 362 |
| 362 IntRect pageRect = m_pageRects[pageNumber]; | 363 IntRect pageRect = m_pageRects[pageNumber]; |
| 363 SkPictureBuilder pictureBuilder(pageRect); | 364 SkPictureBuilder pictureBuilder(pageRect, GraphicsContext::NothingDisabl
ed, &skia::getMetaData(*canvas)); |
| 365 pictureBuilder.context().setPrinting(true); |
| 364 | 366 |
| 365 float scale = spoolPage(pictureBuilder.context(), pageNumber); | 367 float scale = spoolPage(pictureBuilder.context(), pageNumber); |
| 366 pictureBuilder.endRecording()->playback(canvas); | 368 pictureBuilder.endRecording()->playback(canvas); |
| 367 return scale; | 369 return scale; |
| 368 } | 370 } |
| 369 | 371 |
| 370 void spoolAllPagesWithBoundaries(WebCanvas* canvas, const FloatSize& pageSiz
eInPixels) | 372 void spoolAllPagesWithBoundaries(WebCanvas* canvas, const FloatSize& pageSiz
eInPixels) |
| 371 { | 373 { |
| 372 dispatchEventsForPrintingOnAllFrames(); | 374 dispatchEventsForPrintingOnAllFrames(); |
| 373 if (!frame()->document() || !frame()->document()->layoutView()) | 375 if (!frame()->document() || !frame()->document()->layoutView()) |
| 374 return; | 376 return; |
| 375 | 377 |
| 376 frame()->view()->updateLayoutAndStyleForPainting(); | 378 frame()->view()->updateLayoutAndStyleForPainting(); |
| 377 if (!frame()->document() || !frame()->document()->layoutView()) | 379 if (!frame()->document() || !frame()->document()->layoutView()) |
| 378 return; | 380 return; |
| 379 | 381 |
| 380 float pageHeight; | 382 float pageHeight; |
| 381 computePageRects(FloatRect(FloatPoint(0, 0), pageSizeInPixels), 0, 0, 1,
pageHeight); | 383 computePageRects(FloatRect(FloatPoint(0, 0), pageSizeInPixels), 0, 0, 1,
pageHeight); |
| 382 | 384 |
| 383 const float pageWidth = pageSizeInPixels.width(); | 385 const float pageWidth = pageSizeInPixels.width(); |
| 384 size_t numPages = pageRects().size(); | 386 size_t numPages = pageRects().size(); |
| 385 int totalHeight = numPages * (pageSizeInPixels.height() + 1) - 1; | 387 int totalHeight = numPages * (pageSizeInPixels.height() + 1) - 1; |
| 386 IntRect allPagesRect(0, 0, pageWidth, totalHeight); | 388 IntRect allPagesRect(0, 0, pageWidth, totalHeight); |
| 387 | 389 |
| 388 SkPictureBuilder pictureBuilder(allPagesRect); | 390 SkPictureBuilder pictureBuilder(allPagesRect, GraphicsContext::NothingDi
sabled, &skia::getMetaData(*canvas)); |
| 391 pictureBuilder.context().setPrinting(true); |
| 392 |
| 389 GraphicsContext& context = pictureBuilder.context(); | 393 GraphicsContext& context = pictureBuilder.context(); |
| 390 | 394 |
| 391 // Fill the whole background by white. | 395 // Fill the whole background by white. |
| 392 { | 396 { |
| 393 DrawingRecorder backgroundRecorder(context, *this, DisplayItem::Prin
tedContentBackground, allPagesRect); | 397 DrawingRecorder backgroundRecorder(context, *this, DisplayItem::Prin
tedContentBackground, allPagesRect); |
| 394 if (!backgroundRecorder.canUseCachedDrawing()) | 398 if (!backgroundRecorder.canUseCachedDrawing()) |
| 395 context.fillRect(FloatRect(0, 0, pageWidth, totalHeight), Color:
:white); | 399 context.fillRect(FloatRect(0, 0, pageWidth, totalHeight), Color:
:white); |
| 396 } | 400 } |
| 397 | 401 |
| 398 int currentHeight = 0; | 402 int currentHeight = 0; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 // Spools the printed page, a subrect of frame(). Skip the scale step. | 438 // Spools the printed page, a subrect of frame(). Skip the scale step. |
| 435 // NativeTheme doesn't play well with scaling. Scaling is done browser side | 439 // NativeTheme doesn't play well with scaling. Scaling is done browser side |
| 436 // instead. Returns the scale to be applied. | 440 // instead. Returns the scale to be applied. |
| 437 // On Linux, we don't have the problem with NativeTheme, hence we let WebKit | 441 // On Linux, we don't have the problem with NativeTheme, hence we let WebKit |
| 438 // do the scaling and ignore the return value. | 442 // do the scaling and ignore the return value. |
| 439 virtual float spoolPage(GraphicsContext& context, int pageNumber) | 443 virtual float spoolPage(GraphicsContext& context, int pageNumber) |
| 440 { | 444 { |
| 441 IntRect pageRect = m_pageRects[pageNumber]; | 445 IntRect pageRect = m_pageRects[pageNumber]; |
| 442 float scale = m_printedPageWidth / pageRect.width(); | 446 float scale = m_printedPageWidth / pageRect.width(); |
| 443 | 447 |
| 444 context.setPrinting(true); | |
| 445 | |
| 446 AffineTransform transform; | 448 AffineTransform transform; |
| 447 #if OS(POSIX) && !OS(MACOSX) | 449 #if OS(POSIX) && !OS(MACOSX) |
| 448 transform.scale(scale); | 450 transform.scale(scale); |
| 449 #endif | 451 #endif |
| 450 transform.translate(static_cast<float>(-pageRect.x()), static_cast<float
>(-pageRect.y())); | 452 transform.translate(static_cast<float>(-pageRect.x()), static_cast<float
>(-pageRect.y())); |
| 451 TransformRecorder transformRecorder(context, *this, transform); | 453 TransformRecorder transformRecorder(context, *this, transform); |
| 452 | 454 |
| 453 ClipRecorder clipRecorder(context, *this, DisplayItem::ClipPrintedPage,
LayoutRect(pageRect)); | 455 ClipRecorder clipRecorder(context, *this, DisplayItem::ClipPrintedPage,
LayoutRect(pageRect)); |
| 454 | 456 |
| 455 frame()->view()->paintContents(&context, pageRect); | 457 frame()->view()->paintContents(&context, pageRect); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 { | 515 { |
| 514 ASSERT_NOT_REACHED(); | 516 ASSERT_NOT_REACHED(); |
| 515 } | 517 } |
| 516 | 518 |
| 517 protected: | 519 protected: |
| 518 // Spools the printed page, a subrect of frame(). Skip the scale step. | 520 // Spools the printed page, a subrect of frame(). Skip the scale step. |
| 519 // NativeTheme doesn't play well with scaling. Scaling is done browser side | 521 // NativeTheme doesn't play well with scaling. Scaling is done browser side |
| 520 // instead. Returns the scale to be applied. | 522 // instead. Returns the scale to be applied. |
| 521 virtual float spoolPage(GraphicsContext& context, int pageNumber) override | 523 virtual float spoolPage(GraphicsContext& context, int pageNumber) override |
| 522 { | 524 { |
| 523 m_plugin->printPage(pageNumber, &context); | 525 IntRect pageRect = m_pageRects[pageNumber]; |
| 526 m_plugin->printPage(pageNumber, &context, pageRect); |
| 527 |
| 524 return 1.0; | 528 return 1.0; |
| 525 } | 529 } |
| 526 | 530 |
| 527 private: | 531 private: |
| 528 // Set when printing. | 532 // Set when printing. |
| 529 WebPluginContainerImpl* m_plugin; | 533 WebPluginContainerImpl* m_plugin; |
| 530 WebPrintParams m_printParams; | 534 WebPrintParams m_printParams; |
| 531 }; | 535 }; |
| 532 | 536 |
| 533 static WebDataSource* DataSourceForDocLoader(DocumentLoader* loader) | 537 static WebDataSource* DataSourceForDocLoader(DocumentLoader* loader) |
| (...skipping 1574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2108 { | 2112 { |
| 2109 m_frameWidget = frameWidget; | 2113 m_frameWidget = frameWidget; |
| 2110 } | 2114 } |
| 2111 | 2115 |
| 2112 WebFrameWidgetImpl* WebLocalFrameImpl::frameWidget() const | 2116 WebFrameWidgetImpl* WebLocalFrameImpl::frameWidget() const |
| 2113 { | 2117 { |
| 2114 return m_frameWidget; | 2118 return m_frameWidget; |
| 2115 } | 2119 } |
| 2116 | 2120 |
| 2117 } // namespace blink | 2121 } // namespace blink |
| OLD | NEW |