Bug 1669459 - Clean-up CSS.supports. r=heycam

Use UTF8String rather than converting on the callee (which can avoid
copies), and also it doesn't really throw, so don't claim it does.

Differential Revision: https://phabricator.services.mozilla.com/D92583
This commit is contained in:
Emilio Cobos Álvarez 2020-10-08 23:56:14 +00:00
parent 91e35e71fb
commit c8668998be
3 changed files with 11 additions and 19 deletions

View File

@ -13,11 +13,8 @@
[Exposed=Window]
namespace CSS {
[Throws]
boolean supports(DOMString property, DOMString value);
[Throws]
boolean supports(DOMString conditionText);
boolean supports(UTF8String property, UTF8String value);
boolean supports(UTF8String conditionText);
};
// http://dev.w3.org/csswg/cssom/#the-css.escape%28%29-method

View File

@ -19,18 +19,14 @@ namespace mozilla {
namespace dom {
/* static */
bool CSS::Supports(const GlobalObject& aGlobal, const nsAString& aProperty,
const nsAString& aValue, ErrorResult& aRv) {
NS_ConvertUTF16toUTF8 property(aProperty);
NS_ConvertUTF16toUTF8 value(aValue);
return Servo_CSSSupports2(&property, &value);
bool CSS::Supports(const GlobalObject&, const nsACString& aProperty,
const nsACString& aValue) {
return Servo_CSSSupports2(&aProperty, &aValue);
}
/* static */
bool CSS::Supports(const GlobalObject& aGlobal, const nsAString& aCondition,
ErrorResult& aRv) {
NS_ConvertUTF16toUTF8 cond(aCondition);
return Servo_CSSSupports(&cond);
bool CSS::Supports(const GlobalObject&, const nsACString& aCondition) {
return Servo_CSSSupports(&aCondition);
}
/* static */

View File

@ -25,13 +25,12 @@ class CSS {
CSS() = delete;
public:
static bool Supports(const GlobalObject& aGlobal, const nsAString& aProperty,
const nsAString& aValue, ErrorResult& aRv);
static bool Supports(const GlobalObject&, const nsACString& aProperty,
const nsACString& aValue);
static bool Supports(const GlobalObject& aGlobal,
const nsAString& aDeclaration, ErrorResult& aRv);
static bool Supports(const GlobalObject&, const nsACString& aDeclaration);
static void Escape(const GlobalObject& aGlobal, const nsAString& aIdent,
static void Escape(const GlobalObject&, const nsAString& aIdent,
nsAString& aReturn);
};