2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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/. */
|
2006-03-30 09:56:38 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* implementation of interface that allows layout-debug extension access
|
|
|
|
* to some internals of layout
|
|
|
|
*/
|
|
|
|
|
1999-05-06 00:42:51 +04:00
|
|
|
#include "nsILayoutDebugger.h"
|
2009-08-21 01:52:48 +04:00
|
|
|
#include "nsFrame.h"
|
2006-01-26 05:29:17 +03:00
|
|
|
#include "nsDisplayList.h"
|
2011-01-04 06:56:57 +03:00
|
|
|
#include "FrameLayerBuilder.h"
|
1999-05-06 00:42:51 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
#include <stdio.h>
|
1999-05-06 00:42:51 +04:00
|
|
|
|
2011-01-04 06:56:57 +03:00
|
|
|
using namespace mozilla::layers;
|
|
|
|
|
2012-06-25 23:59:42 +04:00
|
|
|
#ifdef DEBUG
|
1999-05-06 00:42:51 +04:00
|
|
|
class nsLayoutDebugger : public nsILayoutDebugger {
|
|
|
|
public:
|
|
|
|
nsLayoutDebugger();
|
|
|
|
virtual ~nsLayoutDebugger();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHOD SetShowFrameBorders(bool aEnable);
|
1999-05-06 00:42:51 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHOD GetShowFrameBorders(bool* aResult);
|
1999-05-06 00:42:51 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHOD SetShowEventTargetFrameBorder(bool aEnable);
|
2000-02-03 05:49:58 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHOD GetShowEventTargetFrameBorder(bool* aResult);
|
2000-02-03 05:49:58 +03:00
|
|
|
|
1999-05-06 00:42:51 +04:00
|
|
|
NS_IMETHOD GetContentSize(nsIDocument* aDocument,
|
|
|
|
PRInt32* aSizeInBytesResult);
|
|
|
|
|
|
|
|
NS_IMETHOD GetFrameSize(nsIPresShell* aPresentation,
|
|
|
|
PRInt32* aSizeInBytesResult);
|
|
|
|
|
|
|
|
NS_IMETHOD GetStyleSize(nsIPresShell* aPresentation,
|
|
|
|
PRInt32* aSizeInBytesResult);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
NS_NewLayoutDebugger(nsILayoutDebugger** aResult)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aResult, "null OUT ptr");
|
|
|
|
if (!aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
nsLayoutDebugger* it = new nsLayoutDebugger();
|
2001-01-04 23:44:42 +03:00
|
|
|
return it->QueryInterface(NS_GET_IID(nsILayoutDebugger), (void**)aResult);
|
1999-05-06 00:42:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsLayoutDebugger::nsLayoutDebugger()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsLayoutDebugger::~nsLayoutDebugger()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-08-21 05:48:11 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(nsLayoutDebugger, nsILayoutDebugger)
|
1999-05-06 00:42:51 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsLayoutDebugger::SetShowFrameBorders(bool aEnable)
|
1999-05-06 00:42:51 +04:00
|
|
|
{
|
2009-08-21 01:52:48 +04:00
|
|
|
nsFrame::ShowFrameBorders(aEnable);
|
1999-05-06 00:42:51 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsLayoutDebugger::GetShowFrameBorders(bool* aResult)
|
1999-05-06 00:42:51 +04:00
|
|
|
{
|
2009-08-21 01:52:48 +04:00
|
|
|
*aResult = nsFrame::GetShowFrameBorders();
|
1999-05-06 00:42:51 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-02-03 05:49:58 +03:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsLayoutDebugger::SetShowEventTargetFrameBorder(bool aEnable)
|
2000-02-03 05:49:58 +03:00
|
|
|
{
|
2009-08-21 01:52:48 +04:00
|
|
|
nsFrame::ShowEventTargetFrameBorder(aEnable);
|
2000-02-03 05:49:58 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsLayoutDebugger::GetShowEventTargetFrameBorder(bool* aResult)
|
2000-02-03 05:49:58 +03:00
|
|
|
{
|
2009-08-21 01:52:48 +04:00
|
|
|
*aResult = nsFrame::GetShowEventTargetFrameBorder();
|
2000-02-03 05:49:58 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-05-06 00:42:51 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLayoutDebugger::GetContentSize(nsIDocument* aDocument,
|
|
|
|
PRInt32* aSizeInBytesResult)
|
|
|
|
{
|
|
|
|
*aSizeInBytesResult = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLayoutDebugger::GetFrameSize(nsIPresShell* aPresentation,
|
|
|
|
PRInt32* aSizeInBytesResult)
|
|
|
|
{
|
|
|
|
*aSizeInBytesResult = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLayoutDebugger::GetStyleSize(nsIPresShell* aPresentation,
|
|
|
|
PRInt32* aSizeInBytesResult)
|
|
|
|
{
|
|
|
|
*aSizeInBytesResult = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2011-11-17 07:44:16 +04:00
|
|
|
#endif
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2011-11-17 07:44:16 +04:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2006-01-26 05:29:17 +03:00
|
|
|
static void
|
|
|
|
PrintDisplayListTo(nsDisplayListBuilder* aBuilder, const nsDisplayList& aList,
|
2012-03-01 12:26:09 +04:00
|
|
|
FILE* aOutput)
|
2006-01-26 05:29:17 +03:00
|
|
|
{
|
2012-03-01 12:26:09 +04:00
|
|
|
fprintf(aOutput, "<ul>");
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
for (nsDisplayItem* i = aList.GetBottom(); i != nullptr; i = i->GetAbove()) {
|
2011-11-17 07:44:16 +04:00
|
|
|
#ifdef DEBUG
|
2010-07-16 01:08:09 +04:00
|
|
|
if (aList.DidComputeVisibility() && i->GetVisibleRect().IsEmpty())
|
|
|
|
continue;
|
2011-11-17 07:44:16 +04:00
|
|
|
#endif
|
2012-03-01 12:26:09 +04:00
|
|
|
fprintf(aOutput, "<li>");
|
2006-01-26 05:29:17 +03:00
|
|
|
nsIFrame* f = i->GetUnderlyingFrame();
|
|
|
|
nsAutoString fName;
|
2011-11-17 07:44:16 +04:00
|
|
|
#ifdef DEBUG
|
2009-08-21 01:52:48 +04:00
|
|
|
if (f) {
|
|
|
|
f->GetFrameName(fName);
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
2011-11-17 07:44:16 +04:00
|
|
|
#endif
|
2012-04-10 15:24:18 +04:00
|
|
|
bool snap;
|
|
|
|
nsRect rect = i->GetBounds(aBuilder, &snap);
|
2006-01-26 05:29:17 +03:00
|
|
|
switch (i->GetType()) {
|
2010-09-09 19:21:46 +04:00
|
|
|
case nsDisplayItem::TYPE_CLIP:
|
|
|
|
case nsDisplayItem::TYPE_CLIP_ROUNDED_RECT: {
|
2007-07-08 11:08:04 +04:00
|
|
|
nsDisplayClip* c = static_cast<nsDisplayClip*>(i);
|
2006-01-26 05:29:17 +03:00
|
|
|
rect = c->GetClipRect();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2010-05-13 04:56:11 +04:00
|
|
|
nscolor color;
|
2010-07-19 06:23:48 +04:00
|
|
|
nsRect vis = i->GetVisibleRect();
|
2012-07-23 07:00:36 +04:00
|
|
|
nsRect component = i->GetComponentAlphaBounds(aBuilder);
|
2010-08-28 03:15:08 +04:00
|
|
|
nsDisplayList* list = i->GetList();
|
2011-01-03 04:48:09 +03:00
|
|
|
nsRegion opaque;
|
2011-08-27 04:01:46 +04:00
|
|
|
if (i->GetType() == nsDisplayItem::TYPE_TRANSFORM) {
|
|
|
|
nsDisplayTransform* t = static_cast<nsDisplayTransform*>(i);
|
|
|
|
list = t->GetStoredList()->GetList();
|
|
|
|
}
|
2011-11-17 07:44:16 +04:00
|
|
|
#ifdef DEBUG
|
2011-01-03 04:48:09 +03:00
|
|
|
if (!list || list->DidComputeVisibility()) {
|
2012-05-03 08:29:05 +04:00
|
|
|
opaque = i->GetOpaqueRegion(aBuilder, &snap);
|
2011-01-03 04:48:09 +03:00
|
|
|
}
|
2011-11-17 07:44:16 +04:00
|
|
|
#endif
|
2012-03-01 12:26:09 +04:00
|
|
|
if (i->Painted()) {
|
|
|
|
nsCString string(i->Name());
|
|
|
|
string.Append("-");
|
|
|
|
string.AppendInt((PRUint64)i);
|
|
|
|
fprintf(aOutput, "<a href=\"javascript:ViewImage('%s')\">", string.BeginReading());
|
|
|
|
}
|
2012-07-23 07:00:36 +04:00
|
|
|
fprintf(aOutput, "%s %p(%s) (%d,%d,%d,%d)(%d,%d,%d,%d)(%d,%d,%d,%d)%s",
|
2010-07-19 06:23:48 +04:00
|
|
|
i->Name(), (void*)f, NS_ConvertUTF16toUTF8(fName).get(),
|
2006-01-26 05:29:17 +03:00
|
|
|
rect.x, rect.y, rect.width, rect.height,
|
2010-07-19 06:23:48 +04:00
|
|
|
vis.x, vis.y, vis.width, vis.height,
|
2012-07-23 07:00:36 +04:00
|
|
|
component.x, component.y, component.width, component.height,
|
2010-08-13 13:54:37 +04:00
|
|
|
i->IsUniform(aBuilder, &color) ? " uniform" : "");
|
2012-07-23 07:00:36 +04:00
|
|
|
nsRegionRectIterator iter(opaque);
|
|
|
|
for (const nsRect* r = iter.Next(); r; r = iter.Next()) {
|
|
|
|
printf("(opaque %d,%d,%d,%d)", r->x, r->y, r->width, r->height);
|
|
|
|
}
|
2012-03-01 12:26:09 +04:00
|
|
|
if (i->Painted()) {
|
|
|
|
fprintf(aOutput, "</a>");
|
|
|
|
}
|
2011-01-04 06:56:57 +03:00
|
|
|
if (f) {
|
|
|
|
PRUint32 key = i->GetPerFrameKey();
|
2012-07-17 21:03:51 +04:00
|
|
|
Layer* layer = mozilla::FrameLayerBuilder::GetDebugOldLayerFor(f, key);
|
2011-01-04 06:56:57 +03:00
|
|
|
if (layer) {
|
2012-03-01 12:26:09 +04:00
|
|
|
fprintf(aOutput, " <a href=\"#%p\">layer=%p</a>", layer, layer);
|
2011-01-04 06:56:57 +03:00
|
|
|
}
|
|
|
|
}
|
2011-11-17 07:44:16 +04:00
|
|
|
if (i->GetType() == nsDisplayItem::TYPE_SVG_EFFECTS) {
|
|
|
|
(static_cast<nsDisplaySVGEffects*>(i))->PrintEffects(aOutput);
|
|
|
|
}
|
2011-01-04 06:56:57 +03:00
|
|
|
fputc('\n', aOutput);
|
2006-01-26 05:29:17 +03:00
|
|
|
if (list) {
|
2012-03-01 12:26:09 +04:00
|
|
|
PrintDisplayListTo(aBuilder, *list, aOutput);
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
2012-03-01 12:26:09 +04:00
|
|
|
fprintf(aOutput, "</li>");
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
2012-03-01 12:26:09 +04:00
|
|
|
|
|
|
|
fprintf(aOutput, "</ul>");
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-08-21 01:52:48 +04:00
|
|
|
nsFrame::PrintDisplayList(nsDisplayListBuilder* aBuilder,
|
2012-03-01 12:26:09 +04:00
|
|
|
const nsDisplayList& aList,
|
|
|
|
FILE* aFile)
|
2006-01-26 05:29:17 +03:00
|
|
|
{
|
2012-03-01 12:26:09 +04:00
|
|
|
PrintDisplayListTo(aBuilder, aList, aFile);
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|