Bug 344050: Kill nsITextContent and move the methods to nsIContent. r/sr=jst

This commit is contained in:
cvshook%sicking.cc 2006-07-19 04:36:36 +00:00
Родитель 9ba0f844b5
Коммит c7936e48f6
78 изменённых файлов: 405 добавлений и 5093 удалений

Просмотреть файл

@ -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"

Просмотреть файл

@ -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<nsITextContent> 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<nsIPresShell> 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<nsPIAccessNode> 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) {

Просмотреть файл

@ -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<nsITextContent> text(do_QueryInterface(child));
if (text) {
nsCOMPtr<nsIContent> text = do_QueryInterface(child);
if (text && text->IsNodeOfType(nsINode::eTEXT)) {
nsAutoString txtValue;
rv = AppendFlatStringFromContentNode(text, &txtValue);
if (NS_SUCCEEDED(rv)) {

Просмотреть файл

@ -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<nsPIAccessNode> 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<nsPIAccessNode> 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<nsIRenderingContext> 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<nsPIAccessNode> 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<nsITextContent> textContent(do_QueryInterface(aNode));
if (textContent) {
textData.length = textContent->TextLength();
nsCOMPtr<nsIContent> 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<nsITextContent> textContent(do_QueryInterface(aChild));
if (textContent) {
textData.length = textContent->TextLength();
nsCOMPtr<nsIContent> content(do_QueryInterface(aChild));
if (content && content->IsNodeOfType(nsINode::eTEXT)) {
textData.length = content->TextLength();
if (!textData.length) {
return NS_OK;
}

Просмотреть файл

@ -63,7 +63,6 @@ nsINodeInfo.h \
nsIRangeUtils.h \
nsIScriptElement.h \
nsIStyleSheetLinkingElement.h \
nsITextContent.h \
nsIPrivateDOMImplementation.h \
nsIContentSerializer.h \
nsIHTMLToTextSink.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.
*/

Просмотреть файл

@ -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

Просмотреть файл

@ -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
};
/**

Просмотреть файл

Просмотреть файл

@ -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"

Просмотреть файл

@ -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

Просмотреть файл

@ -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"

Просмотреть файл

@ -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<nsITextContent> mChild;
nsCOMPtr<nsIContent> mChild;
nsAttributeChildList* mChildList;
nsIContent *GetContentInternal() const

Просмотреть файл

@ -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)

Просмотреть файл

@ -76,6 +76,10 @@ public:
// nsIDOMDocumentType
NS_DECL_NSIDOMDOCUMENTTYPE
// nsIContent overrides
virtual PRBool IsNodeOfType(PRUint32 aFlags) const;
virtual const nsTextFragment* GetText();
protected:
nsCOMPtr<nsIAtom> mName;
nsCOMPtr<nsIDOMNamedNodeMap> mEntities;

Просмотреть файл

@ -2584,7 +2584,7 @@ nsDocument::CreateTextNode(const nsAString& aData, nsIDOMText** aReturn)
{
*aReturn = nsnull;
nsCOMPtr<nsITextContent> text;
nsCOMPtr<nsIContent> text;
nsresult rv = NS_NewTextNode(getter_AddRefs(text), mNodeInfoManager);
if (NS_SUCCEEDED(rv)) {

Просмотреть файл

@ -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<nsITextContent> tc(do_QueryInterface(aNode));
if (tc) {
result = tc->IsOnlyWhitespace();
}
return result;
nsCOMPtr<nsIContent> cont = do_QueryInterface(aNode);
return cont && cont->TextIsOnlyWhitespace();
}
nsresult NS_NewHTMLCopyTextEncoder(nsIDocumentEncoder** aResult); // make mac compiler happy

Просмотреть файл

@ -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<nsITextContent> 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<nsITextContent> newContent = Clone(mNodeInfo, PR_FALSE);
nsCOMPtr<nsIContent> 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

Просмотреть файл

@ -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

Просмотреть файл

@ -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<nsITextContent> 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<nsITextContent> textContent;
nsCOMPtr<nsIContent> 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<nsITextContent> 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);
}
}
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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<nsITextContent> content = do_QueryInterface(aText);
if (!content) return NS_ERROR_FAILURE;
nsCOMPtr<nsIContent> 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;

Просмотреть файл

@ -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<nsIAtom> 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*

Просмотреть файл

@ -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<nsITextContent> content(do_QueryInterface(aNode));
if (!content) return NS_ERROR_FAILURE;
const nsTextFragment* frag = content->Text();
nsCOMPtr<nsIContent> 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;

Просмотреть файл

@ -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<nsITextContent> text;
nsCOMPtr<nsIContent> text;
rv = NS_NewTextNode(getter_AddRefs(text), mNodeInfo->NodeInfoManager());
NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -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 &lt;option&gt;
@ -414,7 +414,7 @@ nsHTMLOptionElement::SetText(const nsAString& aText)
}
if (!usedExistingTextNode) {
nsCOMPtr<nsITextContent> text;
nsCOMPtr<nsIContent> 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<nsITextContent> textContent;
nsCOMPtr<nsIContent> textContent;
result = NS_NewTextNode(getter_AddRefs(textContent),
mNodeInfo->NodeInfoManager());
if (NS_FAILED(result)) {

Просмотреть файл

@ -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"

Просмотреть файл

@ -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<nsITextContent> text;
nsCOMPtr<nsIContent> text;
rv = NS_NewTextNode(getter_AddRefs(text), mNodeInfo->NodeInfoManager());
NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -70,7 +70,6 @@
#include "nsPresState.h"
#include "nsIDOMText.h"
#include "nsReadableUtils.h"
#include "nsITextContent.h"
#include "nsEventDispatcher.h"
#include "nsLayoutUtils.h"

Просмотреть файл

@ -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<nsITextContent> mLastTextNode;
nsCOMPtr<nsIContent> mLastTextNode;
PRInt32 mLastTextNodeSize;
struct Node {
@ -1716,7 +1715,7 @@ SinkContext::FlushText(PRBool* aDidFlush, PRBool aReleaseLast)
}
}
} else {
nsCOMPtr<nsITextContent> textContent;
nsCOMPtr<nsIContent> textContent;
rv = NS_NewTextNode(getter_AddRefs(textContent),
mSink->mNodeInfoManager);
NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -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<nsITextContent> text;
nsCOMPtr<nsIContent> 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<nsITextContent> content;
nsCOMPtr<nsIContent> content;
nsresult rv = NS_NewTextNode(getter_AddRefs(content), mNodeInfoManager);
NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -58,7 +58,6 @@
#include "nsContentCID.h"
#include "nsXMLDocument.h"
#include "nsHTMLAtoms.h"
#include "nsITextContent.h"
#include "nsIStreamListener.h"
#include "nsGenericDOMNodeList.h"

Просмотреть файл

@ -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<nsITextContent> textContent;
nsCOMPtr<nsIContent> 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<nsITextContent> textContent;
nsCOMPtr<nsIContent> textContent;
NS_NewTextNode(getter_AddRefs(textContent),
realElement->NodeInfo()->NodeInfoManager());
if (!textContent) {

Просмотреть файл

@ -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"

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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<nsITextContent> textContent;
nsCOMPtr<nsIContent> textContent;
rv = NS_NewTextNode(getter_AddRefs(textContent), mNodeInfoManager);
NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -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<nsITextContent> 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<nsIDOMNode> node = do_QueryInterface(aNode.mContent);
nsAutoString result;
node->GetNodeValue(result);
aResult.Append(result);
return;
}
nsCOMPtr<nsITextContent> 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<nsITextContent> textCont = do_QueryInterface(aNode.mContent);
if (!textCont) {
return PR_TRUE;
}
return textCont->IsOnlyWhitespace();
return aNode.mContent->TextIsOnlyWhitespace();
}
/* static */

Просмотреть файл

@ -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"

Просмотреть файл

@ -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"

Просмотреть файл

@ -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<nsITextContent> text;
nsCOMPtr<nsIContent> 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<nsIContent> 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;

Просмотреть файл

@ -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<nsITextContent> content;
nsCOMPtr<nsIContent> 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<nsITextContent> textcontent = do_QueryInterface(realKid);
if (textcontent)
textcontent->SetText(value, PR_TRUE);
realKid->SetText(value, PR_TRUE);
}
}

Просмотреть файл

@ -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"

Просмотреть файл

@ -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<nsITextContent> 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<nsITextContent> tc(do_QueryInterface(aContent));
if (tc) {
result = tc->IsOnlyWhitespace();
}
return result;
}
nsresult
nsEditor::CountEditableChildren(nsIDOMNode *aNode, PRUint32 &outCount)
{

Просмотреть файл

@ -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);

Просмотреть файл

@ -1059,7 +1059,7 @@ nsHTMLEditor::StripFormattingNodes(nsIDOMNode *aNode, PRBool aListOnly)
nsresult res = NS_OK;
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
if (IsEmptyTextContent(content))
if (content->TextIsOnlyWhitespace())
{
nsCOMPtr<nsIDOMNode> parent, ignored;
aNode->GetParentNode(getter_AddRefs(parent));

Просмотреть файл

@ -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<nsITextContent> textContent = do_QueryInterface(aNode);
nsCOMPtr<nsIContent> 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<nsIDOMNode> visNode;

Просмотреть файл

@ -707,8 +707,8 @@ nsWSRunObject::GetWSNodes()
// first look backwards to find preceding ws nodes
if (mHTMLEditor->IsTextNode(mNode))
{
nsCOMPtr<nsITextContent> textNode(do_QueryInterface(mNode));
const nsTextFragment *textFrag = textNode->Text();
nsCOMPtr<nsIContent> 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<nsITextContent> textNode(do_QueryInterface(priorNode));
if (!textNode) return NS_ERROR_NULL_POINTER;
const nsTextFragment *textFrag = textNode->Text();
nsCOMPtr<nsIContent> 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<nsITextContent> textNode(do_QueryInterface(mNode));
const nsTextFragment *textFrag = textNode->Text();
nsCOMPtr<nsIContent> textNode(do_QueryInterface(mNode));
const nsTextFragment *textFrag = textNode->GetText();
PRUint32 len = textNode->TextLength();
if (mOffset<len)
@ -899,9 +901,11 @@ nsWSRunObject::GetWSNodes()
{
res = AppendNodeToList(nextNode);
NS_ENSURE_SUCCESS(res, res);
nsCOMPtr<nsITextContent> textNode(do_QueryInterface(nextNode));
if (!textNode) return NS_ERROR_NULL_POINTER;
const nsTextFragment *textFrag = textNode->Text();
nsCOMPtr<nsIContent> 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<nsITextContent> textNode(do_QueryInterface(curNode));
nsCOMPtr<nsIContent> textNode(do_QueryInterface(curNode));
if (cmp < 0)
{
@ -2015,7 +2032,7 @@ nsWSRunObject::GetWSPointBefore(nsIDOMNode *aNode, PRInt32 aOffset, WSPoint *out
lastNum = savedCur;
}
nsCOMPtr<nsITextContent> textNode(do_QueryInterface(curNode));
nsCOMPtr<nsIContent> textNode(do_QueryInterface(curNode));
if (cmp > 0)
{

Просмотреть файл

@ -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<nsITextContent> mTextNode;
nsCOMPtr<nsIContent> 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<nsIDOMNode> *outStartNode, PRInt32 *outStartOffset,
nsCOMPtr<nsIDOMNode> *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);

Просмотреть файл

@ -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<nsITextContent> textContent (do_QueryInterface(aNode));
nsCOMPtr<nsIContent> 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<nsITextContent> tc;
if (!mIterator || aContinueOk)
{
@ -701,8 +699,7 @@ nsFind::NextNode(nsIDOMRange* aSearchRange,
nsCOMPtr<nsIDOMNode> 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<nsIContent> 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<nsITextContent> tc;
nsCOMPtr<nsIContent> 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.

Просмотреть файл

@ -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<nsITextContent> 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<nsIContent> parent = startContent->GetParent();
if (parent) {
nsIContent *parentsFirstChild = parent->GetChildAt(0);
nsCOMPtr<nsITextContent> 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) {

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -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<nsITextContent> 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<nsITextContent> 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

Просмотреть файл

@ -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<nsITextContent> textContent;
nsCOMPtr<nsIContent> 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<nsITextContent> 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<nsITextContent> 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<nsIContent> 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<nsIContent> 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<nsITextContent> 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<nsITextContent> textContent = do_QueryInterface(aContent);
if (textContent && textContent->TextLength()) {
result = !textContent->IsOnlyWhitespace();
}
return result;
return aContent->TextLength() &&
!aContent->TextIsOnlyWhitespace();
}
/**

Просмотреть файл

@ -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<nsITextContent> labelContent;
nsCOMPtr<nsIContent> 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;
}

Просмотреть файл

@ -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<nsITextContent> mDisplayContent; // Anonymous content used to display the current selection
nsCOMPtr<nsIContent> mDisplayContent; // Anonymous content used to display the current selection
nsIFrame* mDisplayFrame; // frame to display selection
nsIFrame* mButtonFrame; // button frame
nsIFrame* mDropdownFrame; // dropdown list frame

Просмотреть файл

@ -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<nsITextContent> labelContent;
nsCOMPtr<nsIContent> labelContent;
NS_NewTextNode(getter_AddRefs(labelContent),
mContent->NodeInfo()->NodeInfoManager());
if (labelContent) {
@ -140,8 +141,7 @@ nsGfxButtonControlFrame::CreateFrameFor(nsPresContext* aPresContext,
if (aFrame)
*aFrame = nsnull;
nsCOMPtr<nsIContent> 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;
}

Просмотреть файл

@ -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<nsITextContent> mTextContent;
nsCOMPtr<nsIContent> mTextContent;
};

Просмотреть файл

@ -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<nsITextContent> labelContent;
nsCOMPtr<nsIContent> labelContent;
NS_NewTextNode(getter_AddRefs(labelContent), nimgr);
if (labelContent) {
// set the value of the text node and add it to the child list

Просмотреть файл

@ -117,7 +117,7 @@ public:
NS_IMETHOD RestoreState(nsPresState* aState);
protected:
nsCOMPtr<nsITextContent> mTextContent;
nsCOMPtr<nsIContent> mTextContent;
nsCOMPtr<nsIContent> mInputContent;
private:

Просмотреть файл

@ -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

Просмотреть файл

@ -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"

Просмотреть файл

@ -54,7 +54,6 @@ class nsIHTMLContentSink;
class nsIFragmentContentSink;
class nsPresContext;
class nsStyleContext;
class nsITextContent;
class nsIURI;
class nsString;
class nsIPresShell;

Просмотреть файл

@ -45,7 +45,6 @@
#include "nsLineLayout.h"
#include "prprf.h"
#include "nsBlockFrame.h"
#include "nsITextContent.h"
#include "nsLayoutAtoms.h"
#include "nsFrameManager.h"
#ifdef IBMBIDI

Просмотреть файл

@ -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<nsITextContent> 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);

Просмотреть файл

@ -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"

Просмотреть файл

@ -64,7 +64,6 @@
#include "nsITableLayout.h"
#include "nsITableCellLayout.h"
#include "nsIDOMNodeList.h"
#include "nsITextContent.h"
#include "nsISelectionListener.h"
#include "nsIContentIterator.h"

Просмотреть файл

@ -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<nsITextContent> 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<nsITextContent> 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<nsITextContent> 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<nsITextContent> 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<nsITextContent> 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<nsITextContent> 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<nsITextContent> 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<nsITextContent> 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<nsITextContent> 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;

Просмотреть файл

@ -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<nsITextContent> 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;
}
//----------------------------------------------------------------------

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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<nsITextContent> textContent = do_QueryInterface(aDataNode);
NS_ASSERTION(textContent, "Does not implement nsITextContent!");
nsCOMPtr<nsIContent> 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<nsIContent> content = do_QueryInterface(aDataNode);
nsIFrame* frame = presShell->GetPrimaryFrameFor(content);
if (frame) {
const nsStyleText* text = frame->GetStyleText();

Просмотреть файл

@ -52,7 +52,6 @@
#include "nsIFontMetrics.h"
#include "nsIDOMText.h"
#include "nsITextContent.h"
#include "nsIDOMMutationEvent.h"
#include "nsFrameManager.h"
#include "nsStyleChangeList.h"

Просмотреть файл

@ -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<nsITextContent> 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<nsIDOMText> domText(do_QueryInterface(quoteContent));
if (domText) {
nsCOMPtr<nsITextContent> 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
}
}
}

Просмотреть файл

@ -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<nsITextContent> 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

Просмотреть файл

@ -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"

Просмотреть файл

@ -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<nsITextContent> 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<nsITextContent> 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<nsITextContent> 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();

Просмотреть файл

@ -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<nsITextContent> text =
do_QueryInterface(child->GetChildAt(j));
nsIContent* text = child->GetChildAt(j);
if (text && text->IsNodeOfType(nsINode::eTEXT)) {
text->AppendTextTo(value);
}

Просмотреть файл

@ -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<nsITextContent> 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<nsIAtom> 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<nsITextContent> 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) {