本文整理汇总了C++中nsAString::LowerCaseEqualsLiteral方法的典型用法代码示例。如果您正苦于以下问题:C++ nsAString::LowerCaseEqualsLiteral方法的具体用法?C++ nsAString::LowerCaseEqualsLiteral怎么用?C++ nsAString::LowerCaseEqualsLiteral使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsAString
的用法示例。
在下文中一共展示了nsAString::LowerCaseEqualsLiteral方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddValueToMultivalueProperty
// Adds the value aNewValue to the list of white-space separated values aValues
void ChangeStyleTransaction::AddValueToMultivalueProperty(
nsAString& aValues, const nsAString& aNewValue) {
if (aValues.IsEmpty() || aValues.LowerCaseEqualsLiteral("none")) {
aValues.Assign(aNewValue);
} else if (!ValueIncludes(aValues, aNewValue)) {
// We already have another value but not this one; add it
aValues.Append(char16_t(' '));
aValues.Append(aNewValue);
}
}
示例2: localeStr
NS_IMETHODIMP
nsPlatformCharset::GetDefaultCharsetForLocale(const nsAString& localeName, nsACString &oResult)
{
//
// if this locale is the user's locale then use the charset
// we already determined at initialization
//
if (mLocale.Equals(localeName) ||
// support the 4.x behavior
(mLocale.LowerCaseEqualsLiteral("en_us") &&
localeName.LowerCaseEqualsLiteral("c"))) {
oResult = mCharset;
return NS_OK;
}
#if HAVE_LANGINFO_CODESET
//
// This locale appears to be a different locale from the user's locale.
// To do this we would need to lock the global resource we are currently
// using or use a library that provides multi locale support.
// ICU is a possible example of a multi locale library.
// http://oss.software.ibm.com/icu/
//
// A more common cause of hitting this warning than the above is that
// Mozilla is launched under an ll_CC.UTF-8 locale. In xpLocale,
// we only store the language and the region (ll-CC) losing 'UTF-8', which
// leads |mLocale| to be different from |localeName|. Although we lose
// 'UTF-8', we init'd |mCharset| with the value obtained via
// |nl_langinfo(CODESET)| so that we're all right here.
//
NS_WARNING("GetDefaultCharsetForLocale: need to add multi locale support");
#ifdef DEBUG_jungshik
printf("localeName=%s mCharset=%s\n", NS_ConvertUTF16toUTF8(localeName).get(),
mCharset.get());
#endif
// until we add multi locale support: use the the charset of the user's locale
oResult = mCharset;
return NS_SUCCESS_USING_FALLBACK_LOCALE;
#else
//
// convert from locale to charset
// using the deprecated locale to charset mapping
//
nsAutoString localeStr(localeName);
nsresult res = ConvertLocaleToCharsetUsingDeprecatedConfig(localeStr, oResult);
if (NS_SUCCEEDED(res))
return res;
NS_ERROR("unable to convert locale to charset using deprecated config");
oResult.AssignLiteral("ISO-8859-1");
return NS_SUCCESS_USING_FALLBACK_LOCALE;
#endif
}
示例3:
nsresult
TabGroup::FindItemWithName(const nsAString& aName,
nsIDocShellTreeItem* aRequestor,
nsIDocShellTreeItem* aOriginalRequestor,
nsIDocShellTreeItem** aFoundItem)
{
MOZ_ASSERT(NS_IsMainThread());
NS_ENSURE_ARG_POINTER(aFoundItem);
*aFoundItem = nullptr;
MOZ_ASSERT(!aName.LowerCaseEqualsLiteral("_blank") &&
!aName.LowerCaseEqualsLiteral("_top") &&
!aName.LowerCaseEqualsLiteral("_parent") &&
!aName.LowerCaseEqualsLiteral("_self"));
for (nsPIDOMWindowOuter* outerWindow : mWindows) {
// Ignore non-toplevel windows
if (outerWindow->GetScriptableParentOrNull()) {
continue;
}
nsCOMPtr<nsIDocShellTreeItem> docshell = outerWindow->GetDocShell();
if (!docshell) {
continue;
}
nsCOMPtr<nsIDocShellTreeItem> root;
docshell->GetSameTypeRootTreeItem(getter_AddRefs(root));
MOZ_RELEASE_ASSERT(docshell == root);
if (root && aRequestor != root) {
root->FindItemWithName(aName, aRequestor, aOriginalRequestor,
/* aSkipTabGroup = */ true, aFoundItem);
if (*aFoundItem) {
break;
}
}
}
return NS_OK;
}
示例4:
NS_IMETHODIMP
sbOriginPageImagePropertyInfo::GetPreventNavigation(const nsAString& aImageValue,
const nsAString& aUrlValue,
bool *_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
*_retval = aImageValue.LowerCaseEqualsLiteral("unknownOrigin") ||
aImageValue.IsEmpty() ||
aUrlValue.IsEmpty();
return NS_OK;
}
示例5: ParseCENCInitData
// The user agent MUST thoroughly validate the Initialization Data before
// passing it to the CDM. This includes verifying that the length and
// values of fields are reasonable, verifying that values are within
// reasonable limits, and stripping irrelevant, unsupported, or unknown
// data or fields. It is RECOMMENDED that user agents pre-parse, sanitize,
// and/or generate a fully sanitized version of the Initialization Data.
// If the Initialization Data format specified by initDataType supports
// multiple entries, the user agent SHOULD remove entries that are not
// needed by the CDM. The user agent MUST NOT re-order entries within
// the Initialization Data.
static bool
ValidateInitData(const nsTArray<uint8_t>& aInitData, const nsAString& aInitDataType)
{
if (aInitDataType.LowerCaseEqualsLiteral("webm")) {
// WebM initData consists of a single keyId. Ensure it's of reasonable length.
return aInitData.Length() <= MAX_KEY_ID_LENGTH;
} else if (aInitDataType.LowerCaseEqualsLiteral("cenc")) {
// Limit initData to less than 64KB.
if (aInitData.Length() > MAX_CENC_INIT_DATA_LENGTH) {
return false;
}
std::vector<std::vector<uint8_t>> keyIds;
return ParseCENCInitData(aInitData.Elements(), aInitData.Length(), keyIds);
} else if (aInitDataType.LowerCaseEqualsLiteral("keyids")) {
if (aInitData.Length() > MAX_KEY_ID_LENGTH) {
return false;
}
// Ensure that init data matches the expected JSON format.
mozilla::dom::KeyIdsInitData keyIds;
nsString json;
nsDependentCSubstring raw(reinterpret_cast<const char*>(aInitData.Elements()), aInitData.Length());
if (NS_FAILED(nsContentUtils::ConvertStringFromEncoding(NS_LITERAL_CSTRING("UTF-8"), raw, json))) {
return false;
}
if (!keyIds.Init(json)) {
return false;
}
if (keyIds.mKids.Length() == 0) {
return false;
}
for (const auto& kid : keyIds.mKids) {
if (kid.IsEmpty()) {
return false;
}
}
}
return true;
}
示例6:
NS_IMETHODIMP
sbImageLinkPropertyInfo::GetImageSrc(const nsAString& aValue,
nsAString& _retval)
{
if(!aValue.IsEmpty() &&
!aValue.LowerCaseEqualsLiteral("default")) {
_retval = aValue;
return NS_OK;
}
_retval.Truncate();
return NS_OK;
}
示例7: if
// adds the value aNewValue to the list of white-space separated values aValues
NS_IMETHODIMP
ChangeCSSInlineStyleTxn::AddValueToMultivalueProperty(nsAString & aValues, const nsAString & aNewValue)
{
if (aValues.IsEmpty()
|| aValues.LowerCaseEqualsLiteral("none")) {
// the list of values is empty of the value is 'none'
aValues.Assign(aNewValue);
}
else if (!ValueIncludes(aValues, aNewValue, false)) {
// we already have another value but not this one; add it
aValues.Append(PRUnichar(' '));
aValues.Append(aNewValue);
}
return NS_OK;
}
示例8: also
/**
Ensures basic sanity of attribute value.
This function also (tries to :-( ) makes sure, that no
unwanted / dangerous URLs appear in the document
(like javascript: and data:).
Pass the value as |aValue| arg. It will be modified in-place.
If the value is not allowed at all, we return with NS_ERROR_ILLEGAL_VALUE.
In that case, do not use the |aValue|, but output nothing.
*/
nsresult
mozSanitizingHTMLSerializer::SanitizeAttrValue(nsHTMLTag aTag,
const nsAString& anAttrName,
nsString& aValue /*inout*/)
{
/* First, cut the attribute to 1000 chars.
Attributes with values longer than 1000 chars seem bogus,
considering that we don't support any JS. The longest attributes
I can think of are URLs, and URLs with 1000 chars are likely to be
bogus, too. */
aValue = Substring(aValue, 0, 1000);
//aValue.Truncate(1000); //-- this cuts half of the document !!?!!
aValue.Adopt(escape(aValue));
/* Check some known bad stuff. Add more!
I don't care too much, if it happens to trigger in some innocent cases
(like <img alt="Statistical data: Mortage rates and newspapers">) -
security first. */
if (aValue.Find("javascript:") != kNotFound ||
aValue.Find("data:") != kNotFound ||
aValue.Find("base64") != kNotFound)
return NS_ERROR_ILLEGAL_VALUE;
// Check img src scheme
if (aTag == eHTMLTag_img &&
anAttrName.LowerCaseEqualsLiteral("src"))
{
nsresult rv;
nsCOMPtr<nsIIOService> ioService = do_GetIOService(&rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCAutoString scheme;
rv = ioService->ExtractScheme(NS_LossyConvertUTF16toASCII(aValue), scheme);
NS_ENSURE_SUCCESS(rv, rv);
if (!scheme.Equals("cid", nsCaseInsensitiveCStringComparator()))
return NS_ERROR_ILLEGAL_VALUE;
}
#ifdef DEBUG_BenB
printf("attribute value for %s: -%s-\n",
NS_LossyConvertUTF16toASCII(anAttrName).get(),
NS_LossyConvertUTF16toASCII(aValue).get());
#endif
return NS_OK;
}
示例9: IsUrlAttribute
PRBool CViewSourceHTML::IsUrlAttribute(const nsAString& tagName,
const nsAString& attrName,
const nsAString& attrValue) {
const nsSubstring &trimmedAttrName = TrimTokenValue(attrName);
PRBool isHref = trimmedAttrName.LowerCaseEqualsLiteral("href");
PRBool isSrc = !isHref && trimmedAttrName.LowerCaseEqualsLiteral("src");
// If this is the HREF attribute of a BASE element, then update the base URI.
// This doesn't feel like the ideal place for this, but the alternatives don't
// seem all that nice either.
if (isHref && tagName.LowerCaseEqualsLiteral("base")) {
const nsAString& baseSpec = TrimTokenValue(attrValue);
nsAutoString expandedBaseSpec;
ExpandEntities(baseSpec, expandedBaseSpec);
SetBaseURI(expandedBaseSpec);
}
return isHref || isSrc;
}
示例10: NS_NewDOMMutationEvent
/* static */ nsresult
nsEventDispatcher::CreateEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
nsEvent* aEvent,
const nsAString& aEventType,
nsIDOMEvent** aDOMEvent)
{
*aDOMEvent = nullptr;
if (aEvent) {
switch(aEvent->eventStructType) {
case NS_MUTATION_EVENT:
return NS_NewDOMMutationEvent(aDOMEvent, aOwner, aPresContext,
static_cast<nsMutationEvent*>(aEvent));
case NS_GUI_EVENT:
case NS_SCROLLPORT_EVENT:
case NS_UI_EVENT:
return NS_NewDOMUIEvent(aDOMEvent, aOwner, aPresContext,
static_cast<nsGUIEvent*>(aEvent));
case NS_SCROLLAREA_EVENT:
return NS_NewDOMScrollAreaEvent(aDOMEvent, aOwner, aPresContext,
static_cast<nsScrollAreaEvent *>(aEvent));
case NS_KEY_EVENT:
return NS_NewDOMKeyboardEvent(aDOMEvent, aOwner, aPresContext,
static_cast<nsKeyEvent*>(aEvent));
case NS_COMPOSITION_EVENT:
return NS_NewDOMCompositionEvent(
aDOMEvent, aOwner,
aPresContext, static_cast<nsCompositionEvent*>(aEvent));
case NS_MOUSE_EVENT:
return NS_NewDOMMouseEvent(aDOMEvent, aOwner, aPresContext,
static_cast<nsInputEvent*>(aEvent));
case NS_MOUSE_SCROLL_EVENT:
return NS_NewDOMMouseScrollEvent(aDOMEvent, aOwner, aPresContext,
static_cast<nsInputEvent*>(aEvent));
case NS_WHEEL_EVENT:
return NS_NewDOMWheelEvent(aDOMEvent, aOwner, aPresContext,
static_cast<widget::WheelEvent*>(aEvent));
case NS_DRAG_EVENT:
return NS_NewDOMDragEvent(aDOMEvent, aOwner, aPresContext,
static_cast<nsDragEvent*>(aEvent));
case NS_TEXT_EVENT:
return NS_NewDOMTextEvent(aDOMEvent, aOwner, aPresContext,
static_cast<nsTextEvent*>(aEvent));
case NS_CLIPBOARD_EVENT:
return NS_NewDOMClipboardEvent(aDOMEvent, aOwner, aPresContext,
static_cast<nsClipboardEvent*>(aEvent));
case NS_SVGZOOM_EVENT:
return NS_NewDOMSVGZoomEvent(aDOMEvent, aOwner, aPresContext,
static_cast<nsGUIEvent*>(aEvent));
case NS_SMIL_TIME_EVENT:
return NS_NewDOMTimeEvent(aDOMEvent, aOwner, aPresContext, aEvent);
case NS_COMMAND_EVENT:
return NS_NewDOMCommandEvent(aDOMEvent, aOwner, aPresContext,
static_cast<nsCommandEvent*>(aEvent));
case NS_SIMPLE_GESTURE_EVENT:
return NS_NewDOMSimpleGestureEvent(aDOMEvent, aOwner, aPresContext,
static_cast<nsSimpleGestureEvent*>(aEvent));
case NS_TOUCH_EVENT:
return NS_NewDOMTouchEvent(aDOMEvent, aOwner, aPresContext,
static_cast<nsTouchEvent*>(aEvent));
case NS_TRANSITION_EVENT:
return NS_NewDOMTransitionEvent(aDOMEvent, aOwner, aPresContext,
static_cast<nsTransitionEvent*>(aEvent));
case NS_ANIMATION_EVENT:
return NS_NewDOMAnimationEvent(aDOMEvent, aOwner, aPresContext,
static_cast<nsAnimationEvent*>(aEvent));
default:
// For all other types of events, create a vanilla event object.
return NS_NewDOMEvent(aDOMEvent, aOwner, aPresContext, aEvent);
}
}
// And if we didn't get an event, check the type argument.
if (aEventType.LowerCaseEqualsLiteral("mouseevent") ||
aEventType.LowerCaseEqualsLiteral("mouseevents") ||
aEventType.LowerCaseEqualsLiteral("popupevents"))
return NS_NewDOMMouseEvent(aDOMEvent, aOwner, aPresContext, nullptr);
if (aEventType.LowerCaseEqualsLiteral("mousescrollevents"))
return NS_NewDOMMouseScrollEvent(aDOMEvent, aOwner, aPresContext, nullptr);
if (aEventType.LowerCaseEqualsLiteral("dragevent") ||
aEventType.LowerCaseEqualsLiteral("dragevents"))
return NS_NewDOMDragEvent(aDOMEvent, aOwner, aPresContext, nullptr);
if (aEventType.LowerCaseEqualsLiteral("keyboardevent") ||
aEventType.LowerCaseEqualsLiteral("keyevents"))
return NS_NewDOMKeyboardEvent(aDOMEvent, aOwner, aPresContext, nullptr);
if (aEventType.LowerCaseEqualsLiteral("compositionevent"))
return NS_NewDOMCompositionEvent(aDOMEvent, aOwner, aPresContext, nullptr);
if (aEventType.LowerCaseEqualsLiteral("mutationevent") ||
aEventType.LowerCaseEqualsLiteral("mutationevents"))
return NS_NewDOMMutationEvent(aDOMEvent, aOwner, aPresContext, nullptr);
if (aEventType.LowerCaseEqualsLiteral("textevent") ||
aEventType.LowerCaseEqualsLiteral("textevents"))
return NS_NewDOMTextEvent(aDOMEvent, aOwner, aPresContext, nullptr);
if (aEventType.LowerCaseEqualsLiteral("popupblockedevents"))
return NS_NewDOMPopupBlockedEvent(aDOMEvent, aOwner, aPresContext, nullptr);
if (aEventType.LowerCaseEqualsLiteral("deviceorientationevent"))
return NS_NewDOMDeviceOrientationEvent(aDOMEvent, aOwner, aPresContext, nullptr);
//.........这里部分代码省略.........
示例11: CheckOneFrameOptionsPolicy
bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIRequest *request,
const nsAString& policy) {
static const char allowFrom[] = "allow-from ";
const uint32_t allowFromLen = ArrayLength(allowFrom) - 1;
bool isAllowFrom =
StringHead(policy, allowFromLen).LowerCaseEqualsLiteral(allowFrom);
// return early if header does not have one of the values with meaning
if (!policy.LowerCaseEqualsLiteral("deny") &&
!policy.LowerCaseEqualsLiteral("sameorigin") &&
!isAllowFrom)
return true;
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(request);
if (!httpChannel) {
return true;
}
if (mDocShell) {
// We need to check the location of this window and the location of the top
// window, if we're not the top. X-F-O: SAMEORIGIN requires that the
// document must be same-origin with top window. X-F-O: DENY requires that
// the document must never be framed.
nsCOMPtr<nsIDOMWindow> thisWindow = do_GetInterface(static_cast<nsIDocShell*>(mDocShell));
// If we don't have DOMWindow there is no risk of clickjacking
if (!thisWindow)
return true;
// GetScriptableTop, not GetTop, because we want this to respect
// <iframe mozbrowser> boundaries.
nsCOMPtr<nsIDOMWindow> topWindow;
thisWindow->GetScriptableTop(getter_AddRefs(topWindow));
// if the document is in the top window, it's not in a frame.
if (thisWindow == topWindow)
return true;
// Find the top docshell in our parent chain that doesn't have the system
// principal and use it for the principal comparison. Finding the top
// content-type docshell doesn't work because some chrome documents are
// loaded in content docshells (see bug 593387).
nsCOMPtr<nsIDocShellTreeItem> thisDocShellItem(do_QueryInterface(
static_cast<nsIDocShell*> (mDocShell)));
nsCOMPtr<nsIDocShellTreeItem> parentDocShellItem,
curDocShellItem = thisDocShellItem;
nsCOMPtr<nsIDocument> topDoc;
nsresult rv;
nsCOMPtr<nsIScriptSecurityManager> ssm =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
if (!ssm) {
NS_ASSERTION(ssm, "Failed to get the ScriptSecurityManager.");
return false;
}
// Traverse up the parent chain and stop when we see a docshell whose
// parent has a system principal, or a docshell corresponding to
// <iframe mozbrowser>.
while (NS_SUCCEEDED(curDocShellItem->GetParent(getter_AddRefs(parentDocShellItem))) &&
parentDocShellItem) {
nsCOMPtr<nsIDocShell> curDocShell = do_QueryInterface(curDocShellItem);
if (curDocShell && curDocShell->GetIsContentBoundary()) {
break;
}
bool system = false;
topDoc = do_GetInterface(parentDocShellItem);
if (topDoc) {
if (NS_SUCCEEDED(ssm->IsSystemPrincipal(topDoc->NodePrincipal(),
&system)) && system) {
// Found a system-principled doc: last docshell was top.
break;
}
}
else {
return false;
}
curDocShellItem = parentDocShellItem;
}
// If this document has the top non-SystemPrincipal docshell it is not being
// framed or it is being framed by a chrome document, which we allow.
if (curDocShellItem == thisDocShellItem)
return true;
// If the value of the header is DENY, and the previous condition is
// not met (current docshell is not the top docshell), prohibit the
// load.
if (policy.LowerCaseEqualsLiteral("deny")) {
return false;
}
topDoc = do_GetInterface(curDocShellItem);
nsCOMPtr<nsIURI> topUri;
topDoc->NodePrincipal()->GetURI(getter_AddRefs(topUri));
nsCOMPtr<nsIURI> uri;
// If the X-Frame-Options value is SAMEORIGIN, then the top frame in the
// parent chain must be from the same origin as this document.
if (policy.LowerCaseEqualsLiteral("sameorigin")) {
//.........这里部分代码省略.........
示例12: nsShouldIgnoreFile
bool nsMsgLocalStoreUtils::nsShouldIgnoreFile(nsAString &name) {
if (name.IsEmpty()) return true;
char16_t firstChar = name.First();
if (firstChar == '.' || firstChar == '#' ||
name.CharAt(name.Length() - 1) == '~')
return true;
if (name.LowerCaseEqualsLiteral("msgfilterrules.dat") ||
name.LowerCaseEqualsLiteral("rules.dat") ||
name.LowerCaseEqualsLiteral("filterlog.html") ||
name.LowerCaseEqualsLiteral("junklog.html") ||
name.LowerCaseEqualsLiteral("rulesbackup.dat"))
return true;
// don't add summary files to the list of folders;
// don't add popstate files to the list either, or rules (sort.dat).
if (StringEndsWith(name, NS_LITERAL_STRING(".snm")) ||
name.LowerCaseEqualsLiteral("popstate.dat") ||
name.LowerCaseEqualsLiteral("sort.dat") ||
name.LowerCaseEqualsLiteral("mailfilt.log") ||
name.LowerCaseEqualsLiteral("filters.js") ||
StringEndsWith(name, NS_LITERAL_STRING(".toc")))
return true;
// ignore RSS data source files
if (name.LowerCaseEqualsLiteral("feeds.rdf") ||
name.LowerCaseEqualsLiteral("feeditems.rdf") ||
StringBeginsWith(name, NS_LITERAL_STRING("feeditems_error")))
return true;
// The .mozmsgs dir is for spotlight support
return (StringEndsWith(name, NS_LITERAL_STRING(".mozmsgs")) ||
StringEndsWith(name, NS_LITERAL_STRING(FOLDER_SUFFIX)) ||
StringEndsWith(name, NS_LITERAL_STRING(SUMMARY_SUFFIX)));
}
示例13: NS_NewDOMMutationEvent
/* static */ nsresult
nsEventDispatcher::CreateEvent(nsPresContext* aPresContext,
nsEvent* aEvent,
const nsAString& aEventType,
nsIDOMEvent** aDOMEvent)
{
*aDOMEvent = nullptr;
if (aEvent) {
switch(aEvent->eventStructType) {
case NS_MUTATION_EVENT:
return NS_NewDOMMutationEvent(aDOMEvent, aPresContext,
static_cast<nsMutationEvent*>(aEvent));
case NS_GUI_EVENT:
case NS_SCROLLPORT_EVENT:
case NS_UI_EVENT:
return NS_NewDOMUIEvent(aDOMEvent, aPresContext,
static_cast<nsGUIEvent*>(aEvent));
case NS_SCROLLAREA_EVENT:
return NS_NewDOMScrollAreaEvent(aDOMEvent, aPresContext,
static_cast<nsScrollAreaEvent *>(aEvent));
case NS_KEY_EVENT:
return NS_NewDOMKeyboardEvent(aDOMEvent, aPresContext,
static_cast<nsKeyEvent*>(aEvent));
case NS_COMPOSITION_EVENT:
return NS_NewDOMCompositionEvent(
aDOMEvent, aPresContext, static_cast<nsCompositionEvent*>(aEvent));
case NS_MOUSE_EVENT:
case NS_POPUP_EVENT:
return NS_NewDOMMouseEvent(aDOMEvent, aPresContext,
static_cast<nsInputEvent*>(aEvent));
case NS_MOUSE_SCROLL_EVENT:
return NS_NewDOMMouseScrollEvent(aDOMEvent, aPresContext,
static_cast<nsInputEvent*>(aEvent));
case NS_WHEEL_EVENT:
return NS_NewDOMWheelEvent(aDOMEvent, aPresContext,
static_cast<widget::WheelEvent*>(aEvent));
case NS_DRAG_EVENT:
return NS_NewDOMDragEvent(aDOMEvent, aPresContext,
static_cast<nsDragEvent*>(aEvent));
case NS_TEXT_EVENT:
return NS_NewDOMTextEvent(aDOMEvent, aPresContext,
static_cast<nsTextEvent*>(aEvent));
case NS_SVG_EVENT:
return NS_NewDOMSVGEvent(aDOMEvent, aPresContext,
aEvent);
case NS_SVGZOOM_EVENT:
return NS_NewDOMSVGZoomEvent(aDOMEvent, aPresContext,
static_cast<nsGUIEvent*>(aEvent));
case NS_SMIL_TIME_EVENT:
return NS_NewDOMTimeEvent(aDOMEvent, aPresContext, aEvent);
case NS_COMMAND_EVENT:
return NS_NewDOMCommandEvent(aDOMEvent, aPresContext,
static_cast<nsCommandEvent*>(aEvent));
case NS_SIMPLE_GESTURE_EVENT:
return NS_NewDOMSimpleGestureEvent(aDOMEvent, aPresContext,
static_cast<nsSimpleGestureEvent*>(aEvent));
case NS_TOUCH_EVENT:
return NS_NewDOMTouchEvent(aDOMEvent, aPresContext,
static_cast<nsTouchEvent*>(aEvent));
case NS_TRANSITION_EVENT:
return NS_NewDOMTransitionEvent(aDOMEvent, aPresContext,
static_cast<nsTransitionEvent*>(aEvent));
case NS_ANIMATION_EVENT:
return NS_NewDOMAnimationEvent(aDOMEvent, aPresContext,
static_cast<nsAnimationEvent*>(aEvent));
}
// For all other types of events, create a vanilla event object.
return NS_NewDOMEvent(aDOMEvent, aPresContext, aEvent);
}
// And if we didn't get an event, check the type argument.
if (aEventType.LowerCaseEqualsLiteral("mouseevent") ||
aEventType.LowerCaseEqualsLiteral("mouseevents") ||
aEventType.LowerCaseEqualsLiteral("popupevents"))
return NS_NewDOMMouseEvent(aDOMEvent, aPresContext, nullptr);
if (aEventType.LowerCaseEqualsLiteral("mousescrollevents"))
return NS_NewDOMMouseScrollEvent(aDOMEvent, aPresContext, nullptr);
if (aEventType.LowerCaseEqualsLiteral("dragevent") ||
aEventType.LowerCaseEqualsLiteral("dragevents"))
return NS_NewDOMDragEvent(aDOMEvent, aPresContext, nullptr);
if (aEventType.LowerCaseEqualsLiteral("keyboardevent") ||
aEventType.LowerCaseEqualsLiteral("keyevents"))
return NS_NewDOMKeyboardEvent(aDOMEvent, aPresContext, nullptr);
if (aEventType.LowerCaseEqualsLiteral("compositionevent"))
return NS_NewDOMCompositionEvent(aDOMEvent, aPresContext, nullptr);
if (aEventType.LowerCaseEqualsLiteral("mutationevent") ||
aEventType.LowerCaseEqualsLiteral("mutationevents"))
return NS_NewDOMMutationEvent(aDOMEvent, aPresContext, nullptr);
if (aEventType.LowerCaseEqualsLiteral("textevent") ||
aEventType.LowerCaseEqualsLiteral("textevents"))
return NS_NewDOMTextEvent(aDOMEvent, aPresContext, nullptr);
if (aEventType.LowerCaseEqualsLiteral("popupblockedevents"))
return NS_NewDOMPopupBlockedEvent(aDOMEvent, aPresContext, nullptr);
if (aEventType.LowerCaseEqualsLiteral("deviceorientationevent"))
return NS_NewDOMDeviceOrientationEvent(aDOMEvent, aPresContext, nullptr);
if (aEventType.LowerCaseEqualsLiteral("devicemotionevent"))
//.........这里部分代码省略.........
示例14: NS_NewDOMMutationEvent
/* static */ nsresult
EventDispatcher::CreateEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent,
const nsAString& aEventType,
nsIDOMEvent** aDOMEvent)
{
*aDOMEvent = nullptr;
if (aEvent) {
switch(aEvent->eventStructType) {
case NS_MUTATION_EVENT:
return NS_NewDOMMutationEvent(aDOMEvent, aOwner, aPresContext,
aEvent->AsMutationEvent());
case NS_GUI_EVENT:
case NS_SCROLLPORT_EVENT:
case NS_UI_EVENT:
return NS_NewDOMUIEvent(aDOMEvent, aOwner, aPresContext,
aEvent->AsGUIEvent());
case NS_SCROLLAREA_EVENT:
return NS_NewDOMScrollAreaEvent(aDOMEvent, aOwner, aPresContext,
aEvent->AsScrollAreaEvent());
case NS_KEY_EVENT:
return NS_NewDOMKeyboardEvent(aDOMEvent, aOwner, aPresContext,
aEvent->AsKeyboardEvent());
case NS_COMPOSITION_EVENT:
return NS_NewDOMCompositionEvent(aDOMEvent, aOwner, aPresContext,
aEvent->AsCompositionEvent());
case NS_MOUSE_EVENT:
return NS_NewDOMMouseEvent(aDOMEvent, aOwner, aPresContext,
aEvent->AsMouseEvent());
case NS_FOCUS_EVENT:
return NS_NewDOMFocusEvent(aDOMEvent, aOwner, aPresContext,
aEvent->AsFocusEvent());
case NS_MOUSE_SCROLL_EVENT:
return NS_NewDOMMouseScrollEvent(aDOMEvent, aOwner, aPresContext,
aEvent->AsMouseScrollEvent());
case NS_WHEEL_EVENT:
return NS_NewDOMWheelEvent(aDOMEvent, aOwner, aPresContext,
aEvent->AsWheelEvent());
case NS_EDITOR_INPUT_EVENT:
return NS_NewDOMInputEvent(aDOMEvent, aOwner, aPresContext,
aEvent->AsEditorInputEvent());
case NS_DRAG_EVENT:
return NS_NewDOMDragEvent(aDOMEvent, aOwner, aPresContext,
aEvent->AsDragEvent());
case NS_TEXT_EVENT:
return NS_NewDOMUIEvent(aDOMEvent, aOwner, aPresContext,
aEvent->AsTextEvent());
case NS_CLIPBOARD_EVENT:
return NS_NewDOMClipboardEvent(aDOMEvent, aOwner, aPresContext,
aEvent->AsClipboardEvent());
case NS_SVGZOOM_EVENT:
return NS_NewDOMSVGZoomEvent(aDOMEvent, aOwner, aPresContext,
aEvent->AsGUIEvent());
case NS_SMIL_TIME_EVENT:
return NS_NewDOMTimeEvent(aDOMEvent, aOwner, aPresContext, aEvent);
case NS_COMMAND_EVENT:
return NS_NewDOMCommandEvent(aDOMEvent, aOwner, aPresContext,
aEvent->AsCommandEvent());
case NS_SIMPLE_GESTURE_EVENT:
return NS_NewDOMSimpleGestureEvent(aDOMEvent, aOwner, aPresContext,
aEvent->AsSimpleGestureEvent());
case NS_POINTER_EVENT:
return NS_NewDOMPointerEvent(aDOMEvent, aOwner, aPresContext,
aEvent->AsPointerEvent());
case NS_TOUCH_EVENT:
return NS_NewDOMTouchEvent(aDOMEvent, aOwner, aPresContext,
aEvent->AsTouchEvent());
case NS_TRANSITION_EVENT:
return NS_NewDOMTransitionEvent(aDOMEvent, aOwner, aPresContext,
aEvent->AsTransitionEvent());
case NS_ANIMATION_EVENT:
return NS_NewDOMAnimationEvent(aDOMEvent, aOwner, aPresContext,
aEvent->AsAnimationEvent());
default:
// For all other types of events, create a vanilla event object.
return NS_NewDOMEvent(aDOMEvent, aOwner, aPresContext, aEvent);
}
}
// And if we didn't get an event, check the type argument.
if (aEventType.LowerCaseEqualsLiteral("mouseevent") ||
aEventType.LowerCaseEqualsLiteral("mouseevents") ||
aEventType.LowerCaseEqualsLiteral("popupevents"))
return NS_NewDOMMouseEvent(aDOMEvent, aOwner, aPresContext, nullptr);
if (aEventType.LowerCaseEqualsLiteral("mousescrollevents"))
return NS_NewDOMMouseScrollEvent(aDOMEvent, aOwner, aPresContext, nullptr);
if (aEventType.LowerCaseEqualsLiteral("dragevent") ||
aEventType.LowerCaseEqualsLiteral("dragevents"))
return NS_NewDOMDragEvent(aDOMEvent, aOwner, aPresContext, nullptr);
if (aEventType.LowerCaseEqualsLiteral("keyboardevent") ||
aEventType.LowerCaseEqualsLiteral("keyevents"))
return NS_NewDOMKeyboardEvent(aDOMEvent, aOwner, aPresContext, nullptr);
if (aEventType.LowerCaseEqualsLiteral("compositionevent"))
return NS_NewDOMCompositionEvent(aDOMEvent, aOwner, aPresContext, nullptr);
if (aEventType.LowerCaseEqualsLiteral("mutationevent") ||
aEventType.LowerCaseEqualsLiteral("mutationevents"))
//.........这里部分代码省略.........