Share implementation of GetCSSParsingEnvironment so we can use it for both style rules' declarations and keyframe rules' declarations. (Bug 435442, patch 2) r=bzbarsky

This commit is contained in:
L. David Baron 2011-04-11 23:18:42 -07:00
Родитель fa6f166e61
Коммит ae52e328b6
3 изменённых файлов: 53 добавлений и 31 удалений

Просмотреть файл

@ -1068,37 +1068,8 @@ DOMCSSDeclarationImpl::GetCSSParsingEnvironment(nsIURI** aSheetURI,
nsIPrincipal** aSheetPrincipal,
css::Loader** aCSSLoader)
{
// null out the out params since some of them may not get initialized below
*aSheetURI = nsnull;
*aBaseURI = nsnull;
*aSheetPrincipal = nsnull;
*aCSSLoader = nsnull;
if (mRule) {
nsIStyleSheet* sheet = mRule->GetStyleSheet();
if (sheet) {
NS_IF_ADDREF(*aSheetURI = sheet->GetSheetURI());
NS_IF_ADDREF(*aBaseURI = sheet->GetBaseURI());
nsRefPtr<nsCSSStyleSheet> cssSheet(do_QueryObject(sheet));
if (cssSheet) {
NS_ADDREF(*aSheetPrincipal = cssSheet->Principal());
}
nsIDocument* document = sheet->GetOwningDocument();
if (document) {
NS_ADDREF(*aCSSLoader = document->CSSLoader());
}
}
}
nsresult result = NS_OK;
if (!*aSheetPrincipal) {
result = CallCreateInstance("@mozilla.org/nullprincipal;1",
aSheetPrincipal);
}
return result;
return GetCSSParsingEnvironmentForRule(mRule, aSheetURI, aBaseURI,
aSheetPrincipal, aCSSLoader);
}
NS_IMETHODIMP

Просмотреть файл

@ -42,7 +42,9 @@
#include "nsIDOMCSSRule.h"
#include "nsCSSParser.h"
#include "mozilla/css/Loader.h"
#include "nsCSSStyleSheet.h"
#include "nsIStyleRule.h"
#include "nsICSSRule.h"
#include "mozilla/css/Declaration.h"
#include "nsCSSProps.h"
#include "nsCOMPtr.h"
@ -269,6 +271,45 @@ nsDOMCSSDeclaration::RemoveProperty(const nsAString& aPropertyName,
return RemoveProperty(propID);
}
/* static */ nsresult
nsDOMCSSDeclaration::GetCSSParsingEnvironmentForRule(
nsICSSRule* aRule, nsIURI** aSheetURI,
nsIURI** aBaseURI, nsIPrincipal** aSheetPrincipal,
mozilla::css::Loader** aCSSLoader)
{
// null out the out params since some of them may not get initialized below
*aSheetURI = nsnull;
*aBaseURI = nsnull;
*aSheetPrincipal = nsnull;
*aCSSLoader = nsnull;
if (aRule) {
nsIStyleSheet* sheet = aRule->GetStyleSheet();
if (sheet) {
NS_IF_ADDREF(*aSheetURI = sheet->GetSheetURI());
NS_IF_ADDREF(*aBaseURI = sheet->GetBaseURI());
nsRefPtr<nsCSSStyleSheet> cssSheet(do_QueryObject(sheet));
if (cssSheet) {
NS_ADDREF(*aSheetPrincipal = cssSheet->Principal());
}
nsIDocument* document = sheet->GetOwningDocument();
if (document) {
NS_ADDREF(*aCSSLoader = document->CSSLoader());
}
}
}
nsresult result = NS_OK;
if (!*aSheetPrincipal) {
result = CallCreateInstance("@mozilla.org/nullprincipal;1",
aSheetPrincipal);
}
return result;
}
nsresult
nsDOMCSSDeclaration::ParsePropertyValue(const nsCSSProperty aPropID,
const nsAString& aPropValue,

Просмотреть файл

@ -48,6 +48,7 @@ class nsCSSParser;
class nsIURI;
class nsIPrincipal;
class nsIDocument;
class nsICSSRule;
namespace mozilla {
namespace css {
@ -107,6 +108,15 @@ protected:
nsIPrincipal** aSheetPrincipal,
mozilla::css::Loader** aCSSLoader) = 0;
// An implementation for GetCSSParsingEnvironment for callers wrapping
// an nsICSSRule.
static nsresult
GetCSSParsingEnvironmentForRule(nsICSSRule* aRule,
nsIURI** aSheetURI,
nsIURI** aBaseURI,
nsIPrincipal** aSheetPrincipal,
mozilla::css::Loader** aCSSLoader);
nsresult ParsePropertyValue(const nsCSSProperty aPropID,
const nsAString& aPropValue,
PRBool aIsImportant);