Changed wrapping of floated elements so the wrapping happens inside of

ConstructFrameByDisplayType(), and now we only wrap frames of display
type 'block' and 'inline'
This commit is contained in:
troy%netscape.com 1998-12-07 18:44:40 +00:00
Родитель cd4bfa41a8
Коммит 78a4ce96ec
3 изменённых файлов: 105 добавлений и 21 удалений

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

@ -1649,12 +1649,34 @@ HTMLStyleSheetImpl::ConstructFrameByDisplayType(nsIPresContext* aPresConte
nsIStyleContext* aStyleContext,
nsIFrame*& aNewFrame)
{
PRBool processChildren = PR_FALSE; // whether we should process child content
nsresult rv = NS_OK;
PRBool processChildren = PR_FALSE; // whether we should process child content
nsIFrame* wrapperFrame = nsnull;
nsresult rv = NS_OK;
// Initialize OUT parameter
aNewFrame = nsnull;
// If the element is floated and it's a block or inline, then we need to
// wrap it in a BODY frame
if (((NS_STYLE_DISPLAY_BLOCK == aDisplay->mDisplay) ||
(NS_STYLE_DISPLAY_INLINE == aDisplay->mDisplay)) &&
(NS_STYLE_FLOAT_NONE != aDisplay->mFloats)) {
// The body wrapper frame gets the original style context
NS_NewBodyFrame(wrapperFrame, NS_BODY_SHRINK_WRAP);
wrapperFrame->Init(*aPresContext, aContent, aParentFrame, aStyleContext);
nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, wrapperFrame,
aStyleContext, PR_FALSE);
// The wrapped frame gets a pseudo style context that inherits the
// display property
nsIStyleContext* wrappedPseudoStyle;
wrappedPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(aContent,
nsHTMLAtoms::wrappedFramePseudo, aStyleContext);
aParentFrame = wrapperFrame;
aStyleContext = wrappedPseudoStyle;
}
switch (aDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
@ -1757,6 +1779,13 @@ HTMLStyleSheetImpl::ConstructFrameByDisplayType(nsIPresContext* aPresConte
aNewFrame->SetInitialChildList(*aPresContext, nsnull, childList);
}
// If there's a wrapper frame then set its initial child list, and return the
// wrapper frame as the new frame
if (nsnull != wrapperFrame) {
wrapperFrame->SetInitialChildList(*aPresContext, nsnull, aNewFrame);
aNewFrame = wrapperFrame;
}
return rv;
}
@ -1981,15 +2010,14 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
}
}
// See if the element is floated or absolutely positioned
// See if the element is absolutely positioned
const nsStylePosition* position = (const nsStylePosition*)
styleContext->GetStyleData(eStyleStruct_Position);
if ((NS_STYLE_FLOAT_NONE != display->mFloats) ||
(NS_STYLE_POSITION_ABSOLUTE == position->mPosition)) {
if (NS_STYLE_POSITION_ABSOLUTE == position->mPosition) {
// If it can contain children then wrap it in a BODY frame.
// XxX Don't wrap tables...
// XxX Don't wrap tables, because that causes all sort of problems.
// We need to figure out how to wrap tables...
PRBool isContainer;
aContent->CanContainChildren(isContainer);

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

@ -1649,12 +1649,34 @@ HTMLStyleSheetImpl::ConstructFrameByDisplayType(nsIPresContext* aPresConte
nsIStyleContext* aStyleContext,
nsIFrame*& aNewFrame)
{
PRBool processChildren = PR_FALSE; // whether we should process child content
nsresult rv = NS_OK;
PRBool processChildren = PR_FALSE; // whether we should process child content
nsIFrame* wrapperFrame = nsnull;
nsresult rv = NS_OK;
// Initialize OUT parameter
aNewFrame = nsnull;
// If the element is floated and it's a block or inline, then we need to
// wrap it in a BODY frame
if (((NS_STYLE_DISPLAY_BLOCK == aDisplay->mDisplay) ||
(NS_STYLE_DISPLAY_INLINE == aDisplay->mDisplay)) &&
(NS_STYLE_FLOAT_NONE != aDisplay->mFloats)) {
// The body wrapper frame gets the original style context
NS_NewBodyFrame(wrapperFrame, NS_BODY_SHRINK_WRAP);
wrapperFrame->Init(*aPresContext, aContent, aParentFrame, aStyleContext);
nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, wrapperFrame,
aStyleContext, PR_FALSE);
// The wrapped frame gets a pseudo style context that inherits the
// display property
nsIStyleContext* wrappedPseudoStyle;
wrappedPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(aContent,
nsHTMLAtoms::wrappedFramePseudo, aStyleContext);
aParentFrame = wrapperFrame;
aStyleContext = wrappedPseudoStyle;
}
switch (aDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
@ -1757,6 +1779,13 @@ HTMLStyleSheetImpl::ConstructFrameByDisplayType(nsIPresContext* aPresConte
aNewFrame->SetInitialChildList(*aPresContext, nsnull, childList);
}
// If there's a wrapper frame then set its initial child list, and return the
// wrapper frame as the new frame
if (nsnull != wrapperFrame) {
wrapperFrame->SetInitialChildList(*aPresContext, nsnull, aNewFrame);
aNewFrame = wrapperFrame;
}
return rv;
}
@ -1981,15 +2010,14 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
}
}
// See if the element is floated or absolutely positioned
// See if the element is absolutely positioned
const nsStylePosition* position = (const nsStylePosition*)
styleContext->GetStyleData(eStyleStruct_Position);
if ((NS_STYLE_FLOAT_NONE != display->mFloats) ||
(NS_STYLE_POSITION_ABSOLUTE == position->mPosition)) {
if (NS_STYLE_POSITION_ABSOLUTE == position->mPosition) {
// If it can contain children then wrap it in a BODY frame.
// XxX Don't wrap tables...
// XxX Don't wrap tables, because that causes all sort of problems.
// We need to figure out how to wrap tables...
PRBool isContainer;
aContent->CanContainChildren(isContainer);

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

@ -1649,12 +1649,34 @@ HTMLStyleSheetImpl::ConstructFrameByDisplayType(nsIPresContext* aPresConte
nsIStyleContext* aStyleContext,
nsIFrame*& aNewFrame)
{
PRBool processChildren = PR_FALSE; // whether we should process child content
nsresult rv = NS_OK;
PRBool processChildren = PR_FALSE; // whether we should process child content
nsIFrame* wrapperFrame = nsnull;
nsresult rv = NS_OK;
// Initialize OUT parameter
aNewFrame = nsnull;
// If the element is floated and it's a block or inline, then we need to
// wrap it in a BODY frame
if (((NS_STYLE_DISPLAY_BLOCK == aDisplay->mDisplay) ||
(NS_STYLE_DISPLAY_INLINE == aDisplay->mDisplay)) &&
(NS_STYLE_FLOAT_NONE != aDisplay->mFloats)) {
// The body wrapper frame gets the original style context
NS_NewBodyFrame(wrapperFrame, NS_BODY_SHRINK_WRAP);
wrapperFrame->Init(*aPresContext, aContent, aParentFrame, aStyleContext);
nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, wrapperFrame,
aStyleContext, PR_FALSE);
// The wrapped frame gets a pseudo style context that inherits the
// display property
nsIStyleContext* wrappedPseudoStyle;
wrappedPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(aContent,
nsHTMLAtoms::wrappedFramePseudo, aStyleContext);
aParentFrame = wrapperFrame;
aStyleContext = wrappedPseudoStyle;
}
switch (aDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
@ -1757,6 +1779,13 @@ HTMLStyleSheetImpl::ConstructFrameByDisplayType(nsIPresContext* aPresConte
aNewFrame->SetInitialChildList(*aPresContext, nsnull, childList);
}
// If there's a wrapper frame then set its initial child list, and return the
// wrapper frame as the new frame
if (nsnull != wrapperFrame) {
wrapperFrame->SetInitialChildList(*aPresContext, nsnull, aNewFrame);
aNewFrame = wrapperFrame;
}
return rv;
}
@ -1981,15 +2010,14 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
}
}
// See if the element is floated or absolutely positioned
// See if the element is absolutely positioned
const nsStylePosition* position = (const nsStylePosition*)
styleContext->GetStyleData(eStyleStruct_Position);
if ((NS_STYLE_FLOAT_NONE != display->mFloats) ||
(NS_STYLE_POSITION_ABSOLUTE == position->mPosition)) {
if (NS_STYLE_POSITION_ABSOLUTE == position->mPosition) {
// If it can contain children then wrap it in a BODY frame.
// XxX Don't wrap tables...
// XxX Don't wrap tables, because that causes all sort of problems.
// We need to figure out how to wrap tables...
PRBool isContainer;
aContent->CanContainChildren(isContainer);