Bug 1000465 - fix bunch of warning in accessible module, r=jwei

This commit is contained in:
Alexander Surkov 2014-04-25 22:42:19 -04:00
parent 8094bc38b3
commit 86b35c575d
8 changed files with 152 additions and 153 deletions

View File

@ -198,7 +198,7 @@ AccGroupInfo::NextItemTo(Accessible* aItem)
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 &&

View File

@ -26,8 +26,8 @@ using namespace mozilla::a11y;
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
@ -37,9 +37,9 @@ TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
// 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!");
@ -50,7 +50,7 @@ TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
if (!nsAccUtils::IsEmbeddedObject(currAcc))
break;
(*aStartHTOffset)--;
(*aStartOffset)--;
}
uint32_t childCount = mHyperTextAcc->ChildCount();
@ -60,7 +60,7 @@ TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
if (!nsAccUtils::IsEmbeddedObject(currAcc))
break;
(*aEndHTOffset)++;
(*aEndOffset)++;
}
return;
@ -141,12 +141,12 @@ TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
// 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--) {
@ -169,7 +169,7 @@ TextAttrsMgr::GetRange(TextAttr* aAttrArray[], uint32_t aAttrArrayLen,
if (offsetFound)
break;
*(aStartHTOffset) -= nsAccUtils::TextLength(currAcc);
*(aStartOffset) -= nsAccUtils::TextLength(currAcc);
}
// Navigate forward from anchor accessible to find end offset.
@ -194,7 +194,7 @@ TextAttrsMgr::GetRange(TextAttr* aAttrArray[], uint32_t aAttrArrayLen,
if (offsetFound)
break;
(*aEndHTOffset) += nsAccUtils::TextLength(currAcc);
(*aEndOffset) += nsAccUtils::TextLength(currAcc);
}
}

View File

@ -69,8 +69,8 @@ public:
* @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:
/**
@ -85,7 +85,7 @@ protected:
*/
class TextAttr;
void GetRange(TextAttr* aAttrArray[], uint32_t aAttrArrayLen,
int32_t* aStartHTOffset, int32_t* aEndHTOffset);
uint32_t* aStartOffset, uint32_t* aEndOffset);
private:
Accessible* mOffsetAcc;

View File

@ -14,7 +14,7 @@ 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
{
@ -325,7 +325,7 @@ nsAccessiblePivot::MoveNextByText(TextBoundaryType aBoundary, bool* aResult)
// 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;
@ -389,7 +389,7 @@ nsAccessiblePivot::MoveNextByText(TextBoundaryType aBoundary, bool* aResult)
// 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;
@ -517,7 +517,7 @@ nsAccessiblePivot::MovePreviousByText(TextBoundaryType aBoundary, bool* aResult)
// 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;

View File

@ -21,22 +21,15 @@ 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
@ -108,8 +101,8 @@ HyperTextAccessible::PasteText(int32_t aPosition)
}
}
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();
@ -117,11 +110,11 @@ HyperTextAccessible::ConvertMagicOffset(int32_t aOffset)
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

View File

@ -149,10 +149,9 @@ HyperTextAccessible::GetBoundsInFrame(nsIFrame* aFrame,
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
@ -192,8 +191,8 @@ HyperTextAccessible::TextSubstring(int32_t aStartOffset, int32_t aEndOffset,
{
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)
@ -234,7 +233,7 @@ HyperTextAccessible::TextSubstring(int32_t aStartOffset, int32_t aEndOffset,
endChild->AppendTextTo(aText, 0, endOffset - endChildOffset);
}
int32_t
uint32_t
HyperTextAccessible::DOMPointToOffset(nsINode* aNode, int32_t aNodeOffset,
bool aIsEndOffset) const
{
@ -256,7 +255,7 @@ HyperTextAccessible::DOMPointToOffset(nsINode* aNode, int32_t aNodeOffset,
nsresult rv = ContentToRenderedOffset(frame, aNodeOffset, &offset);
NS_ENSURE_SUCCESS(rv, 0);
// Get the child node and
findNode = aNode;
} else {
@ -279,7 +278,7 @@ HyperTextAccessible::DOMPointToOffset(nsINode* aNode, int32_t aNodeOffset,
// 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;
@ -319,12 +318,12 @@ HyperTextAccessible::DOMPointToOffset(nsINode* aNode, int32_t aNodeOffset,
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();
@ -420,8 +419,8 @@ HyperTextAccessible::OffsetToDOMPoint(int32_t aOffset)
DOMPoint();
}
int32_t
HyperTextAccessible::FindOffset(int32_t aOffset, nsDirection aDirection,
uint32_t
HyperTextAccessible::FindOffset(uint32_t aOffset, nsDirection aDirection,
nsSelectionAmount aAmount,
EWordMovementType aWordMovementType)
{
@ -434,7 +433,7 @@ HyperTextAccessible::FindOffset(int32_t aOffset, nsDirection aDirection,
int32_t childIdx = text->GetChildIndexAtOffset(innerOffset);
NS_ASSERTION(childIdx != -1, "Bad in offset!");
if (childIdx == -1)
return -1;
return 0;
child = text->GetChildAt(childIdx);
@ -468,7 +467,10 @@ HyperTextAccessible::FindOffset(int32_t aOffset, nsDirection aDirection,
} 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()) {
@ -497,11 +499,13 @@ HyperTextAccessible::FindOffset(int32_t aOffset, nsDirection aDirection,
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,
uint32_t hyperTextOffset = DOMPointToOffset(pos.mResultContent,
pos.mContentOffset,
aDirection == eDirNext);
@ -519,8 +523,8 @@ HyperTextAccessible::FindOffset(int32_t aOffset, nsDirection aDirection,
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'
@ -533,7 +537,7 @@ HyperTextAccessible::FindLineBoundary(int32_t aOffset,
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);
}
@ -542,7 +546,7 @@ HyperTextAccessible::FindLineBoundary(int32_t 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;
@ -572,7 +576,7 @@ HyperTextAccessible::FindLineBoundary(int32_t 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;
@ -584,14 +588,15 @@ HyperTextAccessible::FindLineBoundary(int32_t 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);
uint32_t tmpOffset = FindOffset(aOffset, eDirNext, eSelectLine);
if (tmpOffset == CharacterCount())
return tmpOffset;
return FindOffset(tmpOffset, eDirNext, eSelectEndLine);
}
}
return -1;
return 0;
}
void
@ -603,13 +608,13 @@ HyperTextAccessible::TextBeforeOffset(int32_t aOffset,
*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);
@ -629,7 +634,7 @@ HyperTextAccessible::TextBeforeOffset(int32_t aOffset,
} 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);
}
@ -675,8 +680,8 @@ HyperTextAccessible::TextAtOffset(int32_t aOffset,
*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;
}
@ -739,13 +744,13 @@ HyperTextAccessible::TextAfterOffset(int32_t aOffset,
*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);
@ -776,7 +781,7 @@ HyperTextAccessible::TextAfterOffset(int32_t aOffset,
} 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);
}
@ -812,7 +817,7 @@ HyperTextAccessible::TextAttributes(bool aIncludeDefAttrs, int32_t aOffset,
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
@ -828,8 +833,8 @@ HyperTextAccessible::TextAttributes(bool aIncludeDefAttrs, int32_t aOffset,
}
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,
@ -843,7 +848,7 @@ HyperTextAccessible::TextAttributes(bool aIncludeDefAttrs, int32_t aOffset,
RenderedToContentOffset(offsetFrame, offsetInAcc, &nodeOffset);
// Set 'misspelled' text attribute.
GetSpellTextAttribute(accAtOffset->GetNode(), nodeOffset,
GetSpellTextAttr(accAtOffset->GetNode(), nodeOffset,
&startOffset, &endOffset, attributes);
}
@ -1024,9 +1029,11 @@ 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)
@ -1036,7 +1043,7 @@ HyperTextAccessible::TextBounds(int32_t aStartOffset, int32_t aEndOffset,
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!");
@ -1044,7 +1051,7 @@ HyperTextAccessible::TextBounds(int32_t aStartOffset, int32_t aEndOffset,
}
int32_t nextOffset = GetChildOffset(childIdx);
if (nextOffset >= endOffset) {
if (nextOffset >= static_cast<int32_t>(endOffset)) {
bounds.UnionRect(bounds, GetBoundsInFrame(frame, offset1,
endOffset - prevOffset));
break;
@ -1361,7 +1368,7 @@ HyperTextAccessible::SelectionBoundsAt(int32_t aSelectionNum,
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];
@ -1394,8 +1401,8 @@ 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)
@ -1403,7 +1410,7 @@ HyperTextAccessible::SetSelectionBoundsAt(int32_t aSelectionNum,
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);
@ -1416,7 +1423,7 @@ HyperTextAccessible::SetSelectionBoundsAt(int32_t aSelectionNum,
// 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);
@ -1837,26 +1844,26 @@ HyperTextAccessible::GetDOMPointByFrameOffset(nsIFrame* aFrame, int32_t aOffset,
}
// HyperTextAccessible
nsresult
HyperTextAccessible::GetSpellTextAttribute(nsINode* aNode,
void
HyperTextAccessible::GetSpellTextAttr(nsINode* aNode,
int32_t aNodeOffset,
int32_t* aHTStartOffset,
int32_t* aHTEndOffset,
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())
@ -1865,8 +1872,9 @@ HyperTextAccessible::GetSpellTextAttribute(nsINode* aNode,
// 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
@ -1874,43 +1882,43 @@ HyperTextAccessible::GetSpellTextAttribute(nsINode* aNode,
// 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(),
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
@ -1918,13 +1926,11 @@ HyperTextAccessible::GetSpellTextAttribute(nsINode* aNode,
// 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(),
startOffset = DOMPointToOffset(prevRange->GetEndParent(),
prevRange->EndOffset());
if (startHTOffset > *aHTStartOffset)
*aHTStartOffset = startHTOffset;
return NS_OK;
if (startOffset > *aStartOffset)
*aStartOffset = startOffset;
}
bool

View File

@ -119,13 +119,13 @@ public:
* 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,
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,
uint32_t TransformOffset(Accessible* aDescendant, uint32_t aOffset,
bool aIsEndOffset) const;
/**
@ -416,12 +416,12 @@ protected:
/**
* 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.
@ -440,7 +440,7 @@ protected:
/**
* 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);
@ -464,14 +464,14 @@ protected:
/**
* Return an offset for requested line boundary. See constants above.
*/
int32_t FindLineBoundary(int32_t aOffset,
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,
uint32_t FindOffset(uint32_t aOffset, nsDirection aDirection,
nsSelectionAmount aAmount,
EWordMovementType aWordMovementType = eDefaultBehavior);
@ -516,9 +516,8 @@ protected:
* @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,
void GetSpellTextAttr(nsINode* aNode, int32_t aNodeOffset,
uint32_t* aStartOffset, uint32_t* aEndOffset,
nsIPersistentProperties* aAttributes);
private:

View File

@ -280,7 +280,7 @@ XULListboxAccessible::IsColSelected(uint32_t aColIdx)
nsresult rv = control->GetSelectedCount(&selectedrowCount);
NS_ENSURE_SUCCESS(rv, false);
return selectedrowCount == RowCount();
return selectedrowCount == static_cast<int32_t>(RowCount());
}
bool
@ -338,7 +338,8 @@ XULListboxAccessible::SelectedColCount()
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