[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:15 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 1db4e112f1490e189fdcc2ccaadb88fe3c54b73d
Author: hamaji at chromium.org <hamaji at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Feb 2 06:28:19 2010 +0000
2010-02-01 Shinichiro Hamaji <hamaji at chromium.org>
Reviewed by Eric Seidel.
Provide a way to get page number with layoutTestController
https://bugs.webkit.org/show_bug.cgi?id=33840
* platform/gtk/Skipped:
* platform/mac/Skipped:
* platform/qt/Skipped:
* platform/win/Skipped:
* printing/page-break-always-expected.txt: Added.
* printing/page-break-always.html: Added.
* printing/pageNumerForElementById-expected.txt: Added.
* printing/pageNumerForElementById.html: Added.
* printing/script-tests/TEMPLATE.html: Added.
* printing/script-tests/page-break-always.js: Added.
(createParagraph):
* printing/script-tests/pageNumerForElementById.js: Added.
(createParagraph):
2010-02-01 Shinichiro Hamaji <hamaji at chromium.org>
Reviewed by Eric Seidel.
Provide a way to get page number with layoutTestController
https://bugs.webkit.org/show_bug.cgi?id=33840
Test: printing/page-break-always.html
* WebCore.base.exp:
* WebCore.xcodeproj/project.pbxproj:
* page/PrintContext.cpp:
(WebCore::PrintContext::pageRect): Added a getter function.
(WebCore::PrintContext::computePageRects): Move its logic into computePageRectsWithPageSize.
(WebCore::PrintContext::computePageRectsWithPageSize): Factored out from computePageRects for pageNumberForElement.
(WebCore::enclosingBoxModelObject): Added for pageNumberForElement.
(WebCore::PrintContext::pageNumberForElement): Added for testing.
* page/PrintContext.h:
2010-02-01 Shinichiro Hamaji <hamaji at chromium.org>
Reviewed by Eric Seidel.
Provide a way to get page number with layoutTestController
https://bugs.webkit.org/show_bug.cgi?id=33840
* Misc/WebCoreStatistics.h:
* Misc/WebCoreStatistics.mm:
(-[WebFrame pageNumberForElement:element:pageWidth:]):
2010-02-01 Shinichiro Hamaji <hamaji at chromium.org>
Reviewed by Eric Seidel.
Provide a way to get page number with layoutTestController
https://bugs.webkit.org/show_bug.cgi?id=33840
* DumpRenderTree/LayoutTestController.cpp:
(pageNumberForElementByIdCallback):
(LayoutTestController::staticFunctions):
* DumpRenderTree/LayoutTestController.h:
* DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
(LayoutTestController::pageNumberForElementById):
* DumpRenderTree/mac/LayoutTestControllerMac.mm:
(LayoutTestController::pageNumberForElementById):
* DumpRenderTree/win/LayoutTestControllerWin.cpp:
(LayoutTestController::pageNumberForElementById):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54205 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 409ff7b..0b3a3a3 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,24 @@
+2010-02-01 Shinichiro Hamaji <hamaji at chromium.org>
+
+ Reviewed by Eric Seidel.
+
+ Provide a way to get page number with layoutTestController
+ https://bugs.webkit.org/show_bug.cgi?id=33840
+
+ * platform/gtk/Skipped:
+ * platform/mac/Skipped:
+ * platform/qt/Skipped:
+ * platform/win/Skipped:
+ * printing/page-break-always-expected.txt: Added.
+ * printing/page-break-always.html: Added.
+ * printing/pageNumerForElementById-expected.txt: Added.
+ * printing/pageNumerForElementById.html: Added.
+ * printing/script-tests/TEMPLATE.html: Added.
+ * printing/script-tests/page-break-always.js: Added.
+ (createParagraph):
+ * printing/script-tests/pageNumerForElementById.js: Added.
+ (createParagraph):
+
2010-02-01 Daniel Bates <dbates at webkit.org>
Reviewed by Adam Barth.
diff --git a/LayoutTests/platform/gtk/Skipped b/LayoutTests/platform/gtk/Skipped
index e9a867b..54800f7 100644
--- a/LayoutTests/platform/gtk/Skipped
+++ b/LayoutTests/platform/gtk/Skipped
@@ -5789,3 +5789,9 @@ fast/dom/Window/window-postmessage-clone-frames.html
# Relies on WebKit API [WebView _loadBackForwardListFromOtherView:]
fast/loader/crash-copying-backforwardlist.html
+# https://bugs.webkit.org/show_bug.cgi?id=34086
+media/video-reverse-play-duration.html
+
+# Implement LayoutTestController::pageNumberForElementById().
+printing/page-break-always.html
+printing/pageNumerForElementById.html
diff --git a/LayoutTests/platform/mac/Skipped b/LayoutTests/platform/mac/Skipped
index 88b0e4b..69d6e0b 100644
--- a/LayoutTests/platform/mac/Skipped
+++ b/LayoutTests/platform/mac/Skipped
@@ -36,7 +36,8 @@ fast/events/attempt-scroll-with-no-scrollbars.html
svg/batik/text/smallFonts.svg
# see bug https://bugs.webkit.org/show_bug.cgi?id=20011 -- Printing tests should use ImageDiff
-printing
+printing/compositing-layer-printing.html
+printing/media-queries-print.html
# Skip because fix for https://bugs.webkit.org/show_bug.cgi?id=26770 was reverted
compositing/animation/animated-composited-inside-hidden.html
diff --git a/LayoutTests/platform/qt/Skipped b/LayoutTests/platform/qt/Skipped
index b691eda..a92d619 100644
--- a/LayoutTests/platform/qt/Skipped
+++ b/LayoutTests/platform/qt/Skipped
@@ -5071,3 +5071,7 @@ css2.1/t1505-c524-font-var-00-b.html
# Relies on WebKit API [WebView _loadBackForwardListFromOtherView:]
fast/loader/crash-copying-backforwardlist.html
+
+# Implement LayoutTestController::pageNumberForElementById().
+printing/page-break-always.html
+printing/pageNumerForElementById.html
diff --git a/LayoutTests/platform/win/Skipped b/LayoutTests/platform/win/Skipped
index 26afc46..2162ccc 100644
--- a/LayoutTests/platform/win/Skipped
+++ b/LayoutTests/platform/win/Skipped
@@ -421,7 +421,8 @@ accessibility/transformed-element.html
accessibility/visible-elements.html
# No support for print-to-pdf in Windows DRT
-printing
+printing/compositing-layer-printing.html
+printing/media-queries-print.html
# No upload progress events on windows
http/tests/xmlhttprequest/upload-onload-event.html
@@ -746,3 +747,7 @@ fast/loader/crash-copying-backforwardlist.html
# Fails on Windows
# https://bugs.webkit.org/show_bug.cgi?id=34447
http/tests/media/video-referer.html
+
+# Implement LayoutTestController::pageNumberForElementById().
+printing/page-break-always.html
+printing/pageNumerForElementById.html
diff --git a/LayoutTests/printing/page-break-always-expected.txt b/LayoutTests/printing/page-break-always-expected.txt
new file mode 100644
index 0000000..791a359
--- /dev/null
+++ b/LayoutTests/printing/page-break-always-expected.txt
@@ -0,0 +1,13 @@
+Test for page-break-before:always and page-break-after:always
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS layoutTestController.pageNumberForElementById('firstPage') is 0
+PASS layoutTestController.pageNumberForElementById('secondPage1') is 1
+PASS layoutTestController.pageNumberForElementById('secondPage2') is 1
+PASS layoutTestController.pageNumberForElementById('thirdPage') is 2
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/printing/page-break-always.html b/LayoutTests/printing/page-break-always.html
new file mode 100644
index 0000000..fcd9aa3
--- /dev/null
+++ b/LayoutTests/printing/page-break-always.html
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<div id="sandbox"></div>
+<script src="script-tests/page-break-always.js"></script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/printing/pageNumerForElementById-expected.txt b/LayoutTests/printing/pageNumerForElementById-expected.txt
new file mode 100644
index 0000000..1a1381b
--- /dev/null
+++ b/LayoutTests/printing/pageNumerForElementById-expected.txt
@@ -0,0 +1,13 @@
+Test for layoutTestController.pageNumberForElementById()
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS layoutTestController.pageNumberForElementById('firstPage', 1000, 1000) is 0
+PASS layoutTestController.pageNumberForElementById('secondPage', 1000, 1000) is 1
+PASS layoutTestController.pageNumberForElementById('thirdPage', 1000, 1000) is 2
+PASS layoutTestController.pageNumberForElementById('thirdPage2', 1000, 1000) is 2
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/printing/pageNumerForElementById.html b/LayoutTests/printing/pageNumerForElementById.html
new file mode 100644
index 0000000..0dae98e
--- /dev/null
+++ b/LayoutTests/printing/pageNumerForElementById.html
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<div id="sandbox"></div>
+<script src="script-tests/pageNumerForElementById.js"></script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/printing/script-tests/TEMPLATE.html b/LayoutTests/printing/script-tests/TEMPLATE.html
new file mode 100644
index 0000000..79caac4
--- /dev/null
+++ b/LayoutTests/printing/script-tests/TEMPLATE.html
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<div id="sandbox"></div>
+<script src="YOUR_JS_FILE_HERE"></script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/printing/script-tests/page-break-always.js b/LayoutTests/printing/script-tests/page-break-always.js
new file mode 100644
index 0000000..1c6e5d8
--- /dev/null
+++ b/LayoutTests/printing/script-tests/page-break-always.js
@@ -0,0 +1,24 @@
+description("Test for page-break-before:always and page-break-after:always");
+
+function createParagraph(id)
+{
+ var element = document.createElement("p");
+ element.id = id;
+ element.appendChild(document.createTextNode("foobar"));
+ document.getElementById("sandbox").appendChild(element);
+ return element;
+}
+
+createParagraph("firstPage");
+createParagraph("secondPage1").style.pageBreakBefore = "always";
+createParagraph("secondPage2").style.pageBreakAfter = "always";
+createParagraph("thirdPage").style.pageBreakBefore = "always";
+
+shouldBe("layoutTestController.pageNumberForElementById('firstPage')", "0");
+shouldBe("layoutTestController.pageNumberForElementById('secondPage1')", "1");
+shouldBe("layoutTestController.pageNumberForElementById('secondPage2')", "1");
+shouldBe("layoutTestController.pageNumberForElementById('thirdPage')", "2");
+
+document.body.removeChild(document.getElementById("sandbox"));
+
+var successfullyParsed = true;
diff --git a/LayoutTests/printing/script-tests/pageNumerForElementById.js b/LayoutTests/printing/script-tests/pageNumerForElementById.js
new file mode 100644
index 0000000..87d88ec
--- /dev/null
+++ b/LayoutTests/printing/script-tests/pageNumerForElementById.js
@@ -0,0 +1,31 @@
+description("Test for layoutTestController.pageNumberForElementById()");
+
+function createParagraph(id)
+{
+ var element = document.createElement("div");
+ element.id = id;
+ element.width = 100;
+ document.getElementById("sandbox").appendChild(element);
+ return element;
+}
+
+var firstPage = createParagraph("firstPage");
+firstPage.style.height = 1000;
+
+var secondPage = createParagraph("secondPage");
+secondPage.style.height = 1000;
+
+var thirdPage = createParagraph("thirdPage");
+thirdPage.style.height = 100;
+
+var thirdPage2 = createParagraph("thirdPage2");
+thirdPage2.style.height = 700;
+
+shouldBe("layoutTestController.pageNumberForElementById('firstPage', 1000, 1000)", "0");
+shouldBe("layoutTestController.pageNumberForElementById('secondPage', 1000, 1000)", "1");
+shouldBe("layoutTestController.pageNumberForElementById('thirdPage', 1000, 1000)", "2");
+shouldBe("layoutTestController.pageNumberForElementById('thirdPage2', 1000, 1000)", "2");
+
+document.body.removeChild(document.getElementById("sandbox"));
+
+var successfullyParsed = true;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 7d4114e..5c63d80 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,22 @@
+2010-02-01 Shinichiro Hamaji <hamaji at chromium.org>
+
+ Reviewed by Eric Seidel.
+
+ Provide a way to get page number with layoutTestController
+ https://bugs.webkit.org/show_bug.cgi?id=33840
+
+ Test: printing/page-break-always.html
+
+ * WebCore.base.exp:
+ * WebCore.xcodeproj/project.pbxproj:
+ * page/PrintContext.cpp:
+ (WebCore::PrintContext::pageRect): Added a getter function.
+ (WebCore::PrintContext::computePageRects): Move its logic into computePageRectsWithPageSize.
+ (WebCore::PrintContext::computePageRectsWithPageSize): Factored out from computePageRects for pageNumberForElement.
+ (WebCore::enclosingBoxModelObject): Added for pageNumberForElement.
+ (WebCore::PrintContext::pageNumberForElement): Added for testing.
+ * page/PrintContext.h:
+
2010-02-01 Kwang Yul Seo <skyul at company100.net>
Reviewed by Eric Seidel.
diff --git a/WebCore/WebCore.base.exp b/WebCore/WebCore.base.exp
index 5b013e7..fbab12e 100644
--- a/WebCore/WebCore.base.exp
+++ b/WebCore/WebCore.base.exp
@@ -249,6 +249,7 @@ __ZN7WebCore12IconDatabase4openERKNS_6StringE
__ZN7WebCore12IconDatabase5closeEv
__ZN7WebCore12IconDatabase9setClientEPNS_18IconDatabaseClientE
__ZN7WebCore12PluginWidget14invalidateRectERKNS_7IntRectE
+__ZN7WebCore12PrintContext20pageNumberForElementEPNS_7ElementERKNS_9FloatSizeE
__ZN7WebCore12RenderObject16repaintRectangleERKNS_7IntRectEb
__ZN7WebCore12RenderWidget19showSubstituteImageEN3WTF10PassRefPtrINS_5ImageEEE
__ZN7WebCore12SchedulePairC1EP9NSRunLoopPK10__CFString
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 6e23a81..fbb8baf 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -4100,6 +4100,8 @@
B5A684240FFABEAA00D24689 /* SQLiteFileSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5A684230FFABEAA00D24689 /* SQLiteFileSystem.cpp */; };
B5C1123B102B6C4600096578 /* SQLTransactionCoordinator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5C11239102B6C4600096578 /* SQLTransactionCoordinator.cpp */; };
B5C1123C102B6C4600096578 /* SQLTransactionCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = B5C1123A102B6C4600096578 /* SQLTransactionCoordinator.h */; };
+ B71FE6DF11091CB300DAEF77 /* PrintContext.h in Headers */ = {isa = PBXBuildFile; fileRef = B776D43A1104525D00BEB0EC /* PrintContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ B776D43D1104527500BEB0EC /* PrintContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B776D43C1104527500BEB0EC /* PrintContext.cpp */; };
BC00F0040E0A185500FD04E3 /* DOMFile.h in Headers */ = {isa = PBXBuildFile; fileRef = BC00EFFE0E0A185500FD04E3 /* DOMFile.h */; };
BC00F0050E0A185500FD04E3 /* DOMFile.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC00EFFF0E0A185500FD04E3 /* DOMFile.mm */; };
BC00F0060E0A185500FD04E3 /* DOMFileInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = BC00F0000E0A185500FD04E3 /* DOMFileInternal.h */; };
@@ -9322,6 +9324,8 @@
B5A684230FFABEAA00D24689 /* SQLiteFileSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SQLiteFileSystem.cpp; path = sql/SQLiteFileSystem.cpp; sourceTree = "<group>"; };
B5C11239102B6C4600096578 /* SQLTransactionCoordinator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SQLTransactionCoordinator.cpp; sourceTree = "<group>"; };
B5C1123A102B6C4600096578 /* SQLTransactionCoordinator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SQLTransactionCoordinator.h; sourceTree = "<group>"; };
+ B776D43A1104525D00BEB0EC /* PrintContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrintContext.h; sourceTree = "<group>"; };
+ B776D43C1104527500BEB0EC /* PrintContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrintContext.cpp; sourceTree = "<group>"; };
BC00EFFE0E0A185500FD04E3 /* DOMFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMFile.h; sourceTree = "<group>"; };
BC00EFFF0E0A185500FD04E3 /* DOMFile.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMFile.mm; sourceTree = "<group>"; };
BC00F0000E0A185500FD04E3 /* DOMFileInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMFileInternal.h; sourceTree = "<group>"; };
@@ -11474,6 +11478,8 @@
FE80D7C00E9C1F25000D6F75 /* PositionError.idl */,
FE80D7C10E9C1F25000D6F75 /* PositionErrorCallback.h */,
FE80D7C30E9C1F25000D6F75 /* PositionOptions.h */,
+ B776D43C1104527500BEB0EC /* PrintContext.cpp */,
+ B776D43A1104525D00BEB0EC /* PrintContext.h */,
BCEC01BA0C274DAC009F4EC9 /* Screen.cpp */,
BCEC01BB0C274DAC009F4EC9 /* Screen.h */,
BCEC01BC0C274DAC009F4EC9 /* Screen.idl */,
@@ -18472,6 +18478,7 @@
E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */,
97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */,
84D0C4061115F1EA0018AA34 /* AffineTransform.h in Headers */,
+ B71FE6DF11091CB300DAEF77 /* PrintContext.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -20647,6 +20654,7 @@
E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */,
97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */,
84D0C4041115F1D40018AA34 /* AffineTransform.cpp in Sources */,
+ B776D43D1104527500BEB0EC /* PrintContext.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/WebCore/page/PrintContext.cpp b/WebCore/page/PrintContext.cpp
index 4d3a839..4c902a9 100644
--- a/WebCore/page/PrintContext.cpp
+++ b/WebCore/page/PrintContext.cpp
@@ -45,6 +45,11 @@ int PrintContext::pageCount() const
return m_pageRects.size();
}
+const IntRect& PrintContext::pageRect(int pageNumber) const
+{
+ return m_pageRects[pageNumber];
+}
+
void PrintContext::computePageRects(const FloatRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, float& outPageHeight)
{
m_pageRects.clear();
@@ -60,11 +65,6 @@ void PrintContext::computePageRects(const FloatRect& printRect, float headerHeig
return;
}
- if (userScaleFactor <= 0) {
- LOG_ERROR("userScaleFactor has bad value %.2f", userScaleFactor);
- return;
- }
-
float ratio = printRect.height() / printRect.width();
float pageWidth = (float)root->rightLayoutOverflow();
@@ -77,14 +77,31 @@ void PrintContext::computePageRects(const FloatRect& printRect, float headerHeig
return;
}
- float currPageHeight = pageHeight / userScaleFactor;
+ computePageRectsWithPageSize(FloatSize(pageWidth, pageHeight), userScaleFactor);
+}
+
+void PrintContext::computePageRectsWithPageSize(const FloatSize& pageSizeInPixels, float userScaleFactor)
+{
+ RenderView* root = toRenderView(m_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 currPageHeight = pageSizeInPixels.height() / userScaleFactor;
float docHeight = root->layer()->height();
- float currPageWidth = pageWidth / userScaleFactor;
+ float currPageWidth = pageSizeInPixels.width() / userScaleFactor;
// always return at least one page, since empty files should print a blank page
- float printedPagesHeight = 0.0;
+ float printedPagesHeight = 0;
do {
- float proposedBottom = std::min(docHeight, printedPagesHeight + pageHeight);
+ float proposedBottom = std::min(docHeight, printedPagesHeight + pageSizeInPixels.height());
m_frame->view()->adjustPageHeight(&proposedBottom, printedPagesHeight, proposedBottom, printedPagesHeight);
currPageHeight = max(1.0f, proposedBottom - printedPagesHeight);
@@ -134,4 +151,40 @@ void PrintContext::end()
m_frame->setPrinting(false, 0, 0, true);
}
+static RenderBoxModelObject* enclosingBoxModelObject(RenderObject* object)
+{
+
+ while (object && !object->isBoxModelObject())
+ object = object->parent();
+ if (!object)
+ return 0;
+ return toRenderBoxModelObject(object);
+}
+
+int PrintContext::pageNumberForElement(Element* element, const FloatSize& pageSizeInPixels)
+{
+ // Make sure the element is not freed during the layout.
+ RefPtr<Element> elementRef(element);
+ element->document()->updateLayout();
+
+ RenderBoxModelObject* box = enclosingBoxModelObject(element->renderer());
+ if (!box)
+ return -1;
+
+ Frame* frame = element->document()->frame();
+ FloatRect pageRect(FloatPoint(0, 0), pageSizeInPixels);
+ PrintContext printContext(frame);
+ printContext.begin(pageRect.width());
+ printContext.computePageRectsWithPageSize(pageSizeInPixels, 1);
+
+ int top = box->offsetTop();
+ int left = box->offsetLeft();
+ for (int pageNumber = 0; pageNumber < printContext.pageCount(); pageNumber++) {
+ const IntRect& page = printContext.pageRect(pageNumber);
+ if (page.x() <= left && left < page.right() && page.y() <= top && top < page.bottom())
+ return pageNumber;
+ }
+ return -1;
+}
+
}
diff --git a/WebCore/page/PrintContext.h b/WebCore/page/PrintContext.h
index 0b3b303..a6c2fcb 100644
--- a/WebCore/page/PrintContext.h
+++ b/WebCore/page/PrintContext.h
@@ -25,8 +25,10 @@
namespace WebCore {
+class Element;
class Frame;
class FloatRect;
+class FloatSize;
class GraphicsContext;
class IntRect;
@@ -36,6 +38,7 @@ public:
~PrintContext();
int pageCount() const;
+ const IntRect& pageRect(int pageNumber) const;
void computePageRects(const FloatRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, float& outPageHeight);
@@ -47,7 +50,12 @@ public:
void end();
+ // Used by layout tests.
+ static int pageNumberForElement(Element*, const FloatSize& pageSizeInPixels);
+
protected:
+ void computePageRectsWithPageSize(const FloatSize& pageSizeInPixels, float userScaleFactor);
+
Frame* m_frame;
Vector<IntRect> m_pageRects;
};
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index c5023f8..8bbd4de 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,14 @@
+2010-02-01 Shinichiro Hamaji <hamaji at chromium.org>
+
+ Reviewed by Eric Seidel.
+
+ Provide a way to get page number with layoutTestController
+ https://bugs.webkit.org/show_bug.cgi?id=33840
+
+ * Misc/WebCoreStatistics.h:
+ * Misc/WebCoreStatistics.mm:
+ (-[WebFrame pageNumberForElement:element:pageWidth:]):
+
2010-01-29 Gavin Barraclough <barraclough at apple.com>
Reviewed by Sam Weinig + Oliver Hunt.
diff --git a/WebKit/mac/Misc/WebCoreStatistics.h b/WebKit/mac/Misc/WebCoreStatistics.h
index 7a189ae..6c45fb9 100644
--- a/WebKit/mac/Misc/WebCoreStatistics.h
+++ b/WebKit/mac/Misc/WebCoreStatistics.h
@@ -84,4 +84,5 @@
@interface WebFrame (WebKitDebug)
- (NSString *)renderTreeAsExternalRepresentation;
- (NSString *)counterValueForElement:(DOMElement*)element;
+- (int)pageNumberForElement:(DOMElement*)element:(float)pageWidthInPixels:(float)pageHeightInPixels;
@end
diff --git a/WebKit/mac/Misc/WebCoreStatistics.mm b/WebKit/mac/Misc/WebCoreStatistics.mm
index f204ddb..b18ee29 100644
--- a/WebKit/mac/Misc/WebCoreStatistics.mm
+++ b/WebKit/mac/Misc/WebCoreStatistics.mm
@@ -40,6 +40,7 @@
#import <WebCore/IconDatabase.h>
#import <WebCore/JSDOMWindow.h>
#import <WebCore/PageCache.h>
+#import <WebCore/PrintContext.h>
#import <WebCore/RenderTreeAsText.h>
#import <WebCore/RenderView.h>
@@ -250,4 +251,9 @@ using namespace WebCore;
return counterValueForElement(core(element));
}
+- (int)pageNumberForElement:(DOMElement*)element:(float)pageWidthInPixels:(float)pageHeightInPixels
+{
+ return PrintContext::pageNumberForElement(core(element), FloatSize(pageWidthInPixels, pageHeightInPixels));
+}
+
@end
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 1e33102..9175eb8 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,5 +1,23 @@
2010-02-01 Shinichiro Hamaji <hamaji at chromium.org>
+ Reviewed by Eric Seidel.
+
+ Provide a way to get page number with layoutTestController
+ https://bugs.webkit.org/show_bug.cgi?id=33840
+
+ * DumpRenderTree/LayoutTestController.cpp:
+ (pageNumberForElementByIdCallback):
+ (LayoutTestController::staticFunctions):
+ * DumpRenderTree/LayoutTestController.h:
+ * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
+ (LayoutTestController::pageNumberForElementById):
+ * DumpRenderTree/mac/LayoutTestControllerMac.mm:
+ (LayoutTestController::pageNumberForElementById):
+ * DumpRenderTree/win/LayoutTestControllerWin.cpp:
+ (LayoutTestController::pageNumberForElementById):
+
+2010-02-01 Shinichiro Hamaji <hamaji at chromium.org>
+
Unreviewed fix for an invalid function call.
check-webkit-style: Remove filename parameter from all functions where no longer used
diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/LayoutTestController.cpp
index 4fba8d0..0537d7c 100644
--- a/WebKitTools/DumpRenderTree/LayoutTestController.cpp
+++ b/WebKitTools/DumpRenderTree/LayoutTestController.cpp
@@ -465,6 +465,36 @@ static JSValueRef notifyDoneCallback(JSContextRef context, JSObjectRef function,
return JSValueMakeUndefined(context);
}
+static JSValueRef pageNumberForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+ // FIXME: These values should sync with maxViewWidth/Height in
+ // DumpRenderTree.mm. Factor these values out to somewhere.
+ float pageWidthInPixels = 800;
+ float pageHeightInPixels = 600;
+ switch (argumentCount) {
+ case 1:
+ break;
+ case 3:
+ pageWidthInPixels = static_cast<float>(JSValueToNumber(context, arguments[1], exception));
+ if (*exception)
+ return JSValueMakeUndefined(context);
+ pageHeightInPixels = static_cast<float>(JSValueToNumber(context, arguments[2], exception));
+ if (*exception)
+ return JSValueMakeUndefined(context);
+ break;
+ default:
+ return JSValueMakeUndefined(context);
+ }
+
+ JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+ if (*exception)
+ return JSValueMakeUndefined(context);
+
+ LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+ int pageNumber = controller->pageNumberForElementById(elementId.get(), pageWidthInPixels, pageHeightInPixels);
+ return JSValueMakeNumber(context, pageNumber);
+}
+
static JSValueRef queueBackNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
// Has mac & windows implementation
@@ -1302,6 +1332,7 @@ JSStaticFunction* LayoutTestController::staticFunctions()
{ "notifyDone", notifyDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "numberOfActiveAnimations", numberOfActiveAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "overridePreference", overridePreferenceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+ { "pageNumberForElementById", pageNumberForElementByIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "pathToLocalResource", pathToLocalResourceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "pauseAnimationAtTimeOnElementWithId", pauseAnimationAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "pauseTransitionAtTimeOnElementWithId", pauseTransitionAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.h b/WebKitTools/DumpRenderTree/LayoutTestController.h
index 00a6ac2..76e7cb3 100644
--- a/WebKitTools/DumpRenderTree/LayoutTestController.h
+++ b/WebKitTools/DumpRenderTree/LayoutTestController.h
@@ -57,6 +57,7 @@ public:
void keepWebHistory();
void notifyDone();
void overridePreference(JSStringRef key, JSStringRef value);
+ int pageNumberForElementById(JSStringRef id, float pageWidthInPixels, float pageHeightInPixels);
JSStringRef pathToLocalResource(JSContextRef, JSStringRef url);
void queueBackNavigation(int howFarBackward);
void queueForwardNavigation(int howFarForward);
diff --git a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
index a74f7ad..bad09fb 100644
--- a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
+++ b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
@@ -140,6 +140,12 @@ void LayoutTestController::keepWebHistory()
// FIXME: implement
}
+int LayoutTestController::pageNumberForElementById(JSStringRef, float, float)
+{
+ // FIXME: implement
+ return -1;
+}
+
size_t LayoutTestController::webHistoryItemCount()
{
// FIXME: implement
diff --git a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
index 5f020fa..67c8c91 100644
--- a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
+++ b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
@@ -176,6 +176,18 @@ void LayoutTestController::keepWebHistory()
}
}
+int LayoutTestController::pageNumberForElementById(JSStringRef id, float pageWidthInPixels, float pageHeightInPixels)
+{
+ RetainPtr<CFStringRef> idCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, id));
+ NSString *idNS = (NSString *)idCF.get();
+
+ DOMElement *element = [[mainFrame DOMDocument] getElementById:idNS];
+ if (!element)
+ return -1;
+
+ return [mainFrame pageNumberForElement:element:pageWidthInPixels:pageHeightInPixels];
+}
+
size_t LayoutTestController::webHistoryItemCount()
{
return [[[WebHistory optionalSharedHistory] allItems] count];
diff --git a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
index b7a63fc..4f5e925 100644
--- a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
+++ b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
@@ -1104,3 +1104,8 @@ JSRetainPtr<JSStringRef> LayoutTestController::counterValueForElementById(JSStri
return counterValueJS;
}
+int LayoutTestController::pageNumberForElementById(JSStringRef, float, float)
+{
+ // FIXME: implement
+ return -1;
+}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list