[MathML] Portability: adding explicit get() on pointers coming from nsCOMPtr

This commit is contained in:
rbs%maths.uq.edu.au 1999-10-12 04:38:21 +00:00
Родитель c1ee066eb7
Коммит 5d35f5b61c
4 изменённых файлов: 83 добавлений и 19 удалений

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

@ -249,7 +249,7 @@ nsMathMLContainerFrame::InsertScriptLevelStyleContext(nsIPresContext& aPresConte
aPresContext.ResolvePseudoStyleContextFor(childContent, fontAtom, lastStyleContext,
PR_FALSE, getter_AddRefs(newStyleContext));
if (nsnull == newStyleContext || lastStyleContext == newStyleContext) {
if (newStyleContext && newStyleContext.get() != lastStyleContext) {
break;
}
else {
@ -272,10 +272,10 @@ nsMathMLContainerFrame::InsertScriptLevelStyleContext(nsIPresContext& aPresConte
}
if (nsnull != firstFrame) { // at least one new frame was created
mFrames.ReplaceFrame(this, childFrame, firstFrame);
lastFrame->SetInitialChildList(aPresContext, nsnull, childFrame);
childFrame->SetParent(lastFrame);
childFrame->SetNextSibling(nsnull);
aPresContext.ReParentStyleContext(childFrame, lastStyleContext);
lastFrame->SetInitialChildList(aPresContext, nsnull, childFrame);
}
}
}
@ -319,6 +319,66 @@ nsMathMLContainerFrame::Init(nsIPresContext& aPresContext,
return rv;
}
NS_IMETHODIMP
nsMathMLContainerFrame::SetInitialChildList(nsIPresContext& aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList)
{
// First, let the base class do its job
nsresult rv;
rv = nsHTMLContainerFrame::SetInitialChildList(aPresContext, aListName, aChildList);
// Next, since we are an inline frame, and since we are a container, we have to
// be very careful with the way we treat our children. Things look okay when
// all of our children are only MathML frames. But there are problems if one of
// our children happens to be an nsInlineFrame, e.g., from generated content such
// as :before { content: open-quote } or :after { content: close-quote }
// The code asserts during reflow (in nsLineLayout::BeginSpan)
// Also there are problems when our children are hybrid, e.g., from html markups.
// In short, the nsInlineFrame class expects a number of *invariants* that are not
// met when we mix things.
// So what we do here is to wrap children that happen to be nsInlineFrames in
// anonymous block frames.
// XXX Question: Do we have to handle Insert/Remove/Append on behalf of
// these anonymous blocks?
// Note: By construction, our anonymous blocks have only one child.
nsIFrame* next = mFrames.FirstChild();
while (next) {
nsIFrame* child = next;
rv = next->GetNextSibling(&next);
if (!IsOnlyWhitespace(child)) {
nsInlineFrame* inlineFrame = nsnull;
rv = child->QueryInterface(nsInlineFrame::kInlineFrameCID, (void**)&inlineFrame);
if (inlineFrame) {
// create a new anonymous block frame to wrap this child...
nsIFrame* anonymous;
rv = NS_NewAnonymousBlockFrame(&anonymous);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIStyleContext> newStyleContext;
aPresContext.ResolvePseudoStyleContextFor(mContent, nsHTMLAtoms::mozAnonymousBlock,
mStyleContext, PR_FALSE,
getter_AddRefs(newStyleContext));
rv = anonymous->Init(aPresContext, mContent, this, newStyleContext, nsnull);
if (NS_FAILED(rv)) {
anonymous->Destroy(aPresContext);
delete anonymous;
return rv;
}
mFrames.ReplaceFrame(this, child, anonymous);
child->SetParent(anonymous);
child->SetNextSibling(nsnull);
aPresContext.ReParentStyleContext(child, newStyleContext);
anonymous->SetInitialChildList(aPresContext, nsnull, child);
}
}
}
return rv;
}
NS_IMETHODIMP
nsMathMLContainerFrame::Reflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
@ -377,9 +437,7 @@ nsMathMLContainerFrame::Reflow(nsIPresContext& aPresContext,
// Ask stretchy children to stretch themselves
nsStretchDirection stretchDir = NS_STRETCH_DIRECTION_VERTICAL;
nsCharMetrics parentSize, childSize;
parentSize.descent = aDesiredSize.descent; parentSize.width = aDesiredSize.width;
parentSize.ascent = aDesiredSize.ascent; parentSize.height = aDesiredSize.height;
nsCharMetrics parentSize(aDesiredSize);
aDesiredSize.width = aDesiredSize.height = aDesiredSize.ascent = aDesiredSize.descent = 0;
childFrame = mFrames.FirstChild();
@ -387,9 +445,8 @@ nsMathMLContainerFrame::Reflow(nsIPresContext& aPresContext,
// retrieve the metrics that was stored at the previous pass
childFrame->GetRect(rect);
childSize.descent = rect.x; childSize.width = rect.width;
childSize.ascent = rect.y; childSize.height = rect.height;
nsCharMetrics childSize(rect.x, rect.y, rect.width, rect.height);
//////////
// Stretch ...
// Only directed at frames that implement the nsIMathMLFrame interface

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

@ -26,8 +26,13 @@
#include "nsCOMPtr.h"
#include "nsIViewManager.h"
#include "nsHTMLContainerFrame.h"
#include "nsBlockFrame.h"
#include "nsInlineFrame.h"
#include "nsMathMLAtoms.h"
#include "nsMathMLOperators.h"
#include "nsMathMLChar.h"
#include "nsIMathMLFrame.h"
#include "nsMathMLParts.h"
/*
* Base class for MathML container frames. It acts like an inferred
@ -88,6 +93,11 @@ public:
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow);
NS_IMETHOD
SetInitialChildList(nsIPresContext& aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList);
NS_IMETHOD
Reflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
@ -113,7 +123,7 @@ protected:
// mover, munderover, mmultiscripts, mfrac, mroot, mtable.
PRBool mDisplayStyle; // displaystyle="false" is intended to slightly alter how the
// rendering in done in inline mode.
// rendering is done in inline mode.
virtual PRIntn GetSkipSides() const { return 0; }
};

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

@ -41,8 +41,6 @@
#include "nsIDOMText.h"
#include "nsITextContent.h"
#include "nsMathMLAtoms.h"
#include "nsMathMLParts.h"
#include "nsMathMLmiFrame.h"
//
@ -96,7 +94,7 @@ nsMathMLmiFrame::SetInitialChildList(nsIPresContext& aPresContext,
{
nsresult rv;
// First, let the base class to its work
// First, let the base class do its work
rv = nsMathMLContainerFrame::SetInitialChildList(aPresContext, aListName, aChildList);
@ -136,7 +134,7 @@ nsMathMLmiFrame::SetInitialChildList(nsIPresContext& aPresContext,
aPresContext.ResolvePseudoStyleContextFor(mContent, fontAtom, mStyleContext,
PR_FALSE, getter_AddRefs(newStyleContext));
if (nsnull != newStyleContext && mStyleContext != newStyleContext) {
if (newStyleContext && newStyleContext.get() != mStyleContext) {
nsIFrame* newFrame = nsnull;
NS_NewMathMLContainerFrame(&newFrame);
@ -145,13 +143,14 @@ nsMathMLmiFrame::SetInitialChildList(nsIPresContext& aPresContext,
newFrame->Init(aPresContext, mContent, this, newStyleContext, nsnull);
// our children become children of the new frame
nsIFrame* childFrame = mFrames.FirstChild();
newFrame->SetInitialChildList(aPresContext, nsnull, childFrame);
nsIFrame* firstFrame = mFrames.FirstChild();
nsIFrame* childFrame = firstFrame;
while (nsnull != childFrame) {
childFrame->SetParent(newFrame);
aPresContext.ReParentStyleContext(childFrame, newStyleContext);
childFrame->GetNextSibling(&childFrame);
}
newFrame->SetInitialChildList(aPresContext, nsnull, firstFrame);
// the new frame becomes our sole child
mFrames.SetFrames(newFrame);

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

@ -37,8 +37,6 @@
#include "nsIFontMetrics.h"
#include "nsStyleUtil.h"
#include "nsMathMLAtoms.h"
#include "nsMathMLParts.h"
#include "nsMathMLmmultiscriptsFrame.h"
//
@ -103,12 +101,12 @@ nsMathMLmmultiscriptsFrame::Reflow(nsIPresContext& aPresContext,
childFrame->GetContent(getter_AddRefs(childContent));
childContent->GetTag(*getter_AddRefs(childTag));
if (childTag == nsMathMLAtoms::mprescripts) {
if (childTag.get() == nsMathMLAtoms::mprescripts) {
// NS_ASSERTION(mprescriptsFrame == nsnull,"duplicate <mprescripts/>");
//printf("mprescripts Found ...\n"); // should ignore?
mprescriptsFrame = childFrame;
}
else if (childTag == nsMathMLAtoms::none) {
else if (childTag.get() == nsMathMLAtoms::none) {
childDesiredSize.height = 0;
childDesiredSize.width = 0;
childDesiredSize.ascent = 0;