Bug 99691. nsBoxToBlockAdaptor shouldn't be creating space managers; instead, fix XUL <label> and <description> elements to create area frames. r=dbaron, sr=hyatt

This commit is contained in:
waterson%netscape.com 2002-01-24 22:34:25 +00:00
Родитель 1f3223ece0
Коммит bcccca9bb9
5 изменённых файлов: 84 добавлений и 31 удалений

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

@ -367,7 +367,7 @@ IsFrameSpecial(nsIFrame* aFrame)
return state & NS_FRAME_IS_SPECIAL;
}
static inline void
static void
GetSpecialSibling(nsIFrameManager* aFrameManager, nsIFrame* aFrame, nsIFrame** aResult)
{
// We only store the "special sibling" annotation with the first
@ -5081,12 +5081,16 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
// TEXT CONSTRUCTION
else if (aTag == nsXULAtoms::text || aTag == nsHTMLAtoms::label ||
aTag == nsXULAtoms::description) {
isReplaced = PR_TRUE;
if ((aTag == nsHTMLAtoms::label || aTag == nsXULAtoms::description) &&
(! aContent->HasAttr(kNameSpaceID_None, nsHTMLAtoms::value))) {
return NS_OK;
processChildren = PR_TRUE;
rv = NS_NewAreaFrame(aPresShell, &newFrame,
NS_BLOCK_SPACE_MGR | NS_BLOCK_SHRINK_WRAP | NS_BLOCK_MARGIN_ROOT);
}
else {
isReplaced = PR_TRUE;
rv = NS_NewTextBoxFrame(aPresShell, &newFrame);
}
rv = NS_NewTextBoxFrame(aPresShell, &newFrame);
}
// End of TEXT CONSTRUCTION logic
@ -10404,6 +10408,24 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext,
frameManager->ComputeStyleChangeFor(aPresContext, primaryFrame,
aNameSpaceID, aAttribute,
changeList, aHint, maxHint);
if (IsFrameSpecial(primaryFrame)) {
// Block-in-inline construction, oh no! Compute style
// changes for the IB siblings, too.
// XXXwaterson ComputeStyleChangeFor is broken when
// re-resolving the style for the anonymous block. Don't
// know why yet: deep magic there.
nsIFrame *sibling = primaryFrame;
while (1) {
GetSpecialSibling(frameManager, sibling, &sibling);
if (! sibling)
break;
frameManager->ComputeStyleChangeFor(aPresContext, sibling,
aNameSpaceID, aAttribute,
changeList, aHint, maxHint);
}
}
} else {
#ifdef DEBUG_shaver
fputc('-', stderr);
@ -10456,6 +10478,12 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext,
// let the frame deal with it, since we don't know how to
result = primaryFrame->AttributeChanged(aPresContext, aContent, aNameSpaceID, aAttribute, aModType, maxHint);
// XXXwaterson should probably check for special IB siblings
// here, and propagate the AttributeChanged notification to
// them, as well. Currently, inline and block frames don't
// do anything on this notification, so it's not that big a
// deal.
default:
break;
}

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

@ -367,7 +367,7 @@ IsFrameSpecial(nsIFrame* aFrame)
return state & NS_FRAME_IS_SPECIAL;
}
static inline void
static void
GetSpecialSibling(nsIFrameManager* aFrameManager, nsIFrame* aFrame, nsIFrame** aResult)
{
// We only store the "special sibling" annotation with the first
@ -5081,12 +5081,16 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
// TEXT CONSTRUCTION
else if (aTag == nsXULAtoms::text || aTag == nsHTMLAtoms::label ||
aTag == nsXULAtoms::description) {
isReplaced = PR_TRUE;
if ((aTag == nsHTMLAtoms::label || aTag == nsXULAtoms::description) &&
(! aContent->HasAttr(kNameSpaceID_None, nsHTMLAtoms::value))) {
return NS_OK;
processChildren = PR_TRUE;
rv = NS_NewAreaFrame(aPresShell, &newFrame,
NS_BLOCK_SPACE_MGR | NS_BLOCK_SHRINK_WRAP | NS_BLOCK_MARGIN_ROOT);
}
else {
isReplaced = PR_TRUE;
rv = NS_NewTextBoxFrame(aPresShell, &newFrame);
}
rv = NS_NewTextBoxFrame(aPresShell, &newFrame);
}
// End of TEXT CONSTRUCTION logic
@ -10404,6 +10408,24 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext,
frameManager->ComputeStyleChangeFor(aPresContext, primaryFrame,
aNameSpaceID, aAttribute,
changeList, aHint, maxHint);
if (IsFrameSpecial(primaryFrame)) {
// Block-in-inline construction, oh no! Compute style
// changes for the IB siblings, too.
// XXXwaterson ComputeStyleChangeFor is broken when
// re-resolving the style for the anonymous block. Don't
// know why yet: deep magic there.
nsIFrame *sibling = primaryFrame;
while (1) {
GetSpecialSibling(frameManager, sibling, &sibling);
if (! sibling)
break;
frameManager->ComputeStyleChangeFor(aPresContext, sibling,
aNameSpaceID, aAttribute,
changeList, aHint, maxHint);
}
}
} else {
#ifdef DEBUG_shaver
fputc('-', stderr);
@ -10456,6 +10478,12 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext,
// let the frame deal with it, since we don't know how to
result = primaryFrame->AttributeChanged(aPresContext, aContent, aNameSpaceID, aAttribute, aModType, maxHint);
// XXXwaterson should probably check for special IB siblings
// here, and propagate the AttributeChanged notification to
// them, as well. Currently, inline and block frames don't
// do anything on this notification, so it's not that big a
// deal.
default:
break;
}

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

@ -54,7 +54,6 @@
#include "nsXULAtoms.h"
#include "nsHTMLReflowCommand.h"
#include "nsIContent.h"
#include "nsSpaceManager.h"
#include "nsHTMLParts.h"
#include "nsIViewManager.h"
#include "nsIView.h"
@ -138,7 +137,6 @@ nsAdaptorPrintReason(nsHTMLReflowState& aReflowState)
nsBoxToBlockAdaptor::nsBoxToBlockAdaptor(nsIPresShell* aPresShell, nsIFrame* aFrame):nsBox(aPresShell)
{
mFrame = aFrame;
mSpaceManager = nsnull;
mWasCollapsed = PR_FALSE;
mCachedMaxElementHeight = 0;
mStyleChange = PR_FALSE;
@ -147,6 +145,26 @@ nsBoxToBlockAdaptor::nsBoxToBlockAdaptor(nsIPresShell* aPresShell, nsIFrame* aFr
mIncludeOverflow = PR_TRUE;
mPresShell = aPresShell;
NeedsRecalc();
#ifdef DEBUG
// If we're wrapping a block (we may not be!), be sure the block
// gets a space manager.
static const nsIID kBlockFrameCID = NS_BLOCK_FRAME_CID;
void *block;
mFrame->QueryInterface(kBlockFrameCID, &block);
if (block) {
nsFrameState state;
mFrame->GetFrameState(&state);
NS_ASSERTION(state & NS_BLOCK_SPACE_MGR, "block has no space manager");
}
#ifdef DEBUG_waterson
else {
printf("*** nsBoxToBlockAdaptor: wrapping non-block frame ");
nsFrame::ListTag(stdout, mFrame);
printf("\n");
}
#endif /* DEBUG_waterson */
#endif /* DEBUG */
}
NS_IMETHODIMP
@ -244,7 +262,6 @@ nsBoxToBlockAdaptor::operator delete(void* aPtr, size_t sz)
nsBoxToBlockAdaptor::~nsBoxToBlockAdaptor()
{
delete mSpaceManager;
}
@ -680,20 +697,6 @@ nsBoxToBlockAdaptor::Reflow(nsBoxLayoutState& aState,
// printf("In debug\n");
*/
if (!mSpaceManager) {
nsCOMPtr<nsIPresShell> shell;
aPresContext->GetShell(getter_AddRefs(shell));
mSpaceManager = new nsSpaceManager(shell, mFrame);
}
// Modify the reflow state and set the space manager
nsHTMLReflowState& nonConstState = (nsHTMLReflowState&)aReflowState;
nonConstState.mSpaceManager = mSpaceManager;
// Clear the spacemanager's regions.
mSpaceManager->ClearRegions();
aStatus = NS_FRAME_COMPLETE;
PRBool redrawAfterReflow = PR_FALSE;

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

@ -40,7 +40,6 @@
#include "nsIBoxToBlockAdaptor.h"
#include "nsBox.h"
class nsSpaceManager;
class nsBoxToBlockAdaptor : public nsBox, public nsIBoxToBlockAdaptor {
@ -116,7 +115,6 @@ private:
nscoord mAscent;
nscoord mCachedMaxElementHeight;
nsSpaceManager* mSpaceManager;
nsSize mLastSize;
nsSize mOverflow;
nsIPresShell* mPresShell;

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

@ -599,10 +599,6 @@ spacer {
display: inline;
}
label, description {
display: block;
}
description {
-moz-binding: url("chrome://global/content/bindings/text.xml#text-base");
}