Skip to content

Commit

Permalink
Showing 5 changed files with 30 additions and 35 deletions.
2 changes: 1 addition & 1 deletion dom/base/nsGenericDOMDataNode.cpp
Original file line number Diff line number Diff line change
@@ -976,7 +976,7 @@ nsGenericDOMDataNode::GetText()
uint32_t
nsGenericDOMDataNode::TextLength() const
{
return mText.GetLength();
return TextDataLength();
}

nsresult
5 changes: 5 additions & 0 deletions dom/base/nsGenericDOMDataNode.h
Original file line number Diff line number Diff line change
@@ -219,6 +219,11 @@ class nsGenericDOMDataNode : public nsIContent
rv = ReplaceData(aOffset, aCount, aData);
}

uint32_t TextDataLength() const
{
return mText.GetLength();
}

//----------------------------------------

#ifdef DEBUG
29 changes: 0 additions & 29 deletions editor/libeditor/nsEditor.cpp
Original file line number Diff line number Diff line change
@@ -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
nsEditor::CountEditableChildren(nsINode* aNode)
{
@@ -3625,12 +3616,6 @@ nsEditor::IsTextNode(nsIDOMNode *aNode)
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
//
@@ -4844,20 +4829,6 @@ nsEditor::FinalizeSelection()
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*
nsEditor::GetEditorRoot()
{
24 changes: 21 additions & 3 deletions editor/libeditor/nsEditor.h
Original file line number Diff line number Diff line change
@@ -569,7 +569,13 @@ class nsEditor : public nsIEditor,
virtual bool IsEditable(nsINode* aNode);

/** 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 */
uint32_t CountEditableChildren(nsINode* aNode);
@@ -598,7 +604,10 @@ class nsEditor : public nsIEditor,
virtual bool AreNodesSameType(nsIContent* aNode1, nsIContent* aNode2);

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> GetNodeAtRangeOffsetPoint(nsIDOMNode* aParentOrNode, int32_t aOffset);
@@ -664,7 +673,16 @@ class nsEditor : public nsIEditor,
virtual already_AddRefed<mozilla::dom::EventTarget> GetDOMEventTarget() = 0;

// 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
// editors
5 changes: 3 additions & 2 deletions editor/libeditor/nsTextEditRules.cpp
Original file line number Diff line number Diff line change
@@ -1176,11 +1176,12 @@ nsTextEditRules::CreateBogusNodeIfNeeded(Selection* aSelection)
// 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
// bogus node.
for (nsCOMPtr<nsIContent> bodyChild = body->GetFirstChild();
bool bodyEditable = mEditor->IsEditable(body);
for (nsIContent* bodyChild = body->GetFirstChild();
bodyChild;
bodyChild = bodyChild->GetNextSibling()) {
if (mEditor->IsMozEditorBogusNode(bodyChild) ||
!mEditor->IsEditable(body) || // XXX hoist out of the loop?
!bodyEditable ||
mEditor->IsEditable(bodyChild) || mEditor->IsBlockNode(bodyChild)) {
return NS_OK;
}

0 comments on commit 433aae5

Please sign in to comment.