diff --git a/mozilla/accessible/src/atk/nsHTMLLinkAccessibleWrap.cpp b/mozilla/accessible/src/atk/nsHTMLLinkAccessibleWrap.cpp
index 0a94cc7c480..6b6dc690194 100644
--- a/mozilla/accessible/src/atk/nsHTMLLinkAccessibleWrap.cpp
+++ b/mozilla/accessible/src/atk/nsHTMLLinkAccessibleWrap.cpp
@@ -169,15 +169,12 @@ NS_IMETHODIMP nsHTMLImageMapAccessible::GetURI(PRInt32 aIndex, nsIURI **aURI)
nsCOMPtr content(do_QueryInterface(mDOMNode));
if (content) {
- nsCOMPtr doc;
- if (NS_SUCCEEDED(content->GetDocument(getter_AddRefs(doc)))) {
- nsCOMPtr baseURI;
- if (NS_SUCCEEDED(doc->GetBaseURL(getter_AddRefs(baseURI)))) {
- nsCOMPtr area(do_QueryInterface(domNode));
- nsAutoString hrefValue;
- if (NS_SUCCEEDED(area->GetAttribute(NS_LITERAL_STRING("href"), hrefValue))) {
- return NS_NewURI(aURI, hrefValue, nsnull, baseURI);
- }
+ nsCOMPtr baseURI;
+ if (NS_SUCCEEDED(content->GetBaseURL(getter_AddRefs(baseURI)))) {
+ nsCOMPtr area(do_QueryInterface(domNode));
+ nsAutoString hrefValue;
+ if (NS_SUCCEEDED(area->GetAttribute(NS_LITERAL_STRING("href"), hrefValue))) {
+ return NS_NewURI(aURI, hrefValue, nsnull, baseURI);
}
}
}
diff --git a/mozilla/content/base/public/nsIContent.h b/mozilla/content/base/public/nsIContent.h
index 765211198ac..45f06babb06 100644
--- a/mozilla/content/base/public/nsIContent.h
+++ b/mozilla/content/base/public/nsIContent.h
@@ -55,6 +55,7 @@ class nsISupportsArray;
class nsIDOMRange;
class nsINodeInfo;
class nsIEventListenerManager;
+class nsIURI;
// IID for the nsIContent interface
#define NS_ICONTENT_IID \
@@ -484,6 +485,16 @@ public:
*/
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aResult) = 0;
+ /**
+ * Get the base URL for any relative URLs within this piece
+ * of content. Generally, this is the document's base URL,
+ * but certain content carries a local base for backward
+ * compatibility.
+ *
+ * @param aBaseURL the base URL [OUT]
+ */
+ NS_IMETHOD GetBaseURL(nsIURI** aBaseURL) const = 0;
+
/**
* This method is called when the parser finishes creating the element. This
* particularly means that it has done everything you would expect it to have
diff --git a/mozilla/content/base/public/nsIDocument.h b/mozilla/content/base/public/nsIDocument.h
index 5405ac94ca0..c476782340a 100644
--- a/mozilla/content/base/public/nsIDocument.h
+++ b/mozilla/content/base/public/nsIDocument.h
@@ -140,8 +140,9 @@ public:
NS_IMETHOD GetDocumentLoadGroup(nsILoadGroup** aGroup) const = 0;
/**
- * Return the base URL for relative URLs in the document. May return
- * null (or the document URL).
+ * Return the base URL for relative URLs in the document (the document url
+ * unless it's overridden by SetBaseURL, HTML tags, etc.). The
+ * returned URL could be null if there is no document URL.
*/
NS_IMETHOD GetBaseURL(nsIURI** aURL) const = 0;
NS_IMETHOD SetBaseURL(nsIURI* aURL) = 0;
diff --git a/mozilla/content/base/src/nsContentAreaDragDrop.cpp b/mozilla/content/base/src/nsContentAreaDragDrop.cpp
index 87646c8936c..1f12fdaf0e7 100644
--- a/mozilla/content/base/src/nsContentAreaDragDrop.cpp
+++ b/mozilla/content/base/src/nsContentAreaDragDrop.cpp
@@ -985,14 +985,12 @@ nsTransferableFactory::GetAnchorURL(nsIDOMNode* inNode, nsAString& outURL)
if (value.Equals(NS_LITERAL_STRING("simple"))) {
content->GetAttr(kNameSpaceID_XLink, nsHTMLAtoms::href, value);
if (!value.IsEmpty()) {
- nsCOMPtr xml(do_QueryInterface(inNode));
- if (xml) {
- nsCOMPtr baseURI;
- if (NS_SUCCEEDED(xml->GetXMLBaseURI(getter_AddRefs(baseURI)))) {
- nsCAutoString absoluteSpec;
- baseURI->Resolve(NS_ConvertUCS2toUTF8(value), absoluteSpec);
- outURL = NS_ConvertUTF8toUCS2(absoluteSpec);
- }
+ nsCOMPtr baseURI;
+ content->GetBaseURL(getter_AddRefs(baseURI));
+ if (baseURI) {
+ nsCAutoString absoluteSpec;
+ baseURI->Resolve(NS_ConvertUCS2toUTF8(value), absoluteSpec);
+ CopyUTF8toUTF16(absoluteSpec, outURL);
}
}
} else {
diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.cpp b/mozilla/content/base/src/nsGenericDOMDataNode.cpp
index 76ced9333f6..906d27ec739 100644
--- a/mozilla/content/base/src/nsGenericDOMDataNode.cpp
+++ b/mozilla/content/base/src/nsGenericDOMDataNode.cpp
@@ -49,7 +49,7 @@
#include "nsMutationEvent.h"
#include "nsINameSpaceManager.h"
#include "nsIDOM3Node.h"
-
+#include "nsIURI.h"
#include "nsIPrivateDOMEvent.h"
#include "nsIDOMEvent.h"
#include "nsIDOMText.h"
@@ -287,23 +287,14 @@ nsGenericDOMDataNode::IsSupported(const nsAString& aFeature,
nsresult
nsGenericDOMDataNode::GetBaseURI(nsAString& aURI)
{
- aURI.Truncate();
- nsresult rv = NS_OK;
+ nsCOMPtr baseURI;
+ nsresult rv = GetBaseURL(getter_AddRefs(baseURI));
- // DOM Data Node inherits the base from its parent element/document
- nsCOMPtr node;
-
- nsIContent *parent_weak = GetParentWeak();
-
- if (parent_weak) {
- node = do_QueryInterface(parent_weak);
- } else if (mDocument) {
- node = do_QueryInterface(mDocument);
- }
-
- if (node) {
- rv = node->GetBaseURI(aURI);
+ nsCAutoString spec;
+ if (NS_SUCCEEDED(rv) && baseURI) {
+ baseURI->GetSpec(spec);
}
+ CopyUTF8toUTF16(spec, aURI);
return rv;
}
@@ -1069,6 +1060,23 @@ nsGenericDOMDataNode::DumpContent(FILE* out, PRInt32 aIndent,
}
#endif
+NS_IMETHODIMP
+nsGenericDOMDataNode::GetBaseURL(nsIURI** aURI) const
+{
+ // DOM Data Node inherits the base from its parent element/document
+ nsIContent* parent_weak = GetParentWeak();
+ if (parent_weak) {
+ return parent_weak->GetBaseURL(aURI);
+ }
+
+ if (mDocument) {
+ return mDocument->GetBaseURL(aURI);
+ }
+
+ *aURI = nsnull;
+ return NS_OK;
+}
+
//----------------------------------------------------------------------
// Implementation of the nsIDOMText interface
diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.h b/mozilla/content/base/src/nsGenericDOMDataNode.h
index 8746da1c750..55c11a19fe4 100644
--- a/mozilla/content/base/src/nsGenericDOMDataNode.h
+++ b/mozilla/content/base/src/nsGenericDOMDataNode.h
@@ -54,6 +54,7 @@ class nsIDOMNodeList;
class nsIFrame;
class nsIDOMText;
class nsINodeInfo;
+class nsURI;
#define PARENT_BIT_RANGELISTS ((PtrBits)0x1 << 0)
#define PARENT_BIT_LISTENERMANAGER ((PtrBits)0x1 << 1)
@@ -212,6 +213,7 @@ public:
NS_IMETHOD_(PRBool) IsContentOfType(PRUint32 aFlags);
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aInstancePtrResult);
+ NS_IMETHOD GetBaseURL(nsIURI** aURI) const;
NS_IMETHOD DoneCreatingElement();
NS_IMETHOD GetNodeInfo(nsINodeInfo** aResult) const;
diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp
index 7f0f88582f0..ded2a460b27 100644
--- a/mozilla/content/base/src/nsGenericElement.cpp
+++ b/mozilla/content/base/src/nsGenericElement.cpp
@@ -192,38 +192,7 @@ nsNode3Tearoff::GetBaseURI(nsAString& aURI)
{
nsCOMPtr uri;
- nsCOMPtr doc;
- mContent->GetDocument(getter_AddRefs(doc));
-
- // XML content can use the XML Base (W3C spec) way of setting the
- // base per element. We look at this node and its ancestors until we
- // find the first XML content and get it's base.
- nsCOMPtr content(mContent);
-
- do {
- nsCOMPtr xmlContent(do_QueryInterface(content));
-
- if (xmlContent) {
- xmlContent->GetXMLBaseURI(getter_AddRefs(uri));
-
- break;
- }
-
- nsCOMPtr parent;
- content->GetParent(getter_AddRefs(parent));
- content.swap(parent);
- } while (content);
-
- if (!uri && doc) {
- // HTML document or for some reason there was no XML content in
- // XML document
-
- doc->GetBaseURL(getter_AddRefs(uri));
-
- if (!uri) {
- doc->GetDocumentURL(getter_AddRefs(uri));
- }
- }
+ mContent->GetBaseURL(getter_AddRefs(uri));
nsCAutoString spec;
@@ -1315,16 +1284,6 @@ nsGenericElement::HasAttributes(PRBool* aReturn)
return NS_OK;
}
-NS_IMETHODIMP
-nsGenericElement::GetXMLBaseURI(nsIURI **aURI)
-{
- NS_ENSURE_ARG_POINTER(aURI);
-
- *aURI = nsnull;
-
- return NS_OK;
-}
-
NS_IMETHODIMP
nsGenericElement::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
{
@@ -2281,7 +2240,56 @@ nsGenericElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsGenericElement::GetBaseURL(nsIURI** aBaseURL) const
{
- return NS_ERROR_NOT_IMPLEMENTED;
+ nsCOMPtr doc = mDocument;
+
+ if (!doc) {
+ mNodeInfo->GetDocument(getter_AddRefs(doc));
+ }
+
+ // Our base URL depends on whether we have an xml:base attribute, as
+ // well as on whether any of our ancestors do.
+ nsCOMPtr parentBase;
+ if (mParent) {
+ mParent->GetBaseURL(getter_AddRefs(parentBase));
+ } else if (doc) {
+ // No parent, so just use the document (we must be the root or not in the
+ // tree).
+ doc->GetBaseURL(getter_AddRefs(parentBase));
+ }
+
+ // Now check for an xml:base attr
+ nsAutoString value;
+ nsresult rv = GetAttr(kNameSpaceID_XML, nsHTMLAtoms::base, value);
+ if (rv != NS_CONTENT_ATTR_HAS_VALUE) {
+ // No xml:base, so we just use the parent's base URL
+ NS_IF_ADDREF(*aBaseURL = parentBase);
+ return NS_OK;
+ }
+
+ nsCAutoString charset;
+ if (doc) {
+ doc->GetDocumentCharacterSet(charset);
+ }
+
+ nsCOMPtr ourBase;
+ rv = NS_NewURI(getter_AddRefs(ourBase), value, charset.get(), parentBase);
+ if (NS_SUCCEEDED(rv)) {
+ // do a security check, almost the same as nsDocument::SetBaseURL()
+ nsCOMPtr securityManager =
+ do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
+ if (securityManager) {
+ rv = securityManager->CheckLoadURI(parentBase, ourBase,
+ nsIScriptSecurityManager::STANDARD);
+ }
+ }
+
+ if (NS_FAILED(rv)) {
+ NS_IF_ADDREF(*aBaseURL = parentBase);
+ } else {
+ NS_IF_ADDREF(*aBaseURL = ourBase);
+ }
+
+ return NS_OK;
}
NS_IMETHODIMP
diff --git a/mozilla/content/base/src/nsGenericElement.h b/mozilla/content/base/src/nsGenericElement.h
index 5c417c1bbab..0141ca03a4d 100644
--- a/mozilla/content/base/src/nsGenericElement.h
+++ b/mozilla/content/base/src/nsGenericElement.h
@@ -419,6 +419,7 @@ public:
NS_IMETHOD SetBindingParent(nsIContent* aParent);
NS_IMETHOD_(PRBool) IsContentOfType(PRUint32 aFlags);
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aInstancePtrResult);
+ NS_IMETHOD GetBaseURL(nsIURI** aBaseURL) const;
NS_IMETHOD DoneCreatingElement();
@@ -433,7 +434,6 @@ public:
// nsIXMLContent interface methods
NS_IMETHOD MaybeTriggerAutoLink(nsIDocShell *aShell);
- NS_IMETHOD GetXMLBaseURI(nsIURI **aURI);
// nsIHTMLContent interface methods
NS_IMETHOD Compact();
@@ -449,7 +449,6 @@ public:
NS_IMETHOD StringToAttribute(nsIAtom* aAttribute,
const nsAString& aValue,
nsHTMLValue& aResult);
- NS_IMETHOD GetBaseURL(nsIURI** aBaseURL) const;
NS_IMETHOD GetBaseTarget(nsAString& aBaseTarget) const;
// nsIDOMNode method implementation
diff --git a/mozilla/content/base/src/nsHTMLContentSerializer.cpp b/mozilla/content/base/src/nsHTMLContentSerializer.cpp
index e93157fc1ec..5c4d45fa57c 100644
--- a/mozilla/content/base/src/nsHTMLContentSerializer.cpp
+++ b/mozilla/content/base/src/nsHTMLContentSerializer.cpp
@@ -625,8 +625,6 @@ nsHTMLContentSerializer::SerializeAttributes(nsIContent* aContent,
if (document) {
nsCOMPtr uri;
document->GetBaseURL(getter_AddRefs(uri));
- if (!uri)
- document->GetDocumentURL(getter_AddRefs(uri));
if (uri) {
nsAutoString absURI;
rv = NS_MakeAbsoluteURI(absURI, valueStr, uri);
diff --git a/mozilla/content/base/src/nsImageLoadingContent.cpp b/mozilla/content/base/src/nsImageLoadingContent.cpp
index 00f89a20fad..57b664ba5bf 100644
--- a/mozilla/content/base/src/nsImageLoadingContent.cpp
+++ b/mozilla/content/base/src/nsImageLoadingContent.cpp
@@ -383,7 +383,7 @@ nsImageLoadingContent::ImageURIChanged(const nsACString& aNewURI)
nsresult rv; // XXXbz Should failures in this method fire onerror?
- // First, get a document (needed for security checks, base URI and the like)
+ // First, get a document (needed for security checks and the like)
nsCOMPtr doc;
rv = GetOurDocument(getter_AddRefs(doc));
if (!doc) {
@@ -586,15 +586,9 @@ nsImageLoadingContent::StringToURI(const nsACString& aSpec,
// (1) Get the base URI
nsCOMPtr baseURL;
- nsCOMPtr thisContent = do_QueryInterface(this);
- if (thisContent) {
- rv = thisContent->GetBaseURL(getter_AddRefs(baseURL));
- } else {
- rv = aDocument->GetBaseURL(getter_AddRefs(baseURL));
- if (!baseURL) {
- rv = aDocument->GetDocumentURL(getter_AddRefs(baseURL));
- }
- }
+ nsCOMPtr thisContent = do_QueryInterface(this);
+ NS_ASSERTION(thisContent, "An image loading content must be an nsIContent");
+ rv = thisContent->GetBaseURL(getter_AddRefs(baseURL));
NS_ENSURE_SUCCESS(rv, rv);
// (2) Get the charset
diff --git a/mozilla/content/base/src/nsScriptLoader.cpp b/mozilla/content/base/src/nsScriptLoader.cpp
index 31dd50f4fb9..bfb05126675 100644
--- a/mozilla/content/base/src/nsScriptLoader.cpp
+++ b/mozilla/content/base/src/nsScriptLoader.cpp
@@ -401,7 +401,9 @@ nsScriptLoader::ProcessScriptElement(nsIDOMHTMLScriptElement *aElement,
nsCOMPtr baseURI, scriptURI;
// Use the SRC attribute value to load the URL
- mDocument->GetBaseURL(getter_AddRefs(baseURI));
+ nsCOMPtr content(do_QueryInterface(aElement));
+ NS_ASSERTION(content, "nsIDOMHTMLScriptElement not implementing nsIContent");
+ content->GetBaseURL(getter_AddRefs(baseURI));
rv = NS_NewURI(getter_AddRefs(scriptURI), src, nsnull, baseURI);
if (NS_FAILED(rv)) {
return FireErrorNotification(rv, aElement, aObserver);
diff --git a/mozilla/content/html/content/public/nsIHTMLContent.h b/mozilla/content/html/content/public/nsIHTMLContent.h
index 94041ab846a..977de13d308 100644
--- a/mozilla/content/html/content/public/nsIHTMLContent.h
+++ b/mozilla/content/html/content/public/nsIHTMLContent.h
@@ -133,16 +133,6 @@ public:
const nsAString& aValue,
nsHTMLValue& aResult) = 0;
- /**
- * Get the base URL for any relative URLs within this piece
- * of content. Generally, this is the document's base URL,
- * but certain content carries a local base for backward
- * compatibility.
- *
- * @param aBaseURL the base URL [OUT]
- */
- NS_IMETHOD GetBaseURL(nsIURI** aBaseURL) const = 0;
-
/**
* Get the base target for any links within this piece
* of content. Generally, this is the document's base target,
diff --git a/mozilla/content/html/content/src/nsAttributeContent.cpp b/mozilla/content/html/content/src/nsAttributeContent.cpp
index 698e778240e..d2771d4be96 100644
--- a/mozilla/content/html/content/src/nsAttributeContent.cpp
+++ b/mozilla/content/html/content/src/nsAttributeContent.cpp
@@ -64,7 +64,7 @@
#include "nsVoidArray.h"
#include "nsINameSpaceManager.h"
#include "nsITextContent.h"
-
+#include "nsIURI.h"
// XXX share all id's in this dir
@@ -135,6 +135,8 @@ public:
return NS_ERROR_NOT_IMPLEMENTED;
}
+ NS_IMETHOD GetBaseURL(nsIURI** aURI) const;
+
NS_IMETHOD DoneCreatingElement() {
return NS_OK;
}
@@ -373,6 +375,20 @@ nsAttributeContent::GetRangeList(nsVoidArray** aResult) const
return NS_ERROR_FAILURE;
}
+NS_IMETHODIMP
+nsAttributeContent::GetBaseURL(nsIURI** aURI) const
+{
+ if (mParent) {
+ return mParent->GetBaseURL(aURI);
+ }
+
+ if (mDocument) {
+ return mDocument->GetBaseURL(aURI);
+ }
+
+ *aURI = nsnull;
+ return NS_OK;
+}
diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp
index 619c6cbb12e..d81b9fa8c6a 100644
--- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp
@@ -2355,18 +2355,36 @@ nsGenericHTMLElement::GetInlineStyleRule(nsIStyleRule** aStyleRule)
nsresult
nsGenericHTMLElement::GetBaseURL(nsIURI** aBaseURL) const
{
- nsHTMLValue baseHref;
- if (mAttributes) {
- mAttributes->GetAttribute(nsHTMLAtoms::_baseHref, baseHref);
- }
-
nsCOMPtr doc(mDocument);
if (!doc) {
mNodeInfo->GetDocument(getter_AddRefs(doc));
}
- return GetBaseURL(baseHref, doc, aBaseURL);
+ if (mAttributes &&
+ mAttributes->HasAttribute(nsHTMLAtoms::_baseHref, kNameSpaceID_None)) {
+
+ nsHTMLValue baseHref;
+ mAttributes->GetAttribute(nsHTMLAtoms::_baseHref, baseHref);
+
+ if (baseHref.GetUnit() == eHTMLUnit_String) {
+ // We have a _baseHref attribute; that will determine our base URL
+ return GetBaseURL(baseHref, doc, aBaseURL);
+ }
+ }
+
+ // If we are a plain old HTML element (not XHTML), don't bother asking the
+ // base class -- our base URL is determined solely by the document base.
+ if (mNodeInfo->NamespaceEquals(kNameSpaceID_None)) {
+ if (doc) {
+ return doc->GetBaseURL(aBaseURL);
+ }
+
+ *aBaseURL = nsnull;
+ return NS_OK;
+ }
+
+ return nsGenericElement::GetBaseURL(aBaseURL);
}
nsresult
@@ -2385,7 +2403,6 @@ nsGenericHTMLElement::GetBaseURL(const nsHTMLValue& aBaseHref,
if (eHTMLUnit_String == aBaseHref.GetUnit()) {
nsAutoString baseHref;
aBaseHref.GetStringValue(baseHref);
- baseHref.Trim(" \t\n\r");
*aBaseURL = nsnull;
return NS_NewURI(aBaseURL, baseHref, nsnull, docBaseURL);
@@ -3101,7 +3118,7 @@ nsGenericHTMLElement::ParseStyleAttribute(const nsAString& aValue, nsHTMLValue&
}
if (doc) {
- PRBool isCSS = PR_TRUE; // asume CSS until proven otherwise
+ PRBool isCSS = PR_TRUE; // assume CSS until proven otherwise
nsAutoString styleType;
doc->GetHeaderData(nsHTMLAtoms::headerContentStyleType, styleType);
@@ -3130,11 +3147,12 @@ nsGenericHTMLElement::ParseStyleAttribute(const nsAString& aValue, nsHTMLValue&
}
}
if (cssParser) {
- nsCOMPtr docURL;
- doc->GetBaseURL(getter_AddRefs(docURL));
+ nsCOMPtr baseURL;
+ GetBaseURL(getter_AddRefs(baseURL));
nsCOMPtr rule;
- result = cssParser->ParseStyleAttribute(aValue, docURL, getter_AddRefs(rule));
+ result = cssParser->ParseStyleAttribute(aValue, baseURL,
+ getter_AddRefs(rule));
if (cssLoader) {
cssLoader->RecycleParser(cssParser);
}
@@ -3429,6 +3447,8 @@ nsGenericHTMLElement::MapBackgroundAttributesInto(const nsIHTMLMappedAttributes*
value.GetStringValue(spec);
if (!spec.IsEmpty()) {
// Resolve url to an absolute url
+ // XXX this breaks if the HTML element has an xml:base
+ // attribute (the xml:base will not be taken into account)
nsCOMPtr shell;
nsresult rv = aData->mPresContext->GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv) && shell) {
@@ -4604,10 +4624,6 @@ nsGenericHTMLElement::GetProtocolFromHrefString(const nsAString& aHref,
if (aDocument) {
aDocument->GetBaseURL(getter_AddRefs(uri));
-
- if (!uri) {
- aDocument->GetDocumentURL(getter_AddRefs(uri));
- }
}
if (uri) {
@@ -4615,7 +4631,7 @@ nsGenericHTMLElement::GetProtocolFromHrefString(const nsAString& aHref,
}
if (protocol.IsEmpty()) {
- // set the protocol to http since it is the mostlikely protocol
+ // set the protocol to http since it is the most likely protocol
// to be used.
CopyASCIItoUCS2(nsDependentCString("http:"), aProtocol);
diff --git a/mozilla/content/html/style/src/nsCSSLoader.cpp b/mozilla/content/html/style/src/nsCSSLoader.cpp
index 20451f63202..c6268a4badc 100644
--- a/mozilla/content/html/style/src/nsCSSLoader.cpp
+++ b/mozilla/content/html/style/src/nsCSSLoader.cpp
@@ -956,6 +956,7 @@ CSSLoaderImpl::CheckLoadAllowed(nsIURI* aSourceURI,
*/
nsresult
CSSLoaderImpl::CreateSheet(nsIURI* aURI,
+ nsIContent* aLinkingContent,
PRUint32 aDefaultNameSpaceID,
PRBool aSyncLoad,
StyleSheetState& aSheetState,
@@ -1039,8 +1040,8 @@ CSSLoaderImpl::CreateSheet(nsIURI* aURI,
if (!sheetURI) {
// Inline style. Use the document's base URL so that @import in
// the inline sheet picks up the right base.
- NS_ASSERTION(mDocument, "How did we get in here without a document?");
- mDocument->GetBaseURL(getter_AddRefs(sheetURI));
+ NS_ASSERTION(aLinkingContent, "Inline stylesheet without linking content?");
+ aLinkingContent->GetBaseURL(getter_AddRefs(sheetURI));
}
rv = NS_NewCSSStyleSheet(aSheet, sheetURI);
@@ -1094,7 +1095,7 @@ CSSLoaderImpl::PrepareSheet(nsICSSStyleSheet* aSheet,
*/
nsresult
CSSLoaderImpl::InsertSheetInDoc(nsICSSStyleSheet* aSheet,
- nsIContent* aLinkingElement,
+ nsIContent* aLinkingContent,
nsIDocument* aDocument)
{
LOG(("CSSLoaderImpl::InsertSheetInDoc"));
@@ -1103,8 +1104,8 @@ CSSLoaderImpl::InsertSheetInDoc(nsICSSStyleSheet* aSheet,
// all nodes that link in sheets should be implementing nsIDOM3Node
nsresult rv = NS_OK;
- nsCOMPtr linkingNode = do_QueryInterface(aLinkingElement);
- NS_ASSERTION(linkingNode || !aLinkingElement,
+ nsCOMPtr linkingNode = do_QueryInterface(aLinkingContent);
+ NS_ASSERTION(linkingNode || !aLinkingContent,
"Need to implement nsIDOM3Node to get insertion order right");
// XXX Need to cancel pending sheet loads for this element, if any
@@ -1168,7 +1169,7 @@ CSSLoaderImpl::InsertSheetInDoc(nsICSSStyleSheet* aSheet,
// XXX elements do not implement nsIStyleSheetLinkingElement;
// need to fix this for them to be ordered correctly.
nsCOMPtr
- linkingElement = do_QueryInterface(aLinkingElement);
+ linkingElement = do_QueryInterface(aLinkingContent);
if (linkingElement) {
linkingElement->SetStyleSheet(aSheet); // This sets the ownerNode on the sheet
}
@@ -1589,8 +1590,8 @@ CSSLoaderImpl::LoadInlineStyle(nsIContent* aElement,
StyleSheetState state;
nsCOMPtr sheet;
- nsresult rv = CreateSheet(nsnull, aDefaultNameSpaceID, PR_FALSE, state,
- getter_AddRefs(sheet));
+ nsresult rv = CreateSheet(nsnull, aElement, aDefaultNameSpaceID, PR_FALSE,
+ state, getter_AddRefs(sheet));
NS_ENSURE_SUCCESS(rv, rv);
NS_ASSERTION(state == eSheetNeedsParser,
"Inline sheets should not be cached");
@@ -1651,7 +1652,7 @@ CSSLoaderImpl::LoadStyleLink(nsIContent* aElement,
StyleSheetState state;
nsCOMPtr sheet;
- rv = CreateSheet(aURL, aDefaultNameSpaceID, PR_FALSE, state,
+ rv = CreateSheet(aURL, aElement, aDefaultNameSpaceID, PR_FALSE, state,
getter_AddRefs(sheet));
NS_ENSURE_SUCCESS(rv, rv);
@@ -1761,7 +1762,7 @@ CSSLoaderImpl::LoadChildSheet(nsICSSStyleSheet* aParentSheet,
// loop) do so
nsCOMPtr sheet;
StyleSheetState state;
- rv = CreateSheet(aURL, aDefaultNameSpaceID,
+ rv = CreateSheet(aURL, nsnull, aDefaultNameSpaceID,
parentData ? parentData->mSyncLoad : PR_FALSE,
state, getter_AddRefs(sheet));
NS_ENSURE_SUCCESS(rv, rv);
@@ -1833,8 +1834,8 @@ CSSLoaderImpl::InternalLoadAgentSheet(nsIURI* aURL,
nsCOMPtr sheet;
PRBool syncLoad = (aObserver == nsnull);
- nsresult rv = CreateSheet(aURL, kNameSpaceID_Unknown, syncLoad, state,
- getter_AddRefs(sheet));
+ nsresult rv = CreateSheet(aURL, nsnull, kNameSpaceID_Unknown, syncLoad,
+ state, getter_AddRefs(sheet));
NS_ENSURE_SUCCESS(rv, rv);
NS_NAMED_LITERAL_STRING(empty, "");
diff --git a/mozilla/content/html/style/src/nsCSSLoader.h b/mozilla/content/html/style/src/nsCSSLoader.h
index e99e3f16b61..5b72b77a352 100644
--- a/mozilla/content/html/style/src/nsCSSLoader.h
+++ b/mozilla/content/html/style/src/nsCSSLoader.h
@@ -307,8 +307,11 @@ private:
nsresult CheckLoadAllowed(nsIURI* aSourceURI,
nsIURI* aTargetURI,
nsISupports* aContext);
-
+
+ // For inline style, the aURI param is null, but the aLinkingContent
+ // must be non-null then.
nsresult CreateSheet(nsIURI* aURI,
+ nsIContent* aLinkingContent,
PRUint32 aDefaultNameSpaceID,
PRBool aSyncLoad,
StyleSheetState& aSheetState,
@@ -319,7 +322,7 @@ private:
const nsAString& aMedia);
nsresult InsertSheetInDoc(nsICSSStyleSheet* aSheet,
- nsIContent* aLinkingElement,
+ nsIContent* aLinkingContent,
nsIDocument* aDocument);
nsresult InsertChildSheet(nsICSSStyleSheet* aSheet,
diff --git a/mozilla/content/html/style/src/nsDOMCSSAttrDeclaration.cpp b/mozilla/content/html/style/src/nsDOMCSSAttrDeclaration.cpp
index dd1e79d1b9d..e4130536955 100644
--- a/mozilla/content/html/style/src/nsDOMCSSAttrDeclaration.cpp
+++ b/mozilla/content/html/style/src/nsDOMCSSAttrDeclaration.cpp
@@ -168,15 +168,15 @@ nsDOMCSSAttributeDeclaration::GetCSSParsingEnvironment(nsIURI** aBaseURI,
if (NS_FAILED(result)) {
return result;
}
+
+ mContent->GetBaseURL(aBaseURI);
- if (doc) {
- doc->GetBaseURL(aBaseURI);
- nsCOMPtr htmlContainer(do_QueryInterface(doc));
- if (htmlContainer) {
- htmlContainer->GetCSSLoader(*aCSSLoader);
- }
- NS_ASSERTION(*aCSSLoader, "Document with no CSS loader!");
+ nsCOMPtr htmlContainer(do_QueryInterface(doc));
+ if (htmlContainer) {
+ htmlContainer->GetCSSLoader(*aCSSLoader);
}
+ NS_ASSERTION(!doc || *aCSSLoader, "Document with no CSS loader!");
+
if (*aCSSLoader) {
result = (*aCSSLoader)->GetParserFor(nsnull, aCSSParser);
} else {
diff --git a/mozilla/content/html/style/src/nsStyleUtil.cpp b/mozilla/content/html/style/src/nsStyleUtil.cpp
index 7def156cbfc..f59f2170320 100644
--- a/mozilla/content/html/style/src/nsStyleUtil.cpp
+++ b/mozilla/content/html/style/src/nsStyleUtil.cpp
@@ -647,22 +647,9 @@ PRBool nsStyleUtil::IsSimpleXlink(nsIContent *aContent, nsIPresContext *aPresCon
// is it bad to re-use val here?
aContent->GetAttr(kNameSpaceID_XLink, nsHTMLAtoms::href, val);
- // It's an XLink. Resolve it relative to its document.
+ // It's an XLink. Resolve it relative to aContent's base URI.
nsCOMPtr baseURI;
- nsCOMPtr htmlContent = do_QueryInterface(aContent);
- if (htmlContent) {
- // XXX why do this? will nsIHTMLContent's
- // GetBaseURL() may return something different
- // than the URL of the document it lives in?
- htmlContent->GetBaseURL(getter_AddRefs(baseURI));
- }
- else {
- nsCOMPtr doc;
- aContent->GetDocument(getter_AddRefs(doc));
- if (doc) {
- doc->GetBaseURL(getter_AddRefs(baseURI));
- }
- }
+ aContent->GetBaseURL(getter_AddRefs(baseURI));
nsCOMPtr absURI;
// XXX should we make sure to get the right charset off the document?
diff --git a/mozilla/content/svg/content/src/nsISVGStyleValue.h b/mozilla/content/svg/content/src/nsISVGStyleValue.h
index 0f19150bc4a..7aff7bba8a6 100644
--- a/mozilla/content/svg/content/src/nsISVGStyleValue.h
+++ b/mozilla/content/svg/content/src/nsISVGStyleValue.h
@@ -43,7 +43,7 @@
#include "nsISupports.h"
class nsIStyleRule;
-class nsIDocument;
+class nsIContent;
// {BD099C4C-8FA5-47c4-A44E-189B5AA5DBAF}
#define NS_ISVGSTYLEVALUE_IID \
@@ -54,7 +54,7 @@ class nsISVGStyleValue : public nsISupports
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISVGSTYLEVALUE_IID)
- NS_IMETHOD GetStyleRule(nsIDocument* baseDocument, nsIStyleRule** rule)=0;
+ NS_IMETHOD GetStyleRule(nsIContent* aContent, nsIStyleRule** rule)=0;
};
#endif // __NS_ISVGSTYLEVALUE_H__
diff --git a/mozilla/content/svg/content/src/nsSVGElement.cpp b/mozilla/content/svg/content/src/nsSVGElement.cpp
index 0936926575e..3ca0604c861 100644
--- a/mozilla/content/svg/content/src/nsSVGElement.cpp
+++ b/mozilla/content/svg/content/src/nsSVGElement.cpp
@@ -447,7 +447,7 @@ nsSVGElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
NS_IMETHODIMP
nsSVGElement::GetInlineStyleRule(nsIStyleRule** aStyleRule)
{
- return mStyle->GetStyleRule(mDocument, aStyleRule);
+ return mStyle->GetStyleRule(this, aStyleRule);
}
NS_IMETHODIMP
diff --git a/mozilla/content/svg/content/src/nsSVGStyleValue.cpp b/mozilla/content/svg/content/src/nsSVGStyleValue.cpp
index d1a8cbffed1..e5d1a9c9d36 100644
--- a/mozilla/content/svg/content/src/nsSVGStyleValue.cpp
+++ b/mozilla/content/svg/content/src/nsSVGStyleValue.cpp
@@ -40,7 +40,7 @@
#include "nsISVGStyleValue.h"
#include "nsSVGStyleValue.h"
#include "nsIStyleRule.h"
-#include "nsIDocument.h"
+#include "nsIContent.h"
#include "nsIURI.h"
#include "nsICSSParser.h"
#include "nsIServiceManager.h"
@@ -65,11 +65,11 @@ public:
NS_IMETHOD GetValueString(nsAString& aValue);
// nsISVGStyleValue interface:
- NS_IMETHOD GetStyleRule(nsIDocument* baseDoc, nsIStyleRule** rule);
+ NS_IMETHOD GetStyleRule(nsIContent* aContent, nsIStyleRule** rule);
protected:
// Implementation helpers:
- void UpdateStyleRule(nsIDocument* baseDoc);
+ void UpdateStyleRule(nsIContent* aContent);
nsString mValue;
nsCOMPtr mRule; // lazily cached
@@ -127,10 +127,10 @@ nsSVGStyleValue::GetValueString(nsAString& aValue)
// nsISVGStyleValue interface:
NS_IMETHODIMP
-nsSVGStyleValue::GetStyleRule(nsIDocument* baseDoc, nsIStyleRule** rule)
+nsSVGStyleValue::GetStyleRule(nsIContent* aContent, nsIStyleRule** rule)
{
if (!mRule) {
- UpdateStyleRule(baseDoc);
+ UpdateStyleRule(aContent);
}
*rule = mRule;
@@ -143,7 +143,7 @@ nsSVGStyleValue::GetStyleRule(nsIDocument* baseDoc, nsIStyleRule** rule)
// Implementation helpers:
void
-nsSVGStyleValue::UpdateStyleRule(nsIDocument* baseDoc)
+nsSVGStyleValue::UpdateStyleRule(nsIContent* aContent)
{
if (mValue.IsEmpty()) {
@@ -152,17 +152,13 @@ nsSVGStyleValue::UpdateStyleRule(nsIDocument* baseDoc)
return;
}
- NS_ASSERTION(baseDoc,"need base document");
- nsCOMPtr docURL;
- baseDoc->GetBaseURL(getter_AddRefs(docURL));
+ NS_ASSERTION(aContent, "need content node for base URL");
+ nsCOMPtr baseURL;
+ aContent->GetBaseURL(getter_AddRefs(baseURL));
- nsCOMPtr css;
- nsComponentManager::CreateInstance(kCSSParserCID,
- nsnull,
- NS_GET_IID(nsICSSParser),
- getter_AddRefs(css));
+ nsCOMPtr css = do_CreateInstance(kCSSParserCID);
NS_ASSERTION(css, "can't get a css parser");
if (!css) return;
- css->ParseStyleAttribute(mValue, docURL, getter_AddRefs(mRule));
+ css->ParseStyleAttribute(mValue, baseURL, getter_AddRefs(mRule));
}
diff --git a/mozilla/content/xml/content/public/nsIXMLContent.h b/mozilla/content/xml/content/public/nsIXMLContent.h
index f76e0efae98..ddd8162078f 100644
--- a/mozilla/content/xml/content/public/nsIXMLContent.h
+++ b/mozilla/content/xml/content/public/nsIXMLContent.h
@@ -75,12 +75,6 @@ public:
* which case, the caller should stop parsing as well.
*/
NS_IMETHOD MaybeTriggerAutoLink(nsIDocShell *aShell) = 0;
-
- /**
- * Get the XML Base URI for this element (http://www.w3.org/TR/xmlbase/)
- * @param aURI the base URI [OUT]
- */
- NS_IMETHOD GetXMLBaseURI(nsIURI **aURI) = 0;
};
nsresult
diff --git a/mozilla/content/xml/content/src/nsXMLElement.cpp b/mozilla/content/xml/content/src/nsXMLElement.cpp
index c970b8c31a6..c60dc494171 100644
--- a/mozilla/content/xml/content/src/nsXMLElement.cpp
+++ b/mozilla/content/xml/content/src/nsXMLElement.cpp
@@ -147,125 +147,6 @@ NS_IMPL_ADDREF_INHERITED(nsXMLElement, nsGenericElement)
NS_IMPL_RELEASE_INHERITED(nsXMLElement, nsGenericElement)
-NS_IMETHODIMP
-nsXMLElement::GetXMLBaseURI(nsIURI **aURI)
-{
- NS_ENSURE_ARG_POINTER(aURI);
- *aURI = nsnull;
-
- nsresult rv;
-
- nsAutoString base;
- nsCOMPtr content(do_QueryInterface(NS_STATIC_CAST(nsIXMLContent*,this),&rv));
- while (NS_SUCCEEDED(rv) && content) {
- nsAutoString value;
- rv = content->GetAttr(kNameSpaceID_XML,nsHTMLAtoms::base,value);
- PRInt32 value_len;
- if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
- PRInt32 colon = value.FindChar(':');
- PRInt32 slash = value.FindChar('/');
- if (colon > 0 && !( slash >= 0 && slash < colon)) {
- // Yay, we have absolute path!
- // The complex looking if above is to make sure that we do not erroneously
- // think a value of "./this:that" would have a scheme of "./that"
-
- rv = NS_NewURIWithDocumentCharset(aURI, value, mDocument, nsnull);
- if (NS_FAILED(rv))
- break;
-
- if (!base.IsEmpty()) { // XXXdarin base is always empty
- NS_ConvertUTF16toUTF8 str(base);
- nsCAutoString resolvedStr;
- rv = (*aURI)->Resolve(str, resolvedStr);
- if (NS_FAILED(rv)) break;
- rv = (*aURI)->SetSpec(resolvedStr);
- }
- break;
-
- } else if ((value_len = value.Length()) > 0) {
- if (!base.IsEmpty()) {
- if (base[0] == '/') {
- // Do nothing, we are waiting for a scheme starting value
- } else {
- // We do not want to add double / delimiters (although the user is free to do so)
- if (value[value_len - 1] != '/')
- value.Append(PRUnichar('/'));
- base.Insert(value, 0);
- }
- } else {
- if (value[value_len - 1] != '/')
- value.Append(PRUnichar('/')); // Add delimiter/make sure we treat this as dir
- base = value;
- }
- }
- } // if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
- nsCOMPtr parent;
- rv = content->GetParent(getter_AddRefs(parent));
- content = parent;
- } // while
-
- if (NS_SUCCEEDED(rv)) {
- if (!*aURI && mDocument) {
- nsCOMPtr docBase;
- mDocument->GetBaseURL(getter_AddRefs(docBase));
- if (!docBase) {
- mDocument->GetDocumentURL(getter_AddRefs(docBase));
- }
- if (base.IsEmpty()) {
- *aURI = docBase.get();
- NS_IF_ADDREF(*aURI); // nsCOMPtr releases this once
- } else {
- rv = NS_NewURIWithDocumentCharset(aURI, base, mDocument, docBase);
- }
- }
-
- // Finally do a security check, almost the same as nsDocument::SetBaseURL()
- if (*aURI) {
- nsCOMPtr securityManager =
- do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
- if (NS_SUCCEEDED(rv)) {
- nsCOMPtr docURI;
- mDocument->GetDocumentURL(getter_AddRefs(docURI));
- rv = securityManager->CheckLoadURI(docURI, *aURI, nsIScriptSecurityManager::STANDARD);
- if (NS_FAILED(rv)) {
- // Now we need to get the "closest" allowed base URI
- NS_RELEASE(*aURI);
-
- if (content) { // content is the last content we tried above
- nsCOMPtr parent;
- content->GetParent(getter_AddRefs(parent));
- content = parent;
- while (content) {
- nsCOMPtr xml(do_QueryInterface(content));
- if (xml) {
- return xml->GetXMLBaseURI(aURI);
- }
- content->GetParent(getter_AddRefs(parent));
- content = parent;
- }
- }
-
- nsCOMPtr docBase;
- mDocument->GetBaseURL(getter_AddRefs(docBase));
- if (!docBase) {
- mDocument->GetDocumentURL(getter_AddRefs(docBase));
- }
-
- *aURI = docBase.get();
- NS_IF_ADDREF(*aURI);
- rv = NS_OK;
- }
- }
- }
- }
-
- if (NS_FAILED(rv)) {
- NS_IF_RELEASE(*aURI);
- }
-
- return rv;
-}
-
NS_IMETHODIMP
nsXMLElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString& aValue,
@@ -309,7 +190,6 @@ static nsresult DocShellToPresContext(nsIDocShell *aShell,
return ds->GetPresContext(aPresContext);
}
-
static nsresult CheckLoadURI(const nsString& aSpec, nsIURI *aBaseURI,
nsIDocument* aDocument, nsIURI **aAbsURI)
{
@@ -428,7 +308,7 @@ nsXMLElement::MaybeTriggerAutoLink(nsIDocShell *aShell)
// base
nsCOMPtr base;
- rv = GetXMLBaseURI(getter_AddRefs(base));
+ rv = GetBaseURL(getter_AddRefs(base));
if (NS_FAILED(rv))
break;
@@ -528,7 +408,7 @@ nsXMLElement::HandleDOMEvent(nsIPresContext* aPresContext,
}
nsCOMPtr baseURL;
- GetXMLBaseURI(getter_AddRefs(baseURL));
+ GetBaseURL(getter_AddRefs(baseURL));
nsCOMPtr uri;
ret = NS_NewURIWithDocumentCharset(getter_AddRefs(uri), href,
mDocument, baseURL);
@@ -587,7 +467,7 @@ nsXMLElement::HandleDOMEvent(nsIPresContext* aPresContext,
}
nsCOMPtr baseURL;
- GetXMLBaseURI(getter_AddRefs(baseURL));
+ GetBaseURL(getter_AddRefs(baseURL));
nsCOMPtr uri;
ret = NS_NewURIWithDocumentCharset(getter_AddRefs(uri), href,
diff --git a/mozilla/content/xml/content/src/nsXMLElement.h b/mozilla/content/xml/content/src/nsXMLElement.h
index 4be91205b30..b4319e80b28 100644
--- a/mozilla/content/xml/content/src/nsXMLElement.h
+++ b/mozilla/content/xml/content/src/nsXMLElement.h
@@ -69,7 +69,6 @@ public:
// nsIXMLContent
NS_IMETHOD MaybeTriggerAutoLink(nsIDocShell *aShell);
- NS_IMETHOD GetXMLBaseURI(nsIURI **aURI);
// nsIStyledContent
NS_IMETHOD GetID(nsIAtom** aResult) const;
diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp
index 4ecbf7e71ec..03993412a21 100644
--- a/mozilla/content/xul/content/src/nsXULElement.cpp
+++ b/mozilla/content/xul/content/src/nsXULElement.cpp
@@ -1591,38 +1591,6 @@ nsXULElement::MaybeTriggerAutoLink(nsIDocShell *aShell)
return NS_OK;
}
-NS_IMETHODIMP
-nsXULElement::GetXMLBaseURI(nsIURI **aURI)
-{
- // XXX TODO, should share the impl with nsXMLElement
- NS_ENSURE_ARG_POINTER(aURI);
- *aURI = nsnull;
- if (mDocument) {
- mDocument->GetBaseURL(aURI);
- if (!*aURI) {
- mDocument->GetDocumentURL(aURI);
- }
- }
- return NS_OK;
-}
-
-#if 0
-NS_IMETHODIMP
-nsXULElement::GetBaseURI(nsAString &aURI)
-{
- // XXX TODO, should share the impl with nsXMLElement
- aURI.Truncate();
- nsresult rv = NS_OK;
- if (mDocument) {
- nsCOMPtr doc(do_QueryInterface(mDocument));
- if (doc) {
- rv = doc->GetBaseURI(aURI);
- }
- }
- return rv;
-}
-#endif
-
//----------------------------------------------------------------------
// nsIXULContent interface
@@ -2472,12 +2440,10 @@ nsXULElement::SetAttr(nsINodeInfo* aNodeInfo,
// Check to see if the STYLE attribute is being set. If so, we need to
// create a new style rule based off the value of this attribute, and we
// need to let the document know about the StyleRule change.
- // XXXbz this should not be checking for mDocument; it should get
- // the document off the nodeinfo
- if (aNodeInfo->Equals(nsXULAtoms::style, kNameSpaceID_None) && mDocument) {
- nsCOMPtr docURL;
- mDocument->GetBaseURL(getter_AddRefs(docURL));
- Attributes()->UpdateStyleRule(docURL, aValue);
+ if (aNodeInfo->Equals(nsXULAtoms::style, kNameSpaceID_None)) {
+ nsCOMPtr baseURL;
+ GetBaseURL(getter_AddRefs(baseURL));
+ Attributes()->UpdateStyleRule(baseURL, aValue);
}
nsCOMPtr tag;
@@ -2750,17 +2716,15 @@ nsXULElement::UnsetAttr(PRInt32 aNameSpaceID,
// XXXwaterson if aNotify == PR_TRUE, do we want to call
// nsIDocument::BeginUpdate() now?
if (aNameSpaceID == kNameSpaceID_None) {
- if (mDocument) {
if (aName == nsXULAtoms::clazz) {
// If CLASS is being unset, delete our class list.
Attributes()->UpdateClassList(nsAutoString());
} else if (aName == nsXULAtoms::style) {
- nsCOMPtr docURL;
- mDocument->GetBaseURL(getter_AddRefs(docURL));
- Attributes()->UpdateStyleRule(docURL, nsAutoString());
+ nsCOMPtr baseURL;
+ GetBaseURL(getter_AddRefs(baseURL));
+ Attributes()->UpdateStyleRule(baseURL, nsAutoString());
// XXX Some kind of special document update might need to happen here.
}
- }
}
nsCOMPtr tag;
@@ -3383,6 +3347,18 @@ nsXULElement::SetContentID(PRUint32 aID)
return NS_OK;
}
+NS_IMETHODIMP
+nsXULElement::GetBaseURL(nsIURI **aURI) const
+{
+ // XXX TODO, should share the impl with nsGenericElement
+ if (mDocument) {
+ return mDocument->GetBaseURL(aURI);
+ }
+
+ *aURI = nsnull;
+ return NS_OK;
+}
+
NS_IMETHODIMP
nsXULElement::RangeAdd(nsIDOMRange* aRange)
{
diff --git a/mozilla/content/xul/content/src/nsXULElement.h b/mozilla/content/xul/content/src/nsXULElement.h
index f3528b861ef..fbf2ccf1bbc 100644
--- a/mozilla/content/xul/content/src/nsXULElement.h
+++ b/mozilla/content/xul/content/src/nsXULElement.h
@@ -459,11 +459,11 @@ public:
NS_IMETHOD GetBindingParent(nsIContent** aContent);
NS_IMETHOD SetBindingParent(nsIContent* aParent);
NS_IMETHOD_(PRBool) IsContentOfType(PRUint32 aFlags);
+ NS_IMETHOD GetBaseURL(nsIURI** aURI) const;
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aResult);
// nsIXMLContent
NS_IMETHOD MaybeTriggerAutoLink(nsIDocShell *aShell);
- NS_IMETHOD GetXMLBaseURI(nsIURI **aURI);
// nsIStyledContent
NS_IMETHOD GetID(nsIAtom** aResult) const;
diff --git a/mozilla/dom/src/base/nsLocation.cpp b/mozilla/dom/src/base/nsLocation.cpp
index 1f9d26f02ee..35f4d4c07d9 100644
--- a/mozilla/dom/src/base/nsLocation.cpp
+++ b/mozilla/dom/src/base/nsLocation.cpp
@@ -930,14 +930,10 @@ LocationImpl::GetSourceBaseURL(JSContext* cx, nsIURI** sourceURL)
nsCOMPtr doc;
nsresult rv = GetSourceDocument(cx, getter_AddRefs(doc));
if (doc) {
- rv = doc->GetBaseURL(sourceURL);
-
- if (!*sourceURL) {
- doc->GetDocumentURL(sourceURL);
- }
- } else {
- *sourceURL = nsnull;
+ return doc->GetBaseURL(sourceURL);
}
+
+ *sourceURL = nsnull;
return rv;
}
diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp
index ae21db0381a..b36b7b3ab7d 100644
--- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp
@@ -5982,23 +5982,24 @@ nsHTMLEditor::ParseStyleAttrIntoCSSRule(const nsAString& aString,
return NS_ERROR_UNEXPECTED;
nsCOMPtr docURL;
doc->GetBaseURL(getter_AddRefs(docURL));
- nsCOMPtr css;
- nsCOMPtr mRule;
- nsComponentManager::CreateInstance(kCSSParserCID,
- nsnull,
- NS_GET_IID(nsICSSParser),
- getter_AddRefs(css));
+ nsCOMPtr css = do_CreateInstance(kCSSParserCID);;
NS_ASSERTION(css, "can't get a css parser");
if (!css) return NS_ERROR_NULL_POINTER;
- //nsAutoString value(aString);
+ nsCOMPtr mRule;
css->ParseStyleAttribute(aString, docURL, getter_AddRefs(mRule));
- nsCOMPtr styleRule = do_QueryInterface(mRule);
- if (styleRule) {
- *_retval = styleRule;
- NS_ADDREF(*_retval);
+ nsCOMPtr styleRule = do_QueryInterface(mRule);
+ if (!styleRule) {
+ return NS_ERROR_UNEXPECTED;
}
- return NS_OK;
+
+ nsCOMPtr domRule;
+ styleRule->GetDOMRule(getter_AddRefs(domRule));
+ if (!domRule) {
+ return NS_ERROR_UNEXPECTED;
+ }
+
+ return CallQueryInterface(domRule, _retval);
}
NS_IMETHODIMP
diff --git a/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp b/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp
index 298a4ed3800..ad930cfc899 100644
--- a/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp
+++ b/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp
@@ -1140,10 +1140,6 @@ nsWindowWatcher::URIfromURL(const char *aURL,
doc = do_QueryInterface(domDoc);
if (doc) {
doc->GetBaseURL(getter_AddRefs(baseURI));
-
- if (!baseURI) {
- doc->GetDocumentURL(getter_AddRefs(baseURI));
- }
}
}
}
diff --git a/mozilla/layout/generic/nsBulletFrame.cpp b/mozilla/layout/generic/nsBulletFrame.cpp
index 5078cf57457..f5d9ceb071c 100644
--- a/mozilla/layout/generic/nsBulletFrame.cpp
+++ b/mozilla/layout/generic/nsBulletFrame.cpp
@@ -135,7 +135,7 @@ nsBulletFrame::Init(nsIPresContext* aPresContext,
GetLoadGroup(aPresContext, getter_AddRefs(loadGroup));
nsCOMPtr baseURI;
- GetBaseURI(getter_AddRefs(baseURI));
+ mContent->GetBaseURL(getter_AddRefs(baseURI));
nsCOMPtr imgURI;
NS_NewURI(getter_AddRefs(imgURI), myList->mListStyleImage, nsnull, baseURI);
@@ -1597,7 +1597,7 @@ nsBulletFrame::Reflow(nsIPresContext* aPresContext,
if (isStyleChange) {
nsCOMPtr baseURI;
- GetBaseURI(getter_AddRefs(baseURI));
+ mContent->GetBaseURL(getter_AddRefs(baseURI));
const nsStyleList* myList = GetStyleList();
@@ -1811,30 +1811,6 @@ NS_IMETHODIMP nsBulletFrame::FrameChanged(imgIContainer *aContainer,
return NS_OK;
}
-
-
-void
-nsBulletFrame::GetBaseURI(nsIURI **aURI)
-{
- NS_PRECONDITION(nsnull != aURI, "null OUT parameter pointer");
-
- nsresult rv;
- nsCOMPtr baseURI;
- nsCOMPtr htmlContent(do_QueryInterface(mContent, &rv));
- if (NS_SUCCEEDED(rv)) {
- htmlContent->GetBaseURL(getter_AddRefs(baseURI));
- }
- else {
- nsCOMPtr doc;
- mContent->GetDocument(getter_AddRefs(doc));
- if (doc) {
- doc->GetBaseURL(getter_AddRefs(baseURI));
- }
- }
- *aURI = baseURI;
- NS_IF_ADDREF(*aURI);
-}
-
void
nsBulletFrame::GetLoadGroup(nsIPresContext *aPresContext, nsILoadGroup **aLoadGroup)
{
diff --git a/mozilla/layout/generic/nsBulletFrame.h b/mozilla/layout/generic/nsBulletFrame.h
index 5347797db4f..cd3b44e073e 100644
--- a/mozilla/layout/generic/nsBulletFrame.h
+++ b/mozilla/layout/generic/nsBulletFrame.h
@@ -100,7 +100,6 @@ protected:
const nsStyleList& aStyleList,
nsString& aResult);
- void GetBaseURI(nsIURI **aURI);
void GetLoadGroup(nsIPresContext *aPresContext, nsILoadGroup **aLoadGroup);
PRInt32 mOrdinal;
diff --git a/mozilla/layout/generic/nsImageFrame.cpp b/mozilla/layout/generic/nsImageFrame.cpp
index 7517ed96c08..ee2b13df38f 100644
--- a/mozilla/layout/generic/nsImageFrame.cpp
+++ b/mozilla/layout/generic/nsImageFrame.cpp
@@ -1692,7 +1692,7 @@ nsImageFrame::HandleEvent(nsIPresContext* aPresContext,
if (!inside && isServerMap) {
nsCOMPtr baseURL;
- GetBaseURI(getter_AddRefs(baseURL));
+ mContent->GetBaseURL(getter_AddRefs(baseURL));
if (baseURL) {
// Server side image maps use the href in a containing anchor
@@ -1906,7 +1906,9 @@ nsImageFrame::SpecToURI(const nsAString& aSpec, nsIIOService *aIOService,
nsIURI **aURI)
{
nsCOMPtr baseURI;
- GetBaseURI(getter_AddRefs(baseURI));
+ if (mContent) {
+ mContent->GetBaseURL(getter_AddRefs(baseURI));
+ }
nsCAutoString charset;
GetDocumentCharacterSet(charset);
NS_NewURI(aURI, aSpec,
@@ -1914,30 +1916,6 @@ nsImageFrame::SpecToURI(const nsAString& aSpec, nsIIOService *aIOService,
baseURI, aIOService);
}
-void
-nsImageFrame::GetBaseURI(nsIURI **aURI)
-{
- NS_PRECONDITION(nsnull != aURI, "null OUT parameter pointer");
-
- nsresult rv;
- nsCOMPtr baseURI;
- nsCOMPtr htmlContent(do_QueryInterface(mContent, &rv));
- if (NS_SUCCEEDED(rv)) {
- htmlContent->GetBaseURL(getter_AddRefs(baseURI));
- }
- else {
- nsCOMPtr doc;
- if (mContent) {
- rv = mContent->GetDocument(getter_AddRefs(doc));
- if (doc) {
- doc->GetBaseURL(getter_AddRefs(baseURI));
- }
- }
- }
- *aURI = baseURI;
- NS_IF_ADDREF(*aURI);
-}
-
void
nsImageFrame::GetLoadGroup(nsIPresContext *aPresContext, nsILoadGroup **aLoadGroup)
{
diff --git a/mozilla/layout/generic/nsImageFrame.h b/mozilla/layout/generic/nsImageFrame.h
index 0113a1438ee..065f32a2c95 100644
--- a/mozilla/layout/generic/nsImageFrame.h
+++ b/mozilla/layout/generic/nsImageFrame.h
@@ -200,7 +200,6 @@ private:
inline void SpecToURI(const nsAString& aSpec, nsIIOService *aIOService,
nsIURI **aURI);
- inline void GetBaseURI(nsIURI **uri);
inline void GetLoadGroup(nsIPresContext *aPresContext,
nsILoadGroup **aLoadGroup);
nscoord GetContinuationOffset(nscoord* aWidth = 0) const;
diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp
index bcc779e27bd..4c3cc60ee8a 100644
--- a/mozilla/layout/generic/nsObjectFrame.cpp
+++ b/mozilla/layout/generic/nsObjectFrame.cpp
@@ -560,7 +560,7 @@ void nsObjectFrame::IsSupportedDocument(nsIContent* aContent, PRBool* aDoc)
nsCOMPtr uri;
nsCOMPtr baseURL;
- if (NS_FAILED(GetBaseURL(*getter_AddRefs(baseURL)))) return; // XXX NS_NewURI fails without base
+ aContent->GetBaseURL(getter_AddRefs(baseURL));
rv = NS_NewURI(getter_AddRefs(uri), data, nsnull, baseURL);
if (NS_FAILED(rv)) return;
@@ -1022,16 +1022,15 @@ nsObjectFrame::Reflow(nsIPresContext* aPresContext,
nsAutoString classid;
- if (NS_SUCCEEDED(rv = GetBaseURL(*getter_AddRefs(baseURL)))) {
- nsAutoString codeBase;
- if ((NS_CONTENT_ATTR_HAS_VALUE ==
- mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::codebase, codeBase)) &&
- !codeBase.IsEmpty()) {
- nsCOMPtr codeBaseURL;
- rv = MakeAbsoluteURL(getter_AddRefs(codeBaseURL), codeBase, baseURL);
- if (NS_SUCCEEDED(rv)) {
- baseURL = codeBaseURL;
- }
+ mContent->GetBaseURL(getter_AddRefs(baseURL));
+ nsAutoString codeBase;
+ if ((NS_CONTENT_ATTR_HAS_VALUE ==
+ mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::codebase, codeBase)) &&
+ !codeBase.IsEmpty()) {
+ nsCOMPtr codeBaseURL;
+ rv = MakeAbsoluteURL(getter_AddRefs(codeBaseURL), codeBase, baseURL);
+ if (NS_SUCCEEDED(rv)) {
+ baseURL = codeBaseURL;
}
}
@@ -1392,29 +1391,6 @@ nsObjectFrame::HandleChild(nsIPresContext* aPresContext,
return NS_OK;
}
-
-nsresult
-nsObjectFrame::GetBaseURL(nsIURI* &aURL)
-{
- nsIHTMLContent* htmlContent;
- if (NS_SUCCEEDED(mContent->QueryInterface(NS_GET_IID(nsIHTMLContent), (void**)&htmlContent)))
- {
- htmlContent->GetBaseURL(&aURL);
- NS_RELEASE(htmlContent);
- }
- else
- {
- nsCOMPtr doc;
- mContent->GetDocument(getter_AddRefs(doc));
- if (doc)
- doc->GetBaseURL(&aURL);
- else
- return NS_ERROR_FAILURE;
- }
- return NS_OK;
-}
-
-
PRBool
nsObjectFrame::IsHidden(PRBool aCheckVisibilityStyle) const
{
@@ -2289,6 +2265,8 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarge
nsCOMPtr doc;
rv = GetDocument(getter_AddRefs(doc));
if (NS_SUCCEEDED(rv) && doc) {
+ // XXX should this really be the document base URL? Or the
+ // content's base URL?
rv = doc->GetBaseURL(getter_AddRefs(baseURL)); // gets the document's url
} else {
mOwner->GetFullURL(*getter_AddRefs(baseURL)); // gets the plugin's content url
@@ -2846,13 +2824,11 @@ void nsObjectFrame::FixUpURLS(const nsString &name, nsString &value)
name.EqualsIgnoreCase("PLUGINSPAGE")) {
nsCOMPtr baseURL;
- GetBaseURL(*getter_AddRefs(baseURL));
- if (baseURL) {
- nsAutoString newURL;
- NS_MakeAbsoluteURI(newURL, value, baseURL);
- if (!newURL.IsEmpty())
- value = newURL;
- }
+ mContent->GetBaseURL(getter_AddRefs(baseURL));
+ nsAutoString newURL;
+ NS_MakeAbsoluteURI(newURL, value, baseURL);
+ if (!newURL.IsEmpty())
+ value = newURL;
}
}
diff --git a/mozilla/layout/generic/nsObjectFrame.h b/mozilla/layout/generic/nsObjectFrame.h
index 3e89c4b7bfe..5b94072c9b1 100644
--- a/mozilla/layout/generic/nsObjectFrame.h
+++ b/mozilla/layout/generic/nsObjectFrame.h
@@ -171,8 +171,6 @@ protected:
nsReflowStatus& aStatus,
nsIFrame* child);
- nsresult GetBaseURL(nsIURI* &aURL);
-
// check attributes and optionally CSS to see if we should display anything
PRBool IsHidden(PRBool aCheckVisibilityStyle = PR_TRUE) const;
diff --git a/mozilla/layout/html/base/src/nsBulletFrame.cpp b/mozilla/layout/html/base/src/nsBulletFrame.cpp
index 5078cf57457..f5d9ceb071c 100644
--- a/mozilla/layout/html/base/src/nsBulletFrame.cpp
+++ b/mozilla/layout/html/base/src/nsBulletFrame.cpp
@@ -135,7 +135,7 @@ nsBulletFrame::Init(nsIPresContext* aPresContext,
GetLoadGroup(aPresContext, getter_AddRefs(loadGroup));
nsCOMPtr baseURI;
- GetBaseURI(getter_AddRefs(baseURI));
+ mContent->GetBaseURL(getter_AddRefs(baseURI));
nsCOMPtr imgURI;
NS_NewURI(getter_AddRefs(imgURI), myList->mListStyleImage, nsnull, baseURI);
@@ -1597,7 +1597,7 @@ nsBulletFrame::Reflow(nsIPresContext* aPresContext,
if (isStyleChange) {
nsCOMPtr baseURI;
- GetBaseURI(getter_AddRefs(baseURI));
+ mContent->GetBaseURL(getter_AddRefs(baseURI));
const nsStyleList* myList = GetStyleList();
@@ -1811,30 +1811,6 @@ NS_IMETHODIMP nsBulletFrame::FrameChanged(imgIContainer *aContainer,
return NS_OK;
}
-
-
-void
-nsBulletFrame::GetBaseURI(nsIURI **aURI)
-{
- NS_PRECONDITION(nsnull != aURI, "null OUT parameter pointer");
-
- nsresult rv;
- nsCOMPtr baseURI;
- nsCOMPtr htmlContent(do_QueryInterface(mContent, &rv));
- if (NS_SUCCEEDED(rv)) {
- htmlContent->GetBaseURL(getter_AddRefs(baseURI));
- }
- else {
- nsCOMPtr doc;
- mContent->GetDocument(getter_AddRefs(doc));
- if (doc) {
- doc->GetBaseURL(getter_AddRefs(baseURI));
- }
- }
- *aURI = baseURI;
- NS_IF_ADDREF(*aURI);
-}
-
void
nsBulletFrame::GetLoadGroup(nsIPresContext *aPresContext, nsILoadGroup **aLoadGroup)
{
diff --git a/mozilla/layout/html/base/src/nsBulletFrame.h b/mozilla/layout/html/base/src/nsBulletFrame.h
index 5347797db4f..cd3b44e073e 100644
--- a/mozilla/layout/html/base/src/nsBulletFrame.h
+++ b/mozilla/layout/html/base/src/nsBulletFrame.h
@@ -100,7 +100,6 @@ protected:
const nsStyleList& aStyleList,
nsString& aResult);
- void GetBaseURI(nsIURI **aURI);
void GetLoadGroup(nsIPresContext *aPresContext, nsILoadGroup **aLoadGroup);
PRInt32 mOrdinal;
diff --git a/mozilla/layout/html/base/src/nsImageFrame.cpp b/mozilla/layout/html/base/src/nsImageFrame.cpp
index 7517ed96c08..ee2b13df38f 100644
--- a/mozilla/layout/html/base/src/nsImageFrame.cpp
+++ b/mozilla/layout/html/base/src/nsImageFrame.cpp
@@ -1692,7 +1692,7 @@ nsImageFrame::HandleEvent(nsIPresContext* aPresContext,
if (!inside && isServerMap) {
nsCOMPtr baseURL;
- GetBaseURI(getter_AddRefs(baseURL));
+ mContent->GetBaseURL(getter_AddRefs(baseURL));
if (baseURL) {
// Server side image maps use the href in a containing anchor
@@ -1906,7 +1906,9 @@ nsImageFrame::SpecToURI(const nsAString& aSpec, nsIIOService *aIOService,
nsIURI **aURI)
{
nsCOMPtr baseURI;
- GetBaseURI(getter_AddRefs(baseURI));
+ if (mContent) {
+ mContent->GetBaseURL(getter_AddRefs(baseURI));
+ }
nsCAutoString charset;
GetDocumentCharacterSet(charset);
NS_NewURI(aURI, aSpec,
@@ -1914,30 +1916,6 @@ nsImageFrame::SpecToURI(const nsAString& aSpec, nsIIOService *aIOService,
baseURI, aIOService);
}
-void
-nsImageFrame::GetBaseURI(nsIURI **aURI)
-{
- NS_PRECONDITION(nsnull != aURI, "null OUT parameter pointer");
-
- nsresult rv;
- nsCOMPtr baseURI;
- nsCOMPtr htmlContent(do_QueryInterface(mContent, &rv));
- if (NS_SUCCEEDED(rv)) {
- htmlContent->GetBaseURL(getter_AddRefs(baseURI));
- }
- else {
- nsCOMPtr doc;
- if (mContent) {
- rv = mContent->GetDocument(getter_AddRefs(doc));
- if (doc) {
- doc->GetBaseURL(getter_AddRefs(baseURI));
- }
- }
- }
- *aURI = baseURI;
- NS_IF_ADDREF(*aURI);
-}
-
void
nsImageFrame::GetLoadGroup(nsIPresContext *aPresContext, nsILoadGroup **aLoadGroup)
{
diff --git a/mozilla/layout/html/base/src/nsImageFrame.h b/mozilla/layout/html/base/src/nsImageFrame.h
index 0113a1438ee..065f32a2c95 100644
--- a/mozilla/layout/html/base/src/nsImageFrame.h
+++ b/mozilla/layout/html/base/src/nsImageFrame.h
@@ -200,7 +200,6 @@ private:
inline void SpecToURI(const nsAString& aSpec, nsIIOService *aIOService,
nsIURI **aURI);
- inline void GetBaseURI(nsIURI **uri);
inline void GetLoadGroup(nsIPresContext *aPresContext,
nsILoadGroup **aLoadGroup);
nscoord GetContinuationOffset(nscoord* aWidth = 0) const;
diff --git a/mozilla/layout/html/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp
index bcc779e27bd..4c3cc60ee8a 100644
--- a/mozilla/layout/html/base/src/nsObjectFrame.cpp
+++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp
@@ -560,7 +560,7 @@ void nsObjectFrame::IsSupportedDocument(nsIContent* aContent, PRBool* aDoc)
nsCOMPtr uri;
nsCOMPtr baseURL;
- if (NS_FAILED(GetBaseURL(*getter_AddRefs(baseURL)))) return; // XXX NS_NewURI fails without base
+ aContent->GetBaseURL(getter_AddRefs(baseURL));
rv = NS_NewURI(getter_AddRefs(uri), data, nsnull, baseURL);
if (NS_FAILED(rv)) return;
@@ -1022,16 +1022,15 @@ nsObjectFrame::Reflow(nsIPresContext* aPresContext,
nsAutoString classid;
- if (NS_SUCCEEDED(rv = GetBaseURL(*getter_AddRefs(baseURL)))) {
- nsAutoString codeBase;
- if ((NS_CONTENT_ATTR_HAS_VALUE ==
- mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::codebase, codeBase)) &&
- !codeBase.IsEmpty()) {
- nsCOMPtr codeBaseURL;
- rv = MakeAbsoluteURL(getter_AddRefs(codeBaseURL), codeBase, baseURL);
- if (NS_SUCCEEDED(rv)) {
- baseURL = codeBaseURL;
- }
+ mContent->GetBaseURL(getter_AddRefs(baseURL));
+ nsAutoString codeBase;
+ if ((NS_CONTENT_ATTR_HAS_VALUE ==
+ mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::codebase, codeBase)) &&
+ !codeBase.IsEmpty()) {
+ nsCOMPtr codeBaseURL;
+ rv = MakeAbsoluteURL(getter_AddRefs(codeBaseURL), codeBase, baseURL);
+ if (NS_SUCCEEDED(rv)) {
+ baseURL = codeBaseURL;
}
}
@@ -1392,29 +1391,6 @@ nsObjectFrame::HandleChild(nsIPresContext* aPresContext,
return NS_OK;
}
-
-nsresult
-nsObjectFrame::GetBaseURL(nsIURI* &aURL)
-{
- nsIHTMLContent* htmlContent;
- if (NS_SUCCEEDED(mContent->QueryInterface(NS_GET_IID(nsIHTMLContent), (void**)&htmlContent)))
- {
- htmlContent->GetBaseURL(&aURL);
- NS_RELEASE(htmlContent);
- }
- else
- {
- nsCOMPtr doc;
- mContent->GetDocument(getter_AddRefs(doc));
- if (doc)
- doc->GetBaseURL(&aURL);
- else
- return NS_ERROR_FAILURE;
- }
- return NS_OK;
-}
-
-
PRBool
nsObjectFrame::IsHidden(PRBool aCheckVisibilityStyle) const
{
@@ -2289,6 +2265,8 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarge
nsCOMPtr doc;
rv = GetDocument(getter_AddRefs(doc));
if (NS_SUCCEEDED(rv) && doc) {
+ // XXX should this really be the document base URL? Or the
+ // content's base URL?
rv = doc->GetBaseURL(getter_AddRefs(baseURL)); // gets the document's url
} else {
mOwner->GetFullURL(*getter_AddRefs(baseURL)); // gets the plugin's content url
@@ -2846,13 +2824,11 @@ void nsObjectFrame::FixUpURLS(const nsString &name, nsString &value)
name.EqualsIgnoreCase("PLUGINSPAGE")) {
nsCOMPtr baseURL;
- GetBaseURL(*getter_AddRefs(baseURL));
- if (baseURL) {
- nsAutoString newURL;
- NS_MakeAbsoluteURI(newURL, value, baseURL);
- if (!newURL.IsEmpty())
- value = newURL;
- }
+ mContent->GetBaseURL(getter_AddRefs(baseURL));
+ nsAutoString newURL;
+ NS_MakeAbsoluteURI(newURL, value, baseURL);
+ if (!newURL.IsEmpty())
+ value = newURL;
}
}
diff --git a/mozilla/layout/html/base/src/nsObjectFrame.h b/mozilla/layout/html/base/src/nsObjectFrame.h
index 3e89c4b7bfe..5b94072c9b1 100644
--- a/mozilla/layout/html/base/src/nsObjectFrame.h
+++ b/mozilla/layout/html/base/src/nsObjectFrame.h
@@ -171,8 +171,6 @@ protected:
nsReflowStatus& aStatus,
nsIFrame* child);
- nsresult GetBaseURL(nsIURI* &aURL);
-
// check attributes and optionally CSS to see if we should display anything
PRBool IsHidden(PRBool aCheckVisibilityStyle = PR_TRUE) const;
diff --git a/mozilla/layout/style/nsCSSLoader.cpp b/mozilla/layout/style/nsCSSLoader.cpp
index 20451f63202..c6268a4badc 100644
--- a/mozilla/layout/style/nsCSSLoader.cpp
+++ b/mozilla/layout/style/nsCSSLoader.cpp
@@ -956,6 +956,7 @@ CSSLoaderImpl::CheckLoadAllowed(nsIURI* aSourceURI,
*/
nsresult
CSSLoaderImpl::CreateSheet(nsIURI* aURI,
+ nsIContent* aLinkingContent,
PRUint32 aDefaultNameSpaceID,
PRBool aSyncLoad,
StyleSheetState& aSheetState,
@@ -1039,8 +1040,8 @@ CSSLoaderImpl::CreateSheet(nsIURI* aURI,
if (!sheetURI) {
// Inline style. Use the document's base URL so that @import in
// the inline sheet picks up the right base.
- NS_ASSERTION(mDocument, "How did we get in here without a document?");
- mDocument->GetBaseURL(getter_AddRefs(sheetURI));
+ NS_ASSERTION(aLinkingContent, "Inline stylesheet without linking content?");
+ aLinkingContent->GetBaseURL(getter_AddRefs(sheetURI));
}
rv = NS_NewCSSStyleSheet(aSheet, sheetURI);
@@ -1094,7 +1095,7 @@ CSSLoaderImpl::PrepareSheet(nsICSSStyleSheet* aSheet,
*/
nsresult
CSSLoaderImpl::InsertSheetInDoc(nsICSSStyleSheet* aSheet,
- nsIContent* aLinkingElement,
+ nsIContent* aLinkingContent,
nsIDocument* aDocument)
{
LOG(("CSSLoaderImpl::InsertSheetInDoc"));
@@ -1103,8 +1104,8 @@ CSSLoaderImpl::InsertSheetInDoc(nsICSSStyleSheet* aSheet,
// all nodes that link in sheets should be implementing nsIDOM3Node
nsresult rv = NS_OK;
- nsCOMPtr linkingNode = do_QueryInterface(aLinkingElement);
- NS_ASSERTION(linkingNode || !aLinkingElement,
+ nsCOMPtr linkingNode = do_QueryInterface(aLinkingContent);
+ NS_ASSERTION(linkingNode || !aLinkingContent,
"Need to implement nsIDOM3Node to get insertion order right");
// XXX Need to cancel pending sheet loads for this element, if any
@@ -1168,7 +1169,7 @@ CSSLoaderImpl::InsertSheetInDoc(nsICSSStyleSheet* aSheet,
// XXX elements do not implement nsIStyleSheetLinkingElement;
// need to fix this for them to be ordered correctly.
nsCOMPtr
- linkingElement = do_QueryInterface(aLinkingElement);
+ linkingElement = do_QueryInterface(aLinkingContent);
if (linkingElement) {
linkingElement->SetStyleSheet(aSheet); // This sets the ownerNode on the sheet
}
@@ -1589,8 +1590,8 @@ CSSLoaderImpl::LoadInlineStyle(nsIContent* aElement,
StyleSheetState state;
nsCOMPtr sheet;
- nsresult rv = CreateSheet(nsnull, aDefaultNameSpaceID, PR_FALSE, state,
- getter_AddRefs(sheet));
+ nsresult rv = CreateSheet(nsnull, aElement, aDefaultNameSpaceID, PR_FALSE,
+ state, getter_AddRefs(sheet));
NS_ENSURE_SUCCESS(rv, rv);
NS_ASSERTION(state == eSheetNeedsParser,
"Inline sheets should not be cached");
@@ -1651,7 +1652,7 @@ CSSLoaderImpl::LoadStyleLink(nsIContent* aElement,
StyleSheetState state;
nsCOMPtr sheet;
- rv = CreateSheet(aURL, aDefaultNameSpaceID, PR_FALSE, state,
+ rv = CreateSheet(aURL, aElement, aDefaultNameSpaceID, PR_FALSE, state,
getter_AddRefs(sheet));
NS_ENSURE_SUCCESS(rv, rv);
@@ -1761,7 +1762,7 @@ CSSLoaderImpl::LoadChildSheet(nsICSSStyleSheet* aParentSheet,
// loop) do so
nsCOMPtr sheet;
StyleSheetState state;
- rv = CreateSheet(aURL, aDefaultNameSpaceID,
+ rv = CreateSheet(aURL, nsnull, aDefaultNameSpaceID,
parentData ? parentData->mSyncLoad : PR_FALSE,
state, getter_AddRefs(sheet));
NS_ENSURE_SUCCESS(rv, rv);
@@ -1833,8 +1834,8 @@ CSSLoaderImpl::InternalLoadAgentSheet(nsIURI* aURL,
nsCOMPtr sheet;
PRBool syncLoad = (aObserver == nsnull);
- nsresult rv = CreateSheet(aURL, kNameSpaceID_Unknown, syncLoad, state,
- getter_AddRefs(sheet));
+ nsresult rv = CreateSheet(aURL, nsnull, kNameSpaceID_Unknown, syncLoad,
+ state, getter_AddRefs(sheet));
NS_ENSURE_SUCCESS(rv, rv);
NS_NAMED_LITERAL_STRING(empty, "");
diff --git a/mozilla/layout/style/nsCSSLoader.h b/mozilla/layout/style/nsCSSLoader.h
index e99e3f16b61..5b72b77a352 100644
--- a/mozilla/layout/style/nsCSSLoader.h
+++ b/mozilla/layout/style/nsCSSLoader.h
@@ -307,8 +307,11 @@ private:
nsresult CheckLoadAllowed(nsIURI* aSourceURI,
nsIURI* aTargetURI,
nsISupports* aContext);
-
+
+ // For inline style, the aURI param is null, but the aLinkingContent
+ // must be non-null then.
nsresult CreateSheet(nsIURI* aURI,
+ nsIContent* aLinkingContent,
PRUint32 aDefaultNameSpaceID,
PRBool aSyncLoad,
StyleSheetState& aSheetState,
@@ -319,7 +322,7 @@ private:
const nsAString& aMedia);
nsresult InsertSheetInDoc(nsICSSStyleSheet* aSheet,
- nsIContent* aLinkingElement,
+ nsIContent* aLinkingContent,
nsIDocument* aDocument);
nsresult InsertChildSheet(nsICSSStyleSheet* aSheet,
diff --git a/mozilla/layout/style/nsDOMCSSAttrDeclaration.cpp b/mozilla/layout/style/nsDOMCSSAttrDeclaration.cpp
index dd1e79d1b9d..e4130536955 100644
--- a/mozilla/layout/style/nsDOMCSSAttrDeclaration.cpp
+++ b/mozilla/layout/style/nsDOMCSSAttrDeclaration.cpp
@@ -168,15 +168,15 @@ nsDOMCSSAttributeDeclaration::GetCSSParsingEnvironment(nsIURI** aBaseURI,
if (NS_FAILED(result)) {
return result;
}
+
+ mContent->GetBaseURL(aBaseURI);
- if (doc) {
- doc->GetBaseURL(aBaseURI);
- nsCOMPtr htmlContainer(do_QueryInterface(doc));
- if (htmlContainer) {
- htmlContainer->GetCSSLoader(*aCSSLoader);
- }
- NS_ASSERTION(*aCSSLoader, "Document with no CSS loader!");
+ nsCOMPtr htmlContainer(do_QueryInterface(doc));
+ if (htmlContainer) {
+ htmlContainer->GetCSSLoader(*aCSSLoader);
}
+ NS_ASSERTION(!doc || *aCSSLoader, "Document with no CSS loader!");
+
if (*aCSSLoader) {
result = (*aCSSLoader)->GetParserFor(nsnull, aCSSParser);
} else {
diff --git a/mozilla/layout/style/nsStyleUtil.cpp b/mozilla/layout/style/nsStyleUtil.cpp
index 7def156cbfc..f59f2170320 100644
--- a/mozilla/layout/style/nsStyleUtil.cpp
+++ b/mozilla/layout/style/nsStyleUtil.cpp
@@ -647,22 +647,9 @@ PRBool nsStyleUtil::IsSimpleXlink(nsIContent *aContent, nsIPresContext *aPresCon
// is it bad to re-use val here?
aContent->GetAttr(kNameSpaceID_XLink, nsHTMLAtoms::href, val);
- // It's an XLink. Resolve it relative to its document.
+ // It's an XLink. Resolve it relative to aContent's base URI.
nsCOMPtr baseURI;
- nsCOMPtr htmlContent = do_QueryInterface(aContent);
- if (htmlContent) {
- // XXX why do this? will nsIHTMLContent's
- // GetBaseURL() may return something different
- // than the URL of the document it lives in?
- htmlContent->GetBaseURL(getter_AddRefs(baseURI));
- }
- else {
- nsCOMPtr doc;
- aContent->GetDocument(getter_AddRefs(doc));
- if (doc) {
- doc->GetBaseURL(getter_AddRefs(baseURI));
- }
- }
+ aContent->GetBaseURL(getter_AddRefs(baseURI));
nsCOMPtr absURI;
// XXX should we make sure to get the right charset off the document?
diff --git a/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp b/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp
index e9a7ddb7b8b..72e38fe8378 100644
--- a/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp
+++ b/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp
@@ -431,7 +431,9 @@ nsImageBoxFrame::UpdateImage(nsIPresContext* aPresContext, PRBool& aResize)
}
nsCOMPtr baseURI;
- GetBaseURI(getter_AddRefs(baseURI));
+ if (mContent) {
+ mContent->GetBaseURL(getter_AddRefs(baseURI));
+ }
nsCOMPtr srcURI;
nsresult rv = NS_NewURI(getter_AddRefs(srcURI), mSrc, nsnull, baseURI);
@@ -710,26 +712,6 @@ nsImageBoxFrame::GetFrameName(nsAString& aResult) const
#endif
-void
-nsImageBoxFrame::GetBaseURI(nsIURI **uri)
-{
- nsresult rv;
- nsCOMPtr baseURI;
- nsCOMPtr htmlContent(do_QueryInterface(mContent, &rv));
- if (NS_SUCCEEDED(rv)) {
- htmlContent->GetBaseURL(getter_AddRefs(baseURI));
- }
- else {
- nsCOMPtr doc;
- mContent->GetDocument(getter_AddRefs(doc));
- if (doc) {
- doc->GetBaseURL(getter_AddRefs(baseURI));
- }
- }
- *uri = baseURI;
- NS_IF_ADDREF(*uri);
-}
-
void
nsImageBoxFrame::GetLoadGroup(nsIPresContext *aPresContext, nsILoadGroup **aLoadGroup)
{
diff --git a/mozilla/layout/xul/base/src/nsImageBoxFrame.h b/mozilla/layout/xul/base/src/nsImageBoxFrame.h
index beca5a9b1ba..3c5edb50697 100644
--- a/mozilla/layout/xul/base/src/nsImageBoxFrame.h
+++ b/mozilla/layout/xul/base/src/nsImageBoxFrame.h
@@ -138,8 +138,6 @@ protected:
void GetImageSource();
- void GetBaseURI(nsIURI **uri);
-
void GetLoadGroup(nsIPresContext *aPresContext, nsILoadGroup **group);
virtual void GetImageSize(nsIPresContext* aPresContext);
diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
index 49e635d1366..534b2aa9ff4 100644
--- a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
+++ b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
@@ -1944,7 +1944,8 @@ nsTreeBodyFrame::GetImage(PRInt32 aRowIndex, const PRUnichar* aColID, PRBool aUs
if (!doc)
// The page is currently being torn down. Why bother.
return NS_ERROR_FAILURE;
- doc->GetBaseURL(getter_AddRefs(baseURI));
+
+ mContent->GetBaseURL(getter_AddRefs(baseURI));
nsCOMPtr srcURI;
NS_NewURI(getter_AddRefs(srcURI), *imagePtr, nsnull, baseURI);