Bug 1454241: Remove nsINode::eDATA_NODE. r=bz

MozReview-Commit-ID: 6HQDAwiGgIo
This commit is contained in:
Emilio Cobos Álvarez 2018-04-15 12:46:24 +02:00
Родитель 8e2992c3d7
Коммит 45787fc53f
14 изменённых файлов: 26 добавлений и 42 удалений

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

@ -320,8 +320,7 @@ HTMLSelectOptGroupAccessible::NativeInteractiveState() const
bool
HTMLSelectOptGroupAccessible::IsAcceptableChild(nsIContent* aEl) const
{
return aEl->IsNodeOfType(nsINode::eDATA_NODE) ||
aEl->IsHTMLElement(nsGkAtoms::option);
return aEl->IsCharacterData() || aEl->IsHTMLElement(nsGkAtoms::option);
}
uint8_t

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

@ -663,7 +663,7 @@ CharacterData::DoGetXBLBinding() const
bool
CharacterData::IsNodeOfType(uint32_t aFlags) const
{
return !(aFlags & ~eDATA_NODE);
return false;
}
void

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

@ -28,7 +28,7 @@ NS_IMPL_ISUPPORTS_INHERITED(Comment, CharacterData, nsIDOMNode)
bool
Comment::IsNodeOfType(uint32_t aFlags) const
{
return !(aFlags & ~(eCOMMENT | eDATA_NODE));
return !(aFlags & ~eCOMMENT);
}
already_AddRefed<CharacterData>

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

@ -57,21 +57,16 @@ DocumentType::DocumentType(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
{
MOZ_ASSERT(mNodeInfo->NodeType() == DOCUMENT_TYPE_NODE,
"Bad NodeType in aNodeInfo");
MOZ_ASSERT(!IsCharacterData());
}
DocumentType::~DocumentType()
{
}
DocumentType::~DocumentType() = default;
NS_IMPL_ISUPPORTS_INHERITED(DocumentType, CharacterData, nsIDOMNode)
bool
DocumentType::IsNodeOfType(uint32_t aFlags) const
{
// Don't claim to be eDATA_NODE since we're just inheriting
// CharacterData for convenience. Doctypes aren't really
// data nodes (they have a null .nodeValue and don't implement
// the DOM CharacterData interface)
return false;
}

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

@ -3215,7 +3215,7 @@ Selection::ContainsNode(nsINode& aNode, bool aAllowPartial, ErrorResult& aRv)
// XXXbz this duplicates the GetNodeLength code in nsRange.cpp
uint32_t nodeLength;
bool isData = aNode.IsNodeOfType(nsINode::eDATA_NODE);
bool isData = aNode.IsCharacterData();
if (isData) {
nodeLength = aNode.AsText()->TextLength();
} else {

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

@ -40,7 +40,7 @@ NodeIsInTraversalRange(nsINode* aNode, bool aIsPreMode,
// If a leaf node contains an end point of the traversal range, it is
// always in the traversal range.
if (aNode == aStart.Container() || aNode == aEnd.Container()) {
if (aNode->IsNodeOfType(nsINode::eDATA_NODE)) {
if (aNode->IsCharacterData()) {
return true; // text node or something
}
if (!aNode->HasChildren()) {
@ -317,7 +317,7 @@ nsContentIterator::InitInternal(const RawRangeBoundary& aStart,
return NS_ERROR_FAILURE;
}
bool startIsData = aStart.Container()->IsNodeOfType(nsINode::eDATA_NODE);
bool startIsData = aStart.Container()->IsCharacterData();
// Check to see if we have a collapsed range, if so, there is nothing to
// iterate over.
@ -410,7 +410,7 @@ nsContentIterator::InitInternal(const RawRangeBoundary& aStart,
// Find last node in range.
bool endIsData = aEnd.Container()->IsNodeOfType(nsINode::eDATA_NODE);
bool endIsData = aEnd.Container()->IsCharacterData();
if (endIsData || !aEnd.Container()->HasChildren() || aEnd.IsStartOfContainer()) {
if (mPre) {

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

@ -529,7 +529,7 @@ nsINode::GetNodeValueInternal(nsAString& aNodeValue)
nsINode*
nsINode::RemoveChild(nsINode& aOldChild, ErrorResult& aError)
{
if (IsNodeOfType(eDATA_NODE)) {
if (IsCharacterData()) {
// aOldChild can't be one of our children.
aError.Throw(NS_ERROR_DOM_NOT_FOUND_ERR);
return nullptr;

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

@ -420,8 +420,6 @@ public:
eCOMMENT = 1 << 5,
/** form control elements */
eHTML_FORM_CONTROL = 1 << 6,
/** character data nodes (comments, PIs, text). */
eDATA_NODE = 1 << 8,
/** animation elements */
eANIMATION = 1 << 10,
/** filter elements that implement SVGFilterPrimitiveStandardAttributes */

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

@ -110,7 +110,7 @@ nsTextNode::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
bool
nsTextNode::IsNodeOfType(uint32_t aFlags) const
{
return !(aFlags & ~eDATA_NODE);
return false;
}
already_AddRefed<CharacterData>

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

@ -26,7 +26,7 @@ CDATASection::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
bool
CDATASection::IsNodeOfType(uint32_t aFlags) const
{
return !(aFlags & ~eDATA_NODE);
return false;
}
already_AddRefed<CharacterData>

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

@ -82,7 +82,7 @@ ProcessingInstruction::GetAttrValue(nsAtom *aName, nsAString& aValue)
bool
ProcessingInstruction::IsNodeOfType(uint32_t aFlags) const
{
return !(aFlags & ~(ePROCESSING_INSTRUCTION | eDATA_NODE));
return !(aFlags & ~ePROCESSING_INSTRUCTION);
}
already_AddRefed<CharacterData>

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

@ -136,7 +136,8 @@ DeleteRangeTransaction::CreateTxnsToDeleteBetween(
}
// see what kind of node we have
if (aStart.Container()->IsNodeOfType(nsINode::eDATA_NODE)) {
if (RefPtr<CharacterData> charDataNode =
CharacterData::FromNode(aStart.Container())) {
// if the node is a chardata node, then delete chardata content
int32_t numToDel;
if (aStart == aEnd) {
@ -146,9 +147,6 @@ DeleteRangeTransaction::CreateTxnsToDeleteBetween(
MOZ_DIAGNOSTIC_ASSERT(numToDel > 0);
}
RefPtr<CharacterData> charDataNode =
static_cast<CharacterData*>(aStart.Container());
RefPtr<DeleteTextTransaction> deleteTextTransaction =
DeleteTextTransaction::MaybeCreate(*mEditorBase, *charDataNode,
aStart.Offset(), numToDel);
@ -193,7 +191,8 @@ DeleteRangeTransaction::CreateTxnsToDeleteContent(
return NS_ERROR_NOT_AVAILABLE;
}
if (!aPoint.Container()->IsNodeOfType(nsINode::eDATA_NODE)) {
RefPtr<CharacterData> dataNode = CharacterData::FromNode(aPoint.Container());
if (!dataNode) {
return NS_OK;
}
@ -211,8 +210,6 @@ DeleteRangeTransaction::CreateTxnsToDeleteContent(
return NS_OK;
}
RefPtr<CharacterData> dataNode =
static_cast<CharacterData*>(aPoint.Container());
RefPtr<DeleteTextTransaction> deleteTextTransaction =
DeleteTextTransaction::MaybeCreate(*mEditorBase, *dataNode,
startOffset, numToDelete);

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

@ -4594,9 +4594,8 @@ EditorBase::CreateTxnForDeleteRange(nsRange* aRangeToDelete,
// there is a priorNode, so delete its last child (if chardata, delete the
// last char). if it has no children, delete it
if (priorNode->IsNodeOfType(nsINode::eDATA_NODE)) {
RefPtr<CharacterData> priorNodeAsCharData =
static_cast<CharacterData*>(priorNode.get());
if (RefPtr<CharacterData> priorNodeAsCharData =
CharacterData::FromNode(priorNode)) {
uint32_t length = priorNode->Length();
// Bail out for empty chardata XXX: Do we want to do something else?
if (NS_WARN_IF(!length)) {
@ -4634,9 +4633,8 @@ EditorBase::CreateTxnForDeleteRange(nsRange* aRangeToDelete,
// there is a nextNode, so delete its first child (if chardata, delete the
// first char). if it has no children, delete it
if (nextNode->IsNodeOfType(nsINode::eDATA_NODE)) {
RefPtr<CharacterData> nextNodeAsCharData =
static_cast<CharacterData*>(nextNode.get());
if (RefPtr<CharacterData> nextNodeAsCharData =
CharacterData::FromNode(nextNode)) {
uint32_t length = nextNode->Length();
// Bail out for empty chardata XXX: Do we want to do something else?
if (NS_WARN_IF(!length)) {
@ -4664,12 +4662,10 @@ EditorBase::CreateTxnForDeleteRange(nsRange* aRangeToDelete,
return deleteNodeTransaction.forget();
}
if (node->IsNodeOfType(nsINode::eDATA_NODE)) {
if (RefPtr<CharacterData> nodeAsCharData = CharacterData::FromNode(node)) {
if (NS_WARN_IF(aAction != ePrevious && aAction != eNext)) {
return nullptr;
}
RefPtr<CharacterData> nodeAsCharData =
static_cast<CharacterData*>(node.get());
// We have chardata, so delete a char at the proper offset
RefPtr<DeleteTextTransaction> deleteTextTransaction =
aAction == ePrevious ?
@ -4697,7 +4693,7 @@ EditorBase::CreateTxnForDeleteRange(nsRange* aRangeToDelete,
}
while (selectedNode &&
selectedNode->IsNodeOfType(nsINode::eDATA_NODE) &&
selectedNode->IsCharacterData() &&
!selectedNode->Length()) {
// Can't delete an empty chardata node (bug 762183)
if (aAction == ePrevious) {
@ -4711,12 +4707,11 @@ EditorBase::CreateTxnForDeleteRange(nsRange* aRangeToDelete,
return nullptr;
}
if (selectedNode->IsNodeOfType(nsINode::eDATA_NODE)) {
if (RefPtr<CharacterData> selectedNodeAsCharData =
CharacterData::FromNode(selectedNode)) {
if (NS_WARN_IF(aAction != ePrevious && aAction != eNext)) {
return nullptr;
}
RefPtr<CharacterData> selectedNodeAsCharData =
static_cast<CharacterData*>(selectedNode.get());
// we are deleting from a chardata node, so do a character deletion
uint32_t position = 0;
if (aAction == ePrevious) {

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

@ -222,7 +222,7 @@ public:
bool
IsInDataNode() const
{
return mParent && mParent->IsNodeOfType(nsINode::eDATA_NODE);
return mParent && mParent->IsCharacterData();
}
/**