mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-01 14:45:29 +00:00
e368dc9c85
This patch was generated by a script. Here's the source of the script for future reference: function convert() { echo "Converting $1 to $2..." find . ! -wholename "*nsprpub*" \ ! -wholename "*security/nss*" \ ! -wholename "*/.hg*" \ ! -wholename "obj-ff-dbg*" \ ! -name nsXPCOMCID.h \ ! -name prtypes.h \ -type f \ \( -iname "*.cpp" \ -o -iname "*.h" \ -o -iname "*.c" \ -o -iname "*.cc" \ -o -iname "*.idl" \ -o -iname "*.ipdl" \ -o -iname "*.ipdlh" \ -o -iname "*.mm" \) | \ xargs -n 1 sed -i -e "s/\b$1\b/$2/g" } convert PRInt8 int8_t convert PRUint8 uint8_t convert PRInt16 int16_t convert PRUint16 uint16_t convert PRInt32 int32_t convert PRUint32 uint32_t convert PRInt64 int64_t convert PRUint64 uint64_t convert PRIntn int convert PRUintn unsigned convert PRSize size_t convert PROffset32 int32_t convert PROffset64 int64_t convert PRPtrdiff ptrdiff_t convert PRFloat64 double
237 lines
6.2 KiB
C++
237 lines
6.2 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* 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/. */
|
|
|
|
/*
|
|
* implementation of interface that allows layout-debug extension access
|
|
* to some internals of layout
|
|
*/
|
|
|
|
#include "nsILayoutDebugger.h"
|
|
#include "nsFrame.h"
|
|
#include "nsDisplayList.h"
|
|
#include "FrameLayerBuilder.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
using namespace mozilla::layers;
|
|
|
|
#ifdef DEBUG
|
|
class nsLayoutDebugger : public nsILayoutDebugger {
|
|
public:
|
|
nsLayoutDebugger();
|
|
virtual ~nsLayoutDebugger();
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_IMETHOD SetShowFrameBorders(bool aEnable);
|
|
|
|
NS_IMETHOD GetShowFrameBorders(bool* aResult);
|
|
|
|
NS_IMETHOD SetShowEventTargetFrameBorder(bool aEnable);
|
|
|
|
NS_IMETHOD GetShowEventTargetFrameBorder(bool* aResult);
|
|
|
|
NS_IMETHOD GetContentSize(nsIDocument* aDocument,
|
|
int32_t* aSizeInBytesResult);
|
|
|
|
NS_IMETHOD GetFrameSize(nsIPresShell* aPresentation,
|
|
int32_t* aSizeInBytesResult);
|
|
|
|
NS_IMETHOD GetStyleSize(nsIPresShell* aPresentation,
|
|
int32_t* aSizeInBytesResult);
|
|
|
|
};
|
|
|
|
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
|
|
nsLayoutDebugger::SetShowFrameBorders(bool aEnable)
|
|
{
|
|
nsFrame::ShowFrameBorders(aEnable);
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsLayoutDebugger::GetShowFrameBorders(bool* aResult)
|
|
{
|
|
*aResult = nsFrame::GetShowFrameBorders();
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsLayoutDebugger::SetShowEventTargetFrameBorder(bool aEnable)
|
|
{
|
|
nsFrame::ShowEventTargetFrameBorder(aEnable);
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsLayoutDebugger::GetShowEventTargetFrameBorder(bool* aResult)
|
|
{
|
|
*aResult = nsFrame::GetShowEventTargetFrameBorder();
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsLayoutDebugger::GetContentSize(nsIDocument* aDocument,
|
|
int32_t* aSizeInBytesResult)
|
|
{
|
|
*aSizeInBytesResult = 0;
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsLayoutDebugger::GetFrameSize(nsIPresShell* aPresentation,
|
|
int32_t* aSizeInBytesResult)
|
|
{
|
|
*aSizeInBytesResult = 0;
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsLayoutDebugger::GetStyleSize(nsIPresShell* aPresentation,
|
|
int32_t* aSizeInBytesResult)
|
|
{
|
|
*aSizeInBytesResult = 0;
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
#endif
|
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
static int sPrintDisplayListIndent = 0;
|
|
|
|
static void
|
|
PrintDisplayListTo(nsDisplayListBuilder* aBuilder, const nsDisplayList& aList,
|
|
FILE* aOutput, bool aDumpHtml)
|
|
{
|
|
if (aDumpHtml) {
|
|
fprintf(aOutput, "<ul>");
|
|
}
|
|
|
|
for (nsDisplayItem* i = aList.GetBottom(); i != nullptr; i = i->GetAbove()) {
|
|
#ifdef DEBUG
|
|
if (aList.DidComputeVisibility() && i->GetVisibleRect().IsEmpty())
|
|
continue;
|
|
#endif
|
|
if (aDumpHtml) {
|
|
fprintf(aOutput, "<li>");
|
|
} else {
|
|
sPrintDisplayListIndent ++;
|
|
for (int indent = 0; indent < sPrintDisplayListIndent; indent++) {
|
|
fprintf(aOutput, " ");
|
|
}
|
|
}
|
|
nsIFrame* f = i->GetUnderlyingFrame();
|
|
nsAutoString fName;
|
|
#ifdef DEBUG
|
|
if (f) {
|
|
f->GetFrameName(fName);
|
|
}
|
|
#endif
|
|
bool snap;
|
|
nsRect rect = i->GetBounds(aBuilder, &snap);
|
|
switch (i->GetType()) {
|
|
case nsDisplayItem::TYPE_CLIP:
|
|
case nsDisplayItem::TYPE_CLIP_ROUNDED_RECT: {
|
|
nsDisplayClip* c = static_cast<nsDisplayClip*>(i);
|
|
rect = c->GetClipRect();
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
nscolor color;
|
|
nsRect vis = i->GetVisibleRect();
|
|
nsRect component = i->GetComponentAlphaBounds(aBuilder);
|
|
nsDisplayList* list = i->GetList();
|
|
nsRegion opaque;
|
|
if (i->GetType() == nsDisplayItem::TYPE_TRANSFORM) {
|
|
nsDisplayTransform* t = static_cast<nsDisplayTransform*>(i);
|
|
list = t->GetStoredList()->GetList();
|
|
}
|
|
#ifdef DEBUG
|
|
if (!list || list->DidComputeVisibility()) {
|
|
opaque = i->GetOpaqueRegion(aBuilder, &snap);
|
|
}
|
|
#endif
|
|
if (aDumpHtml && i->Painted()) {
|
|
nsCString string(i->Name());
|
|
string.Append("-");
|
|
string.AppendInt((uint64_t)i);
|
|
fprintf(aOutput, "<a href=\"javascript:ViewImage('%s')\">", string.BeginReading());
|
|
}
|
|
fprintf(aOutput, "%s %p(%s) (%d,%d,%d,%d)(%d,%d,%d,%d)(%d,%d,%d,%d)%s",
|
|
i->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,
|
|
i->IsUniform(aBuilder, &color) ? " uniform" : "");
|
|
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);
|
|
}
|
|
if (aDumpHtml && i->Painted()) {
|
|
fprintf(aOutput, "</a>");
|
|
}
|
|
if (f) {
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
if (i->GetType() == nsDisplayItem::TYPE_SVG_EFFECTS) {
|
|
(static_cast<nsDisplaySVGEffects*>(i))->PrintEffects(aOutput);
|
|
}
|
|
fputc('\n', aOutput);
|
|
if (list) {
|
|
PrintDisplayListTo(aBuilder, *list, aOutput, aDumpHtml);
|
|
}
|
|
if (aDumpHtml) {
|
|
fprintf(aOutput, "</li>");
|
|
} else {
|
|
sPrintDisplayListIndent --;
|
|
}
|
|
}
|
|
|
|
if (aDumpHtml) {
|
|
fprintf(aOutput, "</ul>");
|
|
}
|
|
}
|
|
|
|
void
|
|
nsFrame::PrintDisplayList(nsDisplayListBuilder* aBuilder,
|
|
const nsDisplayList& aList,
|
|
FILE* aFile,
|
|
bool aDumpHtml)
|
|
{
|
|
PrintDisplayListTo(aBuilder, aList, aFile, aDumpHtml);
|
|
}
|
|
|
|
#endif
|