Commit 360f0c63 authored by cmarrin@apple.com's avatar cmarrin@apple.com
Browse files

Added layerTreeAsText function to DRT (for Mac)

        https://bugs.webkit.org/show_bug.cgi?id=36782



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@56934 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 36d22b57
2010-04-01 Chris Marrin <cmarrin@apple.com>
Reviewed by Simon Fraser.
Added layerTreeAsText function to DRT (for Mac)
https://bugs.webkit.org/show_bug.cgi?id=36782
Sample test to show functionality. This test shows a case where the compositing
was corrupted on Windows. This was fixed in http://trac.webkit.org/changeset/56200.
Results are platform specific because the layer tree output contains positions and
sizes that will be different on Mac and Windows.
* compositing/geometry/preserve-3d-switching-expected.txt: Added.
* compositing/geometry/preserve-3d-switching.html: Added.
2010-04-01 Chris Fleizach <cfleizach@apple.com>
Reviewed by Beth Dakin.
......
The green box appear angled out from the yellow box and embedded in it.
-webkit-transform: translateZ(-100px) rotateY(45deg);
(GraphicsLayer
(position 0.00 0.00)
(anchor 0.50 0.50)
(bounds 800.00 600.00)
(opacity 1.00)
(usingTiledLayer 0)
(preserves3D 0)
(drawsContent 0)
(backfaceVisibility visible)
(backgroundColor none)
(transform identity)
(childrenTransform identity)
(children 1
(GraphicsLayer
(position 0.00 0.00)
(anchor 0.50 0.50)
(bounds 800.00 600.00)
(opacity 1.00)
(usingTiledLayer 0)
(preserves3D 0)
(drawsContent 0)
(backfaceVisibility visible)
(backgroundColor none)
(transform identity)
(childrenTransform identity)
(children 1
(GraphicsLayer
(position 108.00 73.00)
(anchor 0.50 0.50)
(bounds 304.00 304.00)
(opacity 1.00)
(usingTiledLayer 0)
(preserves3D 0)
(drawsContent 1)
(backfaceVisibility visible)
(backgroundColor none)
(transform identity)
(childrenTransform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 -0.00] [0.00 0.00 0.00 1.00])
(children 1
(GraphicsLayer
(position 12.00 12.00)
(anchor 0.50 0.50)
(bounds 280.00 280.00)
(opacity 0.80)
(usingTiledLayer 0)
(preserves3D 1)
(drawsContent 1)
(backfaceVisibility visible)
(backgroundColor none)
(transform [0.77 -0.56 -0.32 0.00] [0.00 0.50 -0.87 0.00] [0.64 0.66 0.38 0.00] [0.00 0.00 0.00 1.00])
(childrenTransform identity)
(children 1
(GraphicsLayer
(position 40.00 40.00)
(anchor 0.50 0.50)
(bounds 200.00 200.00)
(opacity 0.70)
(usingTiledLayer 0)
(preserves3D 0)
(drawsContent 1)
(backfaceVisibility visible)
(backgroundColor none)
(transform [0.77 0.00 0.64 0.00] [0.00 1.00 0.00 0.00] [-0.64 0.00 0.77 0.00] [0.00 0.00 50.00 1.00])
(childrenTransform identity)
)
)
)
)
)
)
)
)
)
<!DOCTYPE>
<html>
<head>
<title>Switching layer in and out of preserve-3d</title>
<style type="text/css" media="screen">
body {
font-family: 'Lucida Grande', Verdana, Arial;
font-size: 12px;
}
#container {
position: relative;
height: 300px;
width: 300px;
margin: 50px 100px;
border: 2px solid blue;
-webkit-perspective: 500;
}
#parent {
margin: 10px;
width: 280px;
height: 280px;
background-color: yellow;
opacity: 0.8;
-webkit-transform-style: preserve-3d;
-webkit-transform: rotateX(-60deg) rotateY(40deg);
}
#parent > div {
position: absolute;
top: 40px;
left: 40px;
width: 200px;
height: 200px;
padding: 10px;
-webkit-box-sizing: border-box;
font-family: monospace;
font-size: 12pt;
}
#parent > :first-child {
background-color: green;
opacity:0.7;
-webkit-transform: translateZ(50px) rotateY(-40deg);
}
</style>
<script type="text/javascript" charset="utf-8">
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
timeout = 100;
function startProgram()
{
setTimeout(function()
{
document.getElementById("parent").style.webkitTransformStyle = "flat";
setTimeout(function()
{
document.getElementById("parent").style.webkitTransformStyle = "preserve-3d";
setTimeout(function()
{
if (window.layoutTestController) {
if (layoutTestController.layerTreeAsText) {
var layerTree = layoutTestController.layerTreeAsText();
document.getElementById("layerTree").innerHTML = "<pre>" + layerTree + "</pre>";
}
layoutTestController.notifyDone();
}
}, timeout);
}, timeout);
}, timeout);
}
window.addEventListener('load', startProgram, false)
</script>
</head>
<body>
<p>The green box appear angled out from the yellow box and embedded in it.</p>
<div id="container">
<div id="parent">
<div>-webkit-transform: translateZ(-100px) rotateY(45deg);</div>
</div>
<div id="layerTree"></div>
</div>
</body>
</html>
......@@ -795,6 +795,7 @@ __ZN7WebCoreeqERKNS_19ResourceRequestBaseES2_
__ZN7WebCoreplEPKcRKNS_6StringE
__ZN7WebCoreplERKNS_6StringES2_
__ZNK3JSC8Bindings10RootObject12globalObjectEv
__ZNK7WebCore5Frame15layerTreeAsTextEv
__ZNK7WebCore10FloatPointcv8_NSPointEv
__ZNK7WebCore10PluginData16supportsMimeTypeERKNS_6StringE
__ZNK7WebCore10RenderText16linesBoundingBoxEv
......
......@@ -49,6 +49,7 @@
#include "FrameLoaderClient.h"
#include "FrameView.h"
#include "GraphicsContext.h"
#include "GraphicsLayer.h"
#include "HTMLDocument.h"
#include "HTMLFormControlElement.h"
#include "HTMLFormElement.h"
......@@ -63,6 +64,7 @@
#include "Page.h"
#include "PageGroup.h"
#include "RegularExpression.h"
#include "RenderLayerCompositor.h"
#include "RenderPart.h"
#include "RenderTableCell.h"
#include "RenderTextControl.h"
......@@ -1854,4 +1856,18 @@ IntRect Frame::tiledBackingStoreContentsRect()
}
#endif
#if USE(ACCELERATED_COMPOSITING)
String Frame::layerTreeAsText() const
{
if (!contentRenderer())
return String();
GraphicsLayer* rootLayer = contentRenderer()->compositor()->rootPlatformLayer();
if (!rootLayer)
return String();
return rootLayer->layerTreeAsText();
}
#endif
} // namespace WebCore
......@@ -122,6 +122,10 @@ namespace WebCore {
ScrollbarMode = ScrollbarAuto, ScrollbarMode = ScrollbarAuto);
void injectUserScripts(UserScriptInjectionTime);
#if USE(ACCELERATED_COMPOSITING)
String layerTreeAsText() const;
#endif
private:
void injectUserScriptsForWorld(DOMWrapperWorld*, const UserScriptVector&, UserScriptInjectionTime);
......
......@@ -32,6 +32,7 @@
#include "FloatPoint.h"
#include "RotateTransformOperation.h"
#include "TextStream.h"
#include <wtf/text/CString.h>
namespace WebCore {
......@@ -388,17 +389,23 @@ static void writeIndent(TextStream& ts, int indent)
ts << " ";
}
void GraphicsLayer::dumpLayer(TextStream& ts, int indent) const
void GraphicsLayer::dumpLayer(TextStream& ts, int indent, LayerTreeAsTextBehavior behavior) const
{
writeIndent(ts, indent);
ts << "(" << "GraphicsLayer" << " " << static_cast<void*>(const_cast<GraphicsLayer*>(this));
ts << " \"" << m_name << "\"\n";
dumpProperties(ts, indent);
ts << "(" << "GraphicsLayer";
if (behavior & LayerTreeAsTextDebug) {
ts << " " << static_cast<void*>(const_cast<GraphicsLayer*>(this));
ts << " \"" << m_name << "\"";
}
ts << "\n";
dumpProperties(ts, indent, behavior);
writeIndent(ts, indent);
ts << ")\n";
}
void GraphicsLayer::dumpProperties(TextStream& ts, int indent) const
void GraphicsLayer::dumpProperties(TextStream& ts, int indent, LayerTreeAsTextBehavior behavior) const
{
writeIndent(ts, indent + 1);
ts << "(position " << m_position.x() << " " << m_position.y() << ")\n";
......@@ -416,21 +423,23 @@ void GraphicsLayer::dumpProperties(TextStream& ts, int indent) const
ts << "(usingTiledLayer " << m_usingTiledLayer << ")\n";
writeIndent(ts, indent + 1);
ts << "(m_preserves3D " << m_preserves3D << ")\n";
ts << "(preserves3D " << m_preserves3D << ")\n";
writeIndent(ts, indent + 1);
ts << "(drawsContent " << m_drawsContent << ")\n";
writeIndent(ts, indent + 1);
ts << "(m_backfaceVisibility " << (m_backfaceVisibility ? "visible" : "hidden") << ")\n";
ts << "(backfaceVisibility " << (m_backfaceVisibility ? "visible" : "hidden") << ")\n";
writeIndent(ts, indent + 1);
ts << "(client ";
if (m_client)
ts << static_cast<void*>(m_client);
else
ts << "none";
ts << ")\n";
if (behavior & LayerTreeAsTextDebug) {
ts << "(";
if (m_client)
ts << "client " << static_cast<void*>(m_client);
else
ts << "no client";
ts << ")\n";
}
writeIndent(ts, indent + 1);
ts << "(backgroundColor ";
......@@ -466,13 +475,19 @@ void GraphicsLayer::dumpProperties(TextStream& ts, int indent) const
if (m_replicaLayer) {
writeIndent(ts, indent + 1);
ts << "(replica layer " << m_replicaLayer << ")\n";
m_replicaLayer->dumpLayer(ts, indent+2);
ts << "(replica layer";
if (behavior & LayerTreeAsTextDebug)
ts << " " << m_replicaLayer;
ts << ")\n";
m_replicaLayer->dumpLayer(ts, indent + 2, behavior);
}
if (m_replicatedLayer) {
writeIndent(ts, indent + 1);
ts << "(replicated layer " << m_replicatedLayer << ")\n";
ts << "(replicated layer";
if (behavior & LayerTreeAsTextDebug)
ts << " " << m_replicatedLayer;;
ts << ")\n";
}
if (m_children.size()) {
......@@ -481,12 +496,31 @@ void GraphicsLayer::dumpProperties(TextStream& ts, int indent) const
unsigned i;
for (i = 0; i < m_children.size(); i++)
m_children[i]->dumpLayer(ts, indent+2);
m_children[i]->dumpLayer(ts, indent + 2, behavior);
writeIndent(ts, indent + 1);
ts << ")\n";
}
}
String GraphicsLayer::layerTreeAsText(LayerTreeAsTextBehavior behavior) const
{
TextStream ts;
dumpLayer(ts, 0, behavior);
return ts.release();
}
} // namespace WebCore
#ifndef NDEBUG
void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer)
{
if (!layer)
return;
WebCore::String output = layer->layerTreeAsText(LayerTreeAsTextDebug);
fprintf(stderr, "%s\n", output.utf8().data());
}
#endif
#endif // USE(ACCELERATED_COMPOSITING)
......@@ -74,6 +74,12 @@ typedef void* PlatformLayer;
typedef void* NativeLayer;
#endif
enum LayerTreeAsTextBehaviorFlags {
LayerTreeAsTextBehaviorNormal = 0,
LayerTreeAsTextDebug = 1 << 0, // Dump extra debugging info like layer addresses.
};
typedef unsigned LayerTreeAsTextBehavior;
namespace WebCore {
class FloatPoint3D;
......@@ -304,7 +310,7 @@ public:
virtual PlatformLayer* platformLayer() const { return 0; }
void dumpLayer(TextStream&, int indent = 0) const;
void dumpLayer(TextStream&, int indent = 0, LayerTreeAsTextBehavior = LayerTreeAsTextBehaviorNormal) const;
int repaintCount() const { return m_repaintCount; }
int incrementRepaintCount() { return ++m_repaintCount; }
......@@ -339,6 +345,10 @@ public:
// Some compositing systems may do internal batching to synchronize compositing updates
// with updates drawn into the window. This is a signal to flush any internal batched state.
virtual void syncCompositingState() { }
// Return a string with a human readable form of the layer tree, If debug is true
// pointers for the layers and timing data will be included in the returned string.
String layerTreeAsText(LayerTreeAsTextBehavior = LayerTreeAsTextBehaviorNormal) const;
protected:
......@@ -355,7 +365,7 @@ protected:
GraphicsLayer(GraphicsLayerClient*);
void dumpProperties(TextStream&, int indent) const;
void dumpProperties(TextStream&, int indent, LayerTreeAsTextBehavior) const;
GraphicsLayerClient* m_client;
String m_name;
......@@ -404,6 +414,11 @@ protected:
} // namespace WebCore
#ifndef NDEBUG
// Outside the WebCore namespace for ease of invocation from gdb.
void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer);
#endif
#endif // USE(ACCELERATED_COMPOSITING)
#endif // GraphicsLayer_h
......
2010-04-01 Chris Marrin <cmarrin@apple.com>
Reviewed by Simon Fraser.
Added layerTreeAsText function to DRT (for Mac)
https://bugs.webkit.org/show_bug.cgi?id=36782
This is the WebKit side for Mac. It plumbs the
call from WebCore to DRT.
* WebView/WebFrame.mm:WebKit (Mac) side of plumbing
(-[WebFrame _layerTreeAsText]):
* WebView/WebFramePrivate.h:
2010-04-01 Alexey Proskuryakov <ap@apple.com>
Reviewed by Oliver Hunt.
......
......@@ -1310,6 +1310,15 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
#endif
}
- (NSString*)_layerTreeAsText
{
Frame* coreFrame = _private->coreFrame;
if (!coreFrame)
return @"";
return coreFrame->layerTreeAsText();
}
@end
@implementation WebFrame
......
......@@ -133,4 +133,7 @@ typedef enum {
// Sets the name presented to accessibility clients for the web area object.
- (void)setAccessibleName:(NSString *)name;
- (NSString*)_layerTreeAsText;
@end
2010-04-01 Chris Marrin <cmarrin@apple.com>
Reviewed by Simon Fraser.
Added layerTreeAsText function to DRT (for Mac)
https://bugs.webkit.org/show_bug.cgi?id=36782
This is the WebKit side for Windows. It plumbs the
call from WebCore to DRT.
* Interfaces/IWebFramePrivate.idl:
* WebFrame.cpp:WebKit (Windows) side of plumbing
(WebFrame::layerTreeAsText):
* WebFrame.h:
2010-03-31 Marcus Bulach <bulach@chromium.org>
Reviewed by Jeremy Orlow.
......
......@@ -108,4 +108,6 @@ interface IWebFramePrivate : IUnknown
HRESULT pageNumberForElementById([in] BSTR id, [in] float pageWidthInPixels, [in] float pageHeightInPixels, [out, retval] int* pageNumber);
HRESULT numberOfPages([in] float pageWidthInPixels, [in] float pageHeightInPixels, [out, retval] int* pageNumber);
HRESULT layerTreeAsText([out, retval] BSTR* result);
}
......@@ -1435,6 +1435,25 @@ HRESULT WebFrame::canProvideDocumentSource(bool* result)
return hr;
}
HRESULT STDMETHODCALLTYPE WebFrame::layerTreeAsText(BSTR* result)
{
if (!result)
return E_POINTER;
*result = 0;
Frame* frame = core(this);
if (!frame)
return E_FAIL;
#if USE(ACCELERATED_COMPOSITING)
String text = frame->layerTreeAsText();
#else
String text;
#endif
*result = BString(text).release();
return S_OK;
}
void WebFrame::frameLoaderDestroyed()
{
// The FrameLoader going away is equivalent to the Frame going away,
......@@ -2473,3 +2492,4 @@ void WebFrame::updateBackground()
coreFrame->view()->updateBackgroundRecursively(backgroundColor, webView()->transparent());
}
......@@ -265,6 +265,8 @@ public:
virtual HRESULT STDMETHODCALLTYPE visibleContentRect(RECT*);
virtual HRESULT STDMETHODCALLTYPE layerTreeAsText(BSTR*);
// IWebDocumentText
virtual HRESULT STDMETHODCALLTYPE supportsTextEncoding(
/* [retval][out] */ BOOL* result);
......
2010-04-01 Chris Marrin <cmarrin@apple.com>
Reviewed by Simon Fraser.
Added layerTreeAsText function to DRT (for Mac)
https://bugs.webkit.org/show_bug.cgi?id=36782
This is the DRT side. It exposes the call to JavaScript
through the LayoutTestController.
* DumpRenderTree/LayoutTestController.cpp:Platform independent JavaScript shim
(layerTreeAsTextCallback):
(LayoutTestController::staticFunctions):
* DumpRenderTree/LayoutTestController.h:
* DumpRenderTree/mac/LayoutTestControllerMac.mm:Mac specific plumbing to WebKit
(LayoutTestController::layerTreeAsText):
* DumpRenderTree/win/LayoutTestControllerWin.cpp:Windows specific plumbing to WebKit
(LayoutTestController::layerTreeAsText):
2010-04-01 Kevin Ollivier <kevino@theolliviers.com>
 
[wx] Build fix after addition of JavaScriptCore/wtf/text directory.
......
......@@ -464,6 +464,13 @@ static JSValueRef keepWebHistoryCallback(JSContextRef context, JSObjectRef funct
return JSValueMakeUndefined(context);
}
static JSValueRef layerTreeAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
// Has mac & windows implementation
LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
return JSValueMakeString(context, controller->layerTreeAsText().get());
}
static JSValueRef notifyDoneCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
// Has mac & windows implementation
......@@ -1435,6 +1442,7 @@ JSStaticFunction* LayoutTestController::staticFunctions()
{ "grantDesktopNotificationPermission", grantDesktopNotificationPermissionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "isCommandEnabled", isCommandEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "keepWebHistory", keepWebHistoryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "layerTreeAsText", layerTreeAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "numberOfPages", numberOfPagesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "notifyDone", notifyDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "numberOfActiveAnimations", numberOfActiveAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
......
......@@ -245,6 +245,8 @@ public:
// unit tests outside of DRT once they exist.
void apiTestNewWindowDataLoadBaseURL(JSStringRef utf8Data, JSStringRef baseURL);
void apiTestGoToCurrentBackForwardItem();
JSRetainPtr<JSStringRef> layerTreeAsText() const;
static const unsigned maxViewWidth;
static const unsigned maxViewHeight;
......
......@@ -181,6 +181,12 @@ void LayoutTestController::keepWebHistory()
}
}
JSRetainPtr<JSStringRef> LayoutTestController::layerTreeAsText() const
{
JSRetainPtr<JSStringRef> string(Adopt, JSStringCreateWithCFString((CFStringRef)[mainFrame _layerTreeAsText]));
return string;
}
int LayoutTestController::pageNumberForElementById(JSStringRef id, float pageWidthInPixels, float pageHeightInPixels)
{
RetainPtr<CFStringRef> idCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, id));
......
......@@ -173,6 +173,21 @@ void LayoutTestController::keepWebHistory()
history->setOptionalSharedHistory(sharedHistory.get());