Title: [100040] trunk
Revision
100040
Author
[email protected]
Date
2011-11-11 15:52:09 -0800 (Fri, 11 Nov 2011)

Log Message

[Chromium] DRT does not have LayoutTestController.pageSizeAndMarginsInPixels
https://bugs.webkit.org/show_bug.cgi?id=49257

Source/WebKit/chromium:

Add the WebFrame::getPageProperty method for Chromium.

Patch by Stephen Chenney <[email protected]> on 2011-11-11
Reviewed by Darin Fisher.

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

Tools:

Adds the remaining missing layout test functionality for printing.

Patch by Stephen Chenney <[email protected]> on 2011-11-11
Reviewed by Darin Fisher.

* DumpRenderTree/chromium/LayoutTestController.cpp:
(LayoutTestController::LayoutTestController): Add bindings for new JS methods
(parsePageNumber): Method to parse JS arguments for a page number
(parsePageNumberSizeMargins): Method to parse JS arguments for page size and margins
(LayoutTestController::pageSizeAndMarginsInPixels): Get the page size and margins for a given page.
(LayoutTestController::isPageBoxVisible): get the visibility status for printing
(LayoutTestController::pageProperty): get a specific CSS property when in printing mode
* DumpRenderTree/chromium/LayoutTestController.h: Add declarations for new methods

LayoutTests:

Patch by Stephen Chenney <[email protected]> on 2011-11-11
Reviewed by Darin Fisher.

* platform/chromium/test_expectations.txt: Removed expected fails for
printing tests that were using missing functionality in LayoutTestController.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (100039 => 100040)


--- trunk/LayoutTests/ChangeLog	2011-11-11 23:50:19 UTC (rev 100039)
+++ trunk/LayoutTests/ChangeLog	2011-11-11 23:52:09 UTC (rev 100040)
@@ -1,3 +1,13 @@
+2011-11-11  Stephen Chenney  <[email protected]>
+
+        [Chromium] DRT does not have LayoutTestController.pageSizeAndMarginsInPixels
+        https://bugs.webkit.org/show_bug.cgi?id=49257
+
+        Reviewed by Darin Fisher.
+
+        * platform/chromium/test_expectations.txt: Removed expected fails for
+        printing tests that were using missing functionality in LayoutTestController.
+
 2011-11-11  Joel Webber  <[email protected]>
 
         Repaint broken when children of filtered SVG elements are updated

Modified: trunk/LayoutTests/platform/chromium/test_expectations.txt (100039 => 100040)


--- trunk/LayoutTests/platform/chromium/test_expectations.txt	2011-11-11 23:50:19 UTC (rev 100039)
+++ trunk/LayoutTests/platform/chromium/test_expectations.txt	2011-11-11 23:52:09 UTC (rev 100040)
@@ -2061,9 +2061,6 @@
 BUGCR46603 SKIP DEBUG : fast/frames/lots-of-iframes.html = TIMEOUT
 BUGCR46603 SKIP DEBUG : fast/frames/lots-of-objects.html = TIMEOUT
 
-// LayoutTestController::pageProperty is not implemented for Chromium yet.
-BUGWK35961 : printing/page-rule-selection.html = TEXT
-
 BUGCR47035 WIN DEBUG : fast/loader/stateobjects/document-destroyed-navigate-back-with-fragment-scroll.html = PASS TEXT
 
 // CSS3 Hyphenation landed in http://trac.webkit.org/changeset/61548
@@ -2079,9 +2076,6 @@
 // WebKit roll 61547:61629. Still need to investigate.
 BUG_HCLAM : fast/js/script-line-number.html = TEXT
 
-// LayoutTestController::isPageBoxVisible, pageAreaRectInPixels, and preferredPageSizeInPixels are not implemented yet for Chromium.
-BUGWK37538 : printing/page-format-data.html = TEXT
-
 // First noticed on trybots after r61836, now in the tree.
 BUG_MNAGANOV LINUX : fast/js/Object-create.html = CRASH FAIL
 
@@ -2428,9 +2422,6 @@
 // Added in WK r71424
 BUGCR62138 : animations/stop-animation-on-suspend.html = PASS CRASH TEXT
 
-// test_shell and DRT do not have LayoutTestController.pageSizeAndMarginsInPixels
-BUGCR62515 : printing/page-format-data-display-none.html = TEXT
-
 BUGCR61739 DEBUG : animations/suspend-resume-animation-events.html = PASS CRASH TEXT
 
 // New tests added with http://trac.webkit.org/changeset/72472 and further.

Modified: trunk/Source/WebKit/chromium/ChangeLog (100039 => 100040)


--- trunk/Source/WebKit/chromium/ChangeLog	2011-11-11 23:50:19 UTC (rev 100039)
+++ trunk/Source/WebKit/chromium/ChangeLog	2011-11-11 23:52:09 UTC (rev 100040)
@@ -1,3 +1,17 @@
+2011-11-11  Stephen Chenney  <[email protected]>
+
+        [Chromium] DRT does not have LayoutTestController.pageSizeAndMarginsInPixels
+        https://bugs.webkit.org/show_bug.cgi?id=49257
+
+        Add the WebFrame::getPageProperty method for Chromium.
+
+        Reviewed by Darin Fisher.
+
+        * public/WebFrame.h:
+        * src/WebFrameImpl.cpp:
+        (WebKit::WebFrameImpl::getPageProperty):
+        * src/WebFrameImpl.h:
+
 2011-11-11  Jeff Timanus  <[email protected]>
 
         [chromium] Patch that implementing the changes required to allow WebGL

Modified: trunk/Source/WebKit/chromium/public/WebFrame.h (100039 => 100040)


--- trunk/Source/WebKit/chromium/public/WebFrame.h	2011-11-11 23:50:19 UTC (rev 100039)
+++ trunk/Source/WebKit/chromium/public/WebFrame.h	2011-11-11 23:52:09 UTC (rev 100040)
@@ -479,6 +479,10 @@
                                             int& marginBottom,
                                             int& marginLeft) = 0;
 
+    // Returns the value for a page property that is only defined when printing.
+    // printBegin must have been called before this method.
+    virtual WebString pageProperty(const WebString& propertyName, int pageIndex) = 0;
+
     // Find-in-page --------------------------------------------------------
 
     // Searches a frame for a given string.

Modified: trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp (100039 => 100040)


--- trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp	2011-11-11 23:50:19 UTC (rev 100039)
+++ trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp	2011-11-11 23:52:09 UTC (rev 100040)
@@ -1492,6 +1492,12 @@
     pageSize = size;
 }
 
+WebString WebFrameImpl::pageProperty(const WebString& propertyName, int pageIndex)
+{
+    ASSERT(m_printContext);
+    return m_printContext->pageProperty(m_frame, propertyName.utf8().data(), pageIndex);
+}
+
 bool WebFrameImpl::find(int identifier,
                         const WebString& searchText,
                         const WebFindOptions& options,

Modified: trunk/Source/WebKit/chromium/src/WebFrameImpl.h (100039 => 100040)


--- trunk/Source/WebKit/chromium/src/WebFrameImpl.h	2011-11-11 23:50:19 UTC (rev 100039)
+++ trunk/Source/WebKit/chromium/src/WebFrameImpl.h	2011-11-11 23:52:09 UTC (rev 100040)
@@ -178,6 +178,7 @@
                                             int& marginRight,
                                             int& marginBottom,
                                             int& marginLeft);
+    virtual WebString pageProperty(const WebString& propertyName, int pageIndex);
     virtual void printPagesWithBoundaries(WebCanvas*, const WebSize&);
     virtual bool find(
         int identifier, const WebString& searchText, const WebFindOptions&,

Modified: trunk/Tools/ChangeLog (100039 => 100040)


--- trunk/Tools/ChangeLog	2011-11-11 23:50:19 UTC (rev 100039)
+++ trunk/Tools/ChangeLog	2011-11-11 23:52:09 UTC (rev 100040)
@@ -1,3 +1,21 @@
+2011-11-11  Stephen Chenney  <[email protected]>
+
+        [Chromium] DRT does not have LayoutTestController.pageSizeAndMarginsInPixels
+        https://bugs.webkit.org/show_bug.cgi?id=49257
+
+        Adds the remaining missing layout test functionality for printing.
+
+        Reviewed by Darin Fisher.
+
+        * DumpRenderTree/chromium/LayoutTestController.cpp:
+        (LayoutTestController::LayoutTestController): Add bindings for new JS methods
+        (parsePageNumber): Method to parse JS arguments for a page number
+        (parsePageNumberSizeMargins): Method to parse JS arguments for page size and margins
+        (LayoutTestController::pageSizeAndMarginsInPixels): Get the page size and margins for a given page.
+        (LayoutTestController::isPageBoxVisible): get the visibility status for printing
+        (LayoutTestController::pageProperty): get a specific CSS property when in printing mode
+        * DumpRenderTree/chromium/LayoutTestController.h: Add declarations for new methods
+
 2011-11-11  Darin Adler  <[email protected]>
 
         Remove all releaseRef implementations except for RetainPtr

Modified: trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp (100039 => 100040)


--- trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp	2011-11-11 23:50:19 UTC (rev 100039)
+++ trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp	2011-11-11 23:52:09 UTC (rev 100040)
@@ -63,6 +63,7 @@
 #include <clocale>
 #include <cstdlib>
 #include <limits>
+#include <sstream>
 #include <wtf/text/WTFString.h>
 
 #if OS(WINDOWS)
@@ -122,6 +123,7 @@
     bindMethod("grantDesktopNotificationPermission", &LayoutTestController::grantDesktopNotificationPermission);
     bindMethod("hasSpellingMarker", &LayoutTestController::hasSpellingMarker);
     bindMethod("isCommandEnabled", &LayoutTestController::isCommandEnabled);
+    bindMethod("isPageBoxVisible", &LayoutTestController::isPageBoxVisible);
     bindMethod("layerTreeAsText", &LayoutTestController::layerTreeAsText);
     bindMethod("loseCompositorContext", &LayoutTestController::loseCompositorContext);
     bindMethod("markerTextForListItem", &LayoutTestController::markerTextForListItem);
@@ -132,6 +134,8 @@
     bindMethod("objCIdentityIsEqual", &LayoutTestController::objCIdentityIsEqual);
     bindMethod("overridePreference", &LayoutTestController::overridePreference);
     bindMethod("pageNumberForElementById", &LayoutTestController::pageNumberForElementById);
+    bindMethod("pageProperty", &LayoutTestController::pageProperty);
+    bindMethod("pageSizeAndMarginsInPixels", &LayoutTestController::pageSizeAndMarginsInPixels);
     bindMethod("pathToLocalResource", &LayoutTestController::pathToLocalResource);
     bindMethod("pauseAnimationAtTimeOnElementWithId", &LayoutTestController::pauseAnimationAtTimeOnElementWithId);
     bindMethod("pauseTransitionAtTimeOnElementWithId", &LayoutTestController::pauseTransitionAtTimeOnElementWithId);
@@ -1591,6 +1595,22 @@
     result->set(counterValue.utf8());
 }
 
+// Parse a single argument. The method returns true if there is an argument that
+// is a number or if there is no argument at all. It returns false only if there
+// is some argument that is not a number. The value parameter is filled with the
+// parsed number, or given the default if there is no argument.
+static bool parseCppArgumentInt32(const CppArgumentList& arguments, int argIndex, int* value, int defaultValue)
+{
+    if (static_cast<int>(arguments.size()) > argIndex) {
+        if (!arguments[argIndex].isNumber())
+            return false;
+        *value = arguments[argIndex].toInt32();
+        return true;
+    }
+    *value = defaultValue;
+    return true;
+}
+
 static bool parsePageSizeParameters(const CppArgumentList& arguments,
                                     int argOffset,
                                     int* pageWidthInPixels,
@@ -1598,24 +1618,43 @@
 {
     // WebKit is using the window width/height of DumpRenderTree as the
     // default value of the page size.
-    // FIXME: share these values with other ports.
-    *pageWidthInPixels = 800;
-    *pageHeightInPixels = 600;
-    switch (arguments.size() - argOffset) {
-    case 2:
-        if (!arguments[argOffset].isNumber() || !arguments[1 + argOffset].isNumber())
-            return false;
-        *pageWidthInPixels = arguments[argOffset].toInt32();
-        *pageHeightInPixels = arguments[1 + argOffset].toInt32();
-        // fall through.
-    case 0:
-        break;
-    default:
+    // FIXME: share the default values with other ports.
+    int argCount = static_cast<int>(arguments.size()) - argOffset;
+    if (argCount && argCount != 2)
         return false;
-    }
+    if (!parseCppArgumentInt32(arguments, argOffset, pageWidthInPixels, 800)
+        || !parseCppArgumentInt32(arguments, argOffset + 1, pageHeightInPixels, 600))
+        return false;
     return true;
 }
 
+static bool parsePageNumber(const CppArgumentList& arguments, int argOffset, int* pageNumber)
+{
+    if (static_cast<int>(arguments.size()) > argOffset + 1)
+        return false;
+    if (!parseCppArgumentInt32(arguments, argOffset, pageNumber, 0))
+        return false;
+    return true;
+}
+
+static bool parsePageNumberSizeMargins(const CppArgumentList& arguments, int argOffset,
+                                       int* pageNumber, int* width, int* height,
+                                       int* marginTop, int* marginRight, int* marginBottom, int* marginLeft)
+{
+    int argCount = static_cast<int>(arguments.size()) - argOffset;
+    if (argCount && argCount != 7)
+        return false;
+    if (!parseCppArgumentInt32(arguments, argOffset, pageNumber, 0)
+        || !parseCppArgumentInt32(arguments, argOffset + 1, width, 0)
+        || !parseCppArgumentInt32(arguments, argOffset + 2, height, 0)
+        || !parseCppArgumentInt32(arguments, argOffset + 3, marginTop, 0)
+        || !parseCppArgumentInt32(arguments, argOffset + 4, marginRight, 0)
+        || !parseCppArgumentInt32(arguments, argOffset + 5, marginBottom, 0)
+        || !parseCppArgumentInt32(arguments, argOffset + 6, marginLeft, 0))
+        return false;
+    return true;
+}
+
 void LayoutTestController::setPrinting(const CppArgumentList& arguments, CppVariant* result)
 {
     setIsPrinting(true);
@@ -1640,6 +1679,60 @@
                                                 static_cast<float>(pageHeightInPixels)));
 }
 
+void LayoutTestController::pageSizeAndMarginsInPixels(const CppArgumentList& arguments, CppVariant* result)
+{
+    result->set("");
+    int pageNumber = 0;
+    int width = 0;
+    int height = 0;
+    int marginTop = 0;
+    int marginRight = 0;
+    int marginBottom = 0;
+    int marginLeft = 0;
+    if (!parsePageNumberSizeMargins(arguments, 0, &pageNumber, &width, &height, &marginTop, &marginRight, &marginBottom,
+                                    &marginLeft))
+        return;
+
+    WebFrame* frame = m_shell->webView()->mainFrame();
+    if (!frame)
+        return;
+    WebSize pageSize(width, height);
+    frame->pageSizeAndMarginsInPixels(pageNumber, pageSize, marginTop, marginRight, marginBottom, marginLeft);
+    stringstream resultString;
+    resultString << "(" << pageSize.width << ", " << pageSize.height << ") " << marginTop << " " << marginRight << " "
+                 << marginBottom << " " << marginLeft;
+    result->set(resultString.str());
+}
+
+void LayoutTestController::isPageBoxVisible(const CppArgumentList& arguments, CppVariant* result)
+{
+    result->setNull();
+    int pageNumber = 0;
+    if (!parsePageNumber(arguments, 0, &pageNumber))
+        return;
+    WebFrame* frame = m_shell->webView()->mainFrame();
+    if (!frame)
+        return;
+    result->set(frame->isPageBoxVisible(pageNumber));
+}
+
+void LayoutTestController::pageProperty(const CppArgumentList& arguments, CppVariant* result)
+{
+    result->set("");
+    int pageNumber = 0;
+    if (!parsePageNumber(arguments, 1, &pageNumber))
+        return;
+    if (!arguments[0].isString())
+        return;
+    WebFrame* frame = m_shell->webView()->mainFrame();
+    if (!frame)
+        return;
+    WebSize pageSize(800, 800);
+    frame->printBegin(pageSize);
+    result->set(frame->pageProperty(cppVariantToWebString(arguments[0]), pageNumber).utf8());
+    frame->printEnd();
+}
+
 void LayoutTestController::numberOfPages(const CppArgumentList& arguments, CppVariant* result)
 {
     result->setNull();

Modified: trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h (100039 => 100040)


--- trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h	2011-11-11 23:50:19 UTC (rev 100039)
+++ trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h	2011-11-11 23:52:09 UTC (rev 100040)
@@ -334,6 +334,15 @@
     // Gets the number of page where the specified element will be put.
     void pageNumberForElementById(const CppArgumentList&, CppVariant*);
 
+    // Gets the page size and margins for a printed page.
+    void pageSizeAndMarginsInPixels(const CppArgumentList&, CppVariant*);
+
+    // Returns the visibililty status of a page box for printing
+    void isPageBoxVisible(const CppArgumentList&, CppVariant*);
+
+    // Gets the page-related property for printed content
+    void pageProperty(const CppArgumentList&, CppVariant*);
+
     // Gets the number of pages to be printed.
     void numberOfPages(const CppArgumentList&, CppVariant*);
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to