mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset b7cd1bc458a3 (bug 1230172) because something from this push turned browser_video_test.js permafail on mulet CLOSED TREE
This commit is contained in:
parent
5780a15992
commit
305c250f35
@ -20,5 +20,6 @@ interface CSS {
|
||||
|
||||
// http://dev.w3.org/csswg/cssom/#the-css.escape%28%29-method
|
||||
partial interface CSS {
|
||||
[Throws]
|
||||
static DOMString escape(DOMString ident);
|
||||
};
|
||||
|
@ -85,9 +85,14 @@ CSS::Supports(const GlobalObject& aGlobal,
|
||||
/* static */ void
|
||||
CSS::Escape(const GlobalObject& aGlobal,
|
||||
const nsAString& aIdent,
|
||||
nsAString& aReturn)
|
||||
nsAString& aReturn,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsStyleUtil::AppendEscapedCSSIdent(aIdent, aReturn);
|
||||
bool success = nsStyleUtil::AppendEscapedCSSIdent(aIdent, aReturn);
|
||||
|
||||
if (!success) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_CHARACTER_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
@ -35,7 +35,8 @@ public:
|
||||
|
||||
static void Escape(const GlobalObject& aGlobal,
|
||||
const nsAString& aIdent,
|
||||
nsAString& aReturn);
|
||||
nsAString& aReturn,
|
||||
ErrorResult& aRv);
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
@ -79,7 +79,7 @@ void nsStyleUtil::AppendEscapedCSSString(const nsAString& aString,
|
||||
aReturn.Append(quoteChar);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
/* static */ bool
|
||||
nsStyleUtil::AppendEscapedCSSIdent(const nsAString& aIdent, nsAString& aReturn)
|
||||
{
|
||||
// The relevant parts of the CSS grammar are:
|
||||
@ -98,7 +98,7 @@ nsStyleUtil::AppendEscapedCSSIdent(const nsAString& aIdent, nsAString& aReturn)
|
||||
const char16_t* const end = aIdent.EndReading();
|
||||
|
||||
if (in == end)
|
||||
return;
|
||||
return true;
|
||||
|
||||
// A leading dash does not need to be escaped as long as it is not the
|
||||
// *only* character in the identifier.
|
||||
@ -106,7 +106,7 @@ nsStyleUtil::AppendEscapedCSSIdent(const nsAString& aIdent, nsAString& aReturn)
|
||||
if (in + 1 == end) {
|
||||
aReturn.Append(char16_t('\\'));
|
||||
aReturn.Append(char16_t('-'));
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
aReturn.Append(char16_t('-'));
|
||||
@ -124,8 +124,9 @@ nsStyleUtil::AppendEscapedCSSIdent(const nsAString& aIdent, nsAString& aReturn)
|
||||
for (; in != end; ++in) {
|
||||
char16_t ch = *in;
|
||||
if (ch == 0x00) {
|
||||
aReturn.Append(char16_t(0xFFFD));
|
||||
} else if (ch < 0x20 || (0x7F <= ch && ch < 0xA0)) {
|
||||
return false;
|
||||
}
|
||||
if (ch < 0x20 || (0x7F <= ch && ch < 0xA0)) {
|
||||
// Escape U+0000 through U+001F and U+007F through U+009F numerically.
|
||||
aReturn.AppendPrintf("\\%hx ", *in);
|
||||
} else {
|
||||
@ -141,6 +142,7 @@ nsStyleUtil::AppendEscapedCSSIdent(const nsAString& aIdent, nsAString& aReturn)
|
||||
aReturn.Append(ch);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// unquoted family names must be a sequence of idents
|
||||
|
@ -39,9 +39,10 @@ public:
|
||||
|
||||
// Append the identifier given by |aIdent| to |aResult|, with
|
||||
// appropriate escaping so that it can be reparsed to the same
|
||||
// identifier. An exception is if aIdent contains U+0000, which
|
||||
// will be escaped as U+FFFD and then reparsed back to U+FFFD.
|
||||
static void AppendEscapedCSSIdent(const nsAString& aIdent,
|
||||
// identifier.
|
||||
// Returns false if |aIdent| contains U+0000
|
||||
// Returns true for all other cases
|
||||
static bool AppendEscapedCSSIdent(const nsAString& aIdent,
|
||||
nsAString& aResult);
|
||||
|
||||
static void
|
||||
|
@ -21,18 +21,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=955860
|
||||
// Tests taken from:
|
||||
// https://github.com/mathiasbynens/CSS.escape/blob/master/tests/tests.js
|
||||
|
||||
SimpleTest.doesThrow(() => CSS.escape('\0'), "InvalidCharacterError Character :\\0");
|
||||
SimpleTest.doesThrow(() => CSS.escape('a\0'), "InvalidCharacterError Character : a\\0");
|
||||
SimpleTest.doesThrow(() => CSS.escape('\0b'), "InvalidCharacterError Character : \\0b");
|
||||
SimpleTest.doesThrow(() => CSS.escape('a\0b'), "InvalidCharacterError Character : a\\0b");
|
||||
SimpleTest.doesThrow(() => CSS.escape(), 'undefined');
|
||||
|
||||
is(CSS.escape('\0'), '\uFFFD', "escaping for 0 char (1)");
|
||||
is(CSS.escape('a\0'), 'a\uFFFD', "escaping for 0 char (2)");
|
||||
is(CSS.escape('\0b'), '\uFFFDb', "escaping for 0 char (3)");
|
||||
is(CSS.escape('a\0b'), 'a\uFFFDb', "escaping for 0 char (4)");
|
||||
|
||||
is(CSS.escape('\uFFFD'), '\uFFFD', "escaping for replacement char (1)");
|
||||
is(CSS.escape('a\uFFFD'), 'a\uFFFD', "escaping replacement char (2)");
|
||||
is(CSS.escape('\uFFFDb'), '\uFFFDb', "escaping replacement char (3)");
|
||||
is(CSS.escape('a\uFFFDb'), 'a\uFFFDb', "escaping replacement char (4)");
|
||||
|
||||
is(CSS.escape(true), 'true', "escapingFailed Character : true(bool)");
|
||||
is(CSS.escape(false), 'false', "escapingFailed Character : false(bool)");
|
||||
is(CSS.escape(null), 'null', "escapingFailed Character : null");
|
||||
|
Loading…
Reference in New Issue
Block a user