Bug 890775 - Not all xbl:children elements should be treated specially. r=peterv

This commit is contained in:
Blake Kaplan 2013-07-11 17:52:49 -04:00
parent b001d00a05
commit 2a5c30ab9f
5 changed files with 20 additions and 20 deletions

View File

@ -33,8 +33,8 @@ enum nsLinkState {
// IID for the nsIContent interface
#define NS_ICONTENT_IID \
{ 0x8a8b4b1d, 0x72d8, 0x428e, \
{ 0x95, 0x75, 0xf9, 0x18, 0xba, 0xf6, 0x9e, 0xa1 } }
{ 0Xf22c131c, 0Xc554, 0X4d06, \
{ 0X81, 0Xac, 0X86, 0X64, 0X2f, 0X05, 0Xcc, 0X81 } }
/**
* A node of content in a document's content model. This interface
@ -305,6 +305,12 @@ public:
return mNodeInfo->Equals(aTag, kNameSpaceID_MathML);
}
inline bool IsActiveChildrenElement() const
{
return mNodeInfo->Equals(nsGkAtoms::children, kNameSpaceID_XBL) &&
GetBindingParent();
}
/**
* Returns an atom holding the name of the attribute of type ID on
* this content node (if applicable). Returns null for non-element

View File

@ -16,7 +16,7 @@ ExplicitChildIterator::GetNextChild()
// If we're already in the inserted-children array, look there first
if (mIndexInInserted) {
MOZ_ASSERT(mChild);
MOZ_ASSERT(mChild->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL));
MOZ_ASSERT(mChild->IsActiveChildrenElement());
MOZ_ASSERT(!mDefaultChild);
XBLChildrenElement* point = static_cast<XBLChildrenElement*>(mChild);
@ -28,7 +28,7 @@ ExplicitChildIterator::GetNextChild()
} else if (mDefaultChild) {
// If we're already in default content, check if there are more nodes there
MOZ_ASSERT(mChild);
MOZ_ASSERT(mChild->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL));
MOZ_ASSERT(mChild->IsActiveChildrenElement());
mDefaultChild = mDefaultChild->GetNextSibling();
if (mDefaultChild) {
@ -44,8 +44,7 @@ ExplicitChildIterator::GetNextChild()
}
// Iterate until we find a non-<children>, or a <children> with content.
while (mChild &&
mChild->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) {
while (mChild && mChild->IsActiveChildrenElement()) {
XBLChildrenElement* point = static_cast<XBLChildrenElement*>(mChild);
if (!point->mInsertedChildren.IsEmpty()) {
mIndexInInserted = 1;
@ -85,6 +84,7 @@ FlattenedChildIterator::FlattenedChildIterator(nsIContent* aParent)
child;
child = child->GetNextSibling()) {
if (child->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) {
MOZ_ASSERT(child->GetBindingParent());
mXBLInvolved = true;
break;
}
@ -131,8 +131,7 @@ nsIContent* FlattenedChildIterator::GetPreviousChild()
}
// Iterate until we find a non-<children>, or a <children> with content.
while (mChild &&
mChild->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) {
while (mChild && mChild->IsActiveChildrenElement()) {
XBLChildrenElement* point = static_cast<XBLChildrenElement*>(mChild);
if (!point->mInsertedChildren.IsEmpty()) {
mIndexInInserted = point->InsertedChildrenLength();

View File

@ -3518,7 +3518,7 @@ nsCSSFrameConstructor::ConstructFrameFromItemInternal(FrameConstructionItem& aIt
// descendants.
nsIContent* parent = content->GetParent();
bool pushInsertionPoint = aState.mTreeMatchContext.mAncestorFilter.HasFilter() &&
parent && parent->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL);
parent && parent->IsActiveChildrenElement();
TreeMatchContext::AutoAncestorPusher
insertionPointPusher(pushInsertionPoint,
aState.mTreeMatchContext,
@ -6511,7 +6511,7 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
nsIFrame* parentFrame = GetFrameFor(aContainer);
// See comment in ContentRangeInserted for why this is necessary.
if (!parentFrame && !aContainer->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) {
if (!parentFrame && !aContainer->IsActiveChildrenElement()) {
return NS_OK;
}
@ -6934,7 +6934,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
// The xbl:children element won't have a frame, but default content can have the children as
// a parent. While its uncommon to change the structure of the default content itself, a label,
// for example, can be reframed by having its value attribute set or removed.
if (!parentFrame && !aContainer->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) {
if (!parentFrame && !aContainer->IsActiveChildrenElement()) {
return NS_OK;
}

View File

@ -1379,8 +1379,7 @@ nsFrameManager::ReResolveStyleContext(nsPresContext *aPresContext,
// children element. Push the children element as an ancestor here because it does
// not have a frame and would not otherwise be pushed as an ancestor.
nsIContent* parent = undisplayed->mContent->GetParent();
bool pushInsertionPoint = parent &&
parent->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL);
bool pushInsertionPoint = parent && parent->IsActiveChildrenElement();
TreeMatchContext::AutoAncestorPusher
insertionPointPusher(pushInsertionPoint,
aTreeMatchContext,
@ -1549,8 +1548,7 @@ nsFrameManager::ReResolveStyleContext(nsPresContext *aPresContext,
// Check if the frame has a content because |child| may be a nsPageFrame that does
// not have a content.
nsIContent* parent = child->GetContent() ? child->GetContent()->GetParent() : nullptr;
bool pushInsertionPoint = parent &&
parent->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL);
bool pushInsertionPoint = parent && parent->IsActiveChildrenElement();
TreeMatchContext::AutoAncestorPusher
insertionPointPusher(pushInsertionPoint, aTreeMatchContext,
parent && parent->IsElement() ? parent->AsElement() : nullptr);
@ -1911,8 +1909,7 @@ nsFrameManagerBase::UndisplayedMap::GetEntryFor(nsIContent** aParentContent)
// be a <xbl:children> element) but the parent in the frame tree would be the
// insertion parent (parent of the <xbl:children> element). Here the children
// elements are normalized to the insertion parent to correct for the mismatch.
if (parentContent &&
parentContent->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) {
if (parentContent && parentContent->IsActiveChildrenElement()) {
parentContent = parentContent->GetParent();
// Change the caller's pointer for the parent content to be the insertion parent.
*aParentContent = parentContent;

View File

@ -2312,9 +2312,7 @@ static bool SelectorMatchesTree(Element* aPrevElement,
// <xbl:children> element wasn't in the tree to allow old selectors
// were written before <xbl:children> participated in CSS selector
// matching to work.
if (selector->mOperator == '>' &&
element->NodeInfo()->Equals(nsGkAtoms::children,
kNameSpaceID_XBL)) {
if (selector->mOperator == '>' && element->IsActiveChildrenElement()) {
Element* styleScope = aTreeMatchContext.mCurrentStyleScope;
if (SelectorMatchesTree(element, selector, aTreeMatchContext,
aLookForRelevantLink)) {