2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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
|
|
|
|
2019-07-22 07:48:33 +03:00
|
|
|
/* some layout debugging functions that ought to live in nsFrame.cpp */
|
2015-09-10 13:24:34 +03:00
|
|
|
|
|
|
|
#include "nsAttrValue.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;
|
|
|
|
|
2018-02-23 08:03:45 +03:00
|
|
|
static std::ostream& operator<<(std::ostream& os, const nsPrintfCString& rhs) {
|
2014-06-20 02:36:25 +04:00
|
|
|
os << rhs.get();
|
|
|
|
return os;
|
|
|
|
}
|
|
|
|
|
2014-01-27 02:09:14 +04:00
|
|
|
static void PrintDisplayListTo(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayList& aList,
|
2014-06-20 02:36:25 +04:00
|
|
|
std::stringstream& aStream, uint32_t aIndent,
|
|
|
|
bool aDumpHtml);
|
2014-01-27 02:09:14 +04:00
|
|
|
|
|
|
|
static void PrintDisplayItemTo(nsDisplayListBuilder* aBuilder,
|
2014-06-20 02:36:25 +04:00
|
|
|
nsDisplayItem* aItem, std::stringstream& aStream,
|
|
|
|
uint32_t aIndent, bool aDumpSublist,
|
|
|
|
bool aDumpHtml) {
|
|
|
|
std::stringstream ss;
|
|
|
|
|
2014-01-27 02:09:14 +04:00
|
|
|
if (!aDumpHtml) {
|
|
|
|
for (uint32_t indent = 0; indent < aIndent; indent++) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << " ";
|
2014-01-27 02:09:14 +04:00
|
|
|
}
|
|
|
|
}
|
2015-03-26 12:01:54 +03:00
|
|
|
nsAutoString contentData;
|
2014-01-27 02:09:14 +04:00
|
|
|
nsIFrame* f = aItem->Frame();
|
2014-03-03 02:22:29 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2015-03-26 12:01:54 +03:00
|
|
|
f->GetFrameName(contentData);
|
2014-01-27 02:09:14 +04:00
|
|
|
#endif
|
2015-03-26 12:01:54 +03:00
|
|
|
nsIContent* content = f->GetContent();
|
|
|
|
if (content) {
|
|
|
|
nsString tmp;
|
|
|
|
if (content->GetID()) {
|
|
|
|
content->GetID()->ToString(tmp);
|
|
|
|
contentData.AppendLiteral(" id:");
|
|
|
|
contentData.Append(tmp);
|
|
|
|
}
|
2017-02-14 00:06:45 +03:00
|
|
|
const nsAttrValue* classes =
|
|
|
|
content->IsElement() ? content->AsElement()->GetClasses() : nullptr;
|
|
|
|
if (classes) {
|
|
|
|
classes->ToString(tmp);
|
2015-03-26 12:01:54 +03:00
|
|
|
contentData.AppendLiteral(" class:");
|
|
|
|
contentData.Append(tmp);
|
|
|
|
}
|
|
|
|
}
|
2014-01-27 02:09:14 +04:00
|
|
|
bool snap;
|
|
|
|
nsRect rect = aItem->GetBounds(aBuilder, &snap);
|
2015-11-25 01:53:51 +03:00
|
|
|
nsRect layerRect = rect - (*aItem->GetAnimatedGeometryRoot())
|
|
|
|
->GetOffsetToCrossDoc(aItem->ReferenceFrame());
|
2018-05-16 06:56:32 +03:00
|
|
|
nsRect vis = aItem->GetPaintRect();
|
2018-07-30 07:03:32 +03:00
|
|
|
nsRect build = aItem->GetBuildingRect();
|
2014-01-27 02:09:14 +04:00
|
|
|
nsRect component = aItem->GetComponentAlphaBounds(aBuilder);
|
|
|
|
nsDisplayList* list = aItem->GetChildren();
|
|
|
|
const DisplayItemClip& clip = aItem->GetClip();
|
2014-06-09 08:48:01 +04:00
|
|
|
nsRegion opaque = aItem->GetOpaqueRegion(aBuilder, &snap);
|
2015-12-23 05:29:35 +03:00
|
|
|
|
2014-12-31 23:17:39 +03:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2014-01-27 02:09:14 +04:00
|
|
|
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);
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << nsPrintfCString("<a href=\"javascript:ViewImage('%s')\">",
|
|
|
|
string.BeginReading());
|
2014-01-27 02:09:14 +04:00
|
|
|
}
|
2014-12-31 23:17:39 +03:00
|
|
|
#endif
|
2015-12-23 05:29:35 +03:00
|
|
|
|
2018-07-30 07:03:32 +03:00
|
|
|
aStream << nsPrintfCString(
|
|
|
|
"%s p=0x%p f=0x%p(%s) key=%d %sbounds(%d,%d,%d,%d) "
|
|
|
|
"layerBounds(%d,%d,%d,%d) visible(%d,%d,%d,%d) building(%d,%d,%d,%d) "
|
|
|
|
"componentAlpha(%d,%d,%d,%d) clip(%s) asr(%s) clipChain(%s)%s ref=0x%p "
|
|
|
|
"agr=0x%p",
|
2017-09-28 03:43:11 +03:00
|
|
|
aItem->Name(), aItem, (void*)f, NS_ConvertUTF16toUTF8(contentData).get(),
|
|
|
|
aItem->GetPerFrameKey(),
|
2014-07-24 05:50:26 +04:00
|
|
|
(aItem->ZIndex() ? nsPrintfCString("z=%d ", aItem->ZIndex()).get() : ""),
|
2014-12-18 21:32:51 +03:00
|
|
|
rect.x, rect.y, rect.width, rect.height, layerRect.x, layerRect.y,
|
2014-01-27 02:09:14 +04:00
|
|
|
layerRect.width, layerRect.height, vis.x, vis.y, vis.width, vis.height,
|
2018-07-30 07:03:32 +03:00
|
|
|
build.x, build.y, build.width, build.height, component.x, component.y,
|
2014-01-27 02:09:14 +04:00
|
|
|
component.width, component.height, clip.ToString().get(),
|
2017-02-01 01:07:35 +03:00
|
|
|
ActiveScrolledRoot::ToString(aItem->GetActiveScrolledRoot()).get(),
|
|
|
|
DisplayItemClipChain::ToString(aItem->GetClipChain()).get(),
|
2016-05-19 11:07:52 +03:00
|
|
|
aItem->IsUniform(aBuilder) ? " uniform" : "", aItem->ReferenceFrame(),
|
2015-12-30 22:21:10 +03:00
|
|
|
aItem->GetAnimatedGeometryRoot()->mFrame);
|
2014-06-13 19:32:15 +04:00
|
|
|
|
2016-01-19 04:20:59 +03:00
|
|
|
for (auto iter = opaque.RectIter(); !iter.Done(); iter.Next()) {
|
|
|
|
const nsRect& r = iter.Get();
|
|
|
|
aStream << nsPrintfCString(" (opaque %d,%d,%d,%d)", r.x, r.y, r.width,
|
|
|
|
r.height);
|
2014-01-27 02:09:14 +04:00
|
|
|
}
|
2014-06-13 19:32:15 +04:00
|
|
|
|
2017-03-10 04:26:53 +03:00
|
|
|
const auto& willChange = aItem->Frame()->StyleDisplay()->mWillChange;
|
2019-05-17 02:23:28 +03:00
|
|
|
if (!willChange.features.IsEmpty()) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << " (will-change=";
|
2019-05-17 02:23:28 +03:00
|
|
|
for (size_t i = 0; i < willChange.features.Length(); i++) {
|
2014-06-13 19:32:15 +04:00
|
|
|
if (i > 0) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << ",";
|
2014-06-13 19:32:15 +04:00
|
|
|
}
|
2019-05-17 02:23:28 +03:00
|
|
|
nsDependentAtomString buffer(willChange.features.AsSpan()[i].AsAtom());
|
2017-03-10 04:26:53 +03:00
|
|
|
aStream << NS_LossyConvertUTF16toASCII(buffer).get();
|
2014-06-13 19:32:15 +04:00
|
|
|
}
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << ")";
|
2014-06-13 19:32:15 +04:00
|
|
|
}
|
|
|
|
|
2018-11-02 05:19:03 +03:00
|
|
|
if (aItem->HasHitTestInfo()) {
|
|
|
|
auto* hitTestInfoItem = static_cast<nsDisplayHitTestInfoItem*>(aItem);
|
|
|
|
|
|
|
|
aStream << nsPrintfCString(" hitTestInfo(0x%x)",
|
|
|
|
hitTestInfoItem->HitTestFlags().serialize());
|
|
|
|
|
|
|
|
nsRect area = hitTestInfoItem->HitTestArea();
|
|
|
|
aStream << nsPrintfCString(" hitTestArea(%d,%d,%d,%d)", area.x, area.y,
|
|
|
|
area.width, area.height);
|
|
|
|
}
|
|
|
|
|
2014-06-13 19:32:15 +04:00
|
|
|
// Display item specific debug info
|
2014-11-25 16:45:19 +03:00
|
|
|
aItem->WriteDebugInfo(aStream);
|
2014-06-13 19:32:15 +04:00
|
|
|
|
2014-12-31 23:17:39 +03:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2014-01-27 02:09:14 +04:00
|
|
|
if (aDumpHtml && aItem->Painted()) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << "</a>";
|
2014-01-27 02:09:14 +04:00
|
|
|
}
|
2014-12-31 23:17:39 +03:00
|
|
|
#endif
|
2017-09-28 03:43:11 +03:00
|
|
|
DisplayItemData* data = mozilla::FrameLayerBuilder::GetOldDataFor(aItem);
|
|
|
|
if (data && data->GetLayer()) {
|
2014-01-27 02:09:14 +04:00
|
|
|
if (aDumpHtml) {
|
2017-09-28 03:43:11 +03:00
|
|
|
aStream << nsPrintfCString(" <a href=\"#%p\">layer=%p</a>",
|
|
|
|
data->GetLayer(), data->GetLayer());
|
2014-01-27 02:09:14 +04:00
|
|
|
} else {
|
2017-09-28 03:43:11 +03:00
|
|
|
aStream << nsPrintfCString(" layer=0x%p", data->GetLayer());
|
2014-01-27 02:09:14 +04:00
|
|
|
}
|
|
|
|
}
|
2014-12-31 23:17:39 +03:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2017-08-07 07:07:43 +03:00
|
|
|
if (aItem->GetType() == DisplayItemType::TYPE_MASK) {
|
2014-06-20 02:36:25 +04:00
|
|
|
nsCString str;
|
2018-08-30 12:51:24 +03:00
|
|
|
(static_cast<nsDisplayMasksAndClipPaths*>(aItem))->PrintEffects(str);
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << str.get();
|
2014-01-27 02:09:14 +04:00
|
|
|
}
|
2016-08-16 10:23:33 +03:00
|
|
|
|
2017-08-07 07:07:43 +03:00
|
|
|
if (aItem->GetType() == DisplayItemType::TYPE_FILTER) {
|
2016-08-16 10:23:33 +03:00
|
|
|
nsCString str;
|
2018-08-30 15:15:47 +03:00
|
|
|
(static_cast<nsDisplayFilters*>(aItem))->PrintEffects(str);
|
2016-08-16 10:23:33 +03:00
|
|
|
aStream << str.get();
|
|
|
|
}
|
2014-12-31 23:17:39 +03:00
|
|
|
#endif
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << "\n";
|
2015-09-28 22:22:05 +03:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
if (aDumpHtml && aItem->Painted()) {
|
|
|
|
nsCString string(aItem->Name());
|
|
|
|
string.Append('-');
|
|
|
|
string.AppendInt((uint64_t)aItem);
|
|
|
|
aStream << nsPrintfCString("<br><img id=\"%s\">\n", string.BeginReading());
|
|
|
|
}
|
|
|
|
#endif
|
2014-06-20 02:36:25 +04:00
|
|
|
|
2014-01-27 02:09:14 +04:00
|
|
|
if (aDumpSublist && list) {
|
2014-06-20 02:36:25 +04:00
|
|
|
PrintDisplayListTo(aBuilder, *list, aStream, aIndent + 1, aDumpHtml);
|
2014-01-27 02:09:14 +04:00
|
|
|
}
|
|
|
|
}
|
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-06-20 02:36:25 +04:00
|
|
|
std::stringstream& aStream, uint32_t aIndent,
|
|
|
|
bool aDumpHtml) {
|
2012-08-07 21:57:26 +04:00
|
|
|
if (aDumpHtml) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << "<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) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << "<li>";
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
2014-06-20 02:36:25 +04:00
|
|
|
PrintDisplayItemTo(aBuilder, i, aStream, aIndent, true, aDumpHtml);
|
2012-08-07 21:57:26 +04:00
|
|
|
if (aDumpHtml) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << "</li>";
|
2012-08-07 21:57:26 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aDumpHtml) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << "</ul>";
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-21 01:52:48 +04:00
|
|
|
void nsFrame::PrintDisplayList(nsDisplayListBuilder* aBuilder,
|
2012-03-01 12:26:09 +04:00
|
|
|
const nsDisplayList& aList,
|
2014-06-20 02:36:25 +04:00
|
|
|
std::stringstream& aStream, bool aDumpHtml) {
|
|
|
|
PrintDisplayListTo(aBuilder, aList, aStream, 0, aDumpHtml);
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
|
2018-07-19 22:30:30 +03:00
|
|
|
void nsFrame::PrintDisplayItem(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsDisplayItem* aItem, std::stringstream& aStream,
|
|
|
|
uint32_t aIndent, bool aDumpSublist,
|
|
|
|
bool aDumpHtml) {
|
|
|
|
PrintDisplayItemTo(aBuilder, aItem, aStream, aIndent, aDumpSublist,
|
|
|
|
aDumpHtml);
|
|
|
|
}
|
|
|
|
|
2016-08-22 22:49:09 +03:00
|
|
|
/**
|
|
|
|
* The two functions below are intended to be called from a debugger.
|
|
|
|
*/
|
|
|
|
void PrintDisplayItemToStdout(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsDisplayItem* aItem) {
|
|
|
|
std::stringstream stream;
|
|
|
|
PrintDisplayItemTo(aBuilder, aItem, stream, 0, true, false);
|
2018-03-01 17:07:56 +03:00
|
|
|
puts(stream.str().c_str());
|
2016-08-22 22:49:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void PrintDisplayListToStdout(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayList& aList) {
|
|
|
|
std::stringstream stream;
|
|
|
|
PrintDisplayListTo(aBuilder, aList, stream, 0, false);
|
2018-03-01 17:07:56 +03:00
|
|
|
puts(stream.str().c_str());
|
2016-08-22 22:49:09 +03:00
|
|
|
}
|
|
|
|
|
2014-12-31 23:17:39 +03:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2013-12-12 22:27:07 +04:00
|
|
|
static void PrintDisplayListSetItem(nsDisplayListBuilder* aBuilder,
|
|
|
|
const char* aItemName,
|
|
|
|
const nsDisplayList& aList,
|
2014-06-20 02:36:25 +04:00
|
|
|
std::stringstream& aStream,
|
2013-12-12 22:27:07 +04:00
|
|
|
bool aDumpHtml) {
|
|
|
|
if (aDumpHtml) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << "<li>";
|
2013-12-12 22:27:07 +04:00
|
|
|
}
|
2014-07-24 05:50:26 +04:00
|
|
|
aStream << aItemName << "\n";
|
2014-06-20 02:36:25 +04:00
|
|
|
PrintDisplayListTo(aBuilder, aList, aStream, 0, aDumpHtml);
|
2013-12-12 22:27:07 +04:00
|
|
|
if (aDumpHtml) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << "</li>";
|
2013-12-12 22:27:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsFrame::PrintDisplayListSet(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aSet,
|
2014-06-20 02:36:25 +04:00
|
|
|
std::stringstream& aStream, bool aDumpHtml) {
|
2013-12-12 22:27:07 +04:00
|
|
|
if (aDumpHtml) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << "<ul>";
|
2013-12-12 22:27:07 +04:00
|
|
|
}
|
2014-06-20 02:36:25 +04:00
|
|
|
PrintDisplayListSetItem(aBuilder, "[BorderBackground]",
|
|
|
|
*(aSet.BorderBackground()), aStream, aDumpHtml);
|
|
|
|
PrintDisplayListSetItem(aBuilder, "[BlockBorderBackgrounds]",
|
|
|
|
*(aSet.BlockBorderBackgrounds()), aStream, aDumpHtml);
|
|
|
|
PrintDisplayListSetItem(aBuilder, "[Floats]", *(aSet.Floats()), aStream,
|
|
|
|
aDumpHtml);
|
|
|
|
PrintDisplayListSetItem(aBuilder, "[PositionedDescendants]",
|
|
|
|
*(aSet.PositionedDescendants()), aStream, aDumpHtml);
|
|
|
|
PrintDisplayListSetItem(aBuilder, "[Outlines]", *(aSet.Outlines()), aStream,
|
|
|
|
aDumpHtml);
|
|
|
|
PrintDisplayListSetItem(aBuilder, "[Content]", *(aSet.Content()), aStream,
|
|
|
|
aDumpHtml);
|
2013-12-12 22:27:07 +04:00
|
|
|
if (aDumpHtml) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << "</ul>";
|
2013-12-12 22:27:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|