Files
palemoon27/layout/base/nsLayoutDebugger.cpp
T
roytam1 61a988a8ac import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1225237 - Use stable hashing for DOMExpandoSet; r=jonco (4254b32429)
- Bug 1219288 - Store target shapes in module environment object rather than names r=shu (5cb08ce170)
- Bug 1219288 - Add GETIMPORT instruction for accessing module imports that are not namespace imports r=shu (487ccb37d4)
- Bug 1219288 - Optimize GETIMPORT instructions in baseline r=shu (938079be7f)
- Bug 1219288 - Optimize GETIMPORT instructions in Ion r=shu (cfa7b927a4)
- Bug 1224404 - Use stable hashing for WeakMapPtr; r=jonco (59df9ae61c)
- Bug 1223639. Use ForceInside to constrain the displayport rect to the scrollable rect instead of intersect. r=botond (12a978a2fd)
- Bug 1223639. Rename ForceInside to MoveInsideAndClamp so it's clearer what it does. r=botond (562f0a8f53)
- Bug 1212136 - Remove noisy warning that we don't have time to investigate properly. r=tnikkel (4d752f8b1a)
- Bug 1215356. When setting a display port, schedule paint on that frame, not the root frame of the document. r=mattwoodrow (bad289fbb7)
- Bug 1213711 - Initialize Preserves3DContext::mAccumulatedRectLevels. r=thinker. (99dbae372a)
- Bug 1175492 followup: remove extra dashes left over from removing -moz- prefixes. r=longsonr (060368e850)
- Bug 1207143 - Improve GetBounds() to avoid recomputing every time. r=roc (995b9e9d4f)
- Bug 1216386 - Improve AnimatedGeometryRootLookup::Hash. r=roc. (7c84489583)
- Bug 1201327 - Rename mDestRect to mImageLayerDestRect. r=mattwoodrow (fa32340de9)
- Bug 1201327 - Let DLBI detect background-position changes. r=mattwoodrow (de59480f0d)
- Bug 1201327 - Don't repaint the whole frame subtree when background-position changes. r=dbaron (26a085e548)
- Fix wheel events not working on scrollbars of inactive subframes. (bug 1216488, r=tn) (650d70eaf5)
- Bug 1206468 - Remove unused internal appearance value -moz-mac-unified-toolbar. r=mstange (0c56b0fd65)
- Bug 1214212 - Remove clips from separator transform items. r=roc (6f06f60ec9)
- Bug 947062 - Refactor nsDisplayBackgroundImage::GetLayerState. r=mattwoodrow (23d5496afc)
- Bug 1220020. When we turn something into an animated geometry root, clear the cache of animated geometry roots so it's not stale. r=tnikkel (90470c67ae)
- Bug 1156238. Always stop at the root reference frame when looking for an animated geometry root. r=roc,mattwoodrow (b7a41ac2fb)
- Bug 1156238. Fix the computation of animated geometry roots for transform items. r=mattwoodrow (523f062309)
- Bug 1156238. Skip setting async scroll clips if we aren't painting to the window because they are useless then. r=mstange (1d98f27c40)
- Bug 1205087 - Cache the AnimatedGeometryRoot on DisplayItem. r=roc (4f3f5b7e5e)
- Bug 1224209. The animated geometry root of a fixed pos and transformed frame needs to be that frame itself so FrameLayerBuilder can determine it is fixed pos. r=mattwoodrow (974a3ab1e0)
- Bug 1141884 - Handle wheel events on the main thread if the frame has snapping. r=dvander,mstange (3347cdd831)
- Bug 1176775 part 1 - [css-grid] Implement "Implied Minimum Size of Grid Items" (special min-width/height:auto behavior). r=dholbert (c28098d660)
- Bug 1176775 part 2 - [css-grid] Testcases for 'auto' min-sizing and intrinsic 'min-width|height'. (ec70253cc9)
- Bug 1215974. In GetNearestScrollableFrame don't skip the root scroll frame if we are asked to always match the root scroll frame even if it doesn't WantAsyncScroll(). r=botond (97094eb3b1)
- Bug 1215977. Only match the root scroll frame in GetNearestScrollableFrame if we encounter it. r=botond (69569c757c)
- Bug 1215977. Add a flag for GetNearestScrollable that makes fixed pos frames return the root scroll frame of their document. And make APZCCallbackHelper use it to restore previous behaviour. r=botond (c15650e2ba)
- Bug 1190936 - Attempt some graceful handling for an unexpected situation that otherwise crashes the browser. r=botond (61e5fc4b2c)
- Bug 1208780. Set a zero-margin displayport on all scrollable ancestors of frames with displayports if they don't already have a displayport. r=botond (1cb395354a)
- Bug 1221870. Make fixed pos items always find the root scroll frame when looking for the nearest scrollable. r=botond (739da0c2af)
- Bug 1122918 - Part 3 - Use the resolved physical values of 'float' and 'clear' properties during layout. r=heycam (46e77f1e0a)
- Bug 1223479 - Fix displayport size calculation on fennec. r=kats (bd54d7a6c9)
- Bug 1210560 - Part 3: Convert more complex SVG usecases to PushGroupForBlendBack. r=jwatt r=jrmuizel (1a72ef23ba)
- Bug 1210560 - Part 4: Remove code to support non operator-over in nsRenderDocument and move to CanvasRenderingContext2D::DrawWindow. r=roc (a475f22cd2)
- Bug 1210560 - Part 5: Convert BasicLayers usecases to PushGroupForBlendBack and temporary surfaces. r=jrmuizel (5706386aa9)
- Bug 1210560 - Part 6: Convert code to support non-operator OVER in nsCSSRendering to moz2d. r=roc (ba280199c0)
- Bug 1210560 - Part 7: Convert GTK widget code to use Moz2D instead of PushGroup/PopGroup. r=jwatt (d06408ec0a)
- Bug 1210560 - Part 8: Remove unused PushGroup/PopGroup/PopGroupToSource functions. r=jrmuizel (a39ad555c4)
- Bug 1210560 - Followup: Fix function definition prototype. r=bustage on a CLOSED TREE (daa75a342b)
- Bug 1210560 - Followup 2: Fix UniquePtr usage issue. r=bustage on a CLOSED TREE (68ee7667fe)
- Bug 1210560 - Followup 3: Fix an assertion that can occur on mochitest bc4. r=jrmuizel on a CLOSED TREE (6b68389154)
2023-01-06 17:42:55 +08:00

321 lines
9.3 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 "nsPrintfCString.h"
#include <stdio.h>
using namespace mozilla;
using namespace mozilla::layers;
#ifdef DEBUG
class nsLayoutDebugger : public nsILayoutDebugger {
public:
nsLayoutDebugger();
NS_DECL_ISUPPORTS
NS_IMETHOD SetShowFrameBorders(bool aEnable) override;
NS_IMETHOD GetShowFrameBorders(bool* aResult) override;
NS_IMETHOD SetShowEventTargetFrameBorder(bool aEnable) override;
NS_IMETHOD GetShowEventTargetFrameBorder(bool* aResult) override;
NS_IMETHOD GetContentSize(nsIDocument* aDocument,
int32_t* aSizeInBytesResult) override;
NS_IMETHOD GetFrameSize(nsIPresShell* aPresentation,
int32_t* aSizeInBytesResult) override;
NS_IMETHOD GetStyleSize(nsIPresShell* aPresentation,
int32_t* aSizeInBytesResult) override;
protected:
virtual ~nsLayoutDebugger();
};
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_ISUPPORTS(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
std::ostream& operator<<(std::ostream& os, const nsPrintfCString& rhs) {
os << rhs.get();
return os;
}
static void
PrintDisplayListTo(nsDisplayListBuilder* aBuilder, const nsDisplayList& aList,
std::stringstream& aStream, uint32_t aIndent, bool aDumpHtml);
static void
PrintDisplayItemTo(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem,
std::stringstream& aStream, uint32_t aIndent, bool aDumpSublist, bool aDumpHtml)
{
std::stringstream ss;
if (!aDumpHtml) {
for (uint32_t indent = 0; indent < aIndent; indent++) {
aStream << " ";
}
}
nsAutoString contentData;
nsIFrame* f = aItem->Frame();
#ifdef DEBUG_FRAME_DUMP
f->GetFrameName(contentData);
#endif
nsIContent* content = f->GetContent();
if (content) {
nsString tmp;
if (content->GetID()) {
content->GetID()->ToString(tmp);
contentData.AppendLiteral(" id:");
contentData.Append(tmp);
}
if (content->GetClasses()) {
content->GetClasses()->ToString(tmp);
contentData.AppendLiteral(" class:");
contentData.Append(tmp);
}
}
bool snap;
nsRect rect = aItem->GetBounds(aBuilder, &snap);
nsRect layerRect = rect - aItem->AnimatedGeometryRoot()->GetOffsetToCrossDoc(aItem->ReferenceFrame());
nscolor color;
nsRect vis = aItem->GetVisibleRect();
nsRect component = aItem->GetComponentAlphaBounds(aBuilder);
nsDisplayList* list = aItem->GetChildren();
const DisplayItemClip& clip = aItem->GetClip();
nsRegion opaque = aItem->GetOpaqueRegion(aBuilder, &snap);
#ifdef MOZ_DUMP_PAINTING
if (aDumpHtml && aItem->Painted()) {
nsCString string(aItem->Name());
string.Append('-');
string.AppendInt((uint64_t)aItem);
aStream << nsPrintfCString("<a href=\"javascript:ViewImage('%s')\">", string.BeginReading());
}
#endif
aStream << nsPrintfCString("%s p=0x%p f=0x%p(%s) %sbounds(%d,%d,%d,%d) layerBounds(%d,%d,%d,%d) visible(%d,%d,%d,%d) componentAlpha(%d,%d,%d,%d) clip(%s) %s ref=0x%p agr=0x%p",
aItem->Name(), aItem, (void*)f, NS_ConvertUTF16toUTF8(contentData).get(),
(aItem->ZIndex() ? nsPrintfCString("z=%d ", aItem->ZIndex()).get() : ""),
rect.x, rect.y, rect.width, rect.height,
layerRect.x, layerRect.y, layerRect.width, layerRect.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" : "",
aItem->ReferenceFrame(), aItem->AnimatedGeometryRoot());
nsRegionRectIterator iter(opaque);
for (const nsRect* r = iter.Next(); r; r = iter.Next()) {
aStream << nsPrintfCString(" (opaque %d,%d,%d,%d)", r->x, r->y, r->width, r->height);
}
if (aItem->ShouldFixToViewport(aBuilder)) {
aStream << " fixed";
}
if (aItem->Frame()->StyleDisplay()->mWillChange.Length() > 0) {
aStream << " (will-change=";
for (size_t i = 0; i < aItem->Frame()->StyleDisplay()->mWillChange.Length(); i++) {
if (i > 0) {
aStream << ",";
}
aStream << NS_LossyConvertUTF16toASCII(aItem->Frame()->StyleDisplay()->mWillChange[i]).get();
}
aStream << ")";
}
// Display item specific debug info
aItem->WriteDebugInfo(aStream);
#ifdef MOZ_DUMP_PAINTING
if (aDumpHtml && aItem->Painted()) {
aStream << "</a>";
}
#endif
uint32_t key = aItem->GetPerFrameKey();
Layer* layer = mozilla::FrameLayerBuilder::GetDebugOldLayerFor(f, key);
if (layer) {
if (aDumpHtml) {
aStream << nsPrintfCString(" <a href=\"#%p\">layer=%p</a>", layer, layer);
} else {
aStream << nsPrintfCString(" layer=0x%p", layer);
}
}
#ifdef MOZ_DUMP_PAINTING
if (aItem->GetType() == nsDisplayItem::TYPE_SVG_EFFECTS) {
nsCString str;
(static_cast<nsDisplaySVGEffects*>(aItem))->PrintEffects(str);
aStream << str.get();
}
#endif
aStream << "\n";
#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
if (aDumpSublist && list) {
PrintDisplayListTo(aBuilder, *list, aStream, aIndent+1, aDumpHtml);
}
}
static void
PrintDisplayListTo(nsDisplayListBuilder* aBuilder, const nsDisplayList& aList,
std::stringstream& aStream, uint32_t aIndent, bool aDumpHtml)
{
if (aDumpHtml) {
aStream << "<ul>";
}
for (nsDisplayItem* i = aList.GetBottom(); i != nullptr; i = i->GetAbove()) {
if (aDumpHtml) {
aStream << "<li>";
}
PrintDisplayItemTo(aBuilder, i, aStream, aIndent, true, aDumpHtml);
if (aDumpHtml) {
aStream << "</li>";
}
}
if (aDumpHtml) {
aStream << "</ul>";
}
}
void
nsFrame::PrintDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayList& aList,
std::stringstream& aStream,
bool aDumpHtml)
{
PrintDisplayListTo(aBuilder, aList, aStream, 0, aDumpHtml);
}
#ifdef MOZ_DUMP_PAINTING
static void
PrintDisplayListSetItem(nsDisplayListBuilder* aBuilder,
const char* aItemName,
const nsDisplayList& aList,
std::stringstream& aStream,
bool aDumpHtml)
{
if (aDumpHtml) {
aStream << "<li>";
}
aStream << aItemName << "\n";
PrintDisplayListTo(aBuilder, aList, aStream, 0, aDumpHtml);
if (aDumpHtml) {
aStream << "</li>";
}
}
void
nsFrame::PrintDisplayListSet(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aSet,
std::stringstream& aStream,
bool aDumpHtml)
{
if (aDumpHtml) {
aStream << "<ul>";
}
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);
if (aDumpHtml) {
aStream << "</ul>";
}
}
#endif