本文整理汇总了C++中nsTArray::AppendElement方法的典型用法代码示例。如果您正苦于以下问题:C++ nsTArray::AppendElement方法的具体用法?C++ nsTArray::AppendElement怎么用?C++ nsTArray::AppendElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsTArray
的用法示例。
在下文中一共展示了nsTArray::AppendElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
gfxPlatformMac::GetCommonFallbackFonts(const uint32_t aCh,
int32_t aRunScript,
nsTArray<const char*>& aFontList)
{
aFontList.AppendElement(kFontLucidaGrande);
if (!IS_IN_BMP(aCh)) {
uint32_t p = aCh >> 16;
uint32_t b = aCh >> 8;
if (p == 1) {
if (b >= 0x1f0 && b < 0x1f7) {
aFontList.AppendElement(kFontAppleColorEmoji);
} else {
aFontList.AppendElement(kFontAppleSymbols);
aFontList.AppendElement(kFontSTIXGeneral);
aFontList.AppendElement(kFontGeneva);
}
} else if (p == 2) {
// OSX installations with MS Office may have these fonts
aFontList.AppendElement(kFontMingLiUExtB);
aFontList.AppendElement(kFontSimSunExtB);
}
} else {
示例2:
void
gfxPlatformGtk::GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh,
Script aRunScript,
nsTArray<const char*>& aFontList)
{
if (aNextCh == 0xfe0fu) {
// if char is followed by VS16, try for a color emoji glyph
aFontList.AppendElement(kFontEmojiOneMozilla);
}
aFontList.AppendElement(kFontDejaVuSerif);
aFontList.AppendElement(kFontFreeSerif);
aFontList.AppendElement(kFontDejaVuSans);
aFontList.AppendElement(kFontFreeSans);
if (!IS_IN_BMP(aCh)) {
uint32_t p = aCh >> 16;
if (p == 1) { // try color emoji font, unless VS15 (text style) present
if (aNextCh != 0xfe0fu && aNextCh != 0xfe0eu) {
aFontList.AppendElement(kFontEmojiOneMozilla);
}
}
}
示例3:
void
nsCanvasFrame::AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements, uint32_t aFilter)
{
aElements.AppendElement(mCustomContentContainer);
}
示例4: GetLastResultIndex
nsresult
nsSVGFilterInstance::BuildPrimitives(nsTArray<FilterPrimitiveDescription>& aPrimitiveDescrs,
nsTArray<RefPtr<SourceSurface>>& aInputImages,
bool aInputIsTainted)
{
mSourceGraphicIndex = GetLastResultIndex(aPrimitiveDescrs);
// Clip previous filter's output to this filter's filter region.
if (mSourceGraphicIndex >= 0) {
FilterPrimitiveDescription& sourceDescr = aPrimitiveDescrs[mSourceGraphicIndex];
sourceDescr.SetPrimitiveSubregion(sourceDescr.PrimitiveSubregion().Intersect(mFilterSpaceBounds));
}
// Get the filter primitive elements.
nsTArray<RefPtr<nsSVGFE> > primitives;
for (nsIContent* child = mFilterElement->nsINode::GetFirstChild();
child;
child = child->GetNextSibling()) {
RefPtr<nsSVGFE> primitive;
CallQueryInterface(child, (nsSVGFE**)getter_AddRefs(primitive));
if (primitive) {
primitives.AppendElement(primitive);
}
}
// Maps source image name to source index.
nsDataHashtable<nsStringHashKey, int32_t> imageTable(8);
// The principal that we check principals of any loaded images against.
nsCOMPtr<nsIPrincipal> principal = mTargetContent->NodePrincipal();
for (uint32_t primitiveElementIndex = 0;
primitiveElementIndex < primitives.Length();
++primitiveElementIndex) {
nsSVGFE* filter = primitives[primitiveElementIndex];
AutoTArray<int32_t,2> sourceIndices;
nsresult rv = GetSourceIndices(filter, aPrimitiveDescrs, imageTable, sourceIndices);
if (NS_FAILED(rv)) {
return rv;
}
IntRect primitiveSubregion =
ComputeFilterPrimitiveSubregion(filter, aPrimitiveDescrs, sourceIndices);
nsTArray<bool> sourcesAreTainted;
GetInputsAreTainted(aPrimitiveDescrs, sourceIndices, aInputIsTainted, sourcesAreTainted);
FilterPrimitiveDescription descr =
filter->GetPrimitiveDescription(this, primitiveSubregion, sourcesAreTainted, aInputImages);
descr.SetIsTainted(filter->OutputIsTainted(sourcesAreTainted, principal));
descr.SetFilterSpaceBounds(mFilterSpaceBounds);
descr.SetPrimitiveSubregion(primitiveSubregion.Intersect(descr.FilterSpaceBounds()));
for (uint32_t i = 0; i < sourceIndices.Length(); i++) {
int32_t inputIndex = sourceIndices[i];
descr.SetInputPrimitive(i, inputIndex);
ColorSpace inputColorSpace = inputIndex >= 0
? aPrimitiveDescrs[inputIndex].OutputColorSpace()
: ColorSpace(ColorSpace::SRGB);
ColorSpace desiredInputColorSpace = filter->GetInputColorSpace(i, inputColorSpace);
descr.SetInputColorSpace(i, desiredInputColorSpace);
if (i == 0) {
// the output color space is whatever in1 is if there is an in1
descr.SetOutputColorSpace(desiredInputColorSpace);
}
}
if (sourceIndices.Length() == 0) {
descr.SetOutputColorSpace(filter->GetOutputColorSpace());
}
aPrimitiveDescrs.AppendElement(descr);
uint32_t primitiveDescrIndex = aPrimitiveDescrs.Length() - 1;
nsAutoString str;
filter->GetResultImageName().GetAnimValue(str, filter);
imageTable.Put(str, primitiveDescrIndex);
}
return NS_OK;
}
示例5: GetCasingFor
//.........这里部分代码省略.........
}
// If we didn't have any special action to perform, fall through
// to check for special uppercase (ß)
}
mcm = mozilla::unicode::SpecialUpper(ch);
if (mcm) {
int j = 0;
while (j < 2 && mcm->mMappedChars[j + 1]) {
aConvertedString.Append(mcm->mMappedChars[j]);
++extraChars;
++j;
}
ch = mcm->mMappedChars[j];
break;
}
ch = ToUpperCase(ch);
break;
case NS_STYLE_TEXT_TRANSFORM_CAPITALIZE:
if (aTextRun) {
if (capitalizeDutchIJ && ch == 'j') {
ch = 'J';
capitalizeDutchIJ = false;
break;
}
capitalizeDutchIJ = false;
if (i < aTextRun->mCapitalize.Length() && aTextRun->mCapitalize[i]) {
if (languageSpecificCasing == eLSCB_Turkish && ch == 'i') {
ch = LATIN_CAPITAL_LETTER_I_WITH_DOT_ABOVE;
break;
}
if (languageSpecificCasing == eLSCB_Dutch && ch == 'i') {
ch = 'I';
capitalizeDutchIJ = true;
break;
}
mcm = mozilla::unicode::SpecialTitle(ch);
if (mcm) {
int j = 0;
while (j < 2 && mcm->mMappedChars[j + 1]) {
aConvertedString.Append(mcm->mMappedChars[j]);
++extraChars;
++j;
}
ch = mcm->mMappedChars[j];
break;
}
ch = ToTitleCase(ch);
}
}
break;
case NS_STYLE_TEXT_TRANSFORM_FULLWIDTH:
ch = mozilla::unicode::GetFullWidth(ch);
break;
default:
break;
}
if (ch == uint32_t(-1)) {
aDeletedCharsArray.AppendElement(true);
mergeNeeded = true;
} else {
aDeletedCharsArray.AppendElement(false);
aCharsToMergeArray.AppendElement(false);
if (aTextRun) {
aStyleArray->AppendElement(styleContext);
aCanBreakBeforeArray->AppendElement(inhibitBreakBefore ? false :
aTextRun->CanBreakLineBefore(i));
}
if (IS_IN_BMP(ch)) {
aConvertedString.Append(ch);
} else {
aConvertedString.Append(H_SURROGATE(ch));
aConvertedString.Append(L_SURROGATE(ch));
++i;
aDeletedCharsArray.AppendElement(true); // not exactly deleted, but the
// trailing surrogate is skipped
++extraChars;
}
while (extraChars-- > 0) {
mergeNeeded = true;
aCharsToMergeArray.AppendElement(true);
if (aTextRun) {
aStyleArray->AppendElement(styleContext);
aCanBreakBeforeArray->AppendElement(false);
}
}
}
}
return mergeNeeded;
}
示例6: PresContext
nsresult
nsTextControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
{
NS_ASSERTION(mContent, "We should have a content!");
mState |= NS_FRAME_INDEPENDENT_SELECTION;
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent());
NS_ASSERTION(txtCtrl, "Content not a text control element");
// Bind the frame to its text control
nsresult rv = txtCtrl->BindToFrame(this);
NS_ENSURE_SUCCESS(rv, rv);
nsIContent* rootNode = txtCtrl->GetRootEditorNode();
NS_ENSURE_TRUE(rootNode, NS_ERROR_OUT_OF_MEMORY);
if (!aElements.AppendElement(rootNode))
return NS_ERROR_OUT_OF_MEMORY;
// Do we need a placeholder node?
nsAutoString placeholderTxt;
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::placeholder,
placeholderTxt);
nsContentUtils::RemoveNewlines(placeholderTxt);
mUsePlaceholder = !placeholderTxt.IsEmpty();
// Create the placeholder anonymous content if needed.
if (mUsePlaceholder) {
nsIContent* placeholderNode = txtCtrl->CreatePlaceholderNode();
NS_ENSURE_TRUE(placeholderNode, NS_ERROR_OUT_OF_MEMORY);
// Associate ::-moz-placeholder pseudo-element with the placeholder node.
nsCSSPseudoElements::Type pseudoType =
nsCSSPseudoElements::ePseudo_mozPlaceholder;
nsRefPtr<nsStyleContext> placeholderStyleContext =
PresContext()->StyleSet()->ResolvePseudoElementStyle(
mContent->AsElement(), pseudoType, StyleContext(),
placeholderNode->AsElement());
if (!aElements.AppendElement(ContentInfo(placeholderNode,
placeholderStyleContext))) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
rv = UpdateValueDisplay(false);
NS_ENSURE_SUCCESS(rv, rv);
// textareas are eagerly initialized
bool initEagerly = !IsSingleLineTextControl();
if (!initEagerly) {
// Also, input elements which have a cached selection should get eager
// editor initialization.
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent());
NS_ASSERTION(txtCtrl, "Content not a text control element");
initEagerly = txtCtrl->HasCachedSelection();
}
if (!initEagerly) {
nsCOMPtr<nsIDOMHTMLElement> element = do_QueryInterface(txtCtrl);
if (element) {
// so are input text controls with spellcheck=true
element->GetSpellcheck(&initEagerly);
}
}
if (initEagerly) {
NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),
"Someone forgot a script blocker?");
EditorInitializer* initializer = (EditorInitializer*) Properties().Get(TextControlInitializer());
if (initializer) {
initializer->Revoke();
}
initializer = new EditorInitializer(this);
Properties().Set(TextControlInitializer(),initializer);
if (!nsContentUtils::AddScriptRunner(initializer)) {
initializer->Revoke(); // paranoia
Properties().Delete(TextControlInitializer());
delete initializer;
return NS_ERROR_OUT_OF_MEMORY;
}
}
return NS_OK;
}
示例7: autoDevInfo
nsresult
sbWinFindDevicesByStorageDevNum(STORAGE_DEVICE_NUMBER* aStorageDevNum,
PRBool aMatchPartitionNumber,
const GUID* aGUID,
nsTArray<DEVINST>& aDevInstList)
{
// Validate arguments.
NS_ENSURE_ARG_POINTER(aStorageDevNum);
NS_ENSURE_ARG_POINTER(aGUID);
// Function variables.
nsresult rv;
// Get the interface device class info and set up for auto-disposal.
HDEVINFO devInfo =
SetupDiGetClassDevsW(aGUID,
NULL,
NULL,
DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);
NS_ENSURE_TRUE(devInfo != INVALID_HANDLE_VALUE, NS_ERROR_FAILURE);
sbAutoHDEVINFO autoDevInfo(devInfo);
// Search for device instances with a matching storage device number.
aDevInstList.Clear();
DWORD devIndex = 0;
while (1) {
// Get the next device detail data and set it up for auto-disposal.
PSP_DEVICE_INTERFACE_DETAIL_DATA devIfDetailData;
SP_DEVINFO_DATA devInfoData;
rv = sbWinGetDevDetail(&devIfDetailData,
&devInfoData,
devInfo,
aGUID,
devIndex++);
if (rv == NS_ERROR_NOT_AVAILABLE)
break;
NS_ENSURE_SUCCESS(rv, rv);
sbAutoMemPtr<SP_DEVICE_INTERFACE_DETAIL_DATA>
autoDevIfDetailData(devIfDetailData);
// Get the next storage device number.
STORAGE_DEVICE_NUMBER storageDevNum;
rv = sbWinGetStorageDevNum(devIfDetailData->DevicePath, &storageDevNum);
if (NS_FAILED(rv))
continue;
// Skip device instance if it doesn't match the target storage device
// number.
if (storageDevNum.DeviceType != aStorageDevNum->DeviceType)
continue;
if (storageDevNum.DeviceNumber != aStorageDevNum->DeviceNumber)
continue;
if (aMatchPartitionNumber &&
(storageDevNum.PartitionNumber != aStorageDevNum->PartitionNumber)) {
continue;
}
// Add device instance to list.
NS_ENSURE_TRUE(aDevInstList.AppendElement(devInfoData.DevInst),
NS_ERROR_OUT_OF_MEMORY);
}
return NS_OK;
}
示例8: DummyTouchListener
nsresult
nsCanvasFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
{
if (!mContent) {
return NS_OK;
}
nsCOMPtr<nsIDocument> doc = mContent->OwnerDoc();
nsresult rv = NS_OK;
ErrorResult er;
// We won't create touch caret element if preference is not enabled.
if (PresShell::TouchCaretPrefEnabled()) {
nsRefPtr<NodeInfo> nodeInfo;
// Create and append touch caret frame.
nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::div, nullptr,
kNameSpaceID_XHTML,
nsIDOMNode::ELEMENT_NODE);
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
rv = NS_NewHTMLElement(getter_AddRefs(mTouchCaretElement), nodeInfo.forget(),
NOT_FROM_PARSER);
NS_ENSURE_SUCCESS(rv, rv);
aElements.AppendElement(mTouchCaretElement);
// Set touch caret to visibility: hidden by default.
nsAutoString classValue;
classValue.AppendLiteral("moz-touchcaret hidden");
rv = mTouchCaretElement->SetAttr(kNameSpaceID_None, nsGkAtoms::_class,
classValue, true);
if (!mDummyTouchListener) {
mDummyTouchListener = new DummyTouchListener();
}
mTouchCaretElement->AddEventListener(NS_LITERAL_STRING("touchstart"),
mDummyTouchListener, false);
NS_ENSURE_SUCCESS(rv, rv);
}
if (PresShell::SelectionCaretPrefEnabled()) {
// Selection caret
mSelectionCaretsStartElement = doc->CreateHTMLElement(nsGkAtoms::div);
aElements.AppendElement(mSelectionCaretsStartElement);
nsCOMPtr<mozilla::dom::Element> selectionCaretsStartElementInner = doc->CreateHTMLElement(nsGkAtoms::div);
mSelectionCaretsStartElement->AppendChildTo(selectionCaretsStartElementInner, false);
mSelectionCaretsEndElement = doc->CreateHTMLElement(nsGkAtoms::div);
aElements.AppendElement(mSelectionCaretsEndElement);
nsCOMPtr<mozilla::dom::Element> selectionCaretsEndElementInner = doc->CreateHTMLElement(nsGkAtoms::div);
mSelectionCaretsEndElement->AppendChildTo(selectionCaretsEndElementInner, false);
rv = mSelectionCaretsStartElement->SetAttr(kNameSpaceID_None, nsGkAtoms::_class,
NS_LITERAL_STRING("moz-selectioncaret-left hidden"),
true);
NS_ENSURE_SUCCESS(rv, rv);
rv = mSelectionCaretsEndElement->SetAttr(kNameSpaceID_None, nsGkAtoms::_class,
NS_LITERAL_STRING("moz-selectioncaret-right hidden"),
true);
if (!mDummyTouchListener) {
mDummyTouchListener = new DummyTouchListener();
}
mSelectionCaretsStartElement->AddEventListener(NS_LITERAL_STRING("touchstart"),
mDummyTouchListener, false);
mSelectionCaretsEndElement->AddEventListener(NS_LITERAL_STRING("touchstart"),
mDummyTouchListener, false);
NS_ENSURE_SUCCESS(rv, rv);
}
// Create the custom content container.
mCustomContentContainer = doc->CreateHTMLElement(nsGkAtoms::div);
aElements.AppendElement(mCustomContentContainer);
// XXX add :moz-native-anonymous or will that be automatically set?
rv = mCustomContentContainer->SetAttr(kNameSpaceID_None, nsGkAtoms::_class,
NS_LITERAL_STRING("moz-custom-content-container"),
true);
NS_ENSURE_SUCCESS(rv, rv);
// Append all existing AnonymousContent nodes stored at document level if any.
size_t len = doc->GetAnonymousContents().Length();
for (size_t i = 0; i < len; ++i) {
nsCOMPtr<Element> node = doc->GetAnonymousContents()[i]->GetContentNode();
mCustomContentContainer->AppendChildTo(node->AsContent(), true);
}
// Only create a frame for mCustomContentContainer if it has some children.
if (len == 0) {
HideCustomContentContainer();
}
return NS_OK;
}
示例9: nsTextNode
nsresult
nsFileControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
{
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
nsCOMPtr<nsINodeInfo> nodeInfo;
// Create and setup the file picking button.
nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::button, nullptr,
kNameSpaceID_XHTML,
nsIDOMNode::ELEMENT_NODE);
NS_NewHTMLElement(getter_AddRefs(mBrowse), nodeInfo.forget(),
dom::NOT_FROM_PARSER);
// NOTE: SetNativeAnonymous() has to be called before setting any attribute.
mBrowse->SetNativeAnonymous();
mBrowse->SetAttr(kNameSpaceID_None, nsGkAtoms::type,
NS_LITERAL_STRING("button"), false);
// Set the file picking button text depending on the current locale.
nsXPIDLString buttonTxt;
nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES,
"Browse", buttonTxt);
// Set the browse button text. It's a bit of a pain to do because we want to
// make sure we are not notifying.
nsRefPtr<nsTextNode> textContent =
new nsTextNode(mBrowse->NodeInfo()->NodeInfoManager());
textContent->SetText(buttonTxt, false);
nsresult rv = mBrowse->AppendChildTo(textContent, false);
NS_ENSURE_SUCCESS(rv, rv);
// Make sure access key and tab order for the element actually redirect to the
// file picking button.
nsCOMPtr<nsIDOMHTMLInputElement> fileContent = do_QueryInterface(mContent);
nsCOMPtr<nsIDOMHTMLButtonElement> browseControl = do_QueryInterface(mBrowse);
nsAutoString accessKey;
fileContent->GetAccessKey(accessKey);
browseControl->SetAccessKey(accessKey);
int32_t tabIndex;
fileContent->GetTabIndex(&tabIndex);
browseControl->SetTabIndex(tabIndex);
if (!aElements.AppendElement(mBrowse)) {
return NS_ERROR_OUT_OF_MEMORY;
}
// Create and setup the text showing the selected files.
nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::label, nullptr,
kNameSpaceID_XUL,
nsIDOMNode::ELEMENT_NODE);
NS_TrustedNewXULElement(getter_AddRefs(mTextContent), nodeInfo.forget());
// NOTE: SetNativeAnonymous() has to be called before setting any attribute.
mTextContent->SetNativeAnonymous();
mTextContent->SetAttr(kNameSpaceID_None, nsGkAtoms::crop,
NS_LITERAL_STRING("center"), false);
// Update the displayed text to reflect the current element's value.
nsAutoString value;
HTMLInputElement::FromContent(mContent)->GetDisplayFileName(value);
UpdateDisplayedValue(value, false);
if (!aElements.AppendElement(mTextContent)) {
return NS_ERROR_OUT_OF_MEMORY;
}
// We should be able to interact with the element by doing drag and drop.
mContent->AddSystemEventListener(NS_LITERAL_STRING("drop"),
mMouseListener, false);
mContent->AddSystemEventListener(NS_LITERAL_STRING("dragover"),
mMouseListener, false);
SyncDisabledState();
return NS_OK;
}
示例10:
void
GMPVideoDecoder::InitTags(nsTArray<nsCString>& aTags)
{
aTags.AppendElement(NS_LITERAL_CSTRING("h264"));
}
示例11: InitWhiteList
// Build whitelist to check for board type.
static void InitWhiteList(nsTArray<nsString>& list)
{
nsString ele;
ele.AssignASCII("droid2"); // Motorola Droid 2
list.AppendElement(ele);
ele.AssignASCII("GT-I9100"); // Samsung Galaxy SII
list.AppendElement(ele);
ele.AssignASCII("herring"); // Samsung Nexus S
list.AppendElement(ele);
ele.AssignASCII("omap4sdp"); // Amazon Kindle Fire
list.AppendElement(ele);
ele.AssignASCII("SGH-I897"); // Samsung Galaxy S
list.AppendElement(ele);
ele.AssignASCII("sgh-i997"); // Samsung Infuse 4G
list.AppendElement(ele);
ele.AssignASCII("sgh-t839"); // Samsung Sidekick 4G
list.AppendElement(ele);
ele.AssignASCII("shadow"); // Motorola Droid X
list.AppendElement(ele);
ele.AssignASCII("spyder"); // Motorola Razr
list.AppendElement(ele);
ele.AssignASCII("targa"); // Motorola Droid Bionic
list.AppendElement(ele);
ele.AssignASCII("tuna"); // Galaxy Nexus
list.AppendElement(ele);
ele.AssignASCII("venus2"); // Motorla Droid Pro
list.AppendElement(ele);
}
示例12: DummyTouchListener
nsresult
nsCanvasFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
{
if (!mContent) {
return NS_OK;
}
nsCOMPtr<nsIDocument> doc = mContent->OwnerDoc();
nsresult rv = NS_OK;
ErrorResult er;
// We won't create touch caret element if preference is not enabled.
if (PresShell::TouchCaretPrefEnabled()) {
RefPtr<NodeInfo> nodeInfo;
// Create and append touch caret frame.
nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::div, nullptr,
kNameSpaceID_XHTML,
nsIDOMNode::ELEMENT_NODE);
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
rv = NS_NewHTMLElement(getter_AddRefs(mTouchCaretElement), nodeInfo.forget(),
NOT_FROM_PARSER);
NS_ENSURE_SUCCESS(rv, rv);
aElements.AppendElement(mTouchCaretElement);
// Set touch caret to visibility: hidden by default.
nsAutoString classValue;
classValue.AppendLiteral("moz-touchcaret hidden");
rv = mTouchCaretElement->SetAttr(kNameSpaceID_None, nsGkAtoms::_class,
classValue, true);
if (!mDummyTouchListener) {
mDummyTouchListener = new DummyTouchListener();
}
mTouchCaretElement->AddEventListener(NS_LITERAL_STRING("touchstart"),
mDummyTouchListener, false);
NS_ENSURE_SUCCESS(rv, rv);
}
if (PresShell::SelectionCaretPrefEnabled()) {
// Selection caret
mSelectionCaretsStartElement = doc->CreateHTMLElement(nsGkAtoms::div);
aElements.AppendElement(mSelectionCaretsStartElement);
nsCOMPtr<mozilla::dom::Element> selectionCaretsStartElementInner = doc->CreateHTMLElement(nsGkAtoms::div);
mSelectionCaretsStartElement->AppendChildTo(selectionCaretsStartElementInner, false);
mSelectionCaretsEndElement = doc->CreateHTMLElement(nsGkAtoms::div);
aElements.AppendElement(mSelectionCaretsEndElement);
nsCOMPtr<mozilla::dom::Element> selectionCaretsEndElementInner = doc->CreateHTMLElement(nsGkAtoms::div);
mSelectionCaretsEndElement->AppendChildTo(selectionCaretsEndElementInner, false);
rv = mSelectionCaretsStartElement->SetAttr(kNameSpaceID_None, nsGkAtoms::_class,
NS_LITERAL_STRING("moz-selectioncaret-left hidden"),
true);
NS_ENSURE_SUCCESS(rv, rv);
rv = mSelectionCaretsEndElement->SetAttr(kNameSpaceID_None, nsGkAtoms::_class,
NS_LITERAL_STRING("moz-selectioncaret-right hidden"),
true);
if (!mDummyTouchListener) {
mDummyTouchListener = new DummyTouchListener();
}
mSelectionCaretsStartElement->AddEventListener(NS_LITERAL_STRING("touchstart"),
mDummyTouchListener, false);
mSelectionCaretsEndElement->AddEventListener(NS_LITERAL_STRING("touchstart"),
mDummyTouchListener, false);
NS_ENSURE_SUCCESS(rv, rv);
}
// Create the custom content container.
mCustomContentContainer = doc->CreateHTMLElement(nsGkAtoms::div);
#ifdef DEBUG
// We restyle our mCustomContentContainer, even though it's root anonymous
// content. Normally that's not OK because the frame constructor doesn't know
// how to order the frame tree in such cases, but we make this work for this
// particular case, so it's OK.
mCustomContentContainer->SetProperty(nsGkAtoms::restylableAnonymousNode,
reinterpret_cast<void*>(true));
#endif // DEBUG
aElements.AppendElement(mCustomContentContainer);
// XXX add :moz-native-anonymous or will that be automatically set?
rv = mCustomContentContainer->SetAttr(kNameSpaceID_None, nsGkAtoms::_class,
NS_LITERAL_STRING("moz-custom-content-container"),
true);
NS_ENSURE_SUCCESS(rv, rv);
// Append all existing AnonymousContent nodes stored at document level if any.
size_t len = doc->GetAnonymousContents().Length();
for (size_t i = 0; i < len; ++i) {
nsCOMPtr<Element> node = doc->GetAnonymousContents()[i]->GetContentNode();
mCustomContentContainer->AppendChildTo(node->AsContent(), true);
}
// Only create a frame for mCustomContentContainer if it has some children.
if (len == 0) {
HideCustomContentContainer();
}
//.........这里部分代码省略.........
示例13: nsFontMetrics
nsresult
nsFontCache::GetMetricsFor(const nsFont& aFont,
nsIAtom* aLanguage, bool aExplicitLanguage,
gfxFont::Orientation aOrientation,
gfxUserFontSet* aUserFontSet,
gfxTextPerfMetrics* aTextPerf,
nsFontMetrics*& aMetrics)
{
if (!aLanguage)
aLanguage = mLocaleLanguage;
// First check our cache
// start from the end, which is where we put the most-recent-used element
nsFontMetrics* fm;
int32_t n = mFontMetrics.Length() - 1;
for (int32_t i = n; i >= 0; --i) {
fm = mFontMetrics[i];
if (fm->Font().Equals(aFont) && fm->GetUserFontSet() == aUserFontSet &&
fm->Language() == aLanguage && fm->Orientation() == aOrientation) {
if (i != n) {
// promote it to the end of the cache
mFontMetrics.RemoveElementAt(i);
mFontMetrics.AppendElement(fm);
}
fm->GetThebesFontGroup()->UpdateUserFonts();
NS_ADDREF(aMetrics = fm);
return NS_OK;
}
}
// It's not in the cache. Get font metrics and then cache them.
fm = new nsFontMetrics();
NS_ADDREF(fm);
nsresult rv = fm->Init(aFont, aLanguage, aExplicitLanguage, aOrientation,
mContext, aUserFontSet, aTextPerf);
if (NS_SUCCEEDED(rv)) {
// the mFontMetrics list has the "head" at the end, because append
// is cheaper than insert
mFontMetrics.AppendElement(fm);
aMetrics = fm;
NS_ADDREF(aMetrics);
return NS_OK;
}
fm->Destroy();
NS_RELEASE(fm);
// One reason why Init() fails is because the system is running out of
// resources. e.g., on Win95/98 only a very limited number of GDI
// objects are available. Compact the cache and try again.
Compact();
fm = new nsFontMetrics();
NS_ADDREF(fm);
rv = fm->Init(aFont, aLanguage, aExplicitLanguage, aOrientation, mContext,
aUserFontSet, aTextPerf);
if (NS_SUCCEEDED(rv)) {
mFontMetrics.AppendElement(fm);
aMetrics = fm;
return NS_OK;
}
fm->Destroy();
NS_RELEASE(fm);
// could not setup a new one, send an old one (XXX search a "best
// match"?)
n = mFontMetrics.Length() - 1; // could have changed in Compact()
if (n >= 0) {
aMetrics = mFontMetrics[n];
NS_ADDREF(aMetrics);
return NS_OK;
}
NS_POSTCONDITION(NS_SUCCEEDED(rv),
"font metrics should not be null - bug 136248");
return rv;
}
示例14:
void
SVGFEDropShadowElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
{
aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this));
}
示例15: SyncAttr
nsresult
nsFileControlFrame::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
{
// Get the NodeInfoManager and tag necessary to create input elements
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
nsCOMPtr<nsINodeInfo> nodeInfo;
doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::input, nsnull,
kNameSpaceID_None,
getter_AddRefs(nodeInfo));
// Create the text content
NS_NewHTMLElement(getter_AddRefs(mTextContent), nodeInfo, PR_FALSE);
if (!mTextContent)
return NS_ERROR_OUT_OF_MEMORY;
mTextContent->SetAttr(kNameSpaceID_None, nsGkAtoms::type,
NS_LITERAL_STRING("text"), PR_FALSE);
nsCOMPtr<nsIDOMHTMLInputElement> textControl = do_QueryInterface(mTextContent);
if (textControl) {
nsCOMPtr<nsIFileControlElement> fileControl = do_QueryInterface(mContent);
if (fileControl) {
// Initialize value when we create the content in case the value was set
// before we got here
nsAutoString value;
fileControl->GetFileName(value);
textControl->SetValue(value);
}
textControl->SetTabIndex(-1);
textControl->SetReadOnly(PR_TRUE);
}
if (!aElements.AppendElement(mTextContent))
return NS_ERROR_OUT_OF_MEMORY;
NS_NAMED_LITERAL_STRING(click, "click");
nsCOMPtr<nsIDOMEventGroup> systemGroup;
mContent->GetSystemEventGroup(getter_AddRefs(systemGroup));
nsCOMPtr<nsIDOM3EventTarget> dom3TextContent =
do_QueryInterface(mTextContent);
NS_ENSURE_STATE(dom3TextContent);
// Register as an event listener of the textbox
// to open file dialog on mouse click
dom3TextContent->AddGroupedEventListener(click, mMouseListener, PR_FALSE,
systemGroup);
// Create the browse button
NS_NewHTMLElement(getter_AddRefs(mBrowse), nodeInfo, PR_FALSE);
if (!mBrowse)
return NS_ERROR_OUT_OF_MEMORY;
mBrowse->SetAttr(kNameSpaceID_None, nsGkAtoms::type,
NS_LITERAL_STRING("button"), PR_FALSE);
nsCOMPtr<nsIDOMHTMLInputElement> fileContent = do_QueryInterface(mContent);
nsCOMPtr<nsIDOMHTMLInputElement> browseControl = do_QueryInterface(mBrowse);
if (fileContent && browseControl) {
PRInt32 tabIndex;
nsAutoString accessKey;
fileContent->GetAccessKey(accessKey);
browseControl->SetAccessKey(accessKey);
fileContent->GetTabIndex(&tabIndex);
browseControl->SetTabIndex(tabIndex);
}
if (!aElements.AppendElement(mBrowse))
return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<nsIDOM3EventTarget> dom3Browse = do_QueryInterface(mBrowse);
NS_ENSURE_STATE(dom3Browse);
// Register as an event listener of the button
// to open file dialog on mouse click
dom3Browse->AddGroupedEventListener(click, mMouseListener, PR_FALSE,
systemGroup);
SyncAttr(kNameSpaceID_None, nsGkAtoms::size, SYNC_TEXT);
SyncAttr(kNameSpaceID_None, nsGkAtoms::disabled, SYNC_BOTH);
return NS_OK;
}