Merge cedar into mozilla-central

This commit is contained in:
Ehsan Akhgari 2011-03-29 10:39:07 -04:00
commit 692c3a0600
61 changed files with 1073 additions and 2247 deletions

View File

@ -81,8 +81,7 @@
<stringbundle id="bundlePreferences" src="chrome://browser/locale/preferences/preferences.properties"/>
<!-- addons, forgery (phishing) UI -->
<groupbox id="addonsPhishingGroup"
xmlns:aaa="http://www.w3.org/2005/07/aaa">
<groupbox id="addonsPhishingGroup">
<hbox id="addonInstallBox">
<checkbox id="warnAddonInstall" flex="1"
label="&warnAddonInstall.label;"

View File

@ -48,6 +48,9 @@ var gTabsPane = {
* 1 opens such links in the most recent window or tab,
* 2 opens such links in a new window,
* 3 opens such links in a new tab
* browser.tabs.autoHide
* - true if the tab bar is hidden when only one tab is open, false to always
* show it
* browser.tabs.loadInBackground
* - true if display should switch to a new tab which has been opened from a
* link, false if display shouldn't switch

View File

@ -57,6 +57,7 @@
<preferences id="tabsPreferences">
<preference id="browser.link.open_newwindow" name="browser.link.open_newwindow" type="int"/>
<preference id="browser.tabs.autoHide" name="browser.tabs.autoHide" type="bool" inverted="true"/>
<preference id="browser.tabs.loadInBackground" name="browser.tabs.loadInBackground" type="bool" inverted="true"/>
<preference id="browser.tabs.warnOnClose" name="browser.tabs.warnOnClose" type="bool"/>
<preference id="browser.tabs.warnOnOpen" name="browser.tabs.warnOnOpen" type="bool"/>
@ -81,6 +82,9 @@
<checkbox id="warnOpenMany" label="&warnOpenManyTabs.label;"
accesskey="&warnOpenManyTabs.accesskey;"
preference="browser.tabs.warnOnOpen"/>
<checkbox id="showTabBar" label="&showTabBar.label;"
accesskey="&showTabBar.accesskey;"
preference="browser.tabs.autoHide"/>
<checkbox id="switchToNewTabs" label="&switchToNewTabs.label;"
accesskey="&switchToNewTabs.accesskey;"
preference="browser.tabs.loadInBackground"/>

View File

@ -7,6 +7,9 @@
<!ENTITY warnOpenManyTabs.label "Warn me when opening multiple tabs might slow down &brandShortName;">
<!ENTITY warnOpenManyTabs.accesskey "o">
<!ENTITY showTabBar.label "Always show the tab bar">
<!ENTITY showTabBar.accesskey "b">
<!ENTITY switchToNewTabs.label "When I open a link in a new tab, switch to it immediately">
<!ENTITY switchToNewTabs.accesskey "s">

View File

@ -109,7 +109,7 @@ interface nsIXMLHttpRequestUpload : nsIXMLHttpRequestEventTarget {
* you're aware of all the security implications. And then think twice about
* it.
*/
[scriptable, uuid(6bb91106-85f0-4d93-8cb4-e57b3d0624f2)]
[scriptable, uuid(af62a870-820c-4981-96a3-28ab17b779e1)]
interface nsIXMLHttpRequest : nsISupports
{
/**
@ -187,42 +187,19 @@ interface nsIXMLHttpRequest : nsISupports
*/
ACString getResponseHeader(in AUTF8String header);
/**
* Native (non-script) method to initialize a request. Note that
* the request is not sent until the <code>send</code> method
* is invoked.
*
* If there is an "active" request (that is, if open() or openRequest() has
* been called already), this is equivalent to calling abort().
*
* @param method The HTTP method, for example "POST" or "GET". Ignored
* if the URL is not a HTTP(S) URL.
* @param url The URL to which to send the request.
* @param async Whether the request is synchronous or asynchronous
* i.e. whether send returns only after the response
* is received or if it returns immediately after
* sending the request. In the latter case, notification
* of completion is sent through the event listeners.
* This argument must be true if the multipart
* attribute has been set to true, or an exception will
* be thrown.
* @param user A username for authentication if necessary.
* @param password A password for authentication if necessary.
*/
[noscript] void openRequest(in AUTF8String method,
in AUTF8String url,
in boolean async,
in AString user,
in AString password);
%{C++
// note this is NOT virtual so this won't muck with the vtable!
inline nsresult Open(const nsACString& method, const nsACString& url,
PRBool async, const nsAString& user,
const nsAString& password) {
return Open(method, url, async, user, password, 3);
}
%}
/**
* Meant to be a script-only method for initializing a request.
* The parameters are similar to the ones detailed in the
* description of <code>openRequest</code>, but the last
* 3 are optional.
*
* If there is an "active" request (that is, if open() or openRequest() has
* been called already), this is equivalent to calling abort().
* If there is an "active" request (that is, if open() has been called
* already), this is equivalent to calling abort() and then open().
*
* @param method The HTTP method - either "POST" or "GET". Ignored
* if the URL is not a HTTP URL.

View File

@ -448,6 +448,14 @@ nsContentList::nsContentList(nsINode* aRootNode,
{
NS_ASSERTION(mRootNode, "Must have root");
mRootNode->AddMutationObserver(this);
// We only need to flush if we're in an non-HTML document, since the
// HTML5 parser doesn't need flushing. Further, if we're not in a
// document at all right now (in the GetCurrentDoc() sense), we're
// not parser-created and don't need to be flushing stuff under us
// to get our kids right.
nsIDocument* doc = mRootNode->GetCurrentDoc();
mFlushesNeeded = doc && !doc->IsHTML();
}
nsContentList::~nsContentList()

View File

@ -54,52 +54,337 @@
#include "nsIChannelEventSink.h"
#include "nsIAsyncVerifyRedirectCallback.h"
#include "nsCharSeparatedTokenizer.h"
#include "nsXMLHttpRequest.h"
#include "nsAsyncRedirectVerifyHelper.h"
#include "prclist.h"
#include "prtime.h"
#include "nsClassHashtable.h"
#include "nsHashKeys.h"
#define PREFLIGHT_CACHE_SIZE 100
static PRBool gDisableCORS = PR_FALSE;
static PRBool gDisableCORSPrivateData = PR_FALSE;
class nsChannelCanceller
//////////////////////////////////////////////////////////////////////////
// Preflight cache
class nsPreflightCache
{
public:
nsChannelCanceller(nsIChannel* aChannel)
: mChannel(aChannel)
struct TokenTime
{
nsCString token;
PRTime expirationTime;
};
struct CacheEntry : public PRCList
{
CacheEntry(nsCString& aKey)
: mKey(aKey)
{
MOZ_COUNT_CTOR(nsPreflightCache::CacheEntry);
}
~CacheEntry()
{
MOZ_COUNT_DTOR(nsPreflightCache::CacheEntry);
}
void PurgeExpired(PRTime now);
PRBool CheckRequest(const nsCString& aMethod,
const nsTArray<nsCString>& aCustomHeaders);
nsCString mKey;
nsTArray<TokenTime> mMethods;
nsTArray<TokenTime> mHeaders;
};
nsPreflightCache()
{
MOZ_COUNT_CTOR(nsPreflightCache);
PR_INIT_CLIST(&mList);
}
~nsChannelCanceller()
~nsPreflightCache()
{
if (mChannel) {
mChannel->Cancel(NS_ERROR_DOM_BAD_URI);
Clear();
MOZ_COUNT_DTOR(nsPreflightCache);
}
PRBool Initialize()
{
return mTable.Init();
}
CacheEntry* GetEntry(nsIURI* aURI, nsIPrincipal* aPrincipal,
PRBool aWithCredentials, PRBool aCreate);
void RemoveEntries(nsIURI* aURI, nsIPrincipal* aPrincipal);
void Clear();
private:
static PLDHashOperator
RemoveExpiredEntries(const nsACString& aKey, nsAutoPtr<CacheEntry>& aValue,
void* aUserData);
static PRBool GetCacheKey(nsIURI* aURI, nsIPrincipal* aPrincipal,
PRBool aWithCredentials, nsACString& _retval);
nsClassHashtable<nsCStringHashKey, CacheEntry> mTable;
PRCList mList;
};
// Will be initialized in EnsurePreflightCache.
static nsPreflightCache* sPreflightCache = nsnull;
static PRBool EnsurePreflightCache()
{
if (sPreflightCache)
return PR_TRUE;
nsAutoPtr<nsPreflightCache> newCache(new nsPreflightCache());
if (newCache->Initialize()) {
sPreflightCache = newCache.forget();
return PR_TRUE;
}
return PR_FALSE;
}
void
nsPreflightCache::CacheEntry::PurgeExpired(PRTime now)
{
PRUint32 i;
for (i = 0; i < mMethods.Length(); ++i) {
if (now >= mMethods[i].expirationTime) {
mMethods.RemoveElementAt(i--);
}
}
for (i = 0; i < mHeaders.Length(); ++i) {
if (now >= mHeaders[i].expirationTime) {
mHeaders.RemoveElementAt(i--);
}
}
}
PRBool
nsPreflightCache::CacheEntry::CheckRequest(const nsCString& aMethod,
const nsTArray<nsCString>& aHeaders)
{
PurgeExpired(PR_Now());
if (!aMethod.EqualsLiteral("GET") && !aMethod.EqualsLiteral("POST")) {
PRUint32 i;
for (i = 0; i < mMethods.Length(); ++i) {
if (aMethod.Equals(mMethods[i].token))
break;
}
if (i == mMethods.Length()) {
return PR_FALSE;
}
}
void DontCancel()
{
mChannel = nsnull;
for (PRUint32 i = 0; i < aHeaders.Length(); ++i) {
PRUint32 j;
for (j = 0; j < mHeaders.Length(); ++j) {
if (aHeaders[i].Equals(mHeaders[j].token,
nsCaseInsensitiveCStringComparator())) {
break;
}
}
if (j == mHeaders.Length()) {
return PR_FALSE;
}
}
private:
nsIChannel* mChannel;
};
return PR_TRUE;
}
NS_IMPL_ISUPPORTS5(nsCrossSiteListenerProxy, nsIStreamListener,
nsPreflightCache::CacheEntry*
nsPreflightCache::GetEntry(nsIURI* aURI,
nsIPrincipal* aPrincipal,
PRBool aWithCredentials,
PRBool aCreate)
{
nsCString key;
if (!GetCacheKey(aURI, aPrincipal, aWithCredentials, key)) {
NS_WARNING("Invalid cache key!");
return nsnull;
}
CacheEntry* entry;
if (mTable.Get(key, &entry)) {
// Entry already existed so just return it. Also update the LRU list.
// Move to the head of the list.
PR_REMOVE_LINK(entry);
PR_INSERT_LINK(entry, &mList);
return entry;
}
if (!aCreate) {
return nsnull;
}
// This is a new entry, allocate and insert into the table now so that any
// failures don't cause items to be removed from a full cache.
entry = new CacheEntry(key);
if (!entry) {
NS_WARNING("Failed to allocate new cache entry!");
return nsnull;
}
NS_ASSERTION(mTable.Count() <= PREFLIGHT_CACHE_SIZE,
"Something is borked, too many entries in the cache!");
// Now enforce the max count.
if (mTable.Count() == PREFLIGHT_CACHE_SIZE) {
// Try to kick out all the expired entries.
PRTime now = PR_Now();
mTable.Enumerate(RemoveExpiredEntries, &now);
// If that didn't remove anything then kick out the least recently used
// entry.
if (mTable.Count() == PREFLIGHT_CACHE_SIZE) {
CacheEntry* lruEntry = static_cast<CacheEntry*>(PR_LIST_TAIL(&mList));
PR_REMOVE_LINK(lruEntry);
// This will delete 'lruEntry'.
mTable.Remove(lruEntry->mKey);
NS_ASSERTION(mTable.Count() == PREFLIGHT_CACHE_SIZE - 1,
"Somehow tried to remove an entry that was never added!");
}
}
if (!mTable.Put(key, entry)) {
// Failed, clean up the new entry.
delete entry;
NS_WARNING("Failed to add entry to the CORS preflight cache!");
return nsnull;
}
PR_INSERT_LINK(entry, &mList);
return entry;
}
void
nsPreflightCache::RemoveEntries(nsIURI* aURI, nsIPrincipal* aPrincipal)
{
CacheEntry* entry;
nsCString key;
if (GetCacheKey(aURI, aPrincipal, PR_TRUE, key) &&
mTable.Get(key, &entry)) {
PR_REMOVE_LINK(entry);
mTable.Remove(key);
}
if (GetCacheKey(aURI, aPrincipal, PR_FALSE, key) &&
mTable.Get(key, &entry)) {
PR_REMOVE_LINK(entry);
mTable.Remove(key);
}
}
void
nsPreflightCache::Clear()
{
PR_INIT_CLIST(&mList);
mTable.Clear();
}
/* static */ PLDHashOperator
nsPreflightCache::RemoveExpiredEntries(const nsACString& aKey,
nsAutoPtr<CacheEntry>& aValue,
void* aUserData)
{
PRTime* now = static_cast<PRTime*>(aUserData);
aValue->PurgeExpired(*now);
if (aValue->mHeaders.IsEmpty() &&
aValue->mMethods.IsEmpty()) {
// Expired, remove from the list as well as the hash table.
PR_REMOVE_LINK(aValue);
return PL_DHASH_REMOVE;
}
return PL_DHASH_NEXT;
}
/* static */ PRBool
nsPreflightCache::GetCacheKey(nsIURI* aURI,
nsIPrincipal* aPrincipal,
PRBool aWithCredentials,
nsACString& _retval)
{
NS_ASSERTION(aURI, "Null uri!");
NS_ASSERTION(aPrincipal, "Null principal!");
NS_NAMED_LITERAL_CSTRING(space, " ");
nsCOMPtr<nsIURI> uri;
nsresult rv = aPrincipal->GetURI(getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, PR_FALSE);
nsCAutoString scheme, host, port;
if (uri) {
uri->GetScheme(scheme);
uri->GetHost(host);
port.AppendInt(NS_GetRealPort(uri));
}
nsCAutoString cred;
if (aWithCredentials) {
_retval.AssignLiteral("cred");
}
else {
_retval.AssignLiteral("nocred");
}
nsCAutoString spec;
rv = aURI->GetSpec(spec);
NS_ENSURE_SUCCESS(rv, PR_FALSE);
_retval.Assign(cred + space + scheme + space + host + space + port + space +
spec);
return PR_TRUE;
}
//////////////////////////////////////////////////////////////////////////
// nsCORSListenerProxy
NS_IMPL_ISUPPORTS5(nsCORSListenerProxy, nsIStreamListener,
nsIRequestObserver, nsIChannelEventSink,
nsIInterfaceRequestor, nsIAsyncVerifyRedirectCallback)
/* static */
void
nsCrossSiteListenerProxy::Startup()
nsCORSListenerProxy::Startup()
{
nsContentUtils::AddBoolPrefVarCache("content.cors.disable", &gDisableCORS);
nsContentUtils::AddBoolPrefVarCache("content.cors.no_private_data", &gDisableCORSPrivateData);
}
nsCrossSiteListenerProxy::nsCrossSiteListenerProxy(nsIStreamListener* aOuter,
nsIPrincipal* aRequestingPrincipal,
nsIChannel* aChannel,
PRBool aWithCredentials,
nsresult* aResult)
/* static */
void
nsCORSListenerProxy::Shutdown()
{
delete sPreflightCache;
sPreflightCache = nsnull;
}
nsCORSListenerProxy::nsCORSListenerProxy(nsIStreamListener* aOuter,
nsIPrincipal* aRequestingPrincipal,
nsIChannel* aChannel,
PRBool aWithCredentials,
nsresult* aResult)
: mOuterListener(aOuter),
mRequestingPrincipal(aRequestingPrincipal),
mWithCredentials(aWithCredentials && !gDisableCORSPrivateData),
@ -118,14 +403,13 @@ nsCrossSiteListenerProxy::nsCrossSiteListenerProxy(nsIStreamListener* aOuter,
}
}
nsCrossSiteListenerProxy::nsCrossSiteListenerProxy(nsIStreamListener* aOuter,
nsIPrincipal* aRequestingPrincipal,
nsIChannel* aChannel,
PRBool aWithCredentials,
const nsCString& aPreflightMethod,
const nsTArray<nsCString>& aPreflightHeaders,
nsresult* aResult)
nsCORSListenerProxy::nsCORSListenerProxy(nsIStreamListener* aOuter,
nsIPrincipal* aRequestingPrincipal,
nsIChannel* aChannel,
PRBool aWithCredentials,
const nsCString& aPreflightMethod,
const nsTArray<nsCString>& aPreflightHeaders,
nsresult* aResult)
: mOuterListener(aOuter),
mRequestingPrincipal(aRequestingPrincipal),
mWithCredentials(aWithCredentials && !gDisableCORSPrivateData),
@ -152,19 +436,18 @@ nsCrossSiteListenerProxy::nsCrossSiteListenerProxy(nsIStreamListener* aOuter,
}
NS_IMETHODIMP
nsCrossSiteListenerProxy::OnStartRequest(nsIRequest* aRequest,
nsISupports* aContext)
nsCORSListenerProxy::OnStartRequest(nsIRequest* aRequest,
nsISupports* aContext)
{
mRequestApproved = NS_SUCCEEDED(CheckRequestApproved(aRequest));
if (!mRequestApproved) {
if (nsXMLHttpRequest::sAccessControlCache) {
if (sPreflightCache) {
nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
if (channel) {
nsCOMPtr<nsIURI> uri;
nsCOMPtr<nsIURI> uri;
NS_GetFinalChannelURI(channel, getter_AddRefs(uri));
if (uri) {
nsXMLHttpRequest::sAccessControlCache->
RemoveEntries(uri, mRequestingPrincipal);
sPreflightCache->RemoveEntries(uri, mRequestingPrincipal);
}
}
}
@ -219,7 +502,7 @@ IsValidHTTPToken(const nsCSubstring& aToken)
}
nsresult
nsCrossSiteListenerProxy::CheckRequestApproved(nsIRequest* aRequest)
nsCORSListenerProxy::CheckRequestApproved(nsIRequest* aRequest)
{
// Check if this was actually a cross domain request
if (!mHasBeenCrossSite) {
@ -326,19 +609,19 @@ nsCrossSiteListenerProxy::CheckRequestApproved(nsIRequest* aRequest)
}
NS_IMETHODIMP
nsCrossSiteListenerProxy::OnStopRequest(nsIRequest* aRequest,
nsISupports* aContext,
nsresult aStatusCode)
nsCORSListenerProxy::OnStopRequest(nsIRequest* aRequest,
nsISupports* aContext,
nsresult aStatusCode)
{
return mOuterListener->OnStopRequest(aRequest, aContext, aStatusCode);
}
NS_IMETHODIMP
nsCrossSiteListenerProxy::OnDataAvailable(nsIRequest* aRequest,
nsISupports* aContext,
nsIInputStream* aInputStream,
PRUint32 aOffset,
PRUint32 aCount)
nsCORSListenerProxy::OnDataAvailable(nsIRequest* aRequest,
nsISupports* aContext,
nsIInputStream* aInputStream,
PRUint32 aOffset,
PRUint32 aCount)
{
if (!mRequestApproved) {
return NS_ERROR_DOM_BAD_URI;
@ -348,7 +631,7 @@ nsCrossSiteListenerProxy::OnDataAvailable(nsIRequest* aRequest,
}
NS_IMETHODIMP
nsCrossSiteListenerProxy::GetInterface(const nsIID & aIID, void **aResult)
nsCORSListenerProxy::GetInterface(const nsIID & aIID, void **aResult)
{
if (aIID.Equals(NS_GET_IID(nsIChannelEventSink))) {
*aResult = static_cast<nsIChannelEventSink*>(this);
@ -363,21 +646,20 @@ nsCrossSiteListenerProxy::GetInterface(const nsIID & aIID, void **aResult)
}
NS_IMETHODIMP
nsCrossSiteListenerProxy::AsyncOnChannelRedirect(nsIChannel *aOldChannel,
nsIChannel *aNewChannel,
PRUint32 aFlags,
nsIAsyncVerifyRedirectCallback *cb)
nsCORSListenerProxy::AsyncOnChannelRedirect(nsIChannel *aOldChannel,
nsIChannel *aNewChannel,
PRUint32 aFlags,
nsIAsyncVerifyRedirectCallback *cb)
{
nsresult rv;
if (!NS_IsInternalSameURIRedirect(aOldChannel, aNewChannel, aFlags)) {
rv = CheckRequestApproved(aOldChannel);
if (NS_FAILED(rv)) {
if (nsXMLHttpRequest::sAccessControlCache) {
if (sPreflightCache) {
nsCOMPtr<nsIURI> oldURI;
NS_GetFinalChannelURI(aOldChannel, getter_AddRefs(oldURI));
if (oldURI) {
nsXMLHttpRequest::sAccessControlCache->
RemoveEntries(oldURI, mRequestingPrincipal);
sPreflightCache->RemoveEntries(oldURI, mRequestingPrincipal);
}
}
aOldChannel->Cancel(NS_ERROR_DOM_BAD_URI);
@ -408,7 +690,7 @@ nsCrossSiteListenerProxy::AsyncOnChannelRedirect(nsIChannel *aOldChannel,
}
NS_IMETHODIMP
nsCrossSiteListenerProxy::OnRedirectVerifyCallback(nsresult result)
nsCORSListenerProxy::OnRedirectVerifyCallback(nsresult result)
{
NS_ASSERTION(mRedirectCallback, "mRedirectCallback not set in callback");
NS_ASSERTION(mOldRedirectChannel, "mOldRedirectChannel not set in callback");
@ -417,7 +699,7 @@ nsCrossSiteListenerProxy::OnRedirectVerifyCallback(nsresult result)
if (NS_SUCCEEDED(result)) {
nsresult rv = UpdateChannel(mNewRedirectChannel);
if (NS_FAILED(rv)) {
NS_WARNING("nsCrossSiteListenerProxy::OnRedirectVerifyCallback: "
NS_WARNING("nsCORSListenerProxy::OnRedirectVerifyCallback: "
"UpdateChannel() returned failure");
}
result = rv;
@ -435,7 +717,7 @@ nsCrossSiteListenerProxy::OnRedirectVerifyCallback(nsresult result)
}
nsresult
nsCrossSiteListenerProxy::UpdateChannel(nsIChannel* aChannel)
nsCORSListenerProxy::UpdateChannel(nsIChannel* aChannel)
{
nsCOMPtr<nsIURI> uri, originalURI;
nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri));
@ -517,3 +799,304 @@ nsCrossSiteListenerProxy::UpdateChannel(nsIChannel* aChannel)
return NS_OK;
}
//////////////////////////////////////////////////////////////////////////
// Preflight proxy
// Class used as streamlistener and notification callback when
// doing the initial OPTIONS request for a CORS check
class nsCORSPreflightListener : public nsIStreamListener,
public nsIInterfaceRequestor,
public nsIChannelEventSink
{
public:
nsCORSPreflightListener(nsIChannel* aOuterChannel,
nsIStreamListener* aOuterListener,
nsISupports* aOuterContext,
nsIPrincipal* aReferrerPrincipal,
const nsACString& aRequestMethod,
PRBool aWithCredentials)
: mOuterChannel(aOuterChannel), mOuterListener(aOuterListener),
mOuterContext(aOuterContext), mReferrerPrincipal(aReferrerPrincipal),
mRequestMethod(aRequestMethod), mWithCredentials(aWithCredentials)
{ }
NS_DECL_ISUPPORTS
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSICHANNELEVENTSINK
private:
void AddResultToCache(nsIRequest* aRequest);
nsCOMPtr<nsIChannel> mOuterChannel;
nsCOMPtr<nsIStreamListener> mOuterListener;
nsCOMPtr<nsISupports> mOuterContext;
nsCOMPtr<nsIPrincipal> mReferrerPrincipal;
nsCString mRequestMethod;
PRBool mWithCredentials;
};
NS_IMPL_ISUPPORTS4(nsCORSPreflightListener, nsIStreamListener,
nsIRequestObserver, nsIInterfaceRequestor,
nsIChannelEventSink)
void
nsCORSPreflightListener::AddResultToCache(nsIRequest *aRequest)
{
nsCOMPtr<nsIHttpChannel> http = do_QueryInterface(aRequest);
NS_ASSERTION(http, "Request was not http");
// The "Access-Control-Max-Age" header should return an age in seconds.
nsCAutoString headerVal;
http->GetResponseHeader(NS_LITERAL_CSTRING("Access-Control-Max-Age"),
headerVal);
if (headerVal.IsEmpty()) {
return;
}
// Sanitize the string. We only allow 'delta-seconds' as specified by
// http://dev.w3.org/2006/waf/access-control (digits 0-9 with no leading or
// trailing non-whitespace characters).
PRUint32 age = 0;
nsCSubstring::const_char_iterator iter, end;
headerVal.BeginReading(iter);
headerVal.EndReading(end);
while (iter != end) {
if (*iter < '0' || *iter > '9') {
return;
}
age = age * 10 + (*iter - '0');
// Cap at 24 hours. This also avoids overflow
age = NS_MIN(age, 86400U);
++iter;
}
if (!age || !EnsurePreflightCache()) {
return;
}
// String seems fine, go ahead and cache.
// Note that we have already checked that these headers follow the correct
// syntax.
nsCOMPtr<nsIURI> uri;
NS_GetFinalChannelURI(http, getter_AddRefs(uri));
// PR_Now gives microseconds
PRTime expirationTime = PR_Now() + (PRUint64)age * PR_USEC_PER_SEC;
nsPreflightCache::CacheEntry* entry =
sPreflightCache->GetEntry(uri, mReferrerPrincipal, mWithCredentials,
PR_TRUE);
if (!entry) {
return;
}
// The "Access-Control-Allow-Methods" header contains a comma separated
// list of method names.
http->GetResponseHeader(NS_LITERAL_CSTRING("Access-Control-Allow-Methods"),
headerVal);
nsCCharSeparatedTokenizer methods(headerVal, ',');
while(methods.hasMoreTokens()) {
const nsDependentCSubstring& method = methods.nextToken();
if (method.IsEmpty()) {
continue;
}
PRUint32 i;
for (i = 0; i < entry->mMethods.Length(); ++i) {
if (entry->mMethods[i].token.Equals(method)) {
entry->mMethods[i].expirationTime = expirationTime;
break;
}
}
if (i == entry->mMethods.Length()) {
nsPreflightCache::TokenTime* newMethod =
entry->mMethods.AppendElement();
if (!newMethod) {
return;
}
newMethod->token = method;
newMethod->expirationTime = expirationTime;
}
}
// The "Access-Control-Allow-Headers" header contains a comma separated
// list of method names.
http->GetResponseHeader(NS_LITERAL_CSTRING("Access-Control-Allow-Headers"),
headerVal);
nsCCharSeparatedTokenizer headers(headerVal, ',');
while(headers.hasMoreTokens()) {
const nsDependentCSubstring& header = headers.nextToken();
if (header.IsEmpty()) {
continue;
}
PRUint32 i;
for (i = 0; i < entry->mHeaders.Length(); ++i) {
if (entry->mHeaders[i].token.Equals(header)) {
entry->mHeaders[i].expirationTime = expirationTime;
break;
}
}
if (i == entry->mHeaders.Length()) {
nsPreflightCache::TokenTime* newHeader =
entry->mHeaders.AppendElement();
if (!newHeader) {
return;
}
newHeader->token = header;
newHeader->expirationTime = expirationTime;
}
}
}
NS_IMETHODIMP
nsCORSPreflightListener::OnStartRequest(nsIRequest *aRequest,
nsISupports *aContext)
{
nsresult status;
nsresult rv = aRequest->GetStatus(&status);
if (NS_SUCCEEDED(rv)) {
rv = status;
}
if (NS_SUCCEEDED(rv)) {
// Everything worked, try to cache and then fire off the actual request.
AddResultToCache(aRequest);
rv = mOuterChannel->AsyncOpen(mOuterListener, mOuterContext);
}
if (NS_FAILED(rv)) {
mOuterChannel->Cancel(rv);
mOuterListener->OnStartRequest(mOuterChannel, mOuterContext);
mOuterListener->OnStopRequest(mOuterChannel, mOuterContext, rv);
return rv;
}
return NS_OK;
}
NS_IMETHODIMP
nsCORSPreflightListener::OnStopRequest(nsIRequest *aRequest,
nsISupports *aContext,
nsresult aStatus)
{
return NS_OK;
}
/** nsIStreamListener methods **/
NS_IMETHODIMP
nsCORSPreflightListener::OnDataAvailable(nsIRequest *aRequest,
nsISupports *ctxt,
nsIInputStream *inStr,
PRUint32 sourceOffset,
PRUint32 count)
{
return NS_OK;
}
NS_IMETHODIMP
nsCORSPreflightListener::AsyncOnChannelRedirect(nsIChannel *aOldChannel,
nsIChannel *aNewChannel,
PRUint32 aFlags,
nsIAsyncVerifyRedirectCallback *callback)
{
// Only internal redirects allowed for now.
if (!NS_IsInternalSameURIRedirect(aOldChannel, aNewChannel, aFlags))
return NS_ERROR_DOM_BAD_URI;
callback->OnRedirectVerifyCallback(NS_OK);
return NS_OK;
}
NS_IMETHODIMP
nsCORSPreflightListener::GetInterface(const nsIID & aIID, void **aResult)
{
return QueryInterface(aIID, aResult);
}
nsresult
NS_StartCORSPreflight(nsIChannel* aRequestChannel,
nsIStreamListener* aListener,
nsIPrincipal* aPrincipal,
PRBool aWithCredentials,
nsTArray<nsCString>& aUnsafeHeaders,
nsIChannel** aPreflightChannel)
{
*aPreflightChannel = nsnull;
nsCAutoString method;
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aRequestChannel));
NS_ENSURE_TRUE(httpChannel, NS_ERROR_UNEXPECTED);
httpChannel->GetRequestMethod(method);
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_GetFinalChannelURI(aRequestChannel, getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, rv);
nsPreflightCache::CacheEntry* entry =
sPreflightCache ?
sPreflightCache->GetEntry(uri, aPrincipal, aWithCredentials, PR_FALSE) :
nsnull;
if (entry && entry->CheckRequest(method, aUnsafeHeaders)) {
// We have a cached preflight result, just start the original channel
return aRequestChannel->AsyncOpen(aListener, nsnull);
}
// Either it wasn't cached or the cached result has expired. Build a
// channel for the OPTIONS request.
nsCOMPtr<nsILoadGroup> loadGroup;
rv = aRequestChannel->GetLoadGroup(getter_AddRefs(loadGroup));
NS_ENSURE_SUCCESS(rv, rv);
nsLoadFlags loadFlags;
rv = aRequestChannel->GetLoadFlags(&loadFlags);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIChannel> preflightChannel;
rv = NS_NewChannel(getter_AddRefs(preflightChannel), uri, nsnull,
loadGroup, nsnull, loadFlags);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIHttpChannel> preHttp = do_QueryInterface(preflightChannel);
NS_ASSERTION(preHttp, "Failed to QI to nsIHttpChannel!");
rv = preHttp->SetRequestMethod(NS_LITERAL_CSTRING("OPTIONS"));
NS_ENSURE_SUCCESS(rv, rv);
// Set up listener which will start the original channel
nsCOMPtr<nsIStreamListener> preflightListener =
new nsCORSPreflightListener(aRequestChannel, aListener, nsnull, aPrincipal,
method, aWithCredentials);
NS_ENSURE_TRUE(preflightListener, NS_ERROR_OUT_OF_MEMORY);
preflightListener =
new nsCORSListenerProxy(preflightListener, aPrincipal,
preflightChannel, aWithCredentials,
method, aUnsafeHeaders, &rv);
NS_ENSURE_TRUE(preflightListener, NS_ERROR_OUT_OF_MEMORY);
NS_ENSURE_SUCCESS(rv, rv);
// Start preflight
rv = preflightChannel->AsyncOpen(preflightListener, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
// Return newly created preflight channel
preflightChannel.forget(aPreflightChannel);
return NS_OK;
}

View File

@ -35,8 +35,8 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsCrossSiteListenerProxy_h__
#define nsCrossSiteListenerProxy_h__
#ifndef nsCORSListenerProxy_h__
#define nsCORSListenerProxy_h__
#include "nsIStreamListener.h"
#include "nsIInterfaceRequestor.h"
@ -55,24 +55,32 @@ class nsIPrincipal;
extern PRBool
IsValidHTTPToken(const nsCSubstring& aToken);
class nsCrossSiteListenerProxy : public nsIStreamListener,
public nsIInterfaceRequestor,
public nsIChannelEventSink,
public nsIAsyncVerifyRedirectCallback
nsresult
NS_StartCORSPreflight(nsIChannel* aRequestChannel,
nsIStreamListener* aListener,
nsIPrincipal* aPrincipal,
PRBool aWithCredentials,
nsTArray<nsCString>& aACUnsafeHeaders,
nsIChannel** aPreflightChannel);
class nsCORSListenerProxy : public nsIStreamListener,
public nsIInterfaceRequestor,
public nsIChannelEventSink,
public nsIAsyncVerifyRedirectCallback
{
public:
nsCrossSiteListenerProxy(nsIStreamListener* aOuter,
nsIPrincipal* aRequestingPrincipal,
nsIChannel* aChannel,
PRBool aWithCredentials,
nsresult* aResult);
nsCrossSiteListenerProxy(nsIStreamListener* aOuter,
nsIPrincipal* aRequestingPrincipal,
nsIChannel* aChannel,
PRBool aWithCredentials,
const nsCString& aPreflightMethod,
const nsTArray<nsCString>& aPreflightHeaders,
nsresult* aResult);
nsCORSListenerProxy(nsIStreamListener* aOuter,
nsIPrincipal* aRequestingPrincipal,
nsIChannel* aChannel,
PRBool aWithCredentials,
nsresult* aResult);
nsCORSListenerProxy(nsIStreamListener* aOuter,
nsIPrincipal* aRequestingPrincipal,
nsIChannel* aChannel,
PRBool aWithCredentials,
const nsCString& aPreflightMethod,
const nsTArray<nsCString>& aPreflightHeaders,
nsresult* aResult);
NS_DECL_ISUPPORTS
NS_DECL_NSIREQUESTOBSERVER
@ -84,6 +92,8 @@ public:
// Must be called at startup.
static void Startup();
static void Shutdown();
private:
nsresult UpdateChannel(nsIChannel* aChannel);
nsresult CheckRequestApproved(nsIRequest* aRequest);

View File

@ -220,8 +220,8 @@ nsSyncLoader::LoadDocument(nsIChannel* aChannel,
}
if (aLoaderPrincipal) {
listener = new nsCrossSiteListenerProxy(listener, aLoaderPrincipal,
mChannel, PR_FALSE, &rv);
listener = new nsCORSListenerProxy(listener, aLoaderPrincipal,
mChannel, PR_FALSE, &rv);
NS_ENSURE_TRUE(listener, NS_ERROR_OUT_OF_MEMORY);
NS_ENSURE_SUCCESS(rv, rv);
}

View File

@ -145,8 +145,6 @@
XML_HTTP_REQUEST_SENT | \
XML_HTTP_REQUEST_STOPPED)
#define ACCESS_CONTROL_CACHE_SIZE 100
#define NS_BADCERTHANDLER_CONTRACTID \
"@mozilla.org/content/xmlhttprequest-bad-cert-handler;1"
@ -285,225 +283,6 @@ nsMultipartProxyListener::OnDataAvailable(nsIRequest *aRequest,
count);
}
// Class used as streamlistener and notification callback when
// doing the initial GET request for an access-control check
class nsACProxyListener : public nsIStreamListener,
public nsIInterfaceRequestor,
public nsIChannelEventSink
{
public:
nsACProxyListener(nsIChannel* aOuterChannel,
nsIStreamListener* aOuterListener,
nsISupports* aOuterContext,
nsIPrincipal* aReferrerPrincipal,
const nsACString& aRequestMethod,
PRBool aWithCredentials)
: mOuterChannel(aOuterChannel), mOuterListener(aOuterListener),
mOuterContext(aOuterContext), mReferrerPrincipal(aReferrerPrincipal),
mRequestMethod(aRequestMethod), mWithCredentials(aWithCredentials)
{ }
NS_DECL_ISUPPORTS
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSICHANNELEVENTSINK
private:
void AddResultToCache(nsIRequest* aRequest);
nsCOMPtr<nsIChannel> mOuterChannel;
nsCOMPtr<nsIStreamListener> mOuterListener;
nsCOMPtr<nsISupports> mOuterContext;
nsCOMPtr<nsIPrincipal> mReferrerPrincipal;
nsCString mRequestMethod;
PRBool mWithCredentials;
};
NS_IMPL_ISUPPORTS4(nsACProxyListener, nsIStreamListener, nsIRequestObserver,
nsIInterfaceRequestor, nsIChannelEventSink)
void
nsACProxyListener::AddResultToCache(nsIRequest *aRequest)
{
nsCOMPtr<nsIHttpChannel> http = do_QueryInterface(aRequest);
NS_ASSERTION(http, "Request was not http");
// The "Access-Control-Max-Age" header should return an age in seconds.
nsCAutoString headerVal;
http->GetResponseHeader(NS_LITERAL_CSTRING("Access-Control-Max-Age"),
headerVal);
if (headerVal.IsEmpty()) {
return;
}
// Sanitize the string. We only allow 'delta-seconds' as specified by
// http://dev.w3.org/2006/waf/access-control (digits 0-9 with no leading or
// trailing non-whitespace characters).
PRUint32 age = 0;
nsCSubstring::const_char_iterator iter, end;
headerVal.BeginReading(iter);
headerVal.EndReading(end);
while (iter != end) {
if (*iter < '0' || *iter > '9') {
return;
}
age = age * 10 + (*iter - '0');
// Cap at 24 hours. This also avoids overflow
age = NS_MIN(age, 86400U);
++iter;
}
if (!age || !nsXMLHttpRequest::EnsureACCache()) {
return;
}
// String seems fine, go ahead and cache.
// Note that we have already checked that these headers follow the correct
// syntax.
nsCOMPtr<nsIURI> uri;
NS_GetFinalChannelURI(http, getter_AddRefs(uri));
// PR_Now gives microseconds
PRTime expirationTime = PR_Now() + (PRUint64)age * PR_USEC_PER_SEC;
nsAccessControlLRUCache::CacheEntry* entry =
nsXMLHttpRequest::sAccessControlCache->
GetEntry(uri, mReferrerPrincipal, mWithCredentials, PR_TRUE);
if (!entry) {
return;
}
// The "Access-Control-Allow-Methods" header contains a comma separated
// list of method names.
http->GetResponseHeader(NS_LITERAL_CSTRING("Access-Control-Allow-Methods"),
headerVal);
nsCCharSeparatedTokenizer methods(headerVal, ',');
while(methods.hasMoreTokens()) {
const nsDependentCSubstring& method = methods.nextToken();
if (method.IsEmpty()) {
continue;
}
PRUint32 i;
for (i = 0; i < entry->mMethods.Length(); ++i) {
if (entry->mMethods[i].token.Equals(method)) {
entry->mMethods[i].expirationTime = expirationTime;
break;
}
}
if (i == entry->mMethods.Length()) {
nsAccessControlLRUCache::TokenTime* newMethod =
entry->mMethods.AppendElement();
if (!newMethod) {
return;
}
newMethod->token = method;
newMethod->expirationTime = expirationTime;
}
}
// The "Access-Control-Allow-Headers" header contains a comma separated
// list of method names.
http->GetResponseHeader(NS_LITERAL_CSTRING("Access-Control-Allow-Headers"),
headerVal);
nsCCharSeparatedTokenizer headers(headerVal, ',');
while(headers.hasMoreTokens()) {
const nsDependentCSubstring& header = headers.nextToken();
if (header.IsEmpty()) {
continue;
}
PRUint32 i;
for (i = 0; i < entry->mHeaders.Length(); ++i) {
if (entry->mHeaders[i].token.Equals(header)) {
entry->mHeaders[i].expirationTime = expirationTime;
break;
}
}
if (i == entry->mHeaders.Length()) {
nsAccessControlLRUCache::TokenTime* newHeader =
entry->mHeaders.AppendElement();
if (!newHeader) {
return;
}
newHeader->token = header;
newHeader->expirationTime = expirationTime;
}
}
}
NS_IMETHODIMP
nsACProxyListener::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext)
{
nsresult status;
nsresult rv = aRequest->GetStatus(&status);
if (NS_SUCCEEDED(rv)) {
rv = status;
}
if (NS_SUCCEEDED(rv)) {
// Everything worked, try to cache and then fire off the actual request.
AddResultToCache(aRequest);
rv = mOuterChannel->AsyncOpen(mOuterListener, mOuterContext);
}
if (NS_FAILED(rv)) {
mOuterChannel->Cancel(rv);
mOuterListener->OnStartRequest(mOuterChannel, mOuterContext);
mOuterListener->OnStopRequest(mOuterChannel, mOuterContext, rv);
return rv;
}
return NS_OK;
}
NS_IMETHODIMP
nsACProxyListener::OnStopRequest(nsIRequest *aRequest, nsISupports *aContext,
nsresult aStatus)
{
return NS_OK;
}
/** nsIStreamListener methods **/
NS_IMETHODIMP
nsACProxyListener::OnDataAvailable(nsIRequest *aRequest,
nsISupports *ctxt,
nsIInputStream *inStr,
PRUint32 sourceOffset,
PRUint32 count)
{
return NS_OK;
}
NS_IMETHODIMP
nsACProxyListener::AsyncOnChannelRedirect(nsIChannel *aOldChannel,
nsIChannel *aNewChannel,
PRUint32 aFlags,
nsIAsyncVerifyRedirectCallback *callback)
{
// Only internal redirects allowed for now.
if (!NS_IsInternalSameURIRedirect(aOldChannel, aNewChannel, aFlags))
return NS_ERROR_DOM_BAD_URI;
callback->OnRedirectVerifyCallback(NS_OK);
return NS_OK;
}
NS_IMETHODIMP
nsACProxyListener::GetInterface(const nsIID & aIID, void **aResult)
{
return QueryInterface(aIID, aResult);
}
/////////////////////////////////////////////
NS_IMPL_CYCLE_COLLECTION_CLASS(nsXHREventTarget)
@ -632,219 +411,11 @@ NS_INTERFACE_MAP_END_INHERITING(nsXHREventTarget)
NS_IMPL_ADDREF_INHERITED(nsXMLHttpRequestUpload, nsXHREventTarget)
NS_IMPL_RELEASE_INHERITED(nsXMLHttpRequestUpload, nsXHREventTarget)
void
nsAccessControlLRUCache::CacheEntry::PurgeExpired(PRTime now)
{
PRUint32 i;
for (i = 0; i < mMethods.Length(); ++i) {
if (now >= mMethods[i].expirationTime) {
mMethods.RemoveElementAt(i--);
}
}
for (i = 0; i < mHeaders.Length(); ++i) {
if (now >= mHeaders[i].expirationTime) {
mHeaders.RemoveElementAt(i--);
}
}
}
PRBool
nsAccessControlLRUCache::CacheEntry::CheckRequest(const nsCString& aMethod,
const nsTArray<nsCString>& aHeaders)
{
PurgeExpired(PR_Now());
if (!aMethod.EqualsLiteral("GET") && !aMethod.EqualsLiteral("POST")) {
PRUint32 i;
for (i = 0; i < mMethods.Length(); ++i) {
if (aMethod.Equals(mMethods[i].token))
break;
}
if (i == mMethods.Length()) {
return PR_FALSE;
}
}
for (PRUint32 i = 0; i < aHeaders.Length(); ++i) {
PRUint32 j;
for (j = 0; j < mHeaders.Length(); ++j) {
if (aHeaders[i].Equals(mHeaders[j].token,
nsCaseInsensitiveCStringComparator())) {
break;
}
}
if (j == mHeaders.Length()) {
return PR_FALSE;
}
}
return PR_TRUE;
}
nsAccessControlLRUCache::CacheEntry*
nsAccessControlLRUCache::GetEntry(nsIURI* aURI,
nsIPrincipal* aPrincipal,
PRBool aWithCredentials,
PRBool aCreate)
{
nsCString key;
if (!GetCacheKey(aURI, aPrincipal, aWithCredentials, key)) {
NS_WARNING("Invalid cache key!");
return nsnull;
}
CacheEntry* entry;
if (mTable.Get(key, &entry)) {
// Entry already existed so just return it. Also update the LRU list.
// Move to the head of the list.
PR_REMOVE_LINK(entry);
PR_INSERT_LINK(entry, &mList);
return entry;
}
if (!aCreate) {
return nsnull;
}
// This is a new entry, allocate and insert into the table now so that any
// failures don't cause items to be removed from a full cache.
entry = new CacheEntry(key);
if (!entry) {
NS_WARNING("Failed to allocate new cache entry!");
return nsnull;
}
if (!mTable.Put(key, entry)) {
// Failed, clean up the new entry.
delete entry;
NS_WARNING("Failed to add entry to the access control cache!");
return nsnull;
}
PR_INSERT_LINK(entry, &mList);
NS_ASSERTION(mTable.Count() <= ACCESS_CONTROL_CACHE_SIZE + 1,
"Something is borked, too many entries in the cache!");
// Now enforce the max count.
if (mTable.Count() > ACCESS_CONTROL_CACHE_SIZE) {
// Try to kick out all the expired entries.
PRTime now = PR_Now();
mTable.Enumerate(RemoveExpiredEntries, &now);
// If that didn't remove anything then kick out the least recently used
// entry.
if (mTable.Count() > ACCESS_CONTROL_CACHE_SIZE) {
CacheEntry* lruEntry = static_cast<CacheEntry*>(PR_LIST_TAIL(&mList));
PR_REMOVE_LINK(lruEntry);
// This will delete 'lruEntry'.
mTable.Remove(lruEntry->mKey);
NS_ASSERTION(mTable.Count() == ACCESS_CONTROL_CACHE_SIZE,
"Somehow tried to remove an entry that was never added!");
}
}
return entry;
}
void
nsAccessControlLRUCache::RemoveEntries(nsIURI* aURI, nsIPrincipal* aPrincipal)
{
CacheEntry* entry;
nsCString key;
if (GetCacheKey(aURI, aPrincipal, PR_TRUE, key) &&
mTable.Get(key, &entry)) {
PR_REMOVE_LINK(entry);
mTable.Remove(key);
}
if (GetCacheKey(aURI, aPrincipal, PR_FALSE, key) &&
mTable.Get(key, &entry)) {
PR_REMOVE_LINK(entry);
mTable.Remove(key);
}
}
void
nsAccessControlLRUCache::Clear()
{
PR_INIT_CLIST(&mList);
mTable.Clear();
}
/* static */ PLDHashOperator
nsAccessControlLRUCache::RemoveExpiredEntries(const nsACString& aKey,
nsAutoPtr<CacheEntry>& aValue,
void* aUserData)
{
PRTime* now = static_cast<PRTime*>(aUserData);
aValue->PurgeExpired(*now);
if (aValue->mHeaders.IsEmpty() &&
aValue->mHeaders.IsEmpty()) {
// Expired, remove from the list as well as the hash table.
PR_REMOVE_LINK(aValue);
return PL_DHASH_REMOVE;
}
return PL_DHASH_NEXT;
}
/* static */ PRBool
nsAccessControlLRUCache::GetCacheKey(nsIURI* aURI,
nsIPrincipal* aPrincipal,
PRBool aWithCredentials,
nsACString& _retval)
{
NS_ASSERTION(aURI, "Null uri!");
NS_ASSERTION(aPrincipal, "Null principal!");
NS_NAMED_LITERAL_CSTRING(space, " ");
nsCOMPtr<nsIURI> uri;
nsresult rv = aPrincipal->GetURI(getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, PR_FALSE);
nsCAutoString scheme, host, port;
if (uri) {
uri->GetScheme(scheme);
uri->GetHost(host);
port.AppendInt(NS_GetRealPort(uri));
}
nsCAutoString cred;
if (aWithCredentials) {
_retval.AssignLiteral("cred");
}
else {
_retval.AssignLiteral("nocred");
}
nsCAutoString spec;
rv = aURI->GetSpec(spec);
NS_ENSURE_SUCCESS(rv, PR_FALSE);
_retval.Assign(cred + space + scheme + space + host + space + port + space +
spec);
return PR_TRUE;
}
/////////////////////////////////////////////
//
//
/////////////////////////////////////////////
// Will be initialized in nsXMLHttpRequest::EnsureACCache.
nsAccessControlLRUCache* nsXMLHttpRequest::sAccessControlCache = nsnull;
nsXMLHttpRequest::nsXMLHttpRequest()
: mRequestObserver(nsnull), mState(XML_HTTP_REQUEST_UNINITIALIZED),
mUploadTransferred(0), mUploadTotal(0), mUploadComplete(PR_TRUE),
@ -984,7 +555,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXMLHttpRequest,
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mChannel)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mReadRequest)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mResponseXML)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mACGetChannel)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mCORSPreflightChannel)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnUploadProgressListener)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnReadystatechangeListener)
@ -1005,7 +576,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXMLHttpRequest,
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mChannel)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mReadRequest)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mResponseXML)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mACGetChannel)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCORSPreflightChannel)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnUploadProgressListener)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnReadystatechangeListener)
@ -1362,8 +933,8 @@ nsXMLHttpRequest::Abort()
if (mChannel) {
mChannel->Cancel(NS_BINDING_ABORTED);
}
if (mACGetChannel) {
mACGetChannel->Cancel(NS_BINDING_ABORTED);
if (mCORSPreflightChannel) {
mCORSPreflightChannel->Cancel(NS_BINDING_ABORTED);
}
mResponseXML = nsnull;
PRUint32 responseLength = mResponseBody.Length();
@ -1389,7 +960,7 @@ nsXMLHttpRequest::Abort()
}
// The ChangeState call above calls onreadystatechange handlers which
// if they load a new url will cause nsXMLHttpRequest::OpenRequest to clear
// if they load a new url will cause nsXMLHttpRequest::Open to clear
// the abort state bit. If this occurs we're not uninitialized (bug 361773).
if (mState & XML_HTTP_REQUEST_ABORTED) {
ChangeState(XML_HTTP_REQUEST_UNINITIALIZED, PR_FALSE); // IE seems to do it
@ -1654,7 +1225,7 @@ nsXMLHttpRequest::CheckChannelForCrossSiteRequest(nsIChannel* aChannel)
nsCAutoString method;
httpChannel->GetRequestMethod(method);
if (!mACUnsafeHeaders.IsEmpty() ||
if (!mCORSUnsafeHeaders.IsEmpty() ||
HasListenersFor(NS_LITERAL_STRING(UPLOADPROGRESS_STR)) ||
(mUpload && mUpload->HasListeners()) ||
(!method.LowerCaseEqualsLiteral("get") &&
@ -1666,16 +1237,18 @@ nsXMLHttpRequest::CheckChannelForCrossSiteRequest(nsIChannel* aChannel)
return NS_OK;
}
/* noscript void openRequest (in AUTF8String method, in AUTF8String url, in boolean async, in AString user, in AString password); */
NS_IMETHODIMP
nsXMLHttpRequest::OpenRequest(const nsACString& method,
const nsACString& url,
PRBool async,
const nsAString& user,
const nsAString& password)
nsXMLHttpRequest::Open(const nsACString& method, const nsACString& url,
PRBool async, const nsAString& user,
const nsAString& password, PRUint8 optional_argc)
{
NS_ENSURE_ARG(!method.IsEmpty());
if (!optional_argc) {
// No optional arguments were passed in. Default async to true.
async = PR_TRUE;
}
NS_ENSURE_TRUE(mPrincipal, NS_ERROR_NOT_INITIALIZED);
// Disallow HTTP/1.1 TRACE method (see bug 302489)
@ -1805,20 +1378,6 @@ nsXMLHttpRequest::OpenRequest(const nsACString& method,
return rv;
}
/* void open (in AUTF8String method, in AUTF8String url); */
NS_IMETHODIMP
nsXMLHttpRequest::Open(const nsACString& method, const nsACString& url,
PRBool async, const nsAString& user,
const nsAString& password, PRUint8 optional_argc)
{
if (!optional_argc) {
// No optional arguments were passed in. Default async to true.
async = PR_TRUE;
}
return OpenRequest(method, url, async, user, password);
}
/*
* "Copy" from a stream.
*/
@ -2567,7 +2126,7 @@ nsXMLHttpRequest::Send(nsIVariant *aBody)
if (!contentType.LowerCaseEqualsLiteral("text/plain") &&
!contentType.LowerCaseEqualsLiteral("application/x-www-form-urlencoded") &&
!contentType.LowerCaseEqualsLiteral("multipart/form-data")) {
mACUnsafeHeaders.AppendElement(NS_LITERAL_CSTRING("Content-Type"));
mCORSUnsafeHeaders.AppendElement(NS_LITERAL_CSTRING("Content-Type"));
}
}
}
@ -2584,41 +2143,6 @@ nsXMLHttpRequest::Send(nsIVariant *aBody)
PRBool withCredentials = !!(mState & XML_HTTP_REQUEST_AC_WITH_CREDENTIALS);
// If so, set up the preflight
if (mState & XML_HTTP_REQUEST_NEED_AC_PREFLIGHT) {
// Check to see if this initial OPTIONS request has already been cached
// in our special Access Control Cache.
nsCOMPtr<nsIURI> uri;
rv = NS_GetFinalChannelURI(mChannel, getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, rv);
nsAccessControlLRUCache::CacheEntry* entry =
sAccessControlCache ?
sAccessControlCache->GetEntry(uri, mPrincipal, withCredentials, PR_FALSE) :
nsnull;
if (!entry || !entry->CheckRequest(method, mACUnsafeHeaders)) {
// Either it wasn't cached or the cached result has expired. Build a
// channel for the OPTIONS request.
nsCOMPtr<nsILoadGroup> loadGroup;
GetLoadGroup(getter_AddRefs(loadGroup));
nsLoadFlags loadFlags;
rv = mChannel->GetLoadFlags(&loadFlags);
NS_ENSURE_SUCCESS(rv, rv);
rv = NS_NewChannel(getter_AddRefs(mACGetChannel), uri, nsnull,
loadGroup, nsnull, loadFlags);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIHttpChannel> acHttp = do_QueryInterface(mACGetChannel);
NS_ASSERTION(acHttp, "Failed to QI to nsIHttpChannel!");
rv = acHttp->SetRequestMethod(NS_LITERAL_CSTRING("OPTIONS"));
NS_ENSURE_SUCCESS(rv, rv);
}
}
// Hook us up to listen to redirects and the like
mChannel->GetNotificationCallbacks(getter_AddRefs(mNotificationCallbacks));
mChannel->SetNotificationCallbacks(this);
@ -2633,10 +2157,10 @@ nsXMLHttpRequest::Send(nsIVariant *aBody)
}
if (!IsSystemXHR()) {
// Always create a nsCrossSiteListenerProxy here even if it's
// Always create a nsCORSListenerProxy here even if it's
// a same-origin request right now, since it could be redirected.
listener = new nsCrossSiteListenerProxy(listener, mPrincipal, mChannel,
withCredentials, &rv);
listener = new nsCORSListenerProxy(listener, mPrincipal, mChannel,
withCredentials, &rv);
NS_ENSURE_TRUE(listener, NS_ERROR_OUT_OF_MEMORY);
NS_ENSURE_SUCCESS(rv, rv);
}
@ -2657,10 +2181,6 @@ nsXMLHttpRequest::Send(nsIVariant *aBody)
else if (!(mState & XML_HTTP_REQUEST_ASYNC)) {
AddLoadFlags(mChannel,
nsICachingChannel::LOAD_BYPASS_LOCAL_CACHE_IF_BUSY);
if (mACGetChannel) {
AddLoadFlags(mACGetChannel,
nsICachingChannel::LOAD_BYPASS_LOCAL_CACHE_IF_BUSY);
}
}
// Since we expect XML data, set the type hint accordingly
@ -2668,22 +2188,16 @@ nsXMLHttpRequest::Send(nsIVariant *aBody)
// ignoring return value, as this is not critical
mChannel->SetContentType(NS_LITERAL_CSTRING("application/xml"));
// If we're doing a cross-site non-GET request we need to first do
// a GET request to the same URI. Set that up if needed
if (mACGetChannel) {
nsCOMPtr<nsIStreamListener> acProxyListener =
new nsACProxyListener(mChannel, listener, nsnull, mPrincipal, method,
withCredentials);
NS_ENSURE_TRUE(acProxyListener, NS_ERROR_OUT_OF_MEMORY);
// Set up the preflight if needed
if (mState & XML_HTTP_REQUEST_NEED_AC_PREFLIGHT) {
// Check to see if this initial OPTIONS request has already been cached
// in our special Access Control Cache.
acProxyListener =
new nsCrossSiteListenerProxy(acProxyListener, mPrincipal, mACGetChannel,
withCredentials, method, mACUnsafeHeaders,
&rv);
NS_ENSURE_TRUE(acProxyListener, NS_ERROR_OUT_OF_MEMORY);
rv = NS_StartCORSPreflight(mChannel, listener,
mPrincipal, withCredentials,
mCORSUnsafeHeaders,
getter_AddRefs(mCORSPreflightChannel));
NS_ENSURE_SUCCESS(rv, rv);
rv = mACGetChannel->AsyncOpen(acProxyListener, nsnull);
}
else {
// Start reading from the channel
@ -2693,7 +2207,7 @@ nsXMLHttpRequest::Send(nsIVariant *aBody)
if (NS_FAILED(rv)) {
// Drop our ref to the channel to avoid cycles
mChannel = nsnull;
mACGetChannel = nsnull;
mCORSPreflightChannel = nsnull;
return rv;
}
@ -2770,17 +2284,17 @@ nsXMLHttpRequest::SetRequestHeader(const nsACString& header,
{
nsresult rv;
// Make sure we don't store an invalid header name in mACUnsafeHeaders
// Make sure we don't store an invalid header name in mCORSUnsafeHeaders
if (!IsValidHTTPToken(header)) {
return NS_ERROR_FAILURE;
}
// Check that we haven't already opened the channel. We can't rely on
// the channel throwing from mChannel->SetRequestHeader since we might
// still be waiting for mACGetChannel to actually open mChannel
if (mACGetChannel) {
// still be waiting for mCORSPreflightChannel to actually open mChannel
if (mCORSPreflightChannel) {
PRBool pending;
rv = mACGetChannel->IsPending(&pending);
rv = mCORSPreflightChannel->IsPending(&pending);
NS_ENSURE_SUCCESS(rv, rv);
if (pending) {
@ -2845,7 +2359,7 @@ nsXMLHttpRequest::SetRequestHeader(const nsACString& header,
}
if (!safeHeader) {
mACUnsafeHeaders.AppendElement(header);
mCORSUnsafeHeaders.AppendElement(header);
}
}

View File

@ -60,10 +60,6 @@
#include "nsTArray.h"
#include "nsIJSNativeInitializer.h"
#include "nsIDOMLSProgressEvent.h"
#include "nsClassHashtable.h"
#include "nsHashKeys.h"
#include "prclist.h"
#include "prtime.h"
#include "nsIDOMNSEvent.h"
#include "nsITimer.h"
#include "nsIPrivateDOMEvent.h"
@ -74,72 +70,6 @@
class nsILoadGroup;
class AsyncVerifyRedirectCallbackForwarder;
class nsAccessControlLRUCache
{
public:
struct TokenTime
{
nsCString token;
PRTime expirationTime;
};
struct CacheEntry : public PRCList
{
CacheEntry(nsCString& aKey)
: mKey(aKey)
{
MOZ_COUNT_CTOR(nsAccessControlLRUCache::CacheEntry);
}
~CacheEntry()
{
MOZ_COUNT_DTOR(nsAccessControlLRUCache::CacheEntry);
}
void PurgeExpired(PRTime now);
PRBool CheckRequest(const nsCString& aMethod,
const nsTArray<nsCString>& aCustomHeaders);
nsCString mKey;
nsTArray<TokenTime> mMethods;
nsTArray<TokenTime> mHeaders;
};
nsAccessControlLRUCache()
{
MOZ_COUNT_CTOR(nsAccessControlLRUCache);
PR_INIT_CLIST(&mList);
}
~nsAccessControlLRUCache()
{
Clear();
MOZ_COUNT_DTOR(nsAccessControlLRUCache);
}
PRBool Initialize()
{
return mTable.Init();
}
CacheEntry* GetEntry(nsIURI* aURI, nsIPrincipal* aPrincipal,
PRBool aWithCredentials, PRBool aCreate);
void RemoveEntries(nsIURI* aURI, nsIPrincipal* aPrincipal);
void Clear();
private:
static PLDHashOperator
RemoveExpiredEntries(const nsACString& aKey, nsAutoPtr<CacheEntry>& aValue,
void* aUserData);
static PRBool GetCacheKey(nsIURI* aURI, nsIPrincipal* aPrincipal,
PRBool aWithCredentials, nsACString& _retval);
nsClassHashtable<nsCStringHashKey, CacheEntry> mTable;
PRCList mList;
};
class nsXHREventTarget : public nsDOMEventTargetWrapperCache,
public nsIXMLHttpRequestEventTarget
{
@ -281,32 +211,8 @@ public:
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsXMLHttpRequest,
nsXHREventTarget)
static PRBool EnsureACCache()
{
if (sAccessControlCache)
return PR_TRUE;
nsAutoPtr<nsAccessControlLRUCache> newCache(new nsAccessControlLRUCache());
NS_ENSURE_TRUE(newCache, PR_FALSE);
if (newCache->Initialize()) {
sAccessControlCache = newCache.forget();
return PR_TRUE;
}
return PR_FALSE;
}
static void ShutdownACCache()
{
delete sAccessControlCache;
sAccessControlCache = nsnull;
}
PRBool AllowUploadProgress();
static nsAccessControlLRUCache* sAccessControlCache;
protected:
friend class nsMultipartProxyListener;
@ -357,8 +263,8 @@ protected:
// mReadRequest is different from mChannel for multipart requests
nsCOMPtr<nsIRequest> mReadRequest;
nsCOMPtr<nsIDOMDocument> mResponseXML;
nsCOMPtr<nsIChannel> mACGetChannel;
nsTArray<nsCString> mACUnsafeHeaders;
nsCOMPtr<nsIChannel> mCORSPreflightChannel;
nsTArray<nsCString> mCORSUnsafeHeaders;
nsRefPtr<nsDOMEventListenerWrapper> mOnUploadProgressListener;
nsRefPtr<nsDOMEventListenerWrapper> mOnReadystatechangeListener;

View File

@ -76,7 +76,7 @@ nsresult TestGetURL(const nsCString& aURL)
rv = xhr->Init(systemPrincipal, nsnull, nsnull, nsnull);
TEST_ENSURE_SUCCESS(rv, "Couldn't initialize the XHR!");
rv = xhr->OpenRequest(getString, aURL, PR_FALSE, empty, empty);
rv = xhr->Open(getString, aURL, PR_FALSE, empty, empty);
TEST_ENSURE_SUCCESS(rv, "OpenRequest failed!");
rv = xhr->Send(nsnull);

View File

@ -77,9 +77,9 @@ nsresult TestNativeXMLHttpRequest()
const nsAString& empty = EmptyString();
printf("*** About to see an expected warning about mPrincipal:\n");
rv = xhr->OpenRequest(getString, testURL, PR_FALSE, empty, empty);
rv = xhr->Open(getString, testURL, PR_FALSE, empty, empty);
printf("*** End of expected warning output.\n");
TEST_ENSURE_FAILED(rv, "OpenRequest should have failed!");
TEST_ENSURE_FAILED(rv, "Open should have failed!");
nsCOMPtr<nsIScriptSecurityManager> secman =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
@ -92,8 +92,8 @@ nsresult TestNativeXMLHttpRequest()
rv = xhr->Init(systemPrincipal, nsnull, nsnull, nsnull);
TEST_ENSURE_SUCCESS(rv, "Couldn't initialize the XHR!");
rv = xhr->OpenRequest(getString, testURL, PR_FALSE, empty, empty);
TEST_ENSURE_SUCCESS(rv, "OpenRequest failed!");
rv = xhr->Open(getString, testURL, PR_FALSE, empty, empty);
TEST_ENSURE_SUCCESS(rv, "Open failed!");
rv = xhr->Send(nsnull);
TEST_ENSURE_SUCCESS(rv, "Send failed!");

View File

@ -25,7 +25,7 @@ window.addEventListener("message", function(e) {
};
var xhr = new XMLHttpRequest();
for each(type in ["load", "abort", "error", "loadstart"]) {
for each(type in ["load", "abort", "error", "loadstart", "loadend"]) {
xhr.addEventListener(type, function(e) {
res.events.push(e.type);
}, false);
@ -48,10 +48,10 @@ window.addEventListener("message", function(e) {
}, false);
}
}
xhr.onload = xhr.onerror = function (event) {
if (event.type == "error") {
res.didFail = true;
}
xhr.onerror = function(e) {
res.didFail = true;
};
xhr.onloadend = function (event) {
res.status = xhr.status;
try {
res.statusText = xhr.statusText;

View File

@ -14,7 +14,7 @@ window.addEventListener("message", function(e) {\n\
};\n\
\n\
var xhr = new XMLHttpRequest();\n\
for each(type in ["load", "abort", "error", "loadstart"]) {\n\
for each(type in ["load", "abort", "error", "loadstart", "loadend"]) {\n\
xhr.addEventListener(type, function(e) {\n\
res.events.push(e.type);\n\
}, false);\n\
@ -37,26 +37,27 @@ window.addEventListener("message", function(e) {\n\
}, false);\n\
}\n\
}\n\
xhr.onload = function () {\n\
res.status = xhr.status;\n\
res.statusText = xhr.statusText;\n\
res.responseXML = xhr.responseXML ?\n\
(new XMLSerializer()).serializeToString(xhr.responseXML) :\n\
null;\n\
res.responseText = xhr.responseText;\n\
post(e, res);\n\
};\n\
xhr.onerror = function () {\n\
xhr.onerror = function(e) {\n\
res.didFail = true;\n\
};\n\
xhr.onloadend = function (event) {\n\
res.status = xhr.status;\n\
try {\n\
res.statusText = xhr.statusText;\n\
} catch (e) {\n\
delete(res.statusText);\n\
}\n\
res.responseXML = xhr.responseXML ?\n\
(new XMLSerializer()).serializeToString(xhr.responseXML) :\n\
null;\n\
res.responseText = xhr.responseText;\n\
\n\
res.responseHeaders = {};\n\
for (responseHeader in req.responseHeaders) {\n\
res.responseHeaders[responseHeader] =\n\
xhr.getResponseHeader(responseHeader);\n\
}\n\
\n\
post(e, res);\n\
}\n\
\n\

View File

@ -656,7 +656,7 @@ function runTest() {
is(res.responseText, "<res>hello pass</res>\n",
"wrong responseText in test for " + test.toSource());
is(res.events.join(","),
"opening,rs1,sending,rs1,loadstart,rs2,rs3,rs4,load",
"opening,rs1,sending,rs1,loadstart,rs2,rs3,rs4,load,loadend",
"wrong responseText in test for " + test.toSource());
}
else {
@ -665,7 +665,7 @@ function runTest() {
is(res.responseText, "",
"wrong responseText in test for " + test.toSource());
is(res.events.join(","),
"opening,rs1,sending,rs1,loadstart,rs2,rs4,load",
"opening,rs1,sending,rs1,loadstart,rs2,rs4,load,loadend",
"wrong responseText in test for " + test.toSource());
}
if (test.responseHeaders) {
@ -694,7 +694,7 @@ function runTest() {
"wrong responseText in test for " + test.toSource());
if (!res.sendThrew) {
is(res.events.join(","),
"opening,rs1,sending,rs1,loadstart,rs2,rs4,error",
"opening,rs1,sending,rs1,loadstart,rs2,rs4,error,loadend",
"wrong events in test for " + test.toSource());
}
is(res.progressEvents, 0,
@ -822,7 +822,7 @@ function runTest() {
is(res.responseText, "<res>hello pass</res>\n",
"wrong responseText in test for " + test.toSource());
is(res.events.join(","),
"opening,rs1,sending,rs1,loadstart,rs2,rs3,rs4,load",
"opening,rs1,sending,rs1,loadstart,rs2,rs3,rs4,load,loadend",
"wrong responseText in test for " + test.toSource());
}
else {
@ -835,7 +835,7 @@ function runTest() {
is(res.responseText, "",
"wrong responseText in test for " + test.toSource());
is(res.events.join(","),
"opening,rs1,sending,rs1,loadstart,rs2,rs4,error",
"opening,rs1,sending,rs1,loadstart,rs2,rs4,error,loadend",
"wrong events in test for " + test.toSource());
is(res.progressEvents, 0,
"wrong events in test for " + test.toSource());
@ -1091,7 +1091,7 @@ function runTest() {
is(res.responseText, "<res>hello pass</res>\n",
"wrong responseText in test for " + test.toSource());
is(res.events.join(","),
"opening,rs1,sending,rs1,loadstart,rs2,rs3,rs4,load",
"opening,rs1,sending,rs1,loadstart,rs2,rs3,rs4,load,loadend",
"wrong responseText in test for " + test.toSource());
}
else {
@ -1104,7 +1104,7 @@ function runTest() {
is(res.responseText, "",
"wrong responseText in test for " + test.toSource());
is(res.events.join(","),
"opening,rs1,sending,rs1,loadstart,rs2,rs4,error",
"opening,rs1,sending,rs1,loadstart,rs2,rs4,error,loadend",
"wrong events in test for " + test.toSource());
is(res.progressEvents, 0,
"wrong progressevents in test for " + test.toSource());

View File

@ -464,7 +464,7 @@ function runTest() {
is(res.responseText, "<res>hello pass</res>\n",
"wrong responseText in test for " + testName);
is(res.events.join(","),
"opening,rs1,sending,rs1,loadstart,rs2,rs3,rs4,load",
"opening,rs1,sending,rs1,loadstart,rs2,rs3,rs4,load,loadend",
"wrong events in test for " + testName);
}
else {
@ -476,15 +476,13 @@ function runTest() {
is(res.responseText, "",
"wrong responseText in test for " + testName);
is(res.events.join(","),
"opening,rs1,sending,rs1,loadstart,rs2,rs4,error",
"opening,rs1,sending,rs1,loadstart,rs2,rs4,error,loadend",
"wrong events in test for " + testName);
is(res.progressEvents, 0,
"wrong events in test for " + testName);
}
}
SimpleTest.finish();
yield;

View File

@ -133,7 +133,7 @@ function runTest() {
is(res.responseText, "<res>hello pass</res>\n",
"wrong responseText in test for " + allowOrigin);
is(res.events.join(","),
"opening,rs1,sending,rs1,loadstart,rs2,rs3,rs4,load",
"opening,rs1,sending,rs1,loadstart,rs2,rs3,rs4,load,loadend",
"wrong responseText in test for " + allowOrigin);
}
@ -151,7 +151,7 @@ function runTest() {
is(res.statusText, "", "wrong status text for " + allowOrigin);
is(res.responseXML, null, "should have no XML for " + allowOrigin);
is(res.events.join(","),
"opening,rs1,sending,rs1,loadstart,rs2,rs4,error",
"opening,rs1,sending,rs1,loadstart,rs2,rs4,error,loadend",
"wrong events in test for " + allowOrigin);
is(res.progressEvents, 0,
"wrong events in test for " + allowOrigin);

View File

@ -42,7 +42,6 @@
#include "nsIAtom.h"
#include "nsIContentViewer.h"
#include "mozilla/css/StyleRule.h"
#include "nsCSSStruct.h"
#include "nsIDocument.h"
#include "nsIDocumentEncoder.h"
#include "nsIDOMHTMLBodyElement.h"

View File

@ -43,7 +43,6 @@
#include "nsStyleConsts.h"
#include "nsPresContext.h"
#include "nsMappedAttributes.h"
#include "nsCSSStruct.h"
#include "nsRuleData.h"
#include "nsIDocument.h"

View File

@ -974,11 +974,11 @@ nsresult nsHTMLMediaElement::LoadResource(nsIURI* aURI)
nsCOMPtr<nsIStreamListener> listener;
if (ShouldCheckAllowOrigin()) {
listener =
new nsCrossSiteListenerProxy(loadListener,
NodePrincipal(),
channel,
PR_FALSE,
&rv);
new nsCORSListenerProxy(loadListener,
NodePrincipal(),
channel,
PR_FALSE,
&rv);
} else {
rv = nsContentUtils::GetSecurityManager()->
CheckLoadURIWithPrincipal(NodePrincipal(),

View File

@ -41,7 +41,6 @@
#include "nsStyleConsts.h"
#include "nsMappedAttributes.h"
#include "nsRuleData.h"
#include "nsCSSStruct.h"
class nsHTMLPreElement : public nsGenericHTMLElement,
public nsIDOMHTMLPreElement

View File

@ -161,8 +161,8 @@ nsMediaChannelStream::OnStartRequest(nsIRequest* aRequest)
NS_ENSURE_SUCCESS(rv, rv);
if (element->ShouldCheckAllowOrigin()) {
// If the request was cancelled by nsCrossSiteListenerProxy due to failing
// the Access Control check, send an error through to the media element.
// If the request was cancelled by nsCORSListenerProxy due to failing
// the CORS security check, send an error through to the media element.
if (status == NS_ERROR_DOM_BAD_URI) {
mDecoder->NetworkError();
return NS_ERROR_DOM_BAD_URI;
@ -457,12 +457,12 @@ nsresult nsMediaChannelStream::OpenChannel(nsIStreamListener** aStreamListener)
NS_ENSURE_TRUE(element, NS_ERROR_FAILURE);
if (element->ShouldCheckAllowOrigin()) {
nsresult rv;
nsCrossSiteListenerProxy* crossSiteListener =
new nsCrossSiteListenerProxy(mListener,
element->NodePrincipal(),
mChannel,
PR_FALSE,
&rv);
nsCORSListenerProxy* crossSiteListener =
new nsCORSListenerProxy(mListener,
element->NodePrincipal(),
mChannel,
PR_FALSE,
&rv);
listener = crossSiteListener;
NS_ENSURE_TRUE(crossSiteListener, NS_ERROR_OUT_OF_MEMORY);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -522,8 +522,8 @@ txCompileObserver::startLoad(nsIURI* aUri, txStylesheetCompiler* aCompiler,
// Always install in case of redirects
nsCOMPtr<nsIStreamListener> listener =
new nsCrossSiteListenerProxy(sink, aReferrerPrincipal, channel,
PR_FALSE, &rv);
new nsCORSListenerProxy(sink, aReferrerPrincipal, channel,
PR_FALSE, &rv);
NS_ENSURE_TRUE(listener, NS_ERROR_OUT_OF_MEMORY);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -217,8 +217,8 @@ nsXULTemplateQueryProcessorXML::GetDatasource(nsIArray* aDataSources,
nsCOMPtr<nsPIDOMWindow> owner = do_QueryInterface(scriptObject);
req->Init(docPrincipal, context, owner, nsnull);
rv = req->OpenRequest(NS_LITERAL_CSTRING("GET"), uriStr, PR_TRUE,
EmptyString(), EmptyString());
rv = req->Open(NS_LITERAL_CSTRING("GET"), uriStr, PR_TRUE,
EmptyString(), EmptyString());
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(req));

View File

@ -639,25 +639,6 @@ nsDOMWorkerXHR::GetResponseHeader(const nsACString& aHeader,
return NS_OK;
}
NS_IMETHODIMP
nsDOMWorkerXHR::OpenRequest(const nsACString& aMethod,
const nsACString& aUrl,
PRBool aAsync,
const nsAString& aUser,
const nsAString& aPassword)
{
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
if (mCanceled) {
return NS_ERROR_ABORT;
}
nsresult rv = mXHRProxy->OpenRequest(aMethod, aUrl, aAsync, aUser, aPassword);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
NS_IMETHODIMP
nsDOMWorkerXHR::Open(const nsACString& aMethod, const nsACString& aUrl,
PRBool aAsync, const nsAString& aUser,
@ -673,7 +654,10 @@ nsDOMWorkerXHR::Open(const nsACString& aMethod, const nsACString& aUrl,
aAsync = PR_TRUE;
}
return OpenRequest(aMethod, aUrl, aAsync, aUser, aPassword);
nsresult rv = mXHRProxy->Open(aMethod, aUrl, aAsync, aUser, aPassword);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
NS_IMETHODIMP

View File

@ -136,17 +136,17 @@ namespace nsDOMWorkerProxiedXHRFunctions
}
};
class OpenRequest : public SyncEventCapturingRunnable
class Open : public SyncEventCapturingRunnable
{
public:
OpenRequest(const nsACString& aMethod, const nsACString& aUrl,
PRBool aAsync, const nsAString& aUser,
const nsAString& aPassword)
Open(const nsACString& aMethod, const nsACString& aUrl,
PRBool aAsync, const nsAString& aUser,
const nsAString& aPassword)
: mMethod(aMethod), mUrl(aUrl), mAsync(aAsync), mUser(aUser),
mPassword(aPassword) { }
virtual nsresult RunInternal() {
return mXHR->OpenRequest(mMethod, mUrl, mAsync, mUser, mPassword);
return mXHR->Open(mMethod, mUrl, mAsync, mUser, mPassword);
}
private:

View File

@ -683,7 +683,7 @@ nsDOMWorkerXHRProxy::DispatchPrematureAbortEvents(PRUint32 aType,
}
nsresult
nsDOMWorkerXHRProxy::MaybeDispatchPrematureAbortEvents(PRBool aFromOpenRequest)
nsDOMWorkerXHRProxy::MaybeDispatchPrematureAbortEvents(PRBool aFromOpen)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
@ -698,7 +698,7 @@ nsDOMWorkerXHRProxy::MaybeDispatchPrematureAbortEvents(PRBool aFromOpenRequest)
nsnull);
NS_ENSURE_SUCCESS(rv, rv);
if (aFromOpenRequest) {
if (aFromOpen) {
rv = DispatchPrematureAbortEvents(LISTENER_TYPE_ABORT, target,
mDownloadProgressInfo);
NS_ENSURE_SUCCESS(rv, rv);
@ -866,17 +866,17 @@ nsDOMWorkerXHRProxy::HandleEventRunnable(nsIRunnable* aRunnable)
}
nsresult
nsDOMWorkerXHRProxy::OpenRequest(const nsACString& aMethod,
const nsACString& aUrl,
PRBool aAsync,
const nsAString& aUser,
const nsAString& aPassword)
nsDOMWorkerXHRProxy::Open(const nsACString& aMethod,
const nsACString& aUrl,
PRBool aAsync,
const nsAString& aUser,
const nsAString& aPassword)
{
if (!NS_IsMainThread()) {
mSyncRequest = !aAsync;
// Always do async behind the scenes!
RUN_PROXIED_FUNCTION(OpenRequest,
RUN_PROXIED_FUNCTION(Open,
(aMethod, aUrl, PR_TRUE, aUser, aPassword));
return NS_OK;
}
@ -888,12 +888,12 @@ nsDOMWorkerXHRProxy::OpenRequest(const nsACString& aMethod,
nsresult rv = MaybeDispatchPrematureAbortEvents(PR_TRUE);
NS_ENSURE_SUCCESS(rv, rv);
rv = mXHR->OpenRequest(aMethod, aUrl, aAsync, aUser, aPassword);
rv = mXHR->Open(aMethod, aUrl, aAsync, aUser, aPassword);
NS_ENSURE_SUCCESS(rv, rv);
// Do this after OpenRequest is called so that we will continue to run events
// from the old channel if OpenRequest fails. Any events generated by the
// OpenRequest method will always run regardless of channel ID.
// Do this after Open is called so that we will continue to run events
// from the old channel if Open fails. Any events generated by the
// Open method will always run regardless of channel ID.
mChannelID++;
return NS_OK;

View File

@ -92,11 +92,11 @@ public:
nsIXMLHttpRequest* GetXMLHttpRequest();
nsresult OpenRequest(const nsACString& aMethod,
const nsACString& aUrl,
PRBool aAsync,
const nsAString& aUser,
const nsAString& aPassword);
nsresult Open(const nsACString& aMethod,
const nsACString& aUrl,
PRBool aAsync,
const nsAString& aUser,
const nsAString& aPassword);
nsresult Abort();

View File

@ -1011,7 +1011,7 @@ gfxDWriteFontList::GetFontSubstitutes()
for (i = 0, rv = ERROR_SUCCESS; rv != ERROR_NO_MORE_ITEMS; i++) {
aliasName[0] = 0;
lenAlias = sizeof(aliasName);
lenAlias = NS_ARRAY_LENGTH(aliasName);
actualName[0] = 0;
lenActual = sizeof(actualName);
rv = RegEnumValueW(hKey, i, aliasName, &lenAlias, NULL, &valueType,

View File

@ -626,7 +626,7 @@ gfxGDIFontList::GetFontSubstitutes()
for (i = 0, rv = ERROR_SUCCESS; rv != ERROR_NO_MORE_ITEMS; i++) {
aliasName[0] = 0;
lenAlias = sizeof(aliasName);
lenAlias = NS_ARRAY_LENGTH(aliasName);
actualName[0] = 0;
lenActual = sizeof(actualName);
rv = RegEnumValueW(hKey, i, aliasName, &lenAlias, NULL, &valueType,

View File

@ -17,10 +17,11 @@ class XULInfo:
"""Return JS that when executed sets up variables so that JS expression
predicates on XUL build info evaluate properly."""
return 'var xulRuntime = { OS: "%s", XPCOMABI: "%s", shell: true }; var isDebugBuild=%s;' % (
return 'var xulRuntime = { OS: "%s", XPCOMABI: "%s", shell: true }; var isDebugBuild=%s; var Android=%s;' % (
self.os,
self.abi,
str(self.isdebug).lower())
str(self.isdebug).lower(),
self.os == "Android")
@classmethod
def create(cls, jsdir):

View File

@ -40,23 +40,22 @@
#include "nsICSSDeclaration.h"
#define CSS_PROP_DOMPROP_PREFIXED(prop_) Moz ## prop_
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
parsevariant_, kwtable_, stylestruct_, stylestructoffset_, \
animtype_) \
#define CSS_PROP(name_, id_, method_, flags_, parsevariant_, kwtable_, \
stylestruct_, stylestructoffset_, animtype_) \
static const nsCSSProperty QS_CSS_PROP_##method_ = eCSSProperty_##id_;
#define CSS_PROP_LIST_EXCLUDE_INTERNAL
#define CSS_PROP_SHORTHAND(name_, id_, method_, flags_) \
CSS_PROP(name_, id_, method_, flags_, X, X, X, X, X, X, X)
CSS_PROP(name_, id_, method_, flags_, X, X, X, X, X)
#include "nsCSSPropList.h"
// Aliases
CSS_PROP(X, opacity, MozOpacity, X, X, X, X, X, X, X, X)
CSS_PROP(X, outline, MozOutline, X, X, X, X, X, X, X, X)
CSS_PROP(X, outline_color, MozOutlineColor, X, X, X, X, X, X, X, X)
CSS_PROP(X, outline_style, MozOutlineStyle, X, X, X, X, X, X, X, X)
CSS_PROP(X, outline_width, MozOutlineWidth, X, X, X, X, X, X, X, X)
CSS_PROP(X, outline_offset, MozOutlineOffset, X, X, X, X, X, X, X, X)
CSS_PROP(X, opacity, MozOpacity, X, X, X, X, X, X)
CSS_PROP(X, outline, MozOutline, X, X, X, X, X, X)
CSS_PROP(X, outline_color, MozOutlineColor, X, X, X, X, X, X)
CSS_PROP(X, outline_style, MozOutlineStyle, X, X, X, X, X, X)
CSS_PROP(X, outline_width, MozOutlineWidth, X, X, X, X, X, X)
CSS_PROP(X, outline_offset, MozOutlineOffset, X, X, X, X, X, X)
#undef CSS_PROP_SHORTHAND
#undef CSS_PROP_LIST_EXCLUDE_INTERNAL

View File

@ -104,7 +104,8 @@ nsRefreshDriver::nsRefreshDriver(nsPresContext *aPresContext)
: mPresContext(aPresContext),
mFrozen(false),
mThrottled(false),
mTimerIsPrecise(false)
mTimerIsPrecise(false),
mLastTimerInterval(0)
{
}

View File

@ -79,7 +79,7 @@
#include "nsCCUncollectableMarker.h"
#include "nsTextFragment.h"
#include "nsCSSRuleProcessor.h"
#include "nsXMLHttpRequest.h"
#include "nsCrossSiteListenerProxy.h"
#include "nsWebSocket.h"
#include "nsDOMThreadService.h"
#include "nsHTMLDNSPrefetch.h"
@ -275,7 +275,7 @@ nsLayoutStatics::Initialize()
nsIPresShell::InitializeStatics();
nsRefreshDriver::InitializeStatics();
nsCrossSiteListenerProxy::Startup();
nsCORSListenerProxy::Startup();
rv = nsFrameList::Init();
if (NS_FAILED(rv)) {
@ -365,7 +365,7 @@ nsLayoutStatics::Shutdown()
nsAudioStream::ShutdownLibrary();
#endif
nsXMLHttpRequest::ShutdownACCache();
nsCORSListenerProxy::Shutdown();
nsWebSocket::ReleaseGlobals();

View File

@ -7594,8 +7594,8 @@ DR_FrameTypeInfo::DR_FrameTypeInfo(nsIAtom* aFrameType,
const char* aFrameName)
{
mType = aFrameType;
strcpy(mNameAbbrev, aFrameNameAbbrev);
strcpy(mName, aFrameName);
PL_strncpyz(mNameAbbrev, aFrameNameAbbrev, sizeof(mNameAbbrev));
PL_strncpyz(mName, aFrameName, sizeof(mName));
}
struct DR_FrameTreeNode

View File

@ -68,7 +68,6 @@ EXPORTS = \
nsCSSPseudoElements.h \
nsCSSRuleProcessor.h \
nsCSSStyleSheet.h \
nsCSSStruct.h \
nsCSSValue.h \
nsDOMCSSAttrDeclaration.h \
nsDOMCSSDeclaration.h \
@ -119,7 +118,6 @@ CPPSRCS = \
nsCSSRuleProcessor.cpp \
nsCSSRules.cpp \
nsCSSScanner.cpp \
nsCSSStruct.cpp \
nsCSSStyleSheet.cpp \
nsCSSValue.cpp \
nsComputedDOMStyle.cpp \

View File

@ -330,18 +330,6 @@ nsCSSExpandedDataBlock::~nsCSSExpandedDataBlock()
AssertInitialState();
}
const size_t
nsCSSExpandedDataBlock::kOffsetTable[] = {
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
parsevariant_, kwtable_, stylestruct_, stylestructoffset_,\
animtype_) \
offsetof(nsCSSExpandedDataBlock, m##datastruct_.member_),
#define CSS_PROP_STUB_NOT_CSS size_t(-1),
#include "nsCSSPropList.h"
#undef CSS_PROP
#undef CSS_PROP_STUB_NOT_CSS
};
void
nsCSSExpandedDataBlock::DoExpand(nsCSSCompressedDataBlock *aBlock,
PRBool aImportant)
@ -611,11 +599,8 @@ nsCSSExpandedDataBlock::DoAssertInitialState()
mPropertiesImportant.AssertIsEmpty("not initial state");
for (PRUint32 i = 0; i < eCSSProperty_COUNT_no_shorthands; ++i) {
// Check all properties except the non-CSS ones, which have
// size_t(-1) in kOffsetTable.
nsCSSProperty prop = nsCSSProperty(i);
NS_ABORT_IF_FALSE(kOffsetTable[prop] == size_t(-1) ||
PropertyAt(prop)->GetUnit() == eCSSUnit_Null,
NS_ABORT_IF_FALSE(PropertyAt(prop)->GetUnit() == eCSSUnit_Null,
"not initial state");
}
}

View File

@ -43,7 +43,6 @@
#ifndef nsCSSDataBlock_h__
#define nsCSSDataBlock_h__
#include "nsCSSStruct.h"
#include "nsCSSProps.h"
#include "nsCSSPropertySet.h"
@ -151,23 +150,7 @@ private:
/* Property storage may not be accessed directly; use AddLonghandProperty
* and friends.
*/
nsCSSFont mFont;
nsCSSDisplay mDisplay;
nsCSSMargin mMargin;
nsCSSList mList;
nsCSSPosition mPosition;
nsCSSTable mTable;
nsCSSColor mColor;
nsCSSContent mContent;
nsCSSText mText;
nsCSSUserInterface mUserInterface;
nsCSSAural mAural;
nsCSSPage mPage;
nsCSSBreaks mBreaks;
nsCSSXUL mXUL;
nsCSSSVG mSVG;
nsCSSColumn mColumn;
nsCSSValue mValues[eCSSProperty_COUNT_no_shorthands];
public:
/**
@ -265,10 +248,6 @@ private:
void DoAssertInitialState();
#endif
// XXX These could probably be pointer-to-member, if the casting can
// be done correctly.
static const size_t kOffsetTable[];
/*
* mPropertiesSet stores a bit for every property that is present,
* to optimize compression of blocks with small numbers of
@ -289,11 +268,7 @@ private:
NS_ABORT_IF_FALSE(0 <= aProperty &&
aProperty < eCSSProperty_COUNT_no_shorthands,
"property out of range");
size_t offset = nsCSSExpandedDataBlock::kOffsetTable[aProperty];
NS_ABORT_IF_FALSE(offset != size_t(-1),
"requesting offset of non-CSS property");
return reinterpret_cast<nsCSSValue*>(reinterpret_cast<char*>(this) +
offset);
return &mValues[aProperty];
}
void SetPropertyBit(nsCSSProperty aProperty) {

View File

@ -165,9 +165,8 @@ namespace css = mozilla::css;
// This lives here because it depends on the above macros.
const PRUint32
nsCSSProps::kParserVariantTable[eCSSProperty_COUNT_no_shorthands] = {
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
parsevariant_, kwtable_, stylestruct_, stylestructoffset_, \
animtype_) \
#define CSS_PROP(name_, id_, method_, flags_, parsevariant_, kwtable_, \
stylestruct_, stylestructoffset_, animtype_) \
parsevariant_,
#include "nsCSSPropList.h"
#undef CSS_PROP

File diff suppressed because it is too large Load Diff

View File

@ -51,9 +51,8 @@
enum nsCSSProperty {
eCSSProperty_UNKNOWN = -1,
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
parsevariant_, kwtable_, stylestruct_, \
stylestructoffset_, animtype_) \
#define CSS_PROP(name_, id_, method_, flags_, parsevariant_, kwtable_, \
stylestruct_, stylestructoffset_, animtype_) \
eCSSProperty_##id_,
#include "nsCSSPropList.h"
#undef CSS_PROP

View File

@ -60,9 +60,8 @@ extern const char* const kCSSRawProperties[];
// define an array of all CSS properties
const char* const kCSSRawProperties[] = {
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
parsevariant_, kwtable_, stylestruct_, stylestructoffset_, \
animtype_) \
#define CSS_PROP(name_, id_, method_, flags_, parsevariant_, kwtable_, \
stylestruct_, stylestructoffset_, animtype_) \
#name_,
#include "nsCSSPropList.h"
#undef CSS_PROP
@ -1516,9 +1515,8 @@ nsCSSProps::ValueToKeyword(PRInt32 aValue, const PRInt32 aTable[])
/* static */ const PRInt32* const
nsCSSProps::kKeywordTableTable[eCSSProperty_COUNT_no_shorthands] = {
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
parsevariant_, kwtable_, stylestruct_, stylestructoffset_, \
animtype_) \
#define CSS_PROP(name_, id_, method_, flags_, parsevariant_, kwtable_, \
stylestruct_, stylestructoffset_, animtype_) \
kwtable_,
#include "nsCSSPropList.h"
#undef CSS_PROP
@ -1562,9 +1560,8 @@ const nsStyleStructID nsCSSProps::kSIDTable[eCSSProperty_COUNT_no_shorthands] =
// Note that this uses the special BackendOnly style struct ID
// (which does need to be valid for storing in the
// nsCSSCompressedDataBlock::mStyleBits bitfield).
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
parsevariant_, kwtable_, stylestruct_, stylestructoffset_,\
animtype_) \
#define CSS_PROP(name_, id_, method_, flags_, parsevariant_, kwtable_, \
stylestruct_, stylestructoffset_, animtype_) \
eStyleStruct_##stylestruct_,
#include "nsCSSPropList.h"
@ -1574,9 +1571,8 @@ const nsStyleStructID nsCSSProps::kSIDTable[eCSSProperty_COUNT_no_shorthands] =
const nsStyleAnimType
nsCSSProps::kAnimTypeTable[eCSSProperty_COUNT_no_shorthands] = {
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
parsevariant_, kwtable_, stylestruct_, stylestructoffset_, \
animtype_) \
#define CSS_PROP(name_, id_, method_, flags_, parsevariant_, kwtable_, \
stylestruct_, stylestructoffset_, animtype_) \
animtype_,
#include "nsCSSPropList.h"
#undef CSS_PROP
@ -1584,18 +1580,16 @@ nsCSSProps::kAnimTypeTable[eCSSProperty_COUNT_no_shorthands] = {
const ptrdiff_t
nsCSSProps::kStyleStructOffsetTable[eCSSProperty_COUNT_no_shorthands] = {
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
parsevariant_, kwtable_, stylestruct_, stylestructoffset_, \
animtype_) \
#define CSS_PROP(name_, id_, method_, flags_, parsevariant_, kwtable_, \
stylestruct_, stylestructoffset_, animtype_) \
stylestructoffset_,
#include "nsCSSPropList.h"
#undef CSS_PROP
};
const PRUint32 nsCSSProps::kFlagsTable[eCSSProperty_COUNT] = {
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
parsevariant_, kwtable_, stylestruct_, stylestructoffset_, \
animtype_) \
#define CSS_PROP(name_, id_, method_, flags_, parsevariant_, kwtable_, \
stylestruct_, stylestructoffset_, animtype_) \
flags_,
#include "nsCSSPropList.h"
#undef CSS_PROP
@ -2074,9 +2068,8 @@ nsCSSProps::kSubpropertyTable[eCSSProperty_COUNT - eCSSProperty_COUNT_no_shortha
};
#define ENUM_DATA_FOR_PROPERTY(name_, id_, method_, flags_, datastruct_, \
member_, parsevariant_, kwtable_, \
stylestructoffset_, animtype_) \
#define ENUM_DATA_FOR_PROPERTY(name_, id_, method_, flags_, parsevariant_, \
kwtable_, stylestructoffset_, animtype_) \
ePropertyIndex_for_##id_,
// The order of these enums must match the g*Flags arrays in nsRuleNode.cpp.
@ -2255,12 +2248,11 @@ nsCSSProps::gPropertyCountInStruct[nsStyleStructID_Length] = {
/* static */ const size_t
nsCSSProps::gPropertyIndexInStruct[eCSSProperty_COUNT_no_shorthands] = {
#define CSS_PROP_BACKENDONLY(name_, id_, method_, flags_, datastruct_, \
member_, parsevariant_, kwtable_) \
#define CSS_PROP_BACKENDONLY(name_, id_, method_, flags_, parsevariant_, \
kwtable_) \
size_t(-1),
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
parsevariant_, kwtable_, stylestruct_, \
stylestructoffset_, animtype_) \
#define CSS_PROP(name_, id_, method_, flags_, parsevariant_, kwtable_, \
stylestruct_, stylestructoffset_, animtype_) \
ePropertyIndex_for_##id_,
#include "nsCSSPropList.h"
#undef CSS_PROP

View File

@ -1,279 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Daniel Glazman <glazman@netscape.com>
* Mats Palmgren <mats.palmgren@bredband.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* temporary (expanded) representation of the property-value pairs
* within a CSS declaration using during parsing and mutation, and
* representation of complex values for CSS properties
*/
#include "nsCSSStruct.h"
#include "nsString.h"
// --- nsCSSFont -----------------
nsCSSFont::nsCSSFont(void)
{
MOZ_COUNT_CTOR(nsCSSFont);
}
nsCSSFont::~nsCSSFont(void)
{
MOZ_COUNT_DTOR(nsCSSFont);
}
// --- nsCSSColor -----------------
nsCSSColor::nsCSSColor(void)
{
MOZ_COUNT_CTOR(nsCSSColor);
}
nsCSSColor::~nsCSSColor(void)
{
MOZ_COUNT_DTOR(nsCSSColor);
}
// --- nsCSSText -----------------
nsCSSText::nsCSSText(void)
{
MOZ_COUNT_CTOR(nsCSSText);
}
nsCSSText::~nsCSSText(void)
{
MOZ_COUNT_DTOR(nsCSSText);
}
// --- nsCSSCornerSizes -----------------
nsCSSCornerSizes::nsCSSCornerSizes(void)
{
MOZ_COUNT_CTOR(nsCSSCornerSizes);
}
nsCSSCornerSizes::nsCSSCornerSizes(const nsCSSCornerSizes& aCopy)
: mTopLeft(aCopy.mTopLeft),
mTopRight(aCopy.mTopRight),
mBottomRight(aCopy.mBottomRight),
mBottomLeft(aCopy.mBottomLeft)
{
MOZ_COUNT_CTOR(nsCSSCornerSizes);
}
nsCSSCornerSizes::~nsCSSCornerSizes()
{
MOZ_COUNT_DTOR(nsCSSCornerSizes);
}
void
nsCSSCornerSizes::Reset()
{
NS_FOR_CSS_FULL_CORNERS(corner) {
this->GetCorner(corner).Reset();
}
}
PR_STATIC_ASSERT(NS_CORNER_TOP_LEFT == 0 && NS_CORNER_TOP_RIGHT == 1 && \
NS_CORNER_BOTTOM_RIGHT == 2 && NS_CORNER_BOTTOM_LEFT == 3);
/* static */ const nsCSSCornerSizes::corner_type
nsCSSCornerSizes::corners[4] = {
&nsCSSCornerSizes::mTopLeft,
&nsCSSCornerSizes::mTopRight,
&nsCSSCornerSizes::mBottomRight,
&nsCSSCornerSizes::mBottomLeft,
};
// --- nsCSSDisplay -----------------
nsCSSDisplay::nsCSSDisplay(void)
{
MOZ_COUNT_CTOR(nsCSSDisplay);
}
nsCSSDisplay::~nsCSSDisplay(void)
{
MOZ_COUNT_DTOR(nsCSSDisplay);
}
// --- nsCSSMargin -----------------
nsCSSMargin::nsCSSMargin(void)
{
MOZ_COUNT_CTOR(nsCSSMargin);
}
nsCSSMargin::~nsCSSMargin(void)
{
MOZ_COUNT_DTOR(nsCSSMargin);
}
// --- nsCSSPosition -----------------
nsCSSPosition::nsCSSPosition(void)
{
MOZ_COUNT_CTOR(nsCSSPosition);
}
nsCSSPosition::~nsCSSPosition(void)
{
MOZ_COUNT_DTOR(nsCSSPosition);
}
// --- nsCSSList -----------------
nsCSSList::nsCSSList(void)
{
MOZ_COUNT_CTOR(nsCSSList);
}
nsCSSList::~nsCSSList(void)
{
MOZ_COUNT_DTOR(nsCSSList);
}
// --- nsCSSTable -----------------
nsCSSTable::nsCSSTable(void)
{
MOZ_COUNT_CTOR(nsCSSTable);
}
nsCSSTable::~nsCSSTable(void)
{
MOZ_COUNT_DTOR(nsCSSTable);
}
// --- nsCSSBreaks -----------------
nsCSSBreaks::nsCSSBreaks(void)
{
MOZ_COUNT_CTOR(nsCSSBreaks);
}
nsCSSBreaks::~nsCSSBreaks(void)
{
MOZ_COUNT_DTOR(nsCSSBreaks);
}
// --- nsCSSPage -----------------
nsCSSPage::nsCSSPage(void)
{
MOZ_COUNT_CTOR(nsCSSPage);
}
nsCSSPage::~nsCSSPage(void)
{
MOZ_COUNT_DTOR(nsCSSPage);
}
// --- nsCSSContent -----------------
nsCSSContent::nsCSSContent(void)
{
MOZ_COUNT_CTOR(nsCSSContent);
}
nsCSSContent::~nsCSSContent(void)
{
MOZ_COUNT_DTOR(nsCSSContent);
}
// --- nsCSSUserInterface -----------------
nsCSSUserInterface::nsCSSUserInterface(void)
{
MOZ_COUNT_CTOR(nsCSSUserInterface);
}
nsCSSUserInterface::~nsCSSUserInterface(void)
{
MOZ_COUNT_DTOR(nsCSSUserInterface);
}
// --- nsCSSAural -----------------
nsCSSAural::nsCSSAural(void)
{
MOZ_COUNT_CTOR(nsCSSAural);
}
nsCSSAural::~nsCSSAural(void)
{
MOZ_COUNT_DTOR(nsCSSAural);
}
// --- nsCSSXUL -----------------
nsCSSXUL::nsCSSXUL(void)
{
MOZ_COUNT_CTOR(nsCSSXUL);
}
nsCSSXUL::~nsCSSXUL(void)
{
MOZ_COUNT_DTOR(nsCSSXUL);
}
// --- nsCSSColumn -----------------
nsCSSColumn::nsCSSColumn(void)
{
MOZ_COUNT_CTOR(nsCSSColumn);
}
nsCSSColumn::~nsCSSColumn(void)
{
MOZ_COUNT_DTOR(nsCSSColumn);
}
// --- nsCSSSVG -----------------
nsCSSSVG::nsCSSSVG(void)
{
MOZ_COUNT_CTOR(nsCSSSVG);
}
nsCSSSVG::~nsCSSSVG(void)
{
MOZ_COUNT_DTOR(nsCSSSVG);
}

View File

@ -1,449 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Daniel Glazman <glazman@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* temporary (expanded) representation of the property-value pairs
* within a CSS declaration using during parsing and mutation, and
* representation of complex values for CSS properties
*/
#ifndef nsCSSStruct_h___
#define nsCSSStruct_h___
#include "nsCSSValue.h"
#include "nsStyleConsts.h"
struct nsCSSCornerSizes {
nsCSSCornerSizes(void);
nsCSSCornerSizes(const nsCSSCornerSizes& aCopy);
~nsCSSCornerSizes();
// argument is a "full corner" constant from nsStyleConsts.h
nsCSSValue const & GetCorner(PRUint32 aCorner) const {
return this->*corners[aCorner];
}
nsCSSValue & GetCorner(PRUint32 aCorner) {
return this->*corners[aCorner];
}
PRBool operator==(const nsCSSCornerSizes& aOther) const {
NS_FOR_CSS_FULL_CORNERS(corner) {
if (this->GetCorner(corner) != aOther.GetCorner(corner))
return PR_FALSE;
}
return PR_TRUE;
}
PRBool operator!=(const nsCSSCornerSizes& aOther) const {
NS_FOR_CSS_FULL_CORNERS(corner) {
if (this->GetCorner(corner) != aOther.GetCorner(corner))
return PR_TRUE;
}
return PR_FALSE;
}
PRBool HasValue() const {
NS_FOR_CSS_FULL_CORNERS(corner) {
if (this->GetCorner(corner).GetUnit() != eCSSUnit_Null)
return PR_TRUE;
}
return PR_FALSE;
}
void Reset();
nsCSSValue mTopLeft;
nsCSSValue mTopRight;
nsCSSValue mBottomRight;
nsCSSValue mBottomLeft;
protected:
typedef nsCSSValue nsCSSCornerSizes::*corner_type;
static const corner_type corners[4];
};
/****************************************************************************/
struct nsCSSStruct {
// EMPTY on purpose. ABSTRACT with no virtuals (typedef void nsCSSStruct?)
};
// We use the nsCSS* structures for storing css::Declaration's
// *temporary* data during parsing and modification.
struct nsCSSFont : public nsCSSStruct {
nsCSSFont(void);
~nsCSSFont(void);
nsCSSValue mSystemFont;
nsCSSValue mFamily;
nsCSSValue mStyle;
nsCSSValue mVariant;
nsCSSValue mWeight;
nsCSSValue mSize;
nsCSSValue mSizeAdjust; // NEW
nsCSSValue mStretch; // NEW
nsCSSValue mFontFeatureSettings;
nsCSSValue mFontLanguageOverride;
#ifdef MOZ_MATHML
nsCSSValue mScriptLevel; // Integer values mean "relative", Number values mean "absolute"
nsCSSValue mScriptSizeMultiplier;
nsCSSValue mScriptMinSize;
#endif
private:
nsCSSFont(const nsCSSFont& aOther); // NOT IMPLEMENTED
};
struct nsCSSColor : public nsCSSStruct {
nsCSSColor(void);
~nsCSSColor(void);
nsCSSValue mColor;
nsCSSValue mBackColor;
nsCSSValue mBackImage;
nsCSSValue mBackRepeat;
nsCSSValue mBackAttachment;
nsCSSValue mBackPosition;
nsCSSValue mBackSize;
nsCSSValue mBackClip;
nsCSSValue mBackOrigin;
nsCSSValue mBackInlinePolicy;
private:
nsCSSColor(const nsCSSColor& aOther); // NOT IMPLEMENTED
};
struct nsCSSText : public nsCSSStruct {
nsCSSText(void);
~nsCSSText(void);
nsCSSValue mTabSize;
nsCSSValue mWordSpacing;
nsCSSValue mLetterSpacing;
nsCSSValue mVerticalAlign;
nsCSSValue mTextTransform;
nsCSSValue mTextAlign;
nsCSSValue mTextIndent;
nsCSSValue mDecoration;
nsCSSValue mTextShadow; // NEW
nsCSSValue mUnicodeBidi; // NEW
nsCSSValue mLineHeight;
nsCSSValue mWhiteSpace;
nsCSSValue mWordWrap;
private:
nsCSSText(const nsCSSText& aOther); // NOT IMPLEMENTED
};
struct nsCSSDisplay : public nsCSSStruct {
nsCSSDisplay(void);
~nsCSSDisplay(void);
nsCSSValue mDirection;
nsCSSValue mDisplay;
nsCSSValue mBinding;
nsCSSValue mAppearance;
nsCSSValue mPosition;
nsCSSValue mFloat;
nsCSSValue mClear;
nsCSSValue mClip;
nsCSSValue mOverflowX;
nsCSSValue mOverflowY;
nsCSSValue mResize;
nsCSSValue mPointerEvents;
nsCSSValue mVisibility;
nsCSSValue mOpacity;
nsCSSValue mTransform; // List of Arrays containing transform information
nsCSSValue mTransformOrigin;
nsCSSValue mTransitionProperty;
nsCSSValue mTransitionDuration;
nsCSSValue mTransitionTimingFunction;
nsCSSValue mTransitionDelay;
// temp fix for bug 24000
nsCSSValue mBreakBefore;
nsCSSValue mBreakAfter;
// end temp fix
private:
nsCSSDisplay(const nsCSSDisplay& aOther); // NOT IMPLEMENTED
};
struct nsCSSMargin : public nsCSSStruct {
nsCSSMargin(void);
~nsCSSMargin(void);
nsCSSRect mMargin;
nsCSSValue mMarginStart;
nsCSSValue mMarginEnd;
nsCSSValue mMarginLeftLTRSource;
nsCSSValue mMarginLeftRTLSource;
nsCSSValue mMarginRightLTRSource;
nsCSSValue mMarginRightRTLSource;
nsCSSRect mPadding;
nsCSSValue mPaddingStart;
nsCSSValue mPaddingEnd;
nsCSSValue mPaddingLeftLTRSource;
nsCSSValue mPaddingLeftRTLSource;
nsCSSValue mPaddingRightLTRSource;
nsCSSValue mPaddingRightRTLSource;
nsCSSRect mBorderWidth;
nsCSSValue mBorderStartWidth;
nsCSSValue mBorderEndWidth;
nsCSSValue mBorderLeftWidthLTRSource;
nsCSSValue mBorderLeftWidthRTLSource;
nsCSSValue mBorderRightWidthLTRSource;
nsCSSValue mBorderRightWidthRTLSource;
nsCSSRect mBorderColor;
nsCSSValue mBorderStartColor;
nsCSSValue mBorderEndColor;
nsCSSValue mBorderLeftColorLTRSource;
nsCSSValue mBorderLeftColorRTLSource;
nsCSSValue mBorderRightColorLTRSource;
nsCSSValue mBorderRightColorRTLSource;
nsCSSRect mBorderColors;
nsCSSRect mBorderStyle;
nsCSSValue mBorderStartStyle;
nsCSSValue mBorderEndStyle;
nsCSSValue mBorderLeftStyleLTRSource;
nsCSSValue mBorderLeftStyleRTLSource;
nsCSSValue mBorderRightStyleLTRSource;
nsCSSValue mBorderRightStyleRTLSource;
nsCSSCornerSizes mBorderRadius;
nsCSSValue mOutlineWidth;
nsCSSValue mOutlineColor;
nsCSSValue mOutlineStyle;
nsCSSValue mOutlineOffset;
nsCSSCornerSizes mOutlineRadius;
nsCSSValue mFloatEdge; // NEW
nsCSSValue mBorderImage;
nsCSSValue mBoxShadow;
private:
nsCSSMargin(const nsCSSMargin& aOther); // NOT IMPLEMENTED
};
struct nsCSSPosition : public nsCSSStruct {
nsCSSPosition(void);
~nsCSSPosition(void);
nsCSSValue mWidth;
nsCSSValue mMinWidth;
nsCSSValue mMaxWidth;
nsCSSValue mHeight;
nsCSSValue mMinHeight;
nsCSSValue mMaxHeight;
nsCSSValue mBoxSizing; // NEW
nsCSSRect mOffset;
nsCSSValue mZIndex;
private:
nsCSSPosition(const nsCSSPosition& aOther); // NOT IMPLEMENTED
};
struct nsCSSList : public nsCSSStruct {
nsCSSList(void);
~nsCSSList(void);
nsCSSValue mType;
nsCSSValue mImage;
nsCSSValue mPosition;
nsCSSValue mImageRegion;
private:
nsCSSList(const nsCSSList& aOther); // NOT IMPLEMENTED
};
struct nsCSSTable : public nsCSSStruct { // NEW
nsCSSTable(void);
~nsCSSTable(void);
nsCSSValue mBorderCollapse;
nsCSSValue mBorderSpacing;
nsCSSValue mCaptionSide;
nsCSSValue mEmptyCells;
nsCSSValue mLayout;
private:
nsCSSTable(const nsCSSTable& aOther); // NOT IMPLEMENTED
};
struct nsCSSBreaks : public nsCSSStruct { // NEW
nsCSSBreaks(void);
~nsCSSBreaks(void);
nsCSSValue mOrphans;
nsCSSValue mWidows;
nsCSSValue mPage;
// temp fix for bug 24000
//nsCSSValue mPageBreakAfter;
//nsCSSValue mPageBreakBefore;
nsCSSValue mPageBreakInside;
private:
nsCSSBreaks(const nsCSSBreaks& aOther); // NOT IMPLEMENTED
};
struct nsCSSPage : public nsCSSStruct { // NEW
nsCSSPage(void);
~nsCSSPage(void);
nsCSSValue mMarks;
nsCSSValue mSize;
private:
nsCSSPage(const nsCSSPage& aOther); // NOT IMPLEMENTED
};
struct nsCSSContent : public nsCSSStruct {
nsCSSContent(void);
~nsCSSContent(void);
nsCSSValue mContent;
nsCSSValue mCounterIncrement;
nsCSSValue mCounterReset;
nsCSSValue mMarkerOffset;
nsCSSValue mQuotes;
private:
nsCSSContent(const nsCSSContent& aOther); // NOT IMPLEMENTED
};
struct nsCSSUserInterface : public nsCSSStruct { // NEW
nsCSSUserInterface(void);
~nsCSSUserInterface(void);
nsCSSValue mUserInput;
nsCSSValue mUserModify;
nsCSSValue mUserSelect;
nsCSSValue mUserFocus;
nsCSSValue mCursor;
nsCSSValue mForceBrokenImageIcon;
nsCSSValue mIMEMode;
nsCSSValue mWindowShadow;
private:
nsCSSUserInterface(const nsCSSUserInterface& aOther); // NOT IMPLEMENTED
};
struct nsCSSAural : public nsCSSStruct { // NEW
nsCSSAural(void);
~nsCSSAural(void);
nsCSSValue mAzimuth;
nsCSSValue mElevation;
nsCSSValue mCueAfter;
nsCSSValue mCueBefore;
nsCSSValue mPauseAfter;
nsCSSValue mPauseBefore;
nsCSSValue mPitch;
nsCSSValue mPitchRange;
nsCSSValue mRichness;
nsCSSValue mSpeak;
nsCSSValue mSpeakHeader;
nsCSSValue mSpeakNumeral;
nsCSSValue mSpeakPunctuation;
nsCSSValue mSpeechRate;
nsCSSValue mStress;
nsCSSValue mVoiceFamily;
nsCSSValue mVolume;
private:
nsCSSAural(const nsCSSAural& aOther); // NOT IMPLEMENTED
};
struct nsCSSXUL : public nsCSSStruct {
nsCSSXUL(void);
~nsCSSXUL(void);
nsCSSValue mBoxAlign;
nsCSSValue mBoxDirection;
nsCSSValue mBoxFlex;
nsCSSValue mBoxOrient;
nsCSSValue mBoxPack;
nsCSSValue mBoxOrdinal;
nsCSSValue mStackSizing;
private:
nsCSSXUL(const nsCSSXUL& aOther); // NOT IMPLEMENTED
};
struct nsCSSColumn : public nsCSSStruct {
nsCSSColumn(void);
~nsCSSColumn(void);
nsCSSValue mColumnCount;
nsCSSValue mColumnWidth;
nsCSSValue mColumnGap;
nsCSSValue mColumnRuleColor;
nsCSSValue mColumnRuleWidth;
nsCSSValue mColumnRuleStyle;
private:
nsCSSColumn(const nsCSSColumn& aOther); // NOT IMPLEMENTED
};
struct nsCSSSVG : public nsCSSStruct {
nsCSSSVG(void);
~nsCSSSVG(void);
nsCSSValue mClipPath;
nsCSSValue mClipRule;
nsCSSValue mColorInterpolation;
nsCSSValue mColorInterpolationFilters;
nsCSSValue mDominantBaseline;
nsCSSValue mFill;
nsCSSValue mFillOpacity;
nsCSSValue mFillRule;
nsCSSValue mFilter;
nsCSSValue mFloodColor;
nsCSSValue mFloodOpacity;
nsCSSValue mImageRendering;
nsCSSValue mLightingColor;
nsCSSValue mMarkerEnd;
nsCSSValue mMarkerMid;
nsCSSValue mMarkerStart;
nsCSSValue mMask;
nsCSSValue mShapeRendering;
nsCSSValue mStopColor;
nsCSSValue mStopOpacity;
nsCSSValue mStroke;
nsCSSValue mStrokeDasharray;
nsCSSValue mStrokeDashoffset;
nsCSSValue mStrokeLinecap;
nsCSSValue mStrokeLinejoin;
nsCSSValue mStrokeMiterlimit;
nsCSSValue mStrokeOpacity;
nsCSSValue mStrokeWidth;
nsCSSValue mTextAnchor;
nsCSSValue mTextRendering;
private:
nsCSSSVG(const nsCSSSVG& aOther); // NOT IMPLEMENTED
};
#endif /* nsCSSStruct_h___ */

View File

@ -1317,3 +1317,44 @@ nsCSSValueGradient::nsCSSValueGradient(PRBool aIsRadial,
mRadialSize(eCSSUnit_None)
{
}
// --- nsCSSCornerSizes -----------------
nsCSSCornerSizes::nsCSSCornerSizes(void)
{
MOZ_COUNT_CTOR(nsCSSCornerSizes);
}
nsCSSCornerSizes::nsCSSCornerSizes(const nsCSSCornerSizes& aCopy)
: mTopLeft(aCopy.mTopLeft),
mTopRight(aCopy.mTopRight),
mBottomRight(aCopy.mBottomRight),
mBottomLeft(aCopy.mBottomLeft)
{
MOZ_COUNT_CTOR(nsCSSCornerSizes);
}
nsCSSCornerSizes::~nsCSSCornerSizes()
{
MOZ_COUNT_DTOR(nsCSSCornerSizes);
}
void
nsCSSCornerSizes::Reset()
{
NS_FOR_CSS_FULL_CORNERS(corner) {
this->GetCorner(corner).Reset();
}
}
PR_STATIC_ASSERT(NS_CORNER_TOP_LEFT == 0 && NS_CORNER_TOP_RIGHT == 1 && \
NS_CORNER_BOTTOM_RIGHT == 2 && NS_CORNER_BOTTOM_LEFT == 3);
/* static */ const nsCSSCornerSizes::corner_type
nsCSSCornerSizes::corners[4] = {
&nsCSSCornerSizes::mTopLeft,
&nsCSSCornerSizes::mTopRight,
&nsCSSCornerSizes::mBottomRight,
&nsCSSCornerSizes::mBottomLeft,
};

View File

@ -50,6 +50,7 @@
#include "nsStringBuffer.h"
#include "nsTArray.h"
#include "mozilla/mozalloc.h"
#include "nsStyleConsts.h"
class imgIRequest;
class nsIDocument;
@ -973,5 +974,54 @@ private:
nsCSSValueGradient& operator=(const nsCSSValueGradient& aOther);
};
struct nsCSSCornerSizes {
nsCSSCornerSizes(void);
nsCSSCornerSizes(const nsCSSCornerSizes& aCopy);
~nsCSSCornerSizes();
// argument is a "full corner" constant from nsStyleConsts.h
nsCSSValue const & GetCorner(PRUint32 aCorner) const {
return this->*corners[aCorner];
}
nsCSSValue & GetCorner(PRUint32 aCorner) {
return this->*corners[aCorner];
}
PRBool operator==(const nsCSSCornerSizes& aOther) const {
NS_FOR_CSS_FULL_CORNERS(corner) {
if (this->GetCorner(corner) != aOther.GetCorner(corner))
return PR_FALSE;
}
return PR_TRUE;
}
PRBool operator!=(const nsCSSCornerSizes& aOther) const {
NS_FOR_CSS_FULL_CORNERS(corner) {
if (this->GetCorner(corner) != aOther.GetCorner(corner))
return PR_TRUE;
}
return PR_FALSE;
}
PRBool HasValue() const {
NS_FOR_CSS_FULL_CORNERS(corner) {
if (this->GetCorner(corner).GetUnit() != eCSSUnit_Null)
return PR_TRUE;
}
return PR_FALSE;
}
void Reset();
nsCSSValue mTopLeft;
nsCSSValue mTopRight;
nsCSSValue mBottomRight;
nsCSSValue mBottomLeft;
protected:
typedef nsCSSValue nsCSSCornerSizes::*corner_type;
static const corner_type corners[4];
};
#endif /* nsCSSValue_h___ */

View File

@ -338,9 +338,8 @@ nsDOMCSSDeclaration::RemoveProperty(const nsCSSProperty aPropID)
// nsIDOMCSS2Properties
#define CSS_PROP_DOMPROP_PREFIXED(prop_) Moz ## prop_
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
parsevariant_, kwtable_, stylestruct_, stylestructoffset_, \
animtype_) \
#define CSS_PROP(name_, id_, method_, flags_, parsevariant_, kwtable_, \
stylestruct_, stylestructoffset_, animtype_) \
NS_IMETHODIMP \
nsDOMCSSDeclaration::Get##method_(nsAString& aValue) \
{ \
@ -355,16 +354,16 @@ nsDOMCSSDeclaration::RemoveProperty(const nsCSSProperty aPropID)
#define CSS_PROP_LIST_EXCLUDE_INTERNAL
#define CSS_PROP_SHORTHAND(name_, id_, method_, flags_) \
CSS_PROP(name_, id_, method_, flags_, X, X, X, X, X, X, X)
CSS_PROP(name_, id_, method_, flags_, X, X, X, X, X)
#include "nsCSSPropList.h"
// Aliases
CSS_PROP(X, opacity, MozOpacity, X, X, X, X, X, X, X, X)
CSS_PROP(X, outline, MozOutline, X, X, X, X, X, X, X, X)
CSS_PROP(X, outline_color, MozOutlineColor, X, X, X, X, X, X, X, X)
CSS_PROP(X, outline_style, MozOutlineStyle, X, X, X, X, X, X, X, X)
CSS_PROP(X, outline_width, MozOutlineWidth, X, X, X, X, X, X, X, X)
CSS_PROP(X, outline_offset, MozOutlineOffset, X, X, X, X, X, X, X, X)
CSS_PROP(X, opacity, MozOpacity, X, X, X, X, X, X)
CSS_PROP(X, outline, MozOutline, X, X, X, X, X, X)
CSS_PROP(X, outline_color, MozOutlineColor, X, X, X, X, X, X)
CSS_PROP(X, outline_style, MozOutlineStyle, X, X, X, X, X, X)
CSS_PROP(X, outline_width, MozOutlineWidth, X, X, X, X, X, X)
CSS_PROP(X, outline_offset, MozOutlineOffset, X, X, X, X, X, X)
#undef CSS_PROP_SHORTHAND
#undef CSS_PROP_LIST_EXCLUDE_INTERNAL

View File

@ -418,8 +418,8 @@ nsUserFontSet::StartLoad(gfxFontEntry *aFontToLoad,
rv = channel->AsyncOpen(streamLoader, nsnull);
} else {
nsCOMPtr<nsIStreamListener> listener =
new nsCrossSiteListenerProxy(streamLoader, principal, channel,
PR_FALSE, &rv);
new nsCORSListenerProxy(streamLoader, principal, channel,
PR_FALSE, &rv);
if (NS_FAILED(rv)) {
fontLoader->DropChannel(); // explicitly need to break ref cycle
}

View File

@ -45,7 +45,6 @@
#define nsRuleData_h_
#include "nsCSSProps.h"
#include "nsCSSStruct.h"
#include "nsStyleStructFwd.h"
class nsPresContext;
@ -127,9 +126,8 @@ struct nsRuleData
* mSIDs.
*/
#define CSS_PROP_DOMPROP_PREFIXED(prop_) prop_
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
parsevariant_, kwtable_, stylestruct_, stylestructoffset_,\
animtype_) \
#define CSS_PROP(name_, id_, method_, flags_, parsevariant_, kwtable_, \
stylestruct_, stylestructoffset_, animtype_) \
nsCSSValue* ValueFor##method_() { \
NS_ABORT_IF_FALSE(mSIDs & NS_STYLE_INHERIT_BIT(stylestruct_), \
"Calling nsRuleData::ValueFor" #method_ " without " \
@ -145,8 +143,8 @@ struct nsRuleData
const nsCSSValue* ValueFor##method_() const { \
return const_cast<nsRuleData*>(this)->ValueFor##method_(); \
}
#define CSS_PROP_BACKENDONLY(name_, id_, method_, flags_, datastruct_, \
member_, parsevariant_, kwtable_) \
#define CSS_PROP_BACKENDONLY(name_, id_, method_, flags_, parsevariant_, \
kwtable_) \
/* empty; backend-only structs are not in nsRuleData */
#include "nsCSSPropList.h"
#undef CSS_PROP

View File

@ -1414,9 +1414,8 @@ CheckTextCallback(const nsRuleData* aRuleData,
return aResult;
}
#define FLAG_DATA_FOR_PROPERTY(name_, id_, method_, flags_, datastruct_, \
member_, parsevariant_, kwtable_, \
stylestructoffset_, animtype_) \
#define FLAG_DATA_FOR_PROPERTY(name_, id_, method_, flags_, parsevariant_, \
kwtable_, stylestructoffset_, animtype_) \
flags_,
// The order here must match the enums in *CheckCounter in nsCSSProps.cpp.

View File

@ -53,7 +53,6 @@ struct PLDHashTable;
class nsILanguageAtomService;
struct nsRuleData;
class nsIStyleRule;
struct nsCSSStruct;
struct nsCSSValueList;
class nsCSSValue;

View File

@ -49,7 +49,6 @@
#include "nsComputedDOMStyle.h"
#include "nsCSSParser.h"
#include "mozilla/css/Declaration.h"
#include "nsCSSStruct.h"
#include "mozilla/dom/Element.h"
#include "prlog.h"
#include <math.h>

View File

@ -47,7 +47,6 @@
#include "nsCSSKeywords.h"
#include "nsMathUtils.h"
#include "CSSCalc.h"
#include "nsCSSStruct.h"
namespace css = mozilla::css;

View File

@ -49,9 +49,8 @@ struct PropertyInfo {
const PropertyInfo gLonghandProperties[] = {
#define CSS_PROP_DOMPROP_PREFIXED(prop_) Moz ## prop_
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
parsevariant_, kwtable_, stylestruct_, stylestructoffset_, \
animtype_) \
#define CSS_PROP(name_, id_, method_, flags_, parsevariant_, kwtable_, \
stylestruct_, stylestructoffset_, animtype_) \
{ #name_, #method_ },
#include "nsCSSPropList.h"
@ -69,9 +68,8 @@ const PropertyInfo gLonghandProperties[] = {
const char* gLonghandPropertiesWithDOMProp[] = {
#define CSS_PROP_LIST_EXCLUDE_INTERNAL
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
parsevariant_, kwtable_, stylestruct_, stylestructoffset_, \
animtype_) \
#define CSS_PROP(name_, id_, method_, flags_, parsevariant_, kwtable_, \
stylestruct_, stylestructoffset_, animtype_) \
#name_,
#include "nsCSSPropList.h"

View File

@ -74,7 +74,7 @@ class RefTest(object):
# Set preferences for communication between our command line arguments
# and the reftest harness. Preferences that are required for reftest
# to work should instead be set in reftest-cmdline.js .
prefsFile = open(os.path.join(profileDir, "user.js"), "w")
prefsFile = open(os.path.join(profileDir, "user.js"), "a")
prefsFile.write('user_pref("reftest.timeout", %d);\n' % (options.timeout * 1000))
if options.totalChunks != None:
@ -137,8 +137,8 @@ class RefTest(object):
profileDir = None
try:
profileDir = mkdtemp()
self.createReftestProfile(options, profileDir)
self.copyExtraFilesToProfile(options, profileDir)
self.createReftestProfile(options, profileDir)
self.installExtensionsToProfile(options, profileDir)
# browser environment

View File

@ -1,44 +1,43 @@
<body>
<head>
<title>NPAPI Seekable NPStream Test</title>
<script type="text/javascript"
src="/MochiKit/packed.js"></script>
<script type="text/javascript"
src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css"
href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<iframe id="testframe" name="testframe" onload="frameLoaded()"></iframe>
<!--
- Tests a seekable stream. Calls NPN_RequestRead with the specified
- range, and verifies that an NPP_Write call is made with the correct
- parameters, including the buffer data for the byte range. Once all
- calls to NPP_Write have finished, the plugin calls NPN_DestroyStream
- and then displays the entire stream's content in a browser frame via
- NPN_GetURL.
-->
<embed src="neverending.sjs" streammode="seek" closestream
frame="testframe" streamchunksize="1024" range="100,100"
id="embedtest" style="width: 400px; height: 100px;"
type="application/x-test"></embed>
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
var testframe = document.getElementById('testframe');
function frameLoaded() {
var content = testframe.contentDocument.body.innerHTML;
if (!content.length)
return;
ok(true, "We didn't crash");
SimpleTest.finish();
}
</script>
</body>
</html>
<body>
<head>
<title>NPAPI Seekable NPStream Test</title>
<script type="text/javascript"
src="/MochiKit/packed.js"></script>
<script type="text/javascript"
src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css"
href="/tests/SimpleTest/test.css" />
<script type="application/javascript>
SimpleTest.waitForExplicitFinish();
function frameLoaded() {
var testframe = document.getElementById('testframe');
var content = testframe.contentDocument.body.innerHTML;
if (!content.length)
return;
ok(true, "We didn't crash");
SimpleTest.finish();
}
</script>
</head>
<body>
<p id="display"></p>
<iframe id="testframe" name="testframe" onload="frameLoaded()"></iframe>
<!--
- Tests a seekable stream. Calls NPN_RequestRead with the specified
- range, and verifies that an NPP_Write call is made with the correct
- parameters, including the buffer data for the byte range. Once all
- calls to NPP_Write have finished, the plugin calls NPN_DestroyStream
- and then displays the entire stream's content in a browser frame via
- NPN_GetURL.
-->
<embed src="neverending.sjs" streammode="seek" closestream
frame="testframe" streamchunksize="1024" range="100,100"
id="embedtest" style="width: 400px; height: 100px;"
type="application/x-test"></embed>
</body>
</html>

View File

@ -2182,6 +2182,13 @@ nsCryptoRunnable::Run()
JSPrincipals *principals;
JSContext *cx = m_args->m_cx;
JSAutoRequest ar(cx);
JSAutoEnterCompartment ac;
if (!ac.enter(cx, m_args->m_scope)) {
return NS_ERROR_FAILURE;
}
nsresult rv = m_args->m_principals->GetJSPrincipals(cx, &principals);
if (NS_FAILED(rv))
return NS_ERROR_FAILURE;
@ -2189,11 +2196,10 @@ nsCryptoRunnable::Run()
// make sure the right context is on the stack. must not return w/out popping
nsCOMPtr<nsIJSContextStack> stack(do_GetService("@mozilla.org/js/xpc/ContextStack;1"));
if (!stack || NS_FAILED(stack->Push(cx))) {
JSPRINCIPALS_DROP(cx, principals);
return NS_ERROR_FAILURE;
}
JSAutoRequest ar(cx);
jsval retval;
if (JS_EvaluateScriptForPrincipals(cx, m_args->m_scope, principals,
m_args->m_jsCallback,
@ -2204,6 +2210,7 @@ nsCryptoRunnable::Run()
}
stack->Pop(nsnull);
JSPRINCIPALS_DROP(cx, principals);
return rv;
}

View File

@ -4133,12 +4133,12 @@ static void ConvertCocoaKeyEventToNPCocoaEvent(NSEvent* cocoaEvent, NPCocoaEvent
printf("Asked to convert key event of unknown type to Cocoa plugin event!");
}
pluginEvent.data.key.modifierFlags = [cocoaEvent modifierFlags];
pluginEvent.data.key.keyCode = [cocoaEvent keyCode];
// don't try to access character data for flags changed events, it will raise an exception
if (nativeType != NSFlagsChanged) {
pluginEvent.data.key.characters = (NPNSString*)[cocoaEvent characters];
pluginEvent.data.key.charactersIgnoringModifiers = (NPNSString*)[cocoaEvent charactersIgnoringModifiers];
pluginEvent.data.key.isARepeat = [cocoaEvent isARepeat];
pluginEvent.data.key.keyCode = [cocoaEvent keyCode];
}
}

View File

@ -2898,21 +2898,16 @@ nsWindow::MakeFullScreen(PRBool aFullScreen)
UpdateNonClientMargins();
// Prevent window updates during the transition.
DWORD style;
if (nsUXThemeData::CheckForCompositor()) {
style = GetWindowLong(mWnd, GWL_STYLE);
SetWindowLong(mWnd, GWL_STYLE, style & ~WS_VISIBLE);
}
PRBool visible = mIsVisible;
Show(PR_FALSE);
// Will call hide chrome, reposition window. Note this will
// also cache dimensions for restoration, so it should only
// be called once per fullscreen request.
nsresult rv = nsBaseWidget::MakeFullScreen(aFullScreen);
if (nsUXThemeData::CheckForCompositor()) {
style = GetWindowLong(mWnd, GWL_STYLE);
SetWindowLong(mWnd, GWL_STYLE, style | WS_VISIBLE);
if (visible) {
Show(PR_TRUE);
Invalidate(PR_FALSE);
}