Bug 731271 - Part 6: Add a chrome-only CSSDeclaration.getAuthoredPropertyValue() method to expose a property value in its original syntactic form. r=dbaron

This commit is contained in:
Cameron McCormack 2013-09-16 09:35:49 +10:00
parent 23bc7a36c7
commit ff0d185d24
5 changed files with 62 additions and 4 deletions

View File

@ -29,3 +29,9 @@ interface CSSStyleDeclaration {
readonly attribute CSSRule? parentRule;
};
// Mozilla extensions
partial interface CSSStyleDeclaration {
[ChromeOnly,Throws]
DOMString getAuthoredPropertyValue(DOMString property);
};

View File

@ -1592,6 +1592,15 @@ nsCSSFontFaceStyleDecl::GetPropertyValue(const nsAString & propertyName,
return GetPropertyValue(nsCSSProps::LookupFontDesc(propertyName), aResult);
}
NS_IMETHODIMP
nsCSSFontFaceStyleDecl::GetAuthoredPropertyValue(const nsAString& propertyName,
nsAString& aResult)
{
// We don't return any authored property values different from
// GetPropertyValue, currently.
return GetPropertyValue(nsCSSProps::LookupFontDesc(propertyName), aResult);
}
// nsIDOMCSSValue getPropertyCSSValue (in DOMString propertyName);
already_AddRefed<dom::CSSValue>
nsCSSFontFaceStyleDecl::GetPropertyCSSValue(const nsAString & propertyName,

View File

@ -417,6 +417,15 @@ nsComputedDOMStyle::GetPropertyValue(const nsAString& aPropertyName,
return NS_OK;
}
NS_IMETHODIMP
nsComputedDOMStyle::GetAuthoredPropertyValue(const nsAString& aPropertyName,
nsAString& aReturn)
{
// Authored style doesn't make sense to return from computed DOM style,
// so just return whatever GetPropertyValue() returns.
return GetPropertyValue(aPropertyName, aReturn);
}
/* static */
already_AddRefed<nsStyleContext>
nsComputedDOMStyle::GetStyleContextForElement(Element* aElement,

View File

@ -184,6 +184,31 @@ nsDOMCSSDeclaration::GetPropertyValue(const nsAString& aPropertyName,
return GetPropertyValue(propID, aReturn);
}
NS_IMETHODIMP
nsDOMCSSDeclaration::GetAuthoredPropertyValue(const nsAString& aPropertyName,
nsAString& aReturn)
{
const nsCSSProperty propID = nsCSSProps::LookupProperty(aPropertyName,
nsCSSProps::eEnabled);
if (propID == eCSSProperty_UNKNOWN) {
aReturn.Truncate();
return NS_OK;
}
if (propID == eCSSPropertyExtra_variable) {
GetCustomPropertyValue(aPropertyName, aReturn);
return NS_OK;
}
css::Declaration* decl = GetCSSDeclaration(false);
if (!decl) {
return NS_ERROR_FAILURE;
}
decl->GetAuthoredValue(propID, aReturn);
return NS_OK;
}
NS_IMETHODIMP
nsDOMCSSDeclaration::GetPropertyPriority(const nsAString& aPropertyName,
nsAString& aReturn)

View File

@ -50,6 +50,9 @@ public:
NS_IMETHOD GetPropertyValue(const nsCSSProperty aPropID,
nsAString& aValue) = 0;
NS_IMETHOD GetAuthoredPropertyValue(const nsAString& aPropName,
nsAString& aValue) = 0;
/**
* Method analogous to nsIDOMCSSStyleDeclaration::SetProperty. This
* method does NOT allow setting a priority (the priority will
@ -125,6 +128,10 @@ public:
mozilla::ErrorResult& rv) {
rv = GetPropertyValue(aPropName, aValue);
}
void GetAuthoredPropertyValue(const nsAString& aPropName, nsString& aValue,
mozilla::ErrorResult& rv) {
rv = GetAuthoredPropertyValue(aPropName, aValue);
}
void GetPropertyPriority(const nsAString& aPropName, nsString& aPriority) {
GetPropertyPriority(aPropName, static_cast<nsAString&>(aPriority));
}
@ -145,10 +152,12 @@ public:
NS_DEFINE_STATIC_IID_ACCESSOR(nsICSSDeclaration, NS_ICSSDECLARATION_IID)
#define NS_DECL_NSICSSDECLARATION \
NS_IMETHOD GetPropertyValue(const nsCSSProperty aPropID, \
nsAString& aValue); \
NS_IMETHOD SetPropertyValue(const nsCSSProperty aPropID, \
#define NS_DECL_NSICSSDECLARATION \
NS_IMETHOD GetPropertyValue(const nsCSSProperty aPropID, \
nsAString& aValue); \
NS_IMETHOD GetAuthoredPropertyValue(const nsAString& aPropName, \
nsAString& aValue); \
NS_IMETHOD SetPropertyValue(const nsCSSProperty aPropID, \
const nsAString& aValue);
#define NS_DECL_NSIDOMCSSSTYLEDECLARATION_HELPER \