Changeset 98634 in webkit
- Timestamp:
- Oct 27, 2011 1:53:53 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 12 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r98632 r98634 1 2011-10-27 Stephen Chenney <schenney@chromium.org> 2 3 [Chromium] Need setPrinting 4 https://bugs.webkit.org/show_bug.cgi?id=46152 5 6 Reviewed by Hajime Morita. 7 8 * platform/chromium/test_expectations.txt: Removing setPrinting tests from the expected failures. 9 * platform/chromium-linux/printing/setPrinting-expected.png: Added. 10 * platform/chromium-linux/printing/setPrinting-expected.txt: Added. 11 * platform/chromium-linux/printing/single-line-must-not-be-split-into-two-pages-expected.png: Added. 12 * platform/chromium-linux/printing/single-line-must-not-be-split-into-two-pages-expected.txt: Added. 13 * platform/chromium-mac/printing/setPrinting-expected.png: Added. 14 * platform/chromium-mac/printing/setPrinting-expected.txt: Added. 15 * platform/chromium-mac/printing/single-line-must-not-be-split-into-two-pages-expected.png: Added. 16 * platform/chromium-mac/printing/single-line-must-not-be-split-into-two-pages-expected.txt: Added. 17 * platform/chromium-win/printing/setPrinting-expected.png: Added. 18 * platform/chromium-win/printing/setPrinting-expected.txt: Added. 19 * platform/chromium-win/printing/single-line-must-not-be-split-into-two-pages-expected.png: Added. 20 * platform/chromium-win/printing/single-line-must-not-be-split-into-two-pages-expected.txt: Added. 21 * platform/mac/printing/setPrinting-expected.png: Rebaselined for the change to the test html. 22 * platform/mac/printing/setPrinting-expected.txt: Rebaselined for the change to the test html. 23 * printing/setPrinting.html: Modified the test to make the box have a colored border 24 instead of the solid background, as the solid background does not print on chromium. 25 1 26 2011-10-27 Leandro Pereira <leandro@profusion.mobi> 2 27 -
trunk/LayoutTests/platform/chromium/test_expectations.txt
r98616 r98634 2168 2168 BUGWK42428 LINUX WIN : svg/W3C-SVG-1.1/filters-conv-01-f.svg = IMAGE+TEXT 2169 2169 2170 // Need setPrinting.2171 BUGWK20011 : printing/setPrinting.html = FAIL2172 BUGWK65005 : printing/single-line-must-not-be-split-into-two-pages.html = FAIL MISSING2173 2174 2170 // Needs V8 change. 2175 2171 BUGCR49343 : fast/js/reserved-words-as-property.html = TEXT … … 2377 2373 BUGCR58936 : fast/js/basic-strict-mode.html = TEXT 2378 2374 BUGCR58936 : fast/js/numeric-escapes-in-string-literals.html = TEXT 2379 2380 // Started failing at Webkit r69628.2381 BUGWK47578 : printing/simultaneous-position-float-change.html = IMAGE+TEXT2382 2375 2383 2376 // We don't support layoutTestController.nodesFromRect so this test just times out -
trunk/LayoutTests/platform/mac/printing/setPrinting-expected.txt
r78910 r98634 4 4 RenderBlock {HTML} at (0,0) size 981x785 5 5 RenderBody {BODY} at (0,0) size 981x785 6 RenderBlock {DIV} at (0,0) size 800x749 [b gcolor=#008000]7 RenderText {#text} at ( 0,0) size 235x188 text run at ( 0,0) width 235: "This test case should output 2 pages."6 RenderBlock {DIV} at (0,0) size 800x749 [border: (1px solid #008000)] 7 RenderText {#text} at (1,1) size 235x18 8 text run at (1,1) width 235: "This test case should output 2 pages." 9 9 RenderBlock (anonymous) at (0,749) size 981x36 10 10 RenderText {#text} at (0,0) size 957x36 -
trunk/LayoutTests/printing/setPrinting.html
r63521 r98634 8 8 9 9 <body style="margin: 0px;"> 10 <div style="width: 800px; height: 749px; background-color:green;">10 <div style="width: 798px; height: 747px; border: 1px solid green;"> 11 11 This test case should output 2 pages. 12 12 </div> -
trunk/Source/WebKit/chromium/ChangeLog
r98630 r98634 1 2011-10-27 Stephen Chenney <schenney@chromium.org> 2 3 [Chromium] Need setPrinting 4 https://bugs.webkit.org/show_bug.cgi?id=46152 5 6 Reviewed by Hajime Morita. 7 8 * public/WebFrame.h: Added pure virtual prototype for printPagesWithBoundaries. Added enum 9 and changed parameters for renderTreeAsText. 10 * src/WebFrameImpl.cpp: 11 (WebKit::ChromePrintContext::spoolAllPagesWithBoundaries): Added this method, based on 12 the static in PrintContext. This uses Chromium specific page spooling and transforms. 13 (WebKit::WebFrameImpl::renderTreeAsText): Updated to allow text dump in printed format. 14 (WebKit::WebFrameImpl::printPagesWithBoundaries): Added method for testing printing page 15 breaks. 16 * src/WebFrameImpl.h: Added prototype. 17 1 18 2011-10-27 Antoine Labour <piman@chromium.org> 2 19 -
trunk/Source/WebKit/chromium/public/WebFrame.h
r97301 r98634 80 80 class WebFrame { 81 81 public: 82 // Control of renderTreeAsText output 83 enum RenderAsTextControl { 84 RenderAsTextNormal = 0, 85 RenderAsTextDebug = 1 << 0, 86 RenderAsTextPrinting = 1 << 1 87 }; 88 typedef unsigned RenderAsTextControls; 89 82 90 // Returns the number of live WebFrame objects, used for leak checking. 83 91 WEBKIT_EXPORT static int instanceCount(); … … 547 555 // Returns a text representation of the render tree. This method is used 548 556 // to support layout tests. 549 virtual WebString renderTreeAsText( bool showDebugInfo = false) const = 0;557 virtual WebString renderTreeAsText(RenderAsTextControls toShow = RenderAsTextNormal) const = 0; 550 558 551 559 // Returns the counter value for the specified element. This method is … … 562 570 float pageHeightInPixels) const = 0; 563 571 572 // Prints all of the pages into the canvas, with page boundaries drawn as 573 // one pixel wide blue lines. This method exists to support layout tests. 574 virtual void printPagesWithBoundaries(WebCanvas*, const WebSize&) = 0; 575 564 576 // Returns the bounds rect for current selection. If selection is performed 565 577 // on transformed text, the rect will still bound the selection but will -
trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp
r97478 r98634 363 363 } 364 364 365 void spoolAllPagesWithBoundaries(GraphicsContext& graphicsContext, const FloatSize& pageSizeInPixels) 366 { 367 if (!m_frame->document() || !m_frame->view() || !m_frame->document()->renderer()) 368 return; 369 370 m_frame->document()->updateLayout(); 371 372 float pageHeight; 373 computePageRects(FloatRect(FloatPoint(0, 0), pageSizeInPixels), 0, 0, 1, pageHeight); 374 375 const float pageWidth = pageSizeInPixels.width(); 376 size_t numPages = pageRects().size(); 377 int totalHeight = numPages * (pageSizeInPixels.height() + 1) - 1; 378 379 // Fill the whole background by white. 380 graphicsContext.setFillColor(Color(255, 255, 255), ColorSpaceDeviceRGB); 381 graphicsContext.fillRect(FloatRect(0, 0, pageWidth, totalHeight)); 382 383 graphicsContext.save(); 384 385 int currentHeight = 0; 386 for (size_t pageIndex = 0; pageIndex < numPages; pageIndex++) { 387 // Draw a line for a page boundary if this isn't the first page. 388 if (pageIndex > 0) { 389 graphicsContext.save(); 390 graphicsContext.setStrokeColor(Color(0, 0, 255), ColorSpaceDeviceRGB); 391 graphicsContext.setFillColor(Color(0, 0, 255), ColorSpaceDeviceRGB); 392 graphicsContext.drawLine(IntPoint(0, currentHeight), 393 IntPoint(pageWidth, currentHeight)); 394 graphicsContext.restore(); 395 } 396 397 graphicsContext.save(); 398 399 graphicsContext.translate(0, currentHeight); 400 #if !OS(UNIX) || OS(DARWIN) 401 // Account for the disabling of scaling in spoolPage. In the context 402 // of spoolAllPagesWithBoundaries the scale HAS NOT been pre-applied. 403 float scale = getPageShrink(pageIndex); 404 graphicsContext.scale(WebCore::FloatSize(scale, scale)); 405 #endif 406 spoolPage(graphicsContext, pageIndex); 407 graphicsContext.restore(); 408 409 currentHeight += pageSizeInPixels.height() + 1; 410 } 411 412 graphicsContext.restore(); 413 } 414 365 415 virtual void computePageRects(const FloatRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, float& outPageHeight) 366 416 { … … 1779 1829 } 1780 1830 1781 WebString WebFrameImpl::renderTreeAsText( bool showDebugInfo) const1831 WebString WebFrameImpl::renderTreeAsText(RenderAsTextControls toShow) const 1782 1832 { 1783 1833 RenderAsTextBehavior behavior = RenderAsTextBehaviorNormal; 1784 1834 1785 if ( showDebugInfo) {1835 if (toShow & RenderAsTextDebug) { 1786 1836 behavior |= RenderAsTextShowCompositedLayers 1787 1837 | RenderAsTextShowAddresses … … 1790 1840 } 1791 1841 1842 if (toShow & RenderAsTextPrinting) 1843 behavior |= RenderAsTextPrintingMode; 1844 1792 1845 return externalRepresentation(m_frame, behavior); 1793 1846 } … … 1823 1876 FloatSize pageSize(pageWidthInPixels, pageHeightInPixels); 1824 1877 return PrintContext::pageNumberForElement(element, pageSize); 1878 } 1879 1880 void WebFrameImpl::printPagesWithBoundaries(WebCanvas* canvas, const WebSize& pageSizeInPixels) 1881 { 1882 ASSERT(m_printContext.get()); 1883 1884 GraphicsContextBuilder builder(canvas); 1885 GraphicsContext& graphicsContext = builder.context(); 1886 #if WEBKIT_USING_SKIA 1887 graphicsContext.platformContext()->setPrinting(true); 1888 #endif 1889 1890 m_printContext->spoolAllPagesWithBoundaries(graphicsContext, 1891 FloatSize(pageSizeInPixels.width, pageSizeInPixels.height)); 1825 1892 } 1826 1893 -
trunk/Source/WebKit/chromium/src/WebFrameImpl.h
r97301 r98634 179 179 int& marginBottom, 180 180 int& marginLeft); 181 virtual void printPagesWithBoundaries(WebCanvas*, const WebSize&); 181 182 virtual bool find( 182 183 int identifier, const WebString& searchText, const WebFindOptions&, … … 192 193 virtual WebString contentAsText(size_t maxChars) const; 193 194 virtual WebString contentAsMarkup() const; 194 virtual WebString renderTreeAsText( bool showDebugInfo = false) const;195 virtual WebString renderTreeAsText(RenderAsTextControls toShow = RenderAsTextNormal) const; 195 196 virtual WebString counterValueForElementById(const WebString& id) const; 196 197 virtual WebString markerTextForListItem(const WebElement&) const; -
trunk/Tools/ChangeLog
r98622 r98634 1 2011-10-27 Stephen Chenney <schenney@chromium.org> 2 3 [Chromium] Need setPrinting 4 https://bugs.webkit.org/show_bug.cgi?id=46152 5 6 Reviewed by Hajime Morita. 7 8 * DumpRenderTree/chromium/LayoutTestController.cpp: 9 (LayoutTestController::LayoutTestController): Added logic for handling setPrinting. 10 (LayoutTestController::reset): Clearing flags for setPrinting. 11 (LayoutTestController::setPrinting): Set flags for setPrinting. 12 * DumpRenderTree/chromium/LayoutTestController.h: 13 (LayoutTestController::setIsPrinting): Added the setPrinting methods and flags. 14 (LayoutTestController::isPrinting): Method to return the setPrinting status. 15 * DumpRenderTree/chromium/TestShell.cpp: 16 (dumpFramesAsPrintedText): A method for creating a text dump in printed layout. 17 (TestShell::dump): Modified to dump setPrinting-specific output. 18 * DumpRenderTree/chromium/WebViewHost.cpp: 19 (WebViewHost::paintPagesWithBoundaries): Handling for pixel tests when setPrinting is 20 active. 21 * DumpRenderTree/chromium/WebViewHost.h: Prototype for paintPagesWithBoundaries. 22 1 23 2011-10-27 Sam Weinig <sam@webkit.org> 2 24 -
trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp
r98559 r98634 176 176 bindMethod("setPopupBlockingEnabled", &LayoutTestController::setPopupBlockingEnabled); 177 177 bindMethod("setPOSIXLocale", &LayoutTestController::setPOSIXLocale); 178 bindMethod("setPrinting", &LayoutTestController::setPrinting); 178 179 bindMethod("setScrollbarPolicy", &LayoutTestController::setScrollbarPolicy); 179 180 bindMethod("setSelectTrailingWhitespaceEnabled", &LayoutTestController::setSelectTrailingWhitespaceEnabled); … … 630 631 m_platformName.set("chromium"); 631 632 m_userStyleSheetLocation = WebURL(); 633 m_isPrinting = false; 632 634 633 635 webkit_support::SetAcceptAllCookies(false); … … 1565 1567 } 1566 1568 1569 void LayoutTestController::setPrinting(const CppArgumentList& arguments, CppVariant* result) 1570 { 1571 setIsPrinting(true); 1572 result->setNull(); 1573 } 1574 1567 1575 void LayoutTestController::pageNumberForElementById(const CppArgumentList& arguments, CppVariant* result) 1568 1576 { -
trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h
r97716 r98634 328 328 // Gets the value of the counter in the element specified by its ID. 329 329 void counterValueForElementById(const CppArgumentList&, CppVariant*); 330 331 // Causes layout to happen as if targetted to printed pages. 332 void setPrinting(const CppArgumentList&, CppVariant*); 330 333 331 334 // Gets the number of page where the specified element will be put. … … 452 455 } 453 456 457 void setIsPrinting(bool value) { m_isPrinting = value; } 458 bool isPrinting() { return m_isPrinting; } 459 454 460 bool testRepaint() const { return m_testRepaint; } 455 461 bool sweepHorizontally() const { return m_sweepHorizontally; } … … 643 649 bool m_showDebugLayerTree; 644 650 651 // If true, layout is to target printed pages. 652 bool m_isPrinting; 653 645 654 WorkQueue m_workQueue; 646 655 -
trunk/Tools/DumpRenderTree/chromium/TestShell.cpp
r98559 r98634 372 372 } 373 373 374 static string dumpFramesAsPrintedText(WebFrame* frame, bool recursive) 375 { 376 string result; 377 378 // Cannot do printed format for anything other than HTML 379 if (!frame->document().isHTMLDocument()) 380 return string(); 381 382 // Add header for all but the main frame. Skip empty frames. 383 if (frame->parent() && !frame->document().documentElement().isNull()) { 384 result.append("\n--------\nFrame: '"); 385 result.append(frame->name().utf8().data()); 386 result.append("'\n--------\n"); 387 } 388 389 result.append(frame->renderTreeAsText(WebFrame::RenderAsTextPrinting).utf8()); 390 result.append("\n"); 391 392 if (recursive) { 393 for (WebFrame* child = frame->firstChild(); child; child = child->nextSibling()) 394 result.append(dumpFramesAsPrintedText(child, recursive)); 395 } 396 397 return result; 398 } 399 374 400 static void dumpFrameScrollPosition(WebFrame* frame, bool recursive) 375 401 { … … 489 515 bool shouldDumpAsAudio = m_layoutTestController->shouldDumpAsAudio(); 490 516 bool shouldGeneratePixelResults = m_layoutTestController->shouldGeneratePixelResults(); 517 bool shouldDumpAsPrinted = m_layoutTestController->isPrinting(); 491 518 bool dumpedAnything = false; 492 519 493 520 if (shouldDumpAsAudio) { 494 521 m_printer->handleAudioHeader(); 495 522 496 523 const WebKit::WebArrayBufferView& webArrayBufferView = m_layoutTestController->audioData(); 497 524 printf("Content-Length: %d\n", webArrayBufferView.byteLength()); 498 525 499 526 if (fwrite(webArrayBufferView.baseAddress(), 1, webArrayBufferView.byteLength(), stdout) != webArrayBufferView.byteLength()) 500 527 FATAL("Short write to stdout, disk full?\n"); 501 528 printf("\n"); 502 529 503 530 m_printer->handleTestFooter(true); 504 531 … … 523 550 if (shouldDumpAsText) { 524 551 bool recursive = m_layoutTestController->shouldDumpChildFramesAsText(); 525 string dataUtf8 = dumpFramesAsText(frame, recursive);552 string dataUtf8 = shouldDumpAsPrinted ? dumpFramesAsPrintedText(frame, recursive) : dumpFramesAsText(frame, recursive); 526 553 if (fwrite(dataUtf8.c_str(), 1, dataUtf8.size(), stdout) != dataUtf8.size()) 527 554 FATAL("Short write to stdout, disk full?\n"); 528 555 } else { 529 printf("%s", frame->renderTreeAsText(m_params.debugRenderTree).utf8().data()); 556 WebFrame::RenderAsTextControls renderTextBehavior = WebFrame::RenderAsTextNormal; 557 if (shouldDumpAsPrinted) 558 renderTextBehavior |= WebFrame::RenderAsTextPrinting; 559 if (m_params.debugRenderTree) 560 renderTextBehavior |= WebFrame::RenderAsTextDebug; 561 printf("%s", frame->renderTreeAsText(renderTextBehavior).utf8().data()); 530 562 bool recursive = m_layoutTestController->shouldDumpChildFrameScrollPositions(); 531 563 dumpFrameScrollPosition(frame, recursive); … … 554 586 m_webViewHost->paintRect(line); 555 587 } 556 } else 588 } else if (m_layoutTestController->isPrinting()) 589 m_webViewHost->paintPagesWithBoundaries(); 590 else 557 591 m_webViewHost->paintInvalidatedRegion(); 558 592 -
trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp
r97743 r98634 1574 1574 } 1575 1575 1576 void WebViewHost::paintPagesWithBoundaries() 1577 { 1578 ASSERT(!m_isPainting); 1579 ASSERT(canvas()); 1580 m_isPainting = true; 1581 1582 WebSize pageSizeInPixels = webWidget()->size(); 1583 WebFrame* webFrame = webView()->mainFrame(); 1584 1585 int pageCount = webFrame->printBegin(pageSizeInPixels); 1586 int totalHeight = pageCount * (pageSizeInPixels.height + 1) - 1; 1587 1588 SkCanvas* testCanvas = skia::TryCreateBitmapCanvas(pageSizeInPixels.width, totalHeight, true); 1589 if (testCanvas) { 1590 discardBackingStore(); 1591 m_canvas = adoptPtr(testCanvas); 1592 } else { 1593 webFrame->printEnd(); 1594 return; 1595 } 1596 1597 #if WEBKIT_USING_SKIA 1598 WebCanvas* webCanvas = canvas(); 1599 #elif WEBKIT_USING_CG 1600 const SkBitmap& canvasBitmap = canvas()->getDevice()->accessBitmap(false); 1601 WebCanvas* webCanvas = CGBitmapContextCreate(canvasBitmap.getPixels(), 1602 pageSizeInPixels.width, totalHeight, 1603 8, pageSizeInPixels.width * 4, 1604 CGColorSpaceCreateDeviceRGB(), 1605 kCGImageAlphaPremultipliedFirst | 1606 kCGBitmapByteOrder32Host); 1607 #endif 1608 1609 webFrame->printPagesWithBoundaries(webCanvas, pageSizeInPixels); 1610 webFrame->printEnd(); 1611 1612 m_isPainting = false; 1613 } 1614 1576 1615 SkCanvas* WebViewHost::canvas() 1577 1616 { -
trunk/Tools/DumpRenderTree/chromium/WebViewHost.h
r97743 r98634 89 89 void updatePaintRect(const WebKit::WebRect&); 90 90 void paintInvalidatedRegion(); 91 void paintPagesWithBoundaries(); 91 92 SkCanvas* canvas(); 92 93 void displayRepaintMask();
Note: See TracChangeset
for help on using the changeset viewer.