Changeset 54533 in webkit


Ignore:
Timestamp:
Feb 9, 2010 12:32:53 AM (14 years ago)
Author:
hamaji@chromium.org
Message:

2010-02-09 Shinichiro Hamaji <hamaji@chromium.org>

Reviewed by Darin Adler.

Provide a way to get total number of pages to be printed
https://bugs.webkit.org/show_bug.cgi?id=34699

  • platform/gtk/Skipped:
  • platform/qt/Skipped:
  • platform/win/Skipped:
  • printing/numberOfPages-expected.txt: Added.
  • printing/numberOfPages.html: Added.
  • printing/script-tests/numberOfPages.js: Added. (createParagraph):

2010-02-09 Shinichiro Hamaji <hamaji@chromium.org>

Reviewed by Darin Adler.

Provide a way to get total number of pages to be printed
https://bugs.webkit.org/show_bug.cgi?id=34699

Test: printing/numberOfPages.html

  • WebCore.base.exp:
  • page/PrintContext.cpp: (WebCore::PrintContext::pageNumberForElement): (WebCore::PrintContext::numberOfPages):
  • page/PrintContext.h: (WebCore::PrintContext::pageRects):

2010-02-09 Shinichiro Hamaji <hamaji@chromium.org>

Reviewed by Darin Adler.

Provide a way to get total number of pages to be printed
https://bugs.webkit.org/show_bug.cgi?id=34699

  • Misc/WebCoreStatistics.h:
  • Misc/WebCoreStatistics.mm: (-[WebFrame numberOfPages:pageWidthInPixels:]):

2010-02-09 Shinichiro Hamaji <hamaji@chromium.org>

Reviewed by Darin Adler.

Provide a way to get total number of pages to be printed
https://bugs.webkit.org/show_bug.cgi?id=34699

  • DumpRenderTree/LayoutTestController.cpp: (parsePageParameters): (pageNumberForElementByIdCallback): (numberOfPagesCallback): (LayoutTestController::staticFunctions):
  • DumpRenderTree/LayoutTestController.h:
  • DumpRenderTree/gtk/LayoutTestControllerGtk.cpp: (LayoutTestController::numberOfPages):
  • DumpRenderTree/mac/LayoutTestControllerMac.mm: (LayoutTestController::numberOfPages):
  • DumpRenderTree/win/LayoutTestControllerWin.cpp: (LayoutTestController::numberOfPages):
Location:
trunk
Files:
3 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r54530 r54533  
     12010-02-09  Shinichiro Hamaji  <hamaji@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Provide a way to get total number of pages to be printed
     6        https://bugs.webkit.org/show_bug.cgi?id=34699
     7
     8        * platform/gtk/Skipped:
     9        * platform/qt/Skipped:
     10        * platform/win/Skipped:
     11        * printing/numberOfPages-expected.txt: Added.
     12        * printing/numberOfPages.html: Added.
     13        * printing/script-tests/numberOfPages.js: Added.
     14        (createParagraph):
     15
    1162010-02-09  Zoltan Herczeg  <zherczeg@inf.u-szeged.hu>
    217
  • trunk/LayoutTests/platform/gtk/Skipped

    r54529 r54533  
    58105810# https://bugs.webkit.org/show_bug.cgi?id=32717
    58115811fast/frames/flattening/
     5812
     5813# Implement LayoutTestController::numberOfPages().
     5814printing/numberOfPages.html
  • trunk/LayoutTests/platform/qt/Skipped

    r54468 r54533  
    50785078# Because ENABLE_DASHBOARD_SUPPORT=0 is the default option. (Apple's dashboard support in OS X)
    50795079fast/css/dashboard-regions-attr-crash.html
     5080
     5081# Implement LayoutTestController::numberOfPages().
     5082printing/numberOfPages.html
  • trunk/LayoutTests/platform/win/Skipped

    r54440 r54533  
    749749# https://bugs.webkit.org/show_bug.cgi?id=32717
    750750fast/frames/flattening/
     751
     752# Implement LayoutTestController::numberOfPages().
     753printing/numberOfPages.html
  • trunk/WebCore/ChangeLog

    r54527 r54533  
     12010-02-09  Shinichiro Hamaji  <hamaji@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Provide a way to get total number of pages to be printed
     6        https://bugs.webkit.org/show_bug.cgi?id=34699
     7
     8        Test: printing/numberOfPages.html
     9
     10        * WebCore.base.exp:
     11        * page/PrintContext.cpp:
     12        (WebCore::PrintContext::pageNumberForElement):
     13        (WebCore::PrintContext::numberOfPages):
     14        * page/PrintContext.h:
     15        (WebCore::PrintContext::pageRects):
     16
    1172010-02-08  Dominic Cooney  <dominicc@google.com>
    218
  • trunk/WebCore/WebCore.base.exp

    r54405 r54533  
    251251__ZN7WebCore12IconDatabase9setClientEPNS_18IconDatabaseClientE
    252252__ZN7WebCore12PluginWidget14invalidateRectERKNS_7IntRectE
     253__ZN7WebCore12PrintContext13numberOfPagesEPNS_5FrameERKNS_9FloatSizeE
    253254__ZN7WebCore12PrintContext20pageNumberForElementEPNS_7ElementERKNS_9FloatSizeE
    254255__ZN7WebCore12RenderObject16repaintRectangleERKNS_7IntRectEb
  • trunk/WebCore/page/PrintContext.cpp

    r54205 r54533  
    185185            return pageNumber;
    186186    }
     187    printContext.end();
    187188    return -1;
    188189}
    189190
    190 }
     191int PrintContext::numberOfPages(Frame* frame, const FloatSize& pageSizeInPixels)
     192{
     193    frame->document()->updateLayout();
     194
     195    FloatRect pageRect(FloatPoint(0, 0), pageSizeInPixels);
     196    PrintContext printContext(frame);
     197    printContext.begin(pageRect.width());
     198    printContext.computePageRectsWithPageSize(pageSizeInPixels, 1);
     199    printContext.end();
     200    return printContext.pageCount();
     201}
     202
     203}
  • trunk/WebCore/page/PrintContext.h

    r54221 r54533  
    4040    int pageCount() const;
    4141    const IntRect& pageRect(int pageNumber) const;
    42   const Vector<IntRect>& pageRects() const { return m_pageRects; }
     42    const Vector<IntRect>& pageRects() const { return m_pageRects; }
    4343
    4444    void computePageRects(const FloatRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, float& outPageHeight);
     
    5454    // Used by layout tests.
    5555    static int pageNumberForElement(Element*, const FloatSize& pageSizeInPixels);
     56    static int numberOfPages(Frame*, const FloatSize& pageSizeInPixels);
    5657
    5758protected:
  • trunk/WebKit/mac/ChangeLog

    r54516 r54533  
     12010-02-09  Shinichiro Hamaji  <hamaji@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Provide a way to get total number of pages to be printed
     6        https://bugs.webkit.org/show_bug.cgi?id=34699
     7
     8        * Misc/WebCoreStatistics.h:
     9        * Misc/WebCoreStatistics.mm:
     10        (-[WebFrame numberOfPages:pageWidthInPixels:]):
     11
    1122010-02-08  Alexey Proskuryakov  <ap@apple.com>
    213
  • trunk/WebKit/mac/Misc/WebCoreStatistics.h

    r54205 r54533  
    8686- (NSString *)counterValueForElement:(DOMElement*)element;
    8787- (int)pageNumberForElement:(DOMElement*)element:(float)pageWidthInPixels:(float)pageHeightInPixels;
     88- (int)numberOfPages:(float)pageWidthInPixels:(float)pageHeightInPixels;
    8889@end
  • trunk/WebKit/mac/Misc/WebCoreStatistics.mm

    r54205 r54533  
    257257}
    258258
     259- (int)numberOfPages:(float)pageWidthInPixels:(float)pageHeightInPixels
     260{
     261    return PrintContext::numberOfPages(_private->coreFrame, FloatSize(pageWidthInPixels, pageHeightInPixels));
     262}
     263
    259264@end
  • trunk/WebKitTools/ChangeLog

    r54516 r54533  
     12010-02-09  Shinichiro Hamaji  <hamaji@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Provide a way to get total number of pages to be printed
     6        https://bugs.webkit.org/show_bug.cgi?id=34699
     7
     8        * DumpRenderTree/LayoutTestController.cpp:
     9        (parsePageParameters):
     10        (pageNumberForElementByIdCallback):
     11        (numberOfPagesCallback):
     12        (LayoutTestController::staticFunctions):
     13        * DumpRenderTree/LayoutTestController.h:
     14        * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
     15        (LayoutTestController::numberOfPages):
     16        * DumpRenderTree/mac/LayoutTestControllerMac.mm:
     17        (LayoutTestController::numberOfPages):
     18        * DumpRenderTree/win/LayoutTestControllerWin.cpp:
     19        (LayoutTestController::numberOfPages):
     20
    1212010-02-08  Alexey Proskuryakov  <ap@apple.com>
    222
  • trunk/WebKitTools/DumpRenderTree/LayoutTestController.cpp

    r54205 r54533  
    466466}
    467467
    468 static JSValueRef pageNumberForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
     468static bool parsePageParameters(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, float& pageWidthInPixels, float& pageHeightInPixels)
    469469{
    470470    // FIXME: These values should sync with maxViewWidth/Height in
    471471    //        DumpRenderTree.mm. Factor these values out to somewhere.
    472     float pageWidthInPixels = 800;
    473     float pageHeightInPixels = 600;
     472    pageWidthInPixels = 800;
     473    pageHeightInPixels = 600;
    474474    switch (argumentCount) {
    475     case 1:
    476         break;
    477     case 3:
    478         pageWidthInPixels = static_cast<float>(JSValueToNumber(context, arguments[1], exception));
     475    case 2:
     476        pageWidthInPixels = static_cast<float>(JSValueToNumber(context, arguments[0], exception));
    479477        if (*exception)
    480             return JSValueMakeUndefined(context);
    481         pageHeightInPixels = static_cast<float>(JSValueToNumber(context, arguments[2], exception));
     478            return false;
     479        pageHeightInPixels = static_cast<float>(JSValueToNumber(context, arguments[1], exception));
    482480        if (*exception)
    483             return JSValueMakeUndefined(context);
     481            return false;
     482    case 0: // Fall through.
    484483        break;
    485484    default:
    486         return JSValueMakeUndefined(context);
     485        return false;
    487486    }
     487    return true;
     488}
     489
     490static JSValueRef pageNumberForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
     491{
     492    float pageWidthInPixels = 0;
     493    float pageHeightInPixels = 0;
     494    if (!parsePageParameters(context, argumentCount - 1, arguments + 1, exception, pageWidthInPixels, pageHeightInPixels))
     495        return JSValueMakeUndefined(context);
    488496
    489497    JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
     
    494502    int pageNumber = controller->pageNumberForElementById(elementId.get(), pageWidthInPixels, pageHeightInPixels);
    495503    return JSValueMakeNumber(context, pageNumber);
     504}
     505
     506static JSValueRef numberOfPagesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
     507{
     508    float pageWidthInPixels = 0;
     509    float pageHeightInPixels = 0;
     510    if (!parsePageParameters(context, argumentCount, arguments, exception, pageWidthInPixels, pageHeightInPixels))
     511        return JSValueMakeUndefined(context);
     512
     513    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
     514    return JSValueMakeNumber(context, controller->numberOfPages(pageWidthInPixels, pageHeightInPixels));
    496515}
    497516
     
    13301349        { "isCommandEnabled", isCommandEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    13311350        { "keepWebHistory", keepWebHistoryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     1351        { "numberOfPages", numberOfPagesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    13321352        { "notifyDone", notifyDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    13331353        { "numberOfActiveAnimations", numberOfActiveAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
  • trunk/WebKitTools/DumpRenderTree/LayoutTestController.h

    r54205 r54533  
    5757    void keepWebHistory();
    5858    void notifyDone();
     59    int numberOfPages(float pageWidthInPixels, float pageHeightInPixels);
    5960    void overridePreference(JSStringRef key, JSStringRef value);
    6061    int pageNumberForElementById(JSStringRef id, float pageWidthInPixels, float pageHeightInPixels);
  • trunk/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp

    r54461 r54533  
    150150}
    151151
     152int LayoutTestController::numberOfPages(float, float)
     153{
     154    // FIXME: implement
     155    return -1;
     156}
     157
    152158size_t LayoutTestController::webHistoryItemCount()
    153159{
  • trunk/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm

    r54205 r54533  
    189189}
    190190
     191int LayoutTestController::numberOfPages(float pageWidthInPixels, float pageHeightInPixels)
     192{
     193    return [mainFrame numberOfPages:pageWidthInPixels:pageHeightInPixels];
     194}
     195
    191196size_t LayoutTestController::webHistoryItemCount()
    192197{
  • trunk/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp

    r54205 r54533  
    11101110    return -1;
    11111111}
     1112
     1113int LayoutTestController::numberOfPages(float, float)
     1114{
     1115    // FIXME: implement
     1116    return -1;
     1117}
Note: See TracChangeset for help on using the changeset viewer.