⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 100040 in webkit


Ignore:
Timestamp:
Nov 11, 2011, 3:52:09 PM (15 years ago)
Author:
commit-queue@webkit.org
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 <schenney@chromium.org> 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 <schenney@chromium.org> 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 <schenney@chromium.org> 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.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r100036 r100040  
     12011-11-11  Stephen Chenney  <schenney@chromium.org>
     2
     3        [Chromium] DRT does not have LayoutTestController.pageSizeAndMarginsInPixels
     4        https://bugs.webkit.org/show_bug.cgi?id=49257
     5
     6        Reviewed by Darin Fisher.
     7
     8        * platform/chromium/test_expectations.txt: Removed expected fails for
     9        printing tests that were using missing functionality in LayoutTestController.
     10
    1112011-11-11  Joel Webber  <jgw@google.com>
    212
  • trunk/LayoutTests/platform/chromium/test_expectations.txt

    r100028 r100040  
    20622062BUGCR46603 SKIP DEBUG : fast/frames/lots-of-objects.html = TIMEOUT
    20632063
    2064 // LayoutTestController::pageProperty is not implemented for Chromium yet.
    2065 BUGWK35961 : printing/page-rule-selection.html = TEXT
    2066 
    20672064BUGCR47035 WIN DEBUG : fast/loader/stateobjects/document-destroyed-navigate-back-with-fragment-scroll.html = PASS TEXT
    20682065
     
    20792076// WebKit roll 61547:61629. Still need to investigate.
    20802077BUG_HCLAM : fast/js/script-line-number.html = TEXT
    2081 
    2082 // LayoutTestController::isPageBoxVisible, pageAreaRectInPixels, and preferredPageSizeInPixels are not implemented yet for Chromium.
    2083 BUGWK37538 : printing/page-format-data.html = TEXT
    20842078
    20852079// First noticed on trybots after r61836, now in the tree.
     
    24282422// Added in WK r71424
    24292423BUGCR62138 : animations/stop-animation-on-suspend.html = PASS CRASH TEXT
    2430 
    2431 // test_shell and DRT do not have LayoutTestController.pageSizeAndMarginsInPixels
    2432 BUGCR62515 : printing/page-format-data-display-none.html = TEXT
    24332424
    24342425BUGCR61739 DEBUG : animations/suspend-resume-animation-events.html = PASS CRASH TEXT
  • trunk/Source/WebKit/chromium/ChangeLog

    r100032 r100040  
     12011-11-11  Stephen Chenney  <schenney@chromium.org>
     2
     3        [Chromium] DRT does not have LayoutTestController.pageSizeAndMarginsInPixels
     4        https://bugs.webkit.org/show_bug.cgi?id=49257
     5
     6        Add the WebFrame::getPageProperty method for Chromium.
     7
     8        Reviewed by Darin Fisher.
     9
     10        * public/WebFrame.h:
     11        * src/WebFrameImpl.cpp:
     12        (WebKit::WebFrameImpl::getPageProperty):
     13        * src/WebFrameImpl.h:
     14
    1152011-11-11  Jeff Timanus  <twiz@chromium.org>
    216
  • trunk/Source/WebKit/chromium/public/WebFrame.h

    r98634 r100040  
    480480                                            int& marginLeft) = 0;
    481481
     482    // Returns the value for a page property that is only defined when printing.
     483    // printBegin must have been called before this method.
     484    virtual WebString pageProperty(const WebString& propertyName, int pageIndex) = 0;
     485
    482486    // Find-in-page --------------------------------------------------------
    483487
  • trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp

    r99659 r100040  
    14931493}
    14941494
     1495WebString WebFrameImpl::pageProperty(const WebString& propertyName, int pageIndex)
     1496{
     1497    ASSERT(m_printContext);
     1498    return m_printContext->pageProperty(m_frame, propertyName.utf8().data(), pageIndex);
     1499}
     1500
    14951501bool WebFrameImpl::find(int identifier,
    14961502                        const WebString& searchText,
  • trunk/Source/WebKit/chromium/src/WebFrameImpl.h

    r98634 r100040  
    179179                                            int& marginBottom,
    180180                                            int& marginLeft);
     181    virtual WebString pageProperty(const WebString& propertyName, int pageIndex);
    181182    virtual void printPagesWithBoundaries(WebCanvas*, const WebSize&);
    182183    virtual bool find(
  • trunk/Tools/ChangeLog

    r100030 r100040  
     12011-11-11  Stephen Chenney  <schenney@chromium.org>
     2
     3        [Chromium] DRT does not have LayoutTestController.pageSizeAndMarginsInPixels
     4        https://bugs.webkit.org/show_bug.cgi?id=49257
     5
     6        Adds the remaining missing layout test functionality for printing.
     7
     8        Reviewed by Darin Fisher.
     9
     10        * DumpRenderTree/chromium/LayoutTestController.cpp:
     11        (LayoutTestController::LayoutTestController): Add bindings for new JS methods
     12        (parsePageNumber): Method to parse JS arguments for a page number
     13        (parsePageNumberSizeMargins): Method to parse JS arguments for page size and margins
     14        (LayoutTestController::pageSizeAndMarginsInPixels): Get the page size and margins for a given page.
     15        (LayoutTestController::isPageBoxVisible): get the visibility status for printing
     16        (LayoutTestController::pageProperty): get a specific CSS property when in printing mode
     17        * DumpRenderTree/chromium/LayoutTestController.h: Add declarations for new methods
     18
    1192011-11-11  Darin Adler  <darin@apple.com>
    220
  • trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp

    r99070 r100040  
    6464#include <cstdlib>
    6565#include <limits>
     66#include <sstream>
    6667#include <wtf/text/WTFString.h>
    6768
     
    123124    bindMethod("hasSpellingMarker", &LayoutTestController::hasSpellingMarker);
    124125    bindMethod("isCommandEnabled", &LayoutTestController::isCommandEnabled);
     126    bindMethod("isPageBoxVisible", &LayoutTestController::isPageBoxVisible);
    125127    bindMethod("layerTreeAsText", &LayoutTestController::layerTreeAsText);
    126128    bindMethod("loseCompositorContext", &LayoutTestController::loseCompositorContext);
     
    133135    bindMethod("overridePreference", &LayoutTestController::overridePreference);
    134136    bindMethod("pageNumberForElementById", &LayoutTestController::pageNumberForElementById);
     137    bindMethod("pageProperty", &LayoutTestController::pageProperty);
     138    bindMethod("pageSizeAndMarginsInPixels", &LayoutTestController::pageSizeAndMarginsInPixels);
    135139    bindMethod("pathToLocalResource", &LayoutTestController::pathToLocalResource);
    136140    bindMethod("pauseAnimationAtTimeOnElementWithId", &LayoutTestController::pauseAnimationAtTimeOnElementWithId);
     
    15921596}
    15931597
     1598// Parse a single argument. The method returns true if there is an argument that
     1599// is a number or if there is no argument at all. It returns false only if there
     1600// is some argument that is not a number. The value parameter is filled with the
     1601// parsed number, or given the default if there is no argument.
     1602static bool parseCppArgumentInt32(const CppArgumentList& arguments, int argIndex, int* value, int defaultValue)
     1603{
     1604    if (static_cast<int>(arguments.size()) > argIndex) {
     1605        if (!arguments[argIndex].isNumber())
     1606            return false;
     1607        *value = arguments[argIndex].toInt32();
     1608        return true;
     1609    }
     1610    *value = defaultValue;
     1611    return true;
     1612}
     1613
    15941614static bool parsePageSizeParameters(const CppArgumentList& arguments,
    15951615                                    int argOffset,
     
    15991619    // WebKit is using the window width/height of DumpRenderTree as the
    16001620    // default value of the page size.
    1601     // FIXME: share these values with other ports.
    1602     *pageWidthInPixels = 800;
    1603     *pageHeightInPixels = 600;
    1604     switch (arguments.size() - argOffset) {
    1605     case 2:
    1606         if (!arguments[argOffset].isNumber() || !arguments[1 + argOffset].isNumber())
    1607             return false;
    1608         *pageWidthInPixels = arguments[argOffset].toInt32();
    1609         *pageHeightInPixels = arguments[1 + argOffset].toInt32();
    1610         // fall through.
    1611     case 0:
    1612         break;
    1613     default:
     1621    // FIXME: share the default values with other ports.
     1622    int argCount = static_cast<int>(arguments.size()) - argOffset;
     1623    if (argCount && argCount != 2)
    16141624        return false;
    1615     }
     1625    if (!parseCppArgumentInt32(arguments, argOffset, pageWidthInPixels, 800)
     1626        || !parseCppArgumentInt32(arguments, argOffset + 1, pageHeightInPixels, 600))
     1627        return false;
     1628    return true;
     1629}
     1630
     1631static bool parsePageNumber(const CppArgumentList& arguments, int argOffset, int* pageNumber)
     1632{
     1633    if (static_cast<int>(arguments.size()) > argOffset + 1)
     1634        return false;
     1635    if (!parseCppArgumentInt32(arguments, argOffset, pageNumber, 0))
     1636        return false;
     1637    return true;
     1638}
     1639
     1640static bool parsePageNumberSizeMargins(const CppArgumentList& arguments, int argOffset,
     1641                                       int* pageNumber, int* width, int* height,
     1642                                       int* marginTop, int* marginRight, int* marginBottom, int* marginLeft)
     1643{
     1644    int argCount = static_cast<int>(arguments.size()) - argOffset;
     1645    if (argCount && argCount != 7)
     1646        return false;
     1647    if (!parseCppArgumentInt32(arguments, argOffset, pageNumber, 0)
     1648        || !parseCppArgumentInt32(arguments, argOffset + 1, width, 0)
     1649        || !parseCppArgumentInt32(arguments, argOffset + 2, height, 0)
     1650        || !parseCppArgumentInt32(arguments, argOffset + 3, marginTop, 0)
     1651        || !parseCppArgumentInt32(arguments, argOffset + 4, marginRight, 0)
     1652        || !parseCppArgumentInt32(arguments, argOffset + 5, marginBottom, 0)
     1653        || !parseCppArgumentInt32(arguments, argOffset + 6, marginLeft, 0))
     1654        return false;
    16161655    return true;
    16171656}
     
    16391678                                                static_cast<float>(pageWidthInPixels),
    16401679                                                static_cast<float>(pageHeightInPixels)));
     1680}
     1681
     1682void LayoutTestController::pageSizeAndMarginsInPixels(const CppArgumentList& arguments, CppVariant* result)
     1683{
     1684    result->set("");
     1685    int pageNumber = 0;
     1686    int width = 0;
     1687    int height = 0;
     1688    int marginTop = 0;
     1689    int marginRight = 0;
     1690    int marginBottom = 0;
     1691    int marginLeft = 0;
     1692    if (!parsePageNumberSizeMargins(arguments, 0, &pageNumber, &width, &height, &marginTop, &marginRight, &marginBottom,
     1693                                    &marginLeft))
     1694        return;
     1695
     1696    WebFrame* frame = m_shell->webView()->mainFrame();
     1697    if (!frame)
     1698        return;
     1699    WebSize pageSize(width, height);
     1700    frame->pageSizeAndMarginsInPixels(pageNumber, pageSize, marginTop, marginRight, marginBottom, marginLeft);
     1701    stringstream resultString;
     1702    resultString << "(" << pageSize.width << ", " << pageSize.height << ") " << marginTop << " " << marginRight << " "
     1703                 << marginBottom << " " << marginLeft;
     1704    result->set(resultString.str());
     1705}
     1706
     1707void LayoutTestController::isPageBoxVisible(const CppArgumentList& arguments, CppVariant* result)
     1708{
     1709    result->setNull();
     1710    int pageNumber = 0;
     1711    if (!parsePageNumber(arguments, 0, &pageNumber))
     1712        return;
     1713    WebFrame* frame = m_shell->webView()->mainFrame();
     1714    if (!frame)
     1715        return;
     1716    result->set(frame->isPageBoxVisible(pageNumber));
     1717}
     1718
     1719void LayoutTestController::pageProperty(const CppArgumentList& arguments, CppVariant* result)
     1720{
     1721    result->set("");
     1722    int pageNumber = 0;
     1723    if (!parsePageNumber(arguments, 1, &pageNumber))
     1724        return;
     1725    if (!arguments[0].isString())
     1726        return;
     1727    WebFrame* frame = m_shell->webView()->mainFrame();
     1728    if (!frame)
     1729        return;
     1730    WebSize pageSize(800, 800);
     1731    frame->printBegin(pageSize);
     1732    result->set(frame->pageProperty(cppVariantToWebString(arguments[0]), pageNumber).utf8());
     1733    frame->printEnd();
    16411734}
    16421735
  • trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h

    r99070 r100040  
    334334    // Gets the number of page where the specified element will be put.
    335335    void pageNumberForElementById(const CppArgumentList&, CppVariant*);
     336
     337    // Gets the page size and margins for a printed page.
     338    void pageSizeAndMarginsInPixels(const CppArgumentList&, CppVariant*);
     339
     340    // Returns the visibililty status of a page box for printing
     341    void isPageBoxVisible(const CppArgumentList&, CppVariant*);
     342
     343    // Gets the page-related property for printed content
     344    void pageProperty(const CppArgumentList&, CppVariant*);
    336345
    337346    // Gets the number of pages to be printed.
Note: See TracChangeset for help on using the changeset viewer.