void mozTXTToHTMLConv::CompleteAbbreviatedURL(const PRUnichar * aInString, PRInt32 aInLength, const PRUint32 pos, nsString& aOutString) { NS_ASSERTION(PRInt32(pos) < aInLength, "bad args to CompleteAbbreviatedURL, see bug #190851"); if (PRInt32(pos) >= aInLength) return; if (aInString[pos] == '@') { // only pre-pend a mailto url if the string contains a .domain in it.. //i.e. we want to linkify [email protected] but not "let's meet @8pm" nsDependentString inString(aInString, aInLength); if (inString.FindChar('.', pos) != kNotFound) // if we have a '.' after the @ sign.... { aOutString.AssignLiteral("mailto:"); aOutString += aInString; } } else if (aInString[pos] == '.') { if (ItMatchesDelimited(aInString, aInLength, NS_LITERAL_STRING("www.").get(), 4, LT_IGNORE, LT_IGNORE)) { aOutString.AssignLiteral("http://"); aOutString += aInString; } else if (ItMatchesDelimited(aInString,aInLength, NS_LITERAL_STRING("ftp.").get(), 4, LT_IGNORE, LT_IGNORE)) { aOutString.AssignLiteral("ftp://"); aOutString += aInString; } } }
imgFrame::SurfaceWithFormat imgFrame::SurfaceForDrawing(bool aDoPadding, bool aDoPartialDecode, bool aDoTile, const nsIntMargin& aPadding, gfxMatrix& aUserSpaceToImageSpace, gfxRect& aFill, gfxRect& aSubimage, gfxRect& aSourceRect, gfxRect& aImageRect) { gfxIntSize size(PRInt32(aImageRect.Width()), PRInt32(aImageRect.Height())); if (!aDoPadding && !aDoPartialDecode) { NS_ASSERTION(!mSinglePixel, "This should already have been handled"); return SurfaceWithFormat(new gfxSurfaceDrawable(ThebesSurface(), size), mFormat); } gfxRect available = gfxRect(mDecoded.x, mDecoded.y, mDecoded.width, mDecoded.height); if (aDoTile || mSinglePixel) { // Create a temporary surface. // Give this surface an alpha channel because there are // transparent pixels in the padding or undecoded area gfxImageSurface::gfxImageFormat format = gfxASurface::ImageFormatARGB32; nsRefPtr<gfxASurface> surface = gfxPlatform::GetPlatform()->CreateOffscreenSurface(size, gfxImageSurface::ContentFromFormat(format)); if (!surface || surface->CairoStatus()) return SurfaceWithFormat(); // Fill 'available' with whatever we've got gfxContext tmpCtx(surface); tmpCtx.SetOperator(gfxContext::OPERATOR_SOURCE); if (mSinglePixel) { tmpCtx.SetDeviceColor(mSinglePixelColor); } else { tmpCtx.SetSource(ThebesSurface(), gfxPoint(aPadding.left, aPadding.top)); } tmpCtx.Rectangle(available); tmpCtx.Fill(); return SurfaceWithFormat(new gfxSurfaceDrawable(surface, size), format); } // Not tiling, and we have a surface, so we can account for // padding and/or a partial decode just by twiddling parameters. // First, update our user-space fill rect. aSourceRect = aSourceRect.Intersect(available); gfxMatrix imageSpaceToUserSpace = aUserSpaceToImageSpace; imageSpaceToUserSpace.Invert(); aFill = imageSpaceToUserSpace.Transform(aSourceRect); aSubimage = aSubimage.Intersect(available) - gfxPoint(aPadding.left, aPadding.top); aUserSpaceToImageSpace.Multiply(gfxMatrix().Translate(-gfxPoint(aPadding.left, aPadding.top))); aSourceRect = aSourceRect - gfxPoint(aPadding.left, aPadding.top); aImageRect = gfxRect(0, 0, mSize.width, mSize.height); gfxIntSize availableSize(mDecoded.width, mDecoded.height); return SurfaceWithFormat(new gfxSurfaceDrawable(ThebesSurface(), availableSize), mFormat); }
void nsTableColFrame::Dump(PRInt32 aIndent) { char* indent = new char[aIndent + 1]; if (!indent) return; for (PRInt32 i = 0; i < aIndent + 1; i++) { indent[i] = ' '; } indent[aIndent] = 0; printf("%s**START COL DUMP**\n%s colIndex=%d coltype=", indent, indent, mColIndex); nsTableColType colType = GetColType(); switch (colType) { case eColContent: printf(" content "); break; case eColAnonymousCol: printf(" anonymous-column "); break; case eColAnonymousColGroup: printf(" anonymous-colgroup "); break; case eColAnonymousCell: printf(" anonymous-cell "); break; } printf("\nm:%d c:%d(%c) p:%f sm:%d sc:%d sp:%f f:%d", PRInt32(mMinCoord), PRInt32(mPrefCoord), mHasSpecifiedCoord ? 's' : 'u', mPrefPercent, PRInt32(mSpanMinCoord), PRInt32(mSpanPrefCoord), mSpanPrefPercent, PRInt32(GetFinalWidth())); printf("\n%s**END COL DUMP** ", indent); delete [] indent; }
bool mozTXTToHTMLConv::SmilyHit(const PRUnichar * aInString, PRInt32 aLength, bool col0, const char* tagTXT, const char* imageName, nsString& outputHTML, PRInt32& glyphTextLen) { if ( !aInString || !tagTXT || !imageName ) return false; PRInt32 tagLen = strlen(tagTXT); PRUint32 delim = (col0 ? 0 : 1) + tagLen; if ( (col0 || IsSpace(aInString[0])) && ( aLength <= PRInt32(delim) || IsSpace(aInString[delim]) || (aLength > PRInt32(delim + 1) && ( aInString[delim] == '.' || aInString[delim] == ',' || aInString[delim] == ';' || aInString[delim] == '8' || aInString[delim] == '>' || aInString[delim] == '!' || aInString[delim] == '?' ) && IsSpace(aInString[delim + 1])) ) && ItMatchesDelimited(aInString, aLength, NS_ConvertASCIItoUTF16(tagTXT).get(), tagLen, col0 ? LT_IGNORE : LT_DELIMITER, LT_IGNORE) // Note: tests at different pos for LT_IGNORE and LT_DELIMITER ) { if (!col0) { outputHTML.Truncate(); outputHTML.Append(PRUnichar(' ')); } outputHTML.AppendLiteral("<span class=\""); // <span class=" AppendASCIItoUTF16(imageName, outputHTML); // e.g. smiley-frown outputHTML.AppendLiteral("\" title=\""); // " title=" AppendASCIItoUTF16(tagTXT, outputHTML); // smiley tooltip outputHTML.AppendLiteral("\"><span>"); // "><span> AppendASCIItoUTF16(tagTXT, outputHTML); // original text outputHTML.AppendLiteral("</span></span>"); // </span></span> glyphTextLen = (col0 ? 0 : 1) + tagLen; return true; } return false; }
static void AppendSubString(nsAString& aString, nsIContent* aContent, PRUint32 aXPOffset, PRUint32 aXPLength) { NS_ASSERTION(aContent->IsNodeOfType(nsINode::eTEXT), "aContent is not a text node!"); const nsTextFragment* text = aContent->GetText(); if (!text) return; text->AppendTo(aString, PRInt32(aXPOffset), PRInt32(aXPLength)); }
NS_IMETHODIMP nsHTMLTableRowElement::InsertCell(PRInt32 aIndex, nsIDOMHTMLElement** aValue) { *aValue = nsnull; if (aIndex < -1) { return NS_ERROR_DOM_INDEX_SIZE_ERR; } nsCOMPtr<nsIDOMHTMLCollection> cells; GetCells(getter_AddRefs(cells)); PRUint32 cellCount; cells->GetLength(&cellCount); if (aIndex > PRInt32(cellCount)) { return NS_ERROR_DOM_INDEX_SIZE_ERR; } PRBool doInsert = (aIndex < PRInt32(cellCount)) && (aIndex != -1); // create the cell nsCOMPtr<nsINodeInfo> nodeInfo; nsContentUtils::NameChanged(mNodeInfo, nsGkAtoms::td, getter_AddRefs(nodeInfo)); nsCOMPtr<nsIContent> cellContent = NS_NewHTMLTableCellElement(nodeInfo); if (!cellContent) { return NS_ERROR_OUT_OF_MEMORY; } nsCOMPtr<nsIDOMNode> cellNode(do_QueryInterface(cellContent)); NS_ASSERTION(cellNode, "Should implement nsIDOMNode!"); nsCOMPtr<nsIDOMNode> retChild; nsresult rv; if (doInsert) { nsCOMPtr<nsIDOMNode> refCell; cells->Item(aIndex, getter_AddRefs(refCell)); rv = InsertBefore(cellNode, refCell, getter_AddRefs(retChild)); } else { rv = AppendChild(cellNode, getter_AddRefs(retChild)); } if (retChild) { CallQueryInterface(retChild, aValue); } return NS_OK; }
NS_IMETHODIMP nsDOMMouseScrollEvent::GetAxis(PRInt32* aResult) { NS_ENSURE_ARG_POINTER(aResult); if (mEvent->eventStructType == NS_MOUSE_SCROLL_EVENT) { PRUint32 flags = static_cast<nsMouseScrollEvent*>(mEvent)->scrollFlags; *aResult = (flags & nsMouseScrollEvent::kIsHorizontal) ? PRInt32(HORIZONTAL_AXIS) : PRInt32(VERTICAL_AXIS); } else { *aResult = 0; } return NS_OK; }
CharClass WordSplitState::ClassifyCharacter(PRInt32 aIndex, PRBool aRecurse) const { NS_ASSERTION(aIndex >= 0 && aIndex <= PRInt32(mDOMWordText.Length()), "Index out of range"); if (aIndex == PRInt32(mDOMWordText.Length())) return CHAR_CLASS_SEPARATOR; // this will classify the character, we want to treat "ignorable" characters // such as soft hyphens as word characters. nsIUGenCategory::nsUGenCategory charCategory = mWordUtil->GetCategories()->Get(PRUint32(mDOMWordText[aIndex])); if (charCategory == nsIUGenCategory::kLetter || IsIgnorableCharacter(mDOMWordText[aIndex])) return CHAR_CLASS_WORD; // If conditional punctuation is surrounded immediately on both sides by word // characters it also counts as a word character. if (IsConditionalPunctuation(mDOMWordText[aIndex])) { if (!aRecurse) { // not allowed to look around, this punctuation counts like a separator return CHAR_CLASS_SEPARATOR; } // check the left-hand character if (aIndex == 0) return CHAR_CLASS_SEPARATOR; if (ClassifyCharacter(aIndex - 1, false) != CHAR_CLASS_WORD) return CHAR_CLASS_SEPARATOR; // now we know left char is a word-char, check the right-hand character if (aIndex == PRInt32(mDOMWordText.Length()) - 1) return CHAR_CLASS_SEPARATOR; if (ClassifyCharacter(aIndex + 1, false) != CHAR_CLASS_WORD) return CHAR_CLASS_SEPARATOR; // char on either side is a word, this counts as a word return CHAR_CLASS_WORD; } // all other punctuation if (charCategory == nsIUGenCategory::kSeparator || charCategory == nsIUGenCategory::kOther || charCategory == nsIUGenCategory::kPunctuation || charCategory == nsIUGenCategory::kSymbol) return CHAR_CLASS_SEPARATOR; // any other character counts as a word return CHAR_CLASS_WORD; }
// EXTEND_PAD won't help us here; we have to create a temporary surface to hold // the subimage of pixels we're allowed to sample. static already_AddRefed<gfxDrawable> CreateSamplingRestrictedDrawable(gfxDrawable* aDrawable, gfxContext* aContext, const gfxMatrix& aUserSpaceToImageSpace, const gfxRect& aSourceRect, const gfxRect& aSubimage, const gfxImageSurface::gfxImageFormat aFormat) { gfxRect userSpaceClipExtents = aContext->GetClipExtents(); // This isn't optimal --- if aContext has a rotation then GetClipExtents // will have to do a bounding-box computation, and TransformBounds might // too, so we could get a better result if we computed image space clip // extents in one go --- but it doesn't really matter and this is easier // to understand. gfxRect imageSpaceClipExtents = aUserSpaceToImageSpace.TransformBounds(userSpaceClipExtents); // Inflate by one pixel because bilinear filtering will sample at most // one pixel beyond the computed image pixel coordinate. imageSpaceClipExtents.Outset(1.0); gfxRect needed = imageSpaceClipExtents.Intersect(aSourceRect); needed = needed.Intersect(aSubimage); needed.RoundOut(); // if 'needed' is empty, nothing will be drawn since aFill // must be entirely outside the clip region, so it doesn't // matter what we do here, but we should avoid trying to // create a zero-size surface. if (needed.IsEmpty()) return nsnull; gfxIntSize size(PRInt32(needed.Width()), PRInt32(needed.Height())); nsRefPtr<gfxASurface> temp = gfxPlatform::GetPlatform()->CreateOffscreenSurface(size, gfxASurface::ContentFromFormat(aFormat)); if (!temp || temp->CairoStatus()) return nsnull; nsRefPtr<gfxContext> tmpCtx = new gfxContext(temp); tmpCtx->SetOperator(OptimalFillOperator()); aDrawable->Draw(tmpCtx, needed - needed.pos, PR_TRUE, gfxPattern::FILTER_FAST, gfxMatrix().Translate(needed.pos)); nsRefPtr<gfxPattern> resultPattern = new gfxPattern(temp); if (!resultPattern) return nsnull; nsRefPtr<gfxDrawable> drawable = new gfxSurfaceDrawable(temp, size, gfxMatrix().Translate(-needed.pos)); return drawable.forget(); }
NS_IMETHODIMP InsertElementTxn::DoTransaction(void) { #ifdef DEBUG if (gNoisy) { nsCOMPtr<nsIContent>nodeAsContent = do_QueryInterface(mNode); nsCOMPtr<nsIContent>parentAsContent = do_QueryInterface(mParent); nsString namestr; mNode->GetNodeName(namestr); char* nodename = ToNewCString(namestr); printf("%p Do Insert Element of %p <%s> into parent %p at offset %d\n", static_cast<void*>(this), static_cast<void*>(nodeAsContent.get()), nodename, static_cast<void*>(parentAsContent.get()), mOffset); nsMemory::Free(nodename); } #endif NS_ENSURE_TRUE(mNode && mParent, NS_ERROR_NOT_INITIALIZED); nsCOMPtr<nsINode> parent = do_QueryInterface(mParent); NS_ENSURE_STATE(parent); PRUint32 count = parent->GetChildCount(); if (mOffset > PRInt32(count) || mOffset == -1) { // -1 is sentinel value meaning "append at end" mOffset = count; } nsIContent* refContent = parent->GetChildAt(mOffset); // note, it's ok for refNode to be null. that means append nsCOMPtr<nsIDOMNode> refNode = refContent ? refContent->AsDOMNode() : nullptr; mEditor->MarkNodeDirty(mNode); nsCOMPtr<nsIDOMNode> resultNode; nsresult result = mParent->InsertBefore(mNode, refNode, getter_AddRefs(resultNode)); NS_ENSURE_SUCCESS(result, result); NS_ENSURE_TRUE(resultNode, NS_ERROR_NULL_POINTER); // only set selection to insertion point if editor gives permission bool bAdjustSelection; mEditor->ShouldTxnSetSelection(&bAdjustSelection); if (bAdjustSelection) { nsCOMPtr<nsISelection> selection; result = mEditor->GetSelection(getter_AddRefs(selection)); NS_ENSURE_SUCCESS(result, result); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); // place the selection just after the inserted element selection->Collapse(mParent, mOffset+1); } else { // do nothing - dom range gravity will adjust selection } return result; }
void mozInlineSpellWordUtil::BuildRealWords() { // This is pretty simple. We just have to walk mSoftText, tokenizing it // into "real words". // We do an outer traversal of words delimited by IsDOMWordSeparator, calling // SplitDOMWord on each of those DOM words PRInt32 wordStart = -1; mRealWords.Clear(); for (PRInt32 i = 0; i < PRInt32(mSoftText.Length()); ++i) { if (IsDOMWordSeparator(mSoftText.CharAt(i))) { if (wordStart >= 0) { SplitDOMWord(wordStart, i); wordStart = -1; } } else { if (wordStart < 0) { wordStart = i; } } } if (wordStart >= 0) { SplitDOMWord(wordStart, mSoftText.Length()); } }
nsresult nsHTMLFieldSetElement::InsertChildAt(nsIContent* aChild, PRUint32 aIndex, bool aNotify) { bool firstLegendHasChanged = false; if (aChild->IsHTML(nsGkAtoms::legend)) { if (!mFirstLegend) { mFirstLegend = aChild; // We do not want to notify the first time mFirstElement is set. } else { // If mFirstLegend is before aIndex, we do not change it. // Otherwise, mFirstLegend is now aChild. if (PRInt32(aIndex) <= IndexOf(mFirstLegend)) { mFirstLegend = aChild; firstLegendHasChanged = true; } } } nsresult rv = nsGenericHTMLFormElement::InsertChildAt(aChild, aIndex, aNotify); NS_ENSURE_SUCCESS(rv, rv); if (firstLegendHasChanged) { NotifyElementsForFirstLegendChange(aNotify); } return rv; }
nsresult nsDOMWorkerTimeout::FunctionCallback::Run(nsDOMWorkerTimeout* aTimeout, JSContext* aCx) { PRInt32 lateness = NS_MAX(0, PRInt32(PR_Now() - aTimeout->mTargetTime)) / (PRTime)PR_USEC_PER_MSEC; mCallbackArgs[mCallbackArgsLength - 1] = INT_TO_JSVAL(lateness); JSObject* global = JS_GetGlobalObject(aCx); NS_ENSURE_TRUE(global, NS_ERROR_FAILURE); nsTArray<jsval> argv; PRBool success = argv.SetCapacity(mCallbackArgsLength); NS_ENSURE_TRUE(success, NS_ERROR_OUT_OF_MEMORY); for (PRUint32 index = 0; index < mCallbackArgsLength; index++) { argv.AppendElement(mCallbackArgs[index]); } jsval rval; JSBool ok = JS_CallFunctionValue(aCx, global, mCallback, mCallbackArgsLength, argv.Elements(), &rval); NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE); return NS_OK; }
static PRInt32 ConditionDimension(float aValue, PRInt32 aDefault) { // This will exclude NaNs and infinities if (aValue >= 1.0 && aValue <= 10000.0) return PRInt32(NS_round(aValue)); return aDefault; }
bool nsString::EqualsIgnoreCase( const char* aString, PRInt32 aCount ) const { PRUint32 strLen = nsCharTraits<char>::length(aString); PRInt32 maxCount = PRInt32(NS_MIN(mLength, strLen)); PRInt32 compareCount; if (aCount < 0 || aCount > maxCount) compareCount = maxCount; else compareCount = aCount; PRInt32 result = nsBufferRoutines<PRUnichar>::compare(mData, aString, compareCount, true); if (result == 0 && (aCount < 0 || strLen < PRUint32(aCount) || mLength < PRUint32(aCount))) { // Since the caller didn't give us a length to test, or strings shorter // than aCount, and compareCount characters matched, we have to assume // that the longer string is greater. if (mLength != strLen) result = 1; // Arbitrarily using any number != 0 } return result == 0; }
PRInt32 nsCString::Compare( const char* aString, bool aIgnoreCase, PRInt32 aCount ) const { PRUint32 strLen = char_traits::length(aString); PRInt32 maxCount = PRInt32(NS_MIN(mLength, strLen)); PRInt32 compareCount; if (aCount < 0 || aCount > maxCount) compareCount = maxCount; else compareCount = aCount; PRInt32 result = nsBufferRoutines<char>::compare(mData, aString, compareCount, aIgnoreCase); if (result == 0 && (aCount < 0 || strLen < PRUint32(aCount) || mLength < PRUint32(aCount))) { // Since the caller didn't give us a length to test, or strings shorter // than aCount, and compareCount characters matched, we have to assume // that the longer string is greater. if (mLength != strLen) result = (mLength < strLen) ? -1 : 1; } return result; }
/** * This methods cans the given buffer for the given char * * @update gess 3/25/98 * @param aDest is the buffer to be searched * @param aDestLength is the size (in char-units, not bytes) of the buffer * @param anOffset is the start pos to begin searching * @param aChar is the target character we're looking for * @param aCount tells us how many characters to iterate through (which may be different than aLength); -1 means use full length. * @return index of pos if found, else -1 (kNotFound) */ static PRInt32 RFindChar2(const PRUnichar* aDest,PRUint32 aDestLength,PRInt32 anOffset,const PRUnichar aChar,PRInt32 aCount) { if(anOffset < 0) anOffset=(PRInt32)aDestLength-1; if(aCount < 0) aCount = PRInt32(aDestLength); if((0 < aDestLength) && ((PRUint32)anOffset < aDestLength)) { if(0 < aCount) { const PRUnichar* root = aDest; const PRUnichar* rightmost = root + anOffset; const PRUnichar* min = rightmost - aCount + 1; const PRUnichar* leftmost = (min<root) ? root: min; while(leftmost <= rightmost){ if((*rightmost) == aChar) return rightmost - root; --rightmost; } } } return kNotFound; }
static PRInt32 RFindChar1(const char* aDest,PRUint32 aDestLength,PRInt32 anOffset,const PRUnichar aChar,PRInt32 aCount) { if(anOffset < 0) anOffset=(PRInt32)aDestLength-1; if(aCount < 0) aCount = PRInt32(aDestLength); if((aChar<256) && (0 < aDestLength) && ((PRUint32)anOffset < aDestLength)) { //We'll only search if the given aChar is within the normal ascii a range, //(Since this string is definitely within the ascii range). if(0 < aCount) { const char* rightmost = aDest + anOffset; const char* min = rightmost - aCount + 1; const char* leftmost = (min<aDest) ? aDest: min; char theChar=(char)aChar; while(leftmost <= rightmost){ if((*rightmost) == theChar) return rightmost - aDest; --rightmost; } } } return kNotFound; }
nsTemplateCondition::nsTemplateCondition(nsIAtom* aSourceVariable, const nsAString& aRelation, const nsAString& aTargets, bool aIgnoreCase, bool aNegate, bool aIsMultiple) : mSourceVariable(aSourceVariable), mIgnoreCase(aIgnoreCase), mNegate(aNegate), mNext(nullptr) { SetRelation(aRelation); if (aIsMultiple) { PRInt32 start = 0, end = 0; while ((end = aTargets.FindChar(',',start)) >= 0) { if (end > start) { mTargetList.AppendElement(Substring(aTargets, start, end - start)); } start = end + 1; } if (start < PRInt32(aTargets.Length())) { mTargetList.AppendElement(Substring(aTargets, start)); } } else { mTargetList.AppendElement(aTargets); } MOZ_COUNT_CTOR(nsTemplateCondition); }
bool sbRunnable::Wait(PRIntervalTime aTimeout) { // Compute a fixed expiration time that won't drift: const PRIntervalTime expiry = PR_IntervalNow() + aTimeout; // Enter the monitor to check the done flag: mozilla::ReentrantMonitorAutoEnter lock(mMonitor); // Only wait for Run() to complete if asked: if (aTimeout != PR_INTERVAL_NO_WAIT) { // Loop every time the monitor is signaled, until done // or timed out: while (!mDone) { // Compute how long to wait: indefinitely if PR_INTERVAL_NO_TIMEOUT // was given, or the time remaining until the fixed expiration time, // otherwise. PRIntervalTime timeout; if (aTimeout == PR_INTERVAL_NO_TIMEOUT) { timeout = PR_INTERVAL_NO_TIMEOUT; } else { timeout = expiry - PR_IntervalNow(); if (PRInt32(timeout) <= 0) { break; } } // Wait for a signal from Run(), or until timed out mMonitor.Wait(timeout); } } // Return the done flag: return mDone; }
nsSystemPrincipal::AddRef() { NS_PRECONDITION(PRInt32(refcount) >= 0, "illegal refcnt"); nsrefcnt count = PR_ATOMIC_INCREMENT(&refcount); NS_LOG_ADDREF(this, count, "nsSystemPrincipal", sizeof(*this)); return count; }
nsresult nsLoggingSink::QuoteText(const nsAString& aValue, nsString& aResult) { aResult.Truncate(); /* if you're stepping through the string anyway, why not use iterators instead of forcing the string to copy? */ const nsPromiseFlatString& flat = PromiseFlatString(aValue); const PRUnichar* cp = flat.get(); const PRUnichar* end = cp + aValue.Length(); while (cp < end) { PRUnichar ch = *cp++; if (ch == '"') { aResult.AppendLiteral("""); } else if (ch == '&') { aResult.AppendLiteral("&"); } else if ((ch < 32) || (ch >= 127)) { aResult.AppendLiteral("&#"); aResult.AppendInt(PRInt32(ch), 10); aResult.Append(PRUnichar(';')); } else { aResult.Append(ch); } } return NS_OK; }
static PRInt32 ConditionDimension(float aValue) { // This will exclude NaNs and too-big values. if (aValue > 1.0 && aValue <= PR_INT32_MAX) return PRInt32(NS_round(aValue)); return 0; }
nsresult mozInlineSpellWordUtil::GetNextWord(nsAString& aText, nsIDOMRange** aRange, PRBool* aSkipChecking) { #ifdef DEBUG_SPELLCHECK printf("GetNextWord called; mNextWordIndex=%d\n", mNextWordIndex); #endif if (mNextWordIndex < 0 || mNextWordIndex >= PRInt32(mRealWords.Length())) { mNextWordIndex = -1; *aRange = nsnull; *aSkipChecking = PR_TRUE; return NS_OK; } const RealWord& word = mRealWords[mNextWordIndex]; nsresult rv = MakeRangeForWord(word, aRange); NS_ENSURE_SUCCESS(rv, rv); ++mNextWordIndex; *aSkipChecking = !word.mCheckableWord; ::NormalizeWord(mSoftText, word.mSoftTextOffset, word.mLength, aText); #ifdef DEBUG_SPELLCHECK printf("GetNextWord returning: %s (skip=%d)\n", NS_ConvertUTF16toUTF8(aText).get(), *aSkipChecking); #endif return NS_OK; }
nsSystemPrincipal::AddRef() { NS_PRECONDITION(PRInt32(mJSPrincipals.refcount) >= 0, "illegal refcnt"); nsrefcnt count = PR_AtomicIncrement((PRInt32 *)&mJSPrincipals.refcount); NS_LOG_ADDREF(this, count, "nsSystemPrincipal", sizeof(*this)); return count; }
const char * nsSaveAsCharset::GetNextCharset() { if ((mCharsetListIndex + 1) >= PRInt32(mCharsetList.Length())) return nullptr; // bump the index and return the next charset return mCharsetList[++mCharsetListIndex].get(); }
static PRInt32 GetInt(nsFrameUtil::Tag* aTag, char* aAttr) { char* value = aTag->GetAttr(aAttr); if (nsnull != value) { return PRInt32( atoi(value) ); } return 0; }
NS_IMETHODIMP_(nsrefcnt) xpctestNoisy::AddRef(void) { NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt"); ++mRefCnt; NS_LOG_ADDREF(this, mRefCnt, "xpctestNoisy", sizeof(*this)); printf("Noisy %d - incremented refcount to %d\n", mID, mRefCnt.get()); return mRefCnt; }
NS_IMETHODIMP_(nsrefcnt) nsPrintProgress::AddRef(void) { NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt"); nsrefcnt count; count = NS_AtomicIncrementRefcnt(mRefCnt); //NS_LOG_ADDREF(this, count, "nsPrintProgress", sizeof(*this)); return count; }
//NS_IMPL_ISUPPORTS(npAPInsIInputStreamShim, NS_GET_IID(nsIInputStream)) NS_IMETHODIMP_(nsrefcnt) npAPInsIInputStreamShim::AddRef(void) { NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt"); // Note that we intentionally don't check for owning thread safety. ++mRefCnt; NS_LOG_ADDREF(this, mRefCnt, "npAPInsIInputStreamShim", sizeof(*this)); return mRefCnt; }