Diff
Modified: branches/safari-536-branch/LayoutTests/ChangeLog (118691 => 118692)
--- branches/safari-536-branch/LayoutTests/ChangeLog 2012-05-28 16:41:23 UTC (rev 118691)
+++ branches/safari-536-branch/LayoutTests/ChangeLog 2012-05-28 16:49:45 UTC (rev 118692)
@@ -1,3 +1,19 @@
+2012-05-28 Lucas Forschler <lforsch...@apple.com>
+
+ Merge 118039
+
+ 2012-05-22 Vitaly Buka <vitalyb...@chromium.org>
+
+ LayoutTest for iframe printing.
+ https://bugs.webkit.org/show_bug.cgi?id=85118
+
+ Reviewed by Darin Adler, Eric Seidel.
+
+ * printing/iframe-print-expected.txt: Added.
+ * printing/iframe-print.html: Added.
+ * printing/resources/iframe-subframe-vertical-rl.html: Added.
+ * printing/resources/iframe-subframe.html: Added.
+
2012-05-24 Stephanie Lewis <sle...@apple.com>
See https://bugs.webkit.org/show_bug.cgi?id=87182
Copied: branches/safari-536-branch/LayoutTests/printing/iframe-print-expected.txt (from rev 118039, trunk/LayoutTests/printing/iframe-print-expected.txt) (0 => 118692)
--- branches/safari-536-branch/LayoutTests/printing/iframe-print-expected.txt (rev 0)
+++ branches/safari-536-branch/LayoutTests/printing/iframe-print-expected.txt 2012-05-28 16:49:45 UTC (rev 118692)
@@ -0,0 +1,38 @@
+layer at (0,0) size 1000x324
+ RenderView at (0,0) size 1000x324
+layer at (0,0) size 1000x324
+ RenderBlock {HTML} at (0,0) size 1000x324
+ RenderBody {BODY} at (8,8) size 984x308
+ RenderPartObject {IFRAME} at (0,200) size 304x104 [border: (2px inset #000000)]
+ layer at (0,0) size 300x100
+ RenderView at (0,0) size 300x100
+ layer at (0,0) size 300x34
+ RenderBlock {HTML} at (0,0) size 300x34
+ RenderBody {BODY} at (8,8) size 284x18
+ RenderText {#text} at (0,0) size 246x18
+ text run at (0,0) width 246: "You should see this text when printed."
+ RenderText {#text} at (304,290) size 4x18
+ text run at (304,290) width 4: " "
+ RenderPartObject {IFRAME} at (308,0) size 304x304 [border: (2px inset #000000)]
+ layer at (0,0) size 300x300
+ RenderView at (0,0) size 300x300
+ layer at (40,0) size 260x300
+ RenderBlock {HTML} at (0,0) size 260x300
+ RenderBody {BODY} at (8,8) size 244x284
+ RenderText {#text} at (0,0) size 18x250
+ text run at (0,0) width 250: "You should see this text when printed. "
+ RenderBR {BR} at (0,249) size 18x1
+ RenderText {#text} at (18,0) size 18x166
+ text run at (18,0) width 166: "Vertical text on the right. "
+ RenderBR {BR} at (18,165) size 18x1
+ RenderPartObject {IFRAME} at (36,0) size 204x154 [border: (2px inset #000000)]
+ layer at (0,0) size 200x150
+ RenderView at (0,0) size 200x150
+ layer at (0,0) size 200x52
+ RenderBlock {HTML} at (0,0) size 200x52
+ RenderBody {BODY} at (8,8) size 184x36
+ RenderText {#text} at (0,0) size 154x36
+ text run at (0,0) width 154: "You should see this text"
+ text run at (0,18) width 88: "when printed."
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (0,0) size 0x0
Copied: branches/safari-536-branch/LayoutTests/printing/iframe-print.html (from rev 118039, trunk/LayoutTests/printing/iframe-print.html) (0 => 118692)
--- branches/safari-536-branch/LayoutTests/printing/iframe-print.html (rev 0)
+++ branches/safari-536-branch/LayoutTests/printing/iframe-print.html 2012-05-28 16:49:45 UTC (rev 118692)
@@ -0,0 +1,10 @@
+<html>
+<script>
+ if (window.layoutTestController)
+ layoutTestController.setPrinting();
+</script>
+<body>
+ <iframe src="" frameborder="1" height="100"></iframe>
+ <iframe src="" frameborder="1" height="300"></iframe>
+</body>
+</html>
Copied: branches/safari-536-branch/LayoutTests/printing/resources/iframe-subframe-vertical-rl.html (from rev 118039, trunk/LayoutTests/printing/resources/iframe-subframe-vertical-rl.html) (0 => 118692)
--- branches/safari-536-branch/LayoutTests/printing/resources/iframe-subframe-vertical-rl.html (rev 0)
+++ branches/safari-536-branch/LayoutTests/printing/resources/iframe-subframe-vertical-rl.html 2012-05-28 16:49:45 UTC (rev 118692)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html style="-webkit-writing-mode:vertical-rl">
+<body>
+You should see this text when printed.
+<br>
+Vertical text on the right.
+<br>
+<iframe src="" frameborder="1" width="200"></iframe>
+</body>
+</html>
Copied: branches/safari-536-branch/LayoutTests/printing/resources/iframe-subframe.html (from rev 118039, trunk/LayoutTests/printing/resources/iframe-subframe.html) (0 => 118692)
--- branches/safari-536-branch/LayoutTests/printing/resources/iframe-subframe.html (rev 0)
+++ branches/safari-536-branch/LayoutTests/printing/resources/iframe-subframe.html 2012-05-28 16:49:45 UTC (rev 118692)
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<body>
+You should see this text when printed.
+</body>
+</html>
Modified: branches/safari-536-branch/Source/WebCore/ChangeLog (118691 => 118692)
--- branches/safari-536-branch/Source/WebCore/ChangeLog 2012-05-28 16:41:23 UTC (rev 118691)
+++ branches/safari-536-branch/Source/WebCore/ChangeLog 2012-05-28 16:49:45 UTC (rev 118692)
@@ -1,3 +1,35 @@
+2012-05-28 Lucas Forschler <lforsch...@apple.com>
+
+ Merge 118039
+
+ 2012-05-22 Vitaly Buka <vitalyb...@chromium.org>
+
+ Fix iframe printing.
+ https://bugs.webkit.org/show_bug.cgi?id=85118
+
+ 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:
+
2012-05-24 Lucas Forschler <lforsch...@apple.com>
Merge 118204
Modified: branches/safari-536-branch/Source/WebCore/page/Frame.cpp (118691 => 118692)
--- branches/safari-536-branch/Source/WebCore/page/Frame.cpp 2012-05-28 16:41:23 UTC (rev 118691)
+++ branches/safari-536-branch/Source/WebCore/page/Frame.cpp 2012-05-28 16:49:45 UTC (rev 118692)
@@ -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/safari-536-branch/Source/WebCore/rendering/RenderView.cpp (118691 => 118692)
--- branches/safari-536-branch/Source/WebCore/rendering/RenderView.cpp 2012-05-28 16:41:23 UTC (rev 118691)
+++ branches/safari-536-branch/Source/WebCore/rendering/RenderView.cpp 2012-05-28 16:49:45 UTC (rev 118692)
@@ -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/safari-536-branch/Source/WebCore/rendering/RenderView.h (118691 => 118692)
--- branches/safari-536-branch/Source/WebCore/rendering/RenderView.h 2012-05-28 16:41:23 UTC (rev 118691)
+++ branches/safari-536-branch/Source/WebCore/rendering/RenderView.h 2012-05-28 16:49:45 UTC (rev 118692)
@@ -266,6 +266,8 @@
OwnPtr<RenderBoxSet> m_fixedPositionedElements;
private:
+ bool shouldUsePrintingLayout() const;
+
unsigned m_pageLogicalHeight;
bool m_pageLogicalHeightChanged;
LayoutState* m_layoutState;