зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1501663 - part 3: HTMLEditor::GetElementOrParentByTagNameInternal() shouldn't return <a> element when it's looking for nsGkAtoms::href or nsGkAtoms::anchor but found <a> element does not match with <a href="..."> or <a name="..."> r=m_kato
HTMLEditor::GetElementOrParentByTagNameInternal() may return <a> element which does not match for nsGkAtoms::href or nsGkAtoms::anchor (in the former case, it should return only an <a> element which has "href" attribute and its value is not empty. in the latter case, it should return only <a> element which has "name" attribute and its value is not empty). This patch makes it won't check found element's name when nsGkAtoms::href or nsGkAtoms::anchor is specified. Differential Revision: https://phabricator.services.mozilla.com/D10699 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
2654031504
Коммит
82618136b1
|
@ -2843,24 +2843,28 @@ HTMLEditor::GetElementOrParentByTagNameInternal(const nsAtom& aTagName,
|
|||
|
||||
bool getLink = IsLinkTag(aTagName);
|
||||
bool getNamedAnchor = IsNamedAnchorTag(aTagName);
|
||||
const nsAtom& tagName = getLink || getNamedAnchor ? *nsGkAtoms::a : aTagName;
|
||||
for (; currentElement; currentElement = currentElement->GetParentElement()) {
|
||||
// Test if we have a link (an anchor with href set)
|
||||
if ((getLink && HTMLEditUtils::IsLink(currentElement)) ||
|
||||
(getNamedAnchor && HTMLEditUtils::IsNamedAnchor(currentElement))) {
|
||||
return currentElement;
|
||||
}
|
||||
if (&tagName == nsGkAtoms::list_) {
|
||||
if (getLink) {
|
||||
// Test if we have a link (an anchor with href set)
|
||||
if (HTMLEditUtils::IsLink(currentElement)) {
|
||||
return currentElement;
|
||||
}
|
||||
} else if (getNamedAnchor) {
|
||||
// Test if we have a named anchor (an anchor with name set)
|
||||
if (HTMLEditUtils::IsNamedAnchor(currentElement)) {
|
||||
return currentElement;
|
||||
}
|
||||
} else if (&aTagName == nsGkAtoms::list_) {
|
||||
// Match "ol", "ul", or "dl" for lists
|
||||
if (HTMLEditUtils::IsList(currentElement)) {
|
||||
return currentElement;
|
||||
}
|
||||
} else if (&tagName == nsGkAtoms::td) {
|
||||
} else if (&aTagName == nsGkAtoms::td) {
|
||||
// Table cells are another special case: match either "td" or "th"
|
||||
if (HTMLEditUtils::IsTableCell(currentElement)) {
|
||||
return currentElement;
|
||||
}
|
||||
} else if (&tagName == currentElement->NodeInfo()->NameAtom()) {
|
||||
} else if (&aTagName == currentElement->NodeInfo()->NameAtom()) {
|
||||
return currentElement;
|
||||
}
|
||||
|
||||
|
|
|
@ -543,9 +543,9 @@ SimpleTest.waitForFocus(async function() {
|
|||
is(SpecialPowers.unwrap(getHTMLEditor().getSelectedElement("")),
|
||||
null,
|
||||
"#4-6 nsIHTMLEditor::getSelectedElement(\"\") should return null when Selection is collapsed in a text node even in named anchor element");
|
||||
todo_is(SpecialPowers.unwrap(getHTMLEditor().getSelectedElement("href")),
|
||||
null,
|
||||
"#4-6 nsIHTMLEditor::getSelectedElement(\"href\") should return null when Selection is collapsed in a text node even in named anchor element");
|
||||
is(SpecialPowers.unwrap(getHTMLEditor().getSelectedElement("href")),
|
||||
null,
|
||||
"#4-6 nsIHTMLEditor::getSelectedElement(\"href\") should return null when Selection is collapsed in a text node even in named anchor element");
|
||||
is(SpecialPowers.unwrap(getHTMLEditor().getSelectedElement("anchor")),
|
||||
null,
|
||||
"#4-6 nsIHTMLEditor::getSelectedElement(\"anchor\") should return null when Selection is collapsed in a text node even in named anchor element");
|
||||
|
|
Загрузка…
Ссылка в новой задаче