From 63ee09a3392309df5de9900ffe6331f0ca2834d8 Mon Sep 17 00:00:00 2001 From: "jst%netscape.com" Date: Mon, 15 May 2000 14:07:36 +0000 Subject: [PATCH] Fix .innerHTML regression (from the XIF converter update), and add a null document check. git-svn-id: svn://10.0.0.236/trunk@69789 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/html/content/src/nsGenericHTMLElement.cpp | 8 +++++++- mozilla/layout/html/content/src/nsGenericHTMLElement.cpp | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index b252c09cfd3..ff86f7aa8ab 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -794,6 +794,12 @@ nsGenericHTMLElement::GetOffsetParent(nsIDOMElement** aOffsetParent) nsresult nsGenericHTMLElement::GetInnerHTML(nsString& aInnerHTML) { + aInnerHTML.Truncate(); + + if (!mDocument) { + return NS_OK; // We rely on the document for doing XIF conversion + } + nsCOMPtr thisNode(do_QueryInterface(mContent)); nsresult rv = NS_OK; @@ -805,7 +811,7 @@ nsGenericHTMLElement::GetInnerHTML(nsString& aInnerHTML) NS_GET_IID(nsIXIFConverter), getter_AddRefs(xifc)); NS_ENSURE_TRUE(xifc,NS_ERROR_FAILURE); - xifc->Init(aInnerHTML); + xifc->Init(buf); PRUint32 i, count = 0; nsCOMPtr childNodes; diff --git a/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp b/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp index b252c09cfd3..ff86f7aa8ab 100644 --- a/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp @@ -794,6 +794,12 @@ nsGenericHTMLElement::GetOffsetParent(nsIDOMElement** aOffsetParent) nsresult nsGenericHTMLElement::GetInnerHTML(nsString& aInnerHTML) { + aInnerHTML.Truncate(); + + if (!mDocument) { + return NS_OK; // We rely on the document for doing XIF conversion + } + nsCOMPtr thisNode(do_QueryInterface(mContent)); nsresult rv = NS_OK; @@ -805,7 +811,7 @@ nsGenericHTMLElement::GetInnerHTML(nsString& aInnerHTML) NS_GET_IID(nsIXIFConverter), getter_AddRefs(xifc)); NS_ENSURE_TRUE(xifc,NS_ERROR_FAILURE); - xifc->Init(aInnerHTML); + xifc->Init(buf); PRUint32 i, count = 0; nsCOMPtr childNodes;