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