2001-09-26 02:53:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
2000-01-26 03:36:18 +03:00
|
|
|
*
|
2001-09-26 02:53:13 +04:00
|
|
|
* The contents of this file are subject to the Netscape 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/NPL/
|
2000-01-26 03:36:18 +03:00
|
|
|
*
|
2001-09-26 02:53:13 +04:00
|
|
|
* 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.
|
2000-01-26 03:36:18 +03:00
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-26 02:53:13 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2000-01-26 03:36:18 +03:00
|
|
|
*
|
2001-09-26 02:53:13 +04:00
|
|
|
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2000-01-26 03:36:18 +03:00
|
|
|
|
|
|
|
#include "nsHTMLEditUtils.h"
|
2001-04-06 03:48:01 +04:00
|
|
|
#include "nsTextEditUtils.h"
|
2000-01-26 03:36:18 +03:00
|
|
|
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsEditor.h"
|
|
|
|
#include "nsIDOMNode.h"
|
|
|
|
#include "nsIDOMNodeList.h"
|
2001-01-28 23:13:07 +03:00
|
|
|
#include "nsIDOMHTMLAnchorElement.h"
|
2000-01-26 03:36:18 +03:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
2000-02-08 15:53:34 +03:00
|
|
|
//
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsBig(nsIDOMNode *node)
|
|
|
|
{
|
2001-04-06 03:48:01 +04:00
|
|
|
return nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("big"));
|
2000-02-08 15:53:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsSmall(nsIDOMNode *node)
|
|
|
|
{
|
2001-04-06 03:48:01 +04:00
|
|
|
return nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("small"));
|
2000-01-26 03:36:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* helper methods from nsHTMLEditRules
|
|
|
|
********************************************************/
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// IsHeader: true if node an html header
|
|
|
|
//
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsHeader(nsIDOMNode *node)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(node, "null parent passed to nsHTMLEditUtils::IsHeader");
|
|
|
|
nsAutoString tag;
|
|
|
|
nsEditor::GetTagString(node,tag);
|
|
|
|
tag.ToLowerCase();
|
2000-04-18 11:52:02 +04:00
|
|
|
if ( (tag.EqualsWithConversion("h1")) ||
|
|
|
|
(tag.EqualsWithConversion("h2")) ||
|
|
|
|
(tag.EqualsWithConversion("h3")) ||
|
|
|
|
(tag.EqualsWithConversion("h4")) ||
|
|
|
|
(tag.EqualsWithConversion("h5")) ||
|
|
|
|
(tag.EqualsWithConversion("h6")) )
|
2000-01-26 03:36:18 +03:00
|
|
|
{
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// IsParagraph: true if node an html paragraph
|
|
|
|
//
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsParagraph(nsIDOMNode *node)
|
|
|
|
{
|
2001-04-06 03:48:01 +04:00
|
|
|
return nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("p"));
|
2000-01-26 03:36:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// IsListItem: true if node an html list item
|
|
|
|
//
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsListItem(nsIDOMNode *node)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(node, "null parent passed to nsHTMLEditUtils::IsListItem");
|
|
|
|
nsAutoString tag;
|
|
|
|
nsEditor::GetTagString(node,tag);
|
|
|
|
tag.ToLowerCase();
|
fixes:
14753, 29843, 39864, 40141,
40139, 36679, 39542, 34729,
34855, 37216, 39292, 26447
r=sfraser,cmanske,fm; a=beppe
2000-05-25 03:00:24 +04:00
|
|
|
if (tag.EqualsWithConversion("li") ||
|
|
|
|
tag.EqualsWithConversion("dd") ||
|
|
|
|
tag.EqualsWithConversion("dt"))
|
2000-01-26 03:36:18 +03:00
|
|
|
{
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-14 03:53:34 +04:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// IsTableElement: true if node an html table, td, tr, ...
|
|
|
|
//
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsTableElement(nsIDOMNode *node)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(node, "null node passed to nsHTMLEditor::IsTableElement");
|
|
|
|
nsAutoString tagName;
|
|
|
|
nsEditor::GetTagString(node,tagName);
|
|
|
|
if (tagName.EqualsWithConversion("table") || tagName.EqualsWithConversion("tr") ||
|
|
|
|
tagName.EqualsWithConversion("td") || tagName.EqualsWithConversion("th") ||
|
|
|
|
tagName.EqualsWithConversion("thead") || tagName.EqualsWithConversion("tfoot") ||
|
|
|
|
tagName.EqualsWithConversion("tbody") || tagName.EqualsWithConversion("caption"))
|
|
|
|
{
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-01-26 03:36:18 +03:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
2000-03-21 09:05:24 +03:00
|
|
|
// IsTable: true if node an html table
|
|
|
|
//
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsTable(nsIDOMNode *node)
|
|
|
|
{
|
2001-04-06 03:48:01 +04:00
|
|
|
return nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("table"));
|
2000-03-21 09:05:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// IsTableRow: true if node an html tr
|
2000-01-26 03:36:18 +03:00
|
|
|
//
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsTableRow(nsIDOMNode *node)
|
|
|
|
{
|
2001-04-06 03:48:01 +04:00
|
|
|
return nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("tr"));
|
2000-01-26 03:36:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// IsTableCell: true if node an html td or th
|
|
|
|
//
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsTableCell(nsIDOMNode *node)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(node, "null parent passed to nsHTMLEditUtils::IsTableCell");
|
|
|
|
nsAutoString tag;
|
|
|
|
nsEditor::GetTagString(node,tag);
|
|
|
|
tag.ToLowerCase();
|
2000-04-18 11:52:02 +04:00
|
|
|
if (tag.EqualsWithConversion("td") || tag.EqualsWithConversion("th"))
|
2000-01-26 03:36:18 +03:00
|
|
|
{
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-14 03:53:34 +04:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// IsTableCell: true if node an html td or th
|
|
|
|
//
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsTableCellOrCaption(nsIDOMNode *node)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(node, "null parent passed to nsHTMLEditUtils::IsTableCell");
|
|
|
|
nsAutoString tag;
|
|
|
|
nsEditor::GetTagString(node,tag);
|
|
|
|
tag.ToLowerCase();
|
|
|
|
if (tag.EqualsWithConversion("td") ||
|
|
|
|
tag.EqualsWithConversion("th") ||
|
|
|
|
tag.EqualsWithConversion("caption") )
|
|
|
|
{
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-01-26 03:36:18 +03:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// IsList: true if node an html list
|
|
|
|
//
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsList(nsIDOMNode *node)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(node, "null parent passed to nsHTMLEditUtils::IsList");
|
|
|
|
nsAutoString tag;
|
|
|
|
nsEditor::GetTagString(node,tag);
|
|
|
|
tag.ToLowerCase();
|
fixes:
14753, 29843, 39864, 40141,
40139, 36679, 39542, 34729,
34855, 37216, 39292, 26447
r=sfraser,cmanske,fm; a=beppe
2000-05-25 03:00:24 +04:00
|
|
|
if ( (tag.EqualsWithConversion("dl")) ||
|
|
|
|
(tag.EqualsWithConversion("ol")) ||
|
2000-04-18 11:52:02 +04:00
|
|
|
(tag.EqualsWithConversion("ul")) )
|
2000-01-26 03:36:18 +03:00
|
|
|
{
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
fixes:
14753, 29843, 39864, 40141,
40139, 36679, 39542, 34729,
34855, 37216, 39292, 26447
r=sfraser,cmanske,fm; a=beppe
2000-05-25 03:00:24 +04:00
|
|
|
// IsOrderedList: true if node an html ordered list
|
2000-01-26 03:36:18 +03:00
|
|
|
//
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsOrderedList(nsIDOMNode *node)
|
|
|
|
{
|
2001-04-06 03:48:01 +04:00
|
|
|
return nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("ol"));
|
2000-01-26 03:36:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
fixes:
14753, 29843, 39864, 40141,
40139, 36679, 39542, 34729,
34855, 37216, 39292, 26447
r=sfraser,cmanske,fm; a=beppe
2000-05-25 03:00:24 +04:00
|
|
|
// IsUnorderedList: true if node an html unordered list
|
2000-01-26 03:36:18 +03:00
|
|
|
//
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsUnorderedList(nsIDOMNode *node)
|
|
|
|
{
|
2001-04-06 03:48:01 +04:00
|
|
|
return nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("ul"));
|
2000-01-26 03:36:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
fixes:
14753, 29843, 39864, 40141,
40139, 36679, 39542, 34729,
34855, 37216, 39292, 26447
r=sfraser,cmanske,fm; a=beppe
2000-05-25 03:00:24 +04:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// IsDefinitionList: true if node an html definition list
|
|
|
|
//
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsDefinitionList(nsIDOMNode *node)
|
|
|
|
{
|
2001-04-06 03:48:01 +04:00
|
|
|
return nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("dl"));
|
fixes:
14753, 29843, 39864, 40141,
40139, 36679, 39542, 34729,
34855, 37216, 39292, 26447
r=sfraser,cmanske,fm; a=beppe
2000-05-25 03:00:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-01-26 03:36:18 +03:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// IsBlockquote: true if node an html blockquote node
|
|
|
|
//
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsBlockquote(nsIDOMNode *node)
|
|
|
|
{
|
2001-04-06 03:48:01 +04:00
|
|
|
return nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("blockquote"));
|
2000-01-26 03:36:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-25 07:39:30 +03:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// IsPre: true if node an html pre node
|
|
|
|
//
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsPre(nsIDOMNode *node)
|
|
|
|
{
|
2001-04-06 03:48:01 +04:00
|
|
|
return nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("pre"));
|
2000-02-25 07:39:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// IsAddress: true if node an html address node
|
|
|
|
//
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsAddress(nsIDOMNode *node)
|
|
|
|
{
|
2001-04-06 03:48:01 +04:00
|
|
|
return nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("address"));
|
2000-02-25 07:39:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-01-26 03:36:18 +03:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// IsAnchor: true if node an html anchor node
|
|
|
|
//
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsAnchor(nsIDOMNode *node)
|
|
|
|
{
|
2001-04-06 03:48:01 +04:00
|
|
|
return nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("a"));
|
2000-01-26 03:36:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// IsImage: true if node an html image node
|
|
|
|
//
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsImage(nsIDOMNode *node)
|
|
|
|
{
|
2001-04-06 03:48:01 +04:00
|
|
|
return nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("img"));
|
2000-01-26 03:36:18 +03:00
|
|
|
}
|
|
|
|
|
2001-01-28 23:13:07 +03:00
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsLink(nsIDOMNode *aNode)
|
|
|
|
{
|
|
|
|
if (!aNode) return PR_FALSE;
|
|
|
|
nsCOMPtr<nsIDOMHTMLAnchorElement> anchor = do_QueryInterface(aNode);
|
|
|
|
if (anchor)
|
|
|
|
{
|
|
|
|
nsAutoString tmpText;
|
2001-06-30 15:02:25 +04:00
|
|
|
if (NS_SUCCEEDED(anchor->GetHref(tmpText)) && tmpText.get() && tmpText.Length() != 0)
|
2001-01-28 23:13:07 +03:00
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsNamedAnchor(nsIDOMNode *aNode)
|
|
|
|
{
|
|
|
|
if (!aNode) return PR_FALSE;
|
|
|
|
nsCOMPtr<nsIDOMHTMLAnchorElement> anchor = do_QueryInterface(aNode);
|
|
|
|
if (anchor)
|
|
|
|
{
|
|
|
|
nsAutoString tmpText;
|
2001-06-30 15:02:25 +04:00
|
|
|
if (NS_SUCCEEDED(anchor->GetName(tmpText)) && tmpText.get() && tmpText.Length() != 0)
|
2001-01-28 23:13:07 +03:00
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2000-01-26 03:36:18 +03:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// IsDiv: true if node an html div node
|
|
|
|
//
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsDiv(nsIDOMNode *node)
|
|
|
|
{
|
2001-04-06 03:48:01 +04:00
|
|
|
return nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("div"));
|
2000-01-26 03:36:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// IsNormalDiv: true if node an html div node, without type = _moz
|
|
|
|
//
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsNormalDiv(nsIDOMNode *node)
|
|
|
|
{
|
2001-04-06 03:48:01 +04:00
|
|
|
if (IsDiv(node) && !nsTextEditUtils::HasMozAttr(node)) return PR_TRUE;
|
2000-01-26 03:36:18 +03:00
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// IsMozDiv: true if node an html div node with type = _moz
|
|
|
|
//
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsMozDiv(nsIDOMNode *node)
|
|
|
|
{
|
2001-04-06 03:48:01 +04:00
|
|
|
if (IsDiv(node) && nsTextEditUtils::HasMozAttr(node)) return PR_TRUE;
|
2000-01-26 03:36:18 +03:00
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// IsMailCite: true if node an html blockquote with type=cite
|
|
|
|
//
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsMailCite(nsIDOMNode *node)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(node, "null parent passed to nsHTMLEditUtils::IsMailCite");
|
|
|
|
if (IsBlockquote(node))
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMElement> bqElem = do_QueryInterface(node);
|
2000-04-18 11:52:02 +04:00
|
|
|
nsAutoString typeAttrName; typeAttrName.AssignWithConversion("type");
|
2000-01-26 03:36:18 +03:00
|
|
|
nsAutoString typeAttrVal;
|
|
|
|
nsresult res = bqElem->GetAttribute(typeAttrName, typeAttrVal);
|
|
|
|
typeAttrVal.ToLowerCase();
|
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
{
|
2000-04-18 11:52:02 +04:00
|
|
|
if (typeAttrVal.EqualsWithConversion("cite", PR_TRUE, 4))
|
2000-01-26 03:36:18 +03:00
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-30 18:39:29 +04:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// IsTextarea: true if node is an html textarea node
|
|
|
|
//
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsTextarea(nsIDOMNode *node)
|
|
|
|
{
|
2001-04-06 03:48:01 +04:00
|
|
|
return nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("textarea"));
|
2001-03-30 18:39:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// IsMap: true if node is an html map node
|
|
|
|
//
|
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsMap(nsIDOMNode *node)
|
|
|
|
{
|
2001-04-06 03:48:01 +04:00
|
|
|
return nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("map"));
|
2001-03-30 18:39:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-01-26 03:36:18 +03:00
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsDescendantOf(nsIDOMNode *aNode, nsIDOMNode *aParent)
|
|
|
|
{
|
|
|
|
if (!aNode && !aParent) return PR_FALSE;
|
|
|
|
if (aNode == aParent) return PR_FALSE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNode> parent, node = do_QueryInterface(aNode);
|
|
|
|
nsresult res;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
res = node->GetParentNode(getter_AddRefs(parent));
|
|
|
|
if (NS_FAILED(res)) return PR_FALSE;
|
|
|
|
if (parent.get() == aParent) return PR_TRUE;
|
|
|
|
node = parent;
|
|
|
|
} while (parent);
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-26 08:03:50 +04:00
|
|
|
PRBool
|
|
|
|
nsHTMLEditUtils::IsLeafNode(nsIDOMNode *aNode)
|
|
|
|
{
|
|
|
|
if (!aNode) return PR_FALSE;
|
|
|
|
PRBool hasChildren = PR_FALSE;
|
|
|
|
aNode->HasChildNodes(&hasChildren);
|
|
|
|
return !hasChildren;
|
2000-08-26 18:04:16 +04:00
|
|
|
}
|