From 01519f58e25063bb5cc785df7c82bcbeddfa3a5b Mon Sep 17 00:00:00 2001 From: "kipp%netscape.com" Date: Thu, 4 Feb 1999 16:27:38 +0000 Subject: [PATCH] Avoid crashing when no frame is found during attribute change notifications git-svn-id: svn://10.0.0.236/trunk@19696 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/style/src/nsHTMLStyleSheet.cpp | 38 ++++++++++--------- .../html/style/src/nsHTMLStyleSheet.cpp | 38 ++++++++++--------- mozilla/layout/style/nsHTMLStyleSheet.cpp | 38 ++++++++++--------- 3 files changed, 63 insertions(+), 51 deletions(-) diff --git a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp index a4b11bd3bc1..299ce60ec47 100644 --- a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp @@ -4324,23 +4324,27 @@ HTMLStyleSheetImpl::AttributeChanged(nsIPresContext* aPresContext, RecreateFramesOnAttributeChange(aPresContext, aContent, aAttribute); } else if (PR_TRUE == restyle) { - nsIStyleContext* frameContext; - frame->GetStyleContext(frameContext); - NS_ASSERTION(nsnull != frameContext, "frame must have style context"); - if (nsnull != frameContext) { - nsIStyleContext* parentContext = frameContext->GetParent(); - frame->ReResolveStyleContext(aPresContext, parentContext); - NS_IF_RELEASE(parentContext); - NS_RELEASE(frameContext); - } - if (PR_TRUE == reflow) { - StyleChangeReflow(aPresContext, frame, aAttribute); - } - else if (PR_TRUE == render) { - ApplyRenderingChangeToTree(aPresContext, frame); - } - else { // let the frame deal with it, since we don't know how to - frame->AttributeChanged(aPresContext, aContent, aAttribute, aHint); + // If there is no frame then there is no point in re-styling it, + // is there? + if (nsnull != frame) { + nsIStyleContext* frameContext; + frame->GetStyleContext(frameContext); + NS_ASSERTION(nsnull != frameContext, "frame must have style context"); + if (nsnull != frameContext) { + nsIStyleContext* parentContext = frameContext->GetParent(); + frame->ReResolveStyleContext(aPresContext, parentContext); + NS_IF_RELEASE(parentContext); + NS_RELEASE(frameContext); + } + if (PR_TRUE == reflow) { + StyleChangeReflow(aPresContext, frame, aAttribute); + } + else if (PR_TRUE == render) { + ApplyRenderingChangeToTree(aPresContext, frame); + } + else { // let the frame deal with it, since we don't know how to + frame->AttributeChanged(aPresContext, aContent, aAttribute, aHint); + } } } diff --git a/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp b/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp index a4b11bd3bc1..299ce60ec47 100644 --- a/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp +++ b/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp @@ -4324,23 +4324,27 @@ HTMLStyleSheetImpl::AttributeChanged(nsIPresContext* aPresContext, RecreateFramesOnAttributeChange(aPresContext, aContent, aAttribute); } else if (PR_TRUE == restyle) { - nsIStyleContext* frameContext; - frame->GetStyleContext(frameContext); - NS_ASSERTION(nsnull != frameContext, "frame must have style context"); - if (nsnull != frameContext) { - nsIStyleContext* parentContext = frameContext->GetParent(); - frame->ReResolveStyleContext(aPresContext, parentContext); - NS_IF_RELEASE(parentContext); - NS_RELEASE(frameContext); - } - if (PR_TRUE == reflow) { - StyleChangeReflow(aPresContext, frame, aAttribute); - } - else if (PR_TRUE == render) { - ApplyRenderingChangeToTree(aPresContext, frame); - } - else { // let the frame deal with it, since we don't know how to - frame->AttributeChanged(aPresContext, aContent, aAttribute, aHint); + // If there is no frame then there is no point in re-styling it, + // is there? + if (nsnull != frame) { + nsIStyleContext* frameContext; + frame->GetStyleContext(frameContext); + NS_ASSERTION(nsnull != frameContext, "frame must have style context"); + if (nsnull != frameContext) { + nsIStyleContext* parentContext = frameContext->GetParent(); + frame->ReResolveStyleContext(aPresContext, parentContext); + NS_IF_RELEASE(parentContext); + NS_RELEASE(frameContext); + } + if (PR_TRUE == reflow) { + StyleChangeReflow(aPresContext, frame, aAttribute); + } + else if (PR_TRUE == render) { + ApplyRenderingChangeToTree(aPresContext, frame); + } + else { // let the frame deal with it, since we don't know how to + frame->AttributeChanged(aPresContext, aContent, aAttribute, aHint); + } } } diff --git a/mozilla/layout/style/nsHTMLStyleSheet.cpp b/mozilla/layout/style/nsHTMLStyleSheet.cpp index a4b11bd3bc1..299ce60ec47 100644 --- a/mozilla/layout/style/nsHTMLStyleSheet.cpp +++ b/mozilla/layout/style/nsHTMLStyleSheet.cpp @@ -4324,23 +4324,27 @@ HTMLStyleSheetImpl::AttributeChanged(nsIPresContext* aPresContext, RecreateFramesOnAttributeChange(aPresContext, aContent, aAttribute); } else if (PR_TRUE == restyle) { - nsIStyleContext* frameContext; - frame->GetStyleContext(frameContext); - NS_ASSERTION(nsnull != frameContext, "frame must have style context"); - if (nsnull != frameContext) { - nsIStyleContext* parentContext = frameContext->GetParent(); - frame->ReResolveStyleContext(aPresContext, parentContext); - NS_IF_RELEASE(parentContext); - NS_RELEASE(frameContext); - } - if (PR_TRUE == reflow) { - StyleChangeReflow(aPresContext, frame, aAttribute); - } - else if (PR_TRUE == render) { - ApplyRenderingChangeToTree(aPresContext, frame); - } - else { // let the frame deal with it, since we don't know how to - frame->AttributeChanged(aPresContext, aContent, aAttribute, aHint); + // If there is no frame then there is no point in re-styling it, + // is there? + if (nsnull != frame) { + nsIStyleContext* frameContext; + frame->GetStyleContext(frameContext); + NS_ASSERTION(nsnull != frameContext, "frame must have style context"); + if (nsnull != frameContext) { + nsIStyleContext* parentContext = frameContext->GetParent(); + frame->ReResolveStyleContext(aPresContext, parentContext); + NS_IF_RELEASE(parentContext); + NS_RELEASE(frameContext); + } + if (PR_TRUE == reflow) { + StyleChangeReflow(aPresContext, frame, aAttribute); + } + else if (PR_TRUE == render) { + ApplyRenderingChangeToTree(aPresContext, frame); + } + else { // let the frame deal with it, since we don't know how to + frame->AttributeChanged(aPresContext, aContent, aAttribute, aHint); + } } }