Merge autoland to mozilla-central. a=merge
authorMargareta Eliza Balazs <ebalazs@mozilla.com>
Mon, 29 Oct 2018 11:25:37 +0200
changeset 443290 f7a97b344fa59bd3b01ea81ebd5b150aa63bfb12
parent 443288 28fcf5ff82bf4a5d9e3a6425c586d5fcfdf695d2 (current diff)
parent 443289 7ceb485a00ccd366cb25bedba008dcaf63a355d9 (diff)
child 443291 265e49140f732f2884ceb888f504bd16d6a84c02
child 443417 b851d42e26209d66cf854f4464d637fa943e98a6
push id109336
push userebalazs@mozilla.com
push dateMon, 29 Oct 2018 09:30:25 +0000
treeherdermozilla-inbound@265e49140f73 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone65.0a1
first release with
nightly linux32
f7a97b344fa5 / 65.0a1 / 20181029100347 / files
nightly linux64
f7a97b344fa5 / 65.0a1 / 20181029100347 / files
nightly mac
f7a97b344fa5 / 65.0a1 / 20181029100347 / files
nightly win32
f7a97b344fa5 / 65.0a1 / 20181029100347 / files
nightly win64
f7a97b344fa5 / 65.0a1 / 20181029100347 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge autoland to mozilla-central. a=merge
--- a/accessible/windows/msaa/ARIAGridAccessibleWrap.cpp
+++ b/accessible/windows/msaa/ARIAGridAccessibleWrap.cpp
@@ -12,18 +12,19 @@ using namespace mozilla::a11y;
 
 ////////////////////////////////////////////////////////////////////////////////
 // ARIAGridAccessibleWrap
 ////////////////////////////////////////////////////////////////////////////////
 
 NS_IMPL_ISUPPORTS_INHERITED0(ARIAGridAccessibleWrap,
                              ARIAGridAccessible)
 
-IMPL_IUNKNOWN_INHERITED1(ARIAGridAccessibleWrap,
+IMPL_IUNKNOWN_INHERITED2(ARIAGridAccessibleWrap,
                          AccessibleWrap,
+                         HyperTextAccessibleWrap,
                          ia2AccessibleTable)
 
 void
 ARIAGridAccessibleWrap::Shutdown()
 {
   ia2AccessibleTable::mTable = nullptr;
   ARIAGridAccessible::Shutdown();
 }
--- a/accessible/windows/msaa/HTMLTableAccessibleWrap.cpp
+++ b/accessible/windows/msaa/HTMLTableAccessibleWrap.cpp
@@ -11,18 +11,19 @@ using namespace mozilla::a11y;
 
 ////////////////////////////////////////////////////////////////////////////////
 // HTMLTableAccessibleWrap
 ////////////////////////////////////////////////////////////////////////////////
 
 NS_IMPL_ISUPPORTS_INHERITED0(HTMLTableAccessibleWrap,
                              HTMLTableAccessible)
 
-IMPL_IUNKNOWN_INHERITED1(HTMLTableAccessibleWrap,
+IMPL_IUNKNOWN_INHERITED2(HTMLTableAccessibleWrap,
                          AccessibleWrap,
+                         HyperTextAccessibleWrap,
                          ia2AccessibleTable)
 
 void
 HTMLTableAccessibleWrap::Shutdown()
 {
   ia2AccessibleTable::mTable = nullptr;
   HTMLTableAccessible::Shutdown();
 }
--- a/editor/libeditor/HTMLEditorDataTransfer.cpp
+++ b/editor/libeditor/HTMLEditorDataTransfer.cpp
@@ -2002,43 +2002,50 @@ HTMLEditor::InsertAsPlaintextQuotation(c
     // and set the selection inside it:
     DebugOnly<nsresult> rv = selection->Collapse(newNode, 0);
     NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
       "Failed to collapse selection into the new node");
   }
 
   if (aAddCites) {
     rv = InsertWithQuotationsAsSubAction(aQuotedText);
-    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
-      "Failed to insert the text with quotations");
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
   } else {
     rv = InsertTextAsSubAction(aQuotedText);
-    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
-      "Failed to insert the quoted text as plain text");
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
+  }
+
+  if (!newNode) {
+    return NS_OK;
   }
+
+  // Set the selection to just after the inserted node:
+  EditorRawDOMPoint afterNewNode(newNode);
+  bool advanced = afterNewNode.AdvanceOffset();
+  NS_WARNING_ASSERTION(advanced,
+    "Failed to advance offset to after the new <span> element");
+  if (advanced) {
+    DebugOnly<nsresult> rvIgnored = selection->Collapse(afterNewNode);
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rvIgnored),
+      "Failed to collapse after the new node");
+  }
+
   // Note that if !aAddCites, aNodeInserted isn't set.
   // That's okay because the routines that use aAddCites
   // don't need to know the inserted node.
-
-  if (aNodeInserted && NS_SUCCEEDED(rv)) {
+  if (aNodeInserted) {
     newNode.forget(aNodeInserted);
   }
 
-  // Set the selection to just after the inserted node:
-  if (NS_SUCCEEDED(rv) && newNode) {
-    EditorRawDOMPoint afterNewNode(newNode);
-    if (afterNewNode.AdvanceOffset()) {
-      DebugOnly<nsresult> rv = selection->Collapse(afterNewNode);
-      NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
-        "Failed to collapse after the new node");
-    }
-  }
-
   // XXX Why don't we call HTMLEditRules::DidDoAction() here?
-  return rv;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 HTMLEditor::Rewrap(bool aRespectNewlines)
 {
   // Rewrap makes no sense if there's no wrap column; default to 72.
   int32_t wrapWidth = WrapWidth();
   if (wrapWidth <= 0) {
@@ -2154,34 +2161,46 @@ HTMLEditor::InsertAsCitedQuotationIntern
     newNode->SetAttr(kNameSpaceID_None, nsGkAtoms::cite, aCitation, true);
   }
 
   // Set the selection inside the blockquote so aQuotedText will go there:
   selection->Collapse(newNode, 0);
 
   if (aInsertHTML) {
     rv = LoadHTML(aQuotedText);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
   } else {
     rv = InsertTextAsSubAction(aQuotedText);  // XXX ignore charset
-    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to insert the quoted text");
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
   }
 
-  if (aNodeInserted && NS_SUCCEEDED(rv)) {
-    *aNodeInserted = newNode;
-    NS_IF_ADDREF(*aNodeInserted);
+  if (!newNode) {
+    return NS_OK;
   }
 
   // Set the selection to just after the inserted node:
-  if (NS_SUCCEEDED(rv) && newNode) {
-    EditorRawDOMPoint afterNewNode(newNode);
-    if (afterNewNode.AdvanceOffset()) {
-      selection->Collapse(afterNewNode);
-    }
+  EditorRawDOMPoint afterNewNode(newNode);
+  bool advanced = afterNewNode.AdvanceOffset();
+  NS_WARNING_ASSERTION(advanced,
+    "Failed advance offset to after the new <blockquote> element");
+  if (advanced) {
+    DebugOnly<nsresult> rvIgnored = selection->Collapse(afterNewNode);
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rvIgnored),
+      "Failed to collapse after the new node");
   }
-  return rv;
+
+  if (aNodeInserted) {
+    newNode.forget(aNodeInserted);
+  }
+
+  return NS_OK;
 }
 
 
 void RemoveBodyAndHead(nsINode& aNode)
 {
   nsCOMPtr<nsIContent> body, head;
   // find the body and head nodes if any.
   // look only at immediate children of aNode.
--- a/editor/libeditor/tests/mochitest.ini
+++ b/editor/libeditor/tests/mochitest.ini
@@ -277,16 +277,17 @@ subsuite = clipboard
 skip-if = android_version == '24'
 [test_inline_style_cache.html]
 [test_inlineTableEditing.html]
 [test_insertParagraph_in_inline_editing_host.html]
 [test_keypress_untrusted_event.html]
 [test_middle_click_paste.html]
 subsuite = clipboard
 skip-if = android_version == '24'
+[test_nsIEditorMailSupport_insertAsCitedQuotation.html]
 [test_nsIHTMLEditor_getSelectedElement.html]
 [test_nsIHTMLEditor_selectElement.html]
 [test_nsIHTMLEditor_setCaretAfterElement.html]
 [test_nsIHTMLObjectResizer_hideResizers.html]
 [test_nsITableEditor_deleteTableCell.html]
 [test_nsITableEditor_deleteTableCellContents.html]
 [test_nsITableEditor_deleteTableColumn.html]
 [test_nsITableEditor_deleteTableRow.html]
new file mode 100644
--- /dev/null
+++ b/editor/libeditor/tests/test_nsIEditorMailSupport_insertAsCitedQuotation.html
@@ -0,0 +1,84 @@
+<!DOCTYPE>
+<html>
+<head>
+  <title>Test for nsIEditorMailSupport.insertAsCitedQuotation()</title>
+  <script src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" href="/tests/SimpleTest/test.css">
+</head>
+<body>
+<div id="display">
+</div>
+<div id="content" contenteditable></div>
+<pre id="test">
+</pre>
+
+<script class="testbody" type="application/javascript">
+
+SimpleTest.waitForExplicitFinish();
+SimpleTest.waitForFocus(function() {
+  let editor = document.getElementById("content");
+  let selection = document.getSelection();
+
+  editor.focus();
+  selection.collapse(editor, 0);
+
+  // Tests when the editor is in plaintext mode.
+
+  getEditor().flags |= SpecialPowers.Ci.nsIPlaintextEditor.eEditorPlaintextMask;
+
+  getEditorMailSupport().insertAsCitedQuotation("this is quoted text\nAnd here is second line.", "this is cited text", false);
+
+  ok(selection.isCollapsed,
+     "Selection should be collapsed after calling nsIEditorMailSupport.insertAsCitedQuotation() of plaintext editor");
+  is(selection.focusNode, editor,
+     "focus node of Selection should be a child of the editing host after calling nsIEditorMailSupport.insertAsCitedQuotation() of plaintext editor");
+  is(selection.focusOffset, 1,
+     "focus offset of Selection should be next to inserted <span> element after calling nsIEditorMailSupport.insertAsCitedQuotation() of plaintext editor");
+  is(editor.innerHTML, '<span style="white-space: pre-wrap;">&gt; this is quoted text<br>&gt; And here is second line.<br><br></span>',
+     "The quoted text should be inserted as plaintext into the plaintext editor");
+
+  // Tests when the editor is in HTML editor mode.
+  getEditor().flags &= ~SpecialPowers.Ci.nsIPlaintextEditor.eEditorPlaintextMask;
+
+  editor.innerHTML = "";
+
+  getEditorMailSupport().insertAsCitedQuotation("this is quoted text<br>", "this is cited text", false);
+
+  ok(selection.isCollapsed,
+     "Selection should be collapsed after calling nsIEditorMailSupport.insertAsCitedQuotation() of HTMLEditor editor (inserting as plaintext)");
+  is(selection.focusNode, editor,
+     "focus node of Selection should be a child of the editing host after calling nsIEditorMailSupport.insertAsCitedQuotation() of HTMLEditor editor (inserting as plaintext)");
+  is(selection.focusOffset, 1,
+     "focus offset of Selection should be next to inserted <span> element after calling nsIEditorMailSupport.insertAsCitedQuotation() of HTMLEditor editor (inserting as plaintext)");
+  is(editor.innerHTML,
+     '<blockquote type="cite" cite="this is cited text">this is quoted text&lt;br&gt;</blockquote>', "The quoted text should be inserted as plaintext into the HTML editor");
+
+  editor.innerHTML = "";
+
+  getEditorMailSupport().insertAsCitedQuotation("this is quoted text<br>And here is second line.", "this is cited text", true);
+
+  ok(selection.isCollapsed,
+     "Selection should be collapsed after calling nsIEditorMailSupport.insertAsCitedQuotation() of HTMLEditor editor (inserting as HTML source)");
+  is(selection.focusNode, editor,
+     "focus node of Selection should be a child of the editing host after calling nsIEditorMailSupport.insertAsCitedQuotation() of HTMLEditor editor (inserting as HTML source)");
+  is(selection.focusOffset, 1,
+     "focus offset of Selection should be next to inserted <span> element after calling nsIEditorMailSupport.insertAsCitedQuotation() of HTMLEditor editor (inserting as HTML source)");
+  is(editor.innerHTML, '<blockquote type="cite" cite="this is cited text">this is quoted text<br>And here is second line.</blockquote>',
+     "The quoted text should be inserted as HTML source into the HTML editor");
+
+  SimpleTest.finish();
+});
+
+function getEditor() {
+  var editingSession = SpecialPowers.wrap(window).docShell.editingSession;
+  return editingSession.getEditorForWindow(window);
+}
+
+function getEditorMailSupport() {
+  return getEditor().QueryInterface(SpecialPowers.Ci.nsIEditorMailSupport);
+}
+
+</script>
+</body>
+
+</html>