Bug 700981 part 5. Reduce the amount of time spent calling GetBindingParent(). r=smaug

This commit is contained in:
Boris Zbarsky 2012-03-22 00:10:51 -04:00
Родитель 3c1d835acc
Коммит eec3e8fb77
3 изменённых файлов: 13 добавлений и 9 удалений

Просмотреть файл

@ -114,8 +114,9 @@ public:
* @param aParent The new parent for the content node. May be null if the * @param aParent The new parent for the content node. May be null if the
* node is being bound as a direct child of the document. * node is being bound as a direct child of the document.
* @param aBindingParent The new binding parent for the content node. * @param aBindingParent The new binding parent for the content node.
* This is allowed to be null. In that case, the * This is must either be non-null if a particular
* binding parent of aParent, if any, will be used. * binding parent is desired or match aParent's binding
* parent.
* @param aCompileEventHandlers whether to initialize the event handlers in * @param aCompileEventHandlers whether to initialize the event handlers in
* the document (used by nsXULElement) * the document (used by nsXULElement)
* @note either aDocument or aParent must be non-null. If both are null, * @note either aDocument or aParent must be non-null. If both are null,

Просмотреть файл

@ -3090,10 +3090,9 @@ nsGenericElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
aBindingParent == aParent, aBindingParent == aParent,
"Native anonymous content must have its parent as its " "Native anonymous content must have its parent as its "
"own binding parent"); "own binding parent");
NS_PRECONDITION(aBindingParent || !aParent ||
if (!aBindingParent && aParent) { aBindingParent == aParent->GetBindingParent(),
aBindingParent = aParent->GetBindingParent(); "We should be passed the right binding parent");
}
#ifdef MOZ_XUL #ifdef MOZ_XUL
// First set the binding parent // First set the binding parent
@ -3810,7 +3809,9 @@ nsINode::doInsertChildAt(nsIContent* aKid, PRUint32 aIndex,
nsIContent* parent = nsIContent* parent =
IsNodeOfType(eDOCUMENT) ? nsnull : static_cast<nsIContent*>(this); IsNodeOfType(eDOCUMENT) ? nsnull : static_cast<nsIContent*>(this);
rv = aKid->BindToTree(doc, parent, nsnull, true); rv = aKid->BindToTree(doc, parent,
parent ? parent->GetBindingParent() : nsnull,
true);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
if (GetFirstChild() == aKid) { if (GetFirstChild() == aKid) {
mFirstChild = aKid->GetNextSibling(); mFirstChild = aKid->GetNextSibling();

Просмотреть файл

@ -1326,7 +1326,8 @@ nsXBLPrototypeBinding::ConstructInsertionTable(nsIContent* aContent)
// XXXbz this is somewhat screwed up, since it's sort of like anonymous // XXXbz this is somewhat screwed up, since it's sort of like anonymous
// content... but not. // content... but not.
nsresult rv = nsresult rv =
child->BindToTree(parent->GetCurrentDoc(), parent, nsnull, false); child->BindToTree(parent->GetCurrentDoc(), parent,
parent->GetBindingParent(), false);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
// Well... now what? Just unbind and bail out, I guess... // Well... now what? Just unbind and bail out, I guess...
// XXXbz This really shouldn't be a void method! // XXXbz This really shouldn't be a void method!
@ -1997,7 +1998,8 @@ nsXBLPrototypeBinding::ReadContentNode(nsIObjectInputStream* aStream,
if (defaultContent) { if (defaultContent) {
xblIns->SetDefaultContent(defaultContent); xblIns->SetDefaultContent(defaultContent);
rv = defaultContent->BindToTree(nsnull, content, nsnull, false); rv = defaultContent->BindToTree(nsnull, content,
content->GetBindingParent(), false);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
defaultContent->UnbindFromTree(); defaultContent->UnbindFromTree();
return rv; return rv;