Title: [118243] branches/chromium/1132/Source/WebCore
- Revision
- 118243
- Author
- [email protected]
- Date
- 2012-05-23 14:13:28 -0700 (Wed, 23 May 2012)
Log Message
Merge 118039 - Source/WebCore: Fix iframe printing.
https://bugs.webkit.org/show_bug.cgi?id=85118
Patch by Vitaly Buka <[email protected]> on 2012-05-22
Reviewed by Darin Adler, Eric Seidel.
Patch fixed two issues by disabling special handling of subframes for printing.
1. Regression. Division by zero when forceLayoutForPagination called for subframes
and page sizes set to zero.
2. Old issue. RendererView adjusted layout of subframes for printing and set invalid
dimensions. Sometimes it caused missing iframe when printed.
Test: printing/iframe-print.html
* page/Frame.cpp:
(WebCore::Frame::setPrinting): Calls forceLayoutForPagination for root frames only.
(WebCore::Frame::resizePageRectsKeepingRatio): Added ASSERTs to catch division by zero.
* rendering/RenderView.cpp: Replaced printing() with shouldUsePrintingLayout() for most calls.
(WebCore::RenderView::computeLogicalHeight):
(WebCore::RenderView::computeLogicalWidth):
(WebCore::RenderView::layout):
(WebCore::RenderView::shouldUsePrintingLayout): Returns true only if printing enabled and it's a root frame.
(WebCore::RenderView::viewRect):
(WebCore::RenderView::viewHeight):
(WebCore::RenderView::viewWidth):
* rendering/RenderView.h:
[email protected],[email protected]
Review URL: https://chromiumcodereview.appspot.com/10427008
Modified Paths
Diff
Modified: branches/chromium/1132/Source/WebCore/page/Frame.cpp (118242 => 118243)
--- branches/chromium/1132/Source/WebCore/page/Frame.cpp 2012-05-23 21:02:33 UTC (rev 118242)
+++ branches/chromium/1132/Source/WebCore/page/Frame.cpp 2012-05-23 21:13:28 UTC (rev 118243)
@@ -522,9 +522,10 @@
view()->adjustMediaTypeForPrinting(printing);
m_doc->styleResolverChanged(RecalcStyleImmediately);
- if (printing)
+ if (printing && !tree()->parent()) {
+ // Only root frame should be fit to page size. Subframes should be constrained by parents only.
view()->forceLayoutForPagination(pageSize, originalPageSize, maximumShrinkRatio, shouldAdjustViewSize);
- else {
+ } else {
view()->forceLayout();
if (shouldAdjustViewSize == AdjustViewSize)
view()->adjustViewSize();
@@ -542,10 +543,12 @@
return FloatSize();
if (contentRenderer()->style()->isHorizontalWritingMode()) {
+ ASSERT(fabs(originalSize.width()) > numeric_limits<float>::epsilon());
float ratio = originalSize.height() / originalSize.width();
resultSize.setWidth(floorf(expectedSize.width()));
resultSize.setHeight(floorf(resultSize.width() * ratio));
} else {
+ ASSERT(fabs(originalSize.height()) > numeric_limits<float>::epsilon());
float ratio = originalSize.width() / originalSize.height();
resultSize.setHeight(floorf(expectedSize.height()));
resultSize.setWidth(floorf(resultSize.height() * ratio));
Modified: branches/chromium/1132/Source/WebCore/rendering/RenderView.cpp (118242 => 118243)
--- branches/chromium/1132/Source/WebCore/rendering/RenderView.cpp 2012-05-23 21:02:33 UTC (rev 118242)
+++ branches/chromium/1132/Source/WebCore/rendering/RenderView.cpp 2012-05-23 21:13:28 UTC (rev 118243)
@@ -84,13 +84,13 @@
void RenderView::computeLogicalHeight()
{
- if (!printing() && m_frameView)
+ if (!shouldUsePrintingLayout() && m_frameView)
setLogicalHeight(viewLogicalHeight());
}
void RenderView::computeLogicalWidth()
{
- if (!printing() && m_frameView)
+ if (!shouldUsePrintingLayout() && m_frameView)
setLogicalWidth(viewLogicalWidth());
}
@@ -111,11 +111,11 @@
if (!document()->paginated())
setPageLogicalHeight(0);
- if (printing())
+ if (shouldUsePrintingLayout())
m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = logicalWidth();
// Use calcWidth/Height to get the new width/height, since this will take the full page zoom factor into account.
- bool relayoutChildren = !printing() && (!m_frameView || width() != viewWidth() || height() != viewHeight());
+ bool relayoutChildren = !shouldUsePrintingLayout() && (!m_frameView || width() != viewWidth() || height() != viewHeight());
if (relayoutChildren) {
setChildNeedsLayout(true, MarkOnlyThis);
for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
@@ -647,6 +647,15 @@
return document()->printing();
}
+bool RenderView::shouldUsePrintingLayout() const
+{
+ if (!printing() || !m_frameView)
+ return false;
+ Frame* frame = m_frameView->frame();
+ // Only root frame should have special handling for printing.
+ return frame && !frame->tree()->parent();
+}
+
size_t RenderView::getRetainedWidgets(Vector<RenderWidget*>& renderWidgets)
{
size_t size = m_widgets.size();
@@ -711,7 +720,7 @@
LayoutRect RenderView::viewRect() const
{
- if (printing())
+ if (shouldUsePrintingLayout())
return LayoutRect(LayoutPoint(), size());
if (m_frameView)
return m_frameView->visibleContentRect();
@@ -751,7 +760,7 @@
int RenderView::viewHeight() const
{
int height = 0;
- if (!printing() && m_frameView) {
+ if (!shouldUsePrintingLayout() && m_frameView) {
height = m_frameView->layoutHeight();
height = m_frameView->useFixedLayout() ? ceilf(style()->effectiveZoom() * float(height)) : height;
}
@@ -761,7 +770,7 @@
int RenderView::viewWidth() const
{
int width = 0;
- if (!printing() && m_frameView) {
+ if (!shouldUsePrintingLayout() && m_frameView) {
width = m_frameView->layoutWidth();
width = m_frameView->useFixedLayout() ? ceilf(style()->effectiveZoom() * float(width)) : width;
}
Modified: branches/chromium/1132/Source/WebCore/rendering/RenderView.h (118242 => 118243)
--- branches/chromium/1132/Source/WebCore/rendering/RenderView.h 2012-05-23 21:02:33 UTC (rev 118242)
+++ branches/chromium/1132/Source/WebCore/rendering/RenderView.h 2012-05-23 21:13:28 UTC (rev 118243)
@@ -266,6 +266,8 @@
OwnPtr<RenderBoxSet> m_fixedPositionedElements;
private:
+ bool shouldUsePrintingLayout() const;
+
unsigned m_pageLogicalHeight;
bool m_pageLogicalHeightChanged;
LayoutState* m_layoutState;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes