sync to style resolution api changes

added reresolve support
This commit is contained in:
peterl%netscape.com 1998-11-03 20:23:15 +00:00
Родитель d66e00cc37
Коммит bdb87c7e07
8 изменённых файлов: 136 добавлений и 20 удалений

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

@ -185,6 +185,25 @@ NS_METHOD nsContainerFrame::FirstChild(nsIFrame*& aFirstChild) const
return NS_OK;
}
/////////////////////////////////////////////////////////////////////////////
// Style support
NS_IMETHODIMP
nsContainerFrame::ReResolveStyleContext(nsIPresContext* aPresContext,
nsIStyleContext* aNewParentContext)
{
nsIStyleContext* oldContext = mStyleContext;
nsresult result = nsFrame::ReResolveStyleContext(aPresContext, aNewParentContext);
if (oldContext != mStyleContext) {
nsIFrame* child = mFirstChild;
while ((NS_SUCCEEDED(result)) && (nsnull != child)) {
result = child->ReResolveStyleContext(aPresContext, nsnull);
child->GetNextSibling(child);
}
}
return result;
}
/////////////////////////////////////////////////////////////////////////////
// Painting

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

@ -59,6 +59,11 @@ public:
// IndexOf() returns -1 if the frame is not in the child list.
NS_IMETHOD FirstChild(nsIFrame*& aFirstChild) const;
// re-resolve style context for self and children as necessary
// Subclasses need to override if they add child lists
NS_IMETHOD ReResolveStyleContext(nsIPresContext* aPresContext,
nsIStyleContext* aNewParentContext);
// Debugging
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0, nsIListFilter *aFilter = nsnull) const;
NS_IMETHOD VerifyTree() const;

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

@ -346,15 +346,9 @@ NS_IMETHODIMP nsFrame::GetContent(nsIContent*& aContent) const
return NS_OK;
}
NS_IMETHODIMP nsFrame::GetStyleContext(nsIPresContext* aPresContext,
nsIStyleContext*& aStyleContext)
NS_IMETHODIMP nsFrame::GetStyleContext(nsIStyleContext*& aStyleContext) const
{
if ((nsnull == mStyleContext) && (nsnull != aPresContext)) {
mStyleContext = aPresContext->ResolveStyleContextFor(mContent, mGeometricParent); // XXX should be content parent???
if (nsnull != mStyleContext) {
DidSetStyleContext(aPresContext);
}
}
NS_ASSERTION(nsnull != mStyleContext, "frame should always have style context");
NS_IF_ADDREF(mStyleContext);
aStyleContext = mStyleContext;
return NS_OK;
@ -392,6 +386,45 @@ NS_IMETHODIMP nsFrame::GetStyleData(nsStyleStructID aSID, const nsStyleStruct*&
return NS_OK;
}
NS_IMETHODIMP nsFrame::ReResolveStyleContext(nsIPresContext* aPresContext,
nsIStyleContext* aNewParentContext)
{
NS_ASSERTION(nsnull != mStyleContext, "null style context");
if (nsnull != mStyleContext) {
nsIAtom* pseudoTag = nsnull;
mStyleContext->GetPseudoType(pseudoTag);
nsIStyleContext* parent = aNewParentContext;
if (nsnull == aNewParentContext) {
parent = mStyleContext->GetParent();
}
nsIStyleContext* newContext;
if (nsnull != pseudoTag) {
newContext =
aPresContext->ResolvePseudoStyleContextFor(mContent, pseudoTag, parent);
}
else {
newContext = aPresContext->ResolveStyleContextFor(mContent, parent);
}
if (nsnull == aNewParentContext) {
NS_IF_RELEASE(parent);
}
NS_ASSERTION(nsnull != newContext, "failed to get new style context");
if (nsnull != newContext) {
if (newContext != mStyleContext) {
NS_RELEASE(mStyleContext);
mStyleContext = newContext;
DidSetStyleContext(aPresContext);
}
else {
NS_RELEASE(newContext);
mStyleContext->RemapStyle(aPresContext);
}
}
}
return NS_OK;
}
// Geometric and content parent member functions
NS_IMETHODIMP nsFrame::GetContentParent(nsIFrame*& aParent) const

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

@ -116,12 +116,13 @@ public:
NS_IMETHOD DeleteFrame(nsIPresContext& aPresContext);
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const;
NS_IMETHOD GetContent(nsIContent*& aContent) const;
NS_IMETHOD GetStyleContext(nsIPresContext* aContext,
nsIStyleContext*& aStyleContext);
NS_IMETHOD GetStyleContext(nsIStyleContext*& aStyleContext) const;
NS_IMETHOD SetStyleContext(nsIPresContext* aPresContext,
nsIStyleContext* aContext);
NS_IMETHOD GetStyleData(nsStyleStructID aSID,
const nsStyleStruct*& aStyleStruct) const;
NS_IMETHOD ReResolveStyleContext(nsIPresContext* aPresContext,
nsIStyleContext* aNewParentContext);
NS_IMETHOD GetContentParent(nsIFrame*& aParent) const;
NS_IMETHOD SetContentParent(const nsIFrame* aParent);
NS_IMETHOD GetGeometricParent(nsIFrame*& aParent) const;

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

@ -185,6 +185,25 @@ NS_METHOD nsContainerFrame::FirstChild(nsIFrame*& aFirstChild) const
return NS_OK;
}
/////////////////////////////////////////////////////////////////////////////
// Style support
NS_IMETHODIMP
nsContainerFrame::ReResolveStyleContext(nsIPresContext* aPresContext,
nsIStyleContext* aNewParentContext)
{
nsIStyleContext* oldContext = mStyleContext;
nsresult result = nsFrame::ReResolveStyleContext(aPresContext, aNewParentContext);
if (oldContext != mStyleContext) {
nsIFrame* child = mFirstChild;
while ((NS_SUCCEEDED(result)) && (nsnull != child)) {
result = child->ReResolveStyleContext(aPresContext, nsnull);
child->GetNextSibling(child);
}
}
return result;
}
/////////////////////////////////////////////////////////////////////////////
// Painting

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

@ -59,6 +59,11 @@ public:
// IndexOf() returns -1 if the frame is not in the child list.
NS_IMETHOD FirstChild(nsIFrame*& aFirstChild) const;
// re-resolve style context for self and children as necessary
// Subclasses need to override if they add child lists
NS_IMETHOD ReResolveStyleContext(nsIPresContext* aPresContext,
nsIStyleContext* aNewParentContext);
// Debugging
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0, nsIListFilter *aFilter = nsnull) const;
NS_IMETHOD VerifyTree() const;

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

@ -346,15 +346,9 @@ NS_IMETHODIMP nsFrame::GetContent(nsIContent*& aContent) const
return NS_OK;
}
NS_IMETHODIMP nsFrame::GetStyleContext(nsIPresContext* aPresContext,
nsIStyleContext*& aStyleContext)
NS_IMETHODIMP nsFrame::GetStyleContext(nsIStyleContext*& aStyleContext) const
{
if ((nsnull == mStyleContext) && (nsnull != aPresContext)) {
mStyleContext = aPresContext->ResolveStyleContextFor(mContent, mGeometricParent); // XXX should be content parent???
if (nsnull != mStyleContext) {
DidSetStyleContext(aPresContext);
}
}
NS_ASSERTION(nsnull != mStyleContext, "frame should always have style context");
NS_IF_ADDREF(mStyleContext);
aStyleContext = mStyleContext;
return NS_OK;
@ -392,6 +386,45 @@ NS_IMETHODIMP nsFrame::GetStyleData(nsStyleStructID aSID, const nsStyleStruct*&
return NS_OK;
}
NS_IMETHODIMP nsFrame::ReResolveStyleContext(nsIPresContext* aPresContext,
nsIStyleContext* aNewParentContext)
{
NS_ASSERTION(nsnull != mStyleContext, "null style context");
if (nsnull != mStyleContext) {
nsIAtom* pseudoTag = nsnull;
mStyleContext->GetPseudoType(pseudoTag);
nsIStyleContext* parent = aNewParentContext;
if (nsnull == aNewParentContext) {
parent = mStyleContext->GetParent();
}
nsIStyleContext* newContext;
if (nsnull != pseudoTag) {
newContext =
aPresContext->ResolvePseudoStyleContextFor(mContent, pseudoTag, parent);
}
else {
newContext = aPresContext->ResolveStyleContextFor(mContent, parent);
}
if (nsnull == aNewParentContext) {
NS_IF_RELEASE(parent);
}
NS_ASSERTION(nsnull != newContext, "failed to get new style context");
if (nsnull != newContext) {
if (newContext != mStyleContext) {
NS_RELEASE(mStyleContext);
mStyleContext = newContext;
DidSetStyleContext(aPresContext);
}
else {
NS_RELEASE(newContext);
mStyleContext->RemapStyle(aPresContext);
}
}
}
return NS_OK;
}
// Geometric and content parent member functions
NS_IMETHODIMP nsFrame::GetContentParent(nsIFrame*& aParent) const

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

@ -116,12 +116,13 @@ public:
NS_IMETHOD DeleteFrame(nsIPresContext& aPresContext);
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const;
NS_IMETHOD GetContent(nsIContent*& aContent) const;
NS_IMETHOD GetStyleContext(nsIPresContext* aContext,
nsIStyleContext*& aStyleContext);
NS_IMETHOD GetStyleContext(nsIStyleContext*& aStyleContext) const;
NS_IMETHOD SetStyleContext(nsIPresContext* aPresContext,
nsIStyleContext* aContext);
NS_IMETHOD GetStyleData(nsStyleStructID aSID,
const nsStyleStruct*& aStyleStruct) const;
NS_IMETHOD ReResolveStyleContext(nsIPresContext* aPresContext,
nsIStyleContext* aNewParentContext);
NS_IMETHOD GetContentParent(nsIFrame*& aParent) const;
NS_IMETHOD SetContentParent(const nsIFrame* aParent);
NS_IMETHOD GetGeometricParent(nsIFrame*& aParent) const;