| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 158 |
| 159 HTMLSelectElement* selectElement = ownerSelectElement(); | 159 HTMLSelectElement* selectElement = ownerSelectElement(); |
| 160 if (!selectElement) | 160 if (!selectElement) |
| 161 return 0; | 161 return 0; |
| 162 | 162 |
| 163 int optionIndex = 0; | 163 int optionIndex = 0; |
| 164 | 164 |
| 165 const Vector<HTMLElement*>& items = selectElement->listItems(); | 165 const Vector<HTMLElement*>& items = selectElement->listItems(); |
| 166 size_t length = items.size(); | 166 size_t length = items.size(); |
| 167 for (size_t i = 0; i < length; ++i) { | 167 for (size_t i = 0; i < length; ++i) { |
| 168 if (!items[i]->hasTagName(optionTag)) | 168 if (!isHTMLOptionElement(*items[i])) |
| 169 continue; | 169 continue; |
| 170 if (items[i] == this) | 170 if (items[i] == this) |
| 171 return optionIndex; | 171 return optionIndex; |
| 172 ++optionIndex; | 172 ++optionIndex; |
| 173 } | 173 } |
| 174 | 174 |
| 175 return 0; | 175 return 0; |
| 176 } | 176 } |
| 177 | 177 |
| 178 void HTMLOptionElement::parseAttribute(const QualifiedName& name, const AtomicSt
ring& value) | 178 void HTMLOptionElement::parseAttribute(const QualifiedName& name, const AtomicSt
ring& value) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 for (ContainerNode* parent = parentNode(); parent ; parent = parent->parentN
ode()) { |
| 263 if (parent->hasTagName(datalistTag)) | 263 if (isHTMLDataListElement(*parent)) |
| 264 return toHTMLDataListElement(parent); | 264 return toHTMLDataListElement(parent); |
| 265 } | 265 } |
| 266 return 0; | 266 return 0; |
| 267 } | 267 } |
| 268 | 268 |
| 269 HTMLSelectElement* HTMLOptionElement::ownerSelectElement() const | 269 HTMLSelectElement* HTMLOptionElement::ownerSelectElement() const |
| 270 { | 270 { |
| 271 ContainerNode* select = parentNode(); | 271 ContainerNode* select = parentNode(); |
| 272 while (select && !select->hasTagName(selectTag)) | 272 while (select && !isHTMLSelectElement(*select)) |
| 273 select = select->parentNode(); | 273 select = select->parentNode(); |
| 274 | 274 |
| 275 if (!select) | 275 if (!select) |
| 276 return 0; | 276 return 0; |
| 277 | 277 |
| 278 return toHTMLSelectElement(select); | 278 return toHTMLSelectElement(select); |
| 279 } | 279 } |
| 280 | 280 |
| 281 String HTMLOptionElement::label() const | 281 String HTMLOptionElement::label() const |
| 282 { | 282 { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 // FIXME: We ask our owner select to repaint regardless of which property ch
anged. | 315 // FIXME: We ask our owner select to repaint regardless of which property ch
anged. |
| 316 if (HTMLSelectElement* select = ownerSelectElement()) { | 316 if (HTMLSelectElement* select = ownerSelectElement()) { |
| 317 if (RenderObject* renderer = select->renderer()) | 317 if (RenderObject* renderer = select->renderer()) |
| 318 renderer->repaint(); | 318 renderer->repaint(); |
| 319 } | 319 } |
| 320 } | 320 } |
| 321 | 321 |
| 322 String HTMLOptionElement::textIndentedToRespectGroupLabel() const | 322 String HTMLOptionElement::textIndentedToRespectGroupLabel() const |
| 323 { | 323 { |
| 324 ContainerNode* parent = parentNode(); | 324 ContainerNode* parent = parentNode(); |
| 325 if (parent && parent->hasTagName(optgroupTag)) | 325 if (parent && isHTMLOptGroupElement(*parent)) |
| 326 return " " + text(); | 326 return " " + text(); |
| 327 return text(); | 327 return text(); |
| 328 } | 328 } |
| 329 | 329 |
| 330 bool HTMLOptionElement::isDisabledFormControl() const | 330 bool HTMLOptionElement::isDisabledFormControl() const |
| 331 { | 331 { |
| 332 if (ownElementDisabled()) | 332 if (ownElementDisabled()) |
| 333 return true; | 333 return true; |
| 334 if (Element* parent = parentElement()) | 334 if (Element* parent = parentElement()) |
| 335 return parent->hasTagName(optgroupTag) && parent->isDisabledFormControl(
); | 335 return isHTMLOptGroupElement(*parent) && parent->isDisabledFormControl()
; |
| 336 return false; | 336 return false; |
| 337 } | 337 } |
| 338 | 338 |
| 339 Node::InsertionNotificationRequest HTMLOptionElement::insertedInto(ContainerNode
* insertionPoint) | 339 Node::InsertionNotificationRequest HTMLOptionElement::insertedInto(ContainerNode
* insertionPoint) |
| 340 { | 340 { |
| 341 if (HTMLSelectElement* select = ownerSelectElement()) { | 341 if (HTMLSelectElement* select = ownerSelectElement()) { |
| 342 select->setRecalcListItems(); | 342 select->setRecalcListItems(); |
| 343 // Do not call selected() since calling updateListItemSelectedStates() | 343 // Do not call selected() since calling updateListItemSelectedStates() |
| 344 // at this time won't do the right thing. (Why, exactly?) | 344 // at this time won't do the right thing. (Why, exactly?) |
| 345 // FIXME: Might be better to call this unconditionally, always passing m
_isSelected, | 345 // FIXME: Might be better to call this unconditionally, always passing m
_isSelected, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 369 | 369 |
| 370 HTMLFormElement* HTMLOptionElement::form() const | 370 HTMLFormElement* HTMLOptionElement::form() const |
| 371 { | 371 { |
| 372 if (HTMLSelectElement* selectElement = ownerSelectElement()) | 372 if (HTMLSelectElement* selectElement = ownerSelectElement()) |
| 373 return selectElement->formOwner(); | 373 return selectElement->formOwner(); |
| 374 | 374 |
| 375 return 0; | 375 return 0; |
| 376 } | 376 } |
| 377 | 377 |
| 378 } // namespace WebCore | 378 } // namespace WebCore |
| OLD | NEW |