/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
LocalAccessible* RelatedAccIterator::Next() { if (!mProviders || mIndex == mProviders->Length()) { if (mIsWalkingDependentElements) { // We've walked both dependent ids and dependent elements, so there are // no more targets. return nullptr;
} // We've returned all dependent ids, but there might be dependent elements // too. Walk those next.
mIsWalkingDependentElements = true;
mIndex = 0; if (auto providers =
mDocument->mDependentElementsMap.Lookup(mDependentContent)) {
mProviders = &providers.Data();
} else {
mProviders = nullptr; return nullptr;
}
}
while (mIndex < mProviders->Length()) { constauto& provider = (*mProviders)[mIndex++];
// Return related accessible for the given attribute. if (mRelAttr && provider->mRelAttr != mRelAttr) { continue;
} // If we're walking elements (not ids), the explicitly set attr-element // `mDependentContent` must be a descendant of any of the refering element // `mProvider->mContent`'s shadow-including ancestors. if (mIsWalkingDependentElements &&
!nsCoreUtils::IsDescendantOfAnyShadowIncludingAncestor(
mDependentContent, provider->mContent)) { continue;
}
LocalAccessible* related = mDocument->GetAccessible(provider->mContent); if (related) { return related;
}
// If the document content is pointed by relation then return the // document itself. if (provider->mContent == mDocument->GetContent()) { return mDocument;
}
}
// We exhausted mProviders without returning anything. if (!mIsWalkingDependentElements) { // Call this function again to start walking the dependent elements. return Next();
} return nullptr;
}
LocalAccessible* HTMLLabelIterator::Next() { // Get either <label for="[id]"> element which explicitly points to given // element, or <label> ancestor which implicitly point to it.
LocalAccessible* label = nullptr; while ((label = mRelIter.Next())) { if (IsLabel(label)) { return label;
}
}
// Ignore ancestor label on not widget accessible. if (mLabelFilter == eSkipAncestorLabel || !mAcc->IsWidget()) return nullptr;
// Go up tree to get a name of ancestor label if there is one (an ancestor // <label> implicitly points to us). Don't go up farther than form or // document.
LocalAccessible* walkUp = mAcc->LocalParent(); while (walkUp && !walkUp->IsDoc()) {
nsIContent* walkUpEl = walkUp->GetContent(); if (IsLabel(walkUp) && !walkUpEl->AsElement()->HasAttr(nsGkAtoms::_for)) {
mLabelFilter = eSkipAncestorLabel; // prevent infinite loop return walkUp;
}
if (walkUpEl->IsHTMLElement(nsGkAtoms::form)) break;
dom::Element* AssociatedElementsIterator::NextElem() { while (true) { const nsDependentSubstring id = NextID(); if (id.IsEmpty()) break;
dom::Element* refContent = GetElem(id); if (refContent) return refContent;
}
while (dom::Element* element = mElements.SafeElementAt(mElemIdx++)) { if (nsCoreUtils::IsDescendantOfAnyShadowIncludingAncestor(element,
mContent)) { return element;
}
}
return nullptr;
}
dom::Element* AssociatedElementsIterator::GetElem(nsIContent* aContent, const nsAString& aID) { // Get elements in DOM tree by ID attribute if this is an explicit content. // In case of bound element check its anonymous subtree. if (!aContent->IsInNativeAnonymousSubtree()) {
dom::DocumentOrShadowRoot* docOrShadowRoot =
aContent->GetUncomposedDocOrConnectedShadowRoot(); if (docOrShadowRoot) {
dom::Element* refElm = docOrShadowRoot->GetElementById(aID); if (refElm) { return refElm;
}
}
} return nullptr;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.