|
|
|
Lines 1516-1539
VerifyContextParent(nsPresContext* aPres
|
Link Here
|
|---|
|
| 1516 |
nsStyleContext* aContext, nsStyleContext* aParentContext) |
1516 |
nsStyleContext* aContext, nsStyleContext* aParentContext) |
| 1517 |
{ |
1517 |
{ |
| 1518 |
// get the contexts not provided |
1518 |
// get the contexts not provided |
| 1519 |
if (!aContext) { |
1519 |
if (!aContext) { |
| 1520 |
aContext = aFrame->StyleContext(); |
1520 |
aContext = aFrame->StyleContext(); |
| 1521 |
} |
1521 |
} |
| 1522 |
|
1522 |
|
| 1523 |
if (!aParentContext) { |
1523 |
if (!aParentContext) { |
| 1524 |
// Get the correct parent context from the frame |
1524 |
nsIFrame* providerFrame; |
| 1525 |
// - if the frame is a placeholder, we get the out of flow frame's context |
1525 |
aParentContext = aFrame->GetParentStyleContext(&providerFrame); |
| 1526 |
// as the parent context instead of asking the frame |
|
|
| 1527 |
|
| 1528 |
// get the parent context from the frame (indirectly) |
| 1529 |
nsIFrame* providerFrame = aFrame->GetParentStyleContextFrame(); |
| 1530 |
if (providerFrame) |
| 1531 |
aParentContext = providerFrame->StyleContext(); |
| 1532 |
// aParentContext could still be null |
1526 |
// aParentContext could still be null |
| 1533 |
} |
1527 |
} |
| 1534 |
|
1528 |
|
| 1535 |
NS_ASSERTION(aContext, "Failure to get required contexts"); |
1529 |
NS_ASSERTION(aContext, "Failure to get required contexts"); |
| 1536 |
nsStyleContext* actualParentContext = aContext->GetParent(); |
1530 |
nsStyleContext* actualParentContext = aContext->GetParent(); |
| 1537 |
|
1531 |
|
| 1538 |
if (aParentContext) { |
1532 |
if (aParentContext) { |
| 1539 |
if (aParentContext != actualParentContext) { |
1533 |
if (aParentContext != actualParentContext) { |
|
Lines 1735-1764
RestyleManager::ReparentStyleContext(nsI
|
Link Here
|
|---|
|
| 1735 |
} while ((outOfFlow = outOfFlow->GetNextContinuation())); |
1729 |
} while ((outOfFlow = outOfFlow->GetNextContinuation())); |
| 1736 |
} |
1730 |
} |
| 1737 |
|
1731 |
|
| 1738 |
// DO NOT verify the style tree before reparenting. The frame |
1732 |
// DO NOT verify the style tree before reparenting. The frame |
| 1739 |
// tree has already been changed, so this check would just fail. |
1733 |
// tree has already been changed, so this check would just fail. |
| 1740 |
nsStyleContext* oldContext = aFrame->StyleContext(); |
1734 |
nsStyleContext* oldContext = aFrame->StyleContext(); |
| 1741 |
|
1735 |
|
| 1742 |
nsRefPtr<nsStyleContext> newContext; |
1736 |
nsRefPtr<nsStyleContext> newContext; |
| 1743 |
nsIFrame* providerFrame = aFrame->GetParentStyleContextFrame(); |
1737 |
nsIFrame* providerFrame; |
|
|
1738 |
nsStyleContext* newParentContext = aFrame->GetParentStyleContext(&providerFrame); |
| 1744 |
bool isChild = providerFrame && providerFrame->GetParent() == aFrame; |
1739 |
bool isChild = providerFrame && providerFrame->GetParent() == aFrame; |
| 1745 |
nsStyleContext* newParentContext = nullptr; |
|
|
| 1746 |
nsIFrame* providerChild = nullptr; |
1740 |
nsIFrame* providerChild = nullptr; |
| 1747 |
if (isChild) { |
1741 |
if (isChild) { |
| 1748 |
ReparentStyleContext(providerFrame); |
1742 |
ReparentStyleContext(providerFrame); |
| 1749 |
newParentContext = providerFrame->StyleContext(); |
1743 |
newParentContext = providerFrame->StyleContext(); |
| 1750 |
providerChild = providerFrame; |
1744 |
providerChild = providerFrame; |
| 1751 |
} else if (providerFrame) { |
|
|
| 1752 |
newParentContext = providerFrame->StyleContext(); |
| 1753 |
} else { |
| 1754 |
NS_NOTREACHED("Reparenting something that has no usable parent? " |
| 1755 |
"Shouldn't happen!"); |
| 1756 |
} |
1745 |
} |
|
|
1746 |
NS_ASSERTION(newParentContext, "Reparenting something that has no usable" |
| 1747 |
" parent? Shouldn't happen!"); |
| 1757 |
// XXX need to do something here to produce the correct style context for |
1748 |
// XXX need to do something here to produce the correct style context for |
| 1758 |
// an IB split whose first inline part is inside a first-line frame. |
1749 |
// an IB split whose first inline part is inside a first-line frame. |
| 1759 |
// Currently the first IB anonymous block's style context takes the first |
1750 |
// Currently the first IB anonymous block's style context takes the first |
| 1760 |
// part's style context as parent, which is wrong since first-line style |
1751 |
// part's style context as parent, which is wrong since first-line style |
| 1761 |
// should not apply to the anonymous block. |
1752 |
// should not apply to the anonymous block. |
| 1762 |
|
1753 |
|
| 1763 |
#ifdef DEBUG |
1754 |
#ifdef DEBUG |
| 1764 |
{ |
1755 |
{ |
|
Lines 2053-2068
ElementRestyler::Restyle(nsRestyleHint a
|
Link Here
|
|---|
|
| 2053 |
// |mFrame->GetContent()|, make more sense. However, we can't, |
2044 |
// |mFrame->GetContent()|, make more sense. However, we can't, |
| 2054 |
// because of frame trees like the one in |
2045 |
// because of frame trees like the one in |
| 2055 |
// https://bugzilla.mozilla.org/show_bug.cgi?id=472353#c14 . Once we |
2046 |
// https://bugzilla.mozilla.org/show_bug.cgi?id=472353#c14 . Once we |
| 2056 |
// fix bug 242277 we should be able to make this make more sense. |
2047 |
// fix bug 242277 we should be able to make this make more sense. |
| 2057 |
NS_ASSERTION(mFrame->GetContent() || !mParentContent || |
2048 |
NS_ASSERTION(mFrame->GetContent() || !mParentContent || |
| 2058 |
!mParentContent->GetParent(), |
2049 |
!mParentContent->GetParent(), |
| 2059 |
"frame must have content (unless at the top of the tree)"); |
2050 |
"frame must have content (unless at the top of the tree)"); |
| 2060 |
|
2051 |
|
|
|
2052 |
AutoDisplayContentsAncestorPusher adcp(mTreeMatchContext, mFrame->PresContext(), |
| 2053 |
mFrame->GetContent() ? mFrame->GetContent()->GetParent() : nullptr); |
| 2054 |
|
| 2061 |
if (mContent && mContent->IsElement()) { |
2055 |
if (mContent && mContent->IsElement()) { |
| 2062 |
mContent->OwnerDoc()->FlushPendingLinkUpdates(); |
2056 |
mContent->OwnerDoc()->FlushPendingLinkUpdates(); |
| 2063 |
RestyleTracker::RestyleData restyleData; |
2057 |
RestyleTracker::RestyleData restyleData; |
| 2064 |
if (mRestyleTracker.GetRestyleData(mContent->AsElement(), &restyleData)) { |
2058 |
if (mRestyleTracker.GetRestyleData(mContent->AsElement(), &restyleData)) { |
| 2065 |
if (NS_UpdateHint(mHintsHandled, restyleData.mChangeHint)) { |
2059 |
if (NS_UpdateHint(mHintsHandled, restyleData.mChangeHint)) { |
| 2066 |
mChangeList->AppendChange(mFrame, mContent, restyleData.mChangeHint); |
2060 |
mChangeList->AppendChange(mFrame, mContent, restyleData.mChangeHint); |
| 2067 |
} |
2061 |
} |
| 2068 |
aRestyleHint = nsRestyleHint(aRestyleHint | restyleData.mRestyleHint); |
2062 |
aRestyleHint = nsRestyleHint(aRestyleHint | restyleData.mRestyleHint); |
|
Lines 2105-2134
ElementRestyler::RestyleSelf(nsRestyleHi
|
Link Here
|
|---|
|
| 2105 |
#ifdef ACCESSIBILITY |
2099 |
#ifdef ACCESSIBILITY |
| 2106 |
mWasFrameVisible = nsIPresShell::IsAccessibilityActive() ? |
2100 |
mWasFrameVisible = nsIPresShell::IsAccessibilityActive() ? |
| 2107 |
oldContext->StyleVisibility()->IsVisible() : false; |
2101 |
oldContext->StyleVisibility()->IsVisible() : false; |
| 2108 |
#endif |
2102 |
#endif |
| 2109 |
|
2103 |
|
| 2110 |
nsIAtom* const pseudoTag = oldContext->GetPseudo(); |
2104 |
nsIAtom* const pseudoTag = oldContext->GetPseudo(); |
| 2111 |
const nsCSSPseudoElements::Type pseudoType = oldContext->GetPseudoType(); |
2105 |
const nsCSSPseudoElements::Type pseudoType = oldContext->GetPseudoType(); |
| 2112 |
|
2106 |
|
| 2113 |
nsStyleContext* parentContext; |
|
|
| 2114 |
// Get the frame providing the parent style context. If it is a |
2107 |
// Get the frame providing the parent style context. If it is a |
| 2115 |
// child, then resolve the provider first. |
2108 |
// child, then resolve the provider first. |
| 2116 |
nsIFrame* providerFrame = mFrame->GetParentStyleContextFrame(); |
2109 |
nsIFrame* providerFrame; |
|
|
2110 |
nsStyleContext* parentContext = mFrame->GetParentStyleContext(&providerFrame); |
| 2117 |
bool isChild = providerFrame && providerFrame->GetParent() == mFrame; |
2111 |
bool isChild = providerFrame && providerFrame->GetParent() == mFrame; |
| 2118 |
if (!isChild) { |
2112 |
if (isChild) { |
| 2119 |
if (providerFrame) |
|
|
| 2120 |
parentContext = providerFrame->StyleContext(); |
| 2121 |
else |
| 2122 |
parentContext = nullptr; |
| 2123 |
} |
| 2124 |
else { |
| 2125 |
MOZ_ASSERT(providerFrame->GetContent() == mFrame->GetContent(), |
2113 |
MOZ_ASSERT(providerFrame->GetContent() == mFrame->GetContent(), |
| 2126 |
"Postcondition for GetParentStyleContextFrame() violated. " |
2114 |
"Postcondition for GetParentStyleContext() violated. " |
| 2127 |
"That means we need to add the current element to the " |
2115 |
"That means we need to add the current element to the " |
| 2128 |
"ancestor filter."); |
2116 |
"ancestor filter."); |
| 2129 |
|
2117 |
|
| 2130 |
// resolve the provider here (before mFrame below). |
2118 |
// resolve the provider here (before mFrame below). |
| 2131 |
|
2119 |
|
| 2132 |
// assumeDifferenceHint forces the parent's change to be also |
2120 |
// assumeDifferenceHint forces the parent's change to be also |
| 2133 |
// applied to this frame, no matter what |
2121 |
// applied to this frame, no matter what |
| 2134 |
// nsStyleContext::CalcStyleDifference says. CalcStyleDifference |
2122 |
// nsStyleContext::CalcStyleDifference says. CalcStyleDifference |
|
Lines 2144-2160
ElementRestyler::RestyleSelf(nsRestyleHi
|
Link Here
|
|---|
|
| 2144 |
// The provider's new context becomes the parent context of |
2132 |
// The provider's new context becomes the parent context of |
| 2145 |
// mFrame's context. |
2133 |
// mFrame's context. |
| 2146 |
parentContext = providerFrame->StyleContext(); |
2134 |
parentContext = providerFrame->StyleContext(); |
| 2147 |
// Set |mResolvedChild| so we don't bother resolving the |
2135 |
// Set |mResolvedChild| so we don't bother resolving the |
| 2148 |
// provider again. |
2136 |
// provider again. |
| 2149 |
mResolvedChild = providerFrame; |
2137 |
mResolvedChild = providerFrame; |
| 2150 |
} |
2138 |
} |
| 2151 |
|
2139 |
|
| 2152 |
if (providerFrame != mFrame->GetParent()) { |
2140 |
if (providerFrame != mFrame->GetParent() && true /* XXX display:contents case? */) { |
| 2153 |
// We don't actually know what the parent style context's |
2141 |
// We don't actually know what the parent style context's |
| 2154 |
// non-inherited hints were, so assume the worst. |
2142 |
// non-inherited hints were, so assume the worst. |
| 2155 |
mParentFrameHintsNotHandledForDescendants = |
2143 |
mParentFrameHintsNotHandledForDescendants = |
| 2156 |
nsChangeHint_Hints_NotHandledForDescendants; |
2144 |
nsChangeHint_Hints_NotHandledForDescendants; |
| 2157 |
} |
2145 |
} |
| 2158 |
|
2146 |
|
| 2159 |
#ifdef DEBUG |
2147 |
#ifdef DEBUG |
| 2160 |
{ |
2148 |
{ |
|
Lines 2646-2662
ElementRestyler::RestyleContentChildren(
|
Link Here
|
|---|
|
| 2646 |
// want to pass that on to the out-of-flow reresolve, since that |
2634 |
// want to pass that on to the out-of-flow reresolve, since that |
| 2647 |
// can lead to the out-of-flow not getting reflowed when it should |
2635 |
// can lead to the out-of-flow not getting reflowed when it should |
| 2648 |
// be (eg a reresolve starting at <body> that involves reflowing |
2636 |
// be (eg a reresolve starting at <body> that involves reflowing |
| 2649 |
// the <body> would miss reflowing fixed-pos nodes that also need |
2637 |
// the <body> would miss reflowing fixed-pos nodes that also need |
| 2650 |
// reflow). In the cases when the out-of-flow _is_ a geometric |
2638 |
// reflow). In the cases when the out-of-flow _is_ a geometric |
| 2651 |
// descendant of a frame we already have a reflow hint for, |
2639 |
// descendant of a frame we already have a reflow hint for, |
| 2652 |
// reflow coalescing should keep us from doing the work twice. |
2640 |
// reflow coalescing should keep us from doing the work twice. |
| 2653 |
|
2641 |
|
| 2654 |
// |nsFrame::GetParentStyleContextFrame| checks being out |
2642 |
// |nsFrame::GetParentStyleContext| checks being out |
| 2655 |
// of flow so that this works correctly. |
2643 |
// of flow so that this works correctly. |
| 2656 |
do { |
2644 |
do { |
| 2657 |
ElementRestyler oofRestyler(*this, outOfFlowFrame, |
2645 |
ElementRestyler oofRestyler(*this, outOfFlowFrame, |
| 2658 |
FOR_OUT_OF_FLOW_CHILD); |
2646 |
FOR_OUT_OF_FLOW_CHILD); |
| 2659 |
oofRestyler.Restyle(aChildRestyleHint); |
2647 |
oofRestyler.Restyle(aChildRestyleHint); |
| 2660 |
} while ((outOfFlowFrame = outOfFlowFrame->GetNextContinuation())); |
2648 |
} while ((outOfFlowFrame = outOfFlowFrame->GetNextContinuation())); |
| 2661 |
|
2649 |
|
| 2662 |
// reresolve placeholder's context under the same parent |
2650 |
// reresolve placeholder's context under the same parent |