mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 04:38:02 +00:00
Bug 998941 - part 1-5: Make HTMLEditor set InputEvent.data when InputEvent.inputType is "insertLink" r=smaug,m_kato
Although neither Chrome nor Safari does not set InputEvent.data value when InputEvent.inputType is "insertLink", but it's easy to implement. Therefore, this patch implements it as declaration of Input Events. This patch sets the value to raw href attribute value because we create <a> element without absolute URI when web apps call execCommand("createLink") with relative URI. Differential Revision: https://phabricator.services.mozilla.com/D19291 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
122ab2691a
commit
0d571915df
@ -2950,6 +2950,10 @@ HTMLEditor::InsertLinkAroundSelection(Element* aAnchorElement) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoString rawHref;
|
||||
anchor->GetAttr(kNameSpaceID_None, nsGkAtoms::href, rawHref);
|
||||
editActionData.SetData(rawHref);
|
||||
|
||||
nsAutoString href;
|
||||
anchor->GetHref(href);
|
||||
if (href.IsEmpty()) {
|
||||
|
@ -402,6 +402,32 @@ function runTests() {
|
||||
is(inputEvent.data, "ltr",
|
||||
aDescription + 'data should be "ltr" when dispatching cmd_switchTextDirection command #2');
|
||||
|
||||
// Inserting link
|
||||
editTarget.innerHTML = "link";
|
||||
editTarget.focus();
|
||||
selection.selectAllChildren(editTarget);
|
||||
inputEvent = null;
|
||||
aDocument.execCommand("createLink", false, "https://example.com/foo/bar.html");
|
||||
ok(inputEvent,
|
||||
aDescription + 'input event should be fired by execCommand("createLink", false, "https://example.com/foo/bar.html")');
|
||||
ok(inputEvent.isTrusted,
|
||||
aDescription + 'input event should be trusted when execCommand("createLink", false, "https://example.com/foo/bar.html")');
|
||||
is(inputEvent.inputType, "insertLink",
|
||||
aDescription + 'inputType should be "insertLink" when execCommand("createLink", false, "https://example.com/foo/bar.html")');
|
||||
is(inputEvent.data, "https://example.com/foo/bar.html",
|
||||
aDescription + 'data should be "https://example.com/foo/bar.html" when execCommand("createLink", false, "https://example.com/foo/bar.html")');
|
||||
|
||||
selection.selectAllChildren(editTarget);
|
||||
aDocument.execCommand("createLink", false, "foo/bar.html");
|
||||
ok(inputEvent,
|
||||
aDescription + 'input event should be fired by execCommand("createLink", false, "foo/bar.html")');
|
||||
ok(inputEvent.isTrusted,
|
||||
aDescription + 'input event should be trusted when execCommand("createLink", false, "foo/bar.html")');
|
||||
is(inputEvent.inputType, "insertLink",
|
||||
aDescription + 'inputType should be "insertLink" when execCommand("createLink", false, "foo/bar.html")');
|
||||
is(inputEvent.data, "foo/bar.html",
|
||||
aDescription + 'data should be "foo/bar.html" when execCommand("createLink", false, "foo/bar.html")');
|
||||
|
||||
aWindow.removeEventListener("input", handler, true);
|
||||
}
|
||||
|
||||
|
@ -163,6 +163,7 @@ inline bool IsDataAvailableOnHTMLEditor(EditorInputType aInputType) {
|
||||
case EditorInputType::eInsertFromComposition: // Only level 2
|
||||
case EditorInputType::eFormatSetBlockTextDirection:
|
||||
case EditorInputType::eFormatSetInlineTextDirection:
|
||||
case EditorInputType::eInsertLink:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user