Added GetFrameType() and renamed GetAnchoredItem() to GetOutOfFrameFlow()

This commit is contained in:
troy%netscape.com 1999-04-23 14:34:48 +00:00
Родитель 8b67ee696e
Коммит faca172c4e
14 изменённых файлов: 218 добавлений и 114 удалений

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

@ -1734,8 +1734,13 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresContext* aPresContext,
NS_NewAreaFrame(areaFrame, NS_BLOCK_DOCUMENT_ROOT|NS_BLOCK_MARGIN_ROOT);
areaFrame->Init(*aPresContext, aDocElement, scrollFrame ? scrollFrame :
aParentFrame, styleContext, nsnull);
if (scrollFrame) {
// If the document element is scrollable, then it needs a view. Otherwise,
// don't bother, because the root frame has a view and the extra view is
// just overhead we don't need
nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, areaFrame,
styleContext, PR_FALSE);
}
// The area frame is the "initial containing block"
mInitialContainingBlock = areaFrame;
@ -1748,6 +1753,36 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresContext* aPresContext,
ProcessChildren(aPresContext, aDocElement, areaFrame, absoluteItems,
childItems, aFixedItems, floatingItems, PR_TRUE);
// See if the document element has a fixed background attachment.
// Note: the reason we wait until after processing the document element's
// children is because of special treatment of the background for the HTML
// element. See BodyFixupRule::MapStyleInto() for details
const nsStyleColor* color;
color = (const nsStyleColor*)styleContext->GetStyleData(eStyleStruct_Color);
if (NS_STYLE_BG_ATTACHMENT_FIXED == color->mBackgroundAttachment) {
// Fixed background attachments are handled by setting the
// NS_VIEW_PUBLIC_FLAG_DONT_BITBLT flag bit on the view.
//
// If the document element's frame is scrollable, then set the bit on its
// view; otherwise, set it on the root frame's view. This avoids
// unnecessarily creating another view and should be faster
nsIView* view;
if (scrollFrame) {
areaFrame->GetView(&view);
} else {
nsIFrame* parentFrame;
areaFrame->GetParent(&parentFrame);
parentFrame->GetView(&view);
}
NS_ASSERTION(view, "expected a view");
PRUint32 viewFlags;
view->GetViewFlags(&viewFlags);
view->SetViewFlags(viewFlags | NS_VIEW_PUBLIC_FLAG_DONT_BITBLT);
}
// Set the initial child lists
areaFrame->SetInitialChildList(*aPresContext, nsnull,
childItems.childList);
@ -2017,7 +2052,7 @@ nsCSSFrameConstructor::CreateFloaterPlaceholderFrameFor(nsIPresContext* aPresCo
aPresContext->GetShell(getter_AddRefs(presShell));
presShell->SetPlaceholderFrameFor(aFrame, placeholder);
placeholder->SetAnchoredItem(aFrame);
placeholder->SetOutOfFlowFrame(aFrame);
*aPlaceholderFrame = NS_STATIC_CAST(nsIFrame*, placeholder);
}
@ -4876,7 +4911,7 @@ nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresContext* aPresContext,
nsPlaceholderFrame* floaterPlaceholderFrame;
floaterPlaceholderFrame = (nsPlaceholderFrame*)placeholderFrame;
floaterPlaceholderFrame->SetAnchoredItem(newFrame);
floaterPlaceholderFrame->SetOutOfFlowFrame(newFrame);
}
}
parentFrame->InsertFrames(*aPresContext, *presShell, listName, prevSibling, newFrame);

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

@ -1623,7 +1623,7 @@ nsBlockFrame::FindLineFor(nsIFrame* aFrame,
PRInt32 i, n = a.Count();
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) a[i];
if (aFrame == ph->GetAnchoredItem()) {
if (aFrame == ph->GetOutOfFlowFrame()) {
isFloater = PR_TRUE;
goto done;
}
@ -2138,7 +2138,7 @@ nsBlockFrame::SlideFloaters(nsIPresContext* aPresContext,
PRInt32 i, n = floaters->Count();
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) floaters->ElementAt(i);
nsIFrame* floater = ph->GetAnchoredItem();
nsIFrame* floater = ph->GetOutOfFlowFrame();
floater->GetRect(r);
r.y += aDY;
floater->SetRect(r);
@ -2162,7 +2162,7 @@ ListTag(stdout); printf(": MoveInSpaceManager: d=%d,%d\n", aDeltaX, aDeltaY);
PRInt32 i, n = floaters->Count();
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) floaters->ElementAt(i);
nsIFrame* floater = ph->GetAnchoredItem();
nsIFrame* floater = ph->GetOutOfFlowFrame();
aSpaceManager->OffsetRegion(floater, aDeltaX, aDeltaY);
#if 0
((nsFrame*)kid)->ListTag(stdout); printf(": offset=%d,%d\n", aDeltaX, aDeltaY);
@ -3912,11 +3912,11 @@ nsBlockFrame::RemoveFrame(nsIPresContext& aPresContext,
PRInt32 i, count = floaters->Count();
for (i = 0; i < count; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*)floaters->ElementAt(i);
if (ph->GetAnchoredItem() == aOldFrame) {
if (ph->GetOutOfFlowFrame() == aOldFrame) {
// Note: the placeholder is part of the line's child list
// and will be removed later.
// XXX stop storing pointers to the placeholder in the line list???
ph->SetAnchoredItem(nsnull);
ph->SetOutOfFlowFrame(nsnull);
floaters->RemoveElementAt(i);
aOldFrame->DeleteFrame(aPresContext);
goto found_it;
@ -4296,7 +4296,7 @@ nsBlockFrame::ReflowFloater(nsBlockReflowState& aState,
// unbounded height. Floaters with an auto width are sized to zero
// according to the css2 spec.
nsRect availSpace(0, 0, aState.mAvailSpaceRect.width, NS_UNCONSTRAINEDSIZE);
nsIFrame* floater = aPlaceholder->GetAnchoredItem();
nsIFrame* floater = aPlaceholder->GetOutOfFlowFrame();
PRBool isAdjacentWithTop = aState.IsAdjacentWithTop();
// Setup block reflow state to reflow the floater
@ -4333,7 +4333,7 @@ void
nsBlockReflowState::InitFloater(nsPlaceholderFrame* aPlaceholder)
{
// Set the geometric parent of the floater
nsIFrame* floater = aPlaceholder->GetAnchoredItem();
nsIFrame* floater = aPlaceholder->GetOutOfFlowFrame();
floater->SetParent(mBlock);
// Then add the floater to the current line and place it when
@ -4553,7 +4553,7 @@ nsBlockReflowState::PlaceFloater(nsPlaceholderFrame* aPlaceholder,
// placement are for the floater only, not for any non-floating
// content.
nscoord saveY = mY;
nsIFrame* floater = aPlaceholder->GetAnchoredItem();
nsIFrame* floater = aPlaceholder->GetOutOfFlowFrame();
// Get the type of floater
const nsStyleDisplay* floaterDisplay;
@ -4869,11 +4869,11 @@ nsBlockFrame::PaintFloaters(nsIPresContext& aPresContext,
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) floaters->ElementAt(i);
PaintChild(aPresContext, aRenderingContext, aDirtyRect,
ph->GetAnchoredItem(), NS_FRAME_PAINT_LAYER_BACKGROUND);
ph->GetOutOfFlowFrame(), NS_FRAME_PAINT_LAYER_BACKGROUND);
PaintChild(aPresContext, aRenderingContext, aDirtyRect,
ph->GetAnchoredItem(), NS_FRAME_PAINT_LAYER_FLOATERS);
ph->GetOutOfFlowFrame(), NS_FRAME_PAINT_LAYER_FLOATERS);
PaintChild(aPresContext, aRenderingContext, aDirtyRect,
ph->GetAnchoredItem(), NS_FRAME_PAINT_LAYER_FOREGROUND);
ph->GetOutOfFlowFrame(), NS_FRAME_PAINT_LAYER_FOREGROUND);
}
}
}
@ -5235,7 +5235,7 @@ nsBlockFrame::BuildFloaterList()
PRInt32 i, n = array.Count();
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) array[i];
nsIFrame* floater = ph->GetAnchoredItem();
nsIFrame* floater = ph->GetOutOfFlowFrame();
if (nsnull == head) {
current = head = floater;
}
@ -5414,7 +5414,7 @@ nsAnonymousBlockFrame::RemoveFirstFrame()
}
// Remove the floater from the block frames mFloaters list too
mFloaters.RemoveFrame(placeholderFrame->GetAnchoredItem());
mFloaters.RemoveFrame(placeholderFrame->GetOutOfFlowFrame());
break;
}
}

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

@ -1623,7 +1623,7 @@ nsBlockFrame::FindLineFor(nsIFrame* aFrame,
PRInt32 i, n = a.Count();
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) a[i];
if (aFrame == ph->GetAnchoredItem()) {
if (aFrame == ph->GetOutOfFlowFrame()) {
isFloater = PR_TRUE;
goto done;
}
@ -2138,7 +2138,7 @@ nsBlockFrame::SlideFloaters(nsIPresContext* aPresContext,
PRInt32 i, n = floaters->Count();
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) floaters->ElementAt(i);
nsIFrame* floater = ph->GetAnchoredItem();
nsIFrame* floater = ph->GetOutOfFlowFrame();
floater->GetRect(r);
r.y += aDY;
floater->SetRect(r);
@ -2162,7 +2162,7 @@ ListTag(stdout); printf(": MoveInSpaceManager: d=%d,%d\n", aDeltaX, aDeltaY);
PRInt32 i, n = floaters->Count();
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) floaters->ElementAt(i);
nsIFrame* floater = ph->GetAnchoredItem();
nsIFrame* floater = ph->GetOutOfFlowFrame();
aSpaceManager->OffsetRegion(floater, aDeltaX, aDeltaY);
#if 0
((nsFrame*)kid)->ListTag(stdout); printf(": offset=%d,%d\n", aDeltaX, aDeltaY);
@ -3912,11 +3912,11 @@ nsBlockFrame::RemoveFrame(nsIPresContext& aPresContext,
PRInt32 i, count = floaters->Count();
for (i = 0; i < count; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*)floaters->ElementAt(i);
if (ph->GetAnchoredItem() == aOldFrame) {
if (ph->GetOutOfFlowFrame() == aOldFrame) {
// Note: the placeholder is part of the line's child list
// and will be removed later.
// XXX stop storing pointers to the placeholder in the line list???
ph->SetAnchoredItem(nsnull);
ph->SetOutOfFlowFrame(nsnull);
floaters->RemoveElementAt(i);
aOldFrame->DeleteFrame(aPresContext);
goto found_it;
@ -4296,7 +4296,7 @@ nsBlockFrame::ReflowFloater(nsBlockReflowState& aState,
// unbounded height. Floaters with an auto width are sized to zero
// according to the css2 spec.
nsRect availSpace(0, 0, aState.mAvailSpaceRect.width, NS_UNCONSTRAINEDSIZE);
nsIFrame* floater = aPlaceholder->GetAnchoredItem();
nsIFrame* floater = aPlaceholder->GetOutOfFlowFrame();
PRBool isAdjacentWithTop = aState.IsAdjacentWithTop();
// Setup block reflow state to reflow the floater
@ -4333,7 +4333,7 @@ void
nsBlockReflowState::InitFloater(nsPlaceholderFrame* aPlaceholder)
{
// Set the geometric parent of the floater
nsIFrame* floater = aPlaceholder->GetAnchoredItem();
nsIFrame* floater = aPlaceholder->GetOutOfFlowFrame();
floater->SetParent(mBlock);
// Then add the floater to the current line and place it when
@ -4553,7 +4553,7 @@ nsBlockReflowState::PlaceFloater(nsPlaceholderFrame* aPlaceholder,
// placement are for the floater only, not for any non-floating
// content.
nscoord saveY = mY;
nsIFrame* floater = aPlaceholder->GetAnchoredItem();
nsIFrame* floater = aPlaceholder->GetOutOfFlowFrame();
// Get the type of floater
const nsStyleDisplay* floaterDisplay;
@ -4869,11 +4869,11 @@ nsBlockFrame::PaintFloaters(nsIPresContext& aPresContext,
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) floaters->ElementAt(i);
PaintChild(aPresContext, aRenderingContext, aDirtyRect,
ph->GetAnchoredItem(), NS_FRAME_PAINT_LAYER_BACKGROUND);
ph->GetOutOfFlowFrame(), NS_FRAME_PAINT_LAYER_BACKGROUND);
PaintChild(aPresContext, aRenderingContext, aDirtyRect,
ph->GetAnchoredItem(), NS_FRAME_PAINT_LAYER_FLOATERS);
ph->GetOutOfFlowFrame(), NS_FRAME_PAINT_LAYER_FLOATERS);
PaintChild(aPresContext, aRenderingContext, aDirtyRect,
ph->GetAnchoredItem(), NS_FRAME_PAINT_LAYER_FOREGROUND);
ph->GetOutOfFlowFrame(), NS_FRAME_PAINT_LAYER_FOREGROUND);
}
}
}
@ -5235,7 +5235,7 @@ nsBlockFrame::BuildFloaterList()
PRInt32 i, n = array.Count();
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) array[i];
nsIFrame* floater = ph->GetAnchoredItem();
nsIFrame* floater = ph->GetOutOfFlowFrame();
if (nsnull == head) {
current = head = floater;
}
@ -5414,7 +5414,7 @@ nsAnonymousBlockFrame::RemoveFirstFrame()
}
// Remove the floater from the block frames mFloaters list too
mFloaters.RemoveFrame(placeholderFrame->GetAnchoredItem());
mFloaters.RemoveFrame(placeholderFrame->GetOutOfFlowFrame());
break;
}
}

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

@ -1623,7 +1623,7 @@ nsBlockFrame::FindLineFor(nsIFrame* aFrame,
PRInt32 i, n = a.Count();
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) a[i];
if (aFrame == ph->GetAnchoredItem()) {
if (aFrame == ph->GetOutOfFlowFrame()) {
isFloater = PR_TRUE;
goto done;
}
@ -2138,7 +2138,7 @@ nsBlockFrame::SlideFloaters(nsIPresContext* aPresContext,
PRInt32 i, n = floaters->Count();
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) floaters->ElementAt(i);
nsIFrame* floater = ph->GetAnchoredItem();
nsIFrame* floater = ph->GetOutOfFlowFrame();
floater->GetRect(r);
r.y += aDY;
floater->SetRect(r);
@ -2162,7 +2162,7 @@ ListTag(stdout); printf(": MoveInSpaceManager: d=%d,%d\n", aDeltaX, aDeltaY);
PRInt32 i, n = floaters->Count();
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) floaters->ElementAt(i);
nsIFrame* floater = ph->GetAnchoredItem();
nsIFrame* floater = ph->GetOutOfFlowFrame();
aSpaceManager->OffsetRegion(floater, aDeltaX, aDeltaY);
#if 0
((nsFrame*)kid)->ListTag(stdout); printf(": offset=%d,%d\n", aDeltaX, aDeltaY);
@ -3912,11 +3912,11 @@ nsBlockFrame::RemoveFrame(nsIPresContext& aPresContext,
PRInt32 i, count = floaters->Count();
for (i = 0; i < count; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*)floaters->ElementAt(i);
if (ph->GetAnchoredItem() == aOldFrame) {
if (ph->GetOutOfFlowFrame() == aOldFrame) {
// Note: the placeholder is part of the line's child list
// and will be removed later.
// XXX stop storing pointers to the placeholder in the line list???
ph->SetAnchoredItem(nsnull);
ph->SetOutOfFlowFrame(nsnull);
floaters->RemoveElementAt(i);
aOldFrame->DeleteFrame(aPresContext);
goto found_it;
@ -4296,7 +4296,7 @@ nsBlockFrame::ReflowFloater(nsBlockReflowState& aState,
// unbounded height. Floaters with an auto width are sized to zero
// according to the css2 spec.
nsRect availSpace(0, 0, aState.mAvailSpaceRect.width, NS_UNCONSTRAINEDSIZE);
nsIFrame* floater = aPlaceholder->GetAnchoredItem();
nsIFrame* floater = aPlaceholder->GetOutOfFlowFrame();
PRBool isAdjacentWithTop = aState.IsAdjacentWithTop();
// Setup block reflow state to reflow the floater
@ -4333,7 +4333,7 @@ void
nsBlockReflowState::InitFloater(nsPlaceholderFrame* aPlaceholder)
{
// Set the geometric parent of the floater
nsIFrame* floater = aPlaceholder->GetAnchoredItem();
nsIFrame* floater = aPlaceholder->GetOutOfFlowFrame();
floater->SetParent(mBlock);
// Then add the floater to the current line and place it when
@ -4553,7 +4553,7 @@ nsBlockReflowState::PlaceFloater(nsPlaceholderFrame* aPlaceholder,
// placement are for the floater only, not for any non-floating
// content.
nscoord saveY = mY;
nsIFrame* floater = aPlaceholder->GetAnchoredItem();
nsIFrame* floater = aPlaceholder->GetOutOfFlowFrame();
// Get the type of floater
const nsStyleDisplay* floaterDisplay;
@ -4869,11 +4869,11 @@ nsBlockFrame::PaintFloaters(nsIPresContext& aPresContext,
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) floaters->ElementAt(i);
PaintChild(aPresContext, aRenderingContext, aDirtyRect,
ph->GetAnchoredItem(), NS_FRAME_PAINT_LAYER_BACKGROUND);
ph->GetOutOfFlowFrame(), NS_FRAME_PAINT_LAYER_BACKGROUND);
PaintChild(aPresContext, aRenderingContext, aDirtyRect,
ph->GetAnchoredItem(), NS_FRAME_PAINT_LAYER_FLOATERS);
ph->GetOutOfFlowFrame(), NS_FRAME_PAINT_LAYER_FLOATERS);
PaintChild(aPresContext, aRenderingContext, aDirtyRect,
ph->GetAnchoredItem(), NS_FRAME_PAINT_LAYER_FOREGROUND);
ph->GetOutOfFlowFrame(), NS_FRAME_PAINT_LAYER_FOREGROUND);
}
}
}
@ -5235,7 +5235,7 @@ nsBlockFrame::BuildFloaterList()
PRInt32 i, n = array.Count();
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) array[i];
nsIFrame* floater = ph->GetAnchoredItem();
nsIFrame* floater = ph->GetOutOfFlowFrame();
if (nsnull == head) {
current = head = floater;
}
@ -5414,7 +5414,7 @@ nsAnonymousBlockFrame::RemoveFirstFrame()
}
// Remove the floater from the block frames mFloaters list too
mFloaters.RemoveFrame(placeholderFrame->GetAnchoredItem());
mFloaters.RemoveFrame(placeholderFrame->GetOutOfFlowFrame());
break;
}
}

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

@ -53,7 +53,7 @@ ListFloaters(FILE* out, PRInt32 aIndent, nsVoidArray* aFloaters)
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) aFloaters->ElementAt(i);
if (nsnull != ph) {
fprintf(out, "placeholder@%p ", ph);
nsIFrame* frame = ph->GetAnchoredItem();
nsIFrame* frame = ph->GetOutOfFlowFrame();
if (nsnull != frame) {
frame->GetFrameName(frameName);
fputs(frameName, out);

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

@ -18,11 +18,11 @@
#include "nsPlaceholderFrame.h"
#include "nsLineLayout.h"
#include "nsHTMLIIDs.h"
#include "nsIContent.h"
#include "nsIPresContext.h"
#include "nsIRenderingContext.h"
#include "nsIStyleContext.h"
#include "nsLayoutAtoms.h"
nsresult
NS_NewPlaceholderFrame(nsIFrame** aInstancePtrResult)
@ -94,9 +94,9 @@ nsPlaceholderFrame::ContentChanged(nsIPresContext* aPresContext,
{
NS_ASSERTION(mContent == aChild, "bad content-changed target");
// Forward the notification to the floater
if (nsnull != mAnchoredItem) {
return mAnchoredItem->ContentChanged(aPresContext, aChild, aSubContent);
// Forward the notification to the out of flow frame
if (nsnull != mOutOfFlowFrame) {
return mOutOfFlowFrame->ContentChanged(aPresContext, aChild, aSubContent);
}
return NS_OK;
}
@ -107,14 +107,23 @@ nsPlaceholderFrame::AttributeChanged(nsIPresContext* aPresContext,
nsIAtom* aAttribute,
PRInt32 aHint)
{
// Forward the notification to the floater
if (nsnull != mAnchoredItem) {
return mAnchoredItem->AttributeChanged(aPresContext, aChild,
aAttribute, aHint);
// Forward the notification to the out of flow frame
if (nsnull != mOutOfFlowFrame) {
return mOutOfFlowFrame->AttributeChanged(aPresContext, aChild, aAttribute, aHint);
}
return NS_OK;
}
NS_IMETHODIMP
nsPlaceholderFrame::GetFrameType(nsIAtom** aType) const
{
NS_PRECONDITION(nsnull != aType, "null OUT parameter pointer");
*aType = nsLayoutAtoms::placeholderFrame;
NS_ADDREF(*aType);
return NS_OK;
}
NS_IMETHODIMP
nsPlaceholderFrame::GetFrameName(nsString& aResult) const
{

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

@ -21,7 +21,8 @@
#include "nsFrame.h"
/**
* Implementation of a frame that's used as a placeholder for an anchored item
* Implementation of a frame that's used as a placeholder for a frame that
* has been moved out of the flow
*/
class nsPlaceholderFrame : public nsFrame {
public:
@ -30,9 +31,9 @@ public:
*/
friend nsresult NS_NewPlaceholderFrame(nsIFrame** aInstancePtrResult);
// Get/Set the associated anchored item
nsIFrame* GetAnchoredItem() const {return mAnchoredItem;}
void SetAnchoredItem(nsIFrame* aAnchoredItem) {mAnchoredItem = aAnchoredItem;}
// Get/Set the associated out of flow frame
nsIFrame* GetOutOfFlowFrame() const {return mOutOfFlowFrame;}
void SetOutOfFlowFrame(nsIFrame* aFrame) {mOutOfFlowFrame = aFrame;}
// nsIHTMLReflow overrides
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
@ -55,10 +56,17 @@ public:
nsIAtom* aAttribute,
PRInt32 aHint);
/**
* Get the "type" of the frame
*
* @see nsLayoutAtoms::placeholderFrame
*/
NS_IMETHOD GetFrameType(nsIAtom** aType) const;
NS_IMETHOD GetFrameName(nsString& aResult) const;
protected:
nsIFrame* mAnchoredItem;
nsIFrame* mOutOfFlowFrame;
};
#endif /* nsPlaceholderFrame_h___ */

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

@ -1623,7 +1623,7 @@ nsBlockFrame::FindLineFor(nsIFrame* aFrame,
PRInt32 i, n = a.Count();
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) a[i];
if (aFrame == ph->GetAnchoredItem()) {
if (aFrame == ph->GetOutOfFlowFrame()) {
isFloater = PR_TRUE;
goto done;
}
@ -2138,7 +2138,7 @@ nsBlockFrame::SlideFloaters(nsIPresContext* aPresContext,
PRInt32 i, n = floaters->Count();
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) floaters->ElementAt(i);
nsIFrame* floater = ph->GetAnchoredItem();
nsIFrame* floater = ph->GetOutOfFlowFrame();
floater->GetRect(r);
r.y += aDY;
floater->SetRect(r);
@ -2162,7 +2162,7 @@ ListTag(stdout); printf(": MoveInSpaceManager: d=%d,%d\n", aDeltaX, aDeltaY);
PRInt32 i, n = floaters->Count();
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) floaters->ElementAt(i);
nsIFrame* floater = ph->GetAnchoredItem();
nsIFrame* floater = ph->GetOutOfFlowFrame();
aSpaceManager->OffsetRegion(floater, aDeltaX, aDeltaY);
#if 0
((nsFrame*)kid)->ListTag(stdout); printf(": offset=%d,%d\n", aDeltaX, aDeltaY);
@ -3912,11 +3912,11 @@ nsBlockFrame::RemoveFrame(nsIPresContext& aPresContext,
PRInt32 i, count = floaters->Count();
for (i = 0; i < count; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*)floaters->ElementAt(i);
if (ph->GetAnchoredItem() == aOldFrame) {
if (ph->GetOutOfFlowFrame() == aOldFrame) {
// Note: the placeholder is part of the line's child list
// and will be removed later.
// XXX stop storing pointers to the placeholder in the line list???
ph->SetAnchoredItem(nsnull);
ph->SetOutOfFlowFrame(nsnull);
floaters->RemoveElementAt(i);
aOldFrame->DeleteFrame(aPresContext);
goto found_it;
@ -4296,7 +4296,7 @@ nsBlockFrame::ReflowFloater(nsBlockReflowState& aState,
// unbounded height. Floaters with an auto width are sized to zero
// according to the css2 spec.
nsRect availSpace(0, 0, aState.mAvailSpaceRect.width, NS_UNCONSTRAINEDSIZE);
nsIFrame* floater = aPlaceholder->GetAnchoredItem();
nsIFrame* floater = aPlaceholder->GetOutOfFlowFrame();
PRBool isAdjacentWithTop = aState.IsAdjacentWithTop();
// Setup block reflow state to reflow the floater
@ -4333,7 +4333,7 @@ void
nsBlockReflowState::InitFloater(nsPlaceholderFrame* aPlaceholder)
{
// Set the geometric parent of the floater
nsIFrame* floater = aPlaceholder->GetAnchoredItem();
nsIFrame* floater = aPlaceholder->GetOutOfFlowFrame();
floater->SetParent(mBlock);
// Then add the floater to the current line and place it when
@ -4553,7 +4553,7 @@ nsBlockReflowState::PlaceFloater(nsPlaceholderFrame* aPlaceholder,
// placement are for the floater only, not for any non-floating
// content.
nscoord saveY = mY;
nsIFrame* floater = aPlaceholder->GetAnchoredItem();
nsIFrame* floater = aPlaceholder->GetOutOfFlowFrame();
// Get the type of floater
const nsStyleDisplay* floaterDisplay;
@ -4869,11 +4869,11 @@ nsBlockFrame::PaintFloaters(nsIPresContext& aPresContext,
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) floaters->ElementAt(i);
PaintChild(aPresContext, aRenderingContext, aDirtyRect,
ph->GetAnchoredItem(), NS_FRAME_PAINT_LAYER_BACKGROUND);
ph->GetOutOfFlowFrame(), NS_FRAME_PAINT_LAYER_BACKGROUND);
PaintChild(aPresContext, aRenderingContext, aDirtyRect,
ph->GetAnchoredItem(), NS_FRAME_PAINT_LAYER_FLOATERS);
ph->GetOutOfFlowFrame(), NS_FRAME_PAINT_LAYER_FLOATERS);
PaintChild(aPresContext, aRenderingContext, aDirtyRect,
ph->GetAnchoredItem(), NS_FRAME_PAINT_LAYER_FOREGROUND);
ph->GetOutOfFlowFrame(), NS_FRAME_PAINT_LAYER_FOREGROUND);
}
}
}
@ -5235,7 +5235,7 @@ nsBlockFrame::BuildFloaterList()
PRInt32 i, n = array.Count();
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) array[i];
nsIFrame* floater = ph->GetAnchoredItem();
nsIFrame* floater = ph->GetOutOfFlowFrame();
if (nsnull == head) {
current = head = floater;
}
@ -5414,7 +5414,7 @@ nsAnonymousBlockFrame::RemoveFirstFrame()
}
// Remove the floater from the block frames mFloaters list too
mFloaters.RemoveFrame(placeholderFrame->GetAnchoredItem());
mFloaters.RemoveFrame(placeholderFrame->GetOutOfFlowFrame());
break;
}
}

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

@ -1623,7 +1623,7 @@ nsBlockFrame::FindLineFor(nsIFrame* aFrame,
PRInt32 i, n = a.Count();
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) a[i];
if (aFrame == ph->GetAnchoredItem()) {
if (aFrame == ph->GetOutOfFlowFrame()) {
isFloater = PR_TRUE;
goto done;
}
@ -2138,7 +2138,7 @@ nsBlockFrame::SlideFloaters(nsIPresContext* aPresContext,
PRInt32 i, n = floaters->Count();
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) floaters->ElementAt(i);
nsIFrame* floater = ph->GetAnchoredItem();
nsIFrame* floater = ph->GetOutOfFlowFrame();
floater->GetRect(r);
r.y += aDY;
floater->SetRect(r);
@ -2162,7 +2162,7 @@ ListTag(stdout); printf(": MoveInSpaceManager: d=%d,%d\n", aDeltaX, aDeltaY);
PRInt32 i, n = floaters->Count();
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) floaters->ElementAt(i);
nsIFrame* floater = ph->GetAnchoredItem();
nsIFrame* floater = ph->GetOutOfFlowFrame();
aSpaceManager->OffsetRegion(floater, aDeltaX, aDeltaY);
#if 0
((nsFrame*)kid)->ListTag(stdout); printf(": offset=%d,%d\n", aDeltaX, aDeltaY);
@ -3912,11 +3912,11 @@ nsBlockFrame::RemoveFrame(nsIPresContext& aPresContext,
PRInt32 i, count = floaters->Count();
for (i = 0; i < count; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*)floaters->ElementAt(i);
if (ph->GetAnchoredItem() == aOldFrame) {
if (ph->GetOutOfFlowFrame() == aOldFrame) {
// Note: the placeholder is part of the line's child list
// and will be removed later.
// XXX stop storing pointers to the placeholder in the line list???
ph->SetAnchoredItem(nsnull);
ph->SetOutOfFlowFrame(nsnull);
floaters->RemoveElementAt(i);
aOldFrame->DeleteFrame(aPresContext);
goto found_it;
@ -4296,7 +4296,7 @@ nsBlockFrame::ReflowFloater(nsBlockReflowState& aState,
// unbounded height. Floaters with an auto width are sized to zero
// according to the css2 spec.
nsRect availSpace(0, 0, aState.mAvailSpaceRect.width, NS_UNCONSTRAINEDSIZE);
nsIFrame* floater = aPlaceholder->GetAnchoredItem();
nsIFrame* floater = aPlaceholder->GetOutOfFlowFrame();
PRBool isAdjacentWithTop = aState.IsAdjacentWithTop();
// Setup block reflow state to reflow the floater
@ -4333,7 +4333,7 @@ void
nsBlockReflowState::InitFloater(nsPlaceholderFrame* aPlaceholder)
{
// Set the geometric parent of the floater
nsIFrame* floater = aPlaceholder->GetAnchoredItem();
nsIFrame* floater = aPlaceholder->GetOutOfFlowFrame();
floater->SetParent(mBlock);
// Then add the floater to the current line and place it when
@ -4553,7 +4553,7 @@ nsBlockReflowState::PlaceFloater(nsPlaceholderFrame* aPlaceholder,
// placement are for the floater only, not for any non-floating
// content.
nscoord saveY = mY;
nsIFrame* floater = aPlaceholder->GetAnchoredItem();
nsIFrame* floater = aPlaceholder->GetOutOfFlowFrame();
// Get the type of floater
const nsStyleDisplay* floaterDisplay;
@ -4869,11 +4869,11 @@ nsBlockFrame::PaintFloaters(nsIPresContext& aPresContext,
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) floaters->ElementAt(i);
PaintChild(aPresContext, aRenderingContext, aDirtyRect,
ph->GetAnchoredItem(), NS_FRAME_PAINT_LAYER_BACKGROUND);
ph->GetOutOfFlowFrame(), NS_FRAME_PAINT_LAYER_BACKGROUND);
PaintChild(aPresContext, aRenderingContext, aDirtyRect,
ph->GetAnchoredItem(), NS_FRAME_PAINT_LAYER_FLOATERS);
ph->GetOutOfFlowFrame(), NS_FRAME_PAINT_LAYER_FLOATERS);
PaintChild(aPresContext, aRenderingContext, aDirtyRect,
ph->GetAnchoredItem(), NS_FRAME_PAINT_LAYER_FOREGROUND);
ph->GetOutOfFlowFrame(), NS_FRAME_PAINT_LAYER_FOREGROUND);
}
}
}
@ -5235,7 +5235,7 @@ nsBlockFrame::BuildFloaterList()
PRInt32 i, n = array.Count();
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) array[i];
nsIFrame* floater = ph->GetAnchoredItem();
nsIFrame* floater = ph->GetOutOfFlowFrame();
if (nsnull == head) {
current = head = floater;
}
@ -5414,7 +5414,7 @@ nsAnonymousBlockFrame::RemoveFirstFrame()
}
// Remove the floater from the block frames mFloaters list too
mFloaters.RemoveFrame(placeholderFrame->GetAnchoredItem());
mFloaters.RemoveFrame(placeholderFrame->GetOutOfFlowFrame());
break;
}
}

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

@ -1623,7 +1623,7 @@ nsBlockFrame::FindLineFor(nsIFrame* aFrame,
PRInt32 i, n = a.Count();
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) a[i];
if (aFrame == ph->GetAnchoredItem()) {
if (aFrame == ph->GetOutOfFlowFrame()) {
isFloater = PR_TRUE;
goto done;
}
@ -2138,7 +2138,7 @@ nsBlockFrame::SlideFloaters(nsIPresContext* aPresContext,
PRInt32 i, n = floaters->Count();
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) floaters->ElementAt(i);
nsIFrame* floater = ph->GetAnchoredItem();
nsIFrame* floater = ph->GetOutOfFlowFrame();
floater->GetRect(r);
r.y += aDY;
floater->SetRect(r);
@ -2162,7 +2162,7 @@ ListTag(stdout); printf(": MoveInSpaceManager: d=%d,%d\n", aDeltaX, aDeltaY);
PRInt32 i, n = floaters->Count();
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) floaters->ElementAt(i);
nsIFrame* floater = ph->GetAnchoredItem();
nsIFrame* floater = ph->GetOutOfFlowFrame();
aSpaceManager->OffsetRegion(floater, aDeltaX, aDeltaY);
#if 0
((nsFrame*)kid)->ListTag(stdout); printf(": offset=%d,%d\n", aDeltaX, aDeltaY);
@ -3912,11 +3912,11 @@ nsBlockFrame::RemoveFrame(nsIPresContext& aPresContext,
PRInt32 i, count = floaters->Count();
for (i = 0; i < count; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*)floaters->ElementAt(i);
if (ph->GetAnchoredItem() == aOldFrame) {
if (ph->GetOutOfFlowFrame() == aOldFrame) {
// Note: the placeholder is part of the line's child list
// and will be removed later.
// XXX stop storing pointers to the placeholder in the line list???
ph->SetAnchoredItem(nsnull);
ph->SetOutOfFlowFrame(nsnull);
floaters->RemoveElementAt(i);
aOldFrame->DeleteFrame(aPresContext);
goto found_it;
@ -4296,7 +4296,7 @@ nsBlockFrame::ReflowFloater(nsBlockReflowState& aState,
// unbounded height. Floaters with an auto width are sized to zero
// according to the css2 spec.
nsRect availSpace(0, 0, aState.mAvailSpaceRect.width, NS_UNCONSTRAINEDSIZE);
nsIFrame* floater = aPlaceholder->GetAnchoredItem();
nsIFrame* floater = aPlaceholder->GetOutOfFlowFrame();
PRBool isAdjacentWithTop = aState.IsAdjacentWithTop();
// Setup block reflow state to reflow the floater
@ -4333,7 +4333,7 @@ void
nsBlockReflowState::InitFloater(nsPlaceholderFrame* aPlaceholder)
{
// Set the geometric parent of the floater
nsIFrame* floater = aPlaceholder->GetAnchoredItem();
nsIFrame* floater = aPlaceholder->GetOutOfFlowFrame();
floater->SetParent(mBlock);
// Then add the floater to the current line and place it when
@ -4553,7 +4553,7 @@ nsBlockReflowState::PlaceFloater(nsPlaceholderFrame* aPlaceholder,
// placement are for the floater only, not for any non-floating
// content.
nscoord saveY = mY;
nsIFrame* floater = aPlaceholder->GetAnchoredItem();
nsIFrame* floater = aPlaceholder->GetOutOfFlowFrame();
// Get the type of floater
const nsStyleDisplay* floaterDisplay;
@ -4869,11 +4869,11 @@ nsBlockFrame::PaintFloaters(nsIPresContext& aPresContext,
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) floaters->ElementAt(i);
PaintChild(aPresContext, aRenderingContext, aDirtyRect,
ph->GetAnchoredItem(), NS_FRAME_PAINT_LAYER_BACKGROUND);
ph->GetOutOfFlowFrame(), NS_FRAME_PAINT_LAYER_BACKGROUND);
PaintChild(aPresContext, aRenderingContext, aDirtyRect,
ph->GetAnchoredItem(), NS_FRAME_PAINT_LAYER_FLOATERS);
ph->GetOutOfFlowFrame(), NS_FRAME_PAINT_LAYER_FLOATERS);
PaintChild(aPresContext, aRenderingContext, aDirtyRect,
ph->GetAnchoredItem(), NS_FRAME_PAINT_LAYER_FOREGROUND);
ph->GetOutOfFlowFrame(), NS_FRAME_PAINT_LAYER_FOREGROUND);
}
}
}
@ -5235,7 +5235,7 @@ nsBlockFrame::BuildFloaterList()
PRInt32 i, n = array.Count();
for (i = 0; i < n; i++) {
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) array[i];
nsIFrame* floater = ph->GetAnchoredItem();
nsIFrame* floater = ph->GetOutOfFlowFrame();
if (nsnull == head) {
current = head = floater;
}
@ -5414,7 +5414,7 @@ nsAnonymousBlockFrame::RemoveFirstFrame()
}
// Remove the floater from the block frames mFloaters list too
mFloaters.RemoveFrame(placeholderFrame->GetAnchoredItem());
mFloaters.RemoveFrame(placeholderFrame->GetOutOfFlowFrame());
break;
}
}

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

@ -53,7 +53,7 @@ ListFloaters(FILE* out, PRInt32 aIndent, nsVoidArray* aFloaters)
nsPlaceholderFrame* ph = (nsPlaceholderFrame*) aFloaters->ElementAt(i);
if (nsnull != ph) {
fprintf(out, "placeholder@%p ", ph);
nsIFrame* frame = ph->GetAnchoredItem();
nsIFrame* frame = ph->GetOutOfFlowFrame();
if (nsnull != frame) {
frame->GetFrameName(frameName);
fputs(frameName, out);

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

@ -18,11 +18,11 @@
#include "nsPlaceholderFrame.h"
#include "nsLineLayout.h"
#include "nsHTMLIIDs.h"
#include "nsIContent.h"
#include "nsIPresContext.h"
#include "nsIRenderingContext.h"
#include "nsIStyleContext.h"
#include "nsLayoutAtoms.h"
nsresult
NS_NewPlaceholderFrame(nsIFrame** aInstancePtrResult)
@ -94,9 +94,9 @@ nsPlaceholderFrame::ContentChanged(nsIPresContext* aPresContext,
{
NS_ASSERTION(mContent == aChild, "bad content-changed target");
// Forward the notification to the floater
if (nsnull != mAnchoredItem) {
return mAnchoredItem->ContentChanged(aPresContext, aChild, aSubContent);
// Forward the notification to the out of flow frame
if (nsnull != mOutOfFlowFrame) {
return mOutOfFlowFrame->ContentChanged(aPresContext, aChild, aSubContent);
}
return NS_OK;
}
@ -107,14 +107,23 @@ nsPlaceholderFrame::AttributeChanged(nsIPresContext* aPresContext,
nsIAtom* aAttribute,
PRInt32 aHint)
{
// Forward the notification to the floater
if (nsnull != mAnchoredItem) {
return mAnchoredItem->AttributeChanged(aPresContext, aChild,
aAttribute, aHint);
// Forward the notification to the out of flow frame
if (nsnull != mOutOfFlowFrame) {
return mOutOfFlowFrame->AttributeChanged(aPresContext, aChild, aAttribute, aHint);
}
return NS_OK;
}
NS_IMETHODIMP
nsPlaceholderFrame::GetFrameType(nsIAtom** aType) const
{
NS_PRECONDITION(nsnull != aType, "null OUT parameter pointer");
*aType = nsLayoutAtoms::placeholderFrame;
NS_ADDREF(*aType);
return NS_OK;
}
NS_IMETHODIMP
nsPlaceholderFrame::GetFrameName(nsString& aResult) const
{

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

@ -21,7 +21,8 @@
#include "nsFrame.h"
/**
* Implementation of a frame that's used as a placeholder for an anchored item
* Implementation of a frame that's used as a placeholder for a frame that
* has been moved out of the flow
*/
class nsPlaceholderFrame : public nsFrame {
public:
@ -30,9 +31,9 @@ public:
*/
friend nsresult NS_NewPlaceholderFrame(nsIFrame** aInstancePtrResult);
// Get/Set the associated anchored item
nsIFrame* GetAnchoredItem() const {return mAnchoredItem;}
void SetAnchoredItem(nsIFrame* aAnchoredItem) {mAnchoredItem = aAnchoredItem;}
// Get/Set the associated out of flow frame
nsIFrame* GetOutOfFlowFrame() const {return mOutOfFlowFrame;}
void SetOutOfFlowFrame(nsIFrame* aFrame) {mOutOfFlowFrame = aFrame;}
// nsIHTMLReflow overrides
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
@ -55,10 +56,17 @@ public:
nsIAtom* aAttribute,
PRInt32 aHint);
/**
* Get the "type" of the frame
*
* @see nsLayoutAtoms::placeholderFrame
*/
NS_IMETHOD GetFrameType(nsIAtom** aType) const;
NS_IMETHOD GetFrameName(nsString& aResult) const;
protected:
nsIFrame* mAnchoredItem;
nsIFrame* mOutOfFlowFrame;
};
#endif /* nsPlaceholderFrame_h___ */

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

@ -1734,8 +1734,13 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresContext* aPresContext,
NS_NewAreaFrame(areaFrame, NS_BLOCK_DOCUMENT_ROOT|NS_BLOCK_MARGIN_ROOT);
areaFrame->Init(*aPresContext, aDocElement, scrollFrame ? scrollFrame :
aParentFrame, styleContext, nsnull);
if (scrollFrame) {
// If the document element is scrollable, then it needs a view. Otherwise,
// don't bother, because the root frame has a view and the extra view is
// just overhead we don't need
nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, areaFrame,
styleContext, PR_FALSE);
}
// The area frame is the "initial containing block"
mInitialContainingBlock = areaFrame;
@ -1748,6 +1753,36 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresContext* aPresContext,
ProcessChildren(aPresContext, aDocElement, areaFrame, absoluteItems,
childItems, aFixedItems, floatingItems, PR_TRUE);
// See if the document element has a fixed background attachment.
// Note: the reason we wait until after processing the document element's
// children is because of special treatment of the background for the HTML
// element. See BodyFixupRule::MapStyleInto() for details
const nsStyleColor* color;
color = (const nsStyleColor*)styleContext->GetStyleData(eStyleStruct_Color);
if (NS_STYLE_BG_ATTACHMENT_FIXED == color->mBackgroundAttachment) {
// Fixed background attachments are handled by setting the
// NS_VIEW_PUBLIC_FLAG_DONT_BITBLT flag bit on the view.
//
// If the document element's frame is scrollable, then set the bit on its
// view; otherwise, set it on the root frame's view. This avoids
// unnecessarily creating another view and should be faster
nsIView* view;
if (scrollFrame) {
areaFrame->GetView(&view);
} else {
nsIFrame* parentFrame;
areaFrame->GetParent(&parentFrame);
parentFrame->GetView(&view);
}
NS_ASSERTION(view, "expected a view");
PRUint32 viewFlags;
view->GetViewFlags(&viewFlags);
view->SetViewFlags(viewFlags | NS_VIEW_PUBLIC_FLAG_DONT_BITBLT);
}
// Set the initial child lists
areaFrame->SetInitialChildList(*aPresContext, nsnull,
childItems.childList);
@ -2017,7 +2052,7 @@ nsCSSFrameConstructor::CreateFloaterPlaceholderFrameFor(nsIPresContext* aPresCo
aPresContext->GetShell(getter_AddRefs(presShell));
presShell->SetPlaceholderFrameFor(aFrame, placeholder);
placeholder->SetAnchoredItem(aFrame);
placeholder->SetOutOfFlowFrame(aFrame);
*aPlaceholderFrame = NS_STATIC_CAST(nsIFrame*, placeholder);
}
@ -4876,7 +4911,7 @@ nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresContext* aPresContext,
nsPlaceholderFrame* floaterPlaceholderFrame;
floaterPlaceholderFrame = (nsPlaceholderFrame*)placeholderFrame;
floaterPlaceholderFrame->SetAnchoredItem(newFrame);
floaterPlaceholderFrame->SetOutOfFlowFrame(newFrame);
}
}
parentFrame->InsertFrames(*aPresContext, *presShell, listName, prevSibling, newFrame);