Backed out 7 changesets (bug 1444491, bug 1801761) for causing failures on autofocus-attribute.svg. CLOSED TREE
Backed out changeset 1cee414009cb (bug 1444491) Backed out changeset 30f786b79191 (bug 1444491) Backed out changeset ce06375518a7 (bug 1801761) Backed out changeset 64c8bb293e5c (bug 1444491) Backed out changeset 94aa0ce630f2 (bug 1444491) Backed out changeset 80010eabc0c1 (bug 1444491) Backed out changeset 7d8da1f44177 (bug 1444491)
This commit is contained in:
@@ -1850,9 +1850,7 @@ nsresult PresShell::Initialize() {
|
||||
NS_ENSURE_STATE(!mHaveShutDown);
|
||||
}
|
||||
|
||||
if (mDocument->HasAutoFocusCandidates()) {
|
||||
mDocument->ScheduleFlushAutoFocusCandidates();
|
||||
}
|
||||
mDocument->TriggerAutoFocus();
|
||||
|
||||
NS_ASSERTION(rootFrame, "How did that happen?");
|
||||
|
||||
@@ -3138,8 +3136,52 @@ nsresult PresShell::GoToAnchor(const nsAString& aAnchorName, bool aScroll,
|
||||
//
|
||||
// https://html.spec.whatwg.org/#target-element
|
||||
// https://html.spec.whatwg.org/#find-a-potential-indicated-element
|
||||
RefPtr<Element> target =
|
||||
nsContentUtils::GetTargetElement(mDocument, aAnchorName);
|
||||
RefPtr<Element> target = [&]() -> Element* {
|
||||
// 1. If there is an element in the document tree that has an ID equal to
|
||||
// fragment, then return the first such element in tree order.
|
||||
if (Element* el = mDocument->GetElementById(aAnchorName)) {
|
||||
return el;
|
||||
}
|
||||
|
||||
// 2. If there is an a element in the document tree that has a name
|
||||
// attribute whose value is equal to fragment, then return the first such
|
||||
// element in tree order.
|
||||
//
|
||||
// FIXME(emilio): Why the different code-paths for HTML and non-HTML docs?
|
||||
if (mDocument->IsHTMLDocument()) {
|
||||
nsCOMPtr<nsINodeList> list = mDocument->GetElementsByName(aAnchorName);
|
||||
// Loop through the named nodes looking for the first anchor
|
||||
uint32_t length = list->Length();
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
nsIContent* node = list->Item(i);
|
||||
if (node->IsHTMLElement(nsGkAtoms::a)) {
|
||||
return node->AsElement();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
constexpr auto nameSpace = u"http://www.w3.org/1999/xhtml"_ns;
|
||||
// Get the list of anchor elements
|
||||
nsCOMPtr<nsINodeList> list =
|
||||
mDocument->GetElementsByTagNameNS(nameSpace, u"a"_ns);
|
||||
// Loop through the anchors looking for the first one with the given name.
|
||||
for (uint32_t i = 0; true; i++) {
|
||||
nsIContent* node = list->Item(i);
|
||||
if (!node) { // End of list
|
||||
break;
|
||||
}
|
||||
|
||||
// Compare the name attribute
|
||||
if (node->IsElement() &&
|
||||
node->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name,
|
||||
aAnchorName, eCaseMatters)) {
|
||||
return node->AsElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Return null.
|
||||
return nullptr;
|
||||
}();
|
||||
|
||||
// 1. If there is no indicated part of the document, set the Document's
|
||||
// target element to null.
|
||||
|
||||
Reference in New Issue
Block a user