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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 if (text.isEmpty()) | 130 if (text.isEmpty()) |
131 text = collectOptionInnerText(); | 131 text = collectOptionInnerText(); |
132 | 132 |
133 // FIXME: Is displayStringModifiedByEncoding helpful here? | 133 // FIXME: Is displayStringModifiedByEncoding helpful here? |
134 // If it's correct here, then isn't it needed in the value and label functio
ns too? | 134 // If it's correct here, then isn't it needed in the value and label functio
ns too? |
135 return document->displayStringModifiedByEncoding(text).stripWhiteSpace(isHTM
LSpace).simplifyWhiteSpace(isHTMLSpace); | 135 return document->displayStringModifiedByEncoding(text).stripWhiteSpace(isHTM
LSpace).simplifyWhiteSpace(isHTMLSpace); |
136 } | 136 } |
137 | 137 |
138 void HTMLOptionElement::setText(const String &text, ExceptionCode& ec) | 138 void HTMLOptionElement::setText(const String &text, ExceptionCode& ec) |
139 { | 139 { |
| 140 RefPtr<Node> protectFromMutationEvents(this); |
| 141 |
140 // Changing the text causes a recalc of a select's items, which will reset t
he selected | 142 // Changing the text causes a recalc of a select's items, which will reset t
he selected |
141 // index to the first item if the select is single selection with a menu lis
t. We attempt to | 143 // index to the first item if the select is single selection with a menu lis
t. We attempt to |
142 // preserve the selected item. | 144 // preserve the selected item. |
143 HTMLSelectElement* select = ownerSelectElement(); | 145 RefPtr<HTMLSelectElement> select = ownerSelectElement(); |
144 bool selectIsMenuList = select && select->usesMenuList(); | 146 bool selectIsMenuList = select && select->usesMenuList(); |
145 int oldSelectedIndex = selectIsMenuList ? select->selectedIndex() : -1; | 147 int oldSelectedIndex = selectIsMenuList ? select->selectedIndex() : -1; |
146 | 148 |
147 // Handle the common special case where there's exactly 1 child node, and it
's a text node. | 149 // Handle the common special case where there's exactly 1 child node, and it
's a text node. |
148 Node* child = firstChild(); | 150 Node* child = firstChild(); |
149 if (child && child->isTextNode() && !child->nextSibling()) | 151 if (child && child->isTextNode() && !child->nextSibling()) |
150 static_cast<Text *>(child)->setData(text, ec); | 152 static_cast<Text *>(child)->setData(text, ec); |
151 else { | 153 else { |
152 removeChildren(); | 154 removeChildren(); |
153 appendChild(Text::create(document(), text), ec); | 155 appendChild(Text::create(document(), text), ec); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 | 343 |
342 const HTMLOptionElement* toHTMLOptionElement(const Node* node) | 344 const HTMLOptionElement* toHTMLOptionElement(const Node* node) |
343 { | 345 { |
344 ASSERT(!node || node->hasTagName(optionTag)); | 346 ASSERT(!node || node->hasTagName(optionTag)); |
345 return static_cast<const HTMLOptionElement*>(node); | 347 return static_cast<const HTMLOptionElement*>(node); |
346 } | 348 } |
347 | 349 |
348 #endif | 350 #endif |
349 | 351 |
350 } // namespace | 352 } // namespace |
OLD | NEW |