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

Unified Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 2672983003: Implements PrintBrowser mode. (Closed)
Patch Set: Merge with dependant and fixes Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/frame/FrameView.cpp
diff --git a/third_party/WebKit/Source/core/frame/FrameView.cpp b/third_party/WebKit/Source/core/frame/FrameView.cpp
index 93a42bb40dca6076bc944a1ef652c21933171a5a..e22aff294f003c1e7b72fb7137f19b354251c9f7 100644
--- a/third_party/WebKit/Source/core/frame/FrameView.cpp
+++ b/third_party/WebKit/Source/core/frame/FrameView.cpp
@@ -90,6 +90,7 @@
#include "core/page/FocusController.h"
#include "core/page/FrameTree.h"
#include "core/page/Page.h"
+#include "core/page/PrintContext.h"
#include "core/page/scrolling/RootScrollerUtil.h"
#include "core/page/scrolling/ScrollingCoordinator.h"
#include "core/page/scrolling/TopDocumentRootScrollerController.h"
@@ -234,6 +235,7 @@ DEFINE_TRACE(FrameView) {
visitor->trace(m_scrollAnchor);
visitor->trace(m_anchoringAdjustmentQueue);
visitor->trace(m_scrollbarManager);
+ visitor->trace(m_printContext);
Widget::trace(visitor);
ScrollableArea::trace(visitor);
}
@@ -2886,6 +2888,15 @@ void FrameView::notifyResizeObservers() {
DCHECK(!layoutView()->needsLayout());
}
+void FrameView::dispatchEventsForPrintingOnAllFrames() {
+ DCHECK(m_frame->isMainFrame());
+ for (Frame* currentFrame = m_frame; currentFrame;
+ currentFrame = currentFrame->tree().traverseNext(m_frame)) {
+ if (currentFrame->isLocalFrame())
+ toLocalFrame(currentFrame)->document()->dispatchEventsForPrinting();
+ }
+}
+
// TODO(leviw): We don't assert lifecycle information from documents in child
// PluginViews.
void FrameView::updateLifecyclePhasesInternal(
@@ -2918,6 +2929,24 @@ void FrameView::updateLifecyclePhasesInternal(
return;
}
+ if (RuntimeEnabledFeatures::printBrowserEnabled()) {
+ if (!m_frame->document()->printing()) {
pdr. 2017/02/08 04:28:05 Can you split this logic out into a helper? I thin
gozzard 2017/02/08 05:40:20 Done.
+ if (!m_printContext)
+ m_printContext = new PrintContext(m_frame);
+ if (m_frame->settings())
+ m_frame->settings()->setShouldPrintBackgrounds(true);
+ int pageWidth = 595, pageHeight = 842; // A4 Portrait
pdr. 2017/02/08 04:28:05 Nit: can you break these into constants? Maybe "co
gozzard 2017/02/08 05:40:20 Done.
+ FloatRect pageRect(0, 0, pageWidth, pageHeight);
+ m_printContext->begin(pageRect.width(), pageRect.height());
+ float height;
pdr. 2017/02/08 04:28:05 Do we need to do this print context and page rect
gozzard 2017/02/08 05:40:20 m_printContext->begin() indirectly sets m_frame->d
+ m_printContext->computePageRects(pageRect, 0, 0, 1.0, height);
+ dispatchEventsForPrintingOnAllFrames();
+ }
+ } else if (m_printContext) {
+ m_printContext->end();
+ m_printContext.clear();
+ }
+
updateStyleAndLayoutIfNeededRecursive();
DCHECK(lifecycle().state() >= DocumentLifecycle::LayoutClean);
@@ -2990,7 +3019,8 @@ void FrameView::updateLifecyclePhasesInternal(
DocumentAnimations::updateAnimations(layoutView()->document());
if (targetState == DocumentLifecycle::PaintClean) {
- if (!m_frame->document()->printing())
+ if (!m_frame->document()->printing() ||
+ RuntimeEnabledFeatures::printBrowserEnabled())
paintTree();
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
@@ -3082,6 +3112,8 @@ void FrameView::paintTree() {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
if (layoutView()->layer()->needsRepaint()) {
GraphicsContext graphicsContext(*m_paintController);
+ if (RuntimeEnabledFeatures::printBrowserEnabled())
pdr. 2017/02/08 04:28:05 WDYT about implementing this for both spv2 (as you
gozzard 2017/02/08 05:40:20 I had a look into this and found that it would req
+ graphicsContext.setPrinting(true);
paint(graphicsContext, CullRect(LayoutRect::infiniteIntRect()));
m_paintController->commitNewDisplayItems(LayoutSize());
notifyPaint(*m_paintController);
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameView.h ('k') | third_party/WebKit/Source/core/paint/ObjectPaintInvalidator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698