[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9
hamaji at chromium.org
hamaji at chromium.org
Thu Feb 4 21:36:38 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 25f5f58bbf74ee4876b3b60ccf6fc63ca60d0254
Author: hamaji at chromium.org <hamaji at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Feb 2 11:07:19 2010 +0000
2010-02-02 Shinichiro Hamaji <hamaji at chromium.org>
Reviewed by Eric Seidel.
[Win] Utilize PrintContext to share the printing code with other ports
https://bugs.webkit.org/show_bug.cgi?id=34312
No new tests as this is just a small refactoring.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54221 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 7598626..7a5c77b 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,12 @@
+2010-02-02 Shinichiro Hamaji <hamaji at chromium.org>
+
+ Reviewed by Eric Seidel.
+
+ [Win] Utilize PrintContext to share the printing code with other ports
+ https://bugs.webkit.org/show_bug.cgi?id=34312
+
+ No new tests as this is just a small refactoring.
+
2010-02-02 Kwang Yul Seo <skyul at company100.net>
Reviewed by Eric Seidel.
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index dea1d37..c31de7d 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -20933,6 +20933,14 @@
>
</File>
<File
+ RelativePath="..\page\PrintContext.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\page\PrintContext.h"
+ >
+ </File>
+ <File
RelativePath="..\page\Screen.cpp"
>
</File>
diff --git a/WebCore/page/PrintContext.h b/WebCore/page/PrintContext.h
index a6c2fcb..38b28c4 100644
--- a/WebCore/page/PrintContext.h
+++ b/WebCore/page/PrintContext.h
@@ -39,6 +39,7 @@ public:
int pageCount() const;
const IntRect& pageRect(int pageNumber) const;
+ const Vector<IntRect>& pageRects() const { return m_pageRects; }
void computePageRects(const FloatRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, float& outPageHeight);
diff --git a/WebCore/page/win/FrameWin.cpp b/WebCore/page/win/FrameWin.cpp
index 8440a80..2b5435d 100644
--- a/WebCore/page/win/FrameWin.cpp
+++ b/WebCore/page/win/FrameWin.cpp
@@ -29,64 +29,20 @@
#include "Bridge.h"
#include "Document.h"
#include "FloatRect.h"
+#include "PrintContext.h"
#include "RenderView.h"
#include "Settings.h"
#include "TransformationMatrix.h"
-using std::min;
-
namespace WebCore {
-void computePageRectsForFrame(Frame* frame, const IntRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, Vector<IntRect>& pages, int& outPageHeight)
+void computePageRectsForFrame(Frame* frame, const IntRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, Vector<IntRect>& outPages, int& outPageHeight)
{
- ASSERT(frame);
-
- pages.clear();
- outPageHeight = 0;
-
- if (!frame->document() || !frame->view() || !frame->document()->renderer())
- return;
-
- RenderView* root = toRenderView(frame->document()->renderer());
-
- if (!root) {
- LOG_ERROR("document to be printed has no renderer");
- return;
- }
-
- if (userScaleFactor <= 0) {
- LOG_ERROR("userScaleFactor has bad value %.2f", userScaleFactor);
- return;
- }
-
- float ratio = static_cast<float>(printRect.height()) / static_cast<float>(printRect.width());
-
- float pageWidth = static_cast<float>(root->rightLayoutOverflow());
- float pageHeight = pageWidth * ratio;
- outPageHeight = static_cast<int>(pageHeight); // this is the height of the page adjusted by margins
- pageHeight -= (headerHeight + footerHeight);
-
- if (pageHeight <= 0) {
- LOG_ERROR("pageHeight has bad value %.2f", pageHeight);
- return;
- }
-
- float currPageHeight = pageHeight / userScaleFactor;
- float docHeight = root->layer()->height();
- float docWidth = root->layer()->width();
- float currPageWidth = pageWidth / userScaleFactor;
-
-
- // always return at least one page, since empty files should print a blank page
- float printedPagesHeight = 0.0f;
- do {
- float proposedBottom = min(docHeight, printedPagesHeight + pageHeight);
- frame->view()->adjustPageHeight(&proposedBottom, printedPagesHeight, proposedBottom, printedPagesHeight);
- currPageHeight = max(1.0f, proposedBottom - printedPagesHeight);
-
- pages.append(IntRect(0, printedPagesHeight, currPageWidth, currPageHeight));
- printedPagesHeight += currPageHeight;
- } while (printedPagesHeight < docHeight);
+ PrintContext printContext(frame);
+ float pageHeight = 0;
+ printContext.computePageRects(printRect, headerHeight, footerHeight, userScaleFactor, pageHeight);
+ outPageHeight = static_cast<int>(pageHeight);
+ outPages = printContext.pageRects();
}
DragImageRef Frame::dragImageForSelection()
diff --git a/WebCore/page/win/FrameWin.h b/WebCore/page/win/FrameWin.h
index 9cf9683..4c274b7 100644
--- a/WebCore/page/win/FrameWin.h
+++ b/WebCore/page/win/FrameWin.h
@@ -37,7 +37,7 @@ namespace WebCore {
class IntRect;
HBITMAP imageFromSelection(Frame* frame, bool forceWhiteText);
- void computePageRectsForFrame(Frame*, const IntRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, Vector<IntRect>& pages, int& pageHeight);
+ void computePageRectsForFrame(Frame*, const IntRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, Vector<IntRect>& outPages, int& outPageHeight);
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list