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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 { | 252 { |
253 if (HTMLDataListElement* dataList = ownerDataListElement()) | 253 if (HTMLDataListElement* dataList = ownerDataListElement()) |
254 dataList->optionElementChildrenChanged(); | 254 dataList->optionElementChildrenChanged(); |
255 else if (HTMLSelectElement* select = ownerSelectElement()) | 255 else if (HTMLSelectElement* select = ownerSelectElement()) |
256 select->optionElementChildrenChanged(); | 256 select->optionElementChildrenChanged(); |
257 HTMLElement::childrenChanged(changedByParser, beforeChange, afterChange, chi
ldCountDelta); | 257 HTMLElement::childrenChanged(changedByParser, beforeChange, afterChange, chi
ldCountDelta); |
258 } | 258 } |
259 | 259 |
260 HTMLDataListElement* HTMLOptionElement::ownerDataListElement() const | 260 HTMLDataListElement* HTMLOptionElement::ownerDataListElement() const |
261 { | 261 { |
262 for (ContainerNode* parent = parentNode(); parent ; parent = parent->parentN
ode()) { | 262 return Traversal<HTMLDataListElement>::firstAncestor(*this); |
263 if (isHTMLDataListElement(*parent)) | |
264 return toHTMLDataListElement(parent); | |
265 } | |
266 return 0; | |
267 } | 263 } |
268 | 264 |
269 HTMLSelectElement* HTMLOptionElement::ownerSelectElement() const | 265 HTMLSelectElement* HTMLOptionElement::ownerSelectElement() const |
270 { | 266 { |
271 ContainerNode* select = parentNode(); | 267 return Traversal<HTMLSelectElement>::firstAncestor(*this); |
272 while (select && !isHTMLSelectElement(*select)) | |
273 select = select->parentNode(); | |
274 | |
275 if (!select) | |
276 return 0; | |
277 | |
278 return toHTMLSelectElement(select); | |
279 } | 268 } |
280 | 269 |
281 String HTMLOptionElement::label() const | 270 String HTMLOptionElement::label() const |
282 { | 271 { |
283 const AtomicString& label = fastGetAttribute(labelAttr); | 272 const AtomicString& label = fastGetAttribute(labelAttr); |
284 if (!label.isNull()) | 273 if (!label.isNull()) |
285 return label; | 274 return label; |
286 return collectOptionInnerText().stripWhiteSpace(isHTMLSpace<UChar>).simplify
WhiteSpace(isHTMLSpace<UChar>); | 275 return collectOptionInnerText().stripWhiteSpace(isHTMLSpace<UChar>).simplify
WhiteSpace(isHTMLSpace<UChar>); |
287 } | 276 } |
288 | 277 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 | 358 |
370 HTMLFormElement* HTMLOptionElement::form() const | 359 HTMLFormElement* HTMLOptionElement::form() const |
371 { | 360 { |
372 if (HTMLSelectElement* selectElement = ownerSelectElement()) | 361 if (HTMLSelectElement* selectElement = ownerSelectElement()) |
373 return selectElement->formOwner(); | 362 return selectElement->formOwner(); |
374 | 363 |
375 return 0; | 364 return 0; |
376 } | 365 } |
377 | 366 |
378 } // namespace WebCore | 367 } // namespace WebCore |
OLD | NEW |