本文整理汇总了C++中PRInt32函数的典型用法代码示例。如果您正苦于以下问题:C++ PRInt32函数的具体用法?C++ PRInt32怎么用?C++ PRInt32使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PRInt32函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NS_ASSERTION
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;
}
}
}
示例2: printf
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;
}
示例3: strlen
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;
}
示例4: AppendSubString
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));
}
示例5: GetCells
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;
}
示例6: NS_ENSURE_ARG_POINTER
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;
}
示例7: NS_ASSERTION
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;
}
示例8: CreateSamplingRestrictedDrawable
// 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();
}
示例9: do_QueryInterface
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;
}
示例10: SplitDOMWord
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());
}
}
示例11: NotifyElementsForFirstLegendChange
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;
}
示例12: NS_MAX
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;
}
示例13: ConditionDimension
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;
}
示例14: PRInt32
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;
}
示例15: RFindChar2
/**
* 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;
}