Skip to content

Commit

Permalink
Bug 1781034 - Remove layout debugger's visual debugging. r=layout-rev…
Browse files Browse the repository at this point in the history
…iewers,dshin

Differential Revision: https://phabricator.services.mozilla.com/D152628
  • Loading branch information
emilio committed Jul 26, 2022
1 parent 17d27fa commit eef7f0f
Show file tree
Hide file tree
Showing 12 changed files with 1 addition and 221 deletions.
31 changes: 0 additions & 31 deletions layout/base/PresShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2231,12 +2231,6 @@ void PresShell::NotifyDestroyingFrame(nsIFrame* aFrame) {
mCurrentEventFrame = nullptr;
}

#ifdef DEBUG
if (aFrame == mDrawEventTargetFrame) {
mDrawEventTargetFrame = nullptr;
}
#endif

for (unsigned int i = 0; i < mCurrentEventFrameStack.Length(); i++) {
if (aFrame == mCurrentEventFrameStack.ElementAt(i)) {
// One of our stack frames was deleted. Get its content so that when we
Expand Down Expand Up @@ -7112,9 +7106,6 @@ nsresult PresShell::EventHandler::HandleEventUsingCoordinates(
nsresult rv = eventHandler.HandleEventWithCurrentEventInfo(
aGUIEvent, aEventStatus, true,
MOZ_KnownLive(eventTargetData.mOverrideClickTarget));
#ifdef DEBUG
eventTargetData.mPresShell->ShowEventTargetDebug();
#endif
return rv;
}

Expand Down Expand Up @@ -7911,11 +7902,6 @@ nsresult PresShell::EventHandler::HandleEventAtFocusedContent(

nsresult rv =
HandleEventWithCurrentEventInfo(aGUIEvent, aEventStatus, true, nullptr);

#ifdef DEBUG
mPresShell->ShowEventTargetDebug();
#endif

return rv;
}

Expand Down Expand Up @@ -8017,10 +8003,6 @@ nsresult PresShell::EventHandler::HandleEventWithFrameForPresShell(
HandleEventWithCurrentEventInfo(aGUIEvent, aEventStatus, true, nullptr);
}

#ifdef DEBUG
mPresShell->ShowEventTargetDebug();
#endif

return rv;
}

Expand Down Expand Up @@ -8052,19 +8034,6 @@ Document* PresShell::GetPrimaryContentDocument() {
return childDocShell->GetExtantDocument();
}

#ifdef DEBUG
void PresShell::ShowEventTargetDebug() {
if (nsIFrame::GetShowEventTargetFrameBorder() && GetCurrentEventFrame()) {
if (mDrawEventTargetFrame) {
mDrawEventTargetFrame->InvalidateFrame();
}

mDrawEventTargetFrame = mCurrentEventFrame;
mDrawEventTargetFrame->InvalidateFrame();
}
}
#endif

nsresult PresShell::EventHandler::HandleEventWithTarget(
WidgetEvent* aEvent, nsIFrame* aNewEventFrame, nsIContent* aNewEventContent,
nsEventStatus* aEventStatus, bool aIsHandlingNativeEvent,
Expand Down
7 changes: 0 additions & 7 deletions layout/base/PresShell.h
Original file line number Diff line number Diff line change
Expand Up @@ -1731,10 +1731,6 @@ class PresShell final : public nsStubDocumentObserver,
*/
void NotifyDestroyingFrame(nsIFrame* aFrame);

#ifdef DEBUG
nsIFrame* GetDrawEventTargetFrame() { return mDrawEventTargetFrame; }
#endif

bool GetZoomableByAPZ() const;

private:
Expand Down Expand Up @@ -2833,14 +2829,11 @@ class PresShell final : public nsStubDocumentObserver,
MOZ_CAN_RUN_SCRIPT_BOUNDARY bool VerifyIncrementalReflow();
MOZ_CAN_RUN_SCRIPT_BOUNDARY void DoVerifyReflow();
void VerifyHasDirtyRootAncestor(nsIFrame* aFrame);
void ShowEventTargetDebug();

bool mInVerifyReflow = false;
// The reflow root under which we're currently reflowing. Null when
// not in reflow.
nsIFrame* mCurrentReflowRoot = nullptr;

nsIFrame* mDrawEventTargetFrame = nullptr;
#endif // #ifdef DEBUG

// Send, and reset, the current per tick telemetry. This includes:
Expand Down
67 changes: 0 additions & 67 deletions layout/generic/nsIFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,21 +303,6 @@ std::ostream& operator<<(std::ostream& aStream, const nsReflowStatus& aStatus) {
}

#ifdef DEBUG
static bool gShowFrameBorders = false;

void nsIFrame::ShowFrameBorders(bool aEnable) { gShowFrameBorders = aEnable; }

bool nsIFrame::GetShowFrameBorders() { return gShowFrameBorders; }

static bool gShowEventTargetFrameBorder = false;

void nsIFrame::ShowEventTargetFrameBorder(bool aEnable) {
gShowEventTargetFrameBorder = aEnable;
}

bool nsIFrame::GetShowEventTargetFrameBorder() {
return gShowEventTargetFrameBorder;
}

/**
* Note: the log module is created during library initialization which
Expand Down Expand Up @@ -2762,45 +2747,6 @@ nsSize nsIFrame::OverflowClipMargin(PhysicalAxes aClipAxes) const {
return result;
}

#ifdef DEBUG
static void PaintDebugBorder(nsIFrame* aFrame, DrawTarget* aDrawTarget,
const nsRect& aDirtyRect, nsPoint aPt) {
nsRect r(aPt, aFrame->GetSize());
int32_t appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
sRGBColor blueOrRed(aFrame->HasView() ? sRGBColor(0.f, 0.f, 1.f, 1.f)
: sRGBColor(1.f, 0.f, 0.f, 1.f));
aDrawTarget->StrokeRect(NSRectToRect(r, appUnitsPerDevPixel),
ColorPattern(ToDeviceColor(blueOrRed)));
}

static void PaintEventTargetBorder(nsIFrame* aFrame, DrawTarget* aDrawTarget,
const nsRect& aDirtyRect, nsPoint aPt) {
nsRect r(aPt, aFrame->GetSize());
int32_t appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
ColorPattern purple(ToDeviceColor(sRGBColor(.5f, 0.f, .5f, 1.f)));
aDrawTarget->StrokeRect(NSRectToRect(r, appUnitsPerDevPixel), purple);
}

static void DisplayDebugBorders(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame,
const nsDisplayListSet& aLists) {
// Draw a border around the child
// REVIEW: From nsContainerFrame::PaintChild
if (nsIFrame::GetShowFrameBorders() && !aFrame->GetRect().IsEmpty()) {
aLists.Outlines()->AppendNewToTop<nsDisplayGeneric>(
aBuilder, aFrame, PaintDebugBorder, "DebugBorder",
DisplayItemType::TYPE_DEBUG_BORDER);
}
// Draw a border around the current event target
if (nsIFrame::GetShowEventTargetFrameBorder() &&
aFrame->PresShell()->GetDrawEventTargetFrame() == aFrame) {
aLists.Outlines()->AppendNewToTop<nsDisplayGeneric>(
aBuilder, aFrame, PaintEventTargetBorder, "EventTargetBorder",
DisplayItemType::TYPE_EVENT_TARGET_BORDER);
}
}
#endif

/**
* Returns whether a display item that gets created with the builder's current
* state will have a scrolled clip, i.e. a clip that is scrolled by a scroll
Expand Down Expand Up @@ -3494,10 +3440,6 @@ void nsIFrame::BuildDisplayListForStackingContext(
nsDisplayList resultList(aBuilder);
set.SerializeWithCorrectZOrder(&resultList, content);

#ifdef DEBUG
DisplayDebugBorders(aBuilder, this, set);
#endif

// Get the ASR to use for the container items that we create here.
const ActiveScrolledRoot* containerItemASR = contASRTracker.GetContainerASR();

Expand Down Expand Up @@ -3997,9 +3939,6 @@ void nsIFrame::BuildDisplayListForSimpleChild(nsDisplayListBuilder* aBuilder,
aChild->SetBuiltDisplayList(true);
aBuilder->Check();
aBuilder->DisplayCaret(aChild, aLists.Outlines());
#ifdef DEBUG
DisplayDebugBorders(aBuilder, aChild, aLists);
#endif
}

nsIFrame::DisplayChildFlag nsIFrame::DisplayFlagForFlexOrGridItem() const {
Expand Down Expand Up @@ -4322,9 +4261,6 @@ void nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder,
child->BuildDisplayList(aBuilder, aLists);
aBuilder->Check();
aBuilder->DisplayCaret(child, aLists.Outlines());
#ifdef DEBUG
DisplayDebugBorders(aBuilder, child, aLists);
#endif
return;
}

Expand All @@ -4350,9 +4286,6 @@ void nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder,
list.AppendToTop(pseudoStack.Content());
list.AppendToTop(pseudoStack.Outlines());
extraPositionedDescendants.AppendToTop(pseudoStack.PositionedDescendants());
#ifdef DEBUG
DisplayDebugBorders(aBuilder, child, aLists);
#endif
}

buildingForChild.RestoreBuildingInvisibleItemsValue();
Expand Down
8 changes: 0 additions & 8 deletions layout/generic/nsIFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -5503,14 +5503,6 @@ class nsIFrame : public nsQueryFrame {
static void DisplayReflowShutdown();

static mozilla::LazyLogModule sFrameLogModule;

// Show frame borders when rendering
static void ShowFrameBorders(bool aEnable);
static bool GetShowFrameBorders();

// Show frame border of event target
static void ShowEventTargetFrameBorder(bool aEnable);
static bool GetShowEventTargetFrameBorder();
#endif
};

Expand Down
23 changes: 0 additions & 23 deletions layout/generic/nsImageFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1936,21 +1936,6 @@ ImgDrawResult nsImageFrame::DisplayAltFeedbackWithoutLayer(
return textDrawResult ? ImgDrawResult::SUCCESS : ImgDrawResult::NOT_READY;
}

#ifdef DEBUG
static void PaintDebugImageMap(nsIFrame* aFrame, DrawTarget* aDrawTarget,
const nsRect& aDirtyRect, nsPoint aPt) {
nsImageFrame* f = static_cast<nsImageFrame*>(aFrame);
nsRect inner = f->GetContentRectRelativeToSelf() + aPt;
gfxPoint devPixelOffset = nsLayoutUtils::PointToGfxPoint(
inner.TopLeft(), aFrame->PresContext()->AppUnitsPerDevPixel());
AutoRestoreTransform autoRestoreTransform(aDrawTarget);
aDrawTarget->SetTransform(
aDrawTarget->GetTransform().PreTranslate(ToPoint(devPixelOffset)));
f->GetImageMap()->Draw(aFrame, *aDrawTarget,
ColorPattern(ToDeviceColor(sRGBColor::OpaqueBlack())));
}
#endif

// We want to sync-decode in this case, as otherwise we either need to flash
// white while waiting to decode the new image, or paint the old image with a
// different aspect-ratio, which would be bad as it'd be stretched.
Expand Down Expand Up @@ -2294,14 +2279,6 @@ void nsImageFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
gIconLoad->RemoveIconObserver(this);
mDisplayingIcon = false;
}

#ifdef DEBUG
if (GetShowFrameBorders() && GetImageMap()) {
aLists.Outlines()->AppendNewToTop<nsDisplayGeneric>(
aBuilder, this, PaintDebugImageMap, "DebugImageMap",
DisplayItemType::TYPE_DEBUG_IMAGE_MAP);
}
#endif
}
}

Expand Down
26 changes: 0 additions & 26 deletions layout/generic/nsPlaceholderFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,37 +234,11 @@ ComputedStyle* nsPlaceholderFrame::GetLayoutParentStyleForOutOfFlow(
return *aProviderFrame ? (*aProviderFrame)->Style() : nullptr;
}

#ifdef DEBUG
static void PaintDebugPlaceholder(nsIFrame* aFrame, DrawTarget* aDrawTarget,
const nsRect& aDirtyRect, nsPoint aPt) {
ColorPattern cyan(ToDeviceColor(sRGBColor(0.f, 1.f, 1.f, 1.f)));
int32_t appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();

nscoord x = nsPresContext::CSSPixelsToAppUnits(-5);
nsRect r(aPt.x + x, aPt.y, nsPresContext::CSSPixelsToAppUnits(13),
nsPresContext::CSSPixelsToAppUnits(3));
aDrawTarget->FillRect(NSRectToRect(r, appUnitsPerDevPixel), cyan);

nscoord y = nsPresContext::CSSPixelsToAppUnits(-10);
r = nsRect(aPt.x, aPt.y + y, nsPresContext::CSSPixelsToAppUnits(3),
nsPresContext::CSSPixelsToAppUnits(10));
aDrawTarget->FillRect(NSRectToRect(r, appUnitsPerDevPixel), cyan);
}
#endif // DEBUG

#if defined(DEBUG) || (defined(MOZ_REFLOW_PERF_DSP) && defined(MOZ_REFLOW_PERF))

void nsPlaceholderFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) {
DO_GLOBAL_REFLOW_COUNT_DSP("nsPlaceholderFrame");

# ifdef DEBUG
if (GetShowFrameBorders()) {
aLists.Outlines()->AppendNewToTop<nsDisplayGeneric>(
aBuilder, this, PaintDebugPlaceholder, "DebugPlaceholder",
DisplayItemType::TYPE_DEBUG_PLACEHOLDER);
}
# endif
}
#endif // DEBUG || (MOZ_REFLOW_PERF_DSP && MOZ_REFLOW_PERF)

Expand Down
8 changes: 0 additions & 8 deletions layout/painting/nsDisplayItemTypesList.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ DECLARE_DISPLAY_ITEM_TYPE(XUL_IMAGE, 0)
DECLARE_DISPLAY_ITEM_TYPE(XUL_TEXT_BOX, TYPE_RENDERS_NO_IMAGES)
DECLARE_DISPLAY_ITEM_TYPE(XUL_TREE_BODY, 0)
DECLARE_DISPLAY_ITEM_TYPE(XUL_TREE_COL_SPLITTER_TARGET, TYPE_RENDERS_NO_IMAGES)
#ifdef DEBUG_LAYOUT
DECLARE_DISPLAY_ITEM_TYPE(XUL_DEBUG, TYPE_RENDERS_NO_IMAGES)
#endif

DECLARE_DISPLAY_ITEM_TYPE(MATHML_BAR, TYPE_RENDERS_NO_IMAGES)
DECLARE_DISPLAY_ITEM_TYPE(MATHML_CHAR_FOREGROUND, TYPE_RENDERS_NO_IMAGES)
Expand All @@ -123,9 +120,4 @@ DECLARE_DISPLAY_ITEM_TYPE(MATHML_SLASH, TYPE_RENDERS_NO_IMAGES)
#ifdef DEBUG
DECLARE_DISPLAY_ITEM_TYPE(MATHML_BOUNDING_METRICS, TYPE_RENDERS_NO_IMAGES)
DECLARE_DISPLAY_ITEM_TYPE(MATHML_CHAR_DEBUG, TYPE_RENDERS_NO_IMAGES)

DECLARE_DISPLAY_ITEM_TYPE(DEBUG_BORDER, TYPE_RENDERS_NO_IMAGES)
DECLARE_DISPLAY_ITEM_TYPE(DEBUG_IMAGE_MAP, TYPE_RENDERS_NO_IMAGES)
DECLARE_DISPLAY_ITEM_TYPE(DEBUG_PLACEHOLDER, TYPE_RENDERS_NO_IMAGES)
DECLARE_DISPLAY_ITEM_TYPE(EVENT_TARGET_BORDER, TYPE_RENDERS_NO_IMAGES)
#endif
5 changes: 1 addition & 4 deletions layout/tools/layout-debug/src/nsILayoutDebuggingTools.idl
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ interface mozIDOMWindow;
* layout debugging functions to be used from chrome.
*/

[scriptable, uuid(f336d8d3-9721-4ad3-85d0-a7018c0a3383)]
[builtinclass, scriptable, uuid(f336d8d3-9721-4ad3-85d0-a7018c0a3383)]
interface nsILayoutDebuggingTools : nsISupports
{

/*
* Initialize debugger object to act on a docshell.
*/
Expand All @@ -26,8 +25,6 @@ interface nsILayoutDebuggingTools : nsISupports
void forceRefresh();

/* Toggle various debugging states */
void setVisualDebugging(in boolean enabled);
void setVisualEventDebugging(in boolean enabled);
void setReflowCounts(in boolean enabled);
void setPagedMode(in boolean enabled);

Expand Down
18 changes: 0 additions & 18 deletions layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,6 @@ nsLayoutDebuggingTools::Init(mozIDOMWindow* aWin) {
return NS_OK;
}

NS_IMETHODIMP
nsLayoutDebuggingTools::SetVisualDebugging(bool aVisualDebugging) {
#ifdef DEBUG
nsIFrame::ShowFrameBorders(aVisualDebugging);
ForceRefresh();
#endif
return NS_OK;
}

NS_IMETHODIMP
nsLayoutDebuggingTools::SetVisualEventDebugging(bool aVisualEventDebugging) {
#ifdef DEBUG
nsIFrame::ShowEventTargetFrameBorder(aVisualEventDebugging);
ForceRefresh();
#endif
return NS_OK;
}

NS_IMETHODIMP
nsLayoutDebuggingTools::SetReflowCounts(bool aShow) {
NS_ENSURE_TRUE(mDocShell, NS_ERROR_NOT_INITIALIZED);
Expand Down
22 changes: 0 additions & 22 deletions layout/tools/layout-debug/ui/content/layoutdebug.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ const COMMANDS = [
class Debugger {
constructor() {
this._flags = new Map();
this._visualDebugging = false;
this._visualEventDebugging = false;
this._pagedMode = false;
this._attached = false;

Expand Down Expand Up @@ -89,26 +87,6 @@ class Debugger {
}
}

get visualDebugging() {
return this._visualDebugging;
}

set visualDebugging(v) {
v = !!v;
this._visualDebugging = v;
this._sendMessage("setVisualDebugging", v);
}

get visualEventDebugging() {
return this._visualEventDebugging;
}

set visualEventDebugging(v) {
v = !!v;
this._visualEventDebugging = v;
this._sendMessage("setVisualEventDebugging", v);
}

get pagedMode() {
return this._pagedMode;
}
Expand Down
Loading

0 comments on commit eef7f0f

Please sign in to comment.