Skip to content

Commit

Permalink
Bug 653881 - Normalize the undisplayed map entry for <xbl:children>. …
Browse files Browse the repository at this point in the history
…r=dbaron

--HG--
extra : rebase_source : b851a3dc8f5bf576a42f0b639bdd51375413b123
  • Loading branch information
William Chen committed Jun 20, 2013
1 parent 9be822f commit 0127e8c
Showing 1 changed file with 30 additions and 9 deletions.
39 changes: 30 additions & 9 deletions layout/base/nsFrameManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,12 @@ class nsFrameManagerBase::UndisplayedMap {
NS_HIDDEN_(void) Clear(void);

protected:
NS_HIDDEN_(PLHashEntry**) GetEntryFor(nsIContent* aParentContent);
/**
* Gets the entry for the provided parent content. If the content
* is a <xbl:children> element, |**aParentContent| is set to
* the parent of the children element.
*/
NS_HIDDEN_(PLHashEntry**) GetEntryFor(nsIContent** aParentContent);
NS_HIDDEN_(void) AppendNodeFor(UndisplayedNode* aNode,
nsIContent* aParentContent);

Expand Down Expand Up @@ -1891,13 +1896,29 @@ nsFrameManagerBase::UndisplayedMap::~UndisplayedMap(void)
}

PLHashEntry**
nsFrameManagerBase::UndisplayedMap::GetEntryFor(nsIContent* aParentContent)
nsFrameManagerBase::UndisplayedMap::GetEntryFor(nsIContent** aParentContent)
{
if (mLastLookup && (aParentContent == (*mLastLookup)->key)) {
nsIContent* parentContent = *aParentContent;

if (mLastLookup && (parentContent == (*mLastLookup)->key)) {
return mLastLookup;
}
PLHashNumber hashCode = NS_PTR_TO_INT32(aParentContent);
PLHashEntry** entry = PL_HashTableRawLookup(mTable, hashCode, aParentContent);

// In the case of XBL default content, <xbl:children> elements do not get a
// frame causing a mismatch between the content tree and the frame tree.
// |GetEntryFor| is sometimes called with the content tree parent (which may
// 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)) {
parentContent = parentContent->GetParent();
// Change the caller's pointer for the parent content to be the insertion parent.
*aParentContent = parentContent;
}

PLHashNumber hashCode = NS_PTR_TO_INT32(parentContent);
PLHashEntry** entry = PL_HashTableRawLookup(mTable, hashCode, parentContent);
if (*entry) {
mLastLookup = entry;
}
Expand All @@ -1907,7 +1928,7 @@ nsFrameManagerBase::UndisplayedMap::GetEntryFor(nsIContent* aParentContent)
UndisplayedNode*
nsFrameManagerBase::UndisplayedMap::GetFirstNode(nsIContent* aParentContent)
{
PLHashEntry** entry = GetEntryFor(aParentContent);
PLHashEntry** entry = GetEntryFor(&aParentContent);
if (*entry) {
return (UndisplayedNode*)((*entry)->value);
}
Expand All @@ -1918,7 +1939,7 @@ void
nsFrameManagerBase::UndisplayedMap::AppendNodeFor(UndisplayedNode* aNode,
nsIContent* aParentContent)
{
PLHashEntry** entry = GetEntryFor(aParentContent);
PLHashEntry** entry = GetEntryFor(&aParentContent);
if (*entry) {
UndisplayedNode* node = (UndisplayedNode*)((*entry)->value);
while (node->mNext) {
Expand Down Expand Up @@ -1956,7 +1977,7 @@ void
nsFrameManagerBase::UndisplayedMap::RemoveNodeFor(nsIContent* aParentContent,
UndisplayedNode* aNode)
{
PLHashEntry** entry = GetEntryFor(aParentContent);
PLHashEntry** entry = GetEntryFor(&aParentContent);
NS_ASSERTION(*entry, "content not in map");
if (*entry) {
if ((UndisplayedNode*)((*entry)->value) == aNode) { // first node
Expand Down Expand Up @@ -1987,7 +2008,7 @@ nsFrameManagerBase::UndisplayedMap::RemoveNodeFor(nsIContent* aParentContent,
void
nsFrameManagerBase::UndisplayedMap::RemoveNodesFor(nsIContent* aParentContent)
{
PLHashEntry** entry = GetEntryFor(aParentContent);
PLHashEntry** entry = GetEntryFor(&aParentContent);
NS_ASSERTION(entry, "content not in map");
if (*entry) {
UndisplayedNode* node = (UndisplayedNode*)((*entry)->value);
Expand Down

0 comments on commit 0127e8c

Please sign in to comment.