mirror of
https://github.com/classilla/tenfourfox.git
synced 2024-06-12 17:31:05 +00:00
#432: M1390402 partial (without semantic changes) plus other partial cleanup
This commit is contained in:
parent
bfaa83964f
commit
433aae5429
|
@ -976,7 +976,7 @@ nsGenericDOMDataNode::GetText()
|
||||||
uint32_t
|
uint32_t
|
||||||
nsGenericDOMDataNode::TextLength() const
|
nsGenericDOMDataNode::TextLength() const
|
||||||
{
|
{
|
||||||
return mText.GetLength();
|
return TextDataLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
|
|
@ -219,6 +219,11 @@ public:
|
||||||
rv = ReplaceData(aOffset, aCount, aData);
|
rv = ReplaceData(aOffset, aCount, aData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t TextDataLength() const
|
||||||
|
{
|
||||||
|
return mText.GetLength();
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
|
@ -3473,15 +3473,6 @@ nsEditor::IsEditable(nsINode* aNode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
nsEditor::IsMozEditorBogusNode(nsINode* element)
|
|
||||||
{
|
|
||||||
return element && element->IsElement() &&
|
|
||||||
element->AsElement()->AttrValueIs(kNameSpaceID_None,
|
|
||||||
kMOZEditorBogusNodeAttrAtom, kMOZEditorBogusNodeValue,
|
|
||||||
eCaseMatters);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
nsEditor::CountEditableChildren(nsINode* aNode)
|
nsEditor::CountEditableChildren(nsINode* aNode)
|
||||||
{
|
{
|
||||||
|
@ -3625,12 +3616,6 @@ nsEditor::IsTextNode(nsIDOMNode *aNode)
|
||||||
return (nodeType == nsIDOMNode::TEXT_NODE);
|
return (nodeType == nsIDOMNode::TEXT_NODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
nsEditor::IsTextNode(nsINode *aNode)
|
|
||||||
{
|
|
||||||
return aNode->NodeType() == nsIDOMNode::TEXT_NODE;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// GetChildAt: returns the node at this position index in the parent
|
// GetChildAt: returns the node at this position index in the parent
|
||||||
//
|
//
|
||||||
|
@ -4844,20 +4829,6 @@ nsEditor::FinalizeSelection()
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
dom::Element *
|
|
||||||
nsEditor::GetRoot()
|
|
||||||
{
|
|
||||||
if (!mRootElement)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsIDOMElement> root;
|
|
||||||
|
|
||||||
// Let GetRootElement() do the work
|
|
||||||
GetRootElement(getter_AddRefs(root));
|
|
||||||
}
|
|
||||||
|
|
||||||
return mRootElement;
|
|
||||||
}
|
|
||||||
|
|
||||||
dom::Element*
|
dom::Element*
|
||||||
nsEditor::GetEditorRoot()
|
nsEditor::GetEditorRoot()
|
||||||
{
|
{
|
||||||
|
|
|
@ -569,7 +569,13 @@ public:
|
||||||
virtual bool IsEditable(nsINode* aNode);
|
virtual bool IsEditable(nsINode* aNode);
|
||||||
|
|
||||||
/** returns true if aNode is a MozEditorBogus node */
|
/** returns true if aNode is a MozEditorBogus node */
|
||||||
bool IsMozEditorBogusNode(nsINode* aNode);
|
bool IsMozEditorBogusNode(nsINode* aNode)
|
||||||
|
{
|
||||||
|
return aNode && aNode->IsElement() &&
|
||||||
|
aNode->AsElement()->AttrValueIs(kNameSpaceID_None,
|
||||||
|
kMOZEditorBogusNodeAttrAtom, kMOZEditorBogusNodeValue,
|
||||||
|
eCaseMatters);
|
||||||
|
}
|
||||||
|
|
||||||
/** counts number of editable child nodes */
|
/** counts number of editable child nodes */
|
||||||
uint32_t CountEditableChildren(nsINode* aNode);
|
uint32_t CountEditableChildren(nsINode* aNode);
|
||||||
|
@ -598,7 +604,10 @@ public:
|
||||||
virtual bool AreNodesSameType(nsIContent* aNode1, nsIContent* aNode2);
|
virtual bool AreNodesSameType(nsIContent* aNode1, nsIContent* aNode2);
|
||||||
|
|
||||||
static bool IsTextNode(nsIDOMNode *aNode);
|
static bool IsTextNode(nsIDOMNode *aNode);
|
||||||
static bool IsTextNode(nsINode *aNode);
|
static bool IsTextNode(nsINode* aNode)
|
||||||
|
{
|
||||||
|
return aNode->NodeType() == nsIDOMNode::TEXT_NODE;
|
||||||
|
}
|
||||||
|
|
||||||
static nsCOMPtr<nsIDOMNode> GetChildAt(nsIDOMNode *aParent, int32_t aOffset);
|
static nsCOMPtr<nsIDOMNode> GetChildAt(nsIDOMNode *aParent, int32_t aOffset);
|
||||||
static nsCOMPtr<nsIDOMNode> GetNodeAtRangeOffsetPoint(nsIDOMNode* aParentOrNode, int32_t aOffset);
|
static nsCOMPtr<nsIDOMNode> GetNodeAtRangeOffsetPoint(nsIDOMNode* aParentOrNode, int32_t aOffset);
|
||||||
|
@ -664,7 +673,16 @@ public:
|
||||||
virtual already_AddRefed<mozilla::dom::EventTarget> GetDOMEventTarget() = 0;
|
virtual already_AddRefed<mozilla::dom::EventTarget> GetDOMEventTarget() = 0;
|
||||||
|
|
||||||
// Fast non-refcounting editor root element accessor
|
// Fast non-refcounting editor root element accessor
|
||||||
mozilla::dom::Element *GetRoot();
|
mozilla::dom::Element *GetRoot()
|
||||||
|
{
|
||||||
|
if (!mRootElement) {
|
||||||
|
// Let GetRootElement() do the work
|
||||||
|
nsCOMPtr<nsIDOMElement> root;
|
||||||
|
GetRootElement(getter_AddRefs(root));
|
||||||
|
}
|
||||||
|
|
||||||
|
return mRootElement;
|
||||||
|
}
|
||||||
|
|
||||||
// Likewise, but gets the editor's root instead, which is different for HTML
|
// Likewise, but gets the editor's root instead, which is different for HTML
|
||||||
// editors
|
// editors
|
||||||
|
|
|
@ -1176,11 +1176,12 @@ nsTextEditRules::CreateBogusNodeIfNeeded(Selection* aSelection)
|
||||||
// Now we've got the body element. Iterate over the body element's children,
|
// Now we've got the body element. Iterate over the body element's children,
|
||||||
// looking for editable content. If no editable content is found, insert the
|
// looking for editable content. If no editable content is found, insert the
|
||||||
// bogus node.
|
// bogus node.
|
||||||
for (nsCOMPtr<nsIContent> bodyChild = body->GetFirstChild();
|
bool bodyEditable = mEditor->IsEditable(body);
|
||||||
|
for (nsIContent* bodyChild = body->GetFirstChild();
|
||||||
bodyChild;
|
bodyChild;
|
||||||
bodyChild = bodyChild->GetNextSibling()) {
|
bodyChild = bodyChild->GetNextSibling()) {
|
||||||
if (mEditor->IsMozEditorBogusNode(bodyChild) ||
|
if (mEditor->IsMozEditorBogusNode(bodyChild) ||
|
||||||
!mEditor->IsEditable(body) || // XXX hoist out of the loop?
|
!bodyEditable ||
|
||||||
mEditor->IsEditable(bodyChild) || mEditor->IsBlockNode(bodyChild)) {
|
mEditor->IsEditable(bodyChild) || mEditor->IsBlockNode(bodyChild)) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user