Give nsHTMLReflowState an explicit copy-constructor and assignment operator to fix up mCBReflowState and fix regressions from previous patch. b=143706 r=bzbarsky sr=waterson

This commit is contained in:
dbaron%fas.harvard.edu 2002-05-15 19:58:20 +00:00
Родитель 0cc2ec0655
Коммит b7e8be94dd
4 изменённых файлов: 56 добавлений и 6 удалений

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

@ -262,9 +262,13 @@ struct nsHTMLReflowState {
static const char* ReasonToString(nsReflowReason aReason);
#endif
// Note: The copy constructor is written by the compiler
// automatically. You can use that and then override specific values
// if you want, or you can call Init as desired...
// A simple copy constructor. (It fixes up |mCBReflowState|, which
// can point to |this|, to point to the copy's |this|.)
nsHTMLReflowState(const nsHTMLReflowState& aOther);
// A simple assignment operator. It does the same fixups as the
// copy-consturctor.
nsHTMLReflowState& operator=(const nsHTMLReflowState& aOther);
// Initialize a <b>root</b> reflow state with a rendering context to
// use for measuring things.

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

@ -88,6 +88,27 @@ nsHTMLReflowState::ReasonToString(nsReflowReason aReason)
}
#endif
nsHTMLReflowState::nsHTMLReflowState(const nsHTMLReflowState& aOther)
{
// Use assignment operator below.
*this = aOther;
}
nsHTMLReflowState&
nsHTMLReflowState::operator=(const nsHTMLReflowState &aOther)
{
// Copy everything.
// XXX This won't work anymore if someone adds member variables that
// have nontrivial constructors or assignment operators (e.g.,
// nsCOMPtr).
memcpy(this, &aOther, sizeof(*this));
// Fix up the |mCBReflowState| member, which should continue to point
// to |this|.
if (aOther.mCBReflowState == &aOther)
mCBReflowState = this;
}
// Initialize a <b>root</b> reflow state with a rendering context to
// use for measuring things.
nsHTMLReflowState::nsHTMLReflowState(nsIPresContext* aPresContext,

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

@ -262,9 +262,13 @@ struct nsHTMLReflowState {
static const char* ReasonToString(nsReflowReason aReason);
#endif
// Note: The copy constructor is written by the compiler
// automatically. You can use that and then override specific values
// if you want, or you can call Init as desired...
// A simple copy constructor. (It fixes up |mCBReflowState|, which
// can point to |this|, to point to the copy's |this|.)
nsHTMLReflowState(const nsHTMLReflowState& aOther);
// A simple assignment operator. It does the same fixups as the
// copy-consturctor.
nsHTMLReflowState& operator=(const nsHTMLReflowState& aOther);
// Initialize a <b>root</b> reflow state with a rendering context to
// use for measuring things.

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

@ -88,6 +88,27 @@ nsHTMLReflowState::ReasonToString(nsReflowReason aReason)
}
#endif
nsHTMLReflowState::nsHTMLReflowState(const nsHTMLReflowState& aOther)
{
// Use assignment operator below.
*this = aOther;
}
nsHTMLReflowState&
nsHTMLReflowState::operator=(const nsHTMLReflowState &aOther)
{
// Copy everything.
// XXX This won't work anymore if someone adds member variables that
// have nontrivial constructors or assignment operators (e.g.,
// nsCOMPtr).
memcpy(this, &aOther, sizeof(*this));
// Fix up the |mCBReflowState| member, which should continue to point
// to |this|.
if (aOther.mCBReflowState == &aOther)
mCBReflowState = this;
}
// Initialize a <b>root</b> reflow state with a rendering context to
// use for measuring things.
nsHTMLReflowState::nsHTMLReflowState(nsIPresContext* aPresContext,