/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* * nsIContentSerializer implementation that can be used with an * nsIDocumentEncoder to convert an XML DOM to an XML string that * could be parsed into more or less the original DOM.
*/
// to be readable, we assume that an indented line contains // at least this number of characters (arbitrary value here). // This is a limit for the indentation. #define MIN_INDENTED_LINE_LENGTH 15
// the string used to indent. #define INDENT_STRING " " #define INDENT_STRING_LENGTH 2
nsresult NS_NewXMLContentSerializer(nsIContentSerializer** aSerializer) {
RefPtr<nsXMLContentSerializer> it = new nsXMLContentSerializer();
it.forget(aSerializer); return NS_OK;
}
NS_ASSERTION(aStartOffset >= 0, "Negative start offset for text fragment!");
NS_ASSERTION(aStartOffset <= endoffset, "A start offset is beyond the end of the text fragment!");
if (length <= 0) { // XXX Zero is a legal value, maybe non-zero values should be an // error. return NS_OK;
}
decl->mPrefix.Assign(aPrefix);
decl->mURI.Assign(aURI); // Don't addref - this weak reference will be removed when // we pop the stack
decl->mOwner = aOwner; return NS_OK;
}
if (aURI.EqualsLiteral("http://www.w3.org/XML/1998/namespace")) { // The prefix must be xml for this namespace. We don't need to declare it, // so always just set the prefix to xml.
aPrefix.AssignLiteral("xml");
returnfalse;
}
bool mustHavePrefix; if (aIsAttribute) { if (aURI.IsEmpty()) { // Attribute in the null namespace. This just shouldn't have a prefix. // And there's no need to push any namespace decls
aPrefix.Truncate(); returnfalse;
}
// Attribute not in the null namespace -- must have a prefix
mustHavePrefix = true;
} else { // Not an attribute, so doesn't _have_ to have a prefix
mustHavePrefix = false;
}
// Keep track of the closest prefix that's bound to aURI and whether we've // found such a thing. closestURIMatch holds the prefix, and uriMatch // indicates whether we actually have one.
nsAutoString closestURIMatch; bool uriMatch = false;
// Also keep track of whether we've seen aPrefix already. If we have, that // means that it's already bound to a URI different from aURI, so even if we // later (so in a more outer scope) see it bound to aURI we can't reuse it. bool haveSeenOurPrefix = false;
int32_t count = mNameSpaceStack.Length();
int32_t index = count - 1; while (index >= 0) {
NameSpaceDecl& decl = mNameSpaceStack.ElementAt(index); // Check if we've found a prefix match if (aPrefix.Equals(decl.mPrefix)) { // If the URIs match and aPrefix is not bound to any other URI, we can // use aPrefix if (!haveSeenOurPrefix && aURI.Equals(decl.mURI)) { // Just use our uriMatch stuff. That will deal with an empty aPrefix // the right way. We can break out of the loop now, though.
uriMatch = true;
closestURIMatch = aPrefix; break;
}
haveSeenOurPrefix = true;
// If they don't, and either: // 1) We have a prefix (so we'd be redeclaring this prefix to point to a // different namespace) or // 2) We're looking at an existing default namespace decl on aElement (so // we can't create a new default namespace decl for this URI) // then generate a new prefix. Note that we do NOT generate new prefixes // if we happen to have aPrefix == decl->mPrefix == "" and mismatching // URIs when |decl| doesn't have aElement as its owner. In that case we // can simply push the new namespace URI as the default namespace for // aElement. if (!aPrefix.IsEmpty() || decl.mOwner == aElement) {
NS_ASSERTION(!aURI.IsEmpty(), "Not allowed to add a xmlns attribute with an empty " "namespace name unless it declares the default " "namespace.");
GenerateNewPrefix(aPrefix); // Now we need to validate our new prefix/uri combination; check it // against the full namespace stack again. Note that just restarting // the while loop is ok, since we haven't changed aURI, so the // closestURIMatch and uriMatch state is not affected.
index = count - 1;
haveSeenOurPrefix = false; continue;
}
}
// If we've found a URI match, then record the first one if (!uriMatch && aURI.Equals(decl.mURI)) { // Need to check that decl->mPrefix is not declared anywhere closer to // us. If it is, we can't use it. bool prefixOK = true;
int32_t index2; for (index2 = count - 1; index2 > index && prefixOK; --index2) {
prefixOK = (mNameSpaceStack[index2].mPrefix != decl.mPrefix);
}
if (prefixOK) {
uriMatch = true;
closestURIMatch.Assign(decl.mPrefix);
}
}
--index;
}
// At this point the following invariants hold: // 1) The prefix in closestURIMatch is mapped to aURI in our scope if // uriMatch is set. // 2) There is nothing on the namespace stack that has aPrefix as the prefix // and a _different_ URI, except for the case aPrefix.IsEmpty (and // possible default namespaces on ancestors)
// So if uriMatch is set it's OK to use the closestURIMatch prefix. The one // exception is when closestURIMatch is actually empty (default namespace // decl) and we must have a prefix. if (uriMatch && (!mustHavePrefix || !closestURIMatch.IsEmpty())) {
aPrefix.Assign(closestURIMatch); returnfalse;
}
if (aPrefix.IsEmpty()) { // At this point, aPrefix is empty (which means we never had a prefix to // start with). If we must have a prefix, just generate a new prefix and // then send it back through the namespace stack checks to make sure it's // OK. if (mustHavePrefix) {
GenerateNewPrefix(aPrefix); return ConfirmPrefix(aPrefix, aURI, aElement, aIsAttribute);
}
// One final special case. If aPrefix is empty and we never saw an empty // prefix (default namespace decl) on the namespace stack and we're in the // null namespace there is no reason to output an |xmlns=""| here. It just // makes the output less readable. if (!haveSeenOurPrefix && aURI.IsEmpty()) { returnfalse;
}
}
// Now just set aURI as the new default namespace URI. Indicate that we need // to create a namespace decl for the final prefix returntrue;
}
bool nsXMLContentSerializer::SerializeAttr(const nsAString& aPrefix, const nsAString& aName, const nsAString& aValue,
nsAString& aStr, bool aDoEscapeEntities) { // Because this method can short-circuit AppendToString for raw output, we // need to make sure that we're not inappropriately serializing attributes // from outside the body if (mBodyOnly && !mInBody) { returntrue;
}
nsAutoString attrString_; // For innerHTML we can do faster appending without // temporary strings. bool rawAppend = mDoRaw && aDoEscapeEntities;
nsAString& attrString = (rawAppend) ? aStr : attrString_;
if (aDoEscapeEntities) { // if problem characters are turned into character entity references // then there will be no problem with the value delimiter characters
NS_ENSURE_TRUE(attrString.AppendLiteral("=\"", mozilla::fallible), false);
NS_ENSURE_TRUE(attrString.Append(char16_t('"'), mozilla::fallible), false); if (rawAppend) { returntrue;
}
} else { // Depending on whether the attribute value contains quotes or apostrophes // we need to select the delimiter character and escape characters using // character entity references, ignoring the value of aDoEscapeEntities. // See http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.3.2.2 for // the standard on character entity references in values. We also have to // make sure to escape any '&' characters.
if (mDoWrap && mColPos + attrString.Length() > mMaxColumn) { // Attr would cause us to overrun the max width, so begin a new line.
NS_ENSURE_TRUE(AppendNewLineToString(aStr), false);
// Chomp the leading space.
nsDependentSubstring chomped(attrString, 1); if (mDoFormat && mIndent.Length() + chomped.Length() <= mMaxColumn) {
NS_ENSURE_TRUE(AppendIndentation(aStr), false);
}
NS_ENSURE_TRUE(AppendToStringConvertLF(chomped, aStr), false);
} else {
NS_ENSURE_TRUE(AppendToStringConvertLF(attrString, aStr), false);
}
// First scan for namespace declarations, pushing each on the stack
uint32_t skipAttr = count; for (index = 0; index < count; index++) { const BorrowedAttrInfo info = aElement->GetAttrInfoAt(index); const nsAttrName* name = info.mName;
if (namespaceID == kNameSpaceID_XMLNS || // Also push on the stack attrs named "xmlns" in the null // namespace... because once we serialize those out they'll look like // namespace decls. :( // XXXbz what if we have both "xmlns" in the null namespace and "xmlns" // in the xmlns namespace?
(namespaceID == kNameSpaceID_None && attrName == nsGkAtoms::xmlns)) {
info.mValue->ToString(uriStr);
if (!name->GetPrefix()) { if (aTagNamespaceURI.IsEmpty() && !uriStr.IsEmpty()) { // If the element is in no namespace we need to add a xmlns // attribute to declare that. That xmlns attribute must not have a // prefix (see http://www.w3.org/TR/REC-xml-names/#dt-prefix), ie it // must declare the default namespace. We just found an xmlns // attribute that declares the default namespace to something // non-empty. We're going to ignore this attribute, for children we // will detect that we need to add it again and attributes aren't // affected by the default namespace.
skipAttr = index;
} else { // Default NS attribute does not have prefix (and the name is "xmlns")
PushNameSpaceDecl(u""_ns, uriStr, aOriginalElement);
}
} else {
PushNameSpaceDecl(nsDependentAtomString(attrName), uriStr,
aOriginalElement);
}
}
} return skipAttr;
}
// If we had to add a new namespace declaration, serialize // and push it on the namespace stack if (aAddNSAttr) { if (aTagPrefix.IsEmpty()) { // Serialize default namespace decl
NS_ENSURE_TRUE(
SerializeAttr(u""_ns, xmlnsStr, aTagNamespaceURI, aStr, true), false);
} else { // Serialize namespace decl
NS_ENSURE_TRUE(
SerializeAttr(xmlnsStr, aTagPrefix, aTagNamespaceURI, aStr, true), false);
}
PushNameSpaceDecl(aTagPrefix, aTagNamespaceURI, aOriginalElement);
}
count = aElement->GetAttrCount();
// Now serialize each of the attributes // XXX Unfortunately we need a namespace manager to get // attribute URIs. for (index = 0; index < count; index++) { if (aSkipAttr == index) { continue;
}
// Filter out any attribute starting with [-|_]moz
nsDependentAtomString attrNameStr(attrName); if (StringBeginsWith(attrNameStr, u"_moz"_ns) ||
StringBeginsWith(attrNameStr, u"-moz"_ns)) { continue;
}
if (attrPrefix) {
attrPrefix->ToString(prefixStr);
} else {
prefixStr.Truncate();
}
bool forceFormat = false;
nsresult rv = NS_OK; if (!CheckElementStart(aElement, forceFormat, *mOutput, rv)) { // When we go to AppendElementEnd for this element, we're going to // MaybeLeaveFromPreContent(). So make sure to MaybeEnterInPreContent() // now, so our PreLevel() doesn't get confused.
MaybeEnterInPreContent(aElement); return rv;
}
// Serialize the qualified name of the element
NS_ENSURE_TRUE(AppendToString(kLessThan, *mOutput), NS_ERROR_OUT_OF_MEMORY); if (!tagPrefix.IsEmpty()) {
NS_ENSURE_TRUE(AppendToString(tagPrefix, *mOutput), NS_ERROR_OUT_OF_MEMORY);
NS_ENSURE_TRUE(AppendToString(u":"_ns, *mOutput), NS_ERROR_OUT_OF_MEMORY);
}
NS_ENSURE_TRUE(AppendToString(tagLocalName, *mOutput),
NS_ERROR_OUT_OF_MEMORY);
// aElement is the actual element we're outputting. aOriginalElement is the one // in the original DOM, which is the one we have to test for kids. staticbool ElementNeedsSeparateEndTag(Element* aElement,
Element* aOriginalElement) { if (aOriginalElement->GetChildCount()) { // We have kids, so we need a separate end tag. This needs to be checked on // aOriginalElement because that's the one that's actually in the DOM and // might have kids. returntrue;
}
if (!aElement->IsHTMLElement()) { // Empty non-HTML elements can just skip a separate end tag. returnfalse;
}
// HTML container tags should have a separate end tag even if empty, per spec. // See // https://w3c.github.io/DOM-Parsing/#dfn-concept-xml-serialization-algorithm
nsAtom* localName = aElement->NodeInfo()->NameAtom(); bool isHTMLContainer = nsHTMLElement::IsContainer(
nsHTMLTags::CaseSensitiveAtomTagToId(localName)); return isHTMLContainer;
}
// We don't need a separate end tag. For HTML elements (which at this point // must be non-containers), append a space before the '/', per spec. See // https://w3c.github.io/DOM-Parsing/#dfn-concept-xml-serialization-algorithm if (aOriginalElement->IsHTMLElement()) { if (!AppendToString(kSpace, aStr)) { returnfalse;
}
}
if (!outputElementEnd) { // Keep this in sync with the cleanup at the end of this method.
PopNameSpaceDeclsFor(aElement);
MaybeLeaveFromPreContent(content);
MaybeFlagNewlineForRootNode(aElement);
AfterElementEnd(content, *mOutput); return NS_OK;
}
if (version.IsEmpty()) return NS_OK; // A declaration must have version, or there is no decl
constexpr auto endQuote = u"\""_ns;
*mOutput += u""_ns + version + endQuote;
if (!mCharset.IsEmpty()) {
*mOutput +=
u" encoding=\""_ns + NS_ConvertASCIItoUTF16(mCharset) + endQuote;
} // Otherwise just don't output an encoding attr. Not that we expect // mCharset to ever be empty. #ifdef DEBUG else {
NS_WARNING("Empty mCharset? How come?");
} #endif
bool nsXMLContentSerializer::CheckElementEnd(Element* aElement,
Element* aOriginalElement, bool& aForceFormat,
nsAString& aStr) { // We don't output a separate end tag for empty element
aForceFormat = false; return ElementNeedsSeparateEndTag(aElement, aOriginalElement);
}
// for each chunk of |aString|...
uint32_t advanceLength = 0;
nsReadingIterator<char16_t> iter;
for (aStr.BeginReading(iter); iter != done_reading;
iter.advance(int32_t(advanceLength))) {
uint32_t fragmentLength = done_reading - iter; const char16_t* c = iter.get(); const char16_t* fragmentStart = c; const char16_t* fragmentEnd = c + fragmentLength; constchar* entityText = nullptr;
advanceLength = 0; // for each character in this chunk, check if it // needs to be replaced for (; c < fragmentEnd; c++, advanceLength++) {
char16_t val = *c; if ((val <= aMaxTableIndex) && aEntityTable[val]) {
entityText = aStringTable[aEntityTable[val]]; break;
}
}
if (mDoRaw) {
NS_ENSURE_TRUE(AppendToString(aStr, aOutputStr), false);
} else { // Convert line-endings to mLineBreak
uint32_t start = 0;
uint32_t theLen = aStr.Length(); while (start < theLen) {
int32_t eol = aStr.FindChar('\n', start); if (eol == kNotFound) {
nsDependentSubstring dataSubstring(aStr, start, theLen - start);
NS_ENSURE_TRUE(AppendToString(dataSubstring, aOutputStr), false);
start = theLen; // if there was a line break before this substring // AppendNewLineToString was called, so we should reverse // this flag
mMayIgnoreLineBreakSequence = false;
} else {
nsDependentSubstring dataSubstring(aStr, start, eol - start);
NS_ENSURE_TRUE(AppendToString(dataSubstring, aOutputStr), false);
NS_ENSURE_TRUE(AppendNewLineToString(aOutputStr), false);
start = eol + 1;
}
}
}
returntrue;
}
bool nsXMLContentSerializer::AppendFormatedWrapped_WhitespaceSequence(
nsAString::const_char_iterator& aPos, const nsAString::const_char_iterator aEnd, const nsAString::const_char_iterator aSequenceStart, bool& aMayIgnoreStartOfLineWhitespaceSequence, nsAString& aOutputStr) { // Handle the complete sequence of whitespace. // Continue to iterate until we find the first non-whitespace char. // Updates "aPos" to point to the first unhandled char. // Also updates the aMayIgnoreStartOfLineWhitespaceSequence flag, // as well as the other "global" state flags.
do { switch (*aPos) { case' ': case'\t':
sawBlankOrTab = true;
[[fallthrough]]; case'\n':
++aPos; // do not increase mColPos, // because we will reduce the whitespace to a single char break; default:
leaveLoop = true; break;
}
} while (!leaveLoop && aPos < aEnd);
if (mAddSpace) { // if we had previously been asked to add space, // our situation has not changed
} elseif (!sawBlankOrTab && mMayIgnoreLineBreakSequence) { // nothing to do in the case where line breaks have already been added // before the call of AppendToStringWrapped // and only if we found line break in the sequence
mMayIgnoreLineBreakSequence = false;
} elseif (aMayIgnoreStartOfLineWhitespaceSequence) { // nothing to do
aMayIgnoreStartOfLineWhitespaceSequence = false;
} else { if (sawBlankOrTab) { if (mDoWrap && mColPos + 1 >= mMaxColumn) { // no much sense in delaying, we only have one slot left, // let's write a break now bool result = aOutputStr.Append(mLineBreak, mozilla::fallible);
mColPos = 0;
mIsIndentationAddedOnCurrentLine = false;
mMayIgnoreLineBreakSequence = true;
NS_ENSURE_TRUE(result, false);
} else { // do not write out yet, we may write out either a space or a linebreak // let's delay writing it out until we know more
mAddSpace = true;
++mColPos; // eat a slot of available space
}
} else { // Asian text usually does not contain spaces, therefore we should not // transform a linebreak into a space. // Since we only saw linebreaks, but no spaces or tabs, // let's write a linebreak now.
NS_ENSURE_TRUE(AppendNewLineToString(aOutputStr), false);
}
}
// Handle the complete sequence of non-whitespace in this block // Iterate until we find the first whitespace char or an aEnd condition // Updates "aPos" to point to the first unhandled char. // Also updates the aMayIgnoreStartOfLineWhitespaceSequence flag, // as well as the other "global" state flags.
do { if (mColPos) {
colPos = mColPos;
} else { if (mDoFormat && !mDoRaw && !PreLevel() &&
!onceAgainBecauseWeAddedBreakInFront) {
colPos = mIndent.Length();
} else
colPos = 0;
}
foundWhitespaceInLoop = false;
length = 0; // we iterate until the next whitespace character // or until we reach the maximum of character per line // or until the end of the string to add. do { if (*aPos == ' ' || *aPos == '\t' || *aPos == '\n') {
foundWhitespaceInLoop = true; break;
}
// in the case we don't reached the end of the string, but we reached the // maxcolumn, we see if there is a whitespace after the maxcolumn if yes, // then we can append directly the string instead of appending a new line // etc. if (*aPos == ' ' || *aPos == '\t' || *aPos == '\n') {
foundWhitespaceInLoop = true;
}
if (aPos == aEnd || foundWhitespaceInLoop) { // there is enough room for the complete block we found if (mDoFormat && !mColPos) {
NS_ENSURE_TRUE(AppendIndentation(aOutputStr), false);
} elseif (mAddSpace) { bool result = aOutputStr.Append(char16_t(' '), mozilla::fallible);
mAddSpace = false;
NS_ENSURE_TRUE(result, false);
}
// We have not yet reached the max column, we will continue to // fill the current line in the next outer loop iteration // (this one in AppendToStringWrapped) // make sure we return in this outer loop
onceAgainBecauseWeAddedBreakInFront = false;
} else { // we reach the max column if (!thisSequenceStartsAtBeginningOfLine &&
(mAddSpace || (!mDoFormat && aSequenceStartAfterAWhiteSpace))) { // when !mDoFormat, mAddSpace is not used, mAddSpace is always false // so, in the case where mDoWrap && !mDoFormat, if we want to enter in // this condition...
// We can avoid to wrap. We try to add the whole block // in an empty new line
if (mAllowLineBreaking) {
MOZ_ASSERT(aPos < aEnd, "We shouldn't be here if aPos reaches the end of text!");
// Search forward from aSequenceStart until we find the largest // wrap position less than or equal to aPos.
Maybe<uint32_t> nextWrapPosition;
Span<const char16_t> subSeq(aSequenceStart, aEnd);
intl::LineBreakIteratorUtf16 lineBreakIter(subSeq); while (true) {
nextWrapPosition = lineBreakIter.Next();
MOZ_ASSERT(nextWrapPosition.isSome(), "We should've exited the loop when reaching the end of " "text in the previous iteration!");
// Trim space at the tail. UAX#14 doesn't have break opportunity // for ASCII space at the tail. const Maybe<uint32_t> originalNextWrapPosition = nextWrapPosition; while (*nextWrapPosition > 0 &&
subSeq.at(*nextWrapPosition - 1) == 0x20) {
nextWrapPosition = Some(*nextWrapPosition - 1);
} if (*nextWrapPosition == 0) { // Restore the original nextWrapPosition.
nextWrapPosition = originalNextWrapPosition;
}
if (!wrapPosition) { // The wrap position found in the first iteration of the above loop // already exceeds aPos. We accept it as valid a wrap position only // if it is not end-of-text. If the line-breaker returned // end-of-text, we don't know that it is actually a good wrap // position, so ignore it and continue to use the fallback code // below. if (*nextWrapPosition < subSeq.Length()) {
wrapPosition = nextWrapPosition;
}
}
}
if (wrapPosition) { if (!mColPos && mDoFormat) {
NS_ENSURE_TRUE(AppendIndentation(aOutputStr), false);
} elseif (mAddSpace) { bool result = aOutputStr.Append(char16_t(' '), mozilla::fallible);
mAddSpace = false;
NS_ENSURE_TRUE(result, false);
}
NS_ENSURE_TRUE(aOutputStr.Append(aSequenceStart, *wrapPosition,
mozilla::fallible), false);
NS_ENSURE_TRUE(AppendNewLineToString(aOutputStr), false);
aPos = aSequenceStart + *wrapPosition;
aMayIgnoreStartOfLineWhitespaceSequence = true;
} else { // try some simple fallback logic // go forward up to the next whitespace position, // in the worst case this will be all the rest of the data
// XXX(jfkthame) Should we (conditionally) output indentation here? // It makes for tidier-looking formatted output, at the cost of // exceeding the target width by a greater amount on such lines. // if (!mColPos && mDoFormat) { // NS_ENSURE_TRUE(AppendIndentation(aOutputStr), false); // mAddSpace = false; // }
// we update the mColPos variable with the length of // the part already parsed.
mColPos += length;
// now try to find the next whitespace do { if (*aPos == ' ' || *aPos == '\t' || *aPos == '\n') { break;
}
// if the current line already has text on it, such as a tag, // leading whitespace is significant bool mayIgnoreStartOfLineWhitespaceSequence =
(!mColPos ||
(mIsIndentationAddedOnCurrentLine && sequenceStartAfterAWhitespace &&
uint32_t(mColPos) == mIndent.Length()));
while (pos < end) {
sequenceStart = pos;
// if beginning of a whitespace sequence if (*pos == ' ' || *pos == '\n' || *pos == '\t') {
NS_ENSURE_TRUE(AppendFormatedWrapped_WhitespaceSequence(
pos, end, sequenceStart,
mayIgnoreStartOfLineWhitespaceSequence, aOutputStr), false);
} else { // any other non-whitespace char
NS_ENSURE_TRUE(
AppendWrapped_NonWhitespaceSequence(
pos, end, sequenceStart, mayIgnoreStartOfLineWhitespaceSequence,
sequenceStartAfterAWhitespace, aOutputStr), false);
}
}
returntrue;
}
bool nsXMLContentSerializer::AppendWrapped_WhitespaceSequence(
nsAString::const_char_iterator& aPos, const nsAString::const_char_iterator aEnd, const nsAString::const_char_iterator aSequenceStart,
nsAString& aOutputStr) { // Handle the complete sequence of whitespace. // Continue to iterate until we find the first non-whitespace char. // Updates "aPos" to point to the first unhandled char.
mAddSpace = false;
mIsIndentationAddedOnCurrentLine = false;
do { switch (*aPos) { case' ': case'\t': // if there are too many spaces on a line, we wrap if (mColPos >= mMaxColumn) { if (lastPos != aPos) {
NS_ENSURE_TRUE(
aOutputStr.Append(lastPos, aPos - lastPos, mozilla::fallible), false);
}
NS_ENSURE_TRUE(AppendToString(mLineBreak, aOutputStr), false);
mColPos = 0;
lastPos = aPos;
}
// not used in this case, but needed by AppendWrapped_NonWhitespaceSequence bool mayIgnoreStartOfLineWhitespaceSequence = false;
mMayIgnoreLineBreakSequence = false;
// if beginning of a whitespace sequence if (*pos == ' ' || *pos == '\n' || *pos == '\t') {
sequenceStartAfterAWhitespace = true;
NS_ENSURE_TRUE(
AppendWrapped_WhitespaceSequence(pos, end, sequenceStart, aOutputStr), false);
} else { // any other non-whitespace char
NS_ENSURE_TRUE(
AppendWrapped_NonWhitespaceSequence(
pos, end, sequenceStart, mayIgnoreStartOfLineWhitespaceSequence,
sequenceStartAfterAWhitespace, aOutputStr), false);
}
}
returntrue;
}
bool nsXMLContentSerializer::ShouldMaintainPreLevel() const { // Only attempt to maintain the pre level for consumers who care about it. return !mDoRaw || (mFlags & nsIDocumentEncoder::OutputNoFormattingInPre);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.