mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Bug 1486602 Part 3 - Create bullet frame for block frames in nsCSSFrameConstructor::ConstructBlock() instead of in their SetInitialSingleChild() r=mats
nsCSSFrameConstructor::FindDisplayData() guarantees a block with "display: list-item" will be constructed by ConstructBlock() (either through ConstructScrollableBlock() or ConstructNonScrollableBlock()). This is also a preparation to fix bug 1491915 since we want to control bullet frame creation under column hierarchy. Depends on D6840 Differential Revision: https://phabricator.services.mozilla.com/D6841 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
f088ec9229
commit
fb26f86deb
@ -10968,9 +10968,9 @@ nsCSSFrameConstructor::ConstructBlock(nsFrameConstructorState& aState,
|
||||
PendingBinding* aPendingBinding)
|
||||
{
|
||||
// Create column wrapper if necessary
|
||||
nsContainerFrame* blockFrame = *aNewFrame;
|
||||
NS_ASSERTION((blockFrame->IsBlockFrame() || blockFrame->IsDetailsFrame()),
|
||||
"not a block frame nor a details frame?");
|
||||
nsBlockFrame* blockFrame = do_QueryFrame(*aNewFrame);
|
||||
MOZ_ASSERT(blockFrame->IsBlockFrame() || blockFrame->IsDetailsFrame(),
|
||||
"not a block frame nor a details frame?");
|
||||
|
||||
*aNewFrame =
|
||||
InitAndWrapInColumnSetFrameIfNeeded(aState, aContent, aParentFrame,
|
||||
@ -11013,6 +11013,36 @@ nsCSSFrameConstructor::ConstructBlock(nsFrameConstructorState& aState,
|
||||
|
||||
// Set the frame's initial child list
|
||||
blockFrame->SetInitialChildList(kPrincipalList, childItems);
|
||||
CreateBulletFrameForListItemIfNeeded(blockFrame);
|
||||
}
|
||||
|
||||
void
|
||||
nsCSSFrameConstructor::CreateBulletFrameForListItemIfNeeded(
|
||||
nsBlockFrame* aBlockFrame)
|
||||
{
|
||||
// Create a list bullet if this is a list-item. Note that this is
|
||||
// done here so that RenumberList will work (it needs the bullets
|
||||
// to store the bullet numbers). Also note that due to various
|
||||
// wrapper frames (scrollframes, columns) we want to use the
|
||||
// outermost (primary, ideally, but it's not set yet when we get
|
||||
// here) frame of our content for the display check. On the other
|
||||
// hand, we look at ourselves for the GetPrevInFlow() check, since
|
||||
// for a columnset we don't want a bullet per column. Note that
|
||||
// the outermost frame for the content is the primary frame in
|
||||
// most cases; the ones when it's not (like tables) can't be
|
||||
// StyleDisplay::ListItem).
|
||||
nsIFrame* possibleListItem = aBlockFrame;
|
||||
while (true) {
|
||||
nsIFrame* parent = possibleListItem->GetParent();
|
||||
if (parent->GetContent() != aBlockFrame->GetContent()) {
|
||||
break;
|
||||
}
|
||||
possibleListItem = parent;
|
||||
}
|
||||
|
||||
if (possibleListItem->StyleDisplay()->mDisplay == StyleDisplay::ListItem) {
|
||||
aBlockFrame->CreateBulletFrameForListItem();
|
||||
}
|
||||
}
|
||||
|
||||
nsIFrame*
|
||||
|
@ -1871,6 +1871,8 @@ private:
|
||||
nsIFrame* aPositionedFrameForAbsPosContainer,
|
||||
PendingBinding* aPendingBinding);
|
||||
|
||||
void CreateBulletFrameForListItemIfNeeded(nsBlockFrame* aBlockFrame);
|
||||
|
||||
nsIFrame* ConstructInline(nsFrameConstructorState& aState,
|
||||
FrameConstructionItem& aItem,
|
||||
nsContainerFrame* aParentFrame,
|
||||
|
@ -7111,10 +7111,6 @@ nsBlockFrame::SetInitialChildList(ChildListID aListID,
|
||||
if (kFloatList == aListID) {
|
||||
mFloats.SetFrames(aChildList);
|
||||
} else if (kPrincipalList == aListID) {
|
||||
NS_ASSERTION((GetStateBits() & (NS_BLOCK_FRAME_HAS_INSIDE_BULLET |
|
||||
NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET)) == 0,
|
||||
"how can we have a bullet already?");
|
||||
|
||||
#ifdef DEBUG
|
||||
// The only times a block that is an anonymous box is allowed to have a
|
||||
// first-letter frame are when it's the block inside a non-anonymous cell,
|
||||
@ -7143,31 +7139,6 @@ nsBlockFrame::SetInitialChildList(ChildListID aListID,
|
||||
#endif
|
||||
|
||||
AddFrames(aChildList, nullptr);
|
||||
|
||||
// Create a list bullet if this is a list-item. Note that this is
|
||||
// done here so that RenumberList will work (it needs the bullets
|
||||
// to store the bullet numbers). Also note that due to various
|
||||
// wrapper frames (scrollframes, columns) we want to use the
|
||||
// outermost (primary, ideally, but it's not set yet when we get
|
||||
// here) frame of our content for the display check. On the other
|
||||
// hand, we look at ourselves for the GetPrevInFlow() check, since
|
||||
// for a columnset we don't want a bullet per column. Note that
|
||||
// the outermost frame for the content is the primary frame in
|
||||
// most cases; the ones when it's not (like tables) can't be
|
||||
// StyleDisplay::ListItem).
|
||||
nsIFrame* possibleListItem = this;
|
||||
while (1) {
|
||||
nsIFrame* parent = possibleListItem->GetParent();
|
||||
if (parent->GetContent() != GetContent()) {
|
||||
break;
|
||||
}
|
||||
possibleListItem = parent;
|
||||
}
|
||||
if (mozilla::StyleDisplay::ListItem ==
|
||||
possibleListItem->StyleDisplay()->mDisplay &&
|
||||
!GetPrevInFlow()) {
|
||||
CreateBulletFrameForListItem();
|
||||
}
|
||||
} else {
|
||||
nsContainerFrame::SetInitialChildList(aListID, aChildList);
|
||||
}
|
||||
@ -7176,6 +7147,10 @@ nsBlockFrame::SetInitialChildList(ChildListID aListID,
|
||||
void
|
||||
nsBlockFrame::CreateBulletFrameForListItem()
|
||||
{
|
||||
MOZ_ASSERT((GetStateBits() & (NS_BLOCK_FRAME_HAS_INSIDE_BULLET |
|
||||
NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET)) == 0,
|
||||
"How can we have a bullet already?");
|
||||
|
||||
nsIPresShell* shell = PresShell();
|
||||
const nsStyleList* styleList = StyleList();
|
||||
|
||||
|
@ -509,12 +509,12 @@ protected:
|
||||
*/
|
||||
bool IsVisualFormControl(nsPresContext* aPresContext);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Helper function to create bullet frame.
|
||||
*/
|
||||
void CreateBulletFrameForListItem();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Does all the real work for removing aDeletedFrame
|
||||
* -- finds the line containing aDeletedFrame
|
||||
|
Loading…
Reference in New Issue
Block a user