зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1774704 - part 4-3: Make `HTMLEditor::MaybeSplitAncestorsForInsertWithTransaction` stop computing editing host with current selection r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152968
This commit is contained in:
Родитель
87542555d4
Коммит
cc6f01f78c
|
@ -8401,7 +8401,8 @@ CreateElementResult HTMLEditor::CreateOrChangeBlockContainerElement(
|
|||
}
|
||||
|
||||
SplitNodeResult HTMLEditor::MaybeSplitAncestorsForInsertWithTransaction(
|
||||
nsAtom& aTag, const EditorDOMPoint& aStartOfDeepestRightNode) {
|
||||
nsAtom& aTag, const EditorDOMPoint& aStartOfDeepestRightNode,
|
||||
const Element& aEditingHost) {
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
if (NS_WARN_IF(!aStartOfDeepestRightNode.IsSet())) {
|
||||
|
@ -8409,15 +8410,11 @@ SplitNodeResult HTMLEditor::MaybeSplitAncestorsForInsertWithTransaction(
|
|||
}
|
||||
MOZ_ASSERT(aStartOfDeepestRightNode.IsSetAndValid());
|
||||
|
||||
RefPtr<Element> host = ComputeEditingHost();
|
||||
if (NS_WARN_IF(!host)) {
|
||||
return SplitNodeResult(NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
// The point must be descendant of editing host.
|
||||
if (aStartOfDeepestRightNode.GetContainer() != host &&
|
||||
// XXX Isn't it a valid case if it points a direct child of aEditingHost?
|
||||
if (aStartOfDeepestRightNode.GetContainer() != &aEditingHost &&
|
||||
!EditorUtils::IsDescendantOf(*aStartOfDeepestRightNode.GetContainer(),
|
||||
*host)) {
|
||||
aEditingHost)) {
|
||||
NS_WARNING("aStartOfDeepestRightNode was not in editing host");
|
||||
return SplitNodeResult(NS_ERROR_INVALID_ARG);
|
||||
}
|
||||
|
@ -8428,7 +8425,7 @@ SplitNodeResult HTMLEditor::MaybeSplitAncestorsForInsertWithTransaction(
|
|||
pointToInsert.Set(pointToInsert.GetContainer())) {
|
||||
// We cannot split active editing host and its ancestor. So, there is
|
||||
// no element to contain the specified element.
|
||||
if (pointToInsert.GetChild() == host) {
|
||||
if (pointToInsert.GetChild() == &aEditingHost) {
|
||||
NS_WARNING(
|
||||
"HTMLEditor::MaybeSplitAncestorsForInsertWithTransaction() reached "
|
||||
"editing host");
|
||||
|
@ -8469,7 +8466,8 @@ HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction(
|
|||
MOZ_ASSERT(aPointToInsert.IsSetAndValid());
|
||||
|
||||
const SplitNodeResult splitNodeResult =
|
||||
MaybeSplitAncestorsForInsertWithTransaction(aTagName, aPointToInsert);
|
||||
MaybeSplitAncestorsForInsertWithTransaction(aTagName, aPointToInsert,
|
||||
aEditingHost);
|
||||
if (splitNodeResult.isErr()) {
|
||||
NS_WARNING(
|
||||
"HTMLEditor::MaybeSplitAncestorsForInsertWithTransaction() failed");
|
||||
|
@ -10295,7 +10293,7 @@ nsresult HTMLEditor::MoveSelectedContentsToDivElementToMakeItAbsolutePosition(
|
|||
// element at end of the <div> element.
|
||||
const SplitNodeResult splitNodeResult =
|
||||
MaybeSplitAncestorsForInsertWithTransaction(
|
||||
MOZ_KnownLive(*ULOrOLOrDLTagName), atContent);
|
||||
MOZ_KnownLive(*ULOrOLOrDLTagName), atContent, aEditingHost);
|
||||
if (splitNodeResult.isOk()) {
|
||||
NS_WARNING(
|
||||
"HTMLEditor::MaybeSplitAncestorsForInsertWithTransaction() "
|
||||
|
@ -10405,7 +10403,7 @@ nsresult HTMLEditor::MoveSelectedContentsToDivElementToMakeItAbsolutePosition(
|
|||
// element at end of the <div> element.
|
||||
const SplitNodeResult splitNodeResult =
|
||||
MaybeSplitAncestorsForInsertWithTransaction(
|
||||
MOZ_KnownLive(*containerName), atListItem);
|
||||
MOZ_KnownLive(*containerName), atListItem, aEditingHost);
|
||||
if (splitNodeResult.isErr()) {
|
||||
NS_WARNING(
|
||||
"HTMLEditor::MaybeSplitAncestorsForInsertWithTransaction() "
|
||||
|
|
|
@ -1300,14 +1300,15 @@ class HTMLEditor final : public EditorBase,
|
|||
* @param aTag The name of element to be inserted
|
||||
* after calling this method.
|
||||
* @param aStartOfDeepestRightNode The start point of deepest right node.
|
||||
* This point must be descendant of
|
||||
* active editing host.
|
||||
* This point must be in aEditingHost.
|
||||
* @param aEditingHost The editing host.
|
||||
* @return When succeeded, SplitPoint() returns
|
||||
* the point to insert the element.
|
||||
*/
|
||||
[[nodiscard]] MOZ_CAN_RUN_SCRIPT SplitNodeResult
|
||||
MaybeSplitAncestorsForInsertWithTransaction(
|
||||
nsAtom& aTag, const EditorDOMPoint& aStartOfDeepestRightNode);
|
||||
nsAtom& aTag, const EditorDOMPoint& aStartOfDeepestRightNode,
|
||||
const Element& aEditingHost);
|
||||
|
||||
/**
|
||||
* InsertElementWithSplittingAncestorsWithTransaction() is a wrapper of
|
||||
|
|
Загрузка…
Ссылка в новой задаче