|
|
|
Lines 1528-1606
RemovePastNames(const nsAString& aName,
|
Link Here
|
|---|
|
| 1528 |
nsresult |
1528 |
nsresult |
| 1529 |
HTMLFormElement::RemoveElementFromTable(nsGenericHTMLFormElement* aElement, |
1529 |
HTMLFormElement::RemoveElementFromTable(nsGenericHTMLFormElement* aElement, |
| 1530 |
const nsAString& aName, |
1530 |
const nsAString& aName, |
| 1531 |
RemoveElementReason aRemoveReason) |
1531 |
RemoveElementReason aRemoveReason) |
| 1532 |
{ |
1532 |
{ |
| 1533 |
// If the element is being removed from the form, we have to remove it from |
1533 |
// If the element is being removed from the form, we have to remove it from |
| 1534 |
// the past names map. |
1534 |
// the past names map. |
| 1535 |
if (aRemoveReason == ElementRemoved) { |
1535 |
if (aRemoveReason == ElementRemoved) { |
| 1536 |
uint32_t count = mPastNameLookupTable.Count(); |
1536 |
uint32_t oldCount = mPastNameLookupTable.Count(); |
| 1537 |
mPastNameLookupTable.Enumerate(RemovePastNames, aElement); |
1537 |
mPastNameLookupTable.Enumerate(RemovePastNames, aElement); |
| 1538 |
mExpandoAndGeneration.generation += count - mPastNameLookupTable.Count(); |
1538 |
if (oldCount != mPastNameLookupTable.Count()) { |
|
|
1539 |
++mExpandoAndGeneration.generation; |
| 1540 |
} |
| 1539 |
} |
1541 |
} |
| 1540 |
|
1542 |
|
| 1541 |
return mControls->RemoveElementFromTable(aElement, aName); |
1543 |
return mControls->RemoveElementFromTable(aElement, aName); |
| 1542 |
} |
1544 |
} |
| 1543 |
|
1545 |
|
| 1544 |
already_AddRefed<Element> |
1546 |
already_AddRefed<nsISupports> |
| 1545 |
HTMLFormElement::NamedGetter(const nsAString& aName, bool &aFound) |
1547 |
HTMLFormElement::NamedGetter(const nsAString& aName, bool &aFound) |
| 1546 |
{ |
1548 |
{ |
| 1547 |
aFound = true; |
1549 |
aFound = true; |
| 1548 |
|
1550 |
|
| 1549 |
nsCOMPtr<nsISupports> result = DoResolveName(aName, true); |
1551 |
nsCOMPtr<nsISupports> result = DoResolveName(aName, true); |
| 1550 |
nsRefPtr<Element> element = static_cast<Element*>(result.get()); |
1552 |
if (result) { |
| 1551 |
if (result && element) { |
|
|
| 1552 |
AddToPastNamesMap(aName, result); |
1553 |
AddToPastNamesMap(aName, result); |
| 1553 |
return element.forget(); |
1554 |
return result.forget(); |
| 1554 |
} |
1555 |
} |
| 1555 |
|
1556 |
|
| 1556 |
result = mImageNameLookupTable.GetWeak(aName); |
1557 |
result = mImageNameLookupTable.GetWeak(aName); |
| 1557 |
element = static_cast<Element*>(result.get()); |
1558 |
if (result) { |
| 1558 |
if (result && element) { |
|
|
| 1559 |
AddToPastNamesMap(aName, result); |
1559 |
AddToPastNamesMap(aName, result); |
| 1560 |
return element.forget(); |
1560 |
return result.forget(); |
| 1561 |
} |
1561 |
} |
| 1562 |
|
1562 |
|
| 1563 |
result = mPastNameLookupTable.GetWeak(aName); |
1563 |
result = mPastNameLookupTable.GetWeak(aName); |
| 1564 |
element = static_cast<Element*>(result.get()); |
1564 |
if (result) { |
| 1565 |
if (element) { |
1565 |
return result.forget(); |
| 1566 |
return element.forget(); |
|
|
| 1567 |
} |
1566 |
} |
| 1568 |
|
1567 |
|
| 1569 |
aFound = false; |
1568 |
aFound = false; |
| 1570 |
return nullptr; |
1569 |
return nullptr; |
| 1571 |
} |
1570 |
} |
| 1572 |
|
1571 |
|
| 1573 |
void |
1572 |
void |
| 1574 |
HTMLFormElement::GetSupportedNames(nsTArray<nsString >& aRetval) |
1573 |
HTMLFormElement::GetSupportedNames(nsTArray<nsString >& aRetval) |
| 1575 |
{ |
1574 |
{ |
| 1576 |
mControls->GetSupportedNames(aRetval); |
1575 |
mControls->GetSupportedNames(aRetval); |
| 1577 |
} |
1576 |
} |
| 1578 |
|
1577 |
|
| 1579 |
already_AddRefed<nsISupports> |
1578 |
already_AddRefed<nsISupports> |
| 1580 |
HTMLFormElement::FindNamedItem(const nsAString& aName, |
1579 |
HTMLFormElement::FindNamedItem(const nsAString& aName, |
| 1581 |
nsWrapperCache** aCache) |
1580 |
nsWrapperCache** aCache) |
| 1582 |
{ |
1581 |
{ |
| 1583 |
nsCOMPtr<nsISupports> result = DoResolveName(aName, true); |
1582 |
// FIXME Get the wrapper cache from DoResolveName. |
| 1584 |
if (result) { |
1583 |
|
| 1585 |
// FIXME Get the wrapper cache from DoResolveName. |
1584 |
bool found; |
| 1586 |
*aCache = nullptr; |
1585 |
nsCOMPtr<nsISupports> result = NamedGetter(aName, found); |
| 1587 |
AddToPastNamesMap(aName, result); |
|
|
| 1588 |
return result.forget(); |
| 1589 |
} |
| 1590 |
|
| 1591 |
result = mImageNameLookupTable.GetWeak(aName); |
| 1592 |
if (result) { |
| 1593 |
*aCache = nullptr; |
| 1594 |
AddToPastNamesMap(aName, result); |
| 1595 |
return result.forget(); |
| 1596 |
} |
| 1597 |
|
| 1598 |
result = mPastNameLookupTable.GetWeak(aName); |
| 1599 |
if (result) { |
1586 |
if (result) { |
| 1600 |
*aCache = nullptr; |
1587 |
*aCache = nullptr; |
| 1601 |
return result.forget(); |
1588 |
return result.forget(); |
| 1602 |
} |
1589 |
} |
| 1603 |
|
1590 |
|
| 1604 |
return nullptr; |
1591 |
return nullptr; |
| 1605 |
} |
1592 |
} |
| 1606 |
|
1593 |
|