Bug 1555947 - Be consistent in using composed / uncomposed doc for <link rel=localization>. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D49180

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2019-10-15 14:15:14 +00:00
Родитель dec9e481a5
Коммит 58050e8a18
1 изменённых файлов: 6 добавлений и 11 удалений

Просмотреть файл

@ -137,8 +137,6 @@ nsresult HTMLLinkElement::BindToTree(BindContext& aContext, nsINode& aParent) {
nsContentUtils::AddScriptRunner(
NewRunnableMethod("dom::HTMLLinkElement::BindToTree", this, update));
// FIXME(emilio, bug 1555947): Why does this use the uncomposed doc but the
// attribute change code the composed doc?
if (IsInUncomposedDoc() &&
AttrValueIs(kNameSpaceID_None, nsGkAtoms::rel, nsGkAtoms::localization,
eIgnoreCase)) {
@ -175,13 +173,12 @@ void HTMLLinkElement::UnbindFromTree(bool aNullParent) {
Document* oldDoc = GetUncomposedDoc();
ShadowRoot* oldShadowRoot = GetContainingShadow();
// We want to update the localization but only if the
// link is removed from a DOM change, and not
// because the document is going away.
// We want to update the localization but only if the link is removed from a
// DOM change, and not because the document is going away.
bool ignore;
if (oldDoc && oldDoc->GetScriptHandlingObject(ignore) &&
this->AttrValueIs(kNameSpaceID_None, nsGkAtoms::rel,
nsGkAtoms::localization, eIgnoreCase)) {
AttrValueIs(kNameSpaceID_None, nsGkAtoms::rel, nsGkAtoms::localization,
eIgnoreCase)) {
oldDoc->LocalizationLinkRemoved(this);
}
@ -288,8 +285,7 @@ nsresult HTMLLinkElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
// If a link's `rel` attribute was changed from or to `localization`,
// update the list of localization links.
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::rel) {
Document* doc = GetComposedDoc();
if (doc) {
if (Document* doc = GetUncomposedDoc()) {
if ((aValue && aValue->Equals(nsGkAtoms::localization, eIgnoreCase)) &&
(!aOldValue ||
!aOldValue->Equals(nsGkAtoms::localization, eIgnoreCase))) {
@ -308,8 +304,7 @@ nsresult HTMLLinkElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::href &&
AttrValueIs(kNameSpaceID_None, nsGkAtoms::rel, nsGkAtoms::localization,
eIgnoreCase)) {
Document* doc = GetComposedDoc();
if (doc) {
if (Document* doc = GetUncomposedDoc()) {
if (aOldValue) {
doc->LocalizationLinkRemoved(this);
}