--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -7850,29 +7850,24 @@ nsCSSFrameConstructor::ContentAppended(n
// because processing a single caption can add a whole bunch of things to
// the frame items due to pseudoframe processing. So we'd have to pull
// captions from a list anyway; might as well do that here.
// XXXbz this is no longer true; we could pull captions directly out of the
// FrameConstructionItemList now.
PullOutCaptionFrames(frameItems, captionItems);
}
- bool dealtWithFirstLine = false;
if (haveFirstLineStyle && parentFrame == containingBlock) {
// It's possible that some of the new frames go into a
// first-line frame. Look at them and see...
AppendFirstLineFrames(state, containingBlock->GetContent(),
containingBlock, frameItems);
// That moved things into line frames as needed, reparenting their
// styles. Nothing else needs to be done.
- dealtWithFirstLine = true;
- }
-
- if (!dealtWithFirstLine &&
- parentFrame->StyleContext()->HasPseudoElementData()) {
+ } else if (parentFrame->StyleContext()->HasPseudoElementData()) {
// parentFrame might be inside a ::first-line frame. Check whether it is,
// and if so fix up our styles.
CheckForFirstLineInsertion(parentFrame, frameItems);
CheckForFirstLineInsertion(parentFrame, captionItems);
}
// Notify the parent frame passing it the list of new frames
// Append the flowed frames to the principal child list; captions
@@ -8431,42 +8426,22 @@ nsCSSFrameConstructor::ContentRangeInser
nsIFrame* appendAfterFrame;
insertion.mParentFrame =
::AdjustAppendParentForAfterContent(this, container,
frameItems.FirstChild()->GetParent(),
aStartChild, &appendAfterFrame);
prevSibling = ::FindAppendPrevSibling(insertion.mParentFrame, appendAfterFrame);
}
- bool dealtWithFirstLine = false;
- if (haveFirstLineStyle && insertion.mParentFrame == containingBlock) {
+ if (haveFirstLineStyle && insertion.mParentFrame == containingBlock && isAppend) {
// It's possible that the new frame goes into a first-line
// frame. Look at it and see...
- if (isAppend) {
- // Use append logic when appending
- AppendFirstLineFrames(state, containingBlock->GetContent(),
- containingBlock, frameItems);
- // That moved things into line frames as needed, reparenting their
- // styles. Nothing else needs to be done to handle ::first-line.
- dealtWithFirstLine = true;
- }
- else {
- // Use more complicated insert logic when inserting
- // XXXbz this method is a no-op, so it's easy for the args being passed
- // here to make no sense without anyone noticing... If it ever stops
- // being a no-op, vet them carefully!
- // XXXbz Can this code even get hit? I'd think/hope not, since any
- // insert would go into an existing lineframe if we have them..
- InsertFirstLineFrames(state, container, containingBlock, &insertion.mParentFrame,
- prevSibling, frameItems);
- }
- }
-
- if (!dealtWithFirstLine &&
- insertion.mParentFrame->StyleContext()->HasPseudoElementData()) {
+ AppendFirstLineFrames(state, containingBlock->GetContent(),
+ containingBlock, frameItems);
+ } else if (insertion.mParentFrame->StyleContext()->HasPseudoElementData()) {
CheckForFirstLineInsertion(insertion.mParentFrame, frameItems);
CheckForFirstLineInsertion(insertion.mParentFrame, captionItems);
}
// We might have captions; put them into the caption list of the
// table wrapper frame.
if (captionItems.NotEmpty()) {
NS_ASSERTION(LayoutFrameType::Table == frameType ||
@@ -8541,18 +8516,17 @@ nsCSSFrameConstructor::ContentRangeInser
#ifdef DEBUG
if (gReallyNoisyContentUpdates && insertion.mParentFrame) {
printf("nsCSSFrameConstructor::ContentRangeInserted: resulting frame model:\n");
insertion.mParentFrame->List(stdout, 0);
}
#endif
#ifdef ACCESSIBILITY
- nsAccessibilityService* accService = nsIPresShell::AccService();
- if (accService) {
+ if (nsAccessibilityService* accService = nsIPresShell::AccService()) {
accService->ContentRangeInserted(mPresShell, aContainer,
aStartChild, aEndChild);
}
#endif
}
bool
nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
@@ -11486,159 +11460,16 @@ nsCSSFrameConstructor::AppendFirstLineFr
return;
}
nsFirstLineFrame* lineFrame = static_cast<nsFirstLineFrame*>(lastBlockKid);
WrapFramesInFirstLineFrame(aState, aBlockContent, aBlockFrame,
lineFrame, aFrameItems);
}
-// Special routine to handle inserting a new frame into a block
-// frame's child list. Takes care of placing the new frame into the
-// right place when first-line style is present.
-void
-nsCSSFrameConstructor::InsertFirstLineFrames(
- nsFrameConstructorState& aState,
- nsIContent* aContent,
- nsIFrame* aBlockFrame,
- nsContainerFrame** aParentFrame,
- nsIFrame* aPrevSibling,
- nsFrameItems& aFrameItems)
-{
- // XXXbz If you make this method actually do something, check to
- // make sure that the caller is passing what you expect. In
- // particular, which content is aContent? And audit the rest of
- // this code too; it makes bogus assumptions and may not build.
-#if 0
- nsIFrame* parentFrame = *aParentFrame;
- nsIFrame* newFrame = aFrameItems.childList;
- bool isInline = IsInlineOutside(newFrame);
-
- if (!aPrevSibling) {
- // Insertion will become the first frame. Two cases: we either
- // already have a first-line frame or we don't.
- nsIFrame* firstBlockKid = aBlockFrame->PrincipalChildList().FirstChild();
- if (firstBlockKid->IsLineFrame()) {
- // We already have a first-line frame
- nsIFrame* lineFrame = firstBlockKid;
-
- if (isInline) {
- // Easy case: the new inline frame will go into the lineFrame.
- ReparentFrame(this, lineFrame, newFrame);
- InsertFrames(lineFrame, kPrincipalList, nullptr, newFrame);
-
- // Since the frame is going into the lineFrame, don't let it
- // go into the block too.
- aFrameItems.childList = nullptr;
- aFrameItems.lastChild = nullptr;
- }
- else {
- // Harder case: We are about to insert a block level element
- // before the first-line frame.
- // XXX need a method to steal away frames from the line-frame
- }
- }
- else {
- // We do not have a first-line frame
- if (isInline) {
- // We now need a first-line frame to contain the inline frame.
- nsIFrame* lineFrame = NS_NewFirstLineFrame(firstLineStyle);
-
- if (NS_SUCCEEDED(rv)) {
- // Lookup first-line style context
- nsStyleContext* parentStyle =
- nsFrame::CorrectStyleParentFrame(aBlockFrame,
- nsCSSPseudoElements::firstLine)->
- StyleContext();
- RefPtr<nsStyleContext> firstLineStyle =
- GetFirstLineStyle(aContent, parentStyle);
-
- // Initialize the line frame
- InitAndRestoreFrame(aState, aContent, aBlockFrame, lineFrame);
-
- // Make sure the caller inserts the lineFrame into the
- // blocks list of children.
- aFrameItems.childList = lineFrame;
- aFrameItems.lastChild = lineFrame;
-
- // Give the inline frames to the lineFrame <b>after</b>
- // reparenting them
- NS_ASSERTION(lineFrame->StyleContext() == firstLineStyle,
- "Bogus style context on line frame");
- ReparentFrame(aPresContext, lineFrame, newFrame);
- lineFrame->SetInitialChildList(kPrincipalList, newFrame);
- }
- }
- else {
- // Easy case: the regular insertion logic can insert the new
- // frame because it's a block frame.
- }
- }
- }
- else {
- // Insertion will not be the first frame.
- nsIFrame* prevSiblingParent = aPrevSibling->GetParent();
- if (prevSiblingParent == aBlockFrame) {
- // Easy case: The prev-siblings parent is the block
- // frame. Therefore the prev-sibling is not currently in a
- // line-frame. Therefore the new frame which is going after it,
- // regardless of type, is not going into a line-frame.
- }
- else {
- // If the prevSiblingParent is not the block-frame then it must
- // be a line-frame (if it were a letter-frame, that logic would
- // already have adjusted the prev-sibling to be the
- // letter-frame).
- if (isInline) {
- // Easy case: the insertion can go where the caller thinks it
- // should go (which is into prevSiblingParent).
- }
- else {
- // Block elements don't end up in line-frames, therefore
- // change the insertion point to aBlockFrame. However, there
- // might be more inline elements following aPrevSibling that
- // need to be pulled out of the line-frame and become children
- // of the block.
- nsIFrame* nextSibling = aPrevSibling->GetNextSibling();
- nsIFrame* nextLineFrame = prevSiblingParent->GetNextInFlow();
- if (nextSibling || nextLineFrame) {
- // Oy. We have work to do. Create a list of the new frames
- // that are going into the block by stripping them away from
- // the line-frame(s).
- if (nextSibling) {
- nsLineFrame* lineFrame = (nsLineFrame*) prevSiblingParent;
- nsFrameList tail = lineFrame->StealFramesAfter(aPrevSibling);
- // XXX do something with 'tail'
- }
-
- nsLineFrame* nextLineFrame = (nsLineFrame*) lineFrame;
- for (;;) {
- nextLineFrame = nextLineFrame->GetNextInFlow();
- if (!nextLineFrame) {
- break;
- }
- nsIFrame* kids = nextLineFrame->PrincipalChildList().FirstChild();
- }
- }
- else {
- // We got lucky: aPrevSibling was the last inline frame in
- // the line-frame.
- ReparentFrame(this, aBlockFrame, newFrame);
- InsertFrames(aBlockFrame, kPrincipalList,
- prevSiblingParent, newFrame);
- aFrameItems.childList = nullptr;
- aFrameItems.lastChild = nullptr;
- }
- }
- }
- }
-
-#endif
-}
-
void
nsCSSFrameConstructor::CheckForFirstLineInsertion(nsIFrame* aParentFrame,
nsFrameItems& aFrameItems)
{
MOZ_ASSERT(aParentFrame->StyleContext()->HasPseudoElementData(),
"Why were we called?");
if (aFrameItems.IsEmpty()) {
--- a/layout/base/nsCSSFrameConstructor.h
+++ b/layout/base/nsCSSFrameConstructor.h
@@ -2096,23 +2096,16 @@ private:
// Handle the case when a block with first-line style is appended to (by
// possibly calling WrapFramesInFirstLineFrame as needed).
void AppendFirstLineFrames(nsFrameConstructorState& aState,
nsIContent* aContent,
nsContainerFrame* aBlockFrame,
nsFrameItems& aFrameItems);
- void InsertFirstLineFrames(nsFrameConstructorState& aState,
- nsIContent* aContent,
- nsIFrame* aBlockFrame,
- nsContainerFrame** aParentFrame,
- nsIFrame* aPrevSibling,
- nsFrameItems& aFrameItems);
-
/**
* When aFrameItems is being inserted into aParentFrame, and aParentFrame has
* pseudo-element-affected styles, it's possible that we're inserting under a
* ::first-line frame. In that case, with servo's style system, the styles we
* resolved for aFrameItems are wrong (they don't take ::first-line into
* account), and we should fix them up, which is what this method does.
*
* This method does not mutate aFrameItems.