зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1505679 - Make HTMLEditor::RemoveList() sets specific EditAction when it's called by execCommand("insertorderedlist") or execCommand("insertunorderedlist") r=m_kato
Even when execCommand("insertorderedlist") and execCommand("insertunorderedlist") remove existing lists, we need to set InputEvent.inputType value to "insertOrderedList" or "insertUnorderedList". Fortunately, the XPCOM method is used only for handling execCommand("insertorderedlist") and execCommand("insertunorderedlist") on Firefox. Therefore, we should make it set EditAction to EditAction::eRemoveOrderedListElement or EditAction::RemoveUnorderedListElement. Note that comm-central uses this method directly and uses "cmd_removeList" which causes calling the XPCOM method with empty string. However, input events for them won't be exposed to the web. Therefore, it's okay to set EditAction::eRemoveListElement for the other cases. Differential Revision: https://phabricator.services.mozilla.com/D11439 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
0451a3f0a7
Коммит
89cf9854fe
|
@ -170,14 +170,17 @@ enum class EditAction
|
||||||
// href attribute.
|
// href attribute.
|
||||||
eInsertLinkElement,
|
eInsertLinkElement,
|
||||||
|
|
||||||
// eInsertUnorderedListElement, eInsertOrderedListElement and
|
// eInsertUnorderedListElement and eInsertOrderedListElement indicate to
|
||||||
// eInsertDefinitionListLElement indicate to insert <ul>, <ol> or <dl>
|
// insert <ul> or <ol> element.
|
||||||
// element.
|
|
||||||
eInsertUnorderedListElement,
|
eInsertUnorderedListElement,
|
||||||
eInsertOrderedListElement,
|
eInsertOrderedListElement,
|
||||||
eInsertDefinitionListElementv,
|
|
||||||
|
|
||||||
// eRemoveListElement indicates to remove parent list related elements.
|
// eRemoveUnorderedListElement and eRemoveOrderedListElement indicate to
|
||||||
|
// remove <ul> or <ol> element.
|
||||||
|
eRemoveUnorderedListElement,
|
||||||
|
eRemoveOrderedListElement,
|
||||||
|
|
||||||
|
// eRemoveListElement indicates to remove <ul>, <ol> and/or <dl> element.
|
||||||
eRemoveListElement,
|
eRemoveListElement,
|
||||||
|
|
||||||
// eInsertBlockquoteElement indicates to insert a <blockquote> element.
|
// eInsertBlockquoteElement indicates to insert a <blockquote> element.
|
||||||
|
|
|
@ -720,6 +720,22 @@ HTMLEditUtils::GetEditActionForInsert(const nsAtom& aTagName)
|
||||||
return EditAction::eInsertNode;
|
return EditAction::eInsertNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EditAction
|
||||||
|
HTMLEditUtils::GetEditActionForRemoveList(const nsAtom& aTagName)
|
||||||
|
{
|
||||||
|
// This method may be in a hot path. So, return only necessary
|
||||||
|
// EditAction::eRemove*Element.
|
||||||
|
if (&aTagName == nsGkAtoms::ul) {
|
||||||
|
// For InputEvent.inputType, "insertUnorderedList".
|
||||||
|
return EditAction::eRemoveUnorderedListElement;
|
||||||
|
}
|
||||||
|
if (&aTagName == nsGkAtoms::ol) {
|
||||||
|
// For InputEvent.inputType, "insertOrderedList".
|
||||||
|
return EditAction::eRemoveOrderedListElement;
|
||||||
|
}
|
||||||
|
return EditAction::eRemoveListElement;
|
||||||
|
}
|
||||||
|
|
||||||
EditAction
|
EditAction
|
||||||
HTMLEditUtils::GetEditActionForInsert(const Element& aElement)
|
HTMLEditUtils::GetEditActionForInsert(const Element& aElement)
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,6 +48,7 @@ public:
|
||||||
static bool IsSingleLineContainer(nsINode& aNode);
|
static bool IsSingleLineContainer(nsINode& aNode);
|
||||||
|
|
||||||
static EditAction GetEditActionForInsert(const nsAtom& aTagName);
|
static EditAction GetEditActionForInsert(const nsAtom& aTagName);
|
||||||
|
static EditAction GetEditActionForRemoveList(const nsAtom& aTagName);
|
||||||
static EditAction GetEditActionForInsert(const Element& aElement);
|
static EditAction GetEditActionForInsert(const Element& aElement);
|
||||||
static EditAction GetEditActionForFormatText(const nsAtom& aProperty,
|
static EditAction GetEditActionForFormatText(const nsAtom& aProperty,
|
||||||
const nsAtom* aAttribute,
|
const nsAtom* aAttribute,
|
||||||
|
|
|
@ -2377,14 +2377,26 @@ HTMLEditor::MakeOrChangeList(const nsAString& aListType,
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
HTMLEditor::RemoveList(const nsAString&)
|
HTMLEditor::RemoveList(const nsAString& aListType)
|
||||||
{
|
{
|
||||||
if (!mRules) {
|
if (!mRules) {
|
||||||
return NS_ERROR_NOT_INITIALIZED;
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoEditActionDataSetter editActionData(*this,
|
// Note that we ignore aListType when we actually remove parent list elements.
|
||||||
EditAction::eRemoveListElement);
|
// However, we need to set InputEvent.inputType to "insertOrderedList" or
|
||||||
|
// "insertedUnorderedList" when this is called for
|
||||||
|
// execCommand("insertorderedlist") or execCommand("insertunorderedlist").
|
||||||
|
// Otherwise, comm-central UI may call this methods with "dl" or "".
|
||||||
|
// So, it's okay to use mismatched EditAction here if this is called in
|
||||||
|
// comm-central.
|
||||||
|
|
||||||
|
RefPtr<nsAtom> listAtom = NS_Atomize(aListType);
|
||||||
|
if (NS_WARN_IF(!listAtom)) {
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
}
|
||||||
|
AutoEditActionDataSetter editActionData(
|
||||||
|
*this, HTMLEditUtils::GetEditActionForRemoveList(*listAtom));
|
||||||
if (NS_WARN_IF(!editActionData.CanHandle())) {
|
if (NS_WARN_IF(!editActionData.CanHandle())) {
|
||||||
return NS_ERROR_NOT_INITIALIZED;
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче