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

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

Issue 1172463002: Fix print context to work under slimming paint. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove unnecessary RuntimeEnabledFeatures include. Created 5 years, 6 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 | « Source/core/page/PrintContextTest.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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 frame()->view()->updateLayoutAndStyleForPainting(); 359 frame()->view()->updateLayoutAndStyleForPainting();
360 if (!frame()->document() || !frame()->document()->layoutView()) 360 if (!frame()->document() || !frame()->document()->layoutView())
361 return 0; 361 return 0;
362 362
363 IntRect pageRect = m_pageRects[pageNumber]; 363 IntRect pageRect = m_pageRects[pageNumber];
364 SkPictureBuilder pictureBuilder(pageRect, GraphicsContext::NothingDisabl ed, &skia::getMetaData(*canvas)); 364 SkPictureBuilder pictureBuilder(pageRect, GraphicsContext::NothingDisabl ed, &skia::getMetaData(*canvas));
365 pictureBuilder.context().setPrinting(true); 365 pictureBuilder.context().setPrinting(true);
366 366
367 float scale = spoolPage(pictureBuilder.context(), pageNumber); 367 float scale = spoolPage(pictureBuilder.context(), pageNumber);
368 pictureBuilder.endRecording()->playback(canvas); 368 pictureBuilder.endRecording()->playback(canvas);
369 outputLinkedDestinations(canvas, pageRect);
369 return scale; 370 return scale;
370 } 371 }
371 372
372 void spoolAllPagesWithBoundaries(WebCanvas* canvas, const FloatSize& pageSiz eInPixels) 373 void spoolAllPagesWithBoundaries(WebCanvas* canvas, const FloatSize& pageSiz eInPixels)
373 { 374 {
374 dispatchEventsForPrintingOnAllFrames(); 375 dispatchEventsForPrintingOnAllFrames();
375 if (!frame()->document() || !frame()->document()->layoutView()) 376 if (!frame()->document() || !frame()->document()->layoutView())
376 return; 377 return;
377 378
378 frame()->view()->updateLayoutAndStyleForPainting(); 379 frame()->view()->updateLayoutAndStyleForPainting();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 // of spoolAllPagesWithBoundaries the scale HAS NOT been pre-applied . 422 // of spoolAllPagesWithBoundaries the scale HAS NOT been pre-applied .
422 float scale = getPageShrink(pageIndex); 423 float scale = getPageShrink(pageIndex);
423 transform.scale(scale, scale); 424 transform.scale(scale, scale);
424 #endif 425 #endif
425 TransformRecorder transformRecorder(context, *this, transform); 426 TransformRecorder transformRecorder(context, *this, transform);
426 spoolPage(context, pageIndex); 427 spoolPage(context, pageIndex);
427 428
428 currentHeight += pageSizeInPixels.height() + 1; 429 currentHeight += pageSizeInPixels.height() + 1;
429 } 430 }
430 pictureBuilder.endRecording()->playback(canvas); 431 pictureBuilder.endRecording()->playback(canvas);
432 outputLinkedDestinations(canvas, allPagesRect);
431 } 433 }
432 434
433 DisplayItemClient displayItemClient() const { return toDisplayItemClient(thi s); } 435 DisplayItemClient displayItemClient() const { return toDisplayItemClient(thi s); }
434 436
435 String debugName() const { return "ChromePrintContext"; } 437 String debugName() const { return "ChromePrintContext"; }
436 438
437 protected: 439 protected:
438 // Spools the printed page, a subrect of frame(). Skip the scale step. 440 // Spools the printed page, a subrect of frame(). Skip the scale step.
439 // NativeTheme doesn't play well with scaling. Scaling is done browser side 441 // NativeTheme doesn't play well with scaling. Scaling is done browser side
440 // instead. Returns the scale to be applied. 442 // instead. Returns the scale to be applied.
441 // On Linux, we don't have the problem with NativeTheme, hence we let WebKit 443 // On Linux, we don't have the problem with NativeTheme, hence we let WebKit
442 // do the scaling and ignore the return value. 444 // do the scaling and ignore the return value.
443 virtual float spoolPage(GraphicsContext& context, int pageNumber) 445 virtual float spoolPage(GraphicsContext& context, int pageNumber)
444 { 446 {
445 IntRect pageRect = m_pageRects[pageNumber]; 447 IntRect pageRect = m_pageRects[pageNumber];
446 float scale = m_printedPageWidth / pageRect.width(); 448 float scale = m_printedPageWidth / pageRect.width();
447 449
448 AffineTransform transform; 450 AffineTransform transform;
449 #if OS(POSIX) && !OS(MACOSX) 451 #if OS(POSIX) && !OS(MACOSX)
450 transform.scale(scale); 452 transform.scale(scale);
451 #endif 453 #endif
452 transform.translate(static_cast<float>(-pageRect.x()), static_cast<float >(-pageRect.y())); 454 transform.translate(static_cast<float>(-pageRect.x()), static_cast<float >(-pageRect.y()));
453 TransformRecorder transformRecorder(context, *this, transform); 455 TransformRecorder transformRecorder(context, *this, transform);
454 456
455 ClipRecorder clipRecorder(context, *this, DisplayItem::ClipPrintedPage, LayoutRect(pageRect)); 457 ClipRecorder clipRecorder(context, *this, DisplayItem::ClipPrintedPage, LayoutRect(pageRect));
456 458
457 frame()->view()->paintContents(&context, pageRect); 459 frame()->view()->paintContents(&context, pageRect);
458 460
459 outputLinkedDestinations(context, pageRect);
460
461 return scale; 461 return scale;
462 } 462 }
463 463
464 private: 464 private:
465 void dispatchEventsForPrintingOnAllFrames() 465 void dispatchEventsForPrintingOnAllFrames()
466 { 466 {
467 WillBeHeapVector<RefPtrWillBeMember<Document>> documents; 467 WillBeHeapVector<RefPtrWillBeMember<Document>> documents;
468 for (Frame* currentFrame = frame(); currentFrame; currentFrame = current Frame->tree().traverseNext(frame())) { 468 for (Frame* currentFrame = frame(); currentFrame; currentFrame = current Frame->tree().traverseNext(frame())) {
469 if (currentFrame->isLocalFrame()) 469 if (currentFrame->isLocalFrame())
470 documents.append(toLocalFrame(currentFrame)->document()); 470 documents.append(toLocalFrame(currentFrame)->document());
(...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after
2112 { 2112 {
2113 m_frameWidget = frameWidget; 2113 m_frameWidget = frameWidget;
2114 } 2114 }
2115 2115
2116 WebFrameWidgetImpl* WebLocalFrameImpl::frameWidget() const 2116 WebFrameWidgetImpl* WebLocalFrameImpl::frameWidget() const
2117 { 2117 {
2118 return m_frameWidget; 2118 return m_frameWidget;
2119 } 2119 }
2120 2120
2121 } // namespace blink 2121 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/page/PrintContextTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698