Added ability to track changes to content without frame

Fix for bug 9013 (and any dynamic change from display:none) r=troy


git-svn-id: svn://10.0.0.236/trunk@49654 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
peterl%netscape.com
1999-10-02 04:26:53 +00:00
parent f47d01c612
commit 5da81c87c7
4 changed files with 32 additions and 34 deletions

View File

@@ -37,10 +37,12 @@ nsStyleChangeList::~nsStyleChangeList(void)
}
nsresult
nsStyleChangeList::ChangeAt(PRInt32 aIndex, nsIFrame*& aFrame, PRInt32& aHint) const
nsStyleChangeList::ChangeAt(PRInt32 aIndex, nsIFrame*& aFrame, nsIContent*& aContent,
PRInt32& aHint) const
{
if ((0 <= aIndex) && (aIndex < mCount)) {
aFrame = mArray[aIndex].mFrame;
aContent = mArray[aIndex].mContent;
aHint = mArray[aIndex].mHint;
return NS_OK;
}
@@ -48,29 +50,22 @@ nsStyleChangeList::ChangeAt(PRInt32 aIndex, nsIFrame*& aFrame, PRInt32& aHint) c
}
nsresult
nsStyleChangeList::AppendChange(nsIFrame* aFrame, PRInt32 aHint)
nsStyleChangeList::AppendChange(nsIFrame* aFrame, nsIContent* aContent, PRInt32 aHint)
{
NS_ASSERTION(aFrame, "must have frame");
NS_ASSERTION(aFrame || (aHint >= NS_STYLE_HINT_FRAMECHANGE), "must have frame");
if ((0 < mCount) && (NS_STYLE_HINT_FRAMECHANGE == aHint)) { // filter out all other changes for same content
nsIContent* changeContent;
aFrame->GetContent(&changeContent);
if (changeContent) {
if (aContent) {
PRInt32 index = mCount;
while (0 < index--) {
nsIContent* content;
mArray[index].mFrame->GetContent(&content);
if (content == changeContent) { // remove this change
if (aContent == mArray[index].mContent) { // remove this change
mCount--;
if (index < mCount) { // move later changes down
nsCRT::memcpy(&(mArray[index]), &(mArray[index + 1]),
(mCount - index) * sizeof(nsStyleChangeData));
}
}
NS_IF_RELEASE(content);
}
NS_RELEASE(changeContent);
}
}
@@ -97,6 +92,7 @@ nsStyleChangeList::AppendChange(nsIFrame* aFrame, PRInt32 aHint)
}
}
mArray[mCount].mFrame = aFrame;
mArray[mCount].mContent = aContent;
mArray[mCount].mHint = aHint;
mCount++;
}

View File

@@ -21,11 +21,13 @@
#include "nslayout.h"
#include "nsError.h"
class nsIFrame;
class nsIContent;
// XXX would all platforms support putting this inside the list?
struct nsStyleChangeData {
nsIFrame* mFrame;
PRInt32 mHint;
nsIFrame* mFrame;
nsIContent* mContent;
PRInt32 mHint;
};
static const PRUint32 kStyleChangeBufferSize = 10;
@@ -39,11 +41,12 @@ public:
return mCount;
}
nsresult ChangeAt(PRInt32 aIndex, nsIFrame*& aFrame, PRInt32& aHint) const;
nsresult ChangeAt(PRInt32 aIndex, nsIFrame*& aFrame, nsIContent*& aContent,
PRInt32& aHint) const;
nsresult AppendChange(nsIFrame* aFrame, PRInt32 aHint);
nsresult AppendChange(nsIFrame* aFrame, nsIContent* aContent, PRInt32 aHint);
void Clear();
void Clear(void);
protected:
nsStyleChangeList& operator=(const nsStyleChangeList& aCopy);

View File

@@ -21,11 +21,13 @@
#include "nslayout.h"
#include "nsError.h"
class nsIFrame;
class nsIContent;
// XXX would all platforms support putting this inside the list?
struct nsStyleChangeData {
nsIFrame* mFrame;
PRInt32 mHint;
nsIFrame* mFrame;
nsIContent* mContent;
PRInt32 mHint;
};
static const PRUint32 kStyleChangeBufferSize = 10;
@@ -39,11 +41,12 @@ public:
return mCount;
}
nsresult ChangeAt(PRInt32 aIndex, nsIFrame*& aFrame, PRInt32& aHint) const;
nsresult ChangeAt(PRInt32 aIndex, nsIFrame*& aFrame, nsIContent*& aContent,
PRInt32& aHint) const;
nsresult AppendChange(nsIFrame* aFrame, PRInt32 aHint);
nsresult AppendChange(nsIFrame* aFrame, nsIContent* aContent, PRInt32 aHint);
void Clear();
void Clear(void);
protected:
nsStyleChangeList& operator=(const nsStyleChangeList& aCopy);

View File

@@ -37,10 +37,12 @@ nsStyleChangeList::~nsStyleChangeList(void)
}
nsresult
nsStyleChangeList::ChangeAt(PRInt32 aIndex, nsIFrame*& aFrame, PRInt32& aHint) const
nsStyleChangeList::ChangeAt(PRInt32 aIndex, nsIFrame*& aFrame, nsIContent*& aContent,
PRInt32& aHint) const
{
if ((0 <= aIndex) && (aIndex < mCount)) {
aFrame = mArray[aIndex].mFrame;
aContent = mArray[aIndex].mContent;
aHint = mArray[aIndex].mHint;
return NS_OK;
}
@@ -48,29 +50,22 @@ nsStyleChangeList::ChangeAt(PRInt32 aIndex, nsIFrame*& aFrame, PRInt32& aHint) c
}
nsresult
nsStyleChangeList::AppendChange(nsIFrame* aFrame, PRInt32 aHint)
nsStyleChangeList::AppendChange(nsIFrame* aFrame, nsIContent* aContent, PRInt32 aHint)
{
NS_ASSERTION(aFrame, "must have frame");
NS_ASSERTION(aFrame || (aHint >= NS_STYLE_HINT_FRAMECHANGE), "must have frame");
if ((0 < mCount) && (NS_STYLE_HINT_FRAMECHANGE == aHint)) { // filter out all other changes for same content
nsIContent* changeContent;
aFrame->GetContent(&changeContent);
if (changeContent) {
if (aContent) {
PRInt32 index = mCount;
while (0 < index--) {
nsIContent* content;
mArray[index].mFrame->GetContent(&content);
if (content == changeContent) { // remove this change
if (aContent == mArray[index].mContent) { // remove this change
mCount--;
if (index < mCount) { // move later changes down
nsCRT::memcpy(&(mArray[index]), &(mArray[index + 1]),
(mCount - index) * sizeof(nsStyleChangeData));
}
}
NS_IF_RELEASE(content);
}
NS_RELEASE(changeContent);
}
}
@@ -97,6 +92,7 @@ nsStyleChangeList::AppendChange(nsIFrame* aFrame, PRInt32 aHint)
}
}
mArray[mCount].mFrame = aFrame;
mArray[mCount].mContent = aContent;
mArray[mCount].mHint = aHint;
mCount++;
}