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

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

Issue 2791043002: Draw recorded content directly into the containing PaintCanvas, when possible. (Closed)
Patch Set: none Created 3 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/web/PageWidgetDelegate.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 PaintRecordBuilder builder(allPagesRect, &canvas->getMetaData()); 332 PaintRecordBuilder builder(allPagesRect, &canvas->getMetaData());
333 { 333 GraphicsContext& context = builder.context();
334 GraphicsContext& context = builder.context(); 334 context.setPrinting(true);
335 context.setPrinting(true); 335 context.beginRecording(allPagesRect);
336 context.beginRecording(allPagesRect);
337 336
338 // Fill the whole background by white. 337 // Fill the whole background by white.
339 context.fillRect(FloatRect(0, 0, pageWidth, totalHeight), Color::white); 338 context.fillRect(FloatRect(0, 0, pageWidth, totalHeight), Color::white);
340 339
341 int currentHeight = 0; 340 int currentHeight = 0;
342 for (size_t pageIndex = 0; pageIndex < numPages; pageIndex++) { 341 for (size_t pageIndex = 0; pageIndex < numPages; pageIndex++) {
343 // Draw a line for a page boundary if this isn't the first page. 342 // Draw a line for a page boundary if this isn't the first page.
344 if (pageIndex > 0) { 343 if (pageIndex > 0) {
345 context.save(); 344 context.save();
346 context.setStrokeColor(Color(0, 0, 255)); 345 context.setStrokeColor(Color(0, 0, 255));
347 context.setFillColor(Color(0, 0, 255)); 346 context.setFillColor(Color(0, 0, 255));
348 context.drawLine(IntPoint(0, currentHeight), 347 context.drawLine(IntPoint(0, currentHeight),
349 IntPoint(pageWidth, currentHeight)); 348 IntPoint(pageWidth, currentHeight));
350 context.restore(); 349 context.restore();
351 } 350 }
352 351
353 AffineTransform transform; 352 AffineTransform transform;
354 transform.translate(0, currentHeight); 353 transform.translate(0, currentHeight);
355 #if OS(WIN) || OS(MACOSX) 354 #if OS(WIN) || OS(MACOSX)
356 // Account for the disabling of scaling in spoolPage. In the context 355 // Account for the disabling of scaling in spoolPage. In the context
357 // of spoolAllPagesWithBoundaries the scale HAS NOT been pre-applied. 356 // of spoolAllPagesWithBoundaries the scale HAS NOT been pre-applied.
358 float scale = getPageShrink(pageIndex); 357 float scale = getPageShrink(pageIndex);
359 transform.scale(scale, scale); 358 transform.scale(scale, scale);
360 #endif 359 #endif
361 context.save(); 360 context.save();
362 context.concatCTM(transform); 361 context.concatCTM(transform);
363 362
364 spoolPage(context, pageIndex, allPagesRect); 363 spoolPage(context, pageIndex, allPagesRect);
365 364
366 context.restore(); 365 context.restore();
367 366
368 currentHeight += pageSizeInPixels.height() + 1; 367 currentHeight += pageSizeInPixels.height() + 1;
369 }
370 canvas->PlaybackPaintRecord(context.endRecording());
371 } 368 }
369 canvas->PlaybackPaintRecord(context.endRecording());
372 } 370 }
373 371
374 protected: 372 protected:
375 // Spools the printed page, a subrect of frame(). Skip the scale step. 373 // Spools the printed page, a subrect of frame(). Skip the scale step.
376 // NativeTheme doesn't play well with scaling. Scaling is done browser side 374 // NativeTheme doesn't play well with scaling. Scaling is done browser side
377 // instead. Returns the scale to be applied. 375 // instead. Returns the scale to be applied.
378 // On Linux, we don't have the problem with NativeTheme, hence we let WebKit 376 // On Linux, we don't have the problem with NativeTheme, hence we let WebKit
379 // do the scaling and ignore the return value. 377 // do the scaling and ignore the return value.
380 virtual float spoolPage(GraphicsContext& context, 378 virtual float spoolPage(GraphicsContext& context,
381 int pageNumber, 379 int pageNumber,
(...skipping 2134 matching lines...) Expand 10 before | Expand all | Expand 10 after
2516 createMarkup(startPosition, endPosition, AnnotateForInterchange, 2514 createMarkup(startPosition, endPosition, AnnotateForInterchange,
2517 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); 2515 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs);
2518 } else { 2516 } else {
2519 clipHtml = 2517 clipHtml =
2520 createMarkup(endPosition, startPosition, AnnotateForInterchange, 2518 createMarkup(endPosition, startPosition, AnnotateForInterchange,
2521 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); 2519 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs);
2522 } 2520 }
2523 } 2521 }
2524 2522
2525 } // namespace blink 2523 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/PageWidgetDelegate.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698