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

Bug 1746310 - Remove nsMenuPopupFrame::GenerateFrames and related code. r=tnikkel

The root of the problem is that nsMenuPopupFrame::GenerateFrames calls
into frame construction without making sure that styles are clean. So it
was pretty much working by chance, sorta.

I was going to fix this by adding the necessary flushes before calling
GenerateFrames, but on closer inspection, the front-end has effectively
already implemented this optimization by only generating the relevant
DOM on popupShowing:

  https://searchfox.org/mozilla-central/rev/a11b63915bd7810a03635d733123448ab5bfcad3/toolkit/content/widgets/menupopup.js#87-91

And for menulists on creation:

  https://searchfox.org/mozilla-central/rev/a11b63915bd7810a03635d733123448ab5bfcad3/toolkit/content/widgets/menupopup.js#151

After bug 1714846 we even destroy frames as needed, for panels.

So I think all of this complexity is unwarranted, and if we need some of
it we should implement it in the front-end like bug 1714846 did, and I'd
rather do this than flushing styles and so on.

There's one tweak I had to do to an nsPlaceholderFrame assertion. The
reason is that now the nsMenuPopupFrames do get their
NS_FRAME_FIRST_REFLOW bit cleared here:

  https://searchfox.org/mozilla-central/rev/bd25b1ca76dd5d323ffc69557f6cf759ba76ba23/layout/xul/nsMenuPopupFrame.cpp#557

Because the IsLeaf() condition here is no longer true:

  https://searchfox.org/mozilla-central/rev/bd25b1ca76dd5d323ffc69557f6cf759ba76ba23/layout/xul/nsMenuPopupFrame.cpp#532

It doesn't change anything though, because this condition never holded
for popups consistently.

Differential Revision: https://phabricator.services.mozilla.com/D134331
parent 9e3ccb99
Loading
Loading
Loading
Loading
+0 −25
Original line number Diff line number Diff line
@@ -11700,31 +11700,6 @@ void nsCSSFrameConstructor::ReframeContainingBlock(nsIFrame* aFrame) {
                           InsertionKind::Async);
}

void nsCSSFrameConstructor::GenerateChildFrames(nsContainerFrame* aFrame) {
  {
    nsAutoScriptBlocker scriptBlocker;
    nsFrameList childList;
    nsFrameConstructorState state(mPresShell, nullptr, nullptr, nullptr);

    nsFrameConstructorSaveState floatSaveState;
    state.MaybePushFloatContainingBlock(aFrame, floatSaveState);

    ProcessChildren(state, aFrame->GetContent(), aFrame->Style(), aFrame, false,
                    childList, false);

    aFrame->SetInitialChildList(kPrincipalList, childList);
  }

#ifdef ACCESSIBILITY
  if (nsAccessibilityService* accService =
          PresShell::GetAccessibilityService()) {
    if (nsIContent* child = aFrame->GetContent()->GetFirstChild()) {
      accService->ContentRangeInserted(mPresShell, child, nullptr);
    }
  }
#endif
}

//////////////////////////////////////////////////////////
// nsCSSFrameConstructor::FrameConstructionItem methods //
//////////////////////////////////////////////////////////
+0 −3
Original line number Diff line number Diff line
@@ -275,9 +275,6 @@ class nsCSSFrameConstructor final : public nsFrameManager {
  bool EnsureFrameForTextNodeIsCreatedAfterFlush(
      mozilla::dom::CharacterData* aContent);

  // Generate the child frames and process bindings
  void GenerateChildFrames(nsContainerFrame* aFrame);

  // Should be called when a frame is going to be destroyed and
  // WillDestroyFrameTree hasn't been called yet.
  void NotifyDestroyingFrame(nsIFrame* aFrame);
+0 −1
Original line number Diff line number Diff line
@@ -6,7 +6,6 @@
# Leaf constants to pass to Frame's leafness argument.
LEAF = "Leaf"
NOT_LEAF = "NotLeaf"
DYNAMIC_LEAF = "DynamicLeaf"


class FrameClass:
+2 −2
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Frame class definitions, used to generate FrameIdList.h and FrameTypeList.h

from FrameClass import Frame, AbstractFrame, LEAF, NOT_LEAF, DYNAMIC_LEAF
from FrameClass import Frame, AbstractFrame, LEAF, NOT_LEAF

FRAME_CLASSES = [
    Frame("BRFrame", "Br", LEAF),
@@ -68,7 +68,7 @@ FRAME_CLASSES = [
    Frame("nsMathMLTokenFrame", "None", NOT_LEAF),
    Frame("nsMenuBarFrame", "Box", NOT_LEAF),
    Frame("nsMenuFrame", "Menu", NOT_LEAF),
    Frame("nsMenuPopupFrame", "MenuPopup", DYNAMIC_LEAF),
    Frame("nsMenuPopupFrame", "MenuPopup", NOT_LEAF),
    Frame("nsMeterFrame", "Meter", LEAF),
    Frame("nsNumberControlFrame", "TextInput", LEAF),
    Frame("nsPageBreakFrame", "PageBreak", LEAF),
+0 −2
Original line number Diff line number Diff line
@@ -171,13 +171,11 @@ const nsIFrame::FrameClassBits nsIFrame::sFrameClassBits[
    0] = {
#define Leaf eFrameClassBitsLeaf
#define NotLeaf eFrameClassBitsNone
#define DynamicLeaf eFrameClassBitsDynamicLeaf
#define FRAME_ID(class_, type_, leaf_, ...) leaf_,
#define ABSTRACT_FRAME_ID(...)
#include "mozilla/FrameIdList.h"
#undef Leaf
#undef NotLeaf
#undef DynamicLeaf
#undef FRAME_ID
#undef ABSTRACT_FRAME_ID
};
Loading