diff --git a/mozilla/accessible/src/base/nsAccessibilityService.cpp b/mozilla/accessible/src/base/nsAccessibilityService.cpp index 79b301a63ae..d919bef4bc4 100644 --- a/mozilla/accessible/src/base/nsAccessibilityService.cpp +++ b/mozilla/accessible/src/base/nsAccessibilityService.cpp @@ -69,7 +69,6 @@ #include "nsIPluginInstance.h" #include "nsIPresShell.h" #include "nsISupportsUtils.h" -#include "nsITextContent.h" #include "nsIWebNavigation.h" #include "nsObjectFrame.h" #include "nsOuterDocAccessible.h" diff --git a/mozilla/accessible/src/base/nsAccessible.cpp b/mozilla/accessible/src/base/nsAccessible.cpp index 2a7b7768872..1e679ca96a8 100644 --- a/mozilla/accessible/src/base/nsAccessible.cpp +++ b/mozilla/accessible/src/base/nsAccessible.cpp @@ -61,7 +61,6 @@ #include "nsXPIDLString.h" #include "prdtoa.h" #include "nsIDOMComment.h" -#include "nsITextContent.h" #include "nsIDOMHTMLImageElement.h" #include "nsIDOMHTMLInputElement.h" #include "nsIDOMHTMLBRElement.h" @@ -1256,8 +1255,6 @@ nsresult nsAccessible::AppendNameFromAccessibleFor(nsIContent *aContent, nsresult nsAccessible::AppendFlatStringFromContentNode(nsIContent *aContent, nsAString *aFlatString) { if (aContent->IsNodeOfType(nsINode::eTEXT)) { - nsCOMPtr textContent(do_QueryInterface(aContent)); - NS_ASSERTION(textContent, "No text content for text content type"); // If it's a text node, append the text PRBool isHTMLBlock = PR_FALSE; nsCOMPtr shell = GetPresShell(); @@ -1283,9 +1280,9 @@ nsresult nsAccessible::AppendFlatStringFromContentNode(nsIContent *aContent, nsA } } } - if (textContent->TextLength() > 0) { + if (aContent->TextLength() > 0) { nsAutoString text; - textContent->AppendTextTo(text); + aContent->AppendTextTo(text); if (!text.IsEmpty()) aFlatString->Append(text); if (isHTMLBlock && !aFlatString->IsEmpty()) @@ -2606,9 +2603,7 @@ nsresult nsAccessible::GetLinkOffset(PRInt32* aStartOffset, PRInt32* aEndOffset) nsCOMPtr accessNode(do_QueryInterface(accessible)); nsIFrame *frame = accessNode->GetFrame(); if (frame) { - nsITextContent *textContent = NS_STATIC_CAST(nsITextContent*, frame->GetContent()); - NS_ASSERTION(textContent, "No text content for a ROLE_TEXT?"); - characterCount += textContent->TextLength(); + characterCount += frame->GetContent()->TextLength(); } } else if (accessible == this) { diff --git a/mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp b/mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp index b029a0ff303..08eff81a905 100644 --- a/mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp +++ b/mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp @@ -48,7 +48,6 @@ #include "nsIDOMHTMLSelectElement.h" #include "nsIListControlFrame.h" #include "nsIServiceManager.h" -#include "nsITextContent.h" #include "nsIMutableArray.h" /** @@ -485,8 +484,8 @@ NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetName(nsAString& aName) mDOMNode->GetFirstChild(getter_AddRefs(child)); if (child) { - nsCOMPtr text(do_QueryInterface(child)); - if (text) { + nsCOMPtr text = do_QueryInterface(child); + if (text && text->IsNodeOfType(nsINode::eTEXT)) { nsAutoString txtValue; rv = AppendFlatStringFromContentNode(text, &txtValue); if (NS_SUCCEEDED(rv)) { diff --git a/mozilla/accessible/src/html/nsHyperTextAccessible.cpp b/mozilla/accessible/src/html/nsHyperTextAccessible.cpp index 3971924733f..1c1ff245525 100644 --- a/mozilla/accessible/src/html/nsHyperTextAccessible.cpp +++ b/mozilla/accessible/src/html/nsHyperTextAccessible.cpp @@ -54,7 +54,6 @@ #include "nsIFrame.h" #include "nsIPlaintextEditor.h" #include "nsIServiceManager.h" -#include "nsITextContent.h" #include "nsTextFragment.h" static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID); @@ -225,17 +224,13 @@ nsIFrame* nsHyperTextAccessible::GetPosAndText(PRInt32& aStartOffset, PRInt32& a nsIFrame *frame = accessNode->GetFrame(); if (Role(accessible) == ROLE_TEXT_LEAF) { if (frame) { - // Avoid string copiesn - nsITextContent *textContent = NS_STATIC_CAST(nsITextContent*, frame->GetContent()); - NS_ASSERTION(textContent, "No text content for text accessible!"); - PRInt32 textContentLength = textContent->TextLength(); + // Avoid string copies + PRInt32 textContentLength = frame->GetContent()->TextLength(); if (startOffset < textContentLength) { // XXX Can we somehow optimize further by getting the nsTextFragment and use // CopyTo to a PRUnichar buffer to copy it directly to the string? nsAutoString newText; - if (aText) { - textContent->AppendTextTo(newText); - } + frame->GetContent()->AppendTextTo(newText); if (startOffset > 0 || endOffset < textContentLength) { // XXX the Substring operation is efficient, but does the reassignment // to the original nsAutoString cause a copy? @@ -324,8 +319,7 @@ NS_IMETHODIMP nsHyperTextAccessible::GetCharacterCount(PRInt32 *aCharacterCount) nsCOMPtr accessNode(do_QueryInterface(accessible)); nsIFrame *frame = accessNode->GetFrame(); if (frame) { - nsITextContent *textContent = NS_STATIC_CAST(nsITextContent*, frame->GetContent()); - *aCharacterCount += textContent->TextLength(); + *aCharacterCount += frame->GetContent()->TextLength(); } } else { @@ -400,9 +394,7 @@ nsresult nsHyperTextAccessible::DOMPointToOffset(nsIDOMNode* aNode, PRInt32 aNod if (Role(accessible) == ROLE_TEXT_LEAF) { if (frame) { - nsITextContent *textContent = NS_STATIC_CAST(nsITextContent*, content); - NS_ASSERTION(textContent, "No text content for a ROLE_TEXT?"); - *aResult += textContent->TextLength(); + *aResult += content->TextLength(); } } else { @@ -520,8 +512,9 @@ nsresult nsHyperTextAccessible::GetTextHelper(EGetTextType aType, nsAccessibleTe case BOUNDARY_ATTRIBUTE_RANGE: { // XXX We should merge identically formatted frames - nsITextContent *textContent = NS_STATIC_CAST(nsITextContent*, startFrame->GetContent()); + nsIContent *textContent = startFrame->GetContent(); // If not text, then it's represented by an embedded object char (length of 1) + // XXX did this mean to check for eTEXT? PRInt32 textLength = textContent ? textContent->TextLength() : 1; *aStartOffset = aOffset - startOffset; *aEndOffset = *aStartOffset + textLength; @@ -597,9 +590,7 @@ NS_IMETHODIMP nsHyperTextAccessible::GetAttributeRange(PRInt32 aOffset, PRInt32 nsCOMPtr accessNode(do_QueryInterface(accessible)); nsIFrame *frame = accessNode->GetFrame(); if (frame) { - nsITextContent *textContent = NS_STATIC_CAST(nsITextContent*, frame->GetContent()); - NS_ASSERTION(textContent, "No text content for a ROLE_TEXT?"); - length = textContent->TextLength(); + length = frame->GetContent()->TextLength(); } else { break; @@ -764,13 +755,12 @@ NS_IMETHODIMP nsHyperTextAccessible::GetOffsetAtPoint(PRInt32 aX, PRInt32 aY, ns nsIFrame *frame = accessNode->GetFrame(); if (Role(accessible) == ROLE_TEXT_LEAF) { if (frame) { - nsITextContent *textContent = NS_STATIC_CAST(nsITextContent*, frame->GetContent()); if (finished) { nsCOMPtr rc; shell->CreateRenderingContext(frame, getter_AddRefs(rc)); NS_ENSURE_TRUE(rc, NS_ERROR_FAILURE); - const nsTextFragment *textFrag = textContent->Text(); - // For each character in textContent, add to totalWidth + const nsTextFragment *textFrag = frame->GetContent()->GetText(); + // For each character in frame->GetContent(), add to totalWidth // until it is wider than the x coordinate we are looking for PRInt32 length = textFrag->GetLength(); PRInt32 totalWidth = 0; @@ -787,7 +777,7 @@ NS_IMETHODIMP nsHyperTextAccessible::GetOffsetAtPoint(PRInt32 aX, PRInt32 aY, ns } return NS_ERROR_FAILURE; } - *aOffset += textContent->TextLength(); + *aOffset += frame->GetContent()->TextLength(); } } else if (finished) { @@ -853,8 +843,7 @@ NS_IMETHODIMP nsHyperTextAccessible::GetLinkIndex(PRInt32 aCharIndex, PRInt32 *a nsCOMPtr accessNode(do_QueryInterface(accessible)); nsIFrame *frame = accessNode->GetFrame(); if (frame) { - nsITextContent *textContent = NS_STATIC_CAST(nsITextContent*, frame->GetContent()); - characterCount += textContent->TextLength(); + characterCount += frame->GetContent()->TextLength(); } } else { @@ -1001,9 +990,9 @@ NS_IMETHODIMP nsHyperTextAccessible::DidInsertNode(nsIDOMNode *aNode, nsIDOMNode AtkTextChange textData; textData.add = PR_TRUE; - nsCOMPtr textContent(do_QueryInterface(aNode)); - if (textContent) { - textData.length = textContent->TextLength(); + nsCOMPtr content(do_QueryInterface(aNode)); + if (content && content->IsNodeOfType(nsINode::eTEXT)) { + textData.length = content->TextLength(); if (!textData.length) { return NS_OK; } @@ -1033,9 +1022,9 @@ NS_IMETHODIMP nsHyperTextAccessible::WillDeleteNode(nsIDOMNode *aChild) AtkTextChange textData; textData.add = PR_FALSE; - nsCOMPtr textContent(do_QueryInterface(aChild)); - if (textContent) { - textData.length = textContent->TextLength(); + nsCOMPtr content(do_QueryInterface(aChild)); + if (content && content->IsNodeOfType(nsINode::eTEXT)) { + textData.length = content->TextLength(); if (!textData.length) { return NS_OK; } diff --git a/mozilla/content/base/public/Makefile.in b/mozilla/content/base/public/Makefile.in index d2d929f8221..0ab521ef2bc 100644 --- a/mozilla/content/base/public/Makefile.in +++ b/mozilla/content/base/public/Makefile.in @@ -63,7 +63,6 @@ nsINodeInfo.h \ nsIRangeUtils.h \ nsIScriptElement.h \ nsIStyleSheetLinkingElement.h \ -nsITextContent.h \ nsIPrivateDOMImplementation.h \ nsIContentSerializer.h \ nsIHTMLToTextSink.h \ diff --git a/mozilla/content/base/public/nsContentCreatorFunctions.h b/mozilla/content/base/public/nsContentCreatorFunctions.h index 42e09bdfdc6..8d8b82f9af6 100644 --- a/mozilla/content/base/public/nsContentCreatorFunctions.h +++ b/mozilla/content/base/public/nsContentCreatorFunctions.h @@ -61,6 +61,18 @@ NS_NewElement(nsIContent** aResult, PRInt32 aElementType, nsresult NS_NewXMLElement(nsIContent** aResult, nsINodeInfo* aNodeInfo); +/** + * aNodeInfoManager must not be null. + */ +nsresult +NS_NewTextNode(nsIContent **aResult, nsNodeInfoManager *aNodeInfoManager); + +/** + * aNodeInfoManager must not be null. + */ +nsresult +NS_NewCommentNode(nsIContent **aResult, nsNodeInfoManager *aNodeInfoManager); + /** * aNodeInfoManager must not be null. */ diff --git a/mozilla/content/base/public/nsIContent.h b/mozilla/content/base/public/nsIContent.h index ba77a20b988..81dd52d6c07 100644 --- a/mozilla/content/base/public/nsIContent.h +++ b/mozilla/content/base/public/nsIContent.h @@ -58,11 +58,12 @@ class nsICSSStyleRule; class nsRuleWalker; class nsAttrValue; class nsAttrName; +class nsTextFragment; // IID for the nsIContent interface #define NS_ICONTENT_IID \ -{ 0x6aea736c, 0xe909, 0x43b7, \ - { 0x9c, 0x55, 0xb0, 0xda, 0x9e, 0x37, 0x16, 0x45 } } +{ 0x98f87249, 0x4cc8, 0x407d, \ + { 0x80, 0xb6, 0xfe, 0x12, 0x91, 0xd1, 0x4d, 0xc9 } } // hack to make egcs / gcc 2.95.2 happy class nsIContent_base : public nsINode { @@ -374,6 +375,49 @@ public: */ virtual PRUint32 GetAttrCount() const = 0; + /** + * Get direct access (but read only) to the text in the text content. + * NOTE: For elements this is *not* the concatenation of all text children, + * it is simply null; + */ + virtual const nsTextFragment *GetText() = 0; + + /** + * Get the length of the text content. + * NOTE: This should not be called on elements. + */ + virtual PRUint32 TextLength() = 0; + + /** + * Set the text to the given value. If aNotify is PR_TRUE then + * the document is notified of the content change. + * NOTE: For elements this always ASSERTS and returns NS_ERROR_FAILURE + */ + virtual nsresult SetText(const PRUnichar* aBuffer, PRUint32 aLength, + PRBool aNotify) = 0; + + /** + * Set the text to the given value. If aNotify is PR_TRUE then + * the document is notified of the content change. + * NOTE: For elements this always asserts and returns NS_ERROR_FAILURE + */ + nsresult SetText(const nsAString& aStr, PRBool aNotify) + { + return SetText(aStr.BeginReading(), aStr.Length(), aNotify); + } + + /** + * Query method to see if the frame is nothing but whitespace + * NOTE: Always returns PR_FALSE for elements + */ + virtual PRBool TextIsOnlyWhitespace() = 0; + + /** + * Append the text content to aResult. + * NOTE: This asserts and returns for elements + */ + virtual void AppendTextTo(nsAString& aResult) = 0; + /** * Set the focus on this content. This is generally something for the event * state manager to do, not ordinary people. Ordinary people should do diff --git a/mozilla/content/base/public/nsINode.h b/mozilla/content/base/public/nsINode.h index 2d4b09650f1..f0fb5e24a3e 100644 --- a/mozilla/content/base/public/nsINode.h +++ b/mozilla/content/base/public/nsINode.h @@ -155,7 +155,10 @@ public: /** svg elements */ eSVG = 1 << 10, /** document fragments */ - eDOCUMENT_FRAGMENT = 1 << 11 + eDOCUMENT_FRAGMENT = 1 << 11, + /** data nodes (comments, PIs, text). Nodes of this type always + returns a non-null value for nsIContent::GetText() */ + eDATA_NODE = 1 << 12 }; /** diff --git a/mozilla/content/base/public/nsITextContent.h b/mozilla/content/base/public/nsITextContent.h deleted file mode 100644 index bb5faec1bc8..00000000000 --- a/mozilla/content/base/public/nsITextContent.h +++ /dev/null @@ -1,117 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#ifndef nsITextContent_h___ -#define nsITextContent_h___ - -#include "nsIContent.h" -#include "nsIDocument.h" -class nsString; -class nsTextFragment; - -// IID for the nsITextContent interface -// e4ef843f-1061-45e6-9c81-30eac2673f41 -#define NS_ITEXT_CONTENT_IID \ -{ 0x2a5789f8, 0xbbec, 0x4340, \ - { 0xa2, 0xc4, 0x54, 0xbb, 0xd0, 0x90, 0x64, 0x60 } } - -/** - * Interface for textual content. This interface is used to provide - * an efficient access to text content. - */ -class nsITextContent : public nsIContent { -public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITEXT_CONTENT_IID) - - nsITextContent(nsINodeInfo *aNodeInfo) - : nsIContent(aNodeInfo) - { - } - - /** - * Get direct access (but read only) to the text in the text content. - */ - virtual const nsTextFragment *Text() = 0; - - /** - * Get the length of the text content. - */ - virtual PRUint32 TextLength() = 0; - - /** - * Set the text to the given value. If aNotify is PR_TRUE then - * the document is notified of the content change. - */ - virtual void SetText(const PRUnichar* aBuffer, PRUint32 aLength, - PRBool aNotify) = 0; - - /** - * Set the text to the given value. If aNotify is PR_TRUE then - * the document is notified of the content change. - */ - void SetText(const nsAString& aStr, PRBool aNotify) - { - SetText(aStr.BeginReading(), aStr.Length(), aNotify); - } - - /** - * Query method to see if the frame is nothing but whitespace - */ - virtual PRBool IsOnlyWhitespace() = 0; - - /** - * Append the text content to aResult. - */ - virtual void AppendTextTo(nsAString& aResult) = 0; -}; - -NS_DEFINE_STATIC_IID_ACCESSOR(nsITextContent, NS_ITEXT_CONTENT_IID) - -// XXX These belong elsewhere -/** - * aNodeInfoManager must not be null. - */ -nsresult -NS_NewTextNode(nsITextContent **aResult, nsNodeInfoManager *aNodeInfoManager); - -/** - * aNodeInfoManager must not be null. - */ -nsresult -NS_NewCommentNode(nsIContent **aResult, nsNodeInfoManager *aNodeInfoManager); - - -#endif /* nsITextContent_h___ */ diff --git a/mozilla/content/base/src/mozSanitizingSerializer.cpp b/mozilla/content/base/src/mozSanitizingSerializer.cpp index 6b8bd3fe8cf..ee27e74e55b 100644 --- a/mozilla/content/base/src/mozSanitizingSerializer.cpp +++ b/mozilla/content/base/src/mozSanitizingSerializer.cpp @@ -55,7 +55,6 @@ #include "nsHTMLAtoms.h" #include "nsIDOMText.h" #include "nsIDOMElement.h" -#include "nsITextContent.h" #include "nsTextFragment.h" #include "nsContentUtils.h" #include "nsReadableUtils.h" diff --git a/mozilla/content/base/src/nsCommentNode.cpp b/mozilla/content/base/src/nsCommentNode.cpp index 661b90946cb..d3fb298c79f 100644 --- a/mozilla/content/base/src/nsCommentNode.cpp +++ b/mozilla/content/base/src/nsCommentNode.cpp @@ -113,7 +113,6 @@ nsCommentNode::~nsCommentNode() // QueryInterface implementation for nsCommentNode NS_INTERFACE_MAP_BEGIN(nsCommentNode) - NS_INTERFACE_MAP_ENTRY(nsITextContent) NS_INTERFACE_MAP_ENTRY(nsIDOMNode) NS_INTERFACE_MAP_ENTRY(nsIDOMCharacterData) NS_INTERFACE_MAP_ENTRY(nsIDOMComment) @@ -135,7 +134,7 @@ nsCommentNode::MayHaveFrame() const PRBool nsCommentNode::IsNodeOfType(PRUint32 aFlags) const { - return !(aFlags & ~(eCONTENT | eCOMMENT)); + return !(aFlags & ~(eCONTENT | eCOMMENT | eDATA_NODE)); } NS_IMETHODIMP diff --git a/mozilla/content/base/src/nsDOMAttribute.cpp b/mozilla/content/base/src/nsDOMAttribute.cpp index 225194f48a9..273df8a5302 100644 --- a/mozilla/content/base/src/nsDOMAttribute.cpp +++ b/mozilla/content/base/src/nsDOMAttribute.cpp @@ -42,7 +42,7 @@ #include "nsDOMAttribute.h" #include "nsGenericElement.h" #include "nsIContent.h" -#include "nsITextContent.h" +#include "nsContentCreatorFunctions.h" #include "nsINameSpaceManager.h" #include "nsDOMError.h" #include "nsContentUtils.h" @@ -52,7 +52,6 @@ #include "nsIDOMDocument.h" #include "nsIDOM3Attr.h" #include "nsIDOMUserDataHandler.h" -#include "nsITextContent.h" #include "nsEventDispatcher.h" #include "nsGkAtoms.h" #include "nsCOMArray.h" diff --git a/mozilla/content/base/src/nsDOMAttribute.h b/mozilla/content/base/src/nsDOMAttribute.h index 0a893d660ec..fc11a0945d0 100644 --- a/mozilla/content/base/src/nsDOMAttribute.h +++ b/mozilla/content/base/src/nsDOMAttribute.h @@ -55,7 +55,6 @@ #include "nsDOMAttributeMap.h" class nsDOMAttribute; -class nsITextContent; // bogus child list for an attribute class nsAttributeChildList : public nsGenericDOMNodeList @@ -134,7 +133,7 @@ private: nsString mValue; // XXX For now, there's only a single child - a text // element representing the value - nsCOMPtr mChild; + nsCOMPtr mChild; nsAttributeChildList* mChildList; nsIContent *GetContentInternal() const diff --git a/mozilla/content/base/src/nsDOMDocumentType.cpp b/mozilla/content/base/src/nsDOMDocumentType.cpp index 95cdab3f3d1..76d0a2541d7 100644 --- a/mozilla/content/base/src/nsDOMDocumentType.cpp +++ b/mozilla/content/base/src/nsDOMDocumentType.cpp @@ -132,6 +132,21 @@ NS_INTERFACE_MAP_END_INHERITING(nsGenericDOMDataNode) NS_IMPL_ADDREF_INHERITED(nsDOMDocumentType, nsGenericDOMDataNode) NS_IMPL_RELEASE_INHERITED(nsDOMDocumentType, nsGenericDOMDataNode) +PRBool +nsDOMDocumentType::IsNodeOfType(PRUint32 aFlags) const +{ + // Don't claim to be eDATA_NODE since we're just inheriting + // nsGenericDOMDataNode for convinience. Doctypes aren't really + // data nodes (they have a null .nodeValue and don't implement + // nsIDOMCharacterData) + return !(aFlags & ~eCONTENT); +} + +const nsTextFragment* +nsDOMDocumentType::GetText() +{ + return nsnull; +} NS_IMETHODIMP nsDOMDocumentType::GetName(nsAString& aName) diff --git a/mozilla/content/base/src/nsDOMDocumentType.h b/mozilla/content/base/src/nsDOMDocumentType.h index 2d45048332e..86b3fd8b817 100644 --- a/mozilla/content/base/src/nsDOMDocumentType.h +++ b/mozilla/content/base/src/nsDOMDocumentType.h @@ -76,6 +76,10 @@ public: // nsIDOMDocumentType NS_DECL_NSIDOMDOCUMENTTYPE + // nsIContent overrides + virtual PRBool IsNodeOfType(PRUint32 aFlags) const; + virtual const nsTextFragment* GetText(); + protected: nsCOMPtr mName; nsCOMPtr mEntities; diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index 8f97ce69f23..dca02411005 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -2584,7 +2584,7 @@ nsDocument::CreateTextNode(const nsAString& aData, nsIDOMText** aReturn) { *aReturn = nsnull; - nsCOMPtr text; + nsCOMPtr text; nsresult rv = NS_NewTextNode(getter_AddRefs(text), mNodeInfoManager); if (NS_SUCCEEDED(rv)) { diff --git a/mozilla/content/base/src/nsDocumentEncoder.cpp b/mozilla/content/base/src/nsDocumentEncoder.cpp index b3fcfd1d663..5d33990ddab 100644 --- a/mozilla/content/base/src/nsDocumentEncoder.cpp +++ b/mozilla/content/base/src/nsDocumentEncoder.cpp @@ -66,7 +66,7 @@ #include "nsIDOMDocument.h" #include "nsICharsetConverterManager.h" #include "nsHTMLAtoms.h" -#include "nsITextContent.h" +#include "nsIContent.h" #include "nsIEnumerator.h" #include "nsISelectionPrivate.h" #include "nsISupportsArray.h" @@ -1724,12 +1724,8 @@ nsHTMLCopyEncoder::IsLastNode(nsIDOMNode *aNode) PRBool nsHTMLCopyEncoder::IsEmptyTextContent(nsIDOMNode* aNode) { - PRBool result = PR_FALSE; - nsCOMPtr tc(do_QueryInterface(aNode)); - if (tc) { - result = tc->IsOnlyWhitespace(); - } - return result; + nsCOMPtr cont = do_QueryInterface(aNode); + return cont && cont->TextIsOnlyWhitespace(); } nsresult NS_NewHTMLCopyTextEncoder(nsIDocumentEncoder** aResult); // make mac compiler happy diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.cpp b/mozilla/content/base/src/nsGenericDOMDataNode.cpp index f15203fe723..07beaba6a4e 100644 --- a/mozilla/content/base/src/nsGenericDOMDataNode.cpp +++ b/mozilla/content/base/src/nsGenericDOMDataNode.cpp @@ -83,7 +83,7 @@ nsGenericDOMDataNode::nsDataSlots::~nsDataSlots() } nsGenericDOMDataNode::nsGenericDOMDataNode(nsINodeInfo *aNodeInfo) - : nsITextContent(aNodeInfo) + : nsIContent(aNodeInfo) { } @@ -111,7 +111,6 @@ NS_INTERFACE_MAP_BEGIN(nsGenericDOMDataNode) NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNSEventTarget, nsDOMEventRTTearoff::Create(this)) NS_INTERFACE_MAP_ENTRY(nsIContent) - // No nsITextContent since all subclasses might not want that. NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3Node, new nsNode3Tearoff(this)) NS_INTERFACE_MAP_ENTRY(nsINode) NS_INTERFACE_MAP_END @@ -354,8 +353,6 @@ nsGenericDOMDataNode::SetData(const nsAString& aData) nsRange::TextOwnerChanged(this, rangeList, 0, mText.GetLength(), 0); } - nsCOMPtr textContent = do_QueryInterface(this); - SetText(aData, PR_TRUE); return NS_OK; @@ -857,7 +854,7 @@ nsGenericDOMDataNode::GetBindingParent() const PRBool nsGenericDOMDataNode::IsNodeOfType(PRUint32 aFlags) const { - return !(aFlags & ~eCONTENT); + return !(aFlags & ~(eCONTENT | eDATA_NODE)); } @@ -931,7 +928,7 @@ nsGenericDOMDataNode::SplitText(PRUint32 aOffset, nsIDOMText** aReturn) * as this node! */ - nsCOMPtr newContent = Clone(mNodeInfo, PR_FALSE); + nsCOMPtr newContent = Clone(mNodeInfo, PR_FALSE); if (!newContent) { return NS_ERROR_OUT_OF_MEMORY; } @@ -956,10 +953,10 @@ nsGenericDOMDataNode::SplitText(PRUint32 aOffset, nsIDOMText** aReturn) //---------------------------------------------------------------------- -// Implementation of the nsITextContent interface +// Implementation of the nsIContent interface text functions const nsTextFragment * -nsGenericDOMDataNode::Text() +nsGenericDOMDataNode::GetText() { return &mText; } @@ -970,7 +967,7 @@ nsGenericDOMDataNode::TextLength() return mText.GetLength(); } -void +nsresult nsGenericDOMDataNode::SetText(const PRUnichar* aBuffer, PRUint32 aLength, PRBool aNotify) @@ -978,7 +975,7 @@ nsGenericDOMDataNode::SetText(const PRUnichar* aBuffer, if (!aBuffer) { NS_ERROR("Null buffer passed to SetText()!"); - return; + return NS_ERROR_NULL_POINTER; } nsIDocument *document = GetCurrentDoc(); @@ -993,6 +990,7 @@ nsGenericDOMDataNode::SetText(const PRUnichar* aBuffer, oldValue = GetCurrentValueAtom(); } + // XXX Add OOM checking to this mText.SetTo(aBuffer, aLength); SetBidiStatus(); @@ -1015,10 +1013,12 @@ nsGenericDOMDataNode::SetText(const PRUnichar* aBuffer, if (aNotify) { nsNodeUtils::CharacterDataChanged(this, PR_FALSE); } + + return NS_OK; } PRBool -nsGenericDOMDataNode::IsOnlyWhitespace() +nsGenericDOMDataNode::TextIsOnlyWhitespace() { if (mText.Is2b()) { // The fragment contains non-8bit characters and such characters diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.h b/mozilla/content/base/src/nsGenericDOMDataNode.h index cea6b9d4c97..d19ad7ab289 100644 --- a/mozilla/content/base/src/nsGenericDOMDataNode.h +++ b/mozilla/content/base/src/nsGenericDOMDataNode.h @@ -43,7 +43,6 @@ #ifndef nsGenericDOMDataNode_h___ #define nsGenericDOMDataNode_h___ -#include "nsITextContent.h" #include "nsIDOMCharacterData.h" #include "nsIDOMEventReceiver.h" #include "nsTextFragment.h" @@ -61,7 +60,7 @@ class nsIDOMText; class nsINodeInfo; class nsURI; -class nsGenericDOMDataNode : public nsITextContent +class nsGenericDOMDataNode : public nsIContent { public: NS_DECL_ISUPPORTS @@ -222,6 +221,17 @@ public: virtual PRBool HasAttr(PRInt32 aNameSpaceID, nsIAtom *aAttribute) const; virtual const nsAttrName* GetAttrNameAt(PRUint32 aIndex) const; virtual PRUint32 GetAttrCount() const; + virtual const nsTextFragment *GetText(); + virtual PRUint32 TextLength(); + virtual nsresult SetText(const PRUnichar* aBuffer, PRUint32 aLength, + PRBool aNotify); + // Need to implement this here too to avoid hiding. + nsresult SetText(const nsAString& aStr, PRBool aNotify) + { + return SetText(aStr.BeginReading(), aStr.Length(), aNotify); + } + virtual PRBool TextIsOnlyWhitespace(); + virtual void AppendTextTo(nsAString& aResult); #ifdef DEBUG virtual void List(FILE* out, PRInt32 aIndent) const; virtual void DumpContent(FILE* out, PRInt32 aIndent, PRBool aDumpAll) const; @@ -252,19 +262,6 @@ public: virtual nsIAtom *GetClassAttributeName() const; - // nsITextContent - virtual const nsTextFragment *Text(); - virtual PRUint32 TextLength(); - virtual void SetText(const PRUnichar* aBuffer, PRUint32 aLength, - PRBool aNotify); - // Need to implement this here too to avoid hiding. - void SetText(const nsAString& aStr, PRBool aNotify) - { - SetText(aStr.BeginReading(), aStr.Length(), aNotify); - } - virtual PRBool IsOnlyWhitespace(); - virtual void AppendTextTo(nsAString& aResult); - //---------------------------------------- #ifdef DEBUG diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index 39dd6348bfc..3688dd2e313 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -53,7 +53,6 @@ #include "nsIDOMRange.h" #include "nsIDOMText.h" #include "nsIDOMEventReceiver.h" -#include "nsITextContent.h" #include "nsIContentIterator.h" #include "nsRange.h" #include "nsIEventListenerManager.h" @@ -115,6 +114,7 @@ #include "nsIDOMDocumentType.h" #include "nsIDOMUserDataHandler.h" #include "nsEventDispatcher.h" +#include "nsContentCreatorFunctions.h" #ifdef MOZ_SVG PRBool NS_SVG_TestFeature(const nsAString &fstr); @@ -428,9 +428,7 @@ nsNode3Tearoff::GetTextContent(nsIContent *aContent, while (!iter->IsDone()) { nsIContent *content = iter->GetCurrentNode(); if (content->IsNodeOfType(nsINode::eTEXT)) { - nsCOMPtr textContent(do_QueryInterface(iter->GetCurrentNode())); - if (textContent) - textContent->AppendTextTo(aTextContent); + content->AppendTextTo(aTextContent); } iter->Next(); } @@ -473,7 +471,7 @@ nsNode3Tearoff::SetTextContent(nsIContent* aContent, } if (!aTextContent.IsEmpty()) { - nsCOMPtr textContent; + nsCOMPtr textContent; nsresult rv = NS_NewTextNode(getter_AddRefs(textContent), aContent->NodeInfo()->NodeInfoManager()); NS_ENSURE_SUCCESS(rv, rv); @@ -3661,6 +3659,45 @@ nsGenericElement::GetAttrCount() const return mAttrsAndChildren.AttrCount(); } +const nsTextFragment* +nsGenericElement::GetText() +{ + return nsnull; +} + +PRUint32 +nsGenericElement::TextLength() +{ + // We can remove this assertion if it turns out to be useful to be able + // to depend on this returning 0 + NS_NOTREACHED("called nsGenericElement::TextLength"); + + return 0; +} + +nsresult +nsGenericElement::SetText(const PRUnichar* aBuffer, PRUint32 aLength, + PRBool aNotify) +{ + NS_ERROR("called nsGenericElement::SetText"); + + return NS_ERROR_FAILURE; +} + +PRBool +nsGenericElement::TextIsOnlyWhitespace() +{ + return PR_FALSE; +} + +void +nsGenericElement::AppendTextTo(nsAString& aResult) +{ + // We can remove this assertion if it turns out to be useful to be able + // to depend on this appending nothing. + NS_NOTREACHED("called nsGenericElement::TextLength"); +} + #ifdef DEBUG void nsGenericElement::List(FILE* out, PRInt32 aIndent) const @@ -3799,16 +3836,12 @@ nsGenericElement::GetContentsAsText(nsAString& aText) aText.Truncate(); PRInt32 children = GetChildCount(); - nsCOMPtr tc; - PRInt32 i; for (i = 0; i < children; ++i) { nsIContent *child = GetChildAt(i); if (child->IsNodeOfType(eTEXT)) { - tc = do_QueryInterface(child); - - tc->AppendTextTo(aText); + child->AppendTextTo(aText); } } } diff --git a/mozilla/content/base/src/nsGenericElement.h b/mozilla/content/base/src/nsGenericElement.h index 5386791dc34..e48e47c9351 100644 --- a/mozilla/content/base/src/nsGenericElement.h +++ b/mozilla/content/base/src/nsGenericElement.h @@ -366,6 +366,17 @@ public: PRBool aNotify); virtual const nsAttrName* GetAttrNameAt(PRUint32 aIndex) const; virtual PRUint32 GetAttrCount() const; + virtual const nsTextFragment *GetText(); + virtual PRUint32 TextLength(); + virtual nsresult SetText(const PRUnichar* aBuffer, PRUint32 aLength, + PRBool aNotify); + // Need to implement this here too to avoid hiding. + nsresult SetText(const nsAString& aStr, PRBool aNotify) + { + return SetText(aStr.BeginReading(), aStr.Length(), aNotify); + } + virtual PRBool TextIsOnlyWhitespace(); + virtual void AppendTextTo(nsAString& aResult); virtual void SetFocus(nsPresContext* aContext); virtual nsIContent *GetBindingParent() const; virtual PRBool IsNodeOfType(PRUint32 aFlags) const; diff --git a/mozilla/content/base/src/nsPlainTextSerializer.cpp b/mozilla/content/base/src/nsPlainTextSerializer.cpp index bef966e98ff..e3072f8508b 100644 --- a/mozilla/content/base/src/nsPlainTextSerializer.cpp +++ b/mozilla/content/base/src/nsPlainTextSerializer.cpp @@ -51,7 +51,6 @@ #include "nsIDOMCDATASection.h" #include "nsIDOMElement.h" #include "nsINameSpaceManager.h" -#include "nsITextContent.h" #include "nsTextFragment.h" #include "nsContentUtils.h" #include "nsReadableUtils.h" @@ -306,26 +305,25 @@ nsPlainTextSerializer::AppendText(nsIDOMText* aText, PRInt32 length = 0; nsAutoString textstr; - nsCOMPtr content = do_QueryInterface(aText); - if (!content) return NS_ERROR_FAILURE; + nsCOMPtr content = do_QueryInterface(aText); + const nsTextFragment* frag; + if (!content || !(frag = content->GetText())) { + return NS_ERROR_FAILURE; + } - const nsTextFragment* frag = content->Text(); + PRInt32 endoffset = (aEndOffset == -1) ? frag->GetLength() : aEndOffset; + NS_ASSERTION(aStartOffset <= endoffset, "A start offset is beyond the end of the text fragment!"); - if (frag) { - PRInt32 endoffset = (aEndOffset == -1) ? frag->GetLength() : aEndOffset; - NS_ASSERTION(aStartOffset <= endoffset, "A start offset is beyond the end of the text fragment!"); + length = endoffset - aStartOffset; + if (length <= 0) { + return NS_OK; + } - length = endoffset - aStartOffset; - if (length <= 0) { - return NS_OK; - } - - if (frag->Is2b()) { - textstr.Assign(frag->Get2b() + aStartOffset, length); - } - else { - textstr.AssignWithConversion(frag->Get1b()+aStartOffset, length); - } + if (frag->Is2b()) { + textstr.Assign(frag->Get2b() + aStartOffset, length); + } + else { + textstr.AssignWithConversion(frag->Get1b()+aStartOffset, length); } mOutputString = &aStr; diff --git a/mozilla/content/base/src/nsTextNode.cpp b/mozilla/content/base/src/nsTextNode.cpp index f45a616762a..dc974367b67 100644 --- a/mozilla/content/base/src/nsTextNode.cpp +++ b/mozilla/content/base/src/nsTextNode.cpp @@ -90,7 +90,7 @@ public: NS_DECL_NSIDOMEVENTLISTENER nsAttrChangeListener(PRInt32 aNameSpaceID, nsIAtom* aAttrName, - nsITextContent* aContent) : + nsIContent* aContent) : mNameSpaceID(aNameSpaceID), mAttrName(aAttrName), mContent(aContent) @@ -109,7 +109,7 @@ public: friend class nsAttributeTextNode; PRInt32 mNameSpaceID; nsCOMPtr mAttrName; - nsITextContent* mContent; // Weak ref; it owns us + nsIContent* mContent; // Weak ref; it owns us }; nsAttributeTextNode(nsINodeInfo *aNodeInfo) : nsTextNode(aNodeInfo) @@ -142,7 +142,7 @@ private: }; nsresult -NS_NewTextNode(nsITextContent** aInstancePtrResult, +NS_NewTextNode(nsIContent** aInstancePtrResult, nsNodeInfoManager *aNodeInfoManager) { NS_PRECONDITION(aNodeInfoManager, "Missing nodeInfoManager"); @@ -154,7 +154,7 @@ NS_NewTextNode(nsITextContent** aInstancePtrResult, return NS_ERROR_OUT_OF_MEMORY; } - nsITextContent *instance = new nsTextNode(ni); + nsIContent *instance = new nsTextNode(ni); if (!instance) { return NS_ERROR_OUT_OF_MEMORY; } @@ -179,7 +179,6 @@ NS_IMPL_RELEASE_INHERITED(nsTextNode, nsGenericDOMDataNode) // QueryInterface implementation for nsTextNode NS_INTERFACE_MAP_BEGIN(nsTextNode) - NS_INTERFACE_MAP_ENTRY(nsITextContent) NS_INTERFACE_MAP_ENTRY(nsIDOMNode) NS_INTERFACE_MAP_ENTRY(nsIDOMText) NS_INTERFACE_MAP_ENTRY(nsIDOMCharacterData) @@ -215,7 +214,7 @@ nsTextNode::GetNodeType(PRUint16* aNodeType) PRBool nsTextNode::IsNodeOfType(PRUint32 aFlags) const { - return !(aFlags & ~(eCONTENT | eTEXT)); + return !(aFlags & ~(eCONTENT | eTEXT | eDATA_NODE)); } nsGenericDOMDataNode* diff --git a/mozilla/content/base/src/nsXMLContentSerializer.cpp b/mozilla/content/base/src/nsXMLContentSerializer.cpp index 7d64f881565..4699105cb15 100644 --- a/mozilla/content/base/src/nsXMLContentSerializer.cpp +++ b/mozilla/content/base/src/nsXMLContentSerializer.cpp @@ -54,7 +54,6 @@ #include "nsIContent.h" #include "nsIDocument.h" #include "nsINameSpaceManager.h" -#include "nsITextContent.h" #include "nsTextFragment.h" #include "nsString.h" #include "prprf.h" @@ -108,10 +107,11 @@ nsXMLContentSerializer::AppendTextData(nsIDOMNode* aNode, PRBool aTranslateEntities, PRBool aIncrColumn) { - nsCOMPtr content(do_QueryInterface(aNode)); - if (!content) return NS_ERROR_FAILURE; - - const nsTextFragment* frag = content->Text(); + nsCOMPtr content = do_QueryInterface(aNode); + const nsTextFragment* frag; + if (!content || !(frag = content->GetText())) { + return NS_ERROR_FAILURE; + } PRInt32 endoffset = (aEndOffset == -1) ? frag->GetLength() : aEndOffset; PRInt32 length = endoffset - aStartOffset; diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index 85d94145a03..d2edcdd59b9 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -135,7 +135,6 @@ #include "nsContentCID.h" #include "nsIDOMText.h" -#include "nsITextContent.h" #include "nsCOMArray.h" #include "nsNodeInfoManager.h" @@ -143,6 +142,7 @@ #include "nsIEditorIMESupport.h" #include "nsEventDispatcher.h" #include "nsLayoutUtils.h" +#include "nsContentCreatorFunctions.h" // XXX todo: add in missing out-of-memory checks @@ -2735,7 +2735,7 @@ nsGenericHTMLElement::ReplaceContentsWithText(const nsAString& aText, if (textChild) { rv = textChild->SetData(aText); } else { - nsCOMPtr text; + nsCOMPtr text; rv = NS_NewTextNode(getter_AddRefs(text), mNodeInfo->NodeInfoManager()); NS_ENSURE_SUCCESS(rv, rv); diff --git a/mozilla/content/html/content/src/nsHTMLOptionElement.cpp b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp index 97e80b32907..415d344395c 100644 --- a/mozilla/content/html/content/src/nsHTMLOptionElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp @@ -49,7 +49,6 @@ #include "nsIFormControl.h" #include "nsIForm.h" #include "nsIDOMText.h" -#include "nsITextContent.h" #include "nsIDOMNode.h" #include "nsGenericElement.h" #include "nsIDOMHTMLCollection.h" @@ -69,6 +68,7 @@ #include "nsIEventStateManager.h" #include "nsIDocument.h" #include "nsIDOMDocument.h" +#include "nsContentCreatorFunctions.h" /** * Implementation of <option> @@ -414,7 +414,7 @@ nsHTMLOptionElement::SetText(const nsAString& aText) } if (!usedExistingTextNode) { - nsCOMPtr text; + nsCOMPtr text; rv = NS_NewTextNode(getter_AddRefs(text), mNodeInfo->NodeInfoManager()); NS_ENSURE_SUCCESS(rv, rv); @@ -525,7 +525,7 @@ nsHTMLOptionElement::Initialize(JSContext* aContext, JSString* jsstr = JS_ValueToString(aContext, argv[0]); if (jsstr) { // Create a new text node and append it to the option - nsCOMPtr textContent; + nsCOMPtr textContent; result = NS_NewTextNode(getter_AddRefs(textContent), mNodeInfo->NodeInfoManager()); if (NS_FAILED(result)) { diff --git a/mozilla/content/html/content/src/nsHTMLScriptElement.cpp b/mozilla/content/html/content/src/nsHTMLScriptElement.cpp index 8e05589ee3a..bac480978e1 100644 --- a/mozilla/content/html/content/src/nsHTMLScriptElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLScriptElement.cpp @@ -41,7 +41,6 @@ #include "nsHTMLAtoms.h" #include "nsStyleConsts.h" #include "nsPresContext.h" -#include "nsITextContent.h" #include "nsIDocument.h" #include "nsIScriptLoader.h" #include "nsIScriptLoaderObserver.h" diff --git a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp index 7b61f75dea3..e4b00d19a50 100644 --- a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp @@ -43,7 +43,7 @@ #include "nsIDOMNSXBLFormControl.h" #include "nsIDOMHTMLFormElement.h" #include "nsIDOMEventReceiver.h" -#include "nsITextContent.h" +#include "nsContentCreatorFunctions.h" #include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsStyleConsts.h" @@ -1126,7 +1126,7 @@ nsHTMLSelectElement::SetLength(PRUint32 aLength) return NS_ERROR_OUT_OF_MEMORY; } - nsCOMPtr text; + nsCOMPtr text; rv = NS_NewTextNode(getter_AddRefs(text), mNodeInfo->NodeInfoManager()); NS_ENSURE_SUCCESS(rv, rv); diff --git a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp index b8a28aaf6f3..f5af09b27a5 100644 --- a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp @@ -70,7 +70,6 @@ #include "nsPresState.h" #include "nsIDOMText.h" #include "nsReadableUtils.h" -#include "nsITextContent.h" #include "nsEventDispatcher.h" #include "nsLayoutUtils.h" diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index 53befbae5b0..375f8c02a15 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -68,7 +68,6 @@ #include "nsIContent.h" #include "nsGenericHTMLElement.h" -#include "nsITextContent.h" #include "nsIDOMText.h" #include "nsIDOMComment.h" @@ -608,7 +607,7 @@ private: public: HTMLContentSink* mSink; PRInt32 mNotifyLevel; - nsCOMPtr mLastTextNode; + nsCOMPtr mLastTextNode; PRInt32 mLastTextNodeSize; struct Node { @@ -1716,7 +1715,7 @@ SinkContext::FlushText(PRBool* aDidFlush, PRBool aReleaseLast) } } } else { - nsCOMPtr textContent; + nsCOMPtr textContent; rv = NS_NewTextNode(getter_AddRefs(textContent), mSink->mNodeInfoManager); NS_ENSURE_SUCCESS(rv, rv); diff --git a/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp b/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp index 99dec369345..22d2b9621db 100644 --- a/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp @@ -49,7 +49,6 @@ #include "nsIDOMHTMLFormElement.h" #include "nsIDOMDocumentFragment.h" #include "nsVoidArray.h" -#include "nsITextContent.h" #include "nsINameSpaceManager.h" #include "nsIDocument.h" #include "nsINodeInfo.h" @@ -725,7 +724,7 @@ nsHTMLFragmentContentSink::AddTextToContent(nsIContent* aContent, const nsAStrin if(aContent) { if (!aText.IsEmpty()) { - nsCOMPtr text; + nsCOMPtr text; result = NS_NewTextNode(getter_AddRefs(text), mNodeInfoManager); if (NS_SUCCEEDED(result)) { text->SetText(aText, PR_TRUE); @@ -744,7 +743,7 @@ nsHTMLFragmentContentSink::FlushText() return NS_OK; } - nsCOMPtr content; + nsCOMPtr content; nsresult rv = NS_NewTextNode(getter_AddRefs(content), mNodeInfoManager); NS_ENSURE_SUCCESS(rv, rv); diff --git a/mozilla/content/xbl/src/nsBindingManager.cpp b/mozilla/content/xbl/src/nsBindingManager.cpp index e062bd77998..4b93f588a06 100644 --- a/mozilla/content/xbl/src/nsBindingManager.cpp +++ b/mozilla/content/xbl/src/nsBindingManager.cpp @@ -58,7 +58,6 @@ #include "nsContentCID.h" #include "nsXMLDocument.h" #include "nsHTMLAtoms.h" -#include "nsITextContent.h" #include "nsIStreamListener.h" #include "nsGenericDOMNodeList.h" diff --git a/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp b/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp index 3639584e134..8c5271a1b70 100644 --- a/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp +++ b/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp @@ -51,7 +51,7 @@ #include "nsParserCIID.h" #include "nsNetUtil.h" #include "plstr.h" -#include "nsITextContent.h" +#include "nsContentCreatorFunctions.h" #include "nsIDocument.h" #include "nsIXMLContentSink.h" #include "nsContentCID.h" @@ -516,7 +516,7 @@ nsXBLPrototypeBinding::AttributeChanged(nsIAtom* aAttribute, nsAutoString value; aChangedElement->GetAttr(aNameSpaceID, aAttribute, value); if (!value.IsEmpty()) { - nsCOMPtr textContent; + nsCOMPtr textContent; NS_NewTextNode(getter_AddRefs(textContent), realElement->NodeInfo()->NodeInfoManager()); if (!textContent) { @@ -884,7 +884,7 @@ PRBool PR_CALLBACK SetAttrs(nsHashKey* aKey, void* aData, void* aClosure) kNameSpaceID_XUL) && dst == nsHTMLAtoms::value && !value.IsEmpty())) { - nsCOMPtr textContent; + nsCOMPtr textContent; NS_NewTextNode(getter_AddRefs(textContent), realElement->NodeInfo()->NodeInfoManager()); if (!textContent) { diff --git a/mozilla/content/xbl/src/nsXBLService.cpp b/mozilla/content/xbl/src/nsXBLService.cpp index 9815846fb3b..69d0493f03f 100644 --- a/mozilla/content/xbl/src/nsXBLService.cpp +++ b/mozilla/content/xbl/src/nsXBLService.cpp @@ -62,7 +62,6 @@ #include "nsContentCID.h" #include "nsXMLDocument.h" #include "nsHTMLAtoms.h" -#include "nsITextContent.h" #include "nsIMemory.h" #include "nsIObserverService.h" #include "nsIDOMNodeList.h" diff --git a/mozilla/content/xml/content/src/nsXMLCDATASection.cpp b/mozilla/content/xml/content/src/nsXMLCDATASection.cpp index b9fc3e98313..de9087e52d4 100644 --- a/mozilla/content/xml/content/src/nsXMLCDATASection.cpp +++ b/mozilla/content/xml/content/src/nsXMLCDATASection.cpp @@ -108,7 +108,6 @@ nsXMLCDATASection::~nsXMLCDATASection() // QueryInterface implementation for nsXMLCDATASection NS_INTERFACE_MAP_BEGIN(nsXMLCDATASection) - NS_INTERFACE_MAP_ENTRY(nsITextContent) NS_INTERFACE_MAP_ENTRY(nsIDOMNode) NS_INTERFACE_MAP_ENTRY(nsIDOMCharacterData) NS_INTERFACE_MAP_ENTRY(nsIDOMText) @@ -123,7 +122,7 @@ NS_IMPL_RELEASE_INHERITED(nsXMLCDATASection, nsGenericDOMDataNode) PRBool nsXMLCDATASection::IsNodeOfType(PRUint32 aFlags) const { - return !(aFlags & ~(eCONTENT | eTEXT)); + return !(aFlags & ~(eCONTENT | eTEXT | eDATA_NODE)); } NS_IMETHODIMP diff --git a/mozilla/content/xml/content/src/nsXMLProcessingInstruction.cpp b/mozilla/content/xml/content/src/nsXMLProcessingInstruction.cpp index d38a7de8bab..83784483dd6 100644 --- a/mozilla/content/xml/content/src/nsXMLProcessingInstruction.cpp +++ b/mozilla/content/xml/content/src/nsXMLProcessingInstruction.cpp @@ -133,7 +133,7 @@ nsXMLProcessingInstruction::GetAttrValue(nsIAtom *aName, nsAString& aValue) PRBool nsXMLProcessingInstruction::IsNodeOfType(PRUint32 aFlags) const { - return !(aFlags & ~(eCONTENT | ePROCESSING_INSTRUCTION)); + return !(aFlags & ~(eCONTENT | ePROCESSING_INSTRUCTION | eDATA_NODE)); } // virtual diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.cpp b/mozilla/content/xml/document/src/nsXMLContentSink.cpp index 7d19f93a759..36d24908d47 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -50,7 +50,6 @@ #include "nsIDocShell.h" #include "nsIDocShellTreeItem.h" #include "nsIContent.h" -#include "nsITextContent.h" #include "nsIStyleSheetLinkingElement.h" #include "nsPresContext.h" #include "nsIPresShell.h" @@ -784,7 +783,7 @@ nsXMLContentSink::FlushText(PRBool aCreateTextNode, PRBool* aDidFlush) PRBool didFlush = PR_FALSE; if (0 != mTextLength) { if (aCreateTextNode) { - nsCOMPtr textContent; + nsCOMPtr textContent; rv = NS_NewTextNode(getter_AddRefs(textContent), mNodeInfoManager); NS_ENSURE_SUCCESS(rv, rv); diff --git a/mozilla/content/xslt/src/xpath/txMozillaXPathTreeWalker.cpp b/mozilla/content/xslt/src/xpath/txMozillaXPathTreeWalker.cpp index 2b5595c4165..135bb7d3db8 100644 --- a/mozilla/content/xslt/src/xpath/txMozillaXPathTreeWalker.cpp +++ b/mozilla/content/xslt/src/xpath/txMozillaXPathTreeWalker.cpp @@ -46,7 +46,6 @@ #include "nsIDOMElement.h" #include "nsIDOMProcessingInstruction.h" #include "nsINodeInfo.h" -#include "nsITextContent.h" #include "nsPrintfCString.h" #include "nsReadableUtils.h" #include "nsString.h" @@ -546,8 +545,7 @@ static void appendTextContent(nsIContent* aElement, nsAString& aResult) appendTextContent(content, aResult); } else if (content->IsNodeOfType(nsINode::eTEXT)) { - nsCOMPtr textContent = do_QueryInterface(content); - textContent->AppendTextTo(aResult); + content->AppendTextTo(aResult); } content = aElement->GetChildAt(++i); } @@ -582,37 +580,16 @@ txXPathNodeUtils::appendNodeValue(const txXPathNode& aNode, nsAString& aResult) return; } - if (aNode.mContent->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) { - nsCOMPtr node = do_QueryInterface(aNode.mContent); - - nsAutoString result; - node->GetNodeValue(result); - aResult.Append(result); - - return; - } - - nsCOMPtr textContent = do_QueryInterface(aNode.mContent); - if (!textContent) { - NS_ERROR("Unexpected nodetype."); - - return; - } - - textContent->AppendTextTo(aResult); + aNode.mContent->AppendTextTo(aResult); } /* static */ PRBool txXPathNodeUtils::isWhitespace(const txXPathNode& aNode) { - NS_ASSERTION(aNode.isContent(), "Wrong type!"); + NS_ASSERTION(aNode.isContent() && isText(aNode), "Wrong type!"); - nsCOMPtr textCont = do_QueryInterface(aNode.mContent); - if (!textCont) { - return PR_TRUE; - } - return textCont->IsOnlyWhitespace(); + return aNode.mContent->TextIsOnlyWhitespace(); } /* static */ diff --git a/mozilla/content/xslt/src/xslt/txMozillaXMLOutput.cpp b/mozilla/content/xslt/src/xslt/txMozillaXMLOutput.cpp index 53fde4bda1c..0a9ae49e239 100644 --- a/mozilla/content/xslt/src/xslt/txMozillaXMLOutput.cpp +++ b/mozilla/content/xslt/src/xslt/txMozillaXMLOutput.cpp @@ -54,7 +54,6 @@ #include "nsIParser.h" #include "nsIRefreshURI.h" #include "nsPIDOMWindow.h" -#include "nsITextContent.h" #include "nsIXMLContent.h" #include "nsContentCID.h" #include "nsNetUtil.h" diff --git a/mozilla/content/xul/document/src/nsXULContentSink.cpp b/mozilla/content/xul/document/src/nsXULContentSink.cpp index 0aa08f94a2c..1fda8cf4abb 100644 --- a/mozilla/content/xul/document/src/nsXULContentSink.cpp +++ b/mozilla/content/xul/document/src/nsXULContentSink.cpp @@ -72,7 +72,6 @@ #include "nsIScriptRuntime.h" #include "nsIScriptGlobalObject.h" #include "nsIServiceManager.h" -#include "nsITextContent.h" #include "nsIURL.h" #include "nsIViewManager.h" #include "nsIXULContentSink.h" diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index ec2f475d620..dc136c77735 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -78,7 +78,6 @@ #include "nsIRDFRemoteDataSource.h" #include "nsIRDFService.h" #include "nsIStreamListener.h" -#include "nsITextContent.h" #include "nsITimer.h" #include "nsIDocShell.h" #include "nsXULAtoms.h" @@ -2862,7 +2861,7 @@ nsXULDocument::ResumeWalk() // and attach them to the parent node. NS_ASSERTION(element, "no element on context stack"); - nsCOMPtr text; + nsCOMPtr text; rv = NS_NewTextNode(getter_AddRefs(text), mNodeInfoManager); NS_ENSURE_SUCCESS(rv, rv); @@ -2871,12 +2870,8 @@ nsXULDocument::ResumeWalk() NS_REINTERPRET_CAST(nsXULPrototypeText*, childproto); text->SetText(textproto->mValue, PR_FALSE); - nsCOMPtr child = do_QueryInterface(text); - if (! child) - return NS_ERROR_UNEXPECTED; - - rv = element->AppendChildTo(child, PR_FALSE); - if (NS_FAILED(rv)) return rv; + rv = element->AppendChildTo(text, PR_FALSE); + NS_ENSURE_SUCCESS(rv, rv); } } break; diff --git a/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp b/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp index d44d9ca2565..85e171c4ee7 100644 --- a/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp +++ b/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp @@ -46,7 +46,6 @@ #include "nsIDOMXULDocument.h" #include "nsINodeInfo.h" #include "nsIServiceManager.h" -#include "nsITextContent.h" #include "nsIXULDocument.h" #include "nsContentSupportMap.h" @@ -746,7 +745,7 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode, rv = SubstituteText(aChild, attrValue, value); if (NS_FAILED(rv)) return rv; - nsCOMPtr content; + nsCOMPtr content; rv = NS_NewTextNode(getter_AddRefs(content), mRoot->NodeInfo()->NodeInfoManager()); if (NS_FAILED(rv)) return rv; @@ -1051,9 +1050,7 @@ nsXULContentBuilder::SynchronizeUsingTemplate(nsIContent* aTemplateNode, nsAutoString value; rv = SubstituteText(aResult, attrValue, value); if (NS_FAILED(rv)) return rv; - nsCOMPtr textcontent = do_QueryInterface(realKid); - if (textcontent) - textcontent->SetText(value, PR_TRUE); + realKid->SetText(value, PR_TRUE); } } diff --git a/mozilla/content/xul/templates/src/nsXULContentUtils.cpp b/mozilla/content/xul/templates/src/nsXULContentUtils.cpp index 9151ac93170..cdbb07a980c 100644 --- a/mozilla/content/xul/templates/src/nsXULContentUtils.cpp +++ b/mozilla/content/xul/templates/src/nsXULContentUtils.cpp @@ -69,7 +69,6 @@ #include "nsINameSpaceManager.h" #include "nsIRDFService.h" #include "nsIServiceManager.h" -#include "nsITextContent.h" #include "nsIURL.h" #include "nsXULContentUtils.h" #include "nsIXULPrototypeCache.h" diff --git a/mozilla/editor/libeditor/base/nsEditor.cpp b/mozilla/editor/libeditor/base/nsEditor.cpp index 150aab2077d..c161882ca06 100644 --- a/mozilla/editor/libeditor/base/nsEditor.cpp +++ b/mozilla/editor/libeditor/base/nsEditor.cpp @@ -86,7 +86,6 @@ #include "nsICSSStyleSheet.h" #include "nsIDocumentStateListener.h" -#include "nsITextContent.h" #include "nsIContent.h" #include "nsServiceManagerUtils.h" @@ -3839,8 +3838,10 @@ nsEditor::IsEditable(nsIDOMNode *aNode) nsIFrame *resultFrame = shell->GetPrimaryFrameFor(content); if (!resultFrame) // if it has no frame, it is not editable return PR_FALSE; - nsCOMPtr text(do_QueryInterface(content)); - if (!text) + NS_ASSERTION(content->IsNodeOfType(nsINode::eTEXT) || + content->IsNodeOfType(nsINode::eELEMENT), + "frame for non element-or-text?"); + if (!content->IsNodeOfType(nsINode::eTEXT)) return PR_TRUE; // not a text node; has a frame if (resultFrame->GetStateBits() & NS_FRAME_IS_DIRTY) // we can only trust width data for undirty frames { @@ -3876,17 +3877,6 @@ nsEditor::IsMozEditorBogusNode(nsIDOMNode *aNode) return PR_FALSE; } -PRBool -nsEditor::IsEmptyTextContent(nsIContent* aContent) -{ - PRBool result = PR_FALSE; - nsCOMPtr tc(do_QueryInterface(aContent)); - if (tc) { - result = tc->IsOnlyWhitespace(); - } - return result; -} - nsresult nsEditor::CountEditableChildren(nsIDOMNode *aNode, PRUint32 &outCount) { diff --git a/mozilla/editor/libeditor/base/nsEditor.h b/mozilla/editor/libeditor/base/nsEditor.h index 080583f8796..d8e9b554de6 100644 --- a/mozilla/editor/libeditor/base/nsEditor.h +++ b/mozilla/editor/libeditor/base/nsEditor.h @@ -497,9 +497,6 @@ public: /** returns PR_TRUE if aNode is a MozEditorBogus node */ PRBool IsMozEditorBogusNode(nsIDOMNode *aNode); - /** returns PR_TRUE if content is an merely formatting whitespacce */ - PRBool IsEmptyTextContent(nsIContent* aContent); - /** counts number of editable child nodes */ nsresult CountEditableChildren(nsIDOMNode *aNode, PRUint32 &outCount); diff --git a/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp b/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp index 16bd4491427..971c738c13e 100644 --- a/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp @@ -1059,7 +1059,7 @@ nsHTMLEditor::StripFormattingNodes(nsIDOMNode *aNode, PRBool aListOnly) nsresult res = NS_OK; nsCOMPtr content = do_QueryInterface(aNode); - if (IsEmptyTextContent(content)) + if (content->TextIsOnlyWhitespace()) { nsCOMPtr parent, ignored; aNode->GetParentNode(getter_AddRefs(parent)); diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp index 72f89abea05..e58de752c3e 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp @@ -54,7 +54,6 @@ #include "nsHTMLURIRefObject.h" #include "nsIDOMText.h" -#include "nsITextContent.h" #include "nsIDOMNodeList.h" #include "nsIDOMDocument.h" #include "nsIDOMAttr.h" @@ -122,7 +121,6 @@ // Misc #include "TextEditorTest.h" #include "nsEditorUtils.h" -#include "nsITextContent.h" #include "nsWSRunObject.h" #include "nsHTMLObjectResizer.h" @@ -1107,7 +1105,7 @@ nsHTMLEditor::IsPrevCharWhitespace(nsIDOMNode *aParentNode, textNode->GetLength(&strLength); if (strLength) { - // you could use nsITextContent::IsOnlyWhitespace here + // you could use nsIContent::TextIsOnlyWhitespace here textNode->SubstringData(strLength-1,strLength,tempString); *outIsSpace = nsCRT::IsAsciiSpace(tempString.First()); *outIsNBSP = (tempString.First() == nbsp); @@ -5098,9 +5096,9 @@ nsHTMLEditor::IsVisTextNode( nsIDOMNode *aNode, *outIsEmptyNode = PR_TRUE; nsresult res = NS_OK; - nsCOMPtr textContent = do_QueryInterface(aNode); + nsCOMPtr textContent = do_QueryInterface(aNode); // callers job to only call us with text nodes - if (!textContent) + if (!textContent || !textContent->IsNodeOfType(nsINode::eTEXT)) return NS_ERROR_NULL_POINTER; PRUint32 length = textContent->TextLength(); if (aSafeToAskFrames) @@ -5125,7 +5123,7 @@ nsHTMLEditor::IsVisTextNode( nsIDOMNode *aNode, } else if (length) { - if (textContent->IsOnlyWhitespace()) + if (textContent->TextIsOnlyWhitespace()) { nsWSRunObject wsRunObj(this, aNode, 0); nsCOMPtr visNode; diff --git a/mozilla/editor/libeditor/html/nsWSRunObject.cpp b/mozilla/editor/libeditor/html/nsWSRunObject.cpp index 797da4c9e6a..042fa1c41da 100644 --- a/mozilla/editor/libeditor/html/nsWSRunObject.cpp +++ b/mozilla/editor/libeditor/html/nsWSRunObject.cpp @@ -707,8 +707,8 @@ nsWSRunObject::GetWSNodes() // first look backwards to find preceding ws nodes if (mHTMLEditor->IsTextNode(mNode)) { - nsCOMPtr textNode(do_QueryInterface(mNode)); - const nsTextFragment *textFrag = textNode->Text(); + nsCOMPtr textNode(do_QueryInterface(mNode)); + const nsTextFragment *textFrag = textNode->GetText(); res = PrependNodeToList(mNode); NS_ENSURE_SUCCESS(res, res); @@ -767,9 +767,11 @@ nsWSRunObject::GetWSNodes() { res = PrependNodeToList(priorNode); NS_ENSURE_SUCCESS(res, res); - nsCOMPtr textNode(do_QueryInterface(priorNode)); - if (!textNode) return NS_ERROR_NULL_POINTER; - const nsTextFragment *textFrag = textNode->Text(); + nsCOMPtr textNode(do_QueryInterface(priorNode)); + const nsTextFragment *textFrag; + if (!textNode || !(textFrag = textNode->GetText())) { + return NS_ERROR_NULL_POINTER; + } PRUint32 len = textNode->TextLength(); if (len < 1) @@ -839,8 +841,8 @@ nsWSRunObject::GetWSNodes() if (mHTMLEditor->IsTextNode(mNode)) { // don't need to put it on list. it already is from code above - nsCOMPtr textNode(do_QueryInterface(mNode)); - const nsTextFragment *textFrag = textNode->Text(); + nsCOMPtr textNode(do_QueryInterface(mNode)); + const nsTextFragment *textFrag = textNode->GetText(); PRUint32 len = textNode->TextLength(); if (mOffset textNode(do_QueryInterface(nextNode)); - if (!textNode) return NS_ERROR_NULL_POINTER; - const nsTextFragment *textFrag = textNode->Text(); + nsCOMPtr textNode(do_QueryInterface(nextNode)); + const nsTextFragment *textFrag; + if (!textNode || !(textFrag = textNode->GetText())) { + return NS_ERROR_NULL_POINTER; + } PRUint32 len = textNode->TextLength(); if (len < 1) @@ -1442,6 +1446,11 @@ nsWSRunObject::PrepareToDeleteRangePriv(nsWSRunObject* aEndObject) address_of(wsEndNode), &wsEndOffset); NS_ENSURE_SUCCESS(res, res); point.mTextNode = do_QueryInterface(wsStartNode); + if (!point.mTextNode->IsNodeOfType(nsINode::eDATA_NODE)) { + // Not sure if this is needed, but it'll maintain the same + // functionality + point.mTextNode = nsnull; + } point.mOffset = wsStartOffset; res = ConvertToNBSP(point, eOutsideUserSelectAll); NS_ENSURE_SUCCESS(res, res); @@ -1493,6 +1502,11 @@ nsWSRunObject::PrepareToSplitAcrossBlocksPriv() address_of(wsEndNode), &wsEndOffset); NS_ENSURE_SUCCESS(res, res); point.mTextNode = do_QueryInterface(wsStartNode); + if (!point.mTextNode->IsNodeOfType(nsINode::eDATA_NODE)) { + // Not sure if this is needed, but it'll maintain the same + // functionality + point.mTextNode = nsnull; + } point.mOffset = wsStartOffset; res = ConvertToNBSP(point); NS_ENSURE_SUCCESS(res, res); @@ -1675,6 +1689,11 @@ nsWSRunObject::GetCharAfter(WSPoint &aPoint, WSPoint *outPoint) nsIDOMNode* node = mNodeArray[idx+1]; if (!node) return NS_ERROR_FAILURE; outPoint->mTextNode = do_QueryInterface(node); + if (!outPoint->mTextNode->IsNodeOfType(nsINode::eDATA_NODE)) { + // Not sure if this is needed, but it'll maintain the same + // functionality + outPoint->mTextNode = nsnull; + } outPoint->mOffset = 0; outPoint->mChar = GetCharAt(outPoint->mTextNode, 0); } @@ -1900,19 +1919,17 @@ nsWSRunObject::FindRun(nsIDOMNode *aNode, PRInt32 aOffset, WSFragment **outRun, } PRUnichar -nsWSRunObject::GetCharAt(nsITextContent *aTextNode, PRInt32 aOffset) +nsWSRunObject::GetCharAt(nsIContent *aTextNode, PRInt32 aOffset) { // return 0 if we can't get a char, for whatever reason if (!aTextNode) return 0; - - const nsTextFragment *textFrag = aTextNode->Text(); - - PRUint32 len = textFrag->GetLength(); - if (aOffset < 0 || aOffset>=len) + + PRUint32 len = aTextNode->TextLength(); + if (aOffset < 0 || aOffset >= len) return 0; - return textFrag->CharAt(aOffset); + return aTextNode->GetText()->CharAt(aOffset); } nsresult @@ -1957,7 +1974,7 @@ nsWSRunObject::GetWSPointAfter(nsIDOMNode *aNode, PRInt32 aOffset, WSPoint *outP lastNum = savedCur; } - nsCOMPtr textNode(do_QueryInterface(curNode)); + nsCOMPtr textNode(do_QueryInterface(curNode)); if (cmp < 0) { @@ -2015,7 +2032,7 @@ nsWSRunObject::GetWSPointBefore(nsIDOMNode *aNode, PRInt32 aOffset, WSPoint *out lastNum = savedCur; } - nsCOMPtr textNode(do_QueryInterface(curNode)); + nsCOMPtr textNode(do_QueryInterface(curNode)); if (cmp > 0) { diff --git a/mozilla/editor/libeditor/html/nsWSRunObject.h b/mozilla/editor/libeditor/html/nsWSRunObject.h index f98dd9d5828..12488e0bc37 100644 --- a/mozilla/editor/libeditor/html/nsWSRunObject.h +++ b/mozilla/editor/libeditor/html/nsWSRunObject.h @@ -41,7 +41,7 @@ #include "nsCOMPtr.h" #include "nsIDOMNode.h" #include "nsCOMArray.h" -#include "nsITextContent.h" +#include "nsIContent.h" #include "nsIEditor.h" #include "nsEditorUtils.h" @@ -228,14 +228,21 @@ class nsWSRunObject // stored in the struct. struct WSPoint { - nsCOMPtr mTextNode; + nsCOMPtr mTextNode; PRInt16 mOffset; PRUnichar mChar; WSPoint() : mTextNode(0),mOffset(0),mChar(0) {} WSPoint(nsIDOMNode *aNode, PRInt32 aOffset, PRUnichar aChar) : - mTextNode(do_QueryInterface(aNode)),mOffset(aOffset),mChar(aChar) {} - WSPoint(nsITextContent *aTextNode, PRInt32 aOffset, PRUnichar aChar) : + mTextNode(do_QueryInterface(aNode)),mOffset(aOffset),mChar(aChar) + { + if (!mTextNode->IsNodeOfType(nsINode::eDATA_NODE)) { + // Not sure if this is needed, but it'll maintain the same + // functionality + mTextNode = nsnull; + } + } + WSPoint(nsIContent *aTextNode, PRInt32 aOffset, PRUnichar aChar) : mTextNode(aTextNode),mOffset(aOffset),mChar(aChar) {} }; @@ -287,7 +294,7 @@ class nsWSRunObject nsCOMPtr *outStartNode, PRInt32 *outStartOffset, nsCOMPtr *outEndNode, PRInt32 *outEndOffset); nsresult FindRun(nsIDOMNode *aNode, PRInt32 aOffset, WSFragment **outRun, PRBool after); - PRUnichar GetCharAt(nsITextContent *aTextNode, PRInt32 aOffset); + PRUnichar GetCharAt(nsIContent *aTextNode, PRInt32 aOffset); nsresult GetWSPointAfter(nsIDOMNode *aNode, PRInt32 aOffset, WSPoint *outPoint); nsresult GetWSPointBefore(nsIDOMNode *aNode, PRInt32 aOffset, WSPoint *outPoint); nsresult CheckTrailingNBSPOfRun(WSFragment *aRun); diff --git a/mozilla/embedding/components/find/src/nsFind.cpp b/mozilla/embedding/components/find/src/nsFind.cpp index a140a7547be..f73895a3429 100644 --- a/mozilla/embedding/components/find/src/nsFind.cpp +++ b/mozilla/embedding/components/find/src/nsFind.cpp @@ -43,7 +43,6 @@ c-basic-offset: 2 -*- */ #include "nsFind.h" #include "nsContentCID.h" #include "nsIEnumerator.h" -#include "nsITextContent.h" #include "nsIDOMNode.h" #include "nsIDOMNodeList.h" #include "nsIDOMDocumentRange.h" @@ -505,11 +504,11 @@ static void DumpNode(nsIDOMNode* aNode) } nsAutoString nodeName; aNode->GetNodeName(nodeName); - nsCOMPtr textContent (do_QueryInterface(aNode)); + nsCOMPtr textContent (do_QueryInterface(aNode)); if (textContent) { nsAutoString newText; - textContent->CopyText(newText); + textContent->AppendTextTo(newText); printf(">>>> Text node (node name %s): '%s'\n", NS_LossyConvertUTF16toASCII(nodeName).get(), NS_LossyConvertUTF16toASCII(newText).get()); @@ -634,7 +633,6 @@ nsFind::NextNode(nsIDOMRange* aSearchRange, nsresult rv; nsIContent *content = nsnull; - nsCOMPtr tc; if (!mIterator || aContinueOk) { @@ -701,8 +699,7 @@ nsFind::NextNode(nsIDOMRange* aSearchRange, nsCOMPtr dnode (do_QueryInterface(content)); printf(":::::: Got the first node "); DumpNode(dnode); #endif - tc = do_QueryInterface(content); - if (tc && !SkipNode(content)) + if (content->IsNodeOfType(nsINode::eTEXT) && !SkipNode(content)) { mIterNode = do_QueryInterface(content); // Also set mIterOffset if appropriate: @@ -760,8 +757,7 @@ nsFind::NextNode(nsIDOMRange* aSearchRange, if (SkipNode(content)) continue; - tc = do_QueryInterface(content); - if (tc) + if (content->IsNodeOfType(nsINode::eTEXT)) break; #ifdef DEBUG_FIND dnode = do_QueryInterface(content); @@ -808,11 +804,11 @@ PRBool nsFind::IsBlockNode(nsIContent* aContent) PRBool nsFind::IsTextNode(nsIDOMNode* aNode) { - // Can't just QI for nsITextContent, because nsCommentNode - // also implements that interface. - nsCOMPtr content (do_QueryInterface(aNode)); + PRUint16 nodeType; + aNode->GetNodeType(&nodeType); - return content && content->IsNodeOfType(nsINode::eTEXT); + return nodeType == nsIDOMNode::TEXT_NODE || + nodeType == nsIDOMNode::CDATA_SECTION_NODE; } PRBool nsFind::IsVisibleNode(nsIDOMNode *aDOMNode) @@ -963,7 +959,7 @@ nsFind::Find(const PRUnichar *aPatText, nsIDOMRange* aSearchRange, // Direction to move pindex and ptr* int incr = (mFindBackward ? -1 : 1); - nsCOMPtr tc; + nsCOMPtr tc; const nsTextFragment *frag = nsnull; PRInt32 fragLen = 0; @@ -1038,7 +1034,7 @@ nsFind::Find(const PRUnichar *aPatText, nsIDOMRange* aSearchRange, // Get the text content: tc = do_QueryInterface(mIterNode); - if (!tc) // Out of nodes + if (!tc || !(frag = tc->GetText())) // Out of nodes { mIterator = nsnull; mLastBlockParent = 0; @@ -1046,8 +1042,6 @@ nsFind::Find(const PRUnichar *aPatText, nsIDOMRange* aSearchRange, return NS_OK; } - frag = tc->Text(); - fragLen = frag->GetLength(); // Set our starting point in this node. diff --git a/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp b/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp index f9949011874..0c8b4d80914 100644 --- a/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp +++ b/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp @@ -78,7 +78,6 @@ #include "nsISelectionPrivate.h" #include "nsISelectElement.h" #include "nsILink.h" -#include "nsITextContent.h" #include "nsTextFragment.h" #include "nsILookAndFeel.h" @@ -1598,12 +1597,9 @@ nsTypeAheadFind::RangeStartsInsideLink(nsIDOMRange *aRange, } } else if (startOffset > 0) { - nsCOMPtr textContent(do_QueryInterface(startContent)); - - if (textContent) { + const nsTextFragment *textFrag = textContent->GetText(); + if (textFrag) { // look for non whitespace character before start offset - const nsTextFragment *textFrag = textContent->Text(); - for (PRInt32 index = 0; index < startOffset; index++) { if (!XP_IS_SPACE(textFrag->CharAt(index))) { *aIsStartingLink = PR_FALSE; // not at start of a node @@ -1652,11 +1648,8 @@ nsTypeAheadFind::RangeStartsInsideLink(nsIDOMRange *aRange, nsCOMPtr parent = startContent->GetParent(); if (parent) { nsIContent *parentsFirstChild = parent->GetChildAt(0); - nsCOMPtr textContent = - do_QueryInterface(parentsFirstChild); - // We don't want to look at a whitespace-only first child - if (textContent && textContent->IsOnlyWhitespace()) + if (parentsFirstChild->TextIsOnlyWhitespace()) parentsFirstChild = parent->GetChildAt(1); if (parentsFirstChild != startContent) { diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp b/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp index 5bbc7f97fd7..21f6548935c 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp @@ -52,8 +52,6 @@ #include "nsILocalFile.h" #include "nsNetUtil.h" -#include "nsITextContent.h" - #include "nsIDOMElement.h" #include "nsISelection.h" #include "nsIDOMText.h" diff --git a/mozilla/layout/base/nsBidiPresUtils.cpp b/mozilla/layout/base/nsBidiPresUtils.cpp index 48253ee94ab..c0d017c2189 100644 --- a/mozilla/layout/base/nsBidiPresUtils.cpp +++ b/mozilla/layout/base/nsBidiPresUtils.cpp @@ -40,7 +40,6 @@ #ifdef IBMBIDI #include "nsBidiPresUtils.h" -#include "nsITextContent.h" #include "nsTextFragment.h" #include "nsLayoutAtoms.h" #include "nsPresContext.h" @@ -330,7 +329,6 @@ nsBidiPresUtils::Resolve(nsPresContext* aPresContext, nsIFrame* frame = nsnull; nsIFrame* nextBidi; nsIContent* content = nsnull; - nsCOMPtr textContent; const nsTextFragment* fragment; nsIAtom* frameType = nsnull; @@ -357,11 +355,7 @@ nsBidiPresUtils::Resolve(nsPresContext* aPresContext, mSuccess = NS_OK; break; } - textContent = do_QueryInterface(content, &mSuccess); - if (NS_FAILED(mSuccess) || (!textContent) ) { - break; - } - fragment = textContent->Text(); + fragment = content->GetText(); if (!fragment) { mSuccess = NS_ERROR_FAILURE; break; @@ -574,7 +568,6 @@ nsBidiPresUtils::CreateBlockBuffer(nsPresContext* aPresContext) nsIFrame* frame; nsIContent* prevContent = nsnull; - nsCOMPtr textContent; PRUint32 i; PRUint32 count = mLogicalFrames.Count(); @@ -592,11 +585,7 @@ nsBidiPresUtils::CreateBlockBuffer(nsPresContext* aPresContext) continue; } prevContent = content; - textContent = do_QueryInterface(content, &mSuccess); - if ( (NS_FAILED(mSuccess) ) || (!textContent) ) { - break; - } - textContent->Text()->AppendTo(mBuffer); + content->AppendTextTo(mBuffer); } else if (nsLayoutAtoms::brFrame == frameType) { // break frame // Append line separator diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index 90c8fbd5710..a6e51b49848 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -84,7 +84,6 @@ #include "nsICheckboxControlFrame.h" #include "nsIDOMCharacterData.h" #include "nsIDOMHTMLImageElement.h" -#include "nsITextContent.h" #include "nsPlaceholderFrame.h" #include "nsTableRowGroupFrame.h" #include "nsStyleChangeList.h" @@ -2237,7 +2236,7 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIFrame* aParentFram if (!content) { // Create a text content node nsIFrame* textFrame = nsnull; - nsCOMPtr textContent; + nsCOMPtr textContent; NS_NewTextNode(getter_AddRefs(textContent), mDocument->NodeInfoManager()); if (textContent) { @@ -2481,16 +2480,10 @@ nsCSSFrameConstructor::CreateHTMLImageFrame(nsIContent* aContent, } static PRBool -IsOnlyWhitespace(nsIContent* aContent) +TextIsOnlyWhitespace(nsIContent* aContent) { - PRBool onlyWhiteSpace = PR_FALSE; - if (aContent->IsNodeOfType(nsINode::eTEXT)) { - nsCOMPtr textContent = do_QueryInterface(aContent); - - onlyWhiteSpace = textContent->IsOnlyWhitespace(); - } - - return onlyWhiteSpace; + return aContent->IsNodeOfType(nsINode::eTEXT) && + aContent->TextIsOnlyWhitespace(); } /**************************************************** @@ -4068,7 +4061,7 @@ MustGeneratePseudoParent(nsIContent* aContent, nsStyleContext* aStyleContext) } if (aContent->IsNodeOfType(nsINode::eTEXT)) { - return !IsOnlyWhitespace(aContent); + return !TextIsOnlyWhitespace(aContent); } return !aContent->IsNodeOfType(nsINode::eCOMMENT); @@ -4144,7 +4137,7 @@ NeedFrameFor(nsIFrame* aParentFrame, { // don't create a whitespace frame if aParentFrame doesn't want it if ((NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE & aParentFrame->GetStateBits()) - && IsOnlyWhitespace(aChildContent)) { + && TextIsOnlyWhitespace(aChildContent)) { return PR_FALSE; } return PR_TRUE; @@ -5482,7 +5475,7 @@ nsCSSFrameConstructor::ConstructTextFrame(nsFrameConstructorState& aState, { // process pending pseudo frames. whitespace doesn't have an effect. if (!aPseudoParent && !aState.mPseudoFrames.IsEmpty() && - !IsOnlyWhitespace(aContent)) + !TextIsOnlyWhitespace(aContent)) ProcessPseudoFrames(aState, aFrameItems); nsIFrame* newFrame = nsnull; @@ -10374,24 +10367,21 @@ nsCSSFrameConstructor::CharacterDataChanged(nsIContent* aContent, // CharacterDataChanged into a ReinsertContent when we are changing text // that is part of a first-letter situation. PRBool doCharacterDataChanged = PR_TRUE; - nsCOMPtr textContent(do_QueryInterface(aContent)); - if (textContent) { - // Ok, it's text content. Now do some real work... - nsIFrame* block = GetFloatContainingBlock(frame); - if (block) { - // See if the block has first-letter style applied to it. - nsIContent* blockContent = block->GetContent(); - nsStyleContext* blockSC = block->GetStyleContext(); - PRBool haveFirstLetterStyle = - HaveFirstLetterStyle(blockContent, blockSC); - if (haveFirstLetterStyle) { - // The block has first-letter style. Use content-replaced to - // repair the blocks frame structure properly. - nsCOMPtr container = aContent->GetParent(); - if (container) { - doCharacterDataChanged = PR_FALSE; - rv = ReinsertContent(container, aContent); - } + // Ok, it's text content. Now do some real work... + nsIFrame* block = GetFloatContainingBlock(frame); + if (block) { + // See if the block has first-letter style applied to it. + nsIContent* blockContent = block->GetContent(); + nsStyleContext* blockSC = block->GetStyleContext(); + PRBool haveFirstLetterStyle = + HaveFirstLetterStyle(blockContent, blockSC); + if (haveFirstLetterStyle) { + // The block has first-letter style. Use content-replaced to + // repair the blocks frame structure properly. + nsCOMPtr container = aContent->GetParent(); + if (container) { + doCharacterDataChanged = PR_FALSE; + rv = ReinsertContent(container, aContent); } } } @@ -12183,9 +12173,8 @@ NeedFirstLetterContinuation(nsIContent* aContent) PRBool result = PR_FALSE; if (aContent) { - nsCOMPtr tc(do_QueryInterface(aContent)); - if (tc) { - const nsTextFragment* frag = tc->Text(); + const nsTextFragment* frag = aContent->GetText(); + if (frag) { PRInt32 flc = FirstLetterCount(frag); PRInt32 tl = frag->GetLength(); if (flc < tl) { @@ -12198,14 +12187,8 @@ NeedFirstLetterContinuation(nsIContent* aContent) static PRBool IsFirstLetterContent(nsIContent* aContent) { - PRBool result = PR_FALSE; - - nsCOMPtr textContent = do_QueryInterface(aContent); - if (textContent && textContent->TextLength()) { - result = !textContent->IsOnlyWhitespace(); - } - - return result; + return aContent->TextLength() && + !aContent->TextIsOnlyWhitespace(); } /** diff --git a/mozilla/layout/forms/nsComboboxControlFrame.cpp b/mozilla/layout/forms/nsComboboxControlFrame.cpp index 6d882ca29fb..6b897d315b1 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.cpp +++ b/mozilla/layout/forms/nsComboboxControlFrame.cpp @@ -70,7 +70,6 @@ #include "nsISupportsPrimitives.h" #include "nsIComponentManager.h" #include "nsContentUtils.h" -#include "nsITextContent.h" #include "nsTextFragment.h" #include "nsCSSFrameConstructor.h" #include "nsIDocument.h" @@ -1778,7 +1777,7 @@ nsComboboxControlFrame::CreateAnonymousContent(nsPresContext* aPresContext, nsNodeInfoManager *nimgr = mContent->NodeInfo()->NodeInfoManager(); - nsCOMPtr labelContent; + nsCOMPtr labelContent; NS_NewTextNode(getter_AddRefs(labelContent), nimgr); if (labelContent) { @@ -1832,7 +1831,7 @@ nsComboboxControlFrame::CreateFrameFor(nsPresContext* aPresContext, *aFrame = nsnull; NS_ASSERTION(mDisplayContent, "mDisplayContent can't be null!"); - if (!SameCOMIdentity(mDisplayContent, aContent)) { + if (mDisplayContent == aContent) { // We only handle the frames for mDisplayContent here return NS_ERROR_FAILURE; } diff --git a/mozilla/layout/forms/nsComboboxControlFrame.h b/mozilla/layout/forms/nsComboboxControlFrame.h index 11e4117662a..c0dd7f05308 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.h +++ b/mozilla/layout/forms/nsComboboxControlFrame.h @@ -60,7 +60,6 @@ #include "nsIRollupListener.h" #include "nsPresState.h" #include "nsCSSFrameConstructor.h" -#include "nsITextContent.h" #include "nsIScrollableViewProvider.h" #include "nsIStatefulFrame.h" #include "nsIDOMMouseListener.h" @@ -240,7 +239,7 @@ protected: PRBool aCheckHeight = PR_FALSE); nsFrameList mPopupFrames; // additional named child list - nsCOMPtr mDisplayContent; // Anonymous content used to display the current selection + nsCOMPtr mDisplayContent; // Anonymous content used to display the current selection nsIFrame* mDisplayFrame; // frame to display selection nsIFrame* mButtonFrame; // button frame nsIFrame* mDropdownFrame; // dropdown list frame diff --git a/mozilla/layout/forms/nsGfxButtonControlFrame.cpp b/mozilla/layout/forms/nsGfxButtonControlFrame.cpp index b9bc52090a5..bb6fa15718c 100644 --- a/mozilla/layout/forms/nsGfxButtonControlFrame.cpp +++ b/mozilla/layout/forms/nsGfxButtonControlFrame.cpp @@ -55,6 +55,7 @@ #include "nsHTMLAtoms.h" // MouseEvent suppression in PP #include "nsGUIEvent.h" +#include "nsContentCreatorFunctions.h" #include "nsNodeInfoManager.h" #include "nsIDOMHTMLInputElement.h" @@ -115,7 +116,7 @@ nsGfxButtonControlFrame::CreateAnonymousContent(nsPresContext* aPresContext, GetLabel(label); // Add a child text content node for the label - nsCOMPtr labelContent; + nsCOMPtr labelContent; NS_NewTextNode(getter_AddRefs(labelContent), mContent->NodeInfo()->NodeInfoManager()); if (labelContent) { @@ -140,8 +141,7 @@ nsGfxButtonControlFrame::CreateFrameFor(nsPresContext* aPresContext, if (aFrame) *aFrame = nsnull; - nsCOMPtr content(do_QueryInterface(mTextContent)); - if (aContent == content.get()) { + if (aContent == mTextContent) { nsIFrame * parentFrame = mFrames.FirstChild(); nsStyleContext* styleContext = parentFrame->GetStyleContext(); @@ -157,7 +157,7 @@ nsGfxButtonControlFrame::CreateFrameFor(nsPresContext* aPresContext, } // initialize the text frame - newFrame->Init(content, parentFrame, nsnull); + newFrame->Init(mTextContent, parentFrame, nsnull); newFrame->SetInitialChildList(nsnull, nsnull); rv = NS_OK; } diff --git a/mozilla/layout/forms/nsGfxButtonControlFrame.h b/mozilla/layout/forms/nsGfxButtonControlFrame.h index 8b6b950d2ae..58d53328370 100644 --- a/mozilla/layout/forms/nsGfxButtonControlFrame.h +++ b/mozilla/layout/forms/nsGfxButtonControlFrame.h @@ -42,7 +42,6 @@ #include "nsHTMLButtonControlFrame.h" #include "nsCOMPtr.h" #include "nsIAnonymousContentCreator.h" -#include "nsITextContent.h" #ifdef ACCESSIBILITY class nsIAccessible; @@ -115,7 +114,7 @@ private: NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; } nsSize mSuggestedSize; - nsCOMPtr mTextContent; + nsCOMPtr mTextContent; }; diff --git a/mozilla/layout/forms/nsIsIndexFrame.cpp b/mozilla/layout/forms/nsIsIndexFrame.cpp index a91b4e755b1..b4e65acc0fc 100644 --- a/mozilla/layout/forms/nsIsIndexFrame.cpp +++ b/mozilla/layout/forms/nsIsIndexFrame.cpp @@ -60,7 +60,6 @@ #include "nsXPCOM.h" #include "nsISupportsPrimitives.h" #include "nsIComponentManager.h" -#include "nsITextContent.h" #include "nsHTMLParts.h" #include "nsLinebreakConverter.h" #include "nsILinkHandler.h" @@ -200,7 +199,7 @@ nsIsIndexFrame::CreateAnonymousContent(nsPresContext* aPresContext, // Add a child text content node for the label if (NS_SUCCEEDED(result)) { - nsCOMPtr labelContent; + nsCOMPtr labelContent; NS_NewTextNode(getter_AddRefs(labelContent), nimgr); if (labelContent) { // set the value of the text node and add it to the child list diff --git a/mozilla/layout/forms/nsIsIndexFrame.h b/mozilla/layout/forms/nsIsIndexFrame.h index fd2075ca90a..477207701e9 100644 --- a/mozilla/layout/forms/nsIsIndexFrame.h +++ b/mozilla/layout/forms/nsIsIndexFrame.h @@ -117,7 +117,7 @@ public: NS_IMETHOD RestoreState(nsPresState* aState); protected: - nsCOMPtr mTextContent; + nsCOMPtr mTextContent; nsCOMPtr mInputContent; private: diff --git a/mozilla/layout/forms/nsTextControlFrame.cpp b/mozilla/layout/forms/nsTextControlFrame.cpp index a5d44710f87..c845d4d9ba6 100644 --- a/mozilla/layout/forms/nsTextControlFrame.cpp +++ b/mozilla/layout/forms/nsTextControlFrame.cpp @@ -107,7 +107,6 @@ #include "nsIDOMNodeList.h" //for selection setting helper func #include "nsIDOMRange.h" //for selection setting helper func #include "nsPIDOMWindow.h" //needed for notify selection changed to update the menus ect. -#include "nsITextContent.h" //needed to create initial text control content #ifdef ACCESSIBILITY #include "nsIAccessibilityService.h" #endif diff --git a/mozilla/layout/generic/nsBlockFrame.cpp b/mozilla/layout/generic/nsBlockFrame.cpp index d89a0e00292..d1accbcc351 100644 --- a/mozilla/layout/generic/nsBlockFrame.cpp +++ b/mozilla/layout/generic/nsBlockFrame.cpp @@ -70,7 +70,6 @@ #include "nsGenericHTMLElement.h" #include "prprf.h" #include "nsLayoutAtoms.h" -#include "nsITextContent.h" #include "nsStyleChangeList.h" #include "nsFrameSelection.h" #include "nsSpaceManager.h" diff --git a/mozilla/layout/generic/nsHTMLParts.h b/mozilla/layout/generic/nsHTMLParts.h index 30d5420bbc2..f1feeda5306 100644 --- a/mozilla/layout/generic/nsHTMLParts.h +++ b/mozilla/layout/generic/nsHTMLParts.h @@ -54,7 +54,6 @@ class nsIHTMLContentSink; class nsIFragmentContentSink; class nsPresContext; class nsStyleContext; -class nsITextContent; class nsIURI; class nsString; class nsIPresShell; diff --git a/mozilla/layout/generic/nsLineBox.cpp b/mozilla/layout/generic/nsLineBox.cpp index 12dac47a22f..cef3b15492a 100644 --- a/mozilla/layout/generic/nsLineBox.cpp +++ b/mozilla/layout/generic/nsLineBox.cpp @@ -45,7 +45,6 @@ #include "nsLineLayout.h" #include "prprf.h" #include "nsBlockFrame.h" -#include "nsITextContent.h" #include "nsLayoutAtoms.h" #include "nsFrameManager.h" #ifdef IBMBIDI diff --git a/mozilla/layout/generic/nsLineLayout.cpp b/mozilla/layout/generic/nsLineLayout.cpp index c6ff9561f67..7e67db9224a 100644 --- a/mozilla/layout/generic/nsLineLayout.cpp +++ b/mozilla/layout/generic/nsLineLayout.cpp @@ -63,7 +63,6 @@ #include "nsIDocument.h" #include "nsIHTMLDocument.h" #include "nsIContent.h" -#include "nsITextContent.h" #include "nsIView.h" #include "nsIViewManager.h" #include "nsHTMLAtoms.h" @@ -1034,15 +1033,13 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame, pfd->SetFlag(PFD_ISNONEMPTYTEXTFRAME, PR_TRUE); nsIContent* content = pfd->mFrame->GetContent(); - nsCOMPtr textContent - = do_QueryInterface(content); - if (textContent) { + const nsTextFragment* frag = content->GetText(); + if (frag) { pfd->SetFlag(PFD_ISNONWHITESPACETEXTFRAME, - !textContent->IsOnlyWhitespace()); + !content->TextIsOnlyWhitespace()); // fix for bug 40882 #ifdef IBMBIDI if (mPresContext->BidiEnabled()) { - const nsTextFragment* frag = textContent->Text(); if (frag->Is2b()) { //PRBool isVisual; //mPresContext->IsVisualMode(isVisual); diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index 717ff0547c0..3220d127566 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -91,7 +91,6 @@ #include "nsIDOMDragListener.h" #include "nsIDOMEventReceiver.h" #include "nsIDOMNSEvent.h" -#include "nsITextContent.h" #include "nsIPrivateDOMEvent.h" #include "nsIDocumentEncoder.h" #include "nsXPIDLString.h" diff --git a/mozilla/layout/generic/nsSelection.cpp b/mozilla/layout/generic/nsSelection.cpp index 90218b12bc9..4568af8b8e8 100644 --- a/mozilla/layout/generic/nsSelection.cpp +++ b/mozilla/layout/generic/nsSelection.cpp @@ -64,7 +64,6 @@ #include "nsITableLayout.h" #include "nsITableCellLayout.h" #include "nsIDOMNodeList.h" -#include "nsITextContent.h" #include "nsISelectionListener.h" #include "nsIContentIterator.h" diff --git a/mozilla/layout/generic/nsTextFrame.cpp b/mozilla/layout/generic/nsTextFrame.cpp index f29257442d3..c0f4e89f1f9 100644 --- a/mozilla/layout/generic/nsTextFrame.cpp +++ b/mozilla/layout/generic/nsTextFrame.cpp @@ -81,7 +81,6 @@ #include "nsDisplayList.h" #include "nsFrame.h" #include "nsTextTransformer.h" -#include "nsITextContent.h" #include "nsTextFragment.h" #include "nsHTMLAtoms.h" @@ -573,7 +572,6 @@ public: const nsHTMLReflowState& aReflowState, nsIFrame* aNextFrame, nsIContent* aContent, - nsITextContent* aText, PRInt32* aMoreSize, const PRUnichar* aWordBuf, PRUint32 &aWordBufLen, @@ -1414,10 +1412,7 @@ nsTextFrame::Init(nsIContent* aContent, // Note that if we're created due to bidi splitting the bidi code // will override what we compute here, so it's ok. - nsCOMPtr tc = do_QueryInterface(mContent); - if (tc) { - mContentLength = tc->Text()->GetLength(); - } + mContentLength = mContent->TextLength(); } return rv; } @@ -2045,13 +2040,9 @@ nsTextFrame::PaintText(nsIRenderingContext& aRenderingContext, nsPoint aPt) } else { // Get the text fragment - nsCOMPtr tc = do_QueryInterface(mContent); - const nsTextFragment* frag = nsnull; - if (tc) { - frag = tc->Text(); - if (!frag) { - return; - } + const nsTextFragment* frag = mContent->GetText(); + if (!frag) { + return; } // Choose rendering pathway based on rendering context performance @@ -3847,14 +3838,9 @@ nsTextFrame::PaintAsciiText(nsPresContext* aPresContext, } // Get the text fragment - nsCOMPtr tc = do_QueryInterface(mContent); - const nsTextFragment* frag = nsnull; - if (tc) { - frag = tc->Text(); - - if (!frag) { - return; - } + const nsTextFragment* frag = mContent->GetText(); + if (!frag) { + return; } // Make enough space to transform @@ -4431,11 +4417,7 @@ nsTextFrame::GetPointFromOffset(nsPresContext* aPresContext, } else { - PRInt32 totalLength = 0; // length up to the last-in-flow frame - nsCOMPtr tc(do_QueryInterface(mContent)); - if (tc) { - totalLength = tc->Text()->GetLength(); // raw value which includes whitespace - } + PRInt32 totalLength = mContent->TextLength(); // length up to the last-in-flow frame if ((hitLength == textLength) && (inOffset = mContentLength) && (mContentOffset + mContentLength == totalLength)) { // no need to re-measure when at the end of the last-in-flow @@ -6222,9 +6204,8 @@ nsTextFrame::TrimTrailingWhiteSpace(nsPresContext* aPresContext, (NS_STYLE_WHITESPACE_MOZ_PRE_WRAP != textStyle->mWhiteSpace)) { // Get the text fragments that make up our content - nsCOMPtr tc = do_QueryInterface(mContent); - if (tc) { - const nsTextFragment* frag = tc->Text(); + const nsTextFragment* frag = mContent->GetText(); + if (frag) { PRInt32 lastCharIndex = mContentOffset + mContentLength - 1; if (lastCharIndex < frag->GetLength()) { PRUnichar ch = frag->CharAt(lastCharIndex); @@ -6304,14 +6285,13 @@ nsTextFrame::ComputeTotalWordDimensions(nsPresContext* aPresContext, printf("\n"); #endif - nsCOMPtr tc(do_QueryInterface(content)); - if (tc) { + if (content->IsNodeOfType(nsINode::eTEXT)) { PRInt32 moreSize = 0; nsTextDimensions moreDimensions; moreDimensions = ComputeWordFragmentDimensions(aPresContext, aLineLayout, aReflowState, - aNextFrame, content, tc, + aNextFrame, content, &moreSize, newWordBuf, aWordLen, @@ -6335,7 +6315,7 @@ nsTextFrame::ComputeTotalWordDimensions(nsPresContext* aPresContext, moreDimensions = ComputeWordFragmentDimensions(aPresContext, aLineLayout, aReflowState, - aNextFrame, content, tc, &moreSize, + aNextFrame, content, &moreSize, newWordBuf, aWordLen, newWordBufSize, aCanBreakBefore); NS_ASSERTION((moreSize <= 0), @@ -6356,9 +6336,9 @@ nsTextFrame::ComputeTotalWordDimensions(nsPresContext* aPresContext, } } else { - // It claimed it was text but it doesn't implement the - // nsITextContent API. Therefore I don't know what to do with it - // and can't look inside it. Oh well. + // It claimed it was text but it doesn't contain a textfragment. + // Therefore I don't know what to do with it and can't look inside + // it. Oh well. goto done; } @@ -6383,7 +6363,6 @@ nsTextFrame::ComputeWordFragmentDimensions(nsPresContext* aPresContext, const nsHTMLReflowState& aReflowState, nsIFrame* aNextFrame, nsIContent* aContent, - nsITextContent* aText, PRInt32* aMoreSize, const PRUnichar* aWordBuf, PRUint32& aRunningWordLen, @@ -6526,13 +6505,11 @@ void nsTextFrame::ToCString(nsString& aBuf, PRInt32* aTotalContentLength) const { // Get the frames text content - nsCOMPtr tc(do_QueryInterface(mContent)); - if (!tc) { + const nsTextFragment* frag = mContent->GetText(); + if (!frag) { return; } - const nsTextFragment* frag = tc->Text(); - // Compute the total length of the text content. *aTotalContentLength = frag->GetLength(); @@ -6586,13 +6563,7 @@ nsTextFrame::IsEmpty() return PR_TRUE; } - nsCOMPtr textContent( do_QueryInterface(mContent) ); - if (! textContent) { - NS_NOTREACHED("text frame has no text content"); - return PR_TRUE; - } - - PRBool isEmpty = textContent->IsOnlyWhitespace(); + PRBool isEmpty = mContent->TextIsOnlyWhitespace(); mState |= (isEmpty ? TEXT_IS_ONLY_WHITESPACE : TEXT_ISNOT_ONLY_WHITESPACE); return isEmpty; } @@ -6755,9 +6726,8 @@ nsTextFrame::SetOffsets(PRInt32 aStart, PRInt32 aEnd) PRBool nsTextFrame::HasTerminalNewline() const { - nsCOMPtr tc(do_QueryInterface(mContent)); - if (tc && mContentLength > 0) { - const nsTextFragment* frag = tc->Text(); + const nsTextFragment* frag = mContent->GetText(); + if (frag && mContentLength > 0) { PRUnichar ch = frag->CharAt(mContentOffset + mContentLength - 1); if (ch == '\n') return PR_TRUE; diff --git a/mozilla/layout/generic/nsTextTransformer.cpp b/mozilla/layout/generic/nsTextTransformer.cpp index 07ef3cb1f8d..b398d79e79b 100644 --- a/mozilla/layout/generic/nsTextTransformer.cpp +++ b/mozilla/layout/generic/nsTextTransformer.cpp @@ -47,7 +47,6 @@ #include "nsContentUtils.h" #include "nsIContent.h" #include "nsIFrame.h" -#include "nsITextContent.h" #include "nsStyleConsts.h" #include "nsILineBreaker.h" #include "nsIWordBreaker.h" @@ -235,11 +234,8 @@ nsTextTransformer::Init(nsIFrame* aFrame, } // Get the contents text content - nsresult rv; - nsCOMPtr tc = do_QueryInterface(aContent, &rv); - if (tc.get()) { - mFrag = tc->Text(); - + mFrag = aContent->GetText(); + if (mFrag) { // Sanitize aStartingOffset if (aStartingOffset < 0) { NS_WARNING("bad starting offset"); @@ -274,7 +270,7 @@ nsTextTransformer::Init(nsIFrame* aFrame, else SetLeaveAsAscii(PR_FALSE); } - return rv; + return NS_OK; } //---------------------------------------------------------------------- diff --git a/mozilla/layout/html/tests/TestAttributes.cpp b/mozilla/layout/html/tests/TestAttributes.cpp index ae6121e38d3..5b9c89102e5 100644 --- a/mozilla/layout/html/tests/TestAttributes.cpp +++ b/mozilla/layout/html/tests/TestAttributes.cpp @@ -40,7 +40,6 @@ #include "nsCRT.h" #include "nsHTMLParts.h" #include "nsGenericHTMLElement.h" -#include "nsITextContent.h" #include "nsString.h" #include "nsIDocument.h" #include "nsISupportsArray.h" @@ -271,11 +270,11 @@ int main(int argc, char** argv) } #if 0 - // Query ITextContent interface - nsITextContent* textContent; - rv = text->QueryInterface(NS_GET_IID(nsITextContent),(void **)&textContent); + // Query IContent interface + nsIContent* textContent; + rv = text->QueryInterface(NS_GET_IID(nsIContent),(void **)&textContent); if (NS_OK != rv) { - printf("Created text content does not have the ITextContent interface.\n"); + printf("Created text content does not have the IContent interface.\n"); return -1; } diff --git a/mozilla/layout/inspector/src/inDOMUtils.cpp b/mozilla/layout/inspector/src/inDOMUtils.cpp index f79baa80f8e..41c0fe7b8ba 100644 --- a/mozilla/layout/inspector/src/inDOMUtils.cpp +++ b/mozilla/layout/inspector/src/inDOMUtils.cpp @@ -45,7 +45,6 @@ #include "nsIDocument.h" #include "nsIDOMDocument.h" #include "nsIDOMCharacterData.h" -#include "nsITextContent.h" #include "nsRuleNode.h" #include "nsIStyleRule.h" #include "nsICSSStyleRule.h" @@ -79,10 +78,10 @@ inDOMUtils::IsIgnorableWhitespace(nsIDOMCharacterData *aDataNode, *aReturn = PR_FALSE; - nsCOMPtr textContent = do_QueryInterface(aDataNode); - NS_ASSERTION(textContent, "Does not implement nsITextContent!"); + nsCOMPtr content = do_QueryInterface(aDataNode); + NS_ASSERTION(content, "Does not implement nsIContent!"); - if (!textContent->IsOnlyWhitespace()) { + if (!content->TextIsOnlyWhitespace()) { return NS_OK; } @@ -102,7 +101,6 @@ inDOMUtils::IsIgnorableWhitespace(nsIDOMCharacterData *aDataNode, return NS_OK; } - nsCOMPtr content = do_QueryInterface(aDataNode); nsIFrame* frame = presShell->GetPrimaryFrameFor(content); if (frame) { const nsStyleText* text = frame->GetStyleText(); diff --git a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp index 89a390bf7eb..c8b9c58aede 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp @@ -52,7 +52,6 @@ #include "nsIFontMetrics.h" #include "nsIDOMText.h" -#include "nsITextContent.h" #include "nsIDOMMutationEvent.h" #include "nsFrameManager.h" #include "nsStyleChangeList.h" diff --git a/mozilla/layout/mathml/base/src/nsMathMLTokenFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLTokenFrame.cpp index c14502e49af..212b7840739 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLTokenFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLTokenFrame.cpp @@ -46,7 +46,6 @@ #include "nsIFontMetrics.h" #include "nsIDOMText.h" -#include "nsITextContent.h" #include "nsFrameManager.h" #include "nsLayoutAtoms.h" #include "nsStyleChangeList.h" @@ -84,12 +83,12 @@ CompressWhitespace(nsIContent* aContent) { PRUint32 numKids = aContent->GetChildCount(); for (PRUint32 kid = 0; kid < numKids; kid++) { - nsCOMPtr tc(do_QueryInterface(aContent->GetChildAt(kid))); - if (tc && tc->IsNodeOfType(nsINode::eTEXT)) { + nsIContent* cont = aContent->GetChildAt(kid); + if (cont && cont->IsNodeOfType(nsINode::eTEXT)) { nsAutoString text; - tc->AppendTextTo(text); + cont->AppendTextTo(text); text.CompressWhitespace(); - tc->SetText(text, PR_FALSE); // not meant to be used if notify is needed + cont->SetText(text, PR_FALSE); // not meant to be used if notify is needed } } } @@ -357,14 +356,8 @@ SetQuote(nsPresContext* aPresContext, } while (textFrame); if (textFrame) { nsIContent* quoteContent = textFrame->GetContent(); - if (quoteContent) { - nsCOMPtr domText(do_QueryInterface(quoteContent)); - if (domText) { - nsCOMPtr tc(do_QueryInterface(quoteContent)); - if (tc) { - tc->SetText(aValue, PR_FALSE); // no notify since we don't want a reflow yet - } - } + if (quoteContent && quoteContent->IsNodeOfType(nsINode::eTEXT)) { + quoteContent->SetText(aValue, PR_FALSE); // no notify since we don't want a reflow yet } } } diff --git a/mozilla/layout/style/nsCSSRuleProcessor.cpp b/mozilla/layout/style/nsCSSRuleProcessor.cpp index 838ef71f2b7..9081873a97e 100644 --- a/mozilla/layout/style/nsCSSRuleProcessor.cpp +++ b/mozilla/layout/style/nsCSSRuleProcessor.cpp @@ -67,7 +67,7 @@ #include "nsDOMError.h" #include "nsRuleWalker.h" #include "nsCSSPseudoClasses.h" -#include "nsITextContent.h" +#include "nsIContent.h" #include "nsCOMPtr.h" #include "nsHashKeys.h" #include "nsStyleUtil.h" @@ -931,19 +931,9 @@ static PRBool IsSignificantChild(nsIContent* aChild, PRBool aTextIsSignificant, return PR_TRUE; } - if (aTextIsSignificant && isText) { - if (!aWhitespaceIsSignificant) { - nsCOMPtr text = do_QueryInterface(aChild); - - if (text && !text->IsOnlyWhitespace()) - return PR_TRUE; - } - else { - return PR_TRUE; - } - } - - return PR_FALSE; + return aTextIsSignificant && isText && + (aWhitespaceIsSignificant || + !aChild->TextIsOnlyWhitespace()); } // This function is to be called once we have fetched a value for an attribute diff --git a/mozilla/layout/style/nsHTMLStyleSheet.cpp b/mozilla/layout/style/nsHTMLStyleSheet.cpp index 3662d3973b5..72330a00741 100644 --- a/mozilla/layout/style/nsHTMLStyleSheet.cpp +++ b/mozilla/layout/style/nsHTMLStyleSheet.cpp @@ -66,7 +66,6 @@ #include "nsIDOMHTMLDocument.h" #include "nsIDOMHTMLElement.h" #include "nsCSSAnonBoxes.h" -#include "nsITextContent.h" #include "nsRuleWalker.h" #include "nsRuleData.h" #include "nsContentErrors.h" diff --git a/mozilla/layout/svg/base/src/nsSVGGlyphFrame.cpp b/mozilla/layout/svg/base/src/nsSVGGlyphFrame.cpp index d2c044bc2e8..c8c43b7c299 100644 --- a/mozilla/layout/svg/base/src/nsSVGGlyphFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGGlyphFrame.cpp @@ -37,7 +37,6 @@ * ***** END LICENSE BLOCK ***** */ #include "nsISVGRenderer.h" -#include "nsITextContent.h" #include "nsSVGOuterSVGFrame.h" #include "nsSVGTextFrame.h" #include "nsILookAndFeel.h" @@ -65,8 +64,8 @@ NS_NewSVGGlyphFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame* pa CallQueryInterface(parentFrame, &metrics); NS_ASSERTION(metrics, "trying to construct an SVGGlyphFrame for an invalid container"); - nsCOMPtr tc = do_QueryInterface(aContent); - NS_ASSERTION(tc, "trying to construct an SVGGlyphFrame for wrong content element"); + NS_ASSERTION(aContent->IsNodeOfType(nsINode::eTEXT), + "trying to construct an SVGGlyphFrame for wrong content element"); return new (aPresShell) nsSVGGlyphFrame(aContext); } @@ -537,12 +536,10 @@ nsSVGGlyphFrame::GetHighlight(PRUint32 *charnum, PRUint32 *nchars, nscolor *fore nsPresContext *presContext = GetPresContext(); - nsCOMPtr tc = do_QueryInterface(mContent); - NS_ASSERTION(tc, "no textcontent interface"); - // The selection ranges are relative to the uncompressed text in // the content element. We'll need the text fragment: - const nsTextFragment *fragment = tc->Text(); + const nsTextFragment *fragment = mContent->GetText(); + NS_ASSERTION(fragment, "no text"); // get the selection details SelectionDetails *details = nsnull; @@ -1112,11 +1109,7 @@ NS_IMETHODIMP_(PRUint32) nsSVGGlyphFrame::BuildGlyphFragmentTree(PRUint32 charNum, PRBool lastBranch) { // XXX actually we should be building a new fragment for each chunk here... - - - nsCOMPtr tc = do_QueryInterface(mContent); - - if (tc->TextLength() == 0) { + if (mContent->TextLength() == 0) { #ifdef DEBUG printf("Glyph frame with zero length text\n"); #endif @@ -1125,7 +1118,7 @@ nsSVGGlyphFrame::BuildGlyphFragmentTree(PRUint32 charNum, PRBool lastBranch) } mCharacterData.Truncate(); - tc->AppendTextTo(mCharacterData); + mContent->AppendTextTo(mCharacterData); mCharacterData.CompressWhitespace(charNum == 0, lastBranch); return charNum + mCharacterData.Length(); diff --git a/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp b/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp index 8571c40c407..f88e336e469 100644 --- a/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp +++ b/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp @@ -48,7 +48,6 @@ #include "nsXULAtoms.h" #include "nsHTMLAtoms.h" #include "nsIContent.h" -#include "nsITextContent.h" #include "nsINameSpaceManager.h" #include "nsIDocument.h" #include "nsIBindingManager.h" @@ -802,9 +801,7 @@ nsListBoxBodyFrame::ComputeIntrinsicWidth(nsBoxLayoutState& aBoxLayoutState) nsAutoString value; PRUint32 textCount = child->GetChildCount(); for (PRUint32 j = 0; j < textCount; ++j) { - nsCOMPtr text = - do_QueryInterface(child->GetChildAt(j)); - + nsIContent* text = child->GetChildAt(j); if (text && text->IsNodeOfType(nsINode::eTEXT)) { text->AppendTextTo(value); } diff --git a/mozilla/toolkit/components/typeaheadfind/src/nsTypeAheadFind.cpp b/mozilla/toolkit/components/typeaheadfind/src/nsTypeAheadFind.cpp index c85224ee7db..7d295609eda 100755 --- a/mozilla/toolkit/components/typeaheadfind/src/nsTypeAheadFind.cpp +++ b/mozilla/toolkit/components/typeaheadfind/src/nsTypeAheadFind.cpp @@ -76,7 +76,6 @@ #include "nsISelection.h" #include "nsISelectElement.h" #include "nsILink.h" -#include "nsITextContent.h" #include "nsTextFragment.h" #include "nsIDOMNSEditableElement.h" #include "nsIDOMNSHTMLElement.h" @@ -813,12 +812,9 @@ nsTypeAheadFind::RangeStartsInsideLink(nsIDOMRange *aRange, } } else if (startOffset > 0) { - nsCOMPtr textContent(do_QueryInterface(startContent)); - - if (textContent) { + const nsTextFragment *textFrag = startContent->GetText(); + if (textFrag) { // look for non whitespace character before start offset - const nsTextFragment *textFrag = textContent->Text(); - for (PRInt32 index = 0; index < startOffset; index++) { if (!XP_IS_SPACE(textFrag->CharAt(index))) { *aIsStartingLink = PR_FALSE; // not at start of a node @@ -838,7 +834,7 @@ nsTypeAheadFind::RangeStartsInsideLink(nsIDOMRange *aRange, nsCOMPtr typeAtom(do_GetAtom("type")); while (PR_TRUE) { - // Keep testing while textContent is equal to something, + // Keep testing while startContent is equal to something, // eventually we'll run out of ancestors if (startContent->IsNodeOfType(nsINode::eHTML)) { @@ -869,12 +865,10 @@ nsTypeAheadFind::RangeStartsInsideLink(nsIDOMRange *aRange, break; nsIContent *parentsFirstChild = parent->GetChildAt(0); - nsCOMPtr textContent (do_QueryInterface(parentsFirstChild)); - if (textContent) { - // We don't want to look at a whitespace-only first child - if (textContent->IsOnlyWhitespace()) - parentsFirstChild = parent->GetChildAt(1); + // We don't want to look at a whitespace-only first child + if (parentsFirstChild->TextIsOnlyWhitespace()) { + parentsFirstChild = parent->GetChildAt(1); } if (parentsFirstChild != startContent) {