Bug 501847 part 1. Some preparatory cleanup of GetIBSpecialSiblingForAnonymousBlock. r=roc

This commit is contained in:
Boris Zbarsky 2009-09-18 14:00:20 -04:00
Родитель adf60cf031
Коммит 28b855a104
4 изменённых файлов: 47 добавлений и 89 удалений

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

@ -465,20 +465,19 @@ IsFrameSpecial(nsIFrame* aFrame)
static nsIFrame* GetSpecialSibling(nsIFrame* aFrame)
{
NS_PRECONDITION(IsFrameSpecial(aFrame), "Shouldn't call this");
// We only store the "special sibling" annotation with the first
// frame in the continuation chain. Walk back to find that frame now.
aFrame = aFrame->GetFirstContinuation();
void* value = aFrame->GetProperty(nsGkAtoms::IBSplitSpecialSibling);
return static_cast<nsIFrame*>(value);
return
static_cast<nsIFrame*>
(aFrame->GetFirstContinuation()->
GetProperty(nsGkAtoms::IBSplitSpecialSibling));
}
static nsIFrame*
GetIBSplitSpecialPrevSiblingForAnonymousBlock(nsIFrame* aFrame)
static nsIFrame* GetSpecialPrevSibling(nsIFrame* aFrame)
{
NS_PRECONDITION(IsFrameSpecial(aFrame) && !IsInlineFrame(aFrame),
"Shouldn't call this");
NS_PRECONDITION(IsFrameSpecial(aFrame), "Shouldn't call this");
// We only store the "special sibling" annotation with the first
// frame in the continuation chain. Walk back to find that frame now.
@ -506,19 +505,24 @@ SetFrameIsSpecial(nsIFrame* aFrame, nsIFrame* aSpecialSibling)
{
NS_PRECONDITION(aFrame, "bad args!");
// Mark the frame and all of its siblings as "special".
for (nsIFrame* frame = aFrame; frame != nsnull; frame = frame->GetNextContinuation()) {
frame->AddStateBits(NS_FRAME_IS_SPECIAL);
}
if (aSpecialSibling) {
// We should be the first continuation
// We should be the only continuation
NS_ASSERTION(!aFrame->GetPrevContinuation(),
"assigning special sibling to other than first continuation!");
NS_ASSERTION(!aFrame->GetNextContinuation(),
"should have no continuations here");
// Mark the frame as "special".
aFrame->AddStateBits(NS_FRAME_IS_SPECIAL);
if (aSpecialSibling) {
NS_ASSERTION(!aSpecialSibling->GetPrevContinuation(),
"assigning something other than the first continuation as the "
"special sibling");
// Store the "special sibling" (if we were given one) with the
// first frame in the flow.
aFrame->SetProperty(nsGkAtoms::IBSplitSpecialSibling, aSpecialSibling);
aSpecialSibling->SetProperty(nsGkAtoms::IBSplitSpecialPrevSibling, aFrame);
}
}
@ -596,21 +600,6 @@ FindLastBlock(const nsFrameList& aList)
return last;
}
/*
* The special-prev-sibling is useful for
* finding the "special parent" of a frame (i.e., a frame from which a
* good parent style context can be obtained), one looks at the
* special previous sibling annotation of the real parent of the frame
* (if the real parent has NS_FRAME_IS_SPECIAL).
*/
inline void
MarkIBSpecialPrevSibling(nsIFrame *aAnonymousFrame,
nsIFrame *aSpecialParent)
{
aAnonymousFrame->SetProperty(nsGkAtoms::IBSplitSpecialPrevSibling,
aSpecialParent, nsnull, nsnull);
}
inline void
SetInitialSingleChild(nsIFrame* aParent, nsIFrame* aFrame)
{
@ -10809,8 +10798,6 @@ nsCSSFrameConstructor::ConstructInline(nsFrameConstructorState& aState,
SetFrameIsSpecial(newFrame, blockFrame);
SetFrameIsSpecial(blockFrame, inlineFrame);
SetFrameIsSpecial(inlineFrame, nsnull);
MarkIBSpecialPrevSibling(blockFrame, newFrame);
MarkIBSpecialPrevSibling(inlineFrame, blockFrame);
#ifdef DEBUG
if (gNoisyInlineConstruction) {
@ -11154,8 +11141,8 @@ nsCSSFrameConstructor::WipeContainingBlock(nsFrameConstructorState& aState,
// here is to construct with the right parents to start with.
nsIFrame* floatContainer = aFrame;
do {
floatContainer = GetFloatContainingBlock(
GetIBSplitSpecialPrevSiblingForAnonymousBlock(floatContainer));
floatContainer =
GetFloatContainingBlock(GetSpecialPrevSibling(floatContainer));
if (!floatContainer) {
break;
}

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

@ -270,7 +270,8 @@ protected:
(aFrame->GetProperty(nsGkAtoms::IBSplitSpecialPrevSibling));
if (block) {
// The {ib} properties are only stored on first continuations
block = block->GetFirstContinuation();
NS_ASSERTION(!block->GetPrevContinuation(),
"Incorrect value for IBSplitSpecialPrevSibling");
prevCont =
static_cast<nsIFrame*>
(block->GetProperty(nsGkAtoms::IBSplitSpecialPrevSibling));

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

@ -1101,7 +1101,7 @@ nsFrameManager::ReParentStyleContext(nsIFrame* aFrame)
// reparent the same frame twice because the "if (newContext !=
// oldContext)" check will prevent us from redoing work.
if ((aFrame->GetStateBits() & NS_FRAME_IS_SPECIAL) &&
!aFrame->GetPrevInFlow()) {
!aFrame->GetPrevContinuation()) {
nsIFrame* sib = static_cast<nsIFrame*>(aFrame->GetProperty(nsGkAtoms::IBSplitSpecialSibling));
if (sib) {
ReParentStyleContext(sib);

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

@ -5679,17 +5679,15 @@ nsFrame::GetParentStyleContextFrame(nsPresContext* aPresContext,
/**
* This function takes a "special" frame and _if_ that frame is the
* anonymous block crated by an ib split it returns the split inline
* as aSpecialSibling. This is needed because the split inline's
* style context is the parent of the anonymous block's srtyle context.
* This function takes a "special" frame and _if_ that frame is an anonymous
* block created by an ib split it returns the block's preceding inline. This
* is needed because the split inline's style context is the parent of the
* anonymous block's style context.
*
* If aFrame is not the anonymous block, aSpecialSibling is set to null.
* If aFrame is not ananonymous block, null is returned.
*/
static nsresult
GetIBSpecialSiblingForAnonymousBlock(nsPresContext* aPresContext,
nsIFrame* aFrame,
nsIFrame** aSpecialSibling)
static nsIFrame*
GetIBSpecialSiblingForAnonymousBlock(nsIFrame* aFrame)
{
NS_PRECONDITION(aFrame, "Must have a non-null frame!");
NS_ASSERTION(aFrame->GetStateBits() & NS_FRAME_IS_SPECIAL,
@ -5698,34 +5696,22 @@ GetIBSpecialSiblingForAnonymousBlock(nsPresContext* aPresContext,
nsIAtom* type = aFrame->GetStyleContext()->GetPseudo();
if (type != nsCSSAnonBoxes::mozAnonymousBlock &&
type != nsCSSAnonBoxes::mozAnonymousPositionedBlock) {
// it's not the anonymous block
*aSpecialSibling = nsnull;
return NS_OK;
// it's not an anonymous block
return nsnull;
}
// Find the first-in-flow of the frame. (Ugh. This ends up
// Find the first continuation of the frame. (Ugh. This ends up
// being O(N^2) when it is called O(N) times.)
aFrame = aFrame->GetFirstInFlow();
aFrame = aFrame->GetFirstContinuation();
/*
* Now look up the nsGkAtoms::IBSplitSpecialPrevSibling
* property, which is only set on the anonymous block frames we're
* interested in.
* property.
*/
nsresult rv;
nsIFrame *specialSibling = static_cast<nsIFrame*>
(aPresContext->PropertyTable()->GetProperty(aFrame,
nsGkAtoms::IBSplitSpecialPrevSibling, &rv));
if (NS_PROPTABLE_PROP_NOT_THERE == rv) {
*aSpecialSibling = nsnull;
rv = NS_OK;
} else if (NS_SUCCEEDED(rv)) {
NS_ASSERTION(specialSibling, "null special sibling");
*aSpecialSibling = specialSibling;
}
return rv;
nsIFrame *specialSibling =
static_cast<nsIFrame*>(aFrame->GetProperty(nsGkAtoms::IBSplitSpecialPrevSibling));
NS_ASSERTION(specialSibling, "Broken frame tree?");
return specialSibling;
}
/**
@ -5784,19 +5770,10 @@ nsFrame::CorrectStyleParentFrame(nsIFrame* aProspectiveParent,
nsIFrame* parent = aProspectiveParent;
do {
if (parent->GetStateBits() & NS_FRAME_IS_SPECIAL) {
nsIFrame* sibling;
nsresult rv =
GetIBSpecialSiblingForAnonymousBlock(parent->PresContext(), parent, &sibling);
if (NS_FAILED(rv)) {
// If GetIBSpecialSiblingForAnonymousBlock fails, then what?
// we used to return what is now |aProspectiveParent|, but maybe
// |parent| would make more sense?
NS_NOTREACHED("Shouldn't get here");
return aProspectiveParent;
}
nsIFrame* sibling = GetIBSpecialSiblingForAnonymousBlock(parent);
if (sibling) {
// |parent| was the block in an {ib} split; use the inline as
// |parent| was a block in an {ib} split; use the inline as
// |the style parent.
parent = sibling;
}
@ -5846,19 +5823,12 @@ nsFrame::DoGetParentStyleContextFrame(nsPresContext* aPresContext,
if (!(mState & NS_FRAME_OUT_OF_FLOW)) {
/*
* If this frame is the anonymous block created when an inline
* with a block inside it got split, then the parent style context
* is on the first of the three special frames. We can get to it
* using GetIBSpecialSiblingForAnonymousBlock
* If this frame is an anonymous block created when an inline with a block
* inside it got split, then the parent style context is on its preceding
* inline. We can get to it using GetIBSpecialSiblingForAnonymousBlock.
*/
if (mState & NS_FRAME_IS_SPECIAL) {
nsresult rv =
GetIBSpecialSiblingForAnonymousBlock(aPresContext, this, aProviderFrame);
if (NS_FAILED(rv)) {
NS_NOTREACHED("Shouldn't get here");
*aProviderFrame = nsnull;
return rv;
}
*aProviderFrame = GetIBSpecialSiblingForAnonymousBlock(this);
if (*aProviderFrame) {
return NS_OK;