Bug 1000465 - fix bunch of warning in accessible module, r=jwei
authorAlexander Surkov <surkov.alexander@gmail.com>
Fri, 25 Apr 2014 22:42:19 -0400
changeset 181049 527c58711da128cbd5a5017f673a61da18c72150
parent 181048 e18d4a0e3bbc466e1a52f3cb3e6ad73cddfb4200
child 181050 c8871dd41a1025feb43dbb4a52192781cbb81300
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersjwei
bugs1000465
milestone32.0a1
Bug 1000465 - fix bunch of warning in accessible module, r=jwei
accessible/src/base/AccGroupInfo.cpp
accessible/src/base/TextAttrs.cpp
accessible/src/base/TextAttrs.h
accessible/src/base/nsAccessiblePivot.cpp
accessible/src/generic/HyperTextAccessible-inl.h
accessible/src/generic/HyperTextAccessible.cpp
accessible/src/generic/HyperTextAccessible.h
accessible/src/xul/XULListboxAccessible.cpp
--- a/accessible/src/base/AccGroupInfo.cpp
+++ b/accessible/src/base/AccGroupInfo.cpp
@@ -193,17 +193,17 @@ AccGroupInfo::NextItemTo(Accessible* aIt
     return nullptr;
 
   // If the item in middle of the group then search next item in siblings.
   if (groupInfo->PosInSet() >= groupInfo->SetSize())
     return nullptr;
 
   Accessible* parent = aItem->Parent();
   uint32_t childCount = parent->ChildCount();
-  for (int32_t idx = aItem->IndexInParent() + 1; idx < childCount; idx++) {
+  for (uint32_t idx = aItem->IndexInParent() + 1; idx < childCount; idx++) {
     Accessible* nextItem = parent->GetChildAt(idx);
     AccGroupInfo* nextGroupInfo = nextItem->GetGroupInfo();
     if (nextGroupInfo &&
         nextGroupInfo->ConceptualParent() == groupInfo->ConceptualParent()) {
       return nextItem;
     }
   }
 
--- a/accessible/src/base/TextAttrs.cpp
+++ b/accessible/src/base/TextAttrs.cpp
@@ -21,51 +21,51 @@ using namespace mozilla;
 using namespace mozilla::a11y;
 
 ////////////////////////////////////////////////////////////////////////////////
 // TextAttrsMgr
 ////////////////////////////////////////////////////////////////////////////////
 
 void
 TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
-                            int32_t* aStartHTOffset,
-                            int32_t* aEndHTOffset)
+                            uint32_t* aStartOffset,
+                            uint32_t* aEndOffset)
 {
   // 1. Hyper text accessible must be specified always.
   // 2. Offset accessible and result hyper text offsets must be specified in
   // the case of text attributes.
   // 3. Offset accessible and result hyper text offsets must not be specified
   // but include default text attributes flag and attributes list must be
   // specified in the case of default text attributes.
   NS_PRECONDITION(mHyperTextAcc &&
                   ((mOffsetAcc && mOffsetAccIdx != -1 &&
-                    aStartHTOffset && aEndHTOffset) ||
+                    aStartOffset && aEndOffset) ||
                   (!mOffsetAcc && mOffsetAccIdx == -1 &&
-                    !aStartHTOffset && !aEndHTOffset &&
+                    !aStartOffset && !aEndOffset &&
                    mIncludeDefAttrs && aAttributes)),
                   "Wrong usage of TextAttrsMgr!");
 
   // Embedded objects are combined into own range with empty attributes set.
   if (mOffsetAcc && nsAccUtils::IsEmbeddedObject(mOffsetAcc)) {
     for (int32_t childIdx = mOffsetAccIdx - 1; childIdx >= 0; childIdx--) {
       Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);
       if (!nsAccUtils::IsEmbeddedObject(currAcc))
         break;
 
-      (*aStartHTOffset)--;
+      (*aStartOffset)--;
     }
 
     uint32_t childCount = mHyperTextAcc->ChildCount();
     for (uint32_t childIdx = mOffsetAccIdx + 1; childIdx < childCount;
          childIdx++) {
       Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);
       if (!nsAccUtils::IsEmbeddedObject(currAcc))
         break;
 
-      (*aEndHTOffset)++;
+      (*aEndOffset)++;
     }
 
     return;
   }
 
   // Get the content and frame of the accessible. In the case of document
   // accessible it's role content and root frame.
   nsIContent *hyperTextElm = mHyperTextAcc->GetContent();
@@ -136,22 +136,22 @@ TextAttrsMgr::GetAttributes(nsIPersisten
   // Expose text attributes if applicable.
   if (aAttributes) {
     for (uint32_t idx = 0; idx < ArrayLength(attrArray); idx++)
       attrArray[idx]->Expose(aAttributes, mIncludeDefAttrs);
   }
 
   // Expose text attributes range where they are applied if applicable.
   if (mOffsetAcc)
-    GetRange(attrArray, ArrayLength(attrArray), aStartHTOffset, aEndHTOffset);
+    GetRange(attrArray, ArrayLength(attrArray), aStartOffset, aEndOffset);
 }
 
 void
 TextAttrsMgr::GetRange(TextAttr* aAttrArray[], uint32_t aAttrArrayLen,
-                       int32_t* aStartHTOffset, int32_t* aEndHTOffset)
+                       uint32_t* aStartOffset, uint32_t* aEndOffset)
 {
   // Navigate backward from anchor accessible to find start offset.
   for (int32_t childIdx = mOffsetAccIdx - 1; childIdx >= 0; childIdx--) {
     Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);
 
     // Stop on embedded accessible since embedded accessibles are combined into
     // own range.
     if (nsAccUtils::IsEmbeddedObject(currAcc))
@@ -164,17 +164,17 @@ TextAttrsMgr::GetRange(TextAttr* aAttrAr
         offsetFound = true;
         break;
       }
     }
 
     if (offsetFound)
       break;
 
-    *(aStartHTOffset) -= nsAccUtils::TextLength(currAcc);
+    *(aStartOffset) -= nsAccUtils::TextLength(currAcc);
   }
 
   // Navigate forward from anchor accessible to find end offset.
   uint32_t childLen = mHyperTextAcc->ChildCount();
   for (uint32_t childIdx = mOffsetAccIdx + 1; childIdx < childLen; childIdx++) {
     Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);
     if (nsAccUtils::IsEmbeddedObject(currAcc))
       break;
@@ -189,17 +189,17 @@ TextAttrsMgr::GetRange(TextAttr* aAttrAr
         offsetFound = true;
         break;
       }
     }
 
     if (offsetFound)
       break;
 
-    (*aEndHTOffset) += nsAccUtils::TextLength(currAcc);
+    (*aEndOffset) += nsAccUtils::TextLength(currAcc);
   }
 }
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // LangTextAttr
 ////////////////////////////////////////////////////////////////////////////////
 
@@ -865,16 +865,16 @@ TextAttrsMgr::TextPosTextAttr::
     case eStyleUnit_Integer:
     case eStyleUnit_Calc:
       break;
   }
 
   const nsIContent* content = aFrame->GetContent();
   if (content && content->IsHTML()) {
     const nsIAtom* tagName = content->Tag();
-    if (tagName == nsGkAtoms::sup) 
+    if (tagName == nsGkAtoms::sup)
       return eTextPosSuper;
-    if (tagName == nsGkAtoms::sub) 
+    if (tagName == nsGkAtoms::sub)
       return eTextPosSub;
   }
 
   return eTextPosNone;
 }
--- a/accessible/src/base/TextAttrs.h
+++ b/accessible/src/base/TextAttrs.h
@@ -64,33 +64,33 @@ public:
    * @note In the case of default attributes pointers on hyper text offsets
    *       must be skipped.
    *
    * @param aAttributes    [in, out] text attributes list
    * @param aStartHTOffset [out, optional] start hyper text offset
    * @param aEndHTOffset   [out, optional] end hyper text offset
    */
   void GetAttributes(nsIPersistentProperties* aAttributes,
-                     int32_t* aStartHTOffset = nullptr,
-                     int32_t* aEndHTOffset = nullptr);
+                     uint32_t* aStartHTOffset = nullptr,
+                     uint32_t* aEndHTOffset = nullptr);
 
 protected:
   /**
    * Calculates range (start and end offsets) of text where the text attributes
    * are stretched. New offsets may be smaller if one of text attributes changes
    * its value before or after the given offsets.
    *
    * @param aTextAttrArray  [in] text attributes array
    * @param aAttrArrayLen   [in] text attributes array length
    * @param aStartHTOffset  [in, out] the start offset
    * @param aEndHTOffset    [in, out] the end offset
    */
   class TextAttr;
   void GetRange(TextAttr* aAttrArray[], uint32_t aAttrArrayLen,
-                int32_t* aStartHTOffset, int32_t* aEndHTOffset);
+                uint32_t* aStartOffset, uint32_t* aEndOffset);
 
 private:
   Accessible* mOffsetAcc;
   HyperTextAccessible* mHyperTextAcc;
   int32_t mOffsetAccIdx;
   bool mIncludeDefAttrs;
 
 protected:
@@ -310,17 +310,17 @@ protected:
    * Class is used for the work with "font-size" text attribute.
    */
   class FontSizeTextAttr : public TTextAttr<nscoord>
   {
   public:
     FontSizeTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
     virtual ~FontSizeTextAttr() { }
 
-  protected: 
+  protected:
 
     // TTextAttr
     virtual bool GetValueFor(Accessible* aAccessible, nscoord* aValue);
     virtual void ExposeValue(nsIPersistentProperties* aAttributes,
                              const nscoord& aValue);
 
   private:
     nsDeviceContext* mDC;
--- a/accessible/src/base/nsAccessiblePivot.cpp
+++ b/accessible/src/base/nsAccessiblePivot.cpp
@@ -9,17 +9,17 @@
 #include "HyperTextAccessible.h"
 #include "nsAccUtils.h"
 #include "States.h"
 
 using namespace mozilla::a11y;
 
 
 /**
- * An object that stores a given traversal rule during 
+ * An object that stores a given traversal rule during the pivot movement.
  */
 class RuleCache
 {
 public:
   RuleCache(nsIAccessibleTraversalRule* aRule) : mRule(aRule),
                                                  mAcceptRoles(nullptr) { }
   ~RuleCache () {
     if (mAcceptRoles)
@@ -320,17 +320,17 @@ nsAccessiblePivot::MoveNextByText(TextBo
     // starting on a text leaf), start the text movement from the end of that
     // node, otherwise we just default to 0.
     if (tempEnd == -1)
       tempEnd = text == curPosition->Parent() ?
                 text->GetChildOffset(curPosition) : 0;
 
     // If there's no more text on the current node, try to find the next text
     // node; if there isn't one, bail out.
-    if (tempEnd == text->CharacterCount()) {
+    if (tempEnd == static_cast<int32_t>(text->CharacterCount())) {
       if (tempPosition == root)
         return NS_OK;
 
       // If we're currently sitting on a link, try move to either the next
       // sibling or the parent, whichever is closer to the current end
       // offset. Otherwise, do a forward search for the next node to land on
       // (we don't do this in the first case because we don't want to go to the
       // subtree).
@@ -384,17 +384,17 @@ nsAccessiblePivot::MoveNextByText(TextBo
         tempEnd = i;
         break;
       }
     }
     // If there's an embedded character at the very start of the range, we
     // instead want to traverse into it. So restart the movement with
     // the child as the starting point.
     if (childAtOffset && nsAccUtils::IsEmbeddedObject(childAtOffset) &&
-        tempStart == childAtOffset->StartOffset()) {
+        tempStart == static_cast<int32_t>(childAtOffset->StartOffset())) {
       tempPosition = childAtOffset;
       tempStart = tempEnd = -1;
       continue;
     }
 
     *aResult = true;
 
     Accessible* startPosition = mPosition;
@@ -512,17 +512,17 @@ nsAccessiblePivot::MovePreviousByText(Te
         tempStart = childAtOffset->EndOffset();
         break;
       }
     }
     // If there's an embedded character at the very end of the range, we
     // instead want to traverse into it. So restart the movement with
     // the child as the starting point.
     if (childAtOffset && nsAccUtils::IsEmbeddedObject(childAtOffset) &&
-        tempEnd == childAtOffset->EndOffset()) {
+        tempEnd == static_cast<int32_t>(childAtOffset->EndOffset())) {
       tempPosition = childAtOffset;
       tempStart = tempEnd = childAtOffset->AsHyperText()->CharacterCount();
       continue;
     }
 
     *aResult = true;
 
     Accessible* startPosition = mPosition;
--- a/accessible/src/generic/HyperTextAccessible-inl.h
+++ b/accessible/src/generic/HyperTextAccessible-inl.h
@@ -16,32 +16,25 @@
 #include "nsIPlaintextEditor.h"
 
 namespace mozilla {
 namespace a11y {
 
 inline bool
 HyperTextAccessible::IsValidOffset(int32_t aOffset)
 {
-  int32_t offset = ConvertMagicOffset(aOffset);
-  return offset >= 0 && offset <= static_cast<int32_t>(CharacterCount());
+  return ConvertMagicOffset(aOffset) <= CharacterCount();
 }
 
 inline bool
 HyperTextAccessible::IsValidRange(int32_t aStartOffset, int32_t aEndOffset)
 {
-  int32_t startOffset = ConvertMagicOffset(aStartOffset);
-  if (startOffset < 0)
-    return false;
-
-  int32_t endOffset = ConvertMagicOffset(aEndOffset);
-  if (endOffset < 0 || startOffset > endOffset)
-    return false;
-
-  return endOffset <= static_cast<int32_t>(CharacterCount());
+  uint32_t endOffset = ConvertMagicOffset(aEndOffset);
+  return ConvertMagicOffset(aStartOffset) <= endOffset &&
+    endOffset <= CharacterCount();
 }
 
 inline bool
 HyperTextAccessible::AddToSelection(int32_t aStartOffset, int32_t aEndOffset)
 {
   dom::Selection* domSel = DOMSelection();
   return domSel &&
     SetSelectionBoundsAt(domSel->GetRangeCount(), aStartOffset, aEndOffset);
@@ -103,30 +96,30 @@ HyperTextAccessible::PasteText(int32_t a
 {
   nsCOMPtr<nsIEditor> editor = GetEditor();
   if (editor) {
     SetSelectionRange(aPosition, aPosition);
     editor->Paste(nsIClipboard::kGlobalClipboard);
   }
 }
 
-inline int32_t
-HyperTextAccessible::ConvertMagicOffset(int32_t aOffset)
+inline uint32_t
+HyperTextAccessible::ConvertMagicOffset(int32_t aOffset) const
 {
   if (aOffset == nsIAccessibleText::TEXT_OFFSET_END_OF_TEXT)
     return CharacterCount();
 
   if (aOffset == nsIAccessibleText::TEXT_OFFSET_CARET)
     return CaretOffset();
 
-  return aOffset;
+  return aOffset < 0 ? std::numeric_limits<uint32_t>::max() : aOffset;
 }
 
-inline int32_t
-HyperTextAccessible::AdjustCaretOffset(int32_t aOffset) const
+inline uint32_t
+HyperTextAccessible::AdjustCaretOffset(uint32_t aOffset) const
 {
   // It is the same character offset when the caret is visually at the very
   // end of a line or the start of a new line (soft line break). Getting text
   // at the line should provide the line with the visual caret, otherwise
   // screen readers will announce the wrong line as the user presses up or
   // down arrow and land at the end of a line.
   if (aOffset > 0 && IsCaretAtEndOfLine())
     return aOffset - 1;
--- a/accessible/src/generic/HyperTextAccessible.cpp
+++ b/accessible/src/generic/HyperTextAccessible.cpp
@@ -78,17 +78,17 @@ HyperTextAccessible::NativeRole()
 
   if (tag == nsGkAtoms::h1 || tag == nsGkAtoms::h2 ||
       tag == nsGkAtoms::h3 || tag == nsGkAtoms::h4 ||
       tag == nsGkAtoms::h5 || tag == nsGkAtoms::h6)
     return roles::HEADING;
 
   if (tag == nsGkAtoms::article)
     return roles::DOCUMENT;
-        
+
   // Deal with html landmark elements
   if (tag == nsGkAtoms::header)
     return roles::HEADER;
 
   if (tag == nsGkAtoms::footer)
     return roles::FOOTER;
 
   if (tag == nsGkAtoms::aside)
@@ -144,20 +144,19 @@ HyperTextAccessible::GetBoundsInFrame(ns
   // Get the right frame continuation -- not really a child, but a sibling of
   // the primary frame passed in
   rv = aFrame->GetChildFrameContainingOffset(startContentOffset, false,
                                              &startContentOffsetInFrame, &frame);
   NS_ENSURE_SUCCESS(rv, nsIntRect());
 
   nsRect screenRect;
   while (frame && startContentOffset < endContentOffset) {
-    // Start with this frame's screen rect, which we will 
-    // shrink based on the substring we care about within it.
-    // We will then add that frame to the total screenRect we
-    // are returning.
+    // Start with this frame's screen rect, which we will shrink based on
+    // the substring we care about within it. We will then add that frame to
+    // the total screenRect we are returning.
     nsRect frameScreenRect = frame->GetScreenRectInAppUnits();
 
     // Get the length of the substring in this frame that we want the bounds for
     int32_t startFrameTextOffset, endFrameTextOffset;
     frame->GetOffsets(startFrameTextOffset, endFrameTextOffset);
     int32_t frameTotalTextLength = endFrameTextOffset - startFrameTextOffset;
     int32_t seekLength = endContentOffset - startContentOffset;
     int32_t frameSubStringLength = std::min(frameTotalTextLength - startContentOffsetInFrame, seekLength);
@@ -187,18 +186,18 @@ HyperTextAccessible::GetBoundsInFrame(ns
 }
 
 void
 HyperTextAccessible::TextSubstring(int32_t aStartOffset, int32_t aEndOffset,
                                    nsAString& aText)
 {
   aText.Truncate();
 
-  int32_t startOffset = ConvertMagicOffset(aStartOffset);
-  int32_t endOffset = ConvertMagicOffset(aEndOffset);
+  uint32_t startOffset = ConvertMagicOffset(aStartOffset);
+  uint32_t endOffset = ConvertMagicOffset(aEndOffset);
 
   int32_t startChildIdx = GetChildIndexAtOffset(startOffset);
   if (startChildIdx == -1)
     return;
 
   int32_t endChildIdx = GetChildIndexAtOffset(endOffset);
   if (endChildIdx == -1)
     return;
@@ -229,17 +228,17 @@ HyperTextAccessible::TextSubstring(int32
   int32_t endChildOffset =  GetChildOffset(endChildIdx);
   if (endChildOffset == -1)
     return;
 
   Accessible* endChild = GetChildAt(endChildIdx);
   endChild->AppendTextTo(aText, 0, endOffset - endChildOffset);
 }
 
-int32_t
+uint32_t
 HyperTextAccessible::DOMPointToOffset(nsINode* aNode, int32_t aNodeOffset,
                                       bool aIsEndOffset) const
 {
   if (!aNode)
     return 0;
 
   uint32_t offset = 0;
   nsINode* findNode = nullptr;
@@ -251,17 +250,17 @@ HyperTextAccessible::DOMPointToOffset(ns
     // For text nodes, aNodeOffset comes in as a character offset
     // Text offset will be added at the end, if we find the offset in this hypertext
     // We want the "skipped" offset into the text (rendered text without the extra whitespace)
     nsIFrame* frame = aNode->AsContent()->GetPrimaryFrame();
     NS_ENSURE_TRUE(frame, 0);
 
     nsresult rv = ContentToRenderedOffset(frame, aNodeOffset, &offset);
     NS_ENSURE_SUCCESS(rv, 0);
-    // Get the child node and 
+
     findNode = aNode;
 
   } else {
     // findNode could be null if aNodeOffset == # of child nodes, which means
     // one of two things:
     // 1) there are no children, and the passed-in node is not mContent -- use
     //    parentContent for the node to find
     // 2) there are no children and the passed-in node is mContent, which means
@@ -274,17 +273,17 @@ HyperTextAccessible::DOMPointToOffset(ns
         if (aNode == GetNode()) {
           // Case #1: this accessible has no children and thus has empty text,
           // we can only be at hypertext offset 0.
           return 0;
         }
 
         // Case #2: there are no children, we're at this node.
         findNode = aNode;
-      } else if (aNodeOffset == aNode->GetChildCount()) {
+      } else if (aNodeOffset == static_cast<int32_t>(aNode->GetChildCount())) {
         // Case #3: we're after the last child, get next node to this one.
         for (nsINode* tmpNode = aNode;
              !findNode && tmpNode && tmpNode != mContent;
              tmpNode = tmpNode->GetParent()) {
           findNode = tmpNode->GetNextSibling();
         }
       }
     }
@@ -314,22 +313,22 @@ HyperTextAccessible::DOMPointToOffset(ns
         descendant = walker.NextChild();
       }
     }
   }
 
   return TransformOffset(descendant, offset, aIsEndOffset);
 }
 
-int32_t
+uint32_t
 HyperTextAccessible::TransformOffset(Accessible* aDescendant,
-                                     int32_t aOffset, bool aIsEndOffset) const
+                                     uint32_t aOffset, bool aIsEndOffset) const
 {
   // From the descendant, go up and get the immediate child of this hypertext.
-  int32_t offset = aOffset;
+  uint32_t offset = aOffset;
   Accessible* descendant = aDescendant;
   while (descendant) {
     Accessible* parent = descendant->Parent();
     if (parent == this)
       return GetChildOffset(descendant) + offset;
 
     // This offset no longer applies because the passed-in text object is not
     // a child of the hypertext. This happens when there are nested hypertexts,
@@ -415,31 +414,31 @@ HyperTextAccessible::OffsetToDOMPoint(in
   NS_ASSERTION(innerOffset == 0 || innerOffset == 1, "A wrong inner offset!");
   nsINode* node = child->GetNode();
   nsINode* parentNode = node->GetParentNode();
   return parentNode ?
     DOMPoint(parentNode, parentNode->IndexOf(node) + innerOffset) :
     DOMPoint();
 }
 
-int32_t
-HyperTextAccessible::FindOffset(int32_t aOffset, nsDirection aDirection,
+uint32_t
+HyperTextAccessible::FindOffset(uint32_t aOffset, nsDirection aDirection,
                                 nsSelectionAmount aAmount,
                                 EWordMovementType aWordMovementType)
 {
   // Find a leaf accessible frame to start with. PeekOffset wants this.
   HyperTextAccessible* text = this;
   Accessible* child = nullptr;
   int32_t innerOffset = aOffset;
 
   do {
     int32_t childIdx = text->GetChildIndexAtOffset(innerOffset);
     NS_ASSERTION(childIdx != -1, "Bad in offset!");
     if (childIdx == -1)
-      return -1;
+      return 0;
 
     child = text->GetChildAt(childIdx);
 
     // HTML list items may need special processing because PeekOffset doesn't
     // work with list bullets.
     if (text->IsHTMLListItem()) {
       HTMLLIAccessible* li = text->AsHTMLListItem();
       if (child == li->Bullet()) {
@@ -463,17 +462,20 @@ HyperTextAccessible::FindOffset(int32_t 
     }
 
     innerOffset -= text->GetChildOffset(childIdx);
 
     text = child->AsHyperText();
   } while (text);
 
   nsIFrame* childFrame = child->GetFrame();
-  NS_ENSURE_TRUE(childFrame, -1);
+  if (!childFrame) {
+    NS_ERROR("No child frame");
+    return 0;
+  }
 
   int32_t innerContentOffset = innerOffset;
   if (child->IsTextLeaf()) {
     NS_ASSERTION(childFrame->GetType() == nsGkAtoms::textFrame, "Wrong frame!");
     RenderedToContentOffset(childFrame, innerOffset, &innerContentOffset);
   }
 
   nsIFrame* frameAtOffset = childFrame;
@@ -492,62 +494,64 @@ HyperTextAccessible::FindOffset(int32_t 
                          aWordMovementType);
   nsresult rv = frameAtOffset->PeekOffset(&pos);
 
   // PeekOffset fails on last/first lines of the text in certain cases.
   if (NS_FAILED(rv) && aAmount == eSelectLine) {
     pos.mAmount = (aDirection == eDirNext) ? eSelectEndLine : eSelectBeginLine;
     frameAtOffset->PeekOffset(&pos);
   }
-  if (!pos.mResultContent)
-    return -1;
+  if (!pos.mResultContent) {
+    NS_ERROR("No result content!");
+    return 0;
+  }
 
   // Turn the resulting DOM point into an offset.
-  int32_t hyperTextOffset = DOMPointToOffset(pos.mResultContent,
-                                             pos.mContentOffset,
-                                             aDirection == eDirNext);
+  uint32_t hyperTextOffset = DOMPointToOffset(pos.mResultContent,
+                                              pos.mContentOffset,
+                                              aDirection == eDirNext);
 
   if (aDirection == eDirPrevious) {
     // If we reached the end during search, this means we didn't find the DOM point
     // and we're actually at the start of the paragraph
     if (hyperTextOffset == CharacterCount())
       return 0;
 
     // PeekOffset stops right before bullet so return 0 to workaround it.
     if (IsHTMLListItem() && aAmount == eSelectBeginLine && hyperTextOffset == 1)
       return 0;
   }
 
   return hyperTextOffset;
 }
 
-int32_t
-HyperTextAccessible::FindLineBoundary(int32_t aOffset,
+uint32_t
+HyperTextAccessible::FindLineBoundary(uint32_t aOffset,
                                       EWhichLineBoundary aWhichLineBoundary)
 {
   // Note: empty last line doesn't have own frame (a previous line contains '\n'
   // character instead) thus when it makes a difference we need to process this
   // case separately (otherwise operations are performed on previous line).
   switch (aWhichLineBoundary) {
     case ePrevLineBegin: {
       // Fetch a previous line and move to its start (as arrow up and home keys
       // were pressed).
       if (IsEmptyLastLineOffset(aOffset))
         return FindOffset(aOffset, eDirPrevious, eSelectBeginLine);
 
-      int32_t tmpOffset = FindOffset(aOffset, eDirPrevious, eSelectLine);
+      uint32_t tmpOffset = FindOffset(aOffset, eDirPrevious, eSelectLine);
       return FindOffset(tmpOffset, eDirPrevious, eSelectBeginLine);
     }
 
     case ePrevLineEnd: {
       if (IsEmptyLastLineOffset(aOffset))
         return aOffset - 1;
 
       // If offset is at first line then return 0 (first line start).
-      int32_t tmpOffset = FindOffset(aOffset, eDirPrevious, eSelectBeginLine);
+      uint32_t tmpOffset = FindOffset(aOffset, eDirPrevious, eSelectBeginLine);
       if (tmpOffset == 0)
         return 0;
 
       // Otherwise move to end of previous line (as arrow up and end keys were
       // pressed).
       tmpOffset = FindOffset(aOffset, eDirPrevious, eSelectLine);
       return FindOffset(tmpOffset, eDirNext, eSelectEndLine);
     }
@@ -567,54 +571,55 @@ HyperTextAccessible::FindLineBoundary(in
       return FindOffset(aOffset, eDirNext, eSelectEndLine);
 
     case eNextLineBegin: {
       if (IsEmptyLastLineOffset(aOffset))
         return aOffset;
 
       // Move to begin of the next line if any (arrow down and home keys),
       // otherwise end of the current line (arrow down only).
-      int32_t tmpOffset = FindOffset(aOffset, eDirNext, eSelectLine);
+      uint32_t tmpOffset = FindOffset(aOffset, eDirNext, eSelectLine);
       if (tmpOffset == CharacterCount())
         return tmpOffset;
 
       return FindOffset(tmpOffset, eDirPrevious, eSelectBeginLine);
     }
 
     case eNextLineEnd: {
       if (IsEmptyLastLineOffset(aOffset))
         return aOffset;
 
       // Move to next line end (as down arrow and end key were pressed).
-      int32_t tmpOffset = FindOffset(aOffset, eDirNext, eSelectLine);
-      if (tmpOffset != CharacterCount())
-        return FindOffset(tmpOffset, eDirNext, eSelectEndLine);
-      return tmpOffset;
+      uint32_t tmpOffset = FindOffset(aOffset, eDirNext, eSelectLine);
+      if (tmpOffset == CharacterCount())
+        return tmpOffset;
+
+      return FindOffset(tmpOffset, eDirNext, eSelectEndLine);
     }
   }
 
-  return -1;
+  return 0;
 }
 
 void
 HyperTextAccessible::TextBeforeOffset(int32_t aOffset,
                                       AccessibleTextBoundary aBoundaryType,
                                       int32_t* aStartOffset, int32_t* aEndOffset,
                                       nsAString& aText)
 {
   *aStartOffset = *aEndOffset = 0;
   aText.Truncate();
 
-  int32_t convertedOffset = ConvertMagicOffset(aOffset);
-  if (convertedOffset < 0) {
+  uint32_t convertedOffset = ConvertMagicOffset(aOffset);
+  if (convertedOffset == std::numeric_limits<uint32_t>::max()) {
     NS_ERROR("Wrong given offset!");
     return;
   }
 
-  int32_t adjustedOffset = convertedOffset;
+  uint32_t adjustedOffset = convertedOffset;
   if (aOffset == nsIAccessibleText::TEXT_OFFSET_CARET)
     adjustedOffset = AdjustCaretOffset(adjustedOffset);
 
   switch (aBoundaryType) {
     case BOUNDARY_CHAR:
       if (convertedOffset != 0)
         CharAt(convertedOffset - 1, aText, aStartOffset, aEndOffset);
       break;
@@ -624,17 +629,17 @@ HyperTextAccessible::TextBeforeOffset(in
       // backward to find a start offset (end offset is the given offset).
       // Otherwise move backward twice to find both start and end offsets.
       if (adjustedOffset == CharacterCount()) {
         *aEndOffset = FindWordBoundary(adjustedOffset, eDirPrevious, eStartWord);
         *aStartOffset = FindWordBoundary(*aEndOffset, eDirPrevious, eStartWord);
       } else {
         *aStartOffset = FindWordBoundary(adjustedOffset, eDirPrevious, eStartWord);
         *aEndOffset = FindWordBoundary(*aStartOffset, eDirNext, eStartWord);
-        if (*aEndOffset != adjustedOffset) {
+        if (*aEndOffset != static_cast<int32_t>(adjustedOffset)) {
           *aEndOffset = *aStartOffset;
           *aStartOffset = FindWordBoundary(*aEndOffset, eDirPrevious, eStartWord);
         }
       }
       TextSubstring(*aStartOffset, *aEndOffset, aText);
       break;
     }
 
@@ -670,18 +675,18 @@ void
 HyperTextAccessible::TextAtOffset(int32_t aOffset,
                                   AccessibleTextBoundary aBoundaryType,
                                   int32_t* aStartOffset, int32_t* aEndOffset,
                                   nsAString& aText)
 {
   *aStartOffset = *aEndOffset = 0;
   aText.Truncate();
 
-  int32_t adjustedOffset = ConvertMagicOffset(aOffset);
-  if (adjustedOffset < 0) {
+  uint32_t adjustedOffset = ConvertMagicOffset(aOffset);
+  if (adjustedOffset == std::numeric_limits<uint32_t>::max()) {
     NS_ERROR("Wrong given offset!");
     return;
   }
 
   switch (aBoundaryType) {
     case BOUNDARY_CHAR:
       // Return no char if caret is at the end of wrapped line (case of no line
       // end character). Returning a next line char is confusing for AT.
@@ -734,23 +739,23 @@ void
 HyperTextAccessible::TextAfterOffset(int32_t aOffset,
                                      AccessibleTextBoundary aBoundaryType,
                                      int32_t* aStartOffset, int32_t* aEndOffset,
                                      nsAString& aText)
 {
   *aStartOffset = *aEndOffset = 0;
   aText.Truncate();
 
-  int32_t convertedOffset = ConvertMagicOffset(aOffset);
-  if (convertedOffset < 0) {
+  uint32_t convertedOffset = ConvertMagicOffset(aOffset);
+  if (convertedOffset == std::numeric_limits<uint32_t>::max()) {
     NS_ERROR("Wrong given offset!");
     return;
   }
 
-  int32_t adjustedOffset = convertedOffset;
+  uint32_t adjustedOffset = convertedOffset;
   if (aOffset == nsIAccessibleText::TEXT_OFFSET_CARET)
     adjustedOffset = AdjustCaretOffset(adjustedOffset);
 
   switch (aBoundaryType) {
     case BOUNDARY_CHAR:
       // If caret is at the end of wrapped line (case of no line end character)
       // then char after the offset is a first char at next line.
       if (adjustedOffset >= CharacterCount())
@@ -771,17 +776,17 @@ HyperTextAccessible::TextAfterOffset(int
       // end offset (start offset is the given offset). Otherwise move forward
       // twice to find both start and end offsets.
       if (convertedOffset == 0) {
         *aStartOffset = FindWordBoundary(convertedOffset, eDirNext, eEndWord);
         *aEndOffset = FindWordBoundary(*aStartOffset, eDirNext, eEndWord);
       } else {
         *aEndOffset = FindWordBoundary(convertedOffset, eDirNext, eEndWord);
         *aStartOffset = FindWordBoundary(*aEndOffset, eDirPrevious, eEndWord);
-        if (*aStartOffset != convertedOffset) {
+        if (*aStartOffset != static_cast<int32_t>(convertedOffset)) {
           *aStartOffset = *aEndOffset;
           *aEndOffset = FindWordBoundary(*aStartOffset, eDirNext, eEndWord);
         }
       }
       TextSubstring(*aStartOffset, *aEndOffset, aText);
       break;
 
     case BOUNDARY_LINE_START:
@@ -807,49 +812,49 @@ HyperTextAccessible::TextAttributes(bool
   // 2. As we get each new attribute, we pass the current start and end offsets
   //    as in/out parameters. In other words, as attributes are collected,
   //    the attribute range itself can only stay the same or get smaller.
 
   *aStartOffset = *aEndOffset = 0;
   nsCOMPtr<nsIPersistentProperties> attributes =
     do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID);
 
-  int32_t offset = ConvertMagicOffset(aOffset);
+  uint32_t offset = ConvertMagicOffset(aOffset);
   Accessible* accAtOffset = GetChildAtOffset(offset);
   if (!accAtOffset) {
     // Offset 0 is correct offset when accessible has empty text. Include
     // default attributes if they were requested, otherwise return empty set.
     if (offset == 0) {
       if (aIncludeDefAttrs) {
         TextAttrsMgr textAttrsMgr(this);
         textAttrsMgr.GetAttributes(attributes);
       }
       return attributes.forget();
     }
     return nullptr;
   }
 
   int32_t accAtOffsetIdx = accAtOffset->IndexInParent();
-  int32_t startOffset = GetChildOffset(accAtOffsetIdx);
-  int32_t endOffset = GetChildOffset(accAtOffsetIdx + 1);
+  uint32_t startOffset = GetChildOffset(accAtOffsetIdx);
+  uint32_t endOffset = GetChildOffset(accAtOffsetIdx + 1);
   int32_t offsetInAcc = offset - startOffset;
 
   TextAttrsMgr textAttrsMgr(this, aIncludeDefAttrs, accAtOffset,
                             accAtOffsetIdx);
   textAttrsMgr.GetAttributes(attributes, &startOffset, &endOffset);
 
   // Compute spelling attributes on text accessible only.
   nsIFrame *offsetFrame = accAtOffset->GetFrame();
   if (offsetFrame && offsetFrame->GetType() == nsGkAtoms::textFrame) {
     int32_t nodeOffset = 0;
     RenderedToContentOffset(offsetFrame, offsetInAcc, &nodeOffset);
 
     // Set 'misspelled' text attribute.
-    GetSpellTextAttribute(accAtOffset->GetNode(), nodeOffset,
-                          &startOffset, &endOffset, attributes);
+    GetSpellTextAttr(accAtOffset->GetNode(), nodeOffset,
+                     &startOffset, &endOffset, attributes);
   }
 
   *aStartOffset = startOffset;
   *aEndOffset = endOffset;
   return attributes.forget();
 }
 
 already_AddRefed<nsIPersistentProperties>
@@ -1019,37 +1024,39 @@ HyperTextAccessible::OffsetAtPoint(int32
 
   return -1; // Not found
 }
 
 nsIntRect
 HyperTextAccessible::TextBounds(int32_t aStartOffset, int32_t aEndOffset,
                                 uint32_t aCoordType)
 {
-  int32_t startOffset = ConvertMagicOffset(aStartOffset);
-  int32_t endOffset = ConvertMagicOffset(aEndOffset);
-  NS_ASSERTION(startOffset < endOffset, "Wrong bad in!");
+  uint32_t startOffset = ConvertMagicOffset(aStartOffset);
+  uint32_t endOffset = ConvertMagicOffset(aEndOffset);
+  NS_ASSERTION(startOffset < endOffset &&
+               endOffset != std::numeric_limits<uint32_t>::max(),
+               "Wrong bad in!");
 
   int32_t childIdx = GetChildIndexAtOffset(startOffset);
   if (childIdx == -1)
     return nsIntRect();
 
   nsIntRect bounds;
   int32_t prevOffset = GetChildOffset(childIdx);
   int32_t offset1 = startOffset - prevOffset;
 
-  while (childIdx < ChildCount()) {
+  while (childIdx < static_cast<int32_t>(ChildCount())) {
     nsIFrame* frame = GetChildAt(childIdx++)->GetFrame();
     if (!frame) {
       NS_NOTREACHED("No frame for a child!");
       continue;
     }
 
     int32_t nextOffset = GetChildOffset(childIdx);
-    if (nextOffset >= endOffset) {
+    if (nextOffset >= static_cast<int32_t>(endOffset)) {
       bounds.UnionRect(bounds, GetBoundsInFrame(frame, offset1,
                                                 endOffset - prevOffset));
       break;
     }
 
     bounds.UnionRect(bounds, GetBoundsInFrame(frame, offset1,
                                               nextOffset - prevOffset));
 
@@ -1356,17 +1363,17 @@ HyperTextAccessible::SelectionBoundsAt(i
                                        int32_t* aEndOffset)
 {
   *aStartOffset = *aEndOffset = 0;
 
   nsTArray<nsRange*> ranges;
   GetSelectionDOMRanges(nsISelectionController::SELECTION_NORMAL, &ranges);
 
   uint32_t rangeCount = ranges.Length();
-  if (aSelectionNum < 0 || aSelectionNum >= rangeCount)
+  if (aSelectionNum < 0 || aSelectionNum >= static_cast<int32_t>(rangeCount))
     return false;
 
   nsRange* range = ranges[aSelectionNum];
 
   // Get start and end points.
   nsINode* startNode = range->GetStartParent();
   nsINode* endNode = range->GetEndParent();
   int32_t startOffset = range->StartOffset(), endOffset = range->EndOffset();
@@ -1389,39 +1396,39 @@ HyperTextAccessible::SelectionBoundsAt(i
   return true;
 }
 
 bool
 HyperTextAccessible::SetSelectionBoundsAt(int32_t aSelectionNum,
                                           int32_t aStartOffset,
                                           int32_t aEndOffset)
 {
-  int32_t startOffset = ConvertMagicOffset(aStartOffset);
-  int32_t endOffset = ConvertMagicOffset(aEndOffset);
+  uint32_t startOffset = ConvertMagicOffset(aStartOffset);
+  uint32_t endOffset = ConvertMagicOffset(aEndOffset);
 
   dom::Selection* domSel = DOMSelection();
   if (!domSel)
     return false;
 
   nsRefPtr<nsRange> range;
   uint32_t rangeCount = domSel->GetRangeCount();
-  if (aSelectionNum == rangeCount)
+  if (aSelectionNum == static_cast<int32_t>(rangeCount))
     range = new nsRange(mContent);
   else
     range = domSel->GetRangeAt(aSelectionNum);
 
   if (!range)
     return false;
 
   if (!OffsetsToDOMRange(startOffset, endOffset, range))
     return false;
 
   // If new range was created then add it, otherwise notify selection listeners
   // that existing selection range was changed.
-  if (aSelectionNum == rangeCount)
+  if (aSelectionNum == static_cast<int32_t>(rangeCount))
     return NS_SUCCEEDED(domSel->AddRange(range));
 
   domSel->RemoveRange(range);
   return NS_SUCCEEDED(domSel->AddRange(range));
 }
 
 bool
 HyperTextAccessible::RemoveFromSelection(int32_t aSelectionNum)
@@ -1796,17 +1803,17 @@ HyperTextAccessible::GetDOMPointByFrameO
                                               Accessible* aAccessible,
                                               DOMPoint* aPoint)
 {
   NS_ENSURE_ARG(aAccessible);
 
   if (!aFrame) {
     // If the given frame is null then set offset after the DOM node of the
     // given accessible.
-    NS_ASSERTION(!aAccessible->IsDoc(), 
+    NS_ASSERTION(!aAccessible->IsDoc(),
                  "Shouldn't be called on document accessible!");
 
     nsIContent* content = aAccessible->GetContent();
     NS_ASSERTION(content, "Shouldn't operate on defunct accessible!");
 
     nsIContent* parent = content->GetParent();
 
     aPoint->idx = parent->IndexOf(content) + 1;
@@ -1832,107 +1839,106 @@ HyperTextAccessible::GetDOMPointByFrameO
     aPoint->idx = parent->IndexOf(content);
     aPoint->node = parent;
   }
 
   return NS_OK;
 }
 
 // HyperTextAccessible
-nsresult
-HyperTextAccessible::GetSpellTextAttribute(nsINode* aNode,
-                                           int32_t aNodeOffset,
-                                           int32_t* aHTStartOffset,
-                                           int32_t* aHTEndOffset,
-                                           nsIPersistentProperties* aAttributes)
+void
+HyperTextAccessible::GetSpellTextAttr(nsINode* aNode,
+                                      int32_t aNodeOffset,
+                                      uint32_t* aStartOffset,
+                                      uint32_t* aEndOffset,
+                                      nsIPersistentProperties* aAttributes)
 {
   nsRefPtr<nsFrameSelection> fs = FrameSelection();
   if (!fs)
-    return NS_OK;
+    return;
 
   dom::Selection* domSel = fs->GetSelection(nsISelectionController::SELECTION_SPELLCHECK);
   if (!domSel)
-    return NS_OK;
+    return;
 
   int32_t rangeCount = domSel->GetRangeCount();
   if (rangeCount <= 0)
-    return NS_OK;
+    return;
 
-  int32_t startHTOffset = 0, endHTOffset = 0;
+  int32_t startOffset = 0, endOffset = 0;
   for (int32_t idx = 0; idx < rangeCount; idx++) {
     nsRange* range = domSel->GetRangeAt(idx);
     if (range->Collapsed())
       continue;
 
     // See if the point comes after the range in which case we must continue in
     // case there is another range after this one.
     nsINode* endNode = range->GetEndParent();
-    int32_t endOffset = range->EndOffset();
-    if (nsContentUtils::ComparePoints(aNode, aNodeOffset, endNode, endOffset) >= 0)
+    int32_t endNodeOffset = range->EndOffset();
+    if (nsContentUtils::ComparePoints(aNode, aNodeOffset,
+                                      endNode, endNodeOffset) >= 0)
       continue;
 
     // At this point our point is either in this range or before it but after
     // the previous range.  So we check to see if the range starts before the
     // point in which case the point is in the missspelled range, otherwise it
     // must be before the range and after the previous one if any.
     nsINode* startNode = range->GetStartParent();
-    int32_t startOffset = range->StartOffset();
-    if (nsContentUtils::ComparePoints(startNode, startOffset, aNode,
+    int32_t startNodeOffset = range->StartOffset();
+    if (nsContentUtils::ComparePoints(startNode, startNodeOffset, aNode,
                                       aNodeOffset) <= 0) {
-      startHTOffset = DOMPointToOffset(startNode, startOffset);
+      startOffset = DOMPointToOffset(startNode, startNodeOffset);
 
-      endHTOffset = DOMPointToOffset(endNode, endOffset);
+      endOffset = DOMPointToOffset(endNode, endNodeOffset);
 
-      if (startHTOffset > *aHTStartOffset)
-        *aHTStartOffset = startHTOffset;
+      if (startOffset > *aStartOffset)
+        *aStartOffset = startOffset;
 
-      if (endHTOffset < *aHTEndOffset)
-        *aHTEndOffset = endHTOffset;
+      if (endOffset < *aEndOffset)
+        *aEndOffset = endOffset;
 
       if (aAttributes) {
         nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid,
                                NS_LITERAL_STRING("spelling"));
       }
 
-      return NS_OK;
+      return;
     }
 
     // This range came after the point.
-    endHTOffset = DOMPointToOffset(startNode, startOffset);
+    endOffset = DOMPointToOffset(startNode, startNodeOffset);
 
     if (idx > 0) {
       nsRange* prevRange = domSel->GetRangeAt(idx - 1);
-      startHTOffset = DOMPointToOffset(prevRange->GetEndParent(),
-                                       prevRange->EndOffset());
+      startOffset = DOMPointToOffset(prevRange->GetEndParent(),
+                                     prevRange->EndOffset());
     }
 
-    if (startHTOffset > *aHTStartOffset)
-      *aHTStartOffset = startHTOffset;
+    if (startOffset > *aStartOffset)
+      *aStartOffset = startOffset;
 
-    if (endHTOffset < *aHTEndOffset)
-      *aHTEndOffset = endHTOffset;
+    if (endOffset < *aEndOffset)
+      *aEndOffset = endOffset;
 
-    return NS_OK;
+    return;
   }
 
   // We never found a range that ended after the point, therefore we know that
   // the point is not in a range, that we do not need to compute an end offset,
   // and that we should use the end offset of the last range to compute the
   // start offset of the text attribute range.
   nsRange* prevRange = domSel->GetRangeAt(rangeCount - 1);
-  startHTOffset = DOMPointToOffset(prevRange->GetEndParent(),
-                                   prevRange->EndOffset());
+  startOffset = DOMPointToOffset(prevRange->GetEndParent(),
+                                 prevRange->EndOffset());
 
-  if (startHTOffset > *aHTStartOffset)
-    *aHTStartOffset = startHTOffset;
-
-  return NS_OK;
+  if (startOffset > *aStartOffset)
+    *aStartOffset = startOffset;
 }
 
-bool 
+bool
 HyperTextAccessible::IsTextRole()
 {
   if (mRoleMapEntry &&
       (mRoleMapEntry->role == roles::GRAPHIC ||
        mRoleMapEntry->role == roles::IMAGE_MAP ||
        mRoleMapEntry->role == roles::SLIDER ||
        mRoleMapEntry->role == roles::PROGRESSBAR ||
        mRoleMapEntry->role == roles::SEPARATOR))
--- a/accessible/src/generic/HyperTextAccessible.h
+++ b/accessible/src/generic/HyperTextAccessible.h
@@ -114,24 +114,24 @@ public:
    * @param aIsEndOffset  [in] if true, then then this offset is not inclusive. The character
    *                       indicated by the offset returned is at [offset - 1]. This means
    *                       if the passed-in offset is really in a descendant, then the offset returned
    *                       will come just after the relevant embedded object characer.
    *                       If false, then the offset is inclusive. The character indicated
    *                       by the offset returned is at [offset]. If the passed-in offset in inside a
    *                       descendant, then the returned offset will be on the relevant embedded object char.
    */
-  int32_t DOMPointToOffset(nsINode* aNode, int32_t aNodeOffset,
-                           bool aIsEndOffset = false) const;
+  uint32_t DOMPointToOffset(nsINode* aNode, int32_t aNodeOffset,
+                            bool aIsEndOffset = false) const;
 
   /**
    * Transform the given a11y point into the offset relative this hypertext.
    */
-  int32_t TransformOffset(Accessible* aDescendant, int32_t aOffset,
-                          bool aIsEndOffset) const;
+  uint32_t TransformOffset(Accessible* aDescendant, uint32_t aOffset,
+                           bool aIsEndOffset) const;
 
   /**
    * Convert start and end hypertext offsets into DOM range.
    *
    * @param  aStartOffset  [in] the given start hypertext offset
    * @param  aEndOffset    [in] the given end hypertext offset
    * @param  aRange        [in, out] the range whose bounds to set
    * @return true   if conversion was successful
@@ -411,22 +411,22 @@ protected:
   virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
   virtual void CacheChildren() MOZ_OVERRIDE;
 
   // HyperTextAccessible
 
   /**
    * Transform magic offset into text offset.
    */
-  int32_t ConvertMagicOffset(int32_t aOffset);
+  uint32_t ConvertMagicOffset(int32_t aOffset) const;
 
   /**
    * Adjust an offset the caret stays at to get a text by line boundary.
    */
-  int32_t AdjustCaretOffset(int32_t aOffset) const;
+  uint32_t AdjustCaretOffset(uint32_t aOffset) const;
 
   /**
    * Return true if caret is at end of line.
    */
   bool IsCaretAtEndOfLine() const;
 
   /**
    * Return true if the given offset points to terminal empty line if any.
@@ -435,17 +435,17 @@ protected:
   {
     return aOffset == static_cast<int32_t>(CharacterCount()) &&
       IsLineEndCharAt(aOffset - 1);
   }
 
   /**
    * Return an offset of the found word boundary.
    */
-  int32_t FindWordBoundary(int32_t aOffset, nsDirection aDirection,
+  uint32_t FindWordBoundary(uint32_t aOffset, nsDirection aDirection,
                            EWordMovementType aWordMovementType)
   {
     return FindOffset(aOffset, aDirection, eSelectWord, aWordMovementType);
   }
 
   /**
    * Used to get begin/end of previous/this/next line. Note: end of line
    * is an offset right before '\n' character if any, the offset is right after
@@ -459,26 +459,26 @@ protected:
     eThisLineEnd,
     eNextLineBegin,
     eNextLineEnd
   };
 
   /**
    * Return an offset for requested line boundary. See constants above.
    */
-  int32_t FindLineBoundary(int32_t aOffset,
-                           EWhichLineBoundary aWhichLineBoundary);
+  uint32_t FindLineBoundary(uint32_t aOffset,
+                            EWhichLineBoundary aWhichLineBoundary);
 
   /**
    * Return an offset corresponding to the given direction and selection amount
    * relative the given offset. A helper used to find word or line boundaries.
    */
-  int32_t FindOffset(int32_t aOffset, nsDirection aDirection,
-                     nsSelectionAmount aAmount,
-                     EWordMovementType aWordMovementType = eDefaultBehavior);
+  uint32_t FindOffset(uint32_t aOffset, nsDirection aDirection,
+                      nsSelectionAmount aAmount,
+                      EWordMovementType aWordMovementType = eDefaultBehavior);
 
   /**
    * Return the boundaries of the substring in case of textual frame or
    * frame boundaries in case of non textual frame, offsets are ignored.
    */
   nsIntRect GetBoundsInFrame(nsIFrame* aFrame,
                              uint32_t aStartRenderedOffset,
                              uint32_t aEndRenderedOffset);
@@ -511,20 +511,19 @@ protected:
    *
    * @param aIncludeDefAttrs  [in] points whether text attributes having default
    *                          values of attributes should be included
    * @param aSourceNode       [in] the node we start to traverse from
    * @param aStartOffset      [in, out] the start offset
    * @param aEndOffset        [in, out] the end offset
    * @param aAttributes       [out, optional] result attributes
    */
-  nsresult GetSpellTextAttribute(nsINode* aNode, int32_t aNodeOffset,
-                                 int32_t *aStartOffset,
-                                 int32_t *aEndOffset,
-                                 nsIPersistentProperties *aAttributes);
+  void GetSpellTextAttr(nsINode* aNode, int32_t aNodeOffset,
+                        uint32_t* aStartOffset, uint32_t* aEndOffset,
+                        nsIPersistentProperties* aAttributes);
 
 private:
   /**
    * End text offsets array.
    */
   mutable nsTArray<uint32_t> mOffsets;
 };
 
--- a/accessible/src/xul/XULListboxAccessible.cpp
+++ b/accessible/src/xul/XULListboxAccessible.cpp
@@ -243,17 +243,17 @@ XULListboxAccessible::RowCount()
   if(element)
     element->GetItemCount(&itemCount);
 
   return itemCount;
 }
 
 Accessible*
 XULListboxAccessible::CellAt(uint32_t aRowIndex, uint32_t aColumnIndex)
-{ 
+{
   nsCOMPtr<nsIDOMXULSelectControlElement> control =
     do_QueryInterface(mContent);
   NS_ENSURE_TRUE(control, nullptr);
 
   nsCOMPtr<nsIDOMXULSelectControlItemElement> item;
   control->GetItemAtIndex(aRowIndex, getter_AddRefs(item));
   if (!item)
     return nullptr;
@@ -275,17 +275,17 @@ XULListboxAccessible::IsColSelected(uint
     do_QueryInterface(mContent);
   NS_ASSERTION(control,
                "Doesn't implement nsIDOMXULMultiSelectControlElement.");
 
   int32_t selectedrowCount = 0;
   nsresult rv = control->GetSelectedCount(&selectedrowCount);
   NS_ENSURE_SUCCESS(rv, false);
 
-  return selectedrowCount == RowCount();
+  return selectedrowCount == static_cast<int32_t>(RowCount());
 }
 
 bool
 XULListboxAccessible::IsRowSelected(uint32_t aRowIdx)
 {
   nsCOMPtr<nsIDOMXULSelectControlElement> control =
     do_QueryInterface(mContent);
   NS_ASSERTION(control,
@@ -333,17 +333,18 @@ XULListboxAccessible::SelectedColCount()
     do_QueryInterface(mContent);
   NS_ASSERTION(control,
                "Doesn't implement nsIDOMXULMultiSelectControlElement.");
 
   int32_t selectedRowCount = 0;
   nsresult rv = control->GetSelectedCount(&selectedRowCount);
   NS_ENSURE_SUCCESS(rv, 0);
 
-  return selectedRowCount > 0 && selectedRowCount == RowCount() ? ColCount() : 0;
+  return selectedRowCount > 0 &&
+   selectedRowCount == static_cast<int32_t>(RowCount()) ? ColCount() : 0;
 }
 
 uint32_t
 XULListboxAccessible::SelectedRowCount()
 {
   nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
     do_QueryInterface(mContent);
   NS_ASSERTION(control,
@@ -555,17 +556,17 @@ XULListboxAccessible::ContainerWidget() 
     nsCOMPtr<nsIDOMXULMenuListElement> menuListElm =
       do_QueryInterface(mContent->GetParent());
     if (menuListElm) {
       nsCOMPtr<nsIDOMNode> inputElm;
       menuListElm->GetInputField(getter_AddRefs(inputElm));
       if (inputElm) {
         nsCOMPtr<nsINode> inputNode = do_QueryInterface(inputElm);
         if (inputNode) {
-          Accessible* input = 
+          Accessible* input =
             mDoc->GetAccessible(inputNode);
           return input ? input->ContainerWidget() : nullptr;
         }
       }
     }
   }
   return nullptr;
 }
@@ -582,22 +583,22 @@ XULListitemAccessible::
                                       nsGkAtoms::type,
                                       nsGkAtoms::checkbox,
                                       eCaseMatters);
   mType = eXULListItemType;
 }
 
 NS_IMPL_ISUPPORTS_INHERITED0(XULListitemAccessible, Accessible)
 
-Accessible* 
+Accessible*
 XULListitemAccessible::GetListAccessible()
 {
   if (IsDefunct())
     return nullptr;
-  
+
   nsCOMPtr<nsIDOMXULSelectControlItemElement> listItem =
     do_QueryInterface(mContent);
   if (!listItem)
     return nullptr;
 
   nsCOMPtr<nsIDOMXULSelectControlElement> list;
   listItem->GetControl(getter_AddRefs(list));