Bug 1334358 - Stop using CreateAnonymousFrames for combo box creation. r=bz

This commit is contained in:
Bobby Holley 2017-01-26 17:47:52 -08:00
Родитель 39d50c2647
Коммит fd04f8fa75
4 изменённых файлов: 38 добавлений и 34 удалений

Просмотреть файл

@ -3079,7 +3079,7 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsFrameConstructorState& aState,
// The drop-down list's frame is created explicitly. The combobox frame shares its content
// with the drop-down list.
nsFrameState flags = NS_BLOCK_FLOAT_MGR;
nsContainerFrame* comboboxFrame =
nsComboboxControlFrame* comboboxFrame =
NS_NewComboboxControlFrame(mPresShell, styleContext, flags);
// Save the history state so we don't restore during construction
@ -3094,10 +3094,6 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsFrameConstructorState& aState,
aState.AddChild(comboboxFrame, aFrameItems, content, styleContext,
aParentFrame);
nsIComboboxControlFrame* comboBox = do_QueryFrame(comboboxFrame);
NS_ASSERTION(comboBox, "NS_NewComboboxControlFrame returned frame that "
"doesn't implement nsIComboboxControlFrame");
// Resolve pseudo element style for the dropdown list
RefPtr<nsStyleContext> listStyle;
listStyle = mPresShell->StyleSet()->
@ -3112,7 +3108,7 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsFrameConstructorState& aState,
listControlFrame->SetComboboxFrame(comboboxFrame);
}
// Notify combobox that it should use the listbox as it's popup
comboBox->SetDropDown(listFrame);
comboboxFrame->SetDropDown(listFrame);
NS_ASSERTION(!listFrame->IsAbsPosContainingBlock(),
"Ended up with positioned dropdown list somehow.");
@ -3133,10 +3129,29 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsFrameConstructorState& aState,
// Create display and button frames from the combobox's anonymous content.
// The anonymous content is appended to existing anonymous content for this
// element (the scrollbars).
nsFrameItems childItems;
CreateAnonymousFrames(aState, content, comboboxFrame,
aItem.mPendingBinding, childItems);
// nsComboboxControlFrame needs special frame creation behavior for its first
// piece of anonymous content, which means that we can't take the normal
// ProcessChildren path.
AutoTArray<nsIAnonymousContentCreator::ContentInfo, 2> newAnonymousItems;
DebugOnly<nsresult> rv = GetAnonymousContent(content, comboboxFrame, newAnonymousItems);
MOZ_ASSERT(NS_SUCCEEDED(rv));
MOZ_ASSERT(newAnonymousItems.Length() == 2);
// Manually create a frame for the special NAC.
MOZ_ASSERT(newAnonymousItems[0].mContent == comboboxFrame->GetDisplayNode());
newAnonymousItems.RemoveElementAt(0);
nsIFrame* customFrame = comboboxFrame->CreateFrameForDisplayNode();
MOZ_ASSERT(customFrame);
customFrame->AddStateBits(NS_FRAME_ANONYMOUSCONTENTCREATOR_CONTENT);
childItems.AddChild(customFrame);
// The other piece of NAC can take the normal path.
FrameConstructionItemList fcItems;
AddFCItemsForAnonymousContent(aState, comboboxFrame, newAnonymousItems,
fcItems);
ConstructFramesFromItemList(aState, fcItems, comboboxFrame, childItems);
comboboxFrame->SetInitialChildList(kPrincipalList, childItems);
@ -4125,7 +4140,6 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsFrameConstructorState& aState,
ancestorPusher.PushStyleScope(aParent->AsElement());
}
nsComboboxControlFrame* comboboxFrame = do_QueryFrame(aParentFrame);
InsertionPoint insertion(aParentFrame, aParent);
for (uint32_t i=0; i < count; i++) {
nsIContent* content = newAnonymousItems[i].mContent;
@ -4136,27 +4150,16 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsFrameConstructorState& aState,
"nsIAnonymousContentCreator::CreateAnonymousContent to "
"output a list where the items have their own children");
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;
{
// Skip parent display based style-fixup during our
// AddFrameConstructionItems() call:
TreeMatchContext::AutoParentDisplayBasedStyleFixupSkipper
parentDisplayBasedStyleFixupSkipper(aState.mTreeMatchContext);
FrameConstructionItemList items;
{
// Skip parent display based style-fixup during our
// AddFrameConstructionItems() call:
TreeMatchContext::AutoParentDisplayBasedStyleFixupSkipper
parentDisplayBasedStyleFixupSkipper(aState.mTreeMatchContext);
AddFrameConstructionItems(aState, content, true, insertion, items);
}
ConstructFramesFromItemList(aState, items, aParentFrame, aChildItems);
AddFrameConstructionItems(aState, content, true, insertion, items);
}
ConstructFramesFromItemList(aState, items, aParentFrame, aChildItems);
}
return NS_OK;

Просмотреть файл

@ -115,7 +115,7 @@ NS_IMPL_ISUPPORTS(nsComboButtonListener,
// static class data member for Bug 32920
nsComboboxControlFrame* nsComboboxControlFrame::sFocused = nullptr;
nsContainerFrame*
nsComboboxControlFrame*
NS_NewComboboxControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, nsFrameState aStateFlags)
{
nsComboboxControlFrame* it = new (aPresShell) nsComboboxControlFrame(aContext);

Просмотреть файл

@ -55,9 +55,9 @@ class nsComboboxControlFrame final : public nsBlockFrame,
public:
NS_DECL_QUERYFRAME_TARGET(nsComboboxControlFrame)
friend nsContainerFrame* NS_NewComboboxControlFrame(nsIPresShell* aPresShell,
nsStyleContext* aContext,
nsFrameState aFlags);
friend nsComboboxControlFrame* NS_NewComboboxControlFrame(nsIPresShell* aPresShell,
nsStyleContext* aContext,
nsFrameState aFlags);
friend class nsComboboxDisplayFrame;
explicit nsComboboxControlFrame(nsStyleContext* aContext);

Просмотреть файл

@ -11,6 +11,7 @@
#include "nscore.h"
#include "nsISupports.h"
#include "nsIFrame.h"
class nsComboboxControlFrame;
class nsIAtom;
class nsNodeInfoManager;
class nsIContent;
@ -162,7 +163,7 @@ nsIFrame*
NS_NewNativeSelectControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsContainerFrame*
NS_NewListControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsContainerFrame*
nsComboboxControlFrame*
NS_NewComboboxControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, nsFrameState aFlags);
nsIFrame*
NS_NewProgressFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);