performance tweaks to apply style change

This commit is contained in:
peterl%netscape.com 1998-09-25 01:49:10 +00:00
Родитель 7aaa6f0444
Коммит 31f87234c8
2 изменённых файлов: 68 добавлений и 10 удалений

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

@ -493,23 +493,44 @@ nsHTMLContainerFrame::AttributeChanged(nsIPresShell* aShell,
return NS_OK;
}
static void
RemapStyleInTree(nsIPresContext* aPresContext,
nsIFrame* aFrame)
{
nsIStyleContext* sc;
aFrame->GetStyleContext(nsnull, sc);
if (nsnull != sc) {
sc->RemapStyle(aPresContext);
// Update the children too...
nsIFrame* kid;
aFrame->FirstChild(kid);
while (nsnull != kid) {
RemapStyleInTree(aPresContext, kid);
kid->GetNextSibling(kid);
}
}
}
void
nsHTMLContainerFrame::ApplyStyleChangeToTree(nsIPresContext& aPresContext,
nsIFrame* aFrame)
{
nsIContent* content;
nsIFrame* geometricParent;
nsIStyleContext* oldSC;
aFrame->GetGeometricParent(geometricParent);
aFrame->GetContent(content);
aFrame->GetStyleContext(&aPresContext, oldSC);
if (nsnull != content) {
PRBool onlyRemap = PR_FALSE;
nsIStyleContext* oldSC;
aFrame->GetStyleContext(nsnull, oldSC);
nsIStyleContext* newSC =
aPresContext.ResolveStyleContextFor(content, geometricParent);
if (newSC == oldSC) {
// Force cached style data to be recomputed
newSC->RemapStyle(&aPresContext);
onlyRemap = PR_TRUE;
}
else {
// Switch to new style context
@ -522,11 +543,19 @@ nsHTMLContainerFrame::ApplyStyleChangeToTree(nsIPresContext& aPresContext,
// Update the children too...
nsIFrame* kid;
aFrame->FirstChild(kid);
if (onlyRemap) {
while (nsnull != kid) {
RemapStyleInTree(&aPresContext, kid);
kid->GetNextSibling(kid);
}
}
else {
while (nsnull != kid) {
ApplyStyleChangeToTree(aPresContext, kid);
kid->GetNextSibling(kid);
}
}
}
}
void

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

@ -493,23 +493,44 @@ nsHTMLContainerFrame::AttributeChanged(nsIPresShell* aShell,
return NS_OK;
}
static void
RemapStyleInTree(nsIPresContext* aPresContext,
nsIFrame* aFrame)
{
nsIStyleContext* sc;
aFrame->GetStyleContext(nsnull, sc);
if (nsnull != sc) {
sc->RemapStyle(aPresContext);
// Update the children too...
nsIFrame* kid;
aFrame->FirstChild(kid);
while (nsnull != kid) {
RemapStyleInTree(aPresContext, kid);
kid->GetNextSibling(kid);
}
}
}
void
nsHTMLContainerFrame::ApplyStyleChangeToTree(nsIPresContext& aPresContext,
nsIFrame* aFrame)
{
nsIContent* content;
nsIFrame* geometricParent;
nsIStyleContext* oldSC;
aFrame->GetGeometricParent(geometricParent);
aFrame->GetContent(content);
aFrame->GetStyleContext(&aPresContext, oldSC);
if (nsnull != content) {
PRBool onlyRemap = PR_FALSE;
nsIStyleContext* oldSC;
aFrame->GetStyleContext(nsnull, oldSC);
nsIStyleContext* newSC =
aPresContext.ResolveStyleContextFor(content, geometricParent);
if (newSC == oldSC) {
// Force cached style data to be recomputed
newSC->RemapStyle(&aPresContext);
onlyRemap = PR_TRUE;
}
else {
// Switch to new style context
@ -522,11 +543,19 @@ nsHTMLContainerFrame::ApplyStyleChangeToTree(nsIPresContext& aPresContext,
// Update the children too...
nsIFrame* kid;
aFrame->FirstChild(kid);
if (onlyRemap) {
while (nsnull != kid) {
RemapStyleInTree(&aPresContext, kid);
kid->GetNextSibling(kid);
}
}
else {
while (nsnull != kid) {
ApplyStyleChangeToTree(aPresContext, kid);
kid->GetNextSibling(kid);
}
}
}
}
void