Title: [101851] trunk
Revision
101851
Author
[email protected]
Date
2011-12-02 14:07:11 -0800 (Fri, 02 Dec 2011)

Log Message

Added helper method to identify whether the page has custom page size style.
https://bugs.webkit.org/show_bug.cgi?id=73585

Patch by Kausalya Madhusudhanan <[email protected]> on 2011-12-02
Reviewed by Darin Fisher.

Source/WebKit/chromium:

* public/WebFrame.h:
* src/WebFrameImpl.cpp:
(WebKit::WebFrameImpl::hasCustomPageSizeStyle):
* src/WebFrameImpl.h:

Tools:

* DumpRenderTree/chromium/LayoutTestController.cpp:
(LayoutTestController::LayoutTestController):
(LayoutTestController::hasCustomPageSizeStyle):
* DumpRenderTree/chromium/LayoutTestController.h:

LayoutTests:

* platform/chromium/printing/custom-page-size-style-expected.txt: Added.
* platform/chromium/printing/custom-page-size-style.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (101850 => 101851)


--- trunk/LayoutTests/ChangeLog	2011-12-02 22:02:58 UTC (rev 101850)
+++ trunk/LayoutTests/ChangeLog	2011-12-02 22:07:11 UTC (rev 101851)
@@ -1,3 +1,13 @@
+2011-12-02  Kausalya Madhusudhanan  <[email protected]>
+
+        Added helper method to identify whether the page has custom page size style.
+        https://bugs.webkit.org/show_bug.cgi?id=73585
+
+        Reviewed by Darin Fisher.
+
+        * platform/chromium/printing/custom-page-size-style-expected.txt: Added.
+        * platform/chromium/printing/custom-page-size-style.html: Added.
+
 2011-12-02  Vincent Scheib  <[email protected]>
 
         [Chromium] Adding flaky tests to test_expectations

Added: trunk/LayoutTests/platform/chromium/printing/custom-page-size-style-expected.txt (0 => 101851)


--- trunk/LayoutTests/platform/chromium/printing/custom-page-size-style-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/printing/custom-page-size-style-expected.txt	2011-12-02 22:07:11 UTC (rev 101851)
@@ -0,0 +1,14 @@
+This tests page custom size style.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Test page size: 10in 10in. Page has custom page size style
+PASS layoutTestController.hasCustomPageSizeStyle(0) is true
+Test page size: auto. Page does not have any custom page size style
+PASS layoutTestController.hasCustomPageSizeStyle(0) is false
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/platform/chromium/printing/custom-page-size-style.html (0 => 101851)


--- trunk/LayoutTests/platform/chromium/printing/custom-page-size-style.html	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/printing/custom-page-size-style.html	2011-12-02 22:07:11 UTC (rev 101851)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head id="head_element">
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+    description("This tests page custom size style.");
+    function appendStyle(styleString)
+    {
+        var styleElement = document.createElement("style");
+        styleElement.innerHTML = styleString;
+        document.getElementById("head_element").appendChild(styleElement);
+    }
+
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+
+        // Page size style tests.
+        debug("Test page size: 10in 10in. Page has custom page size style");
+        appendStyle("@page {size:10in 10in;}");
+        shouldBe("layoutTestController.hasCustomPageSizeStyle(0)", "true");
+
+        debug("Test page size: auto. Page does not have any custom page size style");
+        appendStyle("@page {size:auto;}");
+        shouldBe("layoutTestController.hasCustomPageSizeStyle(0)", "false");
+
+        debug("");
+    } else {
+        testFailed("This test can be run only with window.layoutTestController");
+    }
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebKit/chromium/ChangeLog (101850 => 101851)


--- trunk/Source/WebKit/chromium/ChangeLog	2011-12-02 22:02:58 UTC (rev 101850)
+++ trunk/Source/WebKit/chromium/ChangeLog	2011-12-02 22:07:11 UTC (rev 101851)
@@ -1,3 +1,15 @@
+2011-12-02  Kausalya Madhusudhanan  <[email protected]>
+
+        Added helper method to identify whether the page has custom page size style.
+        https://bugs.webkit.org/show_bug.cgi?id=73585
+
+        Reviewed by Darin Fisher.
+
+        * public/WebFrame.h:
+        * src/WebFrameImpl.cpp:
+        (WebKit::WebFrameImpl::hasCustomPageSizeStyle):
+        * src/WebFrameImpl.h:
+
 2011-12-02  Tony Chang  <[email protected]>
 
         [Chromium] GYP fix for Windows 2010 build

Modified: trunk/Source/WebKit/chromium/public/WebFrame.h (101850 => 101851)


--- trunk/Source/WebKit/chromium/public/WebFrame.h	2011-12-02 22:02:58 UTC (rev 101850)
+++ trunk/Source/WebKit/chromium/public/WebFrame.h	2011-12-02 22:07:11 UTC (rev 101851)
@@ -472,6 +472,9 @@
     // Returns true if page box (margin boxes and page borders) is visible.
     virtual bool isPageBoxVisible(int pageIndex) = 0;
 
+    // Returns true if the page style has custom size information.
+    virtual bool hasCustomPageSizeStyle(int pageIndex) = 0;
+
     // Returns the preferred page size and margins in pixels, assuming 96
     // pixels per inch. pageSize, marginTop, marginRight, marginBottom,
     // marginLeft must be initialized to the default values that are used if

Modified: trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp (101850 => 101851)


--- trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp	2011-12-02 22:02:58 UTC (rev 101850)
+++ trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp	2011-12-02 22:07:11 UTC (rev 101851)
@@ -1476,6 +1476,11 @@
     return pluginContainer->isPrintScalingDisabled();
 }
 
+bool WebFrameImpl::hasCustomPageSizeStyle(int pageIndex)
+{
+    return frame()->document()->styleForPage(pageIndex)->pageSizeType() != PAGE_SIZE_AUTO;
+}
+
 bool WebFrameImpl::isPageBoxVisible(int pageIndex)
 {
     return frame()->document()->isPageBoxVisible(pageIndex);

Modified: trunk/Source/WebKit/chromium/src/WebFrameImpl.h (101850 => 101851)


--- trunk/Source/WebKit/chromium/src/WebFrameImpl.h	2011-12-02 22:02:58 UTC (rev 101850)
+++ trunk/Source/WebKit/chromium/src/WebFrameImpl.h	2011-12-02 22:07:11 UTC (rev 101851)
@@ -172,6 +172,7 @@
     virtual float getPrintPageShrink(int page);
     virtual void printEnd();
     virtual bool isPrintScalingDisabledForPlugin(const WebNode&);
+    virtual bool hasCustomPageSizeStyle(int pageIndex);
     virtual bool isPageBoxVisible(int pageIndex);
     virtual void pageSizeAndMarginsInPixels(int pageIndex,
                                             WebSize& pageSize,

Modified: trunk/Tools/ChangeLog (101850 => 101851)


--- trunk/Tools/ChangeLog	2011-12-02 22:02:58 UTC (rev 101850)
+++ trunk/Tools/ChangeLog	2011-12-02 22:07:11 UTC (rev 101851)
@@ -1,3 +1,15 @@
+2011-12-02  Kausalya Madhusudhanan  <[email protected]>
+
+        Added helper method to identify whether the page has custom page size style.
+        https://bugs.webkit.org/show_bug.cgi?id=73585
+
+        Reviewed by Darin Fisher.
+
+        * DumpRenderTree/chromium/LayoutTestController.cpp:
+        (LayoutTestController::LayoutTestController):
+        (LayoutTestController::hasCustomPageSizeStyle):
+        * DumpRenderTree/chromium/LayoutTestController.h:
+
 2011-12-01  Ryosuke Niwa  <[email protected]>
 
         [NRWT] reftest should support having multiple references per test

Modified: trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp (101850 => 101851)


--- trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp	2011-12-02 22:02:58 UTC (rev 101850)
+++ trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp	2011-12-02 22:07:11 UTC (rev 101851)
@@ -123,6 +123,7 @@
     bindMethod("grantDesktopNotificationPermission", &LayoutTestController::grantDesktopNotificationPermission);
     bindMethod("hasSpellingMarker", &LayoutTestController::hasSpellingMarker);
     bindMethod("isCommandEnabled", &LayoutTestController::isCommandEnabled);
+    bindMethod("hasCustomPageSizeStyle", &LayoutTestController::hasCustomPageSizeStyle);
     bindMethod("isPageBoxVisible", &LayoutTestController::isPageBoxVisible);
     bindMethod("layerTreeAsText", &LayoutTestController::layerTreeAsText);
     bindMethod("loseCompositorContext", &LayoutTestController::loseCompositorContext);
@@ -1704,6 +1705,18 @@
     result->set(resultString.str());
 }
 
+void LayoutTestController::hasCustomPageSizeStyle(const CppArgumentList& arguments, CppVariant* result)
+{
+    result->set(false);
+    int pageIndex = 0;
+    if (!parsePageNumber(arguments, 0, &pageIndex))
+        return;
+    WebFrame* frame = m_shell->webView()->mainFrame();
+    if (!frame)
+        return;
+    result->set(frame->hasCustomPageSizeStyle(pageIndex));
+}
+
 void LayoutTestController::isPageBoxVisible(const CppArgumentList& arguments, CppVariant* result)
 {
     result->setNull();

Modified: trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h (101850 => 101851)


--- trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h	2011-12-02 22:02:58 UTC (rev 101850)
+++ trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h	2011-12-02 22:07:11 UTC (rev 101851)
@@ -337,6 +337,10 @@
     // Gets the page size and margins for a printed page.
     void pageSizeAndMarginsInPixels(const CppArgumentList&, CppVariant*);
 
+    // Returns true if the current page box has custom page size style for
+    // printing.
+    void hasCustomPageSizeStyle(const CppArgumentList&, CppVariant*);
+
     // Returns the visibililty status of a page box for printing
     void isPageBoxVisible(const CppArgumentList&, CppVariant*);
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to