|
|
|
Lines 803-819
RestyleManager::RestyleElement(Element*
|
Link Here
|
|---|
|
| 803 |
FrameConstructor()->RecreateFramesForContent(aElement, false); |
803 |
FrameConstructor()->RecreateFramesForContent(aElement, false); |
| 804 |
} else if (aPrimaryFrame) { |
804 |
} else if (aPrimaryFrame) { |
| 805 |
nsStyleChangeList changeList; |
805 |
nsStyleChangeList changeList; |
| 806 |
ComputeStyleChangeFor(aPrimaryFrame, &changeList, aMinHint, |
806 |
ComputeStyleChangeFor(aPrimaryFrame, &changeList, aMinHint, |
| 807 |
aRestyleTracker, aRestyleDescendants); |
807 |
aRestyleTracker, aRestyleDescendants); |
| 808 |
ProcessRestyledFrames(changeList); |
808 |
ProcessRestyledFrames(changeList); |
| 809 |
} else { |
809 |
} else { |
| 810 |
// no frames, reconstruct for content |
810 |
// no frames, reconstruct for content |
| 811 |
FrameConstructor()->MaybeRecreateFramesForElement(aElement); |
811 |
nsStyleContext* newContext = |
|
|
812 |
FrameConstructor()->MaybeRecreateFramesForElement(aElement); |
| 813 |
if (newContext && |
| 814 |
newContext->StyleDisplay()->mDisplay == NS_STYLE_DISPLAY_CONTENTS) { |
| 815 |
// Style change for a display:contents node that did not recreate frames. |
| 816 |
nsStyleChangeList changeList; |
| 817 |
{ |
| 818 |
// First, reresolve contexts for descendant undisplayed content. |
| 819 |
TreeMatchContext treeMatchContext(true, |
| 820 |
nsRuleWalker::eRelevantLinkUnvisited, |
| 821 |
mPresContext->Document()); |
| 822 |
nsIContent* parent = aElement->GetParent(); |
| 823 |
Element* parentElement = |
| 824 |
parent && parent->IsElement() ? parent->AsElement() : nullptr; |
| 825 |
treeMatchContext.InitAncestors(parentElement); |
| 826 |
nsTArray<nsIContent*> visibleKidsOfHiddenElement; |
| 827 |
ElementRestyler restyler(mPresContext, aElement, &changeList, |
| 828 |
aMinHint, aRestyleTracker, |
| 829 |
treeMatchContext, |
| 830 |
visibleKidsOfHiddenElement); |
| 831 |
restyler.DoRestyleUndisplayedDescendants(nsRestyleHint(0), aElement, |
| 832 |
newContext); |
| 833 |
} |
| 834 |
// Then process child frames for content that is a descendant of aElement. |
| 835 |
// XXX perhaps it's better to walk child frames (before reresolving |
| 836 |
// XXX undisplayed contexts above) and mark those that has a stylecontext |
| 837 |
// XXX leading up to aElement's old context? (instead of the |
| 838 |
// XXX ContentIsDescendantOf check below) |
| 839 |
nsIFrame* ancestorFrame = nullptr; |
| 840 |
for (nsIContent* ancestor = aElement->GetParent(); |
| 841 |
ancestor && !ancestorFrame; |
| 842 |
ancestor = ancestor->GetParent()) { |
| 843 |
ancestorFrame = ancestor->GetPrimaryFrame(); |
| 844 |
} |
| 845 |
MOZ_ASSERT(ancestorFrame, "display:contents node in map although it's a " |
| 846 |
"display:none descendant?"); |
| 847 |
nsIFrame::ChildListIterator lists(ancestorFrame); |
| 848 |
for ( ; !lists.IsDone(); lists.Next()) { |
| 849 |
nsFrameList::Enumerator childFrames(lists.CurrentList()); |
| 850 |
for (; !childFrames.AtEnd(); childFrames.Next()) { |
| 851 |
nsIFrame* f = childFrames.get(); |
| 852 |
nsIContent* c = f->GetContent(); |
| 853 |
if (nsContentUtils::ContentIsDescendantOf(c, aElement) && |
| 854 |
!f->GetPrevContinuation()) { |
| 855 |
if (!(f->GetStateBits() & NS_FRAME_OUT_OF_FLOW)) { |
| 856 |
ComputeStyleChangeFor(f, &changeList, aMinHint, |
| 857 |
aRestyleTracker, aRestyleDescendants); |
| 858 |
} |
| 859 |
} |
| 860 |
} |
| 861 |
} |
| 862 |
ProcessRestyledFrames(changeList); |
| 863 |
} |
| 812 |
} |
864 |
} |
| 813 |
} |
865 |
} |
| 814 |
|
866 |
|
| 815 |
// Forwarded nsIDocumentObserver method, to handle restyling (and |
867 |
// Forwarded nsIDocumentObserver method, to handle restyling (and |
| 816 |
// passing the notification to the frame). |
868 |
// passing the notification to the frame). |
| 817 |
nsresult |
869 |
nsresult |
| 818 |
RestyleManager::ContentStateChanged(nsIContent* aContent, |
870 |
RestyleManager::ContentStateChanged(nsIContent* aContent, |
| 819 |
nsEventStates aStateMask) |
871 |
nsEventStates aStateMask) |
|
Lines 1986-2001
ElementRestyler::ElementRestyler(ParentC
|
Link Here
|
|---|
|
| 1986 |
, mDesiredA11yNotifications(aParentRestyler.mDesiredA11yNotifications) |
2038 |
, mDesiredA11yNotifications(aParentRestyler.mDesiredA11yNotifications) |
| 1987 |
, mKidsDesiredA11yNotifications(mDesiredA11yNotifications) |
2039 |
, mKidsDesiredA11yNotifications(mDesiredA11yNotifications) |
| 1988 |
, mOurA11yNotification(eDontNotify) |
2040 |
, mOurA11yNotification(eDontNotify) |
| 1989 |
, mVisibleKidsOfHiddenElement(aParentRestyler.mVisibleKidsOfHiddenElement) |
2041 |
, mVisibleKidsOfHiddenElement(aParentRestyler.mVisibleKidsOfHiddenElement) |
| 1990 |
#endif |
2042 |
#endif |
| 1991 |
{ |
2043 |
{ |
| 1992 |
} |
2044 |
} |
| 1993 |
|
2045 |
|
|
|
2046 |
ElementRestyler::ElementRestyler(nsPresContext* aPresContext, |
| 2047 |
nsIContent* aContent, |
| 2048 |
nsStyleChangeList* aChangeList, |
| 2049 |
nsChangeHint aHintsHandledByAncestors, |
| 2050 |
RestyleTracker& aRestyleTracker, |
| 2051 |
TreeMatchContext& aTreeMatchContext, |
| 2052 |
nsTArray<nsIContent*>& |
| 2053 |
aVisibleKidsOfHiddenElement) |
| 2054 |
: mPresContext(aPresContext) |
| 2055 |
, mFrame(nullptr) |
| 2056 |
, mParentContent(nullptr) |
| 2057 |
, mContent(aContent) |
| 2058 |
, mChangeList(aChangeList) |
| 2059 |
, mHintsHandled(NS_SubtractHint(aHintsHandledByAncestors, |
| 2060 |
NS_HintsNotHandledForDescendantsIn(aHintsHandledByAncestors))) |
| 2061 |
, mParentFrameHintsNotHandledForDescendants(nsChangeHint(0)) |
| 2062 |
, mHintsNotHandledForDescendants(nsChangeHint(0)) |
| 2063 |
, mRestyleTracker(aRestyleTracker) |
| 2064 |
, mTreeMatchContext(aTreeMatchContext) |
| 2065 |
, mResolvedChild(nullptr) |
| 2066 |
#ifdef ACCESSIBILITY |
| 2067 |
, mDesiredA11yNotifications(eSendAllNotifications) |
| 2068 |
, mKidsDesiredA11yNotifications(mDesiredA11yNotifications) |
| 2069 |
, mOurA11yNotification(eDontNotify) |
| 2070 |
, mVisibleKidsOfHiddenElement(aVisibleKidsOfHiddenElement) |
| 2071 |
#endif |
| 2072 |
{ |
| 2073 |
} |
| 2074 |
|
| 1994 |
void |
2075 |
void |
| 1995 |
ElementRestyler::CaptureChange(nsStyleContext* aOldContext, |
2076 |
ElementRestyler::CaptureChange(nsStyleContext* aOldContext, |
| 1996 |
nsStyleContext* aNewContext, |
2077 |
nsStyleContext* aNewContext, |
| 1997 |
nsChangeHint aChangeToAssume) |
2078 |
nsChangeHint aChangeToAssume) |
| 1998 |
{ |
2079 |
{ |
| 1999 |
// Check some invariants about replacing one style context with another. |
2080 |
// Check some invariants about replacing one style context with another. |
| 2000 |
NS_ASSERTION(aOldContext->GetPseudo() == aNewContext->GetPseudo(), |
2081 |
NS_ASSERTION(aOldContext->GetPseudo() == aNewContext->GetPseudo(), |
| 2001 |
"old and new style contexts should have the same pseudo"); |
2082 |
"old and new style contexts should have the same pseudo"); |
|
Lines 2400-2436
ElementRestyler::RestyleUndisplayedDesce
|
Link Here
|
|---|
|
| 2400 |
checkUndisplayed = mFrame == mPresContext->FrameConstructor()-> |
2481 |
checkUndisplayed = mFrame == mPresContext->FrameConstructor()-> |
| 2401 |
GetDocElementContainingBlock(); |
2482 |
GetDocElementContainingBlock(); |
| 2402 |
undisplayedParent = nullptr; |
2483 |
undisplayedParent = nullptr; |
| 2403 |
} else { |
2484 |
} else { |
| 2404 |
checkUndisplayed = !!mFrame->GetContent(); |
2485 |
checkUndisplayed = !!mFrame->GetContent(); |
| 2405 |
undisplayedParent = mFrame->GetContent(); |
2486 |
undisplayedParent = mFrame->GetContent(); |
| 2406 |
} |
2487 |
} |
| 2407 |
if (checkUndisplayed) { |
2488 |
if (checkUndisplayed) { |
| 2408 |
DoRestyleUndisplayedDescendants(aChildRestyleHint, undisplayedParent); |
2489 |
DoRestyleUndisplayedDescendants(aChildRestyleHint, undisplayedParent, |
|
|
2490 |
mFrame->StyleContext()); |
| 2409 |
} |
2491 |
} |
| 2410 |
} |
2492 |
} |
| 2411 |
|
2493 |
|
| 2412 |
void |
2494 |
void |
| 2413 |
ElementRestyler::DoRestyleUndisplayedDescendants(nsRestyleHint aChildRestyleHint, |
2495 |
ElementRestyler::DoRestyleUndisplayedDescendants(nsRestyleHint aChildRestyleHint, |
| 2414 |
nsIContent* aParent) |
2496 |
nsIContent* aParent, |
|
|
2497 |
nsStyleContext* aParentContext) |
| 2415 |
{ |
2498 |
{ |
| 2416 |
nsCSSFrameConstructor* fc = mPresContext->FrameConstructor(); |
2499 |
nsCSSFrameConstructor* fc = mPresContext->FrameConstructor(); |
| 2417 |
UndisplayedNode* nodes = fc->GetAllUndisplayedContentIn(aParent); |
2500 |
UndisplayedNode* nodes = fc->GetAllUndisplayedContentIn(aParent); |
| 2418 |
RestyleUndisplayedNodes(aChildRestyleHint, nodes, aParent, |
2501 |
RestyleUndisplayedNodes(aChildRestyleHint, nodes, aParent, |
| 2419 |
NS_STYLE_DISPLAY_NONE); |
2502 |
aParentContext, NS_STYLE_DISPLAY_NONE); |
| 2420 |
nodes = fc->GetAllDisplayContentsIn(aParent); |
2503 |
nodes = fc->GetAllDisplayContentsIn(aParent); |
| 2421 |
RestyleUndisplayedNodes(aChildRestyleHint, nodes, aParent, |
2504 |
RestyleUndisplayedNodes(aChildRestyleHint, nodes, aParent, |
| 2422 |
NS_STYLE_DISPLAY_CONTENTS); |
2505 |
aParentContext, NS_STYLE_DISPLAY_CONTENTS); |
| 2423 |
} |
2506 |
} |
| 2424 |
|
2507 |
|
| 2425 |
void |
2508 |
void |
| 2426 |
ElementRestyler::RestyleUndisplayedNodes(nsRestyleHint aChildRestyleHint, |
2509 |
ElementRestyler::RestyleUndisplayedNodes(nsRestyleHint aChildRestyleHint, |
| 2427 |
UndisplayedNode* aUndisplayed, |
2510 |
UndisplayedNode* aUndisplayed, |
| 2428 |
nsIContent* aUndisplayedParent, |
2511 |
nsIContent* aUndisplayedParent, |
|
|
2512 |
nsStyleContext* aParentContext, |
| 2429 |
const uint8_t aDisplay) |
2513 |
const uint8_t aDisplay) |
| 2430 |
{ |
2514 |
{ |
| 2431 |
nsIContent* undisplayedParent = aUndisplayedParent; |
2515 |
nsIContent* undisplayedParent = aUndisplayedParent; |
| 2432 |
UndisplayedNode* undisplayed = aUndisplayed; |
2516 |
UndisplayedNode* undisplayed = aUndisplayed; |
| 2433 |
for (TreeMatchContext::AutoAncestorPusher |
2517 |
for (TreeMatchContext::AutoAncestorPusher |
| 2434 |
pushAncestor(undisplayed, mTreeMatchContext, |
2518 |
pushAncestor(undisplayed, mTreeMatchContext, |
| 2435 |
undisplayedParent ? undisplayedParent->AsElement() |
2519 |
undisplayedParent ? undisplayedParent->AsElement() |
| 2436 |
: nullptr); |
2520 |
: nullptr); |
|
Lines 2460-2496
ElementRestyler::RestyleUndisplayedNodes
|
Link Here
|
|---|
|
| 2460 |
thisChildHint = |
2544 |
thisChildHint = |
| 2461 |
nsRestyleHint(thisChildHint | undisplayedRestyleData.mRestyleHint); |
2545 |
nsRestyleHint(thisChildHint | undisplayedRestyleData.mRestyleHint); |
| 2462 |
} |
2546 |
} |
| 2463 |
nsRefPtr<nsStyleContext> undisplayedContext; |
2547 |
nsRefPtr<nsStyleContext> undisplayedContext; |
| 2464 |
nsStyleSet* styleSet = mPresContext->StyleSet(); |
2548 |
nsStyleSet* styleSet = mPresContext->StyleSet(); |
| 2465 |
if (thisChildHint) { |
2549 |
if (thisChildHint) { |
| 2466 |
undisplayedContext = |
2550 |
undisplayedContext = |
| 2467 |
styleSet->ResolveStyleFor(undisplayed->mContent->AsElement(), |
2551 |
styleSet->ResolveStyleFor(undisplayed->mContent->AsElement(), |
| 2468 |
mFrame->StyleContext(), |
2552 |
aParentContext, |
| 2469 |
mTreeMatchContext); |
2553 |
mTreeMatchContext); |
| 2470 |
} else { |
2554 |
} else { |
| 2471 |
undisplayedContext = |
2555 |
undisplayedContext = |
| 2472 |
styleSet->ReparentStyleContext(undisplayed->mStyle, |
2556 |
styleSet->ReparentStyleContext(undisplayed->mStyle, |
| 2473 |
mFrame->StyleContext(), |
2557 |
aParentContext, |
| 2474 |
undisplayed->mContent->AsElement()); |
2558 |
undisplayed->mContent->AsElement()); |
| 2475 |
} |
2559 |
} |
| 2476 |
const nsStyleDisplay* display = undisplayedContext->StyleDisplay(); |
2560 |
const nsStyleDisplay* display = undisplayedContext->StyleDisplay(); |
| 2477 |
if (display->mDisplay != aDisplay) { |
2561 |
if (display->mDisplay != aDisplay) { |
| 2478 |
NS_ASSERTION(undisplayed->mContent, "Must have undisplayed content"); |
2562 |
NS_ASSERTION(undisplayed->mContent, "Must have undisplayed content"); |
| 2479 |
mChangeList->AppendChange(nullptr, undisplayed->mContent, |
2563 |
mChangeList->AppendChange(nullptr, undisplayed->mContent, |
| 2480 |
NS_STYLE_HINT_FRAMECHANGE); |
2564 |
NS_STYLE_HINT_FRAMECHANGE); |
| 2481 |
// The node should be removed from the undisplayed map when |
2565 |
// The node should be removed from the undisplayed map when |
| 2482 |
// we reframe it. |
2566 |
// we reframe it. |
| 2483 |
} else { |
2567 |
} else { |
| 2484 |
// update the undisplayed node with the new context |
2568 |
// update the undisplayed node with the new context |
| 2485 |
undisplayed->mStyle = undisplayedContext; |
2569 |
undisplayed->mStyle = undisplayedContext; |
| 2486 |
|
2570 |
|
| 2487 |
if (aDisplay == NS_STYLE_DISPLAY_CONTENTS) { |
2571 |
if (aDisplay == NS_STYLE_DISPLAY_CONTENTS) { |
| 2488 |
DoRestyleUndisplayedDescendants(aChildRestyleHint, undisplayed->mContent); |
2572 |
DoRestyleUndisplayedDescendants(aChildRestyleHint, undisplayed->mContent, |
|
|
2573 |
undisplayed->mStyle); |
| 2489 |
} |
2574 |
} |
| 2490 |
} |
2575 |
} |
| 2491 |
} |
2576 |
} |
| 2492 |
} |
2577 |
} |
| 2493 |
|
2578 |
|
| 2494 |
void |
2579 |
void |
| 2495 |
ElementRestyler::RestyleBeforePseudo() |
2580 |
ElementRestyler::RestyleBeforePseudo() |
| 2496 |
{ |
2581 |
{ |