From e045387a835d1a39ad1b5269faa6be8b288611c0 Mon Sep 17 00:00:00 2001 From: "shaver%mozilla.org" Date: Sun, 10 Mar 2002 06:16:01 +0000 Subject: [PATCH] reversion of patch for 92868, to repair severe regression (129827, a=drivers git-svn-id: svn://10.0.0.236/trunk@116295 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsCSSFrameConstructor.cpp | 16 ++-- mozilla/layout/base/nsFrameManager.cpp | 86 +++++++++---------- mozilla/layout/base/public/nsIFrame.h | 25 ++++-- mozilla/layout/generic/nsFrame.cpp | 8 +- mozilla/layout/generic/nsFrame.h | 13 +-- mozilla/layout/generic/nsIFrame.h | 25 ++++-- mozilla/layout/html/base/src/nsFrame.cpp | 8 +- mozilla/layout/html/base/src/nsFrame.h | 13 +-- .../layout/html/base/src/nsFrameManager.cpp | 86 +++++++++---------- .../html/style/src/nsCSSFrameConstructor.cpp | 16 ++-- .../layout/html/table/src/nsTableFrame.cpp | 33 +++++++ mozilla/layout/html/table/src/nsTableFrame.h | 4 + .../html/table/src/nsTableOuterFrame.cpp | 21 +++-- .../layout/html/table/src/nsTableOuterFrame.h | 5 +- mozilla/layout/tables/nsTableFrame.cpp | 33 +++++++ mozilla/layout/tables/nsTableFrame.h | 4 + mozilla/layout/tables/nsTableOuterFrame.cpp | 21 +++-- mozilla/layout/tables/nsTableOuterFrame.h | 5 +- 18 files changed, 252 insertions(+), 170 deletions(-) diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index f008645272a..71bafd01404 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -10270,15 +10270,9 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext, nsCOMPtr shell; aPresContext->GetShell(getter_AddRefs(shell)); - - // Get the frame associated with the content which is the highest in the frame tree - nsIFrame* primaryFrame; - shell->GetPrimaryFrameFor(aContent, &primaryFrame); - // Get the frame associated with the content whose style context is highest in the style context tree - nsIFrame* primaryStyleFrame = nsnull; - if (primaryFrame) { - primaryFrame->GetStyleContextProvider(aPresContext, &primaryStyleFrame); - } + nsIFrame* primaryFrame; + + shell->GetPrimaryFrameFor(aContent, &primaryFrame); PRBool reconstruct = PR_FALSE; PRBool restyle = PR_FALSE; @@ -10370,8 +10364,8 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext, // This style rule exists and we need to blow away any computed data that this // rule cached in the rule tree. rule = getter_AddRefs((nsIStyleRule*)val.GetISupportsValue()); - if (primaryStyleFrame) - primaryStyleFrame->GetStyleContext(getter_AddRefs(styleContext)); + if (primaryFrame) + primaryFrame->GetStyleContext(getter_AddRefs(styleContext)); else { // We might be in the undisplayed map. Retrieve the style context from there. nsCOMPtr frameManager; diff --git a/mozilla/layout/base/nsFrameManager.cpp b/mozilla/layout/base/nsFrameManager.cpp index 3c5216ca4d9..ff914375c9c 100644 --- a/mozilla/layout/base/nsFrameManager.cpp +++ b/mozilla/layout/base/nsFrameManager.cpp @@ -1271,11 +1271,13 @@ VerifyContextParent(nsIPresContext* aPresContext, nsIFrame* aFrame, } else { // get the parent context from the frame (indirectly) nsIFrame* providerFrame = nsnull; - aFrame->GetStyleContextProvider(aPresContext, &providerFrame); ENSURE_TRUE(providerFrame); - nsCOMPtr providerContext; - providerFrame->GetStyleContext(getter_AddRefs(providerContext)); ENSURE_TRUE(providerContext); - aParentContext = providerContext->GetParent(); // released later - // aParentContext could still be null, since some contexts don't have parents + nsContextProviderRelationship relationship; + aFrame->GetParentStyleContextProvider(aPresContext,&providerFrame,relationship); + if (providerFrame) { + providerFrame->GetStyleContext(&aParentContext); + } else { + // no parent context provider: it is OK, some frames' contexts do not have parents + } } NS_IF_RELEASE(frameType); } else { @@ -1678,7 +1680,7 @@ CaptureChange(nsIStyleContext* aOldContext, nsIStyleContext* aNewContext, void FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aParentContextIn, + nsIStyleContext* aParentContext, nsIContent* aParentContent, PRInt32 aAttrNameSpaceID, nsIAtom* aAttribute, @@ -1686,6 +1688,8 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, PRInt32 aMinChange, PRInt32& aResultChange) { + nsIFrame *resolvedDescendant = nsnull; + nsIStyleContext* oldContext = nsnull; nsresult result = aFrame->GetStyleContext(&oldContext); if (NS_SUCCEEDED(result) && oldContext) { @@ -1708,46 +1712,42 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, } } - nsIStyleContext* parentContext = aParentContextIn; - nsIFrame* resolvedDescendant = nsnull; - // Get the frame providing the style context. If it differs from aFrame, then - // reslove the provider first, since the provider's context is the parent of aFrame's - nsIFrame* providerFrame = nsnull; - aFrame->GetStyleContextProvider(aPresContext, &providerFrame); ENSURE_TRUE(providerFrame); - if (providerFrame == aFrame) { - if (parentContext) { - // addref the parent since it gets released later - NS_ADDREF(parentContext); - NOISY_TRACE_FRAME("non-null parent context provided: using it and assuming already resolved",aFrame); - } else { - nsCOMPtr frameContext; - aFrame->GetStyleContext(getter_AddRefs(frameContext)); ENSURE_TRUE(frameContext); - parentContext = frameContext->GetParent(); /* released later */ ENSURE_TRUE(parentContext); + if (aParentContext == nsnull) { + NOISY_TRACE_FRAME("null parent context in ReResolveStyle: getting provider frame for",aFrame); + // get the parent context from the frame (indirectly) + nsIFrame* providerFrame = nsnull; + nsContextProviderRelationship relationship; + aFrame->GetParentStyleContextProvider(aPresContext,&providerFrame,relationship); + if (providerFrame) { + NOISY_TRACE("provider frame retrieved in ReResolveStyle: "); + + // see if we need to recurse and resolve the provider frame first + if (relationship != eContextProvider_Ancestor) { + NOISY_TRACE("non-ancestor provider, recursing.\n"); + // provider is not an ancestor, so assume we have to reresolve it first + ReResolveStyleContext(aPresContext, providerFrame, nsnull, content, + aAttrNameSpaceID, aAttribute, + aChangeList, aMinChange, aResultChange); + resolvedDescendant = providerFrame; + NOISY_TRACE("returned from recursion, descendant parent context provider resolved.\n"); + } else { + NOISY_TRACE("ancestor provider, assuming already resolved.\n"); + } + providerFrame->GetStyleContext(&aParentContext); } - } - else { - nsIFrame* providerFrameParent; - providerFrame->GetParent(&providerFrameParent); ENSURE_TRUE(providerFrameParent); - NS_ASSERTION(providerFrameParent == aFrame, "invalid style context provider"); - // resolve the provider first - nsCOMPtr providerContext; - providerFrame->GetStyleContext(getter_AddRefs(providerContext)); ENSURE_TRUE(providerContext); - nsIStyleContext* providerContextParent = providerContext->GetParent(); ENSURE_TRUE(providerContextParent); - ReResolveStyleContext(aPresContext, providerFrame, providerContextParent, content, - aAttrNameSpaceID, aAttribute, aChangeList, aMinChange, aResultChange); - NS_RELEASE(providerContextParent); - // the provider's new context becomes the parent context of aFrame's context - providerFrame->GetStyleContext(&parentContext); /* released later */ ENSURE_TRUE(parentContext); - resolvedDescendant = providerFrame; // don't want to re-resolve the provider again + } else { + // addref the parent passed in so we can release it at the end + NS_ADDREF(aParentContext); + NOISY_TRACE_FRAME("non-null parent context provided: using it and assuming already resolved",aFrame); } // do primary context nsIStyleContext* newContext = nsnull; if (pseudoTag) { nsIContent* pseudoContent = (aParentContent ? aParentContent : localContent); - aPresContext->ResolvePseudoStyleContextFor(pseudoContent, pseudoTag, parentContext, PR_FALSE, - &newContext); - NS_RELEASE(pseudoTag); + aPresContext->ResolvePseudoStyleContextFor(pseudoContent, pseudoTag, aParentContext, PR_FALSE, + &newContext); + NS_RELEASE(pseudoTag); } else { NS_ASSERTION(localContent, @@ -1763,10 +1763,10 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, aFrame->GetFrameType(getter_AddRefs(frameType)); if (content->IsContentOfType(nsIContent::eELEMENT) && frameType != nsLayoutAtoms::placeholderFrame) { - aPresContext->ResolveStyleContextFor(content, parentContext, + aPresContext->ResolveStyleContextFor(content, aParentContext, PR_TRUE, &newContext); } else { - aPresContext->ResolveStyleContextForNonElement(parentContext, + aPresContext->ResolveStyleContextForNonElement(aParentContext, PR_TRUE, &newContext); } } @@ -1922,7 +1922,7 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, } else { // regular child frame if (child != resolvedDescendant) { - ReResolveStyleContext(aPresContext, child, newContext, content, + ReResolveStyleContext(aPresContext, child, nsnull, content, aAttrNameSpaceID, aAttribute, aChangeList, aMinChange, childChange); } else { @@ -1941,7 +1941,7 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, NS_RELEASE(newContext); NS_IF_RELEASE(localContent); - NS_IF_RELEASE(parentContext); + NS_IF_RELEASE(aParentContext); } } diff --git a/mozilla/layout/base/public/nsIFrame.h b/mozilla/layout/base/public/nsIFrame.h index f63190ea372..548fce53cd0 100644 --- a/mozilla/layout/base/public/nsIFrame.h +++ b/mozilla/layout/base/public/nsIFrame.h @@ -1096,15 +1096,26 @@ public: PRBool aCommandAdded) = 0; /** - * Get the frame that is the primary frame associated with the content. - * aProviderFrame == aFrame except in the case of an outer table, in - * which case it is the inner table. + * Called in style ReResolution to get the frame that contains the style context that is the + * parent style context for this frame. + * @param aProviderFrame: set to the frame who's style context is to be used as the parent context + * in reresolving style for this frame. Note that this may or may not be the + * parent frame of this frame. + * @param aRelatioship : indicates how the provider frame relates to this frame: + * i.e. if the parent context provider frame is a child of this frame, + * then aRelationship must be set to eContextProvider_Descendant, + * if a parent, grandparent etc. set to eContextProvider_Ancestor + * (this is used to control recursion in style reresolution) * - * @param aPresContext: PresContext - * @param aProviderFrame: Set to the primary frame associated with the content + * if return value is NS_OK then aProvdierFrame must be set, otherwise it is ignored. + * + * PRECONDITIONS: aProviderFrame cannot be null + * POSTCONDITIONS: *aProfiderFrame will be a valid frame if this routine succeeds + * aRelationship will be set to a legal enum value indicating the correct relationship */ - NS_IMETHOD GetStyleContextProvider(nsIPresContext* aPresContext, - nsIFrame** aProviderFrame) = 0; + NS_IMETHOD GetParentStyleContextProvider(nsIPresContext* aPresContext, + nsIFrame** aProviderFrame, + nsContextProviderRelationship& aRelationship) = 0; /** * Determines whether a frame is visible for painting diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index db605d7c33d..add391788c3 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -3994,13 +3994,15 @@ nsFrame::ReflowCommandNotify(nsIPresShell* aShell, } NS_IMETHODIMP -nsFrame::GetStyleContextProvider(nsIPresContext* aPresContext, - nsIFrame** aProviderFrame) +nsFrame::GetParentStyleContextProvider(nsIPresContext* aPresContext, + nsIFrame** aProviderFrame, + nsContextProviderRelationship& aRelationship) { NS_ASSERTION(aPresContext && aProviderFrame, "null arguments: aPresContext and-or aProviderFrame"); if (aProviderFrame) { // parent context provider is the parent frame by default - *aProviderFrame = this; + *aProviderFrame = mParent; + aRelationship = eContextProvider_Ancestor; } return ((aProviderFrame != nsnull) && (*aProviderFrame != nsnull)) ? NS_OK : NS_ERROR_FAILURE; } diff --git a/mozilla/layout/generic/nsFrame.h b/mozilla/layout/generic/nsFrame.h index 0e602fb51ae..f2b52479b2d 100644 --- a/mozilla/layout/generic/nsFrame.h +++ b/mozilla/layout/generic/nsFrame.h @@ -282,8 +282,9 @@ public: NS_IMETHOD GetAccessible(nsIAccessible** aAccessible); #endif - NS_IMETHOD GetStyleContextProvider(nsIPresContext* aPresContext, - nsIFrame** aProviderFrame); + NS_IMETHOD GetParentStyleContextProvider(nsIPresContext* aPresContext, + nsIFrame** aProviderFrame, + nsContextProviderRelationship& aRelationship); // Check Style Visibility and mState for Selection (when printing) NS_IMETHOD IsVisibleForPainting(nsIPresContext * aPresContext, @@ -527,12 +528,4 @@ protected: #endif // End Display Reflow Debugging -// similar to NS_ENSURE_TRUE but with no return value -#define ENSURE_TRUE(x) \ - PR_BEGIN_MACRO \ - if (!(x)) { \ - NS_WARNING("ENSURE_TRUE(" #x ") failed"); \ - return; \ - } \ - PR_END_MACRO #endif /* nsFrame_h___ */ diff --git a/mozilla/layout/generic/nsIFrame.h b/mozilla/layout/generic/nsIFrame.h index f63190ea372..548fce53cd0 100644 --- a/mozilla/layout/generic/nsIFrame.h +++ b/mozilla/layout/generic/nsIFrame.h @@ -1096,15 +1096,26 @@ public: PRBool aCommandAdded) = 0; /** - * Get the frame that is the primary frame associated with the content. - * aProviderFrame == aFrame except in the case of an outer table, in - * which case it is the inner table. + * Called in style ReResolution to get the frame that contains the style context that is the + * parent style context for this frame. + * @param aProviderFrame: set to the frame who's style context is to be used as the parent context + * in reresolving style for this frame. Note that this may or may not be the + * parent frame of this frame. + * @param aRelatioship : indicates how the provider frame relates to this frame: + * i.e. if the parent context provider frame is a child of this frame, + * then aRelationship must be set to eContextProvider_Descendant, + * if a parent, grandparent etc. set to eContextProvider_Ancestor + * (this is used to control recursion in style reresolution) * - * @param aPresContext: PresContext - * @param aProviderFrame: Set to the primary frame associated with the content + * if return value is NS_OK then aProvdierFrame must be set, otherwise it is ignored. + * + * PRECONDITIONS: aProviderFrame cannot be null + * POSTCONDITIONS: *aProfiderFrame will be a valid frame if this routine succeeds + * aRelationship will be set to a legal enum value indicating the correct relationship */ - NS_IMETHOD GetStyleContextProvider(nsIPresContext* aPresContext, - nsIFrame** aProviderFrame) = 0; + NS_IMETHOD GetParentStyleContextProvider(nsIPresContext* aPresContext, + nsIFrame** aProviderFrame, + nsContextProviderRelationship& aRelationship) = 0; /** * Determines whether a frame is visible for painting diff --git a/mozilla/layout/html/base/src/nsFrame.cpp b/mozilla/layout/html/base/src/nsFrame.cpp index db605d7c33d..add391788c3 100644 --- a/mozilla/layout/html/base/src/nsFrame.cpp +++ b/mozilla/layout/html/base/src/nsFrame.cpp @@ -3994,13 +3994,15 @@ nsFrame::ReflowCommandNotify(nsIPresShell* aShell, } NS_IMETHODIMP -nsFrame::GetStyleContextProvider(nsIPresContext* aPresContext, - nsIFrame** aProviderFrame) +nsFrame::GetParentStyleContextProvider(nsIPresContext* aPresContext, + nsIFrame** aProviderFrame, + nsContextProviderRelationship& aRelationship) { NS_ASSERTION(aPresContext && aProviderFrame, "null arguments: aPresContext and-or aProviderFrame"); if (aProviderFrame) { // parent context provider is the parent frame by default - *aProviderFrame = this; + *aProviderFrame = mParent; + aRelationship = eContextProvider_Ancestor; } return ((aProviderFrame != nsnull) && (*aProviderFrame != nsnull)) ? NS_OK : NS_ERROR_FAILURE; } diff --git a/mozilla/layout/html/base/src/nsFrame.h b/mozilla/layout/html/base/src/nsFrame.h index 0e602fb51ae..f2b52479b2d 100644 --- a/mozilla/layout/html/base/src/nsFrame.h +++ b/mozilla/layout/html/base/src/nsFrame.h @@ -282,8 +282,9 @@ public: NS_IMETHOD GetAccessible(nsIAccessible** aAccessible); #endif - NS_IMETHOD GetStyleContextProvider(nsIPresContext* aPresContext, - nsIFrame** aProviderFrame); + NS_IMETHOD GetParentStyleContextProvider(nsIPresContext* aPresContext, + nsIFrame** aProviderFrame, + nsContextProviderRelationship& aRelationship); // Check Style Visibility and mState for Selection (when printing) NS_IMETHOD IsVisibleForPainting(nsIPresContext * aPresContext, @@ -527,12 +528,4 @@ protected: #endif // End Display Reflow Debugging -// similar to NS_ENSURE_TRUE but with no return value -#define ENSURE_TRUE(x) \ - PR_BEGIN_MACRO \ - if (!(x)) { \ - NS_WARNING("ENSURE_TRUE(" #x ") failed"); \ - return; \ - } \ - PR_END_MACRO #endif /* nsFrame_h___ */ diff --git a/mozilla/layout/html/base/src/nsFrameManager.cpp b/mozilla/layout/html/base/src/nsFrameManager.cpp index 3c5216ca4d9..ff914375c9c 100644 --- a/mozilla/layout/html/base/src/nsFrameManager.cpp +++ b/mozilla/layout/html/base/src/nsFrameManager.cpp @@ -1271,11 +1271,13 @@ VerifyContextParent(nsIPresContext* aPresContext, nsIFrame* aFrame, } else { // get the parent context from the frame (indirectly) nsIFrame* providerFrame = nsnull; - aFrame->GetStyleContextProvider(aPresContext, &providerFrame); ENSURE_TRUE(providerFrame); - nsCOMPtr providerContext; - providerFrame->GetStyleContext(getter_AddRefs(providerContext)); ENSURE_TRUE(providerContext); - aParentContext = providerContext->GetParent(); // released later - // aParentContext could still be null, since some contexts don't have parents + nsContextProviderRelationship relationship; + aFrame->GetParentStyleContextProvider(aPresContext,&providerFrame,relationship); + if (providerFrame) { + providerFrame->GetStyleContext(&aParentContext); + } else { + // no parent context provider: it is OK, some frames' contexts do not have parents + } } NS_IF_RELEASE(frameType); } else { @@ -1678,7 +1680,7 @@ CaptureChange(nsIStyleContext* aOldContext, nsIStyleContext* aNewContext, void FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aParentContextIn, + nsIStyleContext* aParentContext, nsIContent* aParentContent, PRInt32 aAttrNameSpaceID, nsIAtom* aAttribute, @@ -1686,6 +1688,8 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, PRInt32 aMinChange, PRInt32& aResultChange) { + nsIFrame *resolvedDescendant = nsnull; + nsIStyleContext* oldContext = nsnull; nsresult result = aFrame->GetStyleContext(&oldContext); if (NS_SUCCEEDED(result) && oldContext) { @@ -1708,46 +1712,42 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, } } - nsIStyleContext* parentContext = aParentContextIn; - nsIFrame* resolvedDescendant = nsnull; - // Get the frame providing the style context. If it differs from aFrame, then - // reslove the provider first, since the provider's context is the parent of aFrame's - nsIFrame* providerFrame = nsnull; - aFrame->GetStyleContextProvider(aPresContext, &providerFrame); ENSURE_TRUE(providerFrame); - if (providerFrame == aFrame) { - if (parentContext) { - // addref the parent since it gets released later - NS_ADDREF(parentContext); - NOISY_TRACE_FRAME("non-null parent context provided: using it and assuming already resolved",aFrame); - } else { - nsCOMPtr frameContext; - aFrame->GetStyleContext(getter_AddRefs(frameContext)); ENSURE_TRUE(frameContext); - parentContext = frameContext->GetParent(); /* released later */ ENSURE_TRUE(parentContext); + if (aParentContext == nsnull) { + NOISY_TRACE_FRAME("null parent context in ReResolveStyle: getting provider frame for",aFrame); + // get the parent context from the frame (indirectly) + nsIFrame* providerFrame = nsnull; + nsContextProviderRelationship relationship; + aFrame->GetParentStyleContextProvider(aPresContext,&providerFrame,relationship); + if (providerFrame) { + NOISY_TRACE("provider frame retrieved in ReResolveStyle: "); + + // see if we need to recurse and resolve the provider frame first + if (relationship != eContextProvider_Ancestor) { + NOISY_TRACE("non-ancestor provider, recursing.\n"); + // provider is not an ancestor, so assume we have to reresolve it first + ReResolveStyleContext(aPresContext, providerFrame, nsnull, content, + aAttrNameSpaceID, aAttribute, + aChangeList, aMinChange, aResultChange); + resolvedDescendant = providerFrame; + NOISY_TRACE("returned from recursion, descendant parent context provider resolved.\n"); + } else { + NOISY_TRACE("ancestor provider, assuming already resolved.\n"); + } + providerFrame->GetStyleContext(&aParentContext); } - } - else { - nsIFrame* providerFrameParent; - providerFrame->GetParent(&providerFrameParent); ENSURE_TRUE(providerFrameParent); - NS_ASSERTION(providerFrameParent == aFrame, "invalid style context provider"); - // resolve the provider first - nsCOMPtr providerContext; - providerFrame->GetStyleContext(getter_AddRefs(providerContext)); ENSURE_TRUE(providerContext); - nsIStyleContext* providerContextParent = providerContext->GetParent(); ENSURE_TRUE(providerContextParent); - ReResolveStyleContext(aPresContext, providerFrame, providerContextParent, content, - aAttrNameSpaceID, aAttribute, aChangeList, aMinChange, aResultChange); - NS_RELEASE(providerContextParent); - // the provider's new context becomes the parent context of aFrame's context - providerFrame->GetStyleContext(&parentContext); /* released later */ ENSURE_TRUE(parentContext); - resolvedDescendant = providerFrame; // don't want to re-resolve the provider again + } else { + // addref the parent passed in so we can release it at the end + NS_ADDREF(aParentContext); + NOISY_TRACE_FRAME("non-null parent context provided: using it and assuming already resolved",aFrame); } // do primary context nsIStyleContext* newContext = nsnull; if (pseudoTag) { nsIContent* pseudoContent = (aParentContent ? aParentContent : localContent); - aPresContext->ResolvePseudoStyleContextFor(pseudoContent, pseudoTag, parentContext, PR_FALSE, - &newContext); - NS_RELEASE(pseudoTag); + aPresContext->ResolvePseudoStyleContextFor(pseudoContent, pseudoTag, aParentContext, PR_FALSE, + &newContext); + NS_RELEASE(pseudoTag); } else { NS_ASSERTION(localContent, @@ -1763,10 +1763,10 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, aFrame->GetFrameType(getter_AddRefs(frameType)); if (content->IsContentOfType(nsIContent::eELEMENT) && frameType != nsLayoutAtoms::placeholderFrame) { - aPresContext->ResolveStyleContextFor(content, parentContext, + aPresContext->ResolveStyleContextFor(content, aParentContext, PR_TRUE, &newContext); } else { - aPresContext->ResolveStyleContextForNonElement(parentContext, + aPresContext->ResolveStyleContextForNonElement(aParentContext, PR_TRUE, &newContext); } } @@ -1922,7 +1922,7 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, } else { // regular child frame if (child != resolvedDescendant) { - ReResolveStyleContext(aPresContext, child, newContext, content, + ReResolveStyleContext(aPresContext, child, nsnull, content, aAttrNameSpaceID, aAttribute, aChangeList, aMinChange, childChange); } else { @@ -1941,7 +1941,7 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, NS_RELEASE(newContext); NS_IF_RELEASE(localContent); - NS_IF_RELEASE(parentContext); + NS_IF_RELEASE(aParentContext); } } diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index f008645272a..71bafd01404 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -10270,15 +10270,9 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext, nsCOMPtr shell; aPresContext->GetShell(getter_AddRefs(shell)); - - // Get the frame associated with the content which is the highest in the frame tree - nsIFrame* primaryFrame; - shell->GetPrimaryFrameFor(aContent, &primaryFrame); - // Get the frame associated with the content whose style context is highest in the style context tree - nsIFrame* primaryStyleFrame = nsnull; - if (primaryFrame) { - primaryFrame->GetStyleContextProvider(aPresContext, &primaryStyleFrame); - } + nsIFrame* primaryFrame; + + shell->GetPrimaryFrameFor(aContent, &primaryFrame); PRBool reconstruct = PR_FALSE; PRBool restyle = PR_FALSE; @@ -10370,8 +10364,8 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext, // This style rule exists and we need to blow away any computed data that this // rule cached in the rule tree. rule = getter_AddRefs((nsIStyleRule*)val.GetISupportsValue()); - if (primaryStyleFrame) - primaryStyleFrame->GetStyleContext(getter_AddRefs(styleContext)); + if (primaryFrame) + primaryFrame->GetStyleContext(getter_AddRefs(styleContext)); else { // We might be in the undisplayed map. Retrieve the style context from there. nsCOMPtr frameManager; diff --git a/mozilla/layout/html/table/src/nsTableFrame.cpp b/mozilla/layout/html/table/src/nsTableFrame.cpp index 2b8dfeb6618..f088694b17c 100644 --- a/mozilla/layout/html/table/src/nsTableFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableFrame.cpp @@ -1756,6 +1756,39 @@ nsTableFrame::SetColumnDimensions(nsIPresContext* aPresContext, // SEC: TODO need to worry about continuing frames prev/next in flow for splitting across pages. +// GetParentStyleContextProvider: +// The grandparent frame is he parent style context provider +// That is, the parent of the outerTableFrame is the frame that has our parent style context +// NOTE: if ther is a placeholder frame for the outer table, then we use its grandparent frame. +// +NS_IMETHODIMP +nsTableFrame::GetParentStyleContextProvider(nsIPresContext* aPresContext, + nsIFrame** aProviderFrame, + nsContextProviderRelationship& aRelationship) +{ + NS_ASSERTION(aProviderFrame, "null argument aProviderFrame"); + if (aProviderFrame) { + nsIFrame* f; + GetParent(&f); + NS_ASSERTION(f,"TableFrame has no parent frame"); + if (f) { + // see if there is a placeholder frame representing our parent's place in the frame tree + // if there is, we get the parent of that frame as our surrogate grandparent + nsIFrame* placeholder = nsnull; + GetPlaceholderFor(*aPresContext,*f,&placeholder); + if (placeholder) { + f = placeholder; + } + f->GetParent(&f); + NS_ASSERTION(f,"TableFrame has no grandparent frame"); + } + // parent context provider is the grandparent frame + *aProviderFrame = f; + aRelationship = eContextProvider_Ancestor; + } + return ((aProviderFrame != nsnull) && (*aProviderFrame != nsnull)) ? NS_OK : NS_ERROR_FAILURE; +} + // XXX this could be made more general to handle row modifications that change the // table height, but first we need to scrutinize every Invalidate static void diff --git a/mozilla/layout/html/table/src/nsTableFrame.h b/mozilla/layout/html/table/src/nsTableFrame.h index fbdfd7d0055..f129b125db8 100644 --- a/mozilla/layout/html/table/src/nsTableFrame.h +++ b/mozilla/layout/html/table/src/nsTableFrame.h @@ -370,6 +370,10 @@ public: PRBool& aDidBalance, nsReflowStatus& aStatus); + NS_IMETHOD GetParentStyleContextProvider(nsIPresContext* aPresContext, + nsIFrame** aProviderFrame, + nsContextProviderRelationship& aRelationship); + static nsMargin GetPadding(const nsHTMLReflowState& aReflowState, const nsTableCellFrame* aCellFrame); diff --git a/mozilla/layout/html/table/src/nsTableOuterFrame.cpp b/mozilla/layout/html/table/src/nsTableOuterFrame.cpp index 412ed694fba..d402caa1396 100644 --- a/mozilla/layout/html/table/src/nsTableOuterFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableOuterFrame.cpp @@ -414,20 +414,23 @@ NS_IMETHODIMP nsTableOuterFrame::SetSelected(nsIPresContext* aPresContext, return result; } -// GetStyleContextProvider: -// The innerTableFame is the style context provider, which is cached in a data member +// GetParentStyleContextProvider: +// The innerTableFame is he parent style context provider +// Fortunately, we cache that as a data member, so just return the cached pointer value +// NS_IMETHODIMP -nsTableOuterFrame::GetStyleContextProvider(nsIPresContext* aPresContext, - nsIFrame** aProviderFrame) +nsTableOuterFrame::GetParentStyleContextProvider(nsIPresContext* aPresContext, + nsIFrame** aProviderFrame, + nsContextProviderRelationship& aRelationship) { NS_ASSERTION(aProviderFrame && aPresContext, "null argument: aPresContext and-or aProviderFrame"); if (aProviderFrame) { - if (mInnerTableFrame) - *aProviderFrame = mInnerTableFrame; - else - *aProviderFrame = this; + // parent context provider is the innerTableFrame + NS_ASSERTION(mInnerTableFrame, "innerTableFrame should not be null"); + *aProviderFrame = mInnerTableFrame; + aRelationship = eContextProvider_Descendant; } - return (aProviderFrame && mInnerTableFrame) ? NS_OK : NS_ERROR_FAILURE; + return ((aProviderFrame != nsnull) && (*aProviderFrame != nsnull)) ? NS_OK : NS_ERROR_FAILURE; } // INCREMENTAL REFLOW HELPER FUNCTIONS diff --git a/mozilla/layout/html/table/src/nsTableOuterFrame.h b/mozilla/layout/html/table/src/nsTableOuterFrame.h index b8a7aaf9a57..16eaba4c89d 100644 --- a/mozilla/layout/html/table/src/nsTableOuterFrame.h +++ b/mozilla/layout/html/table/src/nsTableOuterFrame.h @@ -171,8 +171,9 @@ public: */ nscoord GetMinCaptionWidth(); - NS_IMETHOD GetStyleContextProvider(nsIPresContext* aPresContext, - nsIFrame** aProviderFrame); + NS_IMETHOD GetParentStyleContextProvider(nsIPresContext* aPresContext, + nsIFrame** aProviderFrame, + nsContextProviderRelationship& aRelationship); /*---------------- nsITableLayout methods ------------------------*/ diff --git a/mozilla/layout/tables/nsTableFrame.cpp b/mozilla/layout/tables/nsTableFrame.cpp index 2b8dfeb6618..f088694b17c 100644 --- a/mozilla/layout/tables/nsTableFrame.cpp +++ b/mozilla/layout/tables/nsTableFrame.cpp @@ -1756,6 +1756,39 @@ nsTableFrame::SetColumnDimensions(nsIPresContext* aPresContext, // SEC: TODO need to worry about continuing frames prev/next in flow for splitting across pages. +// GetParentStyleContextProvider: +// The grandparent frame is he parent style context provider +// That is, the parent of the outerTableFrame is the frame that has our parent style context +// NOTE: if ther is a placeholder frame for the outer table, then we use its grandparent frame. +// +NS_IMETHODIMP +nsTableFrame::GetParentStyleContextProvider(nsIPresContext* aPresContext, + nsIFrame** aProviderFrame, + nsContextProviderRelationship& aRelationship) +{ + NS_ASSERTION(aProviderFrame, "null argument aProviderFrame"); + if (aProviderFrame) { + nsIFrame* f; + GetParent(&f); + NS_ASSERTION(f,"TableFrame has no parent frame"); + if (f) { + // see if there is a placeholder frame representing our parent's place in the frame tree + // if there is, we get the parent of that frame as our surrogate grandparent + nsIFrame* placeholder = nsnull; + GetPlaceholderFor(*aPresContext,*f,&placeholder); + if (placeholder) { + f = placeholder; + } + f->GetParent(&f); + NS_ASSERTION(f,"TableFrame has no grandparent frame"); + } + // parent context provider is the grandparent frame + *aProviderFrame = f; + aRelationship = eContextProvider_Ancestor; + } + return ((aProviderFrame != nsnull) && (*aProviderFrame != nsnull)) ? NS_OK : NS_ERROR_FAILURE; +} + // XXX this could be made more general to handle row modifications that change the // table height, but first we need to scrutinize every Invalidate static void diff --git a/mozilla/layout/tables/nsTableFrame.h b/mozilla/layout/tables/nsTableFrame.h index fbdfd7d0055..f129b125db8 100644 --- a/mozilla/layout/tables/nsTableFrame.h +++ b/mozilla/layout/tables/nsTableFrame.h @@ -370,6 +370,10 @@ public: PRBool& aDidBalance, nsReflowStatus& aStatus); + NS_IMETHOD GetParentStyleContextProvider(nsIPresContext* aPresContext, + nsIFrame** aProviderFrame, + nsContextProviderRelationship& aRelationship); + static nsMargin GetPadding(const nsHTMLReflowState& aReflowState, const nsTableCellFrame* aCellFrame); diff --git a/mozilla/layout/tables/nsTableOuterFrame.cpp b/mozilla/layout/tables/nsTableOuterFrame.cpp index 412ed694fba..d402caa1396 100644 --- a/mozilla/layout/tables/nsTableOuterFrame.cpp +++ b/mozilla/layout/tables/nsTableOuterFrame.cpp @@ -414,20 +414,23 @@ NS_IMETHODIMP nsTableOuterFrame::SetSelected(nsIPresContext* aPresContext, return result; } -// GetStyleContextProvider: -// The innerTableFame is the style context provider, which is cached in a data member +// GetParentStyleContextProvider: +// The innerTableFame is he parent style context provider +// Fortunately, we cache that as a data member, so just return the cached pointer value +// NS_IMETHODIMP -nsTableOuterFrame::GetStyleContextProvider(nsIPresContext* aPresContext, - nsIFrame** aProviderFrame) +nsTableOuterFrame::GetParentStyleContextProvider(nsIPresContext* aPresContext, + nsIFrame** aProviderFrame, + nsContextProviderRelationship& aRelationship) { NS_ASSERTION(aProviderFrame && aPresContext, "null argument: aPresContext and-or aProviderFrame"); if (aProviderFrame) { - if (mInnerTableFrame) - *aProviderFrame = mInnerTableFrame; - else - *aProviderFrame = this; + // parent context provider is the innerTableFrame + NS_ASSERTION(mInnerTableFrame, "innerTableFrame should not be null"); + *aProviderFrame = mInnerTableFrame; + aRelationship = eContextProvider_Descendant; } - return (aProviderFrame && mInnerTableFrame) ? NS_OK : NS_ERROR_FAILURE; + return ((aProviderFrame != nsnull) && (*aProviderFrame != nsnull)) ? NS_OK : NS_ERROR_FAILURE; } // INCREMENTAL REFLOW HELPER FUNCTIONS diff --git a/mozilla/layout/tables/nsTableOuterFrame.h b/mozilla/layout/tables/nsTableOuterFrame.h index b8a7aaf9a57..16eaba4c89d 100644 --- a/mozilla/layout/tables/nsTableOuterFrame.h +++ b/mozilla/layout/tables/nsTableOuterFrame.h @@ -171,8 +171,9 @@ public: */ nscoord GetMinCaptionWidth(); - NS_IMETHOD GetStyleContextProvider(nsIPresContext* aPresContext, - nsIFrame** aProviderFrame); + NS_IMETHOD GetParentStyleContextProvider(nsIPresContext* aPresContext, + nsIFrame** aProviderFrame, + nsContextProviderRelationship& aRelationship); /*---------------- nsITableLayout methods ------------------------*/