Bug 1648010 - Replace uses of NS_LITERAL_STRING/NS_LITERAL_CSTRING macros by _ns literals. r=geckoview-reviewers,jgilbert,agi,hsivonen,froydnj

Differential Revision: https://phabricator.services.mozilla.com/D80860
This commit is contained in:
Simon Giesecke 2020-07-01 08:29:29 +00:00
parent 675da38265
commit cd8b8939b9
1219 changed files with 10215 additions and 12215 deletions

View file

@ -538,7 +538,7 @@ void AccessibleWrap::GetRoleDescription(role aRole,
if (aRole == roles::HEADING && aAttributes) { if (aRole == roles::HEADING && aAttributes) {
// The heading level is an attribute, so we need that. // The heading level is an attribute, so we need that.
AutoTArray<nsString, 1> formatString; AutoTArray<nsString, 1> formatString;
nsresult rv = aAttributes->GetStringProperty(NS_LITERAL_CSTRING("level"), nsresult rv = aAttributes->GetStringProperty("level"_ns,
*formatString.AppendElement()); *formatString.AppendElement());
if (NS_SUCCEEDED(rv) && if (NS_SUCCEEDED(rv) &&
LocalizeString("headingLevel", aRoleDescription, formatString)) { LocalizeString("headingLevel", aRoleDescription, formatString)) {
@ -548,8 +548,8 @@ void AccessibleWrap::GetRoleDescription(role aRole,
if ((aRole == roles::LANDMARK || aRole == roles::REGION) && aAttributes) { if ((aRole == roles::LANDMARK || aRole == roles::REGION) && aAttributes) {
nsAutoString xmlRoles; nsAutoString xmlRoles;
if (NS_SUCCEEDED(aAttributes->GetStringProperty( if (NS_SUCCEEDED(
NS_LITERAL_CSTRING("xml-roles"), xmlRoles))) { aAttributes->GetStringProperty("xml-roles"_ns, xmlRoles))) {
nsWhitespaceTokenizer tokenizer(xmlRoles); nsWhitespaceTokenizer tokenizer(xmlRoles);
while (tokenizer.hasMoreTokens()) { while (tokenizer.hasMoreTokens()) {
if (LocalizeString(NS_ConvertUTF16toUTF8(tokenizer.nextToken()).get(), if (LocalizeString(NS_ConvertUTF16toUTF8(tokenizer.nextToken()).get(),
@ -798,8 +798,7 @@ mozilla::java::GeckoBundle::LocalRef AccessibleWrap::ToBundle(
} }
nsString posinset; nsString posinset;
nsresult rv = aAttributes->GetStringProperty(NS_LITERAL_CSTRING("posinset"), nsresult rv = aAttributes->GetStringProperty("posinset"_ns, posinset);
posinset);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
int32_t rowIndex; int32_t rowIndex;
if (sscanf(NS_ConvertUTF16toUTF8(posinset).get(), "%d", &rowIndex) > 0) { if (sscanf(NS_ConvertUTF16toUTF8(posinset).get(), "%d", &rowIndex) > 0) {
@ -819,8 +818,7 @@ mozilla::java::GeckoBundle::LocalRef AccessibleWrap::ToBundle(
} }
nsString colSize; nsString colSize;
rv = aAttributes->GetStringProperty(NS_LITERAL_CSTRING("child-item-count"), rv = aAttributes->GetStringProperty("child-item-count"_ns, colSize);
colSize);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
int32_t rowCount; int32_t rowCount;
if (sscanf(NS_ConvertUTF16toUTF8(colSize).get(), "%d", &rowCount) > 0) { if (sscanf(NS_ConvertUTF16toUTF8(colSize).get(), "%d", &rowCount) > 0) {
@ -831,8 +829,7 @@ mozilla::java::GeckoBundle::LocalRef AccessibleWrap::ToBundle(
java::sdk::Integer::ValueOf(1)); java::sdk::Integer::ValueOf(1));
nsString unused; nsString unused;
rv = aAttributes->GetStringProperty(NS_LITERAL_CSTRING("hierarchical"), rv = aAttributes->GetStringProperty("hierarchical"_ns, unused);
unused);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
GECKOBUNDLE_PUT(collectionInfo, "isHierarchical", GECKOBUNDLE_PUT(collectionInfo, "isHierarchical",
java::sdk::Boolean::TRUE()); java::sdk::Boolean::TRUE());
@ -897,8 +894,7 @@ bool AccessibleWrap::HandleLiveRegionEvent(AccEvent* aEvent) {
nsCOMPtr<nsIPersistentProperties> attributes = Attributes(); nsCOMPtr<nsIPersistentProperties> attributes = Attributes();
nsString live; nsString live;
nsresult rv = nsresult rv = attributes->GetStringProperty("container-live"_ns, live);
attributes->GetStringProperty(NS_LITERAL_CSTRING("container-live"), live);
if (!NS_SUCCEEDED(rv)) { if (!NS_SUCCEEDED(rv)) {
return false; return false;
} }
@ -908,8 +904,7 @@ bool AccessibleWrap::HandleLiveRegionEvent(AccEvent* aEvent) {
: nsIAccessibleAnnouncementEvent::POLITE; : nsIAccessibleAnnouncementEvent::POLITE;
nsString atomic; nsString atomic;
rv = attributes->GetStringProperty(NS_LITERAL_CSTRING("container-atomic"), rv = attributes->GetStringProperty("container-atomic"_ns, atomic);
atomic);
Accessible* announcementTarget = this; Accessible* announcementTarget = this;
nsAutoString announcement; nsAutoString announcement;

View file

@ -82,7 +82,7 @@ void AccessibleNode::GetComputedRole(nsAString& aRole) {
void AccessibleNode::GetStates(nsTArray<nsString>& aStates) { void AccessibleNode::GetStates(nsTArray<nsString>& aStates) {
nsAccessibilityService* accService = GetOrCreateAccService(); nsAccessibilityService* accService = GetOrCreateAccService();
if (!mIntl || !accService) { if (!mIntl || !accService) {
aStates.AppendElement(NS_LITERAL_STRING("defunct")); aStates.AppendElement(u"defunct"_ns);
return; return;
} }

View file

@ -315,11 +315,10 @@ dbus_done:
nsCOMPtr<nsIGSettingsCollection> a11y_settings; nsCOMPtr<nsIGSettingsCollection> a11y_settings;
if (gsettings) { if (gsettings) {
gsettings->GetCollectionForSchema( gsettings->GetCollectionForSchema(nsLiteralCString(GSETINGS_A11Y_INTERFACE),
NS_LITERAL_CSTRING(GSETINGS_A11Y_INTERFACE),
getter_AddRefs(a11y_settings)); getter_AddRefs(a11y_settings));
if (a11y_settings) { if (a11y_settings) {
a11y_settings->GetBoolean(NS_LITERAL_CSTRING(GSETINGS_A11Y_KEY), a11y_settings->GetBoolean(nsLiteralCString(GSETINGS_A11Y_KEY),
&sShouldEnable); &sShouldEnable);
} }
} }

View file

@ -1469,8 +1469,7 @@ bool AttrIterator::Next(nsAString& aAttrName, nsAString& aAttrValue) {
if (attr->NamespaceEquals(kNameSpaceID_None)) { if (attr->NamespaceEquals(kNameSpaceID_None)) {
nsAtom* attrAtom = attr->Atom(); nsAtom* attrAtom = attr->Atom();
nsDependentAtomString attrStr(attrAtom); nsDependentAtomString attrStr(attrAtom);
if (!StringBeginsWith(attrStr, NS_LITERAL_STRING("aria-"))) if (!StringBeginsWith(attrStr, u"aria-"_ns)) continue; // Not ARIA
continue; // Not ARIA
uint8_t attrFlags = aria::AttrCharacteristicsFor(attrAtom); uint8_t attrFlags = aria::AttrCharacteristicsFor(attrAtom);
if (attrFlags & ATTR_BYPASSOBJ) if (attrFlags & ATTR_BYPASSOBJ)

View file

@ -387,8 +387,7 @@ void DocManager::AddListeners(Document* aDocument,
nsPIDOMWindowOuter* window = aDocument->GetWindow(); nsPIDOMWindowOuter* window = aDocument->GetWindow();
EventTarget* target = window->GetChromeEventHandler(); EventTarget* target = window->GetChromeEventHandler();
EventListenerManager* elm = target->GetOrCreateListenerManager(); EventListenerManager* elm = target->GetOrCreateListenerManager();
elm->AddEventListenerByType(this, NS_LITERAL_STRING("pagehide"), elm->AddEventListenerByType(this, u"pagehide"_ns, TrustedEventsAtCapture());
TrustedEventsAtCapture());
#ifdef A11Y_LOG #ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDocCreate)) if (logging::IsEnabled(logging::eDocCreate))
@ -396,7 +395,7 @@ void DocManager::AddListeners(Document* aDocument,
#endif #endif
if (aAddDOMContentLoadedListener) { if (aAddDOMContentLoadedListener) {
elm->AddEventListenerByType(this, NS_LITERAL_STRING("DOMContentLoaded"), elm->AddEventListenerByType(this, u"DOMContentLoaded"_ns,
TrustedEventsAtCapture()); TrustedEventsAtCapture());
#ifdef A11Y_LOG #ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDocCreate)) if (logging::IsEnabled(logging::eDocCreate))
@ -413,10 +412,10 @@ void DocManager::RemoveListeners(Document* aDocument) {
if (!target) return; if (!target) return;
EventListenerManager* elm = target->GetOrCreateListenerManager(); EventListenerManager* elm = target->GetOrCreateListenerManager();
elm->RemoveEventListenerByType(this, NS_LITERAL_STRING("pagehide"), elm->RemoveEventListenerByType(this, u"pagehide"_ns,
TrustedEventsAtCapture()); TrustedEventsAtCapture());
elm->RemoveEventListenerByType(this, NS_LITERAL_STRING("DOMContentLoaded"), elm->RemoveEventListenerByType(this, u"DOMContentLoaded"_ns,
TrustedEventsAtCapture()); TrustedEventsAtCapture());
} }

View file

@ -80,8 +80,7 @@ MARKUPMAP(
nsAutoString displayValue; nsAutoString displayValue;
StyleInfo styleInfo(aElement); StyleInfo styleInfo(aElement);
styleInfo.Display(displayValue); styleInfo.Display(displayValue);
if (displayValue != NS_LITERAL_STRING("block") && if (displayValue != u"block"_ns && displayValue != u"inline-block"_ns) {
displayValue != NS_LITERAL_STRING("inline-block")) {
return nullptr; return nullptr;
} }
// Check for various conditions to determine if this is a block // Check for various conditions to determine if this is a block

View file

@ -237,23 +237,19 @@ void TextAttrsMgr::InvalidTextAttr::ExposeValue(
nsIPersistentProperties* aAttributes, const uint32_t& aValue) { nsIPersistentProperties* aAttributes, const uint32_t& aValue) {
switch (aValue) { switch (aValue) {
case eFalse: case eFalse:
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid, nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid, u"false"_ns);
NS_LITERAL_STRING("false"));
break; break;
case eGrammar: case eGrammar:
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid, nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid, u"grammar"_ns);
NS_LITERAL_STRING("grammar"));
break; break;
case eSpelling: case eSpelling:
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid, nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid, u"spelling"_ns);
NS_LITERAL_STRING("spelling"));
break; break;
case eTrue: case eTrue:
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid, nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid, u"true"_ns);
NS_LITERAL_STRING("true"));
break; break;
} }
} }
@ -592,9 +588,8 @@ bool TextAttrsMgr::AutoGeneratedTextAttr::GetValueFor(Accessible* aAccessible,
void TextAttrsMgr::AutoGeneratedTextAttr::ExposeValue( void TextAttrsMgr::AutoGeneratedTextAttr::ExposeValue(
nsIPersistentProperties* aAttributes, const bool& aValue) { nsIPersistentProperties* aAttributes, const bool& aValue) {
nsAccUtils::SetAccAttr( nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::auto_generated,
aAttributes, nsGkAtoms::auto_generated, aValue ? u"true"_ns : u"false"_ns);
aValue ? NS_LITERAL_STRING("true") : NS_LITERAL_STRING("false"));
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -697,17 +692,15 @@ void TextAttrsMgr::TextPosTextAttr::ExposeValue(
switch (aValue) { switch (aValue) {
case eTextPosBaseline: case eTextPosBaseline:
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textPosition, nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textPosition,
NS_LITERAL_STRING("baseline")); u"baseline"_ns);
break; break;
case eTextPosSub: case eTextPosSub:
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textPosition, nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textPosition, u"sub"_ns);
NS_LITERAL_STRING("sub"));
break; break;
case eTextPosSuper: case eTextPosSuper:
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textPosition, nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textPosition, u"super"_ns);
NS_LITERAL_STRING("super"));
break; break;
case eTextPosNone: case eTextPosNone:

View file

@ -38,7 +38,7 @@ XULMAP_TYPE(toolbarbutton, XULToolbarButtonAccessible)
XULMAP_TYPE(tooltip, XULTooltipAccessible) XULMAP_TYPE(tooltip, XULTooltipAccessible)
XULMAP(label, [](Element* aElement, Accessible* aContext) -> Accessible* { XULMAP(label, [](Element* aElement, Accessible* aContext) -> Accessible* {
if (aElement->ClassList()->Contains(NS_LITERAL_STRING("text-link"))) { if (aElement->ClassList()->Contains(u"text-link"_ns)) {
return new XULLinkAccessible(aElement, aContext->Document()); return new XULLinkAccessible(aElement, aContext->Document());
} }
return new XULLabelAccessible(aElement, aContext->Document()); return new XULLabelAccessible(aElement, aContext->Document());

View file

@ -161,8 +161,7 @@ void nsAccUtils::SetLiveContainerAttributes(
if (ancestor->IsElement() && ancestor->AsElement()->AttrValueIs( if (ancestor->IsElement() && ancestor->AsElement()->AttrValueIs(
kNameSpaceID_None, nsGkAtoms::aria_atomic, kNameSpaceID_None, nsGkAtoms::aria_atomic,
nsGkAtoms::_true, eCaseMatters)) { nsGkAtoms::_true, eCaseMatters)) {
SetAccAttr(aAttributes, nsGkAtoms::containerAtomic, SetAccAttr(aAttributes, nsGkAtoms::containerAtomic, u"true"_ns);
NS_LITERAL_STRING("true"));
} }
// container-busy attribute // container-busy attribute
@ -357,10 +356,10 @@ nsIntPoint nsAccUtils::GetScreenCoordsForParent(Accessible* aAccessible) {
bool nsAccUtils::GetLiveAttrValue(uint32_t aRule, nsAString& aValue) { bool nsAccUtils::GetLiveAttrValue(uint32_t aRule, nsAString& aValue) {
switch (aRule) { switch (aRule) {
case eOffLiveAttr: case eOffLiveAttr:
aValue = NS_LITERAL_STRING("off"); aValue = u"off"_ns;
return true; return true;
case ePoliteLiveAttr: case ePoliteLiveAttr:
aValue = NS_LITERAL_STRING("polite"); aValue = u"polite"_ns;
return true; return true;
} }

View file

@ -123,8 +123,7 @@ static bool MustBeAccessible(nsIContent* aContent, DocAccessible* aDocument) {
} }
nsDependentAtomString attrStr(attrAtom); nsDependentAtomString attrStr(attrAtom);
if (!StringBeginsWith(attrStr, NS_LITERAL_STRING("aria-"))) if (!StringBeginsWith(attrStr, u"aria-"_ns)) continue; // not ARIA
continue; // not ARIA
// A global state or a property and in case of token defined. // A global state or a property and in case of token defined.
uint8_t attrFlags = aria::AttrCharacteristicsFor(attrAtom); uint8_t attrFlags = aria::AttrCharacteristicsFor(attrAtom);
@ -702,7 +701,7 @@ void nsAccessibilityService::GetStringStates(uint32_t aState,
// unknown state // unknown state
if (!stringStates->Length()) { if (!stringStates->Length()) {
stringStates->Add(NS_LITERAL_STRING("unknown")); stringStates->Add(u"unknown"_ns);
} }
stringStates.forget(aStringStates); stringStates.forget(aStringStates);
@ -713,148 +712,148 @@ already_AddRefed<DOMStringList> nsAccessibilityService::GetStringStates(
RefPtr<DOMStringList> stringStates = new DOMStringList(); RefPtr<DOMStringList> stringStates = new DOMStringList();
if (aStates & states::UNAVAILABLE) { if (aStates & states::UNAVAILABLE) {
stringStates->Add(NS_LITERAL_STRING("unavailable")); stringStates->Add(u"unavailable"_ns);
} }
if (aStates & states::SELECTED) { if (aStates & states::SELECTED) {
stringStates->Add(NS_LITERAL_STRING("selected")); stringStates->Add(u"selected"_ns);
} }
if (aStates & states::FOCUSED) { if (aStates & states::FOCUSED) {
stringStates->Add(NS_LITERAL_STRING("focused")); stringStates->Add(u"focused"_ns);
} }
if (aStates & states::PRESSED) { if (aStates & states::PRESSED) {
stringStates->Add(NS_LITERAL_STRING("pressed")); stringStates->Add(u"pressed"_ns);
} }
if (aStates & states::CHECKED) { if (aStates & states::CHECKED) {
stringStates->Add(NS_LITERAL_STRING("checked")); stringStates->Add(u"checked"_ns);
} }
if (aStates & states::MIXED) { if (aStates & states::MIXED) {
stringStates->Add(NS_LITERAL_STRING("mixed")); stringStates->Add(u"mixed"_ns);
} }
if (aStates & states::READONLY) { if (aStates & states::READONLY) {
stringStates->Add(NS_LITERAL_STRING("readonly")); stringStates->Add(u"readonly"_ns);
} }
if (aStates & states::HOTTRACKED) { if (aStates & states::HOTTRACKED) {
stringStates->Add(NS_LITERAL_STRING("hottracked")); stringStates->Add(u"hottracked"_ns);
} }
if (aStates & states::DEFAULT) { if (aStates & states::DEFAULT) {
stringStates->Add(NS_LITERAL_STRING("default")); stringStates->Add(u"default"_ns);
} }
if (aStates & states::EXPANDED) { if (aStates & states::EXPANDED) {
stringStates->Add(NS_LITERAL_STRING("expanded")); stringStates->Add(u"expanded"_ns);
} }
if (aStates & states::COLLAPSED) { if (aStates & states::COLLAPSED) {
stringStates->Add(NS_LITERAL_STRING("collapsed")); stringStates->Add(u"collapsed"_ns);
} }
if (aStates & states::BUSY) { if (aStates & states::BUSY) {
stringStates->Add(NS_LITERAL_STRING("busy")); stringStates->Add(u"busy"_ns);
} }
if (aStates & states::FLOATING) { if (aStates & states::FLOATING) {
stringStates->Add(NS_LITERAL_STRING("floating")); stringStates->Add(u"floating"_ns);
} }
if (aStates & states::ANIMATED) { if (aStates & states::ANIMATED) {
stringStates->Add(NS_LITERAL_STRING("animated")); stringStates->Add(u"animated"_ns);
} }
if (aStates & states::INVISIBLE) { if (aStates & states::INVISIBLE) {
stringStates->Add(NS_LITERAL_STRING("invisible")); stringStates->Add(u"invisible"_ns);
} }
if (aStates & states::OFFSCREEN) { if (aStates & states::OFFSCREEN) {
stringStates->Add(NS_LITERAL_STRING("offscreen")); stringStates->Add(u"offscreen"_ns);
} }
if (aStates & states::SIZEABLE) { if (aStates & states::SIZEABLE) {
stringStates->Add(NS_LITERAL_STRING("sizeable")); stringStates->Add(u"sizeable"_ns);
} }
if (aStates & states::MOVEABLE) { if (aStates & states::MOVEABLE) {
stringStates->Add(NS_LITERAL_STRING("moveable")); stringStates->Add(u"moveable"_ns);
} }
if (aStates & states::SELFVOICING) { if (aStates & states::SELFVOICING) {
stringStates->Add(NS_LITERAL_STRING("selfvoicing")); stringStates->Add(u"selfvoicing"_ns);
} }
if (aStates & states::FOCUSABLE) { if (aStates & states::FOCUSABLE) {
stringStates->Add(NS_LITERAL_STRING("focusable")); stringStates->Add(u"focusable"_ns);
} }
if (aStates & states::SELECTABLE) { if (aStates & states::SELECTABLE) {
stringStates->Add(NS_LITERAL_STRING("selectable")); stringStates->Add(u"selectable"_ns);
} }
if (aStates & states::LINKED) { if (aStates & states::LINKED) {
stringStates->Add(NS_LITERAL_STRING("linked")); stringStates->Add(u"linked"_ns);
} }
if (aStates & states::TRAVERSED) { if (aStates & states::TRAVERSED) {
stringStates->Add(NS_LITERAL_STRING("traversed")); stringStates->Add(u"traversed"_ns);
} }
if (aStates & states::MULTISELECTABLE) { if (aStates & states::MULTISELECTABLE) {
stringStates->Add(NS_LITERAL_STRING("multiselectable")); stringStates->Add(u"multiselectable"_ns);
} }
if (aStates & states::EXTSELECTABLE) { if (aStates & states::EXTSELECTABLE) {
stringStates->Add(NS_LITERAL_STRING("extselectable")); stringStates->Add(u"extselectable"_ns);
} }
if (aStates & states::PROTECTED) { if (aStates & states::PROTECTED) {
stringStates->Add(NS_LITERAL_STRING("protected")); stringStates->Add(u"protected"_ns);
} }
if (aStates & states::HASPOPUP) { if (aStates & states::HASPOPUP) {
stringStates->Add(NS_LITERAL_STRING("haspopup")); stringStates->Add(u"haspopup"_ns);
} }
if (aStates & states::REQUIRED) { if (aStates & states::REQUIRED) {
stringStates->Add(NS_LITERAL_STRING("required")); stringStates->Add(u"required"_ns);
} }
if (aStates & states::ALERT) { if (aStates & states::ALERT) {
stringStates->Add(NS_LITERAL_STRING("alert")); stringStates->Add(u"alert"_ns);
} }
if (aStates & states::INVALID) { if (aStates & states::INVALID) {
stringStates->Add(NS_LITERAL_STRING("invalid")); stringStates->Add(u"invalid"_ns);
} }
if (aStates & states::CHECKABLE) { if (aStates & states::CHECKABLE) {
stringStates->Add(NS_LITERAL_STRING("checkable")); stringStates->Add(u"checkable"_ns);
} }
if (aStates & states::SUPPORTS_AUTOCOMPLETION) { if (aStates & states::SUPPORTS_AUTOCOMPLETION) {
stringStates->Add(NS_LITERAL_STRING("autocompletion")); stringStates->Add(u"autocompletion"_ns);
} }
if (aStates & states::DEFUNCT) { if (aStates & states::DEFUNCT) {
stringStates->Add(NS_LITERAL_STRING("defunct")); stringStates->Add(u"defunct"_ns);
} }
if (aStates & states::SELECTABLE_TEXT) { if (aStates & states::SELECTABLE_TEXT) {
stringStates->Add(NS_LITERAL_STRING("selectable text")); stringStates->Add(u"selectable text"_ns);
} }
if (aStates & states::EDITABLE) { if (aStates & states::EDITABLE) {
stringStates->Add(NS_LITERAL_STRING("editable")); stringStates->Add(u"editable"_ns);
} }
if (aStates & states::ACTIVE) { if (aStates & states::ACTIVE) {
stringStates->Add(NS_LITERAL_STRING("active")); stringStates->Add(u"active"_ns);
} }
if (aStates & states::MODAL) { if (aStates & states::MODAL) {
stringStates->Add(NS_LITERAL_STRING("modal")); stringStates->Add(u"modal"_ns);
} }
if (aStates & states::MULTI_LINE) { if (aStates & states::MULTI_LINE) {
stringStates->Add(NS_LITERAL_STRING("multi line")); stringStates->Add(u"multi line"_ns);
} }
if (aStates & states::HORIZONTAL) { if (aStates & states::HORIZONTAL) {
stringStates->Add(NS_LITERAL_STRING("horizontal")); stringStates->Add(u"horizontal"_ns);
} }
if (aStates & states::OPAQUE1) { if (aStates & states::OPAQUE1) {
stringStates->Add(NS_LITERAL_STRING("opaque")); stringStates->Add(u"opaque"_ns);
} }
if (aStates & states::SINGLE_LINE) { if (aStates & states::SINGLE_LINE) {
stringStates->Add(NS_LITERAL_STRING("single line")); stringStates->Add(u"single line"_ns);
} }
if (aStates & states::TRANSIENT) { if (aStates & states::TRANSIENT) {
stringStates->Add(NS_LITERAL_STRING("transient")); stringStates->Add(u"transient"_ns);
} }
if (aStates & states::VERTICAL) { if (aStates & states::VERTICAL) {
stringStates->Add(NS_LITERAL_STRING("vertical")); stringStates->Add(u"vertical"_ns);
} }
if (aStates & states::STALE) { if (aStates & states::STALE) {
stringStates->Add(NS_LITERAL_STRING("stale")); stringStates->Add(u"stale"_ns);
} }
if (aStates & states::ENABLED) { if (aStates & states::ENABLED) {
stringStates->Add(NS_LITERAL_STRING("enabled")); stringStates->Add(u"enabled"_ns);
} }
if (aStates & states::SENSITIVE) { if (aStates & states::SENSITIVE) {
stringStates->Add(NS_LITERAL_STRING("sensitive")); stringStates->Add(u"sensitive"_ns);
} }
if (aStates & states::PINNED) { if (aStates & states::PINNED) {
stringStates->Add(NS_LITERAL_STRING("pinned")); stringStates->Add(u"pinned"_ns);
} }
if (aStates & states::CURRENT) { if (aStates & states::CURRENT) {
stringStates->Add(NS_LITERAL_STRING("current")); stringStates->Add(u"current"_ns);
} }
return stringStates.forget(); return stringStates.forget();
@ -1280,7 +1279,7 @@ bool nsAccessibilityService::Init() {
gApplicationAccessible->Init(); gApplicationAccessible->Init();
CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::Accessibility, CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::Accessibility,
NS_LITERAL_CSTRING("Active")); "Active"_ns);
#ifdef XP_WIN #ifdef XP_WIN
sPendingPlugins = new nsTArray<nsCOMPtr<nsIContent> >; sPendingPlugins = new nsTArray<nsCOMPtr<nsIContent> >;

View file

@ -61,8 +61,7 @@ void nsEventShell::GetEventAttributes(nsINode* aNode,
if (aNode != sEventTargetNode) return; if (aNode != sEventTargetNode) return;
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::eventFromInput, nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::eventFromInput,
sEventFromUserInput ? NS_LITERAL_STRING("true") sEventFromUserInput ? u"true"_ns : u"false"_ns);
: NS_LITERAL_STRING("false"));
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -42,8 +42,7 @@ ARIAGridAccessible::NativeAttributes() {
if (IsProbablyLayoutTable()) { if (IsProbablyLayoutTable()) {
nsAutoString unused; nsAutoString unused;
attributes->SetStringProperty(NS_LITERAL_CSTRING("layout-guess"), attributes->SetStringProperty("layout-guess"_ns, u"true"_ns, unused);
NS_LITERAL_STRING("true"), unused);
} }
return attributes.forget(); return attributes.forget();
@ -385,13 +384,11 @@ nsresult ARIAGridAccessible::SetARIASelected(Accessible* aAccessible,
nsresult rv = NS_OK; nsresult rv = NS_OK;
if (content->IsElement()) { if (content->IsElement()) {
if (aIsSelected) if (aIsSelected)
rv = content->AsElement()->SetAttr(kNameSpaceID_None, rv = content->AsElement()->SetAttr(
nsGkAtoms::aria_selected, kNameSpaceID_None, nsGkAtoms::aria_selected, u"true"_ns, aNotify);
NS_LITERAL_STRING("true"), aNotify);
else else
rv = content->AsElement()->SetAttr(kNameSpaceID_None, rv = content->AsElement()->SetAttr(
nsGkAtoms::aria_selected, kNameSpaceID_None, nsGkAtoms::aria_selected, u"false"_ns, aNotify);
NS_LITERAL_STRING("false"), aNotify);
} }
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -608,8 +605,7 @@ ARIAGridCellAccessible::NativeAttributes() {
#ifdef DEBUG #ifdef DEBUG
nsAutoString unused; nsAutoString unused;
attributes->SetStringProperty(NS_LITERAL_CSTRING("cppclass"), attributes->SetStringProperty("cppclass"_ns, u"ARIAGridCellAccessible"_ns,
NS_LITERAL_STRING("ARIAGridCellAccessible"),
unused); unused);
#endif #endif

View file

@ -675,9 +675,8 @@ void Accessible::SetSelected(bool aSelect) {
if (select->State() & states::MULTISELECTABLE) { if (select->State() & states::MULTISELECTABLE) {
if (mContent->IsElement() && ARIARoleMap()) { if (mContent->IsElement() && ARIARoleMap()) {
if (aSelect) { if (aSelect) {
mContent->AsElement()->SetAttr(kNameSpaceID_None, mContent->AsElement()->SetAttr(
nsGkAtoms::aria_selected, kNameSpaceID_None, nsGkAtoms::aria_selected, u"true"_ns, true);
NS_LITERAL_STRING("true"), true);
} else { } else {
mContent->AsElement()->UnsetAttr(kNameSpaceID_None, mContent->AsElement()->UnsetAttr(kNameSpaceID_None,
nsGkAtoms::aria_selected, true); nsGkAtoms::aria_selected, true);
@ -957,7 +956,7 @@ already_AddRefed<nsIPersistentProperties> Accessible::Attributes() {
if (roleMapEntry) { if (roleMapEntry) {
if (roleMapEntry->Is(nsGkAtoms::searchbox)) { if (roleMapEntry->Is(nsGkAtoms::searchbox)) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::textInputType, nsAccUtils::SetAccAttr(attributes, nsGkAtoms::textInputType,
NS_LITERAL_STRING("search")); u"search"_ns);
} }
nsAutoString live; nsAutoString live;
@ -983,21 +982,18 @@ already_AddRefed<nsIPersistentProperties> Accessible::NativeAttributes() {
if (HasNumericValue()) { if (HasNumericValue()) {
nsAutoString valuetext; nsAutoString valuetext;
Value(valuetext); Value(valuetext);
attributes->SetStringProperty(NS_LITERAL_CSTRING("valuetext"), valuetext, attributes->SetStringProperty("valuetext"_ns, valuetext, unused);
unused);
} }
// Expose checkable object attribute if the accessible has checkable state // Expose checkable object attribute if the accessible has checkable state
if (State() & states::CHECKABLE) { if (State() & states::CHECKABLE) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::checkable, nsAccUtils::SetAccAttr(attributes, nsGkAtoms::checkable, u"true"_ns);
NS_LITERAL_STRING("true"));
} }
// Expose 'explicit-name' attribute. // Expose 'explicit-name' attribute.
nsAutoString name; nsAutoString name;
if (Name(name) != eNameFromSubtree && !name.IsVoid()) { if (Name(name) != eNameFromSubtree && !name.IsVoid()) {
attributes->SetStringProperty(NS_LITERAL_CSTRING("explicit-name"), attributes->SetStringProperty("explicit-name"_ns, u"true"_ns, unused);
NS_LITERAL_STRING("true"), unused);
} }
// Group attributes (level/setsize/posinset) // Group attributes (level/setsize/posinset)
@ -1010,13 +1006,11 @@ already_AddRefed<nsIPersistentProperties> Accessible::NativeAttributes() {
if (itemCount) { if (itemCount) {
nsAutoString itemCountStr; nsAutoString itemCountStr;
itemCountStr.AppendInt(itemCount); itemCountStr.AppendInt(itemCount);
attributes->SetStringProperty(NS_LITERAL_CSTRING("child-item-count"), attributes->SetStringProperty("child-item-count"_ns, itemCountStr, unused);
itemCountStr, unused);
} }
if (hierarchical) { if (hierarchical) {
attributes->SetStringProperty(NS_LITERAL_CSTRING("hierarchical"), attributes->SetStringProperty("hierarchical"_ns, u"true"_ns, unused);
NS_LITERAL_STRING("true"), unused);
} }
// If the accessible doesn't have own content (such as list item bullet or // If the accessible doesn't have own content (such as list item bullet or
@ -1035,7 +1029,7 @@ already_AddRefed<nsIPersistentProperties> Accessible::NativeAttributes() {
nsAutoString id; nsAutoString id;
if (nsCoreUtils::GetID(mContent, id)) if (nsCoreUtils::GetID(mContent, id))
attributes->SetStringProperty(NS_LITERAL_CSTRING("id"), id, unused); attributes->SetStringProperty("id"_ns, id, unused);
// Expose class because it may have useful microformat information. // Expose class because it may have useful microformat information.
nsAutoString _class; nsAutoString _class;
@ -1051,8 +1045,7 @@ already_AddRefed<nsIPersistentProperties> Accessible::NativeAttributes() {
// Expose draggable object attribute. // Expose draggable object attribute.
if (auto htmlElement = nsGenericHTMLElement::FromNode(mContent)) { if (auto htmlElement = nsGenericHTMLElement::FromNode(mContent)) {
if (htmlElement->Draggable()) { if (htmlElement->Draggable()) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::draggable, nsAccUtils::SetAccAttr(attributes, nsGkAtoms::draggable, u"true"_ns);
NS_LITERAL_STRING("true"));
} }
} }
@ -1759,8 +1752,7 @@ Relation Accessible::RelationByType(RelationType aType) const {
nsIContent* buttonEl = nullptr; nsIContent* buttonEl = nullptr;
if (doc->AllowXULXBL()) { if (doc->AllowXULXBL()) {
nsCOMPtr<nsIHTMLCollection> possibleDefaultButtons = nsCOMPtr<nsIHTMLCollection> possibleDefaultButtons =
doc->GetElementsByAttribute(NS_LITERAL_STRING("default"), doc->GetElementsByAttribute(u"default"_ns, u"true"_ns);
NS_LITERAL_STRING("true"));
if (possibleDefaultButtons) { if (possibleDefaultButtons) {
uint32_t length = possibleDefaultButtons->Length(); uint32_t length = possibleDefaultButtons->Length();
// Check for button in list of default="true" elements // Check for button in list of default="true" elements

View file

@ -824,8 +824,7 @@ void DocAccessible::AttributeChangedImpl(Accessible* aAccessible,
// Check for namespaced ARIA attribute // Check for namespaced ARIA attribute
if (aNameSpaceID == kNameSpaceID_None) { if (aNameSpaceID == kNameSpaceID_None) {
// Check for hyphenated aria-foo property? // Check for hyphenated aria-foo property?
if (StringBeginsWith(nsDependentAtomString(aAttribute), if (StringBeginsWith(nsDependentAtomString(aAttribute), u"aria-"_ns)) {
NS_LITERAL_STRING("aria-"))) {
ARIAAttributeChanged(aAccessible, aAttribute); ARIAAttributeChanged(aAccessible, aAttribute);
} }
} }

View file

@ -1062,8 +1062,7 @@ HyperTextAccessible::NativeAttributes() {
nsIFrame* frame = GetFrame(); nsIFrame* frame = GetFrame();
if (frame && frame->IsBlockFrame()) { if (frame && frame->IsBlockFrame()) {
nsAutoString unused; nsAutoString unused;
attributes->SetStringProperty(NS_LITERAL_CSTRING("formatting"), attributes->SetStringProperty("formatting"_ns, u"block"_ns, unused);
NS_LITERAL_STRING("block"), unused);
} }
if (FocusMgr()->IsFocused(this)) { if (FocusMgr()->IsFocused(this)) {
@ -2056,8 +2055,7 @@ void HyperTextAccessible::GetSpellTextAttr(
if (endOffset < *aEndOffset) *aEndOffset = endOffset; if (endOffset < *aEndOffset) *aEndOffset = endOffset;
if (aAttributes) { if (aAttributes) {
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid, nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid, u"spelling"_ns);
NS_LITERAL_STRING("spelling"));
} }
return; return;

View file

@ -667,10 +667,10 @@ void RootAccessible::HandleTreeRowCountChangedEvent(
nsresult rv; nsresult rv;
int32_t index, count; int32_t index, count;
rv = propBag->GetPropertyAsInt32(NS_LITERAL_STRING("index"), &index); rv = propBag->GetPropertyAsInt32(u"index"_ns, &index);
if (NS_FAILED(rv)) return; if (NS_FAILED(rv)) return;
rv = propBag->GetPropertyAsInt32(NS_LITERAL_STRING("count"), &count); rv = propBag->GetPropertyAsInt32(u"count"_ns, &count);
if (NS_FAILED(rv)) return; if (NS_FAILED(rv)) return;
aAccessible->InvalidateCache(index, count); aAccessible->InvalidateCache(index, count);
@ -683,10 +683,10 @@ void RootAccessible::HandleTreeInvalidatedEvent(
if (!propBag) return; if (!propBag) return;
int32_t startRow = 0, endRow = -1, startCol = 0, endCol = -1; int32_t startRow = 0, endRow = -1, startCol = 0, endCol = -1;
propBag->GetPropertyAsInt32(NS_LITERAL_STRING("startrow"), &startRow); propBag->GetPropertyAsInt32(u"startrow"_ns, &startRow);
propBag->GetPropertyAsInt32(NS_LITERAL_STRING("endrow"), &endRow); propBag->GetPropertyAsInt32(u"endrow"_ns, &endRow);
propBag->GetPropertyAsInt32(NS_LITERAL_STRING("startcolumn"), &startCol); propBag->GetPropertyAsInt32(u"startcolumn"_ns, &startCol);
propBag->GetPropertyAsInt32(NS_LITERAL_STRING("endcolumn"), &endCol); propBag->GetPropertyAsInt32(u"endcolumn"_ns, &endCol);
aAccessible->TreeViewInvalidated(startRow, endRow, startCol, endCol); aAccessible->TreeViewInvalidated(startRow, endRow, startCol, endCol);
} }

View file

@ -31,8 +31,8 @@ bool TableAccessible::IsProbablyLayoutTable() {
# define RETURN_LAYOUT_ANSWER(isLayout, heuristic) \ # define RETURN_LAYOUT_ANSWER(isLayout, heuristic) \
{ \ { \
mLayoutHeuristic = isLayout \ mLayoutHeuristic = isLayout \
? NS_LITERAL_STRING("layout table: " heuristic) \ ? nsLiteralString(u"layout table: " heuristic) \
: NS_LITERAL_STRING("data table: " heuristic); \ : nsLiteralString(u"data table: " heuristic); \
return isLayout; \ return isLayout; \
} }
#else #else
@ -64,8 +64,8 @@ bool TableAccessible::IsProbablyLayoutTable() {
"Table should not be built by CSS display:table style"); "Table should not be built by CSS display:table style");
// Check if datatable attribute has "0" value. // Check if datatable attribute has "0" value.
if (el->AttrValueIs(kNameSpaceID_None, nsGkAtoms::datatable, if (el->AttrValueIs(kNameSpaceID_None, nsGkAtoms::datatable, u"0"_ns,
NS_LITERAL_STRING("0"), eCaseMatters)) { eCaseMatters)) {
RETURN_LAYOUT_ANSWER(true, "Has datatable = 0 attribute, it's for layout"); RETURN_LAYOUT_ANSWER(true, "Has datatable = 0 attribute, it's for layout");
} }
@ -130,7 +130,7 @@ bool TableAccessible::IsProbablyLayoutTable() {
// Check for nested tables. // Check for nested tables.
nsCOMPtr<nsIHTMLCollection> nestedTables = nsCOMPtr<nsIHTMLCollection> nestedTables =
el->GetElementsByTagName(NS_LITERAL_STRING("table")); el->GetElementsByTagName(u"table"_ns);
if (nestedTables->Length() > 0) { if (nestedTables->Length() > 0) {
RETURN_LAYOUT_ANSWER(true, "Has a nested table within it"); RETURN_LAYOUT_ANSWER(true, "Has a nested table within it");
} }
@ -222,9 +222,8 @@ bool TableAccessible::IsProbablyLayoutTable() {
RETURN_LAYOUT_ANSWER(true, "2-4 columns, 10 cells or less, non-bordered"); RETURN_LAYOUT_ANSWER(true, "2-4 columns, 10 cells or less, non-bordered");
} }
static const nsLiteralString tags[] = {NS_LITERAL_STRING("embed"), static const nsLiteralString tags[] = {u"embed"_ns, u"object"_ns,
NS_LITERAL_STRING("object"), u"iframe"_ns};
NS_LITERAL_STRING("iframe")};
for (auto& tag : tags) { for (auto& tag : tags) {
nsCOMPtr<nsIHTMLCollection> descendants = el->GetElementsByTagName(tag); nsCOMPtr<nsIHTMLCollection> descendants = el->GetElementsByTagName(tag);
if (descendants->Length() > 0) { if (descendants->Length() > 0) {

View file

@ -249,8 +249,7 @@ HTMLTextFieldAccessible::NativeAttributes() {
type)) { type)) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::textInputType, type); nsAccUtils::SetAccAttr(attributes, nsGkAtoms::textInputType, type);
if (!ARIARoleMap() && type.EqualsLiteral("search")) { if (!ARIARoleMap() && type.EqualsLiteral("search")) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles, nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles, u"searchbox"_ns);
NS_LITERAL_STRING("searchbox"));
} }
} }

View file

@ -114,7 +114,7 @@ class HTMLTextFieldAccessible : public HyperTextAccessibleWrap {
return el; return el;
} }
// XUL search-textbox custom element // XUL search-textbox custom element
return Elm()->Closest(NS_LITERAL_STRING("search-textbox"), IgnoreErrors()); return Elm()->Closest(u"search-textbox"_ns, IgnoreErrors());
} }
}; };

View file

@ -90,7 +90,7 @@ void HTMLSelectListAccessible::SetCurrentItem(const Accessible* aItem) {
if (!aItem->GetContent()->IsElement()) return; if (!aItem->GetContent()->IsElement()) return;
aItem->GetContent()->AsElement()->SetAttr( aItem->GetContent()->AsElement()->SetAttr(
kNameSpaceID_None, nsGkAtoms::selected, NS_LITERAL_STRING("true"), true); kNameSpaceID_None, nsGkAtoms::selected, u"true"_ns, true);
} }
bool HTMLSelectListAccessible::IsAcceptableChild(nsIContent* aEl) const { bool HTMLSelectListAccessible::IsAcceptableChild(nsIContent* aEl) const {

View file

@ -118,8 +118,7 @@ HTMLTableCellAccessible::NativeAttributes() {
#ifdef DEBUG #ifdef DEBUG
nsAutoString unused; nsAutoString unused;
attributes->SetStringProperty(NS_LITERAL_CSTRING("cppclass"), attributes->SetStringProperty("cppclass"_ns, u"HTMLTableCellAccessible"_ns,
NS_LITERAL_STRING("HTMLTableCellAccessible"),
unused); unused);
#endif #endif
@ -396,8 +395,7 @@ HTMLTableAccessible::NativeAttributes() {
if (IsProbablyLayoutTable()) { if (IsProbablyLayoutTable()) {
nsAutoString unused; nsAutoString unused;
attributes->SetStringProperty(NS_LITERAL_CSTRING("layout-guess"), attributes->SetStringProperty("layout-guess"_ns, u"true"_ns, unused);
NS_LITERAL_STRING("true"), unused);
} }
return attributes.forget(); return attributes.forget();

View file

@ -462,34 +462,33 @@ struct RoleDescrMap {
const nsString description; const nsString description;
}; };
static const RoleDescrMap sRoleDescrMap[] = { static const RoleDescrMap sRoleDescrMap[] = {{@"AXApplicationAlert", u"alert"_ns},
{@"AXApplicationAlert", NS_LITERAL_STRING("alert")}, {@"AXApplicationAlertDialog", u"alertDialog"_ns},
{@"AXApplicationAlertDialog", NS_LITERAL_STRING("alertDialog")}, {@"AXApplicationDialog", u"dialog"_ns},
{@"AXApplicationDialog", NS_LITERAL_STRING("dialog")}, {@"AXApplicationLog", u"log"_ns},
{@"AXApplicationLog", NS_LITERAL_STRING("log")}, {@"AXApplicationMarquee", u"marquee"_ns},
{@"AXApplicationMarquee", NS_LITERAL_STRING("marquee")}, {@"AXApplicationStatus", u"status"_ns},
{@"AXApplicationStatus", NS_LITERAL_STRING("status")}, {@"AXApplicationTimer", u"timer"_ns},
{@"AXApplicationTimer", NS_LITERAL_STRING("timer")}, {@"AXContentSeparator", u"separator"_ns},
{@"AXContentSeparator", NS_LITERAL_STRING("separator")}, {@"AXDefinition", u"definition"_ns},
{@"AXDefinition", NS_LITERAL_STRING("definition")}, {@"AXDetails", u"details"_ns},
{@"AXDetails", NS_LITERAL_STRING("details")}, {@"AXDocument", u"document"_ns},
{@"AXDocument", NS_LITERAL_STRING("document")}, {@"AXDocumentArticle", u"article"_ns},
{@"AXDocumentArticle", NS_LITERAL_STRING("article")}, {@"AXDocumentMath", u"math"_ns},
{@"AXDocumentMath", NS_LITERAL_STRING("math")}, {@"AXDocumentNote", u"note"_ns},
{@"AXDocumentNote", NS_LITERAL_STRING("note")}, {@"AXLandmarkApplication", u"application"_ns},
{@"AXLandmarkApplication", NS_LITERAL_STRING("application")}, {@"AXLandmarkBanner", u"banner"_ns},
{@"AXLandmarkBanner", NS_LITERAL_STRING("banner")}, {@"AXLandmarkComplementary", u"complementary"_ns},
{@"AXLandmarkComplementary", NS_LITERAL_STRING("complementary")}, {@"AXLandmarkContentInfo", u"content"_ns},
{@"AXLandmarkContentInfo", NS_LITERAL_STRING("content")}, {@"AXLandmarkMain", u"main"_ns},
{@"AXLandmarkMain", NS_LITERAL_STRING("main")}, {@"AXLandmarkNavigation", u"navigation"_ns},
{@"AXLandmarkNavigation", NS_LITERAL_STRING("navigation")}, {@"AXLandmarkRegion", u"region"_ns},
{@"AXLandmarkRegion", NS_LITERAL_STRING("region")}, {@"AXLandmarkSearch", u"search"_ns},
{@"AXLandmarkSearch", NS_LITERAL_STRING("search")}, {@"AXSearchField", u"searchTextField"_ns},
{@"AXSearchField", NS_LITERAL_STRING("searchTextField")}, {@"AXSummary", u"summary"_ns},
{@"AXSummary", NS_LITERAL_STRING("summary")}, {@"AXTabPanel", u"tabPanel"_ns},
{@"AXTabPanel", NS_LITERAL_STRING("tabPanel")}, {@"AXTerm", u"term"_ns},
{@"AXTerm", NS_LITERAL_STRING("term")}, {@"AXUserInterfaceTooltip", u"tooltip"_ns}};
{@"AXUserInterfaceTooltip", NS_LITERAL_STRING("tooltip")}};
struct RoleDescrComparator { struct RoleDescrComparator {
const NSString* mRole; const NSString* mRole;
@ -498,14 +497,14 @@ struct RoleDescrComparator {
}; };
- (NSString*)moxRoleDescription { - (NSString*)moxRoleDescription {
if (mRole == roles::DOCUMENT) return utils::LocalizedString(NS_LITERAL_STRING("htmlContent")); if (mRole == roles::DOCUMENT) return utils::LocalizedString(u"htmlContent"_ns);
if (mRole == roles::FIGURE) return utils::LocalizedString(NS_LITERAL_STRING("figure")); if (mRole == roles::FIGURE) return utils::LocalizedString(u"figure"_ns);
if (mRole == roles::HEADING) return utils::LocalizedString(NS_LITERAL_STRING("heading")); if (mRole == roles::HEADING) return utils::LocalizedString(u"heading"_ns);
if (mRole == roles::MARK) { if (mRole == roles::MARK) {
return utils::LocalizedString(NS_LITERAL_STRING("highlight")); return utils::LocalizedString(u"highlight"_ns);
} }
NSString* subrole = [self moxSubrole]; NSString* subrole = [self moxSubrole];

View file

@ -91,7 +91,7 @@
@implementation mozTabAccessible @implementation mozTabAccessible
- (NSString*)moxRoleDescription { - (NSString*)moxRoleDescription {
return utils::LocalizedString(NS_LITERAL_STRING("tab")); return utils::LocalizedString(u"tab"_ns);
} }
- (id)moxValue { - (id)moxValue {

View file

@ -478,7 +478,7 @@ AccessibleWrap::get_accRole(
if (!nodeInfo->NamespaceEquals(document->GetDefaultNamespaceID())) { if (!nodeInfo->NamespaceEquals(document->GetDefaultNamespaceID())) {
nsAutoString nameSpaceURI; nsAutoString nameSpaceURI;
nodeInfo->GetNamespaceURI(nameSpaceURI); nodeInfo->GetNamespaceURI(nameSpaceURI);
roleString += NS_LITERAL_STRING(", ") + nameSpaceURI; roleString += u", "_ns + nameSpaceURI;
} }
} }

View file

@ -32,9 +32,7 @@ ApplicationAccessibleWrap::NativeAttributes() {
gfxInfo->GetD2DEnabled(&isD2DEnabled); gfxInfo->GetD2DEnabled(&isD2DEnabled);
nsAutoString unused; nsAutoString unused;
attributes->SetStringProperty( attributes->SetStringProperty(
NS_LITERAL_CSTRING("D2D"), "D2D"_ns, isD2DEnabled ? u"true"_ns : u"false"_ns, unused);
isD2DEnabled ? NS_LITERAL_STRING("true") : NS_LITERAL_STRING("false"),
unused);
} }
return attributes.forget(); return attributes.forget();

View file

@ -282,7 +282,7 @@ static bool IsSystemOleAcc(nsCOMPtr<nsIFile>& aFile) {
return false; return false;
} }
rv = oleAcc->Append(NS_LITERAL_STRING("oleacc.dll")); rv = oleAcc->Append(u"oleacc.dll"_ns);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return false; return false;
} }
@ -369,8 +369,7 @@ static bool UseIAccessibleProxyStub() {
// IAccessible configuration in the computer's registry. Let's annotate this // IAccessible configuration in the computer's registry. Let's annotate this
// so that we can easily determine this condition during crash analysis. // so that we can easily determine this condition during crash analysis.
CrashReporter::AnnotateCrashReport( CrashReporter::AnnotateCrashReport(
CrashReporter::Annotation::IAccessibleConfig, CrashReporter::Annotation::IAccessibleConfig, "NoSystemTypeLibOrPS"_ns);
NS_LITERAL_CSTRING("NoSystemTypeLibOrPS"));
return false; return false;
} }

View file

@ -174,8 +174,7 @@ Maybe<bool> Compatibility::OnUIAMessage(WPARAM aWParam, LPARAM aLParam) {
nsAutoHandle section; nsAutoHandle section;
auto comparator = [&](const nsDependentSubstring& aName, auto comparator = [&](const nsDependentSubstring& aName,
const nsDependentSubstring& aType) -> bool { const nsDependentSubstring& aType) -> bool {
if (aType.Equals(NS_LITERAL_STRING("Section")) && if (aType.Equals(u"Section"_ns) && FindInReadable(kStrHookShmem, aName) &&
FindInReadable(kStrHookShmem, aName) &&
StringEndsWith(aName, partialSectionSuffix)) { StringEndsWith(aName, partialSectionSuffix)) {
section.own(::OpenFileMapping(GENERIC_READ, FALSE, section.own(::OpenFileMapping(GENERIC_READ, FALSE,
PromiseFlatString(aName).get())); PromiseFlatString(aName).get()));
@ -274,7 +273,7 @@ Maybe<bool> Compatibility::OnUIAMessage(WPARAM aWParam, LPARAM aLParam) {
// Now we check whether the object's type name matches "Section" // Now we check whether the object's type name matches "Section"
nsDependentSubstring objTypeName( nsDependentSubstring objTypeName(
objType->TypeName.Buffer, objType->TypeName.Length / sizeof(wchar_t)); objType->TypeName.Buffer, objType->TypeName.Length / sizeof(wchar_t));
if (!objTypeName.Equals(NS_LITERAL_STRING("Section"))) { if (!objTypeName.Equals(u"Section"_ns)) {
nonSectionObjTypes.PutEntry( nonSectionObjTypes.PutEntry(
static_cast<uint32_t>(curHandle.mObjectTypeIndex)); static_cast<uint32_t>(curHandle.mObjectTypeIndex));
continue; continue;

View file

@ -218,7 +218,7 @@ bool a11y::IsHandlerRegistered() {
return false; return false;
} }
rv = expectedHandler->Append(NS_LITERAL_STRING("AccessibleHandler.dll")); rv = expectedHandler->Append(u"AccessibleHandler.dll"_ns);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return false; return false;
} }
@ -337,7 +337,7 @@ void a11y::SetInstantiator(const uint32_t aPid) {
if (!GetInstantiatorExecutable(aPid, getter_AddRefs(clientExe))) { if (!GetInstantiatorExecutable(aPid, getter_AddRefs(clientExe))) {
#if defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER) #if defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER)
AccumulateInstantiatorTelemetry( AccumulateInstantiatorTelemetry(
NS_LITERAL_STRING("(Failed to retrieve client image name)")); u"(Failed to retrieve client image name)"_ns);
#endif // defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER) #endif // defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER)
return; return;
} }

View file

@ -29,7 +29,7 @@ ENameValueFlag XULMenuitemAccessibleWrap::Name(nsString& aName) const {
mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::acceltext, mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::acceltext,
accel); accel);
} }
if (!accel.IsEmpty()) aName += NS_LITERAL_STRING("\t") + accel; if (!accel.IsEmpty()) aName += u"\t"_ns + accel;
return eNameOK; return eNameOK;
} }

View file

@ -147,7 +147,7 @@ uiaRawElmProvider::GetPropertyValue(PROPERTYID aPropertyId,
nsAutoString xmlRoles; nsAutoString xmlRoles;
nsCOMPtr<nsIPersistentProperties> attributes = mAcc->Attributes(); nsCOMPtr<nsIPersistentProperties> attributes = mAcc->Attributes();
attributes->GetStringProperty(NS_LITERAL_CSTRING("xml-roles"), xmlRoles); attributes->GetStringProperty("xml-roles"_ns, xmlRoles);
if (!xmlRoles.IsEmpty()) { if (!xmlRoles.IsEmpty()) {
aPropertyValue->vt = VT_BSTR; aPropertyValue->vt = VT_BSTR;

View file

@ -87,8 +87,7 @@ Relation XULTabAccessible::RelationByType(RelationType aType) const {
// Expose 'LABEL_FOR' relation on tab accessible for tabpanel accessible. // Expose 'LABEL_FOR' relation on tab accessible for tabpanel accessible.
ErrorResult rv; ErrorResult rv;
nsIContent* parent = nsIContent* parent = mContent->AsElement()->Closest(u"tabs"_ns, rv);
mContent->AsElement()->Closest(NS_LITERAL_STRING("tabs"), rv);
if (!parent) return rel; if (!parent) return rel;
nsCOMPtr<nsIDOMXULRelatedElement> tabsElm = nsCOMPtr<nsIDOMXULRelatedElement> tabsElm =

View file

@ -614,8 +614,7 @@ nsIntRect XULTreeItemAccessibleBase::BoundsInCSSPixels() const {
RefPtr<nsTreeColumn> column = nsCoreUtils::GetFirstSensibleColumn(mTree); RefPtr<nsTreeColumn> column = nsCoreUtils::GetFirstSensibleColumn(mTree);
nsresult rv; nsresult rv;
nsIntRect rect = nsIntRect rect = mTree->GetCoordsForCellItem(mRow, column, u"cell"_ns, rv);
mTree->GetCoordsForCellItem(mRow, column, NS_LITERAL_STRING("cell"), rv);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return nsIntRect(); return nsIntRect();
} }
@ -843,7 +842,7 @@ void XULTreeItemAccessibleBase::DispatchClickEvent(
} else { } else {
// Primary column contains a twisty we should click on. // Primary column contains a twisty we should click on.
column = columns->GetPrimaryColumn(); column = columns->GetPrimaryColumn();
pseudoElm = NS_LITERAL_STRING("twisty"); pseudoElm = u"twisty"_ns;
} }
if (column) { if (column) {

View file

@ -402,8 +402,7 @@ nsIntRect XULTreeGridCellAccessible::BoundsInCSSPixels() const {
// Get bounds for tree cell and add x and y of treechildren element to // Get bounds for tree cell and add x and y of treechildren element to
// x and y of the cell. // x and y of the cell.
nsresult rv; nsresult rv;
nsIntRect rect = nsIntRect rect = mTree->GetCoordsForCellItem(mRow, mColumn, u"cell"_ns, rv);
mTree->GetCoordsForCellItem(mRow, mColumn, NS_LITERAL_STRING("cell"), rv);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return nsIntRect(); return nsIntRect();
} }
@ -535,8 +534,7 @@ XULTreeGridCellAccessible::NativeAttributes() {
// "cycles" attribute // "cycles" attribute
if (mColumn->Cycler()) if (mColumn->Cycler())
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::cycles, nsAccUtils::SetAccAttr(attributes, nsGkAtoms::cycles, u"true"_ns);
NS_LITERAL_STRING("true"));
return attributes.forget(); return attributes.forget();
} }

View file

@ -60,12 +60,12 @@ static void AppendDistroSearchDirs(nsIProperties* aDirSvc,
nsresult rv = aDirSvc->Get(XRE_APP_DISTRIBUTION_DIR, NS_GET_IID(nsIFile), nsresult rv = aDirSvc->Get(XRE_APP_DISTRIBUTION_DIR, NS_GET_IID(nsIFile),
getter_AddRefs(searchPlugins)); getter_AddRefs(searchPlugins));
if (NS_FAILED(rv)) return; if (NS_FAILED(rv)) return;
searchPlugins->AppendNative(NS_LITERAL_CSTRING("searchplugins")); searchPlugins->AppendNative("searchplugins"_ns);
nsCOMPtr<nsIFile> commonPlugins; nsCOMPtr<nsIFile> commonPlugins;
rv = searchPlugins->Clone(getter_AddRefs(commonPlugins)); rv = searchPlugins->Clone(getter_AddRefs(commonPlugins));
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
commonPlugins->AppendNative(NS_LITERAL_CSTRING("common")); commonPlugins->AppendNative("common"_ns);
array.AppendObject(commonPlugins); array.AppendObject(commonPlugins);
} }
@ -75,7 +75,7 @@ static void AppendDistroSearchDirs(nsIProperties* aDirSvc,
rv = searchPlugins->Clone(getter_AddRefs(localePlugins)); rv = searchPlugins->Clone(getter_AddRefs(localePlugins));
if (NS_FAILED(rv)) return; if (NS_FAILED(rv)) return;
localePlugins->AppendNative(NS_LITERAL_CSTRING("locale")); localePlugins->AppendNative("locale"_ns);
nsAutoCString defLocale; nsAutoCString defLocale;
rv = prefs->GetCharPref("distribution.searchplugins.defaultLocale", rv = prefs->GetCharPref("distribution.searchplugins.defaultLocale",

View file

@ -74,11 +74,10 @@ nsIEHistoryEnumerator::HasMoreElements(bool* _retval) {
mCachedNextEntry = do_CreateInstance("@mozilla.org/hash-property-bag;1"); mCachedNextEntry = do_CreateInstance("@mozilla.org/hash-property-bag;1");
MOZ_ASSERT(mCachedNextEntry, "Should have instanced a new property bag"); MOZ_ASSERT(mCachedNextEntry, "Should have instanced a new property bag");
if (mCachedNextEntry) { if (mCachedNextEntry) {
mCachedNextEntry->SetPropertyAsInterface(NS_LITERAL_STRING("uri"), uri); mCachedNextEntry->SetPropertyAsInterface(u"uri"_ns, uri);
mCachedNextEntry->SetPropertyAsAString(NS_LITERAL_STRING("title"), title); mCachedNextEntry->SetPropertyAsAString(u"title"_ns, title);
if (lastVisitTimeIsValid) { if (lastVisitTimeIsValid) {
mCachedNextEntry->SetPropertyAsInt64(NS_LITERAL_STRING("time"), mCachedNextEntry->SetPropertyAsInt64(u"time"_ns, lastVisited);
lastVisited);
} }
*_retval = true; *_retval = true;

View file

@ -428,19 +428,19 @@ nsGNOMEShellService::SetDesktopBackground(dom::Element* aElement,
do_GetService(NS_GSETTINGSSERVICE_CONTRACTID); do_GetService(NS_GSETTINGSSERVICE_CONTRACTID);
if (gsettings) { if (gsettings) {
nsCOMPtr<nsIGSettingsCollection> background_settings; nsCOMPtr<nsIGSettingsCollection> background_settings;
gsettings->GetCollectionForSchema(NS_LITERAL_CSTRING(kDesktopBGSchema), gsettings->GetCollectionForSchema(nsLiteralCString(kDesktopBGSchema),
getter_AddRefs(background_settings)); getter_AddRefs(background_settings));
if (background_settings) { if (background_settings) {
gchar* file_uri = g_filename_to_uri(filePath.get(), nullptr, nullptr); gchar* file_uri = g_filename_to_uri(filePath.get(), nullptr, nullptr);
if (!file_uri) return NS_ERROR_FAILURE; if (!file_uri) return NS_ERROR_FAILURE;
background_settings->SetString(NS_LITERAL_CSTRING(kDesktopOptionGSKey), background_settings->SetString(nsLiteralCString(kDesktopOptionGSKey),
options); options);
background_settings->SetString(NS_LITERAL_CSTRING(kDesktopImageGSKey), background_settings->SetString(nsLiteralCString(kDesktopImageGSKey),
nsDependentCString(file_uri)); nsDependentCString(file_uri));
g_free(file_uri); g_free(file_uri);
background_settings->SetBoolean(NS_LITERAL_CSTRING(kDesktopDrawBGGSKey), background_settings->SetBoolean(nsLiteralCString(kDesktopDrawBGGSKey),
true); true);
return rv; return rv;
} }
@ -460,10 +460,10 @@ nsGNOMEShellService::GetDesktopBackgroundColor(uint32_t* aColor) {
nsAutoCString background; nsAutoCString background;
if (gsettings) { if (gsettings) {
gsettings->GetCollectionForSchema(NS_LITERAL_CSTRING(kDesktopBGSchema), gsettings->GetCollectionForSchema(nsLiteralCString(kDesktopBGSchema),
getter_AddRefs(background_settings)); getter_AddRefs(background_settings));
if (background_settings) { if (background_settings) {
background_settings->GetString(NS_LITERAL_CSTRING(kDesktopColorGSKey), background_settings->GetString(nsLiteralCString(kDesktopColorGSKey),
background); background);
} }
} }
@ -506,10 +506,10 @@ nsGNOMEShellService::SetDesktopBackgroundColor(uint32_t aColor) {
do_GetService(NS_GSETTINGSSERVICE_CONTRACTID); do_GetService(NS_GSETTINGSSERVICE_CONTRACTID);
if (gsettings) { if (gsettings) {
nsCOMPtr<nsIGSettingsCollection> background_settings; nsCOMPtr<nsIGSettingsCollection> background_settings;
gsettings->GetCollectionForSchema(NS_LITERAL_CSTRING(kDesktopBGSchema), gsettings->GetCollectionForSchema(nsLiteralCString(kDesktopBGSchema),
getter_AddRefs(background_settings)); getter_AddRefs(background_settings));
if (background_settings) { if (background_settings) {
background_settings->SetString(NS_LITERAL_CSTRING(kDesktopColorGSKey), background_settings->SetString(nsLiteralCString(kDesktopColorGSKey),
colorString); colorString);
return NS_OK; return NS_OK;
} }

View file

@ -27,10 +27,9 @@
using mozilla::dom::Element; using mozilla::dom::Element;
using mozilla::widget::SetDesktopImage; using mozilla::widget::SetDesktopImage;
#define NETWORK_PREFPANE \ #define NETWORK_PREFPANE "/System/Library/PreferencePanes/Network.prefPane"_ns
NS_LITERAL_CSTRING("/System/Library/PreferencePanes/Network.prefPane")
#define DESKTOP_PREFPANE \ #define DESKTOP_PREFPANE \
NS_LITERAL_CSTRING( \ nsLiteralCString( \
"/System/Library/PreferencePanes/DesktopScreenEffectsPref.prefPane") "/System/Library/PreferencePanes/DesktopScreenEffectsPref.prefPane")
#define SAFARI_BUNDLE_IDENTIFIER "com.apple.Safari" #define SAFARI_BUNDLE_IDENTIFIER "com.apple.Safari"

View file

@ -111,10 +111,10 @@ nsresult GetHelperPath(nsAutoString& aPath) {
getter_AddRefs(appHelper)); getter_AddRefs(appHelper));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = appHelper->SetNativeLeafName(NS_LITERAL_CSTRING("uninstall")); rv = appHelper->SetNativeLeafName("uninstall"_ns);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = appHelper->AppendNative(NS_LITERAL_CSTRING("helper.exe")); rv = appHelper->AppendNative("helper.exe"_ns);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = appHelper->GetPath(aPath); rv = appHelper->GetPath(aPath);
@ -268,9 +268,9 @@ nsresult nsWindowsShellService::LaunchControlPanelDefaultPrograms() {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
nsAutoString params(NS_LITERAL_STRING( nsAutoString params(
"control.exe /name Microsoft.DefaultPrograms " u"control.exe /name Microsoft.DefaultPrograms "
"/page pageDefaultProgram\\pageAdvancedSettings?pszAppName=")); "/page pageDefaultProgram\\pageAdvancedSettings?pszAppName="_ns);
nsAutoString appRegName; nsAutoString appRegName;
GetAppRegName(appRegName); GetAppRegName(appRegName);
params.Append(appRegName); params.Append(appRegName);
@ -313,16 +313,15 @@ static bool SettingsAppBelievesConnected() {
return false; return false;
} }
rv = regKey->Open( rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER,
nsIWindowsRegKey::ROOT_KEY_CURRENT_USER, u"SOFTWARE\\Microsoft\\Windows\\Shell\\Associations"_ns,
NS_LITERAL_STRING("SOFTWARE\\Microsoft\\Windows\\Shell\\Associations"),
nsIWindowsRegKey::ACCESS_READ); nsIWindowsRegKey::ACCESS_READ);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return false; return false;
} }
uint32_t value; uint32_t value;
rv = regKey->ReadIntValue(NS_LITERAL_STRING("IsConnectedAtLogon"), &value); rv = regKey->ReadIntValue(u"IsConnectedAtLogon"_ns, &value);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return false; return false;
} }
@ -373,12 +372,11 @@ nsresult nsWindowsShellService::InvokeHTTPOpenAsVerb() {
} }
nsString urlStr; nsString urlStr;
nsresult rv = formatter->FormatURLPref( nsresult rv = formatter->FormatURLPref(u"app.support.baseURL"_ns, urlStr);
NS_LITERAL_STRING("app.support.baseURL"), urlStr);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;
} }
if (!StringBeginsWith(urlStr, NS_LITERAL_STRING("https://"))) { if (!StringBeginsWith(urlStr, u"https://"_ns)) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
urlStr.AppendLiteral("win10-default-browser"); urlStr.AppendLiteral("win10-default-browser");
@ -615,7 +613,7 @@ nsWindowsShellService::SetDesktopBackground(dom::Element* aElement,
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = regKey->Create(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER, rv = regKey->Create(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER,
NS_LITERAL_STRING("Control Panel\\Desktop"), u"Control Panel\\Desktop"_ns,
nsIWindowsRegKey::ACCESS_SET_VALUE); nsIWindowsRegKey::ACCESS_SET_VALUE);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -648,9 +646,9 @@ nsWindowsShellService::SetDesktopBackground(dom::Element* aElement,
break; break;
} }
rv = regKey->WriteStringValue(NS_LITERAL_STRING("TileWallpaper"), tile); rv = regKey->WriteStringValue(u"TileWallpaper"_ns, tile);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = regKey->WriteStringValue(NS_LITERAL_STRING("WallpaperStyle"), style); rv = regKey->WriteStringValue(u"WallpaperStyle"_ns, style);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = regKey->Close(); rv = regKey->Close();
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -685,15 +683,14 @@ nsWindowsShellService::SetDesktopBackgroundColor(uint32_t aColor) {
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = regKey->Create(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER, rv = regKey->Create(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER,
NS_LITERAL_STRING("Control Panel\\Colors"), u"Control Panel\\Colors"_ns,
nsIWindowsRegKey::ACCESS_SET_VALUE); nsIWindowsRegKey::ACCESS_SET_VALUE);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
wchar_t rgb[12]; wchar_t rgb[12];
_snwprintf(rgb, 12, L"%u %u %u", r, g, b); _snwprintf(rgb, 12, L"%u %u %u", r, g, b);
rv = regKey->WriteStringValue(NS_LITERAL_STRING("Background"), rv = regKey->WriteStringValue(u"Background"_ns, nsDependentString(rgb));
nsDependentString(rgb));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
return regKey->Close(); return regKey->Close();

View file

@ -831,7 +831,7 @@ NS_IMETHODIMP BasePrincipal::GetIsOnion(bool* aIsOnion) {
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return NS_OK; return NS_OK;
} }
*aIsOnion = StringEndsWith(host, NS_LITERAL_CSTRING(".onion")); *aIsOnion = StringEndsWith(host, ".onion"_ns);
return NS_OK; return NS_OK;
} }
@ -1060,12 +1060,12 @@ already_AddRefed<BasePrincipal> BasePrincipal::CreateContentPrincipal(
already_AddRefed<BasePrincipal> BasePrincipal::CreateContentPrincipal( already_AddRefed<BasePrincipal> BasePrincipal::CreateContentPrincipal(
const nsACString& aOrigin) { const nsACString& aOrigin) {
MOZ_ASSERT(!StringBeginsWith(aOrigin, NS_LITERAL_CSTRING("[")), MOZ_ASSERT(!StringBeginsWith(aOrigin, "["_ns),
"CreateContentPrincipal does not support System and Expanded " "CreateContentPrincipal does not support System and Expanded "
"principals"); "principals");
MOZ_ASSERT(!StringBeginsWith(aOrigin, MOZ_ASSERT(
NS_LITERAL_CSTRING(NS_NULLPRINCIPAL_SCHEME ":")), !StringBeginsWith(aOrigin, nsLiteralCString(NS_NULLPRINCIPAL_SCHEME ":")),
"CreateContentPrincipal does not support NullPrincipal"); "CreateContentPrincipal does not support NullPrincipal");
nsAutoCString originNoSuffix; nsAutoCString originNoSuffix;

View file

@ -147,7 +147,7 @@ nsresult ContentPrincipal::GenerateOriginNoSuffixFromURI(
// sources. We check for moz-safe-about:blank since origin is an // sources. We check for moz-safe-about:blank since origin is an
// innermost URI. // innermost URI.
!StringBeginsWith(origin->GetSpecOrDefault(), !StringBeginsWith(origin->GetSpecOrDefault(),
NS_LITERAL_CSTRING("moz-safe-about:blank")))) { "moz-safe-about:blank"_ns))) {
rv = origin->GetAsciiSpec(aOriginNoSuffix); rv = origin->GetAsciiSpec(aOriginNoSuffix);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);

View file

@ -237,7 +237,7 @@ nsresult NullPrincipal::PopulateJSONObject(Json::Value& aObject) {
nsresult rv = mURI->GetSpec(principalURI); nsresult rv = mURI->GetSpec(principalURI);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
MOZ_ASSERT(principalURI.Length() == MOZ_ASSERT(principalURI.Length() ==
NS_LITERAL_CSTRING(NS_NULLPRINCIPAL_SCHEME ":").Length() + nsLiteralCString(NS_NULLPRINCIPAL_SCHEME ":").Length() +
NSID_LENGTH - 1, NSID_LENGTH - 1,
"Length of the URI should be: (scheme, uuid, - nullptr)"); "Length of the URI should be: (scheme, uuid, - nullptr)");
aObject[std::to_string(eSpec)] = principalURI.get(); aObject[std::to_string(eSpec)] = principalURI.get();

View file

@ -146,7 +146,7 @@ nsresult NullPrincipalURI::SetRef(const nsACString& aRef) {
NS_IMETHODIMP NS_IMETHODIMP
NullPrincipalURI::GetPrePath(nsACString& _prePath) { NullPrincipalURI::GetPrePath(nsACString& _prePath) {
_prePath = NS_LITERAL_CSTRING(NS_NULLPRINCIPAL_SCHEME ":"); _prePath = nsLiteralCString(NS_NULLPRINCIPAL_SCHEME ":");
return NS_OK; return NS_OK;
} }
@ -159,7 +159,7 @@ nsresult NullPrincipalURI::SetPort(int32_t aPort) {
NS_IMETHODIMP NS_IMETHODIMP
NullPrincipalURI::GetScheme(nsACString& _scheme) { NullPrincipalURI::GetScheme(nsACString& _scheme) {
_scheme = NS_LITERAL_CSTRING(NS_NULLPRINCIPAL_SCHEME); _scheme = nsLiteralCString(NS_NULLPRINCIPAL_SCHEME);
return NS_OK; return NS_OK;
} }
@ -169,7 +169,7 @@ nsresult NullPrincipalURI::SetScheme(const nsACString& aScheme) {
NS_IMETHODIMP NS_IMETHODIMP
NullPrincipalURI::GetSpec(nsACString& _spec) { NullPrincipalURI::GetSpec(nsACString& _spec) {
_spec = NS_LITERAL_CSTRING(NS_NULLPRINCIPAL_SCHEME ":") + mPath; _spec = nsLiteralCString(NS_NULLPRINCIPAL_SCHEME ":") + mPath;
return NS_OK; return NS_OK;
} }

View file

@ -70,7 +70,7 @@ static void PopulateTopLevelInfoFromURI(const bool aIsTopLevelDocument,
NS_ENSURE_SUCCESS_VOID(rv); NS_ENSURE_SUCCESS_VOID(rv);
if (scheme.EqualsLiteral("about")) { if (scheme.EqualsLiteral("about")) {
MakeTopLevelInfo(scheme, NS_LITERAL_CSTRING(ABOUT_URI_FIRST_PARTY_DOMAIN), MakeTopLevelInfo(scheme, nsLiteralCString(ABOUT_URI_FIRST_PARTY_DOMAIN),
aUseSite, topLevelInfo); aUseSite, topLevelInfo);
return; return;
} }
@ -200,27 +200,26 @@ void OriginAttributes::CreateSuffix(nsACString& aStr) const {
// //
if (mInIsolatedMozBrowser) { if (mInIsolatedMozBrowser) {
params.Set(NS_LITERAL_STRING("inBrowser"), NS_LITERAL_STRING("1")); params.Set(u"inBrowser"_ns, u"1"_ns);
} }
if (mUserContextId != nsIScriptSecurityManager::DEFAULT_USER_CONTEXT_ID) { if (mUserContextId != nsIScriptSecurityManager::DEFAULT_USER_CONTEXT_ID) {
value.Truncate(); value.Truncate();
value.AppendInt(mUserContextId); value.AppendInt(mUserContextId);
params.Set(NS_LITERAL_STRING("userContextId"), value); params.Set(u"userContextId"_ns, value);
} }
if (mPrivateBrowsingId) { if (mPrivateBrowsingId) {
value.Truncate(); value.Truncate();
value.AppendInt(mPrivateBrowsingId); value.AppendInt(mPrivateBrowsingId);
params.Set(NS_LITERAL_STRING("privateBrowsingId"), value); params.Set(u"privateBrowsingId"_ns, value);
} }
if (!mFirstPartyDomain.IsEmpty()) { if (!mFirstPartyDomain.IsEmpty()) {
nsAutoString sanitizedFirstPartyDomain(mFirstPartyDomain); nsAutoString sanitizedFirstPartyDomain(mFirstPartyDomain);
sanitizedFirstPartyDomain.ReplaceChar(kSourceChar, kSanitizedChar); sanitizedFirstPartyDomain.ReplaceChar(kSourceChar, kSanitizedChar);
params.Set(NS_LITERAL_STRING("firstPartyDomain"), params.Set(u"firstPartyDomain"_ns, sanitizedFirstPartyDomain);
sanitizedFirstPartyDomain);
} }
if (!mGeckoViewSessionContextId.IsEmpty()) { if (!mGeckoViewSessionContextId.IsEmpty()) {
@ -228,15 +227,14 @@ void OriginAttributes::CreateSuffix(nsACString& aStr) const {
sanitizedGeckoViewUserContextId.ReplaceChar( sanitizedGeckoViewUserContextId.ReplaceChar(
dom::quota::QuotaManager::kReplaceChars, kSanitizedChar); dom::quota::QuotaManager::kReplaceChars, kSanitizedChar);
params.Set(NS_LITERAL_STRING("geckoViewUserContextId"), params.Set(u"geckoViewUserContextId"_ns, sanitizedGeckoViewUserContextId);
sanitizedGeckoViewUserContextId);
} }
if (!mPartitionKey.IsEmpty()) { if (!mPartitionKey.IsEmpty()) {
nsAutoString sanitizedPartitionKey(mPartitionKey); nsAutoString sanitizedPartitionKey(mPartitionKey);
sanitizedPartitionKey.ReplaceChar(kSourceChar, kSanitizedChar); sanitizedPartitionKey.ReplaceChar(kSourceChar, kSanitizedChar);
params.Set(NS_LITERAL_STRING("partitionKey"), sanitizedPartitionKey); params.Set(u"partitionKey"_ns, sanitizedPartitionKey);
} }
aStr.Truncate(); aStr.Truncate();

View file

@ -26,7 +26,7 @@ NS_IMPL_CI_INTERFACE_GETTER(SystemPrincipal, nsIPrincipal, nsISerializable)
already_AddRefed<SystemPrincipal> SystemPrincipal::Create() { already_AddRefed<SystemPrincipal> SystemPrincipal::Create() {
RefPtr<SystemPrincipal> sp = new SystemPrincipal(); RefPtr<SystemPrincipal> sp = new SystemPrincipal();
sp->FinishInit(NS_LITERAL_CSTRING(SYSTEM_PRINCIPAL_SPEC), OriginAttributes()); sp->FinishInit(nsLiteralCString(SYSTEM_PRINCIPAL_SPEC), OriginAttributes());
return sp.forget(); return sp.forget();
} }

View file

@ -172,7 +172,7 @@ static nsresult GetOriginFromURI(nsIURI* aURI, nsACString& aOrigin) {
nsAutoCString scheme; nsAutoCString scheme;
rv = uri->GetScheme(scheme); rv = uri->GetScheme(scheme);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
aOrigin = scheme + NS_LITERAL_CSTRING("://") + hostPort; aOrigin = scheme + "://"_ns + hostPort;
} else { } else {
// Some URIs (e.g., nsSimpleURI) don't support host. Just // Some URIs (e.g., nsSimpleURI) don't support host. Just
// get the full spec. // get the full spec.
@ -1029,10 +1029,9 @@ nsresult nsScriptSecurityManager::ReportError(const char* aMessageTag,
// using category of "SOP" so we can link to MDN // using category of "SOP" so we can link to MDN
if (aInnerWindowID != 0) { if (aInnerWindowID != 0) {
rv = error->InitWithWindowID(message, EmptyString(), EmptyString(), 0, 0, rv = error->InitWithWindowID(
nsIScriptError::errorFlag, message, EmptyString(), EmptyString(), 0, 0, nsIScriptError::errorFlag,
NS_LITERAL_CSTRING("SOP"), aInnerWindowID, "SOP"_ns, aInnerWindowID, true /* From chrome context */);
true /* From chrome context */);
} else { } else {
rv = error->Init(message, EmptyString(), EmptyString(), 0, 0, rv = error->Init(message, EmptyString(), EmptyString(), 0, 0,
nsIScriptError::errorFlag, "SOP", aFromPrivateWindow, nsIScriptError::errorFlag, "SOP", aFromPrivateWindow,
@ -1157,12 +1156,12 @@ nsScriptSecurityManager::CreateContentPrincipal(
NS_IMETHODIMP NS_IMETHODIMP
nsScriptSecurityManager::CreateContentPrincipalFromOrigin( nsScriptSecurityManager::CreateContentPrincipalFromOrigin(
const nsACString& aOrigin, nsIPrincipal** aPrincipal) { const nsACString& aOrigin, nsIPrincipal** aPrincipal) {
if (StringBeginsWith(aOrigin, NS_LITERAL_CSTRING("["))) { if (StringBeginsWith(aOrigin, "["_ns)) {
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
if (StringBeginsWith(aOrigin, if (StringBeginsWith(aOrigin,
NS_LITERAL_CSTRING(NS_NULLPRINCIPAL_SCHEME ":"))) { nsLiteralCString(NS_NULLPRINCIPAL_SCHEME ":"))) {
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
@ -1506,8 +1505,8 @@ void nsScriptSecurityManager::AddSitesToFileURIAllowlist(
// Check if the URI is schemeless. If so, add both http and https. // Check if the URI is schemeless. If so, add both http and https.
nsAutoCString unused; nsAutoCString unused;
if (NS_FAILED(sIOService->ExtractScheme(site, unused))) { if (NS_FAILED(sIOService->ExtractScheme(site, unused))) {
AddSitesToFileURIAllowlist(NS_LITERAL_CSTRING("http://") + site); AddSitesToFileURIAllowlist("http://"_ns + site);
AddSitesToFileURIAllowlist(NS_LITERAL_CSTRING("https://") + site); AddSitesToFileURIAllowlist("https://"_ns + site);
continue; continue;
} }
@ -1521,8 +1520,7 @@ void nsScriptSecurityManager::AddSitesToFileURIAllowlist(
do_GetService("@mozilla.org/consoleservice;1")); do_GetService("@mozilla.org/consoleservice;1"));
if (console) { if (console) {
nsAutoString msg = nsAutoString msg =
NS_LITERAL_STRING( u"Unable to to add site to file:// URI allowlist: "_ns +
"Unable to to add site to file:// URI allowlist: ") +
NS_ConvertASCIItoUTF16(site); NS_ConvertASCIItoUTF16(site);
console->LogStringMessage(msg.get()); console->LogStringMessage(msg.get());
} }
@ -1655,8 +1653,7 @@ nsScriptSecurityManager::EnsureFileURIAllowlist() {
// Figure out if this policy allows loading file:// URIs. If not, we can // Figure out if this policy allows loading file:// URIs. If not, we can
// skip it. // skip it.
nsCString checkLoadURIPrefName = nsCString checkLoadURIPrefName =
NS_LITERAL_CSTRING("capability.policy.") + policyName + "capability.policy."_ns + policyName + ".checkloaduri.enabled"_ns;
NS_LITERAL_CSTRING(".checkloaduri.enabled");
nsAutoString value; nsAutoString value;
nsresult rv = Preferences::GetString(checkLoadURIPrefName.get(), value); nsresult rv = Preferences::GetString(checkLoadURIPrefName.get(), value);
if (NS_FAILED(rv) || !value.LowerCaseEqualsLiteral("allaccess")) { if (NS_FAILED(rv) || !value.LowerCaseEqualsLiteral("allaccess")) {
@ -1664,8 +1661,8 @@ nsScriptSecurityManager::EnsureFileURIAllowlist() {
} }
// Grab the list of domains associated with this policy. // Grab the list of domains associated with this policy.
nsCString domainPrefName = NS_LITERAL_CSTRING("capability.policy.") + nsCString domainPrefName =
policyName + NS_LITERAL_CSTRING(".sites"); "capability.policy."_ns + policyName + ".sites"_ns;
nsAutoCString siteList; nsAutoCString siteList;
Preferences::GetCString(domainPrefName.get(), siteList); Preferences::GetCString(domainPrefName.get(), siteList);
AddSitesToFileURIAllowlist(siteList); AddSitesToFileURIAllowlist(siteList);

View file

@ -73,19 +73,19 @@ TEST(PrincipalSerialization, TwoKeys)
{ {
// Sanity check that this returns a system principal // Sanity check that this returns a system principal
nsCOMPtr<nsIPrincipal> systemPrincipal = nsCOMPtr<nsIPrincipal> systemPrincipal =
BasePrincipal::FromJSON(NS_LITERAL_CSTRING("{\"3\":{}}")); BasePrincipal::FromJSON("{\"3\":{}}"_ns);
ASSERT_EQ(BasePrincipal::Cast(systemPrincipal)->Kind(), ASSERT_EQ(BasePrincipal::Cast(systemPrincipal)->Kind(),
BasePrincipal::eSystemPrincipal); BasePrincipal::eSystemPrincipal);
// Sanity check that this returns a content principal // Sanity check that this returns a content principal
nsCOMPtr<nsIPrincipal> contentPrincipal = BasePrincipal::FromJSON( nsCOMPtr<nsIPrincipal> contentPrincipal =
NS_LITERAL_CSTRING("{\"1\":{\"0\":\"https://mozilla.com\"}}")); BasePrincipal::FromJSON("{\"1\":{\"0\":\"https://mozilla.com\"}}"_ns);
ASSERT_EQ(BasePrincipal::Cast(contentPrincipal)->Kind(), ASSERT_EQ(BasePrincipal::Cast(contentPrincipal)->Kind(),
BasePrincipal::eContentPrincipal); BasePrincipal::eContentPrincipal);
// Check both combined don't return a principal // Check both combined don't return a principal
nsCOMPtr<nsIPrincipal> combinedPrincipal = BasePrincipal::FromJSON( nsCOMPtr<nsIPrincipal> combinedPrincipal = BasePrincipal::FromJSON(
NS_LITERAL_CSTRING("{\"1\":{\"0\":\"https://mozilla.com\"},\"3\":{}}")); "{\"1\":{\"0\":\"https://mozilla.com\"},\"3\":{}}"_ns);
ASSERT_EQ(nullptr, combinedPrincipal); ASSERT_EQ(nullptr, combinedPrincipal);
} }

View file

@ -171,7 +171,7 @@ nsChromeProtocolHandler::NewChannel(nsIURI* aURI, nsILoadInfo* aLoadInfo,
nsCOMPtr<nsIURL> url = do_QueryInterface(aURI); nsCOMPtr<nsIURL> url = do_QueryInterface(aURI);
nsAutoCString path; nsAutoCString path;
rv = url->GetPathQueryRef(path); rv = url->GetPathQueryRef(path);
if (StringBeginsWith(path, NS_LITERAL_CSTRING("/content/"))) { if (StringBeginsWith(path, "/content/"_ns)) {
result->SetOwner(nsContentUtils::GetSystemPrincipal()); result->SetOwner(nsContentUtils::GetSystemPrincipal());
} }
@ -180,7 +180,7 @@ nsChromeProtocolHandler::NewChannel(nsIURI* aURI, nsILoadInfo* aLoadInfo,
// and with startupcache not at all), but this is where we would start // and with startupcache not at all), but this is where we would start
// if we need to re-add. // if we need to re-add.
// See bug 531886, bug 533038. // See bug 531886, bug 533038.
result->SetContentCharset(NS_LITERAL_CSTRING("UTF-8")); result->SetContentCharset("UTF-8"_ns);
*aResult = result; *aResult = result;
NS_ADDREF(*aResult); NS_ADDREF(*aResult);

View file

@ -35,7 +35,7 @@
#include "nsIXULRuntime.h" #include "nsIXULRuntime.h"
#define PACKAGE_OVERRIDE_BRANCH "chrome.override_package." #define PACKAGE_OVERRIDE_BRANCH "chrome.override_package."
#define SKIN NS_LITERAL_CSTRING("classic/1.0") #define SKIN "classic/1.0"_ns
using namespace mozilla; using namespace mozilla;
using mozilla::dom::ContentParent; using mozilla::dom::ContentParent;
@ -170,8 +170,7 @@ nsresult nsChromeRegistryChrome::GetSelectedLocale(const nsACString& aPackage,
nsresult nsChromeRegistryChrome::OverrideLocalePackage( nsresult nsChromeRegistryChrome::OverrideLocalePackage(
const nsACString& aPackage, nsACString& aOverride) { const nsACString& aPackage, nsACString& aOverride) {
const nsACString& pref = const nsACString& pref = nsLiteralCString(PACKAGE_OVERRIDE_BRANCH) + aPackage;
NS_LITERAL_CSTRING(PACKAGE_OVERRIDE_BRANCH) + aPackage;
nsAutoCString override; nsAutoCString override;
nsresult rv = mozilla::Preferences::GetCString(PromiseFlatCString(pref).get(), nsresult rv = mozilla::Preferences::GetCString(PromiseFlatCString(pref).get(),
override); override);
@ -527,8 +526,7 @@ void nsChromeRegistryChrome::ManifestLocale(ManifestProcessingContext& cx,
// registered. For most cases it will be "global", but for Fennec it will be // registered. For most cases it will be "global", but for Fennec it will be
// "browser". // "browser".
nsAutoCString mainPackage; nsAutoCString mainPackage;
nsresult rv = nsresult rv = OverrideLocalePackage("global"_ns, mainPackage);
OverrideLocalePackage(NS_LITERAL_CSTRING("global"), mainPackage);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return; return;
} }
@ -592,9 +590,8 @@ void nsChromeRegistryChrome::ManifestOverride(ManifestProcessingContext& cx,
nsAutoCString chromePath, resolvedPath; nsAutoCString chromePath, resolvedPath;
chromeuri->GetPathQueryRef(chromePath); chromeuri->GetPathQueryRef(chromePath);
resolveduri->GetPathQueryRef(resolvedPath); resolveduri->GetPathQueryRef(resolvedPath);
chromeSkinOnly = chromeSkinOnly = StringBeginsWith(chromePath, "/skin/"_ns) &&
StringBeginsWith(chromePath, NS_LITERAL_CSTRING("/skin/")) && StringBeginsWith(resolvedPath, "/skin/"_ns);
StringBeginsWith(resolvedPath, NS_LITERAL_CSTRING("/skin/"));
} }
if (!chromeSkinOnly) { if (!chromeSkinOnly) {
LogMessageWithContext( LogMessageWithContext(

View file

@ -1869,7 +1869,7 @@ void BrowsingContext::PostMessageMoz(JSContext* aCx,
messageData = ErrorMessageData(); messageData = ErrorMessageData();
nsContentUtils::ReportToConsole( nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag, NS_LITERAL_CSTRING("DOM Window"), nsIScriptError::warningFlag, "DOM Window"_ns,
callerInnerWindow ? callerInnerWindow->GetDocument() : nullptr, callerInnerWindow ? callerInnerWindow->GetDocument() : nullptr,
nsContentUtils::eDOM_PROPERTIES, nsContentUtils::eDOM_PROPERTIES,
"PostMessageSharedMemoryObjectToCrossOriginWarning"); "PostMessageSharedMemoryObjectToCrossOriginWarning");
@ -1893,7 +1893,7 @@ void BrowsingContext::PostMessageMoz(JSContext* aCx,
messageData = ErrorMessageData(); messageData = ErrorMessageData();
nsContentUtils::ReportToConsole( nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag, NS_LITERAL_CSTRING("DOM Window"), nsIScriptError::warningFlag, "DOM Window"_ns,
callerInnerWindow ? callerInnerWindow->GetDocument() : nullptr, callerInnerWindow ? callerInnerWindow->GetDocument() : nullptr,
nsContentUtils::eDOM_PROPERTIES, nsContentUtils::eDOM_PROPERTIES,
"PostMessageSharedMemoryObjectToCrossOriginWarning"); "PostMessageSharedMemoryObjectToCrossOriginWarning");
@ -2359,7 +2359,7 @@ void BrowsingContext::DidSet(FieldIndex<IDX_TextZoom>, float aOldValue) {
if (IsTop() && XRE_IsParentProcess()) { if (IsTop() && XRE_IsParentProcess()) {
if (Element* element = GetEmbedderElement()) { if (Element* element = GetEmbedderElement()) {
auto dispatcher = MakeRefPtr<AsyncEventDispatcher>( auto dispatcher = MakeRefPtr<AsyncEventDispatcher>(
element, NS_LITERAL_STRING("TextZoomChange"), CanBubble::eYes, element, u"TextZoomChange"_ns, CanBubble::eYes,
ChromeOnlyDispatch::eYes); ChromeOnlyDispatch::eYes);
dispatcher->RunDOMEventWhenSafe(); dispatcher->RunDOMEventWhenSafe();
} }
@ -2389,7 +2389,7 @@ void BrowsingContext::DidSet(FieldIndex<IDX_FullZoom>, float aOldValue) {
if (IsTop() && XRE_IsParentProcess()) { if (IsTop() && XRE_IsParentProcess()) {
if (Element* element = GetEmbedderElement()) { if (Element* element = GetEmbedderElement()) {
auto dispatcher = MakeRefPtr<AsyncEventDispatcher>( auto dispatcher = MakeRefPtr<AsyncEventDispatcher>(
element, NS_LITERAL_STRING("FullZoomChange"), CanBubble::eYes, element, u"FullZoomChange"_ns, CanBubble::eYes,
ChromeOnlyDispatch::eYes); ChromeOnlyDispatch::eYes);
dispatcher->RunDOMEventWhenSafe(); dispatcher->RunDOMEventWhenSafe();
} }

View file

@ -349,8 +349,7 @@ void CanonicalBrowsingContext::DispatchWheelZoomChange(bool aIncrease) {
return; return;
} }
auto event = aIncrease ? NS_LITERAL_STRING("DoZoomEnlargeBy10") auto event = aIncrease ? u"DoZoomEnlargeBy10"_ns : u"DoZoomReduceBy10"_ns;
: NS_LITERAL_STRING("DoZoomReduceBy10");
auto dispatcher = MakeRefPtr<AsyncEventDispatcher>( auto dispatcher = MakeRefPtr<AsyncEventDispatcher>(
element, event, CanBubble::eYes, ChromeOnlyDispatch::eYes); element, event, CanBubble::eYes, ChromeOnlyDispatch::eYes);
dispatcher->PostDOMEvent(); dispatcher->PostDOMEvent();
@ -609,9 +608,8 @@ void CanonicalBrowsingContext::PendingRemotenessChange::Finish() {
// Some frontend code checks the value of the `remote` attribute on the // Some frontend code checks the value of the `remote` attribute on the
// browser to determine if it is remote, so update the value. // browser to determine if it is remote, so update the value.
browserElement->SetAttr( browserElement->SetAttr(kNameSpaceID_None, nsGkAtoms::remote,
kNameSpaceID_None, nsGkAtoms::remote, mContentParent ? u"true"_ns : u"false"_ns,
mContentParent ? NS_LITERAL_STRING("true") : NS_LITERAL_STRING("false"),
/* notify */ true); /* notify */ true);
// The process has been created, hand off to nsFrameLoaderOwner to finish // The process has been created, hand off to nsFrameLoaderOwner to finish

View file

@ -2339,8 +2339,7 @@ void nsDocShell::MaybeCreateInitialClientSource(nsIPrincipal* aPrincipal) {
} }
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
MOZ_ALWAYS_SUCCEEDS( MOZ_ALWAYS_SUCCEEDS(NS_NewURI(getter_AddRefs(uri), "about:blank"_ns));
NS_NewURI(getter_AddRefs(uri), NS_LITERAL_CSTRING("about:blank")));
// We're done if there is no parent controller or if this docshell // We're done if there is no parent controller or if this docshell
// is not permitted to control for some reason. // is not permitted to control for some reason.
@ -3432,7 +3431,7 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
RefPtr<EventTarget> handler = mChromeEventHandler; RefPtr<EventTarget> handler = mChromeEventHandler;
if (handler) { if (handler) {
nsCOMPtr<Element> element = do_QueryInterface(handler); nsCOMPtr<Element> element = do_QueryInterface(handler);
element->GetAttribute(NS_LITERAL_STRING("crashedPageTitle"), messageStr); element->GetAttribute(u"crashedPageTitle"_ns, messageStr);
} }
// DisplayLoadError requires a non-empty messageStr to proceed and call // DisplayLoadError requires a non-empty messageStr to proceed and call
@ -3585,7 +3584,7 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
} }
Telemetry::AccumulateCategoricalKeyed( Telemetry::AccumulateCategoricalKeyed(
IsFrame() ? NS_LITERAL_CSTRING("frame") : NS_LITERAL_CSTRING("top"), IsFrame() ? "frame"_ns : "top"_ns,
mozilla::dom::LoadErrorToTelemetryLabel(aError)); mozilla::dom::LoadErrorToTelemetryLabel(aError));
// Test if the error needs to be formatted // Test if the error needs to be formatted
@ -5217,8 +5216,7 @@ nsDocShell::SetupRefreshURI(nsIChannel* aChannel) {
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aChannel, &rv)); nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aChannel, &rv));
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
nsAutoCString refreshHeader; nsAutoCString refreshHeader;
rv = httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("refresh"), rv = httpChannel->GetResponseHeader("refresh"_ns, refreshHeader);
refreshHeader);
if (!refreshHeader.IsEmpty()) { if (!refreshHeader.IsEmpty()) {
nsCOMPtr<nsIScriptSecurityManager> secMan = nsCOMPtr<nsIScriptSecurityManager> secMan =
@ -5739,7 +5737,7 @@ already_AddRefed<nsIURI> nsDocShell::AttemptURIFixup(
nsAutoCString scheme; nsAutoCString scheme;
Unused << url->GetScheme(scheme); Unused << url->GetScheme(scheme);
if (Preferences::GetBool("keyword.enabled", false) && if (Preferences::GetBool("keyword.enabled", false) &&
StringBeginsWith(scheme, NS_LITERAL_CSTRING("http"))) { StringBeginsWith(scheme, "http"_ns)) {
bool attemptFixup = false; bool attemptFixup = false;
nsAutoCString host; nsAutoCString host;
Unused << url->GetHost(host); Unused << url->GetHost(host);
@ -5855,7 +5853,7 @@ already_AddRefed<nsIURI> nsDocShell::AttemptURIFixup(
newURI = nullptr; newURI = nullptr;
newPostData = nullptr; newPostData = nullptr;
Unused << NS_MutateURI(url) Unused << NS_MutateURI(url)
.SetScheme(NS_LITERAL_CSTRING("https")) .SetScheme("https"_ns)
.Finalize(getter_AddRefs(newURI)); .Finalize(getter_AddRefs(newURI));
} }
} }
@ -6122,7 +6120,7 @@ nsresult nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
if (NS_SUCCEEDED(rv) && port == -1) { if (NS_SUCCEEDED(rv) && port == -1) {
nsCOMPtr<nsIURI> httpsURI; nsCOMPtr<nsIURI> httpsURI;
rv = NS_MutateURI(url) rv = NS_MutateURI(url)
.SetScheme(NS_LITERAL_CSTRING("https")) .SetScheme("https"_ns)
.Finalize(getter_AddRefs(httpsURI)); .Finalize(getter_AddRefs(httpsURI));
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
@ -6175,9 +6173,9 @@ nsresult nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
params.LastElement().AssignLiteral(u"(unknown uri)"); params.LastElement().AssignLiteral(u"(unknown uri)");
} }
nsContentUtils::ReportToConsole( nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag, NS_LITERAL_CSTRING("DOM"), nsIScriptError::warningFlag, "DOM"_ns, GetExtantDocument(),
GetExtantDocument(), nsContentUtils::eDOM_PROPERTIES, nsContentUtils::eDOM_PROPERTIES, "UnknownProtocolNavigationPrevented",
"UnknownProtocolNavigationPrevented", params); params);
} }
} else { } else {
// If we have a host // If we have a host
@ -6335,8 +6333,7 @@ nsresult nsDocShell::CreateAboutBlankContentViewer(
mFiredUnloadEvent = false; mFiredUnloadEvent = false;
nsCOMPtr<nsIDocumentLoaderFactory> docFactory = nsCOMPtr<nsIDocumentLoaderFactory> docFactory =
nsContentUtils::FindInternalContentViewer( nsContentUtils::FindInternalContentViewer("text/html"_ns);
NS_LITERAL_CSTRING("text/html"));
if (docFactory) { if (docFactory) {
nsCOMPtr<nsIPrincipal> principal, partitionedPrincipal; nsCOMPtr<nsIPrincipal> principal, partitionedPrincipal;
@ -8892,7 +8889,7 @@ bool nsDocShell::CanLoadInParentProcess(nsIURI* aURI) {
uri->GetScheme(scheme); uri->GetScheme(scheme);
// Allow ext+foo URIs (extension-registered custom protocols). See // Allow ext+foo URIs (extension-registered custom protocols). See
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/protocol_handlers // https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/protocol_handlers
if (StringBeginsWith(scheme, NS_LITERAL_CSTRING("ext+")) && if (StringBeginsWith(scheme, "ext+"_ns) &&
!StaticPrefs::extensions_webextensions_remote()) { !StaticPrefs::extensions_webextensions_remote()) {
return true; return true;
} }
@ -8981,9 +8978,9 @@ nsIPrincipal* nsDocShell::GetInheritedPrincipal(
MOZ_TRY(vsh->NewSrcdocChannel(aURI, aBaseURI, aSrcdoc, aLoadInfo, MOZ_TRY(vsh->NewSrcdocChannel(aURI, aBaseURI, aSrcdoc, aLoadInfo,
getter_AddRefs(channel))); getter_AddRefs(channel)));
} else { } else {
MOZ_TRY(NS_NewInputStreamChannelInternal( MOZ_TRY(NS_NewInputStreamChannelInternal(getter_AddRefs(channel), aURI,
getter_AddRefs(channel), aURI, aSrcdoc, NS_LITERAL_CSTRING("text/html"), aSrcdoc, "text/html"_ns, aLoadInfo,
aLoadInfo, true)); true));
nsCOMPtr<nsIInputStreamChannel> isc = do_QueryInterface(channel); nsCOMPtr<nsIInputStreamChannel> isc = do_QueryInterface(channel);
MOZ_ASSERT(isc); MOZ_ASSERT(isc);
isc->SetBaseURI(aBaseURI); isc->SetBaseURI(aBaseURI);
@ -9071,9 +9068,8 @@ nsIPrincipal* nsDocShell::GetInheritedPrincipal(
nsCOMPtr<nsIPrincipal> permissionPrincipal = nsCOMPtr<nsIPrincipal> permissionPrincipal =
BasePrincipal::CreateContentPrincipal(aLoadState->URI(), attrs); BasePrincipal::CreateContentPrincipal(aLoadState->URI(), attrs);
if (nsContentUtils::IsExactSitePermAllow( if (nsContentUtils::IsExactSitePermAllow(permissionPrincipal,
permissionPrincipal, "https-only-mode-exception"_ns)) {
NS_LITERAL_CSTRING("https-only-mode-exception"))) {
uint32_t httpsOnlyStatus = aLoadInfo->GetHttpsOnlyStatus(); uint32_t httpsOnlyStatus = aLoadInfo->GetHttpsOnlyStatus();
httpsOnlyStatus |= nsILoadInfo::HTTPS_ONLY_EXEMPT; httpsOnlyStatus |= nsILoadInfo::HTTPS_ONLY_EXEMPT;
aLoadInfo->SetHttpsOnlyStatus(httpsOnlyStatus); aLoadInfo->SetHttpsOnlyStatus(httpsOnlyStatus);
@ -9190,12 +9186,10 @@ nsIPrincipal* nsDocShell::GetInheritedPrincipal(
} }
// save true referrer for those who need it (e.g. xpinstall whitelisting) // save true referrer for those who need it (e.g. xpinstall whitelisting)
// Currently only http and ftp channels support this. // Currently only http and ftp channels support this.
props->SetPropertyAsInterface( props->SetPropertyAsInterface(u"docshell.internalReferrer"_ns, referrer);
NS_LITERAL_STRING("docshell.internalReferrer"), referrer);
if (aLoadState->HasLoadFlags(INTERNAL_LOAD_FLAGS_FIRST_LOAD)) { if (aLoadState->HasLoadFlags(INTERNAL_LOAD_FLAGS_FIRST_LOAD)) {
props->SetPropertyAsBool(NS_LITERAL_STRING("docshell.newWindowTarget"), props->SetPropertyAsBool(u"docshell.newWindowTarget"_ns, true);
true);
} }
} }
@ -11138,7 +11132,7 @@ nsDocShell::MakeEditable(bool aInWaitForUriLoad) {
nsCOMPtr<nsIPropertyBag2> props(do_QueryInterface(aChannel)); nsCOMPtr<nsIPropertyBag2> props(do_QueryInterface(aChannel));
if (props) { if (props) {
mozilla::Unused << props->GetPropertyAsBool( mozilla::Unused << props->GetPropertyAsBool(
NS_LITERAL_STRING("docshell.needToAddURIVisit"), &needToAddURIVisit); u"docshell.needToAddURIVisit"_ns, &needToAddURIVisit);
} }
return needToAddURIVisit; return needToAddURIVisit;
@ -11151,8 +11145,8 @@ nsDocShell::MakeEditable(bool aInWaitForUriLoad) {
return; return;
} }
nsresult rv = props->GetPropertyAsInterface( nsresult rv = props->GetPropertyAsInterface(u"docshell.previousURI"_ns,
NS_LITERAL_STRING("docshell.previousURI"), NS_GET_IID(nsIURI), NS_GET_IID(nsIURI),
reinterpret_cast<void**>(aURI)); reinterpret_cast<void**>(aURI));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
@ -11161,7 +11155,7 @@ nsDocShell::MakeEditable(bool aInWaitForUriLoad) {
// Treat referrer as null if there is an error getting it. // Treat referrer as null if there is an error getting it.
(void)NS_GetReferrerFromChannel(aChannel, aURI); (void)NS_GetReferrerFromChannel(aChannel, aURI);
} else { } else {
rv = props->GetPropertyAsUint32(NS_LITERAL_STRING("docshell.previousFlags"), rv = props->GetPropertyAsUint32(u"docshell.previousFlags"_ns,
aChannelRedirectFlags); aChannelRedirectFlags);
NS_WARNING_ASSERTION( NS_WARNING_ASSERTION(
@ -11177,9 +11171,8 @@ void nsDocShell::SaveLastVisit(nsIChannel* aChannel, nsIURI* aURI,
return; return;
} }
props->SetPropertyAsInterface(NS_LITERAL_STRING("docshell.previousURI"), props->SetPropertyAsInterface(u"docshell.previousURI"_ns, aURI);
aURI); props->SetPropertyAsUint32(u"docshell.previousFlags"_ns,
props->SetPropertyAsUint32(NS_LITERAL_STRING("docshell.previousFlags"),
aChannelRedirectFlags); aChannelRedirectFlags);
} }
@ -11326,7 +11319,7 @@ nsresult nsDocShell::ConfirmRepost(bool* aRepost) {
// locking up the browser, see bug 1412559 for an example. // locking up the browser, see bug 1412559 for an example.
if (nsCOMPtr<nsIWritablePropertyBag2> promptBag = if (nsCOMPtr<nsIWritablePropertyBag2> promptBag =
do_QueryInterface(prompter)) { do_QueryInterface(prompter)) {
promptBag->SetPropertyAsUint32(NS_LITERAL_STRING("modalType"), promptBag->SetPropertyAsUint32(u"modalType"_ns,
nsIPrompt::MODAL_TYPE_CONTENT); nsIPrompt::MODAL_TYPE_CONTENT);
} }
@ -12074,7 +12067,7 @@ nsDocShell::InitOrReusePrintPreviewViewer(nsIWebBrowserPrint** aPrintPreview) {
nsCOMPtr<nsIPrincipal> principal = nsCOMPtr<nsIPrincipal> principal =
NullPrincipal::CreateWithInheritedAttributes(this); NullPrincipal::CreateWithInheritedAttributes(this);
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
NS_NewURI(getter_AddRefs(uri), NS_LITERAL_CSTRING("about:printpreview")); NS_NewURI(getter_AddRefs(uri), "about:printpreview"_ns);
// Reuse the null principal for the partitioned principal. // Reuse the null principal for the partitioned principal.
// XXXehsan is that the right principal to use here? // XXXehsan is that the right principal to use here?
nsresult rv = CreateAboutBlankContentViewer(principal, principal, nsresult rv = CreateAboutBlankContentViewer(principal, principal,

View file

@ -811,9 +811,9 @@ nsDocShellTreeOwner::AddChromeListeners() {
EventListenerManager* elmP = target->GetOrCreateListenerManager(); EventListenerManager* elmP = target->GetOrCreateListenerManager();
if (elmP) { if (elmP) {
elmP->AddEventListenerByType(this, NS_LITERAL_STRING("dragover"), elmP->AddEventListenerByType(this, u"dragover"_ns,
TrustedEventsAtSystemGroupBubble()); TrustedEventsAtSystemGroupBubble());
elmP->AddEventListenerByType(this, NS_LITERAL_STRING("drop"), elmP->AddEventListenerByType(this, u"drop"_ns,
TrustedEventsAtSystemGroupBubble()); TrustedEventsAtSystemGroupBubble());
} }
@ -835,9 +835,9 @@ nsDocShellTreeOwner::RemoveChromeListeners() {
EventListenerManager* elmP = piTarget->GetOrCreateListenerManager(); EventListenerManager* elmP = piTarget->GetOrCreateListenerManager();
if (elmP) { if (elmP) {
elmP->RemoveEventListenerByType(this, NS_LITERAL_STRING("dragover"), elmP->RemoveEventListenerByType(this, u"dragover"_ns,
TrustedEventsAtSystemGroupBubble()); TrustedEventsAtSystemGroupBubble());
elmP->RemoveEventListenerByType(this, NS_LITERAL_STRING("drop"), elmP->RemoveEventListenerByType(this, u"drop"_ns,
TrustedEventsAtSystemGroupBubble()); TrustedEventsAtSystemGroupBubble());
} }
@ -1009,18 +1009,18 @@ ChromeTooltipListener::AddTooltipListener() {
if (mEventTarget) { if (mEventTarget) {
nsresult rv = NS_OK; nsresult rv = NS_OK;
#ifndef XP_WIN #ifndef XP_WIN
rv = mEventTarget->AddSystemEventListener(NS_LITERAL_STRING("keydown"), rv =
this, false, false); mEventTarget->AddSystemEventListener(u"keydown"_ns, this, false, false);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
#endif #endif
rv = mEventTarget->AddSystemEventListener(NS_LITERAL_STRING("mousedown"), rv = mEventTarget->AddSystemEventListener(u"mousedown"_ns, this, false,
this, false, false); false);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = mEventTarget->AddSystemEventListener(NS_LITERAL_STRING("mouseout"), rv = mEventTarget->AddSystemEventListener(u"mouseout"_ns, this, false,
this, false, false); false);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = mEventTarget->AddSystemEventListener(NS_LITERAL_STRING("mousemove"), rv = mEventTarget->AddSystemEventListener(u"mousemove"_ns, this, false,
this, false, false); false);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
mTooltipListenerInstalled = true; mTooltipListenerInstalled = true;
@ -1049,15 +1049,11 @@ NS_IMETHODIMP
ChromeTooltipListener::RemoveTooltipListener() { ChromeTooltipListener::RemoveTooltipListener() {
if (mEventTarget) { if (mEventTarget) {
#ifndef XP_WIN #ifndef XP_WIN
mEventTarget->RemoveSystemEventListener(NS_LITERAL_STRING("keydown"), this, mEventTarget->RemoveSystemEventListener(u"keydown"_ns, this, false);
false);
#endif #endif
mEventTarget->RemoveSystemEventListener(NS_LITERAL_STRING("mousedown"), mEventTarget->RemoveSystemEventListener(u"mousedown"_ns, this, false);
this, false); mEventTarget->RemoveSystemEventListener(u"mouseout"_ns, this, false);
mEventTarget->RemoveSystemEventListener(NS_LITERAL_STRING("mouseout"), this, mEventTarget->RemoveSystemEventListener(u"mousemove"_ns, this, false);
false);
mEventTarget->RemoveSystemEventListener(NS_LITERAL_STRING("mousemove"),
this, false);
mTooltipListenerInstalled = false; mTooltipListenerInstalled = false;
} }

View file

@ -126,25 +126,21 @@ static void SendPing(void* aClosure, nsIContent* aContent, nsIURI* aURI,
MOZ_ASSERT(NS_SUCCEEDED(rv)); MOZ_ASSERT(NS_SUCCEEDED(rv));
} }
rv = httpChan->SetRequestMethod(NS_LITERAL_CSTRING("POST")); rv = httpChan->SetRequestMethod("POST"_ns);
MOZ_ASSERT(NS_SUCCEEDED(rv)); MOZ_ASSERT(NS_SUCCEEDED(rv));
// Remove extraneous request headers (to reduce request size) // Remove extraneous request headers (to reduce request size)
rv = httpChan->SetRequestHeader(NS_LITERAL_CSTRING("accept"), EmptyCString(), rv = httpChan->SetRequestHeader("accept"_ns, EmptyCString(), false);
false);
MOZ_ASSERT(NS_SUCCEEDED(rv)); MOZ_ASSERT(NS_SUCCEEDED(rv));
rv = httpChan->SetRequestHeader(NS_LITERAL_CSTRING("accept-language"), rv = httpChan->SetRequestHeader("accept-language"_ns, EmptyCString(), false);
EmptyCString(), false);
MOZ_ASSERT(NS_SUCCEEDED(rv)); MOZ_ASSERT(NS_SUCCEEDED(rv));
rv = httpChan->SetRequestHeader(NS_LITERAL_CSTRING("accept-encoding"), rv = httpChan->SetRequestHeader("accept-encoding"_ns, EmptyCString(), false);
EmptyCString(), false);
MOZ_ASSERT(NS_SUCCEEDED(rv)); MOZ_ASSERT(NS_SUCCEEDED(rv));
// Always send a Ping-To header. // Always send a Ping-To header.
nsAutoCString pingTo; nsAutoCString pingTo;
if (NS_SUCCEEDED(info->target->GetSpec(pingTo))) { if (NS_SUCCEEDED(info->target->GetSpec(pingTo))) {
rv = httpChan->SetRequestHeader(NS_LITERAL_CSTRING("Ping-To"), pingTo, rv = httpChan->SetRequestHeader("Ping-To"_ns, pingTo, false);
false);
MOZ_ASSERT(NS_SUCCEEDED(rv)); MOZ_ASSERT(NS_SUCCEEDED(rv));
} }
@ -178,8 +174,7 @@ static void SendPing(void* aClosure, nsIContent* aContent, nsIURI* aURI,
if (sameOrigin || !referrerIsSecure) { if (sameOrigin || !referrerIsSecure) {
nsAutoCString pingFrom; nsAutoCString pingFrom;
if (NS_SUCCEEDED(referrer->GetSpec(pingFrom))) { if (NS_SUCCEEDED(referrer->GetSpec(pingFrom))) {
rv = httpChan->SetRequestHeader(NS_LITERAL_CSTRING("Ping-From"), rv = httpChan->SetRequestHeader("Ping-From"_ns, pingFrom, false);
pingFrom, false);
MOZ_ASSERT(NS_SUCCEEDED(rv)); MOZ_ASSERT(NS_SUCCEEDED(rv));
} }
} }
@ -206,9 +201,8 @@ static void SendPing(void* aClosure, nsIContent* aContent, nsIURI* aURI,
return; return;
} }
uploadChan->ExplicitSetUploadStream( uploadChan->ExplicitSetUploadStream(uploadStream, "text/ping"_ns,
uploadStream, NS_LITERAL_CSTRING("text/ping"), uploadData.Length(), uploadData.Length(), "POST"_ns, false);
NS_LITERAL_CSTRING("POST"), false);
// The channel needs to have a loadgroup associated with it, so that we can // The channel needs to have a loadgroup associated with it, so that we can
// cancel the channel and any redirected channels it may create. // cancel the channel and any redirected channels it may create.

View file

@ -81,7 +81,7 @@ extern mozilla::LazyLogModule gPageCacheLog;
#define LOG_SPEC(format, uri) \ #define LOG_SPEC(format, uri) \
PR_BEGIN_MACRO \ PR_BEGIN_MACRO \
if (MOZ_LOG_TEST(gSHistoryLog, LogLevel::Debug)) { \ if (MOZ_LOG_TEST(gSHistoryLog, LogLevel::Debug)) { \
nsAutoCString _specStr(NS_LITERAL_CSTRING("(null)")); \ nsAutoCString _specStr("(null)"_ns); \
if (uri) { \ if (uri) { \
_specStr = uri->GetSpecOrDefault(); \ _specStr = uri->GetSpecOrDefault(); \
} \ } \

View file

@ -80,8 +80,7 @@ void AbortSignal::Abort() {
init.mBubbles = false; init.mBubbles = false;
init.mCancelable = false; init.mCancelable = false;
RefPtr<Event> event = RefPtr<Event> event = Event::Constructor(this, u"abort"_ns, init);
Event::Constructor(this, NS_LITERAL_STRING("abort"), init);
event->SetTrusted(true); event->SetTrusted(true);
DispatchEvent(*event); DispatchEvent(*event);

View file

@ -541,8 +541,7 @@ void Animation::Cancel(PostRestyleMode aPostRestyle) {
} }
ResetFinishedPromise(); ResetFinishedPromise();
QueuePlaybackEvent(NS_LITERAL_STRING("cancel"), QueuePlaybackEvent(u"cancel"_ns, GetTimelineCurrentTimeAsTimeStamp());
GetTimelineCurrentTimeAsTimeStamp());
} }
StickyTimeDuration activeTime = StickyTimeDuration activeTime =
@ -1153,8 +1152,7 @@ void Animation::Remove() {
UpdateEffect(PostRestyleMode::IfNeeded); UpdateEffect(PostRestyleMode::IfNeeded);
PostUpdate(); PostUpdate();
QueuePlaybackEvent(NS_LITERAL_STRING("remove"), QueuePlaybackEvent(u"remove"_ns, GetTimelineCurrentTimeAsTimeStamp());
GetTimelineCurrentTimeAsTimeStamp());
} }
bool Animation::HasLowerCompositeOrderThan(const Animation& aOther) const { bool Animation::HasLowerCompositeOrderThan(const Animation& aOther) const {
@ -1809,8 +1807,7 @@ void Animation::DoFinishNotificationImmediately(MicroTaskRunnable* aAsync) {
MaybeResolveFinishedPromise(); MaybeResolveFinishedPromise();
QueuePlaybackEvent(NS_LITERAL_STRING("finish"), QueuePlaybackEvent(u"finish"_ns, AnimationTimeToTimeStamp(EffectEnd()));
AnimationTimeToTimeStamp(EffectEnd()));
} }
void Animation::QueuePlaybackEvent(const nsAString& aName, void Animation::QueuePlaybackEvent(const nsAString& aName,

View file

@ -1106,7 +1106,7 @@ static void CreatePropertyValue(
aResult.mEasing.Construct(); aResult.mEasing.Construct();
aTimingFunction->AppendToString(aResult.mEasing.Value()); aTimingFunction->AppendToString(aResult.mEasing.Value());
} else { } else {
aResult.mEasing.Construct(NS_LITERAL_STRING("linear")); aResult.mEasing.Construct(u"linear"_ns);
} }
aResult.mComposite = aComposite; aResult.mComposite = aComposite;

View file

@ -625,9 +625,9 @@ static void ReportInvalidPropertyValueToConsole(
params.AppendElement(aInvalidPropertyValue); params.AppendElement(aInvalidPropertyValue);
CopyASCIItoUTF16(nsCSSProps::GetStringValue(aProperty), CopyASCIItoUTF16(nsCSSProps::GetStringValue(aProperty),
*params.AppendElement()); *params.AppendElement());
nsContentUtils::ReportToConsole( nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, "Animation"_ns,
nsIScriptError::warningFlag, NS_LITERAL_CSTRING("Animation"), aDoc, aDoc, nsContentUtils::eDOM_PROPERTIES,
nsContentUtils::eDOM_PROPERTIES, "InvalidKeyframePropertyValue", params); "InvalidKeyframePropertyValue", params);
} }
/** /**

View file

@ -191,9 +191,8 @@ void AnonymousContent::GetComputedStylePropertyValue(
return; return;
} }
RefPtr<nsComputedDOMStyle> cs = RefPtr<nsComputedDOMStyle> cs = new nsComputedDOMStyle(
new nsComputedDOMStyle(element, NS_LITERAL_STRING(""), element, u""_ns, element->OwnerDoc(), nsComputedDOMStyle::eAll);
element->OwnerDoc(), nsComputedDOMStyle::eAll);
aRv = cs->GetPropertyValue(aPropertyName, aResult); aRv = cs->GetPropertyValue(aPropertyName, aResult);
} }

View file

@ -155,15 +155,13 @@ class MOZ_STACK_CLASS FormDataParser {
continue; continue;
} }
if (seenFormData && if (seenFormData && StringBeginsWith(token, "name="_ns)) {
StringBeginsWith(token, NS_LITERAL_CSTRING("name="))) {
mName = StringTail(token, token.Length() - 5); mName = StringTail(token, token.Length() - 5);
mName.Trim(" \""); mName.Trim(" \"");
continue; continue;
} }
if (seenFormData && if (seenFormData && StringBeginsWith(token, "filename="_ns)) {
StringBeginsWith(token, NS_LITERAL_CSTRING("filename="))) {
mFilename = StringTail(token, token.Length() - 9); mFilename = StringTail(token, token.Length() - 9);
mFilename.Trim(" \""); mFilename.Trim(" \"");
continue; continue;
@ -323,7 +321,7 @@ class MOZ_STACK_CLASS FormDataParser {
case START_PART: case START_PART:
mName.SetIsVoid(true); mName.SetIsVoid(true);
mFilename.SetIsVoid(true); mFilename.SetIsVoid(true);
mContentType = NS_LITERAL_CSTRING("text/plain"); mContentType = "text/plain"_ns;
// MUST start with boundary. // MUST start with boundary.
if (!PushOverBoundary(boundaryString, start, end)) { if (!PushOverBoundary(boundaryString, start, end)) {

View file

@ -178,7 +178,7 @@ void ChromeUtils::ReleaseAssert(GlobalObject& aGlobal, bool aCondition,
location->GetFilename(aGlobal.Context(), filename); location->GetFilename(aGlobal.Context(), filename);
lineNo = location->GetLineNumber(aGlobal.Context()); lineNo = location->GetLineNumber(aGlobal.Context());
} else { } else {
filename.Assign(NS_LITERAL_STRING("<unknown>")); filename.Assign(u"<unknown>"_ns);
} }
// Convert to utf-8 for adding as the MozCrashReason. // Convert to utf-8 for adding as the MozCrashReason.
@ -794,8 +794,7 @@ already_AddRefed<Promise> ChromeUtils::RequestProcInfo(GlobalObject& aGlobal,
global->EventTargetFor(TaskCategory::Performance); global->EventTargetFor(TaskCategory::Performance);
// Getting the parent proc info // Getting the parent proc info
mozilla::GetProcInfo(parentPid, 0, mozilla::ProcType::Browser, mozilla::GetProcInfo(parentPid, 0, mozilla::ProcType::Browser, u""_ns)
NS_LITERAL_STRING(""))
->Then( ->Then(
target, __func__, target, __func__,
[target, domPromise, parentPid](ProcInfo aParentInfo) { [target, domPromise, parentPid](ProcInfo aParentInfo) {

View file

@ -905,8 +905,7 @@ void CustomElementRegistry::Define(
* any exceptions from the conversion. * any exceptions from the conversion.
*/ */
if (callbacksHolder->mAttributeChangedCallback.WasPassed()) { if (callbacksHolder->mAttributeChangedCallback.WasPassed()) {
if (!JSObjectToAtomArray(aCx, constructor, if (!JSObjectToAtomArray(aCx, constructor, u"observedAttributes"_ns,
NS_LITERAL_STRING("observedAttributes"),
observedAttributes, aRv)) { observedAttributes, aRv)) {
return; return;
} }
@ -922,8 +921,7 @@ void CustomElementRegistry::Define(
* Rethrow any exceptions from the conversion. * Rethrow any exceptions from the conversion.
*/ */
if (StaticPrefs::dom_webcomponents_elementInternals_enabled()) { if (StaticPrefs::dom_webcomponents_elementInternals_enabled()) {
if (!JSObjectToAtomArray(aCx, constructor, if (!JSObjectToAtomArray(aCx, constructor, u"disabledFeatures"_ns,
NS_LITERAL_STRING("disabledFeatures"),
disabledFeatures, aRv)) { disabledFeatures, aRv)) {
return; return;
} }
@ -994,7 +992,7 @@ void CustomElementRegistry::Define(
JS::Rooted<JS::Value> detail(aCx, JS::StringValue(nameJsStr)); JS::Rooted<JS::Value> detail(aCx, JS::StringValue(nameJsStr));
RefPtr<CustomEvent> event = NS_NewDOMCustomEvent(doc, nullptr, nullptr); RefPtr<CustomEvent> event = NS_NewDOMCustomEvent(doc, nullptr, nullptr);
event->InitCustomEvent(aCx, NS_LITERAL_STRING("customelementdefined"), event->InitCustomEvent(aCx, u"customelementdefined"_ns,
/* CanBubble */ true, /* CanBubble */ true,
/* Cancelable */ true, detail); /* Cancelable */ true, detail);
event->SetTrusted(true); event->SetTrusted(true);

View file

@ -362,7 +362,7 @@ already_AddRefed<DOMException> DOMException::Constructor(
const Optional<nsAString>& aName) { const Optional<nsAString>& aName) {
nsresult exceptionResult = NS_OK; nsresult exceptionResult = NS_OK;
uint16_t exceptionCode = 0; uint16_t exceptionCode = 0;
nsCString name(NS_LITERAL_CSTRING("Error")); nsCString name("Error"_ns);
if (aName.WasPassed()) { if (aName.WasPassed()) {
CopyUTF16toUTF8(aName.Value(), name); CopyUTF16toUTF8(aName.Value(), name);

View file

@ -96,11 +96,11 @@ nsresult DOMImplementation::CreateDocument(const nsAString& aNamespaceURI,
// document to the new instance. // document to the new instance.
if (aNamespaceURI.EqualsLiteral("http://www.w3.org/1999/xhtml")) { if (aNamespaceURI.EqualsLiteral("http://www.w3.org/1999/xhtml")) {
doc->SetContentType(NS_LITERAL_STRING("application/xhtml+xml")); doc->SetContentType(u"application/xhtml+xml"_ns);
} else if (aNamespaceURI.EqualsLiteral("http://www.w3.org/2000/svg")) { } else if (aNamespaceURI.EqualsLiteral("http://www.w3.org/2000/svg")) {
doc->SetContentType(NS_LITERAL_STRING("image/svg+xml")); doc->SetContentType(u"image/svg+xml"_ns);
} else { } else {
doc->SetContentType(NS_LITERAL_STRING("application/xml")); doc->SetContentType(u"application/xml"_ns);
} }
doc->SetReadyStateInternal(Document::READYSTATE_COMPLETE); doc->SetReadyStateInternal(Document::READYSTATE_COMPLETE);
@ -145,18 +145,18 @@ nsresult DOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<Element> root = nsCOMPtr<Element> root =
doc->CreateElem(NS_LITERAL_STRING("html"), nullptr, kNameSpaceID_XHTML); doc->CreateElem(u"html"_ns, nullptr, kNameSpaceID_XHTML);
rv = doc->AppendChildTo(root, false); rv = doc->AppendChildTo(root, false);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<Element> head = nsCOMPtr<Element> head =
doc->CreateElem(NS_LITERAL_STRING("head"), nullptr, kNameSpaceID_XHTML); doc->CreateElem(u"head"_ns, nullptr, kNameSpaceID_XHTML);
rv = root->AppendChildTo(head, false); rv = root->AppendChildTo(head, false);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
if (!DOMStringIsNull(aTitle)) { if (!DOMStringIsNull(aTitle)) {
nsCOMPtr<Element> title = doc->CreateElem(NS_LITERAL_STRING("title"), nsCOMPtr<Element> title =
nullptr, kNameSpaceID_XHTML); doc->CreateElem(u"title"_ns, nullptr, kNameSpaceID_XHTML);
rv = head->AppendChildTo(title, false); rv = head->AppendChildTo(title, false);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -169,7 +169,7 @@ nsresult DOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
} }
nsCOMPtr<Element> body = nsCOMPtr<Element> body =
doc->CreateElem(NS_LITERAL_STRING("body"), nullptr, kNameSpaceID_XHTML); doc->CreateElem(u"body"_ns, nullptr, kNameSpaceID_XHTML);
rv = root->AppendChildTo(body, false); rv = root->AppendChildTo(body, false);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);

View file

@ -96,8 +96,7 @@ already_AddRefed<Document> DOMParser::ParseFromString(const nsAString& aStr,
return nullptr; return nullptr;
} }
return ParseFromStream(stream, NS_LITERAL_STRING("UTF-8"), utf8str.Length(), return ParseFromStream(stream, u"UTF-8"_ns, utf8str.Length(), aType, aRv);
aType, aRv);
} }
already_AddRefed<Document> DOMParser::ParseFromSafeString(const nsAString& aStr, already_AddRefed<Document> DOMParser::ParseFromSafeString(const nsAString& aStr,

View file

@ -82,7 +82,7 @@ void DOMRequest::FireSuccess(JS::Handle<JS::Value> aResult) {
} }
mResult = aResult; mResult = aResult;
FireEvent(NS_LITERAL_STRING("success"), false, false); FireEvent(u"success"_ns, false, false);
if (mPromise) { if (mPromise) {
mPromise->MaybeResolve(mResult); mPromise->MaybeResolve(mResult);
@ -99,7 +99,7 @@ void DOMRequest::FireError(const nsAString& aError) {
mError = DOMException::Create(NS_ERROR_DOM_UNKNOWN_ERR, mError = DOMException::Create(NS_ERROR_DOM_UNKNOWN_ERR,
NS_ConvertUTF16toUTF8(aError)); NS_ConvertUTF16toUTF8(aError));
FireEvent(NS_LITERAL_STRING("error"), true, true); FireEvent(u"error"_ns, true, true);
if (mPromise) { if (mPromise) {
mPromise->MaybeRejectBrokenly(mError); mPromise->MaybeRejectBrokenly(mError);
@ -114,7 +114,7 @@ void DOMRequest::FireError(nsresult aError) {
mDone = true; mDone = true;
mError = DOMException::Create(aError); mError = DOMException::Create(aError);
FireEvent(NS_LITERAL_STRING("error"), true, true); FireEvent(u"error"_ns, true, true);
if (mPromise) { if (mPromise) {
mPromise->MaybeRejectBrokenly(mError); mPromise->MaybeRejectBrokenly(mError);
@ -129,7 +129,7 @@ void DOMRequest::FireDetailedError(DOMException& aError) {
mDone = true; mDone = true;
mError = &aError; mError = &aError;
FireEvent(NS_LITERAL_STRING("error"), true, true); FireEvent(u"error"_ns, true, true);
if (mPromise) { if (mPromise) {
mPromise->MaybeRejectBrokenly(mError); mPromise->MaybeRejectBrokenly(mError);

View file

@ -178,8 +178,7 @@ DocGroup::DocGroup(BrowsingContextGroup* aBrowsingContextGroup,
mArena = new mozilla::dom::DOMArena(); mArena = new mozilla::dom::DOMArena();
} }
mPerformanceCounter = mPerformanceCounter = new mozilla::PerformanceCounter("DocGroup:"_ns + aKey);
new mozilla::PerformanceCounter(NS_LITERAL_CSTRING("DocGroup:") + aKey);
} }
DocGroup::~DocGroup() { DocGroup::~DocGroup() {

View file

@ -2452,8 +2452,8 @@ void Document::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) {
nsCOMPtr<nsIPropertyBag2> bag = do_QueryInterface(aChannel); nsCOMPtr<nsIPropertyBag2> bag = do_QueryInterface(aChannel);
if (bag) { if (bag) {
nsCOMPtr<nsIURI> baseURI; nsCOMPtr<nsIURI> baseURI;
bag->GetPropertyAsInterface(NS_LITERAL_STRING("baseURI"), bag->GetPropertyAsInterface(u"baseURI"_ns, NS_GET_IID(nsIURI),
NS_GET_IID(nsIURI), getter_AddRefs(baseURI)); getter_AddRefs(baseURI));
if (baseURI) { if (baseURI) {
mDocumentBaseURI = baseURI; mDocumentBaseURI = baseURI;
mChromeXHRDocBaseURI = nullptr; mChromeXHRDocBaseURI = nullptr;
@ -2959,7 +2959,7 @@ static void WarnIfSandboxIneffective(nsIDocShell* aDocShell,
!(aSandboxFlags & SANDBOXED_TOPLEVEL_NAVIGATION_USER_ACTIVATION)) { !(aSandboxFlags & SANDBOXED_TOPLEVEL_NAVIGATION_USER_ACTIVATION)) {
nsCOMPtr<nsIURI> iframeUri; nsCOMPtr<nsIURI> iframeUri;
nsContentUtils::ReportToConsole( nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag, NS_LITERAL_CSTRING("Iframe Sandbox"), nsIScriptError::warningFlag, "Iframe Sandbox"_ns,
aDocShell->GetDocument(), nsContentUtils::eSECURITY_PROPERTIES, aDocShell->GetDocument(), nsContentUtils::eSECURITY_PROPERTIES,
"BothAllowTopNavigationAndUserActivationPresent"); "BothAllowTopNavigationAndUserActivationPresent");
} }
@ -3002,11 +3002,11 @@ static void WarnIfSandboxIneffective(nsIDocShell* aDocShell,
nsCOMPtr<Document> parentDocument = parentDocShell->GetDocument(); nsCOMPtr<Document> parentDocument = parentDocShell->GetDocument();
nsCOMPtr<nsIURI> iframeUri; nsCOMPtr<nsIURI> iframeUri;
parentChannel->GetURI(getter_AddRefs(iframeUri)); parentChannel->GetURI(getter_AddRefs(iframeUri));
nsContentUtils::ReportToConsole( nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
nsIScriptError::warningFlag, NS_LITERAL_CSTRING("Iframe Sandbox"), "Iframe Sandbox"_ns, parentDocument,
parentDocument, nsContentUtils::eSECURITY_PROPERTIES, nsContentUtils::eSECURITY_PROPERTIES,
"BothAllowScriptsAndSameOriginPresent", nsTArray<nsString>(), "BothAllowScriptsAndSameOriginPresent",
iframeUri); nsTArray<nsString>(), iframeUri);
} }
} }
@ -3066,8 +3066,8 @@ nsresult Document::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
nsAutoCString contentType; nsAutoCString contentType;
nsCOMPtr<nsIPropertyBag2> bag = do_QueryInterface(aChannel); nsCOMPtr<nsIPropertyBag2> bag = do_QueryInterface(aChannel);
if ((bag && NS_SUCCEEDED(bag->GetPropertyAsACString( if ((bag && NS_SUCCEEDED(bag->GetPropertyAsACString(u"contentType"_ns,
NS_LITERAL_STRING("contentType"), contentType))) || contentType))) ||
NS_SUCCEEDED(aChannel->GetContentType(contentType))) { NS_SUCCEEDED(aChannel->GetContentType(contentType))) {
// XXX this is only necessary for viewsource: // XXX this is only necessary for viewsource:
nsACString::const_iterator start, end, semicolon; nsACString::const_iterator start, end, semicolon;
@ -3350,12 +3350,11 @@ nsresult Document::InitCSP(nsIChannel* aChannel) {
} }
if (httpChannel) { if (httpChannel) {
Unused << httpChannel->GetResponseHeader( Unused << httpChannel->GetResponseHeader("content-security-policy"_ns,
NS_LITERAL_CSTRING("content-security-policy"), tCspHeaderValue); tCspHeaderValue);
Unused << httpChannel->GetResponseHeader( Unused << httpChannel->GetResponseHeader(
NS_LITERAL_CSTRING("content-security-policy-report-only"), "content-security-policy-report-only"_ns, tCspROHeaderValue);
tCspROHeaderValue);
} }
NS_ConvertASCIItoUTF16 cspHeaderValue(tCspHeaderValue); NS_ConvertASCIItoUTF16 cspHeaderValue(tCspHeaderValue);
NS_ConvertASCIItoUTF16 cspROHeaderValue(tCspROHeaderValue); NS_ConvertASCIItoUTF16 cspROHeaderValue(tCspROHeaderValue);
@ -3506,8 +3505,7 @@ nsresult Document::InitFeaturePolicy(nsIChannel* aChannel) {
// query the policy from the header // query the policy from the header
nsAutoCString value; nsAutoCString value;
rv = httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Feature-Policy"), rv = httpChannel->GetResponseHeader("Feature-Policy"_ns, value);
value);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
mFeaturePolicy->SetDeclaredPolicy(this, NS_ConvertUTF8toUTF16(value), mFeaturePolicy->SetDeclaredPolicy(this, NS_ConvertUTF8toUTF16(value),
NodePrincipal(), nullptr); NodePrincipal(), nullptr);
@ -4165,349 +4163,349 @@ void Document::EnsureInitializeInternalCommandDataHashtable() {
sInternalCommandDataHashtable = new InternalCommandDataHashtable(); sInternalCommandDataHashtable = new InternalCommandDataHashtable();
// clang-format off // clang-format off
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("bold"), u"bold"_ns,
InternalCommandData( InternalCommandData(
"cmd_bold", "cmd_bold",
Command::FormatBold, Command::FormatBold,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
StyleUpdatingCommand::GetInstance)); StyleUpdatingCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("italic"), u"italic"_ns,
InternalCommandData( InternalCommandData(
"cmd_italic", "cmd_italic",
Command::FormatItalic, Command::FormatItalic,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
StyleUpdatingCommand::GetInstance)); StyleUpdatingCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("underline"), u"underline"_ns,
InternalCommandData( InternalCommandData(
"cmd_underline", "cmd_underline",
Command::FormatUnderline, Command::FormatUnderline,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
StyleUpdatingCommand::GetInstance)); StyleUpdatingCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("strikethrough"), u"strikethrough"_ns,
InternalCommandData( InternalCommandData(
"cmd_strikethrough", "cmd_strikethrough",
Command::FormatStrikeThrough, Command::FormatStrikeThrough,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
StyleUpdatingCommand::GetInstance)); StyleUpdatingCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("subscript"), u"subscript"_ns,
InternalCommandData( InternalCommandData(
"cmd_subscript", "cmd_subscript",
Command::FormatSubscript, Command::FormatSubscript,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
StyleUpdatingCommand::GetInstance)); StyleUpdatingCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("superscript"), u"superscript"_ns,
InternalCommandData( InternalCommandData(
"cmd_superscript", "cmd_superscript",
Command::FormatSuperscript, Command::FormatSuperscript,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
StyleUpdatingCommand::GetInstance)); StyleUpdatingCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("cut"), u"cut"_ns,
InternalCommandData( InternalCommandData(
"cmd_cut", "cmd_cut",
Command::Cut, Command::Cut,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
CutCommand::GetInstance)); CutCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("copy"), u"copy"_ns,
InternalCommandData( InternalCommandData(
"cmd_copy", "cmd_copy",
Command::Copy, Command::Copy,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
CopyCommand::GetInstance)); CopyCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("paste"), u"paste"_ns,
InternalCommandData( InternalCommandData(
"cmd_paste", "cmd_paste",
Command::Paste, Command::Paste,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
PasteCommand::GetInstance)); PasteCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("delete"), u"delete"_ns,
InternalCommandData( InternalCommandData(
"cmd_deleteCharBackward", "cmd_deleteCharBackward",
Command::DeleteCharBackward, Command::DeleteCharBackward,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
DeleteCommand::GetInstance)); DeleteCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("forwarddelete"), u"forwarddelete"_ns,
InternalCommandData( InternalCommandData(
"cmd_deleteCharForward", "cmd_deleteCharForward",
Command::DeleteCharForward, Command::DeleteCharForward,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
DeleteCommand::GetInstance)); DeleteCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("selectall"), u"selectall"_ns,
InternalCommandData( InternalCommandData(
"cmd_selectAll", "cmd_selectAll",
Command::SelectAll, Command::SelectAll,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
SelectAllCommand::GetInstance)); SelectAllCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("undo"), u"undo"_ns,
InternalCommandData( InternalCommandData(
"cmd_undo", "cmd_undo",
Command::HistoryUndo, Command::HistoryUndo,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
UndoCommand::GetInstance)); UndoCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("redo"), u"redo"_ns,
InternalCommandData( InternalCommandData(
"cmd_redo", "cmd_redo",
Command::HistoryRedo, Command::HistoryRedo,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
RedoCommand::GetInstance)); RedoCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("indent"), u"indent"_ns,
InternalCommandData("cmd_indent", InternalCommandData("cmd_indent",
Command::FormatIndent, Command::FormatIndent,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
IndentCommand::GetInstance)); IndentCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("outdent"), u"outdent"_ns,
InternalCommandData( InternalCommandData(
"cmd_outdent", "cmd_outdent",
Command::FormatOutdent, Command::FormatOutdent,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
OutdentCommand::GetInstance)); OutdentCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("backcolor"), u"backcolor"_ns,
InternalCommandData( InternalCommandData(
"cmd_highlight", "cmd_highlight",
Command::FormatBackColor, Command::FormatBackColor,
ExecCommandParam::String, ExecCommandParam::String,
HighlightColorStateCommand::GetInstance)); HighlightColorStateCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("hilitecolor"), u"hilitecolor"_ns,
InternalCommandData( InternalCommandData(
"cmd_highlight", "cmd_highlight",
Command::FormatBackColor, Command::FormatBackColor,
ExecCommandParam::String, ExecCommandParam::String,
HighlightColorStateCommand::GetInstance)); HighlightColorStateCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("forecolor"), u"forecolor"_ns,
InternalCommandData( InternalCommandData(
"cmd_fontColor", "cmd_fontColor",
Command::FormatFontColor, Command::FormatFontColor,
ExecCommandParam::String, ExecCommandParam::String,
FontColorStateCommand::GetInstance)); FontColorStateCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("fontname"), u"fontname"_ns,
InternalCommandData( InternalCommandData(
"cmd_fontFace", "cmd_fontFace",
Command::FormatFontName, Command::FormatFontName,
ExecCommandParam::String, ExecCommandParam::String,
FontFaceStateCommand::GetInstance)); FontFaceStateCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("fontsize"), u"fontsize"_ns,
InternalCommandData( InternalCommandData(
"cmd_fontSize", "cmd_fontSize",
Command::FormatFontSize, Command::FormatFontSize,
ExecCommandParam::String, ExecCommandParam::String,
FontSizeStateCommand::GetInstance)); FontSizeStateCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("increasefontsize"), u"increasefontsize"_ns,
InternalCommandData( InternalCommandData(
"cmd_increaseFont", "cmd_increaseFont",
Command::FormatIncreaseFontSize, Command::FormatIncreaseFontSize,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
IncreaseFontSizeCommand::GetInstance)); IncreaseFontSizeCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("decreasefontsize"), u"decreasefontsize"_ns,
InternalCommandData( InternalCommandData(
"cmd_decreaseFont", "cmd_decreaseFont",
Command::FormatDecreaseFontSize, Command::FormatDecreaseFontSize,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
DecreaseFontSizeCommand::GetInstance)); DecreaseFontSizeCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("inserthorizontalrule"), u"inserthorizontalrule"_ns,
InternalCommandData( InternalCommandData(
"cmd_insertHR", "cmd_insertHR",
Command::InsertHorizontalRule, Command::InsertHorizontalRule,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
InsertTagCommand::GetInstance)); InsertTagCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("createlink"), u"createlink"_ns,
InternalCommandData( InternalCommandData(
"cmd_insertLinkNoUI", "cmd_insertLinkNoUI",
Command::InsertLink, Command::InsertLink,
ExecCommandParam::String, ExecCommandParam::String,
InsertTagCommand::GetInstance)); InsertTagCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("insertimage"), u"insertimage"_ns,
InternalCommandData( InternalCommandData(
"cmd_insertImageNoUI", "cmd_insertImageNoUI",
Command::InsertImage, Command::InsertImage,
ExecCommandParam::String, ExecCommandParam::String,
InsertTagCommand::GetInstance)); InsertTagCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("inserthtml"), u"inserthtml"_ns,
InternalCommandData( InternalCommandData(
"cmd_insertHTML", "cmd_insertHTML",
Command::InsertHTML, Command::InsertHTML,
ExecCommandParam::String, ExecCommandParam::String,
InsertHTMLCommand::GetInstance)); InsertHTMLCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("inserttext"), u"inserttext"_ns,
InternalCommandData( InternalCommandData(
"cmd_insertText", "cmd_insertText",
Command::InsertText, Command::InsertText,
ExecCommandParam::String, ExecCommandParam::String,
InsertPlaintextCommand::GetInstance)); InsertPlaintextCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("gethtml"), u"gethtml"_ns,
InternalCommandData( InternalCommandData(
"cmd_getContents", "cmd_getContents",
Command::GetHTML, Command::GetHTML,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
nullptr)); // Not defined in EditorCommands.h nullptr)); // Not defined in EditorCommands.h
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("justifyleft"), u"justifyleft"_ns,
InternalCommandData( InternalCommandData(
"cmd_align", "cmd_align",
Command::FormatJustifyLeft, Command::FormatJustifyLeft,
ExecCommandParam::Ignore, // Will be set to "left" ExecCommandParam::Ignore, // Will be set to "left"
AlignCommand::GetInstance)); AlignCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("justifyright"), u"justifyright"_ns,
InternalCommandData( InternalCommandData(
"cmd_align", "cmd_align",
Command::FormatJustifyRight, Command::FormatJustifyRight,
ExecCommandParam::Ignore, // Will be set to "right" ExecCommandParam::Ignore, // Will be set to "right"
AlignCommand::GetInstance)); AlignCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("justifycenter"), u"justifycenter"_ns,
InternalCommandData( InternalCommandData(
"cmd_align", "cmd_align",
Command::FormatJustifyCenter, Command::FormatJustifyCenter,
ExecCommandParam::Ignore, // Will be set to "center" ExecCommandParam::Ignore, // Will be set to "center"
AlignCommand::GetInstance)); AlignCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("justifyfull"), u"justifyfull"_ns,
InternalCommandData( InternalCommandData(
"cmd_align", "cmd_align",
Command::FormatJustifyFull, Command::FormatJustifyFull,
ExecCommandParam::Ignore, // Will be set to "justify" ExecCommandParam::Ignore, // Will be set to "justify"
AlignCommand::GetInstance)); AlignCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("removeformat"), u"removeformat"_ns,
InternalCommandData( InternalCommandData(
"cmd_removeStyles", "cmd_removeStyles",
Command::FormatRemove, Command::FormatRemove,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
RemoveStylesCommand::GetInstance)); RemoveStylesCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("unlink"), u"unlink"_ns,
InternalCommandData( InternalCommandData(
"cmd_removeLinks", "cmd_removeLinks",
Command::FormatRemoveLink, Command::FormatRemoveLink,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
StyleUpdatingCommand::GetInstance)); StyleUpdatingCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("insertorderedlist"), u"insertorderedlist"_ns,
InternalCommandData( InternalCommandData(
"cmd_ol", "cmd_ol",
Command::InsertOrderedList, Command::InsertOrderedList,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
ListCommand::GetInstance)); ListCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("insertunorderedlist"), u"insertunorderedlist"_ns,
InternalCommandData( InternalCommandData(
"cmd_ul", "cmd_ul",
Command::InsertUnorderedList, Command::InsertUnorderedList,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
ListCommand::GetInstance)); ListCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("insertparagraph"), u"insertparagraph"_ns,
InternalCommandData( InternalCommandData(
"cmd_insertParagraph", "cmd_insertParagraph",
Command::InsertParagraph, Command::InsertParagraph,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
InsertParagraphCommand::GetInstance)); InsertParagraphCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("insertlinebreak"), u"insertlinebreak"_ns,
InternalCommandData( InternalCommandData(
"cmd_insertLineBreak", "cmd_insertLineBreak",
Command::InsertLineBreak, Command::InsertLineBreak,
ExecCommandParam::Ignore, ExecCommandParam::Ignore,
InsertLineBreakCommand::GetInstance)); InsertLineBreakCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("formatblock"), u"formatblock"_ns,
InternalCommandData( InternalCommandData(
"cmd_paragraphState", "cmd_paragraphState",
Command::FormatBlock, Command::FormatBlock,
ExecCommandParam::String, ExecCommandParam::String,
ParagraphStateCommand::GetInstance)); ParagraphStateCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("heading"), u"heading"_ns,
InternalCommandData( InternalCommandData(
"cmd_paragraphState", "cmd_paragraphState",
Command::FormatBlock, Command::FormatBlock,
ExecCommandParam::String, ExecCommandParam::String,
ParagraphStateCommand::GetInstance)); ParagraphStateCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("styleWithCSS"), u"styleWithCSS"_ns,
InternalCommandData( InternalCommandData(
"cmd_setDocumentUseCSS", "cmd_setDocumentUseCSS",
Command::SetDocumentUseCSS, Command::SetDocumentUseCSS,
ExecCommandParam::Boolean, ExecCommandParam::Boolean,
SetDocumentStateCommand::GetInstance)); SetDocumentStateCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("usecss"), // Legacy command u"usecss"_ns, // Legacy command
InternalCommandData( InternalCommandData(
"cmd_setDocumentUseCSS", "cmd_setDocumentUseCSS",
Command::SetDocumentUseCSS, Command::SetDocumentUseCSS,
ExecCommandParam::InvertedBoolean, ExecCommandParam::InvertedBoolean,
SetDocumentStateCommand::GetInstance)); SetDocumentStateCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("contentReadOnly"), u"contentReadOnly"_ns,
InternalCommandData( InternalCommandData(
"cmd_setDocumentReadOnly", "cmd_setDocumentReadOnly",
Command::SetDocumentReadOnly, Command::SetDocumentReadOnly,
ExecCommandParam::Boolean, ExecCommandParam::Boolean,
SetDocumentStateCommand::GetInstance)); SetDocumentStateCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("readonly"), // Legacy command u"readonly"_ns, // Legacy command
InternalCommandData( InternalCommandData(
"cmd_setDocumentReadOnly", "cmd_setDocumentReadOnly",
Command::SetDocumentReadOnly, Command::SetDocumentReadOnly,
ExecCommandParam::InvertedBoolean, ExecCommandParam::InvertedBoolean,
SetDocumentStateCommand::GetInstance)); SetDocumentStateCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("insertBrOnReturn"), u"insertBrOnReturn"_ns,
InternalCommandData( InternalCommandData(
"cmd_insertBrOnReturn", "cmd_insertBrOnReturn",
Command::SetDocumentInsertBROnEnterKeyPress, Command::SetDocumentInsertBROnEnterKeyPress,
ExecCommandParam::Boolean, ExecCommandParam::Boolean,
SetDocumentStateCommand::GetInstance)); SetDocumentStateCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("defaultParagraphSeparator"), u"defaultParagraphSeparator"_ns,
InternalCommandData( InternalCommandData(
"cmd_defaultParagraphSeparator", "cmd_defaultParagraphSeparator",
Command::SetDocumentDefaultParagraphSeparator, Command::SetDocumentDefaultParagraphSeparator,
ExecCommandParam::String, ExecCommandParam::String,
SetDocumentStateCommand::GetInstance)); SetDocumentStateCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("enableObjectResizing"), u"enableObjectResizing"_ns,
InternalCommandData( InternalCommandData(
"cmd_enableObjectResizing", "cmd_enableObjectResizing",
Command::ToggleObjectResizers, Command::ToggleObjectResizers,
ExecCommandParam::Boolean, ExecCommandParam::Boolean,
SetDocumentStateCommand::GetInstance)); SetDocumentStateCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("enableInlineTableEditing"), u"enableInlineTableEditing"_ns,
InternalCommandData( InternalCommandData(
"cmd_enableInlineTableEditing", "cmd_enableInlineTableEditing",
Command::ToggleInlineTableEditor, Command::ToggleInlineTableEditor,
ExecCommandParam::Boolean, ExecCommandParam::Boolean,
SetDocumentStateCommand::GetInstance)); SetDocumentStateCommand::GetInstance));
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("enableAbsolutePositionEditing"), u"enableAbsolutePositionEditing"_ns,
InternalCommandData( InternalCommandData(
"cmd_enableAbsolutePositionEditing", "cmd_enableAbsolutePositionEditing",
Command::ToggleAbsolutePositionEditor, Command::ToggleAbsolutePositionEditor,
@ -4516,7 +4514,7 @@ void Document::EnsureInitializeInternalCommandDataHashtable() {
#if 0 #if 0
// with empty string // with empty string
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("justifynone"), u"justifynone"_ns,
InternalCommandData( InternalCommandData(
"cmd_align", "cmd_align",
Command::Undefined, Command::Undefined,
@ -4524,7 +4522,7 @@ void Document::EnsureInitializeInternalCommandDataHashtable() {
nullptr)); // Not implemented yet. nullptr)); // Not implemented yet.
// REQUIRED SPECIAL REVIEW special review // REQUIRED SPECIAL REVIEW special review
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("saveas"), u"saveas"_ns,
InternalCommandData( InternalCommandData(
"cmd_saveAs", "cmd_saveAs",
Command::Undefined, Command::Undefined,
@ -4532,7 +4530,7 @@ void Document::EnsureInitializeInternalCommandDataHashtable() {
nullptr)); // Not implemented yet. nullptr)); // Not implemented yet.
// REQUIRED SPECIAL REVIEW special review // REQUIRED SPECIAL REVIEW special review
sInternalCommandDataHashtable->Put( sInternalCommandDataHashtable->Put(
NS_LITERAL_STRING("print"), u"print"_ns,
InternalCommandData( InternalCommandData(
"cmd_print", "cmd_print",
Command::Undefined, Command::Undefined,
@ -4732,9 +4730,8 @@ bool Document::ExecCommand(const nsAString& aHTMLCommandName, bool aShowUI,
if (!nsContentUtils::IsCutCopyAllowed(this, aSubjectPrincipal)) { if (!nsContentUtils::IsCutCopyAllowed(this, aSubjectPrincipal)) {
// We have rejected the event due to it not being performed in an // We have rejected the event due to it not being performed in an
// input-driven context therefore, we report the error to the console. // input-driven context therefore, we report the error to the console.
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, "DOM"_ns,
NS_LITERAL_CSTRING("DOM"), this, this, nsContentUtils::eDOM_PROPERTIES,
nsContentUtils::eDOM_PROPERTIES,
"ExecCommandCutCopyDeniedNotInputDriven"); "ExecCommandCutCopyDeniedNotInputDriven");
return false; return false;
} }
@ -5182,7 +5179,7 @@ void Document::QueryCommandValue(const nsAString& aHTMLCommandName,
if (aRv.Failed()) { if (aRv.Failed()) {
return; return;
} }
aRv = params->SetCString("format", NS_LITERAL_CSTRING("text/html")); aRv = params->SetCString("format", "text/html"_ns);
if (aRv.Failed()) { if (aRv.Failed()) {
return; return;
} }
@ -5497,8 +5494,7 @@ nsresult Document::EditingStateChanged() {
// restricted one. // restricted one.
ErrorResult errorResult; ErrorResult errorResult;
nsCOMPtr<nsIPrincipal> principal = NodePrincipal(); nsCOMPtr<nsIPrincipal> principal = NodePrincipal();
Unused << ExecCommand(NS_LITERAL_STRING("insertBrOnReturn"), false, Unused << ExecCommand(u"insertBrOnReturn"_ns, false, u"false"_ns,
NS_LITERAL_STRING("false"),
// Principal doesn't matter here, because the // Principal doesn't matter here, because the
// insertBrOnReturn command doesn't use it. Still // insertBrOnReturn command doesn't use it. Still
// it's too bad we can't easily grab a nullprincipal // it's too bad we can't easily grab a nullprincipal
@ -6578,7 +6574,7 @@ void Document::StyleSheetApplicableStateChanged(StyleSheet& aSheet) {
RefPtr<StyleSheetApplicableStateChangeEvent> event = RefPtr<StyleSheetApplicableStateChangeEvent> event =
StyleSheetApplicableStateChangeEvent::Constructor( StyleSheetApplicableStateChangeEvent::Constructor(
this, NS_LITERAL_STRING("StyleSheetApplicableStateChanged"), init); this, u"StyleSheetApplicableStateChanged"_ns, init);
event->SetTrusted(true); event->SetTrusted(true);
event->SetTarget(this); event->SetTarget(this);
RefPtr<AsyncEventDispatcher> asyncDispatcher = RefPtr<AsyncEventDispatcher> asyncDispatcher =
@ -7195,8 +7191,8 @@ void Document::DispatchContentLoadedEvents() {
// loaded (excluding images and other loads initiated by this // loaded (excluding images and other loads initiated by this
// document). // document).
nsContentUtils::DispatchTrustedEvent(this, ToSupports(this), nsContentUtils::DispatchTrustedEvent(this, ToSupports(this),
NS_LITERAL_STRING("DOMContentLoaded"), u"DOMContentLoaded"_ns, CanBubble::eYes,
CanBubble::eYes, Cancelable::eNo); Cancelable::eNo);
if (auto* const window = GetInnerWindow()) { if (auto* const window = GetInnerWindow()) {
const RefPtr<ServiceWorkerContainer> serviceWorker = const RefPtr<ServiceWorkerContainer> serviceWorker =
@ -7244,13 +7240,11 @@ void Document::DispatchContentLoadedEvents() {
RefPtr<Event> event; RefPtr<Event> event;
if (parent) { if (parent) {
IgnoredErrorResult ignored; IgnoredErrorResult ignored;
event = parent->CreateEvent(NS_LITERAL_STRING("Events"), event = parent->CreateEvent(u"Events"_ns, CallerType::System, ignored);
CallerType::System, ignored);
} }
if (event) { if (event) {
event->InitEvent(NS_LITERAL_STRING("DOMFrameContentLoaded"), true, event->InitEvent(u"DOMFrameContentLoaded"_ns, true, true);
true);
event->SetTarget(target_frame); event->SetTarget(target_frame);
event->SetTrusted(true); event->SetTrusted(true);
@ -7280,8 +7274,8 @@ void Document::DispatchContentLoadedEvents() {
// event. // event.
Element* root = GetRootElement(); Element* root = GetRootElement();
if (root && root->HasAttr(kNameSpaceID_None, nsGkAtoms::manifest)) { if (root && root->HasAttr(kNameSpaceID_None, nsGkAtoms::manifest)) {
nsContentUtils::DispatchChromeEvent( nsContentUtils::DispatchChromeEvent(this, ToSupports(this),
this, ToSupports(this), NS_LITERAL_STRING("MozApplicationManifest"), u"MozApplicationManifest"_ns,
CanBubble::eYes, Cancelable::eYes); CanBubble::eYes, Cancelable::eYes);
} }
@ -7766,7 +7760,7 @@ already_AddRefed<CDATASection> Document::CreateCDATASection(
return nullptr; return nullptr;
} }
if (FindInReadable(NS_LITERAL_STRING("]]>"), aData)) { if (FindInReadable(u"]]>"_ns, aData)) {
rv.Throw(NS_ERROR_DOM_INVALID_CHARACTER_ERR); rv.Throw(NS_ERROR_DOM_INVALID_CHARACTER_ERR);
return nullptr; return nullptr;
} }
@ -7788,7 +7782,7 @@ already_AddRefed<ProcessingInstruction> Document::CreateProcessingInstruction(
return nullptr; return nullptr;
} }
if (FindInReadable(NS_LITERAL_STRING("?>"), aData)) { if (FindInReadable(u"?>"_ns, aData)) {
rv.Throw(NS_ERROR_DOM_INVALID_CHARACTER_ERR); rv.Throw(NS_ERROR_DOM_INVALID_CHARACTER_ERR);
return nullptr; return nullptr;
} }
@ -8075,8 +8069,7 @@ void Document::SetDomain(const nsAString& aDomain, ErrorResult& rv) {
return; return;
} }
if (!FeaturePolicyUtils::IsFeatureAllowed( if (!FeaturePolicyUtils::IsFeatureAllowed(this, u"document-domain"_ns)) {
this, NS_LITERAL_STRING("document-domain"))) {
rv.Throw(NS_ERROR_DOM_SECURITY_ERR); rv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return; return;
} }
@ -8421,8 +8414,8 @@ void Document::DoNotifyPossibleTitleChange() {
// Fire a DOM event for the title change. // Fire a DOM event for the title change.
nsContentUtils::DispatchChromeEvent(this, ToSupports(this), nsContentUtils::DispatchChromeEvent(this, ToSupports(this),
NS_LITERAL_STRING("DOMTitleChanged"), u"DOMTitleChanged"_ns, CanBubble::eYes,
CanBubble::eYes, Cancelable::eYes); Cancelable::eYes);
} }
already_AddRefed<MediaQueryList> Document::MatchMedia( already_AddRefed<MediaQueryList> Document::MatchMedia(
@ -9058,7 +9051,7 @@ void Document::WriteCommon(const nsAString& aText, bool aNewlineTerminate,
if (mIgnoreDestructiveWritesCounter) { if (mIgnoreDestructiveWritesCounter) {
// Instead of implying a call to document.open(), ignore the call. // Instead of implying a call to document.open(), ignore the call.
nsContentUtils::ReportToConsole( nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag, NS_LITERAL_CSTRING("DOM Events"), this, nsIScriptError::warningFlag, "DOM Events"_ns, this,
nsContentUtils::eDOM_PROPERTIES, "DocumentWriteIgnored"); nsContentUtils::eDOM_PROPERTIES, "DocumentWriteIgnored");
return; return;
} }
@ -9075,7 +9068,7 @@ void Document::WriteCommon(const nsAString& aText, bool aNewlineTerminate,
if (mIgnoreDestructiveWritesCounter) { if (mIgnoreDestructiveWritesCounter) {
// Instead of implying a call to document.open(), ignore the call. // Instead of implying a call to document.open(), ignore the call.
nsContentUtils::ReportToConsole( nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag, NS_LITERAL_CSTRING("DOM Events"), this, nsIScriptError::warningFlag, "DOM Events"_ns, this,
nsContentUtils::eDOM_PROPERTIES, "DocumentWriteIgnored"); nsContentUtils::eDOM_PROPERTIES, "DocumentWriteIgnored");
return; return;
} }
@ -9889,9 +9882,9 @@ void Document::AddMetaViewportElement(HTMLMetaElement* aElement,
// Trigger recomputation of the nsViewportInfo the next time it's queried. // Trigger recomputation of the nsViewportInfo the next time it's queried.
mViewportType = Unknown; mViewportType = Unknown;
RefPtr<AsyncEventDispatcher> asyncDispatcher = new AsyncEventDispatcher( RefPtr<AsyncEventDispatcher> asyncDispatcher =
this, NS_LITERAL_STRING("DOMMetaViewportFitChanged"), CanBubble::eYes, new AsyncEventDispatcher(this, u"DOMMetaViewportFitChanged"_ns,
ChromeOnlyDispatch::eYes); CanBubble::eYes, ChromeOnlyDispatch::eYes);
asyncDispatcher->RunDOMEventWhenSafe(); asyncDispatcher->RunDOMEventWhenSafe();
} }
@ -9902,9 +9895,9 @@ void Document::RemoveMetaViewportElement(HTMLMetaElement* aElement) {
// Trigger recomputation of the nsViewportInfo the next time it's queried. // Trigger recomputation of the nsViewportInfo the next time it's queried.
mViewportType = Unknown; mViewportType = Unknown;
RefPtr<AsyncEventDispatcher> asyncDispatcher = new AsyncEventDispatcher( RefPtr<AsyncEventDispatcher> asyncDispatcher =
this, NS_LITERAL_STRING("DOMMetaViewportFitChanged"), CanBubble::eYes, new AsyncEventDispatcher(this, u"DOMMetaViewportFitChanged"_ns,
ChromeOnlyDispatch::eYes); CanBubble::eYes, ChromeOnlyDispatch::eYes);
asyncDispatcher->RunDOMEventWhenSafe(); asyncDispatcher->RunDOMEventWhenSafe();
return; return;
} }
@ -10143,8 +10136,7 @@ void Document::RetrieveRelevantHeaders(nsIChannel* aChannel) {
if (httpChannel) { if (httpChannel) {
nsAutoCString tmp; nsAutoCString tmp;
rv = httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("last-modified"), rv = httpChannel->GetResponseHeader("last-modified"_ns, tmp);
tmp);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
PRTime time; PRTime time;
@ -10252,8 +10244,7 @@ void Document::Sanitize() {
// First locate all input elements, regardless of whether they are // First locate all input elements, regardless of whether they are
// in a form, and reset the password and autocomplete=off elements. // in a form, and reset the password and autocomplete=off elements.
RefPtr<nsContentList> nodes = RefPtr<nsContentList> nodes = GetElementsByTagName(u"input"_ns);
GetElementsByTagName(NS_LITERAL_STRING("input"));
nsAutoString value; nsAutoString value;
@ -10272,7 +10263,7 @@ void Document::Sanitize() {
} }
// Now locate all _form_ elements that have autocomplete=off and reset them // Now locate all _form_ elements that have autocomplete=off and reset them
nodes = GetElementsByTagName(NS_LITERAL_STRING("form")); nodes = GetElementsByTagName(u"form"_ns);
length = nodes->Length(true); length = nodes->Length(true);
for (uint32_t i = 0; i < length; ++i) { for (uint32_t i = 0; i < length; ++i) {
@ -10685,9 +10676,9 @@ void Document::UnblockOnload(bool aFireSync) {
// event to indicate that the SVG should be considered fully loaded. // event to indicate that the SVG should be considered fully loaded.
// Because scripting is disabled on SVG-as-image documents, this event // Because scripting is disabled on SVG-as-image documents, this event
// is not accessible to content authors. (See bug 837315.) // is not accessible to content authors. (See bug 837315.)
RefPtr<AsyncEventDispatcher> asyncDispatcher = new AsyncEventDispatcher( RefPtr<AsyncEventDispatcher> asyncDispatcher =
this, NS_LITERAL_STRING("MozSVGAsImageDocumentLoad"), CanBubble::eNo, new AsyncEventDispatcher(this, u"MozSVGAsImageDocumentLoad"_ns,
ChromeOnlyDispatch::eNo); CanBubble::eNo, ChromeOnlyDispatch::eNo);
asyncDispatcher->PostDOMEvent(); asyncDispatcher->PostDOMEvent();
} }
} }
@ -10801,7 +10792,7 @@ void Document::OnPageShow(bool aPersisted, EventTarget* aDispatchStartTarget,
if (aPersisted && root) { if (aPersisted && root) {
// Send out notifications that our <link> elements are attached. // Send out notifications that our <link> elements are attached.
RefPtr<nsContentList> links = RefPtr<nsContentList> links =
NS_GetContentList(root, kNameSpaceID_XHTML, NS_LITERAL_STRING("link")); NS_GetContentList(root, kNameSpaceID_XHTML, u"link"_ns);
uint32_t linkCount = links->Length(true); uint32_t linkCount = links->Length(true);
for (uint32_t i = 0; i < linkCount; ++i) { for (uint32_t i = 0; i < linkCount; ++i) {
@ -10850,8 +10841,8 @@ void Document::OnPageShow(bool aPersisted, EventTarget* aDispatchStartTarget,
if (!target) { if (!target) {
target = do_QueryInterface(GetWindow()); target = do_QueryInterface(GetWindow());
} }
DispatchPageTransition(target, NS_LITERAL_STRING("pageshow"), DispatchPageTransition(target, u"pageshow"_ns, inFrameLoaderSwap,
inFrameLoaderSwap, aPersisted, aOnlySystemGroup); aPersisted, aOnlySystemGroup);
} }
} }
@ -10878,7 +10869,7 @@ void Document::OnPageHide(bool aPersisted, EventTarget* aDispatchStartTarget,
Element* root = GetRootElement(); Element* root = GetRootElement();
if (aPersisted && root) { if (aPersisted && root) {
RefPtr<nsContentList> links = RefPtr<nsContentList> links =
NS_GetContentList(root, kNameSpaceID_XHTML, NS_LITERAL_STRING("link")); NS_GetContentList(root, kNameSpaceID_XHTML, u"link"_ns);
uint32_t linkCount = links->Length(true); uint32_t linkCount = links->Length(true);
for (uint32_t i = 0; i < linkCount; ++i) { for (uint32_t i = 0; i < linkCount; ++i) {
@ -10924,8 +10915,8 @@ void Document::OnPageHide(bool aPersisted, EventTarget* aDispatchStartTarget,
} }
{ {
PageUnloadingEventTimeStamp timeStamp(this); PageUnloadingEventTimeStamp timeStamp(this);
DispatchPageTransition(target, NS_LITERAL_STRING("pagehide"), DispatchPageTransition(target, u"pagehide"_ns, inFrameLoaderSwap,
inFrameLoaderSwap, aPersisted, aOnlySystemGroup); aPersisted, aOnlySystemGroup);
} }
} }
@ -11257,9 +11248,8 @@ void Document::SetReadyStateInternal(ReadyState aReadyState,
RecordNavigationTiming(aReadyState); RecordNavigationTiming(aReadyState);
} }
RefPtr<AsyncEventDispatcher> asyncDispatcher = RefPtr<AsyncEventDispatcher> asyncDispatcher = new AsyncEventDispatcher(
new AsyncEventDispatcher(this, NS_LITERAL_STRING("readystatechange"), this, u"readystatechange"_ns, CanBubble::eNo, ChromeOnlyDispatch::eNo);
CanBubble::eNo, ChromeOnlyDispatch::eNo);
asyncDispatcher->RunDOMEventWhenSafe(); asyncDispatcher->RunDOMEventWhenSafe();
} }
@ -11419,8 +11409,8 @@ void Document::PreLoadImage(nsIURI* aUri, const nsAString& aCrossOriginAttr,
nsresult rv = nsContentUtils::LoadImage( nsresult rv = nsContentUtils::LoadImage(
aUri, static_cast<nsINode*>(this), this, NodePrincipal(), 0, referrerInfo, aUri, static_cast<nsINode*>(this), this, NodePrincipal(), 0, referrerInfo,
nullptr /* no observer */, loadFlags, nullptr /* no observer */, loadFlags,
aLinkPreload ? NS_LITERAL_STRING("link") : NS_LITERAL_STRING("img"), aLinkPreload ? u"link"_ns : u"img"_ns, getter_AddRefs(request),
getter_AddRefs(request), policyType, false /* urgent */, aLinkPreload); policyType, false /* urgent */, aLinkPreload);
// Pin image-reference to avoid evicting it from the img-cache before // Pin image-reference to avoid evicting it from the img-cache before
// the "real" load occurs. Unpinned in DispatchContentLoadedEvents and // the "real" load occurs. Unpinned in DispatchContentLoadedEvents and
@ -11473,9 +11463,9 @@ void Document::MaybePreconnect(nsIURI* aOrigURI, mozilla::CORSMode aCORSMode) {
// normalize the path before putting it in the hash to accomplish that. // normalize the path before putting it in the hash to accomplish that.
if (aCORSMode == CORS_ANONYMOUS) { if (aCORSMode == CORS_ANONYMOUS) {
mutator.SetPathQueryRef(NS_LITERAL_CSTRING("/anonymous")); mutator.SetPathQueryRef("/anonymous"_ns);
} else { } else {
mutator.SetPathQueryRef(NS_LITERAL_CSTRING("/")); mutator.SetPathQueryRef("/"_ns);
} }
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
@ -12262,7 +12252,7 @@ void Document::WarnOnceAbout(
} }
uint32_t flags = uint32_t flags =
asError ? nsIScriptError::errorFlag : nsIScriptError::warningFlag; asError ? nsIScriptError::errorFlag : nsIScriptError::warningFlag;
nsContentUtils::ReportToConsole(flags, NS_LITERAL_CSTRING("DOM Core"), this, nsContentUtils::ReportToConsole(flags, "DOM Core"_ns, this,
nsContentUtils::eDOM_PROPERTIES, nsContentUtils::eDOM_PROPERTIES,
kDeprecationWarnings[aOperation], aParams); kDeprecationWarnings[aOperation], aParams);
} }
@ -12281,7 +12271,7 @@ void Document::WarnOnceAbout(
mDocWarningWarnedAbout[aWarning] = true; mDocWarningWarnedAbout[aWarning] = true;
uint32_t flags = uint32_t flags =
asError ? nsIScriptError::errorFlag : nsIScriptError::warningFlag; asError ? nsIScriptError::errorFlag : nsIScriptError::warningFlag;
nsContentUtils::ReportToConsole(flags, NS_LITERAL_CSTRING("DOM Core"), this, nsContentUtils::ReportToConsole(flags, "DOM Core"_ns, this,
nsContentUtils::eDOM_PROPERTIES, nsContentUtils::eDOM_PROPERTIES,
kDocumentWarnings[aWarning], aParams); kDocumentWarnings[aWarning], aParams);
} }
@ -12805,9 +12795,9 @@ void Document::MaybeWarnAboutZoom() {
} }
mHasWarnedAboutZoom = true; mHasWarnedAboutZoom = true;
nsContentUtils::ReportToConsole( nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, "Layout"_ns,
nsIScriptError::warningFlag, NS_LITERAL_CSTRING("Layout"), this, this, nsContentUtils::eLAYOUT_PROPERTIES,
nsContentUtils::eLAYOUT_PROPERTIES, "ZoomPropertyWarning"); "ZoomPropertyWarning");
} }
nsIHTMLCollection* Document::Children() { nsIHTMLCollection* Document::Children() {
@ -13076,8 +13066,8 @@ already_AddRefed<Promise> Document::ExitFullscreen(ErrorResult& aRv) {
static void AskWindowToExitFullscreen(Document* aDoc) { static void AskWindowToExitFullscreen(Document* aDoc) {
if (XRE_GetProcessType() == GeckoProcessType_Content) { if (XRE_GetProcessType() == GeckoProcessType_Content) {
nsContentUtils::DispatchEventOnlyToChrome( nsContentUtils::DispatchEventOnlyToChrome(
aDoc, ToSupports(aDoc), NS_LITERAL_STRING("MozDOMFullscreen:Exit"), aDoc, ToSupports(aDoc), u"MozDOMFullscreen:Exit"_ns, CanBubble::eYes,
CanBubble::eYes, Cancelable::eNo, /* DefaultAction */ nullptr); Cancelable::eNo, /* DefaultAction */ nullptr);
} else { } else {
if (nsPIDOMWindowOuter* win = aDoc->GetWindow()) { if (nsPIDOMWindowOuter* win = aDoc->GetWindow()) {
win->SetFullscreenInternal(FullscreenReason::ForFullscreenAPI, false); win->SetFullscreenInternal(FullscreenReason::ForFullscreenAPI, false);
@ -13190,7 +13180,7 @@ class ExitFullscreenScriptRunnable : public Runnable {
// document since we want this event to follow the same path that // document since we want this event to follow the same path that
// MozDOMFullscreen:Entered was dispatched. // MozDOMFullscreen:Entered was dispatched.
nsContentUtils::DispatchEventOnlyToChrome( nsContentUtils::DispatchEventOnlyToChrome(
mLeaf, ToSupports(mLeaf), NS_LITERAL_STRING("MozDOMFullscreen:Exited"), mLeaf, ToSupports(mLeaf), u"MozDOMFullscreen:Exited"_ns,
CanBubble::eYes, Cancelable::eNo, /* DefaultAction */ nullptr); CanBubble::eYes, Cancelable::eNo, /* DefaultAction */ nullptr);
// Ensure the window exits fullscreen. // Ensure the window exits fullscreen.
if (nsPIDOMWindowOuter* win = mRoot->GetWindow()) { if (nsPIDOMWindowOuter* win = mRoot->GetWindow()) {
@ -13253,9 +13243,9 @@ void Document::ExitFullscreenInDocTree(Document* aMaybeNotARootDoc) {
} }
static void DispatchFullscreenNewOriginEvent(Document* aDoc) { static void DispatchFullscreenNewOriginEvent(Document* aDoc) {
RefPtr<AsyncEventDispatcher> asyncDispatcher = new AsyncEventDispatcher( RefPtr<AsyncEventDispatcher> asyncDispatcher =
aDoc, NS_LITERAL_STRING("MozDOMFullscreen:NewOrigin"), CanBubble::eYes, new AsyncEventDispatcher(aDoc, u"MozDOMFullscreen:NewOrigin"_ns,
ChromeOnlyDispatch::eYes); CanBubble::eYes, ChromeOnlyDispatch::eYes);
asyncDispatcher->PostDOMEvent(); asyncDispatcher->PostDOMEvent();
} }
@ -13640,8 +13630,7 @@ const char* Document::GetFullscreenError(CallerType aCallerType) {
return "FullscreenDeniedHidden"; return "FullscreenDeniedHidden";
} }
if (!FeaturePolicyUtils::IsFeatureAllowed(this, if (!FeaturePolicyUtils::IsFeatureAllowed(this, u"fullscreen"_ns)) {
NS_LITERAL_STRING("fullscreen"))) {
return "FullscreenDeniedFeaturePolicy"; return "FullscreenDeniedFeaturePolicy";
} }
@ -13797,8 +13786,8 @@ void Document::RequestFullscreenInContentProcess(
// If we are not the top level process, dispatch an event to make // If we are not the top level process, dispatch an event to make
// our parent process go fullscreen first. // our parent process go fullscreen first.
nsContentUtils::DispatchEventOnlyToChrome( nsContentUtils::DispatchEventOnlyToChrome(
this, ToSupports(this), NS_LITERAL_STRING("MozDOMFullscreen:Request"), this, ToSupports(this), u"MozDOMFullscreen:Request"_ns, CanBubble::eYes,
CanBubble::eYes, Cancelable::eNo, /* DefaultAction */ nullptr); Cancelable::eNo, /* DefaultAction */ nullptr);
} }
void Document::RequestFullscreenInParentProcess( void Document::RequestFullscreenInParentProcess(
@ -13946,8 +13935,8 @@ bool Document::ApplyFullscreen(UniquePtr<FullscreenRequest> aRequest) {
// to pop up warning UI. // to pop up warning UI.
if (!previousFullscreenDoc) { if (!previousFullscreenDoc) {
nsContentUtils::DispatchEventOnlyToChrome( nsContentUtils::DispatchEventOnlyToChrome(
this, ToSupports(elem), NS_LITERAL_STRING("MozDOMFullscreen:Entered"), this, ToSupports(elem), u"MozDOMFullscreen:Entered"_ns, CanBubble::eYes,
CanBubble::eYes, Cancelable::eNo, /* DefaultAction */ nullptr); Cancelable::eNo, /* DefaultAction */ nullptr);
} }
// The origin which is fullscreen gets changed. Trigger an event so // The origin which is fullscreen gets changed. Trigger an event so
@ -13991,7 +13980,7 @@ static void DispatchPointerLockChange(Document* aTarget) {
} }
RefPtr<AsyncEventDispatcher> asyncDispatcher = RefPtr<AsyncEventDispatcher> asyncDispatcher =
new AsyncEventDispatcher(aTarget, NS_LITERAL_STRING("pointerlockchange"), new AsyncEventDispatcher(aTarget, u"pointerlockchange"_ns,
CanBubble::eYes, ChromeOnlyDispatch::eNo); CanBubble::eYes, ChromeOnlyDispatch::eNo);
asyncDispatcher->PostDOMEvent(); asyncDispatcher->PostDOMEvent();
} }
@ -14002,12 +13991,12 @@ static void DispatchPointerLockError(Document* aTarget, const char* aMessage) {
} }
RefPtr<AsyncEventDispatcher> asyncDispatcher = RefPtr<AsyncEventDispatcher> asyncDispatcher =
new AsyncEventDispatcher(aTarget, NS_LITERAL_STRING("pointerlockerror"), new AsyncEventDispatcher(aTarget, u"pointerlockerror"_ns, CanBubble::eYes,
CanBubble::eYes, ChromeOnlyDispatch::eNo); ChromeOnlyDispatch::eNo);
asyncDispatcher->PostDOMEvent(); asyncDispatcher->PostDOMEvent();
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, "DOM"_ns,
NS_LITERAL_CSTRING("DOM"), aTarget, aTarget, nsContentUtils::eDOM_PROPERTIES,
nsContentUtils::eDOM_PROPERTIES, aMessage); aMessage);
} }
class PointerLockRequest final : public Runnable { class PointerLockRequest final : public Runnable {
@ -14150,8 +14139,8 @@ PointerLockRequest::Run() {
ChangePointerLockedElement(e, doc, nullptr); ChangePointerLockedElement(e, doc, nullptr);
nsContentUtils::DispatchEventOnlyToChrome( nsContentUtils::DispatchEventOnlyToChrome(
doc, ToSupports(e), NS_LITERAL_STRING("MozDOMPointerLock:Entered"), doc, ToSupports(e), u"MozDOMPointerLock:Entered"_ns, CanBubble::eYes,
CanBubble::eYes, Cancelable::eNo, /* DefaultAction */ nullptr); Cancelable::eNo, /* DefaultAction */ nullptr);
return NS_OK; return NS_OK;
} }
@ -14247,8 +14236,8 @@ void Document::UnlockPointer(Document* aDoc) {
ChangePointerLockedElement(nullptr, pointerLockedDoc, pointerLockedElement); ChangePointerLockedElement(nullptr, pointerLockedDoc, pointerLockedElement);
RefPtr<AsyncEventDispatcher> asyncDispatcher = new AsyncEventDispatcher( RefPtr<AsyncEventDispatcher> asyncDispatcher = new AsyncEventDispatcher(
pointerLockedElement, NS_LITERAL_STRING("MozDOMPointerLock:Exited"), pointerLockedElement, u"MozDOMPointerLock:Exited"_ns, CanBubble::eYes,
CanBubble::eYes, ChromeOnlyDispatch::eYes); ChromeOnlyDispatch::eYes);
asyncDispatcher->RunDOMEventWhenSafe(); asyncDispatcher->RunDOMEventWhenSafe();
} }
@ -14257,7 +14246,7 @@ void Document::UpdateVisibilityState() {
mVisibilityState = ComputeVisibilityState(); mVisibilityState = ComputeVisibilityState();
if (oldState != mVisibilityState) { if (oldState != mVisibilityState) {
nsContentUtils::DispatchTrustedEvent(this, ToSupports(this), nsContentUtils::DispatchTrustedEvent(this, ToSupports(this),
NS_LITERAL_STRING("visibilitychange"), u"visibilitychange"_ns,
CanBubble::eYes, Cancelable::eNo); CanBubble::eYes, Cancelable::eNo);
EnumerateActivityObservers(NotifyActivityChanged); EnumerateActivityObservers(NotifyActivityChanged);
} }
@ -15110,7 +15099,7 @@ void Document::ReportHasScrollLinkedEffect() {
} }
mHasScrollLinkedEffect = true; mHasScrollLinkedEffect = true;
nsContentUtils::ReportToConsole( nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag, NS_LITERAL_CSTRING("Async Pan/Zoom"), this, nsIScriptError::warningFlag, "Async Pan/Zoom"_ns, this,
nsContentUtils::eLAYOUT_PROPERTIES, "ScrollLinkedEffectFound2"); nsContentUtils::eLAYOUT_PROPERTIES, "ScrollLinkedEffectFound2");
} }
@ -15399,7 +15388,7 @@ class UserIntractionTimer final : public Runnable,
NS_ENSURE_TRUE(!!phase, NS_OK); NS_ENSURE_TRUE(!!phase, NS_OK);
rv = phase->AddBlocker(this, NS_LITERAL_STRING(__FILE__), __LINE__, rv = phase->AddBlocker(this, NS_LITERAL_STRING(__FILE__), __LINE__,
NS_LITERAL_STRING("UserIntractionTimer shutdown")); u"UserIntractionTimer shutdown"_ns);
NS_ENSURE_SUCCESS(rv, NS_OK); NS_ENSURE_SUCCESS(rv, NS_OK);
raii.release(); raii.release();
@ -16242,10 +16231,10 @@ void Document::ReportShadowDOMUsage() {
nsString uri; nsString uri;
Unused << topLevel->GetDocumentURI(uri); Unused << topLevel->GetDocumentURI(uri);
if (!uri.IsEmpty()) { if (!uri.IsEmpty()) {
nsAutoString msg = NS_LITERAL_STRING("Shadow DOM used in [") + uri + nsAutoString msg = u"Shadow DOM used in ["_ns + uri +
NS_LITERAL_STRING("] or in some of its subdocuments."); u"] or in some of its subdocuments."_ns;
nsContentUtils::ReportToConsoleNonLocalized( nsContentUtils::ReportToConsoleNonLocalized(msg, nsIScriptError::infoFlag,
msg, nsIScriptError::infoFlag, NS_LITERAL_CSTRING("DOM"), topLevel); "DOM"_ns, topLevel);
} }
} }

View file

@ -1112,7 +1112,7 @@ already_AddRefed<ShadowRoot> Element::AttachShadowWithoutNameChecks(
// Dispatch a "shadowrootattached" event for devtools. // Dispatch a "shadowrootattached" event for devtools.
{ {
AsyncEventDispatcher* dispatcher = new AsyncEventDispatcher( AsyncEventDispatcher* dispatcher = new AsyncEventDispatcher(
this, NS_LITERAL_STRING("shadowrootattached"), CanBubble::eYes, this, u"shadowrootattached"_ns, CanBubble::eYes,
ChromeOnlyDispatch::eYes, Composed::eYes); ChromeOnlyDispatch::eYes, Composed::eYes);
dispatcher->PostDOMEvent(); dispatcher->PostDOMEvent();
} }
@ -1157,8 +1157,8 @@ void Element::NotifyUAWidgetSetupOrChange() {
MOZ_ASSERT(self->GetShadowRoot() && MOZ_ASSERT(self->GetShadowRoot() &&
self->GetShadowRoot()->IsUAWidget()); self->GetShadowRoot()->IsUAWidget());
nsContentUtils::DispatchChromeEvent( nsContentUtils::DispatchChromeEvent(ownerDoc, self,
ownerDoc, self, NS_LITERAL_STRING("UAWidgetSetupOrChange"), u"UAWidgetSetupOrChange"_ns,
CanBubble::eYes, Cancelable::eNo); CanBubble::eYes, Cancelable::eNo);
})); }));
} }
@ -1186,8 +1186,8 @@ void Element::NotifyUAWidgetTeardown(UnattachShadowRoot aUnattachShadowRoot) {
} }
nsresult rv = nsContentUtils::DispatchChromeEvent( nsresult rv = nsContentUtils::DispatchChromeEvent(
ownerDoc, self, NS_LITERAL_STRING("UAWidgetTeardown"), ownerDoc, self, u"UAWidgetTeardown"_ns, CanBubble::eYes,
CanBubble::eYes, Cancelable::eNo); Cancelable::eNo);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return; return;
} }
@ -1699,9 +1699,9 @@ void Element::UnbindFromTree(bool aNullParent) {
if (mState.HasState(NS_EVENT_STATE_FULLSCREEN)) { if (mState.HasState(NS_EVENT_STATE_FULLSCREEN)) {
// The element being removed is an ancestor of the fullscreen element, // The element being removed is an ancestor of the fullscreen element,
// exit fullscreen state. // exit fullscreen state.
nsContentUtils::ReportToConsole( nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, "DOM"_ns,
nsIScriptError::warningFlag, NS_LITERAL_CSTRING("DOM"), OwnerDoc(), OwnerDoc(), nsContentUtils::eDOM_PROPERTIES,
nsContentUtils::eDOM_PROPERTIES, "RemovedFullscreenElement"); "RemovedFullscreenElement");
// Fully exit fullscreen. // Fully exit fullscreen.
Document::ExitFullscreenInDocTree(OwnerDoc()); Document::ExitFullscreenInDocTree(OwnerDoc());
} }

View file

@ -401,7 +401,7 @@ class CleanupRunnable final : public WorkerMainThreadRunnable {
public: public:
explicit CleanupRunnable(EventSourceImpl* aEventSourceImpl) explicit CleanupRunnable(EventSourceImpl* aEventSourceImpl)
: WorkerMainThreadRunnable(GetCurrentThreadWorkerPrivate(), : WorkerMainThreadRunnable(GetCurrentThreadWorkerPrivate(),
NS_LITERAL_CSTRING("EventSource :: Cleanup")), "EventSource :: Cleanup"_ns),
mImpl(aEventSourceImpl) { mImpl(aEventSourceImpl) {
mWorkerPrivate->AssertIsOnWorkerThread(); mWorkerPrivate->AssertIsOnWorkerThread();
} }
@ -492,8 +492,7 @@ class InitRunnable final : public WorkerMainThreadRunnable {
public: public:
InitRunnable(WorkerPrivate* aWorkerPrivate, EventSourceImpl* aEventSourceImpl, InitRunnable(WorkerPrivate* aWorkerPrivate, EventSourceImpl* aEventSourceImpl,
const nsAString& aURL) const nsAString& aURL)
: WorkerMainThreadRunnable(aWorkerPrivate, : WorkerMainThreadRunnable(aWorkerPrivate, "EventSource :: Init"_ns),
NS_LITERAL_CSTRING("EventSource :: Init")),
mImpl(aEventSourceImpl), mImpl(aEventSourceImpl),
mURL(aURL), mURL(aURL),
mRv(NS_ERROR_NOT_INITIALIZED) { mRv(NS_ERROR_NOT_INITIALIZED) {
@ -534,8 +533,7 @@ class ConnectRunnable final : public WorkerMainThreadRunnable {
public: public:
explicit ConnectRunnable(WorkerPrivate* aWorkerPrivate, explicit ConnectRunnable(WorkerPrivate* aWorkerPrivate,
EventSourceImpl* aEventSourceImpl) EventSourceImpl* aEventSourceImpl)
: WorkerMainThreadRunnable(aWorkerPrivate, : WorkerMainThreadRunnable(aWorkerPrivate, "EventSource :: Connect"_ns),
NS_LITERAL_CSTRING("EventSource :: Connect")),
mImpl(aEventSourceImpl) { mImpl(aEventSourceImpl) {
MOZ_ASSERT(aWorkerPrivate); MOZ_ASSERT(aWorkerPrivate);
aWorkerPrivate->AssertIsOnWorkerThread(); aWorkerPrivate->AssertIsOnWorkerThread();
@ -971,14 +969,13 @@ nsresult EventSourceImpl::GetBaseURI(nsIURI** aBaseURI) {
void EventSourceImpl::SetupHttpChannel() { void EventSourceImpl::SetupHttpChannel() {
AssertIsOnMainThread(); AssertIsOnMainThread();
MOZ_ASSERT(!IsShutDown()); MOZ_ASSERT(!IsShutDown());
nsresult rv = mHttpChannel->SetRequestMethod(NS_LITERAL_CSTRING("GET")); nsresult rv = mHttpChannel->SetRequestMethod("GET"_ns);
MOZ_ASSERT(NS_SUCCEEDED(rv)); MOZ_ASSERT(NS_SUCCEEDED(rv));
/* set the http request headers */ /* set the http request headers */
rv = mHttpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"), rv = mHttpChannel->SetRequestHeader(
NS_LITERAL_CSTRING(TEXT_EVENT_STREAM), "Accept"_ns, nsLiteralCString(TEXT_EVENT_STREAM), false);
false);
MOZ_ASSERT(NS_SUCCEEDED(rv)); MOZ_ASSERT(NS_SUCCEEDED(rv));
// LOAD_BYPASS_CACHE already adds the Cache-Control: no-cache header // LOAD_BYPASS_CACHE already adds the Cache-Control: no-cache header
@ -987,8 +984,7 @@ void EventSourceImpl::SetupHttpChannel() {
return; return;
} }
NS_ConvertUTF16toUTF8 eventId(mLastEventID); NS_ConvertUTF16toUTF8 eventId(mLastEventID);
rv = mHttpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Last-Event-ID"), rv = mHttpChannel->SetRequestHeader("Last-Event-ID"_ns, eventId, false);
eventId, false);
#ifdef DEBUG #ifdef DEBUG
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
MOZ_LOG(gEventSourceLog, LogLevel::Warning, MOZ_LOG(gEventSourceLog, LogLevel::Warning,
@ -1117,7 +1113,7 @@ void EventSourceImpl::AnnounceConnection() {
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return; return;
} }
rv = mEventSource->CreateAndDispatchSimpleEvent(NS_LITERAL_STRING("open")); rv = mEventSource->CreateAndDispatchSimpleEvent(u"open"_ns);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch the error event!!!"); NS_WARNING("Failed to dispatch the error event!!!");
return; return;
@ -1145,9 +1141,8 @@ void EventSourceImpl::ResetDecoder() {
class CallRestartConnection final : public WorkerMainThreadRunnable { class CallRestartConnection final : public WorkerMainThreadRunnable {
public: public:
explicit CallRestartConnection(EventSourceImpl* aEventSourceImpl) explicit CallRestartConnection(EventSourceImpl* aEventSourceImpl)
: WorkerMainThreadRunnable( : WorkerMainThreadRunnable(aEventSourceImpl->mWorkerRef->Private(),
aEventSourceImpl->mWorkerRef->Private(), "EventSource :: RestartConnection"_ns),
NS_LITERAL_CSTRING("EventSource :: RestartConnection")),
mImpl(aEventSourceImpl) { mImpl(aEventSourceImpl) {
mWorkerPrivate->AssertIsOnWorkerThread(); mWorkerPrivate->AssertIsOnWorkerThread();
} }
@ -1202,7 +1197,7 @@ void EventSourceImpl::ReestablishConnection() {
SetReadyState(CONNECTING); SetReadyState(CONNECTING);
ResetDecoder(); ResetDecoder();
rv = mEventSource->CreateAndDispatchSimpleEvent(NS_LITERAL_STRING("error")); rv = mEventSource->CreateAndDispatchSimpleEvent(u"error"_ns);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch the error event!!!"); NS_WARNING("Failed to dispatch the error event!!!");
return; return;
@ -1325,7 +1320,7 @@ void EventSourceImpl::FailConnection() {
// named error at the EventSource object. // named error at the EventSource object.
nsresult rv = mEventSource->CheckCurrentGlobalCorrectness(); nsresult rv = mEventSource->CheckCurrentGlobalCorrectness();
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
rv = mEventSource->CreateAndDispatchSimpleEvent(NS_LITERAL_STRING("error")); rv = mEventSource->CreateAndDispatchSimpleEvent(u"error"_ns);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch the error event!!!"); NS_WARNING("Failed to dispatch the error event!!!");
} }

View file

@ -39,7 +39,7 @@ already_AddRefed<File> GetOrCreateFileCalledBlob(Blob& aBlob,
} }
// Forcing 'blob' as filename // Forcing 'blob' as filename
file = aBlob.ToFile(NS_LITERAL_STRING("blob"), aRv); file = aBlob.ToFile(u"blob"_ns, aRv);
if (NS_WARN_IF(aRv.Failed())) { if (NS_WARN_IF(aRv.Failed())) {
return nullptr; return nullptr;
} }

View file

@ -103,9 +103,9 @@ class FullscreenRequest : public FullscreenChange {
std::move(pendingEvent)); std::move(pendingEvent));
} }
MayRejectPromise("Fullscreen request denied"); MayRejectPromise("Fullscreen request denied");
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, "DOM"_ns,
NS_LITERAL_CSTRING("DOM"), Document(), Document(), nsContentUtils::eDOM_PROPERTIES,
nsContentUtils::eDOM_PROPERTIES, aReason); aReason);
} }
private: private:

View file

@ -433,7 +433,7 @@ already_AddRefed<imgIEncoder> ImageEncoder::GetImageEncoder(nsAString& aType) {
encoderCID += encoderType; encoderCID += encoderType;
nsCOMPtr<imgIEncoder> encoder = do_CreateInstance(encoderCID.get()); nsCOMPtr<imgIEncoder> encoder = do_CreateInstance(encoderCID.get());
if (!encoder && aType != NS_LITERAL_STRING("image/png")) { if (!encoder && aType != u"image/png"_ns) {
// Unable to create an encoder instance of the specified type. Falling back // Unable to create an encoder instance of the specified type. Falling back
// to PNG. // to PNG.
aType.AssignLiteral("image/png"); aType.AssignLiteral("image/png");

View file

@ -212,7 +212,7 @@ void InProcessBrowserChildMessageManager::FireUnloadEvent() {
// Don't let the unload event propagate to chrome event handlers. // Don't let the unload event propagate to chrome event handlers.
mPreventEventsEscaping = true; mPreventEventsEscaping = true;
DOMEventTargetHelper::DispatchTrustedEvent(NS_LITERAL_STRING("unload")); DOMEventTargetHelper::DispatchTrustedEvent(u"unload"_ns);
// Allow events fired during docshell destruction (pagehide, unload) to // Allow events fired during docshell destruction (pagehide, unload) to
// propagate to the <browser> element since chrome code depends on this. // propagate to the <browser> element since chrome code depends on this.

View file

@ -118,7 +118,7 @@ bool MaybeCrossOriginObjectMixins::CrossOriginPropertyFallback(
} }
// Step 2. // Step 2.
return ReportCrossOriginDenial(cx, id, NS_LITERAL_CSTRING("access")); return ReportCrossOriginDenial(cx, id, "access"_ns);
} }
/* static */ /* static */
@ -173,7 +173,7 @@ bool MaybeCrossOriginObjectMixins::CrossOriginGet(
JS::Rooted<JSObject*> getter(cx); JS::Rooted<JSObject*> getter(cx);
if (!desc.hasGetterObject() || !(getter = desc.getterObject())) { if (!desc.hasGetterObject() || !(getter = desc.getterObject())) {
// Step 6. // Step 6.
return ReportCrossOriginDenial(cx, id, NS_LITERAL_CSTRING("get")); return ReportCrossOriginDenial(cx, id, "get"_ns);
} }
// Step 7. // Step 7.
@ -229,7 +229,7 @@ bool MaybeCrossOriginObjectMixins::CrossOriginSet(
} }
// Step 4. // Step 4.
return ReportCrossOriginDenial(cx, id, NS_LITERAL_CSTRING("set")); return ReportCrossOriginDenial(cx, id, "set"_ns);
} }
/* static */ /* static */
@ -432,7 +432,7 @@ bool MaybeCrossOriginObject<Base>::defineProperty(
JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& result) const { JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& result) const {
if (!IsPlatformObjectSameOrigin(cx, proxy)) { if (!IsPlatformObjectSameOrigin(cx, proxy)) {
return ReportCrossOriginDenial(cx, id, NS_LITERAL_CSTRING("define")); return ReportCrossOriginDenial(cx, id, "define"_ns);
} }
// Enter the Realm of proxy and do the remaining work in there. // Enter the Realm of proxy and do the remaining work in there.

View file

@ -115,8 +115,7 @@
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
static const nsLiteralCString kVibrationPermissionType = static const nsLiteralCString kVibrationPermissionType = "vibration"_ns;
NS_LITERAL_CSTRING("vibration");
Navigator::Navigator(nsPIDOMWindowInner* aWindow) : mWindow(aWindow) {} Navigator::Navigator(nsPIDOMWindowInner* aWindow) : mWindow(aWindow) {}
@ -589,7 +588,7 @@ void Navigator::GetBuildID(nsAString& aBuildID, CallerType aCallerType,
} }
// Spoof the buildID on pages not loaded from "https://*.mozilla.org". // Spoof the buildID on pages not loaded from "https://*.mozilla.org".
if (!isHTTPS || !StringEndsWith(host, NS_LITERAL_CSTRING(".mozilla.org"))) { if (!isHTTPS || !StringEndsWith(host, ".mozilla.org"_ns)) {
aBuildID.AssignLiteral(LEGACY_BUILD_ID); aBuildID.AssignLiteral(LEGACY_BUILD_ID);
return; return;
} }
@ -895,7 +894,7 @@ void Navigator::CheckProtocolHandlerAllowed(const nsAString& aScheme,
aHandlerURI->GetSpec(spec); aHandlerURI->GetSpec(spec);
// If the uri doesn't contain '%s', it won't be a good handler - the %s // If the uri doesn't contain '%s', it won't be a good handler - the %s
// gets replaced with the handled URI. // gets replaced with the handled URI.
if (!FindInReadable(NS_LITERAL_CSTRING("%s"), spec)) { if (!FindInReadable("%s"_ns, spec)) {
aRv.ThrowSyntaxError("Handler URI does not contain \"%s\"."); aRv.ThrowSyntaxError("Handler URI does not contain \"%s\".");
return; return;
} }
@ -925,7 +924,7 @@ void Navigator::CheckProtocolHandlerAllowed(const nsAString& aScheme,
// Having checked the handler URI, check the scheme: // Having checked the handler URI, check the scheme:
nsAutoCString scheme; nsAutoCString scheme;
ToLowerCase(NS_ConvertUTF16toUTF8(aScheme), scheme); ToLowerCase(NS_ConvertUTF16toUTF8(aScheme), scheme);
if (StringBeginsWith(scheme, NS_LITERAL_CSTRING("web+"))) { if (StringBeginsWith(scheme, "web+"_ns)) {
// Check for non-ascii // Check for non-ascii
nsReadingIterator<char> iter; nsReadingIterator<char> iter;
nsReadingIterator<char> iterEnd; nsReadingIterator<char> iterEnd;
@ -998,8 +997,8 @@ void Navigator::RegisterProtocolHandler(const nsAString& aScheme,
// If we're a private window, don't alert the user or webpage. We log to the // If we're a private window, don't alert the user or webpage. We log to the
// console so that web developers have some way to tell what's going wrong. // console so that web developers have some way to tell what's going wrong.
nsContentUtils::ReportToConsole( nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag, NS_LITERAL_CSTRING("DOM"), nsIScriptError::warningFlag, "DOM"_ns, mWindow->GetDoc(),
mWindow->GetDoc(), nsContentUtils::eDOM_PROPERTIES, nsContentUtils::eDOM_PROPERTIES,
"RegisterProtocolHandlerPrivateBrowsingWarning"); "RegisterProtocolHandlerPrivateBrowsingWarning");
return; return;
} }
@ -1186,8 +1185,8 @@ bool Navigator::SendBeaconInternal(const nsAString& aUrl,
// Ensure that only streams with content types that are safelisted ignore CORS // Ensure that only streams with content types that are safelisted ignore CORS
// rules // rules
if (aBody && !contentTypeWithCharset.IsVoid() && if (aBody && !contentTypeWithCharset.IsVoid() &&
!nsContentUtils::IsCORSSafelistedRequestHeader( !nsContentUtils::IsCORSSafelistedRequestHeader("content-type"_ns,
NS_LITERAL_CSTRING("content-type"), contentTypeWithCharset)) { contentTypeWithCharset)) {
securityFlags |= nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS; securityFlags |= nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS;
} else { } else {
securityFlags |= nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS; securityFlags |= nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS;
@ -1221,9 +1220,9 @@ bool Navigator::SendBeaconInternal(const nsAString& aUrl,
} }
uploadChannel->ExplicitSetUploadStream(in, contentTypeWithCharset, length, uploadChannel->ExplicitSetUploadStream(in, contentTypeWithCharset, length,
NS_LITERAL_CSTRING("POST"), false); "POST"_ns, false);
} else { } else {
rv = httpChannel->SetRequestMethod(NS_LITERAL_CSTRING("POST")); rv = httpChannel->SetRequestMethod("POST"_ns);
MOZ_ASSERT(NS_SUCCEEDED(rv)); MOZ_ASSERT(NS_SUCCEEDED(rv));
} }
@ -1483,14 +1482,13 @@ void Navigator::GetGamepads(nsTArray<RefPtr<Gamepad>>& aGamepads,
// show a console warning to developers. // show a console warning to developers.
if (!mGamepadSecureContextWarningShown && !win->IsSecureContext()) { if (!mGamepadSecureContextWarningShown && !win->IsSecureContext()) {
mGamepadSecureContextWarningShown = true; mGamepadSecureContextWarningShown = true;
auto msg = NS_LITERAL_STRING( auto msg =
"The Gamepad API is only available in " u"The Gamepad API is only available in "
"secure contexts (e.g., https). Please see " "secure contexts (e.g., https). Please see "
"https://hacks.mozilla.org/2020/06/securing-gamepad-api/ for more " "https://hacks.mozilla.org/2020/06/securing-gamepad-api/ for more "
"info."); "info."_ns;
nsContentUtils::ReportToConsoleNonLocalized( nsContentUtils::ReportToConsoleNonLocalized(
msg, nsIScriptError::warningFlag, NS_LITERAL_CSTRING("DOM"), msg, nsIScriptError::warningFlag, "DOM"_ns, win->GetExtantDoc());
win->GetExtantDoc());
} }
#ifdef NIGHTLY_BUILD #ifdef NIGHTLY_BUILD
@ -1517,7 +1515,7 @@ already_AddRefed<Promise> Navigator::GetVRDisplays(ErrorResult& aRv) {
} }
if (!FeaturePolicyUtils::IsFeatureAllowed(mWindow->GetExtantDoc(), if (!FeaturePolicyUtils::IsFeatureAllowed(mWindow->GetExtantDoc(),
NS_LITERAL_STRING("vr"))) { u"vr"_ns)) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR); aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return nullptr; return nullptr;
} }
@ -1995,8 +1993,7 @@ nsresult Navigator::GetUserAgent(nsPIDOMWindowInner* aWindow,
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(doc->GetChannel()); nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(doc->GetChannel());
if (httpChannel) { if (httpChannel) {
nsAutoCString userAgent; nsAutoCString userAgent;
rv = httpChannel->GetRequestHeader(NS_LITERAL_CSTRING("User-Agent"), rv = httpChannel->GetRequestHeader("User-Agent"_ns, userAgent);
userAgent);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }
@ -2033,22 +2030,21 @@ already_AddRefed<Promise> Navigator::RequestMediaKeySystemAccess(
if (doc) { if (doc) {
Unused << doc->GetDocumentURI(*uri); Unused << doc->GetDocumentURI(*uri);
} }
nsContentUtils::ReportToConsole( nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, "Media"_ns,
nsIScriptError::warningFlag, NS_LITERAL_CSTRING("Media"), doc, doc, nsContentUtils::eDOM_PROPERTIES,
nsContentUtils::eDOM_PROPERTIES, "MediaEMEInsecureContextDeprecatedWarning",
"MediaEMEInsecureContextDeprecatedWarning", params); params);
} }
Document* doc = mWindow->GetExtantDoc(); Document* doc = mWindow->GetExtantDoc();
if (doc && !FeaturePolicyUtils::IsFeatureAllowed( if (doc &&
doc, NS_LITERAL_STRING("encrypted-media"))) { !FeaturePolicyUtils::IsFeatureAllowed(doc, u"encrypted-media"_ns)) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR); aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return nullptr; return nullptr;
} }
RefPtr<DetailedPromise> promise = DetailedPromise::Create( RefPtr<DetailedPromise> promise = DetailedPromise::Create(
mWindow->AsGlobal(), aRv, mWindow->AsGlobal(), aRv, "navigator.requestMediaKeySystemAccess"_ns,
NS_LITERAL_CSTRING("navigator.requestMediaKeySystemAccess"),
Telemetry::VIDEO_EME_REQUEST_SUCCESS_LATENCY_MS, Telemetry::VIDEO_EME_REQUEST_SUCCESS_LATENCY_MS,
Telemetry::VIDEO_EME_REQUEST_FAILURE_LATENCY_MS); Telemetry::VIDEO_EME_REQUEST_FAILURE_LATENCY_MS);
if (aRv.Failed()) { if (aRv.Failed()) {

View file

@ -62,8 +62,7 @@ NodeInfo::NodeInfo(nsAtom* aName, nsAtom* aPrefix, int32_t aNamespaceID,
// Qualified name. If we have no prefix, use ToString on // Qualified name. If we have no prefix, use ToString on
// mInner.mName so that we get to share its buffer. // mInner.mName so that we get to share its buffer.
if (aPrefix) { if (aPrefix) {
mQualifiedName = nsDependentAtomString(mInner.mPrefix) + mQualifiedName = nsDependentAtomString(mInner.mPrefix) + u":"_ns +
NS_LITERAL_STRING(":") +
nsDependentAtomString(mInner.mName); nsDependentAtomString(mInner.mName);
} else { } else {
mInner.mName->ToString(mQualifiedName); mInner.mName->ToString(mQualifiedName);

View file

@ -127,7 +127,7 @@ bool PopupBlocker::CanShowPopupByPermission(nsIPrincipal* aPrincipal) {
if (permissionManager && if (permissionManager &&
NS_SUCCEEDED(permissionManager->TestPermissionFromPrincipal( NS_SUCCEEDED(permissionManager->TestPermissionFromPrincipal(
aPrincipal, NS_LITERAL_CSTRING("popup"), &permit))) { aPrincipal, "popup"_ns, &permit))) {
if (permit == nsIPermissionManager::ALLOW_ACTION) { if (permit == nsIPermissionManager::ALLOW_ACTION) {
return true; return true;
} }

View file

@ -218,7 +218,7 @@ PostMessageEvent::Run() {
return NS_OK; return NS_OK;
} }
event->InitMessageEvent(nullptr, NS_LITERAL_STRING("message"), CanBubble::eNo, event->InitMessageEvent(nullptr, u"message"_ns, CanBubble::eNo,
Cancelable::eNo, messageData, mCallerOrigin, Cancelable::eNo, messageData, mCallerOrigin,
EmptyString(), source, ports); EmptyString(), source, ports);
@ -238,8 +238,8 @@ void PostMessageEvent::DispatchError(JSContext* aCx,
init.mSource.SetValue().SetAsWindowProxy() = mSource; init.mSource.SetValue().SetAsWindowProxy() = mSource;
} }
RefPtr<Event> event = MessageEvent::Constructor( RefPtr<Event> event =
aEventTarget, NS_LITERAL_STRING("messageerror"), init); MessageEvent::Constructor(aEventTarget, u"messageerror"_ns, init);
Dispatch(aTargetWindow, event); Dispatch(aTargetWindow, event);
} }

View file

@ -99,7 +99,7 @@ bool RemoteOuterWindowProxy::getOwnPropertyDescriptor(
return WrapResult(aCx, aProxy, children[index], return WrapResult(aCx, aProxy, children[index],
JSPROP_READONLY | JSPROP_ENUMERATE, aDesc); JSPROP_READONLY | JSPROP_ENUMERATE, aDesc);
} }
return ReportCrossOriginDenial(aCx, aId, NS_LITERAL_CSTRING("access")); return ReportCrossOriginDenial(aCx, aId, "access"_ns);
} }
bool ok = CrossOriginGetOwnPropertyHelper(aCx, aProxy, aId, aDesc); bool ok = CrossOriginGetOwnPropertyHelper(aCx, aProxy, aId, aDesc);

View file

@ -364,7 +364,7 @@ bool ScreenOrientation::LockDeviceOrientation(
mFullscreenListener = new FullscreenEventListener(); mFullscreenListener = new FullscreenEventListener();
} }
aRv = target->AddSystemEventListener(NS_LITERAL_STRING("fullscreenchange"), aRv = target->AddSystemEventListener(u"fullscreenchange"_ns,
mFullscreenListener, mFullscreenListener,
/* useCapture = */ true); /* useCapture = */ true);
if (NS_WARN_IF(aRv.Failed())) { if (NS_WARN_IF(aRv.Failed())) {
@ -390,7 +390,7 @@ void ScreenOrientation::UnlockDeviceOrientation() {
// Remove event listener in case of fullscreen lock. // Remove event listener in case of fullscreen lock.
nsCOMPtr<EventTarget> target = GetOwner()->GetDoc(); nsCOMPtr<EventTarget> target = GetOwner()->GetDoc();
if (target) { if (target) {
target->RemoveSystemEventListener(NS_LITERAL_STRING("fullscreenchange"), target->RemoveSystemEventListener(u"fullscreenchange"_ns,
mFullscreenListener, mFullscreenListener,
/* useCapture */ true); /* useCapture */ true);
} }
@ -510,15 +510,14 @@ void ScreenOrientation::Notify(const hal::ScreenConfiguration& aConfiguration) {
DebugOnly<nsresult> rv; DebugOnly<nsresult> rv;
if (mScreen && mType != previousOrientation) { if (mScreen && mType != previousOrientation) {
// Use of mozorientationchange is deprecated. // Use of mozorientationchange is deprecated.
rv = mScreen->DispatchTrustedEvent( rv = mScreen->DispatchTrustedEvent(u"mozorientationchange"_ns);
NS_LITERAL_STRING("mozorientationchange"));
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "DispatchTrustedEvent failed"); NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "DispatchTrustedEvent failed");
} }
if (doc->Hidden() && !mVisibleListener) { if (doc->Hidden() && !mVisibleListener) {
mVisibleListener = new VisibleEventListener(); mVisibleListener = new VisibleEventListener();
rv = doc->AddSystemEventListener(NS_LITERAL_STRING("visibilitychange"), rv = doc->AddSystemEventListener(u"visibilitychange"_ns, mVisibleListener,
mVisibleListener, /* useCapture = */ true); /* useCapture = */ true);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "AddSystemEventListener failed"); NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "AddSystemEventListener failed");
return; return;
} }
@ -548,8 +547,7 @@ ScreenOrientation::DispatchChangeEventAndResolvePromise() {
RefPtr<ScreenOrientation> self = this; RefPtr<ScreenOrientation> self = this;
return NS_NewRunnableFunction( return NS_NewRunnableFunction(
"dom::ScreenOrientation::DispatchChangeEvent", [self, doc]() { "dom::ScreenOrientation::DispatchChangeEvent", [self, doc]() {
DebugOnly<nsresult> rv = DebugOnly<nsresult> rv = self->DispatchTrustedEvent(u"change"_ns);
self->DispatchTrustedEvent(NS_LITERAL_STRING("change"));
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "DispatchTrustedEvent failed"); NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "DispatchTrustedEvent failed");
if (doc) { if (doc) {
Promise* pendingPromise = doc->GetOrientationPendingPromise(); Promise* pendingPromise = doc->GetOrientationPendingPromise();
@ -603,8 +601,7 @@ ScreenOrientation::VisibleEventListener::HandleEvent(Event* aEvent) {
ScreenOrientation* orientation = screen->Orientation(); ScreenOrientation* orientation = screen->Orientation();
MOZ_ASSERT(orientation); MOZ_ASSERT(orientation);
target->RemoveSystemEventListener(NS_LITERAL_STRING("visibilitychange"), this, target->RemoveSystemEventListener(u"visibilitychange"_ns, this, true);
true);
BrowsingContext* bc = doc->GetBrowsingContext(); BrowsingContext* bc = doc->GetBrowsingContext();
if (bc && bc->GetCurrentOrientationType() != if (bc && bc->GetCurrentOrientationType() !=
@ -650,7 +647,6 @@ ScreenOrientation::FullscreenEventListener::HandleEvent(Event* aEvent) {
hal::UnlockScreenOrientation(); hal::UnlockScreenOrientation();
target->RemoveSystemEventListener(NS_LITERAL_STRING("fullscreenchange"), this, target->RemoveSystemEventListener(u"fullscreenchange"_ns, this, true);
true);
return NS_OK; return NS_OK;
} }

View file

@ -285,8 +285,8 @@ void Selection::Stringify(nsAString& aResult, FlushFrames aFlushFrames) {
} }
IgnoredErrorResult rv; IgnoredErrorResult rv;
ToStringWithFormat(NS_LITERAL_STRING("text/plain"), ToStringWithFormat(u"text/plain"_ns, nsIDocumentEncoder::SkipInvisibleContent,
nsIDocumentEncoder::SkipInvisibleContent, 0, aResult, rv); 0, aResult, rv);
if (rv.Failed()) { if (rv.Failed()) {
aResult.Truncate(); aResult.Truncate();
} }
@ -806,8 +806,8 @@ static bool MaybeDispatchSelectstartEvent(
if (selectstartEventTarget) { if (selectstartEventTarget) {
nsContentUtils::DispatchTrustedEvent( nsContentUtils::DispatchTrustedEvent(
aDocument, selectstartEventTarget, NS_LITERAL_STRING("selectstart"), aDocument, selectstartEventTarget, u"selectstart"_ns, CanBubble::eYes,
CanBubble::eYes, Cancelable::eYes, &executeDefaultAction); Cancelable::eYes, &executeDefaultAction);
} }
return executeDefaultAction; return executeDefaultAction;

View file

@ -152,7 +152,7 @@ class ShadowRoot final : public DocumentFragment,
void RemoveSlot(HTMLSlotElement* aSlot); void RemoveSlot(HTMLSlotElement* aSlot);
bool HasSlots() const { return !mSlotMap.IsEmpty(); }; bool HasSlots() const { return !mSlotMap.IsEmpty(); };
HTMLSlotElement* GetDefaultSlot() const { HTMLSlotElement* GetDefaultSlot() const {
SlotArray* list = mSlotMap.Get(NS_LITERAL_STRING("")); SlotArray* list = mSlotMap.Get(u""_ns);
return list ? (*list)->ElementAt(0) : nullptr; return list ? (*list)->ElementAt(0) : nullptr;
} }

View file

@ -22,8 +22,8 @@ StorageAccessPermissionRequest::StorageAccessPermissionRequest(
nsPIDOMWindowInner* aWindow, nsIPrincipal* aNodePrincipal, nsPIDOMWindowInner* aWindow, nsIPrincipal* aNodePrincipal,
AllowCallback&& aAllowCallback, CancelCallback&& aCancelCallback) AllowCallback&& aAllowCallback, CancelCallback&& aCancelCallback)
: ContentPermissionRequestBase(aNodePrincipal, aWindow, : ContentPermissionRequestBase(aNodePrincipal, aWindow,
NS_LITERAL_CSTRING("dom.storage_access"), "dom.storage_access"_ns,
NS_LITERAL_CSTRING("storage-access")), "storage-access"_ns),
mAllowCallback(std::move(aAllowCallback)), mAllowCallback(std::move(aAllowCallback)),
mCancelCallback(std::move(aCancelCallback)), mCancelCallback(std::move(aCancelCallback)),
mCallbackCalled(false) { mCallbackCalled(false) {

View file

@ -37,8 +37,7 @@ void WindowOrientationObserver::Notify(
uint16_t currentAngle = aConfiguration.angle(); uint16_t currentAngle = aConfiguration.angle();
if (mAngle != currentAngle && mWindow->IsCurrentInnerWindow()) { if (mAngle != currentAngle && mWindow->IsCurrentInnerWindow()) {
mAngle = currentAngle; mAngle = currentAngle;
mWindow->GetOuterWindow()->DispatchCustomEvent( mWindow->GetOuterWindow()->DispatchCustomEvent(u"orientationchange"_ns);
NS_LITERAL_STRING("orientationchange"));
} }
} }

View file

@ -103,15 +103,14 @@ void GenerateConcatExpression(const nsAString& aStr, nsAString& aResult) {
} }
// Prepend concat(' and append '). // Prepend concat(' and append ').
aResult.Assign(NS_LITERAL_STRING("concat(\'") + result + aResult.Assign(u"concat(\'"_ns + result + u"\')"_ns);
NS_LITERAL_STRING("\')"));
} }
void XPathGenerator::QuoteArgument(const nsAString& aArg, nsAString& aResult) { void XPathGenerator::QuoteArgument(const nsAString& aArg, nsAString& aResult) {
if (!aArg.Contains('\'')) { if (!aArg.Contains('\'')) {
aResult.Assign(NS_LITERAL_STRING("\'") + aArg + NS_LITERAL_STRING("\'")); aResult.Assign(u"\'"_ns + aArg + u"\'"_ns);
} else if (!aArg.Contains('\"')) { } else if (!aArg.Contains('\"')) {
aResult.Assign(NS_LITERAL_STRING("\"") + aArg + NS_LITERAL_STRING("\"")); aResult.Assign(u"\""_ns + aArg + u"\""_ns);
} else { } else {
GenerateConcatExpression(aArg, aResult); GenerateConcatExpression(aArg, aResult);
} }
@ -121,8 +120,7 @@ void XPathGenerator::EscapeName(const nsAString& aName, nsAString& aResult) {
if (ContainNonWordCharacter(aName)) { if (ContainNonWordCharacter(aName)) {
nsAutoString quotedArg; nsAutoString quotedArg;
QuoteArgument(aName, quotedArg); QuoteArgument(aName, quotedArg);
aResult.Assign(NS_LITERAL_STRING("*[local-name()=") + quotedArg + aResult.Assign(u"*[local-name()="_ns + quotedArg + u"]"_ns);
NS_LITERAL_STRING("]"));
} else { } else {
aResult.Assign(aName); aResult.Assign(aName);
} }
@ -146,7 +144,7 @@ void XPathGenerator::Generate(const nsINode* aNode, nsAString& aResult) {
if (prefix.IsEmpty()) { if (prefix.IsEmpty()) {
tag.Assign(nodeEscapeName); tag.Assign(nodeEscapeName);
} else { } else {
tag.Assign(prefix + NS_LITERAL_STRING(":") + nodeEscapeName); tag.Assign(prefix + u":"_ns + nodeEscapeName);
} }
if (aNode->HasID()) { if (aNode->HasID()) {
@ -156,8 +154,7 @@ void XPathGenerator::Generate(const nsINode* aNode, nsAString& aResult) {
nsAutoString quotedArgument; nsAutoString quotedArgument;
elem->GetId(elemId); elem->GetId(elemId);
QuoteArgument(elemId, quotedArgument); QuoteArgument(elemId, quotedArgument);
aResult.Assign(NS_LITERAL_STRING("//") + tag + NS_LITERAL_STRING("[@id=") + aResult.Assign(u"//"_ns + tag + u"[@id="_ns + quotedArgument + u"]"_ns);
quotedArgument + NS_LITERAL_STRING("]"));
return; return;
} }
@ -183,8 +180,7 @@ void XPathGenerator::Generate(const nsINode* aNode, nsAString& aResult) {
if (!nodeNameAttribute.IsEmpty()) { if (!nodeNameAttribute.IsEmpty()) {
nsAutoString quotedArgument; nsAutoString quotedArgument;
QuoteArgument(nodeNameAttribute, quotedArgument); QuoteArgument(nodeNameAttribute, quotedArgument);
namePart.Assign(NS_LITERAL_STRING("[@name=") + quotedArgument + namePart.Assign(u"[@name="_ns + quotedArgument + u"]"_ns);
NS_LITERAL_STRING("]"));
} }
if (count != 1) { if (count != 1) {
countPart.AssignLiteral(u"["); countPart.AssignLiteral(u"[");
@ -192,5 +188,5 @@ void XPathGenerator::Generate(const nsINode* aNode, nsAString& aResult) {
countPart.AppendLiteral(u"]"); countPart.AppendLiteral(u"]");
} }
Generate(aNode->GetParentNode(), aResult); Generate(aNode->GetParentNode(), aResult);
aResult.Append(NS_LITERAL_STRING("/") + tag + namePart + countPart); aResult.Append(u"/"_ns + tag + namePart + countPart);
} }

View file

@ -552,7 +552,7 @@ void nsAttrValue::ToString(nsAString& aResult) const {
} else { } else {
str.AppendInt(GetIntInternal()); str.AppendInt(GetIntInternal());
} }
aResult = str + NS_LITERAL_STRING("%"); aResult = str + u"%"_ns;
break; break;
} }

View file

@ -392,9 +392,8 @@ void DragDataProducer::CreateLinkText(const nsAString& inURL,
// use a temp var in case |inText| is the same string as // use a temp var in case |inText| is the same string as
// |outLinkText| to avoid overwriting it while building up the // |outLinkText| to avoid overwriting it while building up the
// string in pieces. // string in pieces.
nsAutoString linkText(NS_LITERAL_STRING("<a href=\"") + inURL + nsAutoString linkText(u"<a href=\""_ns + inURL + u"\">"_ns + inText +
NS_LITERAL_STRING("\">") + inText + u"</a>"_ns);
NS_LITERAL_STRING("</a>"));
outLinkText = linkText; outLinkText = linkText;
} }
@ -813,12 +812,13 @@ nsresult DragDataProducer::AddStringsToDataTransfer(
dragData += title; dragData += title;
AddString(aDataTransfer, NS_LITERAL_STRING(kURLMime), dragData, principal); AddString(aDataTransfer, NS_LITERAL_STRING(kURLMime), dragData, principal);
AddString(aDataTransfer, NS_LITERAL_STRING(kURLDataMime), mUrlString,
principal);
AddString(aDataTransfer, NS_LITERAL_STRING(kURLDataMime), mUrlString, AddString(aDataTransfer, NS_LITERAL_STRING(kURLDataMime), mUrlString,
principal); principal);
AddString(aDataTransfer, NS_LITERAL_STRING(kURLDescriptionMime), AddString(aDataTransfer, NS_LITERAL_STRING(kURLDescriptionMime),
mTitleString, principal); mTitleString, principal);
AddString(aDataTransfer, NS_LITERAL_STRING("text/uri-list"), mUrlString, AddString(aDataTransfer, u"text/uri-list"_ns, mUrlString, principal);
principal);
} }
// add a special flavor for the html context data // add a special flavor for the html context data
@ -878,8 +878,7 @@ nsresult DragDataProducer::AddStringsToDataTransfer(
if (!mIsAnchor) { if (!mIsAnchor) {
AddString(aDataTransfer, NS_LITERAL_STRING(kURLDataMime), mUrlString, AddString(aDataTransfer, NS_LITERAL_STRING(kURLDataMime), mUrlString,
principal); principal);
AddString(aDataTransfer, NS_LITERAL_STRING("text/uri-list"), mUrlString, AddString(aDataTransfer, u"text/uri-list"_ns, mUrlString, principal);
principal);
} }
} }

View file

@ -229,8 +229,7 @@ nsresult nsContentSink::ProcessHTTPHeaders(nsIChannel* aChannel) {
nsAutoCString linkHeader; nsAutoCString linkHeader;
nsresult rv = nsresult rv = httpchannel->GetResponseHeader("link"_ns, linkHeader);
httpchannel->GetResponseHeader(NS_LITERAL_CSTRING("link"), linkHeader);
if (NS_SUCCEEDED(rv) && !linkHeader.IsEmpty()) { if (NS_SUCCEEDED(rv) && !linkHeader.IsEmpty()) {
mDocument->SetHeaderData(nsGkAtoms::link, mDocument->SetHeaderData(nsGkAtoms::link,
NS_ConvertASCIItoUTF16(linkHeader)); NS_ConvertASCIItoUTF16(linkHeader));
@ -832,7 +831,7 @@ void nsContentSink::PrefetchDNS(const nsAString& aHref) {
nsAutoString hostname; nsAutoString hostname;
bool isHttps = false; bool isHttps = false;
if (StringBeginsWith(aHref, NS_LITERAL_STRING("//"))) { if (StringBeginsWith(aHref, u"//"_ns)) {
hostname = Substring(aHref, 2); hostname = Substring(aHref, 2);
} else { } else {
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
@ -1162,7 +1161,7 @@ void nsContentSink::StartLayout(bool aIgnorePendingSheets) {
if (aIgnorePendingSheets) { if (aIgnorePendingSheets) {
nsContentUtils::ReportToConsole( nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag, NS_LITERAL_CSTRING("Layout"), mDocument, nsIScriptError::warningFlag, "Layout"_ns, mDocument,
nsContentUtils::eLAYOUT_PROPERTIES, "ForcedLayoutStart"); nsContentUtils::eLAYOUT_PROPERTIES, "ForcedLayoutStart");
} }
@ -1559,8 +1558,8 @@ void nsContentSink::NotifyDocElementCreated(Document* aDoc) {
observerService->NotifyObservers( observerService->NotifyObservers(
ToSupports(aDoc), "document-element-inserted", EmptyString().get()); ToSupports(aDoc), "document-element-inserted", EmptyString().get());
nsContentUtils::DispatchChromeEvent( nsContentUtils::DispatchChromeEvent(aDoc, ToSupports(aDoc),
aDoc, ToSupports(aDoc), NS_LITERAL_STRING("DOMDocElementInserted"), u"DOMDocElementInserted"_ns,
CanBubble::eYes, Cancelable::eNo); CanBubble::eYes, Cancelable::eNo);
} }

View file

@ -675,8 +675,7 @@ nsresult nsContentUtils::Init() {
#endif #endif
nsDependentCString buildID(mozilla::PlatformBuildID()); nsDependentCString buildID(mozilla::PlatformBuildID());
sJSBytecodeMimeType = sJSBytecodeMimeType = new nsCString("javascript/moz-bytecode-"_ns + buildID);
new nsCString(NS_LITERAL_CSTRING("javascript/moz-bytecode-") + buildID);
Element::InitCCCallbacks(); Element::InitCCCallbacks();
@ -1064,8 +1063,8 @@ nsContentUtils::InternalSerializeAutocompleteAttribute(
enumValue.ParseEnumValue(tokenString, kAutocompleteFieldNameTable, false); enumValue.ParseEnumValue(tokenString, kAutocompleteFieldNameTable, false);
if (result) { if (result) {
// Off/Automatic/Normal categories. // Off/Automatic/Normal categories.
if (enumValue.Equals(NS_LITERAL_STRING("off"), eIgnoreCase) || if (enumValue.Equals(u"off"_ns, eIgnoreCase) ||
enumValue.Equals(NS_LITERAL_STRING("on"), eIgnoreCase)) { enumValue.Equals(u"on"_ns, eIgnoreCase)) {
if (numTokens > 1) { if (numTokens > 1) {
return eAutocompleteAttrState_Invalid; return eAutocompleteAttrState_Invalid;
} }
@ -1073,7 +1072,7 @@ nsContentUtils::InternalSerializeAutocompleteAttribute(
ASCIIToLower(str); ASCIIToLower(str);
aInfo.mFieldName.Assign(str); aInfo.mFieldName.Assign(str);
aInfo.mCanAutomaticallyPersist = aInfo.mCanAutomaticallyPersist =
!enumValue.Equals(NS_LITERAL_STRING("off"), eIgnoreCase); !enumValue.Equals(u"off"_ns, eIgnoreCase);
return eAutocompleteAttrState_Valid; return eAutocompleteAttrState_Valid;
} }
@ -2709,9 +2708,9 @@ static inline void KeyAppendInt(int32_t aInt, nsACString& aKey) {
static inline bool IsAutocompleteOff(const nsIContent* aContent) { static inline bool IsAutocompleteOff(const nsIContent* aContent) {
return aContent->IsElement() && return aContent->IsElement() &&
aContent->AsElement()->AttrValueIs( aContent->AsElement()->AttrValueIs(kNameSpaceID_None,
kNameSpaceID_None, nsGkAtoms::autocomplete, nsGkAtoms::autocomplete, u"off"_ns,
NS_LITERAL_STRING("off"), eIgnoreCase); eIgnoreCase);
} }
/*static*/ /*static*/
@ -2799,11 +2798,11 @@ void nsContentUtils::GenerateStateKey(nsIContent* aContent, Document* aDocument,
MOZ_ASSERT(formElement->GetFormNumberForStateKey() != -1, MOZ_ASSERT(formElement->GetFormNumberForStateKey() != -1,
"when generating a state key for a parser inserted form " "when generating a state key for a parser inserted form "
"control we should have a parser inserted <form> element"); "control we should have a parser inserted <form> element");
KeyAppendString(NS_LITERAL_CSTRING("fp"), aKey); KeyAppendString("fp"_ns, aKey);
KeyAppendInt(formElement->GetFormNumberForStateKey(), aKey); KeyAppendInt(formElement->GetFormNumberForStateKey(), aKey);
appendedForm = true; appendedForm = true;
} else { } else {
KeyAppendString(NS_LITERAL_CSTRING("fn"), aKey); KeyAppendString("fn"_ns, aKey);
int32_t index = htmlForms->IndexOf(formElement, false); int32_t index = htmlForms->IndexOf(formElement, false);
if (index <= -1) { if (index <= -1) {
// //
@ -2840,12 +2839,12 @@ void nsContentUtils::GenerateStateKey(nsIContent* aContent, Document* aDocument,
// inserted control, or the index of the control in the document // inserted control, or the index of the control in the document
// otherwise. // otherwise.
if (parserInserted) { if (parserInserted) {
KeyAppendString(NS_LITERAL_CSTRING("dp"), aKey); KeyAppendString("dp"_ns, aKey);
KeyAppendInt(control->GetParserInsertedControlNumberForStateKey(), KeyAppendInt(control->GetParserInsertedControlNumberForStateKey(),
aKey); aKey);
generatedUniqueKey = true; generatedUniqueKey = true;
} else { } else {
KeyAppendString(NS_LITERAL_CSTRING("dn"), aKey); KeyAppendString("dn"_ns, aKey);
int32_t index = htmlFormControls->IndexOf(aContent, true); int32_t index = htmlFormControls->IndexOf(aContent, true);
if (index > -1) { if (index > -1) {
KeyAppendInt(index, aKey); KeyAppendInt(index, aKey);
@ -2872,7 +2871,7 @@ void nsContentUtils::GenerateStateKey(nsIContent* aContent, Document* aDocument,
} else { } else {
// Append a character that is not "d" or "f" to disambiguate from // Append a character that is not "d" or "f" to disambiguate from
// the case when we were a form control in an HTML document. // the case when we were a form control in an HTML document.
KeyAppendString(NS_LITERAL_CSTRING("o"), aKey); KeyAppendString("o"_ns, aKey);
} }
// Now start at aContent and append the indices of it and all its ancestors // Now start at aContent and append the indices of it and all its ancestors
@ -3764,7 +3763,7 @@ nsresult nsContentUtils::ReportToConsole(
/* static */ /* static */
void nsContentUtils::ReportEmptyGetElementByIdArg(const Document* aDoc) { void nsContentUtils::ReportEmptyGetElementByIdArg(const Document* aDoc) {
ReportToConsole(nsIScriptError::warningFlag, NS_LITERAL_CSTRING("DOM"), aDoc, ReportToConsole(nsIScriptError::warningFlag, "DOM"_ns, aDoc,
nsContentUtils::eDOM_PROPERTIES, "EmptyGetElementByIdParam"); nsContentUtils::eDOM_PROPERTIES, "EmptyGetElementByIdParam");
} }
@ -3934,7 +3933,7 @@ nsAtom* nsContentUtils::GetEventMessageAndAtom(
} }
*aEventMessage = eUnidentifiedEvent; *aEventMessage = eUnidentifiedEvent;
RefPtr<nsAtom> atom = NS_AtomizeMainThread(NS_LITERAL_STRING("on") + aName); RefPtr<nsAtom> atom = NS_AtomizeMainThread(u"on"_ns + aName);
sUserDefinedEvents->AppendElement(atom); sUserDefinedEvents->AppendElement(atom);
mapping.mAtom = atom; mapping.mAtom = atom;
mapping.mMessage = eUnidentifiedEvent; mapping.mMessage = eUnidentifiedEvent;
@ -3967,7 +3966,7 @@ EventMessage nsContentUtils::GetEventMessageAndAtomForListener(
if (mapping.mMaybeSpecialSVGorSMILEvent) { if (mapping.mMaybeSpecialSVGorSMILEvent) {
// Try the atom version so that we should get the right message for // Try the atom version so that we should get the right message for
// SVG/SMIL. // SVG/SMIL.
atom = NS_AtomizeMainThread(NS_LITERAL_STRING("on") + aName); atom = NS_AtomizeMainThread(u"on"_ns + aName);
msg = GetEventMessage(atom); msg = GetEventMessage(atom);
} else { } else {
atom = mapping.mAtom; atom = mapping.mAtom;
@ -3995,7 +3994,7 @@ static nsresult GetEventAndTarget(Document* aDoc, nsISupports* aTarget,
ErrorResult err; ErrorResult err;
RefPtr<Event> event = RefPtr<Event> event =
aDoc->CreateEvent(NS_LITERAL_STRING("Events"), CallerType::System, err); aDoc->CreateEvent(u"Events"_ns, CallerType::System, err);
if (NS_WARN_IF(err.Failed())) { if (NS_WARN_IF(err.Failed())) {
return err.StealNSResult(); return err.StealNSResult();
} }
@ -4299,9 +4298,9 @@ void nsContentUtils::RequestFrameFocus(Element& aFrameElement, bool aCanRaise,
RefPtr<Element> target = &aFrameElement; RefPtr<Element> target = &aFrameElement;
bool defaultAction = true; bool defaultAction = true;
if (aCanRaise) { if (aCanRaise) {
DispatchEventOnlyToChrome( DispatchEventOnlyToChrome(target->OwnerDoc(), target,
target->OwnerDoc(), target, NS_LITERAL_STRING("framefocusrequested"), u"framefocusrequested"_ns, CanBubble::eYes,
CanBubble::eYes, Cancelable::eYes, &defaultAction); Cancelable::eYes, &defaultAction);
} }
if (!defaultAction) { if (!defaultAction) {
return; return;
@ -4974,7 +4973,7 @@ nsresult nsContentUtils::ConvertToPlainText(const nsAString& aSourceBuffer,
nsCOMPtr<nsIDocumentEncoder> encoder = do_createDocumentEncoder("text/plain"); nsCOMPtr<nsIDocumentEncoder> encoder = do_createDocumentEncoder("text/plain");
rv = encoder->Init(document, NS_LITERAL_STRING("text/plain"), aFlags); rv = encoder->Init(document, u"text/plain"_ns, aFlags);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
encoder->SetWrapColumn(aWrapCol); encoder->SetWrapColumn(aWrapCol);
@ -5938,7 +5937,7 @@ nsresult nsContentUtils::DispatchXULCommand(nsIContent* aTarget, bool aTrusted,
RefPtr<XULCommandEvent> xulCommand = RefPtr<XULCommandEvent> xulCommand =
new XULCommandEvent(doc, presContext, nullptr); new XULCommandEvent(doc, presContext, nullptr);
xulCommand->InitCommandEvent(NS_LITERAL_STRING("command"), true, true, xulCommand->InitCommandEvent(u"command"_ns, true, true,
nsGlobalWindowInner::Cast(doc->GetInnerWindow()), nsGlobalWindowInner::Cast(doc->GetInnerWindow()),
0, aCtrl, aAlt, aShift, aMeta, aSourceEvent, 0, aCtrl, aAlt, aShift, aMeta, aSourceEvent,
aInputSource, IgnoreErrors()); aInputSource, IgnoreErrors());
@ -6323,7 +6322,7 @@ bool nsContentUtils::AllowXULXBLForPrincipal(nsIPrincipal* aPrincipal) {
return (StaticPrefs::dom_allow_XUL_XBL_for_file() && return (StaticPrefs::dom_allow_XUL_XBL_for_file() &&
aPrincipal->SchemeIs("file")) || aPrincipal->SchemeIs("file")) ||
IsSitePermAllow(aPrincipal, NS_LITERAL_CSTRING("allowXULXBL")); IsSitePermAllow(aPrincipal, "allowXULXBL"_ns);
} }
bool nsContentUtils::IsPDFJSEnabled() { bool nsContentUtils::IsPDFJSEnabled() {
@ -6403,9 +6402,8 @@ static void ReportPatternCompileFailure(nsAString& aPattern,
return; return;
} }
nsContentUtils::ReportToConsole(nsIScriptError::errorFlag, nsContentUtils::ReportToConsole(nsIScriptError::errorFlag, "DOM"_ns,
NS_LITERAL_CSTRING("DOM"), aDocument, aDocument, nsContentUtils::eDOM_PROPERTIES,
nsContentUtils::eDOM_PROPERTIES,
"PatternAttributeCompileFailure", strings); "PatternAttributeCompileFailure", strings);
savedExc.drop(); savedExc.drop();
} }
@ -6806,9 +6804,9 @@ bool nsContentUtils::IsForbiddenRequestHeader(const nsACString& aHeader) {
return true; return true;
} }
return StringBeginsWith(aHeader, NS_LITERAL_CSTRING("proxy-"), return StringBeginsWith(aHeader, "proxy-"_ns,
nsCaseInsensitiveCStringComparator) || nsCaseInsensitiveCStringComparator) ||
StringBeginsWith(aHeader, NS_LITERAL_CSTRING("sec-"), StringBeginsWith(aHeader, "sec-"_ns,
nsCaseInsensitiveCStringComparator); nsCaseInsensitiveCStringComparator);
} }
@ -7310,7 +7308,7 @@ bool nsContentUtils::IsFileImage(nsIFile* aFile, nsACString& aType) {
return false; return false;
} }
return StringBeginsWith(aType, NS_LITERAL_CSTRING("image/")); return StringBeginsWith(aType, "image/"_ns);
} }
nsresult nsContentUtils::CalculateBufferSizeForImage( nsresult nsContentUtils::CalculateBufferSizeForImage(
@ -7991,8 +7989,7 @@ ReferrerPolicy nsContentUtils::GetReferrerPolicyFromChannel(
nsresult rv; nsresult rv;
nsAutoCString headerValue; nsAutoCString headerValue;
rv = httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("referrer-policy"), rv = httpChannel->GetResponseHeader("referrer-policy"_ns, headerValue);
headerValue);
if (NS_FAILED(rv) || headerValue.IsEmpty()) { if (NS_FAILED(rv) || headerValue.IsEmpty()) {
return ReferrerPolicy::_empty; return ReferrerPolicy::_empty;
} }
@ -8537,8 +8534,8 @@ static void StartElement(Element* aContent, StringBuilder& aBuilder) {
// Filter out any attribute starting with [-|_]moz // Filter out any attribute starting with [-|_]moz
nsDependentAtomString attrNameStr(attName); nsDependentAtomString attrNameStr(attName);
if (StringBeginsWith(attrNameStr, NS_LITERAL_STRING("_moz")) || if (StringBeginsWith(attrNameStr, u"_moz"_ns) ||
StringBeginsWith(attrNameStr, NS_LITERAL_STRING("-moz"))) { StringBeginsWith(attrNameStr, u"-moz"_ns)) {
continue; continue;
} }
@ -8549,7 +8546,7 @@ static void StartElement(Element* aContent, StringBuilder& aBuilder) {
// Bug 16988. Yuck. // Bug 16988. Yuck.
if (localName == nsGkAtoms::br && tagNS == kNameSpaceID_XHTML && if (localName == nsGkAtoms::br && tagNS == kNameSpaceID_XHTML &&
attName == nsGkAtoms::type && attNs == kNameSpaceID_None && attName == nsGkAtoms::type && attNs == kNameSpaceID_None &&
StringBeginsWith(*attValue, NS_LITERAL_STRING("_moz"))) { StringBeginsWith(*attValue, u"_moz"_ns)) {
delete attValue; delete attValue;
continue; continue;
} }
@ -9536,8 +9533,7 @@ bool nsContentUtils::ShouldBlockReservedKeys(WidgetKeyboardEvent* aKeyEvent) {
} }
if (principal) { if (principal) {
return nsContentUtils::IsSitePermDeny(principal, return nsContentUtils::IsSitePermDeny(principal, "shortcuts"_ns);
NS_LITERAL_CSTRING("shortcuts"));
} }
return false; return false;
@ -9744,11 +9740,9 @@ bool nsContentUtils::GetUserIsInteracting() {
/* static */ /* static */
bool nsContentUtils::GetSourceMapURL(nsIHttpChannel* aChannel, bool nsContentUtils::GetSourceMapURL(nsIHttpChannel* aChannel,
nsACString& aResult) { nsACString& aResult) {
nsresult rv = nsresult rv = aChannel->GetResponseHeader("SourceMap"_ns, aResult);
aChannel->GetResponseHeader(NS_LITERAL_CSTRING("SourceMap"), aResult);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
rv = rv = aChannel->GetResponseHeader("X-SourceMap"_ns, aResult);
aChannel->GetResponseHeader(NS_LITERAL_CSTRING("X-SourceMap"), aResult);
} }
return NS_SUCCEEDED(rv); return NS_SUCCEEDED(rv);
} }
@ -9826,7 +9820,7 @@ void nsContentUtils::UserInteractionObserver::AnnotateHang(
BackgroundHangAnnotations& aAnnotations) { BackgroundHangAnnotations& aAnnotations) {
// NOTE: Only annotate the hang report if the user is known to be interacting. // NOTE: Only annotate the hang report if the user is known to be interacting.
if (sUserActive) { if (sUserActive) {
aAnnotations.AddAnnotation(NS_LITERAL_STRING("UserInteracting"), true); aAnnotations.AddAnnotation(u"UserInteracting"_ns, true);
} }
} }
@ -10167,8 +10161,7 @@ bool nsContentUtils::IsURIInList(nsIURI* aURI, const nsCString& aList) {
if (startIndexOfNextLevel <= 0) { if (startIndexOfNextLevel <= 0) {
break; break;
} }
host = NS_LITERAL_CSTRING("*") + host = "*"_ns + nsDependentCSubstring(host, startIndexOfNextLevel);
nsDependentCSubstring(host, startIndexOfNextLevel);
} }
} }

View file

@ -918,7 +918,7 @@ bool nsCopySupport::FireClipboardEvent(EventMessage aEventMessage,
// Now that we have copied, update the clipboard commands. This should have // Now that we have copied, update the clipboard commands. This should have
// the effect of updating the enabled state of the paste menu item. // the effect of updating the enabled state of the paste menu item.
if (doDefault || count) { if (doDefault || count) {
piWindow->UpdateCommands(NS_LITERAL_STRING("clipboard"), nullptr, 0); piWindow->UpdateCommands(u"clipboard"_ns, nullptr, 0);
} }
if (aActionTaken) { if (aActionTaken) {

View file

@ -312,7 +312,7 @@ nsresult nsDOMDataChannel::DoOnMessageAvailable(const nsACString& aData,
RefPtr<MessageEvent> event = new MessageEvent(this, nullptr, nullptr); RefPtr<MessageEvent> event = new MessageEvent(this, nullptr, nullptr);
event->InitMessageEvent(nullptr, NS_LITERAL_STRING("message"), CanBubble::eNo, event->InitMessageEvent(nullptr, u"message"_ns, CanBubble::eNo,
Cancelable::eNo, jsData, mOrigin, EmptyString(), Cancelable::eNo, jsData, mOrigin, EmptyString(),
nullptr, Sequence<OwningNonNull<MessagePort>>()); nullptr, Sequence<OwningNonNull<MessagePort>>());
event->SetTrusted(true); event->SetTrusted(true);
@ -364,7 +364,7 @@ nsresult nsDOMDataChannel::OnChannelConnected(nsISupports* aContext) {
DC_DEBUG( DC_DEBUG(
("%p(%p): %s - Dispatching\n", this, (void*)mDataChannel, __FUNCTION__)); ("%p(%p): %s - Dispatching\n", this, (void*)mDataChannel, __FUNCTION__));
return OnSimpleEvent(aContext, NS_LITERAL_STRING("open")); return OnSimpleEvent(aContext, u"open"_ns);
} }
nsresult nsDOMDataChannel::OnChannelClosed(nsISupports* aContext) { nsresult nsDOMDataChannel::OnChannelClosed(nsISupports* aContext) {
@ -377,7 +377,7 @@ nsresult nsDOMDataChannel::OnChannelClosed(nsISupports* aContext) {
DC_DEBUG(("%p(%p): %s - Dispatching\n", this, (void*)mDataChannel, DC_DEBUG(("%p(%p): %s - Dispatching\n", this, (void*)mDataChannel,
__FUNCTION__)); __FUNCTION__));
rv = OnSimpleEvent(aContext, NS_LITERAL_STRING("close")); rv = OnSimpleEvent(aContext, u"close"_ns);
// no more events can happen // no more events can happen
mSentClose = true; mSentClose = true;
} else { } else {
@ -391,7 +391,7 @@ nsresult nsDOMDataChannel::OnBufferLow(nsISupports* aContext) {
DC_DEBUG( DC_DEBUG(
("%p(%p): %s - Dispatching\n", this, (void*)mDataChannel, __FUNCTION__)); ("%p(%p): %s - Dispatching\n", this, (void*)mDataChannel, __FUNCTION__));
return OnSimpleEvent(aContext, NS_LITERAL_STRING("bufferedamountlow")); return OnSimpleEvent(aContext, u"bufferedamountlow"_ns);
} }
nsresult nsDOMDataChannel::NotBuffered(nsISupports* aContext) { nsresult nsDOMDataChannel::NotBuffered(nsISupports* aContext) {

View file

@ -33,7 +33,7 @@ static already_AddRefed<nsIDocumentEncoder> SetUpEncoder(
// This method will fail if no document // This method will fail if no document
nsresult rv = encoder->NativeInit( nsresult rv = encoder->NativeInit(
doc, NS_LITERAL_STRING("application/xhtml+xml"), doc, u"application/xhtml+xml"_ns,
nsIDocumentEncoder::OutputRaw | nsIDocumentEncoder::OutputRaw |
nsIDocumentEncoder::OutputDontRewriteEncodingDeclaration); nsIDocumentEncoder::OutputDontRewriteEncodingDeclaration);

View file

@ -93,7 +93,7 @@ LazyLogModule gFocusNavigationLog("FocusNavigation");
#define LOGTAG(log, format, content) \ #define LOGTAG(log, format, content) \
if (MOZ_LOG_TEST(log, LogLevel::Debug)) { \ if (MOZ_LOG_TEST(log, LogLevel::Debug)) { \
nsAutoCString tag(NS_LITERAL_CSTRING("(none)")); \ nsAutoCString tag("(none)"_ns); \
if (content) { \ if (content) { \
content->NodeInfo()->NameAtom()->ToUTF8String(tag); \ content->NodeInfo()->NameAtom()->ToUTF8String(tag); \
} \ } \
@ -1026,7 +1026,7 @@ nsFocusManager::WindowHidden(mozIDOMWindowProxy* aWindow) {
if (oldFocusedElement && oldFocusedElement->IsInComposedDoc()) { if (oldFocusedElement && oldFocusedElement->IsInComposedDoc()) {
NotifyFocusStateChange(oldFocusedElement, nullptr, NotifyFocusStateChange(oldFocusedElement, nullptr,
mFocusedWindow->ShouldShowFocusRing(), 0, false); mFocusedWindow->ShouldShowFocusRing(), 0, false);
window->UpdateCommands(NS_LITERAL_STRING("focus"), nullptr, 0); window->UpdateCommands(u"focus"_ns, nullptr, 0);
if (presShell) { if (presShell) {
SendFocusOrBlurEvent(eBlur, presShell, SendFocusOrBlurEvent(eBlur, presShell,
@ -1291,9 +1291,8 @@ void nsFocusManager::ActivateOrDeactivate(nsPIDOMWindowOuter* aWindow,
if (aWindow->GetExtantDoc()) { if (aWindow->GetExtantDoc()) {
nsContentUtils::DispatchEventOnlyToChrome( nsContentUtils::DispatchEventOnlyToChrome(
aWindow->GetExtantDoc(), aWindow->GetCurrentInnerWindow(), aWindow->GetExtantDoc(), aWindow->GetCurrentInnerWindow(),
aActive ? NS_LITERAL_STRING("activate") aActive ? u"activate"_ns : u"deactivate"_ns, CanBubble::eYes,
: NS_LITERAL_STRING("deactivate"), Cancelable::eYes, nullptr);
CanBubble::eYes, Cancelable::eYes, nullptr);
} }
// Look for any remote child frames, iterate over them and send the activation // Look for any remote child frames, iterate over them and send the activation
@ -1331,7 +1330,7 @@ void LogWarningFullscreenWindowRaise(Element* aElement) {
NS_ENSURE_SUCCESS_VOID(rv); NS_ENSURE_SUCCESS_VOID(rv);
Unused << nsContentUtils::ReportToConsoleByWindowID( Unused << nsContentUtils::ReportToConsoleByWindowID(
localizedMsg, nsIScriptError::warningFlag, NS_LITERAL_CSTRING("DOM"), localizedMsg, nsIScriptError::warningFlag, "DOM"_ns,
windowGlobalParent->InnerWindowId(), windowGlobalParent->InnerWindowId(),
windowGlobalParent->GetDocumentURI()); windowGlobalParent->GetDocumentURI());
} }
@ -1533,9 +1532,9 @@ void nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags,
nsContentUtils::GetRootDocument(elementToFocus->OwnerDoc()) nsContentUtils::GetRootDocument(elementToFocus->OwnerDoc())
->GetFullscreenElement() && ->GetFullscreenElement() &&
nsContentUtils::HasPluginWithUncontrolledEventDispatch(elementToFocus)) { nsContentUtils::HasPluginWithUncontrolledEventDispatch(elementToFocus)) {
nsContentUtils::ReportToConsole( nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, "DOM"_ns,
nsIScriptError::warningFlag, NS_LITERAL_CSTRING("DOM"), elementToFocus->OwnerDoc(),
elementToFocus->OwnerDoc(), nsContentUtils::eDOM_PROPERTIES, nsContentUtils::eDOM_PROPERTIES,
"FocusedWindowedPluginWhileFullscreen"); "FocusedWindowedPluginWhileFullscreen");
Document::AsyncExitFullscreen(elementToFocus->OwnerDoc()); Document::AsyncExitFullscreen(elementToFocus->OwnerDoc());
} }
@ -1632,8 +1631,7 @@ void nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags,
// update the commands even when inactive so that the attributes for that // update the commands even when inactive so that the attributes for that
// window are up to date. // window are up to date.
if (allowFrameSwitch) if (allowFrameSwitch) newWindow->UpdateCommands(u"focus"_ns, nullptr, 0);
newWindow->UpdateCommands(NS_LITERAL_STRING("focus"), nullptr, 0);
if (aFlags & FLAG_RAISE) { if (aFlags & FLAG_RAISE) {
if (newRootBrowsingContext) { if (newRootBrowsingContext) {
@ -2188,7 +2186,7 @@ bool nsFocusManager::BlurImpl(BrowsingContext* aBrowsingContextToClear,
// window, then this was a blur caused by the active window being lowered, // window, then this was a blur caused by the active window being lowered,
// so there is no need to update the commands // so there is no need to update the commands
if (GetActiveBrowsingContext()) { if (GetActiveBrowsingContext()) {
window->UpdateCommands(NS_LITERAL_STRING("focus"), nullptr, 0); window->UpdateCommands(u"focus"_ns, nullptr, 0);
} }
SendFocusOrBlurEvent(eBlur, presShell, element->GetComposedDoc(), element, SendFocusOrBlurEvent(eBlur, presShell, element->GetComposedDoc(), element,
@ -2436,7 +2434,7 @@ void nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, Element* aElement,
// commands // commands
// XXXndeakin P2 someone could adjust the focus during the update // XXXndeakin P2 someone could adjust the focus during the update
if (!aWindowRaised) { if (!aWindowRaised) {
aWindow->UpdateCommands(NS_LITERAL_STRING("focus"), nullptr, 0); aWindow->UpdateCommands(u"focus"_ns, nullptr, 0);
} }
if (!aFocusInOtherContentProcess) { if (!aFocusInOtherContentProcess) {
@ -2448,7 +2446,7 @@ void nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, Element* aElement,
IMEStateManager::OnChangeFocus(presContext, nullptr, IMEStateManager::OnChangeFocus(presContext, nullptr,
GetFocusMoveActionCause(aFlags)); GetFocusMoveActionCause(aFlags));
if (!aWindowRaised) { if (!aWindowRaised) {
aWindow->UpdateCommands(NS_LITERAL_STRING("focus"), nullptr, 0); aWindow->UpdateCommands(u"focus"_ns, nullptr, 0);
} }
} }
} else { } else {
@ -2477,8 +2475,7 @@ void nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, Element* aElement,
GetFocusMoveActionCause(aFlags)); GetFocusMoveActionCause(aFlags));
} }
if (!aWindowRaised) if (!aWindowRaised) aWindow->UpdateCommands(u"focus"_ns, nullptr, 0);
aWindow->UpdateCommands(NS_LITERAL_STRING("focus"), nullptr, 0);
} }
// update the caret visibility and position to match the newly focused // update the caret visibility and position to match the newly focused
@ -2819,9 +2816,8 @@ void nsFocusManager::UpdateCaret(bool aMoveCaretToFocus, bool aUpdateVisibility,
if (!browseWithCaret) { if (!browseWithCaret) {
nsCOMPtr<Element> docElement = mFocusedWindow->GetFrameElementInternal(); nsCOMPtr<Element> docElement = mFocusedWindow->GetFrameElementInternal();
if (docElement) if (docElement)
browseWithCaret = browseWithCaret = docElement->AttrValueIs(
docElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::showcaret, kNameSpaceID_None, nsGkAtoms::showcaret, u"true"_ns, eCaseMatters);
NS_LITERAL_STRING("true"), eCaseMatters);
} }
SetCaretVisible(presShell, browseWithCaret, aContent); SetCaretVisible(presShell, browseWithCaret, aContent);

View file

@ -508,8 +508,7 @@ void nsFrameLoader::LoadFrame(bool aOriginalSrc) {
// If the URI was malformed, try to recover by loading about:blank. // If the URI was malformed, try to recover by loading about:blank.
if (rv == NS_ERROR_MALFORMED_URI) { if (rv == NS_ERROR_MALFORMED_URI) {
rv = NS_NewURI(getter_AddRefs(uri), NS_LITERAL_STRING("about:blank"), rv = NS_NewURI(getter_AddRefs(uri), u"about:blank"_ns, encoding, base_uri);
encoding, base_uri);
} }
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
@ -538,8 +537,7 @@ void nsFrameLoader::FireErrorEvent() {
} }
RefPtr<AsyncEventDispatcher> loadBlockingAsyncDispatcher = RefPtr<AsyncEventDispatcher> loadBlockingAsyncDispatcher =
new LoadBlockingAsyncEventDispatcher( new LoadBlockingAsyncEventDispatcher(
mOwnerContent, NS_LITERAL_STRING("error"), CanBubble::eNo, mOwnerContent, u"error"_ns, CanBubble::eNo, ChromeOnlyDispatch::eNo);
ChromeOnlyDispatch::eNo);
loadBlockingAsyncDispatcher->PostDOMEvent(); loadBlockingAsyncDispatcher->PostDOMEvent();
} }
@ -994,11 +992,9 @@ bool nsFrameLoader::Show(nsSubDocumentFrame* frame) {
// same editor object, instead of creating a new one. // same editor object, instead of creating a new one.
RefPtr<HTMLEditor> htmlEditor = GetDocShell()->GetHTMLEditor(); RefPtr<HTMLEditor> htmlEditor = GetDocShell()->GetHTMLEditor();
Unused << htmlEditor; Unused << htmlEditor;
htmlDoc->SetDesignMode(NS_LITERAL_STRING("off"), Nothing(), htmlDoc->SetDesignMode(u"off"_ns, Nothing(), IgnoreErrors());
IgnoreErrors());
htmlDoc->SetDesignMode(NS_LITERAL_STRING("on"), Nothing(), htmlDoc->SetDesignMode(u"on"_ns, Nothing(), IgnoreErrors());
IgnoreErrors());
} else { } else {
// Re-initialize the presentation for contenteditable documents // Re-initialize the presentation for contenteditable documents
bool editable = false, hasEditingSession = false; bool editable = false, hasEditingSession = false;
@ -3227,7 +3223,7 @@ void nsFrameLoader::InitializeBrowserAPI() {
return; return;
} }
mMessageManager->LoadFrameScript( mMessageManager->LoadFrameScript(
NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js"), u"chrome://global/content/BrowserElementChild.js"_ns,
/* allowDelayedLoad = */ true, /* allowDelayedLoad = */ true,
/* aRunInGlobalScope */ true, IgnoreErrors()); /* aRunInGlobalScope */ true, IgnoreErrors());
@ -3478,9 +3474,9 @@ void nsFrameLoader::MaybeNotifyCrashed(BrowsingContext* aBrowsingContext,
// Fire the actual crashed event. // Fire the actual crashed event.
nsString eventName; nsString eventName;
if (aChannel && !aChannel->DoBuildIDsMatch()) { if (aChannel && !aChannel->DoBuildIDsMatch()) {
eventName = NS_LITERAL_STRING("oop-browser-buildid-mismatch"); eventName = u"oop-browser-buildid-mismatch"_ns;
} else { } else {
eventName = NS_LITERAL_STRING("oop-browser-crashed"); eventName = u"oop-browser-crashed"_ns;
} }
FrameCrashedEventInit init; FrameCrashedEventInit init;

View file

@ -183,9 +183,9 @@ void nsFrameLoaderOwner::ChangeRemotenessCommon(
// to what XULFrameElement does after rebinding to the tree. // to what XULFrameElement does after rebinding to the tree.
// ChromeOnlyDispatch is turns on to make sure this isn't fired into // ChromeOnlyDispatch is turns on to make sure this isn't fired into
// content. // content.
(new mozilla::AsyncEventDispatcher( (new mozilla::AsyncEventDispatcher(owner, u"XULFrameLoaderCreated"_ns,
owner, NS_LITERAL_STRING("XULFrameLoaderCreated"), mozilla::CanBubble::eYes,
mozilla::CanBubble::eYes, mozilla::ChromeOnlyDispatch::eYes)) mozilla::ChromeOnlyDispatch::eYes))
->RunDOMEventWhenSafe(); ->RunDOMEventWhenSafe();
} }
} }

View file

@ -391,11 +391,11 @@ bool nsFrameMessageManager::GetParamsForMessage(JSContext* aCx,
nsJSUtils::GetCallingLocation(aCx, filename, &lineno, &column); nsJSUtils::GetCallingLocation(aCx, filename, &lineno, &column);
nsCOMPtr<nsIScriptError> error( nsCOMPtr<nsIScriptError> error(
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID)); do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
error->Init(NS_LITERAL_STRING("Sending message that cannot be cloned. Are " error->Init(
"you trying to send an XPCOM object?"), u"Sending message that cannot be cloned. Are "
filename, EmptyString(), lineno, column, "you trying to send an XPCOM object?"_ns,
nsIScriptError::warningFlag, "chrome javascript", filename, EmptyString(), lineno, column, nsIScriptError::warningFlag,
false /* from private window */, "chrome javascript", false /* from private window */,
true /* from chrome context */); true /* from chrome context */);
console->LogMessage(error); console->LogMessage(error);
} }
@ -742,8 +742,9 @@ void nsFrameMessageManager::ReceiveMessage(
data->Write(cx, rval, aError); data->Write(cx, rval, aError);
if (NS_WARN_IF(aError.Failed())) { if (NS_WARN_IF(aError.Failed())) {
aRetVal->RemoveLastElement(); aRetVal->RemoveLastElement();
nsString msg = aMessage + NS_LITERAL_STRING( nsString msg =
": message reply cannot be cloned. Are " aMessage + nsLiteralString(
u": message reply cannot be cloned. Are "
"you trying to send an XPCOM object?"); "you trying to send an XPCOM object?");
nsCOMPtr<nsIConsoleService> console( nsCOMPtr<nsIConsoleService> console(

View file

@ -2936,7 +2936,7 @@ void nsGlobalWindowInner::GetOwnPropertyNames(
} }
// "Components" is marked as enumerable but only resolved on demand :-/. // "Components" is marked as enumerable but only resolved on demand :-/.
// aNames.AppendElement(NS_LITERAL_STRING("Components")); // aNames.AppendElement(u"Components"_ns);
JS::Rooted<JSObject*> wrapper(aCx, GetWrapper()); JS::Rooted<JSObject*> wrapper(aCx, GetWrapper());
@ -4261,7 +4261,7 @@ nsresult nsGlobalWindowInner::FireHashchange(const nsAString& aOldURL,
init.mOldURL = aOldURL; init.mOldURL = aOldURL;
RefPtr<HashChangeEvent> event = RefPtr<HashChangeEvent> event =
HashChangeEvent::Constructor(this, NS_LITERAL_STRING("hashchange"), init); HashChangeEvent::Constructor(this, u"hashchange"_ns, init);
event->SetTrusted(true); event->SetTrusted(true);
@ -4299,7 +4299,7 @@ nsresult nsGlobalWindowInner::DispatchSyncPopState() {
init.mState = stateJSValue; init.mState = stateJSValue;
RefPtr<PopStateEvent> event = RefPtr<PopStateEvent> event =
PopStateEvent::Constructor(this, NS_LITERAL_STRING("popstate"), init); PopStateEvent::Constructor(this, u"popstate"_ns, init);
event->SetTrusted(true); event->SetTrusted(true);
event->SetTarget(this); event->SetTarget(this);
@ -4755,7 +4755,7 @@ nsGlobalWindowInner::ShowSlowScriptDialog(JSContext* aCx,
mHasHadSlowScript = true; mHasHadSlowScript = true;
// Override the cursor to something that we're sure the user can see. // Override the cursor to something that we're sure the user can see.
SetCursor(NS_LITERAL_CSTRING("auto"), IgnoreErrors()); SetCursor("auto"_ns, IgnoreErrors());
if (XRE_IsContentProcess() && ProcessHangMonitor::Get()) { if (XRE_IsContentProcess() && ProcessHangMonitor::Get()) {
ProcessHangMonitor::SlowScriptAction action; ProcessHangMonitor::SlowScriptAction action;
@ -4982,7 +4982,7 @@ nsresult nsGlobalWindowInner::Observe(nsISupports* aSubject, const char* aTopic,
nsAutoCString type; nsAutoCString type;
perm->GetType(type); perm->GetType(type);
if (type == NS_LITERAL_CSTRING("autoplay-media")) { if (type == "autoplay-media"_ns) {
UpdateAutoplayPermission(); UpdateAutoplayPermission();
} }
@ -5017,7 +5017,7 @@ nsresult nsGlobalWindowInner::Observe(nsISupports* aSubject, const char* aTopic,
} }
RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr); RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
event->InitEvent(NS_LITERAL_STRING("languagechange"), false, false); event->InitEvent(u"languagechange"_ns, false, false);
event->SetTrusted(true); event->SetTrusted(true);
ErrorResult rv; ErrorResult rv;
@ -6433,8 +6433,8 @@ void nsGlobalWindowInner::DispatchVRDisplayActivate(
init.mDisplay = display; init.mDisplay = display;
init.mReason.Construct(aReason); init.mReason.Construct(aReason);
RefPtr<VRDisplayEvent> event = VRDisplayEvent::Constructor( RefPtr<VRDisplayEvent> event =
this, NS_LITERAL_STRING("vrdisplayactivate"), init); VRDisplayEvent::Constructor(this, u"vrdisplayactivate"_ns, init);
// vrdisplayactivate is a trusted event, allowing VRDisplay.requestPresent // vrdisplayactivate is a trusted event, allowing VRDisplay.requestPresent
// to be used in response to link traversal, user request (chrome UX), and // to be used in response to link traversal, user request (chrome UX), and
// HMD mounting detection sensors. // HMD mounting detection sensors.
@ -6470,8 +6470,8 @@ void nsGlobalWindowInner::DispatchVRDisplayDeactivate(
init.mDisplay = display; init.mDisplay = display;
init.mReason.Construct(aReason); init.mReason.Construct(aReason);
RefPtr<VRDisplayEvent> event = VRDisplayEvent::Constructor( RefPtr<VRDisplayEvent> event =
this, NS_LITERAL_STRING("vrdisplaydeactivate"), init); VRDisplayEvent::Constructor(this, u"vrdisplaydeactivate"_ns, init);
event->SetTrusted(true); event->SetTrusted(true);
DispatchEvent(*event); DispatchEvent(*event);
// Once we dispatch the event, we must not access any members as an event // Once we dispatch the event, we must not access any members as an event
@ -6496,8 +6496,8 @@ void nsGlobalWindowInner::DispatchVRDisplayConnect(uint32_t aDisplayID) {
init.mDisplay = display; init.mDisplay = display;
// VRDisplayEvent.reason is not set for vrdisplayconnect // VRDisplayEvent.reason is not set for vrdisplayconnect
RefPtr<VRDisplayEvent> event = VRDisplayEvent::Constructor( RefPtr<VRDisplayEvent> event =
this, NS_LITERAL_STRING("vrdisplayconnect"), init); VRDisplayEvent::Constructor(this, u"vrdisplayconnect"_ns, init);
event->SetTrusted(true); event->SetTrusted(true);
DispatchEvent(*event); DispatchEvent(*event);
// Once we dispatch the event, we must not access any members as an event // Once we dispatch the event, we must not access any members as an event
@ -6522,8 +6522,8 @@ void nsGlobalWindowInner::DispatchVRDisplayDisconnect(uint32_t aDisplayID) {
init.mDisplay = display; init.mDisplay = display;
// VRDisplayEvent.reason is not set for vrdisplaydisconnect // VRDisplayEvent.reason is not set for vrdisplaydisconnect
RefPtr<VRDisplayEvent> event = VRDisplayEvent::Constructor( RefPtr<VRDisplayEvent> event =
this, NS_LITERAL_STRING("vrdisplaydisconnect"), init); VRDisplayEvent::Constructor(this, u"vrdisplaydisconnect"_ns, init);
event->SetTrusted(true); event->SetTrusted(true);
DispatchEvent(*event); DispatchEvent(*event);
// Once we dispatch the event, we must not access any members as an event // Once we dispatch the event, we must not access any members as an event
@ -6547,8 +6547,8 @@ void nsGlobalWindowInner::DispatchVRDisplayPresentChange(uint32_t aDisplayID) {
init.mCancelable = false; init.mCancelable = false;
init.mDisplay = display; init.mDisplay = display;
// VRDisplayEvent.reason is not set for vrdisplaypresentchange // VRDisplayEvent.reason is not set for vrdisplaypresentchange
RefPtr<VRDisplayEvent> event = VRDisplayEvent::Constructor( RefPtr<VRDisplayEvent> event =
this, NS_LITERAL_STRING("vrdisplaypresentchange"), init); VRDisplayEvent::Constructor(this, u"vrdisplaypresentchange"_ns, init);
event->SetTrusted(true); event->SetTrusted(true);
DispatchEvent(*event); DispatchEvent(*event);
// Once we dispatch the event, we must not access any members as an event // Once we dispatch the event, we must not access any members as an event
@ -6942,8 +6942,7 @@ void nsGlobalWindowInner::GetSidebar(OwningExternalOrWindowProxy& aResult,
ErrorResult& aRv) { ErrorResult& aRv) {
#ifdef HAVE_SIDEBAR #ifdef HAVE_SIDEBAR
// First check for a named frame named "sidebar" // First check for a named frame named "sidebar"
RefPtr<BrowsingContext> domWindow = RefPtr<BrowsingContext> domWindow = GetChildWindow(u"sidebar"_ns);
GetChildWindow(NS_LITERAL_STRING("sidebar"));
if (domWindow) { if (domWindow) {
aResult.SetAsWindowProxy() = std::move(domWindow); aResult.SetAsWindowProxy() = std::move(domWindow);
return; return;

View file

@ -615,7 +615,7 @@ bool nsOuterWindowProxy::getOwnPropertyDescriptor(
// case. // case.
if (!isSameOrigin && IsArrayIndex(GetArrayIndexFromId(id))) { if (!isSameOrigin && IsArrayIndex(GetArrayIndexFromId(id))) {
// Step 2.5.2. // Step 2.5.2.
return ReportCrossOriginDenial(cx, id, NS_LITERAL_CSTRING("access")); return ReportCrossOriginDenial(cx, id, "access"_ns);
} }
// Step 2.5.1 is handled via the forwarding to js::Wrapper; it saves us an // Step 2.5.1 is handled via the forwarding to js::Wrapper; it saves us an
@ -835,7 +835,7 @@ bool nsOuterWindowProxy::delete_(JSContext* cx, JS::Handle<JSObject*> proxy,
JS::Handle<jsid> id, JS::Handle<jsid> id,
JS::ObjectOpResult& result) const { JS::ObjectOpResult& result) const {
if (!IsPlatformObjectSameOrigin(cx, proxy)) { if (!IsPlatformObjectSameOrigin(cx, proxy)) {
return ReportCrossOriginDenial(cx, id, NS_LITERAL_CSTRING("delete")); return ReportCrossOriginDenial(cx, id, "delete"_ns);
} }
if (!GetSubframeWindow(cx, proxy, id).IsNull()) { if (!GetSubframeWindow(cx, proxy, id).IsNull()) {
@ -1259,7 +1259,7 @@ already_AddRefed<nsIPrincipal> nsOuterWindowProxy::GetNoPDFJSPrincipal(
} }
nsCOMPtr<nsIPrincipal> principal; nsCOMPtr<nsIPrincipal> principal;
propBag->GetPropertyAsInterface(NS_LITERAL_STRING("noPDFJSPrincipal"), propBag->GetPropertyAsInterface(u"noPDFJSPrincipal"_ns,
NS_GET_IID(nsIPrincipal), NS_GET_IID(nsIPrincipal),
getter_AddRefs(principal)); getter_AddRefs(principal));
return principal.forget(); return principal.forget();
@ -2592,8 +2592,8 @@ void nsGlobalWindowOuter::DispatchDOMWindowCreated() {
// Fire DOMWindowCreated at chrome event listeners // Fire DOMWindowCreated at chrome event listeners
nsContentUtils::DispatchChromeEvent(mDoc, ToSupports(mDoc), nsContentUtils::DispatchChromeEvent(mDoc, ToSupports(mDoc),
NS_LITERAL_STRING("DOMWindowCreated"), u"DOMWindowCreated"_ns, CanBubble::eYes,
CanBubble::eYes, Cancelable::eNo); Cancelable::eNo);
nsCOMPtr<nsIObserverService> observerService = nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService(); mozilla::services::GetObserverService();
@ -3342,7 +3342,7 @@ void nsGlobalWindowOuter::GetContentOuter(JSContext* aCx,
already_AddRefed<nsPIDOMWindowOuter> nsGlobalWindowOuter::GetContentInternal( already_AddRefed<nsPIDOMWindowOuter> nsGlobalWindowOuter::GetContentInternal(
ErrorResult& aError, CallerType aCallerType) { ErrorResult& aError, CallerType aCallerType) {
// First check for a named frame named "content" // First check for a named frame named "content"
RefPtr<BrowsingContext> bc = GetChildWindow(NS_LITERAL_STRING("content")); RefPtr<BrowsingContext> bc = GetChildWindow(u"content"_ns);
if (bc) { if (bc) {
nsCOMPtr<nsPIDOMWindowOuter> content(bc->GetDOMWindow()); nsCOMPtr<nsPIDOMWindowOuter> content(bc->GetDOMWindow());
return content.forget(); return content.forget();
@ -3919,7 +3919,7 @@ double nsGlobalWindowOuter::GetDevicePixelRatioOuter(CallerType aCallerType) {
// blurriness... // blurriness...
nsAutoCString origin; nsAutoCString origin;
nsresult rv = this->GetPrincipal()->GetOrigin(origin); nsresult rv = this->GetPrincipal()->GetOrigin(origin);
if (NS_FAILED(rv) || origin != NS_LITERAL_CSTRING("resource://pdf.js")) { if (NS_FAILED(rv) || origin != "resource://pdf.js"_ns) {
return 1.0; return 1.0;
} }
} }
@ -4213,8 +4213,8 @@ bool nsGlobalWindowOuter::DispatchCustomEvent(
bool nsGlobalWindowOuter::DispatchResizeEvent(const CSSIntSize& aSize) { bool nsGlobalWindowOuter::DispatchResizeEvent(const CSSIntSize& aSize) {
ErrorResult res; ErrorResult res;
RefPtr<Event> domEvent = mDoc->CreateEvent(NS_LITERAL_STRING("CustomEvent"), RefPtr<Event> domEvent =
CallerType::System, res); mDoc->CreateEvent(u"CustomEvent"_ns, CallerType::System, res);
if (res.Failed()) { if (res.Failed()) {
return false; return false;
} }
@ -4235,7 +4235,7 @@ bool nsGlobalWindowOuter::DispatchResizeEvent(const CSSIntSize& aSize) {
} }
CustomEvent* customEvent = static_cast<CustomEvent*>(domEvent.get()); CustomEvent* customEvent = static_cast<CustomEvent*>(domEvent.get());
customEvent->InitCustomEvent(cx, NS_LITERAL_STRING("DOMWindowResize"), customEvent->InitCustomEvent(cx, u"DOMWindowResize"_ns,
/* aCanBubble = */ true, /* aCanBubble = */ true,
/* aCancelable = */ true, detailValue); /* aCancelable = */ true, detailValue);
@ -4694,11 +4694,9 @@ bool nsGlobalWindowOuter::SetWidgetFullscreen(FullscreenReason aReason,
/* virtual */ /* virtual */
void nsGlobalWindowOuter::FullscreenWillChange(bool aIsFullscreen) { void nsGlobalWindowOuter::FullscreenWillChange(bool aIsFullscreen) {
if (aIsFullscreen) { if (aIsFullscreen) {
DispatchCustomEvent(NS_LITERAL_STRING("willenterfullscreen"), DispatchCustomEvent(u"willenterfullscreen"_ns, ChromeOnlyDispatch::eYes);
ChromeOnlyDispatch::eYes);
} else { } else {
DispatchCustomEvent(NS_LITERAL_STRING("willexitfullscreen"), DispatchCustomEvent(u"willexitfullscreen"_ns, ChromeOnlyDispatch::eYes);
ChromeOnlyDispatch::eYes);
} }
} }
@ -4733,8 +4731,7 @@ void nsGlobalWindowOuter::FinishFullscreenChange(bool aIsFullscreen) {
// dispatch a "fullscreen" DOM event so that XUL apps can // dispatch a "fullscreen" DOM event so that XUL apps can
// respond visually if we are kicked into full screen mode // respond visually if we are kicked into full screen mode
DispatchCustomEvent(NS_LITERAL_STRING("fullscreen"), DispatchCustomEvent(u"fullscreen"_ns, ChromeOnlyDispatch::eYes);
ChromeOnlyDispatch::eYes);
if (!NS_WARN_IF(!IsChromeWindow())) { if (!NS_WARN_IF(!IsChromeWindow())) {
if (RefPtr<PresShell> presShell = if (RefPtr<PresShell> presShell =
@ -4755,7 +4752,7 @@ void nsGlobalWindowOuter::FinishFullscreenChange(bool aIsFullscreen) {
// XXXkhuey using the inner here, do we need to do something if it changes? // XXXkhuey using the inner here, do we need to do something if it changes?
ErrorResult rv; ErrorResult rv;
mWakeLock = pmService->NewWakeLock(NS_LITERAL_STRING("DOM_Fullscreen"), mWakeLock = pmService->NewWakeLock(u"DOM_Fullscreen"_ns,
GetCurrentInnerWindow(), rv); GetCurrentInnerWindow(), rv);
NS_WARNING_ASSERTION(!rv.Failed(), "Failed to lock the wakelock"); NS_WARNING_ASSERTION(!rv.Failed(), "Failed to lock the wakelock");
rv.SuppressException(); rv.SuppressException();
@ -4953,7 +4950,7 @@ bool nsGlobalWindowOuter::AlertOrConfirm(bool aAlert, const nsAString& aMessage,
// Always allow content modal prompts for alert and confirm. // Always allow content modal prompts for alert and confirm.
if (nsCOMPtr<nsIWritablePropertyBag2> promptBag = do_QueryInterface(prompt)) { if (nsCOMPtr<nsIWritablePropertyBag2> promptBag = do_QueryInterface(prompt)) {
promptBag->SetPropertyAsUint32(NS_LITERAL_STRING("modalType"), promptBag->SetPropertyAsUint32(u"modalType"_ns,
nsIPrompt::MODAL_TYPE_CONTENT); nsIPrompt::MODAL_TYPE_CONTENT);
} }
@ -5043,7 +5040,7 @@ void nsGlobalWindowOuter::PromptOuter(const nsAString& aMessage,
// Always allow content modal prompts for prompt. // Always allow content modal prompts for prompt.
if (nsCOMPtr<nsIWritablePropertyBag2> promptBag = do_QueryInterface(prompt)) { if (nsCOMPtr<nsIWritablePropertyBag2> promptBag = do_QueryInterface(prompt)) {
promptBag->SetPropertyAsUint32(NS_LITERAL_STRING("modalType"), promptBag->SetPropertyAsUint32(u"modalType"_ns,
nsIPrompt::MODAL_TYPE_CONTENT); nsIPrompt::MODAL_TYPE_CONTENT);
} }
@ -5539,8 +5536,8 @@ void nsGlobalWindowOuter::FirePopupBlockedEvent(
init.mPopupWindowName = aPopupWindowName; init.mPopupWindowName = aPopupWindowName;
init.mPopupWindowFeatures = aPopupWindowFeatures; init.mPopupWindowFeatures = aPopupWindowFeatures;
RefPtr<PopupBlockedEvent> event = PopupBlockedEvent::Constructor( RefPtr<PopupBlockedEvent> event =
aDoc, NS_LITERAL_STRING("DOMPopupBlocked"), init); PopupBlockedEvent::Constructor(aDoc, u"DOMPopupBlocked"_ns, init);
event->SetTrusted(true); event->SetTrusted(true);
@ -6106,9 +6103,8 @@ void nsGlobalWindowOuter::CloseOuter(bool aTrustedCaller) {
nsresult rv = mDoc->GetURL(url); nsresult rv = mDoc->GetURL(url);
NS_ENSURE_SUCCESS_VOID(rv); NS_ENSURE_SUCCESS_VOID(rv);
if (!StringBeginsWith(url, NS_LITERAL_STRING("about:neterror")) && if (!StringBeginsWith(url, u"about:neterror"_ns) && !HadOriginalOpener() &&
!HadOriginalOpener() && !aTrustedCaller && !aTrustedCaller && !IsOnlyTopLevelDocumentInSHistory()) {
!IsOnlyTopLevelDocumentInSHistory()) {
bool allowClose = bool allowClose =
mAllowScriptsToClose || mAllowScriptsToClose ||
Preferences::GetBool("dom.allow_scripts_to_close_windows", true); Preferences::GetBool("dom.allow_scripts_to_close_windows", true);
@ -6116,7 +6112,7 @@ void nsGlobalWindowOuter::CloseOuter(bool aTrustedCaller) {
// We're blocking the close operation // We're blocking the close operation
// report localized error msg in JS console // report localized error msg in JS console
nsContentUtils::ReportToConsole( nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag, NS_LITERAL_CSTRING("DOM Window"), nsIScriptError::warningFlag, "DOM Window"_ns,
mDoc, // Better name for the category? mDoc, // Better name for the category?
nsContentUtils::eDOM_PROPERTIES, "WindowCloseBlockedWarning"); nsContentUtils::eDOM_PROPERTIES, "WindowCloseBlockedWarning");
@ -6139,8 +6135,7 @@ void nsGlobalWindowOuter::CloseOuter(bool aTrustedCaller) {
bool wasInClose = mInClose; bool wasInClose = mInClose;
mInClose = true; mInClose = true;
if (!DispatchCustomEvent(NS_LITERAL_STRING("DOMWindowClose"), if (!DispatchCustomEvent(u"DOMWindowClose"_ns, ChromeOnlyDispatch::eYes)) {
ChromeOnlyDispatch::eYes)) {
// Someone chose to prevent the default action for this event, if // Someone chose to prevent the default action for this event, if
// so, let's not close this window after all... // so, let's not close this window after all...
@ -6189,8 +6184,7 @@ void nsGlobalWindowOuter::ForceClose() {
mInClose = true; mInClose = true;
DispatchCustomEvent(NS_LITERAL_STRING("DOMWindowClose"), DispatchCustomEvent(u"DOMWindowClose"_ns, ChromeOnlyDispatch::eYes);
ChromeOnlyDispatch::eYes);
FinalClose(); FinalClose();
} }
@ -6376,7 +6370,7 @@ void nsGlobalWindowOuter::LeaveModalState() {
if (topWin->mModalStateDepth == 0) { if (topWin->mModalStateDepth == 0) {
RefPtr<Event> event = NS_NewDOMEvent(inner, nullptr, nullptr); RefPtr<Event> event = NS_NewDOMEvent(inner, nullptr, nullptr);
event->InitEvent(NS_LITERAL_STRING("endmodalstate"), true, false); event->InitEvent(u"endmodalstate"_ns, true, false);
event->SetTrusted(true); event->SetTrusted(true);
event->WidgetEventPtr()->mFlags.mOnlyChromeDispatch = true; event->WidgetEventPtr()->mFlags.mOnlyChromeDispatch = true;
topWin->DispatchEvent(*event); topWin->DispatchEvent(*event);
@ -7020,7 +7014,7 @@ nsresult nsGlobalWindowOuter::OpenInternal(
OPENER_POLICY_SAME_ORIGIN_EMBEDDER_POLICY_REQUIRE_CORP) && OPENER_POLICY_SAME_ORIGIN_EMBEDDER_POLICY_REQUIRE_CORP) &&
!mBrowsingContext->SameOriginWithTop()) { !mBrowsingContext->SameOriginWithTop()) {
forceNoOpener = true; forceNoOpener = true;
windowName = NS_LITERAL_STRING("_blank"); windowName = u"_blank"_ns;
} }
bool windowExists = WindowExists(windowName, forceNoOpener, !aCalledNoScript); bool windowExists = WindowExists(windowName, forceNoOpener, !aCalledNoScript);

View file

@ -66,8 +66,8 @@ bool nsHTMLContentSerializer::SerializeHTMLAttributes(
// Filter out any attribute starting with [-|_]moz // Filter out any attribute starting with [-|_]moz
nsDependentAtomString attrNameStr(attrName); nsDependentAtomString attrNameStr(attrName);
if (StringBeginsWith(attrNameStr, NS_LITERAL_STRING("_moz")) || if (StringBeginsWith(attrNameStr, u"_moz"_ns) ||
StringBeginsWith(attrNameStr, NS_LITERAL_STRING("-moz"))) { StringBeginsWith(attrNameStr, u"-moz"_ns)) {
continue; continue;
} }
aElement->GetAttr(namespaceID, attrName, valueStr); aElement->GetAttr(namespaceID, attrName, valueStr);
@ -107,8 +107,7 @@ bool nsHTMLContentSerializer::SerializeHTMLAttributes(
nsAutoString header; nsAutoString header;
aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::httpEquiv, header); aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::httpEquiv, header);
if (header.LowerCaseEqualsLiteral("content-type")) { if (header.LowerCaseEqualsLiteral("content-type")) {
valueStr = NS_LITERAL_STRING("text/html; charset=") + valueStr = u"text/html; charset="_ns + NS_ConvertASCIItoUTF16(mCharset);
NS_ConvertASCIItoUTF16(mCharset);
} }
} }

Some files were not shown because too many files have changed in this diff Show more