зеркало из https://github.com/mozilla/pjs.git
Bug 682299 - Move CORS attributes and enumerations to nsGenericHTMLElement. r=bz
This commit is contained in:
Родитель
5701277759
Коммит
77567290e2
|
@ -60,6 +60,7 @@
|
|||
#include "nsThreadUtils.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsAsyncDOMEvent.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsEventStates.h"
|
||||
|
@ -774,9 +775,9 @@ nsImageLoadingContent::LoadImage(nsIURI* aNewURI,
|
|||
|
||||
nsLoadFlags loadFlags = aLoadFlags;
|
||||
PRInt32 corsmode = GetCORSMode();
|
||||
if (corsmode == nsImageLoadingContent::CORS_ANONYMOUS) {
|
||||
if (corsmode == nsGenericHTMLElement::CORS_ANONYMOUS) {
|
||||
loadFlags |= imgILoader::LOAD_CORS_ANONYMOUS;
|
||||
} else if (corsmode == nsImageLoadingContent::CORS_USE_CREDENTIALS) {
|
||||
} else if (corsmode == nsGenericHTMLElement::CORS_USE_CREDENTIALS) {
|
||||
loadFlags |= imgILoader::LOAD_CORS_USE_CREDENTIALS;
|
||||
}
|
||||
|
||||
|
@ -1186,8 +1187,8 @@ nsImageLoadingContent::CreateStaticImageClone(nsImageLoadingContent* aDest) cons
|
|||
aDest->mSuppressed = mSuppressed;
|
||||
}
|
||||
|
||||
nsImageLoadingContent::CORSMode
|
||||
nsGenericHTMLElement::CORSMode
|
||||
nsImageLoadingContent::GetCORSMode()
|
||||
{
|
||||
return CORS_NONE;
|
||||
return nsGenericHTMLElement::CORS_NONE;
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "nsContentUtils.h" // NS_CONTENT_DELETE_LIST_MEMBER
|
||||
#include "nsString.h"
|
||||
#include "nsEventStates.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
|
||||
class nsIURI;
|
||||
class nsIDocument;
|
||||
|
@ -70,25 +71,6 @@ public:
|
|||
NS_DECL_IMGIDECODEROBSERVER
|
||||
NS_DECL_NSIIMAGELOADINGCONTENT
|
||||
|
||||
enum CORSMode {
|
||||
/**
|
||||
* The default of not using CORS to validate cross-origin loads.
|
||||
*/
|
||||
CORS_NONE,
|
||||
|
||||
/**
|
||||
* Validate cross-site loads using CORS, but do not send any credentials
|
||||
* (cookies, HTTP auth logins, etc) along with the request.
|
||||
*/
|
||||
CORS_ANONYMOUS,
|
||||
|
||||
/**
|
||||
* Validate cross-site loads using CORS, and send credentials such as cookies
|
||||
* and HTTP auth logins along with the request.
|
||||
*/
|
||||
CORS_USE_CREDENTIALS
|
||||
};
|
||||
|
||||
protected:
|
||||
/**
|
||||
* LoadImage is called by subclasses when the appropriate
|
||||
|
@ -199,9 +181,9 @@ protected:
|
|||
|
||||
/**
|
||||
* Returns the CORS mode that will be used for all future image loads. The
|
||||
* default implementation returns CORS_NONE unconditionally.
|
||||
* default implementation returns nsGenericHTMLElement::CORS_NONE unconditionally.
|
||||
*/
|
||||
virtual CORSMode GetCORSMode();
|
||||
virtual nsGenericHTMLElement::CORSMode GetCORSMode();
|
||||
|
||||
private:
|
||||
/**
|
||||
|
|
|
@ -2884,6 +2884,14 @@ nsGenericHTMLFormElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
|
|||
return nsGenericHTMLElement::PreHandleEvent(aVisitor);
|
||||
}
|
||||
|
||||
const nsAttrValue::EnumTable nsGenericHTMLElement::kCORSAttributeTable[] = {
|
||||
// Order matters here
|
||||
// See ParseAttribute in nsHTMLImageElement or nsHTMLMediaElement
|
||||
{ "anonymous", nsGenericHTMLElement::CORS_ANONYMOUS },
|
||||
{ "use-credentials", nsGenericHTMLElement::CORS_USE_CREDENTIALS },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
/* virtual */
|
||||
bool
|
||||
nsGenericHTMLFormElement::IsDisabled() const
|
||||
|
|
|
@ -542,6 +542,32 @@ public:
|
|||
return HasAttr(kNameSpaceID_None, nsGkAtoms::hidden);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shared cross-origin resource sharing attributes so they don't get
|
||||
* duplicated on every CORS-enabled element
|
||||
*/
|
||||
|
||||
enum CORSMode {
|
||||
/**
|
||||
* The default of not using CORS to validate cross-origin loads.
|
||||
*/
|
||||
CORS_NONE,
|
||||
|
||||
/**
|
||||
* Validate cross-site loads using CORS, but do not send any credentials
|
||||
* (cookies, HTTP auth logins, etc) along with the request.
|
||||
*/
|
||||
CORS_ANONYMOUS,
|
||||
|
||||
/**
|
||||
* Validate cross-site loads using CORS, and send credentials such as cookies
|
||||
* and HTTP auth logins along with the request.
|
||||
*/
|
||||
CORS_USE_CREDENTIALS
|
||||
};
|
||||
|
||||
const static nsAttrValue::EnumTable kCORSAttributeTable[];
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Add/remove this element to the documents name cache
|
||||
|
|
|
@ -126,7 +126,7 @@ public:
|
|||
NS_DECL_NSIDOMHTMLIMAGEELEMENT
|
||||
|
||||
// override from nsImageLoadingContent
|
||||
nsImageLoadingContent::CORSMode GetCORSMode();
|
||||
nsGenericHTMLElement::CORSMode GetCORSMode();
|
||||
|
||||
// nsIJSNativeInitializer
|
||||
NS_IMETHOD Initialize(nsISupports* aOwner, JSContext* aContext,
|
||||
|
@ -245,13 +245,6 @@ NS_IMPL_URI_ATTR(nsHTMLImageElement, Src, src)
|
|||
NS_IMPL_STRING_ATTR(nsHTMLImageElement, UseMap, usemap)
|
||||
NS_IMPL_INT_ATTR(nsHTMLImageElement, Vspace, vspace)
|
||||
|
||||
static const nsAttrValue::EnumTable kCrossOriginTable[] = {
|
||||
// Order matters here; see ParseAttribute
|
||||
{ "anonymous", nsImageLoadingContent::CORS_ANONYMOUS },
|
||||
{ "use-credentials", nsImageLoadingContent::CORS_USE_CREDENTIALS },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
// crossorigin is not "limited to only known values" per spec, so it's
|
||||
// just a string attr purposes of the DOM crossOrigin property.
|
||||
NS_IMPL_STRING_ATTR(nsHTMLImageElement, CrossOrigin, crossorigin)
|
||||
|
@ -370,10 +363,10 @@ nsHTMLImageElement::ParseAttribute(PRInt32 aNamespaceID,
|
|||
return ParseAlignValue(aValue, aResult);
|
||||
}
|
||||
if (aAttribute == nsGkAtoms::crossorigin) {
|
||||
return aResult.ParseEnumValue(aValue, kCrossOriginTable, false,
|
||||
return aResult.ParseEnumValue(aValue, nsGenericHTMLElement::kCORSAttributeTable, false,
|
||||
// default value is anonymous if aValue is
|
||||
// not a value we understand
|
||||
&kCrossOriginTable[0]);
|
||||
&nsGenericHTMLElement::kCORSAttributeTable[0]);
|
||||
}
|
||||
if (ParseImageAttribute(aAttribute, aValue, aResult)) {
|
||||
return true;
|
||||
|
@ -669,16 +662,16 @@ nsHTMLImageElement::CopyInnerTo(nsGenericElement* aDest) const
|
|||
return nsGenericHTMLElement::CopyInnerTo(aDest);
|
||||
}
|
||||
|
||||
nsImageLoadingContent::CORSMode
|
||||
nsGenericHTMLElement::CORSMode
|
||||
nsHTMLImageElement::GetCORSMode()
|
||||
{
|
||||
nsImageLoadingContent::CORSMode ret = nsImageLoadingContent::CORS_NONE;
|
||||
nsGenericHTMLElement::CORSMode ret = nsGenericHTMLElement::CORS_NONE;
|
||||
|
||||
const nsAttrValue* value = GetParsedAttr(nsGkAtoms::crossorigin);
|
||||
if (value) {
|
||||
NS_ASSERTION(value->Type() == nsAttrValue::eEnum,
|
||||
"Why is this not an enum value?");
|
||||
ret = nsImageLoadingContent::CORSMode(value->GetEnumValue());
|
||||
ret = nsGenericHTMLElement::CORSMode(value->GetEnumValue());
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -106,6 +106,7 @@ LOCAL_INCLUDES = \
|
|||
-I$(srcdir)/../../../xul/base/src \
|
||||
-I$(srcdir)/../../../../content/svg/content/src \
|
||||
-I$(srcdir)/../../../../content/base/src \
|
||||
-I$(srcdir)/../../../../content/html/content/src \
|
||||
$(NULL)
|
||||
|
||||
libs::
|
||||
|
|
Загрузка…
Ссылка в новой задаче