Bug 474655: Add a deprecation warning + use counter to GetPropertyCSSValue. r?bholley
The use counter comes built-in with the DeprecatedOperationList stuff.
MozReview-Commit-ID: 9Opag1NMp32
--- a/dom/base/nsDeprecatedOperationList.h
+++ b/dom/base/nsDeprecatedOperationList.h
@@ -43,8 +43,9 @@ DEPRECATED_OPERATION(XMLBaseAttribute)
DEPRECATED_OPERATION(WindowContentUntrusted)
DEPRECATED_OPERATION(RegisterProtocolHandlerInsecure)
DEPRECATED_OPERATION(MixedDisplayObjectSubrequest)
DEPRECATED_OPERATION(MotionEvent)
DEPRECATED_OPERATION(OrientationEvent)
DEPRECATED_OPERATION(ProximityEvent)
DEPRECATED_OPERATION(AmbientLightEvent)
DEPRECATED_OPERATION(IDBOpenDBOptions_StorageType)
+DEPRECATED_OPERATION(GetPropertyCSSValue)
--- a/dom/locales/en-US/chrome/dom/dom.properties
+++ b/dom/locales/en-US/chrome/dom/dom.properties
@@ -356,8 +356,10 @@ ReadableStreamReadingFailed=Failed to read data from the ReadableStream: “%S”.
RegisterProtocolHandlerInsecureWarning=Use of the registerProtocolHandler for insecure connections will be removed in version 62.
MixedDisplayObjectSubrequestWarning=Loading insecure content within a plugin embedded in a secure connection is going to be removed.
MotionEventWarning=Use of the motion sensor is deprecated.
OrientationEventWarning=Use of the orientation sensor is deprecated.
ProximityEventWarning=Use of the proximity sensor is deprecated.
AmbientLightEventWarning=Use of the ambient light sensor is deprecated.
# LOCALIZATION NOTE: Do not translate "storage", "indexedDB.open" and "navigator.storage.persist()".
IDBOpenDBOptions_StorageTypeWarning=The ‘storage’ attribute in options passed to indexedDB.open is deprecated and will soon be removed. To get persistent storage, please use navigator.storage.persist() instead.
+# LOCALIZATION NOTE: Do not translate "getPropertyCSSValue" and "getPropertyValue".
+GetPropertyCSSValueWarning=Use of getPropertyCSSValue is deprecated, use getPropertyValue instead.
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -494,17 +494,18 @@ nsComputedDOMStyle::GetParentRule()
NS_IMETHODIMP
nsComputedDOMStyle::GetPropertyValue(const nsAString& aPropertyName,
nsAString& aReturn)
{
aReturn.Truncate();
ErrorResult error;
- RefPtr<CSSValue> val = GetPropertyCSSValue(aPropertyName, error);
+ RefPtr<CSSValue> val =
+ GetPropertyCSSValueWithoutWarning(aPropertyName, error);
if (error.Failed()) {
return error.StealNSResult();
}
if (val) {
nsString text;
val->GetCssText(text, error);
aReturn.Assign(text);
@@ -1286,17 +1287,29 @@ nsComputedDOMStyle::ClearCurrentStyleSou
}
mOuterFrame = nullptr;
mInnerFrame = nullptr;
mPresShell = nullptr;
}
already_AddRefed<CSSValue>
-nsComputedDOMStyle::GetPropertyCSSValue(const nsAString& aPropertyName, ErrorResult& aRv)
+nsComputedDOMStyle::GetPropertyCSSValue(const nsAString& aPropertyName,
+ ErrorResult& aRv)
+{
+ if (nsCOMPtr<nsIDocument> document = do_QueryReferent(mDocumentWeak)) {
+ document->WarnOnceAbout(nsIDocument::eGetPropertyCSSValue);
+ }
+ return GetPropertyCSSValueWithoutWarning(aPropertyName, aRv);
+}
+
+already_AddRefed<CSSValue>
+nsComputedDOMStyle::GetPropertyCSSValueWithoutWarning(
+ const nsAString& aPropertyName,
+ ErrorResult& aRv)
{
nsCSSPropertyID prop =
nsCSSProps::LookupProperty(aPropertyName, CSSEnabledState::eForAllContent);
bool needsLayoutFlush;
nsComputedStyleMap::Entry::ComputeMethod getter;
if (prop == eCSSPropertyExtra_variable) {
--- a/layout/style/nsComputedDOMStyle.h
+++ b/layout/style/nsComputedDOMStyle.h
@@ -53,32 +53,38 @@ class nsComputedDOMStyle final : public
, public nsStubMutationObserver
{
private:
// Convenience typedefs:
typedef nsCSSProps::KTableEntry KTableEntry;
typedef mozilla::dom::CSSValue CSSValue;
typedef mozilla::StyleGeometryBox StyleGeometryBox;
+ already_AddRefed<CSSValue>
+ GetPropertyCSSValueWithoutWarning(const nsAString& aProp,
+ mozilla::ErrorResult& aRv);
+
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsComputedDOMStyle,
nsICSSDeclaration)
NS_DECL_NSIDOMCSSSTYLEDECLARATION_HELPER
nsresult GetPropertyValue(const nsCSSPropertyID aPropID,
nsAString& aValue) override;
nsresult SetPropertyValue(const nsCSSPropertyID aPropID,
const nsAString& aValue,
nsIPrincipal* aSubjectPrincipal) override;
- virtual already_AddRefed<CSSValue>
- GetPropertyCSSValue(const nsAString& aProp, mozilla::ErrorResult& aRv)
- override;
+
+ // Do NOT use this, it is deprecated, see bug 474655.
+ already_AddRefed<CSSValue>
+ GetPropertyCSSValue(const nsAString& aProp, mozilla::ErrorResult& aRv) final;
using nsICSSDeclaration::GetPropertyCSSValue;
- virtual void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aPropName) override;
+
+ void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aPropName) final;
enum StyleType {
eDefaultOnly, // Only includes UA and user sheets
eAll // Includes all stylesheets
};
enum AnimationFlag {
eWithAnimation,