PRInt32 CaseInsensitiveCompare(const char *aLeft, const char *aRight, PRUint32 aLeftBytes, PRUint32 aRightBytes) { const char *leftEnd = aLeft + aLeftBytes; const char *rightEnd = aRight + aRightBytes; while (aLeft < leftEnd && aRight < rightEnd) { PRUint32 leftChar = GetLowerUTF8Codepoint(aLeft, leftEnd, &aLeft); if (NS_UNLIKELY(leftChar == PRUint32(-1))) return -1; PRUint32 rightChar = GetLowerUTF8Codepoint(aRight, rightEnd, &aRight); if (NS_UNLIKELY(rightChar == PRUint32(-1))) return -1; // Now leftChar and rightChar are lower-case, so we can compare them. if (leftChar != rightChar) { if (leftChar > rightChar) return 1; return -1; } } // Make sure that if one string is longer than the other we return the // correct result. if (aLeft < leftEnd) return 1; if (aRight < rightEnd) return -1; return 0; }
bool CaseInsensitiveUTF8CharsEqual(const char* aLeft, const char* aRight, const char* aLeftEnd, const char* aRightEnd, const char** aLeftNext, const char** aRightNext, bool* aErr) { NS_ASSERTION(aLeftNext, "Out pointer shouldn't be null."); NS_ASSERTION(aRightNext, "Out pointer shouldn't be null."); NS_ASSERTION(aErr, "Out pointer shouldn't be null."); NS_ASSERTION(aLeft < aLeftEnd, "aLeft must be less than aLeftEnd."); NS_ASSERTION(aRight < aRightEnd, "aRight must be less than aRightEnd."); PRUint32 leftChar = GetLowerUTF8Codepoint(aLeft, aLeftEnd, aLeftNext); if (NS_UNLIKELY(leftChar == PRUint32(-1))) { *aErr = true; return false; } PRUint32 rightChar = GetLowerUTF8Codepoint(aRight, aRightEnd, aRightNext); if (NS_UNLIKELY(rightChar == PRUint32(-1))) { *aErr = true; return false; } // Can't have an error past this point. *aErr = false; return leftChar == rightChar; }
// Returns true if an image of aWidth x aHeight is allowed and legal. static bool AllowedImageSize(PRInt32 aWidth, PRInt32 aHeight) { // reject over-wide or over-tall images const PRInt32 k64KLimit = 0x0000FFFF; if (NS_UNLIKELY(aWidth > k64KLimit || aHeight > k64KLimit )) { NS_WARNING("image too big"); return PR_FALSE; } // protect against invalid sizes if (NS_UNLIKELY(aHeight <= 0 || aWidth <= 0)) { return PR_FALSE; } // check to make sure we don't overflow a 32-bit PRInt32 tmp = aWidth * aHeight; if (NS_UNLIKELY(tmp / aHeight != aWidth)) { NS_WARNING("width or height too large"); return PR_FALSE; } tmp = tmp * 4; if (NS_UNLIKELY(tmp / 4 != aWidth * aHeight)) { NS_WARNING("width or height too large"); return PR_FALSE; } #if defined(XP_MACOSX) // CoreGraphics is limited to images < 32K in *height*, so clamp all surfaces on the Mac to that height if (NS_UNLIKELY(aHeight > SHRT_MAX)) { NS_WARNING("image too big"); return PR_FALSE; } #endif return PR_TRUE; }
/* void getInterfaces (out PRUint32 count, [array, size_is (count), retval] out nsIIDPtr array); */ NS_IMETHODIMP WSPProxy::GetInterfaces(PRUint32 *count, nsIID * **array) { if (!mIID) { return NS_ERROR_NOT_INITIALIZED; } *count = 2; nsIID** iids = static_cast<nsIID**>(nsMemory::Alloc(2 * sizeof(nsIID*))); if (!iids) { return NS_ERROR_OUT_OF_MEMORY; } iids[0] = static_cast<nsIID *>(nsMemory::Clone(mIID, sizeof(nsIID))); if (NS_UNLIKELY(!iids[0])) { NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(0, iids); return NS_ERROR_OUT_OF_MEMORY; } const nsIID& wsiid = NS_GET_IID(nsIWebServiceProxy); iids[1] = static_cast<nsIID *>(nsMemory::Clone(&wsiid, sizeof(nsIID))); if (NS_UNLIKELY(!iids[1])) { NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(1, iids); return NS_ERROR_OUT_OF_MEMORY; } *array = iids; return NS_OK; }
NS_IMETHODIMP TelemetryImpl::GetHistogramById(const nsACString &name, JSContext *cx, jsval *ret) { // Cache names // Note the histogram names are statically allocated if (!mHistogramMap.Count()) { for (PRUint32 i = 0; i < Telemetry::HistogramCount; i++) { CharPtrEntryType *entry = mHistogramMap.PutEntry(gHistograms[i].id); if (NS_UNLIKELY(!entry)) { mHistogramMap.Clear(); return NS_ERROR_OUT_OF_MEMORY; } entry->mData = (Telemetry::ID) i; } } CharPtrEntryType *entry = mHistogramMap.GetEntry(PromiseFlatCString(name).get()); if (!entry) return NS_ERROR_FAILURE; Histogram *h; nsresult rv = GetHistogramByEnumId(entry->mData, &h); if (NS_FAILED(rv)) return rv; return WrapAndReturnHistogram(h, cx, ret); }
void TelemetryImpl::RecordSlowStatement(const nsACString &statement, const nsACString &dbName, PRUint32 delay) { if (!sTelemetry) { // Make the service manager hold a long-lived reference to the service nsCOMPtr<nsITelemetry> telemetryService = do_GetService("@mozilla.org/base/telemetry;1"); if (!telemetryService || !sTelemetry) return; } if (!sTelemetry->mCanRecord || !sTelemetry->mTrackedDBs.GetEntry(dbName)) return; nsTHashtable<SlowSQLEntryType> *slowSQLMap = NULL; if (NS_IsMainThread()) slowSQLMap = &(sTelemetry->mSlowSQLOnMainThread); else slowSQLMap = &(sTelemetry->mSlowSQLOnOtherThread); MutexAutoLock hashMutex(sTelemetry->mHashMutex); SlowSQLEntryType *entry = slowSQLMap->GetEntry(statement); if (!entry) { entry = slowSQLMap->PutEntry(statement); if (NS_UNLIKELY(!entry)) return; entry->mData.hitCount = 0; entry->mData.totalTime = 0; } entry->mData.hitCount++; entry->mData.totalTime += delay; }
void TelemetryImpl::RecordSlowStatement(const nsACString &statement, const nsACString &dbName, PRUint32 delay) { MOZ_ASSERT(sTelemetry); if (!sTelemetry->mCanRecord || !sTelemetry->mTrackedDBs.GetEntry(dbName)) return; AutoHashtable<SlowSQLEntryType> *slowSQLMap = NULL; if (NS_IsMainThread()) slowSQLMap = &(sTelemetry->mSlowSQLOnMainThread); else slowSQLMap = &(sTelemetry->mSlowSQLOnOtherThread); MutexAutoLock hashMutex(sTelemetry->mHashMutex); SlowSQLEntryType *entry = slowSQLMap->GetEntry(statement); if (!entry) { entry = slowSQLMap->PutEntry(statement); if (NS_UNLIKELY(!entry)) return; entry->mData.hitCount = 0; entry->mData.totalTime = 0; } entry->mData.hitCount++; entry->mData.totalTime += delay; }
const gfxFont::Metrics& gfxFT2FontBase::GetMetrics() { if (mHasMetrics) return mMetrics; if (NS_UNLIKELY(GetStyle()->size <= 0.0)) { new(&mMetrics) gfxFont::Metrics(); // zero initialize mSpaceGlyph = 0; } else { gfxFT2LockedFace(this).GetMetrics(&mMetrics, &mSpaceGlyph); } SanitizeMetrics(&mMetrics, PR_FALSE); #if 0 // printf("font name: %s %f\n", NS_ConvertUTF16toUTF8(GetName()).get(), GetStyle()->size); // printf ("pango font %s\n", pango_font_description_to_string (pango_font_describe (font))); fprintf (stderr, "Font: %s\n", NS_ConvertUTF16toUTF8(GetName()).get()); fprintf (stderr, " emHeight: %f emAscent: %f emDescent: %f\n", mMetrics.emHeight, mMetrics.emAscent, mMetrics.emDescent); fprintf (stderr, " maxAscent: %f maxDescent: %f\n", mMetrics.maxAscent, mMetrics.maxDescent); fprintf (stderr, " internalLeading: %f externalLeading: %f\n", mMetrics.externalLeading, mMetrics.internalLeading); fprintf (stderr, " spaceWidth: %f aveCharWidth: %f xHeight: %f\n", mMetrics.spaceWidth, mMetrics.aveCharWidth, mMetrics.xHeight); fprintf (stderr, " uOff: %f uSize: %f stOff: %f stSize: %f suOff: %f suSize: %f\n", mMetrics.underlineOffset, mMetrics.underlineSize, mMetrics.strikeoutOffset, mMetrics.strikeoutSize, mMetrics.superscriptOffset, mMetrics.subscriptOffset); #endif mHasMetrics = PR_TRUE; return mMetrics; }
void TelemetryImpl::StoreSlowSQL(const nsACString &sql, uint32_t delay, bool isDynamicSql, bool isTrackedDB, bool isAggregate) { AutoHashtable<SlowSQLEntryType> *slowSQLMap = NULL; if (NS_IsMainThread()) slowSQLMap = &(sTelemetry->mSlowSQLOnMainThread); else slowSQLMap = &(sTelemetry->mSlowSQLOnOtherThread); MutexAutoLock hashMutex(sTelemetry->mHashMutex); SlowSQLEntryType *entry = slowSQLMap->GetEntry(sql); if (!entry) { entry = slowSQLMap->PutEntry(sql); if (NS_UNLIKELY(!entry)) return; entry->mData.isDynamicSql = isDynamicSql; entry->mData.isTrackedDb = isTrackedDB; entry->mData.isAggregate = isAggregate; entry->mData.hitCount = 0; entry->mData.totalTime = 0; } entry->mData.hitCount++; entry->mData.totalTime += delay; }
void tableInterfaceInitCB(AtkTableIface* aIface) { NS_ASSERTION(aIface, "no interface!"); if (NS_UNLIKELY(!aIface)) return; aIface->ref_at = refAtCB; aIface->get_index_at = getIndexAtCB; aIface->get_column_at_index = getColumnAtIndexCB; aIface->get_row_at_index = getRowAtIndexCB; aIface->get_n_columns = getColumnCountCB; aIface->get_n_rows = getRowCountCB; aIface->get_column_extent_at = getColumnExtentAtCB; aIface->get_row_extent_at = getRowExtentAtCB; aIface->get_caption = getCaptionCB; aIface->get_column_description = getColumnDescriptionCB; aIface->get_column_header = getColumnHeaderCB; aIface->get_row_description = getRowDescriptionCB; aIface->get_row_header = getRowHeaderCB; aIface->get_summary = getSummaryCB; aIface->get_selected_columns = getSelectedColumnsCB; aIface->get_selected_rows = getSelectedRowsCB; aIface->is_column_selected = isColumnSelectedCB; aIface->is_row_selected = isRowSelectedCB; aIface->is_selected = isCellSelectedCB; }
NS_IMETHODIMP nsMenuFrame::InsertFrames(nsIAtom* aListName, nsIFrame* aPrevFrame, nsFrameList& aFrameList) { if (!mPopupFrame && (!aListName || aListName == nsGkAtoms::popupList)) { SetPopupFrame(aFrameList); if (mPopupFrame) { #ifdef DEBUG_LAYOUT nsBoxLayoutState state(PresContext()); SetDebug(state, aFrameList, mState & NS_STATE_CURRENTLY_IN_DEBUG); #endif PresContext()->PresShell()-> FrameNeedsReflow(this, nsIPresShell::eTreeChange, NS_FRAME_HAS_DIRTY_CHILDREN); } } if (aFrameList.IsEmpty()) return NS_OK; if (NS_UNLIKELY(aPrevFrame == mPopupFrame)) { aPrevFrame = nsnull; } return nsBoxFrame::InsertFrames(aListName, aPrevFrame, aFrameList); }
void nsLineBox::DeleteLineList(nsPresContext* aPresContext, nsLineList& aLines, nsIFrame* aDestructRoot, nsFrameList* aFrames) { nsIPresShell* shell = aPresContext->PresShell(); // Keep our line list and frame list up to date as we // remove frames, in case something wants to traverse the // frame tree while we're destroying. while (!aLines.empty()) { nsLineBox* line = aLines.front(); if (NS_UNLIKELY(line->mFlags.mHasHashedFrames)) { line->SwitchToCounter(); // Avoid expensive has table removals. } while (line->GetChildCount() > 0) { nsIFrame* child = aFrames->RemoveFirstChild(); MOZ_ASSERT(child == line->mFirstChild, "Lines out of sync"); line->mFirstChild = aFrames->FirstChild(); line->NoteFrameRemoved(child); child->DestroyFrom(aDestructRoot); } aLines.pop_front(); line->Destroy(shell); } }
nsresult TelemetryImpl::GetHistogramEnumId(const char *name, Telemetry::ID *id) { if (!sTelemetry) { return NS_ERROR_FAILURE; } // Cache names // Note the histogram names are statically allocated TelemetryImpl::HistogramMapType *map = &sTelemetry->mHistogramMap; if (!map->Count()) { for (uint32_t i = 0; i < Telemetry::HistogramCount; i++) { CharPtrEntryType *entry = map->PutEntry(gHistograms[i].id); if (NS_UNLIKELY(!entry)) { map->Clear(); return NS_ERROR_OUT_OF_MEMORY; } entry->mData = (Telemetry::ID) i; } } CharPtrEntryType *entry = map->GetEntry(name); if (!entry) { return NS_ERROR_INVALID_ARG; } *id = entry->mData; return NS_OK; }
bool nsLineBox::RFindLineContaining(nsIFrame* aFrame, const nsLineList::iterator& aBegin, nsLineList::iterator& aEnd, nsIFrame* aLastFrameBeforeEnd, PRInt32* aFrameIndexInLine) { NS_PRECONDITION(aFrame, "null ptr"); nsIFrame* curFrame = aLastFrameBeforeEnd; while (aBegin != aEnd) { --aEnd; NS_ASSERTION(aEnd->LastChild() == curFrame, "Unexpected curFrame"); if (NS_UNLIKELY(aEnd->mFlags.mHasHashedFrames) && !aEnd->Contains(aFrame)) { if (aEnd->mFirstChild) { curFrame = aEnd->mFirstChild->GetPrevSibling(); } continue; } // i is the index of curFrame in aEnd PRInt32 i = aEnd->GetChildCount() - 1; while (i >= 0) { if (curFrame == aFrame) { *aFrameIndexInLine = i; return true; } --i; curFrame = curFrame->GetPrevSibling(); } MOZ_ASSERT(!aEnd->mFlags.mHasHashedFrames, "Contains lied to us!"); } *aFrameIndexInLine = -1; return false; }
nsLineBox::~nsLineBox() { MOZ_COUNT_DTOR(nsLineBox); if (NS_UNLIKELY(mFlags.mHasHashedFrames)) { delete mFrames; } Cleanup(); }
NS_IMETHODIMP nsStorageStream::Write(const char *aBuffer, PRUint32 aCount, PRUint32 *aNumWritten) { NS_ENSURE_TRUE(mSegmentedBuffer, NS_ERROR_NOT_INITIALIZED); const char* readCursor; PRUint32 count, availableInSegment, remaining; nsresult rv = NS_OK; NS_ENSURE_ARG_POINTER(aNumWritten); NS_ENSURE_ARG(aBuffer); LOG(("nsStorageStream [%p] Write mWriteCursor=%x mSegmentEnd=%x aCount=%d\n", this, mWriteCursor, mSegmentEnd, aCount)); remaining = aCount; readCursor = aBuffer; // If no segments have been created yet, create one even if we don't have // to write any data; this enables creating an input stream which reads from // the very end of the data for any amount of data in the stream (i.e. // this stream contains N bytes of data and newInputStream(N) is called), // even for N=0 (with the caveat that we require .write("", 0) be called to // initialize internal buffers). bool firstTime = mSegmentedBuffer->GetSegmentCount() == 0; while (remaining || NS_UNLIKELY(firstTime)) { firstTime = false; availableInSegment = mSegmentEnd - mWriteCursor; if (!availableInSegment) { mWriteCursor = mSegmentedBuffer->AppendNewSegment(); if (!mWriteCursor) { mSegmentEnd = 0; rv = NS_ERROR_OUT_OF_MEMORY; goto out; } mLastSegmentNum++; mSegmentEnd = mWriteCursor + mSegmentSize; availableInSegment = mSegmentEnd - mWriteCursor; LOG(("nsStorageStream [%p] Write (new seg) mWriteCursor=%x mSegmentEnd=%x\n", this, mWriteCursor, mSegmentEnd)); } count = NS_MIN(availableInSegment, remaining); memcpy(mWriteCursor, readCursor, count); remaining -= count; readCursor += count; mWriteCursor += count; LOG(("nsStorageStream [%p] Writing mWriteCursor=%x mSegmentEnd=%x count=%d\n", this, mWriteCursor, mSegmentEnd, count)); }; out: *aNumWritten = aCount - remaining; mLogicalLength += *aNumWritten; LOG(("nsStorageStream [%p] Wrote mWriteCursor=%x mSegmentEnd=%x numWritten=%d\n", this, mWriteCursor, mSegmentEnd, *aNumWritten)); return rv; }
void hyperlinkImplInterfaceInitCB(AtkHyperlinkImplIface *aIface) { NS_ASSERTION(aIface, "no interface!"); if (NS_UNLIKELY(!aIface)) return; aIface->get_hyperlink = getHyperlinkCB; }
void mai_atk_component_iface_init(AtkComponentIface* aIface) { NS_ASSERTION(aIface, "Invalid Interface"); if (NS_UNLIKELY(!aIface)) return; aIface->ref_accessible_at_point = RefAccessibleAtPoint; aIface->get_extents = GetExtents; }
NS_IMETHODIMP nsMenuFrame::Init(nsIContent* aContent, nsIFrame* aParent, nsIFrame* aPrevInFlow) { nsresult rv = nsBoxFrame::Init(aContent, aParent, aPrevInFlow); // Set up a mediator which can be used for callbacks on this frame. mTimerMediator = new nsMenuTimerMediator(this); if (NS_UNLIKELY(!mTimerMediator)) return NS_ERROR_OUT_OF_MEMORY; InitMenuParent(aParent); //load the display strings for the keyboard accelerators, but only once if (gRefCnt++ == 0) { nsCOMPtr<nsIStringBundleService> bundleService = mozilla::services::GetStringBundleService(); nsCOMPtr<nsIStringBundle> bundle; if (bundleService) { rv = bundleService->CreateBundle( "chrome://global-platform/locale/platformKeys.properties", getter_AddRefs(bundle)); } NS_ASSERTION(NS_SUCCEEDED(rv) && bundle, "chrome://global/locale/platformKeys.properties could not be loaded"); nsXPIDLString shiftModifier; nsXPIDLString metaModifier; nsXPIDLString altModifier; nsXPIDLString controlModifier; nsXPIDLString modifierSeparator; if (NS_SUCCEEDED(rv) && bundle) { //macs use symbols for each modifier key, so fetch each from the bundle, which also covers i18n rv = bundle->GetStringFromName(NS_LITERAL_STRING("VK_SHIFT").get(), getter_Copies(shiftModifier)); rv = bundle->GetStringFromName(NS_LITERAL_STRING("VK_META").get(), getter_Copies(metaModifier)); rv = bundle->GetStringFromName(NS_LITERAL_STRING("VK_ALT").get(), getter_Copies(altModifier)); rv = bundle->GetStringFromName(NS_LITERAL_STRING("VK_CONTROL").get(), getter_Copies(controlModifier)); rv = bundle->GetStringFromName(NS_LITERAL_STRING("MODIFIER_SEPARATOR").get(), getter_Copies(modifierSeparator)); } else { rv = NS_ERROR_NOT_AVAILABLE; } //if any of these don't exist, we get an empty string gShiftText = new nsString(shiftModifier); gMetaText = new nsString(metaModifier); gAltText = new nsString(altModifier); gControlText = new nsString(controlModifier); gModifierSeparator = new nsString(modifierSeparator); } BuildAcceleratorText(); nsIReflowCallback* cb = new nsASyncMenuInitialization(this); NS_ENSURE_TRUE(cb, NS_ERROR_OUT_OF_MEMORY); PresContext()->PresShell()->PostReflowCallback(cb); return rv; }
void imageInterfaceInitCB(AtkImageIface* aIface) { NS_ASSERTION(aIface, "no interface!"); if (NS_UNLIKELY(!aIface)) return; aIface->get_image_position = getImagePositionCB; aIface->get_image_description = getImageDescriptionCB; aIface->get_image_size = getImageSizeCB; }
bool nsLocation::CallerSubsumes() { // Get the principal associated with the location object. nsCOMPtr<nsIDOMWindow> outer = do_QueryReferent(mOuter); if (NS_UNLIKELY(!outer)) return false; nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(outer); bool subsumes = false; nsresult rv = nsContentUtils::GetSubjectPrincipal()->Subsumes(sop->GetPrincipal(), &subsumes); NS_ENSURE_SUCCESS(rv, false); return subsumes || nsContentUtils::CallerHasUniversalXPConnect(); }
void editableTextInterfaceInitCB(AtkEditableTextIface* aIface) { NS_ASSERTION(aIface, "Invalid aIface"); if (NS_UNLIKELY(!aIface)) return; aIface->set_text_contents = setTextContentsCB; aIface->insert_text = insertTextCB; aIface->copy_text = copyTextCB; aIface->cut_text = cutTextCB; aIface->delete_text = deleteTextCB; aIface->paste_text = pasteTextCB; }
// Convert the list of words in iwords to the same capitalization aWord and // return them in owords. NS_IMETHODIMP mozEnglishWordUtils::FromRootForm(const PRUnichar *aWord, const PRUnichar **iwords, PRUint32 icount, PRUnichar ***owords, PRUint32 *ocount) { nsAutoString word(aWord); nsresult rv = NS_OK; PRInt32 length; PRUnichar **tmpPtr = (PRUnichar **)nsMemory::Alloc(sizeof(PRUnichar *)*icount); if (!tmpPtr) return NS_ERROR_OUT_OF_MEMORY; mozEnglishWordUtils::myspCapitalization ct = captype(word); for(PRUint32 i = 0; i < icount; ++i) { length = nsCRT::strlen(iwords[i]); tmpPtr[i] = (PRUnichar *) nsMemory::Alloc(sizeof(PRUnichar) * (length + 1)); if (NS_UNLIKELY(!tmpPtr[i])) { NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(i, tmpPtr); return NS_ERROR_OUT_OF_MEMORY; } memcpy(tmpPtr[i], iwords[i], (length + 1) * sizeof(PRUnichar)); nsAutoString capTest(tmpPtr[i]); mozEnglishWordUtils::myspCapitalization newCt=captype(capTest); if(newCt == NoCap){ switch(ct) { case HuhCap: case NoCap: break; case AllCap: ToUpperCase(tmpPtr[i],tmpPtr[i],length); rv = NS_OK; break; case InitCap: ToUpperCase(tmpPtr[i],tmpPtr[i],1); rv = NS_OK; break; default: rv = NS_ERROR_FAILURE; // should never get here; break; } } } if (NS_SUCCEEDED(rv)){ *owords = tmpPtr; *ocount = icount; } return rv; }
PRBool gfxFT2LockedFace::GetFontTable(PRUint32 aTag, FallibleTArray<PRUint8>& aBuffer) { if (!mFace || !FT_IS_SFNT(mFace)) return PR_FALSE; FT_ULong length = 0; // TRUETYPE_TAG is defined equivalent to FT_MAKE_TAG FT_Error error = FT_Load_Sfnt_Table(mFace, aTag, 0, NULL, &length); if (error != 0) return PR_FALSE; if (NS_UNLIKELY(length > static_cast<FallibleTArray<PRUint8>::size_type>(-1)) || NS_UNLIKELY(!aBuffer.SetLength(length))) return PR_FALSE; error = FT_Load_Sfnt_Table(mFace, aTag, 0, aBuffer.Elements(), &length); if (NS_UNLIKELY(error != 0)) { aBuffer.Clear(); return PR_FALSE; } return PR_TRUE; }
NS_IMETHODIMP nsFieldSetFrame::InsertFrames(nsIAtom* aListName, nsIFrame* aPrevFrame, nsIFrame* aFrameList) { aFrameList = MaybeSetLegend(aFrameList, aListName); if (aFrameList) { ReParentFrameList(aFrameList); if (NS_UNLIKELY(aPrevFrame == mLegendFrame)) { aPrevFrame = nsnull; } return mContentFrame->InsertFrames(aListName, aPrevFrame, aFrameList); } return NS_OK; }
void componentInterfaceInitCB(AtkComponentIface* aIface) { NS_ASSERTION(aIface, "Invalid Interface"); if(NS_UNLIKELY(!aIface)) return; /* * Use default implementation in atk for contains, get_position, * and get_size */ aIface->ref_accessible_at_point = refAccessibleAtPointCB; aIface->get_extents = getExtentsCB; aIface->grab_focus = grabFocusCB; }
NS_IMETHODIMP TelemetryImpl::RegisterAddonHistogram(const nsACString &id, const nsACString &name, uint32_t min, uint32_t max, uint32_t bucketCount, uint32_t histogramType) { AddonEntryType *addonEntry = mAddonMap.GetEntry(id); if (!addonEntry) { addonEntry = mAddonMap.PutEntry(id); if (NS_UNLIKELY(!addonEntry)) { return NS_ERROR_OUT_OF_MEMORY; } addonEntry->mData = new AddonHistogramMapType(); } AddonHistogramMapType *histogramMap = addonEntry->mData; AddonHistogramEntryType *histogramEntry = histogramMap->GetEntry(name); // Can't re-register the same histogram. if (histogramEntry) { return NS_ERROR_FAILURE; } histogramEntry = histogramMap->PutEntry(name); if (NS_UNLIKELY(!histogramEntry)) { return NS_ERROR_OUT_OF_MEMORY; } AddonHistogramInfo &info = histogramEntry->mData; info.min = min; info.max = max; info.bucketCount = bucketCount; info.histogramType = histogramType; return NS_OK; }
void documentInterfaceInitCB(AtkDocumentIface *aIface) { NS_ASSERTION(aIface, "Invalid Interface"); if(NS_UNLIKELY(!aIface)) return; /* * We don't support get_document or set_attribute right now. * get_document_type is deprecated, we return DocType in * get_document_attribute_value and get_document_attributes instead. */ aIface->get_document_attributes = getDocumentAttributesCB; aIface->get_document_attribute_value = getDocumentAttributeValueCB; aIface->get_document_locale = getDocumentLocaleCB; }
void nsCSSValue::SetStringValue(const nsString& aValue, nsCSSUnit aUnit) { Reset(); mUnit = aUnit; NS_ABORT_IF_FALSE(UnitHasStringValue(), "not a string unit"); if (UnitHasStringValue()) { mValue.mString = BufferFromString(aValue).get(); if (NS_UNLIKELY(!mValue.mString)) { // XXXbz not much we can do here; just make sure that our promise of a // non-null mValue.mString holds for string units. mUnit = eCSSUnit_Null; } } else mUnit = eCSSUnit_Null; }
nsCSSValue::nsCSSValue(const nsString& aValue, nsCSSUnit aUnit) : mUnit(aUnit) { NS_ABORT_IF_FALSE(UnitHasStringValue(), "not a string value"); if (UnitHasStringValue()) { mValue.mString = BufferFromString(aValue); if (NS_UNLIKELY(!mValue.mString)) { // XXXbz not much we can do here; just make sure that our promise of a // non-null mValue.mString holds for string units. mUnit = eCSSUnit_Null; } } else { mUnit = eCSSUnit_Null; mValue.mInt = 0; } }