From eef7f0ff1658a653cd2d3f24d60d54413deba06a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Tue, 26 Jul 2022 15:06:30 +0000 Subject: [PATCH] Bug 1781034 - Remove layout debugger's visual debugging. r=layout-reviewers,dshin Differential Revision: https://phabricator.services.mozilla.com/D152628 --- layout/base/PresShell.cpp | 31 --------- layout/base/PresShell.h | 7 -- layout/generic/nsIFrame.cpp | 67 ------------------- layout/generic/nsIFrame.h | 8 --- layout/generic/nsImageFrame.cpp | 23 ------- layout/generic/nsPlaceholderFrame.cpp | 26 ------- layout/painting/nsDisplayItemTypesList.h | 8 --- .../src/nsILayoutDebuggingTools.idl | 5 +- .../src/nsLayoutDebuggingTools.cpp | 18 ----- .../layout-debug/ui/content/layoutdebug.js | 22 ------ .../layout-debug/ui/content/layoutdebug.xhtml | 3 - .../ui/locale/en-US/layoutdebug.dtd | 4 -- 12 files changed, 1 insertion(+), 221 deletions(-) diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index 014b655e374af..24eb1ef59ed45 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -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 @@ -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; } @@ -7911,11 +7902,6 @@ nsresult PresShell::EventHandler::HandleEventAtFocusedContent( nsresult rv = HandleEventWithCurrentEventInfo(aGUIEvent, aEventStatus, true, nullptr); - -#ifdef DEBUG - mPresShell->ShowEventTargetDebug(); -#endif - return rv; } @@ -8017,10 +8003,6 @@ nsresult PresShell::EventHandler::HandleEventWithFrameForPresShell( HandleEventWithCurrentEventInfo(aGUIEvent, aEventStatus, true, nullptr); } -#ifdef DEBUG - mPresShell->ShowEventTargetDebug(); -#endif - return rv; } @@ -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, diff --git a/layout/base/PresShell.h b/layout/base/PresShell.h index 99afe0c50bbae..4d91f3de2232b 100644 --- a/layout/base/PresShell.h +++ b/layout/base/PresShell.h @@ -1731,10 +1731,6 @@ class PresShell final : public nsStubDocumentObserver, */ void NotifyDestroyingFrame(nsIFrame* aFrame); -#ifdef DEBUG - nsIFrame* GetDrawEventTargetFrame() { return mDrawEventTargetFrame; } -#endif - bool GetZoomableByAPZ() const; private: @@ -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: diff --git a/layout/generic/nsIFrame.cpp b/layout/generic/nsIFrame.cpp index 230795307effc..a64df0be36358 100644 --- a/layout/generic/nsIFrame.cpp +++ b/layout/generic/nsIFrame.cpp @@ -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 @@ -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( - 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( - 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 @@ -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(); @@ -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 { @@ -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; } @@ -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(); diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index 90cd5b533960b..de2fbc14a014f 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -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 }; diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index 04876318c51cc..15e03e6985e9f 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -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(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. @@ -2294,14 +2279,6 @@ void nsImageFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, gIconLoad->RemoveIconObserver(this); mDisplayingIcon = false; } - -#ifdef DEBUG - if (GetShowFrameBorders() && GetImageMap()) { - aLists.Outlines()->AppendNewToTop( - aBuilder, this, PaintDebugImageMap, "DebugImageMap", - DisplayItemType::TYPE_DEBUG_IMAGE_MAP); - } -#endif } } diff --git a/layout/generic/nsPlaceholderFrame.cpp b/layout/generic/nsPlaceholderFrame.cpp index c0e61c4718442..c2852577adcf6 100644 --- a/layout/generic/nsPlaceholderFrame.cpp +++ b/layout/generic/nsPlaceholderFrame.cpp @@ -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( - aBuilder, this, PaintDebugPlaceholder, "DebugPlaceholder", - DisplayItemType::TYPE_DEBUG_PLACEHOLDER); - } -# endif } #endif // DEBUG || (MOZ_REFLOW_PERF_DSP && MOZ_REFLOW_PERF) diff --git a/layout/painting/nsDisplayItemTypesList.h b/layout/painting/nsDisplayItemTypesList.h index 06cd20aba4024..82343e7d477f1 100644 --- a/layout/painting/nsDisplayItemTypesList.h +++ b/layout/painting/nsDisplayItemTypesList.h @@ -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) @@ -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 diff --git a/layout/tools/layout-debug/src/nsILayoutDebuggingTools.idl b/layout/tools/layout-debug/src/nsILayoutDebuggingTools.idl index 409e42405d3ee..f689734a464ef 100644 --- a/layout/tools/layout-debug/src/nsILayoutDebuggingTools.idl +++ b/layout/tools/layout-debug/src/nsILayoutDebuggingTools.idl @@ -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. */ @@ -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); diff --git a/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp b/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp index 701da4c2f71b5..72bb48f5d404b 100644 --- a/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp +++ b/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp @@ -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); diff --git a/layout/tools/layout-debug/ui/content/layoutdebug.js b/layout/tools/layout-debug/ui/content/layoutdebug.js index 212c333bd7fe1..077aa67e00c62 100644 --- a/layout/tools/layout-debug/ui/content/layoutdebug.js +++ b/layout/tools/layout-debug/ui/content/layoutdebug.js @@ -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; @@ -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; } diff --git a/layout/tools/layout-debug/ui/content/layoutdebug.xhtml b/layout/tools/layout-debug/ui/content/layoutdebug.xhtml index 4f5513eb30e73..fc6f26e811800 100644 --- a/layout/tools/layout-debug/ui/content/layoutdebug.xhtml +++ b/layout/tools/layout-debug/ui/content/layoutdebug.xhtml @@ -72,9 +72,6 @@ - - - diff --git a/layout/tools/layout-debug/ui/locale/en-US/layoutdebug.dtd b/layout/tools/layout-debug/ui/locale/en-US/layoutdebug.dtd index 2e7e07fed478f..45bc21eb81e92 100644 --- a/layout/tools/layout-debug/ui/locale/en-US/layoutdebug.dtd +++ b/layout/tools/layout-debug/ui/locale/en-US/layoutdebug.dtd @@ -15,10 +15,6 @@ - - - -