|
|
|
Lines 72-87
RestyleManager::NotifyDestroyingFrame(ns
|
Link Here
|
|---|
|
| 72 |
} |
72 |
} |
| 73 |
|
73 |
|
| 74 |
#ifdef DEBUG |
74 |
#ifdef DEBUG |
| 75 |
// To ensure that the functions below are only called within |
75 |
// To ensure that the functions below are only called within |
| 76 |
// |ApplyRenderingChangeToTree|. |
76 |
// |ApplyRenderingChangeToTree|. |
| 77 |
static bool gInApplyRenderingChangeToTree = false; |
77 |
static bool gInApplyRenderingChangeToTree = false; |
| 78 |
#endif |
78 |
#endif |
| 79 |
|
79 |
|
|
|
80 |
static nsIFrame* |
| 81 |
GetNearestAncestorFrame(nsIContent* aContent) |
| 82 |
{ |
| 83 |
nsIFrame* ancestorFrame = nullptr; |
| 84 |
for (nsIContent* ancestor = aContent->GetParent(); |
| 85 |
ancestor && !ancestorFrame; |
| 86 |
ancestor = ancestor->GetParent()) { |
| 87 |
ancestorFrame = ancestor->GetPrimaryFrame(); |
| 88 |
} |
| 89 |
return ancestorFrame; |
| 90 |
} |
| 91 |
|
| 92 |
|
| 80 |
static void |
93 |
static void |
| 81 |
DoApplyRenderingChangeToTree(nsIFrame* aFrame, |
94 |
DoApplyRenderingChangeToTree(nsIFrame* aFrame, |
| 82 |
nsChangeHint aChange); |
95 |
nsChangeHint aChange); |
| 83 |
|
96 |
|
| 84 |
/** |
97 |
/** |
| 85 |
* Sync views on aFrame and all of aFrame's descendants (following placeholders), |
98 |
* Sync views on aFrame and all of aFrame's descendants (following placeholders), |
| 86 |
* if aChange has nsChangeHint_SyncFrameView. |
99 |
* if aChange has nsChangeHint_SyncFrameView. |
| 87 |
* Calls DoApplyRenderingChangeToTree on all aFrame's out-of-flow descendants |
100 |
* Calls DoApplyRenderingChangeToTree on all aFrame's out-of-flow descendants |
|
Lines 912-928
RestyleManager::RestyleElement(Element*
|
Link Here
|
|---|
|
| 912 |
// We're restyling an element with no frame, so we should try to |
925 |
// We're restyling an element with no frame, so we should try to |
| 913 |
// make one if its new style says it should have one. But in order |
926 |
// make one if its new style says it should have one. But in order |
| 914 |
// to try to honor the restyle hint (which we'd like to do so that, |
927 |
// to try to honor the restyle hint (which we'd like to do so that, |
| 915 |
// for example, an animation-only style flush doesn't flush other |
928 |
// for example, an animation-only style flush doesn't flush other |
| 916 |
// buffered style changes), we only do this if the restyle hint says |
929 |
// buffered style changes), we only do this if the restyle hint says |
| 917 |
// we have *some* restyling for this frame. This means we'll |
930 |
// we have *some* restyling for this frame. This means we'll |
| 918 |
// potentially get ahead of ourselves in that case, but not as much |
931 |
// potentially get ahead of ourselves in that case, but not as much |
| 919 |
// as we would if we didn't check the restyle hint. |
932 |
// as we would if we didn't check the restyle hint. |
| 920 |
FrameConstructor()->MaybeRecreateFramesForElement(aElement); |
933 |
nsStyleContext* newContext = |
|
|
934 |
FrameConstructor()->MaybeRecreateFramesForElement(aElement); |
| 935 |
if (newContext && |
| 936 |
newContext->StyleDisplay()->mDisplay == NS_STYLE_DISPLAY_CONTENTS) { |
| 937 |
// Style change for a display:contents node that did not recreate frames. |
| 938 |
nsIFrame* frame = GetNearestAncestorFrame(aElement); |
| 939 |
MOZ_ASSERT(frame, "display:contents node in map although it's a " |
| 940 |
"display:none descendant?"); |
| 941 |
TreeMatchContext treeMatchContext(true, |
| 942 |
nsRuleWalker::eRelevantLinkUnvisited, |
| 943 |
frame->PresContext()->Document()); |
| 944 |
nsIContent* parent = aElement->GetParent(); |
| 945 |
Element* parentElement = |
| 946 |
parent && parent->IsElement() ? parent->AsElement() : nullptr; |
| 947 |
treeMatchContext.InitAncestors(parentElement); |
| 948 |
nsTArray<nsIContent*> visibleKidsOfHiddenElement; |
| 949 |
nsStyleChangeList changeList; |
| 950 |
ElementRestyler r(frame->PresContext(), aElement, &changeList, |
| 951 |
aMinHint, aRestyleTracker, treeMatchContext, |
| 952 |
visibleKidsOfHiddenElement); |
| 953 |
r.RestyleChildrenOfDisplayContentsElement(frame, newContext, |
| 954 |
aMinHint, aRestyleTracker, |
| 955 |
aRestyleHint, this); |
| 956 |
ProcessRestyledFrames(changeList); |
| 957 |
} |
| 921 |
} |
958 |
} |
| 922 |
} |
959 |
} |
| 923 |
|
960 |
|
| 924 |
static inline dom::Element* |
961 |
static inline dom::Element* |
| 925 |
ElementForStyleContext(nsIContent* aParentContent, |
962 |
ElementForStyleContext(nsIContent* aParentContent, |
| 926 |
nsIFrame* aFrame, |
963 |
nsIFrame* aFrame, |
| 927 |
nsCSSPseudoElements::Type aPseudoType); |
964 |
nsCSSPseudoElements::Type aPseudoType); |
| 928 |
|
965 |
|
|
Lines 2316-2331
ElementRestyler::ElementRestyler(ParentC
|
Link Here
|
|---|
|
| 2316 |
, mDesiredA11yNotifications(aParentRestyler.mDesiredA11yNotifications) |
2353 |
, mDesiredA11yNotifications(aParentRestyler.mDesiredA11yNotifications) |
| 2317 |
, mKidsDesiredA11yNotifications(mDesiredA11yNotifications) |
2354 |
, mKidsDesiredA11yNotifications(mDesiredA11yNotifications) |
| 2318 |
, mOurA11yNotification(eDontNotify) |
2355 |
, mOurA11yNotification(eDontNotify) |
| 2319 |
, mVisibleKidsOfHiddenElement(aParentRestyler.mVisibleKidsOfHiddenElement) |
2356 |
, mVisibleKidsOfHiddenElement(aParentRestyler.mVisibleKidsOfHiddenElement) |
| 2320 |
#endif |
2357 |
#endif |
| 2321 |
{ |
2358 |
{ |
| 2322 |
} |
2359 |
} |
| 2323 |
|
2360 |
|
|
|
2361 |
ElementRestyler::ElementRestyler(nsPresContext* aPresContext, |
| 2362 |
nsIContent* aContent, |
| 2363 |
nsStyleChangeList* aChangeList, |
| 2364 |
nsChangeHint aHintsHandledByAncestors, |
| 2365 |
RestyleTracker& aRestyleTracker, |
| 2366 |
TreeMatchContext& aTreeMatchContext, |
| 2367 |
nsTArray<nsIContent*>& |
| 2368 |
aVisibleKidsOfHiddenElement) |
| 2369 |
: mPresContext(aPresContext) |
| 2370 |
, mFrame(nullptr) |
| 2371 |
, mParentContent(nullptr) |
| 2372 |
, mContent(aContent) |
| 2373 |
, mChangeList(aChangeList) |
| 2374 |
, mHintsHandled(NS_SubtractHint(aHintsHandledByAncestors, |
| 2375 |
NS_HintsNotHandledForDescendantsIn(aHintsHandledByAncestors))) |
| 2376 |
, mParentFrameHintsNotHandledForDescendants(nsChangeHint(0)) |
| 2377 |
, mHintsNotHandledForDescendants(nsChangeHint(0)) |
| 2378 |
, mRestyleTracker(aRestyleTracker) |
| 2379 |
, mTreeMatchContext(aTreeMatchContext) |
| 2380 |
, mResolvedChild(nullptr) |
| 2381 |
#ifdef ACCESSIBILITY |
| 2382 |
, mDesiredA11yNotifications(eSendAllNotifications) |
| 2383 |
, mKidsDesiredA11yNotifications(mDesiredA11yNotifications) |
| 2384 |
, mOurA11yNotification(eDontNotify) |
| 2385 |
, mVisibleKidsOfHiddenElement(aVisibleKidsOfHiddenElement) |
| 2386 |
#endif |
| 2387 |
{ |
| 2388 |
} |
| 2389 |
|
| 2324 |
void |
2390 |
void |
| 2325 |
ElementRestyler::CaptureChange(nsStyleContext* aOldContext, |
2391 |
ElementRestyler::CaptureChange(nsStyleContext* aOldContext, |
| 2326 |
nsStyleContext* aNewContext, |
2392 |
nsStyleContext* aNewContext, |
| 2327 |
nsChangeHint aChangeToAssume, |
2393 |
nsChangeHint aChangeToAssume, |
| 2328 |
uint32_t* aEqualStructs) |
2394 |
uint32_t* aEqualStructs) |
| 2329 |
{ |
2395 |
{ |
| 2330 |
static_assert(nsStyleStructID_Length <= 32, |
2396 |
static_assert(nsStyleStructID_Length <= 32, |
| 2331 |
"aEqualStructs is not big enough"); |
2397 |
"aEqualStructs is not big enough"); |
|
Lines 2499-2515
ElementRestyler::Restyle(nsRestyleHint a
|
Link Here
|
|---|
|
| 2499 |
// left on mFrame. Since we ended up restyling our parent, change |
2565 |
// left on mFrame. Since we ended up restyling our parent, change |
| 2500 |
// this old style context to point to its new parent. |
2566 |
// this old style context to point to its new parent. |
| 2501 |
oldContext->MoveTo(parentContext); |
2567 |
oldContext->MoveTo(parentContext); |
| 2502 |
} |
2568 |
} |
| 2503 |
|
2569 |
|
| 2504 |
// Send the accessibility notifications that RestyleChildren otherwise |
2570 |
// Send the accessibility notifications that RestyleChildren otherwise |
| 2505 |
// would have sent. |
2571 |
// would have sent. |
| 2506 |
if (!(mHintsHandled & nsChangeHint_ReconstructFrame)) { |
2572 |
if (!(mHintsHandled & nsChangeHint_ReconstructFrame)) { |
| 2507 |
InitializeAccessibilityNotifications(); |
2573 |
InitializeAccessibilityNotifications(mFrame->StyleContext()); |
| 2508 |
SendAccessibilityNotifications(); |
2574 |
SendAccessibilityNotifications(); |
| 2509 |
} |
2575 |
} |
| 2510 |
|
2576 |
|
| 2511 |
mRestyleTracker.AddRestyleRootsIfAwaitingRestyle(descendants); |
2577 |
mRestyleTracker.AddRestyleRootsIfAwaitingRestyle(descendants); |
| 2512 |
return; |
2578 |
return; |
| 2513 |
} |
2579 |
} |
| 2514 |
|
2580 |
|
| 2515 |
if (!swappedStructs) { |
2581 |
if (!swappedStructs) { |
|
Lines 3088-3104
ElementRestyler::RestyleChildren(nsResty
|
Link Here
|
|---|
|
| 3088 |
// descendants anyway, so we want to avoid wasting time processing |
3154 |
// descendants anyway, so we want to avoid wasting time processing |
| 3089 |
// style contexts that we're just going to throw away anyway. - dwh |
3155 |
// style contexts that we're just going to throw away anyway. - dwh |
| 3090 |
// It's also important to check mHintsHandled since reresolving the |
3156 |
// It's also important to check mHintsHandled since reresolving the |
| 3091 |
// kids would use mFrame->StyleContext(), which is out of date if |
3157 |
// kids would use mFrame->StyleContext(), which is out of date if |
| 3092 |
// mHintsHandled has a ReconstructFrame hint; doing this could trigger |
3158 |
// mHintsHandled has a ReconstructFrame hint; doing this could trigger |
| 3093 |
// assertions about mismatched rule trees. |
3159 |
// assertions about mismatched rule trees. |
| 3094 |
nsIFrame *lastContinuation; |
3160 |
nsIFrame *lastContinuation; |
| 3095 |
if (!(mHintsHandled & nsChangeHint_ReconstructFrame)) { |
3161 |
if (!(mHintsHandled & nsChangeHint_ReconstructFrame)) { |
| 3096 |
InitializeAccessibilityNotifications(); |
3162 |
InitializeAccessibilityNotifications(mFrame->StyleContext()); |
| 3097 |
|
3163 |
|
| 3098 |
for (nsIFrame* f = mFrame; f; |
3164 |
for (nsIFrame* f = mFrame; f; |
| 3099 |
f = GetNextContinuationWithSameStyle(f, f->StyleContext())) { |
3165 |
f = GetNextContinuationWithSameStyle(f, f->StyleContext())) { |
| 3100 |
lastContinuation = f; |
3166 |
lastContinuation = f; |
| 3101 |
RestyleContentChildren(f, aChildRestyleHint); |
3167 |
RestyleContentChildren(f, aChildRestyleHint); |
| 3102 |
} |
3168 |
} |
| 3103 |
|
3169 |
|
| 3104 |
SendAccessibilityNotifications(); |
3170 |
SendAccessibilityNotifications(); |
|
Lines 3108-3160
ElementRestyler::RestyleChildren(nsResty
|
Link Here
|
|---|
|
| 3108 |
// See comments above regarding :before. |
3174 |
// See comments above regarding :before. |
| 3109 |
if (!(mHintsHandled & nsChangeHint_ReconstructFrame) && |
3175 |
if (!(mHintsHandled & nsChangeHint_ReconstructFrame) && |
| 3110 |
mightReframePseudos) { |
3176 |
mightReframePseudos) { |
| 3111 |
MaybeReframeForAfterPseudo(lastContinuation); |
3177 |
MaybeReframeForAfterPseudo(lastContinuation); |
| 3112 |
} |
3178 |
} |
| 3113 |
} |
3179 |
} |
| 3114 |
|
3180 |
|
| 3115 |
void |
3181 |
void |
|
|
3182 |
ElementRestyler::RestyleChildrenOfDisplayContentsElement( |
| 3183 |
nsIFrame* aParentFrame, |
| 3184 |
nsStyleContext* aNewContext, |
| 3185 |
nsChangeHint aMinHint, |
| 3186 |
RestyleTracker& aRestyleTracker, |
| 3187 |
nsRestyleHint aRestyleHint, |
| 3188 |
RestyleManager* aRestyleManager) |
| 3189 |
{ |
| 3190 |
const bool mightReframePseudos = aRestyleHint & eRestyle_Subtree; |
| 3191 |
InitializeAccessibilityNotifications(aNewContext); |
| 3192 |
DoRestyleUndisplayedDescendants(nsRestyleHint(0), mContent, aNewContext); |
| 3193 |
if (!(mHintsHandled & nsChangeHint_ReconstructFrame) && |
| 3194 |
mightReframePseudos) { |
| 3195 |
MaybeReframeForBeforePseudo(aParentFrame, nullptr, mContent, aNewContext); |
| 3196 |
} |
| 3197 |
if (!(mHintsHandled & nsChangeHint_ReconstructFrame) && |
| 3198 |
mightReframePseudos) { |
| 3199 |
MaybeReframeForAfterPseudo(aParentFrame, nullptr, mContent, aNewContext); |
| 3200 |
} |
| 3201 |
if (!(mHintsHandled & nsChangeHint_ReconstructFrame)) { |
| 3202 |
// Then process child frames for content that is a descendant of mContent. |
| 3203 |
// XXX perhaps it's better to walk child frames (before reresolving |
| 3204 |
// XXX undisplayed contexts above) and mark those that has a stylecontext |
| 3205 |
// XXX leading up to mContent's old context? (instead of the |
| 3206 |
// XXX ContentIsDescendantOf check below) |
| 3207 |
nsIFrame::ChildListIterator lists(aParentFrame); |
| 3208 |
for ( ; !lists.IsDone(); lists.Next()) { |
| 3209 |
nsFrameList::Enumerator childFrames(lists.CurrentList()); |
| 3210 |
for (; !childFrames.AtEnd(); childFrames.Next()) { |
| 3211 |
nsIFrame* f = childFrames.get(); |
| 3212 |
if (nsContentUtils::ContentIsDescendantOf(f->GetContent(), mContent) && |
| 3213 |
!f->GetPrevContinuation()) { |
| 3214 |
if (!(f->GetStateBits() & NS_FRAME_OUT_OF_FLOW)) { |
| 3215 |
aRestyleManager->ComputeStyleChangeFor(f, mChangeList, aMinHint, |
| 3216 |
aRestyleTracker, |
| 3217 |
aRestyleHint); |
| 3218 |
} |
| 3219 |
} |
| 3220 |
} |
| 3221 |
} |
| 3222 |
} |
| 3223 |
if (!(mHintsHandled & nsChangeHint_ReconstructFrame)) { |
| 3224 |
SendAccessibilityNotifications(); |
| 3225 |
} |
| 3226 |
} |
| 3227 |
|
| 3228 |
void |
| 3116 |
ElementRestyler::RestyleUndisplayedDescendants(nsRestyleHint aChildRestyleHint) |
3229 |
ElementRestyler::RestyleUndisplayedDescendants(nsRestyleHint aChildRestyleHint) |
| 3117 |
{ |
3230 |
{ |
| 3118 |
// When the root element is display:none, we still construct *some* |
3231 |
// When the root element is display:none, we still construct *some* |
| 3119 |
// frames that have the root element as their mContent, down to the |
3232 |
// frames that have the root element as their mContent, down to the |
| 3120 |
// DocElementContainingBlock. |
3233 |
// DocElementContainingBlock. |
| 3121 |
bool checkUndisplayed; |
3234 |
bool checkUndisplayed; |
| 3122 |
nsIContent* undisplayedParent; |
3235 |
nsIContent* undisplayedParent; |
| 3123 |
if (mFrame->StyleContext()->GetPseudo()) { |
3236 |
if (mFrame->StyleContext()->GetPseudo()) { |
| 3124 |
checkUndisplayed = mFrame == mPresContext->FrameConstructor()-> |
3237 |
checkUndisplayed = mFrame == mPresContext->FrameConstructor()-> |
| 3125 |
GetDocElementContainingBlock(); |
3238 |
GetDocElementContainingBlock(); |
| 3126 |
undisplayedParent = nullptr; |
3239 |
undisplayedParent = nullptr; |
| 3127 |
} else { |
3240 |
} else { |
| 3128 |
checkUndisplayed = !!mFrame->GetContent(); |
3241 |
checkUndisplayed = !!mFrame->GetContent(); |
| 3129 |
undisplayedParent = mFrame->GetContent(); |
3242 |
undisplayedParent = mFrame->GetContent(); |
| 3130 |
} |
3243 |
} |
| 3131 |
if (checkUndisplayed) { |
3244 |
if (checkUndisplayed) { |
| 3132 |
DoRestyleUndisplayedDescendants(aChildRestyleHint, undisplayedParent); |
3245 |
DoRestyleUndisplayedDescendants(aChildRestyleHint, undisplayedParent, |
|
|
3246 |
mFrame->StyleContext()); |
| 3133 |
} |
3247 |
} |
| 3134 |
} |
3248 |
} |
| 3135 |
|
3249 |
|
| 3136 |
void |
3250 |
void |
| 3137 |
ElementRestyler::DoRestyleUndisplayedDescendants(nsRestyleHint aChildRestyleHint, |
3251 |
ElementRestyler::DoRestyleUndisplayedDescendants(nsRestyleHint aChildRestyleHint, |
| 3138 |
nsIContent* aParent) |
3252 |
nsIContent* aParent, |
|
|
3253 |
nsStyleContext* aParentContext) |
| 3139 |
{ |
3254 |
{ |
| 3140 |
nsCSSFrameConstructor* fc = mPresContext->FrameConstructor(); |
3255 |
nsCSSFrameConstructor* fc = mPresContext->FrameConstructor(); |
| 3141 |
UndisplayedNode* nodes = fc->GetAllUndisplayedContentIn(aParent); |
3256 |
UndisplayedNode* nodes = fc->GetAllUndisplayedContentIn(aParent); |
| 3142 |
RestyleUndisplayedNodes(aChildRestyleHint, nodes, aParent, |
3257 |
RestyleUndisplayedNodes(aChildRestyleHint, nodes, aParent, |
| 3143 |
NS_STYLE_DISPLAY_NONE); |
3258 |
aParentContext, NS_STYLE_DISPLAY_NONE); |
| 3144 |
nodes = fc->GetAllDisplayContentsIn(aParent); |
3259 |
nodes = fc->GetAllDisplayContentsIn(aParent); |
| 3145 |
RestyleUndisplayedNodes(aChildRestyleHint, nodes, aParent, |
3260 |
RestyleUndisplayedNodes(aChildRestyleHint, nodes, aParent, |
| 3146 |
NS_STYLE_DISPLAY_CONTENTS); |
3261 |
aParentContext, NS_STYLE_DISPLAY_CONTENTS); |
| 3147 |
} |
3262 |
} |
| 3148 |
|
3263 |
|
| 3149 |
void |
3264 |
void |
| 3150 |
ElementRestyler::RestyleUndisplayedNodes(nsRestyleHint aChildRestyleHint, |
3265 |
ElementRestyler::RestyleUndisplayedNodes(nsRestyleHint aChildRestyleHint, |
| 3151 |
UndisplayedNode* aUndisplayed, |
3266 |
UndisplayedNode* aUndisplayed, |
| 3152 |
nsIContent* aUndisplayedParent, |
3267 |
nsIContent* aUndisplayedParent, |
|
|
3268 |
nsStyleContext* aParentContext, |
| 3153 |
const uint8_t aDisplay) |
3269 |
const uint8_t aDisplay) |
| 3154 |
{ |
3270 |
{ |
| 3155 |
nsIContent* undisplayedParent = aUndisplayedParent; |
3271 |
nsIContent* undisplayedParent = aUndisplayedParent; |
| 3156 |
UndisplayedNode* undisplayed = aUndisplayed; |
3272 |
UndisplayedNode* undisplayed = aUndisplayed; |
| 3157 |
TreeMatchContext::AutoAncestorPusher pusher(mTreeMatchContext); |
3273 |
TreeMatchContext::AutoAncestorPusher pusher(mTreeMatchContext); |
| 3158 |
if (undisplayed) { |
3274 |
if (undisplayed) { |
| 3159 |
pusher.PushAncestorAndStyleScope(undisplayedParent); |
3275 |
pusher.PushAncestorAndStyleScope(undisplayedParent); |
| 3160 |
} |
3276 |
} |
|
Lines 3183-3316
ElementRestyler::RestyleUndisplayedNodes
|
Link Here
|
|---|
|
| 3183 |
undisplayedRestyleData)) { |
3299 |
undisplayedRestyleData)) { |
| 3184 |
thisChildHint = |
3300 |
thisChildHint = |
| 3185 |
nsRestyleHint(thisChildHint | undisplayedRestyleData->mRestyleHint); |
3301 |
nsRestyleHint(thisChildHint | undisplayedRestyleData->mRestyleHint); |
| 3186 |
} |
3302 |
} |
| 3187 |
nsRefPtr<nsStyleContext> undisplayedContext; |
3303 |
nsRefPtr<nsStyleContext> undisplayedContext; |
| 3188 |
nsStyleSet* styleSet = mPresContext->StyleSet(); |
3304 |
nsStyleSet* styleSet = mPresContext->StyleSet(); |
| 3189 |
if (thisChildHint & (eRestyle_Self | eRestyle_Subtree)) { |
3305 |
if (thisChildHint & (eRestyle_Self | eRestyle_Subtree)) { |
| 3190 |
undisplayedContext = |
3306 |
undisplayedContext = |
| 3191 |
styleSet->ResolveStyleFor(element, |
3307 |
styleSet->ResolveStyleFor(element, aParentContext, mTreeMatchContext); |
| 3192 |
mFrame->StyleContext(), |
|
|
| 3193 |
mTreeMatchContext); |
| 3194 |
} else if (thisChildHint || |
3308 |
} else if (thisChildHint || |
| 3195 |
styleSet->IsInRuleTreeReconstruct()) { |
3309 |
styleSet->IsInRuleTreeReconstruct()) { |
| 3196 |
// Use ResolveStyleWithReplacement either for actual |
3310 |
// Use ResolveStyleWithReplacement either for actual |
| 3197 |
// replacements, or as a substitute for ReparentStyleContext |
3311 |
// replacements, or as a substitute for ReparentStyleContext |
| 3198 |
// that rebuilds the path in the rule tree rather than reusing |
3312 |
// that rebuilds the path in the rule tree rather than reusing |
| 3199 |
// the rule node, as we need to do during a rule tree |
3313 |
// the rule node, as we need to do during a rule tree |
| 3200 |
// reconstruct. |
3314 |
// reconstruct. |
| 3201 |
undisplayedContext = |
3315 |
undisplayedContext = |
| 3202 |
styleSet->ResolveStyleWithReplacement(element, |
3316 |
styleSet->ResolveStyleWithReplacement(element, |
| 3203 |
mFrame->StyleContext(), |
3317 |
aParentContext, |
| 3204 |
undisplayed->mStyle, |
3318 |
undisplayed->mStyle, |
| 3205 |
thisChildHint); |
3319 |
thisChildHint); |
| 3206 |
} else { |
3320 |
} else { |
| 3207 |
undisplayedContext = |
3321 |
undisplayedContext = |
| 3208 |
styleSet->ReparentStyleContext(undisplayed->mStyle, |
3322 |
styleSet->ReparentStyleContext(undisplayed->mStyle, |
| 3209 |
mFrame->StyleContext(), |
3323 |
aParentContext, |
| 3210 |
element, element); |
3324 |
element, element); |
| 3211 |
} |
3325 |
} |
| 3212 |
const nsStyleDisplay* display = undisplayedContext->StyleDisplay(); |
3326 |
const nsStyleDisplay* display = undisplayedContext->StyleDisplay(); |
| 3213 |
if (display->mDisplay != aDisplay) { |
3327 |
if (display->mDisplay != aDisplay) { |
| 3214 |
NS_ASSERTION(element, "Must have undisplayed content"); |
3328 |
NS_ASSERTION(element, "Must have undisplayed content"); |
| 3215 |
mChangeList->AppendChange(nullptr, element, |
3329 |
mChangeList->AppendChange(nullptr, element, |
| 3216 |
NS_STYLE_HINT_FRAMECHANGE); |
3330 |
NS_STYLE_HINT_FRAMECHANGE); |
| 3217 |
// The node should be removed from the undisplayed map when |
3331 |
// The node should be removed from the undisplayed map when |
| 3218 |
// we reframe it. |
3332 |
// we reframe it. |
| 3219 |
} else { |
3333 |
} else { |
| 3220 |
// update the undisplayed node with the new context |
3334 |
// update the undisplayed node with the new context |
| 3221 |
undisplayed->mStyle = undisplayedContext; |
3335 |
undisplayed->mStyle = undisplayedContext; |
| 3222 |
|
3336 |
|
| 3223 |
if (aDisplay == NS_STYLE_DISPLAY_CONTENTS) { |
3337 |
if (aDisplay == NS_STYLE_DISPLAY_CONTENTS) { |
| 3224 |
DoRestyleUndisplayedDescendants(aChildRestyleHint, element); |
3338 |
DoRestyleUndisplayedDescendants(aChildRestyleHint, element, |
|
|
3339 |
undisplayed->mStyle); |
| 3225 |
} |
3340 |
} |
| 3226 |
} |
3341 |
} |
| 3227 |
} |
3342 |
} |
| 3228 |
} |
3343 |
} |
| 3229 |
|
3344 |
|
| 3230 |
void |
3345 |
void |
| 3231 |
ElementRestyler::MaybeReframeForBeforePseudo() |
3346 |
ElementRestyler::MaybeReframeForBeforePseudo() |
| 3232 |
{ |
3347 |
{ |
|
|
3348 |
MaybeReframeForBeforePseudo(mFrame, mFrame, mFrame->GetContent(), |
| 3349 |
mFrame->StyleContext()); |
| 3350 |
} |
| 3351 |
|
| 3352 |
void |
| 3353 |
ElementRestyler::MaybeReframeForBeforePseudo(nsIFrame* aGenConParentFrame, |
| 3354 |
nsIFrame* aFrame, |
| 3355 |
nsIContent* aContent, |
| 3356 |
nsStyleContext* aStyleContext) |
| 3357 |
{ |
| 3233 |
// Make sure not to do this for pseudo-frames or frames that |
3358 |
// Make sure not to do this for pseudo-frames or frames that |
| 3234 |
// can't have generated content. |
3359 |
// can't have generated content. |
| 3235 |
nsContainerFrame* cif; |
3360 |
nsContainerFrame* cif; |
| 3236 |
if (!mFrame->StyleContext()->GetPseudo() && |
3361 |
if (!aStyleContext->GetPseudo() && |
| 3237 |
((mFrame->GetStateBits() & NS_FRAME_MAY_HAVE_GENERATED_CONTENT) || |
3362 |
((aGenConParentFrame->GetStateBits() & NS_FRAME_MAY_HAVE_GENERATED_CONTENT) || |
| 3238 |
// Our content insertion frame might have gotten flagged |
3363 |
// Our content insertion frame might have gotten flagged. |
| 3239 |
((cif = mFrame->GetContentInsertionFrame()) && |
3364 |
((cif = aGenConParentFrame->GetContentInsertionFrame()) && |
| 3240 |
(cif->GetStateBits() & NS_FRAME_MAY_HAVE_GENERATED_CONTENT)))) { |
3365 |
(cif->GetStateBits() & NS_FRAME_MAY_HAVE_GENERATED_CONTENT)))) { |
| 3241 |
// Check for a new :before pseudo and an existing :before |
3366 |
// Check for a ::before pseudo style and the absence of a ::before content, |
| 3242 |
// frame, but only if the frame is the first continuation. |
3367 |
// but only if aFrame is null or is the first continuation. |
| 3243 |
nsIFrame* prevContinuation = mFrame->GetPrevContinuation(); |
3368 |
if (!aFrame || !aFrame->GetPrevContinuation()) { |
| 3244 |
if (!prevContinuation) { |
3369 |
// Checking for a ::before frame is cheaper than getting the |
| 3245 |
// Checking for a :before frame is cheaper than getting the |
3370 |
// ::before style context. |
| 3246 |
// :before style context. |
3371 |
if (!nsLayoutUtils::GetBeforeFrameForContent(aGenConParentFrame, aContent) && |
| 3247 |
if (!nsLayoutUtils::GetBeforeFrame(mFrame) && |
3372 |
nsLayoutUtils::HasPseudoStyle(aContent, aStyleContext, |
| 3248 |
nsLayoutUtils::HasPseudoStyle(mFrame->GetContent(), |
|
|
| 3249 |
mFrame->StyleContext(), |
| 3250 |
nsCSSPseudoElements::ePseudo_before, |
3373 |
nsCSSPseudoElements::ePseudo_before, |
| 3251 |
mPresContext)) { |
3374 |
mPresContext)) { |
| 3252 |
// Have to create the new :before frame |
3375 |
// Have to create the new ::before frame. |
| 3253 |
NS_UpdateHint(mHintsHandled, nsChangeHint_ReconstructFrame); |
3376 |
NS_UpdateHint(mHintsHandled, nsChangeHint_ReconstructFrame); |
| 3254 |
mChangeList->AppendChange(mFrame, mContent, |
3377 |
mChangeList->AppendChange(aFrame, aContent, |
| 3255 |
nsChangeHint_ReconstructFrame); |
3378 |
nsChangeHint_ReconstructFrame); |
| 3256 |
} |
3379 |
} |
| 3257 |
} |
3380 |
} |
| 3258 |
} |
3381 |
} |
| 3259 |
} |
3382 |
} |
| 3260 |
|
3383 |
|
| 3261 |
/** |
3384 |
/** |
| 3262 |
* aFrame is the last continuation or block-in-inline sibling that this |
3385 |
* aFrame is the last continuation or block-in-inline sibling that this |
| 3263 |
* ElementRestyler is restyling. |
3386 |
* ElementRestyler is restyling. |
| 3264 |
*/ |
3387 |
*/ |
| 3265 |
void |
3388 |
void |
| 3266 |
ElementRestyler::MaybeReframeForAfterPseudo(nsIFrame* aFrame) |
3389 |
ElementRestyler::MaybeReframeForAfterPseudo(nsIFrame* aFrame) |
| 3267 |
{ |
3390 |
{ |
|
|
3391 |
MOZ_ASSERT(aFrame); |
| 3392 |
MaybeReframeForAfterPseudo(aFrame, aFrame, aFrame->GetContent(), |
| 3393 |
aFrame->StyleContext()); |
| 3394 |
} |
| 3395 |
|
| 3396 |
void |
| 3397 |
ElementRestyler::MaybeReframeForAfterPseudo(nsIFrame* aGenConParentFrame, |
| 3398 |
nsIFrame* aFrame, |
| 3399 |
nsIContent* aContent, |
| 3400 |
nsStyleContext* aStyleContext) |
| 3401 |
{ |
| 3268 |
// Make sure not to do this for pseudo-frames or frames that |
3402 |
// Make sure not to do this for pseudo-frames or frames that |
| 3269 |
// can't have generated content. |
3403 |
// can't have generated content. |
| 3270 |
nsContainerFrame* cif; |
3404 |
nsContainerFrame* cif; |
| 3271 |
if (!aFrame->StyleContext()->GetPseudo() && |
3405 |
if (!aStyleContext->GetPseudo() && |
| 3272 |
((aFrame->GetStateBits() & NS_FRAME_MAY_HAVE_GENERATED_CONTENT) || |
3406 |
((aGenConParentFrame->GetStateBits() & NS_FRAME_MAY_HAVE_GENERATED_CONTENT) || |
| 3273 |
// Our content insertion frame might have gotten flagged |
3407 |
// Our content insertion frame might have gotten flagged. |
| 3274 |
((cif = aFrame->GetContentInsertionFrame()) && |
3408 |
((cif = aGenConParentFrame->GetContentInsertionFrame()) && |
| 3275 |
(cif->GetStateBits() & NS_FRAME_MAY_HAVE_GENERATED_CONTENT)))) { |
3409 |
(cif->GetStateBits() & NS_FRAME_MAY_HAVE_GENERATED_CONTENT)))) { |
| 3276 |
// Check for new :after content, but only if the frame is the |
3410 |
// Check for an ::after pseudo style and the absence of an ::after content, |
| 3277 |
// last continuation. |
3411 |
// but only if aFrame is null or is the last continuation. |
| 3278 |
nsIFrame* nextContinuation = aFrame->GetNextContinuation(); |
3412 |
if (!aFrame || !aFrame->GetNextContinuation()) { |
| 3279 |
|
3413 |
// Checking for an ::after frame is cheaper than getting the |
| 3280 |
if (!nextContinuation) { |
3414 |
// ::after style context. |
| 3281 |
// Getting the :after frame is more expensive than getting the pseudo |
3415 |
if (!nsLayoutUtils::GetAfterFrameForContent(aGenConParentFrame, aContent) && |
| 3282 |
// context, so get the pseudo context first. |
3416 |
nsLayoutUtils::HasPseudoStyle(aContent, aStyleContext, |
| 3283 |
if (nsLayoutUtils::HasPseudoStyle(aFrame->GetContent(), |
|
|
| 3284 |
aFrame->StyleContext(), |
| 3285 |
nsCSSPseudoElements::ePseudo_after, |
3417 |
nsCSSPseudoElements::ePseudo_after, |
| 3286 |
mPresContext) && |
3418 |
mPresContext)) { |
| 3287 |
!nsLayoutUtils::GetAfterFrame(aFrame)) { |
3419 |
// Have to create the new ::after frame. |
| 3288 |
// have to create the new :after frame |
|
|
| 3289 |
NS_UpdateHint(mHintsHandled, nsChangeHint_ReconstructFrame); |
3420 |
NS_UpdateHint(mHintsHandled, nsChangeHint_ReconstructFrame); |
| 3290 |
mChangeList->AppendChange(aFrame, mContent, |
3421 |
mChangeList->AppendChange(aFrame, mContent, |
| 3291 |
nsChangeHint_ReconstructFrame); |
3422 |
nsChangeHint_ReconstructFrame); |
| 3292 |
} |
3423 |
} |
| 3293 |
} |
3424 |
} |
| 3294 |
} |
3425 |
} |
| 3295 |
} |
3426 |
} |
| 3296 |
|
3427 |
|
| 3297 |
void |
3428 |
void |
| 3298 |
ElementRestyler::InitializeAccessibilityNotifications() |
3429 |
ElementRestyler::InitializeAccessibilityNotifications(nsStyleContext* aNewContext) |
| 3299 |
{ |
3430 |
{ |
| 3300 |
#ifdef ACCESSIBILITY |
3431 |
#ifdef ACCESSIBILITY |
| 3301 |
// Notify a11y for primary frame only if it's a root frame of visibility |
3432 |
// Notify a11y for primary frame only if it's a root frame of visibility |
| 3302 |
// changes or its parent frame was hidden while it stays visible and |
3433 |
// changes or its parent frame was hidden while it stays visible and |
| 3303 |
// it is not inside a {ib} split or is the first frame of {ib} split. |
3434 |
// it is not inside a {ib} split or is the first frame of {ib} split. |
| 3304 |
if (nsIPresShell::IsAccessibilityActive() && |
3435 |
if (nsIPresShell::IsAccessibilityActive() && |
| 3305 |
!mFrame->GetPrevContinuation() && |
3436 |
(!mFrame || |
| 3306 |
!mFrame->FrameIsNonFirstInIBSplit()) { |
3437 |
(!mFrame->GetPrevContinuation() && |
|
|
3438 |
!mFrame->FrameIsNonFirstInIBSplit()))) { |
| 3307 |
if (mDesiredA11yNotifications == eSendAllNotifications) { |
3439 |
if (mDesiredA11yNotifications == eSendAllNotifications) { |
| 3308 |
bool isFrameVisible = mFrame->StyleVisibility()->IsVisible(); |
3440 |
bool isFrameVisible = aNewContext->StyleVisibility()->IsVisible(); |
| 3309 |
if (isFrameVisible != mWasFrameVisible) { |
3441 |
if (isFrameVisible != mWasFrameVisible) { |
| 3310 |
if (isFrameVisible) { |
3442 |
if (isFrameVisible) { |
| 3311 |
// Notify a11y the element (perhaps with its children) was shown. |
3443 |
// Notify a11y the element (perhaps with its children) was shown. |
| 3312 |
// We don't fall into this case if this element gets or stays shown |
3444 |
// We don't fall into this case if this element gets or stays shown |
| 3313 |
// while its parent becomes hidden. |
3445 |
// while its parent becomes hidden. |
| 3314 |
mKidsDesiredA11yNotifications = eSkipNotifications; |
3446 |
mKidsDesiredA11yNotifications = eSkipNotifications; |
| 3315 |
mOurA11yNotification = eNotifyShown; |
3447 |
mOurA11yNotification = eNotifyShown; |
| 3316 |
} else { |
3448 |
} else { |
|
Lines 3319-3338
ElementRestyler::InitializeAccessibility
|
Link Here
|
|---|
|
| 3319 |
// visible children then we should notify a11y about that as if |
3451 |
// visible children then we should notify a11y about that as if |
| 3320 |
// they were inserted into tree. Notify a11y this element was |
3452 |
// they were inserted into tree. Notify a11y this element was |
| 3321 |
// hidden. |
3453 |
// hidden. |
| 3322 |
mKidsDesiredA11yNotifications = eNotifyIfShown; |
3454 |
mKidsDesiredA11yNotifications = eNotifyIfShown; |
| 3323 |
mOurA11yNotification = eNotifyHidden; |
3455 |
mOurA11yNotification = eNotifyHidden; |
| 3324 |
} |
3456 |
} |
| 3325 |
} |
3457 |
} |
| 3326 |
} else if (mDesiredA11yNotifications == eNotifyIfShown && |
3458 |
} else if (mDesiredA11yNotifications == eNotifyIfShown && |
| 3327 |
mFrame->StyleVisibility()->IsVisible()) { |
3459 |
aNewContext->StyleVisibility()->IsVisible()) { |
| 3328 |
// Notify a11y that element stayed visible while its parent was |
3460 |
// Notify a11y that element stayed visible while its parent was hidden. |
| 3329 |
// hidden. |
3461 |
nsIContent* c = mFrame ? mFrame->GetContent() : mContent; |
| 3330 |
mVisibleKidsOfHiddenElement.AppendElement(mFrame->GetContent()); |
3462 |
mVisibleKidsOfHiddenElement.AppendElement(c); |
| 3331 |
mKidsDesiredA11yNotifications = eSkipNotifications; |
3463 |
mKidsDesiredA11yNotifications = eSkipNotifications; |
| 3332 |
} |
3464 |
} |
| 3333 |
} |
3465 |
} |
| 3334 |
#endif |
3466 |
#endif |
| 3335 |
} |
3467 |
} |
| 3336 |
|
3468 |
|
| 3337 |
void |
3469 |
void |
| 3338 |
ElementRestyler::RestyleContentChildren(nsIFrame* aParent, |
3470 |
ElementRestyler::RestyleContentChildren(nsIFrame* aParent, |
|
Lines 3408-3435
ElementRestyler::RestyleContentChildren(
|
Link Here
|
|---|
|
| 3408 |
void |
3540 |
void |
| 3409 |
ElementRestyler::SendAccessibilityNotifications() |
3541 |
ElementRestyler::SendAccessibilityNotifications() |
| 3410 |
{ |
3542 |
{ |
| 3411 |
#ifdef ACCESSIBILITY |
3543 |
#ifdef ACCESSIBILITY |
| 3412 |
// Send notifications about visibility changes. |
3544 |
// Send notifications about visibility changes. |
| 3413 |
if (mOurA11yNotification == eNotifyShown) { |
3545 |
if (mOurA11yNotification == eNotifyShown) { |
| 3414 |
nsAccessibilityService* accService = nsIPresShell::AccService(); |
3546 |
nsAccessibilityService* accService = nsIPresShell::AccService(); |
| 3415 |
if (accService) { |
3547 |
if (accService) { |
| 3416 |
nsIPresShell* presShell = mFrame->PresContext()->GetPresShell(); |
3548 |
nsIPresShell* presShell = mPresContext->GetPresShell(); |
| 3417 |
nsIContent* content = mFrame->GetContent(); |
3549 |
nsIContent* content = mFrame ? mFrame->GetContent() : mContent; |
| 3418 |
|
3550 |
|
| 3419 |
accService->ContentRangeInserted(presShell, content->GetParent(), |
3551 |
accService->ContentRangeInserted(presShell, content->GetParent(), |
| 3420 |
content, |
3552 |
content, |
| 3421 |
content->GetNextSibling()); |
3553 |
content->GetNextSibling()); |
| 3422 |
} |
3554 |
} |
| 3423 |
} else if (mOurA11yNotification == eNotifyHidden) { |
3555 |
} else if (mOurA11yNotification == eNotifyHidden) { |
| 3424 |
nsAccessibilityService* accService = nsIPresShell::AccService(); |
3556 |
nsAccessibilityService* accService = nsIPresShell::AccService(); |
| 3425 |
if (accService) { |
3557 |
if (accService) { |
| 3426 |
nsIPresShell* presShell = mFrame->PresContext()->GetPresShell(); |
3558 |
nsIPresShell* presShell = mPresContext->GetPresShell(); |
| 3427 |
nsIContent* content = mFrame->GetContent(); |
3559 |
nsIContent* content = mFrame ? mFrame->GetContent() : mContent; |
| 3428 |
accService->ContentRemoved(presShell, content->GetParent(), content); |
3560 |
accService->ContentRemoved(presShell, content->GetParent(), content); |
| 3429 |
|
3561 |
|
| 3430 |
// Process children staying shown. |
3562 |
// Process children staying shown. |
| 3431 |
uint32_t visibleContentCount = mVisibleKidsOfHiddenElement.Length(); |
3563 |
uint32_t visibleContentCount = mVisibleKidsOfHiddenElement.Length(); |
| 3432 |
for (uint32_t idx = 0; idx < visibleContentCount; idx++) { |
3564 |
for (uint32_t idx = 0; idx < visibleContentCount; idx++) { |
| 3433 |
nsIContent* childContent = mVisibleKidsOfHiddenElement[idx]; |
3565 |
nsIContent* childContent = mVisibleKidsOfHiddenElement[idx]; |
| 3434 |
accService->ContentRangeInserted(presShell, childContent->GetParent(), |
3566 |
accService->ContentRangeInserted(presShell, childContent->GetParent(), |
| 3435 |
childContent, |
3567 |
childContent, |