Files
palemoon27/layout/base/nsLayoutDebugger.cpp
T
roytam1 9be4c7427e import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1194851. Change one instance of GetDisplayPort to HasDisplayPort. r=botond (ff16711347)
- Bug 1194851. Make ViewportHasDisplayPort only return a bool, not the displayport rect. r=botond (bfe7d49225)
- Bug 1194851. Change GetOrMaybeCreateDisplayPort into just MaybeCreateDisplayPort, and make it only return a bool, and not the displayport rect. r=botond (af2a6eedbc)
- Bug 1194851. Always store the displayport base relative to the scrollport (not the scroll frame). r=botond (841ff20d8c)
- Bug 1194851 - Remove the second parameter of IsFixedPosFrameInDisplayPort(). r=kats (7eca35088f)
- Bug 1229853 - Don't apply the displayport multiplier if we don't have a frame for the element the displayport is set on. r=tn (f0e829164e)
- Bug 1237086. When getting the displayport for a content node if there is no root scroll frame just use the primary frame of the content node. r=botond (35a1e1a2f6)
- Bug 1194851. Introduce GetDisplayPortRelativeToScrollFrame. r=botond (d209135b33)
- Bug 1194851. Change GetDisplayPortForVisibilityTesting into GetDisplayPortRelativeToScrollFrameForVisibilityTesting since it has only one user. r=botond (ba2f91af92)
- Bug 1194851. Split GetDisplayPort callers into GetDisplayPortRelative ToScrollPort and GetDisplayPortRelativeToScrollFrame. r=botond (4628829811)
- Bug 1194851. Rename GetDisplayPortRelativeToScrollPort back to GetDisplayPort. r=botond (e632511674)
- Bug 1194851. Change the GetDisplayPort API to take an optional RelativeTo parameter, instead of having that expressed in the function name. r=botond (8f0be47c51)
- Bug 1232561 part 1 - Replace AppliesToTransitionsLevel() with a cascade level enumeration; r=heycam (ca46bd9c5c)
- Bug 1229280 - Move animation generation from AnimationCollection to EffectSet; r=dbaron (7e15533b9f)
- Bug 1232561 part 2 - Move the animation style rules from AnimationCollection to EffectSet; r=heycam (6166363541)
- Bug 1232561 part 3 - Move AnimValuesStyleRule to a separate file; r=heycam (e2cc2f76c1)
- Bug 1232561 part 4 - Add EffectCompositor::ComposeAnimationRule; r=heycam (c29fef6a32)
- Bug 1232577 part 1 - Add EffectCompositor as a member of nsPresContext; r=heycam (027c5d9aa2)
- Bug 1232577 part 2 - Add a hashmap to ElementCompositor to track which (pseudo-) elements need to have their animation style rule updated; r=heycam (9d6e66d674)
- Bug 1232563 part 1 - Request a layer update if an animation is newly finished; r=heycam (9b73effbf2)
- Bug 1232563 part 2 - Move RequestRestyle calls to the effect; r=heycam (71eeb3a73d)
- Bug 1232563 part 3 - Drop check for an empty set of properties when requesting restyles from KeyframeEffectReadOnly; r=heycam (d4768a7394)
- Bug 1232563 part 4 - Don't perform style updates when the effect progress has not changed; r=heycam (8e92edd63e)
- Bug 1232577 part 3 - Move RestyleType to EffectCompositor; r=heycam (ded7dc780d)
- Bug 1232577 part 4 - Add and remove (pseudo-)elements needing an animation style rule update to the EffectCompositor; r=heycam (62f6220505)
- Bug 1232577 part 5 - Make sure CSSTransition::CancelFromStyle updates the transitions level of the cascade; r=heycam (e8912154f1)
- Bug 1232577 part 6 - Add animation rule refresh time to EffectSet; r=heycam (ba10c84ace)
- Bug 1232577 part 7 - Move call to SetNeedStyleFlush() to EffectCompositor::RequestRestyle; r=heycam (433ed32b4c)
- Bug 1232577 part 8 - Move call to PostRestyleForAnimation to EffectCompositor; r=heycam (be7dd74654)
- Bug 1232577 part 9 - Remove AnimationCollection::mStyleRuleRefreshTime; r=heycam (0fcc53cbfc)
- Bug 1232577 part 10 - Remove AnimationCollection::mStyleChanging; r=heycam (0737fe0747)
- Bug 1232577 part 11 - Remove AnimationCollection::mHasPendingAnimationRestyle; r=heycam (3d2aa0bfa4)
- Bug 1232577 part 12 - Move the remainder of RequestRestyle from AnimationCollection to EffectCompositor; r=heycam (1a180acbc2)
- Bug 1232577 part 13 - Move EnsureStyleRuleFor from AnimationCollection to EffectCompositor (dcce4b105b)
- Bug 1232577 part 14 - Move FlushAnimations to EffectCompositor; r=heycam (67e5019f44)
- Bug 1232577 part 15 - Drop LastStyleUpdateForAllAnimations flag from pres context; r=heycam (dce1abfd87)
- Bug 1232577 part 16 - Move GetAnimationRule to EffectCompositor; r=heycam (df45ee5e40)
- Bug 1232577 part 17 - Move AddStyleUpdatesTo to EffectCompositor; r=heycam (eb62d19b17)
- Bug 1232577 part 18 - Drop RestyleManager::mLastUpdateForThrottledAni…mations; r=heycam (066ca553d3)
- Bug 1232577 part 19 - Move ClearIsRunningOnCompositor to EffectCompositor; r=heycam (0bd47b0890)
- Bug 1237083 - Don't trigger layer flattening if the component alpha layer is directly on top of a forced active layer. r=roc (a54393afd9)
- Bug 1231818 - Make FrameLayerBuilder try harder to respect layers.max-active pref. r=mstange (e9cbb8d6bd)
- Bug 1231538 - Build a ContainerLayer for position:fixed and background-attachment:fixed content. r=roc (efbd221475)
- Bug 1235186 - Part 2: Fix -Wclass-varargs warning in layout/. r=dholbert (4222fbf329)
- Bug 1235186 - Part 1: Fix -Wformat warnings in layout/. r=dholbert (1f6be477be)
- Bug 1235678. Fix printing animated geometry roots of display items. r=dholbert (69dbeb290f)
- Bug 1239864 (part 9) - Use the new rect iterators in layout/ and ipc/. r=dholbert. (98626d2b36)
- Bug 1239864 (part 10) - Use the new rect iterators in view/ and widget/. r=roc. (53a86e19d6)
- Bug 1239864 (part 11) - Remove the old rect iterators. r=roc. (38d2fad35a)
- Bug 1204084 - Double tap gesture fails when tapping on a large element contained in an iframe or scrollable div. r=botond (71463b4cdf)
- Bug 1231517 - part 1, Move GetBoundingContentRect to nsLayoutUtils r=botond (3dbe9c6309)
- Bug 1231517 - part 2, Add support for APZ ZoomToRectBehavior flags r=kats (4a7f22a0cf)
2023-08-16 12:06:39 +08:00

289 lines
8.4 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 "DisplayItemScrollClip.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;
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;
}
#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->GetAnimatedGeometryRoot())->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) scrollClip(%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(),
DisplayItemScrollClip::ToString(aItem->ScrollClip()).get(),
aItem->IsUniform(aBuilder, &color) ? " uniform" : "",
aItem->ReferenceFrame(), aItem->GetAnimatedGeometryRoot()->mFrame);
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);
}
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