Bug 1397576 - Avoid using GetChildAt() in HTMLEditor::GetCellFromRange(); r=smaug
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 06 Sep 2017 22:03:02 -0400
changeset 431521 13327b54fbd559d86d39e38244f1315754f76280
parent 431520 7e21f710ecec4a16f1f23e7489bbb0eb3e45e462
child 431522 df9d3661abb63c68caeca8de66c6e44eb7456260
push id1567
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 12:36:05 +0000
treeherdermozilla-release@e512c14a0406 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1397576
milestone57.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 1397576 - Avoid using GetChildAt() in HTMLEditor::GetCellFromRange(); r=smaug
dom/base/nsRange.h
editor/libeditor/HTMLTableEditor.cpp
--- a/dom/base/nsRange.h
+++ b/dom/base/nsRange.h
@@ -97,16 +97,26 @@ public:
     return static_cast<uint32_t>(mStart.Offset());
   }
 
   uint32_t EndOffset() const
   {
     return static_cast<uint32_t>(mEnd.Offset());
   }
 
+  nsIContent* GetChildAtStartOffset() const
+  {
+    return mStart.GetChildAtOffset();
+  }
+
+  nsIContent* GetChildAtEndOffset() const
+  {
+    return mEnd.GetChildAtOffset();
+  }
+
   bool IsPositioned() const
   {
     return mIsPositioned;
   }
 
   void SetMaySpanAnonymousSubtrees(bool aMaySpanAnonymousSubtrees)
   {
     mMaySpanAnonymousSubtrees = aMaySpanAnonymousSubtrees;
--- a/editor/libeditor/HTMLTableEditor.cpp
+++ b/editor/libeditor/HTMLTableEditor.cpp
@@ -2916,18 +2916,17 @@ HTMLEditor::GetCellFromRange(nsRange* aR
 
   nsCOMPtr<nsINode> startContainer = aRange->GetStartContainer();
   if (NS_WARN_IF(!startContainer)) {
     return NS_ERROR_FAILURE;
   }
 
   uint32_t startOffset = aRange->StartOffset();
 
-  nsCOMPtr<nsINode> childNode =
-    startContainer->GetChildAt(static_cast<int32_t>(startOffset));
+  nsCOMPtr<nsINode> childNode = aRange->GetChildAtStartOffset();
   // This means selection is probably at a text node (or end of doc?)
   if (!childNode) {
     return NS_ERROR_FAILURE;
   }
 
   nsCOMPtr<nsINode> endContainer = aRange->GetEndContainer();
   if (NS_WARN_IF(!endContainer)) {
     return NS_ERROR_FAILURE;