зеркало из https://github.com/mozilla/pjs.git
[XForms] xf:textarea appears to have 4096 characters size restriction. Bug 357652, patch by surkov, r=doronr+aaronr
This commit is contained in:
Родитель
35a2ff5700
Коммит
21b14a3d7b
|
@ -674,6 +674,7 @@ nsXFormsMDGEngine::SetNodeValueInternal(nsIDOMNode *aContextNode,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nsIDOMNode::ELEMENT_NODE:
|
case nsIDOMNode::ELEMENT_NODE:
|
||||||
|
|
||||||
rv = aContextNode->GetFirstChild(getter_AddRefs(childNode));
|
rv = aContextNode->GetFirstChild(getter_AddRefs(childNode));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
@ -684,19 +685,41 @@ nsXFormsMDGEngine::SetNodeValueInternal(nsIDOMNode *aContextNode,
|
||||||
PRUint16 childType;
|
PRUint16 childType;
|
||||||
rv = childNode->GetNodeType(&childType);
|
rv = childNode->GetNodeType(&childType);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
if ( childType == nsIDOMNode::TEXT_NODE
|
if (childType == nsIDOMNode::TEXT_NODE ||
|
||||||
|| childType == nsIDOMNode::CDATA_SECTION_NODE) {
|
childType == nsIDOMNode::CDATA_SECTION_NODE) {
|
||||||
rv = childNode->SetNodeValue(aNodeValue);
|
rv = childNode->SetNodeValue(aNodeValue);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
// Remove all leading text child nodes except first one (see
|
||||||
|
// nsXFormsUtils::GetNodeValue method for motivation).
|
||||||
|
nsCOMPtr<nsIDOMNode> siblingNode;
|
||||||
|
while (true) {
|
||||||
|
rv = childNode->GetNextSibling(getter_AddRefs(siblingNode));
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
if (!siblingNode)
|
||||||
|
break;
|
||||||
|
|
||||||
|
rv = siblingNode->GetNodeType(&childType);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
if (childType != nsIDOMNode::TEXT_NODE &&
|
||||||
|
childType != nsIDOMNode::CDATA_SECTION_NODE) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
nsCOMPtr<nsIDOMNode> stubNode;
|
||||||
|
rv = aContextNode->RemoveChild(siblingNode,
|
||||||
|
getter_AddRefs(stubNode));
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Not a text child, create a new one
|
// Not a text child, create a new one
|
||||||
rv = CreateNewChild(aContextNode, aNodeValue, childNode);
|
rv = CreateNewChild(aContextNode, aNodeValue, childNode);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/// Unsupported nodeType
|
/// Unsupported nodeType
|
||||||
/// @todo Should return more specific error? (XXX)
|
/// @todo Should return more specific error? (XXX)
|
||||||
|
|
|
@ -759,8 +759,22 @@ nsXFormsUtils::GetNodeValue(nsIDOMNode* aDataNode, nsAString& aNodeValue)
|
||||||
|
|
||||||
case nsIDOMNode::ELEMENT_NODE:
|
case nsIDOMNode::ELEMENT_NODE:
|
||||||
{
|
{
|
||||||
// "If text child nodes are present, returns the string-value of the
|
// XForms specs 8.1.1 (http://www.w3.org/TR/xforms/slice8.html#ui-processing)
|
||||||
// first text child node. Otherwise, returns "" (the empty string)".
|
// says: 'if text child nodes are present, returns the string-value of the
|
||||||
|
// first text child node. Otherwise, returns "" (the empty string)'.
|
||||||
|
// The 'text child node' that is mentioned above is from the xforms
|
||||||
|
// instance document which is, according to spec, is formed by
|
||||||
|
// 'creating an XPath data model'. So we need to treat 'text node' in
|
||||||
|
// this case as an XPath text node and not a DOM text node.
|
||||||
|
// DOM XPath specs (http://www.w3.org/TR/2002/WD-DOM-Level-3-XPath-20020328/xpath.html#TextNodes)
|
||||||
|
// says:
|
||||||
|
// 'Applications using XPath in an environment with fragmented text nodes
|
||||||
|
// must manually gather the text of a single logical text node possibly
|
||||||
|
// from multiple nodes beginning with the first Text node or CDATASection
|
||||||
|
// node returned by the implementation'.
|
||||||
|
|
||||||
|
// Therefore we concatenate contiguous CDATA/DOM text nodes and return
|
||||||
|
// as node value.
|
||||||
|
|
||||||
// Find the first child text node.
|
// Find the first child text node.
|
||||||
nsCOMPtr<nsIDOMNodeList> childNodes;
|
nsCOMPtr<nsIDOMNodeList> childNodes;
|
||||||
|
@ -771,6 +785,7 @@ nsXFormsUtils::GetNodeValue(nsIDOMNode* aDataNode, nsAString& aNodeValue)
|
||||||
PRUint32 childCount;
|
PRUint32 childCount;
|
||||||
childNodes->GetLength(&childCount);
|
childNodes->GetLength(&childCount);
|
||||||
|
|
||||||
|
nsAutoString value;
|
||||||
for (PRUint32 i = 0; i < childCount; ++i) {
|
for (PRUint32 i = 0; i < childCount; ++i) {
|
||||||
childNodes->Item(i, getter_AddRefs(child));
|
childNodes->Item(i, getter_AddRefs(child));
|
||||||
NS_ASSERTION(child, "DOMNodeList length is wrong!");
|
NS_ASSERTION(child, "DOMNodeList length is wrong!");
|
||||||
|
@ -778,7 +793,9 @@ nsXFormsUtils::GetNodeValue(nsIDOMNode* aDataNode, nsAString& aNodeValue)
|
||||||
child->GetNodeType(&nodeType);
|
child->GetNodeType(&nodeType);
|
||||||
if (nodeType == nsIDOMNode::TEXT_NODE ||
|
if (nodeType == nsIDOMNode::TEXT_NODE ||
|
||||||
nodeType == nsIDOMNode::CDATA_SECTION_NODE) {
|
nodeType == nsIDOMNode::CDATA_SECTION_NODE) {
|
||||||
child->GetNodeValue(aNodeValue);
|
child->GetNodeValue(value);
|
||||||
|
aNodeValue.Append(value);
|
||||||
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче