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 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 5 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
6 * Copyright (C) 2004, 2005, 2006, 2010 Apple Inc. All rights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2010 Apple Inc. All rights reserved. |
7 * Copyright (C) 2010 Google Inc. All rights reserved. | 7 * Copyright (C) 2010 Google Inc. All rights reserved. |
8 * Copyright (C) 2011 Motorola Mobility, Inc. All rights reserved. | 8 * Copyright (C) 2011 Motorola Mobility, Inc. All rights reserved. |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 176 |
177 int HTMLOptionElement::index() const | 177 int HTMLOptionElement::index() const |
178 { | 178 { |
179 // It would be faster to cache the index, but harder to get it right in all
cases. | 179 // It would be faster to cache the index, but harder to get it right in all
cases. |
180 | 180 |
181 HTMLSelectElement* selectElement = ownerSelectElement(); | 181 HTMLSelectElement* selectElement = ownerSelectElement(); |
182 if (!selectElement) | 182 if (!selectElement) |
183 return 0; | 183 return 0; |
184 | 184 |
185 int optionIndex = 0; | 185 int optionIndex = 0; |
186 | 186 for (const auto& option : selectElement->optionList()) { |
187 const HeapVector<Member<HTMLElement>>& items = selectElement->listItems(); | 187 if (option == this) |
188 size_t length = items.size(); | |
189 for (size_t i = 0; i < length; ++i) { | |
190 if (!isHTMLOptionElement(*items[i])) | |
191 continue; | |
192 if (items[i].get() == this) | |
193 return optionIndex; | 188 return optionIndex; |
194 ++optionIndex; | 189 ++optionIndex; |
195 } | 190 } |
196 | 191 |
197 return 0; | 192 return 0; |
198 } | 193 } |
199 | 194 |
200 int HTMLOptionElement::listIndex() const | 195 int HTMLOptionElement::listIndex() const |
201 { | 196 { |
202 if (HTMLSelectElement* selectElement = ownerSelectElement()) | 197 if (HTMLSelectElement* selectElement = ownerSelectElement()) |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 ASSERT(parent); | 467 ASSERT(parent); |
473 if (isHTMLOptGroupElement(*parent)) { | 468 if (isHTMLOptGroupElement(*parent)) { |
474 const ComputedStyle* parentStyle = parent->computedStyle() ? parent-
>computedStyle() : parent->ensureComputedStyle(); | 469 const ComputedStyle* parentStyle = parent->computedStyle() ? parent-
>computedStyle() : parent->ensureComputedStyle(); |
475 return !parentStyle || parentStyle->display() == NONE; | 470 return !parentStyle || parentStyle->display() == NONE; |
476 } | 471 } |
477 } | 472 } |
478 return m_style->display() == NONE; | 473 return m_style->display() == NONE; |
479 } | 474 } |
480 | 475 |
481 } // namespace blink | 476 } // namespace blink |
OLD | NEW |