diff options
author | Matt A. Tobin <email@mattatobin.com> | 2020-04-14 22:04:32 -0400 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2020-04-14 22:04:32 -0400 |
commit | e215bfbb802a4c854aa7323c698ea5dff4045e25 (patch) | |
tree | f58f4b3dc8d9440f40840f635b39c8eefefe6cca /layout | |
parent | b356448d145cbd294d051624512bfbfaaf18d9b6 (diff) | |
download | UXP-e215bfbb802a4c854aa7323c698ea5dff4045e25.tar UXP-e215bfbb802a4c854aa7323c698ea5dff4045e25.tar.gz UXP-e215bfbb802a4c854aa7323c698ea5dff4045e25.tar.lz UXP-e215bfbb802a4c854aa7323c698ea5dff4045e25.tar.xz UXP-e215bfbb802a4c854aa7323c698ea5dff4045e25.zip |
Bug 1334247 - Remove nsIAnonymousContentCreator::CreateFrameFor
Tag #1375
Diffstat (limited to 'layout')
-rw-r--r-- | layout/base/nsCSSFrameConstructor.cpp | 27 | ||||
-rw-r--r-- | layout/forms/nsComboboxControlFrame.cpp | 14 | ||||
-rw-r--r-- | layout/forms/nsComboboxControlFrame.h | 5 | ||||
-rw-r--r-- | layout/forms/nsGfxButtonControlFrame.cpp | 24 | ||||
-rw-r--r-- | layout/forms/nsGfxButtonControlFrame.h | 1 | ||||
-rw-r--r-- | layout/generic/nsIAnonymousContentCreator.h | 8 |
6 files changed, 19 insertions, 60 deletions
diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 37cd3e45e..d5b21f8d1 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -43,6 +43,7 @@ #include "nsContainerFrame.h" #include "nsNameSpaceManager.h" #include "nsIComboboxControlFrame.h" +#include "nsComboboxControlFrame.h" #include "nsIListControlFrame.h" #include "nsIDOMCharacterData.h" #include "nsPlaceholderFrame.h" @@ -4121,9 +4122,7 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsFrameConstructorState& aState, ancestorPusher.PushStyleScope(aParent->AsElement()); } - nsIAnonymousContentCreator* creator = do_QueryFrame(aParentFrame); - NS_ASSERTION(creator, - "How can that happen if we have nodes to construct frames for?"); + nsComboboxControlFrame* comboboxFrame = do_QueryFrame(aParentFrame); InsertionPoint insertion(aParentFrame, aParent); for (uint32_t i=0; i < count; i++) { @@ -4135,12 +4134,15 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsFrameConstructorState& aState, "nsIAnonymousContentCreator::CreateAnonymousContent to " "output a list where the items have their own children"); - nsIFrame* newFrame = creator->CreateFrameFor(content); - if (newFrame) { - NS_ASSERTION(content->GetPrimaryFrame(), - "Content must have a primary frame now"); - newFrame->AddStateBits(NS_FRAME_ANONYMOUSCONTENTCREATOR_CONTENT); - aChildItems.AddChild(newFrame); + if (comboboxFrame && comboboxFrame->GetDisplayNode() == content) { + // Combo box frames have a custom hook to create frames for the anonymous + // text node. This is the last vestigial trace of an old custom hook that + // allowed arbitrary custom frame creation by any nsIAnonymousContentCreator + // implementation. It's possible that this could all be refactored away. + nsIFrame* customFrame = comboboxFrame->CreateFrameForDisplayNode(); + MOZ_ASSERT(customFrame); + customFrame->AddStateBits(NS_FRAME_ANONYMOUSCONTENTCREATOR_CONTENT); + aChildItems.AddChild(customFrame); } else { FrameConstructionItemList items; { @@ -10660,13 +10662,6 @@ nsCSSFrameConstructor::AddFCItemsForAnonymousContent( { for (uint32_t i = 0; i < aAnonymousItems.Length(); ++i) { nsIContent* content = aAnonymousItems[i].mContent; -#ifdef DEBUG - nsIAnonymousContentCreator* creator = do_QueryFrame(aFrame); - NS_ASSERTION(!creator || !creator->CreateFrameFor(content), - "If you need to use CreateFrameFor, you need to call " - "CreateAnonymousFrames manually and not follow the standard " - "ProcessChildren() codepath for this frame"); -#endif // Gecko-styled nodes should have no pending restyle flags. MOZ_ASSERT_IF(!content->IsStyledByServo(), !content->IsElement() || diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index 78185616f..9d8d639ee 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -249,6 +249,7 @@ nsComboboxControlFrame::~nsComboboxControlFrame() //-------------------------------------------------------------- NS_QUERYFRAME_HEAD(nsComboboxControlFrame) + NS_QUERYFRAME_ENTRY(nsComboboxControlFrame) NS_QUERYFRAME_ENTRY(nsIComboboxControlFrame) NS_QUERYFRAME_ENTRY(nsIFormControlFrame) NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator) @@ -1350,16 +1351,9 @@ nsComboboxDisplayFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, } nsIFrame* -nsComboboxControlFrame::CreateFrameFor(nsIContent* aContent) +nsComboboxControlFrame::CreateFrameForDisplayNode() { - NS_PRECONDITION(nullptr != aContent, "null ptr"); - - NS_ASSERTION(mDisplayContent, "mDisplayContent can't be null!"); - - if (mDisplayContent != aContent) { - // We only handle the frames for mDisplayContent here - return nullptr; - } + MOZ_ASSERT(mDisplayContent); // Get PresShell nsIPresShell *shell = PresContext()->PresShell(); @@ -1384,7 +1378,7 @@ nsComboboxControlFrame::CreateFrameFor(nsIContent* aContent) nsIFrame* textFrame = NS_NewTextFrame(shell, textStyleContext); // initialize the text frame - textFrame->Init(aContent, mDisplayFrame, nullptr); + textFrame->Init(mDisplayContent, mDisplayFrame, nullptr); mDisplayContent->SetPrimaryFrame(textFrame); nsFrameList textList(textFrame, textFrame); diff --git a/layout/forms/nsComboboxControlFrame.h b/layout/forms/nsComboboxControlFrame.h index 22849e8d1..5f190814a 100644 --- a/layout/forms/nsComboboxControlFrame.h +++ b/layout/forms/nsComboboxControlFrame.h @@ -54,6 +54,7 @@ class nsComboboxControlFrame final : public nsBlockFrame, typedef mozilla::gfx::DrawTarget DrawTarget; public: + NS_DECL_QUERYFRAME_TARGET(nsComboboxControlFrame) friend nsContainerFrame* NS_NewComboboxControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, nsFrameState aFlags); @@ -69,7 +70,9 @@ public: virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) override; virtual void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements, uint32_t aFilter) override; - virtual nsIFrame* CreateFrameFor(nsIContent* aContent) override; + + nsIContent* GetDisplayNode() { return mDisplayContent; } + nsIFrame* CreateFrameForDisplayNode(); #ifdef ACCESSIBILITY virtual mozilla::a11y::AccType AccessibleType() override; diff --git a/layout/forms/nsGfxButtonControlFrame.cpp b/layout/forms/nsGfxButtonControlFrame.cpp index 393145e0b..df729c1aa 100644 --- a/layout/forms/nsGfxButtonControlFrame.cpp +++ b/layout/forms/nsGfxButtonControlFrame.cpp @@ -77,30 +77,6 @@ nsGfxButtonControlFrame::AppendAnonymousContentTo(nsTArray<nsIContent*>& aElemen } } -// Create the text content used as label for the button. -// The frame will be generated by the frame constructor. -nsIFrame* -nsGfxButtonControlFrame::CreateFrameFor(nsIContent* aContent) -{ - nsIFrame * newFrame = nullptr; - - if (aContent == mTextContent) { - nsContainerFrame* parentFrame = do_QueryFrame(mFrames.FirstChild()); - - nsPresContext* presContext = PresContext(); - RefPtr<nsStyleContext> textStyleContext; - textStyleContext = presContext->StyleSet()-> - ResolveStyleForText(mTextContent, mStyleContext); - - newFrame = NS_NewTextFrame(presContext->PresShell(), textStyleContext); - // initialize the text frame - newFrame->Init(mTextContent, parentFrame, nullptr); - mTextContent->SetPrimaryFrame(newFrame); - } - - return newFrame; -} - NS_QUERYFRAME_HEAD(nsGfxButtonControlFrame) NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator) NS_QUERYFRAME_TAIL_INHERITING(nsHTMLButtonControlFrame) diff --git a/layout/forms/nsGfxButtonControlFrame.h b/layout/forms/nsGfxButtonControlFrame.h index d91fe3695..07072fdb5 100644 --- a/layout/forms/nsGfxButtonControlFrame.h +++ b/layout/forms/nsGfxButtonControlFrame.h @@ -42,7 +42,6 @@ public: virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) override; virtual void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements, uint32_t aFilter) override; - virtual nsIFrame* CreateFrameFor(nsIContent* aContent) override; virtual nsresult AttributeChanged(int32_t aNameSpaceID, nsIAtom* aAttribute, diff --git a/layout/generic/nsIAnonymousContentCreator.h b/layout/generic/nsIAnonymousContentCreator.h index 844b3a063..2728bb4bb 100644 --- a/layout/generic/nsIAnonymousContentCreator.h +++ b/layout/generic/nsIAnonymousContentCreator.h @@ -72,14 +72,6 @@ public: */ virtual void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements, uint32_t aFilter) = 0; - - /** - * Implementations can override this method to create special frames for the - * anonymous content returned from CreateAnonymousContent. - * By default this method returns nullptr, which means the default frame - * is created. - */ - virtual nsIFrame* CreateFrameFor(nsIContent* aContent) { return nullptr; } }; #endif |