Bug 641333: Kill nsIDOM3Text and move its contents to nsIDOMText. r=ms2ger

This commit is contained in:
Jonas Sicking 2011-05-20 22:21:28 -07:00
parent a19b1cf42c
commit 22fc5a364b
12 changed files with 56 additions and 199 deletions

View File

@ -846,52 +846,6 @@ nsGenericDOMDataNode::SplitText(PRUint32 aOffset, nsIDOMText** aReturn)
return rv;
}
//----------------------------------------------------------------------
// Implementation of the nsGenericDOMDataNode nsIDOM3Text tearoff
NS_IMPL_CYCLE_COLLECTION_CLASS(nsText3Tearoff)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsText3Tearoff)
NS_INTERFACE_MAP_ENTRY(nsIDOM3Text)
NS_INTERFACE_MAP_END_AGGREGATED(mNode)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsText3Tearoff)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mNode)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsText3Tearoff)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mNode, nsIContent)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsText3Tearoff)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsText3Tearoff)
NS_IMETHODIMP
nsText3Tearoff::GetIsElementContentWhitespace(PRBool *aReturn)
{
*aReturn = mNode->IsElementContentWhitespace();
return NS_OK;
}
NS_IMETHODIMP
nsText3Tearoff::GetWholeText(nsAString& aWholeText)
{
return mNode->GetWholeText(aWholeText);
}
NS_IMETHODIMP
nsText3Tearoff::ReplaceWholeText(const nsAString& aContent,
nsIDOMText **aReturn)
{
nsresult rv;
nsIContent* result = mNode->ReplaceWholeText(PromiseFlatString(aContent),
&rv);
return result ? CallQueryInterface(result, aReturn) : rv;
}
// Implementation of the nsIDOM3Text interface
/* static */ PRInt32
nsGenericDOMDataNode::FirstLogicallyAdjacentTextNode(nsIContent* aParent,
PRInt32 aIndex)
@ -918,7 +872,7 @@ nsGenericDOMDataNode::LastLogicallyAdjacentTextNode(nsIContent* aParent,
}
nsresult
nsGenericTextNode::GetWholeText(nsAString& aWholeText)
nsGenericDOMDataNode::GetWholeText(nsAString& aWholeText)
{
nsIContent* parent = GetParent();
@ -949,21 +903,21 @@ nsGenericTextNode::GetWholeText(nsAString& aWholeText)
return NS_OK;
}
nsIContent*
nsGenericTextNode::ReplaceWholeText(const nsAFlatString& aContent,
nsresult* aResult)
nsresult
nsGenericDOMDataNode::ReplaceWholeText(const nsAString& aContent,
nsIDOMText **aResult)
{
*aResult = NS_OK;
*aResult = nsnull;
// Handle parent-less nodes
nsCOMPtr<nsIContent> parent = GetParent();
if (!parent) {
if (aContent.IsEmpty()) {
return nsnull;
return NS_OK;
}
SetNodeValue(aContent);
return this;
return CallQueryInterface(this, aResult);
}
// We're relying on mozAutoSubtreeModified to keep the doc alive here.
@ -976,8 +930,7 @@ nsGenericTextNode::ReplaceWholeText(const nsAFlatString& aContent,
if (index < 0) {
NS_WARNING("Trying to use .replaceWholeText with an anonymous text node "
"child of a binding parent?");
*aResult = NS_ERROR_DOM_NOT_SUPPORTED_ERR;
return nsnull;
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
}
// We don't support entity references or read-only nodes, so remove the
@ -1016,11 +969,11 @@ nsGenericTextNode::ReplaceWholeText(const nsAFlatString& aContent,
// Empty string means we removed this node too.
if (aContent.IsEmpty()) {
return nsnull;
return NS_OK;
}
SetText(aContent.get(), aContent.Length(), PR_TRUE);
return this;
SetText(aContent.BeginReading(), aContent.Length(), PR_TRUE);
return CallQueryInterface(this, aResult);
}
//----------------------------------------------------------------------

View File

@ -46,7 +46,6 @@
#include "nsIContent.h"
#include "nsIDOMCharacterData.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOM3Text.h"
#include "nsTextFragment.h"
#include "nsDOMError.h"
#include "nsIEventListenerManager.h"
@ -328,7 +327,15 @@ protected:
nsresult SplitText(PRUint32 aOffset, nsIDOMText** aReturn);
friend class nsText3Tearoff;
nsresult GetWholeText(nsAString& aWholeText);
nsresult ReplaceWholeText(const nsAString& aContent, nsIDOMText **aReturn);
nsresult GetIsElementContentWhitespace(PRBool *aReturn)
{
*aReturn = TextIsOnlyWhitespace();
return NS_OK;
}
static PRInt32 FirstLogicallyAdjacentTextNode(nsIContent* aParent,
PRInt32 aIndex);
@ -360,45 +367,6 @@ private:
already_AddRefed<nsIAtom> GetCurrentValueAtom();
};
class nsGenericTextNode : public nsGenericDOMDataNode
{
public:
nsGenericTextNode(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsGenericDOMDataNode(aNodeInfo)
{
}
PRBool IsElementContentWhitespace()
{
return TextIsOnlyWhitespace();
}
nsresult GetWholeText(nsAString& aWholeText);
nsIContent* ReplaceWholeText(const nsAFlatString& aContent,
nsresult *aResult);
};
/** Tearoff class for the nsIDOM3Text portion of nsGenericDOMDataNode. */
class nsText3Tearoff : public nsIDOM3Text
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_NSIDOM3TEXT
NS_DECL_CYCLE_COLLECTION_CLASS(nsText3Tearoff)
nsText3Tearoff(nsGenericTextNode *aNode) : mNode(aNode)
{
}
protected:
virtual ~nsText3Tearoff() {}
private:
nsRefPtr<nsGenericTextNode> mNode;
};
//----------------------------------------------------------------------
/**

View File

@ -40,7 +40,6 @@
*/
#include "nsTextNode.h"
#include "nsIDOM3Text.h"
#include "nsContentUtils.h"
#include "nsIDOMEventListener.h"
#include "nsIDOMEventTarget.h"
@ -142,7 +141,7 @@ NS_NewTextNode(nsIContent** aInstancePtrResult,
}
nsTextNode::nsTextNode(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsGenericTextNode(aNodeInfo)
: nsGenericDOMDataNode(aNodeInfo)
{
}
@ -159,7 +158,6 @@ DOMCI_NODE_DATA(Text, nsTextNode)
NS_INTERFACE_TABLE_HEAD(nsTextNode)
NS_NODE_INTERFACE_TABLE3(nsTextNode, nsIDOMNode, nsIDOMText,
nsIDOMCharacterData)
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3Text, new nsText3Tearoff(this))
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsTextNode)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Text)
NS_INTERFACE_MAP_END_INHERITING(nsGenericDOMDataNode)

View File

@ -41,7 +41,6 @@
#include "nsGenericDOMDataNode.h"
#include "nsIDOMText.h"
#include "nsIDOM3Text.h"
#include "nsContentUtils.h"
#include "nsIDOMEventListener.h"
#include "nsIDOMEventTarget.h"
@ -53,7 +52,7 @@
/**
* Class used to implement DOM text nodes
*/
class nsTextNode : public nsGenericTextNode,
class nsTextNode : public nsGenericDOMDataNode,
public nsIDOMText
{
public:

View File

@ -36,14 +36,13 @@
* ***** END LICENSE BLOCK ***** */
#include "nsIDOMCDATASection.h"
#include "nsIDOM3Text.h"
#include "nsGenericDOMDataNode.h"
#include "nsGkAtoms.h"
#include "nsIDocument.h"
#include "nsContentUtils.h"
class nsXMLCDATASection : public nsGenericTextNode,
class nsXMLCDATASection : public nsGenericDOMDataNode,
public nsIDOMCDATASection
{
public:
@ -99,7 +98,7 @@ NS_NewXMLCDATASection(nsIContent** aInstancePtrResult,
}
nsXMLCDATASection::nsXMLCDATASection(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsGenericTextNode(aNodeInfo)
: nsGenericDOMDataNode(aNodeInfo)
{
}
@ -114,7 +113,6 @@ DOMCI_NODE_DATA(CDATASection, nsXMLCDATASection)
NS_INTERFACE_TABLE_HEAD(nsXMLCDATASection)
NS_NODE_INTERFACE_TABLE4(nsXMLCDATASection, nsIDOMNode, nsIDOMCharacterData,
nsIDOMText, nsIDOMCDATASection)
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3Text, new nsText3Tearoff(this))
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CDATASection)
NS_INTERFACE_MAP_END_INHERITING(nsGenericDOMDataNode)

View File

@ -224,7 +224,6 @@
#include "nsIDOMDocumentFragment.h"
#include "nsDOMAttribute.h"
#include "nsIDOMText.h"
#include "nsIDOM3Text.h"
#include "nsIDOMComment.h"
#include "nsIDOMCDATASection.h"
#include "nsIDOMProcessingInstruction.h"
@ -2547,7 +2546,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Text)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(Comment, nsIDOMComment)
@ -2562,7 +2560,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Text)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(ProcessingInstruction, nsIDOMProcessingInstruction)

View File

@ -80,13 +80,12 @@ DOMCI_CASTABLE_INTERFACE(nsIContent, nsIContent, 1, _extra) \
DOMCI_CASTABLE_INTERFACE(nsIDocument, nsIDocument, 2, _extra) \
DOMCI_CASTABLE_INTERFACE(nsINodeList, nsINodeList, 3, _extra) \
DOMCI_CASTABLE_INTERFACE(nsICSSDeclaration, nsICSSDeclaration, 4, _extra) \
DOMCI_CASTABLE_INTERFACE(nsGenericTextNode, nsGenericTextNode, 5, _extra) \
DOMCI_CASTABLE_INTERFACE(nsDocument, nsIDocument, 6, _extra) \
DOMCI_CASTABLE_INTERFACE(nsGenericHTMLElement, nsGenericHTMLElement, 7, \
DOMCI_CASTABLE_INTERFACE(nsDocument, nsIDocument, 5, _extra) \
DOMCI_CASTABLE_INTERFACE(nsGenericHTMLElement, nsGenericHTMLElement, 6, \
_extra) \
DOMCI_CASTABLE_INTERFACE(nsHTMLDocument, nsIDocument, 8, _extra) \
DOMCI_CASTABLE_INTERFACE(nsStyledElement, nsStyledElement, 9, _extra) \
DOMCI_CASTABLE_INTERFACE(nsSVGStylableElement, nsIContent, 10, _extra)
DOMCI_CASTABLE_INTERFACE(nsHTMLDocument, nsIDocument, 7, _extra) \
DOMCI_CASTABLE_INTERFACE(nsStyledElement, nsStyledElement, 8, _extra) \
DOMCI_CASTABLE_INTERFACE(nsSVGStylableElement, nsIContent, 9, _extra)
// Make sure all classes mentioned in DOMCI_CASTABLE_INTERFACES
// have been declared.

View File

@ -68,7 +68,6 @@ SDK_XPIDLSRCS = \
$(NULL)
XPIDLSRCS = \
nsIDOM3Node.idl \
nsIDOM3Text.idl \
nsIDOM3TypeInfo.idl \
nsIDOM3Attr.idl \
nsIDOMDOMStringList.idl \

View File

@ -1,65 +0,0 @@
/* ***** 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 DOM 3 Core interface definitions.
*
* The Initial Developer of the Original Code is
* Jeff Walden <jwalden+code@mit.edu>.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either 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 ***** */
#include "domstubs.idl"
[scriptable, uuid(BCCA052E-46F4-4B8E-8859-A86776C2F1D7)]
interface nsIDOM3Text : nsISupports
{
/**
* Indicates whether this text node contains element content whitespace.
* A text node is element content whitespace if it contains only XML
* white space characters and is a child of an element whose content
* model allows only child elements optionally separated by white space.
*/
readonly attribute boolean isElementContentWhitespace;
/**
* The concatenation of all logically adjacent text nodes with this text
* node, where "logically adjacent" consists of all text nodes which can be
* reached by traversing the document tree in either direction without
* passing an element, comment, or processing-instruction boundary.
*/
readonly attribute DOMString wholeText;
/**
* If content is empty, removes all logically adjacent text nodes (including
* this node) from the DOM tree, returning null; otherwise, replaces the
* contents of this node with aContent and removes all other logically
* adjacent text nodes from the DOM tree, returning this node.
*/
nsIDOMText replaceWholeText(in DOMString content) raises(DOMException);
};

View File

@ -49,7 +49,7 @@
* http://www.w3.org/TR/DOM-Level-2-Core/
*/
[scriptable, uuid(f8da723d-0d32-4bbc-a11e-898e506cd908)]
[scriptable, uuid(f1eea89d-8af3-4c2a-90df-6c3a75cb5005)]
interface nsIDOMCDATASection : nsIDOMText
{
};

View File

@ -44,12 +44,36 @@
* the textual content (termed character data in XML) of an Element or Attr.
*
* For more information on this interface please see
* http://www.w3.org/TR/DOM-Level-2-Core/
* http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
*/
[scriptable, uuid(48642156-d686-46b7-8e96-35edd5b2afa8)]
[scriptable, uuid(04a1ec2b-491f-4a80-8db4-694c37e31a6f)]
interface nsIDOMText : nsIDOMCharacterData
{
nsIDOMText splitText(in unsigned long offset)
raises(DOMException);
/**
* Indicates whether this text node contains element content whitespace.
* A text node is element content whitespace if it contains only XML
* white space characters and is a child of an element whose content
* model allows only child elements optionally separated by white space.
*/
readonly attribute boolean isElementContentWhitespace;
/**
* The concatenation of all logically adjacent text nodes with this text
* node, where "logically adjacent" consists of all text nodes which can be
* reached by traversing the document tree in either direction without
* passing an element, comment, or processing-instruction boundary.
*/
readonly attribute DOMString wholeText;
/**
* If content is empty, removes all logically adjacent text nodes (including
* this node) from the DOM tree, returning null; otherwise, replaces the
* contents of this node with aContent and removes all other logically
* adjacent text nodes from the DOM tree, returning this node.
*/
nsIDOMText replaceWholeText(in DOMString content) raises(DOMException);
};

View File

@ -784,19 +784,6 @@ customMethodCalls = {
'thisType': 'nsGenericElement',
'code': ' PRBool result = self->MozMatchesSelector(arg0, &rv);',
},
'nsIDOM3Text_': {
'thisType': 'nsGenericTextNode'
},
'nsIDOM3Text_IsElementContentWhitespace': {
'thisType': 'nsGenericTextNode',
'code': ' PRBool result = self->IsElementContentWhitespace();',
'canFail': False
},
'nsIDOM3Text_ReplaceWholeText': {
'thisType': 'nsGenericTextNode',
'code': ' nsIContent* result = '
'self->ReplaceWholeText(PromiseFlatString(arg0), &rv);'
},
'nsIDOMNodeSelector_QuerySelector': {
'thisType': 'nsINode',
'code': ' nsIContent* result = '