From 9cfc8750a915c97403abf8b94f4c5f654cfc8868 Mon Sep 17 00:00:00 2001 From: "rbs%maths.uq.edu.au" Date: Wed, 20 Nov 2002 01:47:06 +0000 Subject: [PATCH] .innerHTML wasn't recovering   and this was causing consumers such as View Selection Source to lose it, b=165686, r=jst, sr=bzbarsky --- content/base/src/nsHTMLContentSerializer.cpp | 9 ++++++++- content/html/content/src/nsGenericHTMLElement.cpp | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/content/base/src/nsHTMLContentSerializer.cpp b/content/base/src/nsHTMLContentSerializer.cpp index 148c9f6533a..a4dda335bc1 100644 --- a/content/base/src/nsHTMLContentSerializer.cpp +++ b/content/base/src/nsHTMLContentSerializer.cpp @@ -787,6 +787,9 @@ nsHTMLContentSerializer::AppendToStringWrapped(const nsASingleFragmentString& aS } } +static PRUint16 kValNBSP = 160; +static const char* kEntityNBSP = "nbsp"; + static PRUint16 kGTVal = 62; static const char* kEntities[] = { "", "", "", "", "", "", "", "", "", "", @@ -856,7 +859,11 @@ nsHTMLContentSerializer::AppendToString(const nsAString& aStr, // needs to be replaced for (; c < fragmentEnd; c++, advanceLength++) { PRUnichar val = *c; - if ((val <= kGTVal) && (entityTable[val][0] != 0)) { + if (val == kValNBSP) { + entityText = kEntityNBSP; + break; + } + else if ((val <= kGTVal) && (entityTable[val][0] != 0)) { entityText = entityTable[val]; break; } else if (mIsLatin1 && val > 127 && val < 256) { diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 2581b7e2afb..1d3cb915913 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -880,7 +880,8 @@ nsGenericHTMLElement::GetInnerHTML(nsAString& aInnerHTML) NS_ENSURE_TRUE(docEncoder, NS_ERROR_FAILURE); - docEncoder->Init(doc, NS_LITERAL_STRING("text/html"), 0); + docEncoder->Init(doc, NS_LITERAL_STRING("text/html"), + nsIDocumentEncoder::OutputEncodeEntities); nsCOMPtr range(new nsRange); NS_ENSURE_TRUE(range, NS_ERROR_OUT_OF_MEMORY);