[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
mitz at apple.com
mitz at apple.com
Wed Dec 22 11:37:23 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit aca7dab0fa2dc99a03bf9387e1b7bec04740dcb1
Author: mitz at apple.com <mitz at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sat Jul 31 05:59:02 2010 +0000
<rdar://problem/8257783> Short documents may print a second blank page
https://bugs.webkit.org/show_bug.cgi?id=43271
Reviewed by Darin Adler.
WebCore:
Test: printing/stretch-to-view-height.html
* WebCore.exp.in: Export Frame::forceLayoutForPagination(), replacing forceLayoutWithPageWidthRange().
* page/Frame.cpp:
(WebCore::Frame::setPrinting): Now takes a page width and height and a maximum shrink factor and passes
them down to forceLayoutForPagination().
* page/Frame.h:
(WebCore::Frame::):
* page/FrameView.cpp:
(WebCore::FrameView::reset): Initialize m_pageHeight.
(WebCore::FrameView::forceLayoutForPagination): Renamed forceLayoutWithPageWidthRange() to this and
changed it to take a page width and height and a maximum shrink factor. Sets m_pageHeight, which is
queried by RenderBox::calcHeight() during layout. If the given pageHeight is 0, m_pageHeight is set
to the visible height, retaining the behavior before this change.
* page/FrameView.h:
(WebCore::FrameView::pageHeight): Added this accessor.
* page/PrintContext.cpp:
(WebCore::PrintContext::begin): Added a height parameter, used when calling setPrinting().
(WebCore::PrintContext::end): Updated for setPrinting() changes.
(WebCore::PrintContext::pageNumberForElement): Account for shrink-to-fit.
(WebCore::PrintContext::pageProperty): Pass 0 for the height, retaining current behavior.
(WebCore::PrintContext::numberOfPages): Account for shrink-to-fit.
(WebCore::PrintContext::spoolAllPagesWithBoundaries): Pass the page width to begin().
* page/PrintContext.h:
* rendering/RenderBox.cpp:
(WebCore::RenderBox::calcHeight): When printing, use FrameView::pageHeight() as the basis for
viewport-relative heights.
WebKit/mac:
* WebView/WebHTMLView.mm:
(-[WebHTMLView _web_setPrintingModeRecursive]): Updated for additional height parameter
to _setPrinting:minimumPageWidth:height:maximumPageWidth:adjustViewSize:.
(-[WebHTMLView _web_clearPrintingModeRecursive]): Ditto.
(-[WebHTMLView _web_setPrintingModeRecursiveAndAdjustViewSize]): Ditto.
(-[WebHTMLView _beginPrintModeWithPageWidth:height:shrinkToFit:]): Added height parameter,
which is scaled and passed on to _setPrinting:minimumPageWidth:height:maximumPageWidth:adjustViewSize:.
(-[WebHTMLView _endPrintMode]): Updated for additional height parameter to
_setPrinting:minimumPageWidth:height:maximumPageWidth:adjustViewSize:.
(-[WebHTMLView layoutToMinimumPageWidth:height:maximumPageWidth:adjustingViewSize:]): Added
height parameter, which is passed on to FrameView::forceLayoutForPagination().
(-[WebHTMLView layout]): Updated for additional height parameter.
(-[WebHTMLView _setPrinting:minimumPageWidth:height:maximumPageWidth:adjustViewSize:]): Added height
parameter, which is passed on to -layoutToMinimumPageWidth:height:maximumPageWidth:adjustViewSize:.
(-[WebHTMLView adjustPageHeightNew:top:bottom:limit:]): Updated for additional height
parameter.
(-[WebHTMLView setPageWidthForPrinting:]): Ditto.
(-[WebHTMLView knowsPageRange:]): Pass the available height on the page on to
_setPrinting:minimumPageWidth:height:maximumPageWidth:adjustViewSize.
* WebView/WebHTMLViewPrivate.h:
WebKit/win:
* WebFrame.cpp:
(WebFrame::setPrinting): Updated for changes to Frame::setPrinting(). Passing 0 for the
page height, which maintains existing behavior.
LayoutTests:
* platform/mac/printing/media-queries-print-expected.txt:
* printing/page-break-margin-collapsed-expected.txt:
* printing/resources/paged-media-test-utils.js:
(ratioToPageHeightToPixels): Changed to reflect the default shrink factor of 1.25.
* printing/script-tests/stretch-to-view-height.js: Added.
(test):
* printing/stretch-to-view-height-expected.txt: Added.
* printing/stretch-to-view-height.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64409 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index eeb7fb3..cef55c8 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,19 @@
+2010-07-30 Dan Bernstein <mitz at apple.com>
+
+ Reviewed by Darin Adler.
+
+ <rdar://problem/8257783> Short documents may print a second blank page
+ https://bugs.webkit.org/show_bug.cgi?id=43271
+
+ * platform/mac/printing/media-queries-print-expected.txt:
+ * printing/page-break-margin-collapsed-expected.txt:
+ * printing/resources/paged-media-test-utils.js:
+ (ratioToPageHeightToPixels): Changed to reflect the default shrink factor of 1.25.
+ * printing/script-tests/stretch-to-view-height.js: Added.
+ (test):
+ * printing/stretch-to-view-height-expected.txt: Added.
+ * printing/stretch-to-view-height.html: Added.
+
2010-07-30 Mihai Parparita <mihaip at chromium.org>
Reviewed by Darin Fisher.
diff --git a/LayoutTests/platform/mac/printing/media-queries-print-expected.txt b/LayoutTests/platform/mac/printing/media-queries-print-expected.txt
index c00dd37..5c81bed 100644
--- a/LayoutTests/platform/mac/printing/media-queries-print-expected.txt
+++ b/LayoutTests/platform/mac/printing/media-queries-print-expected.txt
@@ -1,8 +1,8 @@
-layer at (0,0) size 1000x585
- RenderView at (0,0) size 1000x585
-layer at (0,0) size 1000x585
- RenderBlock {HTML} at (0,0) size 1000x585
- RenderBody {BODY} at (8,8) size 984x569
+layer at (0,0) size 1000x600
+ RenderView at (0,0) size 1000x600
+layer at (0,0) size 1000x600
+ RenderBlock {HTML} at (0,0) size 1000x600
+ RenderBody {BODY} at (8,8) size 984x584
RenderBlock {DIV} at (0,0) size 100x100 [bgcolor=#008000]
RenderBlock (anonymous) at (0,100) size 984x18
RenderInline {SPAN} at (0,0) size 533x18
diff --git a/LayoutTests/printing/page-break-margin-collapsed-expected.txt b/LayoutTests/printing/page-break-margin-collapsed-expected.txt
index c1d3e4a..e544c57 100644
--- a/LayoutTests/printing/page-break-margin-collapsed-expected.txt
+++ b/LayoutTests/printing/page-break-margin-collapsed-expected.txt
@@ -5,7 +5,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
PASS: page number of "page1" is 1
-FAIL: expected page number of "page2" is 2. Was 167
+FAIL: expected page number of "page2" is 2. Was 134
PASS successfullyParsed is true
diff --git a/LayoutTests/printing/resources/paged-media-test-utils.js b/LayoutTests/printing/resources/paged-media-test-utils.js
index e34208e..d8061d3 100644
--- a/LayoutTests/printing/resources/paged-media-test-utils.js
+++ b/LayoutTests/printing/resources/paged-media-test-utils.js
@@ -62,7 +62,7 @@ function runPrintingTest(testFunction)
function ratioToPageHeightToPixels(heightInRatioToPageHeight)
{
- var pageHeightInPixels = 600;
+ var pageHeightInPixels = 600 * 1.25;
return Math.floor(pageHeightInPixels * heightInRatioToPageHeight);
}
diff --git a/LayoutTests/printing/script-tests/stretch-to-view-height.js b/LayoutTests/printing/script-tests/stretch-to-view-height.js
new file mode 100644
index 0000000..a5ae898
--- /dev/null
+++ b/LayoutTests/printing/script-tests/stretch-to-view-height.js
@@ -0,0 +1,12 @@
+description("Test that the height of elements whose height depends on the viewport height is computed relative to the page height when printing.");
+
+function test()
+{
+ numberOfPagesShouldBe(1);
+ numberOfPagesShouldBe(1, 1000, 100);
+ numberOfPagesShouldBe(1, 1000, 10000);
+
+ document.body.removeChild(document.getElementById("sandbox"));
+}
+
+var successfullyParsed = true;
diff --git a/LayoutTests/printing/stretch-to-view-height-expected.txt b/LayoutTests/printing/stretch-to-view-height-expected.txt
new file mode 100644
index 0000000..88ec513
--- /dev/null
+++ b/LayoutTests/printing/stretch-to-view-height-expected.txt
@@ -0,0 +1,15 @@
+Test that the height of elements whose height depends on the viewport height is computed relative to the page height when printing.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+PASS: number of pages is 1
+PASS: number of pages is 1
+PASS: number of pages is 1
+All tests passed
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/printing/stretch-to-view-height.html b/LayoutTests/printing/stretch-to-view-height.html
new file mode 100644
index 0000000..02fc4a3
--- /dev/null
+++ b/LayoutTests/printing/stretch-to-view-height.html
@@ -0,0 +1,15 @@
+<html>
+<head>
+<link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
+<script src="../fast/js/resources/js-test-pre.js"></script>
+<script src="resources/paged-media-test-utils.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<div id="sandbox"></div>
+<script src="script-tests/stretch-to-view-height.js"></script>
+<script>runPrintingTest(test);</script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 0f77912..47eb971 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,38 @@
+2010-07-30 Dan Bernstein <mitz at apple.com>
+
+ Reviewed by Darin Adler.
+
+ <rdar://problem/8257783> Short documents may print a second blank page
+ https://bugs.webkit.org/show_bug.cgi?id=43271
+
+ Test: printing/stretch-to-view-height.html
+
+ * WebCore.exp.in: Export Frame::forceLayoutForPagination(), replacing forceLayoutWithPageWidthRange().
+ * page/Frame.cpp:
+ (WebCore::Frame::setPrinting): Now takes a page width and height and a maximum shrink factor and passes
+ them down to forceLayoutForPagination().
+ * page/Frame.h:
+ (WebCore::Frame::):
+ * page/FrameView.cpp:
+ (WebCore::FrameView::reset): Initialize m_pageHeight.
+ (WebCore::FrameView::forceLayoutForPagination): Renamed forceLayoutWithPageWidthRange() to this and
+ changed it to take a page width and height and a maximum shrink factor. Sets m_pageHeight, which is
+ queried by RenderBox::calcHeight() during layout. If the given pageHeight is 0, m_pageHeight is set
+ to the visible height, retaining the behavior before this change.
+ * page/FrameView.h:
+ (WebCore::FrameView::pageHeight): Added this accessor.
+ * page/PrintContext.cpp:
+ (WebCore::PrintContext::begin): Added a height parameter, used when calling setPrinting().
+ (WebCore::PrintContext::end): Updated for setPrinting() changes.
+ (WebCore::PrintContext::pageNumberForElement): Account for shrink-to-fit.
+ (WebCore::PrintContext::pageProperty): Pass 0 for the height, retaining current behavior.
+ (WebCore::PrintContext::numberOfPages): Account for shrink-to-fit.
+ (WebCore::PrintContext::spoolAllPagesWithBoundaries): Pass the page width to begin().
+ * page/PrintContext.h:
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::calcHeight): When printing, use FrameView::pageHeight() as the basis for
+ viewport-relative heights.
+
2010-07-30 Mihai Parparita <mihaip at chromium.org>
Reviewed by Darin Fisher.
diff --git a/WebCore/WebCore.exp.in b/WebCore/WebCore.exp.in
index 0abbcf1..9f33e36 100644
--- a/WebCore/WebCore.exp.in
+++ b/WebCore/WebCore.exp.in
@@ -769,7 +769,7 @@ __ZN7WebCore9FrameView21flushDeferredRepaintsEv
__ZN7WebCore9FrameView22setBaseBackgroundColorENS_5ColorE
__ZN7WebCore9FrameView23layoutIfNeededRecursiveEv
__ZN7WebCore9FrameView23updateCanHaveScrollbarsEv
-__ZN7WebCore9FrameView29forceLayoutWithPageWidthRangeEffb
+__ZN7WebCore9FrameView24forceLayoutForPaginationERKNS_9FloatSizeEfNS_5Frame19AdjustViewSizeOrNotE
__ZN7WebCore9FrameView29setShouldUpdateWhileOffscreenEb
__ZN7WebCore9FrameView29syncCompositingStateRecursiveEv
__ZN7WebCore9FrameView38scrollPositionChangedViaPlatformWidgetEv
diff --git a/WebCore/page/Frame.cpp b/WebCore/page/Frame.cpp
index b419e14..06cddb1 100644
--- a/WebCore/page/Frame.cpp
+++ b/WebCore/page/Frame.cpp
@@ -617,16 +617,16 @@ void Frame::paintDragCaret(GraphicsContext* p, int tx, int ty, const IntRect& cl
#endif
}
-void Frame::setPrinting(bool printing, float minPageWidth, float maxPageWidth, bool adjustViewSize)
+void Frame::setPrinting(bool printing, const FloatSize& pageSize, float maximumShrinkRatio, AdjustViewSizeOrNot shouldAdjustViewSize)
{
m_doc->setPrinting(printing);
view()->adjustMediaTypeForPrinting(printing);
m_doc->updateStyleSelector();
- view()->forceLayoutWithPageWidthRange(minPageWidth, maxPageWidth, adjustViewSize);
+ view()->forceLayoutForPagination(pageSize, maximumShrinkRatio, shouldAdjustViewSize);
for (Frame* child = tree()->firstChild(); child; child = child->tree()->nextSibling())
- child->setPrinting(printing, minPageWidth, maxPageWidth, adjustViewSize);
+ child->setPrinting(printing, pageSize, maximumShrinkRatio, shouldAdjustViewSize);
}
void Frame::setNeedsReapplyStyles()
diff --git a/WebCore/page/Frame.h b/WebCore/page/Frame.h
index c2d364f..4e522c4 100644
--- a/WebCore/page/Frame.h
+++ b/WebCore/page/Frame.h
@@ -140,7 +140,8 @@ namespace WebCore {
Settings* settings() const; // can be NULL
- void setPrinting(bool printing, float minPageWidth, float maxPageWidth, bool adjustViewSize);
+ enum AdjustViewSizeOrNot { DoNotAdjustViewSize, AdjustViewSize };
+ void setPrinting(bool printing, const FloatSize& pageSize, float maximumShrinkRatio, AdjustViewSizeOrNot);
bool inViewSourceMode() const;
void setInViewSourceMode(bool = true);
diff --git a/WebCore/page/FrameView.cpp b/WebCore/page/FrameView.cpp
index 0547c82..88c05db 100644
--- a/WebCore/page/FrameView.cpp
+++ b/WebCore/page/FrameView.cpp
@@ -212,6 +212,7 @@ void FrameView::reset()
m_wasScrolledByUser = false;
m_lastLayoutSize = IntSize();
m_lastZoomFactor = 1.0f;
+ m_pageHeight = 0;
m_deferringRepaints = 0;
m_repaintCount = 0;
m_repaintRects.clear();
@@ -2042,33 +2043,36 @@ void FrameView::forceLayout(bool allowSubtree)
//unscheduleRelayout();
}
-void FrameView::forceLayoutWithPageWidthRange(float minPageWidth, float maxPageWidth, bool _adjustViewSize)
+void FrameView::forceLayoutForPagination(const FloatSize& pageSize, float maximumShrinkFactor, Frame::AdjustViewSizeOrNot shouldAdjustViewSize)
{
// Dumping externalRepresentation(m_frame->renderer()).ascii() is a good trick to see
// the state of things before and after the layout
RenderView *root = toRenderView(m_frame->document()->renderer());
if (root) {
- // This magic is basically copied from khtmlview::print
- int pageW = (int)ceilf(minPageWidth);
+ int pageW = ceilf(pageSize.width());
+ m_pageHeight = pageSize.height() ? pageSize.height() : visibleHeight();
root->setWidth(pageW);
root->setNeedsLayoutAndPrefWidthsRecalc();
forceLayout();
- // If we don't fit in the minimum page width, we'll lay out again. If we don't fit in the
- // maximum page width, we will lay out to the maximum page width and clip extra content.
+ // If we don't fit in the given page width, we'll lay out again. If we don't fit in the
+ // page width when shrunk, we will lay out at maximum shrink and clip extra content.
// FIXME: We are assuming a shrink-to-fit printing implementation. A cropping
// implementation should not do this!
int rightmostPos = root->rightmostPosition();
- if (rightmostPos > minPageWidth) {
- pageW = std::min(rightmostPos, (int)ceilf(maxPageWidth));
+ if (rightmostPos > pageSize.width()) {
+ pageW = std::min<int>(rightmostPos, ceilf(pageSize.width() * maximumShrinkFactor));
+ if (pageSize.height())
+ m_pageHeight = pageW / pageSize.width() * pageSize.height();
root->setWidth(pageW);
root->setNeedsLayoutAndPrefWidthsRecalc();
forceLayout();
}
}
- if (_adjustViewSize)
+ if (shouldAdjustViewSize)
adjustViewSize();
+ m_pageHeight = 0;
}
void FrameView::adjustPageHeight(float *newBottom, float oldTop, float oldBottom, float /*bottomLimit*/)
diff --git a/WebCore/page/FrameView.h b/WebCore/page/FrameView.h
index 718b793..9765c6f 100644
--- a/WebCore/page/FrameView.h
+++ b/WebCore/page/FrameView.h
@@ -199,7 +199,8 @@ public:
void setIsVisuallyNonEmpty() { m_isVisuallyNonEmpty = true; }
void forceLayout(bool allowSubtree = false);
- void forceLayoutWithPageWidthRange(float minPageWidth, float maxPageWidth, bool adjustViewSize);
+ void forceLayoutForPagination(const FloatSize& pageSize, float maximumShrinkFactor, Frame::AdjustViewSizeOrNot);
+ int pageHeight() const { return m_pageHeight; }
void adjustPageHeight(float* newBottom, float oldTop, float oldBottom, float bottomLimit);
@@ -332,6 +333,8 @@ private:
String m_mediaType;
String m_mediaTypeWhenNotPrinting;
+ int m_pageHeight;
+
unsigned m_enqueueEvents;
Vector<ScheduledEvent*> m_scheduledEvents;
diff --git a/WebCore/page/PrintContext.cpp b/WebCore/page/PrintContext.cpp
index 84a4891..c1a3d8b 100644
--- a/WebCore/page/PrintContext.cpp
+++ b/WebCore/page/PrintContext.cpp
@@ -116,7 +116,7 @@ void PrintContext::computePageRectsWithPageSizeInternal(const FloatSize& pageSiz
} while (printedPagesHeight < docHeight);
}
-void PrintContext::begin(float width)
+void PrintContext::begin(float width, float height)
{
ASSERT(!m_isPrinting);
m_isPrinting = true;
@@ -135,11 +135,11 @@ void PrintContext::begin(float width)
const float PrintingMaximumShrinkFactor = 2.0f;
float minLayoutWidth = width * PrintingMinimumShrinkFactor;
- float maxLayoutWidth = width * PrintingMaximumShrinkFactor;
+ float minLayoutHeight = height * PrintingMinimumShrinkFactor;
// FIXME: This will modify the rendering of the on-screen frame.
// Could lead to flicker during printing.
- m_frame->setPrinting(true, minLayoutWidth, maxLayoutWidth, true);
+ m_frame->setPrinting(true, FloatSize(minLayoutWidth, minLayoutHeight), PrintingMaximumShrinkFactor / PrintingMinimumShrinkFactor, Frame::AdjustViewSize);
}
void PrintContext::spoolPage(GraphicsContext& ctx, int pageNumber, float width)
@@ -159,7 +159,7 @@ void PrintContext::end()
{
ASSERT(m_isPrinting);
m_isPrinting = false;
- m_frame->setPrinting(false, 0, 0, true);
+ m_frame->setPrinting(false, FloatSize(), 0, Frame::AdjustViewSize);
}
static RenderBoxModelObject* enclosingBoxModelObject(RenderObject* object)
@@ -185,8 +185,10 @@ int PrintContext::pageNumberForElement(Element* element, const FloatSize& pageSi
Frame* frame = element->document()->frame();
FloatRect pageRect(FloatPoint(0, 0), pageSizeInPixels);
PrintContext printContext(frame);
- printContext.begin(pageRect.width());
- printContext.computePageRectsWithPageSize(pageSizeInPixels, false);
+ printContext.begin(pageRect.width(), pageRect.height());
+ FloatSize scaledPageSize = pageSizeInPixels;
+ scaledPageSize.scale(frame->view()->contentsSize().width() / pageRect.width());
+ printContext.computePageRectsWithPageSize(scaledPageSize, false);
int top = box->offsetTop();
int left = box->offsetLeft();
@@ -243,8 +245,11 @@ int PrintContext::numberOfPages(Frame* frame, const FloatSize& pageSizeInPixels)
FloatRect pageRect(FloatPoint(0, 0), pageSizeInPixels);
PrintContext printContext(frame);
- printContext.begin(pageRect.width());
- printContext.computePageRectsWithPageSize(pageSizeInPixels, false);
+ printContext.begin(pageRect.width(), pageRect.height());
+ // Account for shrink-to-fit.
+ FloatSize scaledPageSize = pageSizeInPixels;
+ scaledPageSize.scale(frame->view()->contentsSize().width() / pageRect.width());
+ printContext.computePageRectsWithPageSize(scaledPageSize, false);
return printContext.pageCount();
}
@@ -256,7 +261,7 @@ void PrintContext::spoolAllPagesWithBoundaries(Frame* frame, GraphicsContext& gr
frame->document()->updateLayout();
PrintContext printContext(frame);
- printContext.begin(pageSizeInPixels.width());
+ printContext.begin(pageSizeInPixels.width(), pageSizeInPixels.height());
float pageHeight;
printContext.computePageRects(FloatRect(FloatPoint(0, 0), pageSizeInPixels), 0, 0, 1, pageHeight);
diff --git a/WebCore/page/PrintContext.h b/WebCore/page/PrintContext.h
index 8492718..ed1cfa4 100644
--- a/WebCore/page/PrintContext.h
+++ b/WebCore/page/PrintContext.h
@@ -46,7 +46,7 @@ public:
void computePageRectsWithPageSize(const FloatSize& pageSizeInPixels, bool allowHorizontalMultiPages);
// TODO: eliminate width param
- void begin(float width);
+ void begin(float width, float height = 0);
// TODO: eliminate width param
void spoolPage(GraphicsContext& ctx, int pageNumber, float width);
diff --git a/WebCore/rendering/RenderBox.cpp b/WebCore/rendering/RenderBox.cpp
index daf94ea..ba29776 100644
--- a/WebCore/rendering/RenderBox.cpp
+++ b/WebCore/rendering/RenderBox.cpp
@@ -1513,7 +1513,7 @@ void RenderBox::calcHeight()
&& (isRoot() || (isBody() && document()->documentElement()->renderer()->style()->height().isPercent()));
if (stretchesToViewHeight() || printingNeedsBaseHeight) {
int margins = collapsedMarginTop() + collapsedMarginBottom();
- int visHeight = document()->printing() ? view()->frameView()->visibleHeight() : view()->viewHeight();
+ int visHeight = document()->printing() ? view()->frameView()->pageHeight() : view()->viewHeight();
if (isRoot())
setHeight(max(height(), visHeight - margins));
else {
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index ab1fec9..87299fd 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,31 @@
+2010-07-30 Dan Bernstein <mitz at apple.com>
+
+ Reviewed by Darin Adler.
+
+ <rdar://problem/8257783> Short documents may print a second blank page
+ https://bugs.webkit.org/show_bug.cgi?id=43271
+
+ * WebView/WebHTMLView.mm:
+ (-[WebHTMLView _web_setPrintingModeRecursive]): Updated for additional height parameter
+ to _setPrinting:minimumPageWidth:height:maximumPageWidth:adjustViewSize:.
+ (-[WebHTMLView _web_clearPrintingModeRecursive]): Ditto.
+ (-[WebHTMLView _web_setPrintingModeRecursiveAndAdjustViewSize]): Ditto.
+ (-[WebHTMLView _beginPrintModeWithPageWidth:height:shrinkToFit:]): Added height parameter,
+ which is scaled and passed on to _setPrinting:minimumPageWidth:height:maximumPageWidth:adjustViewSize:.
+ (-[WebHTMLView _endPrintMode]): Updated for additional height parameter to
+ _setPrinting:minimumPageWidth:height:maximumPageWidth:adjustViewSize:.
+ (-[WebHTMLView layoutToMinimumPageWidth:height:maximumPageWidth:adjustingViewSize:]): Added
+ height parameter, which is passed on to FrameView::forceLayoutForPagination().
+ (-[WebHTMLView layout]): Updated for additional height parameter.
+ (-[WebHTMLView _setPrinting:minimumPageWidth:height:maximumPageWidth:adjustViewSize:]): Added height
+ parameter, which is passed on to -layoutToMinimumPageWidth:height:maximumPageWidth:adjustViewSize:.
+ (-[WebHTMLView adjustPageHeightNew:top:bottom:limit:]): Updated for additional height
+ parameter.
+ (-[WebHTMLView setPageWidthForPrinting:]): Ditto.
+ (-[WebHTMLView knowsPageRange:]): Pass the available height on the page on to
+ _setPrinting:minimumPageWidth:height:maximumPageWidth:adjustViewSize.
+ * WebView/WebHTMLViewPrivate.h:
+
2010-07-30 Joseph Pecoraro <joepeck at webkit.org>
Fix for tests that broke after r64400. Tracking a more
diff --git a/WebKit/mac/WebView/WebHTMLView.mm b/WebKit/mac/WebView/WebHTMLView.mm
index 08c8911..58ce124 100644
--- a/WebKit/mac/WebView/WebHTMLView.mm
+++ b/WebKit/mac/WebView/WebHTMLView.mm
@@ -399,7 +399,7 @@ static CachedResourceClient* promisedDataClient()
#endif
@interface WebHTMLView (WebForwardDeclaration) // FIXME: Put this in a normal category and stop doing the forward declaration trick.
-- (void)_setPrinting:(BOOL)printing minimumPageWidth:(float)minPageWidth maximumPageWidth:(float)maxPageWidth adjustViewSize:(BOOL)adjustViewSize;
+- (void)_setPrinting:(BOOL)printing minimumPageWidth:(float)minPageWidth height:(float)minPageHeight maximumPageWidth:(float)maxPageWidth adjustViewSize:(BOOL)adjustViewSize;
@end
@class NSTextInputContext;
@@ -1040,7 +1040,7 @@ static NSURL* uniqueURLWithRelativePart(NSString *relativePart)
- (void)_web_setPrintingModeRecursive
{
- [self _setPrinting:YES minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:NO];
+ [self _setPrinting:YES minimumPageWidth:0 height:0 maximumPageWidth:0 adjustViewSize:NO];
#ifndef NDEBUG
_private->enumeratingSubviews = YES;
@@ -1052,7 +1052,7 @@ static NSURL* uniqueURLWithRelativePart(NSString *relativePart)
unsigned count = [descendantWebHTMLViews count];
for (unsigned i = 0; i < count; ++i)
- [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:YES minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:NO];
+ [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:YES minimumPageWidth:0 height:0 maximumPageWidth:0 adjustViewSize:NO];
[descendantWebHTMLViews release];
@@ -1063,7 +1063,7 @@ static NSURL* uniqueURLWithRelativePart(NSString *relativePart)
- (void)_web_clearPrintingModeRecursive
{
- [self _setPrinting:NO minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:NO];
+ [self _setPrinting:NO minimumPageWidth:0 height:0 maximumPageWidth:0 adjustViewSize:NO];
#ifndef NDEBUG
_private->enumeratingSubviews = YES;
@@ -1075,7 +1075,7 @@ static NSURL* uniqueURLWithRelativePart(NSString *relativePart)
unsigned count = [descendantWebHTMLViews count];
for (unsigned i = 0; i < count; ++i)
- [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:NO minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:NO];
+ [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:NO minimumPageWidth:0 height:0 maximumPageWidth:0 adjustViewSize:NO];
[descendantWebHTMLViews release];
@@ -1086,7 +1086,7 @@ static NSURL* uniqueURLWithRelativePart(NSString *relativePart)
- (void)_web_setPrintingModeRecursiveAndAdjustViewSize
{
- [self _setPrinting:YES minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:YES];
+ [self _setPrinting:YES minimumPageWidth:0 height:0 maximumPageWidth:0 adjustViewSize:YES];
#ifndef NDEBUG
_private->enumeratingSubviews = YES;
@@ -1098,7 +1098,7 @@ static NSURL* uniqueURLWithRelativePart(NSString *relativePart)
unsigned count = [descendantWebHTMLViews count];
for (unsigned i = 0; i < count; ++i)
- [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:YES minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:YES];
+ [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:YES minimumPageWidth:0 height:0 maximumPageWidth:0 adjustViewSize:YES];
[descendantWebHTMLViews release];
@@ -2230,29 +2230,31 @@ static void _updateMouseoverTimerCallback(CFRunLoopTimerRef timer, void *info)
return _private->printing;
}
-- (BOOL)_beginPrintModeWithPageWidth:(float)pageWidth shrinkToFit:(BOOL)shrinkToFit
+- (BOOL)_beginPrintModeWithPageWidth:(float)pageWidth height:(float)pageHeight shrinkToFit:(BOOL)shrinkToFit
{
Frame* frame = core([self _frame]);
if (!frame)
return NO;
float minLayoutWidth = 0;
+ float minLayoutHeight = 0;
float maxLayoutWidth = 0;
// If we are a frameset just print with the layout we have onscreen, otherwise relayout
// according to the page width.
if (!frame->document() || !frame->document()->isFrameSet()) {
minLayoutWidth = shrinkToFit ? pageWidth * _WebHTMLViewPrintingMinimumShrinkFactor : pageWidth;
+ minLayoutHeight = shrinkToFit ? pageHeight * _WebHTMLViewPrintingMinimumShrinkFactor : pageHeight;
maxLayoutWidth = shrinkToFit ? pageWidth * _WebHTMLViewPrintingMaximumShrinkFactor : pageWidth;
}
- [self _setPrinting:YES minimumPageWidth:minLayoutWidth maximumPageWidth:maxLayoutWidth adjustViewSize:YES];
+ [self _setPrinting:YES minimumPageWidth:minLayoutWidth height:minLayoutHeight maximumPageWidth:maxLayoutWidth adjustViewSize:YES];
return YES;
}
- (void)_endPrintMode
{
- [self _setPrinting:NO minimumPageWidth:0 maximumPageWidth:0 adjustViewSize:YES];
+ [self _setPrinting:NO minimumPageWidth:0 height:0 maximumPageWidth:0 adjustViewSize:YES];
}
- (CGFloat)_adjustedBottomOfPageWithTop:(CGFloat)top bottom:(CGFloat)bottom limit:(CGFloat)bottomLimit
@@ -3104,7 +3106,7 @@ WEBCORE_COMMAND(yankAndSelect)
// Do a layout, but set up a new fixed width for the purposes of doing printing layout.
// minPageWidth==0 implies a non-printing layout
-- (void)layoutToMinimumPageWidth:(float)minPageWidth maximumPageWidth:(float)maxPageWidth adjustingViewSize:(BOOL)adjustViewSize
+- (void)layoutToMinimumPageWidth:(float)minPageWidth height:(float)minPageHeight maximumPageWidth:(float)maxPageWidth adjustingViewSize:(BOOL)adjustViewSize
{
[self reapplyStyles];
@@ -3123,7 +3125,7 @@ WEBCORE_COMMAND(yankAndSelect)
if (FrameView* coreView = coreFrame->view()) {
if (minPageWidth > 0.0)
- coreView->forceLayoutWithPageWidthRange(minPageWidth, maxPageWidth, adjustViewSize);
+ coreView->forceLayoutForPagination(FloatSize(minPageWidth, minPageHeight), maxPageWidth / minPageWidth, adjustViewSize ? Frame::AdjustViewSize : Frame::DoNotAdjustViewSize);
else {
coreView->forceLayout(!adjustViewSize);
if (adjustViewSize)
@@ -3139,7 +3141,7 @@ WEBCORE_COMMAND(yankAndSelect)
- (void)layout
{
- [self layoutToMinimumPageWidth:0.0f maximumPageWidth:0.0f adjustingViewSize:NO];
+ [self layoutToMinimumPageWidth:0 height:0 maximumPageWidth:0 adjustingViewSize:NO];
}
// Deliver mouseup events to the DOM for button 2.
@@ -3820,7 +3822,7 @@ static BOOL isInPasswordField(Frame* coreFrame)
// Does setNeedsDisplay:NO as a side effect when printing is ending.
// pageWidth != 0 implies we will relayout to a new width
-- (void)_setPrinting:(BOOL)printing minimumPageWidth:(float)minPageWidth maximumPageWidth:(float)maxPageWidth adjustViewSize:(BOOL)adjustViewSize
+- (void)_setPrinting:(BOOL)printing minimumPageWidth:(float)minPageWidth height:(float)minPageHeight maximumPageWidth:(float)maxPageWidth adjustViewSize:(BOOL)adjustViewSize
{
WebFrame *frame = [self _frame];
NSArray *subframes = [frame childFrames];
@@ -3830,7 +3832,7 @@ static BOOL isInPasswordField(Frame* coreFrame)
WebFrame *subframe = [subframes objectAtIndex:i];
WebFrameView *frameView = [subframe frameView];
if ([[subframe _dataSource] _isDocumentHTML]) {
- [(WebHTMLView *)[frameView documentView] _setPrinting:printing minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:adjustViewSize];
+ [(WebHTMLView *)[frameView documentView] _setPrinting:printing minimumPageWidth:0 height:0 maximumPageWidth:0 adjustViewSize:adjustViewSize];
}
}
@@ -3842,7 +3844,7 @@ static BOOL isInPasswordField(Frame* coreFrame)
_private->avoidingPrintOrphan = NO;
[self setNeedsToApplyStyles:YES];
[self setNeedsLayout:YES];
- [self layoutToMinimumPageWidth:minPageWidth maximumPageWidth:maxPageWidth adjustingViewSize:adjustViewSize];
+ [self layoutToMinimumPageWidth:minPageWidth height:minPageHeight maximumPageWidth:maxPageWidth adjustingViewSize:adjustViewSize];
if (!printing) {
// Can't do this when starting printing or nested printing won't work, see 3491427.
[self setNeedsDisplay:NO];
@@ -3863,7 +3865,7 @@ static BOOL isInPasswordField(Frame* coreFrame)
// If the WebHTMLView itself is what we're printing, then we will never have to do this.
BOOL wasInPrintingMode = _private->printing;
if (!wasInPrintingMode)
- [self _setPrinting:YES minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:NO];
+ [self _setPrinting:YES minimumPageWidth:0 height:0 maximumPageWidth:0 adjustViewSize:NO];
*newBottom = [self _adjustedBottomOfPageWithTop:oldTop bottom:oldBottom limit:bottomLimit];
@@ -3874,7 +3876,7 @@ static BOOL isInPasswordField(Frame* coreFrame)
[self performSelector:@selector(_delayedEndPrintMode:) withObject:currenPrintOperation afterDelay:0];
else
// not sure if this is actually ever invoked, it probably shouldn't be
- [self _setPrinting:NO minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:NO];
+ [self _setPrinting:NO minimumPageWidth:0 height:0 maximumPageWidth:0 adjustViewSize:NO];
}
}
@@ -3904,8 +3906,8 @@ static BOOL isInPasswordField(Frame* coreFrame)
// This is used for Carbon printing. At some point we might want to make this public API.
- (void)setPageWidthForPrinting:(float)pageWidth
{
- [self _setPrinting:NO minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:NO];
- [self _setPrinting:YES minimumPageWidth:pageWidth maximumPageWidth:pageWidth adjustViewSize:YES];
+ [self _setPrinting:NO minimumPageWidth:0 height:0 maximumPageWidth:0 adjustViewSize:NO];
+ [self _setPrinting:YES minimumPageWidth:pageWidth height:0 maximumPageWidth:pageWidth adjustViewSize:YES];
}
- (void)_endPrintModeAndRestoreWindowAutodisplay
@@ -3948,8 +3950,9 @@ static BOOL isInPasswordField(Frame* coreFrame)
[self displayIfNeeded];
[[self window] setAutodisplay:NO];
+ [[self _webView] _adjustPrintingMarginsForHeaderAndFooter];
NSPrintOperation *printOperation = [NSPrintOperation currentOperation];
- if (![self _beginPrintModeWithPageWidth:[printOperation _web_availablePaperWidth] shrinkToFit:YES])
+ if (![self _beginPrintModeWithPageWidth:[printOperation _web_availablePaperWidth] height:[printOperation _web_availablePaperHeight] shrinkToFit:YES])
return NO;
// Certain types of errors, including invalid page ranges, can cause beginDocument and
@@ -3959,7 +3962,6 @@ static BOOL isInPasswordField(Frame* coreFrame)
// If not cancelled, this delayed call will be invoked in the next pass through the main event loop,
// which is after beginDocument and endDocument would be called.
[self performSelector:@selector(_delayedEndPrintMode:) withObject:printOperation afterDelay:0];
- [[self _webView] _adjustPrintingMarginsForHeaderAndFooter];
// There is a theoretical chance that someone could do some drawing between here and endDocument,
// if something caused setNeedsDisplay after this point. If so, it's not a big tragedy, because
diff --git a/WebKit/mac/WebView/WebHTMLViewPrivate.h b/WebKit/mac/WebView/WebHTMLViewPrivate.h
index 3beb0d6..c2ca3fe 100644
--- a/WebKit/mac/WebView/WebHTMLViewPrivate.h
+++ b/WebKit/mac/WebView/WebHTMLViewPrivate.h
@@ -135,7 +135,7 @@ extern const float _WebHTMLViewPrintingMaximumShrinkFactor;
- (void)_layoutForPrinting;
- (WebCGFloat)_adjustedBottomOfPageWithTop:(WebCGFloat)top bottom:(WebCGFloat)bottom limit:(WebCGFloat)bottomLimit;
- (BOOL)_isInPrintMode;
-- (BOOL)_beginPrintModeWithPageWidth:(float)pageWidth shrinkToFit:(BOOL)shrinkToFit;
+- (BOOL)_beginPrintModeWithPageWidth:(float)pageWidth height:(float)pageHeight shrinkToFit:(BOOL)shrinkToFit;
- (void)_endPrintMode;
- (BOOL)_canSmartReplaceWithPasteboard:(NSPasteboard *)pasteboard;
diff --git a/WebKit/win/ChangeLog b/WebKit/win/ChangeLog
index 3606bde..0719e49 100644
--- a/WebKit/win/ChangeLog
+++ b/WebKit/win/ChangeLog
@@ -1,3 +1,14 @@
+2010-07-30 Dan Bernstein <mitz at apple.com>
+
+ Reviewed by Darin Adler.
+
+ <rdar://problem/8257783> Short documents may print a second blank page
+ https://bugs.webkit.org/show_bug.cgi?id=43271
+
+ * WebFrame.cpp:
+ (WebFrame::setPrinting): Updated for changes to Frame::setPrinting(). Passing 0 for the
+ page height, which maintains existing behavior.
+
2010-07-30 Joseph Pecoraro <joepeck at webkit.org>
Reviewed by David Kilzer.
diff --git a/WebKit/win/WebFrame.cpp b/WebKit/win/WebFrame.cpp
index 5705f1e..492da2d 100644
--- a/WebKit/win/WebFrame.cpp
+++ b/WebKit/win/WebFrame.cpp
@@ -1939,7 +1939,7 @@ void WebFrame::setPrinting(bool printing, float minPageWidth, float maxPageWidth
{
Frame* coreFrame = core(this);
ASSERT(coreFrame);
- coreFrame->setPrinting(printing, minPageWidth, maxPageWidth, adjustViewSize);
+ coreFrame->setPrinting(printing, FloatSize(minPageWidth, 0), maxPageWidth / minPageWidth, adjustViewSize ? Frame::AdjustViewSize : Frame:DoNotAdjustViewSize);
}
HRESULT STDMETHODCALLTYPE WebFrame::setInPrintingMode(
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list