зеркало из https://github.com/mozilla/pjs.git
set attributes on <frame>, <frameset> layout
This commit is contained in:
Родитель
c056561675
Коммит
62fd08cdee
|
@ -595,6 +595,7 @@ HTMLContentSink::OpenFrameset(const nsIParserNode& aNode)
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult rv = NS_NewHTMLFrameset(&mFrameset, atom, nsnull);
|
||||
mFrameset->SetDocument(mDocument);
|
||||
NS_RELEASE(atom);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
|
@ -605,9 +606,6 @@ HTMLContentSink::OpenFrameset(const nsIParserNode& aNode)
|
|||
|
||||
// Add attributes to the frameset content object
|
||||
AddAttributes(aNode, mFrameset);
|
||||
// XXX If the frameset already existed and has been reflowed somewhat
|
||||
// then we need to trigger a style change
|
||||
mRoot->AppendChild(mFrameset, PR_TRUE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -617,6 +615,8 @@ HTMLContentSink::CloseFrameset(const nsIParserNode& aNode)
|
|||
{
|
||||
FlushText();
|
||||
|
||||
mRoot->AppendChild(mFrameset, PR_TRUE);
|
||||
|
||||
SINK_TRACE_NODE(SINK_TRACE_CALLS,
|
||||
"HTMLContentSink::CloseFrameset", aNode);
|
||||
|
||||
|
@ -1805,6 +1805,9 @@ nsresult HTMLContentSink::ProcessFrameTag(nsIHTMLContent** aInstancePtrResult,
|
|||
nsIAtom* atom = NS_NewAtom(tmp);
|
||||
|
||||
nsresult rv = NS_NewHTMLFrame(aInstancePtrResult, atom, mWebShell);
|
||||
if (NS_OK == rv) {
|
||||
rv = AddAttributes(aNode, *aInstancePtrResult);
|
||||
}
|
||||
|
||||
NS_RELEASE(atom);
|
||||
return rv;
|
||||
|
|
|
@ -595,6 +595,7 @@ HTMLContentSink::OpenFrameset(const nsIParserNode& aNode)
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult rv = NS_NewHTMLFrameset(&mFrameset, atom, nsnull);
|
||||
mFrameset->SetDocument(mDocument);
|
||||
NS_RELEASE(atom);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
|
@ -605,9 +606,6 @@ HTMLContentSink::OpenFrameset(const nsIParserNode& aNode)
|
|||
|
||||
// Add attributes to the frameset content object
|
||||
AddAttributes(aNode, mFrameset);
|
||||
// XXX If the frameset already existed and has been reflowed somewhat
|
||||
// then we need to trigger a style change
|
||||
mRoot->AppendChild(mFrameset, PR_TRUE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -617,6 +615,8 @@ HTMLContentSink::CloseFrameset(const nsIParserNode& aNode)
|
|||
{
|
||||
FlushText();
|
||||
|
||||
mRoot->AppendChild(mFrameset, PR_TRUE);
|
||||
|
||||
SINK_TRACE_NODE(SINK_TRACE_CALLS,
|
||||
"HTMLContentSink::CloseFrameset", aNode);
|
||||
|
||||
|
@ -1805,6 +1805,9 @@ nsresult HTMLContentSink::ProcessFrameTag(nsIHTMLContent** aInstancePtrResult,
|
|||
nsIAtom* atom = NS_NewAtom(tmp);
|
||||
|
||||
nsresult rv = NS_NewHTMLFrame(aInstancePtrResult, atom, mWebShell);
|
||||
if (NS_OK == rv) {
|
||||
rv = AddAttributes(aNode, *aInstancePtrResult);
|
||||
}
|
||||
|
||||
NS_RELEASE(atom);
|
||||
return rv;
|
||||
|
|
|
@ -244,31 +244,22 @@ nsHTMLFrameOuterFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
|||
const nsReflowState& aReflowState,
|
||||
nsReflowMetrics& aDesiredSize)
|
||||
{
|
||||
if (IsInline()) {
|
||||
float p2t = aPresContext->GetPixelsToTwips();
|
||||
// <frame> processing does not use this routine, only <iframe>
|
||||
float p2t = aPresContext->GetPixelsToTwips();
|
||||
|
||||
nsSize size;
|
||||
PRIntn ss = nsCSSLayout::GetStyleSize(aPresContext, aReflowState, size);
|
||||
nsSize size;
|
||||
PRIntn ss = nsCSSLayout::GetStyleSize(aPresContext, aReflowState, size);
|
||||
|
||||
if (0 == (ss & NS_SIZE_HAS_WIDTH)) {
|
||||
size.width = (nscoord)(200.0 * p2t + 0.5);
|
||||
}
|
||||
if (0 == (ss & NS_SIZE_HAS_HEIGHT)) {
|
||||
size.height = (nscoord)(200 * p2t + 0.5);
|
||||
}
|
||||
|
||||
aDesiredSize.width = size.width;
|
||||
aDesiredSize.height = size.height;
|
||||
} else {
|
||||
nsHTMLFramesetFrame* framesetParent = nsHTMLFramesetFrame::GetFramesetParent(this);
|
||||
if (nsnull != framesetParent) {
|
||||
framesetParent->GetSizeOfChild(this, aDesiredSize);
|
||||
} else {
|
||||
NS_ASSERTION(0, "parent of <frame> not a <frameset>");
|
||||
aDesiredSize.width = 0;
|
||||
aDesiredSize.height = 0;
|
||||
}
|
||||
// XXX this needs to be changed from (200,200) to a better default for inline frames
|
||||
if (0 == (ss & NS_SIZE_HAS_WIDTH)) {
|
||||
size.width = (nscoord)(200.0 * p2t + 0.5);
|
||||
}
|
||||
if (0 == (ss & NS_SIZE_HAS_HEIGHT)) {
|
||||
size.height = (nscoord)(200 * p2t + 0.5);
|
||||
}
|
||||
|
||||
aDesiredSize.width = size.width;
|
||||
aDesiredSize.height = size.height;
|
||||
aDesiredSize.ascent = aDesiredSize.height;
|
||||
aDesiredSize.descent = 0;
|
||||
}
|
||||
|
@ -283,7 +274,7 @@ nsHTMLFrameOuterFrame::Paint(nsIPresContext& aPresContext,
|
|||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
//printf("outer paint %d %d %d %d \n", aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height);
|
||||
printf("outer paint %d (%d,%d,%d,%d) ", this, aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height);
|
||||
if (nsnull != mFirstChild) {
|
||||
mFirstChild->Paint(aPresContext, aRenderingContext, aDirtyRect);
|
||||
}
|
||||
|
@ -296,8 +287,12 @@ nsHTMLFrameOuterFrame::Reflow(nsIPresContext& aPresContext,
|
|||
const nsReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
// Always get the size so that the caller knows how big we are
|
||||
GetDesiredSize(&aPresContext, aReflowState, aDesiredSize);
|
||||
if (IsInline()) {
|
||||
GetDesiredSize(&aPresContext, aReflowState, aDesiredSize);
|
||||
} else {
|
||||
aDesiredSize.width = aReflowState.maxSize.width;
|
||||
aDesiredSize.height = aReflowState.maxSize.height;
|
||||
}
|
||||
|
||||
if (nsnull == mFirstChild) {
|
||||
mFirstChild = new nsHTMLFrameInnerFrame(mContent, this);
|
||||
|
@ -313,8 +308,9 @@ nsHTMLFrameOuterFrame::Reflow(nsIPresContext& aPresContext,
|
|||
// Reflow the child and get its desired size
|
||||
nsReflowState kidReflowState(mFirstChild, aReflowState, innerSize);
|
||||
mFirstChild->WillReflow(aPresContext);
|
||||
nsReflowMetrics ignore(nsnull);
|
||||
aStatus = ReflowChild(mFirstChild, &aPresContext, ignore, kidReflowState);
|
||||
aStatus = ReflowChild(mFirstChild, &aPresContext, aDesiredSize, kidReflowState);
|
||||
// nsReflowMetrics ignore(nsnull);
|
||||
// aStatus = ReflowChild(mFirstChild, &aPresContext, ignore, kidReflowState);
|
||||
NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status");
|
||||
|
||||
// Place and size the child
|
||||
|
@ -422,7 +418,7 @@ nsHTMLFrameInnerFrame::Paint(nsIPresContext& aPresContext,
|
|||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
//printf("inner paint %d %d %d %d \n", aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height);
|
||||
printf("inner paint %d (%d,%d,%d,%d) ", this, aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height);
|
||||
if (nsnull != mWebShell) {
|
||||
//mWebShell->Show();
|
||||
}
|
||||
|
@ -774,29 +770,35 @@ NS_IMETHODIMP
|
|||
TempObserver::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax,
|
||||
const nsString& aMsg)
|
||||
{
|
||||
#if 0
|
||||
fputs("[progress ", stdout);
|
||||
fputs(mURL, stdout);
|
||||
printf(" %d %d ", aProgress, aProgressMax);
|
||||
fputs(aMsg, stdout);
|
||||
fputs("]\n", stdout);
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TempObserver::OnStartBinding(nsIURL* aURL, const char *aContentType)
|
||||
{
|
||||
#if 0
|
||||
fputs("Loading ", stdout);
|
||||
fputs(mURL, stdout);
|
||||
fputs("\n", stdout);
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TempObserver::OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg)
|
||||
{
|
||||
#if 0
|
||||
fputs("Done loading ", stdout);
|
||||
fputs(mURL, stdout);
|
||||
fputs("\n", stdout);
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -249,7 +249,10 @@ nsHTMLFramesetFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
|||
aDesiredSize.width = area.width;
|
||||
aDesiredSize.height= area.height;
|
||||
} else {
|
||||
framesetParent->GetSizeOfChild(this, aDesiredSize);
|
||||
nsSize size;
|
||||
framesetParent->GetSizeOfChild(this, size);
|
||||
aDesiredSize.width = size.width;
|
||||
aDesiredSize.height = size.height;
|
||||
}
|
||||
aDesiredSize.ascent = aDesiredSize.height;
|
||||
aDesiredSize.descent = 0;
|
||||
|
@ -272,7 +275,7 @@ nsHTMLFramesetFrame* nsHTMLFramesetFrame::GetFramesetParent(nsIFrame* aChild)
|
|||
return parent;
|
||||
}
|
||||
|
||||
void nsHTMLFramesetFrame::GetSizeOfChildAt(PRInt32 aIndexInParent, nsReflowMetrics& aSize, nsPoint& aCellIndex)
|
||||
void nsHTMLFramesetFrame::GetSizeOfChildAt(PRInt32 aIndexInParent, nsSize& aSize, nsPoint& aCellIndex)
|
||||
{
|
||||
PRInt32 row = aIndexInParent / mNumCols;
|
||||
PRInt32 col = aIndexInParent - (row * mNumCols); // remainder from dividing index by mNumCols
|
||||
|
@ -288,7 +291,7 @@ void nsHTMLFramesetFrame::GetSizeOfChildAt(PRInt32 aIndexInParent, nsReflowMetri
|
|||
|
||||
|
||||
void nsHTMLFramesetFrame::GetSizeOfChild(nsIFrame* aChild,
|
||||
nsReflowMetrics& aSize)
|
||||
nsSize& aSize)
|
||||
{
|
||||
// Reflow only creates children frames for <frameset> and <frame> content.
|
||||
// this assumption is used here
|
||||
|
@ -311,6 +314,7 @@ nsHTMLFramesetFrame::Paint(nsIPresContext& aPresContext,
|
|||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
printf("frameset paint %d (%d,%d,%d,%d) ", this, aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height);
|
||||
return nsHTMLContainerFrame::Paint(aPresContext, aRenderingContext, aDirtyRect);
|
||||
}
|
||||
|
||||
|
@ -333,7 +337,9 @@ void nsHTMLFramesetFrame::ParseRowCol(nsIAtom* aAttrType, PRInt32& aNumSpecs, ns
|
|||
}
|
||||
}
|
||||
aNumSpecs = 1;
|
||||
*aSpecs = nsnull;
|
||||
*aSpecs = new nsFramesetSpec[1];
|
||||
aSpecs[0]->mUnit = eFramesetUnit_Free;
|
||||
aSpecs[0]->mValue = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -425,17 +431,17 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext& aPresContext,
|
|||
// Always get the size so that the caller knows how big we are
|
||||
GetDesiredSize(&aPresContext, aReflowState, aDesiredSize);
|
||||
|
||||
if (mNumRows > 1) {
|
||||
CalculateRowCol(&aPresContext, aReflowState.maxSize.width, mNumRows, mRowSpecs, mRowSizes);
|
||||
}
|
||||
if (mNumCols > 1) {
|
||||
CalculateRowCol(&aPresContext, aReflowState.maxSize.height, mNumCols, mColSpecs, mColSizes);
|
||||
}
|
||||
nscoord width = (aDesiredSize.width <= aReflowState.maxSize.width)
|
||||
? aDesiredSize.width : aReflowState.maxSize.width;
|
||||
nscoord height = (aDesiredSize.height <= aReflowState.maxSize.height)
|
||||
? aDesiredSize.height : aReflowState.maxSize.height;
|
||||
|
||||
CalculateRowCol(&aPresContext, width, mNumCols, mColSpecs, mColSizes);
|
||||
CalculateRowCol(&aPresContext, height, mNumRows, mRowSpecs, mRowSizes);
|
||||
|
||||
// create the children frames; skip those which aren't frameset or frame
|
||||
mChildCount = 0;
|
||||
if (firstTime) {
|
||||
mChildCount = 0;
|
||||
nsIFrame* lastFrame = nsnull;
|
||||
nsHTMLFrameset* content = (nsHTMLFrameset*)mContent;
|
||||
PRInt32 numChildren = content->ChildCount();
|
||||
|
@ -468,19 +474,20 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext& aPresContext,
|
|||
PRInt32 i = 0;
|
||||
nsPoint offset(0,0);
|
||||
for (nsIFrame* child = mFirstChild; child; child->GetNextSibling(child)) {
|
||||
nsReflowMetrics metrics(nsnull);
|
||||
nsSize size;
|
||||
nsPoint cellIndex;
|
||||
GetSizeOfChildAt(i, metrics, cellIndex);
|
||||
GetSizeOfChildAt(i, size, cellIndex);
|
||||
nsReflowState reflowState(child, aReflowState, size);
|
||||
|
||||
nsSize size(metrics.width, metrics.height);
|
||||
nsReflowState childReflowState(child, aReflowState, size);
|
||||
child->WillReflow(aPresContext);
|
||||
nsReflowMetrics ignore(nsnull);
|
||||
aStatus = ReflowChild(mFirstChild, &aPresContext, ignore, childReflowState);
|
||||
nsReflowMetrics metrics(nsnull);
|
||||
metrics.width = size.width;
|
||||
metrics.height= size.height;
|
||||
aStatus = ReflowChild(child, &aPresContext, metrics, reflowState);
|
||||
NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status");
|
||||
|
||||
// Place and size the child
|
||||
nsRect rect(offset.x, offset.y, metrics.width, metrics.height);
|
||||
nsRect rect(offset.x, offset.y, size.width, size.height);
|
||||
child->SetRect(rect);
|
||||
child->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
|
||||
|
|
|
@ -57,9 +57,9 @@ public:
|
|||
|
||||
static PRInt32 gMaxNumRowColSpecs;
|
||||
|
||||
void GetSizeOfChild(nsIFrame* aChild, nsReflowMetrics& aSize);
|
||||
void GetSizeOfChild(nsIFrame* aChild, nsSize& aSize);
|
||||
|
||||
void GetSizeOfChildAt(PRInt32 aIndexInParent, nsReflowMetrics& aSize, nsPoint& aCellIndex);
|
||||
void GetSizeOfChildAt(PRInt32 aIndexInParent, nsSize& aSize, nsPoint& aCellIndex);
|
||||
|
||||
static nsHTMLFramesetFrame* GetFramesetParent(nsIFrame* aChild);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче