зеркало из https://github.com/mozilla/gecko-dev.git
Bug 732209 part 2. Communicate the CORS state of style link loads to the CSS loader. r=sicking
This commit is contained in:
Родитель
af0f91ba81
Коммит
23f0b64faa
|
@ -737,9 +737,15 @@ nsContentSink::ProcessStyleLink(nsIContent* aElement,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_ASSERTION(!aElement ||
|
||||
aElement->NodeType() == nsIDOMNode::PROCESSING_INSTRUCTION_NODE,
|
||||
"We only expect processing instructions here");
|
||||
|
||||
// If this is a fragment parser, we don't want to observe.
|
||||
// We don't support CORS for processing instructions
|
||||
bool isAlternate;
|
||||
rv = mCSSLoader->LoadStyleLink(aElement, url, aTitle, aMedia, aAlternate,
|
||||
CORS_NONE,
|
||||
mRunsToCompletion ? nullptr : this, &isAlternate);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
|
|
@ -276,8 +276,8 @@ nsStyleLinkElement::DoUpdateStyleSheet(nsIDocument *aOldDocument,
|
|||
uri->Clone(getter_AddRefs(clonedURI));
|
||||
NS_ENSURE_TRUE(clonedURI, NS_ERROR_OUT_OF_MEMORY);
|
||||
rv = doc->CSSLoader()->
|
||||
LoadStyleLink(thisContent, clonedURI, title, media, isAlternate, aObserver,
|
||||
&isAlternate);
|
||||
LoadStyleLink(thisContent, clonedURI, title, media, isAlternate,
|
||||
GetCORSMode(), aObserver, &isAlternate);
|
||||
if (NS_FAILED(rv)) {
|
||||
// Don't propagate LoadStyleLink() errors further than this, since some
|
||||
// consumers (e.g. nsXMLContentSink) will completely abort on innocuous
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "nsIStyleSheet.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsTArray.h"
|
||||
#include "mozilla/CORSMode.h"
|
||||
|
||||
#define PREFETCH 0x00000001
|
||||
#define DNS_PREFETCH 0x00000002
|
||||
|
@ -76,6 +77,12 @@ protected:
|
|||
|
||||
nsIStyleSheet* GetStyleSheet() { return mStyleSheet; }
|
||||
|
||||
virtual mozilla::CORSMode GetCORSMode() const
|
||||
{
|
||||
// Default to no CORS
|
||||
return mozilla::CORS_NONE;
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* @param aOldDocument should be non-null only if we're updating because we
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include "nsAsyncDOMEvent.h"
|
||||
|
||||
#include "Link.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
class nsHTMLLinkElement : public nsGenericHTMLElement,
|
||||
|
@ -63,6 +65,10 @@ public:
|
|||
bool aCompileEventHandlers);
|
||||
virtual void UnbindFromTree(bool aDeep = true,
|
||||
bool aNullParent = true);
|
||||
virtual bool ParseAttribute(int32_t aNamespaceID,
|
||||
nsIAtom* aAttribute,
|
||||
const nsAString& aValue,
|
||||
nsAttrValue& aResult);
|
||||
void CreateAndDispatchEvent(nsIDocument* aDoc, const nsAString& aEventName);
|
||||
nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
const nsAString& aValue, bool aNotify)
|
||||
|
@ -94,6 +100,7 @@ protected:
|
|||
nsAString& aType,
|
||||
nsAString& aMedia,
|
||||
bool* aIsAlternate);
|
||||
virtual CORSMode GetCORSMode() const;
|
||||
protected:
|
||||
virtual void GetItemValueText(nsAString& text);
|
||||
virtual void SetItemValueText(const nsAString& text);
|
||||
|
@ -242,6 +249,22 @@ nsHTMLLinkElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
|||
UpdateStyleSheetInternal(oldDoc);
|
||||
}
|
||||
|
||||
bool
|
||||
nsHTMLLinkElement::ParseAttribute(int32_t aNamespaceID,
|
||||
nsIAtom* aAttribute,
|
||||
const nsAString& aValue,
|
||||
nsAttrValue& aResult)
|
||||
{
|
||||
if (aNamespaceID == kNameSpaceID_None &&
|
||||
aAttribute == nsGkAtoms::crossorigin) {
|
||||
ParseCORSValue(aValue, aResult);
|
||||
return true;
|
||||
}
|
||||
|
||||
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
||||
aResult);
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLLinkElement::CreateAndDispatchEvent(nsIDocument* aDoc,
|
||||
const nsAString& aEventName)
|
||||
|
@ -443,6 +466,12 @@ nsHTMLLinkElement::GetStyleSheetInfo(nsAString& aTitle,
|
|||
return;
|
||||
}
|
||||
|
||||
CORSMode
|
||||
nsHTMLLinkElement::GetCORSMode() const
|
||||
{
|
||||
return AttrValueToCORSMode(GetParsedAttr(nsGkAtoms::crossorigin));
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
nsHTMLLinkElement::IntrinsicState() const
|
||||
{
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include "nsStyleLinkElement.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
typedef nsSVGElement nsSVGStyleElementBase;
|
||||
|
||||
class nsSVGStyleElement : public nsSVGStyleElementBase,
|
||||
|
@ -48,6 +50,10 @@ public:
|
|||
bool aNotify);
|
||||
virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
|
||||
bool aNotify);
|
||||
virtual bool ParseAttribute(int32_t aNamespaceID,
|
||||
nsIAtom* aAttribute,
|
||||
const nsAString& aValue,
|
||||
nsAttrValue& aResult);
|
||||
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
|
||||
|
@ -76,6 +82,8 @@ protected:
|
|||
nsAString& aType,
|
||||
nsAString& aMedia,
|
||||
bool* aIsAlternate);
|
||||
virtual CORSMode GetCORSMode() const;
|
||||
|
||||
/**
|
||||
* Common method to call from the various mutation observer methods.
|
||||
* aContent is a content node that's either the one that changed or its
|
||||
|
@ -184,6 +192,22 @@ nsSVGStyleElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
|
|||
return rv;
|
||||
}
|
||||
|
||||
bool
|
||||
nsSVGStyleElement::ParseAttribute(int32_t aNamespaceID,
|
||||
nsIAtom* aAttribute,
|
||||
const nsAString& aValue,
|
||||
nsAttrValue& aResult)
|
||||
{
|
||||
if (aNamespaceID == kNameSpaceID_None &&
|
||||
aAttribute == nsGkAtoms::crossorigin) {
|
||||
ParseCORSValue(aValue, aResult);
|
||||
return true;
|
||||
}
|
||||
|
||||
return nsSVGStyleElementBase::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
||||
aResult);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIMutationObserver methods
|
||||
|
||||
|
@ -317,3 +341,9 @@ nsSVGStyleElement::GetStyleSheetInfo(nsAString& aTitle,
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
CORSMode
|
||||
nsSVGStyleElement::GetCORSMode() const
|
||||
{
|
||||
return AttrValueToCORSMode(GetParsedAttr(nsGkAtoms::crossorigin));
|
||||
}
|
||||
|
|
|
@ -1846,6 +1846,7 @@ Loader::LoadStyleLink(nsIContent* aElement,
|
|||
const nsAString& aTitle,
|
||||
const nsAString& aMedia,
|
||||
bool aHasAlternateRel,
|
||||
CORSMode aCORSMode,
|
||||
nsICSSLoaderObserver* aObserver,
|
||||
bool* aIsAlternate)
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "nsTObserverArray.h"
|
||||
#include "nsURIHashKey.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/CORSMode.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsICSSLoaderObserver;
|
||||
|
@ -168,6 +169,7 @@ public:
|
|||
* @param aMedia the media string for the sheet.
|
||||
* @param aHasAlternateRel whether the rel for this link included
|
||||
* "alternate".
|
||||
* @param aCORSMode the CORS mode for this load.
|
||||
* @param aObserver the observer to notify when the load completes.
|
||||
* May be null.
|
||||
* @param [out] aIsAlternate whether the stylesheet actually ended up beinga
|
||||
|
@ -179,6 +181,7 @@ public:
|
|||
const nsAString& aTitle,
|
||||
const nsAString& aMedia,
|
||||
bool aHasAlternateRel,
|
||||
mozilla::CORSMode aCORSMode,
|
||||
nsICSSLoaderObserver* aObserver,
|
||||
bool* aIsAlternate);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче