Bug 898438 nsITableEditor.getCellAt doesn't default to the current table r=ehsan
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Sun, 28 Jul 2013 11:04:09 +0100
changeset 152551 1bb4b1eba285fd3074140b1af90b62e22502254f
parent 152550 4a126050ecdbdfc3a7b4432783db8ac8373af002
child 152552 318216ea648d6acfee79c017517c3edba1c03af9
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs898438
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 898438 nsITableEditor.getCellAt doesn't default to the current table r=ehsan
editor/libeditor/html/nsTableEditor.cpp
--- a/editor/libeditor/html/nsTableEditor.cpp
+++ b/editor/libeditor/html/nsTableEditor.cpp
@@ -2747,16 +2747,26 @@ nsHTMLEditor::GetCellDataAt(nsIDOMElemen
 
 // When all you want is the cell
 NS_IMETHODIMP 
 nsHTMLEditor::GetCellAt(nsIDOMElement* aTable, int32_t aRowIndex, int32_t aColIndex, nsIDOMElement **aCell)
 {
   NS_ENSURE_ARG_POINTER(aCell);
   *aCell = nullptr;
 
+  if (!aTable)
+  {
+    // Get the selected table or the table enclosing the selection anchor
+    nsCOMPtr<nsIDOMElement> table;
+    nsresult res = GetElementOrParentByTagName(NS_LITERAL_STRING("table"), nullptr, getter_AddRefs(table));
+    NS_ENSURE_SUCCESS(res, res);
+    NS_ENSURE_TRUE(table, NS_ERROR_FAILURE);
+    aTable = table;
+  }
+
   nsTableOuterFrame* tableFrame = GetTableFrame(aTable);
   if (!tableFrame)
     return NS_ERROR_FAILURE;
 
   nsCOMPtr<nsIDOMElement> domCell =
     do_QueryInterface(tableFrame->GetCellAt(aRowIndex, aColIndex));
   domCell.forget(aCell);