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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 PassRefPtr<HTMLOptionElement> HTMLOptionElement::create(const QualifiedName& tag
Name, Document& document) | 64 PassRefPtr<HTMLOptionElement> HTMLOptionElement::create(const QualifiedName& tag
Name, Document& document) |
65 { | 65 { |
66 return adoptRef(new HTMLOptionElement(tagName, document)); | 66 return adoptRef(new HTMLOptionElement(tagName, document)); |
67 } | 67 } |
68 | 68 |
69 PassRefPtr<HTMLOptionElement> HTMLOptionElement::createForJSConstructor(Document
& document, const String& data, const String& value, | 69 PassRefPtr<HTMLOptionElement> HTMLOptionElement::createForJSConstructor(Document
& document, const String& data, const String& value, |
70 bool defaultSelected, bool selected, ExceptionState& es) | 70 bool defaultSelected, bool selected, ExceptionState& es) |
71 { | 71 { |
72 RefPtr<HTMLOptionElement> element = adoptRef(new HTMLOptionElement(optionTag
, document)); | 72 RefPtr<HTMLOptionElement> element = adoptRef(new HTMLOptionElement(optionTag
, document)); |
73 | 73 |
74 RefPtr<Text> text = Text::create(&document, data.isNull() ? "" : data); | 74 RefPtr<Text> text = Text::create(document, data.isNull() ? "" : data); |
75 | 75 |
76 element->appendChild(text.release(), es); | 76 element->appendChild(text.release(), es); |
77 if (es.hadException()) | 77 if (es.hadException()) |
78 return 0; | 78 return 0; |
79 | 79 |
80 if (!value.isNull()) | 80 if (!value.isNull()) |
81 element->setValue(value); | 81 element->setValue(value); |
82 if (defaultSelected) | 82 if (defaultSelected) |
83 element->setAttribute(selectedAttr, emptyAtom); | 83 element->setAttribute(selectedAttr, emptyAtom); |
84 element->setSelected(selected); | 84 element->setSelected(selected); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 RefPtr<HTMLSelectElement> select = ownerSelectElement(); | 138 RefPtr<HTMLSelectElement> select = ownerSelectElement(); |
139 bool selectIsMenuList = select && select->usesMenuList(); | 139 bool selectIsMenuList = select && select->usesMenuList(); |
140 int oldSelectedIndex = selectIsMenuList ? select->selectedIndex() : -1; | 140 int oldSelectedIndex = selectIsMenuList ? select->selectedIndex() : -1; |
141 | 141 |
142 // Handle the common special case where there's exactly 1 child node, and it
's a text node. | 142 // Handle the common special case where there's exactly 1 child node, and it
's a text node. |
143 Node* child = firstChild(); | 143 Node* child = firstChild(); |
144 if (child && child->isTextNode() && !child->nextSibling()) | 144 if (child && child->isTextNode() && !child->nextSibling()) |
145 toText(child)->setData(text); | 145 toText(child)->setData(text); |
146 else { | 146 else { |
147 removeChildren(); | 147 removeChildren(); |
148 appendChild(Text::create(&document(), text), es); | 148 appendChild(Text::create(document(), text), es); |
149 } | 149 } |
150 | 150 |
151 if (selectIsMenuList && select->selectedIndex() != oldSelectedIndex) | 151 if (selectIsMenuList && select->selectedIndex() != oldSelectedIndex) |
152 select->setSelectedIndex(oldSelectedIndex); | 152 select->setSelectedIndex(oldSelectedIndex); |
153 } | 153 } |
154 | 154 |
155 void HTMLOptionElement::accessKeyAction(bool) | 155 void HTMLOptionElement::accessKeyAction(bool) |
156 { | 156 { |
157 HTMLSelectElement* select = ownerSelectElement(); | 157 HTMLSelectElement* select = ownerSelectElement(); |
158 if (select) | 158 if (select) |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 // Text nodes inside script elements are not part of the option text. | 368 // Text nodes inside script elements are not part of the option text. |
369 if (node->isElementNode() && toScriptLoaderIfPossible(toElement(node))) | 369 if (node->isElementNode() && toScriptLoaderIfPossible(toElement(node))) |
370 node = NodeTraversal::nextSkippingChildren(node, this); | 370 node = NodeTraversal::nextSkippingChildren(node, this); |
371 else | 371 else |
372 node = NodeTraversal::next(node, this); | 372 node = NodeTraversal::next(node, this); |
373 } | 373 } |
374 return text.toString(); | 374 return text.toString(); |
375 } | 375 } |
376 | 376 |
377 } // namespace WebCore | 377 } // namespace WebCore |
OLD | NEW |