Commit fbee9667 authored by hamaji@chromium.org's avatar hamaji@chromium.org
Browse files

2010-04-27 Shinichiro Hamaji <hamaji@chromium.org>

        Reviewed by Darin Adler and Eric Seidel.

        Add layoutTestController.setPrinting()
        https://bugs.webkit.org/show_bug.cgi?id=37203

        Now we can test media queries with the new function because the
        render tree has the color information of the box.

        Note that the pixel test is currently failing. We'll need another
        patch to enable printing mode for pixel tests.

        * platform/mac/Skipped:
        * platform/mac/printing/media-queries-print-expected.checksum: Added.
        * platform/mac/printing/media-queries-print-expected.png: Added.
        * platform/mac/printing/media-queries-print-expected.txt: Added.
        * printing/media-queries-print.html:
2010-04-27  Shinichiro Hamaji  <hamaji@chromium.org>

        Reviewed by Darin Adler and Eric Seidel.

        Add layoutTestController.setPrinting()
        https://bugs.webkit.org/show_bug.cgi?id=37203

        Added RenderAsTextPrintingMode as a behavior of externalRepresentation.

        Now ~PrintContext() calls end() automatically.

        * page/PrintContext.cpp:
        (WebCore::PrintContext::~PrintContext):
        * rendering/RenderTreeAsText.cpp:
        (WebCore::externalRepresentation):
        * rendering/RenderTreeAsText.h:
        (WebCore::):
2010-04-27  Shinichiro Hamaji  <hamaji@chromium.org>

        Reviewed by Darin Adler and Eric Seidel.

        Add layoutTestController.setPrinting()
        https://bugs.webkit.org/show_bug.cgi?id=37203

        * Misc/WebCoreStatistics.h:
        * Misc/WebCoreStatistics.mm:
        (-[WebFrame renderTreeAsExternalRepresentationForPrinting:]):
2010-04-27  Shinichiro Hamaji  <hamaji@chromium.org>

        Reviewed by Darin Adler and Eric Seidel.

        Add layoutTestController.setPrinting()
        https://bugs.webkit.org/show_bug.cgi?id=37203

        * DumpRenderTree/LayoutTestController.cpp:
        (LayoutTestController::LayoutTestController):
        (setPrintingCallback):
        (LayoutTestController::staticFunctions):
        * DumpRenderTree/LayoutTestController.h:
        (LayoutTestController::isPrinting):
        (LayoutTestController::setIsPrinting):
        * DumpRenderTree/mac/DumpRenderTree.mm:
        (dump):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@58386 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 77d5c0cd
2010-04-27 Shinichiro Hamaji <hamaji@chromium.org>
Reviewed by Darin Adler and Eric Seidel.
Add layoutTestController.setPrinting()
https://bugs.webkit.org/show_bug.cgi?id=37203
Now we can test media queries with the new function because the
render tree has the color information of the box.
Note that the pixel test is currently failing. We'll need another
patch to enable printing mode for pixel tests.
* platform/mac/Skipped:
* platform/mac/printing/media-queries-print-expected.checksum: Added.
* platform/mac/printing/media-queries-print-expected.png: Added.
* platform/mac/printing/media-queries-print-expected.txt: Added.
* printing/media-queries-print.html:
2010-04-27 Yuzo Fujishima <yuzo@google.com>
 
Reviewed by Eric Seidel.
......
......@@ -37,7 +37,6 @@ svg/batik/text/smallFonts.svg
# see bug https://bugs.webkit.org/show_bug.cgi?id=20011 -- Printing tests should use ImageDiff
printing/compositing-layer-printing.html
printing/media-queries-print.html
# Skip because fix for https://bugs.webkit.org/show_bug.cgi?id=26770 was reverted
compositing/animation/animated-composited-inside-hidden.html
......
......@@ -16,7 +16,7 @@ div {
</style>
<script>
if (window.layoutTestController)
layoutTestController.printToPDF();
layoutTestController.setPrinting();
</script>
<body>
<div></div>
......
2010-04-27 Shinichiro Hamaji <hamaji@chromium.org>
Reviewed by Darin Adler and Eric Seidel.
Add layoutTestController.setPrinting()
https://bugs.webkit.org/show_bug.cgi?id=37203
Added RenderAsTextPrintingMode as a behavior of externalRepresentation.
Now ~PrintContext() calls end() automatically.
* page/PrintContext.cpp:
(WebCore::PrintContext::~PrintContext):
* rendering/RenderTreeAsText.cpp:
(WebCore::externalRepresentation):
* rendering/RenderTreeAsText.h:
(WebCore::):
2010-04-27 Yuzo Fujishima <yuzo@google.com>
 
Reviewed by Eric Seidel.
......@@ -38,7 +38,8 @@ PrintContext::PrintContext(Frame* frame)
PrintContext::~PrintContext()
{
ASSERT(!m_isPrinting);
if (m_isPrinting)
end();
m_pageRects.clear();
}
......
......@@ -34,6 +34,7 @@
#include "HTMLElement.h"
#include "HTMLNames.h"
#include "InlineTextBox.h"
#include "PrintContext.h"
#include "RenderBR.h"
#include "RenderFileUploadControl.h"
#include "RenderInline.h"
......@@ -43,6 +44,7 @@
#include "RenderTableCell.h"
#include "RenderView.h"
#include "RenderWidget.h"
#include "Screen.h"
#include "SelectionController.h"
#include "TextStream.h"
#include <wtf/UnusedParam.h>
......@@ -617,6 +619,10 @@ static void writeSelection(TextStream& ts, const RenderObject* o)
String externalRepresentation(Frame* frame, RenderAsTextBehavior behavior)
{
PrintContext printContext(frame);
if (behavior & RenderAsTextPrintingMode)
printContext.begin(frame->domWindow()->screen()->width());
frame->document()->updateLayout();
RenderObject* o = frame->contentRenderer();
......
......@@ -39,10 +39,12 @@ enum RenderAsTextBehaviorFlags {
RenderAsTextShowAllLayers = 1 << 0, // Dump all layers, not just those that would paint.
RenderAsTextShowLayerNesting = 1 << 1, // Annotate the layer lists.
RenderAsTextShowCompositedLayers = 1 << 2, // Show which layers are composited.
RenderAsTextShowAddresses = 1 << 3 // Show layer and renderer addresses.
RenderAsTextShowAddresses = 1 << 3, // Show layer and renderer addresses.
RenderAsTextPrintingMode = 1 << 4 // Dump the tree in printing mode.
};
typedef unsigned RenderAsTextBehavior;
// You don't need pageWidthInPixels if you don't specify RenderAsTextInPrintingMode.
String externalRepresentation(Frame*, RenderAsTextBehavior = RenderAsTextBehaviorNormal);
void write(TextStream&, const RenderObject&, int indent = 0, RenderAsTextBehavior = RenderAsTextBehaviorNormal);
......
2010-04-27 Shinichiro Hamaji <hamaji@chromium.org>
Reviewed by Darin Adler and Eric Seidel.
Add layoutTestController.setPrinting()
https://bugs.webkit.org/show_bug.cgi?id=37203
* Misc/WebCoreStatistics.h:
* Misc/WebCoreStatistics.mm:
(-[WebFrame renderTreeAsExternalRepresentationForPrinting:]):
2010-04-25 Sam Weinig <sam@webkit.org>
Reviewed by Maciej Stachowiak.
......
......@@ -83,7 +83,7 @@
@end
@interface WebFrame (WebKitDebug)
- (NSString *)renderTreeAsExternalRepresentation;
- (NSString *)renderTreeAsExternalRepresentationForPrinting:(BOOL)forPrinting;
- (NSString *)counterValueForElement:(DOMElement*)element;
- (int)pageNumberForElement:(DOMElement*)element:(float)pageWidthInPixels:(float)pageHeightInPixels;
- (int)numberOfPages:(float)pageWidthInPixels:(float)pageHeightInPixels;
......
......@@ -255,9 +255,9 @@ using namespace WebCore;
@implementation WebFrame (WebKitDebug)
- (NSString *)renderTreeAsExternalRepresentation
- (NSString *)renderTreeAsExternalRepresentationForPrinting:(BOOL)forPrinting
{
return externalRepresentation(_private->coreFrame);
return externalRepresentation(_private->coreFrame, forPrinting ? RenderAsTextPrintingMode : RenderAsTextBehaviorNormal);
}
- (NSString *)counterValueForElement:(DOMElement*)element
......
2010-04-27 Shinichiro Hamaji <hamaji@chromium.org>
Reviewed by Darin Adler and Eric Seidel.
Add layoutTestController.setPrinting()
https://bugs.webkit.org/show_bug.cgi?id=37203
* DumpRenderTree/LayoutTestController.cpp:
(LayoutTestController::LayoutTestController):
(setPrintingCallback):
(LayoutTestController::staticFunctions):
* DumpRenderTree/LayoutTestController.h:
(LayoutTestController::isPrinting):
(LayoutTestController::setIsPrinting):
* DumpRenderTree/mac/DumpRenderTree.mm:
(dump):
2010-04-27 Michael Nordman <michaeln@google.com>
 
Reviewed by Dmitry Titov.
......@@ -76,6 +76,7 @@ LayoutTestController::LayoutTestController(const std::string& testPathOrURL, con
, m_isGeolocationPermissionSet(false)
, m_geolocationPermission(false)
, m_handlesAuthenticationChallenges(false)
, m_isPrinting(false)
, m_testPathOrURL(testPathOrURL)
, m_expectedPixelHash(expectedPixelHash)
{
......@@ -959,6 +960,13 @@ static JSValueRef setSpatialNavigationEnabledCallback(JSContextRef context, JSOb
return JSValueMakeUndefined(context);
}
static JSValueRef setPrintingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
controller->setIsPrinting(true);
return JSValueMakeUndefined(context);
}
static JSValueRef setFrameFlatteningEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
......@@ -1582,6 +1590,7 @@ JSStaticFunction* LayoutTestController::staticFunctions()
{ "setPOSIXLocale", setPOSIXLocaleCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "setPersistentUserStyleSheetLocation", setPersistentUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "setPopupBlockingEnabled", setPopupBlockingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "setPrinting", setPrintingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "setPrivateBrowsingEnabled", setPrivateBrowsingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "setSelectTrailingWhitespaceEnabled", setSelectTrailingWhitespaceEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "setSmartInsertDeleteEnabled", setSmartInsertDeleteEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
......
......@@ -211,6 +211,9 @@ public:
bool handlesAuthenticationChallenges() const { return m_handlesAuthenticationChallenges; }
void setHandlesAuthenticationChallenges(bool handlesAuthenticationChallenges) { m_handlesAuthenticationChallenges = handlesAuthenticationChallenges; }
bool isPrinting() const { return m_isPrinting; }
void setIsPrinting(bool isPrinting) { m_isPrinting = isPrinting; }
const std::string& authenticationUsername() const { return m_authenticationUsername; }
void setAuthenticationUsername(std::string username) { m_authenticationUsername = username; }
......@@ -301,6 +304,7 @@ private:
bool m_isGeolocationPermissionSet;
bool m_geolocationPermission;
bool m_handlesAuthenticationChallenges;
bool m_isPrinting;
std::string m_authenticationUsername;
std::string m_authenticationPassword;
......
......@@ -1085,7 +1085,7 @@ void dump()
resultMimeType = @"application/x-webarchive";
} else {
sizeWebViewForCurrentTest();
resultString = [mainFrame renderTreeAsExternalRepresentation];
resultString = [mainFrame renderTreeAsExternalRepresentationForPrinting:gLayoutTestController->isPrinting()];
}
if (resultString && !resultData)
......@@ -1116,6 +1116,7 @@ void dump()
}
if (dumpPixels && !dumpAsText)
// FIXME: when isPrinting is set, dump the image with page separators.
dumpWebViewAsPixelsAndCompareWithExpected(gLayoutTestController->expectedPixelHash());
puts("#EOF"); // terminate the (possibly empty) pixels block
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment