|
|
|
Lines 601-640
FindFirstNonBlock(const nsFrameList& aLi
|
Link Here
|
|---|
|
| 601 |
inline void |
601 |
inline void |
| 602 |
SetInitialSingleChild(nsContainerFrame* aParent, nsIFrame* aFrame) |
602 |
SetInitialSingleChild(nsContainerFrame* aParent, nsIFrame* aFrame) |
| 603 |
{ |
603 |
{ |
| 604 |
NS_PRECONDITION(!aFrame->GetNextSibling(), "Should be using a frame list"); |
604 |
NS_PRECONDITION(!aFrame->GetNextSibling(), "Should be using a frame list"); |
| 605 |
nsFrameList temp(aFrame, aFrame); |
605 |
nsFrameList temp(aFrame, aFrame); |
| 606 |
aParent->SetInitialChildList(kPrincipalList, temp); |
606 |
aParent->SetInitialChildList(kPrincipalList, temp); |
| 607 |
} |
607 |
} |
| 608 |
|
608 |
|
| 609 |
static nsContainerFrame* |
|
|
| 610 |
GetContentInsertionFrameFor(nsIContent* aContent) |
| 611 |
{ |
| 612 |
// Get the primary frame associated with the content |
| 613 |
nsIFrame* frame = aContent->GetPrimaryFrame(); |
| 614 |
|
| 615 |
if (!frame) |
| 616 |
return nullptr; |
| 617 |
|
| 618 |
// If the content of the frame is not the desired content then this is not |
| 619 |
// really a frame for the desired content. |
| 620 |
// XXX This check is needed due to bug 135040. Remove it once that's fixed. |
| 621 |
if (frame->GetContent() != aContent) { |
| 622 |
return nullptr; |
| 623 |
} |
| 624 |
|
| 625 |
nsContainerFrame* insertionFrame = frame->GetContentInsertionFrame(); |
| 626 |
|
| 627 |
NS_ASSERTION(!insertionFrame || insertionFrame == frame || !frame->IsLeaf(), |
| 628 |
"The insertion frame is the primary frame or the primary frame isn't a leaf"); |
| 629 |
|
| 630 |
return insertionFrame; |
| 631 |
} |
| 632 |
|
| 633 |
// ----------------------------------------------------------- |
609 |
// ----------------------------------------------------------- |
| 634 |
|
610 |
|
| 635 |
// Structure used when constructing formatting object trees. |
611 |
// Structure used when constructing formatting object trees. |
| 636 |
struct nsFrameItems : public nsFrameList |
612 |
struct nsFrameItems : public nsFrameList |
| 637 |
{ |
613 |
{ |
| 638 |
// Appends the frame to the end of the list |
614 |
// Appends the frame to the end of the list |
| 639 |
void AddChild(nsIFrame* aChild); |
615 |
void AddChild(nsIFrame* aChild); |
| 640 |
}; |
616 |
}; |
|
Lines 2252-2269
NeedFrameFor(const nsFrameConstructorSta
|
Link Here
|
|---|
|
| 2252 |
// whitespace. |
2228 |
// whitespace. |
| 2253 |
|
2229 |
|
| 2254 |
// We could handle all this in CreateNeededTablePseudos or some other place |
2230 |
// We could handle all this in CreateNeededTablePseudos or some other place |
| 2255 |
// after we build our frame construction items, but that would involve |
2231 |
// after we build our frame construction items, but that would involve |
| 2256 |
// creating frame construction items for whitespace kids of |
2232 |
// creating frame construction items for whitespace kids of |
| 2257 |
// eExcludesIgnorableWhitespace frames, where we know we'll be dropping them |
2233 |
// eExcludesIgnorableWhitespace frames, where we know we'll be dropping them |
| 2258 |
// all anyway, and involve an extra walk down the frame construction item |
2234 |
// all anyway, and involve an extra walk down the frame construction item |
| 2259 |
// list. |
2235 |
// list. |
| 2260 |
if (!aParentFrame->IsFrameOfType(nsIFrame::eExcludesIgnorableWhitespace) || |
2236 |
if ((aParentFrame && |
| 2261 |
aParentFrame->IsGeneratedContentFrame() || |
2237 |
(!aParentFrame->IsFrameOfType(nsIFrame::eExcludesIgnorableWhitespace) || |
|
|
2238 |
aParentFrame->IsGeneratedContentFrame())) || |
| 2262 |
!aChildContent->IsNodeOfType(nsINode::eTEXT)) { |
2239 |
!aChildContent->IsNodeOfType(nsINode::eTEXT)) { |
| 2263 |
return true; |
2240 |
return true; |
| 2264 |
} |
2241 |
} |
| 2265 |
|
2242 |
|
| 2266 |
aChildContent->SetFlags(NS_CREATE_FRAME_IF_NON_WHITESPACE | |
2243 |
aChildContent->SetFlags(NS_CREATE_FRAME_IF_NON_WHITESPACE | |
| 2267 |
NS_REFRAME_IF_WHITESPACE); |
2244 |
NS_REFRAME_IF_WHITESPACE); |
| 2268 |
return !aChildContent->TextIsOnlyWhitespace(); |
2245 |
return !aChildContent->TextIsOnlyWhitespace(); |
| 2269 |
} |
2246 |
} |
|
Lines 2436-2452
nsCSSFrameConstructor::ConstructDocEleme
|
Link Here
|
|---|
|
| 2436 |
|
2413 |
|
| 2437 |
#ifdef DEBUG |
2414 |
#ifdef DEBUG |
| 2438 |
NS_ASSERTION(!display->IsScrollableOverflow() || |
2415 |
NS_ASSERTION(!display->IsScrollableOverflow() || |
| 2439 |
state.mPresContext->IsPaginated() || |
2416 |
state.mPresContext->IsPaginated() || |
| 2440 |
propagatedScrollFrom == aDocElement, |
2417 |
propagatedScrollFrom == aDocElement, |
| 2441 |
"Scrollbars should have been propagated to the viewport"); |
2418 |
"Scrollbars should have been propagated to the viewport"); |
| 2442 |
#endif |
2419 |
#endif |
| 2443 |
|
2420 |
|
| 2444 |
if (MOZ_UNLIKELY(display->mDisplay == NS_STYLE_DISPLAY_NONE)) { |
2421 |
if (MOZ_UNLIKELY(display->mDisplayBox == NS_STYLE_DISPLAY_BOX_NONE)) { |
| 2445 |
SetUndisplayedContent(aDocElement, styleContext); |
2422 |
SetUndisplayedContent(aDocElement, styleContext); |
| 2446 |
return nullptr; |
2423 |
return nullptr; |
| 2447 |
} |
2424 |
} |
| 2448 |
|
2425 |
|
| 2449 |
TreeMatchContext::AutoAncestorPusher ancestorPusher(state.mTreeMatchContext); |
2426 |
TreeMatchContext::AutoAncestorPusher ancestorPusher(state.mTreeMatchContext); |
| 2450 |
ancestorPusher.PushAncestorAndStyleScope(aDocElement); |
2427 |
ancestorPusher.PushAncestorAndStyleScope(aDocElement); |
| 2451 |
|
2428 |
|
| 2452 |
// Make sure to start any background image loads for the root element now. |
2429 |
// Make sure to start any background image loads for the root element now. |
|
Lines 2572-2588
nsCSSFrameConstructor::ConstructDocEleme
|
Link Here
|
|---|
|
| 2572 |
NS_ASSERTION(processChildren ? !mRootElementFrame : |
2549 |
NS_ASSERTION(processChildren ? !mRootElementFrame : |
| 2573 |
mRootElementFrame == contentFrame, |
2550 |
mRootElementFrame == contentFrame, |
| 2574 |
"unexpected mRootElementFrame"); |
2551 |
"unexpected mRootElementFrame"); |
| 2575 |
mRootElementFrame = contentFrame; |
2552 |
mRootElementFrame = contentFrame; |
| 2576 |
|
2553 |
|
| 2577 |
// Figure out which frame has the main style for the document element, |
2554 |
// Figure out which frame has the main style for the document element, |
| 2578 |
// assigning it to mRootElementStyleFrame. |
2555 |
// assigning it to mRootElementStyleFrame. |
| 2579 |
// Backgrounds should be propagated from that frame to the viewport. |
2556 |
// Backgrounds should be propagated from that frame to the viewport. |
| 2580 |
mRootElementStyleFrame = contentFrame->GetParentStyleContextFrame(); |
2557 |
contentFrame->GetParentStyleContext(&mRootElementStyleFrame); |
| 2581 |
bool isChild = mRootElementStyleFrame && |
2558 |
bool isChild = mRootElementStyleFrame && |
| 2582 |
mRootElementStyleFrame->GetParent() == contentFrame; |
2559 |
mRootElementStyleFrame->GetParent() == contentFrame; |
| 2583 |
if (!isChild) { |
2560 |
if (!isChild) { |
| 2584 |
mRootElementStyleFrame = mRootElementFrame; |
2561 |
mRootElementStyleFrame = mRootElementFrame; |
| 2585 |
} |
2562 |
} |
| 2586 |
|
2563 |
|
| 2587 |
if (processChildren) { |
2564 |
if (processChildren) { |
| 2588 |
// Still need to process the child content |
2565 |
// Still need to process the child content |
|
Lines 3407-3422
IsFrameForFieldSet(nsIFrame* aFrame, nsI
|
Link Here
|
|---|
|
| 3407 |
/* static */ |
3384 |
/* static */ |
| 3408 |
const nsCSSFrameConstructor::FrameConstructionData* |
3385 |
const nsCSSFrameConstructor::FrameConstructionData* |
| 3409 |
nsCSSFrameConstructor::FindHTMLData(Element* aElement, |
3386 |
nsCSSFrameConstructor::FindHTMLData(Element* aElement, |
| 3410 |
nsIAtom* aTag, |
3387 |
nsIAtom* aTag, |
| 3411 |
int32_t aNameSpaceID, |
3388 |
int32_t aNameSpaceID, |
| 3412 |
nsIFrame* aParentFrame, |
3389 |
nsIFrame* aParentFrame, |
| 3413 |
nsStyleContext* aStyleContext) |
3390 |
nsStyleContext* aStyleContext) |
| 3414 |
{ |
3391 |
{ |
|
|
3392 |
MOZ_ASSERT(aStyleContext->StyleDisplay()->mDisplayBox != NS_STYLE_DISPLAY_BOX_NONE); |
| 3393 |
|
| 3415 |
// Ignore the tag if it's not HTML content and if it doesn't extend (via XBL) |
3394 |
// Ignore the tag if it's not HTML content and if it doesn't extend (via XBL) |
| 3416 |
// a valid HTML namespace. This check must match the one in |
3395 |
// a valid HTML namespace. This check must match the one in |
| 3417 |
// ShouldHaveFirstLineStyle. |
3396 |
// ShouldHaveFirstLineStyle. |
| 3418 |
if (aNameSpaceID != kNameSpaceID_XHTML) { |
3397 |
if (aNameSpaceID != kNameSpaceID_XHTML) { |
| 3419 |
return nullptr; |
3398 |
return nullptr; |
| 3420 |
} |
3399 |
} |
| 3421 |
|
3400 |
|
| 3422 |
NS_ASSERTION(!aParentFrame || |
3401 |
NS_ASSERTION(!aParentFrame || |
|
Lines 3652-3680
nsCSSFrameConstructor::ConstructFrameFro
|
Link Here
|
|---|
|
| 3652 |
|
3631 |
|
| 3653 |
// Don't create a subdocument frame for iframes if we're creating extra frames |
3632 |
// Don't create a subdocument frame for iframes if we're creating extra frames |
| 3654 |
if (aState.mCreatingExtraFrames && aItem.mContent->IsHTML() && |
3633 |
if (aState.mCreatingExtraFrames && aItem.mContent->IsHTML() && |
| 3655 |
aItem.mContent->Tag() == nsGkAtoms::iframe) |
3634 |
aItem.mContent->Tag() == nsGkAtoms::iframe) |
| 3656 |
{ |
3635 |
{ |
| 3657 |
return; |
3636 |
return; |
| 3658 |
} |
3637 |
} |
| 3659 |
|
3638 |
|
| 3660 |
nsStyleContext* const styleContext = aItem.mStyleContext; |
|
|
| 3661 |
const nsStyleDisplay* display = styleContext->StyleDisplay(); |
| 3662 |
nsIContent* const content = aItem.mContent; |
3639 |
nsIContent* const content = aItem.mContent; |
|
|
3640 |
nsIContent* parent = content->GetParent(); |
| 3641 |
|
| 3642 |
// Push display-box:contents ancestors. |
| 3643 |
AutoDisplayBoxContentsAncestorPusher adcp(aState.mTreeMatchContext, |
| 3644 |
aState.mPresContext, |
| 3645 |
parent); |
| 3663 |
|
3646 |
|
| 3664 |
// Get the parent of the content and check if it is a XBL children element. |
3647 |
// Get the parent of the content and check if it is a XBL children element. |
| 3665 |
// Push the children element as an ancestor here because it does |
3648 |
// Push the children element as an ancestor here because it does |
| 3666 |
// not have a frame and would not otherwise be pushed as an ancestor. It is |
3649 |
// not have a frame and would not otherwise be pushed as an ancestor. It is |
| 3667 |
// necessary to do so in order to correctly handle style resolution on |
3650 |
// necessary to do so in order to correctly handle style resolution on |
| 3668 |
// descendants. |
3651 |
// descendants. |
| 3669 |
nsIContent* parent = content->GetParent(); |
|
|
| 3670 |
TreeMatchContext::AutoAncestorPusher |
3652 |
TreeMatchContext::AutoAncestorPusher |
| 3671 |
insertionPointPusher(aState.mTreeMatchContext); |
3653 |
insertionPointPusher(aState.mTreeMatchContext); |
| 3672 |
if (parent && nsContentUtils::IsContentInsertionPoint(parent)) { |
3654 |
if (adcp.IsEmpty() && parent && nsContentUtils::IsContentInsertionPoint(parent)) { |
| 3673 |
if (aState.mTreeMatchContext.mAncestorFilter.HasFilter()) { |
3655 |
if (aState.mTreeMatchContext.mAncestorFilter.HasFilter()) { |
| 3674 |
insertionPointPusher.PushAncestorAndStyleScope(parent); |
3656 |
insertionPointPusher.PushAncestorAndStyleScope(parent); |
| 3675 |
} else { |
3657 |
} else { |
| 3676 |
insertionPointPusher.PushStyleScope(parent); |
3658 |
insertionPointPusher.PushStyleScope(parent); |
| 3677 |
} |
3659 |
} |
| 3678 |
} |
3660 |
} |
| 3679 |
|
3661 |
|
| 3680 |
// Push the content as a style ancestor now, so we don't have to do |
3662 |
// Push the content as a style ancestor now, so we don't have to do |
|
Lines 3690-3705
nsCSSFrameConstructor::ConstructFrameFro
|
Link Here
|
|---|
|
| 3690 |
if (aState.mTreeMatchContext.mAncestorFilter.HasFilter()) { |
3672 |
if (aState.mTreeMatchContext.mAncestorFilter.HasFilter()) { |
| 3691 |
ancestorPusher.PushAncestorAndStyleScope(content); |
3673 |
ancestorPusher.PushAncestorAndStyleScope(content); |
| 3692 |
} else { |
3674 |
} else { |
| 3693 |
ancestorPusher.PushStyleScope(content); |
3675 |
ancestorPusher.PushStyleScope(content); |
| 3694 |
} |
3676 |
} |
| 3695 |
|
3677 |
|
| 3696 |
nsIFrame* newFrame; |
3678 |
nsIFrame* newFrame; |
| 3697 |
nsIFrame* primaryFrame; |
3679 |
nsIFrame* primaryFrame; |
|
|
3680 |
nsStyleContext* const styleContext = aItem.mStyleContext; |
| 3681 |
const nsStyleDisplay* display = styleContext->StyleDisplay(); |
| 3698 |
if (bits & FCDATA_FUNC_IS_FULL_CTOR) { |
3682 |
if (bits & FCDATA_FUNC_IS_FULL_CTOR) { |
| 3699 |
newFrame = |
3683 |
newFrame = |
| 3700 |
(this->*(data->mFullConstructor))(aState, aItem, aParentFrame, |
3684 |
(this->*(data->mFullConstructor))(aState, aItem, aParentFrame, |
| 3701 |
display, aFrameItems); |
3685 |
display, aFrameItems); |
| 3702 |
MOZ_ASSERT(newFrame, "Full constructor failed"); |
3686 |
MOZ_ASSERT(newFrame, "Full constructor failed"); |
| 3703 |
primaryFrame = newFrame; |
3687 |
primaryFrame = newFrame; |
| 3704 |
} else { |
3688 |
} else { |
| 3705 |
newFrame = |
3689 |
newFrame = |
|
Lines 4452-4475
nsCSSFrameConstructor::BuildScrollFrame(
|
Link Here
|
|---|
|
| 4452 |
|
4436 |
|
| 4453 |
const nsCSSFrameConstructor::FrameConstructionData* |
4437 |
const nsCSSFrameConstructor::FrameConstructionData* |
| 4454 |
nsCSSFrameConstructor::FindDisplayData(const nsStyleDisplay* aDisplay, |
4438 |
nsCSSFrameConstructor::FindDisplayData(const nsStyleDisplay* aDisplay, |
| 4455 |
Element* aElement, |
4439 |
Element* aElement, |
| 4456 |
nsIFrame* aParentFrame, |
4440 |
nsIFrame* aParentFrame, |
| 4457 |
nsStyleContext* aStyleContext) |
4441 |
nsStyleContext* aStyleContext) |
| 4458 |
{ |
4442 |
{ |
| 4459 |
PR_STATIC_ASSERT(eParentTypeCount < (1 << (32 - FCDATA_PARENT_TYPE_OFFSET))); |
4443 |
PR_STATIC_ASSERT(eParentTypeCount < (1 << (32 - FCDATA_PARENT_TYPE_OFFSET))); |
|
|
4444 |
MOZ_ASSERT(aDisplay->mDisplayBox != NS_STYLE_DISPLAY_BOX_NONE); |
| 4460 |
|
4445 |
|
| 4461 |
// The style system ensures that floated and positioned frames are |
4446 |
// The style system ensures that floated and positioned frames are |
| 4462 |
// block-level. |
4447 |
// block-level. |
| 4463 |
NS_ASSERTION(!(aDisplay->IsFloatingStyle() || |
4448 |
NS_ASSERTION(!(aDisplay->IsFloatingStyle() || |
| 4464 |
aDisplay->IsAbsolutelyPositionedStyle()) || |
4449 |
aDisplay->IsAbsolutelyPositionedStyle()) || |
| 4465 |
aDisplay->IsBlockOutsideStyle(), |
4450 |
aDisplay->IsBlockOutsideStyle(), |
| 4466 |
"Style system did not apply CSS2.1 section 9.7 fixups"); |
4451 |
"Style system did not apply CSS2.1 section 9.7 fixups"); |
| 4467 |
|
4452 |
|
|
|
4453 |
if (aDisplay->mDisplayBox == NS_STYLE_DISPLAY_BOX_CONTENTS) { |
| 4454 |
// See the mDisplay/Box fixup code in nsRuleNode::ComputeDisplayData. |
| 4455 |
MOZ_ASSERT(!aElement->IsRootOfNativeAnonymousSubtree(), |
| 4456 |
"display-box:contents on anonymous content is unsupported"); |
| 4457 |
static const FrameConstructionData sDisplayBoxContentsData = |
| 4458 |
FULL_CTOR_FCDATA(FCDATA_IS_CONTENTS, nullptr/*never called*/); |
| 4459 |
return &sDisplayBoxContentsData; |
| 4460 |
} |
| 4461 |
|
| 4468 |
// If this is "body", try propagating its scroll style to the viewport |
4462 |
// If this is "body", try propagating its scroll style to the viewport |
| 4469 |
// Note that we need to do this even if the body is NOT scrollable; |
4463 |
// Note that we need to do this even if the body is NOT scrollable; |
| 4470 |
// it might have dynamically changed from scrollable to not scrollable, |
4464 |
// it might have dynamically changed from scrollable to not scrollable, |
| 4471 |
// and that might need to be propagated. |
4465 |
// and that might need to be propagated. |
| 4472 |
// XXXbz is this the right place to do this? If this code moves, |
4466 |
// XXXbz is this the right place to do this? If this code moves, |
| 4473 |
// make this function static. |
4467 |
// make this function static. |
| 4474 |
bool propagatedScrollToViewport = false; |
4468 |
bool propagatedScrollToViewport = false; |
| 4475 |
if (aElement->IsHTML(nsGkAtoms::body)) { |
4469 |
if (aElement->IsHTML(nsGkAtoms::body)) { |
|
Lines 4683-4713
nsCSSFrameConstructor::InitAndRestoreFra
|
Link Here
|
|---|
|
| 4683 |
} |
4677 |
} |
| 4684 |
} |
4678 |
} |
| 4685 |
|
4679 |
|
| 4686 |
already_AddRefed<nsStyleContext> |
4680 |
already_AddRefed<nsStyleContext> |
| 4687 |
nsCSSFrameConstructor::ResolveStyleContext(nsIFrame* aParentFrame, |
4681 |
nsCSSFrameConstructor::ResolveStyleContext(nsIFrame* aParentFrame, |
| 4688 |
nsIContent* aContent, |
4682 |
nsIContent* aContent, |
| 4689 |
nsFrameConstructorState* aState) |
4683 |
nsFrameConstructorState* aState) |
| 4690 |
{ |
4684 |
{ |
| 4691 |
nsStyleContext* parentStyleContext = nullptr; |
4685 |
nsIContent* container = aContent->GetParent(); |
| 4692 |
NS_ASSERTION(aContent->GetParent(), "Must have parent here"); |
4686 |
NS_ASSERTION(container, "Must have parent here"); |
| 4693 |
|
4687 |
nsStyleContext* parentStyleContext = GetDisplayBoxContentsStyleFor(container); |
| 4694 |
aParentFrame = nsFrame::CorrectStyleParentFrame(aParentFrame, nullptr); |
4688 |
if (MOZ_LIKELY(!parentStyleContext)) { |
| 4695 |
|
4689 |
aParentFrame = nsFrame::CorrectStyleParentFrame(aParentFrame, nullptr); |
| 4696 |
if (aParentFrame) { |
4690 |
if (aParentFrame) { |
| 4697 |
// Resolve the style context based on the content object and the parent |
4691 |
// Resolve the style context based on the content object and the parent |
| 4698 |
// style context |
4692 |
// style context |
| 4699 |
parentStyleContext = aParentFrame->StyleContext(); |
4693 |
parentStyleContext = aParentFrame->StyleContext(); |
| 4700 |
} else { |
4694 |
} else { |
| 4701 |
// Perhaps aParentFrame is a canvasFrame and we're replicating |
4695 |
// Perhaps aParentFrame is a canvasFrame and we're replicating |
| 4702 |
// fixed-pos frames. |
4696 |
// fixed-pos frames. |
| 4703 |
// XXX should we create a way to tell ConstructFrame which style |
4697 |
// XXX should we create a way to tell ConstructFrame which style |
| 4704 |
// context to use, and pass it the style context for the |
4698 |
// context to use, and pass it the style context for the |
| 4705 |
// previous page's fixed-pos frame? |
4699 |
// previous page's fixed-pos frame? |
|
|
4700 |
} |
| 4706 |
} |
4701 |
} |
| 4707 |
|
4702 |
|
| 4708 |
return ResolveStyleContext(parentStyleContext, aContent, aState); |
4703 |
return ResolveStyleContext(parentStyleContext, aContent, aState); |
| 4709 |
} |
4704 |
} |
| 4710 |
|
4705 |
|
| 4711 |
already_AddRefed<nsStyleContext> |
4706 |
already_AddRefed<nsStyleContext> |
| 4712 |
nsCSSFrameConstructor::ResolveStyleContext(nsStyleContext* aParentStyleContext, |
4707 |
nsCSSFrameConstructor::ResolveStyleContext(nsStyleContext* aParentStyleContext, |
| 4713 |
nsIContent* aContent, |
4708 |
nsIContent* aContent, |
|
Lines 5203-5224
nsCSSFrameConstructor::AddPageBreakItem(
|
Link Here
|
|---|
|
| 5203 |
|
5198 |
|
| 5204 |
// Lie about the tag and namespace so we don't trigger anything |
5199 |
// Lie about the tag and namespace so we don't trigger anything |
| 5205 |
// interesting during frame construction. |
5200 |
// interesting during frame construction. |
| 5206 |
aItems.AppendItem(&sPageBreakData, aContent, nsCSSAnonBoxes::pageBreak, |
5201 |
aItems.AppendItem(&sPageBreakData, aContent, nsCSSAnonBoxes::pageBreak, |
| 5207 |
kNameSpaceID_None, nullptr, pseudoStyle.forget(), |
5202 |
kNameSpaceID_None, nullptr, pseudoStyle.forget(), |
| 5208 |
true, nullptr); |
5203 |
true, nullptr); |
| 5209 |
} |
5204 |
} |
| 5210 |
|
5205 |
|
| 5211 |
void |
5206 |
bool |
| 5212 |
nsCSSFrameConstructor::AddFrameConstructionItems(nsFrameConstructorState& aState, |
5207 |
nsCSSFrameConstructor::ShouldCreateItemsForChild(nsFrameConstructorState& aState, |
| 5213 |
nsIContent* aContent, |
5208 |
nsIContent* aContent, |
| 5214 |
bool aSuppressWhiteSpaceOptimizations, |
5209 |
nsContainerFrame* aParentFrame) |
| 5215 |
nsContainerFrame* aParentFrame, |
|
|
| 5216 |
FrameConstructionItemList& aItems) |
| 5217 |
{ |
5210 |
{ |
| 5218 |
aContent->UnsetFlags(NODE_DESCENDANTS_NEED_FRAMES | NODE_NEEDS_FRAME); |
5211 |
aContent->UnsetFlags(NODE_DESCENDANTS_NEED_FRAMES | NODE_NEEDS_FRAME); |
| 5219 |
if (aContent->IsElement()) { |
5212 |
if (aContent->IsElement()) { |
| 5220 |
// We can't just remove our pending restyle flags, since we may |
5213 |
// We can't just remove our pending restyle flags, since we may |
| 5221 |
// have restyle-later-siblings set on us. But we _can_ remove the |
5214 |
// have restyle-later-siblings set on us. But we _can_ remove the |
| 5222 |
// "is possible restyle root" flags, and need to. Otherwise we can |
5215 |
// "is possible restyle root" flags, and need to. Otherwise we can |
| 5223 |
// end up with stale such flags (e.g. if we used to have a |
5216 |
// end up with stale such flags (e.g. if we used to have a |
| 5224 |
// display:none parent when our last restyle was posted and |
5217 |
// display:none parent when our last restyle was posted and |
|
Lines 5229-5276
nsCSSFrameConstructor::AddFrameConstruct
|
Link Here
|
|---|
|
| 5229 |
|
5222 |
|
| 5230 |
// XXX the GetContent() != aContent check is needed due to bug 135040. |
5223 |
// XXX the GetContent() != aContent check is needed due to bug 135040. |
| 5231 |
// Remove it once that's fixed. |
5224 |
// Remove it once that's fixed. |
| 5232 |
if (aContent->GetPrimaryFrame() && |
5225 |
if (aContent->GetPrimaryFrame() && |
| 5233 |
aContent->GetPrimaryFrame()->GetContent() == aContent && |
5226 |
aContent->GetPrimaryFrame()->GetContent() == aContent && |
| 5234 |
!aState.mCreatingExtraFrames) { |
5227 |
!aState.mCreatingExtraFrames) { |
| 5235 |
NS_ERROR("asked to create frame construction item for a node that already " |
5228 |
NS_ERROR("asked to create frame construction item for a node that already " |
| 5236 |
"has a frame"); |
5229 |
"has a frame"); |
| 5237 |
return; |
5230 |
return false; |
| 5238 |
} |
5231 |
} |
| 5239 |
|
5232 |
|
| 5240 |
// don't create a whitespace frame if aParent doesn't want it |
5233 |
// don't create a whitespace frame if aParent doesn't want it |
| 5241 |
if (!NeedFrameFor(aState, aParentFrame, aContent)) { |
5234 |
if (!NeedFrameFor(aState, aParentFrame, aContent)) { |
| 5242 |
return; |
5235 |
return false; |
| 5243 |
} |
5236 |
} |
| 5244 |
|
5237 |
|
| 5245 |
// never create frames for comments or PIs |
5238 |
// never create frames for comments or PIs |
| 5246 |
if (aContent->IsNodeOfType(nsINode::eCOMMENT) || |
5239 |
if (aContent->IsNodeOfType(nsINode::eCOMMENT) || |
| 5247 |
aContent->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) |
5240 |
aContent->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) { |
| 5248 |
return; |
5241 |
return false; |
| 5249 |
|
5242 |
} |
| 5250 |
nsRefPtr<nsStyleContext> styleContext; |
5243 |
|
| 5251 |
styleContext = ResolveStyleContext(aParentFrame, aContent, &aState); |
5244 |
return true; |
| 5252 |
|
5245 |
} |
|
|
5246 |
|
| 5247 |
void |
| 5248 |
nsCSSFrameConstructor::DoAddFrameConstructionItems(nsFrameConstructorState& aState, |
| 5249 |
nsIContent* aContent, |
| 5250 |
nsStyleContext* aStyleContext, |
| 5251 |
bool aSuppressWhiteSpaceOptimizations, |
| 5252 |
nsContainerFrame* aParentFrame, |
| 5253 |
nsTArray<nsIAnonymousContentCreator::ContentInfo>* aAnonChildren, |
| 5254 |
FrameConstructionItemList& aItems) |
| 5255 |
{ |
| 5253 |
uint32_t flags = ITEM_ALLOW_XBL_BASE | ITEM_ALLOW_PAGE_BREAK; |
5256 |
uint32_t flags = ITEM_ALLOW_XBL_BASE | ITEM_ALLOW_PAGE_BREAK; |
| 5254 |
if (aParentFrame->IsSVGText()) { |
5257 |
if (aParentFrame) { |
| 5255 |
flags |= ITEM_IS_WITHIN_SVG_TEXT; |
5258 |
if (aParentFrame->IsSVGText()) { |
| 5256 |
} |
5259 |
flags |= ITEM_IS_WITHIN_SVG_TEXT; |
| 5257 |
if (aParentFrame->GetType() == nsGkAtoms::blockFrame && |
5260 |
} |
| 5258 |
aParentFrame->GetParent() && |
5261 |
if (aParentFrame->GetType() == nsGkAtoms::blockFrame && |
| 5259 |
aParentFrame->GetParent()->GetType() == nsGkAtoms::svgTextFrame) { |
5262 |
aParentFrame->GetParent() && |
| 5260 |
flags |= ITEM_ALLOWS_TEXT_PATH_CHILD; |
5263 |
aParentFrame->GetParent()->GetType() == nsGkAtoms::svgTextFrame) { |
|
|
5264 |
flags |= ITEM_ALLOWS_TEXT_PATH_CHILD; |
| 5265 |
} |
| 5261 |
} |
5266 |
} |
| 5262 |
AddFrameConstructionItemsInternal(aState, aContent, aParentFrame, |
5267 |
AddFrameConstructionItemsInternal(aState, aContent, aParentFrame, |
| 5263 |
aContent->Tag(), aContent->GetNameSpaceID(), |
5268 |
aContent->Tag(), aContent->GetNameSpaceID(), |
| 5264 |
aSuppressWhiteSpaceOptimizations, |
5269 |
aSuppressWhiteSpaceOptimizations, |
| 5265 |
styleContext, |
5270 |
aStyleContext, |
| 5266 |
flags, nullptr, |
5271 |
flags, aAnonChildren, |
| 5267 |
aItems); |
5272 |
aItems); |
| 5268 |
} |
5273 |
} |
|
|
5274 |
|
| 5275 |
void |
| 5276 |
nsCSSFrameConstructor::AddFrameConstructionItems(nsFrameConstructorState& aState, |
| 5277 |
nsIContent* aContent, |
| 5278 |
bool aSuppressWhiteSpaceOptimizations, |
| 5279 |
nsContainerFrame* aParentFrame, |
| 5280 |
FrameConstructionItemList& aItems) |
| 5281 |
{ |
| 5282 |
if (!ShouldCreateItemsForChild(aState, aContent, aParentFrame)) { |
| 5283 |
return; |
| 5284 |
} |
| 5285 |
nsRefPtr<nsStyleContext> styleContext = |
| 5286 |
ResolveStyleContext(aParentFrame, aContent, &aState); |
| 5287 |
DoAddFrameConstructionItems(aState, aContent, styleContext, |
| 5288 |
aSuppressWhiteSpaceOptimizations, aParentFrame, |
| 5289 |
nullptr, aItems); |
| 5290 |
} |
| 5269 |
|
5291 |
|
| 5270 |
/* static */ void |
5292 |
/* static */ void |
| 5271 |
nsCSSFrameConstructor::SetAsUndisplayedContent(FrameConstructionItemList& aList, |
5293 |
nsCSSFrameConstructor::SetAsUndisplayedContent(FrameConstructionItemList& aList, |
| 5272 |
nsIContent* aContent, |
5294 |
nsIContent* aContent, |
| 5273 |
nsStyleContext* aStyleContext, |
5295 |
nsStyleContext* aStyleContext, |
| 5274 |
bool aIsGeneratedContent) |
5296 |
bool aIsGeneratedContent) |
| 5275 |
{ |
5297 |
{ |
| 5276 |
if (aStyleContext->GetPseudo()) { |
5298 |
if (aStyleContext->GetPseudo()) { |
|
Lines 5338-5356
nsCSSFrameConstructor::AddFrameConstruct
|
Link Here
|
|---|
|
| 5338 |
aStyleContext = styleContext; |
5360 |
aStyleContext = styleContext; |
| 5339 |
} |
5361 |
} |
| 5340 |
|
5362 |
|
| 5341 |
aTag = mDocument->BindingManager()->ResolveTag(aContent, &aNameSpaceID); |
5363 |
aTag = mDocument->BindingManager()->ResolveTag(aContent, &aNameSpaceID); |
| 5342 |
} |
5364 |
} |
| 5343 |
|
5365 |
|
| 5344 |
bool isGeneratedContent = ((aFlags & ITEM_IS_GENERATED_CONTENT) != 0); |
5366 |
bool isGeneratedContent = ((aFlags & ITEM_IS_GENERATED_CONTENT) != 0); |
| 5345 |
|
5367 |
|
| 5346 |
// Pre-check for display "none" - if we find that, don't create |
5368 |
// Pre-check for display-box:none - if we find that, don't create any frame at all. |
| 5347 |
// any frame at all |
5369 |
if (NS_STYLE_DISPLAY_BOX_NONE == display->mDisplayBox) { |
| 5348 |
if (NS_STYLE_DISPLAY_NONE == display->mDisplay) { |
|
|
| 5349 |
SetAsUndisplayedContent(aItems, aContent, styleContext, isGeneratedContent); |
5370 |
SetAsUndisplayedContent(aItems, aContent, styleContext, isGeneratedContent); |
| 5350 |
return; |
5371 |
return; |
| 5351 |
} |
5372 |
} |
| 5352 |
|
5373 |
|
| 5353 |
bool isText = !aContent->IsElement(); |
5374 |
bool isText = !aContent->IsElement(); |
| 5354 |
|
5375 |
|
| 5355 |
// never create frames for non-option/optgroup kids of <select> and |
5376 |
// never create frames for non-option/optgroup kids of <select> and |
| 5356 |
// non-option kids of <optgroup> inside a <select>. |
5377 |
// non-option kids of <optgroup> inside a <select>. |
|
Lines 5465-5480
nsCSSFrameConstructor::AddFrameConstruct
|
Link Here
|
|---|
|
| 5465 |
!display->IsAbsolutelyPositionedStyle() && |
5486 |
!display->IsAbsolutelyPositionedStyle() && |
| 5466 |
!(bits & FCDATA_IS_TABLE_PART) && |
5487 |
!(bits & FCDATA_IS_TABLE_PART) && |
| 5467 |
!(bits & FCDATA_IS_SVG_TEXT); |
5488 |
!(bits & FCDATA_IS_SVG_TEXT); |
| 5468 |
|
5489 |
|
| 5469 |
if (canHavePageBreak && display->mBreakBefore) { |
5490 |
if (canHavePageBreak && display->mBreakBefore) { |
| 5470 |
AddPageBreakItem(aContent, aStyleContext, aItems); |
5491 |
AddPageBreakItem(aContent, aStyleContext, aItems); |
| 5471 |
} |
5492 |
} |
| 5472 |
|
5493 |
|
|
|
5494 |
if (MOZ_UNLIKELY(bits & FCDATA_IS_CONTENTS)) { |
| 5495 |
if (!GetDisplayBoxContentsStyleFor(aContent)) { |
| 5496 |
MOZ_ASSERT(styleContext->GetPseudo() || !isGeneratedContent, |
| 5497 |
"Should have had pseudo type"); |
| 5498 |
aState.mFrameManager->SetDisplayBoxContents(aContent, styleContext); |
| 5499 |
} else { |
| 5500 |
aState.mFrameManager->ChangeDisplayBoxContents(aContent, styleContext); |
| 5501 |
} |
| 5502 |
|
| 5503 |
TreeMatchContext::AutoAncestorPusher ancestorPusher(aState.mTreeMatchContext); |
| 5504 |
if (aState.mTreeMatchContext.mAncestorFilter.HasFilter()) { |
| 5505 |
ancestorPusher.PushAncestorAndStyleScope(aContent->AsElement()); |
| 5506 |
} else { |
| 5507 |
ancestorPusher.PushStyleScope(aContent->AsElement()); |
| 5508 |
} |
| 5509 |
|
| 5510 |
if (aParentFrame) { |
| 5511 |
aParentFrame->AddStateBits(NS_FRAME_MAY_HAVE_GENERATED_CONTENT); |
| 5512 |
} |
| 5513 |
CreateGeneratedContentItem(aState, aParentFrame, aContent, styleContext, |
| 5514 |
nsCSSPseudoElements::ePseudo_before, aItems); |
| 5515 |
|
| 5516 |
FlattenedChildIterator iter(aContent); |
| 5517 |
for (nsIContent* child = iter.GetNextChild(); child; child = iter.GetNextChild()) { |
| 5518 |
if (!ShouldCreateItemsForChild(aState, child, aParentFrame)) { |
| 5519 |
continue; |
| 5520 |
} |
| 5521 |
|
| 5522 |
// Get the parent of the content and check if it is a XBL children element |
| 5523 |
// (if the content is a children element then parent != aContent because the |
| 5524 |
// FlattenedChildIterator will transitively iterate through <xbl:children> |
| 5525 |
// for default content). Push the children element as an ancestor here because |
| 5526 |
// it does not have a frame and would not otherwise be pushed as an ancestor. |
| 5527 |
nsIContent* parent = child->GetParent(); |
| 5528 |
MOZ_ASSERT(parent, "Parent must be non-null because we are iterating children."); |
| 5529 |
TreeMatchContext::AutoAncestorPusher ancestorPusher(aState.mTreeMatchContext); |
| 5530 |
if (parent != aContent && parent->IsElement()) { |
| 5531 |
if (aState.mTreeMatchContext.mAncestorFilter.HasFilter()) { |
| 5532 |
ancestorPusher.PushAncestorAndStyleScope(parent->AsElement()); |
| 5533 |
} else { |
| 5534 |
ancestorPusher.PushStyleScope(parent->AsElement()); |
| 5535 |
} |
| 5536 |
} |
| 5537 |
|
| 5538 |
nsRefPtr<nsStyleContext> childContext = |
| 5539 |
ResolveStyleContext(styleContext, child, nullptr); |
| 5540 |
DoAddFrameConstructionItems(aState, child, childContext, |
| 5541 |
aSuppressWhiteSpaceOptimizations, |
| 5542 |
aParentFrame, aAnonChildren, aItems); |
| 5543 |
} |
| 5544 |
aItems.SetParentHasNoXBLChildren(!iter.XBLInvolved()); |
| 5545 |
|
| 5546 |
CreateGeneratedContentItem(aState, aParentFrame, aContent, styleContext, |
| 5547 |
nsCSSPseudoElements::ePseudo_after, aItems); |
| 5548 |
if (canHavePageBreak && display->mBreakAfter) { |
| 5549 |
AddPageBreakItem(aContent, aStyleContext, aItems); |
| 5550 |
} |
| 5551 |
return; |
| 5552 |
} |
| 5553 |
|
| 5473 |
FrameConstructionItem* item = |
5554 |
FrameConstructionItem* item = |
| 5474 |
aItems.AppendItem(data, aContent, aTag, aNameSpaceID, |
5555 |
aItems.AppendItem(data, aContent, aTag, aNameSpaceID, |
| 5475 |
pendingBinding, styleContext.forget(), |
5556 |
pendingBinding, styleContext.forget(), |
| 5476 |
aSuppressWhiteSpaceOptimizations, aAnonChildren); |
5557 |
aSuppressWhiteSpaceOptimizations, aAnonChildren); |
| 5477 |
if (!item) { |
5558 |
if (!item) { |
| 5478 |
if (isGeneratedContent) { |
5559 |
if (isGeneratedContent) { |
| 5479 |
aContent->UnbindFromTree(); |
5560 |
aContent->UnbindFromTree(); |
| 5480 |
} |
5561 |
} |
|
Lines 5571-5604
nsCSSFrameConstructor::AddFrameConstruct
|
Link Here
|
|---|
|
| 5571 |
((bits & FCDATA_DISALLOW_OUT_OF_FLOW) || |
5652 |
((bits & FCDATA_DISALLOW_OUT_OF_FLOW) || |
| 5572 |
!aState.GetGeometricParent(display, nullptr))) { |
5653 |
!aState.GetGeometricParent(display, nullptr))) { |
| 5573 |
item->mIsLineParticipant = true; |
5654 |
item->mIsLineParticipant = true; |
| 5574 |
aItems.LineParticipantItemAdded(); |
5655 |
aItems.LineParticipantItemAdded(); |
| 5575 |
} |
5656 |
} |
| 5576 |
} |
5657 |
} |
| 5577 |
|
5658 |
|
| 5578 |
static void |
5659 |
static void |
| 5579 |
DestroyContent(void* aPropertyValue) |
5660 |
AddGenConPseudoToFrame(nsIFrame* aOwnerFrame, nsIContent* aContent) |
| 5580 |
{ |
5661 |
{ |
| 5581 |
nsIContent* content = static_cast<nsIContent*>(aPropertyValue); |
5662 |
typedef nsAutoTArray<nsIContent*, 2> T; |
| 5582 |
content->UnbindFromTree(); |
5663 |
const FramePropertyDescriptor* prop = nsIFrame::GenConProperty(); |
| 5583 |
NS_RELEASE(content); |
5664 |
FrameProperties props = aOwnerFrame->Properties(); |
| 5584 |
} |
5665 |
T* value = static_cast<T*>(props.Get(prop)); |
| 5585 |
|
5666 |
if (!value) { |
| 5586 |
NS_DECLARE_FRAME_PROPERTY(BeforeProperty, DestroyContent) |
5667 |
value = new T; |
| 5587 |
NS_DECLARE_FRAME_PROPERTY(AfterProperty, DestroyContent) |
5668 |
props.Set(prop, value); |
| 5588 |
|
5669 |
} |
| 5589 |
static const FramePropertyDescriptor* |
5670 |
value->AppendElement(aContent); |
| 5590 |
GenConPseudoToProperty(nsIAtom* aPseudo) |
|
|
| 5591 |
{ |
| 5592 |
NS_ASSERTION(aPseudo == nsCSSPseudoElements::before || |
| 5593 |
aPseudo == nsCSSPseudoElements::after, |
| 5594 |
"Bad gen-con pseudo"); |
| 5595 |
return aPseudo == nsCSSPseudoElements::before ? BeforeProperty() |
| 5596 |
: AfterProperty(); |
| 5597 |
} |
5671 |
} |
| 5598 |
|
5672 |
|
| 5599 |
/** |
5673 |
/** |
| 5600 |
* Return true if the frame construction item pointed to by aIter will |
5674 |
* Return true if the frame construction item pointed to by aIter will |
| 5601 |
* create a frame adjacent to a line boundary in the frame tree, and that |
5675 |
* create a frame adjacent to a line boundary in the frame tree, and that |
| 5602 |
* line boundary is induced by a content node adjacent to the frame's |
5676 |
* line boundary is induced by a content node adjacent to the frame's |
| 5603 |
* content node in the content tree. The latter condition is necessary so |
5677 |
* content node in the content tree. The latter condition is necessary so |
| 5604 |
* that ContentAppended/ContentInserted/ContentRemoved can easily find any |
5678 |
* that ContentAppended/ContentInserted/ContentRemoved can easily find any |
|
Lines 5692-5709
nsCSSFrameConstructor::ConstructFramesFr
|
Link Here
|
|---|
|
| 5692 |
// NS_FRAME_GENERATED_CONTENT. |
5766 |
// NS_FRAME_GENERATED_CONTENT. |
| 5693 |
aState.mAdditionalStateBits |= NS_FRAME_GENERATED_CONTENT; |
5767 |
aState.mAdditionalStateBits |= NS_FRAME_GENERATED_CONTENT; |
| 5694 |
|
5768 |
|
| 5695 |
// Note that we're not necessarily setting this property on the primary |
5769 |
// Note that we're not necessarily setting this property on the primary |
| 5696 |
// frame for the content for which this is generated content. We might be |
5770 |
// frame for the content for which this is generated content. We might be |
| 5697 |
// setting it on a table pseudo-frame inserted under that instead. That's |
5771 |
// setting it on a table pseudo-frame inserted under that instead. That's |
| 5698 |
// OK, though; we just need to do the property set so that the content will |
5772 |
// OK, though; we just need to do the property set so that the content will |
| 5699 |
// get cleaned up when the frame is destroyed. |
5773 |
// get cleaned up when the frame is destroyed. |
| 5700 |
aParentFrame->Properties().Set(GenConPseudoToProperty(styleContext->GetPseudo()), |
5774 |
::AddGenConPseudoToFrame(aParentFrame, item.mContent); |
| 5701 |
item.mContent); |
|
|
| 5702 |
|
5775 |
|
| 5703 |
// Now that we've passed ownership of item.mContent to the frame, unset |
5776 |
// Now that we've passed ownership of item.mContent to the frame, unset |
| 5704 |
// our generated content flag so we don't release or unbind it ourselves. |
5777 |
// our generated content flag so we don't release or unbind it ourselves. |
| 5705 |
item.mIsGeneratedContent = false; |
5778 |
item.mIsGeneratedContent = false; |
| 5706 |
} |
5779 |
} |
| 5707 |
|
5780 |
|
| 5708 |
// XXXbz maybe just inline ConstructFrameFromItemInternal here or something? |
5781 |
// XXXbz maybe just inline ConstructFrameFromItemInternal here or something? |
| 5709 |
ConstructFrameFromItemInternal(item, aState, adjParentFrame, aFrameItems); |
5782 |
ConstructFrameFromItemInternal(item, aState, adjParentFrame, aFrameItems); |
|
Lines 5827-5857
nsCSSFrameConstructor::GetFloatContainin
|
Link Here
|
|---|
|
| 5827 |
|
5900 |
|
| 5828 |
/** |
5901 |
/** |
| 5829 |
* This function will check whether aContainer has :after generated content. |
5902 |
* This function will check whether aContainer has :after generated content. |
| 5830 |
* If so, appending to it should actually insert. The return value is the |
5903 |
* If so, appending to it should actually insert. The return value is the |
| 5831 |
* parent to use for newly-appended content. *aAfterFrame points to the :after |
5904 |
* parent to use for newly-appended content. *aAfterFrame points to the :after |
| 5832 |
* frame before which appended content should go, if there is one. |
5905 |
* frame before which appended content should go, if there is one. |
| 5833 |
*/ |
5906 |
*/ |
| 5834 |
static nsContainerFrame* |
5907 |
static nsContainerFrame* |
| 5835 |
AdjustAppendParentForAfterContent(nsPresContext* aPresContext, |
5908 |
AdjustAppendParentForAfterContent(nsFrameManager* aFrameManager, |
| 5836 |
nsIContent* aContainer, |
5909 |
nsIContent* aContainer, |
| 5837 |
nsContainerFrame* aParentFrame, |
5910 |
nsContainerFrame* aParentFrame, |
|
|
5911 |
nsIContent* aChild, |
| 5838 |
nsIFrame** aAfterFrame) |
5912 |
nsIFrame** aAfterFrame) |
| 5839 |
{ |
5913 |
{ |
| 5840 |
// See if the parent has an :after pseudo-element. Check for the presence |
5914 |
// If the parent frame has any pseudo-elements or aContainer is a |
| 5841 |
// of style first, since nsLayoutUtils::GetAfterFrame is sorta expensive. |
5915 |
// display-box:contents node then we need to walk through the child |
| 5842 |
nsStyleContext* parentStyle = aParentFrame->StyleContext(); |
5916 |
// frames to find the first one that is either a ::after frame for an |
| 5843 |
if (nsLayoutUtils::HasPseudoStyle(aContainer, parentStyle, |
5917 |
// ancestor of aChild or a frame that is for a node later in the |
|
|
5918 |
// document than aChild and return that in aAfterFrame. |
| 5919 |
if (aParentFrame->GetGenConPseudos() || |
| 5920 |
nsLayoutUtils::HasPseudoStyle(aContainer, aParentFrame->StyleContext(), |
| 5844 |
nsCSSPseudoElements::ePseudo_after, |
5921 |
nsCSSPseudoElements::ePseudo_after, |
| 5845 |
aPresContext)) { |
5922 |
aParentFrame->PresContext()) || |
| 5846 |
// Ensure that the :after frame is on the principal child list. |
5923 |
aFrameManager->GetDisplayBoxContentsStyleFor(aContainer)) { |
| 5847 |
aParentFrame->DrainSelfOverflowList(); |
5924 |
nsIFrame* afterFrame = nullptr; |
| 5848 |
|
5925 |
nsContainerFrame* parent = |
| 5849 |
nsIFrame* afterFrame = nsLayoutUtils::GetAfterFrame(aParentFrame); |
5926 |
static_cast<nsContainerFrame*>(aParentFrame->LastContinuation()); |
|
|
5927 |
bool done = false; |
| 5928 |
while (!done && parent) { |
| 5929 |
// Ensure that all normal flow children are on the principal child list. |
| 5930 |
parent->DrainSelfOverflowList(); |
| 5931 |
|
| 5932 |
nsIFrame* child = parent->GetLastChild(nsIFrame::kPrincipalList); |
| 5933 |
if (child && child->IsPseudoFrame(aContainer) && |
| 5934 |
!child->IsGeneratedContentFrame()) { |
| 5935 |
// Drill down into non-generated pseudo frames of aContainer. |
| 5936 |
parent = nsLayoutUtils::LastContinuationWithChild(do_QueryFrame(child)); |
| 5937 |
continue; |
| 5938 |
} |
| 5939 |
|
| 5940 |
for (; child; child = child->GetPrevSibling()) { |
| 5941 |
nsIContent* c = child->GetContent(); |
| 5942 |
if (child->IsGeneratedContentFrame()) { |
| 5943 |
nsIContent* p = c->GetParent(); |
| 5944 |
if (c->Tag() == nsGkAtoms::mozgeneratedcontentafter) { |
| 5945 |
if (!nsContentUtils::ContentIsDescendantOf(aChild, p) && |
| 5946 |
c->GetBindingParent() != aContainer && |
| 5947 |
nsContentUtils::PositionIsBefore(p, aChild)) { |
| 5948 |
// ::after generated content for content earlier in the doc and not |
| 5949 |
// for an ancestor. |
| 5950 |
done = true; |
| 5951 |
break; |
| 5952 |
} |
| 5953 |
} else if (nsContentUtils::PositionIsBefore(p, aChild)) { |
| 5954 |
// Non-::after generated content for content earlier in the doc. |
| 5955 |
done = true; |
| 5956 |
break; |
| 5957 |
} |
| 5958 |
} else if (nsContentUtils::PositionIsBefore(c, aChild)) { |
| 5959 |
// Content is before aChild. |
| 5960 |
done = true; |
| 5961 |
break; |
| 5962 |
} |
| 5963 |
afterFrame = child; |
| 5964 |
} |
| 5965 |
|
| 5966 |
parent = static_cast<nsContainerFrame*>(parent->GetPrevContinuation()); |
| 5967 |
} |
| 5850 |
if (afterFrame) { |
5968 |
if (afterFrame) { |
| 5851 |
*aAfterFrame = afterFrame; |
5969 |
*aAfterFrame = afterFrame; |
| 5852 |
return afterFrame->GetParent(); |
5970 |
return afterFrame->GetParent(); |
| 5853 |
} |
5971 |
} |
| 5854 |
} |
5972 |
} |
| 5855 |
|
5973 |
|
| 5856 |
*aAfterFrame = nullptr; |
5974 |
*aAfterFrame = nullptr; |
| 5857 |
|
5975 |
|
|
Lines 6036-6060
nsCSSFrameConstructor::IsValidSibling(ns
|
Link Here
|
|---|
|
| 6036 |
(NS_STYLE_DISPLAY_TABLE_COLUMN == siblingDisplay) || |
6154 |
(NS_STYLE_DISPLAY_TABLE_COLUMN == siblingDisplay) || |
| 6037 |
(NS_STYLE_DISPLAY_TABLE_CAPTION == siblingDisplay) || |
6155 |
(NS_STYLE_DISPLAY_TABLE_CAPTION == siblingDisplay) || |
| 6038 |
(NS_STYLE_DISPLAY_TABLE_HEADER_GROUP == siblingDisplay) || |
6156 |
(NS_STYLE_DISPLAY_TABLE_HEADER_GROUP == siblingDisplay) || |
| 6039 |
(NS_STYLE_DISPLAY_TABLE_ROW_GROUP == siblingDisplay) || |
6157 |
(NS_STYLE_DISPLAY_TABLE_ROW_GROUP == siblingDisplay) || |
| 6040 |
(NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == siblingDisplay) || |
6158 |
(NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == siblingDisplay) || |
| 6041 |
nsGkAtoms::menuFrame == parentType) { |
6159 |
nsGkAtoms::menuFrame == parentType) { |
| 6042 |
// if we haven't already, construct a style context to find the display type of aContent |
6160 |
// if we haven't already, construct a style context to find the display type of aContent |
| 6043 |
if (UNSET_DISPLAY == aDisplay) { |
6161 |
if (UNSET_DISPLAY == aDisplay) { |
| 6044 |
nsRefPtr<nsStyleContext> styleContext; |
6162 |
nsIFrame* styleParent; |
| 6045 |
nsIFrame* styleParent = aSibling->GetParentStyleContextFrame(); |
6163 |
aSibling->GetParentStyleContext(&styleParent); |
|
|
6164 |
if (!styleParent) { |
| 6165 |
styleParent = aSibling->GetParent(); |
| 6166 |
} |
| 6046 |
if (!styleParent) { |
6167 |
if (!styleParent) { |
| 6047 |
NS_NOTREACHED("Shouldn't happen"); |
6168 |
NS_NOTREACHED("Shouldn't happen"); |
| 6048 |
return false; |
6169 |
return false; |
| 6049 |
} |
6170 |
} |
| 6050 |
// XXXbz when this code is killed, the state argument to |
6171 |
// XXXbz when this code is killed, the state argument to |
| 6051 |
// ResolveStyleContext can be made non-optional. |
6172 |
// ResolveStyleContext can be made non-optional. |
| 6052 |
styleContext = ResolveStyleContext(styleParent, aContent, nullptr); |
6173 |
nsRefPtr<nsStyleContext> styleContext = |
|
|
6174 |
ResolveStyleContext(styleParent, aContent, nullptr); |
| 6053 |
const nsStyleDisplay* display = styleContext->StyleDisplay(); |
6175 |
const nsStyleDisplay* display = styleContext->StyleDisplay(); |
| 6054 |
aDisplay = display->mDisplay; |
6176 |
aDisplay = display->mDisplay; |
| 6055 |
} |
6177 |
} |
| 6056 |
if (nsGkAtoms::menuFrame == parentType) { |
6178 |
if (nsGkAtoms::menuFrame == parentType) { |
| 6057 |
return |
6179 |
return |
| 6058 |
(NS_STYLE_DISPLAY_POPUP == aDisplay) == |
6180 |
(NS_STYLE_DISPLAY_POPUP == aDisplay) == |
| 6059 |
(NS_STYLE_DISPLAY_POPUP == siblingDisplay); |
6181 |
(NS_STYLE_DISPLAY_POPUP == siblingDisplay); |
| 6060 |
} |
6182 |
} |
|
Lines 6222-6238
nsCSSFrameConstructor::GetInsertionPrevS
|
Link Here
|
|---|
|
| 6222 |
*aIsAppend = false; |
6344 |
*aIsAppend = false; |
| 6223 |
|
6345 |
|
| 6224 |
// Find the frame that precedes the insertion point. Walk backwards |
6346 |
// Find the frame that precedes the insertion point. Walk backwards |
| 6225 |
// from the parent frame to get the parent content, because if an |
6347 |
// from the parent frame to get the parent content, because if an |
| 6226 |
// XBL insertion point is involved, we'll need to use _that_ to find |
6348 |
// XBL insertion point is involved, we'll need to use _that_ to find |
| 6227 |
// the preceding frame. |
6349 |
// the preceding frame. |
| 6228 |
|
6350 |
|
| 6229 |
NS_PRECONDITION(aParentFrame, "Must have parent frame to start with"); |
6351 |
NS_PRECONDITION(aParentFrame, "Must have parent frame to start with"); |
| 6230 |
nsIContent* container = aParentFrame->GetContent(); |
6352 |
const bool boxContents = GetDisplayBoxContentsStyleFor(aContainer); |
|
|
6353 |
nsIContent* container = boxContents ? aContainer : aParentFrame->GetContent(); |
| 6231 |
|
6354 |
|
| 6232 |
FlattenedChildIterator iter(container); |
6355 |
FlattenedChildIterator iter(container); |
| 6233 |
bool xblCase = iter.XBLInvolved() || container != aContainer; |
6356 |
bool xblCase = iter.XBLInvolved() || container != aContainer; |
| 6234 |
if (xblCase || !aChild->IsRootOfAnonymousSubtree()) { |
6357 |
if (xblCase || !aChild->IsRootOfAnonymousSubtree()) { |
| 6235 |
// The check for IsRootOfAnonymousSubtree() is because editor is |
6358 |
// The check for IsRootOfAnonymousSubtree() is because editor is |
| 6236 |
// severely broken and calls us directly for native anonymous |
6359 |
// severely broken and calls us directly for native anonymous |
| 6237 |
// nodes that it creates. |
6360 |
// nodes that it creates. |
| 6238 |
if (aStartSkipChild) { |
6361 |
if (aStartSkipChild) { |
|
Lines 6252-6280
nsCSSFrameConstructor::GetInsertionPrevS
|
Link Here
|
|---|
|
| 6252 |
uint8_t childDisplay = UNSET_DISPLAY; |
6375 |
uint8_t childDisplay = UNSET_DISPLAY; |
| 6253 |
nsIFrame* prevSibling = FindPreviousSibling(iter, childDisplay); |
6376 |
nsIFrame* prevSibling = FindPreviousSibling(iter, childDisplay); |
| 6254 |
|
6377 |
|
| 6255 |
// Now, find the geometric parent so that we can handle |
6378 |
// Now, find the geometric parent so that we can handle |
| 6256 |
// continuations properly. Use the prev sibling if we have it; |
6379 |
// continuations properly. Use the prev sibling if we have it; |
| 6257 |
// otherwise use the next sibling. |
6380 |
// otherwise use the next sibling. |
| 6258 |
if (prevSibling) { |
6381 |
if (prevSibling) { |
| 6259 |
aParentFrame = prevSibling->GetParent()->GetContentInsertionFrame(); |
6382 |
aParentFrame = prevSibling->GetParent()->GetContentInsertionFrame(); |
| 6260 |
} |
6383 |
} else { |
| 6261 |
else { |
|
|
| 6262 |
// If there is no previous sibling, then find the frame that follows |
6384 |
// If there is no previous sibling, then find the frame that follows |
| 6263 |
if (aEndSkipChild) { |
6385 |
if (aEndSkipChild) { |
| 6264 |
iter.Seek(aEndSkipChild); |
6386 |
iter.Seek(aEndSkipChild); |
| 6265 |
iter.GetPreviousChild(); |
6387 |
iter.GetPreviousChild(); |
| 6266 |
} |
6388 |
} |
| 6267 |
nsIFrame* nextSibling = FindNextSibling(iter, childDisplay); |
6389 |
nsIFrame* nextSibling = FindNextSibling(iter, childDisplay); |
| 6268 |
|
6390 |
if (boxContents) { |
|
|
6391 |
if (nextSibling) { |
| 6392 |
aParentFrame = nextSibling->GetParent()->GetContentInsertionFrame(); |
| 6393 |
return nextSibling->GetPrevSibling(); |
| 6394 |
} |
| 6395 |
return GetInsertionPrevSibling(aParentFrame, aContainer->GetParent(), |
| 6396 |
aContainer, aIsAppend, |
| 6397 |
aIsRangeInsertSafe, nullptr, nullptr); |
| 6398 |
} |
| 6269 |
if (nextSibling) { |
6399 |
if (nextSibling) { |
| 6270 |
aParentFrame = nextSibling->GetParent()->GetContentInsertionFrame(); |
6400 |
aParentFrame = nextSibling->GetParent()->GetContentInsertionFrame(); |
| 6271 |
} |
6401 |
} else { |
| 6272 |
else { |
|
|
| 6273 |
// No previous or next sibling, so treat this like an appended frame. |
6402 |
// No previous or next sibling, so treat this like an appended frame. |
| 6274 |
*aIsAppend = true; |
6403 |
*aIsAppend = true; |
| 6275 |
if (IsFramePartOfIBSplit(aParentFrame)) { |
6404 |
if (IsFramePartOfIBSplit(aParentFrame)) { |
| 6276 |
// Since we're appending, we'll walk to the last anonymous frame |
6405 |
// Since we're appending, we'll walk to the last anonymous frame |
| 6277 |
// that was created for the broken inline frame. But don't walk |
6406 |
// that was created for the broken inline frame. But don't walk |
| 6278 |
// to the trailing inline if it's empty; stop at the block. |
6407 |
// to the trailing inline if it's empty; stop at the block. |
| 6279 |
aParentFrame = GetLastIBSplitSibling(aParentFrame, false); |
6408 |
aParentFrame = GetLastIBSplitSibling(aParentFrame, false); |
| 6280 |
} |
6409 |
} |
|
Lines 6282-6308
nsCSSFrameConstructor::GetInsertionPrevS
|
Link Here
|
|---|
|
| 6282 |
// before the AdjustAppendParentForAfterContent call. |
6411 |
// before the AdjustAppendParentForAfterContent call. |
| 6283 |
aParentFrame = nsLayoutUtils::LastContinuationWithChild(aParentFrame); |
6412 |
aParentFrame = nsLayoutUtils::LastContinuationWithChild(aParentFrame); |
| 6284 |
// Deal with fieldsets |
6413 |
// Deal with fieldsets |
| 6285 |
aParentFrame = ::GetAdjustedParentFrame(aParentFrame, |
6414 |
aParentFrame = ::GetAdjustedParentFrame(aParentFrame, |
| 6286 |
aParentFrame->GetType(), |
6415 |
aParentFrame->GetType(), |
| 6287 |
aChild); |
6416 |
aChild); |
| 6288 |
nsIFrame* appendAfterFrame; |
6417 |
nsIFrame* appendAfterFrame; |
| 6289 |
aParentFrame = |
6418 |
aParentFrame = |
| 6290 |
::AdjustAppendParentForAfterContent(mPresShell->GetPresContext(), |
6419 |
::AdjustAppendParentForAfterContent(this, container, aParentFrame, |
| 6291 |
container, aParentFrame, |
6420 |
aChild, &appendAfterFrame); |
| 6292 |
&appendAfterFrame); |
|
|
| 6293 |
prevSibling = ::FindAppendPrevSibling(aParentFrame, appendAfterFrame); |
6421 |
prevSibling = ::FindAppendPrevSibling(aParentFrame, appendAfterFrame); |
| 6294 |
} |
6422 |
} |
| 6295 |
} |
6423 |
} |
| 6296 |
|
6424 |
|
| 6297 |
*aIsRangeInsertSafe = (childDisplay == UNSET_DISPLAY); |
6425 |
*aIsRangeInsertSafe = (childDisplay == UNSET_DISPLAY); |
| 6298 |
return prevSibling; |
6426 |
return prevSibling; |
| 6299 |
} |
6427 |
} |
| 6300 |
|
6428 |
|
|
|
6429 |
nsContainerFrame* |
| 6430 |
nsCSSFrameConstructor::GetContentInsertionFrameFor(nsIContent* aContent) |
| 6431 |
{ |
| 6432 |
// Get the primary frame associated with the content |
| 6433 |
nsIFrame* frame = aContent->GetPrimaryFrame(); |
| 6434 |
|
| 6435 |
if (!frame) { |
| 6436 |
if (GetDisplayBoxContentsStyleFor(aContent)) { |
| 6437 |
nsIContent* parent = aContent->GetParent(); |
| 6438 |
frame = parent ? GetContentInsertionFrameFor(parent) : nullptr; |
| 6439 |
} |
| 6440 |
if (!frame) { |
| 6441 |
return nullptr; |
| 6442 |
} |
| 6443 |
} else { |
| 6444 |
// If the content of the frame is not the desired content then this is not |
| 6445 |
// really a frame for the desired content. |
| 6446 |
// XXX This check is needed due to bug 135040. Remove it once that's fixed. |
| 6447 |
if (frame->GetContent() != aContent) { |
| 6448 |
return nullptr; |
| 6449 |
} |
| 6450 |
} |
| 6451 |
|
| 6452 |
nsContainerFrame* insertionFrame = frame->GetContentInsertionFrame(); |
| 6453 |
|
| 6454 |
NS_ASSERTION(!insertionFrame || insertionFrame == frame || !frame->IsLeaf(), |
| 6455 |
"The insertion frame is the primary frame or the primary frame isn't a leaf"); |
| 6456 |
|
| 6457 |
return insertionFrame; |
| 6458 |
} |
| 6459 |
|
| 6301 |
static bool |
6460 |
static bool |
| 6302 |
IsSpecialFramesetChild(nsIContent* aContent) |
6461 |
IsSpecialFramesetChild(nsIContent* aContent) |
| 6303 |
{ |
6462 |
{ |
| 6304 |
// IMPORTANT: This must match the conditions in nsHTMLFramesetFrame::Init. |
6463 |
// IMPORTANT: This must match the conditions in nsHTMLFramesetFrame::Init. |
| 6305 |
return aContent->IsHTML() && |
6464 |
return aContent->IsHTML() && |
| 6306 |
(aContent->Tag() == nsGkAtoms::frameset || |
6465 |
(aContent->Tag() == nsGkAtoms::frameset || |
| 6307 |
aContent->Tag() == nsGkAtoms::frame); |
6466 |
aContent->Tag() == nsGkAtoms::frame); |
| 6308 |
} |
6467 |
} |
|
Lines 6429-6444
nsCSSFrameConstructor::MaybeConstructLaz
|
Link Here
|
|---|
|
| 6429 |
} |
6588 |
} |
| 6430 |
if (!noPrimaryFrame && !content->GetPrimaryFrame()) { |
6589 |
if (!noPrimaryFrame && !content->GetPrimaryFrame()) { |
| 6431 |
noPrimaryFrame = true; |
6590 |
noPrimaryFrame = true; |
| 6432 |
} |
6591 |
} |
| 6433 |
if (!needsFrameBitSet && content->HasFlag(NODE_NEEDS_FRAME)) { |
6592 |
if (!needsFrameBitSet && content->HasFlag(NODE_NEEDS_FRAME)) { |
| 6434 |
needsFrameBitSet = true; |
6593 |
needsFrameBitSet = true; |
| 6435 |
} |
6594 |
} |
| 6436 |
#endif |
6595 |
#endif |
|
|
6596 |
// XXX no lazy frames for display-box:contents descendants yet (bug 979782). |
| 6597 |
if (GetDisplayBoxContentsStyleFor(content)) { |
| 6598 |
return false; |
| 6599 |
} |
| 6437 |
content->SetFlags(NODE_DESCENDANTS_NEED_FRAMES); |
6600 |
content->SetFlags(NODE_DESCENDANTS_NEED_FRAMES); |
| 6438 |
content = content->GetFlattenedTreeParent(); |
6601 |
content = content->GetFlattenedTreeParent(); |
| 6439 |
} |
6602 |
} |
| 6440 |
#ifdef DEBUG |
6603 |
#ifdef DEBUG |
| 6441 |
if (content && content->GetPrimaryFrame() && |
6604 |
if (content && content->GetPrimaryFrame() && |
| 6442 |
content->GetPrimaryFrame()->IsLeaf()) { |
6605 |
content->GetPrimaryFrame()->IsLeaf()) { |
| 6443 |
noPrimaryFrame = needsFrameBitSet = false; |
6606 |
noPrimaryFrame = needsFrameBitSet = false; |
| 6444 |
} |
6607 |
} |
|
|
| 6551 |
nsCSSFrameConstructor::IssueSingleInsertNofications(nsIContent* aContainer, |
6714 |
nsCSSFrameConstructor::IssueSingleInsertNofications(nsIContent* aContainer, |
| 6552 |
nsIContent* aStartChild, |
6715 |
nsIContent* aStartChild, |
| 6553 |
nsIContent* aEndChild, |
6716 |
nsIContent* aEndChild, |
| 6554 |
bool aAllowLazyConstruction) |
6717 |
bool aAllowLazyConstruction) |
| 6555 |
{ |
6718 |
{ |
| 6556 |
for (nsIContent* child = aStartChild; |
6719 |
for (nsIContent* child = aStartChild; |
| 6557 |
child != aEndChild; |
6720 |
child != aEndChild; |
| 6558 |
child = child->GetNextSibling()) { |
6721 |
child = child->GetNextSibling()) { |
| 6559 |
if ((child->GetPrimaryFrame() || |
6722 |
if ((child->GetPrimaryFrame() || GetUndisplayedContent(child) || |
| 6560 |
GetUndisplayedContent(child)) |
6723 |
GetDisplayBoxContentsStyleFor(child)) |
| 6561 |
#ifdef MOZ_XUL |
6724 |
#ifdef MOZ_XUL |
| 6562 |
// Except listboxes suck, so do NOT skip anything here if |
6725 |
// Except listboxes suck, so do NOT skip anything here if |
| 6563 |
// we plan to notify a listbox. |
6726 |
// we plan to notify a listbox. |
| 6564 |
&& !MaybeGetListBoxBodyFrame(aContainer, child) |
6727 |
&& !MaybeGetListBoxBodyFrame(aContainer, child) |
| 6565 |
#endif |
6728 |
#endif |
| 6566 |
) { |
6729 |
) { |
| 6567 |
// Already have a frame or undisplayed entry for this content; a |
6730 |
// Already have a frame or undisplayed entry for this content; a |
| 6568 |
// previous ContentInserted in this loop must have reconstructed |
6731 |
// previous ContentInserted in this loop must have reconstructed |
|
Lines 6711-6727
nsCSSFrameConstructor::ContentAppended(n
|
Link Here
|
|---|
|
| 6711 |
nsIContent* bindingParent = aContainer->GetBindingParent(); |
6874 |
nsIContent* bindingParent = aContainer->GetBindingParent(); |
| 6712 |
LAYOUT_PHASE_TEMP_EXIT(); |
6875 |
LAYOUT_PHASE_TEMP_EXIT(); |
| 6713 |
nsresult rv = RecreateFramesForContent(bindingParent, false); |
6876 |
nsresult rv = RecreateFramesForContent(bindingParent, false); |
| 6714 |
LAYOUT_PHASE_TEMP_REENTER(); |
6877 |
LAYOUT_PHASE_TEMP_REENTER(); |
| 6715 |
return rv; |
6878 |
return rv; |
| 6716 |
} |
6879 |
} |
| 6717 |
|
6880 |
|
| 6718 |
// Get the frame associated with the content |
6881 |
// Get the frame associated with the content |
| 6719 |
nsContainerFrame* parentFrame = ::GetContentInsertionFrameFor(aContainer); |
6882 |
nsContainerFrame* parentFrame = GetContentInsertionFrameFor(aContainer); |
| 6720 |
|
6883 |
|
| 6721 |
// See comment in ContentRangeInserted for why this is necessary. |
6884 |
// See comment in ContentRangeInserted for why this is necessary. |
| 6722 |
if (!parentFrame && !aContainer->IsActiveChildrenElement()) { |
6885 |
if (!parentFrame && !aContainer->IsActiveChildrenElement()) { |
| 6723 |
return NS_OK; |
6886 |
return NS_OK; |
| 6724 |
} |
6887 |
} |
| 6725 |
|
6888 |
|
| 6726 |
if (aAllowLazyConstruction && |
6889 |
if (aAllowLazyConstruction && |
| 6727 |
MaybeConstructLazily(CONTENTAPPEND, aContainer, aFirstNewContent)) { |
6890 |
MaybeConstructLazily(CONTENTAPPEND, aContainer, aFirstNewContent)) { |
|
Lines 6784-6802
nsCSSFrameConstructor::ContentAppended(n
|
Link Here
|
|---|
|
| 6784 |
// We should never get here with fieldsets, since they have multiple |
6947 |
// We should never get here with fieldsets, since they have multiple |
| 6785 |
// insertion points. |
6948 |
// insertion points. |
| 6786 |
NS_ASSERTION(parentFrame->GetType() != nsGkAtoms::fieldSetFrame, |
6949 |
NS_ASSERTION(parentFrame->GetType() != nsGkAtoms::fieldSetFrame, |
| 6787 |
"Unexpected parent"); |
6950 |
"Unexpected parent"); |
| 6788 |
|
6951 |
|
| 6789 |
// Deal with possible :after generated content on the parent |
6952 |
// Deal with possible :after generated content on the parent |
| 6790 |
nsIFrame* parentAfterFrame; |
6953 |
nsIFrame* parentAfterFrame; |
| 6791 |
parentFrame = |
6954 |
parentFrame = |
| 6792 |
::AdjustAppendParentForAfterContent(mPresShell->GetPresContext(), |
6955 |
::AdjustAppendParentForAfterContent(this, aContainer, parentFrame, |
| 6793 |
aContainer, parentFrame, |
6956 |
aFirstNewContent, &parentAfterFrame); |
| 6794 |
&parentAfterFrame); |
|
|
| 6795 |
|
6957 |
|
| 6796 |
// Create some new frames |
6958 |
// Create some new frames |
| 6797 |
nsFrameConstructorState state(mPresShell, |
6959 |
nsFrameConstructorState state(mPresShell, |
| 6798 |
GetAbsoluteContainingBlock(parentFrame, FIXED_POS), |
6960 |
GetAbsoluteContainingBlock(parentFrame, FIXED_POS), |
| 6799 |
GetAbsoluteContainingBlock(parentFrame, ABS_POS), |
6961 |
GetAbsoluteContainingBlock(parentFrame, ABS_POS), |
| 6800 |
GetFloatContainingBlock(parentFrame)); |
6962 |
GetFloatContainingBlock(parentFrame)); |
| 6801 |
state.mTreeMatchContext.InitAncestors(aContainer->AsElement()); |
6963 |
state.mTreeMatchContext.InitAncestors(aContainer->AsElement()); |
| 6802 |
|
6964 |
|
|
Lines 7144-7169
nsCSSFrameConstructor::ContentRangeInser
|
Link Here
|
|---|
|
| 7144 |
// the children of the host. |
7306 |
// the children of the host. |
| 7145 |
nsIContent* bindingParent = aContainer->GetBindingParent(); |
7307 |
nsIContent* bindingParent = aContainer->GetBindingParent(); |
| 7146 |
LAYOUT_PHASE_TEMP_EXIT(); |
7308 |
LAYOUT_PHASE_TEMP_EXIT(); |
| 7147 |
nsresult rv = RecreateFramesForContent(bindingParent, false); |
7309 |
nsresult rv = RecreateFramesForContent(bindingParent, false); |
| 7148 |
LAYOUT_PHASE_TEMP_REENTER(); |
7310 |
LAYOUT_PHASE_TEMP_REENTER(); |
| 7149 |
return rv; |
7311 |
return rv; |
| 7150 |
} |
7312 |
} |
| 7151 |
|
7313 |
|
| 7152 |
nsContainerFrame* parentFrame = ::GetContentInsertionFrameFor(aContainer); |
7314 |
nsContainerFrame* parentFrame = GetContentInsertionFrameFor(aContainer); |
| 7153 |
// The xbl:children element won't have a frame, but default content can have the children as |
7315 |
// The xbl:children element won't have a frame, but default content can have the children as |
| 7154 |
// a parent. While its uncommon to change the structure of the default content itself, a label, |
7316 |
// a parent. While its uncommon to change the structure of the default content itself, a label, |
| 7155 |
// for example, can be reframed by having its value attribute set or removed. |
7317 |
// for example, can be reframed by having its value attribute set or removed. |
| 7156 |
if (!parentFrame && !aContainer->IsActiveChildrenElement()) { |
7318 |
if (!parentFrame && !aContainer->IsActiveChildrenElement()) { |
| 7157 |
return NS_OK; |
7319 |
return NS_OK; |
| 7158 |
} |
7320 |
} |
| 7159 |
|
7321 |
|
| 7160 |
// Otherwise, we've got parent content. Find its frame. |
7322 |
// Otherwise, we've got parent content. Find its frame. |
| 7161 |
NS_ASSERTION(!parentFrame || parentFrame->GetContent() == aContainer, "New XBL code is possibly wrong!"); |
7323 |
NS_ASSERTION(!parentFrame || parentFrame->GetContent() == aContainer || |
|
|
7324 |
GetDisplayBoxContentsStyleFor(aContainer), "New XBL code is possibly wrong!"); |
| 7162 |
|
7325 |
|
| 7163 |
if (aAllowLazyConstruction && |
7326 |
if (aAllowLazyConstruction && |
| 7164 |
MaybeConstructLazily(CONTENTINSERT, aContainer, aStartChild)) { |
7327 |
MaybeConstructLazily(CONTENTINSERT, aContainer, aStartChild)) { |
| 7165 |
return NS_OK; |
7328 |
return NS_OK; |
| 7166 |
} |
7329 |
} |
| 7167 |
|
7330 |
|
| 7168 |
if (isSingleInsert) { |
7331 |
if (isSingleInsert) { |
| 7169 |
// See if we have an XBL insertion point. If so, then that's our |
7332 |
// See if we have an XBL insertion point. If so, then that's our |
|
Lines 7440-7459
nsCSSFrameConstructor::ContentRangeInser
|
Link Here
|
|---|
|
| 7440 |
frame1->GetType() == nsGkAtoms::fieldSetFrame || |
7603 |
frame1->GetType() == nsGkAtoms::fieldSetFrame || |
| 7441 |
(frame1->GetParent() && |
7604 |
(frame1->GetParent() && |
| 7442 |
frame1->GetParent()->GetType() == nsGkAtoms::fieldSetFrame), |
7605 |
frame1->GetParent()->GetType() == nsGkAtoms::fieldSetFrame), |
| 7443 |
"Unexpected frame types"); |
7606 |
"Unexpected frame types"); |
| 7444 |
#endif |
7607 |
#endif |
| 7445 |
isAppend = true; |
7608 |
isAppend = true; |
| 7446 |
nsIFrame* appendAfterFrame; |
7609 |
nsIFrame* appendAfterFrame; |
| 7447 |
parentFrame = |
7610 |
parentFrame = |
| 7448 |
::AdjustAppendParentForAfterContent(mPresShell->GetPresContext(), |
7611 |
::AdjustAppendParentForAfterContent(this, container, |
| 7449 |
container, |
|
|
| 7450 |
frameItems.FirstChild()->GetParent(), |
7612 |
frameItems.FirstChild()->GetParent(), |
| 7451 |
&appendAfterFrame); |
7613 |
aStartChild, &appendAfterFrame); |
| 7452 |
prevSibling = ::FindAppendPrevSibling(parentFrame, appendAfterFrame); |
7614 |
prevSibling = ::FindAppendPrevSibling(parentFrame, appendAfterFrame); |
| 7453 |
} |
7615 |
} |
| 7454 |
|
7616 |
|
| 7455 |
if (haveFirstLineStyle && parentFrame == containingBlock) { |
7617 |
if (haveFirstLineStyle && parentFrame == containingBlock) { |
| 7456 |
// It's possible that the new frame goes into a first-line |
7618 |
// It's possible that the new frame goes into a first-line |
| 7457 |
// frame. Look at it and see... |
7619 |
// frame. Look at it and see... |
| 7458 |
if (isAppend) { |
7620 |
if (isAppend) { |
| 7459 |
// Use append logic when appending |
7621 |
// Use append logic when appending |
|
Lines 7583-7610
nsCSSFrameConstructor::ContentRemoved(ns
|
Link Here
|
|---|
|
| 7583 |
static_cast<void*>(aChild), |
7745 |
static_cast<void*>(aChild), |
| 7584 |
static_cast<void*>(aOldNextSibling)); |
7746 |
static_cast<void*>(aOldNextSibling)); |
| 7585 |
if (gReallyNoisyContentUpdates) { |
7747 |
if (gReallyNoisyContentUpdates) { |
| 7586 |
aContainer->List(stdout, 0); |
7748 |
aContainer->List(stdout, 0); |
| 7587 |
} |
7749 |
} |
| 7588 |
} |
7750 |
} |
| 7589 |
#endif |
7751 |
#endif |
| 7590 |
|
7752 |
|
| 7591 |
nsPresContext *presContext = mPresShell->GetPresContext(); |
7753 |
nsresult rv = NS_OK; |
| 7592 |
nsresult rv = NS_OK; |
|
|
| 7593 |
|
| 7594 |
// Find the child frame that maps the content |
| 7595 |
nsIFrame* childFrame = aChild->GetPrimaryFrame(); |
7754 |
nsIFrame* childFrame = aChild->GetPrimaryFrame(); |
| 7596 |
|
|
|
| 7597 |
if (!childFrame || childFrame->GetContent() != aChild) { |
7755 |
if (!childFrame || childFrame->GetContent() != aChild) { |
| 7598 |
// XXXbz the GetContent() != aChild check is needed due to bug 135040. |
7756 |
// XXXbz the GetContent() != aChild check is needed due to bug 135040. |
| 7599 |
// Remove it once that's fixed. |
7757 |
// Remove it once that's fixed. |
| 7600 |
ClearUndisplayedContentIn(aChild, aContainer); |
7758 |
ClearUndisplayedContentIn(aChild, aContainer); |
| 7601 |
} |
7759 |
} |
| 7602 |
|
7760 |
MOZ_ASSERT(!childFrame || !GetDisplayBoxContentsStyleFor(aChild), |
|
|
7761 |
"display-box:contents nodes shouldn't have a frame"); |
| 7762 |
if (!childFrame && GetDisplayBoxContentsStyleFor(aChild)) { |
| 7763 |
nsIFrame* ancestorFrame = nullptr; |
| 7764 |
nsIContent* ancestor = aContainer; |
| 7765 |
for (; ancestor; ancestor = ancestor->GetParent()) { |
| 7766 |
ancestorFrame = ancestor->GetPrimaryFrame(); |
| 7767 |
if (ancestorFrame) { |
| 7768 |
break; |
| 7769 |
} |
| 7770 |
} |
| 7771 |
if (ancestorFrame) { |
| 7772 |
nsTArray<nsIContent*>* generated = ancestorFrame->GetGenConPseudos(); |
| 7773 |
if (generated) { |
| 7774 |
LAYOUT_PHASE_TEMP_EXIT(); |
| 7775 |
// XXXmats Can we recreate frames only for the ::after/::before content? |
| 7776 |
// XXX Perhaps even only those that belong to the aChild sub-tree? |
| 7777 |
RecreateFramesForContent(ancestor, false); |
| 7778 |
LAYOUT_PHASE_TEMP_REENTER(); |
| 7779 |
*aDidReconstruct = true; |
| 7780 |
return NS_OK; |
| 7781 |
} |
| 7782 |
} |
| 7783 |
|
| 7784 |
FlattenedChildIterator iter(aChild); |
| 7785 |
for (nsIContent* c = iter.GetNextChild(); c; c = iter.GetNextChild()) { |
| 7786 |
if (c->GetPrimaryFrame() || GetDisplayBoxContentsStyleFor(c)) { |
| 7787 |
LAYOUT_PHASE_TEMP_EXIT(); |
| 7788 |
rv = ContentRemoved(aChild, c, nullptr, aFlags, aDidReconstruct); |
| 7789 |
LAYOUT_PHASE_TEMP_REENTER(); |
| 7790 |
NS_ENSURE_SUCCESS(rv, rv); |
| 7791 |
if (*aDidReconstruct) { |
| 7792 |
return rv; |
| 7793 |
} |
| 7794 |
} |
| 7795 |
} |
| 7796 |
ClearDisplayBoxContentsIn(aChild, aContainer); |
| 7797 |
} |
| 7798 |
|
| 7799 |
nsPresContext* presContext = mPresShell->GetPresContext(); |
| 7603 |
#ifdef MOZ_XUL |
7800 |
#ifdef MOZ_XUL |
| 7604 |
if (NotifyListBoxBody(presContext, aContainer, aChild, aOldNextSibling, |
7801 |
if (NotifyListBoxBody(presContext, aContainer, aChild, aOldNextSibling, |
| 7605 |
mDocument, childFrame, CONTENT_REMOVED)) |
7802 |
mDocument, childFrame, CONTENT_REMOVED)) |
| 7606 |
return NS_OK; |
7803 |
return NS_OK; |
| 7607 |
|
7804 |
|
| 7608 |
#endif // MOZ_XUL |
7805 |
#endif // MOZ_XUL |
| 7609 |
|
7806 |
|
| 7610 |
// If we're removing the root, then make sure to remove things starting at |
7807 |
// If we're removing the root, then make sure to remove things starting at |
|
Lines 8431-8447
nsCSSFrameConstructor::GetInsertionPoint
|
Link Here
|
|---|
|
| 8431 |
|
8628 |
|
| 8432 |
nsIContent* insertionElement; |
8629 |
nsIContent* insertionElement; |
| 8433 |
if (aChildContent) { |
8630 |
if (aChildContent) { |
| 8434 |
// We've got an explicit insertion child. Check to see if it's |
8631 |
// We've got an explicit insertion child. Check to see if it's |
| 8435 |
// anonymous. |
8632 |
// anonymous. |
| 8436 |
if (aChildContent->GetBindingParent() == aContainer) { |
8633 |
if (aChildContent->GetBindingParent() == aContainer) { |
| 8437 |
// This child content is anonymous. Don't use the insertion |
8634 |
// This child content is anonymous. Don't use the insertion |
| 8438 |
// point, since that's only for the explicit kids. |
8635 |
// point, since that's only for the explicit kids. |
| 8439 |
return ::GetContentInsertionFrameFor(aContainer); |
8636 |
return GetContentInsertionFrameFor(aContainer); |
| 8440 |
} |
8637 |
} |
| 8441 |
|
8638 |
|
| 8442 |
insertionElement = bindingManager->FindNestedInsertionPoint(aContainer, aChildContent); |
8639 |
insertionElement = bindingManager->FindNestedInsertionPoint(aContainer, aChildContent); |
| 8443 |
} |
8640 |
} |
| 8444 |
else { |
8641 |
else { |
| 8445 |
bool multiple; |
8642 |
bool multiple; |
| 8446 |
insertionElement = bindingManager->FindNestedSingleInsertionPoint(aContainer, &multiple); |
8643 |
insertionElement = bindingManager->FindNestedSingleInsertionPoint(aContainer, &multiple); |
| 8447 |
|
8644 |
|
|
Lines 8452-8469
nsCSSFrameConstructor::GetInsertionPoint
|
Link Here
|
|---|
|
| 8452 |
return nullptr; |
8649 |
return nullptr; |
| 8453 |
} |
8650 |
} |
| 8454 |
} |
8651 |
} |
| 8455 |
|
8652 |
|
| 8456 |
if (!insertionElement) { |
8653 |
if (!insertionElement) { |
| 8457 |
insertionElement = aContainer; |
8654 |
insertionElement = aContainer; |
| 8458 |
} |
8655 |
} |
| 8459 |
|
8656 |
|
| 8460 |
nsContainerFrame* insertionPoint = |
8657 |
nsContainerFrame* insertionPoint = GetContentInsertionFrameFor(insertionElement); |
| 8461 |
::GetContentInsertionFrameFor(insertionElement); |
|
|
| 8462 |
|
8658 |
|
| 8463 |
// fieldsets have multiple insertion points. Note that we might |
8659 |
// fieldsets have multiple insertion points. Note that we might |
| 8464 |
// have to look at insertionElement here... |
8660 |
// have to look at insertionElement here... |
| 8465 |
if (aMultiple && insertionElement->IsHTML(nsGkAtoms::fieldset)) { |
8661 |
if (aMultiple && insertionElement->IsHTML(nsGkAtoms::fieldset)) { |
| 8466 |
*aMultiple = true; |
8662 |
*aMultiple = true; |
| 8467 |
} |
8663 |
} |
| 8468 |
|
8664 |
|
| 8469 |
return insertionPoint; |
8665 |
return insertionPoint; |
|
Lines 8490-8534
nsCSSFrameConstructor::CaptureStateForFr
|
Link Here
|
|---|
|
| 8490 |
|
8686 |
|
| 8491 |
static bool EqualURIs(mozilla::css::URLValue *aURI1, |
8687 |
static bool EqualURIs(mozilla::css::URLValue *aURI1, |
| 8492 |
mozilla::css::URLValue *aURI2) |
8688 |
mozilla::css::URLValue *aURI2) |
| 8493 |
{ |
8689 |
{ |
| 8494 |
return aURI1 == aURI2 || // handle null==null, and optimize |
8690 |
return aURI1 == aURI2 || // handle null==null, and optimize |
| 8495 |
(aURI1 && aURI2 && aURI1->URIEquals(*aURI2)); |
8691 |
(aURI1 && aURI2 && aURI1->URIEquals(*aURI2)); |
| 8496 |
} |
8692 |
} |
| 8497 |
|
8693 |
|
| 8498 |
nsresult |
8694 |
nsStyleContext* |
| 8499 |
nsCSSFrameConstructor::MaybeRecreateFramesForElement(Element* aElement) |
8695 |
nsCSSFrameConstructor::MaybeRecreateFramesForElement(Element* aElement) |
| 8500 |
{ |
8696 |
{ |
| 8501 |
nsRefPtr<nsStyleContext> oldContext = GetUndisplayedContent(aElement); |
8697 |
nsRefPtr<nsStyleContext> oldContext = GetUndisplayedContent(aElement); |
|
|
8698 |
uint8_t oldDisplayBoxStyle = NS_STYLE_DISPLAY_BOX_NONE; |
| 8502 |
if (!oldContext) { |
8699 |
if (!oldContext) { |
| 8503 |
return NS_OK; |
8700 |
oldContext = GetDisplayBoxContentsStyleFor(aElement); |
|
|
8701 |
if (!oldContext) { |
| 8702 |
return nullptr; |
| 8703 |
} |
| 8704 |
oldDisplayBoxStyle = NS_STYLE_DISPLAY_BOX_CONTENTS; |
| 8504 |
} |
8705 |
} |
| 8505 |
|
8706 |
|
| 8506 |
// The parent has a frame, so try resolving a new context. |
8707 |
// The parent has a frame, so try resolving a new context. |
| 8507 |
nsRefPtr<nsStyleContext> newContext = mPresShell->StyleSet()-> |
8708 |
nsRefPtr<nsStyleContext> newContext = mPresShell->StyleSet()-> |
| 8508 |
ResolveStyleFor(aElement, oldContext->GetParent()); |
8709 |
ResolveStyleFor(aElement, oldContext->GetParent()); |
| 8509 |
|
8710 |
|
| 8510 |
ChangeUndisplayedContent(aElement, newContext); |
8711 |
if (oldDisplayBoxStyle == NS_STYLE_DISPLAY_BOX_NONE) { |
|
|
8712 |
ChangeUndisplayedContent(aElement, newContext); |
| 8713 |
} else { |
| 8714 |
ChangeDisplayBoxContents(aElement, newContext); |
| 8715 |
} |
| 8716 |
|
| 8511 |
const nsStyleDisplay* disp = newContext->StyleDisplay(); |
8717 |
const nsStyleDisplay* disp = newContext->StyleDisplay(); |
| 8512 |
if (disp->mDisplay == NS_STYLE_DISPLAY_NONE) { |
8718 |
if (oldDisplayBoxStyle == disp->mDisplayBox) { |
| 8513 |
// We can skip trying to recreate frames here, but only if our style |
8719 |
// We can skip trying to recreate frames here, but only if our style |
| 8514 |
// context does not have a binding URI that differs from our old one. |
8720 |
// context does not have a binding URI that differs from our old one. |
| 8515 |
// Otherwise, we should try to recreate, because we may want to apply the |
8721 |
// Otherwise, we should try to recreate, because we may want to apply the |
| 8516 |
// new binding |
8722 |
// new binding |
| 8517 |
if (!disp->mBinding) { |
8723 |
if (!disp->mBinding) { |
| 8518 |
return NS_OK; |
8724 |
return newContext; |
| 8519 |
} |
8725 |
} |
| 8520 |
const nsStyleDisplay* oldDisp = oldContext->PeekStyleDisplay(); |
8726 |
const nsStyleDisplay* oldDisp = oldContext->PeekStyleDisplay(); |
| 8521 |
if (oldDisp && EqualURIs(disp->mBinding, oldDisp->mBinding)) { |
8727 |
if (oldDisp && EqualURIs(disp->mBinding, oldDisp->mBinding)) { |
| 8522 |
return NS_OK; |
8728 |
return newContext; |
| 8523 |
} |
8729 |
} |
| 8524 |
} |
8730 |
} |
| 8525 |
|
8731 |
|
| 8526 |
return RecreateFramesForContent(aElement, false); |
8732 |
RecreateFramesForContent(aElement, false); |
|
|
8733 |
return nullptr; |
| 8527 |
} |
8734 |
} |
| 8528 |
|
8735 |
|
| 8529 |
static nsIFrame* |
8736 |
static nsIFrame* |
| 8530 |
FindFirstNonWhitespaceChild(nsIFrame* aParentFrame) |
8737 |
FindFirstNonWhitespaceChild(nsIFrame* aParentFrame) |
| 8531 |
{ |
8738 |
{ |
| 8532 |
nsIFrame* f = aParentFrame->GetFirstPrincipalChild(); |
8739 |
nsIFrame* f = aParentFrame->GetFirstPrincipalChild(); |
| 8533 |
while (f && f->GetType() == nsGkAtoms::textFrame && |
8740 |
while (f && f->GetType() == nsGkAtoms::textFrame && |
| 8534 |
f->GetContent()->TextIsOnlyWhitespace()) { |
8741 |
f->GetContent()->TextIsOnlyWhitespace()) { |
|
Lines 10410-10430
nsCSSFrameConstructor::CreateListBoxCont
|
Link Here
|
|---|
|
| 10410 |
mTempFrameTreeState); |
10617 |
mTempFrameTreeState); |
| 10411 |
|
10618 |
|
| 10412 |
// If we ever initialize the ancestor filter on |state|, make sure |
10619 |
// If we ever initialize the ancestor filter on |state|, make sure |
| 10413 |
// to push the right parent! |
10620 |
// to push the right parent! |
| 10414 |
|
10621 |
|
| 10415 |
nsRefPtr<nsStyleContext> styleContext; |
10622 |
nsRefPtr<nsStyleContext> styleContext; |
| 10416 |
styleContext = ResolveStyleContext(aParentFrame, aChild, &state); |
10623 |
styleContext = ResolveStyleContext(aParentFrame, aChild, &state); |
| 10417 |
|
10624 |
|
| 10418 |
// Pre-check for display "none" - only if we find that, do we create |
10625 |
// Pre-check for display-box:none - if we find that, don't create any frame at all. |
| 10419 |
// any frame at all |
|
|
| 10420 |
const nsStyleDisplay* display = styleContext->StyleDisplay(); |
10626 |
const nsStyleDisplay* display = styleContext->StyleDisplay(); |
| 10421 |
|
10627 |
if (NS_STYLE_DISPLAY_BOX_NONE == display->mDisplayBox) { |
| 10422 |
if (NS_STYLE_DISPLAY_NONE == display->mDisplay) { |
|
|
| 10423 |
*aNewFrame = nullptr; |
10628 |
*aNewFrame = nullptr; |
| 10424 |
return NS_OK; |
10629 |
return NS_OK; |
| 10425 |
} |
10630 |
} |
| 10426 |
|
10631 |
|
| 10427 |
BeginUpdate(); |
10632 |
BeginUpdate(); |
| 10428 |
|
10633 |
|
| 10429 |
FrameConstructionItemList items; |
10634 |
FrameConstructionItemList items; |
| 10430 |
AddFrameConstructionItemsInternal(state, aChild, aParentFrame, |
10635 |
AddFrameConstructionItemsInternal(state, aChild, aParentFrame, |