mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1463981
part 3. Remove nsIDOMNode usage in editor. r=masayuki
This commit is contained in:
parent
0f8f7f6fba
commit
c73f664888
@ -95,7 +95,7 @@ CreateElementTransaction::DoTransaction()
|
||||
NS_ENSURE_STATE(mNewNode);
|
||||
|
||||
// Try to insert formatting whitespace for the new node:
|
||||
mEditorBase->MarkNodeDirty(GetAsDOMNode(mNewNode));
|
||||
mEditorBase->MarkNodeDirty(mNewNode);
|
||||
|
||||
// Insert the new node
|
||||
ErrorResult error;
|
||||
|
@ -75,7 +75,6 @@
|
||||
#include "nsIContent.h" // for nsIContent
|
||||
#include "nsIDocument.h" // for nsIDocument
|
||||
#include "nsIDOMEventListener.h" // for nsIDOMEventListener
|
||||
#include "nsIDOMNode.h" // for nsIDOMNode, etc.
|
||||
#include "nsIDocumentStateListener.h" // for nsIDocumentStateListener
|
||||
#include "nsIEditActionListener.h" // for nsIEditActionListener
|
||||
#include "nsIEditorObserver.h" // for nsIEditorObserver
|
||||
@ -1261,16 +1260,16 @@ EditorBase::RemoveAttributeWithTransaction(Element& aElement,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EditorBase::MarkNodeDirty(nsIDOMNode* aNode)
|
||||
EditorBase::MarkNodeDirty(nsINode* aNode)
|
||||
{
|
||||
// Mark the node dirty, but not for webpages (bug 599983)
|
||||
if (!OutputsMozDirty()) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<dom::Element> element = do_QueryInterface(aNode);
|
||||
if (element) {
|
||||
element->SetAttr(kNameSpaceID_None, nsGkAtoms::mozdirty,
|
||||
EmptyString(), false);
|
||||
if (aNode && aNode->IsElement()) {
|
||||
RefPtr<Element> element = aNode->AsElement();
|
||||
element->SetAttr(kNameSpaceID_None, nsGkAtoms::mozdirty, EmptyString(),
|
||||
false);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1404,23 +1403,22 @@ EditorBase::CreateNodeWithTransaction(
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EditorBase::InsertNode(nsIDOMNode* aNodeToInsert,
|
||||
nsIDOMNode* aContainer,
|
||||
EditorBase::InsertNode(nsINode* aNodeToInsert,
|
||||
nsINode* aContainer,
|
||||
int32_t aOffset)
|
||||
{
|
||||
nsCOMPtr<nsIContent> contentToInsert = do_QueryInterface(aNodeToInsert);
|
||||
if (NS_WARN_IF(!contentToInsert)) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsCOMPtr<nsINode> container = do_QueryInterface(aContainer);
|
||||
if (NS_WARN_IF(!container)) {
|
||||
if (NS_WARN_IF(!aContainer)) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
int32_t offset =
|
||||
aOffset < 0 ? static_cast<int32_t>(container->Length()) :
|
||||
std::min(aOffset, static_cast<int32_t>(container->Length()));
|
||||
aOffset < 0 ? static_cast<int32_t>(aContainer->Length()) :
|
||||
std::min(aOffset, static_cast<int32_t>(aContainer->Length()));
|
||||
return InsertNodeWithTransaction(*contentToInsert,
|
||||
EditorRawDOMPoint(container, offset));
|
||||
EditorRawDOMPoint(aContainer, offset));
|
||||
}
|
||||
|
||||
template<typename PT, typename CT>
|
||||
@ -1463,21 +1461,20 @@ EditorBase::InsertNodeWithTransaction(
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EditorBase::SplitNode(nsIDOMNode* aNode,
|
||||
EditorBase::SplitNode(nsINode* aNode,
|
||||
int32_t aOffset,
|
||||
nsIDOMNode** aNewLeftNode)
|
||||
nsINode** aNewLeftNode)
|
||||
{
|
||||
nsCOMPtr<nsIContent> node = do_QueryInterface(aNode);
|
||||
if (NS_WARN_IF(!node)) {
|
||||
if (NS_WARN_IF(!aNode)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
int32_t offset = std::min(std::max(aOffset, 0),
|
||||
static_cast<int32_t>(node->Length()));
|
||||
static_cast<int32_t>(aNode->Length()));
|
||||
ErrorResult error;
|
||||
nsCOMPtr<nsIContent> newNode =
|
||||
SplitNodeWithTransaction(EditorRawDOMPoint(node, offset), error);
|
||||
*aNewLeftNode = GetAsDOMNode(newNode.forget().take());
|
||||
SplitNodeWithTransaction(EditorRawDOMPoint(aNode, offset), error);
|
||||
newNode.forget(aNewLeftNode);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
@ -1547,14 +1544,12 @@ EditorBase::SplitNodeWithTransaction(
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EditorBase::JoinNodes(nsIDOMNode* aLeftNode,
|
||||
nsIDOMNode* aRightNode,
|
||||
nsIDOMNode*)
|
||||
EditorBase::JoinNodes(nsINode* aLeftNode,
|
||||
nsINode* aRightNode,
|
||||
nsINode*)
|
||||
{
|
||||
nsCOMPtr<nsINode> leftNode = do_QueryInterface(aLeftNode);
|
||||
nsCOMPtr<nsINode> rightNode = do_QueryInterface(aRightNode);
|
||||
NS_ENSURE_STATE(leftNode && rightNode && leftNode->GetParentNode());
|
||||
return JoinNodesWithTransaction(*leftNode, *rightNode);
|
||||
NS_ENSURE_STATE(aLeftNode && aRightNode && aLeftNode->GetParentNode());
|
||||
return JoinNodesWithTransaction(*aLeftNode, *aRightNode);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -1621,13 +1616,12 @@ EditorBase::JoinNodesWithTransaction(nsINode& aLeftNode,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EditorBase::DeleteNode(nsIDOMNode* aNode)
|
||||
EditorBase::DeleteNode(nsINode* aNode)
|
||||
{
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
if (NS_WARN_IF(!node)) {
|
||||
if (NS_WARN_IF(!aNode)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
return DeleteNodeWithTransaction(*node);
|
||||
return DeleteNodeWithTransaction(*aNode);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -2443,22 +2437,16 @@ EditorBase::EndOperation()
|
||||
|
||||
NS_IMETHODIMP
|
||||
EditorBase::CloneAttribute(const nsAString& aAttribute,
|
||||
nsIDOMNode* aDestNode,
|
||||
nsIDOMNode* aSourceNode)
|
||||
Element* aDestElement,
|
||||
Element* aSourceElement)
|
||||
{
|
||||
NS_ENSURE_TRUE(aDestNode && aSourceNode, NS_ERROR_NULL_POINTER);
|
||||
NS_ENSURE_TRUE(aDestElement && aSourceElement, NS_ERROR_NULL_POINTER);
|
||||
if (NS_WARN_IF(aAttribute.IsEmpty())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<Element> destElement = do_QueryInterface(aDestNode);
|
||||
nsCOMPtr<Element> sourceElement = do_QueryInterface(aSourceNode);
|
||||
if (NS_WARN_IF(!destElement) || NS_WARN_IF(!sourceElement)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
RefPtr<nsAtom> attribute = NS_Atomize(aAttribute);
|
||||
return CloneAttributeWithTransaction(*attribute, *destElement, *sourceElement);
|
||||
return CloneAttributeWithTransaction(*attribute, *aDestElement, *aSourceElement);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -2478,16 +2466,14 @@ EditorBase::CloneAttributeWithTransaction(nsAtom& aAttribute,
|
||||
* @param aSource Must be a DOM element.
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
EditorBase::CloneAttributes(nsIDOMNode* aDestDOMElement,
|
||||
nsIDOMNode* aSourceDOMElement)
|
||||
EditorBase::CloneAttributes(Element* aDestElement,
|
||||
Element* aSourceElement)
|
||||
{
|
||||
nsCOMPtr<Element> destElement = do_QueryInterface(aDestDOMElement);
|
||||
nsCOMPtr<Element> sourceElement = do_QueryInterface(aSourceDOMElement);
|
||||
if (NS_WARN_IF(!destElement) || NS_WARN_IF(!sourceElement)) {
|
||||
if (NS_WARN_IF(!aDestElement) || NS_WARN_IF(!aSourceElement)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
CloneAttributesWithTransaction(*destElement, *sourceElement);
|
||||
CloneAttributesWithTransaction(*aDestElement, *aSourceElement);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -3372,20 +3358,6 @@ EditorBase::DoJoinNodes(nsINode* aNodeToKeep,
|
||||
return err.StealNSResult();
|
||||
}
|
||||
|
||||
// static
|
||||
int32_t
|
||||
EditorBase::GetChildOffset(nsIDOMNode* aChild,
|
||||
nsIDOMNode* aParent)
|
||||
{
|
||||
MOZ_ASSERT(aChild && aParent);
|
||||
|
||||
nsCOMPtr<nsINode> parent = do_QueryInterface(aParent);
|
||||
nsCOMPtr<nsINode> child = do_QueryInterface(aChild);
|
||||
MOZ_ASSERT(parent && child);
|
||||
|
||||
return GetChildOffset(child, parent);
|
||||
}
|
||||
|
||||
// static
|
||||
int32_t
|
||||
EditorBase::GetChildOffset(nsINode* aChild,
|
||||
@ -3753,16 +3725,6 @@ EditorBase::TagCanContainTag(nsAtom& aParentTag,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
EditorBase::IsRoot(nsIDOMNode* inNode)
|
||||
{
|
||||
NS_ENSURE_TRUE(inNode, false);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> rootNode = do_QueryInterface(GetRoot());
|
||||
|
||||
return inNode == rootNode;
|
||||
}
|
||||
|
||||
bool
|
||||
EditorBase::IsRoot(nsINode* inNode)
|
||||
{
|
||||
@ -3781,13 +3743,6 @@ EditorBase::IsEditorRoot(nsINode* aNode)
|
||||
return aNode == rootNode;
|
||||
}
|
||||
|
||||
bool
|
||||
EditorBase::IsDescendantOfRoot(nsIDOMNode* inNode)
|
||||
{
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(inNode);
|
||||
return IsDescendantOfRoot(node);
|
||||
}
|
||||
|
||||
bool
|
||||
EditorBase::IsDescendantOfRoot(nsINode* inNode)
|
||||
{
|
||||
@ -3814,13 +3769,6 @@ EditorBase::IsContainer(nsINode* aNode)
|
||||
return aNode ? true : false;
|
||||
}
|
||||
|
||||
bool
|
||||
EditorBase::IsEditable(nsIDOMNode* aNode)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
||||
return IsEditable(content);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
EditorBase::CountEditableChildren(nsINode* aNode)
|
||||
{
|
||||
@ -3873,19 +3821,6 @@ EditorBase::ResetModificationCount()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAtom*
|
||||
EditorBase::GetTag(nsIDOMNode* aNode)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
||||
|
||||
if (!content) {
|
||||
NS_ASSERTION(aNode, "null node passed to EditorBase::GetTag()");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return content->NodeInfo()->NameAtom();
|
||||
}
|
||||
|
||||
bool
|
||||
EditorBase::AreNodesSameType(nsIContent* aNode1,
|
||||
nsIContent* aNode2)
|
||||
@ -3895,18 +3830,6 @@ EditorBase::AreNodesSameType(nsIContent* aNode1,
|
||||
return aNode1->NodeInfo()->NameAtom() == aNode2->NodeInfo()->NameAtom();
|
||||
}
|
||||
|
||||
bool
|
||||
EditorBase::IsTextNode(nsIDOMNode* aNode)
|
||||
{
|
||||
if (!aNode) {
|
||||
NS_NOTREACHED("null node passed to IsTextNode()");
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
return IsTextNode(node);
|
||||
}
|
||||
|
||||
// static
|
||||
nsIContent*
|
||||
EditorBase::GetNodeAtRangeOffsetPoint(const RawRangeBoundary& aPoint)
|
||||
|
@ -38,7 +38,6 @@
|
||||
class mozInlineSpellChecker;
|
||||
class nsAtom;
|
||||
class nsIContent;
|
||||
class nsIDOMNode;
|
||||
class nsIDocumentStateListener;
|
||||
class nsIEditActionListener;
|
||||
class nsIEditorObserver;
|
||||
@ -1399,14 +1398,6 @@ protected: // May be called by friends.
|
||||
nsIContent* GetLeftmostChild(nsINode *aCurrentNode,
|
||||
bool bNoBlockCrossing = false);
|
||||
|
||||
/**
|
||||
* Returns true if aNode is of the type implied by aTag.
|
||||
*/
|
||||
static inline bool NodeIsType(nsIDOMNode* aNode, nsAtom* aTag)
|
||||
{
|
||||
return GetTag(aNode) == aTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if aParent can contain a child of type aTag.
|
||||
*/
|
||||
@ -1418,14 +1409,12 @@ protected: // May be called by friends.
|
||||
/**
|
||||
* Returns true if aNode is our root node.
|
||||
*/
|
||||
bool IsRoot(nsIDOMNode* inNode);
|
||||
bool IsRoot(nsINode* inNode);
|
||||
bool IsEditorRoot(nsINode* aNode);
|
||||
|
||||
/**
|
||||
* Returns true if aNode is a descendant of our root node.
|
||||
*/
|
||||
bool IsDescendantOfRoot(nsIDOMNode* inNode);
|
||||
bool IsDescendantOfRoot(nsINode* inNode);
|
||||
bool IsDescendantOfEditorRoot(nsINode* aNode);
|
||||
|
||||
@ -1437,7 +1426,6 @@ protected: // May be called by friends.
|
||||
/**
|
||||
* returns true if aNode is an editable node.
|
||||
*/
|
||||
bool IsEditable(nsIDOMNode* aNode);
|
||||
bool IsEditable(nsINode* aNode)
|
||||
{
|
||||
NS_ENSURE_TRUE(aNode, false);
|
||||
@ -1503,11 +1491,8 @@ protected: // May be called by friends.
|
||||
/**
|
||||
* From html rules code - migration in progress.
|
||||
*/
|
||||
static nsAtom* GetTag(nsIDOMNode* aNode);
|
||||
|
||||
virtual bool AreNodesSameType(nsIContent* aNode1, nsIContent* aNode2);
|
||||
|
||||
static bool IsTextNode(nsIDOMNode* aNode);
|
||||
static bool IsTextNode(nsINode* aNode)
|
||||
{
|
||||
return aNode->NodeType() == nsINode::TEXT_NODE;
|
||||
@ -1796,8 +1781,6 @@ protected: // Shouldn't be used by friend classes
|
||||
* methods may return wrong index if aChild doesn't have previous
|
||||
* sibling or next sibling.
|
||||
*/
|
||||
static int32_t GetChildOffset(nsIDOMNode* aChild,
|
||||
nsIDOMNode* aParent);
|
||||
static int32_t GetChildOffset(nsINode* aChild,
|
||||
nsINode* aParent);
|
||||
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsINode.h"
|
||||
|
||||
namespace mozilla {
|
||||
@ -97,14 +96,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
EditorDOMPointBase(nsIDOMNode* aDOMContainer,
|
||||
int32_t aOffset)
|
||||
: mIsChildInitialized(false)
|
||||
{
|
||||
nsCOMPtr<nsINode> container = do_QueryInterface(aDOMContainer);
|
||||
this->Set(container, aOffset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Different from RangeBoundary, aPointedNode should be a child node
|
||||
* which you want to refer.
|
||||
@ -123,16 +114,6 @@ public:
|
||||
"Initializing RangeBoundary with invalid value");
|
||||
}
|
||||
|
||||
explicit EditorDOMPointBase(nsIDOMNode* aDOMPointedNode)
|
||||
: mIsChildInitialized(false)
|
||||
{
|
||||
nsCOMPtr<nsIContent> child = do_QueryInterface(aDOMPointedNode);
|
||||
if (NS_WARN_IF(!child)) {
|
||||
return;
|
||||
}
|
||||
this->Set(child);
|
||||
}
|
||||
|
||||
EditorDOMPointBase(nsINode* aContainer,
|
||||
nsIContent* aPointedNode,
|
||||
int32_t aOffset)
|
||||
@ -198,12 +179,6 @@ public:
|
||||
return mParent ? mParent->GetAsText() : nullptr;
|
||||
}
|
||||
|
||||
nsIDOMNode*
|
||||
GetContainerAsDOMNode() const
|
||||
{
|
||||
return mParent ? mParent->AsDOMNode() : nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* CanContainerHaveChildren() returns true if the container node can have
|
||||
* child nodes. Otherwise, e.g., when the container is a text node, returns
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "nsGkAtoms.h" // for nsGkAtoms, nsGkAtoms::a, etc.
|
||||
#include "nsHTMLTags.h"
|
||||
#include "nsAtom.h" // for nsAtom
|
||||
#include "nsIDOMNode.h" // for nsIDOMNode
|
||||
#include "nsNameSpaceManager.h" // for kNameSpaceID_None
|
||||
#include "nsLiteralString.h" // for NS_LITERAL_STRING
|
||||
#include "nsString.h" // for nsAutoString
|
||||
@ -29,14 +28,6 @@ namespace mozilla {
|
||||
/**
|
||||
* IsInlineStyle() returns true if aNode is an inline style.
|
||||
*/
|
||||
bool
|
||||
HTMLEditUtils::IsInlineStyle(nsIDOMNode* aNode)
|
||||
{
|
||||
MOZ_ASSERT(aNode);
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
return node && IsInlineStyle(node);
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLEditUtils::IsInlineStyle(nsINode* aNode)
|
||||
{
|
||||
@ -57,14 +48,6 @@ HTMLEditUtils::IsInlineStyle(nsINode* aNode)
|
||||
/**
|
||||
* IsFormatNode() returns true if aNode is a format node.
|
||||
*/
|
||||
bool
|
||||
HTMLEditUtils::IsFormatNode(nsIDOMNode* aNode)
|
||||
{
|
||||
MOZ_ASSERT(aNode);
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
return node && IsFormatNode(node);
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLEditUtils::IsFormatNode(nsINode* aNode)
|
||||
{
|
||||
@ -111,35 +94,9 @@ HTMLEditUtils::IsHeader(nsINode& aNode)
|
||||
nsGkAtoms::h6);
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLEditUtils::IsHeader(nsIDOMNode* aNode)
|
||||
{
|
||||
MOZ_ASSERT(aNode);
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
MOZ_ASSERT(node);
|
||||
return IsHeader(*node);
|
||||
}
|
||||
|
||||
/**
|
||||
* IsParagraph() returns true if aNode is an html paragraph.
|
||||
*/
|
||||
bool
|
||||
HTMLEditUtils::IsParagraph(nsIDOMNode* aNode)
|
||||
{
|
||||
return EditorBase::NodeIsType(aNode, nsGkAtoms::p);
|
||||
}
|
||||
|
||||
/**
|
||||
* IsListItem() returns true if aNode is an html list item.
|
||||
*/
|
||||
bool
|
||||
HTMLEditUtils::IsListItem(nsIDOMNode* aNode)
|
||||
{
|
||||
MOZ_ASSERT(aNode);
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
return node && IsListItem(node);
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLEditUtils::IsListItem(nsINode* aNode)
|
||||
{
|
||||
@ -152,14 +109,6 @@ HTMLEditUtils::IsListItem(nsINode* aNode)
|
||||
/**
|
||||
* IsTableElement() returns true if aNode is an html table, td, tr, ...
|
||||
*/
|
||||
bool
|
||||
HTMLEditUtils::IsTableElement(nsIDOMNode* aNode)
|
||||
{
|
||||
MOZ_ASSERT(aNode);
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
return node && IsTableElement(node);
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLEditUtils::IsTableElement(nsINode* aNode)
|
||||
{
|
||||
@ -178,14 +127,6 @@ HTMLEditUtils::IsTableElement(nsINode* aNode)
|
||||
* IsTableElementButNotTable() returns true if aNode is an html td, tr, ...
|
||||
* (doesn't include table)
|
||||
*/
|
||||
bool
|
||||
HTMLEditUtils::IsTableElementButNotTable(nsIDOMNode* aNode)
|
||||
{
|
||||
MOZ_ASSERT(aNode);
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
return node && IsTableElementButNotTable(node);
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLEditUtils::IsTableElementButNotTable(nsINode* aNode)
|
||||
{
|
||||
@ -211,12 +152,6 @@ HTMLEditUtils::IsTable(nsINode* aNode)
|
||||
/**
|
||||
* IsTableRow() returns true if aNode is an html tr.
|
||||
*/
|
||||
bool
|
||||
HTMLEditUtils::IsTableRow(nsIDOMNode* aNode)
|
||||
{
|
||||
return EditorBase::NodeIsType(aNode, nsGkAtoms::tr);
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLEditUtils::IsTableRow(nsINode* aNode)
|
||||
{
|
||||
@ -226,14 +161,6 @@ HTMLEditUtils::IsTableRow(nsINode* aNode)
|
||||
/**
|
||||
* IsTableCell() returns true if aNode is an html td or th.
|
||||
*/
|
||||
bool
|
||||
HTMLEditUtils::IsTableCell(nsIDOMNode* aNode)
|
||||
{
|
||||
MOZ_ASSERT(aNode);
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
return node && IsTableCell(node);
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLEditUtils::IsTableCell(nsINode* aNode)
|
||||
{
|
||||
@ -254,14 +181,6 @@ HTMLEditUtils::IsTableCellOrCaption(nsINode& aNode)
|
||||
/**
|
||||
* IsList() returns true if aNode is an html list.
|
||||
*/
|
||||
bool
|
||||
HTMLEditUtils::IsList(nsIDOMNode* aNode)
|
||||
{
|
||||
MOZ_ASSERT(aNode);
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
return node && IsList(node);
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLEditUtils::IsList(nsINode* aNode)
|
||||
{
|
||||
@ -271,43 +190,9 @@ HTMLEditUtils::IsList(nsINode* aNode)
|
||||
nsGkAtoms::dl);
|
||||
}
|
||||
|
||||
/**
|
||||
* IsOrderedList() returns true if aNode is an html ordered list.
|
||||
*/
|
||||
bool
|
||||
HTMLEditUtils::IsOrderedList(nsIDOMNode* aNode)
|
||||
{
|
||||
return EditorBase::NodeIsType(aNode, nsGkAtoms::ol);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* IsUnorderedList() returns true if aNode is an html unordered list.
|
||||
*/
|
||||
bool
|
||||
HTMLEditUtils::IsUnorderedList(nsIDOMNode* aNode)
|
||||
{
|
||||
return EditorBase::NodeIsType(aNode, nsGkAtoms::ul);
|
||||
}
|
||||
|
||||
/**
|
||||
* IsBlockquote() returns true if aNode is an html blockquote node.
|
||||
*/
|
||||
bool
|
||||
HTMLEditUtils::IsBlockquote(nsIDOMNode* aNode)
|
||||
{
|
||||
return EditorBase::NodeIsType(aNode, nsGkAtoms::blockquote);
|
||||
}
|
||||
|
||||
/**
|
||||
* IsPre() returns true if aNode is an html pre node.
|
||||
*/
|
||||
bool
|
||||
HTMLEditUtils::IsPre(nsIDOMNode* aNode)
|
||||
{
|
||||
return EditorBase::NodeIsType(aNode, nsGkAtoms::pre);
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLEditUtils::IsPre(nsINode* aNode)
|
||||
{
|
||||
@ -323,12 +208,6 @@ HTMLEditUtils::IsImage(nsINode* aNode)
|
||||
return aNode && aNode->IsHTMLElement(nsGkAtoms::img);
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLEditUtils::IsImage(nsIDOMNode* aNode)
|
||||
{
|
||||
return EditorBase::NodeIsType(aNode, nsGkAtoms::img);
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLEditUtils::IsLink(nsINode* aNode)
|
||||
{
|
||||
@ -361,15 +240,6 @@ HTMLEditUtils::IsNamedAnchor(nsINode* aNode)
|
||||
text) && !text.IsEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* IsDiv() returns true if aNode is an html div node.
|
||||
*/
|
||||
bool
|
||||
HTMLEditUtils::IsDiv(nsIDOMNode* aNode)
|
||||
{
|
||||
return EditorBase::NodeIsType(aNode, nsGkAtoms::div);
|
||||
}
|
||||
|
||||
/**
|
||||
* IsMozDiv() returns true if aNode is an html div node with |type = _moz|.
|
||||
*/
|
||||
@ -384,14 +254,6 @@ HTMLEditUtils::IsMozDiv(nsINode* aNode)
|
||||
/**
|
||||
* IsMailCite() returns true if aNode is an html blockquote with |type=cite|.
|
||||
*/
|
||||
bool
|
||||
HTMLEditUtils::IsMailCite(nsIDOMNode* aNode)
|
||||
{
|
||||
MOZ_ASSERT(aNode);
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
return node && IsMailCite(node);
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLEditUtils::IsMailCite(nsINode* aNode)
|
||||
{
|
||||
@ -419,14 +281,6 @@ HTMLEditUtils::IsMailCite(nsINode* aNode)
|
||||
/**
|
||||
* IsFormWidget() returns true if aNode is a form widget of some kind.
|
||||
*/
|
||||
bool
|
||||
HTMLEditUtils::IsFormWidget(nsIDOMNode* aNode)
|
||||
{
|
||||
MOZ_ASSERT(aNode);
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
return node && IsFormWidget(node);
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLEditUtils::IsFormWidget(nsINode* aNode)
|
||||
{
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
class nsIDOMNode;
|
||||
class nsINode;
|
||||
|
||||
namespace mozilla {
|
||||
@ -17,43 +16,24 @@ class HTMLEditUtils final
|
||||
{
|
||||
public:
|
||||
static bool IsInlineStyle(nsINode* aNode);
|
||||
static bool IsInlineStyle(nsIDOMNode *aNode);
|
||||
static bool IsFormatNode(nsINode* aNode);
|
||||
static bool IsFormatNode(nsIDOMNode* aNode);
|
||||
static bool IsNodeThatCanOutdent(nsINode* aNode);
|
||||
static bool IsHeader(nsINode& aNode);
|
||||
static bool IsHeader(nsIDOMNode* aNode);
|
||||
static bool IsParagraph(nsIDOMNode* aNode);
|
||||
static bool IsListItem(nsINode* aNode);
|
||||
static bool IsListItem(nsIDOMNode* aNode);
|
||||
static bool IsTable(nsINode* aNode);
|
||||
static bool IsTableRow(nsIDOMNode* aNode);
|
||||
static bool IsTableRow(nsINode* aNode);
|
||||
static bool IsTableElement(nsINode* aNode);
|
||||
static bool IsTableElement(nsIDOMNode* aNode);
|
||||
static bool IsTableElementButNotTable(nsINode* aNode);
|
||||
static bool IsTableElementButNotTable(nsIDOMNode* aNode);
|
||||
static bool IsTableCell(nsINode* node);
|
||||
static bool IsTableCell(nsIDOMNode* aNode);
|
||||
static bool IsTableCellOrCaption(nsINode& aNode);
|
||||
static bool IsList(nsINode* aNode);
|
||||
static bool IsList(nsIDOMNode* aNode);
|
||||
static bool IsOrderedList(nsIDOMNode* aNode);
|
||||
static bool IsUnorderedList(nsIDOMNode* aNode);
|
||||
static bool IsBlockquote(nsIDOMNode* aNode);
|
||||
static bool IsPre(nsIDOMNode* aNode);
|
||||
static bool IsPre(nsINode* aNode);
|
||||
static bool IsAnchor(nsIDOMNode* aNode);
|
||||
static bool IsImage(nsINode* aNode);
|
||||
static bool IsImage(nsIDOMNode* aNode);
|
||||
static bool IsLink(nsINode* aNode);
|
||||
static bool IsNamedAnchor(nsINode* aNode);
|
||||
static bool IsDiv(nsIDOMNode* aNode);
|
||||
static bool IsMozDiv(nsINode* aNode);
|
||||
static bool IsMailCite(nsINode* aNode);
|
||||
static bool IsMailCite(nsIDOMNode* aNode);
|
||||
static bool IsFormWidget(nsINode* aNode);
|
||||
static bool IsFormWidget(nsIDOMNode* aNode);
|
||||
static bool SupportsAlignAttr(nsINode& aNode);
|
||||
static bool CanContain(int32_t aParent, int32_t aChild);
|
||||
static bool IsContainer(int32_t aTag);
|
||||
|
@ -2590,11 +2590,12 @@ HTMLEditor::GetSelectedElement(const nsAString& aTagName,
|
||||
iter->Init(currange);
|
||||
// loop through the content iterator for each content node
|
||||
while (!iter->IsDone()) {
|
||||
// Query interface to cast nsIContent to nsIDOMNode
|
||||
// Query interface to cast nsIContent to Element
|
||||
// then get tagType to compare to aTagName
|
||||
// Clone node of each desired type and append it to the aDomFrag
|
||||
nsINode* currentNode = iter->GetCurrentNode();
|
||||
selectedElement = do_QueryInterface(currentNode);
|
||||
selectedElement = currentNode && currentNode->IsElement() ?
|
||||
currentNode->AsElement() : nullptr;
|
||||
if (selectedElement) {
|
||||
// If we already found a node, then we have another element,
|
||||
// thus there's not just one element selected
|
||||
@ -3171,8 +3172,7 @@ HTMLEditor::GetEmbeddedObjects(nsIArray** aNodeList)
|
||||
nsGkAtoms::a) ||
|
||||
(element->IsHTMLElement(nsGkAtoms::body) &&
|
||||
element->HasAttr(kNameSpaceID_None, nsGkAtoms::background))) {
|
||||
nsCOMPtr<nsIDOMNode> domNode = do_QueryInterface(node);
|
||||
nodes->AppendElement(domNode);
|
||||
nodes->AppendElement(node);
|
||||
}
|
||||
}
|
||||
iter->Next();
|
||||
@ -3259,13 +3259,12 @@ HTMLEditor::DeleteNodeWithTransaction(nsINode& aNode)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLEditor::DeleteNode(nsIDOMNode* aDOMNode)
|
||||
HTMLEditor::DeleteNode(nsINode* aNode)
|
||||
{
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aDOMNode);
|
||||
if (NS_WARN_IF(!node)) {
|
||||
if (NS_WARN_IF(!aNode)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
nsresult rv = DeleteNodeWithTransaction(*node);
|
||||
nsresult rv = DeleteNodeWithTransaction(*aNode);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -3673,18 +3672,6 @@ HTMLEditor::GetEnclosingTable(nsINode* aNode)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsIDOMNode*
|
||||
HTMLEditor::GetEnclosingTable(nsIDOMNode* aNode)
|
||||
{
|
||||
MOZ_ASSERT(aNode, "null node passed to HTMLEditor::GetEnclosingTable");
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
NS_ENSURE_TRUE(node, nullptr);
|
||||
nsCOMPtr<Element> table = GetEnclosingTable(node);
|
||||
nsCOMPtr<nsIDOMNode> ret = do_QueryInterface(table);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method scans the selection for adjacent text nodes
|
||||
* and collapses them into a single text node.
|
||||
|
@ -141,7 +141,7 @@ public:
|
||||
|
||||
NS_IMETHOD PasteTransferable(nsITransferable* aTransferable) override;
|
||||
|
||||
NS_IMETHOD DeleteNode(nsIDOMNode* aNode) override;
|
||||
NS_IMETHOD DeleteNode(nsINode* aNode) override;
|
||||
|
||||
NS_IMETHOD SelectAll() override;
|
||||
|
||||
@ -1018,7 +1018,6 @@ protected: // Shouldn't be used by friend classes
|
||||
nsresult SetSelectionAtDocumentStart(Selection* aSelection);
|
||||
|
||||
static Element* GetEnclosingTable(nsINode* aNode);
|
||||
static nsIDOMNode* GetEnclosingTable(nsIDOMNode* aNode);
|
||||
|
||||
// Methods for handling plaintext quotations
|
||||
nsresult PasteAsPlaintextQuotation(int32_t aSelectionType);
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIClipboard.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIInputStream.h"
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsAtom.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsINode.h"
|
||||
#include "nsIPresShell.h"
|
||||
|
@ -102,7 +102,7 @@ InsertNodeTransaction::DoTransaction()
|
||||
}
|
||||
}
|
||||
|
||||
mEditorBase->MarkNodeDirty(GetAsDOMNode(mContentToInsert));
|
||||
mEditorBase->MarkNodeDirty(mContentToInsert);
|
||||
|
||||
ErrorResult error;
|
||||
mPointToInsert.GetContainer()->InsertBefore(*mContentToInsert,
|
||||
|
@ -85,7 +85,7 @@ SplitNodeTransaction::DoTransaction()
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
mNewLeftNode = dont_AddRef(clone.forget().take()->AsContent());
|
||||
mEditorBase->MarkNodeDirty(mStartOfRightNode.GetContainerAsDOMNode());
|
||||
mEditorBase->MarkNodeDirty(mStartOfRightNode.GetContainer());
|
||||
|
||||
// Get the parent node
|
||||
mParent = mStartOfRightNode.GetContainer()->GetParentNode();
|
||||
|
@ -41,7 +41,6 @@
|
||||
#include "nsIClipboard.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIContentIterator.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDocumentEncoder.h"
|
||||
#include "nsINode.h"
|
||||
#include "nsIPresShell.h"
|
||||
|
@ -90,7 +90,6 @@ function onLoadIFrame()
|
||||
getInterface(SpecialPowers.Ci.nsISelectionDisplay).
|
||||
QueryInterface(SpecialPowers.Ci.nsISelectionController);
|
||||
var utils = SpecialPowers.getDOMWindowUtils(window);
|
||||
const nsIDOMNode = SpecialPowers.Ci.nsIDOMNode;
|
||||
|
||||
// move focus to the HTML editor
|
||||
const kTest = kTests[gTestIndex];
|
||||
@ -110,9 +109,9 @@ function onLoadIFrame()
|
||||
var content = frameDoc.body.firstChild;
|
||||
ok(content, "body doesn't have contents -- " + kTest.description);
|
||||
if (content) {
|
||||
is(content.nodeType, nsIDOMNode.TEXT_NODE,
|
||||
is(content.nodeType, Node.TEXT_NODE,
|
||||
"the content of body isn't text node -- " + kTest.description);
|
||||
if (content.nodeType == nsIDOMNode.TEXT_NODE) {
|
||||
if (content.nodeType == Node.TEXT_NODE) {
|
||||
is(content.data, "ABC",
|
||||
"the content of body text isn't 'ABC' -- " + kTest.description);
|
||||
is(frameDoc.body.innerHTML, "ABC",
|
||||
|
@ -21,6 +21,7 @@ interface nsITransferable;
|
||||
|
||||
webidl Document;
|
||||
webidl Element;
|
||||
webidl Node;
|
||||
webidl Selection;
|
||||
|
||||
%{C++
|
||||
@ -355,28 +356,25 @@ interface nsIEditor : nsISupports
|
||||
* the destination node and delete those not in the source.
|
||||
*
|
||||
* The supplied nodes MUST BE ELEMENTS (most callers are working with nodes)
|
||||
* @param aAttribute the name of the attribute to copy
|
||||
* @param aDestNode the destination element to operate on
|
||||
* @param aSourceNode the source element to copy attributes from
|
||||
* @exception NS_ERROR_NULL_POINTER at least one of the nodes is null
|
||||
* @exception NS_ERROR_NO_INTERFACE at least one of the nodes is not an
|
||||
* element
|
||||
* @param aAttribute the name of the attribute to copy
|
||||
* @param aDestElement the destination element to operate on
|
||||
* @param aSourceElement the source element to copy attributes from
|
||||
* @exception NS_ERROR_NULL_POINTER at least one of the elements is null
|
||||
*/
|
||||
void cloneAttribute(in AString aAttribute,
|
||||
in nsIDOMNode aDestNode, in nsIDOMNode aSourceNode);
|
||||
in Element aDestElement, in Element aSourceElement);
|
||||
|
||||
/**
|
||||
* cloneAttributes() is similar to nsIDOMNode::cloneNode(),
|
||||
* cloneAttributes() is similar to Node::cloneNode(),
|
||||
* it assures the attribute nodes of the destination are identical
|
||||
* with the source node by copying all existing attributes from the
|
||||
* source and deleting those not in the source.
|
||||
* This is used when the destination node (element) already exists
|
||||
* This is used when the destination element already exists
|
||||
*
|
||||
* The supplied nodes MUST BE ELEMENTS (most callers are working with nodes)
|
||||
* @param aDestNode the destination element to operate on
|
||||
* @param aSourceNode the source element to copy attributes from
|
||||
*/
|
||||
void cloneAttributes(in nsIDOMNode destNode, in nsIDOMNode sourceNode);
|
||||
void cloneAttributes(in Element aDestElement, in Element aSourceElement);
|
||||
|
||||
/**
|
||||
* insertNode inserts aNode into aParent at aPosition.
|
||||
@ -388,9 +386,9 @@ interface nsIEditor : nsISupports
|
||||
* 0=first child, 1=second child, etc.
|
||||
* any number > number of current children = last child
|
||||
*/
|
||||
void insertNode(in nsIDOMNode node,
|
||||
in nsIDOMNode parent,
|
||||
in long aPosition);
|
||||
void insertNode(in Node node,
|
||||
in Node parent,
|
||||
in long aPosition);
|
||||
|
||||
|
||||
/**
|
||||
@ -403,9 +401,9 @@ interface nsIEditor : nsISupports
|
||||
* @param aNewLeftNode [OUT] the new node resulting from the split,
|
||||
* becomes aExistingRightNode's previous sibling.
|
||||
*/
|
||||
void splitNode(in nsIDOMNode existingRightNode,
|
||||
in long offset,
|
||||
out nsIDOMNode newLeftNode);
|
||||
void splitNode(in Node existingRightNode,
|
||||
in long offset,
|
||||
out Node newLeftNode);
|
||||
|
||||
/**
|
||||
* joinNodes() takes 2 nodes and merge their content|children.
|
||||
@ -417,22 +415,22 @@ interface nsIEditor : nsISupports
|
||||
* of the same type. However, a text node can be
|
||||
* merged only with another text node.
|
||||
*/
|
||||
void joinNodes(in nsIDOMNode leftNode,
|
||||
in nsIDOMNode rightNode,
|
||||
in nsIDOMNode parent);
|
||||
void joinNodes(in Node leftNode,
|
||||
in Node rightNode,
|
||||
in Node parent);
|
||||
|
||||
/**
|
||||
* deleteNode removes aChild from aParent.
|
||||
* @param aChild The node to delete
|
||||
*/
|
||||
void deleteNode(in nsIDOMNode child);
|
||||
void deleteNode(in Node child);
|
||||
|
||||
/**
|
||||
* markNodeDirty() sets a special dirty attribute on the node.
|
||||
* Usually this will be called immediately after creating a new node.
|
||||
* @param aNode The node for which to insert formatting.
|
||||
*/
|
||||
void markNodeDirty(in nsIDOMNode node);
|
||||
void markNodeDirty(in Node node);
|
||||
|
||||
/* ---------- direction controller ---------- */
|
||||
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "nsIContent.h" // for nsIContent, etc
|
||||
#include "nsIContentIterator.h" // for nsIContentIterator
|
||||
#include "nsID.h" // for NS_GET_IID
|
||||
#include "nsIDOMNode.h" // for nsIDOMNode, etc
|
||||
#include "nsIEditor.h" // for nsIEditor, etc
|
||||
#include "nsINode.h" // for nsINode
|
||||
#include "nsIPlaintextEditor.h" // for nsIPlaintextEditor
|
||||
@ -1914,16 +1913,6 @@ TextServicesDocument::IsTextNode(nsIContent* aContent)
|
||||
return nsINode::TEXT_NODE == aContent->NodeType();
|
||||
}
|
||||
|
||||
// static
|
||||
bool
|
||||
TextServicesDocument::IsTextNode(nsIDOMNode* aNode)
|
||||
{
|
||||
NS_ENSURE_TRUE(aNode, false);
|
||||
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
||||
return IsTextNode(content);
|
||||
}
|
||||
|
||||
nsresult
|
||||
TextServicesDocument::SetSelectionInternal(int32_t aOffset,
|
||||
int32_t aLength,
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
class nsIContent;
|
||||
class nsIContentIterator;
|
||||
class nsIDOMNode;
|
||||
class nsIEditor;
|
||||
class nsINode;
|
||||
class nsISelectionController;
|
||||
@ -262,7 +261,6 @@ private:
|
||||
|
||||
static bool IsBlockNode(nsIContent* aContent);
|
||||
static bool IsTextNode(nsIContent* aContent);
|
||||
static bool IsTextNode(nsIDOMNode* aNode);
|
||||
|
||||
static bool DidSkip(nsIContentIterator* aFilteredIter);
|
||||
static void ClearDidSkip(nsIContentIterator* aFilteredIter);
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "nsAtom.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIContentIterator.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsINode.h"
|
||||
#include "nsISupportsBase.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "nscore.h"
|
||||
|
||||
class nsAtom;
|
||||
class nsIDOMNode;
|
||||
class nsINode;
|
||||
class nsITextServicesFilter;
|
||||
class nsRange;
|
||||
|
Loading…
Reference in New Issue
Block a user