Commit 275707a5 authored by Emilio Cobos Álvarez's avatar Emilio Cobos Álvarez
Browse files

Bug 1665476 - Remove nsRootBoxFrame to unify background propagation between...

Bug 1665476 - Remove nsRootBoxFrame to unify background propagation between XUL and non-XUL documents. r=layout-reviewers,mats

It's unused on mozilla-central, and Thunderbird can just use the canvas
frame as regular (X)HTML documents, so just use a canvas frame instead
of an nsRootBoxFrame for XUL as well.

nsRootBoxFrame was needed because of various XUL-specific things like
tooltips and so on lived there. But with the move away from XUL, that
functionality has been added to nsCanvasFrame already, behind a
principal check instead.

This also allows simplifying our background propagation setup, which was
only half-working for XUL documents (this bug is a consequence of that).

With this, most of the callers of nsCSSRendering::IsCanvasFrame can go.
They're only two of the frames that would return true for that that
actually paint backgrounds (nsCanvasFrame and nsRootBoxFrame), so the
codepaths in display list building and painting can just check
frame->IsCanvasFrame() instead.

The remaining caller to that function is
nsContainerFrame::SyncWindowProperties, and the change is also legit, in
the sense that the only thing SyncWindowProperties() really cares about
is propagating the max/min-width constraints from the root element's
style to the view/widget, and the only frame that would return true from
IsCanvasFrame and have a view is the viewport frame which is the root of
the frame tree.

Differential Revision: https://phabricator.services.mozilla.com/D90846
parent edad6cfc
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@
#include "nsCSSPropertyIDSet.h"
#include "nsCSSProps.h"             // For nsCSSProps::PropHasFlags
#include "nsCSSPseudoElements.h"    // For PseudoStyleType
#include "nsCSSRendering.h"         // For IsCanvasFrame
#include "nsDOMMutationObserver.h"  // For nsAutoAnimationMutationBatch
#include "nsIFrame.h"
#include "nsIFrameInlines.h"
@@ -2052,7 +2051,7 @@ KeyframeEffect::MatchForCompositor KeyframeEffect::IsMatchForCompositor(
    // We don't yet support off-main-thread background-color animations on
    // canvas frame or on <body> which genarate nsDisplayCanvasBackgroundColor
    // or nsDisplaySolidColor display item.
    if (nsCSSRendering::IsCanvasFrame(aFrame) ||
    if (aFrame->IsCanvasFrame() ||
        (aFrame->GetContent() &&
         aFrame->GetContent()->IsHTMLElement(nsGkAtoms::body))) {
      return KeyframeEffect::MatchForCompositor::No;
+0 −2
Original line number Diff line number Diff line
@@ -466,8 +466,6 @@ void APZCCallbackHelper::InitializeRootDisplayport(PresShell* aPresShell) {
      DisplayPortUtils::SetDisplayPortBaseIfNotSet(content, *baseRect);
    }

    // Note that we also set the base rect that goes with these margins in
    // nsRootBoxFrame::BuildDisplayList.
    DisplayPortUtils::SetDisplayPortMargins(
        content, aPresShell, DisplayPortMargins::Empty(content),
        DisplayPortUtils::ClearMinimalDisplayPortProperty::Yes, 0);
+1 −1
Original line number Diff line number Diff line
@@ -5216,7 +5216,7 @@ void PresShell::AddCanvasBackgroundColorItem(
  // cases (it will usually be a viewport frame when we have a canvas frame in
  // the (sub)tree).
  if (!(aFlags & AddCanvasBackgroundColorFlags::ForceDraw) &&
      !nsCSSRendering::IsCanvasFrame(aFrame)) {
      !aFrame->IsViewportFrame() && !aFrame->IsPageContentFrame()) {
    return;
  }

+5 −19
Original line number Diff line number Diff line
@@ -214,9 +214,6 @@ static FrameCtorDebugFlags gFlags[] = {

//------------------------------------------------------------------

nsContainerFrame* NS_NewRootBoxFrame(PresShell* aPresShell,
                                     ComputedStyle* aStyle);

nsContainerFrame* NS_NewDocElementBoxFrame(PresShell* aPresShell,
                                           ComputedStyle* aStyle);

@@ -2595,7 +2592,7 @@ void nsCSSFrameConstructor::SetUpDocElementContainingBlock(
  Galley presentation, XUL

      ViewportFrame [fixed-cb]
        nsRootBoxFrame
        nsCanvasFrame [abs-cb]
          root element frame (nsDocElementBoxFrame)

  Print presentation, non-XUL
@@ -2632,7 +2629,7 @@ void nsCSSFrameConstructor::SetUpDocElementContainingBlock(
    mRootElementFrame is "root element frame".  This is the primary frame for
      the root element.
    mDocElementContainingBlock is the parent of mRootElementFrame
      (i.e. nsCanvasFrame or nsRootBoxFrame)
      (i.e. nsCanvasFrame)
    mPageSequenceFrame is the nsPageSequenceFrame, or null if there isn't
      one
  */
@@ -2675,21 +2672,10 @@ void nsCSSFrameConstructor::SetUpDocElementContainingBlock(
      static_cast<nsContainerFrame*>(GetRootFrame());
  ComputedStyle* viewportPseudoStyle = viewportFrame->Style();

  nsContainerFrame* rootFrame = nullptr;

#ifdef MOZ_XUL
  if (aDocElement->IsXULElement()) {
    // pass a temporary stylecontext, the correct one will be set later
    rootFrame = NS_NewRootBoxFrame(mPresShell, viewportPseudoStyle);
  } else
#endif
  {
    // pass a temporary stylecontext, the correct one will be set later
    rootFrame = NS_NewCanvasFrame(mPresShell, viewportPseudoStyle);
    mHasRootAbsPosContainingBlock = true;
  }

  nsContainerFrame* rootFrame =
    NS_NewCanvasFrame(mPresShell, viewportPseudoStyle);
  PseudoStyleType rootPseudo = PseudoStyleType::canvas;
  mHasRootAbsPosContainingBlock = true;
  mDocElementContainingBlock = rootFrame;

  // --------- IF SCROLLABLE WRAP IN SCROLLFRAME --------
+1 −3
Original line number Diff line number Diff line
@@ -203,9 +203,7 @@ bool nsFrameIterator::IsDone() { return mOffEdge != 0; }

void nsFrameIterator::First() { mCurrent = mStart; }

static bool IsRootFrame(nsIFrame* aFrame) {
  return aFrame->IsCanvasFrame() || aFrame->IsXULRootFrame();
}
static bool IsRootFrame(nsIFrame* aFrame) { return aFrame->IsCanvasFrame(); }

void nsFrameIterator::Last() {
  nsIFrame* result;
Loading