mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-19 09:30:44 +00:00
Separate sheet URI and base URI for style attributes and for CSS parsing from DOM APIs. b=258707 r+sr=bzbarsky
This commit is contained in:
parent
3ea4400949
commit
2afd699c4e
@ -2707,7 +2707,8 @@ nsGenericHTMLElement::ParseStyleAttribute(nsIContent* aContent,
|
||||
nsCOMPtr<nsIURI> baseURI = aContent->GetBaseURI();
|
||||
|
||||
nsCOMPtr<nsICSSStyleRule> rule;
|
||||
result = cssParser->ParseStyleAttribute(aValue, baseURI,
|
||||
result = cssParser->ParseStyleAttribute(aValue, doc->GetDocumentURI(),
|
||||
baseURI,
|
||||
getter_AddRefs(rule));
|
||||
if (cssLoader) {
|
||||
cssLoader->RecycleParser(cssParser);
|
||||
@ -3032,7 +3033,7 @@ nsGenericHTMLElement::MapScrollingAttributeInto(const nsMappedAttributes* aAttri
|
||||
&aData->mDisplayData->mOverflowX,
|
||||
&aData->mDisplayData->mOverflowY,
|
||||
};
|
||||
for (PRInt32 i = 0; i < NS_ARRAY_LENGTH(overflowValues); ++i) {
|
||||
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(overflowValues); ++i) {
|
||||
if (overflowValues[i]->GetUnit() == eCSSUnit_Null) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::scrolling);
|
||||
if (value && value->Type() == nsAttrValue::eEnum) {
|
||||
|
@ -90,10 +90,12 @@ public:
|
||||
// languages. aBaseURL is the base url to use for relative links in
|
||||
// the declaration.
|
||||
NS_IMETHOD ParseStyleAttribute(const nsAString& aAttributeValue,
|
||||
nsIURI* aDocURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsICSSStyleRule** aResult) = 0;
|
||||
|
||||
NS_IMETHOD ParseAndAppendDeclaration(const nsAString& aBuffer,
|
||||
nsIURI* aSheetURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsCSSDeclaration* aDeclaration,
|
||||
PRBool aParseOnlyOneDecl,
|
||||
@ -101,11 +103,13 @@ public:
|
||||
PRBool aClearOldDecl) = 0;
|
||||
|
||||
NS_IMETHOD ParseRule(const nsAString& aRule,
|
||||
nsIURI* aSheetURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsISupportsArray** aResult) = 0;
|
||||
|
||||
NS_IMETHOD ParseProperty(const nsCSSProperty aPropID,
|
||||
const nsAString& aPropValue,
|
||||
nsIURI* aSheetURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsCSSDeclaration* aDeclaration,
|
||||
PRBool* aChanged) = 0;
|
||||
|
@ -112,10 +112,12 @@ public:
|
||||
nsICSSStyleSheet*& aResult);
|
||||
|
||||
NS_IMETHOD ParseStyleAttribute(const nsAString& aAttributeValue,
|
||||
nsIURI* aDocURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsICSSStyleRule** aResult);
|
||||
|
||||
NS_IMETHOD ParseAndAppendDeclaration(const nsAString& aBuffer,
|
||||
nsIURI* aSheetURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsCSSDeclaration* aDeclaration,
|
||||
PRBool aParseOnlyOneDecl,
|
||||
@ -123,11 +125,13 @@ public:
|
||||
PRBool aClearOldDecl);
|
||||
|
||||
NS_IMETHOD ParseRule(const nsAString& aRule,
|
||||
nsIURI* aSheetURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsISupportsArray** aResult);
|
||||
|
||||
NS_IMETHOD ParseProperty(const nsCSSProperty aPropID,
|
||||
const nsAString& aPropValue,
|
||||
nsIURI* aSheetURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsCSSDeclaration* aDeclaration,
|
||||
PRBool* aChanged);
|
||||
@ -629,6 +633,7 @@ CSSParserImpl::Parse(nsIUnicharInputStream* aInput,
|
||||
|
||||
NS_IMETHODIMP
|
||||
CSSParserImpl::ParseStyleAttribute(const nsAString& aAttributeValue,
|
||||
nsIURI* aDocURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsICSSStyleRule** aResult)
|
||||
{
|
||||
@ -647,7 +652,7 @@ CSSParserImpl::ParseStyleAttribute(const nsAString& aAttributeValue,
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = InitScanner(input, aBaseURL, 1, aBaseURL); // XXX line number & URLs
|
||||
rv = InitScanner(input, aDocURL, 0, aBaseURL); // XXX line number
|
||||
NS_RELEASE(input);
|
||||
if (! NS_SUCCEEDED(rv)) {
|
||||
return rv;
|
||||
@ -692,6 +697,7 @@ CSSParserImpl::ParseStyleAttribute(const nsAString& aAttributeValue,
|
||||
|
||||
NS_IMETHODIMP
|
||||
CSSParserImpl::ParseAndAppendDeclaration(const nsAString& aBuffer,
|
||||
nsIURI* aSheetURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsCSSDeclaration* aDeclaration,
|
||||
PRBool aParseOnlyOneDecl,
|
||||
@ -712,7 +718,7 @@ CSSParserImpl::ParseAndAppendDeclaration(const nsAString& aBuffer,
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = InitScanner(input, aBaseURL, 1, aBaseURL); // XXX line number & URLs
|
||||
rv = InitScanner(input, aSheetURL, 0, aBaseURL);
|
||||
NS_RELEASE(input);
|
||||
if (! NS_SUCCEEDED(rv)) {
|
||||
return rv;
|
||||
@ -753,6 +759,7 @@ CSSParserImpl::ParseAndAppendDeclaration(const nsAString& aBuffer,
|
||||
|
||||
NS_IMETHODIMP
|
||||
CSSParserImpl::ParseRule(const nsAString& aRule,
|
||||
nsIURI* aSheetURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsISupportsArray** aResult)
|
||||
{
|
||||
@ -770,7 +777,7 @@ CSSParserImpl::ParseRule(const nsAString& aRule,
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = InitScanner(input, aBaseURL, 1, aBaseURL); // XXX line number & URLs
|
||||
rv = InitScanner(input, aSheetURL, 0, aBaseURL);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
@ -809,6 +816,7 @@ CSSParserImpl::ParseRule(const nsAString& aRule,
|
||||
NS_IMETHODIMP
|
||||
CSSParserImpl::ParseProperty(const nsCSSProperty aPropID,
|
||||
const nsAString& aPropValue,
|
||||
nsIURI* aSheetURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsCSSDeclaration* aDeclaration,
|
||||
PRBool* aChanged)
|
||||
@ -829,7 +837,7 @@ CSSParserImpl::ParseProperty(const nsCSSProperty aPropID,
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = InitScanner(input, aBaseURL, 1, aBaseURL); // XXX line number & URLs
|
||||
rv = InitScanner(input, aSheetURL, 0, aBaseURL);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -304,7 +304,9 @@ PRInt32 nsCSSScanner::Read(nsresult& aErrorCode)
|
||||
}
|
||||
rv = PRInt32(mBuffer[mOffset++]);
|
||||
if (((rv == '\n') && (mLastRead != '\r')) || (rv == '\r')) {
|
||||
mLineNumber++;
|
||||
// 0 is a magical line number meaning that we don't know (i.e., script)
|
||||
if (mLineNumber != 0)
|
||||
++mLineNumber;
|
||||
#ifdef CSS_REPORT_PARSE_ERRORS
|
||||
mColNumber = 0;
|
||||
#endif
|
||||
|
@ -124,6 +124,8 @@ class nsCSSScanner {
|
||||
~nsCSSScanner();
|
||||
|
||||
// Init the scanner.
|
||||
// |aLineNumber == 1| is the beginning of a file, use |aLineNumber == 0|
|
||||
// when the line number is unknown.
|
||||
void Init(nsIUnicharInputStream* aInput, nsIURI* aURI, PRUint32 aLineNumber);
|
||||
|
||||
#ifdef CSS_REPORT_PARSE_ERRORS
|
||||
|
@ -901,7 +901,8 @@ public:
|
||||
virtual void DropReference(void);
|
||||
virtual nsresult GetCSSDeclaration(nsCSSDeclaration **aDecl,
|
||||
PRBool aAllocate);
|
||||
virtual nsresult GetCSSParsingEnvironment(nsIURI** aBaseURI,
|
||||
virtual nsresult GetCSSParsingEnvironment(nsIURI** aSheetURI,
|
||||
nsIURI** aBaseURI,
|
||||
nsICSSLoader** aCSSLoader,
|
||||
nsICSSParser** aCSSParser);
|
||||
virtual nsresult DeclarationChanged();
|
||||
@ -1003,11 +1004,13 @@ DOMCSSDeclarationImpl::GetCSSDeclaration(nsCSSDeclaration **aDecl,
|
||||
* being initialized.
|
||||
*/
|
||||
nsresult
|
||||
DOMCSSDeclarationImpl::GetCSSParsingEnvironment(nsIURI** aBaseURI,
|
||||
DOMCSSDeclarationImpl::GetCSSParsingEnvironment(nsIURI** aSheetURI,
|
||||
nsIURI** aBaseURI,
|
||||
nsICSSLoader** aCSSLoader,
|
||||
nsICSSParser** aCSSParser)
|
||||
{
|
||||
// null out the out params since some of them may not get initialized below
|
||||
*aSheetURI = nsnull;
|
||||
*aBaseURI = nsnull;
|
||||
*aCSSLoader = nsnull;
|
||||
*aCSSParser = nsnull;
|
||||
@ -1016,6 +1019,7 @@ DOMCSSDeclarationImpl::GetCSSParsingEnvironment(nsIURI** aBaseURI,
|
||||
if (mRule) {
|
||||
mRule->GetStyleSheet(*getter_AddRefs(sheet));
|
||||
if (sheet) {
|
||||
sheet->GetSheetURI(aSheetURI);
|
||||
sheet->GetBaseURI(aBaseURI);
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
sheet->GetOwningDocument(*getter_AddRefs(document));
|
||||
|
@ -2411,7 +2411,8 @@ nsCSSStyleSheet::InsertRule(const nsAString& aRule,
|
||||
mozAutoDocUpdate updateBatch(mDocument, UPDATE_STYLE, PR_TRUE);
|
||||
|
||||
nsCOMPtr<nsISupportsArray> rules;
|
||||
result = css->ParseRule(aRule, mInner->mBaseURI, getter_AddRefs(rules));
|
||||
result = css->ParseRule(aRule, mInner->mSheetURI, mInner->mBaseURI,
|
||||
getter_AddRefs(rules));
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
@ -2655,7 +2656,8 @@ nsCSSStyleSheet::InsertRuleIntoGroup(const nsAString & aRule, nsICSSGroupRule* a
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
nsCOMPtr<nsISupportsArray> rules;
|
||||
result = css->ParseRule(aRule, mInner->mBaseURI, getter_AddRefs(rules));
|
||||
result = css->ParseRule(aRule, mInner->mSheetURI, mInner->mBaseURI,
|
||||
getter_AddRefs(rules));
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
PRUint32 rulecount = 0;
|
||||
|
@ -137,12 +137,14 @@ nsDOMCSSAttributeDeclaration::GetCSSDeclaration(nsCSSDeclaration **aDecl,
|
||||
* being initialized.
|
||||
*/
|
||||
nsresult
|
||||
nsDOMCSSAttributeDeclaration::GetCSSParsingEnvironment(nsIURI** aBaseURI,
|
||||
nsDOMCSSAttributeDeclaration::GetCSSParsingEnvironment(nsIURI** aSheetURI,
|
||||
nsIURI** aBaseURI,
|
||||
nsICSSLoader** aCSSLoader,
|
||||
nsICSSParser** aCSSParser)
|
||||
{
|
||||
NS_ASSERTION(mContent, "Something is severely broken -- there should be an nsIContent here!");
|
||||
// null out the out params since some of them may not get initialized below
|
||||
*aSheetURI = nsnull;
|
||||
*aBaseURI = nsnull;
|
||||
*aCSSLoader = nsnull;
|
||||
*aCSSParser = nsnull;
|
||||
@ -152,7 +154,8 @@ nsDOMCSSAttributeDeclaration::GetCSSParsingEnvironment(nsIURI** aBaseURI,
|
||||
// XXXbz GetOwnerDocument
|
||||
nsIDocument* doc = nsContentUtils::GetDocument(nodeInfo);
|
||||
|
||||
nsCOMPtr<nsIURI> base = mContent->GetBaseURI();
|
||||
nsCOMPtr<nsIURI> baseURI = mContent->GetBaseURI();
|
||||
nsCOMPtr<nsIURI> sheetURI = doc->GetDocumentURI();
|
||||
|
||||
if (doc) {
|
||||
NS_IF_ADDREF(*aCSSLoader = doc->GetCSSLoader());
|
||||
@ -176,7 +179,8 @@ nsDOMCSSAttributeDeclaration::GetCSSParsingEnvironment(nsIURI** aBaseURI,
|
||||
(*aCSSParser)->SetCaseSensitive(!mContent->IsContentOfType(nsIContent::eHTML) ||
|
||||
nodeInfo->NamespaceEquals(kNameSpaceID_XHTML));
|
||||
|
||||
base.swap(*aBaseURI);
|
||||
baseURI.swap(*aBaseURI);
|
||||
sheetURI.swap(*aSheetURI);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -63,7 +63,8 @@ public:
|
||||
// is owned by our current style rule.
|
||||
virtual nsresult GetCSSDeclaration(nsCSSDeclaration **aDecl,
|
||||
PRBool aAllocate);
|
||||
virtual nsresult GetCSSParsingEnvironment(nsIURI** aBaseURI,
|
||||
virtual nsresult GetCSSParsingEnvironment(nsIURI** aSheetURI,
|
||||
nsIURI** aBaseURI,
|
||||
nsICSSLoader** aCSSLoader,
|
||||
nsICSSParser** aCSSParser);
|
||||
NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent);
|
||||
|
@ -249,9 +249,10 @@ nsDOMCSSDeclaration::ParsePropertyValue(const nsCSSProperty aPropID,
|
||||
|
||||
nsCOMPtr<nsICSSLoader> cssLoader;
|
||||
nsCOMPtr<nsICSSParser> cssParser;
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
nsCOMPtr<nsIURI> baseURI, sheetURI;
|
||||
|
||||
result = GetCSSParsingEnvironment(getter_AddRefs(baseURI),
|
||||
result = GetCSSParsingEnvironment(getter_AddRefs(sheetURI),
|
||||
getter_AddRefs(baseURI),
|
||||
getter_AddRefs(cssLoader),
|
||||
getter_AddRefs(cssParser));
|
||||
if (NS_FAILED(result)) {
|
||||
@ -259,8 +260,8 @@ nsDOMCSSDeclaration::ParsePropertyValue(const nsCSSProperty aPropID,
|
||||
}
|
||||
|
||||
PRBool changed;
|
||||
result = cssParser->ParseProperty(aPropID, aPropValue, baseURI, decl,
|
||||
&changed);
|
||||
result = cssParser->ParseProperty(aPropID, aPropValue, sheetURI, baseURI,
|
||||
decl, &changed);
|
||||
if (NS_SUCCEEDED(result) && changed) {
|
||||
result = DeclarationChanged();
|
||||
}
|
||||
@ -285,9 +286,10 @@ nsDOMCSSDeclaration::ParseDeclaration(const nsAString& aDecl,
|
||||
|
||||
nsCOMPtr<nsICSSLoader> cssLoader;
|
||||
nsCOMPtr<nsICSSParser> cssParser;
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
nsCOMPtr<nsIURI> baseURI, sheetURI;
|
||||
|
||||
result = GetCSSParsingEnvironment(getter_AddRefs(baseURI),
|
||||
result = GetCSSParsingEnvironment(getter_AddRefs(sheetURI),
|
||||
getter_AddRefs(baseURI),
|
||||
getter_AddRefs(cssLoader),
|
||||
getter_AddRefs(cssParser));
|
||||
|
||||
@ -296,7 +298,7 @@ nsDOMCSSDeclaration::ParseDeclaration(const nsAString& aDecl,
|
||||
}
|
||||
|
||||
PRBool changed;
|
||||
result = cssParser->ParseAndAppendDeclaration(aDecl, baseURI, decl,
|
||||
result = cssParser->ParseAndAppendDeclaration(aDecl, sheetURI, baseURI, decl,
|
||||
aParseOnlyOneDecl,
|
||||
&changed,
|
||||
aClearOldDecl);
|
||||
|
@ -100,7 +100,8 @@ protected:
|
||||
|
||||
// This will only fail if it can't get a parser. This means it can
|
||||
// return NS_OK without aURI or aCSSLoader being initialized.
|
||||
virtual nsresult GetCSSParsingEnvironment(nsIURI** aBaseURI,
|
||||
virtual nsresult GetCSSParsingEnvironment(nsIURI** aSheetURI,
|
||||
nsIURI** aBaseURI,
|
||||
nsICSSLoader** aCSSLoader,
|
||||
nsICSSParser** aCSSParser) = 0;
|
||||
|
||||
|
@ -735,6 +735,7 @@ nsSVGElement::UpdateContentStyleRule()
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
||||
nsIURI *docURI = GetOwnerDoc()->GetDocumentURI();
|
||||
nsCOMPtr<nsICSSParser> parser;
|
||||
NS_NewCSSParser(getter_AddRefs(parser));
|
||||
if (!parser)
|
||||
@ -763,7 +764,8 @@ nsSVGElement::UpdateContentStyleRule()
|
||||
mAttrsAndChildren.AttrAt(i)->ToString(value);
|
||||
|
||||
PRBool changed;
|
||||
parser->ParseProperty(nsCSSProps::LookupProperty(name), value, baseURI,
|
||||
parser->ParseProperty(nsCSSProps::LookupProperty(name), value,
|
||||
docURI, baseURI,
|
||||
declaration, &changed);
|
||||
}
|
||||
|
||||
|
@ -4360,7 +4360,8 @@ nsXULPrototypeElement::SetAttrAt(PRUint32 aPos, const nsAString& aValue,
|
||||
nsICSSParser* parser = GetCSSParser();
|
||||
NS_ENSURE_TRUE(parser, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
parser->ParseStyleAttribute(aValue, aDocumentURI,
|
||||
// XXX Get correct Base URI (need GetBaseURI on *prototype* element)
|
||||
parser->ParseStyleAttribute(aValue, aDocumentURI, aDocumentURI,
|
||||
getter_AddRefs(rule));
|
||||
if (rule) {
|
||||
mAttributes[aPos].mValue.SetTo(rule);
|
||||
|
@ -112,10 +112,12 @@ public:
|
||||
nsICSSStyleSheet*& aResult);
|
||||
|
||||
NS_IMETHOD ParseStyleAttribute(const nsAString& aAttributeValue,
|
||||
nsIURI* aDocURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsICSSStyleRule** aResult);
|
||||
|
||||
NS_IMETHOD ParseAndAppendDeclaration(const nsAString& aBuffer,
|
||||
nsIURI* aSheetURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsCSSDeclaration* aDeclaration,
|
||||
PRBool aParseOnlyOneDecl,
|
||||
@ -123,11 +125,13 @@ public:
|
||||
PRBool aClearOldDecl);
|
||||
|
||||
NS_IMETHOD ParseRule(const nsAString& aRule,
|
||||
nsIURI* aSheetURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsISupportsArray** aResult);
|
||||
|
||||
NS_IMETHOD ParseProperty(const nsCSSProperty aPropID,
|
||||
const nsAString& aPropValue,
|
||||
nsIURI* aSheetURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsCSSDeclaration* aDeclaration,
|
||||
PRBool* aChanged);
|
||||
@ -629,6 +633,7 @@ CSSParserImpl::Parse(nsIUnicharInputStream* aInput,
|
||||
|
||||
NS_IMETHODIMP
|
||||
CSSParserImpl::ParseStyleAttribute(const nsAString& aAttributeValue,
|
||||
nsIURI* aDocURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsICSSStyleRule** aResult)
|
||||
{
|
||||
@ -647,7 +652,7 @@ CSSParserImpl::ParseStyleAttribute(const nsAString& aAttributeValue,
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = InitScanner(input, aBaseURL, 1, aBaseURL); // XXX line number & URLs
|
||||
rv = InitScanner(input, aDocURL, 0, aBaseURL); // XXX line number
|
||||
NS_RELEASE(input);
|
||||
if (! NS_SUCCEEDED(rv)) {
|
||||
return rv;
|
||||
@ -692,6 +697,7 @@ CSSParserImpl::ParseStyleAttribute(const nsAString& aAttributeValue,
|
||||
|
||||
NS_IMETHODIMP
|
||||
CSSParserImpl::ParseAndAppendDeclaration(const nsAString& aBuffer,
|
||||
nsIURI* aSheetURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsCSSDeclaration* aDeclaration,
|
||||
PRBool aParseOnlyOneDecl,
|
||||
@ -712,7 +718,7 @@ CSSParserImpl::ParseAndAppendDeclaration(const nsAString& aBuffer,
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = InitScanner(input, aBaseURL, 1, aBaseURL); // XXX line number & URLs
|
||||
rv = InitScanner(input, aSheetURL, 0, aBaseURL);
|
||||
NS_RELEASE(input);
|
||||
if (! NS_SUCCEEDED(rv)) {
|
||||
return rv;
|
||||
@ -753,6 +759,7 @@ CSSParserImpl::ParseAndAppendDeclaration(const nsAString& aBuffer,
|
||||
|
||||
NS_IMETHODIMP
|
||||
CSSParserImpl::ParseRule(const nsAString& aRule,
|
||||
nsIURI* aSheetURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsISupportsArray** aResult)
|
||||
{
|
||||
@ -770,7 +777,7 @@ CSSParserImpl::ParseRule(const nsAString& aRule,
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = InitScanner(input, aBaseURL, 1, aBaseURL); // XXX line number & URLs
|
||||
rv = InitScanner(input, aSheetURL, 0, aBaseURL);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
@ -809,6 +816,7 @@ CSSParserImpl::ParseRule(const nsAString& aRule,
|
||||
NS_IMETHODIMP
|
||||
CSSParserImpl::ParseProperty(const nsCSSProperty aPropID,
|
||||
const nsAString& aPropValue,
|
||||
nsIURI* aSheetURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsCSSDeclaration* aDeclaration,
|
||||
PRBool* aChanged)
|
||||
@ -829,7 +837,7 @@ CSSParserImpl::ParseProperty(const nsCSSProperty aPropID,
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = InitScanner(input, aBaseURL, 1, aBaseURL); // XXX line number & URLs
|
||||
rv = InitScanner(input, aSheetURL, 0, aBaseURL);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -304,7 +304,9 @@ PRInt32 nsCSSScanner::Read(nsresult& aErrorCode)
|
||||
}
|
||||
rv = PRInt32(mBuffer[mOffset++]);
|
||||
if (((rv == '\n') && (mLastRead != '\r')) || (rv == '\r')) {
|
||||
mLineNumber++;
|
||||
// 0 is a magical line number meaning that we don't know (i.e., script)
|
||||
if (mLineNumber != 0)
|
||||
++mLineNumber;
|
||||
#ifdef CSS_REPORT_PARSE_ERRORS
|
||||
mColNumber = 0;
|
||||
#endif
|
||||
|
@ -124,6 +124,8 @@ class nsCSSScanner {
|
||||
~nsCSSScanner();
|
||||
|
||||
// Init the scanner.
|
||||
// |aLineNumber == 1| is the beginning of a file, use |aLineNumber == 0|
|
||||
// when the line number is unknown.
|
||||
void Init(nsIUnicharInputStream* aInput, nsIURI* aURI, PRUint32 aLineNumber);
|
||||
|
||||
#ifdef CSS_REPORT_PARSE_ERRORS
|
||||
|
@ -901,7 +901,8 @@ public:
|
||||
virtual void DropReference(void);
|
||||
virtual nsresult GetCSSDeclaration(nsCSSDeclaration **aDecl,
|
||||
PRBool aAllocate);
|
||||
virtual nsresult GetCSSParsingEnvironment(nsIURI** aBaseURI,
|
||||
virtual nsresult GetCSSParsingEnvironment(nsIURI** aSheetURI,
|
||||
nsIURI** aBaseURI,
|
||||
nsICSSLoader** aCSSLoader,
|
||||
nsICSSParser** aCSSParser);
|
||||
virtual nsresult DeclarationChanged();
|
||||
@ -1003,11 +1004,13 @@ DOMCSSDeclarationImpl::GetCSSDeclaration(nsCSSDeclaration **aDecl,
|
||||
* being initialized.
|
||||
*/
|
||||
nsresult
|
||||
DOMCSSDeclarationImpl::GetCSSParsingEnvironment(nsIURI** aBaseURI,
|
||||
DOMCSSDeclarationImpl::GetCSSParsingEnvironment(nsIURI** aSheetURI,
|
||||
nsIURI** aBaseURI,
|
||||
nsICSSLoader** aCSSLoader,
|
||||
nsICSSParser** aCSSParser)
|
||||
{
|
||||
// null out the out params since some of them may not get initialized below
|
||||
*aSheetURI = nsnull;
|
||||
*aBaseURI = nsnull;
|
||||
*aCSSLoader = nsnull;
|
||||
*aCSSParser = nsnull;
|
||||
@ -1016,6 +1019,7 @@ DOMCSSDeclarationImpl::GetCSSParsingEnvironment(nsIURI** aBaseURI,
|
||||
if (mRule) {
|
||||
mRule->GetStyleSheet(*getter_AddRefs(sheet));
|
||||
if (sheet) {
|
||||
sheet->GetSheetURI(aSheetURI);
|
||||
sheet->GetBaseURI(aBaseURI);
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
sheet->GetOwningDocument(*getter_AddRefs(document));
|
||||
|
@ -2411,7 +2411,8 @@ nsCSSStyleSheet::InsertRule(const nsAString& aRule,
|
||||
mozAutoDocUpdate updateBatch(mDocument, UPDATE_STYLE, PR_TRUE);
|
||||
|
||||
nsCOMPtr<nsISupportsArray> rules;
|
||||
result = css->ParseRule(aRule, mInner->mBaseURI, getter_AddRefs(rules));
|
||||
result = css->ParseRule(aRule, mInner->mSheetURI, mInner->mBaseURI,
|
||||
getter_AddRefs(rules));
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
@ -2655,7 +2656,8 @@ nsCSSStyleSheet::InsertRuleIntoGroup(const nsAString & aRule, nsICSSGroupRule* a
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
nsCOMPtr<nsISupportsArray> rules;
|
||||
result = css->ParseRule(aRule, mInner->mBaseURI, getter_AddRefs(rules));
|
||||
result = css->ParseRule(aRule, mInner->mSheetURI, mInner->mBaseURI,
|
||||
getter_AddRefs(rules));
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
PRUint32 rulecount = 0;
|
||||
|
@ -137,12 +137,14 @@ nsDOMCSSAttributeDeclaration::GetCSSDeclaration(nsCSSDeclaration **aDecl,
|
||||
* being initialized.
|
||||
*/
|
||||
nsresult
|
||||
nsDOMCSSAttributeDeclaration::GetCSSParsingEnvironment(nsIURI** aBaseURI,
|
||||
nsDOMCSSAttributeDeclaration::GetCSSParsingEnvironment(nsIURI** aSheetURI,
|
||||
nsIURI** aBaseURI,
|
||||
nsICSSLoader** aCSSLoader,
|
||||
nsICSSParser** aCSSParser)
|
||||
{
|
||||
NS_ASSERTION(mContent, "Something is severely broken -- there should be an nsIContent here!");
|
||||
// null out the out params since some of them may not get initialized below
|
||||
*aSheetURI = nsnull;
|
||||
*aBaseURI = nsnull;
|
||||
*aCSSLoader = nsnull;
|
||||
*aCSSParser = nsnull;
|
||||
@ -152,7 +154,8 @@ nsDOMCSSAttributeDeclaration::GetCSSParsingEnvironment(nsIURI** aBaseURI,
|
||||
// XXXbz GetOwnerDocument
|
||||
nsIDocument* doc = nsContentUtils::GetDocument(nodeInfo);
|
||||
|
||||
nsCOMPtr<nsIURI> base = mContent->GetBaseURI();
|
||||
nsCOMPtr<nsIURI> baseURI = mContent->GetBaseURI();
|
||||
nsCOMPtr<nsIURI> sheetURI = doc->GetDocumentURI();
|
||||
|
||||
if (doc) {
|
||||
NS_IF_ADDREF(*aCSSLoader = doc->GetCSSLoader());
|
||||
@ -176,7 +179,8 @@ nsDOMCSSAttributeDeclaration::GetCSSParsingEnvironment(nsIURI** aBaseURI,
|
||||
(*aCSSParser)->SetCaseSensitive(!mContent->IsContentOfType(nsIContent::eHTML) ||
|
||||
nodeInfo->NamespaceEquals(kNameSpaceID_XHTML));
|
||||
|
||||
base.swap(*aBaseURI);
|
||||
baseURI.swap(*aBaseURI);
|
||||
sheetURI.swap(*aSheetURI);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -63,7 +63,8 @@ public:
|
||||
// is owned by our current style rule.
|
||||
virtual nsresult GetCSSDeclaration(nsCSSDeclaration **aDecl,
|
||||
PRBool aAllocate);
|
||||
virtual nsresult GetCSSParsingEnvironment(nsIURI** aBaseURI,
|
||||
virtual nsresult GetCSSParsingEnvironment(nsIURI** aSheetURI,
|
||||
nsIURI** aBaseURI,
|
||||
nsICSSLoader** aCSSLoader,
|
||||
nsICSSParser** aCSSParser);
|
||||
NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent);
|
||||
|
@ -249,9 +249,10 @@ nsDOMCSSDeclaration::ParsePropertyValue(const nsCSSProperty aPropID,
|
||||
|
||||
nsCOMPtr<nsICSSLoader> cssLoader;
|
||||
nsCOMPtr<nsICSSParser> cssParser;
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
nsCOMPtr<nsIURI> baseURI, sheetURI;
|
||||
|
||||
result = GetCSSParsingEnvironment(getter_AddRefs(baseURI),
|
||||
result = GetCSSParsingEnvironment(getter_AddRefs(sheetURI),
|
||||
getter_AddRefs(baseURI),
|
||||
getter_AddRefs(cssLoader),
|
||||
getter_AddRefs(cssParser));
|
||||
if (NS_FAILED(result)) {
|
||||
@ -259,8 +260,8 @@ nsDOMCSSDeclaration::ParsePropertyValue(const nsCSSProperty aPropID,
|
||||
}
|
||||
|
||||
PRBool changed;
|
||||
result = cssParser->ParseProperty(aPropID, aPropValue, baseURI, decl,
|
||||
&changed);
|
||||
result = cssParser->ParseProperty(aPropID, aPropValue, sheetURI, baseURI,
|
||||
decl, &changed);
|
||||
if (NS_SUCCEEDED(result) && changed) {
|
||||
result = DeclarationChanged();
|
||||
}
|
||||
@ -285,9 +286,10 @@ nsDOMCSSDeclaration::ParseDeclaration(const nsAString& aDecl,
|
||||
|
||||
nsCOMPtr<nsICSSLoader> cssLoader;
|
||||
nsCOMPtr<nsICSSParser> cssParser;
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
nsCOMPtr<nsIURI> baseURI, sheetURI;
|
||||
|
||||
result = GetCSSParsingEnvironment(getter_AddRefs(baseURI),
|
||||
result = GetCSSParsingEnvironment(getter_AddRefs(sheetURI),
|
||||
getter_AddRefs(baseURI),
|
||||
getter_AddRefs(cssLoader),
|
||||
getter_AddRefs(cssParser));
|
||||
|
||||
@ -296,7 +298,7 @@ nsDOMCSSDeclaration::ParseDeclaration(const nsAString& aDecl,
|
||||
}
|
||||
|
||||
PRBool changed;
|
||||
result = cssParser->ParseAndAppendDeclaration(aDecl, baseURI, decl,
|
||||
result = cssParser->ParseAndAppendDeclaration(aDecl, sheetURI, baseURI, decl,
|
||||
aParseOnlyOneDecl,
|
||||
&changed,
|
||||
aClearOldDecl);
|
||||
|
@ -100,7 +100,8 @@ protected:
|
||||
|
||||
// This will only fail if it can't get a parser. This means it can
|
||||
// return NS_OK without aURI or aCSSLoader being initialized.
|
||||
virtual nsresult GetCSSParsingEnvironment(nsIURI** aBaseURI,
|
||||
virtual nsresult GetCSSParsingEnvironment(nsIURI** aSheetURI,
|
||||
nsIURI** aBaseURI,
|
||||
nsICSSLoader** aCSSLoader,
|
||||
nsICSSParser** aCSSParser) = 0;
|
||||
|
||||
|
@ -90,10 +90,12 @@ public:
|
||||
// languages. aBaseURL is the base url to use for relative links in
|
||||
// the declaration.
|
||||
NS_IMETHOD ParseStyleAttribute(const nsAString& aAttributeValue,
|
||||
nsIURI* aDocURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsICSSStyleRule** aResult) = 0;
|
||||
|
||||
NS_IMETHOD ParseAndAppendDeclaration(const nsAString& aBuffer,
|
||||
nsIURI* aSheetURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsCSSDeclaration* aDeclaration,
|
||||
PRBool aParseOnlyOneDecl,
|
||||
@ -101,11 +103,13 @@ public:
|
||||
PRBool aClearOldDecl) = 0;
|
||||
|
||||
NS_IMETHOD ParseRule(const nsAString& aRule,
|
||||
nsIURI* aSheetURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsISupportsArray** aResult) = 0;
|
||||
|
||||
NS_IMETHOD ParseProperty(const nsCSSProperty aPropID,
|
||||
const nsAString& aPropValue,
|
||||
nsIURI* aSheetURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsCSSDeclaration* aDeclaration,
|
||||
PRBool* aChanged) = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user