From 71d538ea91cab26bd3e673ca9f836e539bef90cd Mon Sep 17 00:00:00 2001 From: "buster%netscape.com" Date: Thu, 24 Aug 2000 04:38:08 +0000 Subject: [PATCH] bug 49239 r=hyatt bug 42372 r=waterson git-svn-id: svn://10.0.0.236/trunk@77054 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsCSSFrameConstructor.cpp | 20 +++++++++++++------ mozilla/layout/generic/nsHTMLReflowState.cpp | 10 ++++++++-- .../html/base/src/nsHTMLReflowState.cpp | 10 ++++++++-- .../html/style/src/nsCSSFrameConstructor.cpp | 20 +++++++++++++------ 4 files changed, 44 insertions(+), 16 deletions(-) diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index fb41371ea9d..d030c163873 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -433,6 +433,15 @@ MoveChildrenTo(nsIPresContext* aPresContext, nsIFrame* aNewParent, nsIFrame* aFrameList) { + // when reparenting a frame, it would seem to be critical to also reparent any views associated with the frame + // I haven't found a case where this is required yet, but if we ever see a bug where the frame and + // view models are out of synch, particularly after a "special" block-in-inline situation is encountered, + // the following 3 lines of code would fix it. + /* + nsIFrame *oldParent; + aFrameList->GetParent(&oldParent); + nsHTMLContainerFrame::ReparentFrameViewList(aPresContext, aFrameList, oldParent, aNewParent); + */ while (aFrameList) { aFrameList->SetParent(aNewParent); aFrameList->GetNextSibling(&aFrameList); @@ -2402,12 +2411,10 @@ nsCSSFrameConstructor::GetParentFrame(nsIPresShell* aPresShell, // XXX can this go away? if (nsLayoutAtoms::tableFrame != parentFrameType.get()) { // trees allow row groups to contain row groups, so don't create pseudo frames - if (nsLayoutAtoms::tableRowGroupFrame == parentFrameType.get()) { // need pseudo table parent rv = GetPseudoTableFrame(aPresShell, aPresContext, aTableCreator, aState, aParentFrameIn); if (NS_FAILED(rv)) return rv; pseudoParentFrame = pseudoFrames.mTableInner.mFrame; - } - } + } } else if (nsLayoutAtoms::tableRowFrame == aChildFrameType) { // row child if (nsLayoutAtoms::tableRowGroupFrame != parentFrameType.get()) { // need pseudo row group parent @@ -8072,7 +8079,6 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext, // Get the frame associated with the content nsIFrame* parentFrame = GetFrameFor(shell, aPresContext, aContainer); if (nsnull != parentFrame) { - // If the frame we are manipulating is a special frame then do // something different instead of just appending newly created // frames. Note that only the first-in-flow is marked so we check @@ -12333,14 +12339,16 @@ nsCSSFrameConstructor::ConstructInline(nsIPresShell* aPresShell, InitAndRestoreFrame(aPresContext, aState, aContent, aParentFrame, aStyleContext, nsnull, aNewFrame); - if (aIsPositioned) { + nsFrameConstructorSaveState absoluteSaveState; // definition cannot be inside next block + // because the object's destructor is significant + // this is part of the fix for bug 42372 + if (aIsPositioned) { // Relatively positioned frames need a view nsHTMLContainerFrame::CreateViewForFrame(aPresContext, aNewFrame, aStyleContext, nsnull, PR_FALSE); // Relatively positioned frames becomes a container for child // frames that are positioned - nsFrameConstructorSaveState absoluteSaveState; aState.PushAbsoluteContainingBlock(aNewFrame, absoluteSaveState); } diff --git a/mozilla/layout/generic/nsHTMLReflowState.cpp b/mozilla/layout/generic/nsHTMLReflowState.cpp index ba6d2daa401..ada34bc3d3a 100644 --- a/mozilla/layout/generic/nsHTMLReflowState.cpp +++ b/mozilla/layout/generic/nsHTMLReflowState.cpp @@ -2240,8 +2240,14 @@ nsHTMLReflowState::ComputeVerticalValue(nscoord aContainingBlockHeight, // a height that's shrink wrapping to its content. In that case they should // treat the specified value like 'auto' NS_ASSERTION(NS_AUTOHEIGHT != aContainingBlockHeight, "unexpected containing block height"); - float pct = aCoord.GetPercentValue(); - aResult = NSToCoordFloor(aContainingBlockHeight * pct); + if (NS_AUTOHEIGHT!=aContainingBlockHeight) + { + float pct = aCoord.GetPercentValue(); + aResult = NSToCoordFloor(aContainingBlockHeight * pct); + } + else { // safest thing to do for an undefined height is to make it 0 + aResult = 0; + } } else if (eStyleUnit_Coord == aUnit) { aResult = aCoord.GetCoordValue(); diff --git a/mozilla/layout/html/base/src/nsHTMLReflowState.cpp b/mozilla/layout/html/base/src/nsHTMLReflowState.cpp index ba6d2daa401..ada34bc3d3a 100644 --- a/mozilla/layout/html/base/src/nsHTMLReflowState.cpp +++ b/mozilla/layout/html/base/src/nsHTMLReflowState.cpp @@ -2240,8 +2240,14 @@ nsHTMLReflowState::ComputeVerticalValue(nscoord aContainingBlockHeight, // a height that's shrink wrapping to its content. In that case they should // treat the specified value like 'auto' NS_ASSERTION(NS_AUTOHEIGHT != aContainingBlockHeight, "unexpected containing block height"); - float pct = aCoord.GetPercentValue(); - aResult = NSToCoordFloor(aContainingBlockHeight * pct); + if (NS_AUTOHEIGHT!=aContainingBlockHeight) + { + float pct = aCoord.GetPercentValue(); + aResult = NSToCoordFloor(aContainingBlockHeight * pct); + } + else { // safest thing to do for an undefined height is to make it 0 + aResult = 0; + } } else if (eStyleUnit_Coord == aUnit) { aResult = aCoord.GetCoordValue(); diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index fb41371ea9d..d030c163873 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -433,6 +433,15 @@ MoveChildrenTo(nsIPresContext* aPresContext, nsIFrame* aNewParent, nsIFrame* aFrameList) { + // when reparenting a frame, it would seem to be critical to also reparent any views associated with the frame + // I haven't found a case where this is required yet, but if we ever see a bug where the frame and + // view models are out of synch, particularly after a "special" block-in-inline situation is encountered, + // the following 3 lines of code would fix it. + /* + nsIFrame *oldParent; + aFrameList->GetParent(&oldParent); + nsHTMLContainerFrame::ReparentFrameViewList(aPresContext, aFrameList, oldParent, aNewParent); + */ while (aFrameList) { aFrameList->SetParent(aNewParent); aFrameList->GetNextSibling(&aFrameList); @@ -2402,12 +2411,10 @@ nsCSSFrameConstructor::GetParentFrame(nsIPresShell* aPresShell, // XXX can this go away? if (nsLayoutAtoms::tableFrame != parentFrameType.get()) { // trees allow row groups to contain row groups, so don't create pseudo frames - if (nsLayoutAtoms::tableRowGroupFrame == parentFrameType.get()) { // need pseudo table parent rv = GetPseudoTableFrame(aPresShell, aPresContext, aTableCreator, aState, aParentFrameIn); if (NS_FAILED(rv)) return rv; pseudoParentFrame = pseudoFrames.mTableInner.mFrame; - } - } + } } else if (nsLayoutAtoms::tableRowFrame == aChildFrameType) { // row child if (nsLayoutAtoms::tableRowGroupFrame != parentFrameType.get()) { // need pseudo row group parent @@ -8072,7 +8079,6 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext, // Get the frame associated with the content nsIFrame* parentFrame = GetFrameFor(shell, aPresContext, aContainer); if (nsnull != parentFrame) { - // If the frame we are manipulating is a special frame then do // something different instead of just appending newly created // frames. Note that only the first-in-flow is marked so we check @@ -12333,14 +12339,16 @@ nsCSSFrameConstructor::ConstructInline(nsIPresShell* aPresShell, InitAndRestoreFrame(aPresContext, aState, aContent, aParentFrame, aStyleContext, nsnull, aNewFrame); - if (aIsPositioned) { + nsFrameConstructorSaveState absoluteSaveState; // definition cannot be inside next block + // because the object's destructor is significant + // this is part of the fix for bug 42372 + if (aIsPositioned) { // Relatively positioned frames need a view nsHTMLContainerFrame::CreateViewForFrame(aPresContext, aNewFrame, aStyleContext, nsnull, PR_FALSE); // Relatively positioned frames becomes a container for child // frames that are positioned - nsFrameConstructorSaveState absoluteSaveState; aState.PushAbsoluteContainingBlock(aNewFrame, absoluteSaveState); }