зеркало из https://github.com/mozilla/pjs.git
added reparent method
This commit is contained in:
Родитель
8a50910dfc
Коммит
c5b842e239
|
@ -161,6 +161,7 @@ static nscoord CalcSideFor(const nsIFrame* aFrame, const nsStyleCoord& aCoord,
|
|||
NS_RELEASE(parentContext);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case eStyleUnit_Percent:
|
||||
{
|
||||
|
@ -651,10 +652,14 @@ public:
|
|||
virtual void ForceUnique(void);
|
||||
virtual void RecalcAutomaticData(nsIPresContext* aPresContext);
|
||||
|
||||
virtual void ReParent(nsIStyleContext* aNewParentContext,
|
||||
nsIPresContext* aPresContext);
|
||||
|
||||
virtual void List(FILE* out, PRInt32 aIndent);
|
||||
|
||||
protected:
|
||||
void AppendChild(StyleContextImpl* aChild);
|
||||
void RemoveChild(StyleContextImpl* aChild);
|
||||
|
||||
StyleContextImpl* mParent;
|
||||
StyleContextImpl* mChild;
|
||||
|
@ -769,8 +774,6 @@ StyleContextImpl::~StyleContextImpl()
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef DEBUG_REFS
|
||||
NS_IMPL_QUERY_INTERFACE(StyleContextImpl, kIStyleContextIID)
|
||||
|
||||
|
@ -825,6 +828,48 @@ void StyleContextImpl::AppendChild(StyleContextImpl* aChild)
|
|||
NS_ADDREF(aChild);
|
||||
}
|
||||
|
||||
void StyleContextImpl::RemoveChild(StyleContextImpl* aChild)
|
||||
{
|
||||
NS_ASSERTION((nsnull != aChild) && (this == mChild->mParent), "bad argument");
|
||||
|
||||
if ((nsnull == aChild) || (this != mChild->mParent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mEmptyChild == aChild) {
|
||||
mEmptyChild = nsnull;
|
||||
}
|
||||
else {
|
||||
if (aChild->mPrevSibling != aChild) {
|
||||
if (mChild == aChild) {
|
||||
mChild = mChild->mNextSibling;
|
||||
}
|
||||
aChild->mPrevSibling->mNextSibling = aChild->mNextSibling;
|
||||
aChild->mNextSibling->mPrevSibling = aChild->mPrevSibling;
|
||||
aChild->mNextSibling = aChild;
|
||||
aChild->mPrevSibling = aChild;
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(mChild == aChild, "bad sibling pointers");
|
||||
if (mChild == aChild) {
|
||||
mChild = nsnull;
|
||||
}
|
||||
}
|
||||
}
|
||||
NS_RELEASE(aChild);
|
||||
}
|
||||
|
||||
void StyleContextImpl::ReParent(nsIStyleContext* aNewParentContext,
|
||||
nsIPresContext* aPresContext)
|
||||
{
|
||||
if (aNewParentContext != mParent) {
|
||||
mParent->RemoveChild(this);
|
||||
mParent = (StyleContextImpl*)aNewParentContext; // weak ref
|
||||
mParent->AppendChild(this);
|
||||
RemapStyle(aPresContext);
|
||||
}
|
||||
}
|
||||
|
||||
nsISupportsArray* StyleContextImpl::GetStyleRules(void) const
|
||||
{
|
||||
NS_IF_ADDREF(mRules);
|
||||
|
@ -1071,6 +1116,17 @@ StyleContextImpl::RemapStyle(nsIPresContext* aPresContext)
|
|||
mRules->EnumerateForwards(MapStyleRule, &data);
|
||||
}
|
||||
}
|
||||
|
||||
if (nsnull != mChild) {
|
||||
StyleContextImpl* child = mChild;
|
||||
do {
|
||||
child->RemapStyle(aPresContext);
|
||||
child = child->mNextSibling;
|
||||
} while (mChild != child);
|
||||
}
|
||||
if (nsnull != mEmptyChild) {
|
||||
mEmptyChild->RemapStyle(aPresContext);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -203,6 +203,11 @@ public:
|
|||
// call if you change style data after creation
|
||||
virtual void RecalcAutomaticData(nsIPresContext* aPresContext) = 0;
|
||||
|
||||
// Change the parent of the context, only to be used for
|
||||
// inserting or removing pseudo contexts
|
||||
virtual void ReParent(nsIStyleContext* aNewParentContext,
|
||||
nsIPresContext* aPresContext) = 0;
|
||||
|
||||
// debugging
|
||||
virtual void List(FILE* out, PRInt32 aIndent) = 0;
|
||||
};
|
||||
|
|
|
@ -161,6 +161,7 @@ static nscoord CalcSideFor(const nsIFrame* aFrame, const nsStyleCoord& aCoord,
|
|||
NS_RELEASE(parentContext);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case eStyleUnit_Percent:
|
||||
{
|
||||
|
@ -651,10 +652,14 @@ public:
|
|||
virtual void ForceUnique(void);
|
||||
virtual void RecalcAutomaticData(nsIPresContext* aPresContext);
|
||||
|
||||
virtual void ReParent(nsIStyleContext* aNewParentContext,
|
||||
nsIPresContext* aPresContext);
|
||||
|
||||
virtual void List(FILE* out, PRInt32 aIndent);
|
||||
|
||||
protected:
|
||||
void AppendChild(StyleContextImpl* aChild);
|
||||
void RemoveChild(StyleContextImpl* aChild);
|
||||
|
||||
StyleContextImpl* mParent;
|
||||
StyleContextImpl* mChild;
|
||||
|
@ -769,8 +774,6 @@ StyleContextImpl::~StyleContextImpl()
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef DEBUG_REFS
|
||||
NS_IMPL_QUERY_INTERFACE(StyleContextImpl, kIStyleContextIID)
|
||||
|
||||
|
@ -825,6 +828,48 @@ void StyleContextImpl::AppendChild(StyleContextImpl* aChild)
|
|||
NS_ADDREF(aChild);
|
||||
}
|
||||
|
||||
void StyleContextImpl::RemoveChild(StyleContextImpl* aChild)
|
||||
{
|
||||
NS_ASSERTION((nsnull != aChild) && (this == mChild->mParent), "bad argument");
|
||||
|
||||
if ((nsnull == aChild) || (this != mChild->mParent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mEmptyChild == aChild) {
|
||||
mEmptyChild = nsnull;
|
||||
}
|
||||
else {
|
||||
if (aChild->mPrevSibling != aChild) {
|
||||
if (mChild == aChild) {
|
||||
mChild = mChild->mNextSibling;
|
||||
}
|
||||
aChild->mPrevSibling->mNextSibling = aChild->mNextSibling;
|
||||
aChild->mNextSibling->mPrevSibling = aChild->mPrevSibling;
|
||||
aChild->mNextSibling = aChild;
|
||||
aChild->mPrevSibling = aChild;
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(mChild == aChild, "bad sibling pointers");
|
||||
if (mChild == aChild) {
|
||||
mChild = nsnull;
|
||||
}
|
||||
}
|
||||
}
|
||||
NS_RELEASE(aChild);
|
||||
}
|
||||
|
||||
void StyleContextImpl::ReParent(nsIStyleContext* aNewParentContext,
|
||||
nsIPresContext* aPresContext)
|
||||
{
|
||||
if (aNewParentContext != mParent) {
|
||||
mParent->RemoveChild(this);
|
||||
mParent = (StyleContextImpl*)aNewParentContext; // weak ref
|
||||
mParent->AppendChild(this);
|
||||
RemapStyle(aPresContext);
|
||||
}
|
||||
}
|
||||
|
||||
nsISupportsArray* StyleContextImpl::GetStyleRules(void) const
|
||||
{
|
||||
NS_IF_ADDREF(mRules);
|
||||
|
@ -1071,6 +1116,17 @@ StyleContextImpl::RemapStyle(nsIPresContext* aPresContext)
|
|||
mRules->EnumerateForwards(MapStyleRule, &data);
|
||||
}
|
||||
}
|
||||
|
||||
if (nsnull != mChild) {
|
||||
StyleContextImpl* child = mChild;
|
||||
do {
|
||||
child->RemapStyle(aPresContext);
|
||||
child = child->mNextSibling;
|
||||
} while (mChild != child);
|
||||
}
|
||||
if (nsnull != mEmptyChild) {
|
||||
mEmptyChild->RemapStyle(aPresContext);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -161,6 +161,7 @@ static nscoord CalcSideFor(const nsIFrame* aFrame, const nsStyleCoord& aCoord,
|
|||
NS_RELEASE(parentContext);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case eStyleUnit_Percent:
|
||||
{
|
||||
|
@ -651,10 +652,14 @@ public:
|
|||
virtual void ForceUnique(void);
|
||||
virtual void RecalcAutomaticData(nsIPresContext* aPresContext);
|
||||
|
||||
virtual void ReParent(nsIStyleContext* aNewParentContext,
|
||||
nsIPresContext* aPresContext);
|
||||
|
||||
virtual void List(FILE* out, PRInt32 aIndent);
|
||||
|
||||
protected:
|
||||
void AppendChild(StyleContextImpl* aChild);
|
||||
void RemoveChild(StyleContextImpl* aChild);
|
||||
|
||||
StyleContextImpl* mParent;
|
||||
StyleContextImpl* mChild;
|
||||
|
@ -769,8 +774,6 @@ StyleContextImpl::~StyleContextImpl()
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef DEBUG_REFS
|
||||
NS_IMPL_QUERY_INTERFACE(StyleContextImpl, kIStyleContextIID)
|
||||
|
||||
|
@ -825,6 +828,48 @@ void StyleContextImpl::AppendChild(StyleContextImpl* aChild)
|
|||
NS_ADDREF(aChild);
|
||||
}
|
||||
|
||||
void StyleContextImpl::RemoveChild(StyleContextImpl* aChild)
|
||||
{
|
||||
NS_ASSERTION((nsnull != aChild) && (this == mChild->mParent), "bad argument");
|
||||
|
||||
if ((nsnull == aChild) || (this != mChild->mParent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mEmptyChild == aChild) {
|
||||
mEmptyChild = nsnull;
|
||||
}
|
||||
else {
|
||||
if (aChild->mPrevSibling != aChild) {
|
||||
if (mChild == aChild) {
|
||||
mChild = mChild->mNextSibling;
|
||||
}
|
||||
aChild->mPrevSibling->mNextSibling = aChild->mNextSibling;
|
||||
aChild->mNextSibling->mPrevSibling = aChild->mPrevSibling;
|
||||
aChild->mNextSibling = aChild;
|
||||
aChild->mPrevSibling = aChild;
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(mChild == aChild, "bad sibling pointers");
|
||||
if (mChild == aChild) {
|
||||
mChild = nsnull;
|
||||
}
|
||||
}
|
||||
}
|
||||
NS_RELEASE(aChild);
|
||||
}
|
||||
|
||||
void StyleContextImpl::ReParent(nsIStyleContext* aNewParentContext,
|
||||
nsIPresContext* aPresContext)
|
||||
{
|
||||
if (aNewParentContext != mParent) {
|
||||
mParent->RemoveChild(this);
|
||||
mParent = (StyleContextImpl*)aNewParentContext; // weak ref
|
||||
mParent->AppendChild(this);
|
||||
RemapStyle(aPresContext);
|
||||
}
|
||||
}
|
||||
|
||||
nsISupportsArray* StyleContextImpl::GetStyleRules(void) const
|
||||
{
|
||||
NS_IF_ADDREF(mRules);
|
||||
|
@ -1071,6 +1116,17 @@ StyleContextImpl::RemapStyle(nsIPresContext* aPresContext)
|
|||
mRules->EnumerateForwards(MapStyleRule, &data);
|
||||
}
|
||||
}
|
||||
|
||||
if (nsnull != mChild) {
|
||||
StyleContextImpl* child = mChild;
|
||||
do {
|
||||
child->RemapStyle(aPresContext);
|
||||
child = child->mNextSibling;
|
||||
} while (mChild != child);
|
||||
}
|
||||
if (nsnull != mEmptyChild) {
|
||||
mEmptyChild->RemapStyle(aPresContext);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче