Make the base URI for anon nodes in an XBL binding be the URI of the XBL

document.  Bug 211128, r+sr=jst, a=chofmann
This commit is contained in:
bzbarsky%mit.edu 2005-05-03 16:01:22 +00:00
Родитель c076641412
Коммит 632a834fb0
2 изменённых файлов: 31 добавлений и 4 удалений

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

@ -70,6 +70,7 @@ REQUIRES = xpcom \
webbrowserpersist \
imglib2 \
prefetch \
xuldoc \
$(NULL)
EXPORTS = \

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

@ -80,6 +80,7 @@
#include "nsIBindingManager.h"
#include "nsXBLBinding.h"
#include "nsXBLPrototypeBinding.h"
#include "nsIDOMCSSStyleDeclaration.h"
#include "nsIDOMViewCSS.h"
#include "nsIXBLService.h"
@ -2379,13 +2380,38 @@ nsGenericElement::GetBaseURI() const
return nsnull;
}
// Our base URL depends on whether we have an xml:base attribute, as
// well as on whether any of our ancestors do.
nsCOMPtr<nsIURI> parentBase;
// Our base URL depends on whether we have an xml:base attribute, as well as
// on whether any of our ancestors do. The basic idea is to ask our parent
// (GetParent() if we have one, our document otherwise) for its base
// URL. Then we resolve our xml:base attr, if any, relative to that.
// The one complication is that we may be an anonymous node bound via XBL.
// If this is the case, we still want to use our parent's baseURL unless our
// parent is not part of our own binding (eg is the element the binding is
// attached to). If that is the case, we want to use the binding url as the
// "parent" url.
nsIContent *parent = GetParent();
nsCOMPtr<nsIURI> parentBase;
if (parent) {
parentBase = parent->GetBaseURI();
// XXX Not all things with a bindingParent are actually XBL anonymous
// content, so we may not end up getting a binding in the case when we have
// a bindingParent... This seems very wrong. Perhaps it should be fixed?
if (!IsNativeAnonymous()) {
nsIContent* bindingParent = GetBindingParent();
nsIContent* parentsBindingParent = parent->GetBindingParent();
if (bindingParent != parentsBindingParent) {
nsXBLBinding* binding =
doc->BindingManager()->GetBinding(bindingParent);
if (binding) {
parentBase = binding->PrototypeBinding()->BindingURI();
}
}
}
if (!parentBase) {
parentBase = parent->GetBaseURI();
}
} else {
// No parent, so just use the document (we must be the root or not in the
// tree).