mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-31 22:25:30 +00:00
performance tweaks to apply style change
This commit is contained in:
parent
7aaa6f0444
commit
31f87234c8
@ -493,23 +493,44 @@ nsHTMLContainerFrame::AttributeChanged(nsIPresShell* aShell,
|
|||||||
return NS_OK;
|
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
|
void
|
||||||
nsHTMLContainerFrame::ApplyStyleChangeToTree(nsIPresContext& aPresContext,
|
nsHTMLContainerFrame::ApplyStyleChangeToTree(nsIPresContext& aPresContext,
|
||||||
nsIFrame* aFrame)
|
nsIFrame* aFrame)
|
||||||
{
|
{
|
||||||
nsIContent* content;
|
nsIContent* content;
|
||||||
nsIFrame* geometricParent;
|
nsIFrame* geometricParent;
|
||||||
nsIStyleContext* oldSC;
|
|
||||||
aFrame->GetGeometricParent(geometricParent);
|
aFrame->GetGeometricParent(geometricParent);
|
||||||
aFrame->GetContent(content);
|
aFrame->GetContent(content);
|
||||||
aFrame->GetStyleContext(&aPresContext, oldSC);
|
|
||||||
|
|
||||||
if (nsnull != content) {
|
if (nsnull != content) {
|
||||||
|
PRBool onlyRemap = PR_FALSE;
|
||||||
|
nsIStyleContext* oldSC;
|
||||||
|
aFrame->GetStyleContext(nsnull, oldSC);
|
||||||
nsIStyleContext* newSC =
|
nsIStyleContext* newSC =
|
||||||
aPresContext.ResolveStyleContextFor(content, geometricParent);
|
aPresContext.ResolveStyleContextFor(content, geometricParent);
|
||||||
if (newSC == oldSC) {
|
if (newSC == oldSC) {
|
||||||
// Force cached style data to be recomputed
|
// Force cached style data to be recomputed
|
||||||
newSC->RemapStyle(&aPresContext);
|
newSC->RemapStyle(&aPresContext);
|
||||||
|
onlyRemap = PR_TRUE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Switch to new style context
|
// Switch to new style context
|
||||||
@ -522,9 +543,17 @@ nsHTMLContainerFrame::ApplyStyleChangeToTree(nsIPresContext& aPresContext,
|
|||||||
// Update the children too...
|
// Update the children too...
|
||||||
nsIFrame* kid;
|
nsIFrame* kid;
|
||||||
aFrame->FirstChild(kid);
|
aFrame->FirstChild(kid);
|
||||||
while (nsnull != kid) {
|
if (onlyRemap) {
|
||||||
ApplyStyleChangeToTree(aPresContext, kid);
|
while (nsnull != kid) {
|
||||||
kid->GetNextSibling(kid);
|
RemapStyleInTree(&aPresContext, kid);
|
||||||
|
kid->GetNextSibling(kid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
while (nsnull != kid) {
|
||||||
|
ApplyStyleChangeToTree(aPresContext, kid);
|
||||||
|
kid->GetNextSibling(kid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -493,23 +493,44 @@ nsHTMLContainerFrame::AttributeChanged(nsIPresShell* aShell,
|
|||||||
return NS_OK;
|
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
|
void
|
||||||
nsHTMLContainerFrame::ApplyStyleChangeToTree(nsIPresContext& aPresContext,
|
nsHTMLContainerFrame::ApplyStyleChangeToTree(nsIPresContext& aPresContext,
|
||||||
nsIFrame* aFrame)
|
nsIFrame* aFrame)
|
||||||
{
|
{
|
||||||
nsIContent* content;
|
nsIContent* content;
|
||||||
nsIFrame* geometricParent;
|
nsIFrame* geometricParent;
|
||||||
nsIStyleContext* oldSC;
|
|
||||||
aFrame->GetGeometricParent(geometricParent);
|
aFrame->GetGeometricParent(geometricParent);
|
||||||
aFrame->GetContent(content);
|
aFrame->GetContent(content);
|
||||||
aFrame->GetStyleContext(&aPresContext, oldSC);
|
|
||||||
|
|
||||||
if (nsnull != content) {
|
if (nsnull != content) {
|
||||||
|
PRBool onlyRemap = PR_FALSE;
|
||||||
|
nsIStyleContext* oldSC;
|
||||||
|
aFrame->GetStyleContext(nsnull, oldSC);
|
||||||
nsIStyleContext* newSC =
|
nsIStyleContext* newSC =
|
||||||
aPresContext.ResolveStyleContextFor(content, geometricParent);
|
aPresContext.ResolveStyleContextFor(content, geometricParent);
|
||||||
if (newSC == oldSC) {
|
if (newSC == oldSC) {
|
||||||
// Force cached style data to be recomputed
|
// Force cached style data to be recomputed
|
||||||
newSC->RemapStyle(&aPresContext);
|
newSC->RemapStyle(&aPresContext);
|
||||||
|
onlyRemap = PR_TRUE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Switch to new style context
|
// Switch to new style context
|
||||||
@ -522,9 +543,17 @@ nsHTMLContainerFrame::ApplyStyleChangeToTree(nsIPresContext& aPresContext,
|
|||||||
// Update the children too...
|
// Update the children too...
|
||||||
nsIFrame* kid;
|
nsIFrame* kid;
|
||||||
aFrame->FirstChild(kid);
|
aFrame->FirstChild(kid);
|
||||||
while (nsnull != kid) {
|
if (onlyRemap) {
|
||||||
ApplyStyleChangeToTree(aPresContext, kid);
|
while (nsnull != kid) {
|
||||||
kid->GetNextSibling(kid);
|
RemapStyleInTree(&aPresContext, kid);
|
||||||
|
kid->GetNextSibling(kid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
while (nsnull != kid) {
|
||||||
|
ApplyStyleChangeToTree(aPresContext, kid);
|
||||||
|
kid->GetNextSibling(kid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user