mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backing out bug 614058, bug 609272, bug 478445, bug 499628, bug 605296, bug 608914 and bug 614724 due to potentially causing bug 615736 CLOSED TREE. a=backout
This commit is contained in:
parent
ad5534594c
commit
7a0e0a5cd9
@ -242,8 +242,8 @@ interface nsIXMLHttpRequest : nsISupports
|
||||
*/
|
||||
[optional_argc] void open(in AUTF8String method, in AUTF8String url,
|
||||
[optional] in boolean async,
|
||||
[optional,Undefined(Empty)] in DOMString user,
|
||||
[optional,Undefined(Empty)] in DOMString password);
|
||||
[optional] in DOMString user,
|
||||
[optional] in DOMString password);
|
||||
|
||||
/**
|
||||
* Sends the request. If the request is asynchronous, returns
|
||||
|
@ -445,8 +445,9 @@ nsAttrValue::ToString(nsAString& aResult) const
|
||||
#endif
|
||||
case eFloatValue:
|
||||
{
|
||||
aResult.Truncate();
|
||||
aResult.AppendFloat(GetFloatValue());
|
||||
nsAutoString str;
|
||||
str.AppendFloat(GetFloatValue());
|
||||
aResult = str;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -4351,18 +4351,7 @@ nsDocument::CreateElementNS(const nsAString& aNamespaceURI,
|
||||
nsIDOMElement** aReturn)
|
||||
{
|
||||
*aReturn = nsnull;
|
||||
nsCOMPtr<nsIContent> content;
|
||||
nsresult rv = CreateElementNS(aNamespaceURI, aQualifiedName,
|
||||
getter_AddRefs(content));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return CallQueryInterface(content, aReturn);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDocument::CreateElementNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aQualifiedName,
|
||||
nsIContent** aReturn)
|
||||
{
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nsresult rv = nsContentUtils::GetNodeInfoFromQName(aNamespaceURI,
|
||||
aQualifiedName,
|
||||
@ -4370,9 +4359,13 @@ nsDocument::CreateElementNS(const nsAString& aNamespaceURI,
|
||||
getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
PRInt32 ns = nodeInfo->NamespaceID();
|
||||
return NS_NewElement(aReturn, nodeInfo->NamespaceID(),
|
||||
nodeInfo.forget(), NOT_FROM_PARSER);
|
||||
rv = NS_NewElement(getter_AddRefs(content), ns, nodeInfo.forget(),
|
||||
NOT_FROM_PARSER);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return CallQueryInterface(content, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -859,9 +859,6 @@ public:
|
||||
|
||||
nsresult CreateElement(const nsAString& aTagName,
|
||||
nsIContent** aReturn);
|
||||
nsresult CreateElementNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aQualifiedName,
|
||||
nsIContent** aReturn);
|
||||
|
||||
nsresult CreateTextNode(const nsAString& aData, nsIContent** aReturn);
|
||||
|
||||
|
@ -1095,6 +1095,19 @@ nsIContent::IsEqual(nsIContent* aOther)
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// Child nodes count.
|
||||
PRUint32 childCount = GetChildCount();
|
||||
if (childCount != element2->GetChildCount()) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// Iterate over child nodes.
|
||||
for (PRUint32 i = 0; i < childCount; ++i) {
|
||||
if (!GetChildAt(i)->IsEqual(element2->GetChildAt(i))) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Node value check.
|
||||
nsCOMPtr<nsIDOMNode> domNode1 = do_QueryInterface(this);
|
||||
@ -1107,18 +1120,6 @@ nsIContent::IsEqual(nsIContent* aOther)
|
||||
}
|
||||
}
|
||||
|
||||
// Child nodes count.
|
||||
PRUint32 childCount = GetChildCount();
|
||||
if (childCount != aOther->GetChildCount()) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// Iterate over child nodes.
|
||||
for (PRUint32 i = 0; i < childCount; ++i) {
|
||||
if (!GetChildAt(i)->IsEqual(aOther->GetChildAt(i))) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
@ -370,17 +370,17 @@ _TEST_FILES2 = \
|
||||
file_CSP_main.html \
|
||||
file_CSP_main.html^headers^ \
|
||||
file_CSP_main.js \
|
||||
test_CSP_frameancestors.html \
|
||||
file_CSP_frameancestors.sjs \
|
||||
file_CSP_frameancestors_main.html \
|
||||
file_CSP_frameancestors_main.js \
|
||||
test_CSP_inlinescript.html \
|
||||
file_CSP_inlinescript_main.html \
|
||||
file_CSP_inlinescript_main.html^headers^ \
|
||||
test_CSP_evalscript.html \
|
||||
file_CSP_evalscript_main.html \
|
||||
file_CSP_evalscript_main.html^headers^ \
|
||||
file_CSP_evalscript_main.js \
|
||||
test_CSP_frameancestors.html \
|
||||
file_CSP_frameancestors.sjs \
|
||||
file_CSP_frameancestors_main.html \
|
||||
file_CSP_frameancestors_main.js \
|
||||
test_CSP_inlinescript.html \
|
||||
file_CSP_inlinescript_main.html \
|
||||
file_CSP_inlinescript_main.html^headers^ \
|
||||
test_CSP_evalscript.html \
|
||||
file_CSP_evalscript_main.html \
|
||||
file_CSP_evalscript_main.html^headers^ \
|
||||
file_CSP_evalscript_main.js \
|
||||
test_bug540854.html \
|
||||
bug540854.sjs \
|
||||
test_bug548463.html \
|
||||
@ -444,7 +444,6 @@ _TEST_FILES2 = \
|
||||
test_bug605982.html \
|
||||
test_bug606729.html \
|
||||
test_treewalker_nextsibling.xml \
|
||||
test_bug614058.html \
|
||||
$(NULL)
|
||||
|
||||
# This test fails on the Mac for some reason
|
||||
|
@ -16,11 +16,7 @@ window.addEventListener("message", function(e) {
|
||||
var res = {
|
||||
didFail: false,
|
||||
events: [],
|
||||
progressEvents: 0,
|
||||
status: 0,
|
||||
responseText: "",
|
||||
responseXML: null,
|
||||
sendThrew: false
|
||||
progressEvents: 0
|
||||
};
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
@ -76,28 +72,14 @@ window.addEventListener("message", function(e) {
|
||||
sendData = req.body;
|
||||
|
||||
res.events.push("opening");
|
||||
// Allow passign in falsy usernames/passwords so we can test them
|
||||
try {
|
||||
xhr.open(req.method, req.url, true,
|
||||
("username" in req) ? req.username : "",
|
||||
("password" in req) ? req.password : "aa");
|
||||
} catch (ex) {
|
||||
res.didFail = true;
|
||||
post(e, res);
|
||||
}
|
||||
xhr.open(req.method, req.url, true);
|
||||
|
||||
for (header in req.headers) {
|
||||
xhr.setRequestHeader(header, req.headers[header]);
|
||||
}
|
||||
|
||||
res.events.push("sending");
|
||||
try {
|
||||
xhr.send(sendData);
|
||||
} catch (ex) {
|
||||
res.didFail = true;
|
||||
res.sendThrew = true;
|
||||
post(e, res);
|
||||
}
|
||||
xhr.send(sendData);
|
||||
|
||||
}, false);
|
||||
|
||||
|
@ -49,37 +49,6 @@ function runTest() {
|
||||
noAllowPreflight: 1,
|
||||
},
|
||||
|
||||
// undefined username
|
||||
{ pass: 1,
|
||||
method: "GET",
|
||||
noAllowPreflight: 1,
|
||||
username: undefined
|
||||
},
|
||||
|
||||
// undefined username and password
|
||||
{ pass: 1,
|
||||
method: "GET",
|
||||
noAllowPreflight: 1,
|
||||
username: undefined,
|
||||
password: undefined
|
||||
},
|
||||
|
||||
// nonempty username
|
||||
{ pass: 0,
|
||||
method: "GET",
|
||||
noAllowPreflight: 1,
|
||||
username: "user",
|
||||
},
|
||||
|
||||
// nonempty password
|
||||
// XXXbz this passes for now, because we ignore passwords
|
||||
// without usernames in most cases.
|
||||
{ pass: 1,
|
||||
method: "GET",
|
||||
noAllowPreflight: 1,
|
||||
password: "password",
|
||||
},
|
||||
|
||||
// Default allowed headers
|
||||
{ pass: 1,
|
||||
method: "GET",
|
||||
@ -588,14 +557,6 @@ function runTest() {
|
||||
"&requestMethod=" + test.method;
|
||||
}
|
||||
|
||||
if ("username" in test) {
|
||||
req.username = test.username;
|
||||
}
|
||||
|
||||
if ("password" in test) {
|
||||
req.password = test.password;
|
||||
}
|
||||
|
||||
if (test.noAllowPreflight)
|
||||
req.url += "&noAllowPreflight";
|
||||
|
||||
@ -692,11 +653,9 @@ function runTest() {
|
||||
"wrong responseXML in test for " + test.toSource());
|
||||
is(res.responseText, "",
|
||||
"wrong responseText in test for " + test.toSource());
|
||||
if (!res.sendThrew) {
|
||||
is(res.events.join(","),
|
||||
"opening,rs1,sending,rs1,loadstart,rs2,rs4,error",
|
||||
"wrong events in test for " + test.toSource());
|
||||
}
|
||||
is(res.events.join(","),
|
||||
"opening,rs1,sending,rs1,loadstart,rs2,rs4,error",
|
||||
"wrong events in test for " + test.toSource());
|
||||
is(res.progressEvents, 0,
|
||||
"wrong events in test for " + test.toSource());
|
||||
if (test.responseHeaders) {
|
||||
|
@ -1,30 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=614058
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 614058</title>
|
||||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=614058">Mozilla Bug 614058</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 614058 **/
|
||||
var f1 = document.createDocumentFragment();
|
||||
f2 = f1.cloneNode(true);
|
||||
f1.appendChild(document.createElement("foo"));
|
||||
is(f1.isEqualNode(f2), false, "Fragments have different kids!");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -948,7 +948,9 @@ nsCanvasRenderingContext2D::StyleColorToString(const nscolor& aColor, nsAString&
|
||||
NS_GET_G(aColor),
|
||||
NS_GET_B(aColor)),
|
||||
aStr);
|
||||
aStr.AppendFloat(nsStyleUtil::ColorComponentToFloat(NS_GET_A(aColor)));
|
||||
nsString tmp;
|
||||
tmp.AppendFloat(nsStyleUtil::ColorComponentToFloat(NS_GET_A(aColor)));
|
||||
aStr.Append(tmp);
|
||||
aStr.Append(')');
|
||||
}
|
||||
}
|
||||
@ -2799,11 +2801,9 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
|
||||
|
||||
gfxContextPathAutoSaveRestore pathSR(mThebes, PR_FALSE);
|
||||
|
||||
// back up and clear path if stroking
|
||||
if (aOp == nsCanvasRenderingContext2D::TEXT_DRAW_OPERATION_STROKE) {
|
||||
// back up path if stroking
|
||||
if (aOp == nsCanvasRenderingContext2D::TEXT_DRAW_OPERATION_STROKE)
|
||||
pathSR.Save();
|
||||
mThebes->NewPath();
|
||||
}
|
||||
// doUseIntermediateSurface is mutually exclusive to op == STROKE
|
||||
else {
|
||||
if (doUseIntermediateSurface) {
|
||||
|
@ -122,8 +122,9 @@ nsSVGNumber2::SetBaseValueString(const nsAString &aValueAsString,
|
||||
void
|
||||
nsSVGNumber2::GetBaseValueString(nsAString & aValueAsString)
|
||||
{
|
||||
aValueAsString.Truncate();
|
||||
aValueAsString.AppendFloat(mBaseVal);
|
||||
nsAutoString s;
|
||||
s.AppendFloat(mBaseVal);
|
||||
aValueAsString.Assign(s);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -103,7 +103,6 @@ members = [
|
||||
'nsIDOMDocument.getElementById',
|
||||
'nsIDOMDocument.createDocumentFragment',
|
||||
'nsIDOMDocument.createElement',
|
||||
'nsIDOMDocument.createElementNS',
|
||||
'nsIDOMDocument.importNode',
|
||||
'nsIDOMDocument.createTextNode',
|
||||
'nsIDOMElement.removeAttributeNS',
|
||||
@ -428,6 +427,8 @@ members = [
|
||||
# nsIXMLHttpRequest.channel is not used on the web, and more
|
||||
# importantly relies on the CAPS check that quickstubs don't make.
|
||||
'-nsIXMLHttpRequest.channel',
|
||||
# nsIXMLHttpRequest.open uses the JS stack
|
||||
'-nsIXMLHttpRequest.open',
|
||||
# various XHR things use ACString and AUTF8String and [cstring]
|
||||
# which quickstubs don't handle as return values (or at all in the
|
||||
# case of AUTF8String) yet.
|
||||
@ -908,11 +909,6 @@ customMethodCalls = {
|
||||
'code': ' nsCOMPtr<nsIContent> result;\n'
|
||||
' rv = self->CreateElement(arg0, getter_AddRefs(result));'
|
||||
},
|
||||
'nsIDOMDocument_CreateElementNS': {
|
||||
'thisType': 'nsDocument',
|
||||
'code': ' nsCOMPtr<nsIContent> result;\n'
|
||||
' rv = self->CreateElementNS(arg0, arg1, getter_AddRefs(result));'
|
||||
},
|
||||
'nsIDOMDocument_CreateTextNode': {
|
||||
'thisType': 'nsDocument',
|
||||
'code': ' nsCOMPtr<nsIContent> result;\n'
|
||||
|
@ -496,11 +496,6 @@ argumentUnboxingTemplates = {
|
||||
" if (!${name}.IsValid())\n"
|
||||
" return JS_FALSE;\n",
|
||||
|
||||
'[utf8string]':
|
||||
" xpc_qsAUTF8String ${name}(cx, ${argVal}, ${argPtr});\n"
|
||||
" if (!${name}.IsValid())\n"
|
||||
" return JS_FALSE;\n",
|
||||
|
||||
'[jsval]':
|
||||
" jsval ${name} = ${argVal};\n"
|
||||
}
|
||||
@ -585,7 +580,7 @@ def writeArgumentUnboxing(f, i, name, type, haveCcx, optional, rvdeclared,
|
||||
" }\n")
|
||||
return True
|
||||
|
||||
warn("Unable to unbox argument of type %s (native type %s)" % (type.name, typeName))
|
||||
warn("Unable to unbox argument of type %s" % type.name)
|
||||
if i is None:
|
||||
src = '*vp'
|
||||
else:
|
||||
@ -1136,7 +1131,7 @@ traceableArgumentConversionTemplates = {
|
||||
" XPCReadableJSStringWrapper ${name}(${argVal});\n",
|
||||
'[domstring]':
|
||||
" XPCReadableJSStringWrapper ${name}(${argVal});\n",
|
||||
'[utf8string]':
|
||||
'[cstring]':
|
||||
" NS_ConvertUTF16toUTF8 ${name}("
|
||||
"(const PRUnichar *)JS_GetStringChars(${argVal}), "
|
||||
"JS_GetStringLength(${argVal}));\n",
|
||||
|
@ -694,28 +694,83 @@ xpc_qsDOMString::xpc_qsDOMString(JSContext *cx, jsval v, jsval *pval,
|
||||
StringificationBehavior nullBehavior,
|
||||
StringificationBehavior undefinedBehavior)
|
||||
{
|
||||
typedef implementation_type::char_traits traits;
|
||||
// From the T_DOMSTRING case in XPCConvert::JSData2Native.
|
||||
JSString *s = InitOrStringify<traits>(cx, v, pval, nullBehavior,
|
||||
undefinedBehavior);
|
||||
if (!s)
|
||||
return;
|
||||
typedef implementation_type::char_traits traits;
|
||||
JSString *s;
|
||||
const PRUnichar *chars;
|
||||
size_t len;
|
||||
|
||||
size_t len = s->length();
|
||||
const PRUnichar* chars =
|
||||
(len == 0 ? traits::sEmptyBuffer :
|
||||
reinterpret_cast<const PRUnichar*>(JS_GetStringChars(s)));
|
||||
if(JSVAL_IS_STRING(v))
|
||||
{
|
||||
s = JSVAL_TO_STRING(v);
|
||||
}
|
||||
else
|
||||
{
|
||||
StringificationBehavior behavior = eStringify;
|
||||
if(JSVAL_IS_NULL(v))
|
||||
{
|
||||
behavior = nullBehavior;
|
||||
}
|
||||
else if(JSVAL_IS_VOID(v))
|
||||
{
|
||||
behavior = undefinedBehavior;
|
||||
}
|
||||
|
||||
// If pval is null, that means the argument was optional and
|
||||
// not passed; turn those into void strings if they're
|
||||
// supposed to be stringified.
|
||||
if (behavior != eStringify || !pval)
|
||||
{
|
||||
// Here behavior == eStringify implies !pval, so both eNull and
|
||||
// eStringify should end up with void strings.
|
||||
(new(mBuf) implementation_type(
|
||||
traits::sEmptyBuffer, PRUint32(0)))->SetIsVoid(behavior != eEmpty);
|
||||
mValid = JS_TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
s = JS_ValueToString(cx, v);
|
||||
if(!s)
|
||||
{
|
||||
mValid = JS_FALSE;
|
||||
return;
|
||||
}
|
||||
*pval = STRING_TO_JSVAL(s); // Root the new string.
|
||||
}
|
||||
|
||||
len = s->length();
|
||||
chars = (len == 0 ? traits::sEmptyBuffer :
|
||||
reinterpret_cast<const PRUnichar*>(JS_GetStringChars(s)));
|
||||
new(mBuf) implementation_type(chars, len);
|
||||
mValid = JS_TRUE;
|
||||
}
|
||||
|
||||
xpc_qsACString::xpc_qsACString(JSContext *cx, jsval v, jsval *pval)
|
||||
{
|
||||
typedef implementation_type::char_traits traits;
|
||||
// From the T_CSTRING case in XPCConvert::JSData2Native.
|
||||
JSString *s = InitOrStringify<traits>(cx, v, pval, eNull, eNull);
|
||||
if (!s)
|
||||
return;
|
||||
JSString *s;
|
||||
|
||||
if(JSVAL_IS_STRING(v))
|
||||
{
|
||||
s = JSVAL_TO_STRING(v);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v))
|
||||
{
|
||||
(new(mBuf) implementation_type())->SetIsVoid(PR_TRUE);
|
||||
mValid = JS_TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
s = JS_ValueToString(cx, v);
|
||||
if(!s)
|
||||
{
|
||||
mValid = JS_FALSE;
|
||||
return;
|
||||
}
|
||||
*pval = STRING_TO_JSVAL(s); // Root the new string.
|
||||
}
|
||||
|
||||
JSAutoByteString bytes(cx, s);
|
||||
if(!bytes)
|
||||
@ -728,22 +783,6 @@ xpc_qsACString::xpc_qsACString(JSContext *cx, jsval v, jsval *pval)
|
||||
mValid = JS_TRUE;
|
||||
}
|
||||
|
||||
xpc_qsAUTF8String::xpc_qsAUTF8String(JSContext *cx, jsval v, jsval *pval)
|
||||
{
|
||||
typedef nsCharTraits<PRUnichar> traits;
|
||||
// From the T_UTF8STRING case in XPCConvert::JSData2Native.
|
||||
JSString *s = InitOrStringify<traits>(cx, v, pval, eNull, eNull);
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
size_t len = s->length();
|
||||
const PRUnichar* chars =
|
||||
reinterpret_cast<const PRUnichar*>(JS_GetStringChars(s));
|
||||
|
||||
new(mBuf) implementation_type(chars, len);
|
||||
mValid = JS_TRUE;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
getNative(nsISupports *idobj,
|
||||
QITableEntry* entries,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
@ -313,6 +313,33 @@ public:
|
||||
return *Ptr();
|
||||
}
|
||||
|
||||
protected:
|
||||
/*
|
||||
* Neither field is initialized; that is left to the derived class
|
||||
* constructor. However, the destructor destroys the string object
|
||||
* stored in mBuf, if mValid is true.
|
||||
*/
|
||||
void *mBuf[JS_HOWMANY(sizeof(implementation_type), sizeof(void *))];
|
||||
JSBool mValid;
|
||||
};
|
||||
|
||||
/**
|
||||
* Class for converting a jsval to DOMString.
|
||||
*
|
||||
* xpc_qsDOMString arg0(cx, &argv[0]);
|
||||
* if (!arg0.IsValid())
|
||||
* return JS_FALSE;
|
||||
*
|
||||
* The second argument to the constructor is an in-out parameter. It must
|
||||
* point to a rooted jsval, such as a JSNative argument or return value slot.
|
||||
* The value in the jsval on entry is converted to a string. The constructor
|
||||
* may overwrite that jsval with a string value, to protect the characters of
|
||||
* the string from garbage collection. The caller must leave the jsval alone
|
||||
* for the lifetime of the xpc_qsDOMString.
|
||||
*/
|
||||
class xpc_qsDOMString : public xpc_qsBasicString<nsAString, nsDependentString>
|
||||
{
|
||||
public:
|
||||
/* Enum that defines how JS |null| and |undefined| should be treated. See
|
||||
* the WebIDL specification. eStringify means convert to the string "null"
|
||||
* or "undefined" respectively, via the standard JS ToString() operation;
|
||||
@ -333,88 +360,6 @@ public:
|
||||
eDefaultUndefinedBehavior = eStringify
|
||||
};
|
||||
|
||||
protected:
|
||||
/*
|
||||
* Neither field is initialized; that is left to the derived class
|
||||
* constructor. However, the destructor destroys the string object
|
||||
* stored in mBuf, if mValid is true.
|
||||
*/
|
||||
void *mBuf[JS_HOWMANY(sizeof(implementation_type), sizeof(void *))];
|
||||
JSBool mValid;
|
||||
|
||||
/*
|
||||
* If null is returned, then we either failed or fully initialized
|
||||
* |this|; in either case the caller should return immediately
|
||||
* without doing anything else. Otherwise, the JSString* created
|
||||
* from |v| will be returned. It'll be rooted, as needed, in
|
||||
* *pval. nullBehavior and undefinedBehavior control what happens
|
||||
* when |v| is JSVAL_IS_NULL and JSVAL_IS_VOID respectively.
|
||||
*/
|
||||
template<class traits>
|
||||
JSString* InitOrStringify(JSContext* cx, jsval v, jsval* pval,
|
||||
StringificationBehavior nullBehavior,
|
||||
StringificationBehavior undefinedBehavior) {
|
||||
JSString *s;
|
||||
if(JSVAL_IS_STRING(v))
|
||||
{
|
||||
s = JSVAL_TO_STRING(v);
|
||||
}
|
||||
else
|
||||
{
|
||||
StringificationBehavior behavior = eStringify;
|
||||
if(JSVAL_IS_NULL(v))
|
||||
{
|
||||
behavior = nullBehavior;
|
||||
}
|
||||
else if(JSVAL_IS_VOID(v))
|
||||
{
|
||||
behavior = undefinedBehavior;
|
||||
}
|
||||
|
||||
// If pval is null, that means the argument was optional and
|
||||
// not passed; turn those into void strings if they're
|
||||
// supposed to be stringified.
|
||||
if (behavior != eStringify || !pval)
|
||||
{
|
||||
// Here behavior == eStringify implies !pval, so both eNull and
|
||||
// eStringify should end up with void strings.
|
||||
(new(mBuf) implementation_type(
|
||||
traits::sEmptyBuffer, PRUint32(0)))->
|
||||
SetIsVoid(behavior != eEmpty);
|
||||
mValid = JS_TRUE;
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
s = JS_ValueToString(cx, v);
|
||||
if(!s)
|
||||
{
|
||||
mValid = JS_FALSE;
|
||||
return nsnull;
|
||||
}
|
||||
*pval = STRING_TO_JSVAL(s); // Root the new string.
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Class for converting a jsval to DOMString.
|
||||
*
|
||||
* xpc_qsDOMString arg0(cx, &argv[0]);
|
||||
* if (!arg0.IsValid())
|
||||
* return JS_FALSE;
|
||||
*
|
||||
* The second argument to the constructor is an in-out parameter. It must
|
||||
* point to a rooted jsval, such as a JSNative argument or return value slot.
|
||||
* The value in the jsval on entry is converted to a string. The constructor
|
||||
* may overwrite that jsval with a string value, to protect the characters of
|
||||
* the string from garbage collection. The caller must leave the jsval alone
|
||||
* for the lifetime of the xpc_qsDOMString.
|
||||
*/
|
||||
class xpc_qsDOMString : public xpc_qsBasicString<nsAString, nsDependentString>
|
||||
{
|
||||
public:
|
||||
xpc_qsDOMString(JSContext *cx, jsval v, jsval *pval,
|
||||
StringificationBehavior nullBehavior,
|
||||
StringificationBehavior undefinedBehavior);
|
||||
@ -442,16 +387,6 @@ public:
|
||||
xpc_qsACString(JSContext *cx, jsval v, jsval *pval);
|
||||
};
|
||||
|
||||
/**
|
||||
* And similar for AUTF8String.
|
||||
*/
|
||||
class xpc_qsAUTF8String :
|
||||
public xpc_qsBasicString<nsACString, NS_ConvertUTF16toUTF8>
|
||||
{
|
||||
public:
|
||||
xpc_qsAUTF8String(JSContext* cx, jsval v, jsval *pval);
|
||||
};
|
||||
|
||||
struct xpc_qsSelfRef
|
||||
{
|
||||
xpc_qsSelfRef() : ptr(nsnull) {}
|
||||
|
@ -2468,7 +2468,8 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle
|
||||
*aNewFrame = frameItems.FirstChild();
|
||||
NS_ASSERTION(frameItems.OnlyChild(), "multiple root element frames");
|
||||
} else {
|
||||
contentFrame = NS_NewBlockFormattingContext(mPresShell, styleContext);
|
||||
contentFrame = NS_NewBlockFrame(mPresShell, styleContext,
|
||||
NS_BLOCK_FLOAT_MGR|NS_BLOCK_MARGIN_ROOT);
|
||||
if (!contentFrame)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsFrameItems frameItems;
|
||||
@ -3708,11 +3709,6 @@ nsCSSFrameConstructor::ConstructFrameFromItemInternal(FrameConstructionItem& aIt
|
||||
CHECK_ONLY_ONE_BIT(FCDATA_FUNC_IS_FULL_CTOR, FCDATA_ALLOW_BLOCK_STYLES);
|
||||
CHECK_ONLY_ONE_BIT(FCDATA_MAY_NEED_SCROLLFRAME, FCDATA_FORCE_VIEW);
|
||||
#undef CHECK_ONLY_ONE_BIT
|
||||
NS_ASSERTION(!(bits & FCDATA_FORCED_NON_SCROLLABLE_BLOCK) ||
|
||||
((bits & FCDATA_FUNC_IS_FULL_CTOR) &&
|
||||
data->mFullConstructor ==
|
||||
&nsCSSFrameConstructor::ConstructNonScrollableBlock),
|
||||
"Unexpected FCDATA_FORCED_NON_SCROLLABLE_BLOCK flag");
|
||||
|
||||
// Don't create a subdocument frame for iframes if we're creating extra frames
|
||||
if (aState.mCreatingExtraFrames && aItem.mContent->IsHTML() &&
|
||||
@ -4369,25 +4365,20 @@ nsCSSFrameConstructor::FindDisplayData(const nsStyleDisplay* aDisplay,
|
||||
"Shouldn't propagate scroll in paginated contexts");
|
||||
|
||||
// If the frame is a block-level frame and is scrollable, then wrap it in a
|
||||
// scroll frame.
|
||||
// scroll frame. Except we don't want to do that for paginated contexts for
|
||||
// frames that are block-outside and aren't frames for native anonymous stuff.
|
||||
// The condition on skipping scrollframe construction in the
|
||||
// paginated case needs to match code in ConstructNonScrollableBlock
|
||||
// and in nsFrame::ApplyPaginatedOverflowClipping.
|
||||
// XXX Ignore tables for the time being
|
||||
// XXXbz it would be nice to combine this with the other block
|
||||
// case... Think about how do do this?
|
||||
if (aDisplay->IsBlockInside() &&
|
||||
aDisplay->IsScrollableOverflow() &&
|
||||
!propagatedScrollToViewport) {
|
||||
// Except we don't want to do that for paginated contexts for
|
||||
// frames that are block-outside and aren't frames for native
|
||||
// anonymous stuff.
|
||||
if (mPresShell->GetPresContext()->IsPaginated() &&
|
||||
aDisplay->IsBlockOutside() &&
|
||||
!aContent->IsInNativeAnonymousSubtree()) {
|
||||
static const FrameConstructionData sForcedNonScrollableBlockData =
|
||||
FULL_CTOR_FCDATA(FCDATA_FORCED_NON_SCROLLABLE_BLOCK,
|
||||
&nsCSSFrameConstructor::ConstructNonScrollableBlock);
|
||||
return &sForcedNonScrollableBlockData;
|
||||
}
|
||||
|
||||
!propagatedScrollToViewport &&
|
||||
(!mPresShell->GetPresContext()->IsPaginated() ||
|
||||
!aDisplay->IsBlockOutside() ||
|
||||
aContent->IsInNativeAnonymousSubtree())) {
|
||||
static const FrameConstructionData sScrollableBlockData =
|
||||
FULL_CTOR_FCDATA(0, &nsCSSFrameConstructor::ConstructScrollableBlock);
|
||||
return &sScrollableBlockData;
|
||||
@ -4513,20 +4504,22 @@ nsCSSFrameConstructor::ConstructNonScrollableBlock(nsFrameConstructorState& aSta
|
||||
{
|
||||
nsStyleContext* const styleContext = aItem.mStyleContext;
|
||||
|
||||
// We want a block formatting context root in paginated contexts for
|
||||
// every block that would be scrollable in a non-paginated context.
|
||||
// We mark our blocks with a bit here if this condition is true, so
|
||||
// we can check it later in nsFrame::ApplyPaginatedOverflowClipping.
|
||||
PRBool clipPaginatedOverflow =
|
||||
(aItem.mFCData->mBits & FCDATA_FORCED_NON_SCROLLABLE_BLOCK) != 0;
|
||||
if (aDisplay->IsAbsolutelyPositioned() ||
|
||||
aDisplay->IsFloating() ||
|
||||
NS_STYLE_DISPLAY_INLINE_BLOCK == aDisplay->mDisplay ||
|
||||
clipPaginatedOverflow) {
|
||||
// This check just needs to be the same as the check for using scrollable
|
||||
// blocks in FindDisplayData and the check for clipping in
|
||||
// nsFrame::ApplyPaginatedOverflowClipping; we want a block formatting
|
||||
// context root in paginated contexts for every block that would be
|
||||
// scrollable in a non-paginated context. Note that IsPaginated()
|
||||
// implies that no propagation to viewport has taken place, so we don't
|
||||
// need to check for propagation here.
|
||||
(mPresShell->GetPresContext()->IsPaginated() &&
|
||||
aDisplay->IsBlockInside() &&
|
||||
aDisplay->IsScrollableOverflow() &&
|
||||
aDisplay->IsBlockOutside() &&
|
||||
!aItem.mContent->IsInNativeAnonymousSubtree())) {
|
||||
*aNewFrame = NS_NewBlockFormattingContext(mPresShell, styleContext);
|
||||
if (clipPaginatedOverflow) {
|
||||
(*aNewFrame)->AddStateBits(NS_BLOCK_CLIP_PAGINATED_OVERFLOW);
|
||||
}
|
||||
} else {
|
||||
*aNewFrame = NS_NewBlockFrame(mPresShell, styleContext);
|
||||
}
|
||||
|
@ -728,10 +728,6 @@ private:
|
||||
This can be used with or without FCDATA_FUNC_IS_FULL_CTOR.
|
||||
The child items might still need table pseudo processing. */
|
||||
#define FCDATA_USE_CHILD_ITEMS 0x20000
|
||||
/* If FCDATA_FORCED_NON_SCROLLABLE_BLOCK is set, then this block
|
||||
would have been scrollable but has been forced to be
|
||||
non-scrollable due to being in a paginated context. */
|
||||
#define FCDATA_FORCED_NON_SCROLLABLE_BLOCK 0x40000
|
||||
|
||||
/* Structure representing information about how a frame should be
|
||||
constructed. */
|
||||
|
@ -378,7 +378,7 @@ protected:
|
||||
nsLineList::iterator* aEndIterator,
|
||||
PRBool* aInOverflowLines);
|
||||
|
||||
void SetFlags(nsFrameState aFlags) {
|
||||
void SetFlags(PRUint32 aFlags) {
|
||||
mState &= ~NS_BLOCK_FLAGS_MASK;
|
||||
mState |= aFlags;
|
||||
}
|
||||
|
@ -1231,13 +1231,20 @@ static inline PRBool ApplyOverflowHiddenClipping(nsIFrame* aFrame,
|
||||
static inline PRBool ApplyPaginatedOverflowClipping(nsIFrame* aFrame,
|
||||
const nsStyleDisplay* aDisp)
|
||||
{
|
||||
// If we're paginated and aFrame is a block, and it has
|
||||
// NS_BLOCK_CLIP_PAGINATED_OVERFLOW set, then we want to clip our
|
||||
// overflow.
|
||||
// These conditions on aDisp need to match the conditions for which in
|
||||
// non-paginated contexts we'd create a scrollframe for a block but in a
|
||||
// paginated context we don't. See nsCSSFrameConstructor::FindDisplayData
|
||||
// for the relevant conditions. These conditions must also match those in
|
||||
// nsCSSFrameConstructor::ConstructNonScrollableBlock for creating block
|
||||
// formatting context roots for forced-to-be-no-longer scrollable blocks in
|
||||
// paginated contexts.
|
||||
return
|
||||
aFrame->PresContext()->IsPaginated() &&
|
||||
aDisp->IsBlockInside() &&
|
||||
aDisp->IsScrollableOverflow() &&
|
||||
aDisp->IsBlockOutside() &&
|
||||
aFrame->GetType() == nsGkAtoms::blockFrame &&
|
||||
(aFrame->GetStateBits() & NS_BLOCK_CLIP_PAGINATED_OVERFLOW) != 0;
|
||||
!aFrame->GetContent()->IsInNativeAnonymousSubtree();
|
||||
}
|
||||
|
||||
static PRBool ApplyOverflowClipping(nsDisplayListBuilder* aBuilder,
|
||||
|
@ -62,10 +62,6 @@ class nsTableColFrame;
|
||||
* Additional frame-state bits used by nsBlockFrame
|
||||
* See the meanings at http://www.mozilla.org/newlayout/doc/block-and-line.html
|
||||
*
|
||||
* NS_BLOCK_CLIP_PAGINATED_OVERFLOW is only set in paginated prescontexts, on
|
||||
* blocks which were forced to not have scrollframes but still need to clip
|
||||
* the display of their kids.
|
||||
*
|
||||
* NS_BLOCK_HAS_FIRST_LETTER_STYLE means that the block has first-letter style,
|
||||
* even if it has no actual first-letter frame among its descendants.
|
||||
*
|
||||
@ -76,7 +72,6 @@ class nsTableColFrame;
|
||||
*/
|
||||
#define NS_BLOCK_MARGIN_ROOT NS_FRAME_STATE_BIT(22)
|
||||
#define NS_BLOCK_FLOAT_MGR NS_FRAME_STATE_BIT(23)
|
||||
#define NS_BLOCK_CLIP_PAGINATED_OVERFLOW NS_FRAME_STATE_BIT(28)
|
||||
#define NS_BLOCK_HAS_FIRST_LETTER_STYLE NS_FRAME_STATE_BIT(29)
|
||||
#define NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET NS_FRAME_STATE_BIT(30)
|
||||
#define NS_BLOCK_HAS_FIRST_LETTER_CHILD NS_FRAME_STATE_BIT(31)
|
||||
@ -84,7 +79,6 @@ class nsTableColFrame;
|
||||
// next-in-flows and are not private to blocks
|
||||
#define NS_BLOCK_FLAGS_MASK (NS_BLOCK_MARGIN_ROOT | \
|
||||
NS_BLOCK_FLOAT_MGR | \
|
||||
NS_BLOCK_CLIP_PAGINATED_OVERFLOW | \
|
||||
NS_BLOCK_HAS_FIRST_LETTER_STYLE | \
|
||||
NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET | \
|
||||
NS_BLOCK_HAS_FIRST_LETTER_CHILD)
|
||||
|
@ -1,4 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="reftest-print">
|
||||
This text should show up
|
||||
</html>
|
@ -1,4 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="reftest-print" style="height: 0; overflow: hidden">
|
||||
This text should show up
|
||||
</html>
|
@ -1541,7 +1541,6 @@ fails-if(!haveTestPlugin) == 599476.html 599476-ref.html
|
||||
== 604737.html 604737-ref.html
|
||||
== 605138-1.html 605138-1-ref.html
|
||||
== 605157-1.xhtml 605157-1-ref.xhtml
|
||||
== 609272-1.html 609272-1-ref.html
|
||||
== 608636-1.html 608636-1-ref.html
|
||||
== 613433-1.html 613433-1-ref.html
|
||||
== 613433-1.html 613433-2-ref.html
|
||||
|
@ -39,5 +39,3 @@ asserts-if(cocoaWidget,0-2) == size-change-1.html size-change-1-ref.html
|
||||
== text-bidi-rtl-test.html text-bidi-rtl-ref.html
|
||||
|
||||
!= text-font-lang.html text-font-lang-notref.html
|
||||
|
||||
== strokeText-path.html strokeText-path-ref.html
|
||||
|
@ -1,23 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript"><!--
|
||||
window.onload = function () {
|
||||
var canvas = document.getElementById('testCanvas'),
|
||||
context = canvas.getContext('2d');
|
||||
|
||||
// draw some text
|
||||
context.font = 'bold 40px sans-serif';
|
||||
context.strokeText("Hello world!", 10, 50);
|
||||
};
|
||||
// --></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>You should see only see "Hello world!" below, without any additional
|
||||
line. JavaScript is required.</p>
|
||||
|
||||
<p><canvas id="testCanvas" width="400" height="300">You need Canvas
|
||||
support.</canvas></p>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,33 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript"><!--
|
||||
window.onload = function () {
|
||||
var canvas = document.getElementById('testCanvas'),
|
||||
context = canvas.getContext('2d');
|
||||
|
||||
// draw a path
|
||||
context.beginPath();
|
||||
context.moveTo(10, 10);
|
||||
context.lineTo(200, 10);
|
||||
context.lineTo(200, 200);
|
||||
context.stroke();
|
||||
context.closePath();
|
||||
|
||||
context.clearRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// draw some text
|
||||
context.font = 'bold 40px sans-serif';
|
||||
context.strokeText("Hello world!", 10, 50);
|
||||
};
|
||||
// --></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>You should see only see "Hello world!" below, without any additional
|
||||
line. JavaScript is required.</p>
|
||||
|
||||
<p><canvas id="testCanvas" width="400" height="300">You need Canvas
|
||||
support.</canvas></p>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -468,7 +468,10 @@ nsMediaQuery::AppendToString(nsAString& aString) const
|
||||
break;
|
||||
case nsMediaFeature::eResolution:
|
||||
{
|
||||
aString.AppendFloat(expr.mValue.GetFloatValue());
|
||||
nsAutoString buffer;
|
||||
buffer.AppendFloat(expr.mValue.GetFloatValue());
|
||||
aString.Append(buffer);
|
||||
buffer.Truncate();
|
||||
if (expr.mValue.GetUnit() == eCSSUnit_Inch) {
|
||||
aString.AppendLiteral("dpi");
|
||||
} else {
|
||||
|
@ -769,7 +769,9 @@ nsCSSValue::AppendToString(nsCSSProperty aProperty, nsAString& aResult) const
|
||||
css::SerializeCalc(*this, ops);
|
||||
}
|
||||
else if (eCSSUnit_Integer == unit) {
|
||||
aResult.AppendInt(GetIntValue(), 10);
|
||||
nsAutoString tmpStr;
|
||||
tmpStr.AppendInt(GetIntValue(), 10);
|
||||
aResult.Append(tmpStr);
|
||||
}
|
||||
else if (eCSSUnit_Enumerated == unit) {
|
||||
if (eCSSProperty_text_decoration == aProperty) {
|
||||
@ -830,25 +832,28 @@ nsCSSValue::AppendToString(nsCSSProperty aProperty, nsAString& aResult) const
|
||||
// round-tripping of all other rgba() values.
|
||||
aResult.AppendLiteral("transparent");
|
||||
} else {
|
||||
nsAutoString tmpStr;
|
||||
PRUint8 a = NS_GET_A(color);
|
||||
if (a < 255) {
|
||||
aResult.AppendLiteral("rgba(");
|
||||
tmpStr.AppendLiteral("rgba(");
|
||||
} else {
|
||||
aResult.AppendLiteral("rgb(");
|
||||
tmpStr.AppendLiteral("rgb(");
|
||||
}
|
||||
|
||||
NS_NAMED_LITERAL_STRING(comma, ", ");
|
||||
|
||||
aResult.AppendInt(NS_GET_R(color), 10);
|
||||
aResult.Append(comma);
|
||||
aResult.AppendInt(NS_GET_G(color), 10);
|
||||
aResult.Append(comma);
|
||||
aResult.AppendInt(NS_GET_B(color), 10);
|
||||
tmpStr.AppendInt(NS_GET_R(color), 10);
|
||||
tmpStr.Append(comma);
|
||||
tmpStr.AppendInt(NS_GET_G(color), 10);
|
||||
tmpStr.Append(comma);
|
||||
tmpStr.AppendInt(NS_GET_B(color), 10);
|
||||
if (a < 255) {
|
||||
aResult.Append(comma);
|
||||
aResult.AppendFloat(nsStyleUtil::ColorComponentToFloat(a));
|
||||
tmpStr.Append(comma);
|
||||
tmpStr.AppendFloat(nsStyleUtil::ColorComponentToFloat(a));
|
||||
}
|
||||
aResult.Append(PRUnichar(')'));
|
||||
tmpStr.Append(PRUnichar(')'));
|
||||
|
||||
aResult.Append(tmpStr);
|
||||
}
|
||||
}
|
||||
else if (eCSSUnit_URL == unit || eCSSUnit_Image == unit) {
|
||||
@ -866,10 +871,14 @@ nsCSSValue::AppendToString(nsCSSProperty aProperty, nsAString& aResult) const
|
||||
aResult.Append(NS_LITERAL_STRING(")"));
|
||||
}
|
||||
else if (eCSSUnit_Percent == unit) {
|
||||
aResult.AppendFloat(GetPercentValue() * 100.0f);
|
||||
nsAutoString tmpStr;
|
||||
tmpStr.AppendFloat(GetPercentValue() * 100.0f);
|
||||
aResult.Append(tmpStr);
|
||||
}
|
||||
else if (eCSSUnit_Percent < unit) { // length unit
|
||||
aResult.AppendFloat(GetFloatValue());
|
||||
nsAutoString tmpStr;
|
||||
tmpStr.AppendFloat(GetFloatValue());
|
||||
aResult.Append(tmpStr);
|
||||
}
|
||||
else if (eCSSUnit_Gradient == unit) {
|
||||
nsCSSValueGradient* gradient = GetGradientValue();
|
||||
|
@ -384,6 +384,34 @@ class nsTString_CharT : public nsTSubstring_CharT
|
||||
NS_COM void AppendWithConversion( const nsTAString_IncompatibleCharT& aString );
|
||||
NS_COM void AppendWithConversion( const incompatible_char_type* aData, PRInt32 aLength=-1 );
|
||||
|
||||
using nsTSubstring_CharT::AppendInt;
|
||||
|
||||
/**
|
||||
* Append the given integer to this string
|
||||
* @param aInteger The integer to append
|
||||
* @param aRadix The radix to use; can be 8, 10 or 16.
|
||||
* @deprecated Use AppendInt( PRInt32 aInteger ) or
|
||||
* AppendInt( PRUint32 aInteger, PRInt32 aRadix = 10 )
|
||||
*/
|
||||
NS_COM void AppendInt( PRInt32 aInteger, PRInt32 aRadix ); //radix=8,10 or 16
|
||||
|
||||
/**
|
||||
* Append the given 64-bit integer to this string.
|
||||
* @param aInteger The integer to append
|
||||
* @param aRadix The radix to use; can be 8, 10 or 16.
|
||||
* @deprecated Use AppendInt( PRInt64 aInteger ) or
|
||||
* AppendInt( PRUint64 aInteger, PRInt32 aRadix = 10 )
|
||||
*/
|
||||
NS_COM void AppendInt( PRInt64 aInteger, PRInt32 aRadix );
|
||||
|
||||
/**
|
||||
* Append the given float to this string
|
||||
*/
|
||||
|
||||
NS_COM void AppendFloat( float aFloat );
|
||||
|
||||
NS_COM void AppendFloat( double aFloat );
|
||||
|
||||
#endif // !MOZ_STRING_WITH_OBSOLETE_API
|
||||
|
||||
|
||||
|
@ -418,17 +418,6 @@ class nsTSubstring_CharT
|
||||
AppendPrintf( fmt, aInteger );
|
||||
}
|
||||
|
||||
/**
|
||||
* Append the given float to this string
|
||||
*/
|
||||
void AppendFloat( float aFloat )
|
||||
{ DoAppendFloat(aFloat, 6); }
|
||||
void AppendFloat( double aFloat )
|
||||
{ DoAppendFloat(aFloat, 15); }
|
||||
private:
|
||||
NS_COM void NS_FASTCALL DoAppendFloat( double aFloat, int digits );
|
||||
public:
|
||||
|
||||
// AppendLiteral must ONLY be applied to an actual literal string.
|
||||
// Do not attempt to use it with a regular char* pointer, or with a char
|
||||
// array variable. Use AppendASCII for those.
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "nsCRT.h"
|
||||
#include "nsUTF8Utils.h"
|
||||
#include "prdtoa.h"
|
||||
#include "prprf.h"
|
||||
|
||||
/* ***** BEGIN RICKG BLOCK *****
|
||||
*
|
||||
@ -799,6 +800,99 @@ RFindCharInSet( const CharT* data, PRUint32 dataLen, const SetCharT* set )
|
||||
return kNotFound;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a copy of |PR_cnvtf| with a bug fixed. (The second argument
|
||||
* of PR_dtoa is 2 rather than 1.)
|
||||
*
|
||||
* XXX(darin): if this is the right thing, then why wasn't it fixed in NSPR?!?
|
||||
*/
|
||||
void
|
||||
Modified_cnvtf(char *buf, int bufsz, int prcsn, double fval)
|
||||
{
|
||||
PRIntn decpt, sign, numdigits;
|
||||
char *num, *nump;
|
||||
char *bufp = buf;
|
||||
char *endnum;
|
||||
|
||||
/* If anything fails, we store an empty string in 'buf' */
|
||||
num = (char*)malloc(bufsz);
|
||||
if (num == NULL) {
|
||||
buf[0] = '\0';
|
||||
return;
|
||||
}
|
||||
if (PR_dtoa(fval, 2, prcsn, &decpt, &sign, &endnum, num, bufsz)
|
||||
== PR_FAILURE) {
|
||||
buf[0] = '\0';
|
||||
goto done;
|
||||
}
|
||||
numdigits = endnum - num;
|
||||
nump = num;
|
||||
|
||||
/*
|
||||
* The NSPR code had a fancy way of checking that we weren't dealing
|
||||
* with -0.0 or -NaN, but I'll just use < instead.
|
||||
* XXX Should we check !isnan(fval) as well? Is it portable? We
|
||||
* probably don't need to bother since NAN isn't portable.
|
||||
*/
|
||||
if (sign && fval < 0.0f) {
|
||||
*bufp++ = '-';
|
||||
}
|
||||
|
||||
if (decpt == 9999) {
|
||||
while ((*bufp++ = *nump++) != 0) {} /* nothing to execute */
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (decpt > (prcsn+1) || decpt < -(prcsn-1) || decpt < -5) {
|
||||
*bufp++ = *nump++;
|
||||
if (numdigits != 1) {
|
||||
*bufp++ = '.';
|
||||
}
|
||||
|
||||
while (*nump != '\0') {
|
||||
*bufp++ = *nump++;
|
||||
}
|
||||
*bufp++ = 'e';
|
||||
PR_snprintf(bufp, bufsz - (bufp - buf), "%+d", decpt-1);
|
||||
}
|
||||
else if (decpt >= 0) {
|
||||
if (decpt == 0) {
|
||||
*bufp++ = '0';
|
||||
}
|
||||
else {
|
||||
while (decpt--) {
|
||||
if (*nump != '\0') {
|
||||
*bufp++ = *nump++;
|
||||
}
|
||||
else {
|
||||
*bufp++ = '0';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (*nump != '\0') {
|
||||
*bufp++ = '.';
|
||||
while (*nump != '\0') {
|
||||
*bufp++ = *nump++;
|
||||
}
|
||||
}
|
||||
*bufp++ = '\0';
|
||||
}
|
||||
else if (decpt < 0) {
|
||||
*bufp++ = '0';
|
||||
*bufp++ = '.';
|
||||
while (decpt++) {
|
||||
*bufp++ = '0';
|
||||
}
|
||||
|
||||
while (*nump != '\0') {
|
||||
*bufp++ = *nump++;
|
||||
}
|
||||
*bufp++ = '\0';
|
||||
}
|
||||
done:
|
||||
free(num);
|
||||
}
|
||||
|
||||
/**
|
||||
* this method changes the meaning of |offset| and |count|:
|
||||
*
|
||||
@ -1077,4 +1171,133 @@ nsString::AppendWithConversion( const nsACString& aData )
|
||||
AppendASCIItoUTF16(aData, *this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* nsTString::AppendInt
|
||||
*/
|
||||
|
||||
void
|
||||
nsCString::AppendInt( PRInt32 aInteger, PRInt32 aRadix )
|
||||
{
|
||||
char buf[20];
|
||||
const char* fmt;
|
||||
switch (aRadix) {
|
||||
case 8:
|
||||
fmt = "%o";
|
||||
break;
|
||||
case 10:
|
||||
fmt = "%d";
|
||||
break;
|
||||
default:
|
||||
NS_ASSERTION(aRadix == 16, "Invalid radix!");
|
||||
fmt = "%x";
|
||||
}
|
||||
PR_snprintf(buf, sizeof(buf), fmt, aInteger);
|
||||
Append(buf);
|
||||
}
|
||||
|
||||
void
|
||||
nsString::AppendInt( PRInt32 aInteger, PRInt32 aRadix )
|
||||
{
|
||||
char buf[20];
|
||||
const char* fmt;
|
||||
switch (aRadix) {
|
||||
case 8:
|
||||
fmt = "%o";
|
||||
break;
|
||||
case 10:
|
||||
fmt = "%d";
|
||||
break;
|
||||
default:
|
||||
NS_ASSERTION(aRadix == 16, "Invalid radix!");
|
||||
fmt = "%x";
|
||||
}
|
||||
PR_snprintf(buf, sizeof(buf), fmt, aInteger);
|
||||
AppendASCIItoUTF16(buf, *this);
|
||||
}
|
||||
|
||||
void
|
||||
nsCString::AppendInt( PRInt64 aInteger, PRInt32 aRadix )
|
||||
{
|
||||
char buf[30];
|
||||
const char* fmt;
|
||||
switch (aRadix) {
|
||||
case 8:
|
||||
fmt = "%llo";
|
||||
break;
|
||||
case 10:
|
||||
fmt = "%lld";
|
||||
break;
|
||||
default:
|
||||
NS_ASSERTION(aRadix == 16, "Invalid radix!");
|
||||
fmt = "%llx";
|
||||
}
|
||||
PR_snprintf(buf, sizeof(buf), fmt, aInteger);
|
||||
Append(buf);
|
||||
}
|
||||
|
||||
void
|
||||
nsString::AppendInt( PRInt64 aInteger, PRInt32 aRadix )
|
||||
{
|
||||
char buf[30];
|
||||
const char* fmt;
|
||||
switch (aRadix) {
|
||||
case 8:
|
||||
fmt = "%llo";
|
||||
break;
|
||||
case 10:
|
||||
fmt = "%lld";
|
||||
break;
|
||||
default:
|
||||
NS_ASSERTION(aRadix == 16, "Invalid radix!");
|
||||
fmt = "%llx";
|
||||
}
|
||||
PR_snprintf(buf, sizeof(buf), fmt, aInteger);
|
||||
AppendASCIItoUTF16(buf, *this);
|
||||
}
|
||||
|
||||
/**
|
||||
* nsTString::AppendFloat
|
||||
*/
|
||||
|
||||
void
|
||||
nsCString::AppendFloat( float aFloat )
|
||||
{
|
||||
char buf[40];
|
||||
// Use Modified_cnvtf, which is locale-insensitive, instead of the
|
||||
// locale-sensitive PR_snprintf or sprintf(3)
|
||||
Modified_cnvtf(buf, sizeof(buf), 6, aFloat);
|
||||
Append(buf);
|
||||
}
|
||||
|
||||
void
|
||||
nsString::AppendFloat( float aFloat )
|
||||
{
|
||||
char buf[40];
|
||||
// Use Modified_cnvtf, which is locale-insensitive, instead of the
|
||||
// locale-sensitive PR_snprintf or sprintf(3)
|
||||
Modified_cnvtf(buf, sizeof(buf), 6, aFloat);
|
||||
AppendWithConversion(buf);
|
||||
}
|
||||
|
||||
void
|
||||
nsCString::AppendFloat( double aFloat )
|
||||
{
|
||||
char buf[40];
|
||||
// Use Modified_cnvtf, which is locale-insensitive, instead of the
|
||||
// locale-sensitive PR_snprintf or sprintf(3)
|
||||
Modified_cnvtf(buf, sizeof(buf), 15, aFloat);
|
||||
Append(buf);
|
||||
}
|
||||
|
||||
void
|
||||
nsString::AppendFloat( double aFloat )
|
||||
{
|
||||
char buf[40];
|
||||
// Use Modified_cnvtf, which is locale-insensitive, instead of the
|
||||
// locale-sensitive PR_snprintf or sprintf(3)
|
||||
Modified_cnvtf(buf, sizeof(buf), 15, aFloat);
|
||||
AppendWithConversion(buf);
|
||||
}
|
||||
|
||||
#endif // !MOZ_STRING_WITH_OBSOLETE_API
|
||||
|
@ -35,7 +35,6 @@
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "prdtoa.h"
|
||||
|
||||
#ifdef XPCOM_STRING_CONSTRUCTOR_OUT_OF_LINE
|
||||
nsTSubstring_CharT::nsTSubstring_CharT( char_type *data, size_type length,
|
||||
@ -743,111 +742,3 @@ void nsTSubstring_CharT::AppendPrintf( const char* format, ...)
|
||||
AppendASCII(buf, len);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
||||
/* hack to make sure we define Modified_cnvtf only once */
|
||||
#ifdef CharT_is_PRUnichar
|
||||
/**
|
||||
* This is a copy of |PR_cnvtf| with a bug fixed. (The second argument
|
||||
* of PR_dtoa is 2 rather than 1.)
|
||||
*
|
||||
* XXX(darin): if this is the right thing, then why wasn't it fixed in NSPR?!?
|
||||
*/
|
||||
static void
|
||||
Modified_cnvtf(char *buf, int bufsz, int prcsn, double fval)
|
||||
{
|
||||
PRIntn decpt, sign, numdigits;
|
||||
char *num, *nump;
|
||||
char *bufp = buf;
|
||||
char *endnum;
|
||||
|
||||
/* If anything fails, we store an empty string in 'buf' */
|
||||
num = (char*)malloc(bufsz);
|
||||
if (num == NULL) {
|
||||
buf[0] = '\0';
|
||||
return;
|
||||
}
|
||||
if (PR_dtoa(fval, 2, prcsn, &decpt, &sign, &endnum, num, bufsz)
|
||||
== PR_FAILURE) {
|
||||
buf[0] = '\0';
|
||||
goto done;
|
||||
}
|
||||
numdigits = endnum - num;
|
||||
nump = num;
|
||||
|
||||
/*
|
||||
* The NSPR code had a fancy way of checking that we weren't dealing
|
||||
* with -0.0 or -NaN, but I'll just use < instead.
|
||||
* XXX Should we check !isnan(fval) as well? Is it portable? We
|
||||
* probably don't need to bother since NAN isn't portable.
|
||||
*/
|
||||
if (sign && fval < 0.0f) {
|
||||
*bufp++ = '-';
|
||||
}
|
||||
|
||||
if (decpt == 9999) {
|
||||
while ((*bufp++ = *nump++) != 0) {} /* nothing to execute */
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (decpt > (prcsn+1) || decpt < -(prcsn-1) || decpt < -5) {
|
||||
*bufp++ = *nump++;
|
||||
if (numdigits != 1) {
|
||||
*bufp++ = '.';
|
||||
}
|
||||
|
||||
while (*nump != '\0') {
|
||||
*bufp++ = *nump++;
|
||||
}
|
||||
*bufp++ = 'e';
|
||||
PR_snprintf(bufp, bufsz - (bufp - buf), "%+d", decpt-1);
|
||||
}
|
||||
else if (decpt >= 0) {
|
||||
if (decpt == 0) {
|
||||
*bufp++ = '0';
|
||||
}
|
||||
else {
|
||||
while (decpt--) {
|
||||
if (*nump != '\0') {
|
||||
*bufp++ = *nump++;
|
||||
}
|
||||
else {
|
||||
*bufp++ = '0';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (*nump != '\0') {
|
||||
*bufp++ = '.';
|
||||
while (*nump != '\0') {
|
||||
*bufp++ = *nump++;
|
||||
}
|
||||
}
|
||||
*bufp++ = '\0';
|
||||
}
|
||||
else if (decpt < 0) {
|
||||
*bufp++ = '0';
|
||||
*bufp++ = '.';
|
||||
while (decpt++) {
|
||||
*bufp++ = '0';
|
||||
}
|
||||
|
||||
while (*nump != '\0') {
|
||||
*bufp++ = *nump++;
|
||||
}
|
||||
*bufp++ = '\0';
|
||||
}
|
||||
done:
|
||||
free(num);
|
||||
}
|
||||
#endif /* CharT_is_PRUnichar */
|
||||
|
||||
void
|
||||
nsTSubstring_CharT::DoAppendFloat( double aFloat, int digits )
|
||||
{
|
||||
char buf[40];
|
||||
// Use Modified_cnvtf, which is locale-insensitive, instead of the
|
||||
// locale-sensitive PR_snprintf or sprintf(3)
|
||||
Modified_cnvtf(buf, sizeof(buf), digits, aFloat);
|
||||
AppendASCII(buf);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user