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

Unified Diff: Source/web/WebLocalFrameImpl.cpp

Issue 471623003: WebLocalFrameImpl::printPage needs to ensure layout, style, and compositing are up-to-date (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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
« no previous file with comments | « Source/core/rendering/RenderLayer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebLocalFrameImpl.cpp
diff --git a/Source/web/WebLocalFrameImpl.cpp b/Source/web/WebLocalFrameImpl.cpp
index d3e3ec02014102da058006b84672c72eae57d1bf..8fd551c5782ace2c6569aa82bdef92e2642a8c22 100644
--- a/Source/web/WebLocalFrameImpl.cpp
+++ b/Source/web/WebLocalFrameImpl.cpp
@@ -308,27 +308,12 @@ public:
return m_printedPageWidth / pageRect.width();
}
- // Spools the printed page, a subrect of frame(). Skip the scale step.
- // NativeTheme doesn't play well with scaling. Scaling is done browser side
- // instead. Returns the scale to be applied.
- // On Linux, we don't have the problem with NativeTheme, hence we let WebKit
- // do the scaling and ignore the return value.
- virtual float spoolPage(GraphicsContext& context, int pageNumber)
+ float spoolSinglePage(GraphicsContext& graphicsContext, int pageNumber)
{
- IntRect pageRect = m_pageRects[pageNumber];
- float scale = m_printedPageWidth / pageRect.width();
-
- context.save();
-#if OS(POSIX) && !OS(MACOSX)
- context.scale(scale, scale);
-#endif
- context.translate(static_cast<float>(-pageRect.x()), static_cast<float>(-pageRect.y()));
- context.clip(pageRect);
- frame()->view()->paintContents(&context, pageRect);
- if (context.supportsURLFragments())
- outputLinkedDestinations(context, frame()->document(), pageRect);
- context.restore();
- return scale;
+ // FIXME: Why is it ok to proceed without all the null checks that
+ // spoolAllPagesWithBoundaries does?
+ frame()->view()->updateLayoutAndStyleForPainting();
+ return spoolPage(graphicsContext, pageNumber);
}
void spoolAllPagesWithBoundaries(GraphicsContext& graphicsContext, const FloatSize& pageSizeInPixels)
@@ -376,6 +361,30 @@ public:
}
}
+protected:
+ // Spools the printed page, a subrect of frame(). Skip the scale step.
+ // NativeTheme doesn't play well with scaling. Scaling is done browser side
+ // instead. Returns the scale to be applied.
+ // On Linux, we don't have the problem with NativeTheme, hence we let WebKit
+ // do the scaling and ignore the return value.
+ virtual float spoolPage(GraphicsContext& context, int pageNumber)
+ {
+ IntRect pageRect = m_pageRects[pageNumber];
+ float scale = m_printedPageWidth / pageRect.width();
+
+ context.save();
+#if OS(POSIX) && !OS(MACOSX)
+ context.scale(scale, scale);
+#endif
+ context.translate(static_cast<float>(-pageRect.x()), static_cast<float>(-pageRect.y()));
+ context.clip(pageRect);
+ frame()->view()->paintContents(&context, pageRect);
+ if (context.supportsURLFragments())
+ outputLinkedDestinations(context, frame()->document(), pageRect);
+ context.restore();
+ return scale;
+ }
+
private:
// Set when printing.
float m_printedPageWidth;
@@ -419,6 +428,7 @@ public:
return m_pageCount;
}
+protected:
// Spools the printed page, a subrect of frame(). Skip the scale step.
// NativeTheme doesn't play well with scaling. Scaling is done browser side
// instead. Returns the scale to be applied.
@@ -1287,7 +1297,7 @@ float WebLocalFrameImpl::printPage(int page, WebCanvas* canvas)
GraphicsContext graphicsContext(canvas);
graphicsContext.setPrinting(true);
- return m_printContext->spoolPage(graphicsContext, page);
+ return m_printContext->spoolSinglePage(graphicsContext, page);
#else
return 0;
#endif
« no previous file with comments | « Source/core/rendering/RenderLayer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698