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"
|
2014-01-27 02:07:08 +04:00
|
|
|
#include "nsPrintfCString.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
|
|
|
|
2013-03-04 13:56:02 +04:00
|
|
|
using namespace mozilla;
|
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
|
|
|
|
|
2014-02-24 18:41:56 +04:00
|
|
|
NS_IMETHOD SetShowFrameBorders(bool aEnable) MOZ_OVERRIDE;
|
1999-05-06 00:42:51 +04:00
|
|
|
|
2014-02-24 18:41:56 +04:00
|
|
|
NS_IMETHOD GetShowFrameBorders(bool* aResult) MOZ_OVERRIDE;
|
1999-05-06 00:42:51 +04:00
|
|
|
|
2014-02-24 18:41:56 +04:00
|
|
|
NS_IMETHOD SetShowEventTargetFrameBorder(bool aEnable) MOZ_OVERRIDE;
|
2000-02-03 05:49:58 +03:00
|
|
|
|
2014-02-24 18:41:56 +04:00
|
|
|
NS_IMETHOD GetShowEventTargetFrameBorder(bool* aResult) MOZ_OVERRIDE;
|
2000-02-03 05:49:58 +03:00
|
|
|
|
1999-05-06 00:42:51 +04:00
|
|
|
NS_IMETHOD GetContentSize(nsIDocument* aDocument,
|
2014-02-24 18:41:56 +04:00
|
|
|
int32_t* aSizeInBytesResult) MOZ_OVERRIDE;
|
1999-05-06 00:42:51 +04:00
|
|
|
|
|
|
|
NS_IMETHOD GetFrameSize(nsIPresShell* aPresentation,
|
2014-02-24 18:41:56 +04:00
|
|
|
int32_t* aSizeInBytesResult) MOZ_OVERRIDE;
|
1999-05-06 00:42:51 +04:00
|
|
|
|
|
|
|
NS_IMETHOD GetStyleSize(nsIPresShell* aPresentation,
|
2014-02-24 18:41:56 +04:00
|
|
|
int32_t* aSizeInBytesResult) MOZ_OVERRIDE;
|
1999-05-06 00:42:51 +04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(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,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t* aSizeInBytesResult)
|
1999-05-06 00:42:51 +04:00
|
|
|
{
|
|
|
|
*aSizeInBytesResult = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLayoutDebugger::GetFrameSize(nsIPresShell* aPresentation,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t* aSizeInBytesResult)
|
1999-05-06 00:42:51 +04:00
|
|
|
{
|
|
|
|
*aSizeInBytesResult = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLayoutDebugger::GetStyleSize(nsIPresShell* aPresentation,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t* aSizeInBytesResult)
|
1999-05-06 00:42:51 +04:00
|
|
|
{
|
|
|
|
*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
|
2014-01-27 02:09:14 +04:00
|
|
|
static void
|
|
|
|
PrintDisplayListTo(nsDisplayListBuilder* aBuilder, const nsDisplayList& aList,
|
|
|
|
FILE* aOutput, uint32_t aIndent, bool aDumpHtml);
|
|
|
|
|
|
|
|
static void
|
|
|
|
PrintDisplayItemTo(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem,
|
|
|
|
FILE* aOutput, uint32_t aIndent, bool aDumpSublist, bool aDumpHtml)
|
|
|
|
{
|
|
|
|
nsCString str;
|
|
|
|
if (!aDumpHtml) {
|
|
|
|
for (uint32_t indent = 0; indent < aIndent; indent++) {
|
|
|
|
str += " ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nsIFrame* f = aItem->Frame();
|
|
|
|
nsAutoString fName;
|
2014-03-03 02:22:29 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-01-27 02:09:14 +04:00
|
|
|
f->GetFrameName(fName);
|
|
|
|
#endif
|
|
|
|
bool snap;
|
|
|
|
nsRect rect = aItem->GetBounds(aBuilder, &snap);
|
|
|
|
nscolor color;
|
|
|
|
nsRect vis = aItem->GetVisibleRect();
|
|
|
|
nsRect component = aItem->GetComponentAlphaBounds(aBuilder);
|
|
|
|
nsDisplayList* list = aItem->GetChildren();
|
|
|
|
const DisplayItemClip& clip = aItem->GetClip();
|
|
|
|
nsRegion opaque;
|
|
|
|
if (!list || list->DidComputeVisibility()) {
|
|
|
|
opaque = aItem->GetOpaqueRegion(aBuilder, &snap);
|
|
|
|
}
|
|
|
|
if (aDumpHtml && aItem->Painted()) {
|
|
|
|
nsCString string(aItem->Name());
|
2014-05-22 07:48:52 +04:00
|
|
|
string.Append('-');
|
2014-01-27 02:09:14 +04:00
|
|
|
string.AppendInt((uint64_t)aItem);
|
|
|
|
str += nsPrintfCString("<a href=\"javascript:ViewImage('%s')\">", string.BeginReading());
|
|
|
|
}
|
|
|
|
str += nsPrintfCString("%s %p(%s) bounds(%d,%d,%d,%d) visible(%d,%d,%d,%d) componentAlpha(%d,%d,%d,%d) clip(%s) %s",
|
|
|
|
aItem->Name(), (void*)f, NS_ConvertUTF16toUTF8(fName).get(),
|
|
|
|
rect.x, rect.y, rect.width, rect.height,
|
|
|
|
vis.x, vis.y, vis.width, vis.height,
|
|
|
|
component.x, component.y, component.width, component.height,
|
|
|
|
clip.ToString().get(),
|
|
|
|
aItem->IsUniform(aBuilder, &color) ? " uniform" : "");
|
|
|
|
nsRegionRectIterator iter(opaque);
|
|
|
|
for (const nsRect* r = iter.Next(); r; r = iter.Next()) {
|
|
|
|
str += nsPrintfCString(" (opaque %d,%d,%d,%d)", r->x, r->y, r->width, r->height);
|
|
|
|
}
|
|
|
|
aItem->WriteDebugInfo(str);
|
|
|
|
if (aDumpHtml && aItem->Painted()) {
|
|
|
|
str += "</a>";
|
|
|
|
}
|
|
|
|
uint32_t key = aItem->GetPerFrameKey();
|
|
|
|
Layer* layer = mozilla::FrameLayerBuilder::GetDebugOldLayerFor(f, key);
|
|
|
|
if (layer) {
|
|
|
|
if (aDumpHtml) {
|
|
|
|
str += nsPrintfCString(" <a href=\"#%p\">layer=%p</a>", layer, layer);
|
|
|
|
} else {
|
|
|
|
str += nsPrintfCString(" layer=%p", layer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (aItem->GetType() == nsDisplayItem::TYPE_SVG_EFFECTS) {
|
|
|
|
(static_cast<nsDisplaySVGEffects*>(aItem))->PrintEffects(str);
|
|
|
|
}
|
|
|
|
fprintf_stderr(aOutput, "%s\n", str.get());
|
|
|
|
if (aDumpSublist && list) {
|
|
|
|
PrintDisplayListTo(aBuilder, *list, aOutput, aIndent+1, aDumpHtml);
|
|
|
|
}
|
|
|
|
}
|
2012-08-07 21:57:26 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
static void
|
|
|
|
PrintDisplayListTo(nsDisplayListBuilder* aBuilder, const nsDisplayList& aList,
|
2014-01-27 02:09:14 +04:00
|
|
|
FILE* aOutput, uint32_t aIndent, bool aDumpHtml)
|
2006-01-26 05:29:17 +03:00
|
|
|
{
|
2012-08-07 21:57:26 +04:00
|
|
|
if (aDumpHtml) {
|
2013-11-24 02:44:18 +04:00
|
|
|
fprintf_stderr(aOutput, "<ul>");
|
2012-08-07 21:57:26 +04:00
|
|
|
}
|
2012-03-01 12:26:09 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
for (nsDisplayItem* i = aList.GetBottom(); i != nullptr; i = i->GetAbove()) {
|
2012-08-07 21:57:26 +04:00
|
|
|
if (aDumpHtml) {
|
2013-11-24 02:44:18 +04:00
|
|
|
fprintf_stderr(aOutput, "<li>");
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
2014-01-27 02:09:14 +04:00
|
|
|
PrintDisplayItemTo(aBuilder, i, aOutput, aIndent, true, aDumpHtml);
|
2012-08-07 21:57:26 +04:00
|
|
|
if (aDumpHtml) {
|
2013-11-24 02:44:18 +04:00
|
|
|
fprintf_stderr(aOutput, "</li>");
|
2012-08-07 21:57:26 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aDumpHtml) {
|
2013-11-24 02:44:18 +04:00
|
|
|
fprintf_stderr(aOutput, "</ul>");
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-27 02:09:14 +04:00
|
|
|
void
|
|
|
|
nsFrame::PrintDisplayItem(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsDisplayItem* aItem,
|
|
|
|
FILE* aFile,
|
|
|
|
bool aDumpSublist,
|
|
|
|
bool aDumpHtml)
|
|
|
|
{
|
|
|
|
PrintDisplayItemTo(aBuilder, aItem, aFile, 0, aDumpSublist, aDumpHtml);
|
|
|
|
}
|
|
|
|
|
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,
|
2012-08-07 21:57:26 +04:00
|
|
|
FILE* aFile,
|
|
|
|
bool aDumpHtml)
|
2006-01-26 05:29:17 +03:00
|
|
|
{
|
2014-01-27 02:09:14 +04:00
|
|
|
PrintDisplayListTo(aBuilder, aList, aFile, 0, aDumpHtml);
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
|
2013-12-12 22:27:07 +04:00
|
|
|
static void
|
|
|
|
PrintDisplayListSetItem(nsDisplayListBuilder* aBuilder,
|
|
|
|
const char* aItemName,
|
|
|
|
const nsDisplayList& aList,
|
|
|
|
FILE* aFile,
|
|
|
|
bool aDumpHtml)
|
|
|
|
{
|
|
|
|
if (aDumpHtml) {
|
|
|
|
fprintf_stderr(aFile, "<li>");
|
|
|
|
}
|
|
|
|
fprintf_stderr(aFile, "%s", aItemName);
|
2014-01-27 02:09:14 +04:00
|
|
|
PrintDisplayListTo(aBuilder, aList, aFile, 0, aDumpHtml);
|
2013-12-12 22:27:07 +04:00
|
|
|
if (aDumpHtml) {
|
|
|
|
fprintf_stderr(aFile, "</li>");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsFrame::PrintDisplayListSet(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aSet,
|
|
|
|
FILE *aFile,
|
|
|
|
bool aDumpHtml)
|
|
|
|
{
|
|
|
|
if (aDumpHtml) {
|
|
|
|
fprintf_stderr(aFile, "<ul>");
|
|
|
|
}
|
|
|
|
PrintDisplayListSetItem(aBuilder, "[BorderBackground]", *(aSet.BorderBackground()), aFile, aDumpHtml);
|
|
|
|
PrintDisplayListSetItem(aBuilder, "[BlockBorderBackgrounds]", *(aSet.BlockBorderBackgrounds()), aFile, aDumpHtml);
|
|
|
|
PrintDisplayListSetItem(aBuilder, "[Floats]", *(aSet.Floats()), aFile, aDumpHtml);
|
|
|
|
PrintDisplayListSetItem(aBuilder, "[PositionedDescendants]", *(aSet.PositionedDescendants()), aFile, aDumpHtml);
|
|
|
|
PrintDisplayListSetItem(aBuilder, "[Outlines]", *(aSet.Outlines()), aFile, aDumpHtml);
|
|
|
|
PrintDisplayListSetItem(aBuilder, "[Content]", *(aSet.Content()), aFile, aDumpHtml);
|
|
|
|
if (aDumpHtml) {
|
|
|
|
fprintf_stderr(aFile, "</ul>");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|