| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
| 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 return; | 805 return; |
| 806 } | 806 } |
| 807 | 807 |
| 808 // Second call may return different results from the first call, | 808 // Second call may return different results from the first call, |
| 809 // but if the first the size cannot be zero. | 809 // but if the first the size cannot be zero. |
| 810 WillBeHeapVector<RefPtrWillBeMember<Element>> elements; | 810 WillBeHeapVector<RefPtrWillBeMember<Element>> elements; |
| 811 getNamedElements(name, elements); | 811 getNamedElements(name, elements); |
| 812 ASSERT(!elements.isEmpty()); | 812 ASSERT(!elements.isEmpty()); |
| 813 | 813 |
| 814 bool onlyMatchImg = !elements.isEmpty() && isHTMLImageElement(*elements.firs
t()); | 814 bool onlyMatchImg = !elements.isEmpty() && isHTMLImageElement(*elements.firs
t()); |
| 815 if (onlyMatchImg) | 815 if (onlyMatchImg) { |
| 816 UseCounter::count(document(), UseCounter::FormNameAccessForImageElement)
; | 816 UseCounter::count(document(), UseCounter::FormNameAccessForImageElement)
; |
| 817 // The following code has performance impact, but it should be small |
| 818 // because <img> access via <form> name getter is rarely used. |
| 819 for (auto& element : elements) { |
| 820 if (isHTMLImageElement(*element) && !element->isDescendantOf(this))
{ |
| 821 UseCounter::count(document(), UseCounter::FormNameAccessForNonDe
scendantImageElement); |
| 822 break; |
| 823 } |
| 824 } |
| 825 } |
| 817 if (elements.size() == 1) { | 826 if (elements.size() == 1) { |
| 818 returnValue.setElement(elements.at(0)); | 827 returnValue.setElement(elements.at(0)); |
| 819 return; | 828 return; |
| 820 } | 829 } |
| 821 | 830 |
| 822 returnValue.setRadioNodeList(radioNodeList(name, onlyMatchImg)); | 831 returnValue.setRadioNodeList(radioNodeList(name, onlyMatchImg)); |
| 823 } | 832 } |
| 824 | 833 |
| 825 void HTMLFormElement::setDemoted(bool demoted) | 834 void HTMLFormElement::setDemoted(bool demoted) |
| 826 { | 835 { |
| 827 if (demoted) | 836 if (demoted) |
| 828 UseCounter::count(document(), UseCounter::DemotedFormElement); | 837 UseCounter::count(document(), UseCounter::DemotedFormElement); |
| 829 m_wasDemoted = demoted; | 838 m_wasDemoted = demoted; |
| 830 } | 839 } |
| 831 | 840 |
| 832 } // namespace | 841 } // namespace |
| OLD | NEW |