зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1416080 - Part 2. CreateMozBR should use native dom node. r=masayuki
Part 1. moves native dom method of CreateBR, so we should use it for CreateMozBR, and use native dom as parameter. MozReview-Commit-ID: DHUB88HfowQ --HG-- extra : rebase_source : 00fefd12b50bef0f1a9bd69e1b7992a19999d42f
This commit is contained in:
Родитель
71d57c8182
Коммит
90bfbaba4c
|
@ -5051,7 +5051,7 @@ HTMLEditRules::WillAlign(Selection& aSelection,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
*aHandled = true;
|
||||
// Put in a moz-br so that it won't get deleted
|
||||
rv = CreateMozBR(div->AsDOMNode(), 0);
|
||||
rv = CreateMozBR(*div, 0);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
EditorRawDOMPoint atStartOfDiv(div, 0);
|
||||
ErrorResult error;
|
||||
|
@ -6738,7 +6738,7 @@ HTMLEditRules::ReturnInHeader(Selection& aSelection,
|
|||
rv = htmlEditor->IsEmptyNode(prevItem, &isEmptyNode);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (isEmptyNode) {
|
||||
rv = CreateMozBR(prevItem->AsDOMNode(), 0);
|
||||
rv = CreateMozBR(*prevItem, 0);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
@ -7101,7 +7101,7 @@ HTMLEditRules::ReturnInListItem(Selection& aSelection,
|
|||
rv = htmlEditor->IsEmptyNode(prevItem, &isEmptyNode);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (isEmptyNode) {
|
||||
rv = CreateMozBR(prevItem->AsDOMNode(), 0);
|
||||
rv = CreateMozBR(*prevItem, 0);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else {
|
||||
rv = htmlEditor->IsEmptyNode(&aListItem, &isEmptyNode, true);
|
||||
|
@ -7823,7 +7823,7 @@ HTMLEditRules::AdjustSpecialBreaks()
|
|||
// still pass the "IsEmptyNode" test, and we want the br's to be after
|
||||
// them. Also, we want the br to be after the selection if the selection
|
||||
// is in this node.
|
||||
nsresult rv = CreateMozBR(node->AsDOMNode(), (int32_t)node->Length());
|
||||
nsresult rv = CreateMozBR(*node, (int32_t)node->Length());
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
@ -8030,7 +8030,7 @@ HTMLEditRules::AdjustSelection(Selection* aSelection,
|
|||
}
|
||||
|
||||
// we know we can skip the rest of this routine given the cirumstance
|
||||
return CreateMozBR(GetAsDOMNode(point.Container()), point.Offset());
|
||||
return CreateMozBR(*point.Container(), point.Offset());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8059,12 +8059,10 @@ HTMLEditRules::AdjustSelection(Selection* aSelection,
|
|||
// need to insert special moz BR. Why? Because if we don't
|
||||
// the user will see no new line for the break. Also, things
|
||||
// like table cells won't grow in height.
|
||||
nsCOMPtr<nsIDOMNode> brNode;
|
||||
RefPtr<Element> br;
|
||||
nsresult rv =
|
||||
CreateMozBR(GetAsDOMNode(point.Container()), point.Offset(),
|
||||
getter_AddRefs(brNode));
|
||||
CreateMozBR(*point.Container(), point.Offset(), getter_AddRefs(br));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIContent> br = do_QueryInterface(brNode);
|
||||
point.Set(br);
|
||||
// selection stays *before* moz-br, sticking to it
|
||||
aSelection->SetInterlinePosition(true);
|
||||
|
@ -8695,8 +8693,8 @@ HTMLEditRules::InsertBRIfNeededInternal(nsINode& aNode,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
return aInsertMozBR ? CreateMozBR(aNode.AsDOMNode(), 0) :
|
||||
CreateBR(aNode.AsDOMNode(), 0);
|
||||
return aInsertMozBR ? CreateMozBR(aNode, 0) :
|
||||
CreateBR(aNode, 0);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -1375,8 +1375,7 @@ TextEditRules::CreateTrailingBRIfNeeded()
|
|||
|
||||
if (!lastChild->IsHTMLElement(nsGkAtoms::br)) {
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(mTextEditor);
|
||||
nsCOMPtr<nsIDOMNode> domBody = do_QueryInterface(body);
|
||||
return CreateMozBR(domBody, body->Length());
|
||||
return CreateMozBR(*body, body->Length());
|
||||
}
|
||||
|
||||
// Check to see if the trailing BR is a former bogus node - this will have
|
||||
|
@ -1629,28 +1628,30 @@ TextEditRules::FillBufWithPWChars(nsAString* aOutString,
|
|||
}
|
||||
|
||||
nsresult
|
||||
TextEditRules::CreateBRInternal(nsIDOMNode* inParent,
|
||||
TextEditRules::CreateBRInternal(nsINode& inParent,
|
||||
int32_t inOffset,
|
||||
bool aMozBR,
|
||||
nsIDOMNode** outBRNode)
|
||||
Element** aOutBRElement)
|
||||
{
|
||||
NS_ENSURE_TRUE(inParent, NS_ERROR_NULL_POINTER);
|
||||
if (NS_WARN_IF(!mTextEditor)) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
RefPtr<TextEditor> textEditor = mTextEditor;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> brNode;
|
||||
NS_ENSURE_STATE(mTextEditor);
|
||||
nsresult rv = mTextEditor->CreateBR(inParent, inOffset, address_of(brNode));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
RefPtr<Element> brElem = textEditor->CreateBR(&inParent, inOffset);
|
||||
if (NS_WARN_IF(!brElem)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// give it special moz attr
|
||||
nsCOMPtr<Element> brElem = do_QueryInterface(brNode);
|
||||
if (aMozBR && brElem) {
|
||||
rv = mTextEditor->SetAttribute(brElem, nsGkAtoms::type,
|
||||
NS_LITERAL_STRING("_moz"));
|
||||
if (aMozBR) {
|
||||
nsresult rv = textEditor->SetAttribute(brElem, nsGkAtoms::type,
|
||||
NS_LITERAL_STRING("_moz"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (outBRNode) {
|
||||
brNode.forget(outBRNode);
|
||||
if (aOutBRElement) {
|
||||
brElem.forget(aOutBRElement);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -225,8 +225,8 @@ protected:
|
|||
* be inserted.
|
||||
* @param aOutBRNode Returns created <br> element.
|
||||
*/
|
||||
nsresult CreateBR(nsIDOMNode* aParent, int32_t aOffset,
|
||||
nsIDOMNode** aOutBRNode = nullptr)
|
||||
nsresult CreateBR(nsINode& aParent, int32_t aOffset,
|
||||
Element** aOutBRNode = nullptr)
|
||||
{
|
||||
return CreateBRInternal(aParent, aOffset, false, aOutBRNode);
|
||||
}
|
||||
|
@ -239,8 +239,8 @@ protected:
|
|||
* be inserted.
|
||||
* @param aOutBRNode Returns created <br> element.
|
||||
*/
|
||||
nsresult CreateMozBR(nsIDOMNode* aParent, int32_t aOffset,
|
||||
nsIDOMNode** aOutBRNode = nullptr)
|
||||
nsresult CreateMozBR(nsINode& aParent, int32_t aOffset,
|
||||
Element** aOutBRNode = nullptr)
|
||||
{
|
||||
return CreateBRInternal(aParent, aOffset, true, aOutBRNode);
|
||||
}
|
||||
|
@ -280,10 +280,10 @@ private:
|
|||
* Otherwise, false.
|
||||
* @param aOutBRNode Returns created <br> element.
|
||||
*/
|
||||
nsresult CreateBRInternal(nsIDOMNode* aParent,
|
||||
nsresult CreateBRInternal(nsINode& aParent,
|
||||
int32_t aOffset,
|
||||
bool aMozBR,
|
||||
nsIDOMNode** aOutBRNode = nullptr);
|
||||
Element** aOutBRNode = nullptr);
|
||||
|
||||
|
||||
protected:
|
||||
|
|
Загрузка…
Ссылка в новой задаче