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

View file

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

View file

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

View file

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

View file

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

View file

@ -80,8 +80,7 @@ MARKUPMAP(
nsAutoString displayValue;
StyleInfo styleInfo(aElement);
styleInfo.Display(displayValue);
if (displayValue != NS_LITERAL_STRING("block") &&
displayValue != NS_LITERAL_STRING("inline-block")) {
if (displayValue != u"block"_ns && displayValue != u"inline-block"_ns) {
return nullptr;
}
// 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) {
switch (aValue) {
case eFalse:
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid,
NS_LITERAL_STRING("false"));
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid, u"false"_ns);
break;
case eGrammar:
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid,
NS_LITERAL_STRING("grammar"));
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid, u"grammar"_ns);
break;
case eSpelling:
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid,
NS_LITERAL_STRING("spelling"));
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid, u"spelling"_ns);
break;
case eTrue:
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid,
NS_LITERAL_STRING("true"));
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid, u"true"_ns);
break;
}
}
@ -592,9 +588,8 @@ bool TextAttrsMgr::AutoGeneratedTextAttr::GetValueFor(Accessible* aAccessible,
void TextAttrsMgr::AutoGeneratedTextAttr::ExposeValue(
nsIPersistentProperties* aAttributes, const bool& aValue) {
nsAccUtils::SetAccAttr(
aAttributes, nsGkAtoms::auto_generated,
aValue ? NS_LITERAL_STRING("true") : NS_LITERAL_STRING("false"));
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::auto_generated,
aValue ? u"true"_ns : u"false"_ns);
}
////////////////////////////////////////////////////////////////////////////////
@ -697,17 +692,15 @@ void TextAttrsMgr::TextPosTextAttr::ExposeValue(
switch (aValue) {
case eTextPosBaseline:
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textPosition,
NS_LITERAL_STRING("baseline"));
u"baseline"_ns);
break;
case eTextPosSub:
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textPosition,
NS_LITERAL_STRING("sub"));
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textPosition, u"sub"_ns);
break;
case eTextPosSuper:
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textPosition,
NS_LITERAL_STRING("super"));
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textPosition, u"super"_ns);
break;
case eTextPosNone:

View file

@ -38,7 +38,7 @@ XULMAP_TYPE(toolbarbutton, XULToolbarButtonAccessible)
XULMAP_TYPE(tooltip, XULTooltipAccessible)
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 XULLabelAccessible(aElement, aContext->Document());

View file

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

View file

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

View file

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

View file

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

View file

@ -675,9 +675,8 @@ void Accessible::SetSelected(bool aSelect) {
if (select->State() & states::MULTISELECTABLE) {
if (mContent->IsElement() && ARIARoleMap()) {
if (aSelect) {
mContent->AsElement()->SetAttr(kNameSpaceID_None,
nsGkAtoms::aria_selected,
NS_LITERAL_STRING("true"), true);
mContent->AsElement()->SetAttr(
kNameSpaceID_None, nsGkAtoms::aria_selected, u"true"_ns, true);
} else {
mContent->AsElement()->UnsetAttr(kNameSpaceID_None,
nsGkAtoms::aria_selected, true);
@ -957,7 +956,7 @@ already_AddRefed<nsIPersistentProperties> Accessible::Attributes() {
if (roleMapEntry) {
if (roleMapEntry->Is(nsGkAtoms::searchbox)) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::textInputType,
NS_LITERAL_STRING("search"));
u"search"_ns);
}
nsAutoString live;
@ -983,21 +982,18 @@ already_AddRefed<nsIPersistentProperties> Accessible::NativeAttributes() {
if (HasNumericValue()) {
nsAutoString valuetext;
Value(valuetext);
attributes->SetStringProperty(NS_LITERAL_CSTRING("valuetext"), valuetext,
unused);
attributes->SetStringProperty("valuetext"_ns, valuetext, unused);
}
// Expose checkable object attribute if the accessible has checkable state
if (State() & states::CHECKABLE) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::checkable,
NS_LITERAL_STRING("true"));
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::checkable, u"true"_ns);
}
// Expose 'explicit-name' attribute.
nsAutoString name;
if (Name(name) != eNameFromSubtree && !name.IsVoid()) {
attributes->SetStringProperty(NS_LITERAL_CSTRING("explicit-name"),
NS_LITERAL_STRING("true"), unused);
attributes->SetStringProperty("explicit-name"_ns, u"true"_ns, unused);
}
// Group attributes (level/setsize/posinset)
@ -1010,13 +1006,11 @@ already_AddRefed<nsIPersistentProperties> Accessible::NativeAttributes() {
if (itemCount) {
nsAutoString itemCountStr;
itemCountStr.AppendInt(itemCount);
attributes->SetStringProperty(NS_LITERAL_CSTRING("child-item-count"),
itemCountStr, unused);
attributes->SetStringProperty("child-item-count"_ns, itemCountStr, unused);
}
if (hierarchical) {
attributes->SetStringProperty(NS_LITERAL_CSTRING("hierarchical"),
NS_LITERAL_STRING("true"), unused);
attributes->SetStringProperty("hierarchical"_ns, u"true"_ns, unused);
}
// 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;
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.
nsAutoString _class;
@ -1051,8 +1045,7 @@ already_AddRefed<nsIPersistentProperties> Accessible::NativeAttributes() {
// Expose draggable object attribute.
if (auto htmlElement = nsGenericHTMLElement::FromNode(mContent)) {
if (htmlElement->Draggable()) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::draggable,
NS_LITERAL_STRING("true"));
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::draggable, u"true"_ns);
}
}
@ -1759,8 +1752,7 @@ Relation Accessible::RelationByType(RelationType aType) const {
nsIContent* buttonEl = nullptr;
if (doc->AllowXULXBL()) {
nsCOMPtr<nsIHTMLCollection> possibleDefaultButtons =
doc->GetElementsByAttribute(NS_LITERAL_STRING("default"),
NS_LITERAL_STRING("true"));
doc->GetElementsByAttribute(u"default"_ns, u"true"_ns);
if (possibleDefaultButtons) {
uint32_t length = possibleDefaultButtons->Length();
// 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
if (aNameSpaceID == kNameSpaceID_None) {
// Check for hyphenated aria-foo property?
if (StringBeginsWith(nsDependentAtomString(aAttribute),
NS_LITERAL_STRING("aria-"))) {
if (StringBeginsWith(nsDependentAtomString(aAttribute), u"aria-"_ns)) {
ARIAAttributeChanged(aAccessible, aAttribute);
}
}

View file

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

View file

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

View file

@ -28,12 +28,12 @@ bool TableAccessible::IsProbablyLayoutTable() {
// the algorithm. Integrate it into Logging.
// Change to |#define SHOW_LAYOUT_HEURISTIC DEBUG| before final release
#ifdef SHOW_LAYOUT_HEURISTIC
# define RETURN_LAYOUT_ANSWER(isLayout, heuristic) \
{ \
mLayoutHeuristic = isLayout \
? NS_LITERAL_STRING("layout table: " heuristic) \
: NS_LITERAL_STRING("data table: " heuristic); \
return isLayout; \
# define RETURN_LAYOUT_ANSWER(isLayout, heuristic) \
{ \
mLayoutHeuristic = isLayout \
? nsLiteralString(u"layout table: " heuristic) \
: nsLiteralString(u"data table: " heuristic); \
return isLayout; \
}
#else
# define RETURN_LAYOUT_ANSWER(isLayout, heuristic) \
@ -64,8 +64,8 @@ bool TableAccessible::IsProbablyLayoutTable() {
"Table should not be built by CSS display:table style");
// Check if datatable attribute has "0" value.
if (el->AttrValueIs(kNameSpaceID_None, nsGkAtoms::datatable,
NS_LITERAL_STRING("0"), eCaseMatters)) {
if (el->AttrValueIs(kNameSpaceID_None, nsGkAtoms::datatable, u"0"_ns,
eCaseMatters)) {
RETURN_LAYOUT_ANSWER(true, "Has datatable = 0 attribute, it's for layout");
}
@ -130,7 +130,7 @@ bool TableAccessible::IsProbablyLayoutTable() {
// Check for nested tables.
nsCOMPtr<nsIHTMLCollection> nestedTables =
el->GetElementsByTagName(NS_LITERAL_STRING("table"));
el->GetElementsByTagName(u"table"_ns);
if (nestedTables->Length() > 0) {
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");
}
static const nsLiteralString tags[] = {NS_LITERAL_STRING("embed"),
NS_LITERAL_STRING("object"),
NS_LITERAL_STRING("iframe")};
static const nsLiteralString tags[] = {u"embed"_ns, u"object"_ns,
u"iframe"_ns};
for (auto& tag : tags) {
nsCOMPtr<nsIHTMLCollection> descendants = el->GetElementsByTagName(tag);
if (descendants->Length() > 0) {

View file

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

View file

@ -114,7 +114,7 @@ class HTMLTextFieldAccessible : public HyperTextAccessibleWrap {
return el;
}
// 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;
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 {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -174,8 +174,7 @@ Maybe<bool> Compatibility::OnUIAMessage(WPARAM aWParam, LPARAM aLParam) {
nsAutoHandle section;
auto comparator = [&](const nsDependentSubstring& aName,
const nsDependentSubstring& aType) -> bool {
if (aType.Equals(NS_LITERAL_STRING("Section")) &&
FindInReadable(kStrHookShmem, aName) &&
if (aType.Equals(u"Section"_ns) && FindInReadable(kStrHookShmem, aName) &&
StringEndsWith(aName, partialSectionSuffix)) {
section.own(::OpenFileMapping(GENERIC_READ, FALSE,
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"
nsDependentSubstring objTypeName(
objType->TypeName.Buffer, objType->TypeName.Length / sizeof(wchar_t));
if (!objTypeName.Equals(NS_LITERAL_STRING("Section"))) {
if (!objTypeName.Equals(u"Section"_ns)) {
nonSectionObjTypes.PutEntry(
static_cast<uint32_t>(curHandle.mObjectTypeIndex));
continue;

View file

@ -218,7 +218,7 @@ bool a11y::IsHandlerRegistered() {
return false;
}
rv = expectedHandler->Append(NS_LITERAL_STRING("AccessibleHandler.dll"));
rv = expectedHandler->Append(u"AccessibleHandler.dll"_ns);
if (NS_FAILED(rv)) {
return false;
}
@ -337,7 +337,7 @@ void a11y::SetInstantiator(const uint32_t aPid) {
if (!GetInstantiatorExecutable(aPid, getter_AddRefs(clientExe))) {
#if defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER)
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)
return;
}

View file

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

View file

@ -147,7 +147,7 @@ uiaRawElmProvider::GetPropertyValue(PROPERTYID aPropertyId,
nsAutoString xmlRoles;
nsCOMPtr<nsIPersistentProperties> attributes = mAcc->Attributes();
attributes->GetStringProperty(NS_LITERAL_CSTRING("xml-roles"), xmlRoles);
attributes->GetStringProperty("xml-roles"_ns, xmlRoles);
if (!xmlRoles.IsEmpty()) {
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.
ErrorResult rv;
nsIContent* parent =
mContent->AsElement()->Closest(NS_LITERAL_STRING("tabs"), rv);
nsIContent* parent = mContent->AsElement()->Closest(u"tabs"_ns, rv);
if (!parent) return rel;
nsCOMPtr<nsIDOMXULRelatedElement> tabsElm =

View file

@ -614,8 +614,7 @@ nsIntRect XULTreeItemAccessibleBase::BoundsInCSSPixels() const {
RefPtr<nsTreeColumn> column = nsCoreUtils::GetFirstSensibleColumn(mTree);
nsresult rv;
nsIntRect rect =
mTree->GetCoordsForCellItem(mRow, column, NS_LITERAL_STRING("cell"), rv);
nsIntRect rect = mTree->GetCoordsForCellItem(mRow, column, u"cell"_ns, rv);
if (NS_FAILED(rv)) {
return nsIntRect();
}
@ -843,7 +842,7 @@ void XULTreeItemAccessibleBase::DispatchClickEvent(
} else {
// Primary column contains a twisty we should click on.
column = columns->GetPrimaryColumn();
pseudoElm = NS_LITERAL_STRING("twisty");
pseudoElm = u"twisty"_ns;
}
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
// x and y of the cell.
nsresult rv;
nsIntRect rect =
mTree->GetCoordsForCellItem(mRow, mColumn, NS_LITERAL_STRING("cell"), rv);
nsIntRect rect = mTree->GetCoordsForCellItem(mRow, mColumn, u"cell"_ns, rv);
if (NS_FAILED(rv)) {
return nsIntRect();
}
@ -535,8 +534,7 @@ XULTreeGridCellAccessible::NativeAttributes() {
// "cycles" attribute
if (mColumn->Cycler())
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::cycles,
NS_LITERAL_STRING("true"));
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::cycles, u"true"_ns);
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),
getter_AddRefs(searchPlugins));
if (NS_FAILED(rv)) return;
searchPlugins->AppendNative(NS_LITERAL_CSTRING("searchplugins"));
searchPlugins->AppendNative("searchplugins"_ns);
nsCOMPtr<nsIFile> commonPlugins;
rv = searchPlugins->Clone(getter_AddRefs(commonPlugins));
if (NS_SUCCEEDED(rv)) {
commonPlugins->AppendNative(NS_LITERAL_CSTRING("common"));
commonPlugins->AppendNative("common"_ns);
array.AppendObject(commonPlugins);
}
@ -75,7 +75,7 @@ static void AppendDistroSearchDirs(nsIProperties* aDirSvc,
rv = searchPlugins->Clone(getter_AddRefs(localePlugins));
if (NS_FAILED(rv)) return;
localePlugins->AppendNative(NS_LITERAL_CSTRING("locale"));
localePlugins->AppendNative("locale"_ns);
nsAutoCString defLocale;
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");
MOZ_ASSERT(mCachedNextEntry, "Should have instanced a new property bag");
if (mCachedNextEntry) {
mCachedNextEntry->SetPropertyAsInterface(NS_LITERAL_STRING("uri"), uri);
mCachedNextEntry->SetPropertyAsAString(NS_LITERAL_STRING("title"), title);
mCachedNextEntry->SetPropertyAsInterface(u"uri"_ns, uri);
mCachedNextEntry->SetPropertyAsAString(u"title"_ns, title);
if (lastVisitTimeIsValid) {
mCachedNextEntry->SetPropertyAsInt64(NS_LITERAL_STRING("time"),
lastVisited);
mCachedNextEntry->SetPropertyAsInt64(u"time"_ns, lastVisited);
}
*_retval = true;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -171,7 +171,7 @@ nsChromeProtocolHandler::NewChannel(nsIURI* aURI, nsILoadInfo* aLoadInfo,
nsCOMPtr<nsIURL> url = do_QueryInterface(aURI);
nsAutoCString path;
rv = url->GetPathQueryRef(path);
if (StringBeginsWith(path, NS_LITERAL_CSTRING("/content/"))) {
if (StringBeginsWith(path, "/content/"_ns)) {
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
// if we need to re-add.
// See bug 531886, bug 533038.
result->SetContentCharset(NS_LITERAL_CSTRING("UTF-8"));
result->SetContentCharset("UTF-8"_ns);
*aResult = result;
NS_ADDREF(*aResult);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -78,16 +78,16 @@ extern mozilla::LazyLogModule gPageCacheLog;
// nsIURI *uri = [...];
// LOG_SPEC(("The URI is %s.", _spec), uri);
//
#define LOG_SPEC(format, uri) \
PR_BEGIN_MACRO \
if (MOZ_LOG_TEST(gSHistoryLog, LogLevel::Debug)) { \
nsAutoCString _specStr(NS_LITERAL_CSTRING("(null)")); \
if (uri) { \
_specStr = uri->GetSpecOrDefault(); \
} \
const char* _spec = _specStr.get(); \
LOG(format); \
} \
#define LOG_SPEC(format, uri) \
PR_BEGIN_MACRO \
if (MOZ_LOG_TEST(gSHistoryLog, LogLevel::Debug)) { \
nsAutoCString _specStr("(null)"_ns); \
if (uri) { \
_specStr = uri->GetSpecOrDefault(); \
} \
const char* _spec = _specStr.get(); \
LOG(format); \
} \
PR_END_MACRO
// This macro makes it easy to log a message including an SHEntry's URI.

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -39,7 +39,7 @@ already_AddRefed<File> GetOrCreateFileCalledBlob(Blob& aBlob,
}
// 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())) {
return nullptr;
}

View file

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

View file

@ -433,7 +433,7 @@ already_AddRefed<imgIEncoder> ImageEncoder::GetImageEncoder(nsAString& aType) {
encoderCID += encoderType;
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
// to 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.
mPreventEventsEscaping = true;
DOMEventTargetHelper::DispatchTrustedEvent(NS_LITERAL_STRING("unload"));
DOMEventTargetHelper::DispatchTrustedEvent(u"unload"_ns);
// Allow events fired during docshell destruction (pagehide, unload) to
// propagate to the <browser> element since chrome code depends on this.

View file

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

View file

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

View file

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

View file

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

View file

@ -99,7 +99,7 @@ bool RemoteOuterWindowProxy::getOwnPropertyDescriptor(
return WrapResult(aCx, aProxy, children[index],
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);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -103,15 +103,14 @@ void GenerateConcatExpression(const nsAString& aStr, nsAString& aResult) {
}
// Prepend concat(' and append ').
aResult.Assign(NS_LITERAL_STRING("concat(\'") + result +
NS_LITERAL_STRING("\')"));
aResult.Assign(u"concat(\'"_ns + result + u"\')"_ns);
}
void XPathGenerator::QuoteArgument(const nsAString& aArg, nsAString& aResult) {
if (!aArg.Contains('\'')) {
aResult.Assign(NS_LITERAL_STRING("\'") + aArg + NS_LITERAL_STRING("\'"));
aResult.Assign(u"\'"_ns + aArg + u"\'"_ns);
} else if (!aArg.Contains('\"')) {
aResult.Assign(NS_LITERAL_STRING("\"") + aArg + NS_LITERAL_STRING("\""));
aResult.Assign(u"\""_ns + aArg + u"\""_ns);
} else {
GenerateConcatExpression(aArg, aResult);
}
@ -121,8 +120,7 @@ void XPathGenerator::EscapeName(const nsAString& aName, nsAString& aResult) {
if (ContainNonWordCharacter(aName)) {
nsAutoString quotedArg;
QuoteArgument(aName, quotedArg);
aResult.Assign(NS_LITERAL_STRING("*[local-name()=") + quotedArg +
NS_LITERAL_STRING("]"));
aResult.Assign(u"*[local-name()="_ns + quotedArg + u"]"_ns);
} else {
aResult.Assign(aName);
}
@ -146,7 +144,7 @@ void XPathGenerator::Generate(const nsINode* aNode, nsAString& aResult) {
if (prefix.IsEmpty()) {
tag.Assign(nodeEscapeName);
} else {
tag.Assign(prefix + NS_LITERAL_STRING(":") + nodeEscapeName);
tag.Assign(prefix + u":"_ns + nodeEscapeName);
}
if (aNode->HasID()) {
@ -156,8 +154,7 @@ void XPathGenerator::Generate(const nsINode* aNode, nsAString& aResult) {
nsAutoString quotedArgument;
elem->GetId(elemId);
QuoteArgument(elemId, quotedArgument);
aResult.Assign(NS_LITERAL_STRING("//") + tag + NS_LITERAL_STRING("[@id=") +
quotedArgument + NS_LITERAL_STRING("]"));
aResult.Assign(u"//"_ns + tag + u"[@id="_ns + quotedArgument + u"]"_ns);
return;
}
@ -183,8 +180,7 @@ void XPathGenerator::Generate(const nsINode* aNode, nsAString& aResult) {
if (!nodeNameAttribute.IsEmpty()) {
nsAutoString quotedArgument;
QuoteArgument(nodeNameAttribute, quotedArgument);
namePart.Assign(NS_LITERAL_STRING("[@name=") + quotedArgument +
NS_LITERAL_STRING("]"));
namePart.Assign(u"[@name="_ns + quotedArgument + u"]"_ns);
}
if (count != 1) {
countPart.AssignLiteral(u"[");
@ -192,5 +188,5 @@ void XPathGenerator::Generate(const nsINode* aNode, nsAString& aResult) {
countPart.AppendLiteral(u"]");
}
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 {
str.AppendInt(GetIntInternal());
}
aResult = str + NS_LITERAL_STRING("%");
aResult = str + u"%"_ns;
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
// |outLinkText| to avoid overwriting it while building up the
// string in pieces.
nsAutoString linkText(NS_LITERAL_STRING("<a href=\"") + inURL +
NS_LITERAL_STRING("\">") + inText +
NS_LITERAL_STRING("</a>"));
nsAutoString linkText(u"<a href=\""_ns + inURL + u"\">"_ns + inText +
u"</a>"_ns);
outLinkText = linkText;
}
@ -813,12 +812,13 @@ nsresult DragDataProducer::AddStringsToDataTransfer(
dragData += title;
AddString(aDataTransfer, NS_LITERAL_STRING(kURLMime), dragData, principal);
AddString(aDataTransfer, NS_LITERAL_STRING(kURLDataMime), mUrlString,
principal);
AddString(aDataTransfer, NS_LITERAL_STRING(kURLDataMime), mUrlString,
principal);
AddString(aDataTransfer, NS_LITERAL_STRING(kURLDescriptionMime),
mTitleString, principal);
AddString(aDataTransfer, NS_LITERAL_STRING("text/uri-list"), mUrlString,
principal);
AddString(aDataTransfer, u"text/uri-list"_ns, mUrlString, principal);
}
// add a special flavor for the html context data
@ -878,8 +878,7 @@ nsresult DragDataProducer::AddStringsToDataTransfer(
if (!mIsAnchor) {
AddString(aDataTransfer, NS_LITERAL_STRING(kURLDataMime), mUrlString,
principal);
AddString(aDataTransfer, NS_LITERAL_STRING("text/uri-list"), mUrlString,
principal);
AddString(aDataTransfer, u"text/uri-list"_ns, mUrlString, principal);
}
}

View file

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

View file

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

View file

@ -312,7 +312,7 @@ nsresult nsDOMDataChannel::DoOnMessageAvailable(const nsACString& aData,
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(),
nullptr, Sequence<OwningNonNull<MessagePort>>());
event->SetTrusted(true);
@ -364,7 +364,7 @@ nsresult nsDOMDataChannel::OnChannelConnected(nsISupports* aContext) {
DC_DEBUG(
("%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) {
@ -377,7 +377,7 @@ nsresult nsDOMDataChannel::OnChannelClosed(nsISupports* aContext) {
DC_DEBUG(("%p(%p): %s - Dispatching\n", this, (void*)mDataChannel,
__FUNCTION__));
rv = OnSimpleEvent(aContext, NS_LITERAL_STRING("close"));
rv = OnSimpleEvent(aContext, u"close"_ns);
// no more events can happen
mSentClose = true;
} else {
@ -391,7 +391,7 @@ nsresult nsDOMDataChannel::OnBufferLow(nsISupports* aContext) {
DC_DEBUG(
("%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) {

View file

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

View file

@ -93,7 +93,7 @@ LazyLogModule gFocusNavigationLog("FocusNavigation");
#define LOGTAG(log, format, content) \
if (MOZ_LOG_TEST(log, LogLevel::Debug)) { \
nsAutoCString tag(NS_LITERAL_CSTRING("(none)")); \
nsAutoCString tag("(none)"_ns); \
if (content) { \
content->NodeInfo()->NameAtom()->ToUTF8String(tag); \
} \
@ -1026,7 +1026,7 @@ nsFocusManager::WindowHidden(mozIDOMWindowProxy* aWindow) {
if (oldFocusedElement && oldFocusedElement->IsInComposedDoc()) {
NotifyFocusStateChange(oldFocusedElement, nullptr,
mFocusedWindow->ShouldShowFocusRing(), 0, false);
window->UpdateCommands(NS_LITERAL_STRING("focus"), nullptr, 0);
window->UpdateCommands(u"focus"_ns, nullptr, 0);
if (presShell) {
SendFocusOrBlurEvent(eBlur, presShell,
@ -1291,9 +1291,8 @@ void nsFocusManager::ActivateOrDeactivate(nsPIDOMWindowOuter* aWindow,
if (aWindow->GetExtantDoc()) {
nsContentUtils::DispatchEventOnlyToChrome(
aWindow->GetExtantDoc(), aWindow->GetCurrentInnerWindow(),
aActive ? NS_LITERAL_STRING("activate")
: NS_LITERAL_STRING("deactivate"),
CanBubble::eYes, Cancelable::eYes, nullptr);
aActive ? u"activate"_ns : u"deactivate"_ns, CanBubble::eYes,
Cancelable::eYes, nullptr);
}
// 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);
Unused << nsContentUtils::ReportToConsoleByWindowID(
localizedMsg, nsIScriptError::warningFlag, NS_LITERAL_CSTRING("DOM"),
localizedMsg, nsIScriptError::warningFlag, "DOM"_ns,
windowGlobalParent->InnerWindowId(),
windowGlobalParent->GetDocumentURI());
}
@ -1533,10 +1532,10 @@ void nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags,
nsContentUtils::GetRootDocument(elementToFocus->OwnerDoc())
->GetFullscreenElement() &&
nsContentUtils::HasPluginWithUncontrolledEventDispatch(elementToFocus)) {
nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag, NS_LITERAL_CSTRING("DOM"),
elementToFocus->OwnerDoc(), nsContentUtils::eDOM_PROPERTIES,
"FocusedWindowedPluginWhileFullscreen");
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, "DOM"_ns,
elementToFocus->OwnerDoc(),
nsContentUtils::eDOM_PROPERTIES,
"FocusedWindowedPluginWhileFullscreen");
Document::AsyncExitFullscreen(elementToFocus->OwnerDoc());
}
#endif
@ -1632,8 +1631,7 @@ void nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags,
// update the commands even when inactive so that the attributes for that
// window are up to date.
if (allowFrameSwitch)
newWindow->UpdateCommands(NS_LITERAL_STRING("focus"), nullptr, 0);
if (allowFrameSwitch) newWindow->UpdateCommands(u"focus"_ns, nullptr, 0);
if (aFlags & FLAG_RAISE) {
if (newRootBrowsingContext) {
@ -2188,7 +2186,7 @@ bool nsFocusManager::BlurImpl(BrowsingContext* aBrowsingContextToClear,
// window, then this was a blur caused by the active window being lowered,
// so there is no need to update the commands
if (GetActiveBrowsingContext()) {
window->UpdateCommands(NS_LITERAL_STRING("focus"), nullptr, 0);
window->UpdateCommands(u"focus"_ns, nullptr, 0);
}
SendFocusOrBlurEvent(eBlur, presShell, element->GetComposedDoc(), element,
@ -2436,7 +2434,7 @@ void nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, Element* aElement,
// commands
// XXXndeakin P2 someone could adjust the focus during the update
if (!aWindowRaised) {
aWindow->UpdateCommands(NS_LITERAL_STRING("focus"), nullptr, 0);
aWindow->UpdateCommands(u"focus"_ns, nullptr, 0);
}
if (!aFocusInOtherContentProcess) {
@ -2448,7 +2446,7 @@ void nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, Element* aElement,
IMEStateManager::OnChangeFocus(presContext, nullptr,
GetFocusMoveActionCause(aFlags));
if (!aWindowRaised) {
aWindow->UpdateCommands(NS_LITERAL_STRING("focus"), nullptr, 0);
aWindow->UpdateCommands(u"focus"_ns, nullptr, 0);
}
}
} else {
@ -2477,8 +2475,7 @@ void nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, Element* aElement,
GetFocusMoveActionCause(aFlags));
}
if (!aWindowRaised)
aWindow->UpdateCommands(NS_LITERAL_STRING("focus"), nullptr, 0);
if (!aWindowRaised) aWindow->UpdateCommands(u"focus"_ns, nullptr, 0);
}
// update the caret visibility and position to match the newly focused
@ -2819,9 +2816,8 @@ void nsFocusManager::UpdateCaret(bool aMoveCaretToFocus, bool aUpdateVisibility,
if (!browseWithCaret) {
nsCOMPtr<Element> docElement = mFocusedWindow->GetFrameElementInternal();
if (docElement)
browseWithCaret =
docElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::showcaret,
NS_LITERAL_STRING("true"), eCaseMatters);
browseWithCaret = docElement->AttrValueIs(
kNameSpaceID_None, nsGkAtoms::showcaret, u"true"_ns, eCaseMatters);
}
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 (rv == NS_ERROR_MALFORMED_URI) {
rv = NS_NewURI(getter_AddRefs(uri), NS_LITERAL_STRING("about:blank"),
encoding, base_uri);
rv = NS_NewURI(getter_AddRefs(uri), u"about:blank"_ns, encoding, base_uri);
}
if (NS_SUCCEEDED(rv)) {
@ -538,8 +537,7 @@ void nsFrameLoader::FireErrorEvent() {
}
RefPtr<AsyncEventDispatcher> loadBlockingAsyncDispatcher =
new LoadBlockingAsyncEventDispatcher(
mOwnerContent, NS_LITERAL_STRING("error"), CanBubble::eNo,
ChromeOnlyDispatch::eNo);
mOwnerContent, u"error"_ns, CanBubble::eNo, ChromeOnlyDispatch::eNo);
loadBlockingAsyncDispatcher->PostDOMEvent();
}
@ -994,11 +992,9 @@ bool nsFrameLoader::Show(nsSubDocumentFrame* frame) {
// same editor object, instead of creating a new one.
RefPtr<HTMLEditor> htmlEditor = GetDocShell()->GetHTMLEditor();
Unused << htmlEditor;
htmlDoc->SetDesignMode(NS_LITERAL_STRING("off"), Nothing(),
IgnoreErrors());
htmlDoc->SetDesignMode(u"off"_ns, Nothing(), IgnoreErrors());
htmlDoc->SetDesignMode(NS_LITERAL_STRING("on"), Nothing(),
IgnoreErrors());
htmlDoc->SetDesignMode(u"on"_ns, Nothing(), IgnoreErrors());
} else {
// Re-initialize the presentation for contenteditable documents
bool editable = false, hasEditingSession = false;
@ -3227,7 +3223,7 @@ void nsFrameLoader::InitializeBrowserAPI() {
return;
}
mMessageManager->LoadFrameScript(
NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js"),
u"chrome://global/content/BrowserElementChild.js"_ns,
/* allowDelayedLoad = */ true,
/* aRunInGlobalScope */ true, IgnoreErrors());
@ -3478,9 +3474,9 @@ void nsFrameLoader::MaybeNotifyCrashed(BrowsingContext* aBrowsingContext,
// Fire the actual crashed event.
nsString eventName;
if (aChannel && !aChannel->DoBuildIDsMatch()) {
eventName = NS_LITERAL_STRING("oop-browser-buildid-mismatch");
eventName = u"oop-browser-buildid-mismatch"_ns;
} else {
eventName = NS_LITERAL_STRING("oop-browser-crashed");
eventName = u"oop-browser-crashed"_ns;
}
FrameCrashedEventInit init;

View file

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

View file

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

View file

@ -2936,7 +2936,7 @@ void nsGlobalWindowInner::GetOwnPropertyNames(
}
// "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());
@ -4261,7 +4261,7 @@ nsresult nsGlobalWindowInner::FireHashchange(const nsAString& aOldURL,
init.mOldURL = aOldURL;
RefPtr<HashChangeEvent> event =
HashChangeEvent::Constructor(this, NS_LITERAL_STRING("hashchange"), init);
HashChangeEvent::Constructor(this, u"hashchange"_ns, init);
event->SetTrusted(true);
@ -4299,7 +4299,7 @@ nsresult nsGlobalWindowInner::DispatchSyncPopState() {
init.mState = stateJSValue;
RefPtr<PopStateEvent> event =
PopStateEvent::Constructor(this, NS_LITERAL_STRING("popstate"), init);
PopStateEvent::Constructor(this, u"popstate"_ns, init);
event->SetTrusted(true);
event->SetTarget(this);
@ -4755,7 +4755,7 @@ nsGlobalWindowInner::ShowSlowScriptDialog(JSContext* aCx,
mHasHadSlowScript = true;
// 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()) {
ProcessHangMonitor::SlowScriptAction action;
@ -4982,7 +4982,7 @@ nsresult nsGlobalWindowInner::Observe(nsISupports* aSubject, const char* aTopic,
nsAutoCString type;
perm->GetType(type);
if (type == NS_LITERAL_CSTRING("autoplay-media")) {
if (type == "autoplay-media"_ns) {
UpdateAutoplayPermission();
}
@ -5017,7 +5017,7 @@ nsresult nsGlobalWindowInner::Observe(nsISupports* aSubject, const char* aTopic,
}
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);
ErrorResult rv;
@ -6433,8 +6433,8 @@ void nsGlobalWindowInner::DispatchVRDisplayActivate(
init.mDisplay = display;
init.mReason.Construct(aReason);
RefPtr<VRDisplayEvent> event = VRDisplayEvent::Constructor(
this, NS_LITERAL_STRING("vrdisplayactivate"), init);
RefPtr<VRDisplayEvent> event =
VRDisplayEvent::Constructor(this, u"vrdisplayactivate"_ns, init);
// vrdisplayactivate is a trusted event, allowing VRDisplay.requestPresent
// to be used in response to link traversal, user request (chrome UX), and
// HMD mounting detection sensors.
@ -6470,8 +6470,8 @@ void nsGlobalWindowInner::DispatchVRDisplayDeactivate(
init.mDisplay = display;
init.mReason.Construct(aReason);
RefPtr<VRDisplayEvent> event = VRDisplayEvent::Constructor(
this, NS_LITERAL_STRING("vrdisplaydeactivate"), init);
RefPtr<VRDisplayEvent> event =
VRDisplayEvent::Constructor(this, u"vrdisplaydeactivate"_ns, init);
event->SetTrusted(true);
DispatchEvent(*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;
// VRDisplayEvent.reason is not set for vrdisplayconnect
RefPtr<VRDisplayEvent> event = VRDisplayEvent::Constructor(
this, NS_LITERAL_STRING("vrdisplayconnect"), init);
RefPtr<VRDisplayEvent> event =
VRDisplayEvent::Constructor(this, u"vrdisplayconnect"_ns, init);
event->SetTrusted(true);
DispatchEvent(*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;
// VRDisplayEvent.reason is not set for vrdisplaydisconnect
RefPtr<VRDisplayEvent> event = VRDisplayEvent::Constructor(
this, NS_LITERAL_STRING("vrdisplaydisconnect"), init);
RefPtr<VRDisplayEvent> event =
VRDisplayEvent::Constructor(this, u"vrdisplaydisconnect"_ns, init);
event->SetTrusted(true);
DispatchEvent(*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.mDisplay = display;
// VRDisplayEvent.reason is not set for vrdisplaypresentchange
RefPtr<VRDisplayEvent> event = VRDisplayEvent::Constructor(
this, NS_LITERAL_STRING("vrdisplaypresentchange"), init);
RefPtr<VRDisplayEvent> event =
VRDisplayEvent::Constructor(this, u"vrdisplaypresentchange"_ns, init);
event->SetTrusted(true);
DispatchEvent(*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) {
#ifdef HAVE_SIDEBAR
// First check for a named frame named "sidebar"
RefPtr<BrowsingContext> domWindow =
GetChildWindow(NS_LITERAL_STRING("sidebar"));
RefPtr<BrowsingContext> domWindow = GetChildWindow(u"sidebar"_ns);
if (domWindow) {
aResult.SetAsWindowProxy() = std::move(domWindow);
return;

View file

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

View file

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

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