| 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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 float spoolSinglePage(WebCanvas* canvas, int pageNumber) { | 295 float spoolSinglePage(WebCanvas* canvas, int pageNumber) { |
| 296 dispatchEventsForPrintingOnAllFrames(); | 296 dispatchEventsForPrintingOnAllFrames(); |
| 297 if (!frame()->document() || frame()->document()->layoutViewItem().isNull()) | 297 if (!frame()->document() || frame()->document()->layoutViewItem().isNull()) |
| 298 return 0; | 298 return 0; |
| 299 | 299 |
| 300 frame()->view()->updateAllLifecyclePhasesExceptPaint(); | 300 frame()->view()->updateAllLifecyclePhasesExceptPaint(); |
| 301 if (!frame()->document() || frame()->document()->layoutViewItem().isNull()) | 301 if (!frame()->document() || frame()->document()->layoutViewItem().isNull()) |
| 302 return 0; | 302 return 0; |
| 303 | 303 |
| 304 IntRect pageRect = m_pageRects[pageNumber]; | 304 IntRect pageRect = m_pageRects[pageNumber]; |
| 305 SkPictureBuilder pictureBuilder(pageRect, &skia::GetMetaData(*canvas)); | 305 SkPictureBuilder pictureBuilder(pageRect, &canvas->getMetaData()); |
| 306 pictureBuilder.context().setPrinting(true); | 306 pictureBuilder.context().setPrinting(true); |
| 307 | 307 |
| 308 float scale = spoolPage(pictureBuilder, pageNumber); | 308 float scale = spoolPage(pictureBuilder, pageNumber); |
| 309 pictureBuilder.endRecording()->playback(canvas); | 309 pictureBuilder.endRecording()->playback(canvas); |
| 310 return scale; | 310 return scale; |
| 311 } | 311 } |
| 312 | 312 |
| 313 void spoolAllPagesWithBoundaries(WebCanvas* canvas, | 313 void spoolAllPagesWithBoundaries(WebCanvas* canvas, |
| 314 const FloatSize& pageSizeInPixels) { | 314 const FloatSize& pageSizeInPixels) { |
| 315 dispatchEventsForPrintingOnAllFrames(); | 315 dispatchEventsForPrintingOnAllFrames(); |
| 316 if (!frame()->document() || frame()->document()->layoutViewItem().isNull()) | 316 if (!frame()->document() || frame()->document()->layoutViewItem().isNull()) |
| 317 return; | 317 return; |
| 318 | 318 |
| 319 frame()->view()->updateAllLifecyclePhasesExceptPaint(); | 319 frame()->view()->updateAllLifecyclePhasesExceptPaint(); |
| 320 if (!frame()->document() || frame()->document()->layoutViewItem().isNull()) | 320 if (!frame()->document() || frame()->document()->layoutViewItem().isNull()) |
| 321 return; | 321 return; |
| 322 | 322 |
| 323 float pageHeight; | 323 float pageHeight; |
| 324 computePageRects(FloatRect(FloatPoint(0, 0), pageSizeInPixels), 0, 0, 1, | 324 computePageRects(FloatRect(FloatPoint(0, 0), pageSizeInPixels), 0, 0, 1, |
| 325 pageHeight); | 325 pageHeight); |
| 326 | 326 |
| 327 const float pageWidth = pageSizeInPixels.width(); | 327 const float pageWidth = pageSizeInPixels.width(); |
| 328 size_t numPages = pageRects().size(); | 328 size_t numPages = pageRects().size(); |
| 329 int totalHeight = numPages * (pageSizeInPixels.height() + 1) - 1; | 329 int totalHeight = numPages * (pageSizeInPixels.height() + 1) - 1; |
| 330 IntRect allPagesRect(0, 0, pageWidth, totalHeight); | 330 IntRect allPagesRect(0, 0, pageWidth, totalHeight); |
| 331 | 331 |
| 332 SkPictureBuilder pictureBuilder(allPagesRect, &skia::GetMetaData(*canvas)); | 332 SkPictureBuilder pictureBuilder(allPagesRect, &canvas->getMetaData()); |
| 333 pictureBuilder.context().setPrinting(true); | 333 pictureBuilder.context().setPrinting(true); |
| 334 | 334 |
| 335 { | 335 { |
| 336 GraphicsContext& context = pictureBuilder.context(); | 336 GraphicsContext& context = pictureBuilder.context(); |
| 337 DisplayItemCacheSkipper skipper(context); | 337 DisplayItemCacheSkipper skipper(context); |
| 338 | 338 |
| 339 // Fill the whole background by white. | 339 // Fill the whole background by white. |
| 340 { | 340 { |
| 341 DrawingRecorder backgroundRecorder( | 341 DrawingRecorder backgroundRecorder( |
| 342 context, pictureBuilder, DisplayItem::kPrintedContentBackground, | 342 context, pictureBuilder, DisplayItem::kPrintedContentBackground, |
| (...skipping 2067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2410 createMarkup(startPosition, endPosition, AnnotateForInterchange, | 2410 createMarkup(startPosition, endPosition, AnnotateForInterchange, |
| 2411 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); | 2411 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); |
| 2412 } else { | 2412 } else { |
| 2413 clipHtml = | 2413 clipHtml = |
| 2414 createMarkup(endPosition, startPosition, AnnotateForInterchange, | 2414 createMarkup(endPosition, startPosition, AnnotateForInterchange, |
| 2415 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); | 2415 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); |
| 2416 } | 2416 } |
| 2417 } | 2417 } |
| 2418 | 2418 |
| 2419 } // namespace blink | 2419 } // namespace blink |
| OLD | NEW |