зеркало из https://github.com/mozilla/gecko-dev.git
DOM properties that return URIs should return absolute URIs when they
are accessed (even if the corresponding attribute value is a relative URI). Bug 47534, r=caillon, sr=jst
This commit is contained in:
Родитель
01da75c2a8
Коммит
c0d3c15a88
|
@ -55,7 +55,8 @@ class nsINameSpaceManager;
|
|||
class nsIScriptSecurityManager;
|
||||
class nsIThreadJSContextStack;
|
||||
class nsIParserService;
|
||||
|
||||
class nsIIOService;
|
||||
class nsIURI;
|
||||
|
||||
class nsContentUtils
|
||||
{
|
||||
|
@ -241,13 +242,27 @@ public:
|
|||
|
||||
static nsINameSpaceManager* GetNSManagerWeakRef()
|
||||
{
|
||||
return sNameSpaceManager;
|
||||
return sNameSpaceManager;
|
||||
};
|
||||
|
||||
static nsIIOService* GetIOServiceWeakRef()
|
||||
{
|
||||
return sIOService;
|
||||
};
|
||||
|
||||
static nsresult GenerateStateKey(nsIContent* aContent,
|
||||
nsIStatefulFrame::SpecialStateID aID,
|
||||
nsACString& aKey);
|
||||
|
||||
/**
|
||||
* Create a new URI object from aSpec, using aBaseURI as the base.
|
||||
* The charset associated to the new nsIURI will be the document
|
||||
* charset of aDocument.
|
||||
*/
|
||||
static nsresult NewURIWithDocumentCharset(nsIURI** aResult,
|
||||
const nsAString& aSpec,
|
||||
nsIDocument* aDocument,
|
||||
nsIURI* aBaseURI);
|
||||
private:
|
||||
static nsresult GetDocumentAndPrincipal(nsIDOMNode* aNode,
|
||||
nsIDocument** aDocument,
|
||||
|
@ -271,6 +286,8 @@ private:
|
|||
static nsIParserService *sParserService;
|
||||
|
||||
static nsINameSpaceManager *sNameSpaceManager;
|
||||
|
||||
static nsIIOService *sIOService;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -55,7 +55,10 @@
|
|||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
|
@ -84,6 +87,7 @@ nsIScriptSecurityManager *nsContentUtils::sSecurityManager = nsnull;
|
|||
nsIThreadJSContextStack *nsContentUtils::sThreadJSContextStack = nsnull;
|
||||
nsIParserService *nsContentUtils::sParserService = nsnull;
|
||||
nsINameSpaceManager *nsContentUtils::sNameSpaceManager = nsnull;
|
||||
nsIIOService *nsContentUtils::sIOService = nsnull;
|
||||
|
||||
// static
|
||||
nsresult
|
||||
|
@ -101,6 +105,12 @@ nsContentUtils::Init()
|
|||
sSecurityManager = nsnull;
|
||||
}
|
||||
|
||||
rv = CallGetService(NS_IOSERVICE_CONTRACTID, &sIOService);
|
||||
if (NS_FAILED(rv)) {
|
||||
// If this fails, that's ok
|
||||
sIOService = nsnull;
|
||||
}
|
||||
|
||||
rv = CallGetService(kJSStackContractID, &sThreadJSContextStack);
|
||||
if (NS_FAILED(rv)) {
|
||||
sThreadJSContextStack = nsnull;
|
||||
|
@ -120,20 +130,13 @@ nsIParserService*
|
|||
nsContentUtils::GetParserServiceWeakRef()
|
||||
{
|
||||
// XXX: This isn't accessed from several threads, is it?
|
||||
if (sParserService == nsnull) {
|
||||
if (!sParserService) {
|
||||
// Lock, recheck sCachedParserService and aquire if this should be
|
||||
// safe for multiple threads.
|
||||
nsCOMPtr<nsIServiceManager> mgr;
|
||||
nsresult rv = NS_GetServiceManager(getter_AddRefs(mgr));
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return nsnull;
|
||||
|
||||
// This addrefs the service for us and it will be released in
|
||||
// |Shutdown|.
|
||||
mgr->GetService(kParserServiceCID,
|
||||
NS_GET_IID(nsIParserService),
|
||||
NS_REINTERPRET_CAST(void**, &sParserService));
|
||||
nsresult rv = CallGetService(kParserServiceCID, &sParserService);
|
||||
if (NS_FAILED(rv)) {
|
||||
sParserService = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
return sParserService;
|
||||
|
@ -390,6 +393,7 @@ nsContentUtils::Shutdown()
|
|||
NS_IF_RELEASE(sThreadJSContextStack);
|
||||
NS_IF_RELEASE(sNameSpaceManager);
|
||||
NS_IF_RELEASE(sParserService);
|
||||
NS_IF_RELEASE(sIOService);
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -1537,6 +1541,20 @@ nsContentUtils::GenerateStateKey(nsIContent* aContent,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */ nsresult
|
||||
nsContentUtils::NewURIWithDocumentCharset(nsIURI** aResult,
|
||||
const nsAString& aSpec,
|
||||
nsIDocument* aDocument,
|
||||
nsIURI* aBaseURI)
|
||||
{
|
||||
nsCAutoString originCharset;
|
||||
if (aDocument && NS_FAILED(aDocument->GetDocumentCharacterSet(originCharset)))
|
||||
originCharset.Truncate();
|
||||
|
||||
return NS_NewURI(aResult, NS_ConvertUCS2toUTF8(aSpec), originCharset.get(),
|
||||
aBaseURI, sIOService);
|
||||
}
|
||||
|
||||
void
|
||||
nsCxPusher::Push(nsISupports *aCurrentTarget)
|
||||
{
|
||||
|
|
|
@ -133,8 +133,6 @@
|
|||
#include "nsLayoutCID.h"
|
||||
#include "nsContentCID.h"
|
||||
|
||||
#include "nsHTMLUtils.h"
|
||||
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsITextContent.h"
|
||||
|
||||
|
@ -1613,8 +1611,10 @@ nsGenericHTMLElement::GetHrefURIForAnchors(nsIURI** aURI)
|
|||
GetBaseURL(getter_AddRefs(baseURL));
|
||||
|
||||
// Get absolute URL.
|
||||
nsresult rv = NS_NewURIWithDocumentCharset(aURI, relURLSpec, mDocument,
|
||||
baseURL);
|
||||
nsresult rv = nsContentUtils::NewURIWithDocumentCharset(aURI,
|
||||
relURLSpec,
|
||||
mDocument,
|
||||
baseURL);
|
||||
if (NS_FAILED(rv)) {
|
||||
*aURI = nsnull;
|
||||
}
|
||||
|
@ -3088,6 +3088,46 @@ nsGenericHTMLElement::ScrollingValueToString(const nsHTMLValue& aValue,
|
|||
return aValue.EnumValueToString(kScrollingTable, aResult);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLElement::AttrToURI(nsIAtom* aAttrName, nsAString& aAbsoluteURI)
|
||||
{
|
||||
nsAutoString attrValue;
|
||||
nsresult rv = GetAttr(kNameSpaceID_None, aAttrName, attrValue);
|
||||
if (rv == NS_CONTENT_ATTR_NOT_THERE) {
|
||||
aAbsoluteURI.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
GetBaseURL(getter_AddRefs(baseURI));
|
||||
|
||||
nsCOMPtr<nsIDocument> doc(mDocument);
|
||||
if (!doc) {
|
||||
mNodeInfo->GetDocument(getter_AddRefs(doc));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> attrURI;
|
||||
rv = nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(attrURI),
|
||||
attrValue, doc, baseURI);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
if (rv != NS_ERROR_MALFORMED_URI) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Just use the attr value as the result...
|
||||
aAbsoluteURI = attrValue;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_ASSERTION(attrURI, "nsContentUtils::NewURIWithDocumentCharset return value lied");
|
||||
|
||||
nsCAutoString spec;
|
||||
attrURI->GetSpec(spec);
|
||||
CopyUTF8toUTF16(spec, aAbsoluteURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLElement::ReparseStyleAttribute(void)
|
||||
{
|
||||
|
@ -4609,12 +4649,13 @@ nsGenericHTMLElement::GetProtocolFromHrefString(const nsAString& aHref,
|
|||
{
|
||||
aProtocol.Truncate();
|
||||
|
||||
NS_ENSURE_TRUE(nsHTMLUtils::IOService, NS_ERROR_FAILURE);
|
||||
nsIIOService* ioService = nsContentUtils::GetIOServiceWeakRef();
|
||||
NS_ENSURE_TRUE(ioService, NS_ERROR_FAILURE);
|
||||
|
||||
nsCAutoString protocol;
|
||||
|
||||
nsresult rv =
|
||||
nsHTMLUtils::IOService->ExtractScheme(NS_ConvertUCS2toUTF8(aHref), protocol);
|
||||
ioService->ExtractScheme(NS_ConvertUCS2toUTF8(aHref), protocol);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
aProtocol.Assign(NS_ConvertASCIItoUCS2(protocol) + NS_LITERAL_STRING(":"));
|
||||
|
|
|
@ -206,8 +206,6 @@ public:
|
|||
/**
|
||||
* Standard anchor HandleDOMEvent, used by A, AREA and LINK (parameters
|
||||
* are the same as HandleDOMEvent)
|
||||
*
|
||||
* Callers must hold a reference to nsHTMLUtils's global reference count.
|
||||
*/
|
||||
nsresult HandleDOMEventForAnchors(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
|
@ -456,6 +454,12 @@ public:
|
|||
static PRBool ScrollingValueToString(const nsHTMLValue& aValue,
|
||||
nsAString& aResult);
|
||||
|
||||
/**
|
||||
* Take an attribute name, and return the value of that attribute,
|
||||
* resolved to an absolute URI. Used by NS_IMPL_URI_ATTR macro.
|
||||
*/
|
||||
nsresult AttrToURI(nsIAtom* aAttrName, nsAString& aAbsoluteURI);
|
||||
|
||||
/**
|
||||
* Create the style struct from the style attr. Used when an element is first
|
||||
* put into a document. Only has an effect if the old value is a string.
|
||||
|
@ -1145,6 +1149,30 @@ protected:
|
|||
return SetHTMLAttribute(nsHTMLAtoms::_atom, value, PR_TRUE); \
|
||||
}
|
||||
|
||||
/**
|
||||
* A macro to implement the getter and setter for a given content
|
||||
* property that needs to return a URI in string form. The method
|
||||
* uses the generic GetAttr and SetAttr methods. This macro is much
|
||||
* like the NS_IMPL_STRING_ATTR macro, except we make sure the URI is
|
||||
* absolute.
|
||||
*/
|
||||
#define NS_IMPL_URI_ATTR_GETTER(_class, _method, _atom) \
|
||||
NS_IMETHODIMP \
|
||||
_class::Get##_method(nsAString& aValue) \
|
||||
{ \
|
||||
return AttrToURI(nsHTMLAtoms::_atom, aValue); \
|
||||
}
|
||||
#define NS_IMPL_URI_ATTR_SETTER(_class, _method, _atom) \
|
||||
NS_IMETHODIMP \
|
||||
_class::Set##_method(const nsAString& aValue) \
|
||||
{ \
|
||||
return SetAttr(kNameSpaceID_None, nsHTMLAtoms::_atom, aValue, \
|
||||
PR_TRUE); \
|
||||
}
|
||||
#define NS_IMPL_URI_ATTR(_class, _method, _atom) \
|
||||
NS_IMPL_URI_ATTR_GETTER(_class, _method, _atom) \
|
||||
NS_IMPL_URI_ATTR_SETTER(_class, _method, _atom)
|
||||
|
||||
/**
|
||||
* QueryInterface() implementation helper macros
|
||||
*/
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsHTMLUtils.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsIDOMHTMLAnchorElement.h"
|
||||
|
@ -164,12 +163,10 @@ NS_NewHTMLAnchorElement(nsIHTMLContent** aInstancePtrResult,
|
|||
|
||||
nsHTMLAnchorElement::nsHTMLAnchorElement() : mLinkState(eLinkState_Unknown)
|
||||
{
|
||||
nsHTMLUtils::AddRef(); // for GetHrefURI
|
||||
}
|
||||
|
||||
nsHTMLAnchorElement::~nsHTMLAnchorElement()
|
||||
{
|
||||
nsHTMLUtils::Release(); // for GetHrefURI
|
||||
}
|
||||
|
||||
|
||||
|
@ -218,6 +215,7 @@ nsHTMLAnchorElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
|||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Charset, charset)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Coords, coords)
|
||||
NS_IMPL_URI_ATTR(nsHTMLAnchorElement, Href, href)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Hreflang, hreflang)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Name, name)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Rel, rel)
|
||||
|
@ -354,29 +352,6 @@ nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
aFlags, aEventStatus);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAnchorElement::GetHref(nsAString& aValue)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = GetHrefURI(getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCAutoString spec;
|
||||
if (uri) {
|
||||
uri->GetSpec(spec);
|
||||
}
|
||||
CopyUTF8toUTF16(spec, aValue);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAnchorElement::SetHref(const nsAString& aValue)
|
||||
{
|
||||
return SetAttr(kNameSpaceID_None, nsHTMLAtoms::href, aValue, PR_TRUE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAnchorElement::GetTarget(nsAString& aValue)
|
||||
{
|
||||
|
|
|
@ -169,7 +169,7 @@ NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Align, align)
|
|||
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Alt, alt)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Archive, archive)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Code, code)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, CodeBase, codebase)
|
||||
NS_IMPL_URI_ATTR(nsHTMLAppletElement, CodeBase, codebase)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Height, height)
|
||||
NS_IMPL_PIXEL_ATTR(nsHTMLAppletElement, Hspace, hspace)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Name, name)
|
||||
|
|
|
@ -49,7 +49,6 @@
|
|||
#include "nsIEventStateManager.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsHTMLUtils.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
|
@ -140,12 +139,10 @@ NS_NewHTMLAreaElement(nsIHTMLContent** aInstancePtrResult,
|
|||
nsHTMLAreaElement::nsHTMLAreaElement()
|
||||
: mLinkState(eLinkState_Unknown)
|
||||
{
|
||||
nsHTMLUtils::AddRef(); // for GetHrefURI
|
||||
}
|
||||
|
||||
nsHTMLAreaElement::~nsHTMLAreaElement()
|
||||
{
|
||||
nsHTMLUtils::Release(); // for GetHrefURI
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsHTMLAreaElement, nsGenericElement)
|
||||
|
@ -194,6 +191,7 @@ nsHTMLAreaElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
|||
NS_IMPL_STRING_ATTR(nsHTMLAreaElement, AccessKey, accesskey)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAreaElement, Alt, alt)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAreaElement, Coords, coords)
|
||||
NS_IMPL_URI_ATTR(nsHTMLAreaElement, Href, href)
|
||||
NS_IMPL_BOOL_ATTR(nsHTMLAreaElement, NoHref, nohref)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAreaElement, Shape, shape)
|
||||
NS_IMPL_INT_ATTR(nsHTMLAreaElement, TabIndex, tabindex)
|
||||
|
@ -270,30 +268,6 @@ nsHTMLAreaElement::RemoveFocus(nsIPresContext* aPresContext)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAreaElement::GetHref(nsAString& aValue)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = GetHrefURI(getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (uri) {
|
||||
nsCAutoString spec;
|
||||
uri->GetSpec(spec);
|
||||
CopyUTF8toUTF16(spec, aValue);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAreaElement::SetHref(const nsAString& aValue)
|
||||
{
|
||||
// Clobber our "cache", so we'll recompute it the next time somebody
|
||||
// asks for it.
|
||||
mLinkState = eLinkState_Unknown;
|
||||
|
||||
return SetAttr(kNameSpaceID_None, nsHTMLAtoms::href, aValue, PR_TRUE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAreaElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers)
|
||||
|
@ -332,6 +306,10 @@ nsHTMLAreaElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
|||
RegUnRegAccessKey(PR_FALSE);
|
||||
}
|
||||
|
||||
if (aName == nsHTMLAtoms::href && aNameSpaceID == kNameSpaceID_None) {
|
||||
SetLinkState(eLinkState_Unknown);
|
||||
}
|
||||
|
||||
nsresult rv =
|
||||
nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aValue, aNotify);
|
||||
|
||||
|
|
|
@ -380,7 +380,7 @@ nsHTMLBodyElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
|||
}
|
||||
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLBodyElement, Background, background)
|
||||
NS_IMPL_URI_ATTR(nsHTMLBodyElement, Background, background)
|
||||
|
||||
#define NS_IMPL_HTMLBODY_COLOR_ATTR(attr_, func_, default_) \
|
||||
NS_IMETHODIMP \
|
||||
|
|
|
@ -170,13 +170,13 @@ nsHTMLFrameElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
|||
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLFrameElement, FrameBorder, frameborder)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLFrameElement, LongDesc, longdesc)
|
||||
NS_IMPL_URI_ATTR(nsHTMLFrameElement, LongDesc, longdesc)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLFrameElement, MarginHeight, marginheight)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLFrameElement, MarginWidth, marginwidth)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLFrameElement, Name, name)
|
||||
NS_IMPL_BOOL_ATTR(nsHTMLFrameElement, NoResize, noresize)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLFrameElement, Scrolling, scrolling)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLFrameElement, Src, src)
|
||||
NS_IMPL_URI_ATTR(nsHTMLFrameElement, Src, src)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -144,4 +144,4 @@ nsHTMLHeadElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
|||
}
|
||||
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLHeadElement, Profile, profile)
|
||||
NS_IMPL_URI_ATTR(nsHTMLHeadElement, Profile, profile)
|
||||
|
|
|
@ -113,6 +113,11 @@ public:
|
|||
|
||||
return rv;
|
||||
}
|
||||
NS_IMETHOD SetAttr(nsINodeInfo* aNodeInfo, const nsAString& aValue,
|
||||
PRBool aNotify) {
|
||||
// This will end up calling our other SetAttr method
|
||||
return nsGenericHTMLContainerElement::SetAttr(aNodeInfo, aValue, aNotify);
|
||||
}
|
||||
|
||||
NS_IMETHOD GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType,
|
||||
nsChangeHint& aHint) const;
|
||||
|
@ -211,29 +216,14 @@ nsHTMLIFrameElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
|||
NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Align, align)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, FrameBorder, frameborder)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Height, height)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, LongDesc, longdesc)
|
||||
NS_IMPL_URI_ATTR(nsHTMLIFrameElement, LongDesc, longdesc)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, MarginHeight, marginheight)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, MarginWidth, marginwidth)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Name, name)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Scrolling, scrolling)
|
||||
NS_IMPL_URI_ATTR(nsHTMLIFrameElement, Src, src)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Width, width)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLIFrameElement::GetSrc(nsAString& aSrc)
|
||||
{
|
||||
nsGenericHTMLContainerElement::GetAttr(kNameSpaceID_None, nsHTMLAtoms::src,
|
||||
aSrc);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLIFrameElement::SetSrc(const nsAString& aSrc)
|
||||
{
|
||||
SetAttribute(NS_LITERAL_STRING("src"), aSrc);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLIFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument)
|
||||
{
|
||||
|
|
|
@ -257,8 +257,9 @@ NS_IMPL_STRING_ATTR(nsHTMLImageElement, Alt, alt)
|
|||
NS_IMPL_STRING_ATTR(nsHTMLImageElement, Border, border)
|
||||
NS_IMPL_PIXEL_ATTR(nsHTMLImageElement, Hspace, hspace)
|
||||
NS_IMPL_BOOL_ATTR(nsHTMLImageElement, IsMap, ismap)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLImageElement, LongDesc, longdesc)
|
||||
NS_IMPL_URI_ATTR(nsHTMLImageElement, LongDesc, longdesc)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLImageElement, Lowsrc, lowsrc)
|
||||
NS_IMPL_URI_ATTR_GETTER(nsHTMLImageElement, Src, src)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLImageElement, UseMap, usemap)
|
||||
NS_IMPL_PIXEL_ATTR(nsHTMLImageElement, Vspace, vspace)
|
||||
|
||||
|
@ -663,34 +664,6 @@ nsHTMLImageElement::Initialize(JSContext* aContext, JSObject *aObj,
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLImageElement::GetSrc(nsAString& aSrc)
|
||||
{
|
||||
// Resolve url to an absolute url
|
||||
nsresult rv = NS_OK;
|
||||
nsAutoString relURLSpec;
|
||||
nsCOMPtr<nsIURI> baseURL;
|
||||
|
||||
// Get base URL.
|
||||
GetBaseURL(getter_AddRefs(baseURL));
|
||||
|
||||
// Get href= attribute (relative URL).
|
||||
nsGenericHTMLLeafElement::GetAttr(kNameSpaceID_None, nsHTMLAtoms::src,
|
||||
relURLSpec);
|
||||
relURLSpec.Trim(" \t\n\r");
|
||||
|
||||
if (baseURL && !relURLSpec.IsEmpty()) {
|
||||
// Get absolute URL.
|
||||
rv = NS_MakeAbsoluteURI(aSrc, relURLSpec, baseURL);
|
||||
}
|
||||
else {
|
||||
// Absolute URL is same as relative URL.
|
||||
aSrc = relURLSpec;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLImageElement::SetSrc(const nsAString& aSrc)
|
||||
{
|
||||
|
|
|
@ -50,7 +50,6 @@
|
|||
#include "nsStyleLinkElement.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsHTMLUtils.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIDocument.h"
|
||||
|
@ -141,6 +140,10 @@ public:
|
|||
|
||||
NS_IMETHOD SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
const nsAString& aValue, PRBool aNotify) {
|
||||
if (aName == nsHTMLAtoms::href && kNameSpaceID_None == aNameSpaceID) {
|
||||
SetLinkState(eLinkState_Unknown);
|
||||
}
|
||||
|
||||
nsresult rv = nsGenericHTMLLeafElement::SetAttr(aNameSpaceID, aName,
|
||||
aValue, aNotify);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
@ -226,12 +229,10 @@ NS_NewHTMLLinkElement(nsIHTMLContent** aInstancePtrResult,
|
|||
nsHTMLLinkElement::nsHTMLLinkElement()
|
||||
: mLinkState(eLinkState_Unknown)
|
||||
{
|
||||
nsHTMLUtils::AddRef(); // for GetHrefURI
|
||||
}
|
||||
|
||||
nsHTMLLinkElement::~nsHTMLLinkElement()
|
||||
{
|
||||
nsHTMLUtils::Release(); // for GetHrefURI
|
||||
}
|
||||
|
||||
|
||||
|
@ -309,6 +310,7 @@ nsHTMLLinkElement::SetDisabled(PRBool aDisabled)
|
|||
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLLinkElement, Charset, charset)
|
||||
NS_IMPL_URI_ATTR(nsHTMLLinkElement, Href, href)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLLinkElement, Hreflang, hreflang)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLLinkElement, Media, media)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLLinkElement, Rel, rel)
|
||||
|
@ -316,38 +318,6 @@ NS_IMPL_STRING_ATTR(nsHTMLLinkElement, Rev, rev)
|
|||
NS_IMPL_STRING_ATTR(nsHTMLLinkElement, Target, target)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLLinkElement, Type, type)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLLinkElement::GetHref(nsAString& aValue)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = GetHrefURI(getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (uri) {
|
||||
nsCAutoString spec;
|
||||
uri->GetSpec(spec);
|
||||
CopyUTF8toUTF16(spec, aValue);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLLinkElement::SetHref(const nsAString& aValue)
|
||||
{
|
||||
// Clobber our "cache", so we'll recompute it the next time
|
||||
// somebody asks for it.
|
||||
mLinkState = eLinkState_Unknown;
|
||||
|
||||
nsresult rv = nsGenericHTMLLeafElement::SetAttr(kNameSpaceID_None,
|
||||
nsHTMLAtoms::href, aValue,
|
||||
PR_TRUE);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
UpdateStyleSheet();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLLinkElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
|
|
|
@ -204,9 +204,9 @@ NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Code, code)
|
|||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Align, align)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Archive, archive)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Border, border)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, CodeBase, codebase)
|
||||
NS_IMPL_URI_ATTR(nsHTMLObjectElement, CodeBase, codebase)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, CodeType, codetype)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Data, data)
|
||||
NS_IMPL_URI_ATTR(nsHTMLObjectElement, Data, data)
|
||||
NS_IMPL_BOOL_ATTR(nsHTMLObjectElement, Declare, declare)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Height, height)
|
||||
NS_IMPL_PIXEL_ATTR(nsHTMLObjectElement, Hspace, hspace)
|
||||
|
|
|
@ -143,4 +143,4 @@ nsHTMLQuoteElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
|||
}
|
||||
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLQuoteElement, Cite, cite)
|
||||
NS_IMPL_URI_ATTR(nsHTMLQuoteElement, Cite, cite)
|
||||
|
|
|
@ -545,7 +545,7 @@ nsHTMLScriptElement::SetText(const nsAString& aValue)
|
|||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLScriptElement, Charset, charset)
|
||||
NS_IMPL_BOOL_ATTR(nsHTMLScriptElement, Defer, defer)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLScriptElement, Src, src)
|
||||
NS_IMPL_URI_ATTR(nsHTMLScriptElement, Src, src)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLScriptElement, Type, type)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLScriptElement, HtmlFor, _for)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLScriptElement, Event, _event)
|
||||
|
|
|
@ -196,7 +196,7 @@ nsHTMLSharedContainerElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
|||
}
|
||||
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLSharedContainerElement, Cite, cite)
|
||||
NS_IMPL_URI_ATTR(nsHTMLSharedContainerElement, Cite, cite)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLSharedContainerElement, DateTime, datetime)
|
||||
|
||||
// For nsIDOMHTMLDirectoryElement, nsIDOMHTMLMenuElement, and
|
||||
|
|
|
@ -227,7 +227,7 @@ nsHTMLSharedLeafElement::IsContentOfType(PRUint32 aFlags)
|
|||
}
|
||||
|
||||
// nsIDOMHTMLBaseElement
|
||||
NS_IMPL_STRING_ATTR(nsHTMLSharedLeafElement, Href, href)
|
||||
NS_IMPL_URI_ATTR(nsHTMLSharedLeafElement, Href, href)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLSharedLeafElement, Target, target)
|
||||
|
||||
// spacer element code
|
||||
|
|
|
@ -227,7 +227,7 @@ nsHTMLSharedLeafElement::IsContentOfType(PRUint32 aFlags)
|
|||
}
|
||||
|
||||
// nsIDOMHTMLBaseElement
|
||||
NS_IMPL_STRING_ATTR(nsHTMLSharedLeafElement, Href, href)
|
||||
NS_IMPL_URI_ATTR(nsHTMLSharedLeafElement, Href, href)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLSharedLeafElement, Target, target)
|
||||
|
||||
// spacer element code
|
||||
|
|
|
@ -204,9 +204,9 @@ NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Code, code)
|
|||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Align, align)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Archive, archive)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Border, border)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, CodeBase, codebase)
|
||||
NS_IMPL_URI_ATTR(nsHTMLObjectElement, CodeBase, codebase)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, CodeType, codetype)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Data, data)
|
||||
NS_IMPL_URI_ATTR(nsHTMLObjectElement, Data, data)
|
||||
NS_IMPL_BOOL_ATTR(nsHTMLObjectElement, Declare, declare)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Height, height)
|
||||
NS_IMPL_PIXEL_ATTR(nsHTMLObjectElement, Hspace, hspace)
|
||||
|
|
|
@ -49,7 +49,6 @@
|
|||
#include "nsStyleLinkElement.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsHTMLUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsParserUtils.h"
|
||||
|
||||
|
@ -204,12 +203,10 @@ NS_NewHTMLStyleElement(nsIHTMLContent** aInstancePtrResult,
|
|||
|
||||
nsHTMLStyleElement::nsHTMLStyleElement()
|
||||
{
|
||||
nsHTMLUtils::AddRef(); // for GetHrefURIForAnchors
|
||||
}
|
||||
|
||||
nsHTMLStyleElement::~nsHTMLStyleElement()
|
||||
{
|
||||
nsHTMLUtils::Release(); // for GetHrefURIForAnchors
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -46,7 +46,6 @@ nsCSSProps.h \
|
|||
nsHTMLAtomList.h \
|
||||
nsHTMLAtoms.h \
|
||||
nsHTMLValue.h \
|
||||
nsHTMLUtils.h \
|
||||
nsImageMapUtils.h \
|
||||
nsLayoutAtomList.h \
|
||||
nsLayoutAtoms.h \
|
||||
|
|
|
@ -49,7 +49,6 @@ CPPSRCS = \
|
|||
nsCSSKeywords.cpp \
|
||||
nsCSSProps.cpp \
|
||||
nsHTMLAtoms.cpp \
|
||||
nsHTMLUtils.cpp \
|
||||
nsHTMLValue.cpp \
|
||||
nsImageMapUtils.cpp \
|
||||
nsLayoutAtoms.cpp \
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#include "nsXMLElement.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsHTMLUtils.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
@ -99,12 +98,10 @@ NS_NewXMLElement(nsIContent** aInstancePtrResult, nsINodeInfo *aNodeInfo)
|
|||
|
||||
nsXMLElement::nsXMLElement() : mIsLink(PR_FALSE)
|
||||
{
|
||||
nsHTMLUtils::AddRef(); // for NS_NewURIWithDocumentCharset
|
||||
}
|
||||
|
||||
nsXMLElement::~nsXMLElement()
|
||||
{
|
||||
nsHTMLUtils::Release(); // for NS_NewURIWithDocumentCharset
|
||||
}
|
||||
|
||||
|
||||
|
@ -196,7 +193,8 @@ static nsresult CheckLoadURI(const nsString& aSpec, nsIURI *aBaseURI,
|
|||
*aAbsURI = nsnull;
|
||||
|
||||
nsresult rv;
|
||||
rv = NS_NewURIWithDocumentCharset(aAbsURI, aSpec, aDocument, aBaseURI);
|
||||
rv = nsContentUtils::NewURIWithDocumentCharset(aAbsURI, aSpec, aDocument,
|
||||
aBaseURI);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> securityManager =
|
||||
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
||||
|
@ -410,8 +408,10 @@ nsXMLElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
nsCOMPtr<nsIURI> baseURL;
|
||||
GetBaseURL(getter_AddRefs(baseURL));
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
ret = NS_NewURIWithDocumentCharset(getter_AddRefs(uri), href,
|
||||
mDocument, baseURL);
|
||||
ret = nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(uri),
|
||||
href,
|
||||
mDocument,
|
||||
baseURL);
|
||||
if (NS_SUCCEEDED(ret)) {
|
||||
ret = TriggerLink(aPresContext, verb, baseURL, uri, target,
|
||||
PR_TRUE);
|
||||
|
@ -470,8 +470,10 @@ nsXMLElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
GetBaseURL(getter_AddRefs(baseURL));
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
ret = NS_NewURIWithDocumentCharset(getter_AddRefs(uri), href,
|
||||
mDocument, baseURL);
|
||||
ret = nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(uri),
|
||||
href,
|
||||
mDocument,
|
||||
baseURL);
|
||||
if (NS_SUCCEEDED(ret)) {
|
||||
ret = TriggerLink(aPresContext, eLinkVerb_Replace, baseURL, uri,
|
||||
target, PR_FALSE);
|
||||
|
|
|
@ -103,7 +103,6 @@
|
|||
#include "npapi.h"
|
||||
#include "nsIPrintSettings.h"
|
||||
#include "nsGfxCIID.h"
|
||||
#include "nsHTMLUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsTransform2D.h"
|
||||
#include "nsIImageLoadingContent.h"
|
||||
|
@ -973,8 +972,7 @@ nsObjectFrame::MakeAbsoluteURL(nsIURI* *aFullURI,
|
|||
if (document && NS_FAILED(document->GetDocumentCharacterSet(originCharset)))
|
||||
originCharset.Truncate();
|
||||
|
||||
return NS_NewURI(aFullURI, aSrc, originCharset.get(),
|
||||
aBaseURI, nsHTMLUtils::IOService);
|
||||
return NS_NewURI(aFullURI, aSrc, originCharset.get(), aBaseURI);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -103,7 +103,6 @@
|
|||
#include "npapi.h"
|
||||
#include "nsIPrintSettings.h"
|
||||
#include "nsGfxCIID.h"
|
||||
#include "nsHTMLUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsTransform2D.h"
|
||||
#include "nsIImageLoadingContent.h"
|
||||
|
@ -973,8 +972,7 @@ nsObjectFrame::MakeAbsoluteURL(nsIURI* *aFullURI,
|
|||
if (document && NS_FAILED(document->GetDocumentCharacterSet(originCharset)))
|
||||
originCharset.Truncate();
|
||||
|
||||
return NS_NewURI(aFullURI, aSrc, originCharset.get(),
|
||||
aBaseURI, nsHTMLUtils::IOService);
|
||||
return NS_NewURI(aFullURI, aSrc, originCharset.get(), aBaseURI);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
Загрузка…
Ссылка в новой задаче