HTMLOptionElement*
HTMLOptionsCollection::GetNamedItem(const nsAString& aName) const
{
  uint32_t count = mElements.Length();
  for (uint32_t i = 0; i < count; i++) {
    HTMLOptionElement* content = mElements.ElementAt(i);
    if (content &&
        (content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name, aName,
                              eCaseMatters) ||
         content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::id, aName,
                              eCaseMatters))) {
      return content;
    }
  }

  return nullptr;
}
예제 #2
0
static HTMLOptionElement*
GetNamedItemHelper(nsTArray<nsRefPtr<HTMLOptionElement> > &aElements,
                   const nsAString& aName)
{
  uint32_t count = aElements.Length();
  for (uint32_t i = 0; i < count; i++) {
    HTMLOptionElement* content = aElements.ElementAt(i);
    if (content &&
        (content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name, aName,
                              eCaseMatters) ||
         content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::id, aName,
                              eCaseMatters))) {
      return content;
    }
  }

  return nullptr;
}
예제 #3
0
HTMLOptionElement*
HTMLOptionsCollection::NamedGetter(const nsAString& aName, bool& aFound)
{
  uint32_t count = mElements.Length();
  for (uint32_t i = 0; i < count; i++) {
    HTMLOptionElement* content = mElements.ElementAt(i);
    if (content &&
        (content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name, aName,
                              eCaseMatters) ||
         content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::id, aName,
                              eCaseMatters))) {
      aFound = true;
      return content;
    }
  }

  aFound = false;
  return nullptr;
}