2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* implementation of interface that allows layout-debug extension access
|
|
|
|
* to some internals of layout
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "nsILayoutDebugger.h"
|
2009-08-20 14:52:48 -07:00
|
|
|
#include "nsFrame.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsDisplayList.h"
|
2011-01-03 19:56:57 -08:00
|
|
|
#include "FrameLayerBuilder.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2013-03-04 01:56:02 -08:00
|
|
|
using namespace mozilla;
|
2011-01-03 19:56:57 -08:00
|
|
|
using namespace mozilla::layers;
|
|
|
|
|
2012-06-25 12:59:42 -07:00
|
|
|
#ifdef DEBUG
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsLayoutDebugger : public nsILayoutDebugger {
|
|
|
|
public:
|
|
|
|
nsLayoutDebugger();
|
|
|
|
virtual ~nsLayoutDebugger();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD SetShowFrameBorders(bool aEnable);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD GetShowFrameBorders(bool* aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD SetShowEventTargetFrameBorder(bool aEnable);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD GetShowEventTargetFrameBorder(bool* aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMETHOD GetContentSize(nsIDocument* aDocument,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t* aSizeInBytesResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMETHOD GetFrameSize(nsIPresShell* aPresentation,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t* aSizeInBytesResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMETHOD GetStyleSize(nsIPresShell* aPresentation,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t* aSizeInBytesResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
NS_NewLayoutDebugger(nsILayoutDebugger** aResult)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aResult, "null OUT ptr");
|
|
|
|
if (!aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
nsLayoutDebugger* it = new nsLayoutDebugger();
|
|
|
|
return it->QueryInterface(NS_GET_IID(nsILayoutDebugger), (void**)aResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsLayoutDebugger::nsLayoutDebugger()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsLayoutDebugger::~nsLayoutDebugger()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(nsLayoutDebugger, nsILayoutDebugger)
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsLayoutDebugger::SetShowFrameBorders(bool aEnable)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-08-20 14:52:48 -07:00
|
|
|
nsFrame::ShowFrameBorders(aEnable);
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsLayoutDebugger::GetShowFrameBorders(bool* aResult)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-08-20 14:52:48 -07:00
|
|
|
*aResult = nsFrame::GetShowFrameBorders();
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsLayoutDebugger::SetShowEventTargetFrameBorder(bool aEnable)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-08-20 14:52:48 -07:00
|
|
|
nsFrame::ShowEventTargetFrameBorder(aEnable);
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsLayoutDebugger::GetShowEventTargetFrameBorder(bool* aResult)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-08-20 14:52:48 -07:00
|
|
|
*aResult = nsFrame::GetShowEventTargetFrameBorder();
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLayoutDebugger::GetContentSize(nsIDocument* aDocument,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t* aSizeInBytesResult)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
*aSizeInBytesResult = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLayoutDebugger::GetFrameSize(nsIPresShell* aPresentation,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t* aSizeInBytesResult)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
*aSizeInBytesResult = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLayoutDebugger::GetStyleSize(nsIPresShell* aPresentation,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t* aSizeInBytesResult)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
*aSizeInBytesResult = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2011-11-16 19:44:16 -08:00
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-11-16 19:44:16 -08:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2012-08-07 10:57:26 -07:00
|
|
|
static int sPrintDisplayListIndent = 0;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
static void
|
|
|
|
PrintDisplayListTo(nsDisplayListBuilder* aBuilder, const nsDisplayList& aList,
|
2012-08-07 10:57:26 -07:00
|
|
|
FILE* aOutput, bool aDumpHtml)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-08-07 10:57:26 -07:00
|
|
|
if (aDumpHtml) {
|
|
|
|
fprintf(aOutput, "<ul>");
|
|
|
|
}
|
2012-03-01 00:26:09 -08:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
for (nsDisplayItem* i = aList.GetBottom(); i != nullptr; i = i->GetAbove()) {
|
2012-08-07 10:57:26 -07:00
|
|
|
if (aDumpHtml) {
|
|
|
|
fprintf(aOutput, "<li>");
|
|
|
|
} else {
|
|
|
|
sPrintDisplayListIndent ++;
|
2012-08-08 04:46:55 -07:00
|
|
|
for (int indent = 0; indent < sPrintDisplayListIndent; indent++) {
|
|
|
|
fprintf(aOutput, " ");
|
|
|
|
}
|
2012-08-07 10:57:26 -07:00
|
|
|
}
|
2013-04-19 05:02:13 -07:00
|
|
|
nsIFrame* f = i->Frame();
|
2007-03-22 10:30:00 -07:00
|
|
|
nsAutoString fName;
|
2011-11-16 19:44:16 -08:00
|
|
|
#ifdef DEBUG
|
2013-04-19 05:02:13 -07:00
|
|
|
f->GetFrameName(fName);
|
2011-11-16 19:44:16 -08:00
|
|
|
#endif
|
2012-04-10 04:24:18 -07:00
|
|
|
bool snap;
|
|
|
|
nsRect rect = i->GetBounds(aBuilder, &snap);
|
2010-05-12 17:56:11 -07:00
|
|
|
nscolor color;
|
2010-07-18 19:23:48 -07:00
|
|
|
nsRect vis = i->GetVisibleRect();
|
2012-07-22 20:00:36 -07:00
|
|
|
nsRect component = i->GetComponentAlphaBounds(aBuilder);
|
2012-11-02 05:59:03 -07:00
|
|
|
nsDisplayList* list = i->GetChildren();
|
2013-03-04 01:56:02 -08:00
|
|
|
const DisplayItemClip& clip = i->GetClip();
|
2011-01-02 17:48:09 -08:00
|
|
|
nsRegion opaque;
|
2011-11-16 19:44:16 -08:00
|
|
|
#ifdef DEBUG
|
2011-01-02 17:48:09 -08:00
|
|
|
if (!list || list->DidComputeVisibility()) {
|
2012-05-02 21:29:05 -07:00
|
|
|
opaque = i->GetOpaqueRegion(aBuilder, &snap);
|
2011-01-02 17:48:09 -08:00
|
|
|
}
|
2011-11-16 19:44:16 -08:00
|
|
|
#endif
|
2012-08-07 10:57:26 -07:00
|
|
|
if (aDumpHtml && i->Painted()) {
|
2012-03-01 00:26:09 -08:00
|
|
|
nsCString string(i->Name());
|
|
|
|
string.Append("-");
|
2012-08-22 08:56:38 -07:00
|
|
|
string.AppendInt((uint64_t)i);
|
2012-03-01 00:26:09 -08:00
|
|
|
fprintf(aOutput, "<a href=\"javascript:ViewImage('%s')\">", string.BeginReading());
|
|
|
|
}
|
2013-03-04 01:56:02 -08:00
|
|
|
fprintf(aOutput, "%s %p(%s) bounds(%d,%d,%d,%d) visible(%d,%d,%d,%d) componentAlpha(%d,%d,%d,%d) clip(%s) %s",
|
2010-07-18 19:23:48 -07:00
|
|
|
i->Name(), (void*)f, NS_ConvertUTF16toUTF8(fName).get(),
|
2007-03-22 10:30:00 -07:00
|
|
|
rect.x, rect.y, rect.width, rect.height,
|
2010-07-18 19:23:48 -07:00
|
|
|
vis.x, vis.y, vis.width, vis.height,
|
2012-07-22 20:00:36 -07:00
|
|
|
component.x, component.y, component.width, component.height,
|
2013-03-04 01:56:02 -08:00
|
|
|
clip.ToString().get(),
|
2010-08-13 02:54:37 -07:00
|
|
|
i->IsUniform(aBuilder, &color) ? " uniform" : "");
|
2012-07-22 20:00:36 -07:00
|
|
|
nsRegionRectIterator iter(opaque);
|
|
|
|
for (const nsRect* r = iter.Next(); r; r = iter.Next()) {
|
2013-03-04 01:56:02 -08:00
|
|
|
fprintf(aOutput, " (opaque %d,%d,%d,%d)", r->x, r->y, r->width, r->height);
|
2012-08-07 10:57:26 -07:00
|
|
|
}
|
2013-01-29 21:07:30 -08:00
|
|
|
i->WriteDebugInfo(aOutput);
|
2012-08-07 10:57:26 -07:00
|
|
|
if (aDumpHtml && i->Painted()) {
|
2012-03-01 00:26:09 -08:00
|
|
|
fprintf(aOutput, "</a>");
|
|
|
|
}
|
2013-04-19 05:02:13 -07:00
|
|
|
uint32_t key = i->GetPerFrameKey();
|
|
|
|
Layer* layer = mozilla::FrameLayerBuilder::GetDebugOldLayerFor(f, key);
|
|
|
|
if (layer) {
|
|
|
|
if (aDumpHtml) {
|
|
|
|
fprintf(aOutput, " <a href=\"#%p\">layer=%p</a>", layer, layer);
|
|
|
|
} else {
|
|
|
|
fprintf(aOutput, " layer=%p", layer);
|
2011-01-03 19:56:57 -08:00
|
|
|
}
|
|
|
|
}
|
2011-11-16 19:44:16 -08:00
|
|
|
if (i->GetType() == nsDisplayItem::TYPE_SVG_EFFECTS) {
|
|
|
|
(static_cast<nsDisplaySVGEffects*>(i))->PrintEffects(aOutput);
|
|
|
|
}
|
2011-01-03 19:56:57 -08:00
|
|
|
fputc('\n', aOutput);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (list) {
|
2012-08-07 10:57:26 -07:00
|
|
|
PrintDisplayListTo(aBuilder, *list, aOutput, aDumpHtml);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-08-07 10:57:26 -07:00
|
|
|
if (aDumpHtml) {
|
|
|
|
fprintf(aOutput, "</li>");
|
|
|
|
} else {
|
|
|
|
sPrintDisplayListIndent --;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aDumpHtml) {
|
|
|
|
fprintf(aOutput, "</ul>");
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-08-20 14:52:48 -07:00
|
|
|
nsFrame::PrintDisplayList(nsDisplayListBuilder* aBuilder,
|
2012-03-01 00:26:09 -08:00
|
|
|
const nsDisplayList& aList,
|
2012-08-07 10:57:26 -07:00
|
|
|
FILE* aFile,
|
|
|
|
bool aDumpHtml)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-08-07 10:57:26 -07:00
|
|
|
PrintDisplayListTo(aBuilder, aList, aFile, aDumpHtml);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|